亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? i2c-s3c2410.c

?? linux和2410結合開發 用他可以生成2410所需的zImage文件
?? C
字號:
/*
   -------------------------------------------------------------------------
   i2c-s3c2410.c i2c-hw access for the IIC peripheral on the Samsung S3C2410X
   processor and SMDK2400 reference board.

   Steve Hein <ssh@sgi.com>
   Copyright 2002 SGI, Inc.

   -------------------------------------------------------------------------
   This file was highly leveraged from i2c-algo-ppc405.c:
  
   Ian DaSilva, MontaVista Software, Inc.
   idasilva@mvista.com or source@mvista.com

   Copyright 2000 MontaVista Software Inc.

   Changes made to support the IIC peripheral on the IBM PPC 405 


   ----------------------------------------------------------------------------
   This file was highly leveraged from i2c-elektor.c, which was created
   by Simon G. Vogl and Hans Berglund:

 
     Copyright (C) 1995-97 Simon G. Vogl
                   1998-99 Hans Berglund

   With some changes from Ky鰏ti M鋖kki <kmalkki@cc.hut.fi> and even
   Frodo Looijaard <frodol@dds.nl>


    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   ----------------------------------------------------------------------------
*/


#include <linux/kernel.h>
#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/version.h>
#include <linux/init.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <linux/i2c.h>
#include <linux/i2c-algo-s3c2410.h>
#include <linux/i2c-s3c2410.h>

#undef KERN_DEBUG
#define KERN_DEBUG

#ifdef MODULE_LICENSE
MODULE_LICENSE("GPL");
#endif

//extern int s3c2410_i2c_debug;
int s3c2410_i2c_debug=0;
#if (LINUX_VERSION_CODE < 0x020301)
static struct wait_queue *iic_wait = NULL;
#else
static wait_queue_head_t iic_wait;
#endif
static int iic_pending;
static int iic_irq;

/* ----- global defines -----------------------------------------------	*/
#define DEB(x)	if (s3c2410_i2c_debug>=1) x
#define DEB2(x) if (s3c2410_i2c_debug>=2) x
#define DEB3(x) if (s3c2410_i2c_debug>=3) x
#define DEBE(x)	x	/* error messages 				*/


/* ----- local functions ----------------------------------------------	*/

//
// Description: Write a byte to IIC hardware
//
static void iic_s3c2410_setbyte(void *data, int ctl, int val)
{
	DEB3(printk("iic_s3c2410_setbyte: Write IIC register 0x%08x = 0x%02x\n", (u32) ctl, (u32) val));
	// writeb resolves to a write to the specified memory location
        writeb(val, ctl);
}


//
// Description: Read a byte from IIC hardware
//
static int iic_s3c2410_getbyte(void *data, int ctl)
{
	int val;

	//DEB3(printk("iic_s3c2410_getbyte: Read IIC register 0x%08x\n", (u32) ctl));
	val = readb(ctl);
	DEB3(printk("iic_s3c2410_getbyte: Read IIC register 0x%08x = 0x%02x\n", (u32) ctl, val));
	//DEB3(printk("iic_s3c2410_getbyte: Read Data 0x%02X\n", val));
	return (val);
}


//
// Description: Return our slave address.  This is the address
// put on the I2C bus when another master on the bus wants to address us
// as a slave
//
static int iic_s3c2410_getown(void *data)
{
	return (-EINVAL);
}


//
// Description: Return the clock rate
//
static int iic_s3c2410_getclock(void *data)
{
	return (-EINVAL);
}


#if 0
static void iic_s3c2410_sleep(unsigned long timeout)
{
	schedule_timeout( timeout * HZ);
}
#endif


