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

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

?? doc2000.c

?? linux下的MTD設備驅動源代碼,配合jffs2 yaffss2文件系統.
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* * Linux driver for Disk-On-Chip 2000 and Millennium * (c) 1999 Machine Vision Holdings, Inc. * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org> * * $Id: doc2000.c,v 1.60 2004/04/07 08:30:04 gleixner Exp $ */#include <linux/kernel.h>#include <linux/module.h>#include <asm/errno.h>#include <asm/io.h>#include <asm/uaccess.h>#include <linux/miscdevice.h>#include <linux/pci.h>#include <linux/delay.h>#include <linux/slab.h>#include <linux/sched.h>#include <linux/init.h>#include <linux/types.h>#include <linux/bitops.h>#include <linux/mtd/mtd.h>#include <linux/mtd/nand.h>#include <linux/mtd/doc2000.h>#define DOC_SUPPORT_2000#define DOC_SUPPORT_2000TSOP#define DOC_SUPPORT_MILLENNIUM#ifdef DOC_SUPPORT_2000#define DoC_is_2000(doc) (doc->ChipID == DOC_ChipID_Doc2k)#else#define DoC_is_2000(doc) (0)#endif#if defined(DOC_SUPPORT_2000TSOP) || defined(DOC_SUPPORT_MILLENNIUM)#define DoC_is_Millennium(doc) (doc->ChipID == DOC_ChipID_DocMil)#else#define DoC_is_Millennium(doc) (0)#endif/* #define ECC_DEBUG *//* I have no idea why some DoC chips can not use memcpy_from|to_io(). * This may be due to the different revisions of the ASIC controller built-in or * simplily a QA/Bug issue. Who knows ?? If you have trouble, please uncomment * this: #undef USE_MEMCPY*/static int doc_read(struct mtd_info *mtd, loff_t from, size_t len,		    size_t *retlen, u_char *buf);static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,		     size_t *retlen, const u_char *buf);static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,			size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel);static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,			 size_t *retlen, const u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel);static int doc_writev_ecc(struct mtd_info *mtd, const struct iovec *vecs, 			  unsigned long count, loff_t to, size_t *retlen,			  u_char *eccbuf, struct nand_oobinfo *oobsel);static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,			size_t *retlen, u_char *buf);static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,			 size_t *retlen, const u_char *buf);static int doc_write_oob_nolock(struct mtd_info *mtd, loff_t ofs, size_t len,			 size_t *retlen, const u_char *buf);static int doc_erase (struct mtd_info *mtd, struct erase_info *instr);static struct mtd_info *doc2klist = NULL;/* Perform the required delay cycles by reading from the appropriate register */static void DoC_Delay(struct DiskOnChip *doc, unsigned short cycles){	volatile char dummy;	int i;		for (i = 0; i < cycles; i++) {		if (DoC_is_Millennium(doc))			dummy = ReadDOC(doc->virtadr, NOP);		else			dummy = ReadDOC(doc->virtadr, DOCStatus);	}	}/* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */static int _DoC_WaitReady(struct DiskOnChip *doc){	unsigned long docptr = doc->virtadr;	unsigned long timeo = jiffies + (HZ * 10);	DEBUG(MTD_DEBUG_LEVEL3,	      "_DoC_WaitReady called for out-of-line wait\n");	/* Out-of-line routine to wait for chip response */	while (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B)) {		/* issue 2 read from NOP register after reading from CDSNControl register	   	see Software Requirement 11.4 item 2. */		DoC_Delay(doc, 2);		if (time_after(jiffies, timeo)) {			DEBUG(MTD_DEBUG_LEVEL2, "_DoC_WaitReady timed out.\n");			return -EIO;		}		udelay(1);		cond_resched();	}	return 0;}static inline int DoC_WaitReady(struct DiskOnChip *doc){	unsigned long docptr = doc->virtadr;	/* This is inline, to optimise the common case, where it's ready instantly */	int ret = 0;	/* 4 read form NOP register should be issued in prior to the read from CDSNControl	   see Software Requirement 11.4 item 2. */	DoC_Delay(doc, 4);	if (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B))		/* Call the out-of-line routine to wait */		ret = _DoC_WaitReady(doc);	/* issue 2 read from NOP register after reading from CDSNControl register	   see Software Requirement 11.4 item 2. */	DoC_Delay(doc, 2);	return ret;}/* DoC_Command: Send a flash command to the flash chip through the CDSN Slow IO register to   bypass the internal pipeline. Each of 4 delay cycles (read from the NOP register) is   required after writing to CDSN Control register, see Software Requirement 11.4 item 3. */static inline int DoC_Command(struct DiskOnChip *doc, unsigned char command,			      unsigned char xtraflags){	unsigned long docptr = doc->virtadr;	if (DoC_is_2000(doc))		xtraflags |= CDSN_CTRL_FLASH_IO;	/* Assert the CLE (Command Latch Enable) line to the flash chip */	WriteDOC(xtraflags | CDSN_CTRL_CLE | CDSN_CTRL_CE, docptr, CDSNControl);	DoC_Delay(doc, 4);	/* Software requirement 11.4.3 for Millennium */	if (DoC_is_Millennium(doc))		WriteDOC(command, docptr, CDSNSlowIO);	/* Send the command */	WriteDOC_(command, docptr, doc->ioreg);	if (DoC_is_Millennium(doc))		WriteDOC(command, docptr, WritePipeTerm);	/* Lower the CLE line */	WriteDOC(xtraflags | CDSN_CTRL_CE, docptr, CDSNControl);	DoC_Delay(doc, 4);	/* Software requirement 11.4.3 for Millennium */	/* Wait for the chip to respond - Software requirement 11.4.1 (extended for any command) */	return DoC_WaitReady(doc);}/* DoC_Address: Set the current address for the flash chip through the CDSN Slow IO register to   bypass the internal pipeline. Each of 4 delay cycles (read from the NOP register) is   required after writing to CDSN Control register, see Software Requirement 11.4 item 3. */static int DoC_Address(struct DiskOnChip *doc, int numbytes, unsigned long ofs,		       unsigned char xtraflags1, unsigned char xtraflags2){	unsigned long docptr;	int i;	docptr = doc->virtadr;	if (DoC_is_2000(doc))		xtraflags1 |= CDSN_CTRL_FLASH_IO;	/* Assert the ALE (Address Latch Enable) line to the flash chip */	WriteDOC(xtraflags1 | CDSN_CTRL_ALE | CDSN_CTRL_CE, docptr, CDSNControl);	DoC_Delay(doc, 4);	/* Software requirement 11.4.3 for Millennium */	/* Send the address */	/* Devices with 256-byte page are addressed as:	   Column (bits 0-7), Page (bits 8-15, 16-23, 24-31)	   * there is no device on the market with page256	   and more than 24 bits.	   Devices with 512-byte page are addressed as:	   Column (bits 0-7), Page (bits 9-16, 17-24, 25-31)	   * 25-31 is sent only if the chip support it.	   * bit 8 changes the read command to be sent	   (NAND_CMD_READ0 or NAND_CMD_READ1).	 */	if (numbytes == ADDR_COLUMN || numbytes == ADDR_COLUMN_PAGE) {		if (DoC_is_Millennium(doc))			WriteDOC(ofs & 0xff, docptr, CDSNSlowIO);		WriteDOC_(ofs & 0xff, docptr, doc->ioreg);	}	if (doc->page256) {		ofs = ofs >> 8;	} else {		ofs = ofs >> 9;	}	if (numbytes == ADDR_PAGE || numbytes == ADDR_COLUMN_PAGE) {		for (i = 0; i < doc->pageadrlen; i++, ofs = ofs >> 8) {			if (DoC_is_Millennium(doc))				WriteDOC(ofs & 0xff, docptr, CDSNSlowIO);			WriteDOC_(ofs & 0xff, docptr, doc->ioreg);		}	}	if (DoC_is_Millennium(doc))		WriteDOC(ofs & 0xff, docptr, WritePipeTerm);	DoC_Delay(doc, 2);	/* Needed for some slow flash chips. mf. */		/* FIXME: The SlowIO's for millennium could be replaced by 	   a single WritePipeTerm here. mf. */	/* Lower the ALE line */	WriteDOC(xtraflags1 | xtraflags2 | CDSN_CTRL_CE, docptr,		 CDSNControl);	DoC_Delay(doc, 4);	/* Software requirement 11.4.3 for Millennium */	/* Wait for the chip to respond - Software requirement 11.4.1 */	return DoC_WaitReady(doc);}/* Read a buffer from DoC, taking care of Millennium odditys */static void DoC_ReadBuf(struct DiskOnChip *doc, u_char * buf, int len){	volatile int dummy;	int modulus = 0xffff;	unsigned long docptr;	int i;	docptr = doc->virtadr;	if (len <= 0)		return;	if (DoC_is_Millennium(doc)) {		/* Read the data via the internal pipeline through CDSN IO register,		   see Pipelined Read Operations 11.3 */		dummy = ReadDOC(docptr, ReadPipeInit);		/* Millennium should use the LastDataRead register - Pipeline Reads */		len--;		/* This is needed for correctly ECC calculation */		modulus = 0xff;	}	for (i = 0; i < len; i++)		buf[i] = ReadDOC_(docptr, doc->ioreg + (i & modulus));	if (DoC_is_Millennium(doc)) {		buf[i] = ReadDOC(docptr, LastDataRead);	}}/* Write a buffer to DoC, taking care of Millennium odditys */static void DoC_WriteBuf(struct DiskOnChip *doc, const u_char * buf, int len){	unsigned long docptr;	int i;	docptr = doc->virtadr;	if (len <= 0)		return;	for (i = 0; i < len; i++)		WriteDOC_(buf[i], docptr, doc->ioreg + i);	if (DoC_is_Millennium(doc)) {		WriteDOC(0x00, docptr, WritePipeTerm);	}}/* DoC_SelectChip: Select a given flash chip within the current floor */static inline int DoC_SelectChip(struct DiskOnChip *doc, int chip){	unsigned long docptr = doc->virtadr;	/* Software requirement 11.4.4 before writing DeviceSelect */	/* Deassert the CE line to eliminate glitches on the FCE# outputs */	WriteDOC(CDSN_CTRL_WP, docptr, CDSNControl);	DoC_Delay(doc, 4);	/* Software requirement 11.4.3 for Millennium */	/* Select the individual flash chip requested */	WriteDOC(chip, docptr, CDSNDeviceSelect);	DoC_Delay(doc, 4);	/* Reassert the CE line */	WriteDOC(CDSN_CTRL_CE | CDSN_CTRL_FLASH_IO | CDSN_CTRL_WP, docptr,		 CDSNControl);	DoC_Delay(doc, 4);	/* Software requirement 11.4.3 for Millennium */	/* Wait for it to be ready */	return DoC_WaitReady(doc);}/* DoC_SelectFloor: Select a given floor (bank of flash chips) */static inline int DoC_SelectFloor(struct DiskOnChip *doc, int floor){	unsigned long docptr = doc->virtadr;	/* Select the floor (bank) of chips required */	WriteDOC(floor, docptr, FloorSelect);	/* Wait for the chip to be ready */	return DoC_WaitReady(doc);}/* DoC_IdentChip: Identify a given NAND chip given {floor,chip} */static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip){	int mfr, id, i, j;	volatile char dummy;	/* Page in the required floor/chip */	DoC_SelectFloor(doc, floor);	DoC_SelectChip(doc, chip);	/* Reset the chip */	if (DoC_Command(doc, NAND_CMD_RESET, CDSN_CTRL_WP)) {		DEBUG(MTD_DEBUG_LEVEL2,		      "DoC_Command (reset) for %d,%d returned true\n",		      floor, chip);		return 0;	}	/* Read the NAND chip ID: 1. Send ReadID command */	if (DoC_Command(doc, NAND_CMD_READID, CDSN_CTRL_WP)) {		DEBUG(MTD_DEBUG_LEVEL2,		      "DoC_Command (ReadID) for %d,%d returned true\n",		      floor, chip);		return 0;	}	/* Read the NAND chip ID: 2. Send address byte zero */	DoC_Address(doc, ADDR_COLUMN, 0, CDSN_CTRL_WP, 0);	/* Read the manufacturer and device id codes from the device */	if (DoC_is_Millennium(doc)) {		DoC_Delay(doc, 2);		dummy = ReadDOC(doc->virtadr, ReadPipeInit);		mfr = ReadDOC(doc->virtadr, LastDataRead);		DoC_Delay(doc, 2);		dummy = ReadDOC(doc->virtadr, ReadPipeInit);		id = ReadDOC(doc->virtadr, LastDataRead);	} else {		/* CDSN Slow IO register see Software Req 11.4 item 5. */		dummy = ReadDOC(doc->virtadr, CDSNSlowIO);		DoC_Delay(doc, 2);		mfr = ReadDOC_(doc->virtadr, doc->ioreg);		/* CDSN Slow IO register see Software Req 11.4 item 5. */		dummy = ReadDOC(doc->virtadr, CDSNSlowIO);		DoC_Delay(doc, 2);		id = ReadDOC_(doc->virtadr, doc->ioreg);	}	/* No response - return failure */	if (mfr == 0xff || mfr == 0)		return 0;	/* Check it's the same as the first chip we identified. 	 * M-Systems say that any given DiskOnChip device should only	 * contain _one_ type of flash part, although that's not a 	 * hardware restriction. */	if (doc->mfr) {		if (doc->mfr == mfr && doc->id == id)			return 1;	/* This is another the same the first */		else			printk(KERN_WARNING			       "Flash chip at floor %d, chip %d is different:\n",			       floor, chip);	}	/* Print and store the manufacturer and ID codes. */	for (i = 0; nand_flash_ids[i].name != NULL; i++) {		if (id == nand_flash_ids[i].id) {			/* Try to identify manufacturer */			for (j = 0; nand_manuf_ids[j].id != 0x0; j++) {				if (nand_manuf_ids[j].id == mfr)					break;			}				printk(KERN_INFO			       "Flash chip found: Manufacturer ID: %2.2X, "			       "Chip ID: %2.2X (%s:%s)\n", mfr, id,			       nand_manuf_ids[j].name, nand_flash_ids[i].name);			if (!doc->mfr) {				doc->mfr = mfr;				doc->id = id;				doc->chipshift = 					ffs((nand_flash_ids[i].chipsize << 20)) - 1;				doc->page256 = (nand_flash_ids[i].pagesize == 256) ? 1 : 0;				doc->pageadrlen = doc->chipshift > 25 ? 3 : 2;				doc->erasesize =				    nand_flash_ids[i].erasesize;				return 1;			}			return 0;		}	}	/* We haven't fully identified the chip. Print as much as we know. */	printk(KERN_WARNING "Unknown flash chip found: %2.2X %2.2X\n",	       id, mfr);	printk(KERN_WARNING "Please report to dwmw2@infradead.org\n");	return 0;}/* DoC_ScanChips: Find all NAND chips present in a DiskOnChip, and identify them */static void DoC_ScanChips(struct DiskOnChip *this, int maxchips){	int floor, chip;	int numchips[MAX_FLOORS];	int ret = 1;	this->numchips = 0;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
不卡的av在线| 午夜精品久久久久久久久| 国产成人综合网| 久久亚洲一级片| 国产一区二区在线影院| 久久久久久99久久久精品网站| 精品亚洲国内自在自线福利| 国产日本欧洲亚洲| 不卡的电影网站| 亚洲成av人片一区二区梦乃| 欧美一级久久久久久久大片| 国产一区二区免费视频| 国产精品卡一卡二卡三| 在线观看视频91| 日韩成人av影视| 国产日韩综合av| 色婷婷亚洲综合| 免费精品视频在线| 国产视频一区二区在线观看| 94-欧美-setu| 奇米影视一区二区三区小说| 国产欧美日韩激情| 欧美伊人久久久久久久久影院 | 国产日韩精品一区二区浪潮av | 91精品国产综合久久久蜜臀图片| 日韩av一区二区三区四区| 2欧美一区二区三区在线观看视频| 成人妖精视频yjsp地址| 亚洲韩国一区二区三区| 26uuu国产日韩综合| 色成年激情久久综合| 精品在线免费观看| 亚洲免费高清视频在线| 久久伊99综合婷婷久久伊| 91久久精品一区二区| 久99久精品视频免费观看| 亚洲另类中文字| 久久久久国产一区二区三区四区| 欧美三级韩国三级日本三斤| 丰满白嫩尤物一区二区| 蜜臀av一区二区在线观看| 自拍偷拍欧美精品| www国产精品av| 欧美日本精品一区二区三区| aaa亚洲精品| 国产一区二区三区四区在线观看| 亚洲电影第三页| 欧美激情一区二区三区蜜桃视频| 91精品久久久久久久久99蜜臂| 99精品欧美一区二区三区小说| 久久99精品视频| 亚洲丰满少妇videoshd| 自拍偷拍亚洲激情| 国产精品久久夜| 久久久美女毛片| 欧美刺激午夜性久久久久久久 | 成人福利视频网站| 精久久久久久久久久久| 日韩激情在线观看| 亚洲国产精品久久久久婷婷884 | 在线一区二区观看| 不卡一区中文字幕| 国产91在线观看| 国产乱码一区二区三区| 久久99热这里只有精品| 奇米一区二区三区| 日韩精品每日更新| 青青草91视频| 青青国产91久久久久久| 日韩精品一卡二卡三卡四卡无卡| 首页综合国产亚洲丝袜| 亚洲成人综合视频| 午夜精品视频在线观看| 丝袜美腿亚洲一区| 日韩av中文在线观看| 六月丁香综合在线视频| 蜜桃一区二区三区在线观看| 免费的国产精品| 九九**精品视频免费播放| 日本不卡一区二区三区| 免费在线看成人av| 精品一区二区三区不卡 | 国产女同互慰高潮91漫画| 久久久久久久久久电影| 中文字幕巨乱亚洲| 亚洲情趣在线观看| 亚洲精品高清视频在线观看| 亚洲精品国产a久久久久久| 亚洲自拍偷拍网站| 亚洲成人av福利| 美女看a上一区| 国产乱码精品一区二区三区忘忧草 | 久久日韩粉嫩一区二区三区| 久久精品视频在线看| 中文一区在线播放| 亚洲蜜臀av乱码久久精品| 亚洲一区二区欧美激情| 日韩高清不卡在线| 国内外成人在线| 成人听书哪个软件好| 色婷婷久久久久swag精品| 欧美另类久久久品| 久久综合久久综合久久| 国产精品视频九色porn| 亚洲一区二区三区国产| 黄一区二区三区| 99精品视频一区| 欧美第一区第二区| 亚洲欧洲日韩综合一区二区| 亚洲国产成人tv| 激情综合色播激情啊| www.日韩精品| 欧美一区二区三区啪啪| 国产拍欧美日韩视频二区| 亚洲在线视频网站| 国内精品久久久久影院一蜜桃| 97精品电影院| 日韩欧美久久久| 亚洲欧洲日产国码二区| 日本午夜精品一区二区三区电影| 国产黄人亚洲片| 欧美人与z0zoxxxx视频| 久久人人爽人人爽| 午夜电影久久久| 成人精品亚洲人成在线| 9191久久久久久久久久久| 国产精品人成在线观看免费| 偷拍日韩校园综合在线| 成av人片一区二区| 久久在线免费观看| 香蕉加勒比综合久久| 成a人片亚洲日本久久| 亚洲精品一区二区三区福利| 亚洲午夜在线视频| 高清av一区二区| 欧美电影免费观看完整版| 一区二区三区精品在线| 国产精品91xxx| 欧美哺乳videos| 无码av中文一区二区三区桃花岛| 不卡电影免费在线播放一区| 亚洲精品在线网站| 视频一区二区不卡| 在线看不卡av| 亚洲青青青在线视频| 成人aa视频在线观看| 久久天堂av综合合色蜜桃网| 日韩和欧美的一区| 欧美三区在线观看| 亚洲欧美激情一区二区| 成人精品小蝌蚪| 国产农村妇女精品| 韩国三级电影一区二区| 欧美日产国产精品| 亚洲国产精品视频| 在线观看日韩电影| 亚洲免费伊人电影| 91在线观看美女| 国产精品成人免费在线| 国产高清精品在线| 国产午夜三级一区二区三| 精品无人区卡一卡二卡三乱码免费卡 | 成人午夜精品一区二区三区| 久久精品一区四区| 国产自产视频一区二区三区 | 久久综合av免费| 久久99精品国产.久久久久久| 91精品国产欧美日韩| 免费在线观看一区| 日韩午夜精品视频| 极品少妇xxxx精品少妇偷拍| 欧美变态口味重另类| 蜜乳av一区二区三区| 欧美成人女星排行榜| 老司机精品视频一区二区三区| 欧美一级理论性理论a| 久久精品国产亚洲a| 欧美成人一区二区三区片免费| 极品少妇一区二区三区精品视频| 久久九九国产精品| 成人爱爱电影网址| 亚洲精品美国一| 在线电影院国产精品| 丝袜脚交一区二区| 精品伦理精品一区| 国产精品自在欧美一区| 国产精品丝袜久久久久久app| 色综合久久久久| 日韩高清不卡在线| 久久精品免视看| 色偷偷成人一区二区三区91| 亚洲国产乱码最新视频| 日韩午夜在线影院| av不卡免费电影| 天堂蜜桃91精品| 国产欧美视频一区二区三区| 99麻豆久久久国产精品免费 | 久草这里只有精品视频| 国产精品系列在线| 91福利小视频|