aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ar71xx/files/arch/mips/ath79/mach-rb2011.c
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2012-09-13 07:26:26 +0000
committerGabor Juhos <juhosg@openwrt.org>2012-09-13 07:26:26 +0000
commit76e3187aa217521dac78d0f2c13fee15c4f773ed (patch)
tree983a04f27a150fca74ce6abb3b7b99ce491937f1 /target/linux/ar71xx/files/arch/mips/ath79/mach-rb2011.c
parent30da844351f93366d4cb5374b05309c033dc1af6 (diff)
downloadmaster-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/linux/ar71xx/files/arch/mips/ath79/mach-rb2011.c')
-rw-r--r--target/linux/ar71xx/files/arch/mips/ath79/mach-rb2011.c77
1 files changed, 77 insertions, 0 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();