//
// Description:  Put this process to sleep.  We will wake up when the
// IIC controller interrupts.
//
static void iic_s3c2410_waitforpin(void) {

   //int timeout = 2;
   int timeout = HZ/4;   /* 0.25 second timeout */

   //printk("iic_s3c2410_waitforpin: At top of function\n");
   //
   // If interrupts are enabled (which they are), then put the process to
   // sleep.  This process will be awakened by two events -- either the
   // the IIC peripheral interrupts or the timeout expires. 
   //
   if (iic_irq > 0) {
      cli();
      if (iic_pending == 0) {
         //printk("iic_s3c2410_waitforpin: calling interruptible_sleep_on_timeout\n");
  	 interruptible_sleep_on_timeout(&iic_wait, timeout);
      } else
 	 iic_pending = 0;
      sti();
   } else {
      //
      // If interrupts are not enabled then delay for a reasonable amount
      // of time and return.  We expect that by time we return to the calling
      // function that the IIC has finished our requested transaction and
      // the status bit reflects this.
      //
      // udelay is probably not the best choice for this since it is
      // the equivalent of a busy wait
      //
      udelay(100);
   }
   //printk("iic_s3c2410_waitforpin: exitting\n");
}


//
// Description: The registered interrupt handler
//
static void iic_s3c2410_handler(int irq, void *dev_id, struct pt_regs *regs) 
{
   u8 ret;
	
   iic_pending = 1;
   DEB2(printk("iic_s3c2410_handler: in interrupt handler\n"));

   // Read status register
   //ret = readb(S3C2410_IICSTAT);
   //DEB2(printk("iic_s3c2410_handler: status = %x\n", ret));

   // Clear interrupt pending bit
   //ret = readb(S3C2410_IICCON);
   //DEB2(printk("iic_s3c2410_handler: ICCON=%x\n", ret));
   //ret &= ~S3C2410_IICCON_INT_PEND;
   //DEB2(printk("iic_s3c2410_handler: set ICCON=%x\n", ret));
   //writeb(ret, S3C2410_IICCON);

   wake_up_interruptible(&iic_wait);
}


//
// Description: This function is very hardware dependent.  First, we lock
// the region of memory where out registers exist.  Next, we request our
// interrupt line and register its associated handler.
//
static int iic_hw_resrc_init(void)
{
	if (request_irq(iic_irq, iic_s3c2410_handler, 0, "s3c2410 IIC", 0) < 0) {
	   printk(KERN_ERR "iic_hw_resrc_init: Request irq%d failed\n", iic_irq);
	   iic_irq = 0;
	} else {
	   DEB3(printk("iic_hw_resrc_init: Enabled interrupt (irq%d)\n", iic_irq));
	   enable_irq(iic_irq);
	}
	return 0;
}


//
// Description: Release irq and memory
//
static void iic_s3c2410_release(void)
{
	if (iic_irq > 0) {
		disable_irq(iic_irq);
		free_irq(iic_irq, 0);
	}
}


//
// Description: Does nothing
//
static int iic_s3c2410_reg(struct i2c_client *client)
{
	return 0;
}


//
// Description: Does nothing
//
static int iic_s3c2410_unreg(struct i2c_client *client)
{
	return 0;
}


//
// Description: If this compiled as a module, then increment the count
//
static void iic_s3c2410_inc_use(struct i2c_adapter *adap)
{
#ifdef MODULE
	MOD_INC_USE_COUNT;
#endif
}


//
// Description: If this is a module, then decrement the count
//
static void iic_s3c2410_dec_use(struct i2c_adapter *adap)
{
#ifdef MODULE
	MOD_DEC_USE_COUNT;
#endif
}


/* ------------------------------------------------------------------------
 * Encapsulate the above functions in the correct operations structure.
 * This is only done when more than one hardware adapter is supported.
 */
static struct i2c_algo_s3c2410_data iic_s3c2410_data = {
	NULL,
	iic_s3c2410_setbyte,
	iic_s3c2410_getbyte,
	iic_s3c2410_getown,
	iic_s3c2410_getclock,
	iic_s3c2410_waitforpin,
	80, 80, 100,		/*	waits, timeout */
};

static struct i2c_adapter iic_s3c2410_ops = {
	"Samsung S3C2410X IIC adapter",
	0,   // adapter ID, none for us in i2c-id.h, and not really needed
	NULL,
	&iic_s3c2410_data,
	iic_s3c2410_inc_use,
	iic_s3c2410_dec_use,
	iic_s3c2410_reg,
	iic_s3c2410_unreg,
};


