Load the appropriate MTD driver if we were booted from NOR/NAND only, use the TRX...
[openwrt.git] / target / linux / adm5120-2.6 / files / drivers / mtd / nand / rbmipsnand.c
index f086552..5b98833 100644 (file)
 #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>
+#include <asm/mach-adm5120/adm5120_info.h>
+#include <asm/mach-adm5120/adm5120_defs.h>
 
-#define SMEM1_BASE 0x10000000   // from ADM5120 documentation
-#define SMEM1(x) (*((volatile unsigned char *) (KSEG1ADDR(SMEM1_BASE) + x)))
+#define SMEM1(x) (*((volatile unsigned char *) (KSEG1ADDR(ADM5120_SRAM1_BASE) + x)))
 
 #define NAND_RW_REG    0x0     //data register
 #define NAND_SET_CEn   0x1     //CE# low
@@ -58,7 +60,7 @@ static struct mtd_partition partition_info[] = {
        size: 4 * 1024 * 1024
     },
     {
-        name: "RouterBoard NAND Main",
+        name: "rootfs",
        offset: MTDPART_OFS_NXTBLK,
        size: MTDPART_SIZ_FULL
     }
@@ -66,7 +68,17 @@ static struct mtd_partition partition_info[] = {
 
 static struct mtd_info rmtd;
 static struct nand_chip rnand;
-
+/*========================================================================*/
+/* We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader */
+/* will not be able to find the kernel that we load.  So set the oobinfo  */
+/* when creating the partitions.                                          */ 
+/*========================================================================*/
+static struct nand_ecclayout rb_ecclayout = {
+        .eccbytes = 6,
+        .eccpos = { 8, 9, 10, 13, 14, 15 },
+       .oobavail = 9,
+        .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1} }
+};
 static unsigned init_ok = 0;
 
 unsigned get_rbnand_block_size(void) {
@@ -76,29 +88,34 @@ unsigned get_rbnand_block_size(void) {
 EXPORT_SYMBOL(get_rbnand_block_size);
 
 int __init rbmips_init(void) {
+
+       if (!adm5120_nand_boot)
+               return -ENODEV;
+
        memset(&rmtd, 0, sizeof(rmtd));
        memset(&rnand, 0, sizeof(rnand));
-       printk("RB1xx nand\n");
+       printk(KERN_INFO "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_R = (unsigned char *)KSEG1ADDR(ADM5120_SRAM1_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);
+       p_nand = (void __iomem *)ioremap(( unsigned long)ADM5120_SRAM1_BASE, 0x1000);
        if (!p_nand) {
-               printk("RB1xx nand Unable ioremap buffer");
+               printk(KERN_WARNING "RB1xx nand Unable ioremap buffer\n");
                return -ENXIO;
        }
        rnand.ecc.mode = NAND_ECC_SOFT;
+       rnand.ecc.layout = &rb_ecclayout;
        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");
+               printk(KERN_INFO "RB1xxx nand device not found\n");
                iounmap ((void *)p_nand);
                return -ENXIO;
        }
This page took 0.026689 seconds and 4 git commands to generate.