1 --- a/drivers/mtd/maps/Kconfig
2 +++ b/drivers/mtd/maps/Kconfig
5 Support for flash chips on NETtel/SecureEdge/SnapGear 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_RBTX4939) += rbtx4939-flash.o
20 obj-$(CONFIG_MTD_VMU) += vmu-flash.o
21 obj-$(CONFIG_MTD_GPIO_ADDR) += gpio-addr-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>
49 +#include <lantiq_platform.h>
52 +lq_read16(struct map_info *map, unsigned long adr)
54 + unsigned long flags;
56 + spin_lock_irqsave(&ebu_lock, flags);
58 + temp.x[0] = *((__u16 *)(map->virt + adr));
59 + spin_unlock_irqrestore(&ebu_lock, flags);
64 +lq_write16(struct map_info *map, map_word d, unsigned long adr)
66 + unsigned long flags;
67 + spin_lock_irqsave(&ebu_lock, flags);
69 + *((__u16 *)(map->virt + adr)) = d.x[0];
70 + spin_unlock_irqrestore(&ebu_lock, flags);
74 +lq_copy_from(struct map_info *map, void *to,
75 + unsigned long from, ssize_t len)
78 + unsigned char *to_8;
79 + unsigned long flags;
80 + spin_lock_irqsave(&ebu_lock, flags);
81 + from = (unsigned long)(from + map->virt);
82 + p = (unsigned char *) from;
83 + to_8 = (unsigned char *) to;
86 + spin_unlock_irqrestore(&ebu_lock, flags);
90 +lq_copy_to(struct map_info *map, unsigned long to,
91 + const void *from, ssize_t len)
93 + unsigned char *p = (unsigned char *)from;
94 + unsigned char *to_8;
95 + unsigned long flags;
96 + spin_lock_irqsave(&ebu_lock, flags);
97 + to += (unsigned long) map->virt;
98 + to_8 = (unsigned char *)to;
101 + spin_unlock_irqrestore(&ebu_lock, flags);
104 +static const char *part_probe_types[] = { "cmdlinepart", NULL };
106 +static struct map_info lq_map = {
110 + .write = lq_write16,
111 + .copy_from = lq_copy_from,
112 + .copy_to = lq_copy_to,
116 +lq_mtd_probe(struct platform_device *pdev)
118 + struct physmap_flash_data *lq_mtd_data =
119 + (struct physmap_flash_data*) dev_get_platdata(&pdev->dev);
120 + struct mtd_info *lq_mtd = NULL;
121 + struct mtd_partition *parts = NULL;
122 + struct resource *res = 0;
125 +#ifdef CONFIG_SOC_LANTIQ_XWAY
126 + lq_w32(lq_r32(LQ_EBU_BUSCON0) & ~EBU_WRDIS, LQ_EBU_BUSCON0);
129 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
132 + dev_err(&pdev->dev, "failed to get memory resource");
135 + res = request_mem_region(res->start, resource_size(res),
136 + dev_name(&pdev->dev));
139 + dev_err(&pdev->dev, "failed to request mem resource");
143 + lq_map.phys = res->start;
144 + lq_map.size = resource_size(res);
145 + lq_map.virt = ioremap_nocache(lq_map.phys, lq_map.size);
147 + if (!lq_map.virt ) {
148 + dev_err(&pdev->dev, "failed to ioremap!\n");
152 + lq_mtd = (struct mtd_info *) do_map_probe("cfi_probe", &lq_map);
154 + iounmap(lq_map.virt);
155 + dev_err(&pdev->dev, "probing failed\n");
159 + lq_mtd->owner = THIS_MODULE;
161 + nr_parts = parse_mtd_partitions(lq_mtd, part_probe_types, &parts, 0);
162 + if (nr_parts > 0) {
163 + dev_info(&pdev->dev, "using %d partitions from cmdline", nr_parts);
165 + nr_parts = lq_mtd_data->nr_parts;
166 + parts = lq_mtd_data->parts;
169 + add_mtd_partitions(lq_mtd, parts, nr_parts);
173 +static struct platform_driver lq_mtd_driver = {
174 + .probe = lq_mtd_probe,
177 + .owner = THIS_MODULE,
184 + int ret = platform_driver_register(&lq_mtd_driver);
186 + printk(KERN_INFO "lq_nor: error registering platfom driver");
190 +module_init(init_lq_mtd);
192 +MODULE_LICENSE("GPL");
193 +MODULE_AUTHOR("John Crispin <blogic@openwrt.org>");
194 +MODULE_DESCRIPTION("Lantiq SoC NOR");
195 --- a/drivers/mtd/chips/cfi_cmdset_0001.c
196 +++ b/drivers/mtd/chips/cfi_cmdset_0001.c
198 /* #define CMDSET0001_DISABLE_WRITE_SUSPEND */
200 // debugging, turns off buffer write mode if set to 1
201 -#define FORCE_WORD_WRITE 0
202 +#ifdef CONFIG_LANTIQ
203 +# define FORCE_WORD_WRITE 1
205 +# define FORCE_WORD_WRITE 0
209 #define I82802AB 0x00ad
210 @@ -1491,6 +1495,9 @@
214 +#ifdef CONFIG_LANTIQ
220 --- a/drivers/mtd/chips/cfi_cmdset_0002.c
221 +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
223 #include <linux/mtd/xip.h>
225 #define AMD_BOOTLOC_BUG
226 -#define FORCE_WORD_WRITE 0
227 +#ifdef CONFIG_LANTIQ
228 +# define FORCE_WORD_WRITE 1
230 +# define FORCE_WORD_WRITE 0
233 #define MAX_WORD_RETRIES 3
235 @@ -1156,6 +1160,10 @@
239 +#ifdef CONFIG_LANTIQ
243 mutex_lock(&chip->mutex);
244 ret = get_chip(map, chip, adr, FL_WRITING);