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

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

?? i2c-adap-pxa.c

?? linux下S3C2410的I2C總線的驅動
?? C
字號:
/* *  i2c_adap_pxa.c * *  I2C adapter for the PXA I2C bus access. * *  Copyright (C) 2002 Intrinsyc Software Inc. *  *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License version 2 as *  published by the Free Software Foundation. * *  History: *    Apr 2002: Initial version [CS] *    Jun 2002: Properly seperated algo/adap [FB] */#include <linux/kernel.h>#include <linux/module.h>#include <linux/i2c.h>#include <linux/i2c-id.h>#include <linux/init.h>#include <linux/time.h>#include <linux/sched.h>#include <linux/delay.h>#include <asm/hardware.h>#include <asm/irq.h>#include <asm/arch/irqs.h>              /* for IRQ_I2C */#include "i2c-pxa.h"/* * Set this to zero to remove all the debug statements via dead code elimination. *///#define DEBUG       1#if DEBUGstatic unsigned int i2c_debug = DEBUG;#else#define i2c_debug	0#endifstatic int irq = 0;static int i2c_pending = 0;             /* interrupt pending when 1 */static volatile int bus_error = 0;static volatile int tx_finished = 0;static volatile int rx_finished = 0;static wait_queue_head_t i2c_wait;/* place a byte in the transmit register */static void i2c_pxa_write_byte(u8 value) {        IDBR = value;}/* read byte in the receive register */static u8 i2c_pxa_read_byte(void) {        return (u8) (0xff & IDBR);}static void i2c_pxa_start(void){	ICR |= ICR_START;	ICR &= ~(ICR_STOP | ICR_ALDIE | ICR_ACKNAK);	bus_error=0;            /* clear any bus_error from previous txfers */	tx_finished=0;          /* clear rx and tx interrupts from previous txfers */	rx_finished=0;}static void i2c_pxa_repeat_start(void){	ICR |= ICR_START;	ICR &= ~(ICR_STOP | ICR_ALDIE);	bus_error=0;            /* clear any bus_error from previous txfers */	tx_finished=0;          /* clear rx and tx interrupts from previous txfers */	rx_finished=0;}static void i2c_pxa_stop(void){	ICR |= ICR_STOP;	ICR &= ~(ICR_START);}static void i2c_pxa_midbyte(void){	ICR &= ~(ICR_START | ICR_STOP);}static void i2c_pxa_abort(void){	ICR |= ICR_MA;}static int i2c_pxa_wait_bus_not_busy( void){        int timeout = DEF_TIMEOUT;        while (timeout-- && (ISR & ISR_IBB)) {                udelay(100); /* wait for 100 us */        }        return (timeout<=0);}static void i2c_pxa_wait_for_ite(void){	unsigned long flags;	if (irq > 0) {		save_flags_cli(flags);		if (i2c_pending == 0) {			interruptible_sleep_on_timeout(&i2c_wait, I2C_SLEEP_TIMEOUT );		}		i2c_pending = 0;		restore_flags(flags);	} else {		udelay(100);	}}static int i2c_pxa_wait_for_int( int wait_type){        int timeout = DEF_TIMEOUT;#ifdef DEBUG	if (bus_error)		printk(KERN_INFO"i2c_pxa_wait_for_int: Bus error on enter\n");	if (rx_finished)		printk(KERN_INFO"i2c_pxa_wait_for_int: Receive interrupt on enter\n");	if (tx_finished)		printk(KERN_INFO"i2c_pxa_wait_for_int: Transmit interrupt on enter\n");#endif        if (wait_type == I2C_RECEIVE){         /* wait on receive */                while (timeout-- && !(rx_finished)){                        i2c_pxa_wait_for_ite();                }#ifdef DEBUG                if (timeout<0){                        if (tx_finished)                                printk("Error: i2c-algo-pxa.o: received a tx"                                        " interrupt while waiting on a rx in wait_for_int");                }#endif        } else {                  /* wait on transmit */                        while (timeout-- && !(tx_finished)){                        i2c_pxa_wait_for_ite();                }#ifdef DEBUG                if (timeout<0){                        if (rx_finished)                                printk("Error: i2c-algo-pxa.o: received a rx"                                        " interrupt while waiting on a tx in wait_for_int");                }#endif        }               udelay(ACK_DELAY);      /* this is needed for the bus error */        tx_finished=0;        rx_finished=0;        if (bus_error){                bus_error=0;                if( i2c_debug > 2)printk("wait_for_int: error - no ack.\n");                return BUS_ERROR;        }        if (timeout <= 0)                return(-1);        else                return(0);}static void i2c_pxa_transfer( int lastbyte, int receive, int midbyte){	if( lastbyte)	{		if( receive==I2C_RECEIVE) ICR |= ICR_ACKNAK; 		i2c_pxa_stop();	}	else if( midbyte)	{		i2c_pxa_midbyte();	}	ICR |= ICR_TB;}static void i2c_pxa_reset( void){#ifdef DEBUG	printk("Resetting I2C Controller Unit\n");	printk("Status Register  %#x\n",ISR);	printk("Control Register %#x\n",ICR);	printk("Data Buffer      %#x\n",IDBR);	printk("Bus Monitor Reg  %#x\n",IBMR);#endif        /* disable unit */	ICR &= ~ICR_IUE;        /* reset the unit */	ICR |= ICR_UR;        udelay(100);        /* disable unit */	ICR &= ~ICR_IUE;                /* set the global I2C clock on */        CKEN |= CKEN14_I2C;        /* set our slave address */	ISAR = I2C_PXA_SLAVE_ADDR;        /* set control register values */	ICR = I2C_ICR_INIT;        /* set clear interrupt bits */	ISR = I2C_ISR_INIT;        /* enable unit */	ICR |= ICR_IUE;        udelay(100);}static void i2c_pxa_handler(int this_irq, void *dev_id, struct pt_regs *regs) {        int status;        status = (ISR);        if (status & ISR_BED){                (ISR) |= ISR_BED;                bus_error=ISR_BED;        }        if (status & ISR_ITE){                (ISR) |= ISR_ITE;                tx_finished=ISR_ITE;        }        if (status & ISR_IRF){                (ISR) |= ISR_IRF;                rx_finished=ISR_IRF;        }        i2c_pending = 1;        wake_up_interruptible(&i2c_wait);}static int i2c_pxa_resource_init( void){        init_waitqueue_head(&i2c_wait);        if (request_irq(IRQ_I2C, &i2c_pxa_handler, SA_INTERRUPT, "I2C_PXA", 0) < 0) {                irq = 0;                if( i2c_debug)			printk(KERN_INFO "I2C: Failed to register I2C irq %i\n", IRQ_I2C);                return -ENODEV;        }else{                irq = IRQ_I2C;                enable_irq(irq);        }        return 0;}static void i2c_pxa_resource_release( void){        if( irq > 0)        {                disable_irq(irq);                free_irq(irq,0);                irq=0;        }}static void i2c_pxa_inc_use(struct i2c_adapter *adap){#ifdef MODULE        MOD_INC_USE_COUNT;#endif}static void i2c_pxa_dec_use(struct i2c_adapter *adap){#ifdef MODULE        MOD_DEC_USE_COUNT;#endif}static int i2c_pxa_client_register(struct i2c_client *client){        return 0;}static int i2c_pxa_client_unregister(struct i2c_client *client){        return 0;}static struct i2c_algo_pxa_data i2c_pxa_data = {        write_byte:		i2c_pxa_write_byte,        read_byte:		i2c_pxa_read_byte,        start:			i2c_pxa_start,        repeat_start:		i2c_pxa_repeat_start,        stop:			i2c_pxa_stop,        abort:			i2c_pxa_abort,        wait_bus_not_busy:	i2c_pxa_wait_bus_not_busy,        wait_for_interrupt:	i2c_pxa_wait_for_int,        transfer:		i2c_pxa_transfer,        reset:			i2c_pxa_reset,	udelay:			10,	timeout:		DEF_TIMEOUT,};static struct i2c_adapter i2c_pxa_ops = {        name:                   "PXA-I2C-Adapter",        id:                     I2C_ALGO_PXA,        algo_data:              &i2c_pxa_data,        inc_use:                i2c_pxa_inc_use,        dec_use:                i2c_pxa_dec_use,        client_register:        i2c_pxa_client_register,        client_unregister:      i2c_pxa_client_unregister,        retries:                2,};extern int i2c_pxa_add_bus(struct i2c_adapter *);extern int i2c_pxa_del_bus(struct i2c_adapter *);static int __init i2c_adap_pxa_init(void){        if( i2c_pxa_resource_init() == 0) {                if (i2c_pxa_add_bus(&i2c_pxa_ops) < 0) {                        i2c_pxa_resource_release();                        printk(KERN_INFO "I2C: Failed to add bus\n");                        return -ENODEV;                }        } else {                return -ENODEV;        }        printk(KERN_INFO "I2C: Successfully added bus\n");        return 0;}static void i2c_adap_pxa_exit(void){        i2c_pxa_del_bus( &i2c_pxa_ops);        i2c_pxa_resource_release();        printk(KERN_INFO "I2C: Successfully removed bus\n");}module_init(i2c_adap_pxa_init);module_exit(i2c_adap_pxa_exit);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美成人a视频| 亚洲va欧美va人人爽| 91精品国产综合久久久久久久| 成人av综合一区| 粉嫩av一区二区三区在线播放 | www.欧美日韩国产在线| 成人午夜又粗又硬又大| 成人免费黄色大片| 不卡视频免费播放| 色中色一区二区| 欧美美女一区二区| 日韩精品综合一本久道在线视频| 精品国产乱码久久久久久牛牛 | 国产婷婷精品av在线| 国产农村妇女精品| 亚洲精品va在线观看| 亚洲成人av福利| 奇米777欧美一区二区| 国产综合色在线| av中文字幕一区| 欧美日韩免费观看一区三区| 日韩视频国产视频| 中文字幕电影一区| 亚洲国产精品久久不卡毛片| 麻豆国产一区二区| 成人黄色在线视频| 欧美日韩国产123区| 久久影院视频免费| 亚洲人成精品久久久久久| 亚洲3atv精品一区二区三区| 韩国av一区二区| 日本韩国视频一区二区| 欧美一区二区三区播放老司机| 久久精品夜色噜噜亚洲aⅴ| 亚洲卡通欧美制服中文| 精品一区二区三区久久| 91麻豆国产在线观看| 欧美一级二级三级乱码| 亚洲乱码中文字幕综合| 久久国产婷婷国产香蕉| 在线一区二区观看| 国产日韩欧美a| 日本不卡一二三区黄网| 色综合天天综合色综合av | 国产成人av一区| 欧美三日本三级三级在线播放| 国产亚洲人成网站| 天天综合网天天综合色| 91色九色蝌蚪| 国产女主播视频一区二区| 午夜精品久久久久影视| 91丨九色丨黑人外教| 精品国产1区2区3区| 亚洲妇女屁股眼交7| 北岛玲一区二区三区四区| 91精品国产综合久久精品| 亚洲精品少妇30p| 国产91丝袜在线18| 精品国产成人系列| 视频一区二区不卡| 欧美日韩亚洲高清一区二区| 中文无字幕一区二区三区 | 秋霞成人午夜伦在线观看| 色综合久久久久久久久久久| 国产偷国产偷精品高清尤物 | 福利视频网站一区二区三区| 日韩免费成人网| 亚洲成人免费观看| 欧美在线观看视频在线| 亚洲精品高清在线| av福利精品导航| 国产精品电影院| 成人污视频在线观看| 国产精品日韩精品欧美在线| 成人一道本在线| 欧美激情中文字幕一区二区| 国产suv精品一区二区6| 国产欧美日韩综合| 风流少妇一区二区| 成人欧美一区二区三区小说| 成人精品国产福利| 亚洲欧美另类小说| 欧美日韩精品一区视频| 午夜私人影院久久久久| 777午夜精品视频在线播放| 免费成人你懂的| 国产偷国产偷精品高清尤物| 高清不卡一区二区在线| 亚洲久草在线视频| 欧美美女一区二区| 国产在线精品一区二区三区不卡| 久久久午夜精品| 92国产精品观看| 午夜精品福利视频网站 | 国产在线播放一区二区三区| 国产调教视频一区| 91福利精品视频| 天堂va蜜桃一区二区三区漫画版| 欧美一二三区精品| gogo大胆日本视频一区| 亚洲综合小说图片| 亚洲精品在线观| 色94色欧美sute亚洲13| 日本成人在线不卡视频| 国产精品丝袜久久久久久app| 在线免费不卡电影| 精品一区二区三区视频| 亚洲欧美另类久久久精品2019| 7777精品伊人久久久大香线蕉的 | 欧美精品一卡两卡| 国产成人亚洲精品青草天美| 亚洲女同一区二区| 日韩一区二区三区电影| 97久久精品人人做人人爽50路| 日韩精品一二三区| **欧美大码日韩| 91精品国产aⅴ一区二区| 不卡一区中文字幕| 久久av资源站| 亚洲va国产va欧美va观看| 国产亚洲va综合人人澡精品 | 国产精品欧美极品| 欧美蜜桃一区二区三区| 福利视频网站一区二区三区| 免费一级欧美片在线观看| 亚洲欧美日韩国产综合在线| 久久―日本道色综合久久| 欧美军同video69gay| 波多野结衣中文字幕一区二区三区| 午夜久久久影院| 亚洲视频一区二区在线| 国产精品久线在线观看| 日韩一卡二卡三卡四卡| 欧美日韩精品欧美日韩精品| 99国产精品视频免费观看| 激情综合网激情| 日本成人在线不卡视频| 午夜精品成人在线| 亚洲成在人线免费| 亚洲v精品v日韩v欧美v专区| 亚洲日本成人在线观看| 国产精品福利一区二区三区| 国产欧美综合在线| 欧美激情一区二区三区蜜桃视频| 精品国产青草久久久久福利| 制服丝袜亚洲精品中文字幕| 欧美少妇xxx| 色噜噜狠狠成人网p站| 一本大道av一区二区在线播放| av在线综合网| 91麻豆.com| 色综合天天天天做夜夜夜夜做| gogogo免费视频观看亚洲一| www.在线成人| 色综合久久综合网97色综合| 91影视在线播放| 日本乱码高清不卡字幕| 欧美视频一区二区三区四区 | 欧美国产亚洲另类动漫| 日本一区二区三区高清不卡| 欧美国产激情一区二区三区蜜月| 中文字幕精品一区二区三区精品| 国产精品无码永久免费888| 国产精品色噜噜| 亚洲综合久久av| 日韩国产欧美一区二区三区| 美日韩黄色大片| 国产精品自拍网站| 成人美女视频在线观看| 成人网页在线观看| 欧美午夜理伦三级在线观看| 69p69国产精品| 中文字幕精品一区二区三区精品| 亚洲视频精选在线| 男女男精品网站| 国产91丝袜在线播放九色| 色婷婷av一区二区| 日韩午夜在线观看视频| 亚洲国产高清在线| 亚洲在线一区二区三区| 秋霞av亚洲一区二区三| 懂色av一区二区三区免费观看| 91丨porny丨蝌蚪视频| 欧美精品粉嫩高潮一区二区| 国产三级久久久| 日日夜夜精品视频天天综合网| 国产精品456| 7777精品伊人久久久大香线蕉完整版| www激情久久| 亚洲国产精品一区二区久久恐怖片| 美女任你摸久久| 在线免费一区三区| 久久久www成人免费无遮挡大片| 一区二区三区精品| 成人性生交大片免费看视频在线 | 免费久久99精品国产| 成人午夜电影久久影院| 日韩一区二区三区视频在线| 亚洲精品乱码久久久久久久久| 激情都市一区二区|