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