mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-28 00:04:05 +02:00
288f3f6650
* update the flash driver for bcm47xx to use the stubs already in bcma * do some misc enhancements to the flash drivers for bcm47xx git-svn-id: svn://svn.openwrt.org/openwrt/trunk@33920 3c298f89-4303-0410-b956-a3cf2f4a3e73
225 lines
6.6 KiB
Diff
225 lines
6.6 KiB
Diff
--- a/drivers/mtd/maps/Kconfig
|
|
+++ b/drivers/mtd/maps/Kconfig
|
|
@@ -248,6 +248,15 @@ config MTD_LANTIQ
|
|
help
|
|
Support for NOR flash attached to the Lantiq SoC's External Bus Unit.
|
|
|
|
+config MTD_BCM47XX_PFLASH
|
|
+ tristate "bcm47xx parallel flash support"
|
|
+ default y
|
|
+ depends on BCM47XX
|
|
+ select MTD_PARTITIONS
|
|
+ select MTD_BCM47XX_PARTS
|
|
+ help
|
|
+ Support for bcm47xx parallel flash
|
|
+
|
|
config MTD_DILNETPC
|
|
tristate "CFI Flash device mapped on DIL/Net PC"
|
|
depends on X86 && MTD_CFI_INTELEXT && BROKEN
|
|
--- a/drivers/mtd/maps/Makefile
|
|
+++ b/drivers/mtd/maps/Makefile
|
|
@@ -57,3 +57,4 @@ obj-$(CONFIG_MTD_VMU) += vmu-flash.o
|
|
obj-$(CONFIG_MTD_GPIO_ADDR) += gpio-addr-flash.o
|
|
obj-$(CONFIG_MTD_LATCH_ADDR) += latch-addr-flash.o
|
|
obj-$(CONFIG_MTD_LANTIQ) += lantiq-flash.o
|
|
+obj-$(CONFIG_MTD_BCM47XX_PFLASH)+= bcm47xx-pflash.o
|
|
--- /dev/null
|
|
+++ b/drivers/mtd/maps/bcm47xx-pflash.c
|
|
@@ -0,0 +1,196 @@
|
|
+/*
|
|
+ * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
|
|
+ * Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
|
|
+ * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
|
|
+ *
|
|
+ * original functions for finding root filesystem from Mike Baker
|
|
+ *
|
|
+ * 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
|
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
+ *
|
|
+ * 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.,
|
|
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
+ *
|
|
+ * Copyright 2001-2003, Broadcom Corporation
|
|
+ * All Rights Reserved.
|
|
+ *
|
|
+ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
|
|
+ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
|
|
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
|
|
+ *
|
|
+ * Flash mapping for BCM947XX boards
|
|
+ */
|
|
+
|
|
+#define pr_fmt(fmt) "bcm47xx_pflash: " fmt
|
|
+#include <linux/init.h>
|
|
+#include <linux/module.h>
|
|
+#include <linux/types.h>
|
|
+#include <linux/kernel.h>
|
|
+#include <linux/sched.h>
|
|
+#include <linux/mtd/mtd.h>
|
|
+#include <linux/mtd/map.h>
|
|
+#include <linux/mtd/partitions.h>
|
|
+#include <linux/io.h>
|
|
+#include <asm/mach-bcm47xx/bcm47xx.h>
|
|
+#include <linux/platform_device.h>
|
|
+
|
|
+#define WINDOW_ADDR 0x1fc00000
|
|
+#define WINDOW_SIZE 0x400000
|
|
+#define BUSWIDTH 2
|
|
+
|
|
+static struct mtd_info *bcm47xx_mtd;
|
|
+
|
|
+static void bcm47xx_map_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
|
|
+{
|
|
+ if (len == 1) {
|
|
+ memcpy_fromio(to, map->virt + from, len);
|
|
+ } else {
|
|
+ int i;
|
|
+ u16 *dest = (u16 *) to;
|
|
+ u16 *src = (u16 *) (map->virt + from);
|
|
+ for (i = 0; i < (len / 2); i++)
|
|
+ dest[i] = src[i];
|
|
+ if (len & 1)
|
|
+ *((u8 *)dest+len-1) = src[i] & 0xff;
|
|
+ }
|
|
+}
|
|
+
|
|
+static struct map_info bcm47xx_map = {
|
|
+ name: "Physically mapped flash",
|
|
+ size : WINDOW_SIZE,
|
|
+ bankwidth : BUSWIDTH,
|
|
+ phys : WINDOW_ADDR,
|
|
+};
|
|
+
|
|
+static const char *probes[] = { "bcm47xx", NULL };
|
|
+
|
|
+static int bcm47xx_pflash_probe(struct platform_device *pdev)
|
|
+{
|
|
+#ifdef CONFIG_BCM47XX_SSB
|
|
+ struct ssb_mipscore *ssb_mcore;
|
|
+#endif
|
|
+#ifdef CONFIG_BCM47XX_BCMA
|
|
+ struct bcma_drv_cc *bcma_cc;
|
|
+#endif
|
|
+ int ret = 0;
|
|
+
|
|
+ switch (bcm47xx_bus_type) {
|
|
+#ifdef CONFIG_BCM47XX_SSB
|
|
+ case BCM47XX_BUS_TYPE_SSB:
|
|
+ ssb_mcore = &bcm47xx_bus.ssb.mipscore;
|
|
+ if (!ssb_mcore->pflash.present)
|
|
+ return -ENODEV;
|
|
+
|
|
+ bcm47xx_map.phys = ssb_mcore->pflash.window;
|
|
+ bcm47xx_map.size = ssb_mcore->pflash.window_size;
|
|
+ bcm47xx_map.bankwidth = ssb_mcore->pflash.buswidth;
|
|
+ break;
|
|
+#endif
|
|
+#ifdef CONFIG_BCM47XX_BCMA
|
|
+ case BCM47XX_BUS_TYPE_BCMA:
|
|
+ bcma_cc = &bcm47xx_bus.bcma.bus.drv_cc;
|
|
+ if (!bcma_cc->pflash.present)
|
|
+ return -ENODEV;
|
|
+
|
|
+ bcm47xx_map.phys = bcma_cc->pflash.window;
|
|
+ bcm47xx_map.size = bcma_cc->pflash.window_size;
|
|
+ bcm47xx_map.bankwidth = bcma_cc->pflash.buswidth;
|
|
+ break;
|
|
+#endif
|
|
+ }
|
|
+
|
|
+ pr_notice("flash init: 0x%08x 0x%08lx\n", bcm47xx_map.phys, bcm47xx_map.size);
|
|
+ bcm47xx_map.virt = ioremap_nocache(bcm47xx_map.phys, bcm47xx_map.size);
|
|
+
|
|
+ if (!bcm47xx_map.virt) {
|
|
+ pr_err("Failed to ioremap\n");
|
|
+ return -EIO;
|
|
+ }
|
|
+
|
|
+ simple_map_init(&bcm47xx_map);
|
|
+ /* override copy_from routine */
|
|
+ bcm47xx_map.copy_from = bcm47xx_map_copy_from;
|
|
+
|
|
+ bcm47xx_mtd = do_map_probe("cfi_probe", &bcm47xx_map);
|
|
+ if (!bcm47xx_mtd) {
|
|
+ pr_err("Failed to do_map_probe\n");
|
|
+ ret = -ENXIO;
|
|
+ goto err_unmap;
|
|
+ }
|
|
+ bcm47xx_mtd->owner = THIS_MODULE;
|
|
+
|
|
+ pr_notice("Flash device: 0x%lx at 0x%x\n", bcm47xx_map.size, WINDOW_ADDR);
|
|
+
|
|
+ ret = mtd_device_parse_register(bcm47xx_mtd, probes, NULL, NULL, 0);
|
|
+
|
|
+ if (ret) {
|
|
+ pr_err("Flash: mtd_device_register failed\n");
|
|
+ goto err_destroy;
|
|
+ }
|
|
+ return 0;
|
|
+
|
|
+err_destroy:
|
|
+ map_destroy(bcm47xx_mtd);
|
|
+err_unmap:
|
|
+ iounmap(bcm47xx_map.virt);
|
|
+ return ret;
|
|
+}
|
|
+
|
|
+static int __devexit bcm47xx_pflash_remove(struct platform_device *pdev)
|
|
+{
|
|
+ mtd_device_unregister(bcm47xx_mtd);
|
|
+ map_destroy(bcm47xx_mtd);
|
|
+ iounmap(bcm47xx_map.virt);
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static const struct platform_device_id bcm47xx_pflash_table[] = {
|
|
+ { "bcm47xx-pflash", 0 },
|
|
+ { }
|
|
+};
|
|
+MODULE_DEVICE_TABLE(platform, bcm47xx_pflash_table);
|
|
+
|
|
+static struct platform_driver bcm47xx_pflash_driver = {
|
|
+ .id_table = bcm47xx_pflash_table,
|
|
+ .probe = bcm47xx_pflash_probe,
|
|
+ .remove = __devexit_p(bcm47xx_pflash_remove),
|
|
+ .driver = {
|
|
+ .name = "bcm47xx-pflash",
|
|
+ .owner = THIS_MODULE,
|
|
+ },
|
|
+};
|
|
+
|
|
+static int __init init_bcm47xx_pflash(void)
|
|
+{
|
|
+ int ret = platform_driver_register(&bcm47xx_pflash_driver);
|
|
+
|
|
+ if (ret)
|
|
+ pr_err("error registering platform driver: %i\n", ret);
|
|
+ return ret;
|
|
+}
|
|
+
|
|
+static void __exit exit_bcm47xx_pflash(void)
|
|
+{
|
|
+ platform_driver_unregister(&bcm47xx_pflash_driver);
|
|
+}
|
|
+
|
|
+module_init(init_bcm47xx_pflash);
|
|
+module_exit(exit_bcm47xx_pflash);
|
|
+
|
|
+MODULE_LICENSE("GPL");
|
|
+MODULE_DESCRIPTION("BCM47XX parallel flash driver");
|