aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Damm <damm@igel.co.jp>2009-09-18 15:51:44 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-09-19 14:07:50 -0400
commit778dbcc1ebea6f9a560020110987449bf4607e5f (patch)
tree014ff1122c3dc6551e67bb65bbce6f3281c1fc2b
parentf33dabbe79fdf7a8568c65faa1db7794c87ac4d3 (diff)
mtd: onenand: make onenand/generic.c more generic
Remove the ARM dependency from the generic "onenand" platform device driver. This change makes the driver useful for other architectures as well. Needed for the SuperH kfr2r09 board. Apart from the obvious Kconfig bits, the most important change is the move away from ARM specific includes and platform data. Together with this change the only in-tree board code gets an update, and the driver name is also changed gracefully break potential out of tree drivers. The driver is also updated to allow NULL as platform data together with a few changes to make use of resource_size() and dev_name(). Signed-off-by: Magnus Damm <damm@igel.co.jp> Cc: Paul Mundt <lethal@linux-sh.org> Cc: Tony Lindgren <tony@atomide.com> Cc: Kyungmin Park <kmpark@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r--arch/arm/mach-omap2/board-apollon.c4
-rw-r--r--drivers/mtd/onenand/Kconfig1
-rw-r--r--drivers/mtd/onenand/generic.c24
-rw-r--r--include/linux/mtd/onenand.h8
4 files changed, 24 insertions, 13 deletions
diff --git a/arch/arm/mach-omap2/board-apollon.c b/arch/arm/mach-omap2/board-apollon.c
index dcfc20d03894..b4d4ef6d90b9 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -87,7 +87,7 @@ static struct mtd_partition apollon_partitions[] = {
87 }, 87 },
88}; 88};
89 89
90static struct flash_platform_data apollon_flash_data = { 90static struct onenand_platform_data apollon_flash_data = {
91 .parts = apollon_partitions, 91 .parts = apollon_partitions,
92 .nr_parts = ARRAY_SIZE(apollon_partitions), 92 .nr_parts = ARRAY_SIZE(apollon_partitions),
93}; 93};
@@ -99,7 +99,7 @@ static struct resource apollon_flash_resource[] = {
99}; 99};
100 100
101static struct platform_device apollon_onenand_device = { 101static struct platform_device apollon_onenand_device = {
102 .name = "onenand", 102 .name = "onenand-flash",
103 .id = -1, 103 .id = -1,
104 .dev = { 104 .dev = {
105 .platform_data = &apollon_flash_data, 105 .platform_data = &apollon_flash_data,
diff --git a/drivers/mtd/onenand/Kconfig b/drivers/mtd/onenand/Kconfig
index 3a094d1bf8cc..a38f580c2bb3 100644
--- a/drivers/mtd/onenand/Kconfig
+++ b/drivers/mtd/onenand/Kconfig
@@ -24,7 +24,6 @@ config MTD_ONENAND_VERIFY_WRITE
24 24
25config MTD_ONENAND_GENERIC 25config MTD_ONENAND_GENERIC
26 tristate "OneNAND Flash device via platform device driver" 26 tristate "OneNAND Flash device via platform device driver"
27 depends on ARM
28 help 27 help
29 Support for OneNAND flash via platform device driver. 28 Support for OneNAND flash via platform device driver.
30 29
diff --git a/drivers/mtd/onenand/generic.c b/drivers/mtd/onenand/generic.c
index 3a496c33fb52..e78914938c5c 100644
--- a/drivers/mtd/onenand/generic.c
+++ b/drivers/mtd/onenand/generic.c
@@ -19,12 +19,16 @@
19#include <linux/mtd/mtd.h> 19#include <linux/mtd/mtd.h>
20#include <linux/mtd/onenand.h> 20#include <linux/mtd/onenand.h>
21#include <linux/mtd/partitions.h> 21#include <linux/mtd/partitions.h>
22
23#include <asm/io.h> 22#include <asm/io.h>
24#include <asm/mach/flash.h>
25
26#define DRIVER_NAME "onenand"
27 23
24/*
25 * Note: Driver name and platform data format have been updated!
26 *
27 * This version of the driver is named "onenand-flash" and takes struct
28 * onenand_platform_data as platform data. The old ARM-specific version
29 * with the name "onenand" used to take struct flash_platform_data.
30 */
31#define DRIVER_NAME "onenand-flash"
28 32
29#ifdef CONFIG_MTD_PARTITIONS 33#ifdef CONFIG_MTD_PARTITIONS
30static const char *part_probes[] = { "cmdlinepart", NULL, }; 34static const char *part_probes[] = { "cmdlinepart", NULL, };
@@ -39,16 +43,16 @@ struct onenand_info {
39static int __devinit generic_onenand_probe(struct platform_device *pdev) 43static int __devinit generic_onenand_probe(struct platform_device *pdev)
40{ 44{
41 struct onenand_info *info; 45 struct onenand_info *info;
42 struct flash_platform_data *pdata = pdev->dev.platform_data; 46 struct onenand_platform_data *pdata = pdev->dev.platform_data;
43 struct resource *res = pdev->resource; 47 struct resource *res = pdev->resource;
44 unsigned long size = res->end - res->start + 1; 48 unsigned long size = resource_size(res);
45 int err; 49 int err;
46 50
47 info = kzalloc(sizeof(struct onenand_info), GFP_KERNEL); 51 info = kzalloc(sizeof(struct onenand_info), GFP_KERNEL);
48 if (!info) 52 if (!info)
49 return -ENOMEM; 53 return -ENOMEM;
50 54
51 if (!request_mem_region(res->start, size, pdev->dev.driver->name)) { 55 if (!request_mem_region(res->start, size, dev_name(&pdev->dev))) {
52 err = -EBUSY; 56 err = -EBUSY;
53 goto out_free_info; 57 goto out_free_info;
54 } 58 }
@@ -59,7 +63,7 @@ static int __devinit generic_onenand_probe(struct platform_device *pdev)
59 goto out_release_mem_region; 63 goto out_release_mem_region;
60 } 64 }
61 65
62 info->onenand.mmcontrol = pdata->mmcontrol; 66 info->onenand.mmcontrol = pdata ? pdata->mmcontrol : 0;
63 info->onenand.irq = platform_get_irq(pdev, 0); 67 info->onenand.irq = platform_get_irq(pdev, 0);
64 68
65 info->mtd.name = dev_name(&pdev->dev); 69 info->mtd.name = dev_name(&pdev->dev);
@@ -75,7 +79,7 @@ static int __devinit generic_onenand_probe(struct platform_device *pdev)
75 err = parse_mtd_partitions(&info->mtd, part_probes, &info->parts, 0); 79 err = parse_mtd_partitions(&info->mtd, part_probes, &info->parts, 0);
76 if (err > 0) 80 if (err > 0)
77 add_mtd_partitions(&info->mtd, info->parts, err); 81 add_mtd_partitions(&info->mtd, info->parts, err);
78 else if (err <= 0 && pdata->parts) 82 else if (err <= 0 && pdata && pdata->parts)
79 add_mtd_partitions(&info->mtd, pdata->parts, pdata->nr_parts); 83 add_mtd_partitions(&info->mtd, pdata->parts, pdata->nr_parts);
80 else 84 else
81#endif 85#endif
@@ -99,7 +103,7 @@ static int __devexit generic_onenand_remove(struct platform_device *pdev)
99{ 103{
100 struct onenand_info *info = platform_get_drvdata(pdev); 104 struct onenand_info *info = platform_get_drvdata(pdev);
101 struct resource *res = pdev->resource; 105 struct resource *res = pdev->resource;
102 unsigned long size = res->end - res->start + 1; 106 unsigned long size = resource_size(res);
103 107
104 platform_set_drvdata(pdev, NULL); 108 platform_set_drvdata(pdev, NULL);
105 109
diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h
index 8ed873374381..4e49f3350678 100644
--- a/include/linux/mtd/onenand.h
+++ b/include/linux/mtd/onenand.h
@@ -214,4 +214,12 @@ unsigned onenand_block(struct onenand_chip *this, loff_t addr);
214loff_t onenand_addr(struct onenand_chip *this, int block); 214loff_t onenand_addr(struct onenand_chip *this, int block);
215int flexonenand_region(struct mtd_info *mtd, loff_t addr); 215int flexonenand_region(struct mtd_info *mtd, loff_t addr);
216 216
217struct mtd_partition;
218
219struct onenand_platform_data {
220 void (*mmcontrol)(struct mtd_info *mtd, int sync_read);
221 struct mtd_partition *parts;
222 unsigned int nr_parts;
223};
224
217#endif /* __LINUX_MTD_ONENAND_H */ 225#endif /* __LINUX_MTD_ONENAND_H */