//
// Description: Called when the module is loaded.  This function starts the
// cascade of calls up through the heirarchy of i2c modules (i.e. up to the
//  algorithm layer and into to the core layer)
//
static int __init iic_s3c2410_init(void) 
{

	printk(KERN_INFO "iic_s3c2410_init: Samsung S3C2410X iic adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);

	iic_irq = IRQ_IIC;

#if (LINUX_VERSION_CODE >= 0x020301)
	init_waitqueue_head(&iic_wait);
#endif
	if (iic_hw_resrc_init() == 0) {
		if (i2c_s3c2410_add_bus(&iic_s3c2410_ops) < 0)
			return -ENODEV;
	} else {
		return -ENODEV;
	}
	//printk(KERN_INFO "iic_s3c2410_init: initialized iic-bus at %#x.\n", PA_IIC_BASE);
	printk(KERN_INFO "iic_s3c2410_init: initialized iic-bus at %#x.\n", VA_IIC_BASE);
	return 0;
}


static void iic_s3c2410_exit(void)
{
	i2c_s3c2410_del_bus(&iic_s3c2410_ops);
        iic_s3c2410_release();
}

EXPORT_NO_SYMBOLS;

//
// If modules is NOT defined when this file is compiled, then the MODULE_*
// macros will resolve to nothing
//
MODULE_AUTHOR("Steve Hein, SGI Inc. <ssh@sgi.com>");
MODULE_DESCRIPTION("I2C-Bus adapter routines for Samsung S3C2410X IIC bus adapter");

MODULE_PARM(s3c2410_i2c_debug,"i");


//
// Description: Called when module is loaded or when kernel is intialized.
// If MODULES is defined when this file is compiled, then this function will
// resolve to init_module (the function called when insmod is invoked for a
// module).  Otherwise, this function is called early in the boot, when the
// kernel is intialized.  Check out /include/init.h to see how this works.
//
module_init(iic_s3c2410_init);



//
// Description: Resolves to module_cleanup when MODULES is defined.
//
module_exit(iic_s3c2410_exit); 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕不卡三区| 色94色欧美sute亚洲线路二| 国内精品久久久久影院薰衣草| 国产成人免费av在线| 在线区一区二视频| 国产亚洲婷婷免费| 婷婷中文字幕综合| 不卡欧美aaaaa| 精品国产不卡一区二区三区| 一区二区在线观看不卡| 国产专区综合网| 91精品国产综合久久福利| 国产精品久久久久婷婷二区次| 日韩电影网1区2区| 色综合久久久久综合体桃花网| 欧美精品一区二区三区视频| 亚洲一区二区3| av电影天堂一区二区在线| 精品国产麻豆免费人成网站| 亚洲午夜免费福利视频| 972aa.com艺术欧美| 久久嫩草精品久久久精品| 午夜婷婷国产麻豆精品| 色吧成人激情小说| 亚洲人快播电影网| av激情综合网| 中文字幕亚洲区| 成人自拍视频在线| 亚洲国产成人私人影院tom| 久国产精品韩国三级视频| 在线播放中文字幕一区| 亚洲3atv精品一区二区三区| 日本韩国精品在线| 亚洲一区二区精品久久av| 91免费版在线看| 亚洲男人的天堂一区二区| 91一区一区三区| 一区二区在线免费| 欧洲色大大久久| 亚洲国产综合在线| 欧美日本在线播放| 免费在线观看一区| 精品国产乱码久久久久久久久| 捆绑变态av一区二区三区| 欧美成人r级一区二区三区| 麻豆91在线看| 久久一区二区视频| 成人免费视频免费观看| 亚洲色图.com| 欧美伦理视频网站| 精品一区二区三区免费| 久久久久99精品国产片| 播五月开心婷婷综合| 一区二区三区蜜桃| 9191精品国产综合久久久久久| 青娱乐精品视频在线| 久久久久久久综合日本| jlzzjlzz欧美大全| 亚洲h精品动漫在线观看| 日韩亚洲欧美在线观看| 国产91精品一区二区麻豆网站| 亚洲欧美在线另类| 欧美伦理影视网| 国产激情一区二区三区四区| 中文字幕亚洲电影| 91超碰这里只有精品国产| 国产老女人精品毛片久久| 中文字幕二三区不卡| 欧美午夜精品电影| 韩国av一区二区三区| 亚洲激情av在线| 日韩免费一区二区| 95精品视频在线| 麻豆一区二区三| 亚洲人成网站在线| 精品国产成人系列| 在线视频一区二区免费| 国内国产精品久久| 亚洲国产aⅴ天堂久久| 国产亚洲欧美激情| 欧美日本在线观看| 一本一道久久a久久精品综合蜜臀| 肉丝袜脚交视频一区二区| 中文成人av在线| 日韩一区二区三区免费看| 91在线码无精品| 国产在线播放一区三区四| 亚洲国产精品自拍| 国产精品毛片久久久久久| 制服.丝袜.亚洲.中文.综合| jlzzjlzz国产精品久久| 久久精品久久综合| 一区二区三区精品久久久| 久久九九全国免费| 日韩午夜激情电影| 一本大道av伊人久久综合| 国产乱码精品一品二品| 日本中文字幕不卡| 亚洲永久免费av| 自拍偷拍国产精品| 国产欧美一区二区精品性色 | 久草中文综合在线| 亚洲国产精品久久久男人的天堂| 欧美国产欧美综合| 久久理论电影网| 欧美成人三级在线| 91精品午夜视频| 欧美日韩三级一区二区| 色综合久久久久网| 色综合激情久久| 91视频xxxx| 色素色在线综合| 91婷婷韩国欧美一区二区| 成人精品国产一区二区4080| 国模冰冰炮一区二区| 麻豆精品久久久| 男人操女人的视频在线观看欧美| 日韩国产一区二| 蜜桃视频一区二区三区| 日韩高清不卡在线| 免费久久精品视频| 久久99国产精品免费网站| 免费国产亚洲视频| 久久99国产精品成人| 韩国v欧美v亚洲v日本v| 国产一区二区三区观看| 国产高清成人在线| 成人夜色视频网站在线观看| 成人一级片网址| 一本久久综合亚洲鲁鲁五月天 | 欧美在线综合视频| 91精品福利在线| 欧美日韩国产在线观看| 制服丝袜国产精品| 久久久综合网站| 国产精品免费视频一区| 亚洲精品高清在线| 国产成人夜色高潮福利影视| 丁香啪啪综合成人亚洲小说| www.亚洲色图.com| 精品视频在线免费观看| 制服丝袜激情欧洲亚洲| 久久久国产午夜精品| 亚洲国产高清不卡| 亚洲制服丝袜av| 蜜桃av一区二区三区电影| 国产精品77777| 91碰在线视频| 欧美一区二区高清| 亚洲国产精品传媒在线观看| 一区二区三区在线高清| 青青草视频一区| gogo大胆日本视频一区| 欧美日韩一本到| 久久久久国产精品人| 亚洲一区在线观看免费观看电影高清| 天天综合天天综合色| 国产最新精品精品你懂的| 91色在线porny| 日韩一区二区在线观看| 国产精品福利一区二区三区| 视频一区视频二区在线观看| 国产又粗又猛又爽又黄91精品| 91久久人澡人人添人人爽欧美| 日韩欧美国产精品| 亚洲欧美综合色| 久久精品国产99国产| 99视频一区二区| 日韩精品专区在线影院观看| 国产精品亲子乱子伦xxxx裸| 日韩综合小视频| 色综合欧美在线| 久久一区二区视频| 石原莉奈在线亚洲三区| 成人av影院在线| 欧美成人video| 亚洲午夜激情网页| 99九九99九九九视频精品| 日韩免费电影网站| 午夜亚洲福利老司机| 91麻豆高清视频| 国产精品久久久久三级| 奇米精品一区二区三区在线观看 | 91视视频在线观看入口直接观看www | 欧美在线视频日韩| 欧美天堂一区二区三区| 日韩在线一区二区| 免费成人性网站| 91在线视频播放地址| 国产午夜一区二区三区| 久久精品国内一区二区三区| 欧亚一区二区三区| 日韩一区有码在线| 国产成人亚洲精品狼色在线| 日韩美女一区二区三区四区| 午夜精品福利在线| 欧美三级蜜桃2在线观看| 夜夜嗨av一区二区三区| 91看片淫黄大片一级| 亚洲欧美日韩在线不卡|