mtd: onenand: omap2: obtain memory from resource
authorAfzal Mohammed <afzal@ti.com>
Thu, 30 Aug 2012 19:53:23 +0000 (12:53 -0700)
committerTony Lindgren <tony@atomide.com>
Thu, 30 Aug 2012 19:53:23 +0000 (12:53 -0700)
gpmc initialization for onenand done by platform code now provides
onenand address space as memory resource. Hence remove usage of
gpmc_cs_request in onenand driver and obtain memory details from
resource structure.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Acked-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
drivers/mtd/onenand/omap2.c

index 398a827838480a41b4dbd71d4df4ed4b2a9d6e93..3ff893d4e6ce0d43a4e612e866b48dba5085d8c8 100644 (file)
 
 #define DRIVER_NAME "omap2-onenand"
 
-#define ONENAND_IO_SIZE                SZ_128K
 #define ONENAND_BUFRAM_SIZE    (1024 * 5)
 
 struct omap2_onenand {
        struct platform_device *pdev;
        int gpmc_cs;
        unsigned long phys_base;
+       unsigned int mem_size;
        int gpio_irq;
        struct mtd_info mtd;
        struct onenand_chip onenand;
@@ -626,6 +626,7 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev)
        struct omap2_onenand *c;
        struct onenand_chip *this;
        int r;
+       struct resource *res;
 
        pdata = pdev->dev.platform_data;
        if (pdata == NULL) {
@@ -647,20 +648,24 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev)
                c->gpio_irq = 0;
        }
 
-       r = gpmc_cs_request(c->gpmc_cs, ONENAND_IO_SIZE, &c->phys_base);
-       if (r < 0) {
-               dev_err(&pdev->dev, "Cannot request GPMC CS\n");
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (res == NULL) {
+               r = -EINVAL;
+               dev_err(&pdev->dev, "error getting memory resource\n");
                goto err_kfree;
        }
 
-       if (request_mem_region(c->phys_base, ONENAND_IO_SIZE,
+       c->phys_base = res->start;
+       c->mem_size = resource_size(res);
+
+       if (request_mem_region(c->phys_base, c->mem_size,
                               pdev->dev.driver->name) == NULL) {
-               dev_err(&pdev->dev, "Cannot reserve memory region at 0x%08lx, "
-                       "size: 0x%x\n", c->phys_base, ONENAND_IO_SIZE);
+               dev_err(&pdev->dev, "Cannot reserve memory region at 0x%08lx, size: 0x%x\n",
+                                               c->phys_base, c->mem_size);
                r = -EBUSY;
-               goto err_free_cs;
+               goto err_kfree;
        }
-       c->onenand.base = ioremap(c->phys_base, ONENAND_IO_SIZE);
+       c->onenand.base = ioremap(c->phys_base, c->mem_size);
        if (c->onenand.base == NULL) {
                r = -ENOMEM;
                goto err_release_mem_region;
@@ -776,9 +781,7 @@ err_release_gpio:
 err_iounmap:
        iounmap(c->onenand.base);
 err_release_mem_region:
-       release_mem_region(c->phys_base, ONENAND_IO_SIZE);
-err_free_cs:
-       gpmc_cs_free(c->gpmc_cs);
+       release_mem_region(c->phys_base, c->mem_size);
 err_kfree:
        kfree(c);
 
@@ -800,7 +803,7 @@ static int __devexit omap2_onenand_remove(struct platform_device *pdev)
                gpio_free(c->gpio_irq);
        }
        iounmap(c->onenand.base);
-       release_mem_region(c->phys_base, ONENAND_IO_SIZE);
+       release_mem_region(c->phys_base, c->mem_size);
        gpmc_cs_free(c->gpmc_cs);
        kfree(c);