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

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

?? ppc440gx_i2c.c

?? gumstiz u-boot loader in linux
?? C
字號:
/* *  Copyright (C) 2005 Sandburst Corporation * * See file CREDITS for list of people who contributed to this * project. * * 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., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA *//* * Ported from cpu/ppc4xx/i2c.c by AS HARNOIS by * Travis B. Sawyer * Sandburst Corporation. */#include <common.h>#include <ppc4xx.h>#if defined(CONFIG_440)#   include <440_i2c.h>#else#   include <405gp_i2c.h>#endif#include <i2c.h>#include <440_i2c.h>#include <command.h>#include "ppc440gx_i2c.h"#ifdef CONFIG_I2C_BUS1#define IIC_OK		0#define IIC_NOK		1#define IIC_NOK_LA	2		/* Lost arbitration */#define IIC_NOK_ICT	3		/* Incomplete transfer */#define IIC_NOK_XFRA	4		/* Transfer aborted */#define IIC_NOK_DATA	5		/* No data in buffer */#define IIC_NOK_TOUT	6		/* Transfer timeout */#define IIC_TIMEOUT 1			/* 1 second */#if defined(CFG_I2C_NOPROBES)static uchar i2c_no_probes[] = CFG_I2C_NOPROBES;#endifstatic void _i2c_bus1_reset (void){	int i, status;	/* Reset status register */	/* write 1 in SCMP and IRQA to clear these fields */	out8 (IIC_STS1, 0x0A);	/* write 1 in IRQP IRQD LA ICT XFRA to clear these fields */	out8 (IIC_EXTSTS1, 0x8F);	__asm__ volatile ("eieio");	/*	 * Get current state, reset bus	 * only if no transfers are pending.	 */	i = 10;	do {		/* Get status */		status = in8 (IIC_STS1);		udelay (500);			/* 500us */		i--;	} while ((status & IIC_STS_PT) && (i > 0));	/* Soft reset controller */	status = in8 (IIC_XTCNTLSS1);	out8 (IIC_XTCNTLSS1, (status | IIC_XTCNTLSS_SRST));	__asm__ volatile ("eieio");	/* make sure where in initial state, data hi, clock hi */	out8 (IIC_DIRECTCNTL1, 0xC);	for (i = 0; i < 10; i++) {		if ((in8 (IIC_DIRECTCNTL1) & 0x3) != 0x3) {			/* clock until we get to known state */			out8 (IIC_DIRECTCNTL1, 0x8);	/* clock lo */			udelay (100);		/* 100us */			out8 (IIC_DIRECTCNTL1, 0xC);	/* clock hi */			udelay (100);		/* 100us */		} else {			break;		}	}	/* send start condition */	out8 (IIC_DIRECTCNTL1, 0x4);	udelay (1000);				/* 1ms */	/* send stop condition */	out8 (IIC_DIRECTCNTL1, 0xC);	udelay (1000);				/* 1ms */	/* Unreset controller */	out8 (IIC_XTCNTLSS1, (status & ~IIC_XTCNTLSS_SRST));	udelay (1000);				/* 1ms */}void i2c1_init (int speed, int slaveadd){	sys_info_t sysInfo;	unsigned long freqOPB;	int val, divisor;#ifdef CFG_I2C_INIT_BOARD	/* call board specific i2c bus reset routine before accessing the   */	/* environment, which might be in a chip on that bus. For details   */	/* about this problem see doc/I2C_Edge_Conditions.                  */	i2c_init_board();#endif	/* Handle possible failed I2C state */	/* FIXME: put this into i2c_init_board()? */	_i2c_bus1_reset ();	/* clear lo master address */	out8 (IIC_LMADR1, 0);	/* clear hi master address */	out8 (IIC_HMADR1, 0);	/* clear lo slave address */	out8 (IIC_LSADR1, 0);	/* clear hi slave address */	out8 (IIC_HSADR1, 0);	/* Clock divide Register */	/* get OPB frequency */	get_sys_info (&sysInfo);	freqOPB = sysInfo.freqPLB / sysInfo.pllOpbDiv;	/* set divisor according to freqOPB */	divisor = (freqOPB - 1) / 10000000;	if (divisor == 0)		divisor = 1;	out8 (IIC_CLKDIV1, divisor);	/* no interrupts */	out8 (IIC_INTRMSK1, 0);	/* clear transfer count */	out8 (IIC_XFRCNT1, 0);	/* clear extended control & stat */	/* write 1 in SRC SRS SWC SWS to clear these fields */	out8 (IIC_XTCNTLSS1, 0xF0);	/* Mode Control Register	   Flush Slave/Master data buffer */	out8 (IIC_MDCNTL1, IIC_MDCNTL_FSDB | IIC_MDCNTL_FMDB);	__asm__ volatile ("eieio");	val = in8(IIC_MDCNTL1);	__asm__ volatile ("eieio");	/* Ignore General Call, slave transfers are ignored,	   disable interrupts, exit unknown bus state, enable hold	   SCL	   100kHz normaly or FastMode for 400kHz and above	*/	val |= IIC_MDCNTL_EUBS|IIC_MDCNTL_HSCL;	if( speed >= 400000 ){		val |= IIC_MDCNTL_FSM;	}	out8 (IIC_MDCNTL1, val);	/* clear control reg */	out8 (IIC_CNTL1, 0x00);	__asm__ volatile ("eieio");}/*  This code tries to use the features of the 405GP i2c  controller. It will transfer up to 4 bytes in one pass  on the loop. It only does out8(lbz) to the buffer when it  is possible to do out16(lhz) transfers.  cmd_type is 0 for write 1 for read.  addr_len can take any value from 0-255, it is only limited  by the char, we could make it larger if needed. If it is  0 we skip the address write cycle.  Typical case is a Write of an addr followd by a Read. The  IBM FAQ does not cover this. On the last byte of the write  we don't set the creg CHT bit, and on the first bytes of the  read we set the RPST bit.  It does not support address only transfers, there must be  a data part. If you want to write the address yourself, put  it in the data pointer.  It does not support transfer to/from address 0.  It does not check XFRCNT.*/staticint i2c_transfer1(unsigned char cmd_type,		  unsigned char chip,		  unsigned char addr[],		  unsigned char addr_len,		  unsigned char data[],		  unsigned short data_len ){	unsigned char* ptr;	int reading;	int tran,cnt;	int result;	int status;	int i;	uchar creg;	if( data == 0 || data_len == 0 ){		/*Don't support data transfer of no length or to address 0*/		printf( "i2c_transfer: bad call\n" );		return IIC_NOK;	}	if( addr && addr_len ){		ptr = addr;		cnt = addr_len;		reading = 0;	}else{		ptr = data;		cnt = data_len;		reading = cmd_type;	}	/*Clear Stop Complete Bit*/	out8(IIC_STS1,IIC_STS_SCMP);	/* Check init */	i=10;	do {		/* Get status */		status = in8(IIC_STS1);		__asm__ volatile("eieio");		i--;	} while ((status & IIC_STS_PT) && (i>0));	if (status & IIC_STS_PT) {		result = IIC_NOK_TOUT;		return(result);	}	/*flush the Master/Slave Databuffers*/	out8(IIC_MDCNTL1, ((in8(IIC_MDCNTL1))|IIC_MDCNTL_FMDB|IIC_MDCNTL_FSDB));	/*need to wait 4 OPB clocks? code below should take that long*/	/* 7-bit adressing */	out8(IIC_HMADR1,0);	out8(IIC_LMADR1, chip);	__asm__ volatile("eieio");	tran = 0;	result = IIC_OK;	creg = 0;	while ( tran != cnt && (result == IIC_OK)) {		int  bc,j;		/* Control register =		   Normal transfer, 7-bits adressing, Transfer up to bc bytes, Normal start,		   Transfer is a sequence of transfers		*/		creg |= IIC_CNTL_PT;		bc = (cnt - tran) > 4 ? 4 :			cnt - tran;		creg |= (bc-1)<<4;		/* if the real cmd type is write continue trans*/		if ( (!cmd_type && (ptr == addr)) || ((tran+bc) != cnt) )			creg |= IIC_CNTL_CHT;		if (reading)			creg |= IIC_CNTL_READ;		else {			for(j=0; j<bc; j++) {				/* Set buffer */				out8(IIC_MDBUF1,ptr[tran+j]);				__asm__ volatile("eieio");			}		}		out8(IIC_CNTL1, creg );		__asm__ volatile("eieio");		/* Transfer is in progress		   we have to wait for upto 5 bytes of data		   1 byte chip address+r/w bit then bc bytes		   of data.		   udelay(10) is 1 bit time at 100khz		   Doubled for slop. 20 is too small.		*/		i=2*5*8;		do {			/* Get status */			status = in8(IIC_STS1);			__asm__ volatile("eieio");			udelay (10);			i--;		} while ((status & IIC_STS_PT) && !(status & IIC_STS_ERR)			 && (i>0));		if (status & IIC_STS_ERR) {			result = IIC_NOK;			status = in8 (IIC_EXTSTS1);			/* Lost arbitration? */			if (status & IIC_EXTSTS_LA)				result = IIC_NOK_LA;			/* Incomplete transfer? */			if (status & IIC_EXTSTS_ICT)				result = IIC_NOK_ICT;			/* Transfer aborted? */			if (status & IIC_EXTSTS_XFRA)				result = IIC_NOK_XFRA;		} else if ( status & IIC_STS_PT) {			result = IIC_NOK_TOUT;		}		/* Command is reading => get buffer */		if ((reading) && (result == IIC_OK)) {			/* Are there data in buffer */			if (status & IIC_STS_MDBS) {				/*				  even if we have data we have to wait 4OPB clocks				  for it to hit the front of the FIFO, after that				  we can just read. We should check XFCNT here and				  if the FIFO is full there is no need to wait.				*/				udelay (1);				for(j=0;j<bc;j++) {					ptr[tran+j] = in8(IIC_MDBUF1);					__asm__ volatile("eieio");				}			} else				result = IIC_NOK_DATA;		}		creg = 0;		tran+=bc;		if( ptr == addr && tran == cnt ) {			ptr = data;			cnt = data_len;			tran = 0;			reading = cmd_type;			if( reading )				creg = IIC_CNTL_RPST;		}	}	return (result);}int i2c_probe1 (uchar chip){	uchar buf[1];	buf[0] = 0;	/*	 * What is needed is to send the chip address and verify that the	 * address was <ACK>ed (i.e. there was a chip at that address which	 * drove the data line low).	 */	return(i2c_transfer1 (1, chip << 1, 0,0, buf, 1) != 0);}int i2c_read1 (uchar chip, uint addr, int alen, uchar * buffer, int len){	uchar xaddr[4];	int ret;	if ( alen > 4 ) {		printf ("I2C read: addr len %d not supported\n", alen);		return 1;	}	if ( alen > 0 ) {		xaddr[0] = (addr >> 24) & 0xFF;		xaddr[1] = (addr >> 16) & 0xFF;		xaddr[2] = (addr >> 8) & 0xFF;		xaddr[3] = addr & 0xFF;	}#ifdef CFG_I2C_EEPROM_ADDR_OVERFLOW	/*	 * EEPROM chips that implement "address overflow" are ones	 * like Catalyst 24WC04/08/16 which has 9/10/11 bits of	 * address and the extra bits end up in the "chip address"	 * bit slots. This makes a 24WC08 (1Kbyte) chip look like	 * four 256 byte chips.	 *	 * Note that we consider the length of the address field to	 * still be one byte because the extra address bits are	 * hidden in the chip address.	 */	if( alen > 0 )		chip |= ((addr >> (alen * 8)) & CFG_I2C_EEPROM_ADDR_OVERFLOW);#endif	if( (ret = i2c_transfer1( 1, chip<<1, &xaddr[4-alen], alen, buffer, len )) != 0) {		printf( "I2c read: failed %d\n", ret);		return 1;	}	return 0;}int i2c_write1 (uchar chip, uint addr, int alen, uchar * buffer, int len){	uchar xaddr[4];	if ( alen > 4 ) {		printf ("I2C write: addr len %d not supported\n", alen);		return 1;	}	if ( alen > 0 ) {		xaddr[0] = (addr >> 24) & 0xFF;		xaddr[1] = (addr >> 16) & 0xFF;		xaddr[2] = (addr >> 8) & 0xFF;		xaddr[3] = addr & 0xFF;	}#ifdef CFG_I2C_EEPROM_ADDR_OVERFLOW	/*	 * EEPROM chips that implement "address overflow" are ones	 * like Catalyst 24WC04/08/16 which has 9/10/11 bits of	 * address and the extra bits end up in the "chip address"	 * bit slots. This makes a 24WC08 (1Kbyte) chip look like	 * four 256 byte chips.	 *	 * Note that we consider the length of the address field to	 * still be one byte because the extra address bits are	 * hidden in the chip address.	 */	if( alen > 0 )		chip |= ((addr >> (alen * 8)) & CFG_I2C_EEPROM_ADDR_OVERFLOW);#endif	return (i2c_transfer1( 0, chip<<1, &xaddr[4-alen], alen, buffer, len ) != 0);}/*----------------------------------------------------------------------- * Read a register */uchar i2c_reg_read1(uchar i2c_addr, uchar reg){	uchar buf;	i2c_read1(i2c_addr, reg, 1, &buf, (uchar)1);	return(buf);}/*----------------------------------------------------------------------- * Write a register */void i2c_reg_write1(uchar i2c_addr, uchar reg, uchar val){	i2c_write1(i2c_addr, reg, 1, &val, 1);}int do_i2c1_probe(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){	int j;#if defined(CFG_I2C_NOPROBES)	int k, skip;#endif	puts ("Valid chip addresses:");	for(j = 0; j < 128; j++) {#if defined(CFG_I2C_NOPROBES)		skip = 0;		for (k = 0; k < sizeof(i2c_no_probes); k++){			if (j == i2c_no_probes[k]){				skip = 1;				break;			}		}		if (skip)			continue;#endif		if(i2c_probe1(j) == 0) {			printf(" %02X", j);		}	}	putc ('\n');#if defined(CFG_I2C_NOPROBES)	puts ("Excluded chip addresses:");	for( k = 0; k < sizeof(i2c_no_probes); k++ )		printf(" %02X", i2c_no_probes[k] );	putc ('\n');#endif	return 0;}U_BOOT_CMD(	iprobe1,	1,	1,	do_i2c1_probe,	"iprobe1  - probe to discover valid I2C chip addresses\n",	"\n    -discover valid I2C chip addresses\n");#endif	/* CONFIG_I2C_BUS1 */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人精品免费在线| 亚洲一区二区中文在线| 欧美精品黑人性xxxx| 日本道免费精品一区二区三区| 国产成人超碰人人澡人人澡| 国产真实乱偷精品视频免| 日本成人中文字幕在线视频| 日韩福利视频导航| 美女网站色91| 久久精品国产一区二区| 久久精品国产99久久6| 黄页网站大全一区二区| 国产高清在线精品| 成人午夜视频在线观看| 91免费观看视频| 欧美视频中文字幕| 51精品视频一区二区三区| 91精品国产一区二区三区| 精品日韩99亚洲| 中文一区一区三区高中清不卡| 中文字幕一区二区三区在线播放| 亚洲乱码国产乱码精品精小说 | 国产盗摄女厕一区二区三区| 粉嫩久久99精品久久久久久夜| 91蜜桃在线观看| 欧美精品久久99久久在免费线 | 91精品国模一区二区三区| 欧美videofree性高清杂交| 日韩精品一区二区三区视频播放 | 亚洲高清免费视频| 麻豆高清免费国产一区| 国产一区二区伦理| 色综合久久精品| 欧美成人a视频| 亚洲欧美韩国综合色| 蜜臀va亚洲va欧美va天堂| 丁香网亚洲国际| 欧美高清你懂得| 国产欧美一区二区三区沐欲| 国产精品福利影院| 亚洲精品国产精华液| 亚洲欧美在线视频| 日韩精品免费专区| 99麻豆久久久国产精品免费优播| 欧美日韩国产影片| 国产亚洲人成网站| 久久综合色鬼综合色| 一区二区三区丝袜| 丁香另类激情小说| 日韩欧美成人午夜| 亚洲国产一区二区三区| 国产不卡视频在线播放| 欧美一级理论片| 亚洲国产精品视频| 99热国产精品| 久久精品视频在线免费观看| 日本视频一区二区| 91久久免费观看| 成人免费在线视频| 国产一区二区精品在线观看| 欧美一区二区三区免费大片| 亚洲午夜久久久久中文字幕久| 波多野结衣在线一区| 久久无码av三级| 黄网站免费久久| 日韩精品一区国产麻豆| 日本91福利区| 欧美日本一道本在线视频| 一区二区三区美女| 91尤物视频在线观看| 国产区在线观看成人精品| 国产一区二区三区免费观看| 精品美女被调教视频大全网站| 天天综合网 天天综合色| 精品视频在线免费观看| 亚洲精品乱码久久久久久黑人| www.久久久久久久久| 国产精品久久毛片| 99re热这里只有精品免费视频| 国产精品理论片| 91碰在线视频| 亚洲精品videosex极品| 欧洲视频一区二区| 亚洲国产精品久久久久秋霞影院| 在线观看国产一区二区| 午夜私人影院久久久久| 欧美一区二区性放荡片| 久久97超碰国产精品超碰| 精品处破学生在线二十三| 国产91清纯白嫩初高中在线观看 | 成人av网址在线观看| 综合久久久久综合| 欧美在线小视频| 奇米影视7777精品一区二区| 欧美mv和日韩mv的网站| 国产成人精品免费| 一区二区三区欧美激情| 91精品国产综合久久久久久久| 久久精品久久综合| 国产精品理论在线观看| 欧洲一区二区av| 国产一区二区三区在线观看免费 | 国产一区二区成人久久免费影院| 久久久久久久av麻豆果冻| 不卡的av在线播放| 日一区二区三区| 国产视频在线观看一区二区三区 | 麻豆一区二区三区| 日韩欧美一区中文| 国产成人三级在线观看| 亚洲一区在线电影| 欧美二区在线观看| 久久99久久久久久久久久久| 欧美精品18+| 国产·精品毛片| 秋霞国产午夜精品免费视频| 中文字幕精品三区| 91麻豆精品国产自产在线观看一区| 国产精品久线在线观看| 欧美丰满少妇xxxbbb| 久久电影网电视剧免费观看| 亚洲裸体在线观看| 国产无人区一区二区三区| 97久久精品人人做人人爽| 男女激情视频一区| 亚洲激情图片一区| 国产日韩欧美精品一区| 欧美高清精品3d| 91浏览器在线视频| 日韩高清在线不卡| 亚洲在线视频网站| 中日韩免费视频中文字幕| 欧美tickling网站挠脚心| 欧美三级韩国三级日本三斤| 99re热这里只有精品视频| 成人一区二区三区中文字幕| 美女一区二区三区在线观看| 亚洲猫色日本管| 国产精品毛片高清在线完整版| 久久综合狠狠综合久久综合88| 欧美日韩成人一区| 91久久精品国产91性色tv| 不卡大黄网站免费看| 成人av在线资源网站| 国产成人精品影视| 国产一区二区三区免费看| 美女一区二区三区| 奇米影视7777精品一区二区| 天天操天天干天天综合网| 亚洲二区在线观看| 亚洲国产中文字幕| 亚洲国产精品久久久久秋霞影院 | 国产精品久久久久三级| 久久精品在这里| 国产亚洲成aⅴ人片在线观看 | 精品国产百合女同互慰| 91精品国产色综合久久久蜜香臀| 精品视频在线看| 欧美精品成人一区二区三区四区| 欧美挠脚心视频网站| 欧美日韩国产123区| 欧美剧情电影在线观看完整版免费励志电影| 欧美在线免费观看视频| 色综合久久六月婷婷中文字幕| 在线观看区一区二| 欧美福利一区二区| 精品国产1区2区3区| 国产丝袜在线精品| 亚洲日本在线视频观看| 一区二区三区91| 欧美aaaaaa午夜精品| 激情综合网天天干| 成人黄色小视频| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 欧美日韩一区二区三区高清| 5月丁香婷婷综合| 欧美国产成人精品| 亚洲欧美日韩久久| 日本成人在线看| 成人毛片在线观看| 欧美视频一区二| 亚洲精品在线一区二区| 自拍偷拍国产亚洲| 久久99精品国产麻豆不卡| 国产精品资源站在线| 91美女视频网站| 日韩亚洲欧美中文三级| 久久久久久久久久久久久女国产乱 | 欧美日韩一区三区| 精品国产不卡一区二区三区| 亚洲欧美日韩人成在线播放| 久久精品噜噜噜成人av农村| 99麻豆久久久国产精品免费 | 一区二区三区精品久久久| 日韩精品国产欧美| 粗大黑人巨茎大战欧美成人| 欧美疯狂性受xxxxx喷水图片| 国产精品五月天| 蜜臀精品一区二区三区在线观看 | 国产精品麻豆视频|