]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ARM: OMAP2+: nand: header cleanup
authorAfzal Mohammed <afzal@ti.com>
Sat, 29 Sep 2012 06:56:13 +0000 (12:26 +0530)
committerAfzal Mohammed <afzal@ti.com>
Mon, 15 Oct 2012 09:12:05 +0000 (14:42 +0530)
For common arm zImage existing nand header file
in platform specific location was moved to generic
platform data location, but it contained more than
platform data, remove it. New local header has been
created for exposing functions.

Also move gpmc-nand platform data to platform header
meant for nand from gpmc header file

Signed-off-by: Afzal Mohammed <afzal@ti.com>
arch/arm/mach-omap2/board-cm-t35.c
arch/arm/mach-omap2/board-cm-t3517.c
arch/arm/mach-omap2/board-flash.c
arch/arm/mach-omap2/board-omap3pandora.c
arch/arm/mach-omap2/common-board-devices.c
arch/arm/mach-omap2/gpmc-nand.c
arch/arm/mach-omap2/gpmc-nand.h [new file with mode: 0644]
arch/arm/mach-omap2/gpmc.c
arch/arm/plat-omap/include/plat/gpmc.h
include/linux/platform_data/mtd-nand-omap2.h

index 376d26eb601c371b75b4c4af7a3105ebe30bf8c4..fef68de716b5d108857e6d978ccc63df1b9ad8ba 100644 (file)
@@ -53,6 +53,7 @@
 #include "sdram-micron-mt46h32m32lf-6.h"
 #include "hsmmc.h"
 #include "common-board-devices.h"
+#include "gpmc-nand.h"
 
 #define CM_T35_GPIO_PENDOWN            57
 #define SB_T35_USB_HUB_RESET_GPIO      167
