]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
OMAP3: FLASH: Move Flash specific device info in aseparate board file
authorChoraria, Rohit <rohitkc@ti.com>
Fri, 11 Jan 2008 06:07:03 +0000 (11:37 +0530)
committerTony Lindgren <tony@atomide.com>
Thu, 24 Jan 2008 20:58:49 +0000 (12:58 -0800)
This patch does the following
moves flash specific code to a new file board-3430sdp-flash.c
adds support for 3430 ES2 SDP changes for ethernet
changes the check in gpmc to OMAP34XX as same address is valid.
Signed-off-by: Rohit Choraria <rohitkc@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/Makefile
arch/arm/mach-omap2/board-3430sdp-flash.c [new file with mode: 0644]
arch/arm/mach-omap2/board-3430sdp.c
arch/arm/mach-omap2/gpmc.c
include/asm-arm/arch-omap/board-3430sdp.h

index f596a86d74abe6d912377271581627b606e7fdc1..c7e27a82d61cae430cf063a914363c10291bcc01 100644 (file)
@@ -27,7 +27,8 @@ obj-$(CONFIG_MACH_OMAP_2430SDP)               += board-2430sdp.o \
                                           board-2430sdp-usb.o
 obj-$(CONFIG_MACH_OMAP_2430OSK)                += board-2430osk.o
 obj-$(CONFIG_MACH_OMAP_3430SDP)                += board-3430sdp.o \
-                                          board-3430sdp-usb.o
+                                          board-3430sdp-usb.o \
+                                          board-3430sdp-flash.o
 obj-$(CONFIG_MACH_OMAP_APOLLON)                += board-apollon.o \
                                           board-apollon-mmc.o  \
                                           board-apollon-keys.o
