aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/sharpsl.c63
1 files changed, 56 insertions, 7 deletions
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c
index 30a518e211bd..0a99188a7730 100644
--- a/drivers/mtd/nand/sharpsl.c
+++ b/drivers/mtd/nand/sharpsl.c
@@ -20,12 +20,13 @@
20#include <linux/mtd/nand_ecc.h> 20#include <linux/mtd/nand_ecc.h>
21#include <linux/mtd/partitions.h> 21#include <linux/mtd/partitions.h>
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/platform_device.h>
24
23#include <asm/io.h> 25#include <asm/io.h>
24#include <mach/hardware.h> 26#include <mach/hardware.h>
25#include <asm/mach-types.h> 27#include <asm/mach-types.h>
26 28
27static void __iomem *sharpsl_io_base; 29static void __iomem *sharpsl_io_base;
28static int sharpsl_phys_base = 0x0C000000;
29 30
30/* register offset */ 31/* register offset */
31#define ECCLPLB sharpsl_io_base+0x00 /* line parity 7 - 0 bit */ 32#define ECCLPLB sharpsl_io_base+0x00 /* line parity 7 - 0 bit */
@@ -150,10 +151,11 @@ const char *part_probes[] = { "cmdlinepart", NULL };
150/* 151/*
151 * Main initialization routine 152 * Main initialization routine
152 */ 153 */
153static int __init sharpsl_nand_init(void) 154static int __devinit sharpsl_nand_probe(struct platform_device *pdev)
154{ 155{
155 struct nand_chip *this; 156 struct nand_chip *this;
156 struct mtd_partition *sharpsl_partition_info; 157 struct mtd_partition *sharpsl_partition_info;
158 struct resource *r;
157 int err = 0; 159 int err = 0;
158 160
159 /* Allocate memory for MTD device structure and private data */ 161 /* Allocate memory for MTD device structure and private data */
@@ -163,8 +165,15 @@ static int __init sharpsl_nand_init(void)
163 return -ENOMEM; 165 return -ENOMEM;
164 } 166 }
165 167
168 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
169 if (!r) {
170 dev_err(&pdev->dev, "no io memory resource defined!\n");
171 err = -ENODEV;
172 goto err_get_res;
173 }
174
166 /* map physical address */ 175 /* map physical address */
167 sharpsl_io_base = ioremap(sharpsl_phys_base, 0x1000); 176 sharpsl_io_base = ioremap(r->start, resource_size(r));
168 if (!sharpsl_io_base) { 177 if (!sharpsl_io_base) {
169 printk("ioremap to access Sharp SL NAND chip failed\n"); 178 printk("ioremap to access Sharp SL NAND chip failed\n");
170 kfree(sharpsl_mtd); 179 kfree(sharpsl_mtd);
@@ -242,14 +251,16 @@ static int __init sharpsl_nand_init(void)
242 251
243 /* Return happy */ 252 /* Return happy */
244 return 0; 253 return 0;
245}
246 254
247module_init(sharpsl_nand_init); 255err_get_res:
256 kfree(sharpsl_mtd);
257 return err;
258}
248 259
249/* 260/*
250 * Clean up routine 261 * Clean up routine
251 */ 262 */
252static void __exit sharpsl_nand_cleanup(void) 263static int __devexit sharpsl_nand_remove(struct platform_device *pdev)
253{ 264{
254 /* Release resources, unregister device */ 265 /* Release resources, unregister device */
255 nand_release(sharpsl_mtd); 266 nand_release(sharpsl_mtd);
@@ -258,9 +269,47 @@ static void __exit sharpsl_nand_cleanup(void)
258 269
259 /* Free the MTD device structure */ 270 /* Free the MTD device structure */
260 kfree(sharpsl_mtd); 271 kfree(sharpsl_mtd);
272
273 return 0;
274}
275
276static struct platform_driver sharpsl_nand_driver = {
277 .driver = {
278 .name = "sharpsl-nand",
279 .owner = THIS_MODULE,
280 },
281 .probe = sharpsl_nand_probe,
282 .remove = __devexit_p(sharpsl_nand_remove),
283};
284
285static struct resource sharpsl_nand_resources[] = {
286 {
287 .start = 0x0C000000,
288 .end = 0x0C000FFF,
289 .flags = IORESOURCE_MEM,
290 },
291};
292
293static struct platform_device sharpsl_nand_device = {
294 .name = "sharpsl-nand",
295 .id = -1,
296 .resource = sharpsl_nand_resources,
297 .num_resources = ARRAY_SIZE(sharpsl_nand_resources),
298};
299
300static int __init sharpsl_nand_init(void)
301{
302 platform_device_register(&sharpsl_nand_device);
303 return platform_driver_register(&sharpsl_nand_driver);
261} 304}
305module_init(sharpsl_nand_init);
262 306
263module_exit(sharpsl_nand_cleanup); 307static void __exit sharpsl_nand_exit(void)
308{
309 platform_driver_unregister(&sharpsl_nand_driver);
310 platform_device_unregister(&sharpsl_nand_device);
311}
312module_exit(sharpsl_nand_exit);
264 313
265MODULE_LICENSE("GPL"); 314MODULE_LICENSE("GPL");
266MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); 315MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");