⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nand.patch

📁 patches for linux-2.6.
💻 PATCH
📖 第 1 页 / 共 2 页
字号:
diff -rwbupN linux26-cvs/drivers/mtd/nand/au1550nd.c linux26-nand/drivers/mtd/nand/au1550nd.c--- linux26-cvs/drivers/mtd/nand/au1550nd.c	2005-06-14 23:48:19.000000000 -0500+++ linux26-nand/drivers/mtd/nand/au1550nd.c	2005-06-15 00:04:17.000000000 -0500@@ -3,7 +3,7 @@  *  *  Copyright (C) 2004 Embedded Edge, LLC  *- * $Id: au1550nd.c,v 1.11 2004/11/04 12:53:10 gleixner Exp $+ * $Id: au1550nd.c,v 1.4 2004/05/12 06:23:58 ppopov Exp $  *  * This program is free software; you can redistribute it and/or modify  * it under the terms of the GNU General Public License version 2 as@@ -18,359 +18,280 @@ #include <linux/mtd/nand.h> #include <linux/mtd/partitions.h> #include <asm/io.h>--/* fixme: this is ugly */-#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 0) #include <asm/mach-au1x00/au1000.h>+ #ifdef CONFIG_MIPS_PB1550-#include <asm/mach-pb1x00/pb1550.h> +#include <asm/pb1550.h>+#define NAND_STCFG  0x00400005 /* 8-bit NAND */+#define NAND_STTIME 0x00007774 /* valid for 396MHz SD=2 only */+#define NAND_STADDR 0x12000FFF /* physical address 0x20000000 */ #endif+ #ifdef CONFIG_MIPS_DB1550-#include <asm/mach-db1x00/db1x00.h> +#define NAND_CS 1+#define NAND_STCFG  0x00400005 /* 8-bit NAND */+#define NAND_STTIME 0x00007774 /* valid for 396MHz SD=2 only */+#define NAND_STADDR 0x12000FFF /* physical address 0x20000000 */ #endif-#else-#include <asm/au1000.h>-#ifdef CONFIG_MIPS_PB1550-#include <asm/pb1550.h> ++#ifdef CONFIG_MIPS_PB1200+#define NAND_CS 1 #endif-#ifdef CONFIG_MIPS_DB1550-#include <asm/db1x00.h> ++#ifdef CONFIG_MIPS_DB1200+#define NAND_CS 1 #endif++#ifndef NAND_CS+#error "NAND_CS must be defined as 0, 1, 2 or 3, as appropriate" #endif + /*  * MTD structure for NAND controller  */-static struct mtd_info *au1550_mtd = NULL;-static void __iomem *p_nand;-static int nand_width = 1; /* default x8*/--#define NAND_CS 1+static struct mtd_info *au1xxx_nand_mtd = NULL;+static volatile u32 p_nand;+static int nand_width = 1; /* default, only x8 supported for now */++/* Internal buffers. Page buffer and oob buffer for one block*/+static u_char data_buf[512 + 16];+static u_char oob_buf[16 * 32];  /*  * Define partitions for flash device  */ const static struct mtd_partition partition_info[] = {-#ifdef CONFIG_MIPS_PB1550-#define NUM_PARTITIONS            2 	{ -		.name = "Pb1550 NAND FS 0",+		.name = "NAND FS 0", 	  	.offset = 0, 	  	.size = 8*1024*1024  	}, 	{ -		.name = "Pb1550 NAND FS 1",+		.name = "NAND FS 1", 		.offset =  MTDPART_OFS_APPEND,  		.size =    MTDPART_SIZ_FULL 	}-#endif-#ifdef CONFIG_MIPS_DB1550-#define NUM_PARTITIONS            2-	{ -		.name = "Db1550 NAND FS 0",-	  	.offset = 0,-	  	.size = 8*1024*1024 -	},-	{ -		.name = "Db1550 NAND FS 1",-		.offset =  MTDPART_OFS_APPEND,- 		.size =    MTDPART_SIZ_FULL-	}-#endif };+#define NB_OF(x)  (sizeof(x)/sizeof(x[0])) --/**- * au_read_byte -  read one byte from the chip- * @mtd:	MTD device structure- *- *  read function for 8bit buswith- */-static u_char au_read_byte(struct mtd_info *mtd)+static inline void write_cmd_reg(u8 cmd) {-	struct nand_chip *this = mtd->priv;-	u_char ret = readb(this->IO_ADDR_R);+	if (nand_width)+		*((volatile u8 *)(p_nand + MEM_STNAND_CMD)) = cmd;+	else+		*((volatile u16 *)(p_nand + MEM_STNAND_CMD)) = cmd; 	au_sync();-	return ret; } -/**- * au_write_byte -  write one byte to the chip- * @mtd:	MTD device structure- * @byte:	pointer to data byte to write- *- *  write function for 8it buswith- */-static void au_write_byte(struct mtd_info *mtd, u_char byte)+static inline void write_addr_reg(u8 addr) {-	struct nand_chip *this = mtd->priv;-	writeb(byte, this->IO_ADDR_W);+	if (nand_width)+		*((volatile u8 *)(p_nand + MEM_STNAND_ADDR)) = addr;+	else+		*((volatile u16 *)(p_nand + MEM_STNAND_ADDR)) = addr; 	au_sync(); } -/**- * au_read_byte16 -  read one byte endianess aware from the chip- * @mtd:	MTD device structure- *- *  read function for 16bit buswith with - * endianess conversion- */-static u_char au_read_byte16(struct mtd_info *mtd)+static inline void write_data_reg(u8 data) {-	struct nand_chip *this = mtd->priv;-	u_char ret = (u_char) cpu_to_le16(readw(this->IO_ADDR_R));+	if (nand_width)+		*((volatile u8 *)(p_nand + MEM_STNAND_DATA)) = data;+	else+		*((volatile u16 *)(p_nand + MEM_STNAND_DATA)) = data; 	au_sync();-	return ret; } -/**- * au_write_byte16 -  write one byte endianess aware to the chip- * @mtd:	MTD device structure- * @byte:	pointer to data byte to write- *- *  write function for 16bit buswith with- * endianess conversion- */-static void au_write_byte16(struct mtd_info *mtd, u_char byte)+static inline u32 read_data_reg(void) {-	struct nand_chip *this = mtd->priv;-	writew(le16_to_cpu((u16) byte), this->IO_ADDR_W);+	u32 data;+	if (nand_width) {+		data = *((volatile u8 *)(p_nand + MEM_STNAND_DATA)); 	au_sync(); }--/**- * au_read_word -  read one word from the chip- * @mtd:	MTD device structure- *- *  read function for 16bit buswith without - * endianess conversion- */-static u16 au_read_word(struct mtd_info *mtd)-{-	struct nand_chip *this = mtd->priv;-	u16 ret = readw(this->IO_ADDR_R);+	else {+		data = *((volatile u16 *)(p_nand + MEM_STNAND_DATA)); 	au_sync();-	return ret; }--/**- * au_write_word -  write one word to the chip- * @mtd:	MTD device structure- * @word:	data word to write- *- *  write function for 16bit buswith without - * endianess conversion- */-static void au_write_word(struct mtd_info *mtd, u16 word)-{-	struct nand_chip *this = mtd->priv;-	writew(word, this->IO_ADDR_W);-	au_sync();+	return data; } -/**- * au_write_buf -  write buffer to chip- * @mtd:	MTD device structure- * @buf:	data buffer- * @len:	number of bytes to write- *- *  write function for 8bit buswith- */-static void au_write_buf(struct mtd_info *mtd, const u_char *buf, int len)+void au1xxx_hwcontrol(struct mtd_info *mtd, int cmd) {-	int i;-	struct nand_chip *this = mtd->priv;--	for (i=0; i<len; i++) {-		writeb(buf[i], this->IO_ADDR_W);-		au_sync();-	} } -/**- * au_read_buf -  read chip data into buffer - * @mtd:	MTD device structure- * @buf:	buffer to store date- * @len:	number of bytes to read- *- *  read function for 8bit buswith- */-static void au_read_buf(struct mtd_info *mtd, u_char *buf, int len)+int au1xxx_device_ready(struct mtd_info *mtd) {-	int i;-	struct nand_chip *this = mtd->priv;--	for (i=0; i<len; i++) {-		buf[i] = readb(this->IO_ADDR_R);-		au_sync();	-	}+	int ready;+	ready = (au_readl(MEM_STSTAT) & 0x1) ? 1 : 0;+	return ready; } -/**- * au_verify_buf -  Verify chip data against buffer - * @mtd:	MTD device structure- * @buf:	buffer containing the data to compare- * @len:	number of bytes to compare- *- *  verify function for 8bit buswith- */-static int au_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)+static u_char au1xxx_nand_read_byte(struct mtd_info *mtd) {-	int i;-	struct nand_chip *this = mtd->priv;--	for (i=0; i<len; i++) {-		if (buf[i] != readb(this->IO_ADDR_R))-			return -EFAULT;-		au_sync();+	u_char ret;+	ret = read_data_reg();+	return ret; 	} -	return 0;+static void au1xxx_nand_write_byte(struct mtd_info *mtd, u_char byte)+{+	write_data_reg((u8)byte); } -/**- * au_write_buf16 -  write buffer to chip- * @mtd:	MTD device structure- * @buf:	data buffer- * @len:	number of bytes to write- *- *  write function for 16bit buswith- */-static void au_write_buf16(struct mtd_info *mtd, const u_char *buf, int len)+static void+au1xxx_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) { 	int i;-	struct nand_chip *this = mtd->priv;-	u16 *p = (u16 *) buf;-	len >>= 1;-	-	for (i=0; i<len; i++) {-		writew(p[i], this->IO_ADDR_W);-		au_sync();-	} 		+	for (i=0; i<len; i++)+		write_data_reg(buf[i]); } -/**- * au_read_buf16 -  read chip data into buffer - * @mtd:	MTD device structure- * @buf:	buffer to store date- * @len:	number of bytes to read- *- *  read function for 16bit buswith- */-static void au_read_buf16(struct mtd_info *mtd, u_char *buf, int len)+static void+au1xxx_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) { 	int i;-	struct nand_chip *this = mtd->priv;-	u16 *p = (u16 *) buf;-	len >>= 1; -	for (i=0; i<len; i++) {-		p[i] = readw(this->IO_ADDR_R);-		au_sync();-	}+	for (i=0; i<len; i++)+		buf[i] = (u_char)read_data_reg(); } -/**- * au_verify_buf16 -  Verify chip data against buffer - * @mtd:	MTD device structure- * @buf:	buffer containing the data to compare- * @len:	number of bytes to compare- *- *  verify function for 16bit buswith- */-static int au_verify_buf16(struct mtd_info *mtd, const u_char *buf, int len)+static int+au1xxx_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len) { 	int i;-	struct nand_chip *this = mtd->priv;-	u16 *p = (u16 *) buf;-	len >>= 1; -	for (i=0; i<len; i++) {-		if (p[i] != readw(this->IO_ADDR_R))+	for (i=0; i<len; i++)+		if (buf[i] != (u_char)read_data_reg()) 			return -EFAULT;-		au_sync();-	}+

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -