summaryrefslogtreecommitdiff
path: root/cleopatre/linux-2.6.25.10/drivers/mtd/maps/spc300_nor.c
diff options
context:
space:
mode:
Diffstat (limited to 'cleopatre/linux-2.6.25.10/drivers/mtd/maps/spc300_nor.c')
-rw-r--r--cleopatre/linux-2.6.25.10/drivers/mtd/maps/spc300_nor.c155
1 files changed, 155 insertions, 0 deletions
diff --git a/cleopatre/linux-2.6.25.10/drivers/mtd/maps/spc300_nor.c b/cleopatre/linux-2.6.25.10/drivers/mtd/maps/spc300_nor.c
new file mode 100644
index 0000000000..66aa6ff242
--- /dev/null
+++ b/cleopatre/linux-2.6.25.10/drivers/mtd/maps/spc300_nor.c
@@ -0,0 +1,155 @@
+/*
+ * drivers/mtd/maps/spc300_nor.c
+ *
+ * Copyright (C) 2009 SPiDCOM Technologies
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/slab.h>
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/io.h>
+#include <asm/hardware.h>
+#include <asm/mach/flash.h>
+
+struct spc300flash_info {
+ struct mtd_partition *parts;
+ struct mtd_info *mtd;
+ struct map_info map;
+};
+
+static int __devinit spc300flash_probe(struct platform_device *pdev)
+{
+ int err;
+ struct spc300flash_info *info;
+ struct flash_platform_data *pdata = pdev->dev.platform_data;
+ struct resource *res = pdev->resource;
+ unsigned long size = res->end - res->start + 1;
+
+ info = kzalloc(sizeof(struct spc300flash_info), GFP_KERNEL);
+ if(!info)
+ return -ENOMEM;
+
+ if(!request_mem_region(res->start, size, "flash"))
+ {
+ err = -EBUSY;
+ goto out_free_info;
+ }
+
+ info->map.virt = ioremap(res->start, size);
+ if(!info->map.virt) {
+ err = -ENOMEM;
+ goto out_release_mem_region;
+ }
+ info->map.name = pdev->dev.bus_id;
+ info->map.phys = res->start;
+ info->map.size = size;
+ info->map.bankwidth = pdata->width;
+ simple_map_init(&info->map);
+
+ info->mtd = do_map_probe(pdata->map_name, &info->map);
+ if(!info->mtd)
+ {
+ err = -EIO;
+ goto out_iounmap;
+ }
+ info->mtd->owner = THIS_MODULE;
+
+ if(pdata->parts)
+ {
+ add_mtd_partitions(info->mtd, pdata->parts, pdata->nr_parts);
+ info->parts = pdata->parts;
+ }
+ else
+ {
+ add_mtd_device(info->mtd);
+ }
+
+ platform_set_drvdata(pdev, info);
+
+ return 0;
+
+out_iounmap:
+ iounmap(info->map.virt);
+out_release_mem_region:
+ release_mem_region(res->start, size);
+out_free_info:
+ kfree(info);
+
+ return err;
+}
+
+static int __exit spc300flash_remove(struct platform_device *pdev)
+{
+ struct spc300flash_info *info = platform_get_drvdata(pdev);
+
+ platform_set_drvdata(pdev, NULL);
+
+ if(info)
+ {
+ if(info->parts)
+ {
+ del_mtd_partitions(info->mtd);
+ }
+ else
+ {
+ del_mtd_device(info->mtd);
+ }
+ map_destroy(info->mtd);
+ release_mem_region(info->map.phys, info->map.size);
+ iounmap((void __iomem *) info->map.virt);
+ kfree(info);
+ }
+
+ return 0;
+}
+
+static struct platform_driver spc300flash_driver = {
+ .probe = spc300flash_probe,
+ .remove = __exit_p(spc300flash_remove),
+ .driver = {
+ .name = "spc300norflash",
+ },
+};
+
+static int __init spc300flash_init(void)
+{
+ return platform_driver_register(&spc300flash_driver);
+}
+
+static void __exit spc300flash_exit(void)
+{
+ platform_driver_unregister(&spc300flash_driver);
+}
+
+module_init(spc300flash_init);
+module_exit(spc300flash_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR ("SPiDCOM Technologies");
+MODULE_DESCRIPTION("MTD NOR map driver for SPC300 boards");
+