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>
49 +#include <lantiq_platform.h>
51 +#ifdef CONFIG_SOC_LANTIQ_XWAY
56 +lq_read16(struct map_info *map, unsigned long adr)
58 + unsigned long flags;
60 + spin_lock_irqsave(&ebu_lock, flags);
62 + temp.x[0] = *((__u16 *)(map->virt + adr));
63 + spin_unlock_irqrestore(&ebu_lock, flags);
68 +lq_write16(struct map_info *map, map_word d, unsigned long adr)
70 + unsigned long flags;
71 + spin_lock_irqsave(&ebu_lock, flags);
73 + *((__u16 *)(map->virt + adr)) = d.x[0];
74 + spin_unlock_irqrestore(&ebu_lock, flags);
78 +lq_copy_from(struct map_info *map, void *to,
79 + unsigned long from, ssize_t len)
82 + unsigned char *to_8;
83 + unsigned long flags;
84 + spin_lock_irqsave(&ebu_lock, flags);
85 + from = (unsigned long)(from + map->virt);
86 + p = (unsigned char *) from;
87 + to_8 = (unsigned char *) to;
90 + spin_unlock_irqrestore(&ebu_lock, flags);
94 +lq_copy_to(struct map_info *map, unsigned long to,
95 + const void *from, ssize_t len)
97 + unsigned char *p = (unsigned char *)from;
98 + unsigned char *to_8;
99 + unsigned long flags;
100 + spin_lock_irqsave(&ebu_lock, flags);
101 + to += (unsigned long) map->virt;
102 + to_8 = (unsigned char *)to;
105 + spin_unlock_irqrestore(&ebu_lock, flags);
108 +static const char *part_probe_types[] = { "cmdlinepart", NULL };
110 +static struct map_info lq_map = {
114 + .write = lq_write16,
115 + .copy_from = lq_copy_from,
116 + .copy_to = lq_copy_to,
120 +lq_mtd_probe(struct platform_device *pdev)
122 + struct physmap_flash_data *lq_mtd_data =
123 + (struct physmap_flash_data*) dev_get_platdata(&pdev->dev);
124 + struct mtd_info *lq_mtd = NULL;
125 + struct mtd_partition *parts = NULL;
126 + struct resource *res = 0;
129 +#ifdef CONFIG_SOC_LANTIQ_XWAY
130 + lq_w32(lq_r32(LQ_EBU_BUSCON0) & ~EBU_WRDIS, LQ_EBU_BUSCON0);
133 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
136 + dev_err(&pdev->dev, "failed to get memory resource");
139 + res = request_mem_region(res->start, resource_size(res),
140 + dev_name(&pdev->dev));
143 + dev_err(&pdev->dev, "failed to request mem resource");
147 + lq_map.phys = res->start;
148 + lq_map.size = resource_size(res);
149 + lq_map.virt = ioremap_nocache(lq_map.phys, lq_map.size);
151 + if (!lq_map.virt ) {
152 + dev_err(&pdev->dev, "failed to ioremap!\n");
156 + lq_mtd = (struct mtd_info *) do_map_probe("cfi_probe", &lq_map);
158 + iounmap(lq_map.virt);
159 + dev_err(&pdev->dev, "probing failed\n");
163 + lq_mtd->owner = THIS_MODULE;
165 + nr_parts = parse_mtd_partitions(lq_mtd, part_probe_types, &parts, 0);
166 + if (nr_parts > 0) {
167 + dev_info(&pdev->dev, "using %d partitions from cmdline", nr_parts);
169 + nr_parts = lq_mtd_data->nr_parts;
170 + parts = lq_mtd_data->parts;
173 + add_mtd_partitions(lq_mtd, parts, nr_parts);
177 +static struct platform_driver lq_mtd_driver = {
178 + .probe = lq_mtd_probe,
181 + .owner = THIS_MODULE,
188 + int ret = platform_driver_register(&lq_mtd_driver);
190 + printk(KERN_INFO "lq_nor: error registering platfom driver");
194 +module_init(init_lq_mtd);
196 +MODULE_LICENSE("GPL");
197 +MODULE_AUTHOR("John Crispin <blogic@openwrt.org>");
198 +MODULE_DESCRIPTION("Lantiq SoC NOR");
199 --- a/drivers/mtd/chips/cfi_cmdset_0001.c
200 +++ b/drivers/mtd/chips/cfi_cmdset_0001.c
202 /* #define CMDSET0001_DISABLE_WRITE_SUSPEND */
204 // debugging, turns off buffer write mode if set to 1
205 -#define FORCE_WORD_WRITE 0
206 +#ifdef CONFIG_LANTIQ
207 +# define FORCE_WORD_WRITE 1
209 +# define FORCE_WORD_WRITE 0
213 #define I82802AB 0x00ad
214 @@ -1493,6 +1497,9 @@
218 +#ifdef CONFIG_LANTIQ
224 --- a/drivers/mtd/chips/cfi_cmdset_0002.c
225 +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
227 #include <linux/mtd/xip.h>
229 #define AMD_BOOTLOC_BUG
230 -#define FORCE_WORD_WRITE 0
231 +#ifdef CONFIG_LANTIQ
232 +# define FORCE_WORD_WRITE 1
234 +# define FORCE_WORD_WRITE 0
237 #define MAX_WORD_RETRIES 3
239 @@ -1167,6 +1171,10 @@
243 +#ifdef CONFIG_LANTIQ
247 mutex_lock(&chip->mutex);
248 ret = get_chip(map, chip, adr, FL_WRITING);