diff options
author | Dmitry Baryshkov <dbaryshkov@gmail.com> | 2008-10-16 04:08:14 -0400 |
---|---|---|
committer | Dmitry Baryshkov <dbaryshkov@gmail.com> | 2008-10-29 14:06:37 -0400 |
commit | 26615249daaaa9fc194b5154261b9569112ea9fd (patch) | |
tree | 78fbfb6af9f9f067b300267eee9eaf5bfe0a55d7 /drivers/mtd/nand | |
parent | 0173a3265b228da319ceb9c1ec6a5682fd1b2d92 (diff) |
[MTD] sharpsl_nand: switch to driver model usage.
Start cleanup of sharpsl_nand driver. Convert it to platform driver.
Corresponding device is temprorary registered in sharpsl.c but will be
later moved to corresponding board files.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r-- | drivers/mtd/nand/sharpsl.c | 63 |
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 | ||
27 | static void __iomem *sharpsl_io_base; | 29 | static void __iomem *sharpsl_io_base; |
28 | static 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 | */ |
153 | static int __init sharpsl_nand_init(void) | 154 | static 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 | ||
247 | module_init(sharpsl_nand_init); | 255 | err_get_res: |
256 | kfree(sharpsl_mtd); | ||
257 | return err; | ||
258 | } | ||
248 | 259 | ||
249 | /* | 260 | /* |
250 | * Clean up routine | 261 | * Clean up routine |
251 | */ | 262 | */ |
252 | static void __exit sharpsl_nand_cleanup(void) | 263 | static 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 | |||
276 | static 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 | |||
285 | static struct resource sharpsl_nand_resources[] = { | ||
286 | { | ||
287 | .start = 0x0C000000, | ||
288 | .end = 0x0C000FFF, | ||
289 | .flags = IORESOURCE_MEM, | ||
290 | }, | ||
291 | }; | ||
292 | |||
293 | static 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 | |||
300 | static int __init sharpsl_nand_init(void) | ||
301 | { | ||
302 | platform_device_register(&sharpsl_nand_device); | ||
303 | return platform_driver_register(&sharpsl_nand_driver); | ||
261 | } | 304 | } |
305 | module_init(sharpsl_nand_init); | ||
262 | 306 | ||
263 | module_exit(sharpsl_nand_cleanup); | 307 | static void __exit sharpsl_nand_exit(void) |
308 | { | ||
309 | platform_driver_unregister(&sharpsl_nand_driver); | ||
310 | platform_device_unregister(&sharpsl_nand_device); | ||
311 | } | ||
312 | module_exit(sharpsl_nand_exit); | ||
264 | 313 | ||
265 | MODULE_LICENSE("GPL"); | 314 | MODULE_LICENSE("GPL"); |
266 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); | 315 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); |