diff --git a/arch/arm/mach-omap2/board-3430sdp-flash.c b/arch/arm/mach-omap2/board-3430sdp-flash.c
new file mode 100644 (file)
index 0000000..acd576c
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+ * linux/arch/arm/mach-omap2/board-3430sdp-flash.c
+ *
+ * Copyright (c) 2007 Texas Instruments
+ *
+ * Modified from mach-omap2/board-2430sdp-flash.c
+ * Author: Rohit Choraria <rohitkc@ti.com>
+ *
+ * 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
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/onenand_regs.h>
+#include <linux/types.h>
+#include <linux/io.h>
+
+#include <asm/mach/flash.h>
+#include <asm/arch/onenand.h>
+#include <asm/arch/board.h>
+#include <asm/arch/gpmc.h>
+
+static struct mtd_partition sdp_nor_partitions[] = {
+       /* bootloader (U-Boot, etc) in first sector */
+       {
+               .name           = "Bootloader-NOR",
+               .offset         = 0,
+               .size           = SZ_256K,
+               .mask_flags     = MTD_WRITEABLE, /* force read-only */
+       },
+       /* bootloader params in the next sector */
+       {
+               .name           = "Params-NOR",
+               .offset         = MTDPART_OFS_APPEND,
+               .size           = SZ_256K,
+               .mask_flags     = 0,
+       },
+       /* kernel */
+       {
+               .name           = "Kernel-NOR",
+               .offset         = MTDPART_OFS_APPEND,
+               .size           = SZ_2M,
+               .mask_flags     = 0
+       },
+       /* file system */
+       {
+               .name           = "Filesystem-NOR",
+               .offset         = MTDPART_OFS_APPEND,
+               .size           = MTDPART_SIZ_FULL,
+               .mask_flags     = 0
+       }
+};
+
+static struct flash_platform_data sdp_nor_data = {
+       .map_name       = "cfi_probe",
+       .width          = 2,
+       .parts          = sdp_nor_partitions,
+       .nr_parts       = ARRAY_SIZE(sdp_nor_partitions),
+};
+
+static struct resource sdp_nor_resource = {
+       .start          = 0,
+       .end            = 0,
+       .flags          = IORESOURCE_MEM,
+};
+
+static struct platform_device sdp_nor_device = {
+       .name           = "omapflash",
+       .id             = 0,
+       .dev            = {
+                       .platform_data = &sdp_nor_data,
+       },
+       .num_resources  = 1,
+       .resource       = &sdp_nor_resource,
+};
+
+static int sdp_onenand_setup(void __iomem *);
+
+static struct mtd_partition sdp_onenand_partitions[] = {
+       {
+               .name           = "X-Loader-OneNAND",
+               .offset         = 0,
+               .size           = 4 * (64 * 2048),
+               .mask_flags     = MTD_WRITEABLE  /* force read-only */
+       },
+       {
+               .name           = "U-Boot-OneNAND",
+               .offset         = MTDPART_OFS_APPEND,
+               .size           = 2 * (64 * 2048),
+               .mask_flags     = MTD_WRITEABLE  /* force read-only */
+       },
+       {
+               .name           = "U-Boot Environment-OneNAND",
+               .offset         = MTDPART_OFS_APPEND,
+               .size           = 1 * (64 * 2048),
+       },
+       {
+               .name           = "Kernel-OneNAND",
+               .offset         = MTDPART_OFS_APPEND,
+               .size           = 16 * (64 * 2048),
+       },
+       {
+               .name           = "File System-OneNAND",
+               .offset         = MTDPART_OFS_APPEND,
+               .size           = MTDPART_SIZ_FULL,
+       },
+};
+
+static struct omap_onenand_platform_data sdp_onenand_data = {
+       .parts          = sdp_onenand_partitions,
+       .nr_parts       = ARRAY_SIZE(sdp_onenand_partitions),
+       .onenand_setup  = sdp_onenand_setup,
+       .dma_channel    = -1,   /* disable DMA in OMAP OneNAND driver */
+};
+
+static struct platform_device sdp_onenand_device = {
+       .name           = "omap2-onenand",
+       .id             = -1,
+       .dev = {
+               .platform_data = &sdp_onenand_data,
+       },
+};
+
+/*
+ * sdp_onenand_setup - The function configures the onenand flash.
+ * @onenand_base: Onenand base address
+ *
+ * @return int:        Currently always returning zero.
+ */
+static int sdp_onenand_setup(void __iomem *onenand_base)
+{
+       /* Onenand setup does nothing at present */
+       return 0;
+}
+/**
+ * sdp3430_flash_init - Identify devices connected to GPMC and register.
+ *
+ * @return - void.
+ */
+void __init sdp3430_flash_init(void)
+{
+       u8              cs = 0;
+       u8              onenandcs = GPMC_CS_NUM + 1;
+
+       /* Configure start address and size of NOR device */
+       if (is_sil_rev_greater_than(OMAP3430_REV_ES1_0)) {
+               sdp_nor_resource.start  = FLASH_BASE_SDPV2;
+               sdp_nor_resource.end    = FLASH_BASE_SDPV2
+                                               + FLASH_SIZE_SDPV2 - 1;
+       } else {
+               sdp_nor_resource.start  = FLASH_BASE_SDPV1;
+               sdp_nor_resource.end    = FLASH_BASE_SDPV1
+                                               + FLASH_SIZE_SDPV1 - 1;
+       }
+
+       if (platform_device_register(&sdp_nor_device) < 0)
+               printk(KERN_ERR "Unable to register NOR device\n");
+
+       while (cs < GPMC_CS_NUM) {
+               u32 ret = 0;
+               ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
+
+               /*
+               * xloader/Uboot would have programmed the oneNAND
+               * base address for us This is a ugly hack. The proper
+               * way of doing this is to pass the setup of u-boot up
+               * to kernel using kernel params - something on the
+               * lines of machineID. Check if oneNAND is configured
+               */
+               if ((ret & 0x3F) == (ONENAND_MAP >> 24))
+                       onenandcs = cs;
+               cs++;
+       }
+       if (onenandcs > GPMC_CS_NUM) {
+               printk(KERN_INFO "OneNAND: Unable to find configuration "
+                               " in GPMC\n ");
+               return;
+       }
+
+       if (onenandcs < GPMC_CS_NUM) {
+               sdp_onenand_data.cs = onenandcs;
+               if (platform_device_register(&sdp_onenand_device) < 0)
+                       printk(KERN_ERR "Unable to register OneNAND device\n");
+       }
+}
index fc5ca4e101d18778ffecb37363220e18ac79e7c1..0bc26e9fc6a1d64aec6fbc7d613da63f740fdfea 100644 (file)
@@ -15,8 +15,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/partitions.h>
 #include <linux/delay.h>
 #include <linux/input.h>
 #include <linux/workqueue.h>
