aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/onenand/omap2.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/onenand/omap2.c')
-rw-r--r--drivers/mtd/onenand/omap2.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c
index 398a82783848..9d49b1f4ff53 100644
--- a/drivers/mtd/onenand/omap2.c
+++ b/drivers/mtd/onenand/omap2.c
@@ -43,18 +43,17 @@
43#include <asm/gpio.h> 43#include <asm/gpio.h>
44 44
45#include <plat/dma.h> 45#include <plat/dma.h>
46 46#include <plat/cpu.h>
47#include <plat/board.h>
48 47
49#define DRIVER_NAME "omap2-onenand" 48#define DRIVER_NAME "omap2-onenand"
50 49
51#define ONENAND_IO_SIZE SZ_128K
52#define ONENAND_BUFRAM_SIZE (1024 * 5) 50#define ONENAND_BUFRAM_SIZE (1024 * 5)
53 51
54struct omap2_onenand { 52struct omap2_onenand {
55 struct platform_device *pdev; 53 struct platform_device *pdev;
56 int gpmc_cs; 54 int gpmc_cs;
57 unsigned long phys_base; 55 unsigned long phys_base;
56 unsigned int mem_size;
58 int gpio_irq; 57 int gpio_irq;
59 struct mtd_info mtd; 58 struct mtd_info mtd;
60 struct onenand_chip onenand; 59 struct onenand_chip onenand;
@@ -626,6 +625,7 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev)
626 struct omap2_onenand *c; 625 struct omap2_onenand *c;
627 struct onenand_chip *this; 626 struct onenand_chip *this;
628 int r; 627 int r;
628 struct resource *res;
629 629
630 pdata = pdev->dev.platform_data; 630 pdata = pdev->dev.platform_data;
631 if (pdata == NULL) { 631 if (pdata == NULL) {
@@ -647,20 +647,24 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev)
647 c->gpio_irq = 0; 647 c->gpio_irq = 0;
648 } 648 }
649 649
650 r = gpmc_cs_request(c->gpmc_cs, ONENAND_IO_SIZE, &c->phys_base); 650 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
651 if (r < 0) { 651 if (res == NULL) {
652 dev_err(&pdev->dev, "Cannot request GPMC CS\n"); 652 r = -EINVAL;
653 dev_err(&pdev->dev, "error getting memory resource\n");
653 goto err_kfree; 654 goto err_kfree;
654 } 655 }
655 656
656 if (request_mem_region(c->phys_base, ONENAND_IO_SIZE, 657 c->phys_base = res->start;
658 c->mem_size = resource_size(res);
659
660 if (request_mem_region(c->phys_base, c->mem_size,
657 pdev->dev.driver->name) == NULL) { 661 pdev->dev.driver->name) == NULL) {
658 dev_err(&pdev->dev, "Cannot reserve memory region at 0x%08lx, " 662 dev_err(&pdev->dev, "Cannot reserve memory region at 0x%08lx, size: 0x%x\n",
659 "size: 0x%x\n", c->phys_base, ONENAND_IO_SIZE); 663 c->phys_base, c->mem_size);
660 r = -EBUSY; 664 r = -EBUSY;
661 goto err_free_cs; 665 goto err_kfree;
662 } 666 }
663 c->onenand.base = ioremap(c->phys_base, ONENAND_IO_SIZE); 667 c->onenand.base = ioremap(c->phys_base, c->mem_size);
664 if (c->onenand.base == NULL) { 668 if (c->onenand.base == NULL) {
665 r = -ENOMEM; 669 r = -ENOMEM;
666 goto err_release_mem_region; 670 goto err_release_mem_region;
@@ -776,9 +780,7 @@ err_release_gpio:
776err_iounmap: 780err_iounmap:
777 iounmap(c->onenand.base); 781 iounmap(c->onenand.base);
778err_release_mem_region: 782err_release_mem_region:
779 release_mem_region(c->phys_base, ONENAND_IO_SIZE); 783 release_mem_region(c->phys_base, c->mem_size);
780err_free_cs:
781 gpmc_cs_free(c->gpmc_cs);
782err_kfree: 784err_kfree:
783 kfree(c); 785 kfree(c);
784 786
@@ -800,7 +802,7 @@ static int __devexit omap2_onenand_remove(struct platform_device *pdev)
800 gpio_free(c->gpio_irq); 802 gpio_free(c->gpio_irq);
801 } 803 }
802 iounmap(c->onenand.base); 804 iounmap(c->onenand.base);
803 release_mem_region(c->phys_base, ONENAND_IO_SIZE); 805 release_mem_region(c->phys_base, c->mem_size);
804 gpmc_cs_free(c->gpmc_cs); 806 gpmc_cs_free(c->gpmc_cs);
805 kfree(c); 807 kfree(c);
806 808