From: David Howells <dhowells@redhat.com>
To: torvalds@osdl.org, akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-am33-list@redhat.com,
dhowells@redhat.com
Subject: [PATCH 6/6] MN10300: Add MTD flash support for the ASB2303 board [try #5]
Date: Fri, 09 Nov 2007 15:35:03 +0000 [thread overview]
Message-ID: <20071109153503.20803.69203.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20071109153432.20803.69832.stgit@warthog.procyon.org.uk>
Add MTD flash support for the ASB2303 board.
Signed-off-by: David Howells <dhowells@redhat.com>
---
arch/mn10300/configs/asb2303_defconfig | 1
drivers/mtd/chips/jedec_probe.c | 2
drivers/mtd/maps/Kconfig | 8 +
drivers/mtd/maps/Makefile | 1
drivers/mtd/maps/asb2303-flash.c | 180 ++++++++++++++++++++++++++++++++
5 files changed, 192 insertions(+), 0 deletions(-)
diff --git a/arch/mn10300/configs/asb2303_defconfig b/arch/mn10300/configs/asb2303_defconfig
index 7855257..75e2cd7 100644
--- a/arch/mn10300/configs/asb2303_defconfig
+++ b/arch/mn10300/configs/asb2303_defconfig
@@ -282,6 +282,7 @@ CONFIG_MTD_CFI_UTIL=y
# CONFIG_MTD_COMPLEX_MAPPINGS is not set
# CONFIG_MTD_PHYSMAP is not set
# CONFIG_MTD_PLATRAM is not set
+CONFIG_MTD_ASB2303=y
#
# Self-contained MTD device drivers
diff --git a/drivers/mtd/chips/jedec_probe.c b/drivers/mtd/chips/jedec_probe.c
index 5074b5e..8535ae2 100644
--- a/drivers/mtd/chips/jedec_probe.c
+++ b/drivers/mtd/chips/jedec_probe.c
@@ -1883,11 +1883,13 @@ static inline __u8 finfo_uaddr(const struct amd_flash_info *finfo, int device_ty
uaddr = finfo->uaddr[uaddr_idx];
+#ifndef CONFIG_MN10300_UNIT_ASB2303
if (uaddr != MTD_UADDR_NOT_SUPPORTED ) {
/* ASSERT("The unlock addresses for non-8-bit mode
are bollocks. We don't really need an array."); */
uaddr = finfo->uaddr[0];
}
+#endif
uaddr_done:
return uaddr;
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index a592fc0..37157de 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -597,5 +597,13 @@ config MTD_PLATRAM
This selection automatically selects the map_ram driver.
+config MTD_ASB2303
+ tristate "CFI Flash device mapped on MEI ASB2303"
+ depends on MTD_CFI && MN10300_UNIT_ASB2303 && MTD_PARTITIONS
+ help
+ This enables access to the flash chips on the ASB2303 board with
+ the MN10300 processor.
+ Say 'Y' if you have this board.
+
endmenu
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index 316382a..6f28f35 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -69,3 +69,4 @@ obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o
obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
obj-$(CONFIG_MTD_MTX1) += mtx-1_flash.o
obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o
+obj-$(CONFIG_MTD_ASB2303) += asb2303-flash.o
diff --git a/drivers/mtd/maps/asb2303-flash.c b/drivers/mtd/maps/asb2303-flash.c
new file mode 100644
index 0000000..b36358a
--- /dev/null
+++ b/drivers/mtd/maps/asb2303-flash.c
@@ -0,0 +1,180 @@
+/* Handle mapping of the flash on the ASB2303 board
+ *
+ * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/dma-mapping.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+#include <asm/io.h>
+
+#define PROM_ADDR 0xA0000000
+#define FLASH_ADDR 0xA4000000
+#define CONFIG_ADDR 0xA6000000
+
+static struct map_info asb2303_maps[2] = {
+ {
+ .name = "BootPROM",
+ .size = 2 * 1024 * 1024,
+ .bankwidth = 2,
+ .phys = PROM_ADDR,
+ }, {
+ .name = "SysFlash",
+ .size = 32 * 1024 * 1024,
+ .bankwidth = 4,
+ .phys = FLASH_ADDR,
+ }
+};
+
+static struct mtd_partition asb2303_partitions[] = {
+ {
+ .name = "Bootloader",
+ .size = 0x00040000,
+ .offset = 0,
+ .mask_flags = MTD_WRITEABLE /* force read-only */
+ }, {
+ .name = "Kernel",
+ .size = 0x00400000,
+ .offset = 0x00040000,
+ }, {
+ .name = "Filesystem",
+ .size = MTDPART_SIZ_FULL,
+ .offset = 0x00440000
+ }
+};
+
+static struct mtd_info *mymtds[3];
+static struct mtd_partition *parsed_parts[3];
+static int nr_parsed_parts[3];
+
+static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
+
+static int __init init_asb2303(void)
+{
+ int ret = 0, nr, i;
+
+ for (i = 0; i < ARRAY_SIZE(asb2303_maps); i++) {
+ printk(KERN_NOTICE
+ "Probing ASB2303 %s device: %08lx at %08lx\n",
+ asb2303_maps[i].name,
+ asb2303_maps[i].size,
+ (unsigned long) asb2303_maps[i].phys);
+
+ asb2303_maps[i].map_priv_1 = 0;
+ asb2303_maps[i].virt = ioremap(asb2303_maps[i].phys,
+ asb2303_maps[i].size);
+ if (!asb2303_maps[i].virt) {
+ printk(KERN_WARNING
+ "Failed to ioremap %s\n",
+ asb2303_maps[i].name);
+
+ if (!ret)
+ ret = -ENOMEM;
+ continue;
+ }
+
+ simple_map_init(&asb2303_maps[i]);
+
+ printk(KERN_NOTICE
+ "Probing %s at physical address 0x%08lx"
+ " (%d-bit bankwidth)\n",
+ asb2303_maps[i].name,
+ (unsigned long) asb2303_maps[i].phys,
+ asb2303_maps[i].bankwidth * 8);
+
+ mymtds[i] = do_map_probe("cfi_probe", &asb2303_maps[i]);
+ if (!mymtds[i])
+ mymtds[i] = do_map_probe("jedec_probe",
+ &asb2303_maps[i]);
+
+ if (!mymtds[i]) {
+ iounmap((void *) asb2303_maps[i].virt);
+ if (asb2303_maps[i].cached)
+ iounmap(asb2303_maps[i].cached);
+ if (!ret)
+ ret = -EIO;
+ continue;
+ }
+
+ mymtds[i]->owner = THIS_MODULE;
+
+ nr = parse_mtd_partitions(mymtds[i], probes,
+ &parsed_parts[i], 0);
+
+ if (nr > 0)
+ nr_parsed_parts[i] = nr;
+ else if (nr < 0)
+ ret = nr;
+ }
+
+ if (!mymtds[0] && !mymtds[1] && !mymtds[2])
+ return ret;
+
+ for (i = 0; i < ARRAY_SIZE(asb2303_maps); i++) {
+ if (!mymtds[i]) {
+ printk(KERN_WARNING
+ "%s is absent. Skipping\n",
+ asb2303_maps[i].name);
+ }
+ else if (nr_parsed_parts[i]) {
+ add_mtd_partitions(mymtds[i],
+ parsed_parts[i],
+ nr_parsed_parts[i]);
+ }
+ else if (!i) {
+ printk(KERN_INFO
+ "Using static partitions on %s\n",
+ asb2303_maps[i].name);
+ add_mtd_partitions(mymtds[i], asb2303_partitions,
+ ARRAY_SIZE(asb2303_partitions));
+ }
+ else {
+ printk(KERN_INFO
+ "Registering %s as whole device\n",
+ asb2303_maps[i].name);
+ add_mtd_device(mymtds[i]);
+ }
+ }
+
+ return 0;
+}
+
+static void __exit cleanup_asb2303(void)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(mymtds); i++) {
+ if (!mymtds[i])
+ continue;
+
+ if (nr_parsed_parts[i] || !i)
+ del_mtd_partitions(mymtds[i]);
+ else
+ del_mtd_device(mymtds[i]);
+
+ map_destroy(mymtds[i]);
+
+ iounmap((void *) asb2303_maps[i].virt);
+ if (asb2303_maps[i].cached)
+ iounmap(asb2303_maps[i].cached);
+
+ kfree(parsed_parts[i]);
+ }
+}
+
+module_init(init_asb2303);
+module_exit(cleanup_asb2303);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("David Howells <dhowells@redhat.com>");
+MODULE_DESCRIPTION("MTD map driver for MEI ASB2303");
next prev parent reply other threads:[~2007-11-09 15:36 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-09 15:34 [PATCH 0/6] MN10300: Add the MN10300 architecture to Linux kernel " David Howells
2007-11-09 15:34 ` [PATCH 1/6] Suppress A.OUT library support if !CONFIG_BINFMT_AOUT " David Howells
2007-11-11 2:14 ` Andrew Morton
2007-11-11 11:25 ` Adrian Bunk
2007-11-11 13:59 ` David Howells
2007-11-11 14:22 ` Adrian Bunk
2007-11-11 15:03 ` David Howells
2007-11-11 15:19 ` Adrian Bunk
2007-11-11 15:46 ` Andi Kleen
2007-11-11 16:05 ` Adrian Bunk
2007-11-11 16:31 ` David Howells
2007-11-12 15:34 ` David Howells
2007-11-12 19:53 ` Andrew Morton
2007-11-12 22:50 ` SL Baur
2007-11-12 23:14 ` David Howells
2007-11-13 3:09 ` SL Baur
2007-11-13 10:57 ` David Howells
2007-11-13 11:18 ` Andrew Morton
2007-11-13 12:46 ` Peter Zijlstra
2007-11-13 20:40 ` Matt Mackall
2007-11-13 20:46 ` Peter Zijlstra
2007-12-03 15:15 ` David Howells
2007-12-03 16:00 ` Ralf Baechle
2007-12-03 16:17 ` Adrian Bunk
2007-11-09 15:34 ` [PATCH 2/6] MTD: Add support for the SST 39VF1601 flash chip " David Howells
2007-11-09 22:34 ` David Woodhouse
2007-11-09 15:34 ` [PATCH 3/6] USB: net2280 can't have a function called show_registers() " David Howells
2007-11-09 15:34 ` [PATCH 4/6] MN10300: Allocate serial port UART IDs for on-chip serial ports " David Howells
2007-11-09 15:35 ` David Howells [this message]
2007-11-10 4:05 ` [PATCH 6/6] MN10300: Add MTD flash support for the ASB2303 board " David Woodhouse
2007-11-11 14:01 ` David Howells
[not found] ` <20071109153458.20803.10594.stgit@warthog.procyon.org.uk>
2007-11-10 3:53 ` [PATCH 5/6] MN10300: Add the MN10300/AM33 architecture to the kernel " Andrew Morton
2007-11-10 12:18 ` David Howells
2007-11-10 19:43 ` Andrew Morton
2007-11-10 20:02 ` Alan Cox
2007-11-12 7:44 ` Adrian Bunk
2007-11-10 20:09 ` Alan Cox
2007-11-11 14:32 ` David Howells
2007-11-11 14:48 ` David Howells
2007-11-11 15:18 ` Alan Cox
2007-11-11 16:36 ` David Howells
2007-11-11 16:42 ` Alan Cox
2007-11-12 12:19 ` David Howells
2007-11-11 15:07 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071109153503.20803.69203.stgit@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-am33-list@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®