@@ -29,7 +27,6 @@
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
-#include <asm/mach/flash.h>
 
 #include <asm/arch/twl4030.h>
 #include <asm/arch/mcspi.h>
 #include <asm/io.h>
 #include <asm/delay.h>
 
-#define        SDP3430_FLASH_CS        0
 #define        SDP3430_SMC91X_CS       3
 
 #define ENABLE_VAUX3_DEDICATED 0x03
 #define ENABLE_VAUX3_DEV_GRP   0x20
 
-static struct mtd_partition sdp3430_partitions[] = {
-       /* bootloader (U-Boot, etc) in first sector */
-       {
-                 .name         = "bootloader",
-                 .offset               = 0,
-                 .size         = SZ_256K,
-                 .mask_flags   = MTD_WRITEABLE, /* force read-only */
-       },
-       /* bootloader params in the next sector */
-       {
-                 .name         = "params",
-                 .offset               = MTDPART_OFS_APPEND,
-                 .size         = SZ_128K,
-                 .mask_flags   = 0,
-       },
-       /* kernel */
-       {
-                 .name         = "kernel",
-                 .offset               = MTDPART_OFS_APPEND,
-                 .size         = SZ_2M,
-                 .mask_flags   = 0
-       },
-       /* file system */
-       {
-                 .name         = "filesystem",
-                 .offset               = MTDPART_OFS_APPEND,
-                 .size         = MTDPART_SIZ_FULL,
-                 .mask_flags   = 0
-       }
-};
-
-static struct flash_platform_data sdp3430_flash_data = {
-       .map_name       = "cfi_probe",
-       .width          = 2,
-       .parts          = sdp3430_partitions,
-       .nr_parts       = ARRAY_SIZE(sdp3430_partitions),
-};
-
-static struct resource sdp3430_flash_resource = {
-       .start          = FLASH_BASE,
-       .end            = FLASH_BASE + SZ_64M - 1,
-       .flags          = IORESOURCE_MEM,
-};
-
-static struct platform_device sdp3430_flash_device = {
-       .name           = "omapflash",
-       .id             = 0,
-       .dev            = {
-               .platform_data  = &sdp3430_flash_data,
-       },
-       .num_resources  = 1,
-       .resource       = &sdp3430_flash_resource,
-};
 
 static struct resource sdp3430_smc91x_resources[] = {
        [0] = {
                .start  = OMAP34XX_ETHR_START,
                .end    = OMAP34XX_ETHR_START + SZ_4K,
-               .flags          = IORESOURCE_MEM,
+               .flags  = IORESOURCE_MEM,
        },
        [1] = {
-               .start          = OMAP_GPIO_IRQ(OMAP34XX_ETHR_GPIO_IRQ),
+               .start  = 0,
                .end    = 0,
-               .flags          = IORESOURCE_IRQ,
+               .flags  = IORESOURCE_IRQ,
        },
 };
 
@@ -262,7 +205,6 @@ static struct platform_device sdp3430_lcd_device = {
 
 static struct platform_device *sdp3430_devices[] __initdata = {
        &sdp3430_smc91x_device,
-       &sdp3430_flash_device,
        &sdp3430_kp_device,
        &sdp3430_lcd_device,
 };
@@ -271,8 +213,9 @@ static inline void __init sdp3430_init_smc91x(void)
 {
        int eth_cs;
        unsigned long cs_mem_base;
+       int eth_gpio = 0;
 
-       eth_cs  = SDP3430_SMC91X_CS;
+       eth_cs = SDP3430_SMC91X_CS;
 
        if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
                printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
@@ -283,12 +226,19 @@ static inline void __init sdp3430_init_smc91x(void)
        sdp3430_smc91x_resources[0].end   = cs_mem_base + 0xf;
        udelay(100);
 
-       if (omap_request_gpio(OMAP34XX_ETHR_GPIO_IRQ) < 0) {
+       if (is_sil_rev_greater_than(OMAP3430_REV_ES1_0))
+               eth_gpio = OMAP34XX_ETHR_GPIO_IRQ_SDPV2;
+       else
+               eth_gpio = OMAP34XX_ETHR_GPIO_IRQ_SDPV1;
+
+       sdp3430_smc91x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
+
+       if (omap_request_gpio(eth_gpio) < 0) {
                printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
-                       OMAP34XX_ETHR_GPIO_IRQ);
+                       eth_gpio);
                return;
        }
-       omap_set_gpio_direction(OMAP34XX_ETHR_GPIO_IRQ, 1);
+       omap_set_gpio_direction(eth_gpio, 1);
 }
 
 static void __init omap_3430sdp_init_irq(void)
