diff options
author | Afzal Mohammed <afzal@ti.com> | 2012-08-30 15:53:23 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2012-08-30 15:53:23 -0400 |
commit | 9c4c2f8b91a8bcc431d1c033e4d4455479b8183b (patch) | |
tree | ba37152e231c1bb3c3c33a50b304181a8c68ea5a /drivers | |
parent | 681988ba0c369795def0346d210ce96d6177059a (diff) |
mtd: nand: omap2: obtain memory from resource
gpmc initialization done by platform code now updates struct resource
with the address space alloted for nand. Use this interface to obtain
memory rather than relying on platform data field - phys_base.
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/nand/omap2.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c index 52fc089d5bcb..3578c633e97e 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c | |||
@@ -134,6 +134,7 @@ struct omap_nand_info { | |||
134 | 134 | ||
135 | int gpmc_cs; | 135 | int gpmc_cs; |
136 | unsigned long phys_base; | 136 | unsigned long phys_base; |
137 | unsigned long mem_size; | ||
137 | struct completion comp; | 138 | struct completion comp; |
138 | struct dma_chan *dma; | 139 | struct dma_chan *dma; |
139 | int gpmc_irq; | 140 | int gpmc_irq; |
@@ -1270,6 +1271,7 @@ static int __devinit omap_nand_probe(struct platform_device *pdev) | |||
1270 | int i, offset; | 1271 | int i, offset; |
1271 | dma_cap_mask_t mask; | 1272 | dma_cap_mask_t mask; |
1272 | unsigned sig; | 1273 | unsigned sig; |
1274 | struct resource *res; | ||
1273 | 1275 | ||
1274 | pdata = pdev->dev.platform_data; | 1276 | pdata = pdev->dev.platform_data; |
1275 | if (pdata == NULL) { | 1277 | if (pdata == NULL) { |
@@ -1289,7 +1291,6 @@ static int __devinit omap_nand_probe(struct platform_device *pdev) | |||
1289 | info->pdev = pdev; | 1291 | info->pdev = pdev; |
1290 | 1292 | ||
1291 | info->gpmc_cs = pdata->cs; | 1293 | info->gpmc_cs = pdata->cs; |
1292 | info->phys_base = pdata->phys_base; | ||
1293 | info->reg = pdata->reg; | 1294 | info->reg = pdata->reg; |
1294 | 1295 | ||
1295 | info->mtd.priv = &info->nand; | 1296 | info->mtd.priv = &info->nand; |
@@ -1302,13 +1303,23 @@ static int __devinit omap_nand_probe(struct platform_device *pdev) | |||
1302 | /* NAND write protect off */ | 1303 | /* NAND write protect off */ |
1303 | gpmc_cs_configure(info->gpmc_cs, GPMC_CONFIG_WP, 0); | 1304 | gpmc_cs_configure(info->gpmc_cs, GPMC_CONFIG_WP, 0); |
1304 | 1305 | ||
1305 | if (!request_mem_region(info->phys_base, NAND_IO_SIZE, | 1306 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1307 | if (res == NULL) { | ||
1308 | err = -EINVAL; | ||
1309 | dev_err(&pdev->dev, "error getting memory resource\n"); | ||
1310 | goto out_free_info; | ||
1311 | } | ||
1312 | |||
1313 | info->phys_base = res->start; | ||
1314 | info->mem_size = resource_size(res); | ||
1315 | |||
1316 | if (!request_mem_region(info->phys_base, info->mem_size, | ||
1306 | pdev->dev.driver->name)) { | 1317 | pdev->dev.driver->name)) { |
1307 | err = -EBUSY; | 1318 | err = -EBUSY; |
1308 | goto out_free_info; | 1319 | goto out_free_info; |
1309 | } | 1320 | } |
1310 | 1321 | ||
1311 | info->nand.IO_ADDR_R = ioremap(info->phys_base, NAND_IO_SIZE); | 1322 | info->nand.IO_ADDR_R = ioremap(info->phys_base, info->mem_size); |
1312 | if (!info->nand.IO_ADDR_R) { | 1323 | if (!info->nand.IO_ADDR_R) { |
1313 | err = -ENOMEM; | 1324 | err = -ENOMEM; |
1314 | goto out_release_mem_region; | 1325 | goto out_release_mem_region; |
@@ -1479,7 +1490,7 @@ static int __devinit omap_nand_probe(struct platform_device *pdev) | |||
1479 | out_release_mem_region: | 1490 | out_release_mem_region: |
1480 | if (info->dma) | 1491 | if (info->dma) |
1481 | dma_release_channel(info->dma); | 1492 | dma_release_channel(info->dma); |
1482 | release_mem_region(info->phys_base, NAND_IO_SIZE); | 1493 | release_mem_region(info->phys_base, info->mem_size); |
1483 | out_free_info: | 1494 | out_free_info: |
1484 | kfree(info); | 1495 | kfree(info); |
1485 | 1496 | ||