* [PATCH] Magic Panel (SH3-DSP board) MTD mapping
@ 2007-08-20 6:37 Markus Brunner
2007-08-20 7:35 ` David Woodhouse
0 siblings, 1 reply; 5+ messages in thread
From: Markus Brunner @ 2007-08-20 6:37 UTC (permalink / raw)
To: dwmw2; +Cc: Mark Jonas, linux-mtd
Hi,
this adds a MTD mapping for the onboard NOR flash on the Magic Panel R2.
The mapping module is based on the solutionengine mapping module.
How are the chances for inclusion in 2.6.24?
Signed-off by: Markus Brunner <super.firetwister@gmail.com>
Signed-off by: Mark Jonas <toertel@gmail.com>
---
Kconfig | 6 +++
Makefile | 1
magicpanelr2.c | 98
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 105 insertions(+)
--- sh-2.6-intc/drivers/mtd/maps/Kconfig 2007-07-31 12:11:48.000000000 +0200
+++ sh-2.6/drivers/mtd/maps/Kconfig 2007-08-16 16:24:29.000000000 +0200
@@ -407,6 +407,12 @@ config MTD_SOLUTIONENGINE
This enables access to the flash chips on the Hitachi SolutionEngine and
similar boards. Say 'Y' if you are building a kernel for such a board.
+config MTD_MAGICPANELR2
+ tristate "CFI Flash device mapped on Magic Panel R2"
+ depends on SUPERH && MTD_CFI && MTD_REDBOOT_PARTS
+ help
+ This enables access to the flash chip on the Magic Panel R2.
+
config MTD_ARM_INTEGRATOR
tristate "CFI Flash device mapped on ARM Integrator/P720T"
depends on ARM && MTD_CFI
--- sh-2.6-intc/drivers/mtd/maps/magicpanelr2.c 1970-01-01 01:00:00.000000000
+0100
+++ sh-2.6/drivers/mtd/maps/magicpanelr2.c 2007-08-17 14:30:37.000000000 +0200
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2007 Markus Brunner, Mark Jonas
+ *
+ * Flash on Magic Panel R2 board.
+ *
+ * Based on solutionengine.c
+ *
+ * (C) 2001 Red Hat, Inc.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+#include <linux/errno.h>
+#include <asm/magicpanelr2.h>
+
+static struct mtd_info *flash_mtd;
+
+struct map_info mpr2_flash_map = {
+ .name = "Magic Panel R2 Flash",
+ .size = 0x2000000UL,
+ .bankwidth = 2,
+};
+static struct mtd_partition *parsed_parts;
+
+static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
+
+static struct mtd_partition mpr2_partitions[] = {
+ /* Reserved for bootloader, read-only */
+ {
+ .name = "Bootloader",
+ .offset = 0x00000000UL,
+ .size = MPR2_MTD_BOOTLOADER_SIZE,
+ .mask_flags = MTD_WRITEABLE,
+ },
+ /* Reserved for kernel image */
+ {
+ .name = "Kernel Image",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = MPR2_MTD_KERNEL_SIZE,
+ },
+ /* Rest is used for Flash FS */
+ {
+ .name = "Flash FS",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = MTDPART_SIZ_FULL,
+ }
+};
+
+static int __init init_mpr2_maps(void)
+{
+ int nr_parts = 0;
+
+ /* Probe at offset 0 */
+ mpr2_flash_map.phys = 0x00000000UL;
+ mpr2_flash_map.virt = (void __iomem *)P2SEGADDR(0x00000000UL);
+ simple_map_init(&mpr2_flash_map);
+
+ flash_mtd = do_map_probe("cfi_probe", &mpr2_flash_map);
+
+ flash_mtd->owner = THIS_MODULE;
+
+ /* Check if there is a partition table */
+ nr_parts = parse_mtd_partitions(flash_mtd, probes, &parsed_parts, 0);
+
+ /* If there is no partition table, used the hard coded table */
+ if (nr_parts <= 0) {
+ parsed_parts = mpr2_partitions;
+ nr_parts = sizeof(mpr2_partitions)/sizeof(*parsed_parts);
+ }
+
+ /* Add partitions */
+ add_mtd_partitions(flash_mtd, parsed_parts, nr_parts);
+
+ return 0;
+}
+
+static void __exit cleanup_mpr2_maps(void)
+{
+ del_mtd_partitions(flash_mtd);
+ map_destroy(flash_mtd);
+}
+
+module_init(init_mpr2_maps);
+module_exit(cleanup_mpr2_maps);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mark Jonas <toertel@gmail.com>");
+MODULE_DESCRIPTION("MTD map driver for Magic Panel R2");
--- sh-2.6-intc/drivers/mtd/maps/Makefile 2007-07-31 12:11:48.000000000 +0200
+++ sh-2.6/drivers/mtd/maps/Makefile 2007-08-14 13:23:32.000000000 +0200
@@ -71,3 +71,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_TQM834x) += tqm834x.o
+obj-$(CONFIG_MTD_MAGICPANELR2) += magicpanelr2.o
\ No newline at end of file
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Magic Panel (SH3-DSP board) MTD mapping
2007-08-20 6:37 [PATCH] Magic Panel (SH3-DSP board) MTD mapping Markus Brunner
@ 2007-08-20 7:35 ` David Woodhouse
2007-08-21 20:12 ` Markus Brunner
2007-09-17 10:09 ` [PATCH] Magic Panel MTD mapping update Markus Brunner
0 siblings, 2 replies; 5+ messages in thread
From: David Woodhouse @ 2007-08-20 7:35 UTC (permalink / raw)
To: Markus Brunner; +Cc: Mark Jonas, linux-mtd
On Mon, 2007-08-20 at 08:37 +0200, Markus Brunner wrote:
> this adds a MTD mapping for the onboard NOR flash on the Magic Panel
> R2. The mapping module is based on the solutionengine mapping module.
>
> How are the chances for inclusion in 2.6.24?
Looks like you should be able to use a platform_device for this.
--
dwmw2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Magic Panel (SH3-DSP board) MTD mapping
2007-08-20 7:35 ` David Woodhouse
@ 2007-08-21 20:12 ` Markus Brunner
2007-09-17 10:09 ` [PATCH] Magic Panel MTD mapping update Markus Brunner
1 sibling, 0 replies; 5+ messages in thread
From: Markus Brunner @ 2007-08-21 20:12 UTC (permalink / raw)
To: David Woodhouse; +Cc: Mark Jonas, linux-mtd
On Monday 20 August 2007, David Woodhouse wrote:
> On Mon, 2007-08-20 at 08:37 +0200, Markus Brunner wrote:
> > this adds a MTD mapping for the onboard NOR flash on the Magic Panel
> > R2. The mapping module is based on the solutionengine mapping module.
> >
> > How are the chances for inclusion in 2.6.24?
>
> Looks like you should be able to use a platform_device for this.
Yes. I should have looked outside arch/sh/, too.
I'm just a bit confused why the solutionengine mapping isn't done there.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Magic Panel MTD mapping update
2007-08-20 7:35 ` David Woodhouse
2007-08-21 20:12 ` Markus Brunner
@ 2007-09-17 10:09 ` Markus Brunner
2007-09-21 6:25 ` Paul Mundt
1 sibling, 1 reply; 5+ messages in thread
From: Markus Brunner @ 2007-09-17 10:09 UTC (permalink / raw)
To: Paul Mundt; +Cc: Mark Jonas, linux-mtd, linux-sh
Hi Paul,
this update moves the flash mapping for the Magic Panel into the board setup.
It also removes references to the old MTD mapping option in the defconfig.
Signed-off by: Markus Brunner <super.firetwister@gmail.com>
Signed-off by: Mark Jonas <toertel@gmail.com>
---
boards/magicpanelr2/setup.c | 83 ++++++++++++++++++++++++++++++++++++++++-
configs/magicpanelr2_defconfig | 8 ++-
2 files changed, 86 insertions(+), 5 deletions(-)
diff --git a/arch/sh/boards/magicpanelr2/setup.c b/arch/sh/boards/magicpanelr2/setup.c
index c593065..854bcc6 100644
--- a/arch/sh/boards/magicpanelr2/setup.c
+++ b/arch/sh/boards/magicpanelr2/setup.c
@@ -12,14 +12,19 @@
#include <linux/init.h>
#include <linux/irq.h>
#include <linux/platform_device.h>
-#include <linux/ide.h>
-#include <linux/irq.h>
#include <linux/delay.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/mtd/physmap.h>
+#include <linux/mtd/map.h>
#include <asm/magicpanelr2.h>
#include <asm/heartbeat.h>
#define LAN9115_READY (ctrl_inl(0xA8000084UL) & 0x00000001UL)
+/* Prefer cmdline over RedBoot */
+static const char *probes[] = { "cmdlinepart", "RedBoot", NULL };
+
/* Wait until reset finished. Timeout is 100ms. */
static int __init ethernet_reset_finished(void)
{
@@ -270,13 +275,87 @@ static struct platform_device heartbeat_device = {
.resource = heartbeat_resources,
};
+static struct mtd_partition *parsed_partitions;
+
+static struct mtd_partition mpr2_partitions[] = {
+ /* Reserved for bootloader, read-only */
+ {
+ .name = "Bootloader",
+ .offset = 0x00000000UL,
+ .size = MPR2_MTD_BOOTLOADER_SIZE,
+ .mask_flags = MTD_WRITEABLE,
+ },
+ /* Reserved for kernel image */
+ {
+ .name = "Kernel",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = MPR2_MTD_KERNEL_SIZE,
+ },
+ /* Rest is used for Flash FS */
+ {
+ .name = "Flash_FS",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = MTDPART_SIZ_FULL,
+ }
+};
+
+static struct physmap_flash_data flash_data = {
+ .width = 2,
+};
+
+static struct resource flash_resource = {
+ .start = 0x00000000,
+ .end = 0x2000000UL,
+ .flags = IORESOURCE_MEM,
+};
+
+static struct platform_device flash_device = {
+ .name = "physmap-flash",
+ .id = -1,
+ .resource = &flash_resource,
+ .num_resources = 1,
+ .dev = {
+ .platform_data = &flash_data,
+ },
+};
+
+static struct mtd_info *flash_mtd;
+
+struct map_info mpr2_flash_map = {
+ .name = "Magic Panel R2 Flash",
+ .size = 0x2000000UL,
+ .bankwidth = 2,
+};
+
+static void __init set_mtd_partitions(){
+ int nr_parts = 0;
+ simple_map_init(&mpr2_flash_map);
+ flash_mtd = do_map_probe("cfi_probe", &mpr2_flash_map);
+ nr_parts = parse_mtd_partitions(flash_mtd, probes, &parsed_partitions, 0);
+ /* If there is no partition table, used the hard coded table */
+ if (nr_parts <= 0) {
+ flash_data.parts = mpr2_partitions;
+ flash_data.nr_parts = ARRAY_SIZE(mpr2_partitions);
+ } else {
+ flash_data.nr_parts = nr_parts;
+ flash_data.parts = parsed_partitions;
+ }
+}
+
+/*
+ * Add all resources to the platform_device
+ */
+
static struct platform_device *mpr2_devices[] __initdata = {
&heartbeat_device,
&smc911x_device,
+ &flash_device,
};
+
static int __init mpr2_devices_setup(void)
{
+ set_mtd_partitions();
return platform_add_devices(mpr2_devices, ARRAY_SIZE(mpr2_devices));
}
device_initcall(mpr2_devices_setup);
diff --git a/arch/sh/configs/magicpanelr2_defconfig b/arch/sh/configs/magicpanelr2_defconfig
index ce4e764..f8398a5 100644
--- a/arch/sh/configs/magicpanelr2_defconfig
+++ b/arch/sh/configs/magicpanelr2_defconfig
@@ -185,7 +185,7 @@ CONFIG_SH_MAGIC_PANEL_R2=y
#
# Magic Panel R2 options
#
-CONFIG_SH_MAGIC_PANEL_R2_VERSION=2
+CONFIG_SH_MAGIC_PANEL_R2_VERSION=3
#
# Timer and clock configuration
@@ -404,9 +404,11 @@ CONFIG_MTD_CFI_UTIL=y
# Mapping drivers for chip access
#
# CONFIG_MTD_COMPLEX_MAPPINGS is not set
-# CONFIG_MTD_PHYSMAP is not set
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_PHYSMAP_START=0x0000000
+CONFIG_MTD_PHYSMAP_LEN=0
+CONFIG_MTD_PHYSMAP_BANKWIDTH=0
# CONFIG_MTD_SOLUTIONENGINE is not set
-CONFIG_MTD_MAGICPANELR2=y
# CONFIG_MTD_PLATRAM is not set
#
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Magic Panel MTD mapping update
2007-09-17 10:09 ` [PATCH] Magic Panel MTD mapping update Markus Brunner
@ 2007-09-21 6:25 ` Paul Mundt
0 siblings, 0 replies; 5+ messages in thread
From: Paul Mundt @ 2007-09-21 6:25 UTC (permalink / raw)
To: Markus Brunner; +Cc: linux-mtd, linux-sh
On Mon, Sep 17, 2007 at 12:09:15PM +0200, Markus Brunner wrote:
> this update moves the flash mapping for the Magic Panel into the board setup.
> It also removes references to the old MTD mapping option in the defconfig.
>
> Signed-off by: Markus Brunner <super.firetwister@gmail.com>
> Signed-off by: Mark Jonas <toertel@gmail.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-09-21 6:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-20 6:37 [PATCH] Magic Panel (SH3-DSP board) MTD mapping Markus Brunner
2007-08-20 7:35 ` David Woodhouse
2007-08-21 20:12 ` Markus Brunner
2007-09-17 10:09 ` [PATCH] Magic Panel MTD mapping update Markus Brunner
2007-09-21 6:25 ` Paul Mundt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox