diff options
author | florian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2007-04-17 22:15:50 +0000 |
---|---|---|
committer | florian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2007-04-17 22:15:50 +0000 |
commit | 54a10cd62697ff67ad261902837907da6aa49b37 (patch) | |
tree | c1f92299b024dea5b692df58c7ed722e1c7ce5c4 /target | |
parent | bd5a76636d71f9fcb0ea37bb799f9f96d6cb29a9 (diff) |
Move NAND driver from rb1xx to adm5120, rbmipsnand fixed by David Goodenough, thanks !
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@6991 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
-rw-r--r-- | target/linux/adm5120-2.6/config/default | 20 | ||||
-rw-r--r-- | target/linux/adm5120-2.6/files/drivers/mtd/nand/rbmipsnand.c | 111 | ||||
-rw-r--r-- | target/linux/adm5120-2.6/patches/500-Nand.patch | 29 |
3 files changed, 158 insertions, 2 deletions
diff --git a/target/linux/adm5120-2.6/config/default b/target/linux/adm5120-2.6/config/default index 1643d5bd5..38400b935 100644 --- a/target/linux/adm5120-2.6/config/default +++ b/target/linux/adm5120-2.6/config/default @@ -138,7 +138,7 @@ CONFIG_MTD=y # CONFIG_MTD_ABSENT is not set CONFIG_MTD_ADM5120=y CONFIG_MTD_BLOCK=y -# CONFIG_MTD_BLOCK2MTD is not set +CONFIG_MTD_BLOCK2MTD=y CONFIG_MTD_CFI=y # CONFIG_MTD_CFI_ADV_OPTIONS is not set CONFIG_MTD_CFI_AMDSTD=y @@ -168,6 +168,13 @@ CONFIG_MTD_MAP_BANK_WIDTH_4=y # CONFIG_MTD_MAP_BANK_WIDTH_8 is not set # CONFIG_MTD_MTDRAM is not set CONFIG_MTD_MYLOADER_PARTS=y +CONFIG_MTD_NAND=y +# CONFIG_MTD_NAND_DISKONCHIP is not set +# CONFIG_MTD_NAND_ECC_SMC is not set +CONFIG_MTD_NAND_IDS=y +# CONFIG_MTD_NAND_NANDSIM is not set +CONFIG_MTD_NAND_RB100=y +# CONFIG_MTD_NAND_VERIFY_WRITE is not set # CONFIG_MTD_OBSOLETE_CHIPS is not set # CONFIG_MTD_ONENAND is not set CONFIG_MTD_PARTITIONS=y @@ -178,7 +185,6 @@ CONFIG_MTD_PARTITIONS=y # CONFIG_MTD_PMC551 is not set # CONFIG_MTD_RAM is not set # CONFIG_MTD_REDBOOT_PARTS is not set -CONFIG_MTD_MYLOADER_PARTS=y # CONFIG_MTD_ROM is not set # CONFIG_MTD_SLRAM is not set CONFIG_NETFILTER_XT_MATCH_QUOTA=m @@ -233,6 +239,7 @@ CONFIG_SYN_COOKIES=y CONFIG_SYS_HAS_CPU_MIPS32_R1=y CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y CONFIG_SYS_SUPPORTS_ARBIT_HZ=y +CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y CONFIG_TMPFS_POSIX_ACL=y # CONFIG_TOSHIBA_JMR3927 is not set @@ -259,4 +266,13 @@ CONFIG_USB_ADM5120_HCD=y # CONFIG_USB_USBNET_MII is not set # CONFIG_USB_ZD1201 is not set CONFIG_VM_EVENT_COUNTERS=y +# CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED is not set +CONFIG_YAFFS_AUTO_YAFFS2=y +# CONFIG_YAFFS_DISABLE_LAZY_LOAD is not set +# CONFIG_YAFFS_DISABLE_WIDE_TNODES is not set +# CONFIG_YAFFS_DOES_ECC is not set +CONFIG_YAFFS_FS=y +CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y +CONFIG_YAFFS_YAFFS1=y +CONFIG_YAFFS_YAFFS2=y # CONFIG_ZD1211RW is not set diff --git a/target/linux/adm5120-2.6/files/drivers/mtd/nand/rbmipsnand.c b/target/linux/adm5120-2.6/files/drivers/mtd/nand/rbmipsnand.c new file mode 100644 index 000000000..f08655290 --- /dev/null +++ b/target/linux/adm5120-2.6/files/drivers/mtd/nand/rbmipsnand.c @@ -0,0 +1,111 @@ +/*==============================================================================*/ +/* rbmipsnand.c */ +/* This module is derived from the 2.4 driver shipped by Microtik for their */ +/* Routerboard 1xx and 5xx series boards. It provides support for the built in */ +/* NAND flash on the Routerboard 1xx series boards for Linux 2.6.19+. */ +/* Licence: Original Microtik code seems not to have a licence. */ +/* Rewritten code all GPL V2. */ +/* Copyright(C) 2007 david.goodenough@linkchoose.co.uk (for rewriten code) */ +/*==============================================================================*/ + +#include <linux/init.h> +#include <linux/mtd/nand.h> +#include <linux/mtd/mtd.h> +#include <linux/mtd/partitions.h> +#include <linux/delay.h> +#include <asm/io.h> +#include <asm/irq.h> +#include <asm/bootinfo.h> + +#define SMEM1_BASE 0x10000000 // from ADM5120 documentation +#define SMEM1(x) (*((volatile unsigned char *) (KSEG1ADDR(SMEM1_BASE) + x))) + +#define NAND_RW_REG 0x0 //data register +#define NAND_SET_CEn 0x1 //CE# low +#define NAND_CLR_CEn 0x2 //CE# high +#define NAND_CLR_CLE 0x3 //CLE low +#define NAND_SET_CLE 0x4 //CLE high +#define NAND_CLR_ALE 0x5 //ALE low +#define NAND_SET_ALE 0x6 //ALE high +#define NAND_SET_SPn 0x7 //SP# low (use spare area) +#define NAND_CLR_SPn 0x8 //SP# high (do not use spare area) +#define NAND_SET_WPn 0x9 //WP# low +#define NAND_CLR_WPn 0xA //WP# high +#define NAND_STS_REG 0xB //Status register + +#define MEM32(x) *((volatile unsigned *) (x)) +static void __iomem *p_nand; + +static int rb100_dev_ready(struct mtd_info *mtd) { + return SMEM1(NAND_STS_REG) & 0x80; +} + +static void rbmips_hwcontrol100(struct mtd_info *mtd, int cmd, unsigned int ctrl) { + struct nand_chip *chip = mtd->priv; + if (ctrl & NAND_CTRL_CHANGE) { + SMEM1((( ctrl & NAND_CLE) ? NAND_SET_CLE : NAND_CLR_CLE)) = 0x01; + SMEM1((( ctrl & NAND_ALE) ? NAND_SET_ALE : NAND_CLR_ALE)) = 0x01; + SMEM1((( ctrl & NAND_NCE) ? NAND_SET_CEn : NAND_CLR_CEn)) = 0x01; + } + if( cmd != NAND_CMD_NONE) + writeb( cmd, chip->IO_ADDR_W); +} + +static struct mtd_partition partition_info[] = { + { + name: "RouterBoard NAND Boot", + offset: 0, + size: 4 * 1024 * 1024 + }, + { + name: "RouterBoard NAND Main", + offset: MTDPART_OFS_NXTBLK, + size: MTDPART_SIZ_FULL + } +}; + +static struct mtd_info rmtd; +static struct nand_chip rnand; + +static unsigned init_ok = 0; + +unsigned get_rbnand_block_size(void) { + return init_ok ? rmtd.writesize : 0; +} + +EXPORT_SYMBOL(get_rbnand_block_size); + +int __init rbmips_init(void) { + memset(&rmtd, 0, sizeof(rmtd)); + memset(&rnand, 0, sizeof(rnand)); + printk("RB1xx nand\n"); + MEM32(0xB2000064) = 0x100; + MEM32(0xB2000008) = 0x1; + SMEM1(NAND_SET_SPn) = 0x01; + SMEM1(NAND_CLR_WPn) = 0x01; + rnand.IO_ADDR_R = (unsigned char *)KSEG1ADDR(SMEM1_BASE); + rnand.IO_ADDR_W = rnand.IO_ADDR_R; + rnand.cmd_ctrl = rbmips_hwcontrol100; + rnand.dev_ready = rb100_dev_ready; + p_nand = (void __iomem *)ioremap(( unsigned long)SMEM1_BASE, 0x1000); + if (!p_nand) { + printk("RB1xx nand Unable ioremap buffer"); + return -ENXIO; + } + rnand.ecc.mode = NAND_ECC_SOFT; + rnand.chip_delay = 25; + rnand.options |= NAND_NO_AUTOINCR; + rmtd.priv = &rnand; + if (nand_scan(&rmtd, 1) && nand_scan(&rmtd, 1) + && nand_scan(&rmtd, 1) && nand_scan(&rmtd, 1)) { + printk("RB1xxx nand device not found"); + iounmap ((void *)p_nand); + return -ENXIO; + } + add_mtd_partitions(&rmtd, partition_info, 2); + init_ok = 1; + return 0; +} + +module_init(rbmips_init); + diff --git a/target/linux/adm5120-2.6/patches/500-Nand.patch b/target/linux/adm5120-2.6/patches/500-Nand.patch new file mode 100644 index 000000000..05beb2024 --- /dev/null +++ b/target/linux/adm5120-2.6/patches/500-Nand.patch @@ -0,0 +1,29 @@ +diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig +index cfe288a..c528024 100644 +--- a/drivers/mtd/nand/Kconfig ++++ b/drivers/mtd/nand/Kconfig +@@ -55,6 +55,12 @@ config MTD_NAND_TOTO + help + Support for NAND flash on Texas Instruments Toto platform. + ++config MTD_NAND_RB100 ++ tristate "NAND Flash device on RB100 board" ++ depends on MTD_NAND ++ help ++ Support for NAND flash on RB100 platform. ++ + config MTD_NAND_IDS + tristate + +diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile +index 4174202..2be57c1 100644 +--- a/drivers/mtd/nand/Makefile ++++ b/drivers/mtd/nand/Makefile +@@ -8,6 +8,7 @@ obj-$(CONFIG_MTD_NAND_IDS) += nand_ids. + + obj-$(CONFIG_MTD_NAND_SPIA) += spia.o + obj-$(CONFIG_MTD_NAND_TOTO) += toto.o ++obj-$(CONFIG_MTD_NAND_RB100) += rbmipsnand.o + obj-$(CONFIG_MTD_NAND_AUTCPU12) += autcpu12.o + obj-$(CONFIG_MTD_NAND_EDB7312) += edb7312.o + obj-$(CONFIG_MTD_NAND_AU1550) += au1550nd.o |