]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ARM: OMAP2+: nand: unify init functions
authorAfzal Mohammed <afzal@ti.com>
Wed, 29 Feb 2012 12:41:56 +0000 (18:11 +0530)
committerAfzal Mohammed <afzal@ti.com>
Mon, 15 Oct 2012 06:30:44 +0000 (12:00 +0530)
Helper function for updating nand platform data has been
added the capability to take timing structure arguement.
Usage of omap_nand_flash_init() has been replaced by modifed
one, omap_nand_flash_init was doing things similar to
board_nand_init except that NAND CS# were being acquired
based on bootloader setting. As CS# is hardwired for a given
board, acquiring gpmc CS# has been removed, and updated with
the value on board.

NAND CS# used in beagle board & omap3evm was found to be CS0.
Thomas Weber <thomas.weber.linux@googlemail.com> reported
that value of devkit8000 to be CS0. Overo board was found
to be using CS0 based on u-boot, while google grep says
omap3touchbook too has CS0.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Reviewed-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Igor Grinberg <grinberg@compulab.co.il>
12 files changed:
arch/arm/mach-omap2/board-devkit8000.c
arch/arm/mach-omap2/board-flash.c
arch/arm/mach-omap2/board-flash.h
arch/arm/mach-omap2/board-igep0020.c
arch/arm/mach-omap2/board-ldp.c
arch/arm/mach-omap2/board-omap3beagle.c
arch/arm/mach-omap2/board-omap3evm.c
arch/arm/mach-omap2/board-omap3touchbook.c
arch/arm/mach-omap2/board-overo.c
arch/arm/mach-omap2/board-zoom.c
arch/arm/mach-omap2/common-board-devices.c
arch/arm/mach-omap2/common-board-devices.h

index 1fd161e934c7e7df2d9eec52c3c35f3e8abfc964..99339666d2d355ba80f427d2213923408bcde4d9 100644 (file)
 #include "sdram-micron-mt46h32m32lf-6.h"
 #include "mux.h"
 #include "hsmmc.h"
+#include "board-flash.h"
 #include "common-board-devices.h"
 
+#define        NAND_CS                 0
+
 #define OMAP_DM9000_GPIO_IRQ   25
 #define OMAP3_DEVKIT_TS_GPIO   27
 
@@ -621,8 +624,9 @@ static void __init devkit8000_init(void)
 
        usb_musb_init(NULL);
        usbhs_init(&usbhs_bdata);
-       omap_nand_flash_init(NAND_BUSWIDTH_16, devkit8000_nand_partitions,
-                            ARRAY_SIZE(devkit8000_nand_partitions));
+       board_nand_init(devkit8000_nand_partitions,
+                       ARRAY_SIZE(devkit8000_nand_partitions), NAND_CS,
+                       NAND_BUSWIDTH_16, NULL);
        omap_twl4030_audio_init("omap3beagle");
 
        /* Ensure SDRC pins are mux'd for self-refresh */
