diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2012-09-13 07:26:26 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2012-09-13 07:26:26 +0000 |
commit | 76e3187aa217521dac78d0f2c13fee15c4f773ed (patch) | |
tree | 983a04f27a150fca74ce6abb3b7b99ce491937f1 /target | |
parent | 30da844351f93366d4cb5374b05309c033dc1af6 (diff) | |
download | master-187ad058-76e3187aa217521dac78d0f2c13fee15c4f773ed.tar.gz master-187ad058-76e3187aa217521dac78d0f2c13fee15c4f773ed.tar.bz2 master-187ad058-76e3187aa217521dac78d0f2c13fee15c4f773ed.zip |
ar71xx: register the NAND controller device on the RB2011
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@33388 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
4 files changed, 83 insertions, 3 deletions
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-rb2011.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-rb2011.c index 4c7dc6dda9..ecdd7ea2e8 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/mach-rb2011.c +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-rb2011.c @@ -12,15 +12,18 @@ #define pr_fmt(fmt) "rb2011: " fmt #include <linux/phy.h> +#include <linux/delay.h> #include <linux/platform_device.h> #include <linux/ath9k_platform.h> #include <linux/ar8216_platform.h> #include <linux/mtd/mtd.h> +#include <linux/mtd/nand.h> #include <linux/mtd/partitions.h> #include <linux/spi/spi.h> #include <linux/spi/flash.h> #include <linux/rle.h> #include <linux/routerboot.h> +#include <linux/gpio.h> #include <asm/mach-ath79/ath79.h> #include <asm/mach-ath79/ar71xx_regs.h> @@ -28,10 +31,13 @@ #include "common.h" #include "dev-eth.h" #include "dev-m25p80.h" +#include "dev-nfc.h" #include "dev-wmac.h" #include "machtypes.h" #include "routerboot.h" +#define RB2011_GPIO_NAND_NCE 14 + #define RB_ROUTERBOOT_OFFSET 0x0000 #define RB_ROUTERBOOT_SIZE 0xb000 #define RB_HARD_CFG_OFFSET 0xb000 @@ -66,6 +72,25 @@ static struct mtd_partition rb2011_spi_partitions[] = { } }; +static struct mtd_partition rb2011_nand_partitions[] = { + { + .name = "booter", + .offset = 0, + .size = (256 * 1024), + .mask_flags = MTD_WRITEABLE, + }, + { + .name = "kernel", + .offset = (256 * 1024), + .size = (4 * 1024 * 1024) - (256 * 1024), + }, + { + .name = "rootfs", + .offset = MTDPART_OFS_NXTBLK, + .size = MTDPART_SIZ_FULL, + }, +}; + static struct flash_platform_data rb2011_spi_flash_data = { .parts = rb2011_spi_partitions, .nr_parts = ARRAY_SIZE(rb2011_spi_partitions), @@ -151,9 +176,61 @@ free: kfree(art_buf); } +static void rb2011_nand_select_chip(int chip_no) +{ + switch (chip_no) { + case 0: + gpio_set_value(RB2011_GPIO_NAND_NCE, 0); + break; + default: + gpio_set_value(RB2011_GPIO_NAND_NCE, 1); + break; + } + ndelay(500); +} + +static struct nand_ecclayout rb2011_nand_ecclayout = { + .eccbytes = 6, + .eccpos = { 8, 9, 10, 13, 14, 15 }, + .oobavail = 9, + .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } } +}; + +static int rb2011_nand_scan_fixup(struct mtd_info *mtd) +{ + struct nand_chip *chip = mtd->priv; + + if (mtd->writesize == 512) { + /* + * Use the OLD Yaffs-1 OOB layout, otherwise RouterBoot + * will not be able to find the kernel that we load. + */ + chip->ecc.layout = &rb2011_nand_ecclayout; + } + + return 0; +} + +static void __init rb2011_nand_init(void) +{ + ath79_nfc_set_scan_fixup(rb2011_nand_scan_fixup); + ath79_nfc_set_parts(rb2011_nand_partitions, + ARRAY_SIZE(rb2011_nand_partitions)); + ath79_nfc_set_select_chip(rb2011_nand_select_chip); + ath79_register_nfc(); +} + +static void __init rb2011_gpio_init(void) +{ + gpio_request_one(RB2011_GPIO_NAND_NCE, GPIOF_OUT_INIT_HIGH, "NAND nCE"); +} + static void __init rb2011_setup(void) { + rb2011_gpio_init(); + ath79_register_m25p80(&rb2011_spi_flash_data); + rb2011_nand_init(); rb2011_gmac_setup(); diff --git a/target/linux/ar71xx/nand/config-default b/target/linux/ar71xx/nand/config-default index 5ba1486aef..1015cf1fbf 100644 --- a/target/linux/ar71xx/nand/config-default +++ b/target/linux/ar71xx/nand/config-default @@ -1,9 +1,11 @@ +CONFIG_ATH79_DEV_NFC=y CONFIG_CMDLINE="rootfstype=yaffs noinitrd" # CONFIG_JFFS2_CMODE_PRIORITY is not set # CONFIG_JFFS2_FS is not set CONFIG_MDIO_BITBANG=y CONFIG_MDIO_GPIO=y CONFIG_MTD_NAND=y +CONFIG_MTD_NAND_AR934X=y CONFIG_MTD_NAND_ECC=y CONFIG_MTD_NAND_RB4XX=y CONFIG_MTD_NAND_RB750=y diff --git a/target/linux/ar71xx/patches-3.3/613-RB2011-support.patch b/target/linux/ar71xx/patches-3.3/613-RB2011-support.patch index 656d5f8b59..f180fcf335 100644 --- a/target/linux/ar71xx/patches-3.3/613-RB2011-support.patch +++ b/target/linux/ar71xx/patches-3.3/613-RB2011-support.patch @@ -1,6 +1,6 @@ --- a/arch/mips/ath79/Kconfig +++ b/arch/mips/ath79/Kconfig -@@ -335,6 +335,11 @@ config ATH79_MACH_RB750 +@@ -335,6 +335,12 @@ config ATH79_MACH_RB750 select ATH79_ROUTERBOOT select RLE_DECOMPRESS @@ -8,6 +8,7 @@ + bool "MikroTik RouterBOARD 2011 support" + select SOC_AR934x + select ATH79_DEV_ETH ++ select ATH79_DEV_NFC + config ATH79_MACH_WNDR3700 bool "NETGEAR WNDR3700 board support" diff --git a/target/linux/ar71xx/patches-3.3/614-MIPS-ath79-rb2011uas-2hnd-support.patch b/target/linux/ar71xx/patches-3.3/614-MIPS-ath79-rb2011uas-2hnd-support.patch index 875d17c14a..14b712c011 100644 --- a/target/linux/ar71xx/patches-3.3/614-MIPS-ath79-rb2011uas-2hnd-support.patch +++ b/target/linux/ar71xx/patches-3.3/614-MIPS-ath79-rb2011uas-2hnd-support.patch @@ -10,10 +10,10 @@ ATH79_MACH_TEW_632BRP, /* TRENDnet TEW-632BRP */ --- a/arch/mips/ath79/Kconfig +++ b/arch/mips/ath79/Kconfig -@@ -339,6 +339,8 @@ config ATH79_MACH_RB2011 - bool "MikroTik RouterBOARD 2011 support" +@@ -340,6 +340,8 @@ config ATH79_MACH_RB2011 select SOC_AR934x select ATH79_DEV_ETH + select ATH79_DEV_NFC + select ATH79_DEV_WMAC + select ATH79_ROUTERBOOT |