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

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

?? doc2001.c

?? linux下的MTD設備驅動源代碼,配合jffs2 yaffss2文件系統(tǒng).
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * Linux driver for Disk-On-Chip Millennium * (c) 1999 Machine Vision Holdings, Inc. * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org> * * $Id: doc2001.c,v 1.42 2004/04/04 12:36:45 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 ECC_DEBUG *//* I have no idea why some DoC chips can not use memcop_form|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_MEMCPYstatic 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, int 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, int 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_erase (struct mtd_info *mtd, struct erase_info *instr);static struct mtd_info *docmillist = NULL;/* Perform the required delay cycles by reading from the NOP register */static void DoC_Delay(unsigned long docptr, unsigned short cycles){	volatile char dummy;	int i;	for (i = 0; i < cycles; i++)		dummy = ReadDOC(docptr, NOP);}/* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */static int _DoC_WaitReady(unsigned long docptr){	unsigned short c = 0xffff;	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) && --c)		;	if (c == 0)		DEBUG(MTD_DEBUG_LEVEL2, "_DoC_WaitReady timed out.\n");	return (c == 0);}static inline int DoC_WaitReady(unsigned long docptr){	/* 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(docptr, 4);	if (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B))		/* Call the out-of-line routine to wait */		ret = _DoC_WaitReady(docptr);	/* issue 2 read from NOP register after reading from CDSNControl register	   see Software Requirement 11.4 item 2. */	DoC_Delay(docptr, 2);	return ret;}/* DoC_Command: Send a flash command to the flash chip through the CDSN IO register   with 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 void DoC_Command(unsigned long docptr, unsigned char command,			       unsigned char xtraflags){	/* Assert the CLE (Command Latch Enable) line to the flash chip */	WriteDOC(xtraflags | CDSN_CTRL_CLE | CDSN_CTRL_CE, docptr, CDSNControl);	DoC_Delay(docptr, 4);	/* Send the command */	WriteDOC(command, docptr, Mil_CDSN_IO);	WriteDOC(0x00, docptr, WritePipeTerm);	/* Lower the CLE line */	WriteDOC(xtraflags | CDSN_CTRL_CE, docptr, CDSNControl);	DoC_Delay(docptr, 4);}/* DoC_Address: Set the current address for the flash chip through the CDSN IO register   with 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 void DoC_Address(unsigned long docptr, int numbytes, unsigned long ofs,			       unsigned char xtraflags1, unsigned char xtraflags2){	/* Assert the ALE (Address Latch Enable) line to the flash chip */	WriteDOC(xtraflags1 | CDSN_CTRL_ALE | CDSN_CTRL_CE, docptr, CDSNControl);	DoC_Delay(docptr, 4);	/* Send the address */	switch (numbytes)	    {	    case 1:		    /* Send single byte, bits 0-7. */		    WriteDOC(ofs & 0xff, docptr, Mil_CDSN_IO);		    WriteDOC(0x00, docptr, WritePipeTerm);		    break;	    case 2:		    /* Send bits 9-16 followed by 17-23 */		    WriteDOC((ofs >> 9)  & 0xff, docptr, Mil_CDSN_IO);		    WriteDOC((ofs >> 17) & 0xff, docptr, Mil_CDSN_IO);		    WriteDOC(0x00, docptr, WritePipeTerm);		break;	    case 3:		    /* Send 0-7, 9-16, then 17-23 */		    WriteDOC(ofs & 0xff, docptr, Mil_CDSN_IO);		    WriteDOC((ofs >> 9)  & 0xff, docptr, Mil_CDSN_IO);		    WriteDOC((ofs >> 17) & 0xff, docptr, Mil_CDSN_IO);		    WriteDOC(0x00, docptr, WritePipeTerm);		break;	    default:		return;	    }	/* Lower the ALE line */	WriteDOC(xtraflags1 | xtraflags2 | CDSN_CTRL_CE, docptr, CDSNControl);	DoC_Delay(docptr, 4);}/* DoC_SelectChip: Select a given flash chip within the current floor */static int DoC_SelectChip(unsigned long docptr, int chip){	/* Select the individual flash chip requested */	WriteDOC(chip, docptr, CDSNDeviceSelect);	DoC_Delay(docptr, 4);	/* Wait for it to be ready */	return DoC_WaitReady(docptr);}/* DoC_SelectFloor: Select a given floor (bank of flash chips) */static int DoC_SelectFloor(unsigned long docptr, int floor){	/* Select the floor (bank) of chips required */	WriteDOC(floor, docptr, FloorSelect);	/* Wait for the chip to be ready */	return DoC_WaitReady(docptr);}/* 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	   FIXME: is this supported by Millennium ?? */	DoC_SelectFloor(doc->virtadr, floor);	DoC_SelectChip(doc->virtadr, chip);	/* Reset the chip, see Software Requirement 11.4 item 1. */	DoC_Command(doc->virtadr, NAND_CMD_RESET, CDSN_CTRL_WP);	DoC_WaitReady(doc->virtadr);	/* Read the NAND chip ID: 1. Send ReadID command */ 	DoC_Command(doc->virtadr, NAND_CMD_READID, CDSN_CTRL_WP);	/* Read the NAND chip ID: 2. Send address byte zero */ 	DoC_Address(doc->virtadr, 1, 0x00, CDSN_CTRL_WP, 0x00);	/* Read the manufacturer and device id codes of the flash device through	   CDSN IO register see Software Requirement 11.4 item 5.*/	dummy = ReadDOC(doc->virtadr, ReadPipeInit);	DoC_Delay(doc->virtadr, 2);	mfr = ReadDOC(doc->virtadr, Mil_CDSN_IO);	DoC_Delay(doc->virtadr, 2);	id  = ReadDOC(doc->virtadr, Mil_CDSN_IO);	dummy = ReadDOC(doc->virtadr, LastDataRead);	/* No response - return failure */	if (mfr == 0xff || mfr == 0)		return 0;	/* FIXME: to deal with multi-flash on multi-Millennium case more carefully */	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);			doc->mfr = mfr;			doc->id = id;			doc->chipshift = ffs((nand_flash_ids[i].chipsize << 20)) - 1;			break;		}	}	if (nand_flash_ids[i].name == NULL)		return 0;	else		return 1;}/* DoC_ScanChips: Find all NAND chips present in a DiskOnChip, and identify them */static void DoC_ScanChips(struct DiskOnChip *this){	int floor, chip;	int numchips[MAX_FLOORS_MIL];	int ret;	this->numchips = 0;	this->mfr = 0;	this->id = 0;	/* For each floor, find the number of valid chips it contains */	for (floor = 0,ret = 1; floor < MAX_FLOORS_MIL; floor++) {		numchips[floor] = 0;		for (chip = 0; chip < MAX_CHIPS_MIL && ret != 0; chip++) {			ret = DoC_IdentChip(this, floor, chip);			if (ret) {				numchips[floor]++;				this->numchips++;			}		}	}	/* If there are none at all that we recognise, bail */	if (!this->numchips) {		printk("No flash chips recognised.\n");		return;	}	/* Allocate an array to hold the information for each chip */	this->chips = kmalloc(sizeof(struct Nand) * this->numchips, GFP_KERNEL);	if (!this->chips){		printk("No memory for allocating chip info structures\n");		return;	}	/* Fill out the chip array with {floor, chipno} for each 	 * detected chip in the device. */	for (floor = 0, ret = 0; floor < MAX_FLOORS_MIL; floor++) {		for (chip = 0 ; chip < numchips[floor] ; chip++) {			this->chips[ret].floor = floor;			this->chips[ret].chip = chip;			this->chips[ret].curadr = 0;			this->chips[ret].curmode = 0x50;			ret++;		}	}	/* Calculate and print the total size of the device */	this->totlen = this->numchips * (1 << this->chipshift);	printk(KERN_INFO "%d flash chips found. Total DiskOnChip size: %ld MiB\n",	       this->numchips ,this->totlen >> 20);}static int DoCMil_is_alias(struct DiskOnChip *doc1, struct DiskOnChip *doc2){	int tmp1, tmp2, retval;	if (doc1->physadr == doc2->physadr)		return 1;	/* Use the alias resolution register which was set aside for this	 * purpose. If it's value is the same on both chips, they might	 * be the same chip, and we write to one and check for a change in	 * the other. It's unclear if this register is usuable in the	 * DoC 2000 (it's in the Millenium docs), but it seems to work. */	tmp1 = ReadDOC(doc1->virtadr, AliasResolution);	tmp2 = ReadDOC(doc2->virtadr, AliasResolution);	if (tmp1 != tmp2)		return 0;		WriteDOC((tmp1+1) % 0xff, doc1->virtadr, AliasResolution);	tmp2 = ReadDOC(doc2->virtadr, AliasResolution);	if (tmp2 == (tmp1+1) % 0xff)		retval = 1;	else		retval = 0;	/* Restore register contents.  May not be necessary, but do it just to	 * be safe. */	WriteDOC(tmp1, doc1->virtadr, AliasResolution);	return retval;}static const char im_name[] = "DoCMil_init";/* This routine is made available to other mtd code via * inter_module_register.  It must only be accessed through * inter_module_get which will bump the use count of this module.  The * addresses passed back in mtd are valid as long as the use count of * this module is non-zero, i.e. between inter_module_get and * inter_module_put.  Keith Owens <kaos@ocs.com.au> 29 Oct 2000. */static void DoCMil_init(struct mtd_info *mtd){	struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;	struct DiskOnChip *old = NULL;	/* We must avoid being called twice for the same device. */	if (docmillist)		old = (struct DiskOnChip *)docmillist->priv;	while (old) {		if (DoCMil_is_alias(this, old)) {			printk(KERN_NOTICE "Ignoring DiskOnChip Millennium at "			       "0x%lX - already configured\n", this->physadr);			iounmap((void *)this->virtadr);			kfree(mtd);			return;		}		if (old->nextdoc)			old = (struct DiskOnChip *)old->nextdoc->priv;		else			old = NULL;	}	mtd->name = "DiskOnChip Millennium";	printk(KERN_NOTICE "DiskOnChip Millennium found at address 0x%lX\n",	       this->physadr);	mtd->type = MTD_NANDFLASH;	mtd->flags = MTD_CAP_NANDFLASH;	mtd->ecctype = MTD_ECC_RS_DiskOnChip;	mtd->size = 0;	/* FIXME: erase size is not always 8KiB */	mtd->erasesize = 0x2000;	mtd->oobblock = 512;	mtd->oobsize = 16;	mtd->owner = THIS_MODULE;	mtd->erase = doc_erase;	mtd->point = NULL;	mtd->unpoint = NULL;	mtd->read = doc_read;	mtd->write = doc_write;	mtd->read_ecc = doc_read_ecc;	mtd->write_ecc = doc_write_ecc;	mtd->read_oob = doc_read_oob;	mtd->write_oob = doc_write_oob;	mtd->sync = NULL;	this->totlen = 0;	this->numchips = 0;	this->curfloor = -1;	this->curchip = -1;	/* Ident all the chips present. */	DoC_ScanChips(this);	if (!this->totlen) {		kfree(mtd);		iounmap((void *)this->virtadr);	} else {		this->nextdoc = docmillist;		docmillist = mtd;		mtd->size  = this->totlen;		add_mtd_device(mtd);		return;	}}static int doc_read (struct mtd_info *mtd, loff_t from, size_t len,		     size_t *retlen, u_char *buf){	/* Just a special case of doc_read_ecc */	return doc_read_ecc(mtd, from, len, retlen, buf, NULL, 0);}static int doc_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,			 size_t *retlen, u_char *buf, u_char *eccbuf, int oobsel){	int i, ret;	volatile char dummy;	unsigned char syndrome[6];	struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;	unsigned long docptr = this->virtadr;	struct Nand *mychip = &this->chips[from >> (this->chipshift)];	/* Don't allow read past end of device */	if (from >= this->totlen)		return -EINVAL;	/* Don't allow a single read to cross a 512-byte block boundary */	if (from + len > ((from | 0x1ff) + 1)) 		len = ((from | 0x1ff) + 1) - from;	/* Find the chip which is to be used and select it */	if (this->curfloor != mychip->floor) {		DoC_SelectFloor(docptr, mychip->floor);		DoC_SelectChip(docptr, mychip->chip);	} else if (this->curchip != mychip->chip) {		DoC_SelectChip(docptr, mychip->chip);	}	this->curfloor = mychip->floor;	this->curchip = mychip->chip;	/* issue the Read0 or Read1 command depend on which half of the page	   we are accessing. Polling the Flash Ready bit after issue 3 bytes	   address in Sequence Read Mode, see Software Requirement 11.4 item 1.*/	DoC_Command(docptr, (from >> 8) & 1, CDSN_CTRL_WP);	DoC_Address(docptr, 3, from, CDSN_CTRL_WP, 0x00);	DoC_WaitReady(docptr);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品一区二区三区99| 欧美性受xxxx| 99国产麻豆精品| 91精品国产丝袜白色高跟鞋| 欧美高清在线视频| 偷拍自拍另类欧美| 经典三级一区二区| 欧美嫩在线观看| 亚洲免费在线看| 国产成人在线视频播放| 日韩欧美一区中文| 亚洲国产精品天堂| 色婷婷综合中文久久一本| 久久久91精品国产一区二区精品 | 国产精品一区一区三区| 色94色欧美sute亚洲线路二 | 精品少妇一区二区三区在线视频| 综合久久久久久| 成人性视频免费网站| 精品乱人伦小说| 奇米888四色在线精品| 欧美日本韩国一区二区三区视频 | 全国精品久久少妇| 在线视频观看一区| 中文字幕在线视频一区| 国产精品亚洲人在线观看| 91精品欧美综合在线观看最新| 玉米视频成人免费看| 9i在线看片成人免费| 国产精品国产精品国产专区不片 | 久久精品99久久久| 日韩亚洲欧美高清| 蜜桃av一区二区| 欧美本精品男人aⅴ天堂| 免费日本视频一区| 日韩欧美aaaaaa| 国产精品一区二区男女羞羞无遮挡| 欧美一区二区福利视频| 日韩福利视频网| 日韩视频在线一区二区| 久久精品99国产精品日本| 2020国产精品自拍| 日韩一级片网址| 国产曰批免费观看久久久| 精品日韩一区二区| 国产乱码字幕精品高清av| 久久午夜老司机| 波多野结衣欧美| 亚洲综合小说图片| 欧美一区二区日韩一区二区| 另类小说一区二区三区| 久久久国产精品麻豆| 高清国产一区二区| 一区二区三区在线不卡| 欧美怡红院视频| 日本不卡视频在线观看| 久久久精品天堂| 91色.com| 久88久久88久久久| 国产精品久久久久国产精品日日| 色激情天天射综合网| 日本中文在线一区| 国产精品久久久久影院老司| 欧美日韩亚洲高清一区二区| 激情综合色播激情啊| 亚洲欧美日本韩国| 欧美一区二区三区免费观看视频| 国产精品 欧美精品| 亚洲一区二区三区四区在线| 欧美精品一区在线观看| 在线一区二区三区做爰视频网站| 午夜精品成人在线视频| 日本一区二区三区免费乱视频 | 不卡高清视频专区| 日产精品久久久久久久性色| 中文字幕欧美日本乱码一线二线| 在线观看欧美黄色| 丁香六月久久综合狠狠色| 亚洲a一区二区| 亚洲天堂a在线| 久久亚洲综合色一区二区三区 | 久久久久久久久久久久久女国产乱| 91影院在线免费观看| 紧缚捆绑精品一区二区| 亚洲午夜免费电影| 欧美激情一区不卡| 日韩一区二区电影网| 欧美亚洲禁片免费| 成人18精品视频| 久久国产综合精品| 午夜影院在线观看欧美| 亚洲色图欧洲色图婷婷| 国产拍揄自揄精品视频麻豆| 日韩一区二区在线观看视频| 色综合久久中文综合久久97| 国产精品一区二区免费不卡| 久久99精品国产| 日韩av一级片| 青娱乐精品在线视频| 一区二区不卡在线播放 | 国产婷婷色一区二区三区| 欧美精品少妇一区二区三区| 色综合久久综合网| 97se亚洲国产综合自在线| 国产一区激情在线| 久久国产免费看| 日本特黄久久久高潮| 亚洲国产精品自拍| 水野朝阳av一区二区三区| 午夜国产不卡在线观看视频| 亚瑟在线精品视频| 亚洲午夜久久久久中文字幕久| 亚洲激情五月婷婷| 亚洲黄色片在线观看| 一区二区三区在线视频观看58| 亚洲特黄一级片| 亚洲黄色片在线观看| 亚洲曰韩产成在线| 亚洲国产一区二区视频| 偷拍日韩校园综合在线| 日韩国产精品91| 国产又黄又大久久| 国产成人福利片| 成人性生交大片免费看在线播放 | 中文字幕色av一区二区三区| 国产精品卡一卡二卡三| 亚洲精品免费一二三区| 亚洲资源在线观看| 视频精品一区二区| 蜜臀久久99精品久久久久宅男| 日本不卡123| 久久se精品一区二区| 国产麻豆精品95视频| 成+人+亚洲+综合天堂| 在线精品视频免费播放| 欧美日韩国产综合一区二区三区| 欧美一区二区三区播放老司机| 欧美岛国在线观看| 中文字幕+乱码+中文字幕一区| 中文字幕亚洲综合久久菠萝蜜| 午夜国产精品一区| 国产精品亚洲专一区二区三区| 99国产精品久久久久久久久久| 欧美日韩高清不卡| 久久嫩草精品久久久精品| 亚洲色图欧洲色图| 麻豆精品蜜桃视频网站| 99久久免费精品高清特色大片| 欧美三日本三级三级在线播放| 欧美一区二区视频在线观看2020| 精品不卡在线视频| 亚洲激情欧美激情| 国产原创一区二区| 欧美日韩中文另类| 国产欧美一区二区精品婷婷 | 亚洲三级在线免费观看| 麻豆成人免费电影| 91蜜桃网址入口| 日韩一区二区三区高清免费看看| 中文字幕成人网| 美女久久久精品| 色哟哟一区二区在线观看| 精品国产一二三| 一区二区久久久| 国产成人综合亚洲网站| 欧美一区二区性放荡片| 亚洲欧美欧美一区二区三区| 国内精品在线播放| 6080日韩午夜伦伦午夜伦| 国产精品久久精品日日| 久久精品久久综合| 欧美视频在线一区二区三区| 国产精品免费丝袜| 久久成人羞羞网站| 欧美日韩另类一区| 亚洲精品ww久久久久久p站| 国产成人精品影视| 26uuu久久天堂性欧美| 午夜欧美2019年伦理| 色综合 综合色| 1024成人网| 成人性生交大片免费看中文 | 日韩在线播放一区二区| 91在线国产观看| 1000精品久久久久久久久| 国产精品一区在线| 精品国产91久久久久久久妲己| 日韩影视精彩在线| 欧美日韩国产影片| 亚洲国产中文字幕在线视频综合| 色婷婷久久久亚洲一区二区三区| 国产蜜臀av在线一区二区三区| 国产精品99久久久久久久女警| 日韩视频123| 久久99久久99精品免视看婷婷| 欧美一区二区三区四区视频| 日欧美一区二区| 91精品国产综合久久久久| 亚洲va中文字幕| 欧美高清视频在线高清观看mv色露露十八 |