Re: [PATCH 06/36] mtd: nand: omap: Move gpmc_update_nand_reg to nand driver

2014-06-13 Thread Tony Lindgren
* Roger Quadros  [140611 01:58]:
> GPMC and NAND drivers share the same register space but never use the
> same registers. As there is no clear address seperation between the
> registers for GPMC and NAND, we can't easily split it up into 2 regions
> i.e. one for GPMC and other for NAND. Instead, we simply remap the entire
> register space in both the drivers. The NAND driver doesn't re-request
> the region as it is already requested by the GPMC driver (parent).

Oh now, let's not do this. It's best to limit GPMC register access
to the GPMC driver. Even if we need to export few NAND specific
functions from the GPMC driver.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/36] mtd: nand: omap: Move gpmc_update_nand_reg to nand driver

2014-06-11 Thread Roger Quadros
GPMC and NAND drivers share the same register space but never use the
same registers. As there is no clear address seperation between the
registers for GPMC and NAND, we can't easily split it up into 2 regions
i.e. one for GPMC and other for NAND. Instead, we simply remap the entire
register space in both the drivers. The NAND driver doesn't re-request
the region as it is already requested by the GPMC driver (parent).

Signed-off-by: Roger Quadros 
---
 arch/arm/mach-omap2/gpmc-nand.c  |  16 +++-
 arch/arm/mach-omap2/gpmc.c   |  34 +---
 arch/arm/mach-omap2/gpmc.h   |   5 +-
 drivers/mtd/nand/omap2.c | 123 ---
 include/linux/platform_data/mtd-nand-omap2.h |   3 +-
 5 files changed, 127 insertions(+), 54 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc-nand.c b/arch/arm/mach-omap2/gpmc-nand.c
index 3e6420b..aaebd2f 100644
--- a/arch/arm/mach-omap2/gpmc-nand.c
+++ b/arch/arm/mach-omap2/gpmc-nand.c
@@ -26,11 +26,16 @@
 
 static struct resource gpmc_nand_resource[] = {
{
+   /* GPMC I/O space */
.flags  = IORESOURCE_MEM,
},
{
-   .flags  = IORESOURCE_IRQ,
+   /* GPMC register space */
+   .flags  = IORESOURCE_MEM,
},
+   {
+   .flags  = IORESOURCE_IRQ,
+   }
 };
 
 static struct platform_device gpmc_nand_device = {
@@ -91,6 +96,7 @@ int gpmc_nand_init(struct omap_nand_platform_data 
*gpmc_nand_data,
int err = 0;
struct gpmc_settings s;
struct device *dev = &gpmc_nand_device.dev;
+   struct resource res;
 
memset(&s, 0, sizeof(struct gpmc_settings));
 
@@ -107,7 +113,11 @@ int gpmc_nand_init(struct omap_nand_platform_data 
*gpmc_nand_data,
gpmc_nand_resource[0].end = gpmc_nand_resource[0].start +
NAND_IO_SIZE - 1;
 
-   gpmc_nand_resource[1].start = gpmc_get_irq();
+   gpmc_get_mem_resource(&res);
+   gpmc_nand_resource[1].start = res.start;
+   gpmc_nand_resource[1].end = res.end;
+
+   gpmc_nand_resource[2].start = gpmc_get_irq();
 
if (gpmc_t) {
err = gpmc_cs_set_timings(gpmc_nand_data->cs, gpmc_t);
@@ -132,8 +142,6 @@ int gpmc_nand_init(struct omap_nand_platform_data 
*gpmc_nand_data,
if (err < 0)
goto out_free_cs;
 
-   gpmc_update_nand_reg(&gpmc_nand_data->reg, gpmc_nand_data->cs);
-
if (!gpmc_hwecc_bch_capable(gpmc_nand_data->ecc_opt)) {
dev_err(dev, "Unsupported NAND ECC scheme selected\n");
return -EINVAL;
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 2524541..0a8b6ca 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -625,38 +625,10 @@ int gpmc_configure(int cmd, int wval)
 }
 EXPORT_SYMBOL(gpmc_configure);
 
-void gpmc_update_nand_reg(struct gpmc_nand_regs *reg, int cs)
+void gpmc_get_mem_resource(struct resource *res)
 {
-   int i;
-
-   reg->gpmc_status = gpmc_base + GPMC_STATUS;
-   reg->gpmc_irqstatus = gpmc_base + GPMC_IRQSTATUS;
-   reg->gpmc_irqenable = gpmc_base + GPMC_IRQENABLE;
-   reg->gpmc_nand_command = gpmc_base + GPMC_CS0_OFFSET +
-   GPMC_CS_NAND_COMMAND + GPMC_CS_SIZE * cs;
-   reg->gpmc_nand_address = gpmc_base + GPMC_CS0_OFFSET +
-   GPMC_CS_NAND_ADDRESS + GPMC_CS_SIZE * cs;
-   reg->gpmc_nand_data = gpmc_base + GPMC_CS0_OFFSET +
-   GPMC_CS_NAND_DATA + GPMC_CS_SIZE * cs;
-   reg->gpmc_prefetch_config1 = gpmc_base + GPMC_PREFETCH_CONFIG1;
-   reg->gpmc_prefetch_config2 = gpmc_base + GPMC_PREFETCH_CONFIG2;
-   reg->gpmc_prefetch_control = gpmc_base + GPMC_PREFETCH_CONTROL;
-   reg->gpmc_prefetch_status = gpmc_base + GPMC_PREFETCH_STATUS;
-   reg->gpmc_ecc_config = gpmc_base + GPMC_ECC_CONFIG;
-   reg->gpmc_ecc_control = gpmc_base + GPMC_ECC_CONTROL;
-   reg->gpmc_ecc_size_config = gpmc_base + GPMC_ECC_SIZE_CONFIG;
-   reg->gpmc_ecc1_result = gpmc_base + GPMC_ECC1_RESULT;
-
-   for (i = 0; i < GPMC_BCH_NUM_REMAINDER; i++) {
-   reg->gpmc_bch_result0[i] = gpmc_base + GPMC_ECC_BCH_RESULT_0 +
-  GPMC_BCH_SIZE * i;
-   reg->gpmc_bch_result1[i] = gpmc_base + GPMC_ECC_BCH_RESULT_1 +
-  GPMC_BCH_SIZE * i;
-   reg->gpmc_bch_result2[i] = gpmc_base + GPMC_ECC_BCH_RESULT_2 +
-  GPMC_BCH_SIZE * i;
-   reg->gpmc_bch_result3[i] = gpmc_base + GPMC_ECC_BCH_RESULT_3 +
-  GPMC_BCH_SIZE * i;
-   }
+   res->start =  phys_base;
+   res->end = res->start + mem_size - 1;
 }
 
 int gpmc_get_irq(void)
diff --git a/arch/arm/mach-omap2/gpmc.h b/arch/