@@ -320,6 +270,8 @@ static int __init omap3430_i2c_init(void)
        return 0;
 }
 
+extern void __init sdp3430_flash_init(void);
+
 static void __init omap_3430sdp_init(void)
 {
        platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
@@ -328,6 +280,7 @@ static void __init omap_3430sdp_init(void)
        spi_register_board_info(sdp3430_spi_board_info,
                                ARRAY_SIZE(sdp3430_spi_board_info));
        ads7846_dev_init();
+       sdp3430_flash_init();
        omap_serial_init();
        sdp3430_usb_init();
 }
index a992b167a241d735b9f5d2a4596375f29d351270..1b54820d62130bbf3af1addfde0982f416722051 100644 (file)
@@ -24,7 +24,7 @@
 
 #if defined(CONFIG_ARCH_OMAP2420)
 #define GPMC_BASE              0x6800a000
-#elif defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
+#elif defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX)
 #define GPMC_BASE              0x6e000000
 #endif
 
index 369d0025fb29d3c1bf7108859a6035d382f86c5c..bc2bb3746168c7cc0e3d2d74b98ddf871be2cb49 100644 (file)
@@ -36,31 +36,38 @@ extern void sdp3430_usb_init(void);
 /* Placeholder for 3430SDP specific defines */
 
 #define OMAP34XX_ETHR_START            DEBUG_BASE
-#define OMAP34XX_ETHR_GPIO_IRQ         29
+#define OMAP34XX_ETHR_GPIO_IRQ_SDPV1   29
+#define OMAP34XX_ETHR_GPIO_IRQ_SDPV2   6
 
 /*
  * GPIO used for TSC2046, TI's Touchscreen controller
  */
 #ifdef CONFIG_OMAP3430_ES2
-#define TS_GPIO                2
+#define TS_GPIO                2
 #else
-#define TS_GPIO                3
+#define TS_GPIO                3
 #endif
 
 /* NAND */
 /* IMPORTANT NOTE ON MAPPING
- * 3430SDP - 343X
+ * 3430SDP - 34XX
  * ----------
- * NOR always on  0x04000000
+ * NOR always on 0x04000000 for SDPV1
+ * NOR always on 0x10000000 for SDPV2
  * MPDB always on 0x08000000
  * NAND always on 0x0C000000
  * OneNand Mapped to 0x20000000
  * Boot Mode(NAND/NOR). The other on CS1
  */
-#define FLASH_BASE     0x04000000  /* NOR flash (64 Meg aligned) */
-#define DEBUG_BASE     0x08000000  /* debug board */
-#define NAND_BASE      0x0C000000  /* NAND flash */
-#define ONENAND_MAP    0x20000000  /* OneNand flash */
+#define FLASH_BASE_SDPV1       0x04000000 /* NOR flash (64 Meg aligned) */
+#define FLASH_BASE_SDPV2       0x10000000 /* NOR flash (256 Meg aligned) */
+#define DEBUG_BASE             0x08000000 /* debug board */
+#define NAND_BASE              0x0C000000 /* NAND flash */
+#define ONENAND_MAP            0x20000000 /* OneNand flash */
+
+/* various memory sizes */
+#define FLASH_SIZE_SDPV1       SZ_64M
+#define FLASH_SIZE_SDPV2       SZ_128M
 
 #ifdef CONFIG_TWL4030_CORE