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

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

?? i2c-s3c2410.c

?? linux下S3C2410的I2C總線的驅動
?? 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>#include <asm/hardware.h>#undef KERN_DEBUG#define KERN_DEBUG#ifdef MODULE_LICENSEMODULE_LICENSE("GPL");#endif//extern int s3c2410_i2c_debug;static int s3c2410_i2c_debug=2;#if (LINUX_VERSION_CODE < 0x020301)static struct wait_queue *iic_wait = NULL;#elsestatic wait_queue_head_t iic_wait;#endifstatic 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 				*/#if 0//for iic slave receive data. add by threewater#define MAX_IICREV_BUF		1024#define MAX_IICREV_FRAME	64typedef struct {	unsigned short revbuf[MAX_IICREV_BUF];	//receive buffer	unsigned int head, tail;		//frame head and tail	wait_queue_head_t wq;	spinlock_t lock;	int inSlvRev;		// 1 for begin to slave receive data}IIC_SlvRev;static IIC_SlvRev iicSlvRev;#define INCBUF(x) 	((++(x)) & ((MAX_IICREV_BUF) - 1))#define REV_HEAD	(iicSlvRev.revbuf[iicSlvRev.head])#define REV_TAIL		(iicSlvRev.revbuf[iicSlvRev.tail])#define SlvRev_init()	do{iicSlvRev.head=iicSlvRev.tail=0;  \	init_waitqueue_head(&iicSlvRev.wq);}while(0)#define IICFRM_BEGIN		0x100#endif/* ----- 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 the clock rate//static int iic_s3c2410_getclock(void *data){	return (-EINVAL);}#if 0static 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");}//for iic slave receive data. add by threewater//read a iic frame#if 0static int slvRev_Read(unsigned short* pbuffer, int maxcount){	int revnum;	int num;	spin_lock_irq(&(iicSlvRev.lock));	num=revnum=iicSlvRev.head-iicSlvRev.tail;	if(revnum<0)		revnum+=MAX_IICREV_BUF;	while(revnum<maxcount){		interruptible_sleep_on(&(iicSlvRev.wq));		num=revnum=iicSlvRev.head-iicSlvRev.tail;		if(revnum<0)			revnum+=MAX_IICREV_BUF;	}	if(num<0){	//cycle buffer		int endnum=MAX_IICREV_BUF-iicSlvRev.tail;		if(endnum>=maxcount){			//maxcount less than from REV_TAIL to receive BUFFER end			num=maxcount;			memcpy(pbuffer, &(REV_TAIL), num*sizeof(*pbuffer));			iicSlvRev.tail+=num;		}else{			//read cycle buffer			memcpy(pbuffer, &(REV_TAIL), endnum*sizeof(*pbuffer));			pbuffer+=endnum;			memcpy(pbuffer, iicSlvRev.revbuf, (maxcount-endnum)*sizeof(*pbuffer));			num=maxcount;			iicSlvRev.tail=maxcount-endnum;		}			}else{		num=maxcount;		memcpy(pbuffer, &(REV_TAIL), num*sizeof(*pbuffer));		iicSlvRev.tail+=num;	}	spin_unlock_irq(&(iicSlvRev.lock));	return num*sizeof(*pbuffer);}/*static int iic_s3c2410_slaveRev(char *buf, int maxcount){	int i, revcnt;retry: 	if (iicSlvRev.head != iicSlvRev.tail) {		revcnt=slvRev_Frame_Read(buf, maxcount);	} else {		interruptible_sleep_on(&(iicSlvRev.wq));		goto retry;	}	return revcnt;}*/#endifstatic inline void iic_s3c2410_clearPending(void){	u8 ret;	// Clear interrupt pending bit	ret = readb(S3C2410_IICCON);	ret &= ~S3C2410_IICCON_INT_PEND;	writeb(ret, S3C2410_IICCON);	iic_pending = 0;}//// Description: The registered interrupt handler//static void iic_s3c2410_handler(int irq, void *dev_id, struct pt_regs *regs) {	u8 ret;	u8 mode;	u8 data;	extern struct i2c_adapter iic_s3c2410_ops;	int i;	static int framebegin=0;	iic_pending = 1;	DEB3(printk("iic_s3c2410_handler: in interrupt handler\n"));	// Read status register	ret = readb(S3C2410_IICSTAT);	DEB3(printk("iic_s3c2410_handler: status = 0x%x\n", ret));	udelay(10);	mode = ret & S3C2410_IICSTAT_MODE_MSK;	switch (mode){		case	S3C2410_IICSTAT_STX_MODE:			/* We don't use this mode , something must be wrong. */			iic_s3c2410_clearPending();			break;		case	S3C2410_IICSTAT_SRX_MODE:			if(ret & S3C2410_IICSTAT_SLAVEADDR){				//match the own slave address. begin to slave receive data.				readb(S3C2410_IICDS);				framebegin=1;				iic_s3c2410_clearPending();				return;			}			data = readb(S3C2410_IICDS);			for (i = 0; i < iic_s3c2410_ops.client_count; i++){				if (iic_s3c2410_ops.clients[i]){					DEB3(printk ("client name:%s\n", iic_s3c2410_ops.clients[i]->name));					if(iic_s3c2410_ops.clients[i]->slvRecvNotify)						iic_s3c2410_ops.clients[i]->slvRecvNotify (&data, sizeof(data), framebegin);				}			}			framebegin=0;			iic_s3c2410_clearPending();			break;		case	S3C2410_IICSTAT_MRX_MODE:		case	S3C2410_IICSTAT_MTX_MODE:			wake_up_interruptible(&iic_wait);			break;				}}//// 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);	}}#define	MAX_CLIENTS	10static struct i2c_client *s3c2410clients[10];//// 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,	NULL,	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//	SlvRev_init();	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一区二区三区免费野_久草精品视频
欧美剧在线免费观看网站 | 亚洲蜜桃精久久久久久久| 亚洲综合色视频| 国产91精品入口| 日韩欧美在线观看一区二区三区| 国产精品对白交换视频| 美女视频黄 久久| 欧美天天综合网| 亚洲欧美在线观看| 国内精品写真在线观看| 91精品国产综合久久久久久| 亚洲精品欧美在线| 成人高清视频在线观看| 久久这里只有精品首页| 久久精品国产一区二区| 欧美日韩国产小视频在线观看| 国产精品美女久久久久高潮| 国内精品不卡在线| 精品精品国产高清一毛片一天堂| 亚洲一二三区在线观看| 91啦中文在线观看| 成人免费一区二区三区视频| 成人性生交大片免费看在线播放| 久久先锋影音av| 国产精品一级二级三级| 2020日本不卡一区二区视频| 美女www一区二区| 日韩一区二区在线观看视频播放 | 久久亚洲综合色| 老司机精品视频线观看86| 欧美丰满高潮xxxx喷水动漫 | 天天影视色香欲综合网老头| 91丝袜呻吟高潮美腿白嫩在线观看| 久久久久国产精品免费免费搜索| 国产自产视频一区二区三区| 精品99一区二区三区| 国内精品久久久久影院色| 久久综合狠狠综合久久激情| 国产美女在线观看一区| 国产欧美一区二区三区在线看蜜臀| 九色综合国产一区二区三区| 欧美精品一区二区精品网| 国产综合久久久久久鬼色| 国产区在线观看成人精品| 成人久久视频在线观看| 综合欧美亚洲日本| 欧美日韩mp4| 精品一区二区三区香蕉蜜桃 | 91精品国产一区二区三区香蕉| 午夜精品123| 精品电影一区二区三区| 成人做爰69片免费看网站| 中文字幕在线播放不卡一区| 日本黄色一区二区| 奇米影视一区二区三区| 国产日韩v精品一区二区| 99久久精品久久久久久清纯| 亚洲国产精品久久艾草纯爱 | 91精品黄色片免费大全| 国产精品亚洲午夜一区二区三区| 中文字幕在线不卡视频| 欧美视频精品在线观看| 精品一区二区成人精品| 亚洲欧美一区二区三区孕妇| 欧美日本韩国一区二区三区视频 | 欧美最猛性xxxxx直播| 日本在线不卡一区| 国产精品视频第一区| 欧美日韩精品一区二区三区四区 | 在线观看国产一区二区| 日本美女一区二区| 中文字幕在线观看一区二区| 91精品国产美女浴室洗澡无遮挡| 国产精品一区二区你懂的| 一区二区免费在线| 久久综合九色综合欧美98| 欧美性猛交xxxx乱大交退制版| 韩国毛片一区二区三区| 亚洲国产精品欧美一二99| 中文字幕免费不卡在线| 91精品国产免费| 在线亚洲高清视频| 国产高清精品网站| 日本麻豆一区二区三区视频| 亚洲精品水蜜桃| 国产欧美一区二区在线| 欧美一区二区三区视频免费播放| 99re8在线精品视频免费播放| 久久99热狠狠色一区二区| 一区二区三区在线免费视频| 国产欧美一区二区三区在线老狼| 日韩一区二区视频在线观看| 欧美色综合网站| 色婷婷av久久久久久久| www.日本不卡| 国产成人av一区二区| 国产资源在线一区| 看电影不卡的网站| 日本最新不卡在线| 亚洲一二三区在线观看| 夜夜操天天操亚洲| 伊人婷婷欧美激情| 亚洲欧美日韩精品久久久久| 国产精品家庭影院| 亚洲欧洲av一区二区三区久久| 国产亚洲欧美日韩日本| 亚洲精品一区在线观看| 欧美不卡视频一区| 日韩免费高清av| 欧美一级艳片视频免费观看| 欧美一区二区三区在线观看视频| 欧美三级日韩三级国产三级| 欧美性色aⅴ视频一区日韩精品| 色综合久久99| 91国产免费观看| 欧美这里有精品| 欧美日韩一级片在线观看| 欧美少妇一区二区| 制服丝袜激情欧洲亚洲| 日韩午夜中文字幕| 欧美精品一区二区三区在线播放| 日韩亚洲欧美成人一区| 久久综合九色综合97_久久久| 欧美精品一区二区三区蜜桃 | 成人晚上爱看视频| 99久久免费精品| 色婷婷综合久色| 欧美日韩免费观看一区二区三区 | 久久久久久久久久久久久久久99 | 色老汉av一区二区三区| 在线观看免费成人| 日韩一区二区免费在线电影| 欧美r级在线观看| 国产午夜精品一区二区三区嫩草| 国产欧美视频一区二区三区| 国产精品天美传媒| 夜夜嗨av一区二区三区中文字幕 | 久久精品人人做| 亚洲欧洲综合另类| 三级影片在线观看欧美日韩一区二区| 日韩黄色片在线观看| 国产91精品免费| 欧美日韩国产美女| 精品国产第一区二区三区观看体验| 欧美—级在线免费片| 亚洲综合男人的天堂| 国产在线精品一区在线观看麻豆| 国产成人精品一区二| 欧美大片免费久久精品三p | 亚洲国产日韩综合久久精品| 日韩精品电影在线| 日韩欧美中文一区| 国产精品青草久久| 日韩高清在线不卡| 国产黄色精品网站| 欧美三级电影精品| 中文字幕二三区不卡| 日本成人超碰在线观看| 国产成人高清视频| 91精品国产入口| 国产精品久久久久久久久搜平片| 日韩中文字幕一区二区三区| 国产99精品国产| 欧美va日韩va| 亚洲国产日韩一区二区| 成人黄色在线网站| 日韩免费电影网站| 一区二区三区久久久| 成人午夜视频网站| 精品国精品国产尤物美女| 亚洲一区二区三区中文字幕在线| 国产一区高清在线| 91麻豆精品国产综合久久久久久 | 97精品久久久久中文字幕 | 国产精品羞羞答答xxdd| 欧美丰满少妇xxxbbb| 一区二区三区中文字幕精品精品 | 欧美激情一区三区| 麻豆精品视频在线观看视频| 欧美日韩极品在线观看一区| 亚洲人成亚洲人成在线观看图片| 国产高清一区日本| 久久免费电影网| 九色porny丨国产精品| 日韩一区二区在线播放| 日韩电影在线观看网站| 69久久99精品久久久久婷婷 | 欧美在线啊v一区| 亚洲丝袜另类动漫二区| 丁香一区二区三区| 久久久精品免费观看| 国产精品白丝jk黑袜喷水| 精品精品欲导航| 国产美女娇喘av呻吟久久| 久久久国产综合精品女国产盗摄| 久久99深爱久久99精品| 久久久www成人免费无遮挡大片| 美女脱光内衣内裤视频久久网站 | 国产一区二区久久| 久久久午夜电影|