index e642acf9cad0e1132bf3edcd6398d02c05d4cdaa..d4ac5352a71c5733cc4dcf9a04da12a0c37642c1 100644 (file)
@@ -104,41 +104,41 @@ __init board_onenand_init(struct mtd_partition *onenand_parts,
                defined(CONFIG_MTD_NAND_OMAP2_MODULE)
 
 /* Note that all values in this struct are in nanoseconds */
-static struct gpmc_timings nand_timings = {
+struct gpmc_timings nand_default_timings[1] = {
+       {
+               .sync_clk = 0,
 
-       .sync_clk = 0,
+               .cs_on = 0,
+               .cs_rd_off = 36,
+               .cs_wr_off = 36,
 
-       .cs_on = 0,
-       .cs_rd_off = 36,
-       .cs_wr_off = 36,
+               .adv_on = 6,
+               .adv_rd_off = 24,
+               .adv_wr_off = 36,
 
-       .adv_on = 6,
-       .adv_rd_off = 24,
-       .adv_wr_off = 36,
+               .we_off = 30,
+               .oe_off = 48,
 
-       .we_off = 30,
-       .oe_off = 48,
+               .access = 54,
+               .rd_cycle = 72,
+               .wr_cycle = 72,
 
-       .access = 54,
-       .rd_cycle = 72,
-       .wr_cycle = 72,
-
-       .wr_access = 30,
-       .wr_data_mux_bus = 0,
+               .wr_access = 30,
+               .wr_data_mux_bus = 0,
+       },
 };
 
-static struct omap_nand_platform_data board_nand_data = {
-       .gpmc_t         = &nand_timings,
-};
+static struct omap_nand_platform_data board_nand_data;
 
 void
-__init board_nand_init(struct mtd_partition *nand_parts,
-                       u8 nr_parts, u8 cs, int nand_type)
+__init board_nand_init(struct mtd_partition *nand_parts, u8 nr_parts, u8 cs,
+                               int nand_type, struct gpmc_timings *gpmc_t)
 {
        board_nand_data.cs              = cs;
        board_nand_data.parts           = nand_parts;
        board_nand_data.nr_parts        = nr_parts;
        board_nand_data.devsize         = nand_type;
+       board_nand_data.gpmc_t          = gpmc_t;
 
        board_nand_data.ecc_opt = OMAP_ECC_HAMMING_CODE_DEFAULT;
        gpmc_nand_init(&board_nand_data);
@@ -238,5 +238,6 @@ void __init board_flash_init(struct flash_partitions partition_info[],
                pr_err("NAND: Unable to find configuration in GPMC\n");
        else
                board_nand_init(partition_info[2].parts,
-                       partition_info[2].nr_parts, nandcs, nand_type);
+                       partition_info[2].nr_parts, nandcs,
+                       nand_type, nand_default_timings);
 }
index c44b70d5202173a879519ea9ebf2cacdb1ac29d0..a3aa5fca44957bcda19dbe7d76474aa40006a4d5 100644 (file)
@@ -40,12 +40,14 @@ static inline void board_flash_init(struct flash_partitions part[],
 #if defined(CONFIG_MTD_NAND_OMAP2) || \
                defined(CONFIG_MTD_NAND_OMAP2_MODULE)
 extern void board_nand_init(struct mtd_partition *nand_parts,
-                                       u8 nr_parts, u8 cs, int nand_type);
+               u8 nr_parts, u8 cs, int nand_type, struct gpmc_timings *gpmc_t);
+extern struct gpmc_timings nand_default_timings[];
 #else
 static inline void board_nand_init(struct mtd_partition *nand_parts,
-                                       u8 nr_parts, u8 cs, int nand_type)
+               u8 nr_parts, u8 cs, int nand_type, struct gpmc_timings *gpmc_t)
 {
 }
+#define        nand_default_timings    NULL
 #endif
 
 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
index 48d5e41dfbfabe3da59ef00f7457f5012cf2ec1a..f6b3ed0e5c94cb4e26c748c3ca8f556d99c2f652 100644 (file)
@@ -175,7 +175,7 @@ static void __init igep_flash_init(void)
                pr_info("IGEP: initializing NAND memory device\n");
                board_nand_init(igep_flash_partitions,
                                ARRAY_SIZE(igep_flash_partitions),
-                               0, NAND_BUSWIDTH_16);
+                               0, NAND_BUSWIDTH_16, nand_default_timings);
        } else if (mux == IGEP_SYSBOOT_ONENAND) {
                pr_info("IGEP: initializing OneNAND memory device\n");
                board_onenand_init(igep_flash_partitions,
index ee8c3cfb95b392a50e207577679b7383dbc3aee1..83383f39e674f51abdc19e8aef5bf7039ed1d4e7 100644 (file)
@@ -420,8 +420,8 @@ static void __init omap_ldp_init(void)
        omap_serial_init();
        omap_sdrc_init(NULL, NULL);
        usb_musb_init(NULL);
-       board_nand_init(ldp_nand_partitions,
-               ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0);
+       board_nand_init(ldp_nand_partitions, ARRAY_SIZE(ldp_nand_partitions),
+                       ZOOM_NAND_CS, 0, nand_default_timings);
 
        omap_hsmmc_init(mmc);
        ldp_display_init();
index 388c431c745a0e4134c847f96f84b73912053bf7..43b5f797e712b6045a8752b3c27530116b0607af 100644 (file)
 #include "mux.h"
 #include "hsmmc.h"
 #include "pm.h"
+#include "board-flash.h"
 #include "common-board-devices.h"
 
+#define        NAND_CS 0
+
 /*
  * OMAP3 Beagle revision
  * Run time detection of Beagle revision is done by reading GPIO.
@@ -512,8 +515,9 @@ static void __init omap3_beagle_init(void)
 
        usb_musb_init(NULL);
        usbhs_init(&usbhs_bdata);
-       omap_nand_flash_init(NAND_BUSWIDTH_16, omap3beagle_nand_partitions,
-                            ARRAY_SIZE(omap3beagle_nand_partitions));
+       board_nand_init(omap3beagle_nand_partitions,
+                       ARRAY_SIZE(omap3beagle_nand_partitions), NAND_CS,
+                       NAND_BUSWIDTH_16, NULL);
        omap_twl4030_audio_init("omap3beagle");
 
        /* Ensure msecure is mux'd to be able to set the RTC. */
index b9b776b6c954c9a519f6ae2dee868b815a79d990..1d8e926b52fe21c5b31d8e1579812e5b31f30400 100644 (file)
@@ -56,6 +56,9 @@
 #include "sdram-micron-mt46h32m32lf-6.h"
 #include "hsmmc.h"
 #include "common-board-devices.h"
+#include "board-flash.h"
+
+#define        NAND_CS                 0
 
 #define OMAP3_EVM_TS_GPIO      175
 #define OMAP3_EVM_EHCI_VBUS    22
@@ -731,8 +734,9 @@ static void __init omap3_evm_init(void)
        }
        usb_musb_init(&musb_board_data);
        usbhs_init(&usbhs_bdata);
-       omap_nand_flash_init(NAND_BUSWIDTH_16, omap3evm_nand_partitions,
-                            ARRAY_SIZE(omap3evm_nand_partitions));
+       board_nand_init(omap3evm_nand_partitions,
+                       ARRAY_SIZE(omap3evm_nand_partitions), NAND_CS,
+                       NAND_BUSWIDTH_16, NULL);
 
        omap_ads7846_init(1, OMAP3_EVM_TS_GPIO, 310, NULL);
        omap3evm_init_smsc911x();
index 944ffc436577f9fce420cf088af116329cb26132..3f013c8511ee41247080b0b34130fd1a839c1c60 100644 (file)
@@ -50,6 +50,7 @@
 
 #include "mux.h"
 #include "hsmmc.h"
+#include "board-flash.h"
 #include "common-board-devices.h"
 
 #include <asm/setup.h>
@@ -59,6 +60,8 @@
 #define TB_BL_PWM_TIMER                9
 #define TB_KILL_POWER_GPIO     168
 
+#define        NAND_CS                 0
+
 static unsigned long touchbook_revision;
 
 static struct mtd_partition omap3touchbook_nand_partitions[] = {
@@ -365,8 +368,9 @@ static void __init omap3_touchbook_init(void)
        omap_ads7846_init(4, OMAP3_TS_GPIO, 310, &ads7846_pdata);
        usb_musb_init(NULL);
        usbhs_init(&usbhs_bdata);
-       omap_nand_flash_init(NAND_BUSWIDTH_16, omap3touchbook_nand_partitions,
-                            ARRAY_SIZE(omap3touchbook_nand_partitions));
+       board_nand_init(omap3touchbook_nand_partitions,
+                       ARRAY_SIZE(omap3touchbook_nand_partitions), NAND_CS,
+                       NAND_BUSWIDTH_16, NULL);
 
        /* Ensure SDRC pins are mux'd for self-refresh */
        omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
index b700685762b50b70242f823e22bf393b2ebe4943..e2cf0f768dddbcf473d46c817b1fc21b7fc63b53 100644 (file)
 #include "mux.h"
 #include "sdram-micron-mt46h32m32lf-6.h"
 #include "hsmmc.h"
+#include "board-flash.h"
 #include "common-board-devices.h"
 
+#define        NAND_CS                 0
+
 #define OVERO_GPIO_BT_XGATE    15
 #define OVERO_GPIO_W2W_NRESET  16
 #define OVERO_GPIO_PENDOWN     114
@@ -495,8 +498,8 @@ static void __init overo_init(void)
        omap_serial_init();
        omap_sdrc_init(mt46h32m32lf6_sdrc_params,
                                  mt46h32m32lf6_sdrc_params);
-       omap_nand_flash_init(0, overo_nand_partitions,
-                            ARRAY_SIZE(overo_nand_partitions));
+       board_nand_init(overo_nand_partitions,
+                       ARRAY_SIZE(overo_nand_partitions), NAND_CS, 0, NULL);
        usb_musb_init(NULL);
        usbhs_init(&usbhs_bdata);
        overo_spi_init();
index 4994438e1f46cbdee5fee1f26d74afb2a596e7fb..c39578c1fa6da85e8446e111a0672e827368cae9 100644 (file)
@@ -113,8 +113,9 @@ static void __init omap_zoom_init(void)
                usbhs_init(&usbhs_bdata);
        }
 
-       board_nand_init(zoom_nand_partitions, ARRAY_SIZE(zoom_nand_partitions),
-                                               ZOOM_NAND_CS, NAND_BUSWIDTH_16);
+       board_nand_init(zoom_nand_partitions,
+                       ARRAY_SIZE(zoom_nand_partitions), ZOOM_NAND_CS,
+                       NAND_BUSWIDTH_16, nand_default_timings);
        zoom_debugboard_init();
        zoom_peripherals_init();
 
index 48daac2581b4a154a768923681ac108c084a5c98..90e0597667b9e897c24beaf72d99d3104d6bb264 100644 (file)
@@ -96,48 +96,3 @@ void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
 {
 }
 #endif
-
-#if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
-static struct omap_nand_platform_data nand_data;
-
-void __init omap_nand_flash_init(int options, struct mtd_partition *parts,
-                                int nr_parts)
-{
-       u8 cs = 0;
-       u8 nandcs = GPMC_CS_NUM + 1;
-
-       /* find out the chip-select on which NAND exists */
-       while (cs < GPMC_CS_NUM) {
-               u32 ret = 0;
-               ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
-
-               if ((ret & 0xC00) == 0x800) {
-                       printk(KERN_INFO "Found NAND on CS%d\n", cs);
-                       if (nandcs > GPMC_CS_NUM)
-                               nandcs = cs;
-               }
-               cs++;
-       }
-
-       if (nandcs > GPMC_CS_NUM) {
-               pr_info("NAND: Unable to find configuration in GPMC\n");
-               return;
-       }
-
-       if (nandcs < GPMC_CS_NUM) {
-               nand_data.cs = nandcs;
-               nand_data.parts = parts;
-               nand_data.nr_parts = nr_parts;
-               nand_data.devsize = options;
-
-               printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
-               if (gpmc_nand_init(&nand_data) < 0)
-                       printk(KERN_ERR "Unable to register NAND device\n");
-       }
-}
-#else
-void __init omap_nand_flash_init(int options, struct mtd_partition *parts,
-                                int nr_parts)
-{
-}
-#endif
index a0b4a42836ab9f7a29f1757ee410e37a237af00c..72bb41b3fd254382ce23a5759ba607a7f7777f1f 100644 (file)
@@ -10,6 +10,5 @@ struct ads7846_platform_data;
 
 void omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
                       struct ads7846_platform_data *board_pdata);
-void omap_nand_flash_init(int opts, struct mtd_partition *parts, int n_parts);
 
 #endif /* __OMAP_COMMON_BOARD_DEVICES__ */