aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJanusz Krzysztofik <jkrzyszt@tis.icnet.pl>2010-12-15 09:43:44 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2011-01-06 10:28:22 -0500
commiteaca491f75af5afa9265a6bdfcbbfff6837634ab (patch)
tree1dd373ecd237b464cc2ccb252594b84fca5f2ccc /drivers
parentdcf12463c3416b4a8fc84545233424df0a91e406 (diff)
mtd: nand: ams-delta: drop omap_read/write, use ioremap
There is a common requirement for not using OMAP specific omap_readw() / omap_writew() function calls in drivers/, but replace them with readw() / writew() on ioremap()ped addresses passed from arch/ instead. The patch implements this idea for the Amstrad Delta NAND driver. To be able to use the modified driver, the board file is updated with the platform device I/O resource declaration, which is passed from there. Created and tested against linux-2.6.37-rc5, on top of recent patch 'MTD: NAND: ams-delta: convert to platform driver'. Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/nand/ams-delta.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c
index 7d49f6a6b726..a067d090cb31 100644
--- a/drivers/mtd/nand/ams-delta.c
+++ b/drivers/mtd/nand/ams-delta.c
@@ -5,6 +5,7 @@
5 * 5 *
6 * Derived from drivers/mtd/toto.c 6 * Derived from drivers/mtd/toto.c
7 * Converted to platform driver by Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> 7 * Converted to platform driver by Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
8 * Partially stolen from drivers/mtd/nand/plat_nand.c
8 * 9 *
9 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as 11 * it under the terms of the GNU General Public License version 2 as
@@ -63,9 +64,10 @@ static struct mtd_partition partition_info[] = {
63static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) 64static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte)
64{ 65{
65 struct nand_chip *this = mtd->priv; 66 struct nand_chip *this = mtd->priv;
67 void __iomem *io_base = this->priv;
66 68
67 omap_writew(0, (OMAP1_MPUIO_BASE + OMAP_MPUIO_IO_CNTL)); 69 writew(0, io_base + OMAP_MPUIO_IO_CNTL);
68 omap_writew(byte, this->IO_ADDR_W); 70 writew(byte, this->IO_ADDR_W);
69 ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NWE, 0); 71 ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NWE, 0);
70 ndelay(40); 72 ndelay(40);
71 ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NWE, 73 ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NWE,
@@ -76,11 +78,12 @@ static u_char ams_delta_read_byte(struct mtd_info *mtd)
76{ 78{
77 u_char res; 79 u_char res;
78 struct nand_chip *this = mtd->priv; 80 struct nand_chip *this = mtd->priv;
81 void __iomem *io_base = this->priv;
79 82
80 ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NRE, 0); 83 ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NRE, 0);
81 ndelay(40); 84 ndelay(40);
82 omap_writew(~0, (OMAP1_MPUIO_BASE + OMAP_MPUIO_IO_CNTL)); 85 writew(~0, io_base + OMAP_MPUIO_IO_CNTL);
83 res = omap_readw(this->IO_ADDR_R); 86 res = readw(this->IO_ADDR_R);
84 ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NRE, 87 ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NRE,
85 AMS_DELTA_LATCH2_NAND_NRE); 88 AMS_DELTA_LATCH2_NAND_NRE);
86 89
@@ -155,8 +158,13 @@ static int ams_delta_nand_ready(struct mtd_info *mtd)
155static int __devinit ams_delta_init(struct platform_device *pdev) 158static int __devinit ams_delta_init(struct platform_device *pdev)
156{ 159{
157 struct nand_chip *this; 160 struct nand_chip *this;
161 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
162 void __iomem *io_base;
158 int err = 0; 163 int err = 0;
159 164
165 if (!res)
166 return -ENXIO;
167
160 /* Allocate memory for MTD device structure and private data */ 168 /* Allocate memory for MTD device structure and private data */
161 ams_delta_mtd = kmalloc(sizeof(struct mtd_info) + 169 ams_delta_mtd = kmalloc(sizeof(struct mtd_info) +
162 sizeof(struct nand_chip), GFP_KERNEL); 170 sizeof(struct nand_chip), GFP_KERNEL);
@@ -178,9 +186,25 @@ static int __devinit ams_delta_init(struct platform_device *pdev)
178 /* Link the private data with the MTD structure */ 186 /* Link the private data with the MTD structure */
179 ams_delta_mtd->priv = this; 187 ams_delta_mtd->priv = this;
180 188
189 if (!request_mem_region(res->start, resource_size(res),
190 dev_name(&pdev->dev))) {
191 dev_err(&pdev->dev, "request_mem_region failed\n");
192 err = -EBUSY;
193 goto out_free;
194 }
195
196 io_base = ioremap(res->start, resource_size(res));
197 if (io_base == NULL) {
198 dev_err(&pdev->dev, "ioremap failed\n");
199 err = -EIO;
200 goto out_release_io;
201 }
202
203 this->priv = io_base;
204
181 /* Set address of NAND IO lines */ 205 /* Set address of NAND IO lines */
182 this->IO_ADDR_R = (OMAP1_MPUIO_BASE + OMAP_MPUIO_INPUT_LATCH); 206 this->IO_ADDR_R = io_base + OMAP_MPUIO_INPUT_LATCH;
183 this->IO_ADDR_W = (OMAP1_MPUIO_BASE + OMAP_MPUIO_OUTPUT); 207 this->IO_ADDR_W = io_base + OMAP_MPUIO_OUTPUT;
184 this->read_byte = ams_delta_read_byte; 208 this->read_byte = ams_delta_read_byte;
185 this->write_buf = ams_delta_write_buf; 209 this->write_buf = ams_delta_write_buf;
186 this->read_buf = ams_delta_read_buf; 210 this->read_buf = ams_delta_read_buf;
@@ -196,6 +220,8 @@ static int __devinit ams_delta_init(struct platform_device *pdev)
196 this->chip_delay = 30; 220 this->chip_delay = 30;
197 this->ecc.mode = NAND_ECC_SOFT; 221 this->ecc.mode = NAND_ECC_SOFT;
198 222
223 platform_set_drvdata(pdev, io_base);
224
199 /* Set chip enabled, but */ 225 /* Set chip enabled, but */
200 ams_delta_latch2_write(NAND_MASK, AMS_DELTA_LATCH2_NAND_NRE | 226 ams_delta_latch2_write(NAND_MASK, AMS_DELTA_LATCH2_NAND_NRE |
201 AMS_DELTA_LATCH2_NAND_NWE | 227 AMS_DELTA_LATCH2_NAND_NWE |
@@ -215,6 +241,11 @@ static int __devinit ams_delta_init(struct platform_device *pdev)
215 goto out; 241 goto out;
216 242
217 out_mtd: 243 out_mtd:
244 platform_set_drvdata(pdev, NULL);
245 iounmap(io_base);
246out_release_io:
247 release_mem_region(res->start, resource_size(res));
248out_free:
218 kfree(ams_delta_mtd); 249 kfree(ams_delta_mtd);
219 out: 250 out:
220 return err; 251 return err;
@@ -225,9 +256,15 @@ static int __devinit ams_delta_init(struct platform_device *pdev)
225 */ 256 */
226static int __devexit ams_delta_cleanup(struct platform_device *pdev) 257static int __devexit ams_delta_cleanup(struct platform_device *pdev)
227{ 258{
259 void __iomem *io_base = platform_get_drvdata(pdev);
260 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
261
228 /* Release resources, unregister device */ 262 /* Release resources, unregister device */
229 nand_release(ams_delta_mtd); 263 nand_release(ams_delta_mtd);
230 264
265 iounmap(io_base);
266 release_mem_region(res->start, resource_size(res));
267
231 /* Free the MTD device structure */ 268 /* Free the MTD device structure */
232 kfree(ams_delta_mtd); 269 kfree(ams_delta_mtd);
233 270