@@ -181,7 +182,7 @@ static struct omap_nand_platform_data cm_t35_nand_data = {
 
 static void __init cm_t35_init_nand(void)
 {
-       if (gpmc_nand_init(&cm_t35_nand_data) < 0)
+       if (gpmc_nand_init(&cm_t35_nand_data, NULL) < 0)
                pr_err("CM-T35: Unable to register NAND device\n");
 }
 #else
index 59c0a45f75b02aec82fbbb0d8ceb51a4a2879153..3a19e80e0005b8c071dbb6c664ddc6e63e1a49f0 100644 (file)
@@ -49,6 +49,7 @@
 #include "control.h"
 #include "common-board-devices.h"
 #include "am35xx-emac.h"
+#include "gpmc-nand.h"
 
 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
 static struct gpio_led cm_t3517_leds[] = {
@@ -240,7 +241,7 @@ static struct omap_nand_platform_data cm_t3517_nand_data = {
 
 static void __init cm_t3517_init_nand(void)
 {
-       if (gpmc_nand_init(&cm_t3517_nand_data) < 0)
+       if (gpmc_nand_init(&cm_t3517_nand_data, NULL) < 0)
                pr_err("CM-T3517: NAND initialization failed\n");
 }
 #else
index f438d511ba11b6d4df00bef53ed50ed1b66fe656..ba9fa86a10aa225cb59738036402ee61527894a7 100644 (file)
@@ -26,6 +26,7 @@
 #include "common.h"
 #include "board-flash.h"
 #include "gpmc-onenand.h"
+#include "gpmc-nand.h"
 
 #define REG_FPGA_REV                   0x10
 #define REG_FPGA_DIP_SWITCH_INPUT2     0x60
@@ -139,10 +140,9 @@ __init board_nand_init(struct mtd_partition *nand_parts, u8 nr_parts, u8 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);
+       gpmc_nand_init(&board_nand_data, gpmc_t);
 }
 #endif /* CONFIG_MTD_NAND_OMAP2 || CONFIG_MTD_NAND_OMAP2_MODULE */
 
index 00a1f4ae6e4497c7bf62584e13470556fa329428..f286b4b4bd5bd5dfa6ee6c5859a262c8c833a886 100644 (file)
@@ -50,6 +50,7 @@
 #include "sdram-micron-mt46h32m32lf-6.h"
 #include "hsmmc.h"
 #include "common-board-devices.h"
+#include "gpmc-nand.h"
 
 #define PANDORA_WIFI_IRQ_GPIO          21
 #define PANDORA_WIFI_NRESET_GPIO       23
@@ -602,7 +603,7 @@ static void __init omap3pandora_init(void)
        omap_ads7846_init(1, OMAP3_PANDORA_TS_GPIO, 0, NULL);
        usbhs_init(&usbhs_bdata);
        usb_musb_init(NULL);
-       gpmc_nand_init(&pandora_nand_data);
+       gpmc_nand_init(&pandora_nand_data, NULL);
 
        /* Ensure SDRC pins are mux'd for self-refresh */
        omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
index 90e0597667b9e897c24beaf72d99d3104d6bb264..ad856092c06aa889c149a70142f0397573b26a8a 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/spi/ads7846.h>
 
 #include <linux/platform_data/spi-omap2-mcspi.h>
-#include <linux/platform_data/mtd-nand-omap2.h>
 
 #include "common.h"
 #include "common-board-devices.h"
index 4acf497faeb3c14aeb2cdbb81f36f5e6cd45ac69..abdb78a95a9451a9bebc984f506cf37f76542353 100644 (file)
 #include <plat/gpmc.h>
 
 #include "soc.h"
+#include "gpmc-nand.h"
+
+/* minimum size for IO mapping */
+#define        NAND_IO_SIZE    4
 
 static struct resource gpmc_nand_resource[] = {
        {
@@ -40,41 +44,36 @@ static struct platform_device gpmc_nand_device = {
        .resource       = gpmc_nand_resource,
 };
 
-static int omap2_nand_gpmc_retime(struct omap_nand_platform_data *gpmc_nand_data)
+static int omap2_nand_gpmc_retime(
+                               struct omap_nand_platform_data *gpmc_nand_data,
+                               struct gpmc_timings *gpmc_t)
 {
        struct gpmc_timings t;
        int err;
 
-       if (!gpmc_nand_data->gpmc_t)
-               return 0;
-
        memset(&t, 0, sizeof(t));
-       t.sync_clk = gpmc_nand_data->gpmc_t->sync_clk;
-       t.cs_on = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->cs_on);
-       t.adv_on = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->adv_on);
+       t.sync_clk = gpmc_t->sync_clk;
+       t.cs_on = gpmc_round_ns_to_ticks(gpmc_t->cs_on);
+       t.adv_on = gpmc_round_ns_to_ticks(gpmc_t->adv_on);
 
        /* Read */
-       t.adv_rd_off = gpmc_round_ns_to_ticks(
-                               gpmc_nand_data->gpmc_t->adv_rd_off);
+       t.adv_rd_off = gpmc_round_ns_to_ticks(gpmc_t->adv_rd_off);
        t.oe_on  = t.adv_on;
-       t.access = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->access);
-       t.oe_off = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->oe_off);
-       t.cs_rd_off = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->cs_rd_off);
-       t.rd_cycle  = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->rd_cycle);
+       t.access = gpmc_round_ns_to_ticks(gpmc_t->access);
+       t.oe_off = gpmc_round_ns_to_ticks(gpmc_t->oe_off);
+       t.cs_rd_off = gpmc_round_ns_to_ticks(gpmc_t->cs_rd_off);
+       t.rd_cycle  = gpmc_round_ns_to_ticks(gpmc_t->rd_cycle);
 
        /* Write */
-       t.adv_wr_off = gpmc_round_ns_to_ticks(
-                               gpmc_nand_data->gpmc_t->adv_wr_off);
+       t.adv_wr_off = gpmc_round_ns_to_ticks(gpmc_t->adv_wr_off);
        t.we_on  = t.oe_on;
        if (cpu_is_omap34xx()) {
-           t.wr_data_mux_bus = gpmc_round_ns_to_ticks(
-                               gpmc_nand_data->gpmc_t->wr_data_mux_bus);
-           t.wr_access = gpmc_round_ns_to_ticks(
-                               gpmc_nand_data->gpmc_t->wr_access);
+           t.wr_data_mux_bus = gpmc_round_ns_to_ticks(gpmc_t->wr_data_mux_bus);
+           t.wr_access = gpmc_round_ns_to_ticks(gpmc_t->wr_access);
        }
