1 --- a/drivers/mtd/maps/Kconfig
2 +++ b/drivers/mtd/maps/Kconfig
4 Support for parsing CFE image tag and creating MTD partitions on
5 Broadcom BCM63xx boards.
8 + bool "Lantiq SoC NOR support"
9 + depends on LANTIQ && MTD_PARTITIONS
11 + Support for NOR flsh chips on Lantiq SoC
14 tristate "CFI Flash device mapped on DIL/Net PC"
15 depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT && BROKEN
16 --- a/drivers/mtd/maps/Makefile
17 +++ b/drivers/mtd/maps/Makefile
19 obj-$(CONFIG_MTD_VMU) += vmu-flash.o
20 obj-$(CONFIG_MTD_GPIO_ADDR) += gpio-addr-flash.o
21 obj-$(CONFIG_MTD_BCM963XX) += bcm963xx-flash.o
22 +obj-$(CONFIG_MTD_LANTIQ) += lantiq.o
24 +++ b/drivers/mtd/maps/lantiq.c
27 + * This program is free software; you can redistribute it and/or modify it
28 + * under the terms of the GNU General Public License version 2 as published
29 + * by the Free Software Foundation.
31 + * Copyright (C) 2004 Liu Peng Infineon IFAP DC COM CPE
32 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
35 +#include <linux/module.h>
36 +#include <linux/types.h>
37 +#include <linux/kernel.h>
38 +#include <linux/io.h>
39 +#include <linux/init.h>
40 +#include <linux/mtd/mtd.h>
41 +#include <linux/mtd/map.h>
42 +#include <linux/mtd/partitions.h>
43 +#include <linux/mtd/cfi.h>
44 +#include <linux/magic.h>
45 +#include <linux/platform_device.h>
46 +#include <linux/mtd/physmap.h>
47 +#include <linux/mtd/cfi.h>
50 +#include <lantiq_platform.h>
52 +#ifdef CONFIG_SOC_LANTIQ_XWAY
55 +static int ltq_mtd_probing;
58 +lq_read16(struct map_info *map, unsigned long adr)
60 + unsigned long flags;
62 + spin_lock_irqsave(&ebu_lock, flags);
63 + if (ltq_mtd_probing)
65 + temp.x[0] = *((__u16 *)(map->virt + adr));
66 + spin_unlock_irqrestore(&ebu_lock, flags);
71 +lq_write16(struct map_info *map, map_word d, unsigned long adr)
73 + unsigned long flags;
74 + spin_lock_irqsave(&ebu_lock, flags);
75 + if (ltq_mtd_probing)
77 + *((__u16 *)(map->virt + adr)) = d.x[0];
78 + spin_unlock_irqrestore(&ebu_lock, flags);
82 +lq_copy_from(struct map_info *map, void *to,
83 + unsigned long from, ssize_t len)
86 + unsigned char *to_8;
87 + unsigned long flags;
88 + spin_lock_irqsave(&ebu_lock, flags);
89 + from = (unsigned long)(from + map->virt);
90 + p = (unsigned char *) from;
91 + to_8 = (unsigned char *) to;
94 + spin_unlock_irqrestore(&ebu_lock, flags);
98 +lq_copy_to(struct map_info *map, unsigned long to,
99 + const void *from, ssize_t len)
101 + unsigned char *p = (unsigned char *)from;
102 + unsigned char *to_8;
103 + unsigned long flags;
104 + spin_lock_irqsave(&ebu_lock, flags);
105 + to += (unsigned long) map->virt;
106 + to_8 = (unsigned char *)to;
109 + spin_unlock_irqrestore(&ebu_lock, flags);
112 +static const char *part_probe_types[] = { "cmdlinepart", NULL };
114 +static struct map_info lq_map = {
118 + .write = lq_write16,
119 + .copy_from = lq_copy_from,
120 + .copy_to = lq_copy_to,
124 +lq_mtd_probe(struct platform_device *pdev)
126 + struct physmap_flash_data *lq_mtd_data =
127 + (struct physmap_flash_data*) dev_get_platdata(&pdev->dev);
128 + struct mtd_info *lq_mtd = NULL;
129 + struct mtd_partition *parts = NULL;
130 + struct resource *res = 0;
132 + struct cfi_private *cfi;
134 +#ifdef CONFIG_SOC_LANTIQ_XWAY
135 + lq_w32(lq_r32(LQ_EBU_BUSCON0) & ~EBU_WRDIS, LQ_EBU_BUSCON0);
138 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
141 + dev_err(&pdev->dev, "failed to get memory resource");
144 + res = request_mem_region(res->start, resource_size(res),
145 + dev_name(&pdev->dev));
148 + dev_err(&pdev->dev, "failed to request mem resource");
152 + lq_map.phys = res->start;
153 + lq_map.size = resource_size(res);
154 + lq_map.virt = ioremap_nocache(lq_map.phys, lq_map.size);
156 + if (!lq_map.virt ) {
157 + dev_err(&pdev->dev, "failed to ioremap!\n");
161 + ltq_mtd_probing = 1;
162 + lq_mtd = (struct mtd_info *) do_map_probe("cfi_probe", &lq_map);
163 + ltq_mtd_probing = 0;
165 + iounmap(lq_map.virt);
166 + dev_err(&pdev->dev, "probing failed\n");
170 + lq_mtd->owner = THIS_MODULE;
171 + cfi = lq_map.fldrv_priv;
172 + cfi->addr_unlock1 ^= 1;
173 + cfi->addr_unlock2 ^= 1;
175 + nr_parts = parse_mtd_partitions(lq_mtd, part_probe_types, &parts, 0);
176 + if (nr_parts > 0) {
177 + dev_info(&pdev->dev, "using %d partitions from cmdline", nr_parts);
179 + nr_parts = lq_mtd_data->nr_parts;
180 + parts = lq_mtd_data->parts;
183 + add_mtd_partitions(lq_mtd, parts, nr_parts);
187 +static struct platform_driver lq_mtd_driver = {
188 + .probe = lq_mtd_probe,
191 + .owner = THIS_MODULE,
198 + int ret = platform_driver_register(&lq_mtd_driver);
200 + printk(KERN_INFO "lq_nor: error registering platfom driver");
204 +module_init(init_lq_mtd);
206 +MODULE_LICENSE("GPL");
207 +MODULE_AUTHOR("John Crispin <blogic@openwrt.org>");
208 +MODULE_DESCRIPTION("Lantiq SoC NOR");