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

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

?? nand.c

?? 在PXA255下用做擴展NAND Flash芯片的程序源代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
	/* Return happy */	*retlen = len;#ifdef CONFIG_MTD_NAND_VERIFY_WRITE	/* Send command to read back the data */	this->cmdfunc (mtd, NAND_CMD_READOOB, column, page);	/* Loop through and verify the data */	for (i = 0; i < len; i++) {		if (buf[i] != this->read_byte(mtd)) {			DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write verify, page 0x%08x\n", page);			ret = -EIO;			goto out;		}	}#endifout:	/* De-select the NAND device */	this->select_chip(mtd, -1);	/* Wake up anyone waiting on the device */	spin_lock_bh (&this->chip_lock);	this->state = FL_READY;	wake_up (&this->wq);	spin_unlock_bh (&this->chip_lock);	return ret;}/* * NAND write with iovec */static int nand_writev (struct mtd_info *mtd, const struct iovec *vecs, unsigned long count, 		loff_t to, size_t * retlen){	return (nand_writev_ecc (mtd, vecs, count, to, retlen, NULL, 0));	}static int nand_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){	int i, page, len, total_len, ret = 0, written = 0;	struct nand_chip *this = mtd->priv;	/* Calculate total length of data */	total_len = 0;	for (i = 0; i < count; i++)		total_len += (int) vecs[i].iov_len;	DEBUG (MTD_DEBUG_LEVEL3,	       "nand_writev: to = 0x%08x, len = %i, count = %ld\n", (unsigned int) to, (unsigned int) total_len, count);	/* Do not allow write past end of page */	if ((to + total_len) > mtd->size) {		DEBUG (MTD_DEBUG_LEVEL0, "nand_writev: Attempted write past end of device\n");		return -EINVAL;	}	/* reject writes, which are not page aligned */		if (NOTALIGNED (to) || NOTALIGNED(total_len)) {		printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n");		return -EINVAL;	}	// if oobsel is NULL, use chip defaults	if (oobsel == NULL) 		oobsel = &mtd->oobinfo;			/* Shift to get page */	page = ((int) to) >> this->page_shift;	/* Grab the lock and see if the device is available */	nand_get_chip (this, mtd, FL_WRITING, NULL);	/* Select the NAND device */	this->select_chip(mtd, 0);	/* Check the WP bit */	this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);	if (!(this->read_byte(mtd) & 0x80)) {		DEBUG (MTD_DEBUG_LEVEL0, "nand_writev: Device is write protected!!!\n");		ret = -EIO;		goto out;	}	/* Loop until all iovecs' data has been written */	len = 0;	while (count) {		/* 		 *  Check, if the tuple gives us not enough data for a 		 *  full page write. Then we can use the iov direct, 		 *  else we have to copy into data_buf.				 */		if ((vecs->iov_len - len) >= mtd->oobblock) {			this->data_poi = (u_char *) vecs->iov_base;			this->data_poi += len;			len += mtd->oobblock; 			/* Check, if we have to switch to the next tuple */			if (len >= (int) vecs->iov_len) {				vecs++;				len = 0;				count--;			}		} else {			/*			 * Read data out of each tuple until we have a full page			 * to write or we've read all the tuples.		 	*/			int cnt = 0;			while ((cnt < mtd->oobblock) && count) {				if (vecs->iov_base != NULL && vecs->iov_len) {					this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++];				}				/* Check, if we have to switch to the next tuple */				if (len >= (int) vecs->iov_len) {					vecs++;					len = 0;					count--;				}			}				this->data_poi = this->data_buf;			}				/* We use the same function for write and writev !) */		ret = nand_write_page (mtd, this, page, NULL, oobsel);		if (ret)			goto out;		/* Update written bytes count */		written += mtd->oobblock;;		/* Increment page address */		page++;	}out:	/* De-select the NAND device */	this->select_chip(mtd, -1);	/* Wake up anyone waiting on the device */	spin_lock_bh (&this->chip_lock);	this->state = FL_READY;	wake_up (&this->wq);	spin_unlock_bh (&this->chip_lock);	*retlen = written;	return ret;}/* * NAND erase a block */static int nand_erase (struct mtd_info *mtd, struct erase_info *instr){	int page, len, status, pages_per_block, ret;	struct nand_chip *this = mtd->priv;	DECLARE_WAITQUEUE (wait, current);	DEBUG (MTD_DEBUG_LEVEL3,	       "nand_erase: start = 0x%08x, len = %i\n", (unsigned int) instr->addr, (unsigned int) instr->len);	/* Start address must align on block boundary */	if (instr->addr & (mtd->erasesize - 1)) {		DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Unaligned address\n");		return -EINVAL;	}	/* Length must align on block boundary */	if (instr->len & (mtd->erasesize - 1)) {		DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Length not block aligned\n");		return -EINVAL;	}	/* Do not allow erase past end of device */	if ((instr->len + instr->addr) > mtd->size) {		DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Erase past end of device\n");		return -EINVAL;	}	/* Grab the lock and see if the device is available */	nand_get_chip (this, mtd, FL_ERASING, NULL);	/* Shift to get first page */	page = (int) (instr->addr >> this->page_shift);	/* Calculate pages in each block */	pages_per_block = mtd->erasesize / mtd->oobblock;	/* Select the NAND device */	this->select_chip(mtd, 0);	/* Check the WP bit */	this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);	if (!(this->read_byte(mtd) & 0x80)) {		DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Device is write protected!!!\n");		instr->state = MTD_ERASE_FAILED;		goto erase_exit;	}	/* Loop through the pages */	len = instr->len;	instr->state = MTD_ERASING;	while (len) {		/* Check if we have a bad block, we do not erase bad blocks ! */		if (this->block_bad(mtd, page)) {			printk (KERN_WARNING "nand_erase: attempt to erase a bad block at page 0x%08x\n", page);			instr->state = MTD_ERASE_FAILED;			goto erase_exit;		}		/* Send commands to erase a page */		this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page);		this->cmdfunc (mtd, NAND_CMD_ERASE2, -1, -1);		spin_unlock_bh (&this->chip_lock);		status = this->waitfunc (mtd, this, FL_ERASING);		/* Get spinlock, in case we exit */		spin_lock_bh (&this->chip_lock);		/* See if block erase succeeded */		if (status & 0x01) {			DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: " "Failed erase, page 0x%08x\n", page);			instr->state = MTD_ERASE_FAILED;			goto erase_exit;		}				/* Check, if we were interupted */		if (this->state == FL_ERASING) {			/* Increment page address and decrement length */			len -= mtd->erasesize;			page += pages_per_block;		}		/* Release the spin lock */		spin_unlock_bh (&this->chip_lock);erase_retry:		spin_lock_bh (&this->chip_lock);		/* Check the state and sleep if it changed */		if (this->state == FL_ERASING || this->state == FL_READY) {			/* Select the NAND device again, if we were interrupted */			this->state = FL_ERASING;			this->select_chip(mtd, 0);			continue;		} else {			set_current_state (TASK_UNINTERRUPTIBLE);			add_wait_queue (&this->wq, &wait);			spin_unlock_bh (&this->chip_lock);			schedule ();			remove_wait_queue (&this->wq, &wait);			goto erase_retry;		}	}	instr->state = MTD_ERASE_DONE;erase_exit:	/* De-select the NAND device */	this->select_chip(mtd, -1);	spin_unlock_bh (&this->chip_lock);	ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO;;	/* Do call back function */	if (!ret && instr->callback)		instr->callback (instr);	/* The device is ready */	spin_lock_bh (&this->chip_lock);	this->state = FL_READY;	wake_up (&this->wq);	spin_unlock_bh (&this->chip_lock);	/* Return more or less happy */	return ret;}/* * NAND sync */static void nand_sync (struct mtd_info *mtd){	struct nand_chip *this = mtd->priv;	DECLARE_WAITQUEUE (wait, current);	DEBUG (MTD_DEBUG_LEVEL3, "nand_sync: called\n");retry:	/* Grab the spinlock */	spin_lock_bh (&this->chip_lock);	/* See what's going on */	switch (this->state) {	case FL_READY:	case FL_SYNCING:		this->state = FL_SYNCING;		spin_unlock_bh (&this->chip_lock);		break;	default:		/* Not an idle state */		add_wait_queue (&this->wq, &wait);		spin_unlock_bh (&this->chip_lock);		schedule ();		remove_wait_queue (&this->wq, &wait);		goto retry;	}	/* Lock the device */	spin_lock_bh (&this->chip_lock);	/* Set the device to be ready again */	if (this->state == FL_SYNCING) {		this->state = FL_READY;		wake_up (&this->wq);	}	/* Unlock the device */	spin_unlock_bh (&this->chip_lock);}/* * Scan for the NAND device */int nand_scan (struct mtd_info *mtd, int maxchips){	int i, nand_maf_id, nand_dev_id;	struct nand_chip *this = mtd->priv;	/* check for proper chip_delay setup, set 20us if not */	if (!this->chip_delay)		this->chip_delay = 20;	/* check, if a user supplied command function given */	if (this->cmdfunc == NULL)		this->cmdfunc = nand_command;	/* check, if a user supplied wait function given */	if (this->waitfunc == NULL)		this->waitfunc = nand_wait;	if (!this->block_bad)		this->block_bad = nand_block_bad;	if (!this->select_chip)		this->select_chip = nand_select_chip;	if (!this->write_byte)		this->write_byte = nand_write_byte;	if (!this->read_byte)		this->read_byte = nand_read_byte;	if (!this->write_buf)		this->write_buf = nand_write_buf;	if (!this->read_buf)		this->read_buf = nand_read_buf;	if (!this->verify_buf)		this->verify_buf = nand_verify_buf;	/* Select the device */	this->select_chip(mtd, 0);	/* Send the command for reading device ID */	this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1);	/* Read manufacturer and device IDs */	nand_maf_id = this->read_byte(mtd);	nand_dev_id = this->read_byte(mtd);	printk ("%s: %x %x IOadd:%x\n", __FUNCTION__, nand_maf_id, nand_dev_id, this->IO_ADDR_R);	/* Print and store flash device information */	for (i = 0; nand_flash_ids[i].name != NULL; i++) {		if (nand_dev_id == nand_flash_ids[i].id && !mtd->size) {			mtd->name = nand_flash_ids[i].name;			mtd->erasesize = nand_flash_ids[i].erasesize;			mtd->eccsize = 256;			this->chipshift = nand_flash_ids[i].chipshift;			if (nand_flash_ids[i].page256) {				mtd->oobblock = 256;				mtd->oobsize = 8;				this->page_shift = 8;			} else {				mtd->oobblock = 512;				mtd->oobsize = 16;				this->page_shift = 9;			}			/* Try to identify manufacturer */			for (i = 0; nand_manuf_ids[i].id != 0x0; i++) {				if (nand_manuf_ids[i].id == nand_maf_id)					break;			}				printk (KERN_INFO "NAND device: Manufacturer ID:"				" 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, 				nand_manuf_ids[i].name , mtd->name);			break;		}	}	if (!mtd->name) {		printk (KERN_WARNING "No NAND device found!!!\n");		return 1;	}	for (i=1; i < maxchips; i++) {		this->select_chip(mtd, i);		/* Send the command for reading device ID */		this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1);		/* Read manufacturer and device IDs */		if (nand_maf_id != this->read_byte(mtd) ||		    nand_dev_id != this->read_byte(mtd))			break;	}	if (i > 1)		printk(KERN_INFO "%d NAND chips detected\n", i);	mtd->size = (1 << this->chipshift) /* * i when we fix the rest of the code */;	/* 	 * check ECC mode, default to software	 * if 3byte/512byte hardware ECC is selected and we have 256 byte pagesize	 * fallback to software ECC 	*/	this->eccsize = 256;	/* set default eccsize */		switch (this->eccmode) {	case NAND_ECC_HW3_512: 	case NAND_ECC_HW6_512: 		if (mtd->oobblock == 256) {			printk (KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n");			this->eccmode = NAND_ECC_SOFT;			this->calculate_ecc = nand_calculate_ecc;			this->correct_data = nand_correct_data;			break;				} else 			this->eccsize = 512; /* set eccsize to 512 and fall through for function check */	case NAND_ECC_HW3_256:		if (this->calculate_ecc && this->correct_data && this->enable_hwecc)			break;		printk (KERN_WARNING "No ECC functions supplied, Hardware ECC not possible\n");		BUG();		case NAND_ECC_NONE: 		//printk (KERN_WARNING "NAND_ECC_NONE selected by board driver. This is not recommended !!\n");		this->eccmode = NAND_ECC_NONE;		break;	case NAND_ECC_SOFT:			this->calculate_ecc = nand_calculate_ecc;		this->correct_data = nand_correct_data;		break;	default:		printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode);		BUG();		}			/* Initialize state, waitqueue and spinlock */	this->state = FL_READY;	init_waitqueue_head (&this->wq);	spin_lock_init (&this->chip_lock);	/* De-select the device */	this->select_chip(mtd, -1);	/* Fill in remaining MTD driver data */	mtd->type = MTD_NANDFLASH;	mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC;	mtd->ecctype = MTD_ECC_SW;	mtd->erase = nand_erase;	mtd->point = NULL;	mtd->unpoint = NULL;	mtd->read = nand_read;	mtd->write = nand_write;	mtd->read_ecc = nand_read_ecc;	mtd->write_ecc = nand_write_ecc;	mtd->read_oob = nand_read_oob;	mtd->write_oob = nand_write_oob;	mtd->readv = NULL;	mtd->writev = nand_writev;	mtd->writev_ecc = nand_writev_ecc;	mtd->sync = nand_sync;	mtd->lock = NULL;	mtd->unlock = NULL;	mtd->suspend = NULL;	mtd->resume = NULL;	mtd->owner = THIS_MODULE;	/* Return happy */	return 0;}EXPORT_SYMBOL (nand_scan);MODULE_LICENSE ("GPL");MODULE_AUTHOR("<newboder@hybus.net>");MODULE_DESCRIPTION("Nand Flash driver For hycnc board");

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩成人免费电影| 欧美在线视频你懂得| 99热精品国产| 日韩三级av在线播放| 国产精品高潮久久久久无| 免费在线成人网| 日本高清免费不卡视频| 精品久久久久久久人人人人传媒| 亚洲欧美色综合| 粉嫩av亚洲一区二区图片| 欧美日韩专区在线| 综合久久国产九一剧情麻豆| 国产一区美女在线| 欧美一级片在线看| 日韩成人午夜精品| 欧美日韩一区视频| 亚洲欧美经典视频| av亚洲精华国产精华精| 国产人妖乱国产精品人妖| 久久精品国产久精国产| 欧美高清精品3d| 亚洲成av人综合在线观看| 色诱亚洲精品久久久久久| 日本一区二区动态图| 国产在线精品免费av| 亚洲欧美色图小说| 高清视频一区二区| 国产日韩精品一区| 国产黄人亚洲片| 亚洲精品一区二区三区精华液 | 最新国产の精品合集bt伙计| 国产在线精品不卡| 久久精品一区蜜桃臀影院| 国产一区二区三区| 久久久久久影视| 国产99久久久国产精品| 国产精品网站导航| 91免费版在线看| 一区二区三区色| 欧美日韩三级在线| 欧美aa在线视频| 精品久久人人做人人爽| 国产精品一区不卡| 国产精品不卡一区二区三区| 99国内精品久久| 亚洲最新视频在线观看| 欧美精品电影在线播放| 蜜桃视频一区二区三区在线观看| 欧美电影免费观看高清完整版在线 | 国产精品欧美极品| 成人高清在线视频| 一区二区三区精密机械公司| 欧美日韩在线播放三区四区| 亚洲成a人v欧美综合天堂| 91.com视频| 国产一区二区女| 亚洲三级久久久| 欧美日本精品一区二区三区| 美腿丝袜一区二区三区| 国产婷婷色一区二区三区在线| 成人免费av在线| 午夜在线电影亚洲一区| 久久综合九色综合97_久久久| 成人午夜免费电影| 亚洲国产综合在线| 国产日韩欧美电影| 欧美日韩国产小视频在线观看| 麻豆freexxxx性91精品| 国产精品毛片久久久久久| 欧洲生活片亚洲生活在线观看| 奇米一区二区三区| 中文字幕日本乱码精品影院| 欧美日本国产视频| 成人国产精品免费| 麻豆精品久久久| 亚洲欧美在线观看| 欧美r级电影在线观看| 一本色道a无线码一区v| 国产在线日韩欧美| 香蕉久久夜色精品国产使用方法| 精品久久一二三区| 欧美日韩国产另类不卡| www.激情成人| 精品一区二区影视| 亚洲一二三专区| 日本一区二区三区视频视频| 欧美日本韩国一区二区三区视频 | 欧洲精品一区二区| 国产精品99久久久| 蜜臀av一区二区在线观看| 亚洲色图另类专区| 日本一区二区三区免费乱视频| 欧美精品丝袜中出| 色婷婷综合久久久久中文| 国产剧情一区二区| 久久99久久精品| 视频一区欧美日韩| 亚洲愉拍自拍另类高清精品| 国产精品久久毛片av大全日韩| 日韩一区和二区| 欧美日韩日日摸| 日本乱人伦aⅴ精品| 成人黄色小视频在线观看| 国产呦精品一区二区三区网站| 丝瓜av网站精品一区二区| 一区二区三区丝袜| 一区二区三区在线视频播放| 亚洲图片另类小说| 专区另类欧美日韩| 1024国产精品| 中文字幕人成不卡一区| 中文字幕精品—区二区四季| 精品成人一区二区三区四区| 日韩一级片在线播放| 91精品国产美女浴室洗澡无遮挡| 欧美色综合网站| 欧美私人免费视频| 欧美日韩精品福利| 日韩一区二区三区在线| 91精品国产综合久久精品图片| 欧美日韩久久久久久| 91 com成人网| 26uuu欧美日本| 中文字幕精品一区二区三区精品| 国产视频一区在线播放| 亚洲国产成人私人影院tom| 欧美韩国一区二区| 亚洲欧美综合在线精品| 中文字幕亚洲欧美在线不卡| 亚洲欧洲99久久| 亚洲成人动漫在线观看| 老司机免费视频一区二区| 国产精品综合久久| 99riav久久精品riav| 欧美性生活影院| 欧美一区二区三区在线看| 337p日本欧洲亚洲大胆精品| 久久久99免费| 亚洲欧美国产毛片在线| 三级一区在线视频先锋| 久久99久久99小草精品免视看| 国产精品亚洲第一| 色欧美88888久久久久久影院| 欧美日韩免费电影| 国产亚洲福利社区一区| 一区二区高清免费观看影视大全| 免费观看30秒视频久久| 成a人片国产精品| 欧美老肥妇做.爰bbww| 久久品道一品道久久精品| 亚洲精品视频在线观看网站| 免费高清在线视频一区·| 成人午夜av电影| 91精品国产色综合久久久蜜香臀| 久久综合久久久久88| 亚洲激情综合网| 国精产品一区一区三区mba视频 | 一个色综合网站| 麻豆精品精品国产自在97香蕉| 成人av动漫网站| 日韩欧美一区二区视频| 亚洲欧美视频一区| 久久国产人妖系列| 在线观看视频一区| 久久久久久久久岛国免费| 亚洲国产日产av| eeuss鲁片一区二区三区在线观看| 欧美军同video69gay| 中文字幕一区二区三区精华液| 久久av老司机精品网站导航| 欧美写真视频网站| 国产精品成人免费在线| 久久精品999| 欧美精品在线一区二区| 亚洲男人天堂av| 粉嫩aⅴ一区二区三区四区| 日韩女同互慰一区二区| 亚洲国产日韩a在线播放性色| jlzzjlzz亚洲女人18| 欧美电影免费观看完整版| 亚洲电影中文字幕在线观看| 北条麻妃国产九九精品视频| 精品国产91洋老外米糕| 日本不卡123| 欧美美女黄视频| 亚洲在线免费播放| 91麻豆免费观看| 亚洲视频中文字幕| av在线播放成人| 国产精品不卡视频| proumb性欧美在线观看| 国产精品伦一区| 成人黄色网址在线观看| 国产精品乱码一区二区三区软件 | 老司机一区二区| 日韩亚洲欧美高清| 麻豆免费精品视频| 欧美一级专区免费大片| 日本中文字幕一区二区视频| 7777女厕盗摄久久久|