-       t.we_off = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->we_off);
-       t.cs_wr_off = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->cs_wr_off);
-       t.wr_cycle  = gpmc_round_ns_to_ticks(gpmc_nand_data->gpmc_t->wr_cycle);
+       t.we_off = gpmc_round_ns_to_ticks(gpmc_t->we_off);
+       t.cs_wr_off = gpmc_round_ns_to_ticks(gpmc_t->cs_wr_off);
+       t.wr_cycle  = gpmc_round_ns_to_ticks(gpmc_t->wr_cycle);
 
        /* Configure GPMC */
        if (gpmc_nand_data->devsize == NAND_BUSWIDTH_16)
@@ -91,7 +90,8 @@ static int omap2_nand_gpmc_retime(struct omap_nand_platform_data *gpmc_nand_data
        return 0;
 }
 
-int __init gpmc_nand_init(struct omap_nand_platform_data *gpmc_nand_data)
+int __init gpmc_nand_init(struct omap_nand_platform_data *gpmc_nand_data,
+                         struct gpmc_timings *gpmc_t)
 {
        int err = 0;
        struct device *dev = &gpmc_nand_device.dev;
@@ -112,11 +112,13 @@ int __init gpmc_nand_init(struct omap_nand_platform_data *gpmc_nand_data)
                                gpmc_get_client_irq(GPMC_IRQ_FIFOEVENTENABLE);
        gpmc_nand_resource[2].start =
                                gpmc_get_client_irq(GPMC_IRQ_COUNT_EVENT);
-        /* Set timings in GPMC */
-       err = omap2_nand_gpmc_retime(gpmc_nand_data);
-       if (err < 0) {
-               dev_err(dev, "Unable to set gpmc timings: %d\n", err);
-               return err;
+
+       if (gpmc_t) {
+               err = omap2_nand_gpmc_retime(gpmc_nand_data, gpmc_t);
+               if (err < 0) {
+                       dev_err(dev, "Unable to set gpmc timings: %d\n", err);
+                       return err;
+               }
        }
 
        /* Enable RD PIN Monitoring Reg */
diff --git a/arch/arm/mach-omap2/gpmc-nand.h b/arch/arm/mach-omap2/gpmc-nand.h
new file mode 100644 (file)
index 0000000..11a377f
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ *  arch/arm/mach-omap2/gpmc-nand.h
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ */
+
+#ifndef        __OMAP2_GPMC_NAND_H
+#define        __OMAP2_GPMC_NAND_H
+
+#include <plat/gpmc.h>
+#include <linux/platform_data/mtd-nand-omap2.h>
+
+#if IS_ENABLED(CONFIG_MTD_NAND_OMAP2)
+extern int gpmc_nand_init(struct omap_nand_platform_data *d,
+                         struct gpmc_timings *gpmc_t);
+#else
+static inline int gpmc_nand_init(struct omap_nand_platform_data *d,
+                                struct gpmc_timings *gpmc_t)
+{
+       return 0;
+}
+#endif
+
+#endif
index 91af5aefeaae9f1f0c32bfc5cc816b23af17718b..34823b3092f36380b3b723474ae1f063cb456841 100644 (file)
@@ -26,6 +26,8 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 
+#include <linux/platform_data/mtd-nand-omap2.h>
+
 #include <asm/mach-types.h>
 #include <plat/gpmc.h>
 
index f7e0990eaf370214f133ef5a090dc89bd622e288..4b06bb4531a23c1aed1c4c165c54b31db77575f6 100644 (file)
@@ -11,6 +11,8 @@
 #ifndef __OMAP2_GPMC_H
 #define __OMAP2_GPMC_H
 
+#include <linux/platform_data/mtd-nand-omap2.h>
+
 /* Maximum Number of Chip Selects */
 #define GPMC_CS_NUM            8
 
 #define PREFETCH_FIFOTHRESHOLD_MAX     0x40
 #define PREFETCH_FIFOTHRESHOLD(val)    ((val) << 8)
 
-enum omap_ecc {
-               /* 1-bit ecc: stored at end of spare area */
-       OMAP_ECC_HAMMING_CODE_DEFAULT = 0, /* Default, s/w method */
-       OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */
-               /* 1-bit ecc: stored at beginning of spare area as romcode */
-       OMAP_ECC_HAMMING_CODE_HW_ROMCODE, /* gpmc method & romcode layout */
-       OMAP_ECC_BCH4_CODE_HW, /* 4-bit BCH ecc code */
-       OMAP_ECC_BCH8_CODE_HW, /* 8-bit BCH ecc code */
-};
-
 /*
  * Note that all values in this struct are in nanoseconds except sync_clk
  * (which is in picoseconds), while the register values are in gpmc_fck cycles.
@@ -133,22 +125,6 @@ struct gpmc_timings {
        u16 wr_data_mux_bus;    /* WRDATAONADMUXBUS */
 };
 
-struct gpmc_nand_regs {
-       void __iomem    *gpmc_status;
-       void __iomem    *gpmc_nand_command;
-       void __iomem    *gpmc_nand_address;
-       void __iomem    *gpmc_nand_data;
-       void __iomem    *gpmc_prefetch_config1;
-       void __iomem    *gpmc_prefetch_config2;
-       void __iomem    *gpmc_prefetch_control;
-       void __iomem    *gpmc_prefetch_status;
-       void __iomem    *gpmc_ecc_config;
-       void __iomem    *gpmc_ecc_control;
-       void __iomem    *gpmc_ecc_size_config;
-       void __iomem    *gpmc_ecc1_result;
-       void __iomem    *gpmc_bch_result0;
-};
-
 extern void gpmc_update_nand_reg(struct gpmc_nand_regs *reg, int cs);
 extern int gpmc_get_client_irq(unsigned irq_config);
 
index 1a68c1e5fe537a0b0b52c70521ef8672ad66a4ff..e1965fe581d1204cdb7eca19edd780b5b66c4811 100644 (file)
@@ -8,7 +8,9 @@
  * published by the Free Software Foundation.
  */
 
-#include <plat/gpmc.h>
+#ifndef        _MTD_NAND_OMAP2_H
+#define        _MTD_NAND_OMAP2_H
+
 #include <linux/mtd/partitions.h>
 
 enum nand_io {
@@ -18,10 +20,35 @@ enum nand_io {
        NAND_OMAP_PREFETCH_IRQ          /* prefetch enabled irq mode */
 };
 
+enum omap_ecc {
+               /* 1-bit ecc: stored at end of spare area */
+       OMAP_ECC_HAMMING_CODE_DEFAULT = 0, /* Default, s/w method */
+       OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */
+               /* 1-bit ecc: stored at beginning of spare area as romcode */
+       OMAP_ECC_HAMMING_CODE_HW_ROMCODE, /* gpmc method & romcode layout */
+       OMAP_ECC_BCH4_CODE_HW, /* 4-bit BCH ecc code */
+       OMAP_ECC_BCH8_CODE_HW, /* 8-bit BCH ecc code */
+};
+
+struct gpmc_nand_regs {
+       void __iomem    *gpmc_status;
+       void __iomem    *gpmc_nand_command;
+       void __iomem    *gpmc_nand_address;
+       void __iomem    *gpmc_nand_data;
+       void __iomem    *gpmc_prefetch_config1;
+       void __iomem    *gpmc_prefetch_config2;
+       void __iomem    *gpmc_prefetch_control;
+       void __iomem    *gpmc_prefetch_status;
+       void __iomem    *gpmc_ecc_config;
+       void __iomem    *gpmc_ecc_control;
+       void __iomem    *gpmc_ecc_size_config;
+       void __iomem    *gpmc_ecc1_result;
+       void __iomem    *gpmc_bch_result0;
+};
+
 struct omap_nand_platform_data {
        int                     cs;
        struct mtd_partition    *parts;
-       struct gpmc_timings     *gpmc_t;
        int                     nr_parts;
        bool                    dev_ready;
        enum nand_io            xfer_type;
@@ -30,14 +57,4 @@ struct omap_nand_platform_data {
        struct gpmc_nand_regs   reg;
 };
 
-/* minimum size for IO mapping */
-#define        NAND_IO_SIZE    4
-
-#if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
-extern int gpmc_nand_init(struct omap_nand_platform_data *d);
-#else
-static inline int gpmc_nand_init(struct omap_nand_platform_data *d)
-{
-       return 0;
-}
 #endif