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

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

?? s3c2410.c

?? 宋寶華的《Linux設備驅動開發詳解》第一版的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* linux/drivers/mtd/nand/s3c2410.c * * Copyright (c) 2004,2005 Simtec Electronics *	http://www.simtec.co.uk/products/SWLINUX/ *	Ben Dooks <ben@simtec.co.uk> * * Samsung S3C2410/S3C240 NAND driver * * Changelog: *	21-Sep-2004  BJD  Initial version *	23-Sep-2004  BJD  Mulitple device support *	28-Sep-2004  BJD  Fixed ECC placement for Hardware mode *	12-Oct-2004  BJD  Fixed errors in use of platform data *	18-Feb-2005  BJD  Fix sparse errors *	14-Mar-2005  BJD  Applied tglx's code reduction patch *	02-May-2005  BJD  Fixed s3c2440 support *	02-May-2005  BJD  Reduced hwcontrol decode *	20-Jun-2005  BJD  Updated s3c2440 support, fixed timing bug *	08-Jul-2005  BJD  Fix OOPS when no platform data supplied *	20-Oct-2005  BJD  Fix timing calculation bug * * $Id: s3c2410.c,v 1.20 2005/11/07 11:14:31 gleixner Exp $ * * 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*/#include <config/mtd/nand/s3c2410/hwecc.h>#include <config/mtd/nand/s3c2410/debug.h>#ifdef CONFIG_MTD_NAND_S3C2410_DEBUG#define DEBUG#endif#include <linux/module.h>#include <linux/types.h>#include <linux/init.h>#include <linux/kernel.h>#include <linux/string.h>#include <linux/ioport.h>#include <linux/platform_device.h>#include <linux/delay.h>#include <linux/err.h>#include <linux/slab.h>#include <linux/clk.h>#include <linux/mtd/mtd.h>#include <linux/mtd/nand.h>#include <linux/mtd/nand_ecc.h>#include <linux/mtd/partitions.h>#include <asm/io.h>#include <asm/arch/regs-nand.h>#include <asm/arch/nand.h>#define PFX "s3c2410-nand: "#ifdef CONFIG_MTD_NAND_S3C2410_HWECCstatic int hardware_ecc = 1;#elsestatic int hardware_ecc = 0;#endif/* new oob placement block for use with hardware ecc generation */static struct nand_oobinfo nand_hw_eccoob = {	.useecc		= MTD_NANDECC_AUTOPLACE,	.eccbytes	= 3,	.eccpos		= {0, 1, 2 },	.oobfree	= { {8, 8} }};/* controller and mtd information */struct s3c2410_nand_info;struct s3c2410_nand_mtd {	struct mtd_info			mtd;	struct nand_chip		chip;	struct s3c2410_nand_set		*set;	struct s3c2410_nand_info	*info;	int				scan_res;};/* overview of the s3c2410 nand state */struct s3c2410_nand_info {	/* mtd info */	struct nand_hw_control		controller;	struct s3c2410_nand_mtd		*mtds;	struct s3c2410_platform_nand	*platform;	/* device info */	struct device			*device;	struct resource			*area;	struct clk			*clk;	void __iomem			*regs;	int				mtd_count;	unsigned char			is_s3c2440;};/* conversion functions */static struct s3c2410_nand_mtd *s3c2410_nand_mtd_toours(struct mtd_info *mtd){	return container_of(mtd, struct s3c2410_nand_mtd, mtd);}static struct s3c2410_nand_info *s3c2410_nand_mtd_toinfo(struct mtd_info *mtd){	return s3c2410_nand_mtd_toours(mtd)->info;}static struct s3c2410_nand_info *to_nand_info(struct platform_device *dev){	return platform_get_drvdata(dev);}static struct s3c2410_platform_nand *to_nand_plat(struct platform_device *dev){	return dev->dev.platform_data;}/* timing calculations */#define NS_IN_KHZ 1000000static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max){	int result;	result = (wanted * clk) / NS_IN_KHZ;	result++;	pr_debug("result %d from %ld, %d\n", result, clk, wanted);	if (result > max) {		printk("%d ns is too big for current clock rate %ld\n",		       wanted, clk);		return -1;	}	if (result < 1)		result = 1;	return result;}#define to_ns(ticks,clk) (((ticks) * NS_IN_KHZ) / (unsigned int)(clk))/* controller setup */static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,			       struct platform_device *pdev){	struct s3c2410_platform_nand *plat = to_nand_plat(pdev);	unsigned long clkrate = clk_get_rate(info->clk);	int tacls, twrph0, twrph1;	unsigned long cfg;	/* calculate the timing information for the controller */	clkrate /= 1000;	/* turn clock into kHz for ease of use */	if (plat != NULL) {		tacls  = s3c2410_nand_calc_rate(plat->tacls, clkrate, 4);		twrph0 = s3c2410_nand_calc_rate(plat->twrph0, clkrate, 8);		twrph1 = s3c2410_nand_calc_rate(plat->twrph1, clkrate, 8);	} else {		/* default timings */		tacls = 4;		twrph0 = 8;		twrph1 = 8;	}	if (tacls < 0 || twrph0 < 0 || twrph1 < 0) {		printk(KERN_ERR PFX "cannot get timings suitable for board\n");		return -EINVAL;	}	printk(KERN_INFO PFX "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns\n",	       tacls, to_ns(tacls, clkrate),	       twrph0, to_ns(twrph0, clkrate),	       twrph1, to_ns(twrph1, clkrate));	if (!info->is_s3c2440) {		cfg  = S3C2410_NFCONF_EN;		cfg |= S3C2410_NFCONF_TACLS(tacls-1);		cfg |= S3C2410_NFCONF_TWRPH0(twrph0-1);		cfg |= S3C2410_NFCONF_TWRPH1(twrph1-1);	} else {		cfg   = S3C2440_NFCONF_TACLS(tacls-1);		cfg  |= S3C2440_NFCONF_TWRPH0(twrph0-1);		cfg  |= S3C2440_NFCONF_TWRPH1(twrph1-1);	}	pr_debug(PFX "NF_CONF is 0x%lx\n", cfg);	writel(cfg, info->regs + S3C2410_NFCONF);	return 0;}/* select chip */static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip){	struct s3c2410_nand_info *info;	struct s3c2410_nand_mtd *nmtd;	struct nand_chip *this = mtd->priv;	void __iomem *reg;	unsigned long cur;	unsigned long bit;	nmtd = this->priv;	info = nmtd->info;	bit = (info->is_s3c2440) ? S3C2440_NFCONT_nFCE : S3C2410_NFCONF_nFCE;	reg = info->regs+((info->is_s3c2440) ? S3C2440_NFCONT:S3C2410_NFCONF);	cur = readl(reg);	if (chip == -1) {		cur |= bit;	} else {		if (nmtd->set != NULL && chip > nmtd->set->nr_chips) {			printk(KERN_ERR PFX "chip %d out of range\n", chip);			return;		}		if (info->platform != NULL) {			if (info->platform->select_chip != NULL)				(info->platform->select_chip)(nmtd->set, chip);		}		cur &= ~bit;	}	writel(cur, reg);}/* command and control functions * * Note, these all use tglx's method of changing the IO_ADDR_W field * to make the code simpler, and use the nand layer's code to issue the * command and address sequences via the proper IO ports. **/static void s3c2410_nand_hwcontrol(struct mtd_info *mtd, int cmd){	struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);	struct nand_chip *chip = mtd->priv;	switch (cmd) {	case NAND_CTL_SETNCE:	case NAND_CTL_CLRNCE:		printk(KERN_ERR "%s: called for NCE\n", __FUNCTION__);		break;	case NAND_CTL_SETCLE:		chip->IO_ADDR_W = info->regs + S3C2410_NFCMD;		break;	case NAND_CTL_SETALE:		chip->IO_ADDR_W = info->regs + S3C2410_NFADDR;		break;		/* NAND_CTL_CLRCLE: */		/* NAND_CTL_CLRALE: */	default:		chip->IO_ADDR_W = info->regs + S3C2410_NFDATA;		break;	}}/* command and control functions */static void s3c2440_nand_hwcontrol(struct mtd_info *mtd, int cmd){	struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);	struct nand_chip *chip = mtd->priv;	switch (cmd) {	case NAND_CTL_SETNCE:	case NAND_CTL_CLRNCE:		printk(KERN_ERR "%s: called for NCE\n", __FUNCTION__);		break;	case NAND_CTL_SETCLE:		chip->IO_ADDR_W = info->regs + S3C2440_NFCMD;		break;	case NAND_CTL_SETALE:		chip->IO_ADDR_W = info->regs + S3C2440_NFADDR;		break;		/* NAND_CTL_CLRCLE: */		/* NAND_CTL_CLRALE: */	default:		chip->IO_ADDR_W = info->regs + S3C2440_NFDATA;		break;	}}/* s3c2410_nand_devready() * * returns 0 if the nand is busy, 1 if it is ready*/static int s3c2410_nand_devready(struct mtd_info *mtd){	struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);	if (info->is_s3c2440)		return readb(info->regs + S3C2440_NFSTAT) & S3C2440_NFSTAT_READY;	return readb(info->regs + S3C2410_NFSTAT) & S3C2410_NFSTAT_BUSY;}/* ECC handling functions */static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,				     u_char *read_ecc, u_char *calc_ecc){	pr_debug("s3c2410_nand_correct_data(%p,%p,%p,%p)\n",		 mtd, dat, read_ecc, calc_ecc);	pr_debug("eccs: read %02x,%02x,%02x vs calc %02x,%02x,%02x\n",		 read_ecc[0], read_ecc[1], read_ecc[2],		 calc_ecc[0], calc_ecc[1], calc_ecc[2]);	if (read_ecc[0] == calc_ecc[0] &&	    read_ecc[1] == calc_ecc[1] &&	    read_ecc[2] == calc_ecc[2])		return 0;	/* we curently have no method for correcting the error */	return -1;}/* ECC functions * * These allow the s3c2410 and s3c2440 to use the controller's ECC * generator block to ECC the data as it passes through]*/static void s3c2410_nand_enable_hwecc(struct mtd_info *mtd, int mode){	struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);	unsigned long ctrl;	ctrl = readl(info->regs + S3C2410_NFCONF);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一区二区电影在线| 日本午夜一区二区| 日韩高清国产一区在线| 国产999精品久久久久久绿帽| 在线区一区二视频| 国产精品色一区二区三区| 婷婷国产在线综合| 色婷婷久久综合| 国产精品另类一区| 国产乱码精品1区2区3区| 欧美剧情电影在线观看完整版免费励志电影| 久久天堂av综合合色蜜桃网| 奇米影视一区二区三区小说| 日本精品一区二区三区高清 | 最新热久久免费视频| 免费精品视频在线| 欧美绝品在线观看成人午夜影视| 亚洲乱码中文字幕| 99久久精品国产精品久久| 国产精品欧美久久久久一区二区| 国产在线麻豆精品观看| 精品免费一区二区三区| 麻豆精品视频在线观看免费| 欧美日韩一区二区不卡| 午夜日韩在线电影| 欧美性色欧美a在线播放| 一区二区三区在线观看欧美| 色综合一区二区三区| 日韩理论片在线| 日本乱码高清不卡字幕| 洋洋成人永久网站入口| 欧洲精品视频在线观看| 亚洲午夜电影在线观看| 欧美精品乱码久久久久久按摩 | 日韩一区二区三区免费看| 午夜伊人狠狠久久| 3atv在线一区二区三区| 蜜桃一区二区三区在线| 日韩欧美成人午夜| 国产精品亚洲人在线观看| 国产午夜精品理论片a级大结局| 国产一区二区伦理| 国产精品系列在线| 日本高清不卡视频| 婷婷丁香久久五月婷婷| 精品美女被调教视频大全网站| 精品中文字幕一区二区小辣椒| 欧美成人三级在线| 成人性生交大片免费看在线播放 | 欧美国产禁国产网站cc| 91女人视频在线观看| 午夜精品福利一区二区三区av| 欧美精品日韩精品| 国产精品亚洲а∨天堂免在线| 中文字幕中文字幕一区| 欧美男男青年gay1069videost| 久久www免费人成看片高清| 国产精品毛片久久久久久久 | 国产不卡视频一区| 亚洲国产日韩精品| 久久久噜噜噜久久中文字幕色伊伊| 成人手机电影网| 天天影视色香欲综合网老头| 精品免费一区二区三区| 91国偷自产一区二区三区观看| 免费成人在线观看| 亚洲欧洲成人自拍| 欧美刺激午夜性久久久久久久| 国产成人午夜高潮毛片| 午夜日韩在线观看| 亚洲图片激情小说| 久久久久久久久伊人| 欧美日韩亚洲高清一区二区| 国产成人啪午夜精品网站男同| 亚洲成av人片一区二区梦乃 | 91丨九色porny丨蝌蚪| 人禽交欧美网站| 亚洲精品福利视频网站| 久久久久久一二三区| 欧美日韩国产乱码电影| 99免费精品在线观看| 国产一区二区视频在线播放| 午夜视频久久久久久| 国产精品大尺度| 久久亚洲一级片| 欧美一区二区三区日韩视频| 91久久精品午夜一区二区| 国产精品88av| 黑人巨大精品欧美黑白配亚洲| 亚洲国产综合色| 亚洲伦理在线免费看| 欧美经典一区二区| 欧美精品一区二区三区蜜桃| 欧美巨大另类极品videosbest | 1024亚洲合集| 中文成人综合网| 国产欧美日韩精品a在线观看| 日韩免费视频一区二区| 欧美日韩国产成人在线免费| 色哟哟精品一区| 91视频www| 91免费小视频| 91麻豆免费在线观看| 不卡的电影网站| 成人精品免费看| 成人污污视频在线观看| 国产成人鲁色资源国产91色综| 国产乱人伦偷精品视频免下载| 精品一区二区三区视频| 日韩av一区二区三区| 日韩电影一二三区| 日韩av电影免费观看高清完整版| 午夜精品福利久久久| 日韩在线a电影| 日本午夜一本久久久综合| 免费成人美女在线观看.| 免费精品视频在线| 韩国精品一区二区| 国产成人在线视频免费播放| 成人av在线网站| 91免费观看视频| 欧美少妇bbb| 日韩精品中午字幕| 国产日韩欧美精品一区| 亚洲天堂中文字幕| 亚洲成人www| 美女视频黄 久久| 国产91富婆露脸刺激对白| 99视频超级精品| 精品视频免费看| 26uuu久久天堂性欧美| 国产精品久久久久久久浪潮网站| 亚洲欧美成aⅴ人在线观看| 亚洲一区二区三区自拍| 日韩电影在线免费看| 国产成人av电影在线| 色综合咪咪久久| 欧美一区二区三区在线电影| 国产日韩欧美制服另类| 亚洲人成在线播放网站岛国| 午夜av电影一区| 国产精品一区二区三区网站| jvid福利写真一区二区三区| 欧美日韩视频第一区| 26uuu国产日韩综合| 亚洲精品国产精品乱码不99| 日本伊人午夜精品| 99麻豆久久久国产精品免费| 欧美麻豆精品久久久久久| 日韩一区二区在线看片| 欧美一区二区三区系列电影| 久久久久国产成人精品亚洲午夜 | 日日夜夜免费精品视频| 精品在线一区二区| 99精品久久只有精品| 日韩一区二区在线观看视频播放| 国产精品乱人伦| 极品少妇一区二区三区精品视频 | 亚洲精品日韩综合观看成人91| 蜜臀va亚洲va欧美va天堂| 99久久精品国产一区二区三区| 欧美日韩在线三级| 国产精品天天看| 免费高清成人在线| 欧美四级电影在线观看| 中文字幕av一区二区三区免费看 | 91欧美激情一区二区三区成人| 日韩欧美二区三区| 亚洲一区二区精品视频| av毛片久久久久**hd| 久久蜜桃av一区二区天堂| 亚洲福利电影网| 色综合久久六月婷婷中文字幕| 久久久亚洲综合| 美女高潮久久久| 91精品国产高清一区二区三区蜜臀| 日本一区二区动态图| 精品一区二区三区日韩| 欧美一级精品大片| 五月婷婷激情综合网| 欧美午夜宅男影院| 亚洲色图20p| 色吊一区二区三区| 亚洲伦理在线精品| 91亚洲精品久久久蜜桃网站| 欧美激情中文不卡| 粉嫩蜜臀av国产精品网站| 久久久久久免费毛片精品| 六月丁香综合在线视频| 欧美一区二区播放| 五月天一区二区| 欧美一区二区视频观看视频| 日韩高清一区在线| 日韩精品在线一区二区| 久久精品国产精品青草| 精品国产一区二区三区久久影院| 美女视频第一区二区三区免费观看网站 | 91精品91久久久中77777| 亚洲欧洲av色图| 在线观看亚洲成人|