public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 2/7] mtd: Add map file for mpc83xx boards
@ 2006-06-28 14:23 Li Yang-r58472
  2006-06-28 14:27 ` David Woodhouse
  0 siblings, 1 reply; 3+ messages in thread
From: Li Yang-r58472 @ 2006-06-28 14:23 UTC (permalink / raw)
  To: 'dwmw2@infradead.org'
  Cc: Phillips Kim-R1AAHA, Yin Olivia-r63875,
	'linux-kernel@vger.kernel.org', linuxppc-dev,
	'linux-mtd@lists.infradead.org', Chu hanjin-r52514

Flash mapping file for MPC83xx MDS platforms.

Signed-off-by: Yin Olivia <hong-hua.yin@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>

---
 drivers/mtd/maps/Kconfig         |    6 +
 drivers/mtd/maps/Makefile        |    1 
 drivers/mtd/maps/mpc83xx_flash.c |  154 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 161 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 7abd7fe..eac049e 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -631,5 +631,11 @@ config MTD_PLATRAM
 
 	  This selection automatically selects the map_ram driver.
 
+config MTD_MPC83xx
+	tristate "CFI Flash device map on MPC83xx MDS support"
+	depends on 83xx && MTD_CFI && MTD_PARTITIONS
+	help
+	  Freescale MPC83xx board uses CFI compliant flash.
+
 endmenu
 
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index ab71f17..f0f8afd 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -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_MPC83xx)	+= mpc83xx_flash.o
diff --git a/drivers/mtd/maps/mpc83xx_flash.c b/drivers/mtd/maps/mpc83xx_flash.c
new file mode 100644
index 0000000..84f058a
--- /dev/null
+++ b/drivers/mtd/maps/mpc83xx_flash.c
@@ -0,0 +1,154 @@
+/*
+ * Handle mapping of the flash on MPC83xx board
+ *
+ * Copyright (C) 2005 Freescale semicondutor
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <asm/io.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+
+
+/* MPC8349MDS flash layout 
+ * 0 : 0xFE00 0000 - 0xFE01 FFFF : HRCW (128KB)
+ * 1 : 0xFE02 0000 - 0xFE5F FFFF : JFFS2 file system (5.875MB)
+ * 2 : 0xFE60 0000 - 0xFE6F FFFF : Kernel (1MB)
+ * 3 : 0xFE70 0000 - 0xFE7F FFFF : U-Boot (1MB)
+ */
+#ifdef CONFIG_MPC834x
+#define WINDOW_ADDR 0xFE000000
+#define WINDOW_SIZE 0x00800000
+#endif
+
+/* MPC8360EPB flash layout 
+ * 0 : 0xFE00 0000 - 0xFE01 FFFF : HRCW (128KB)
+ * 1 : 0xFE02 0000 - 0xFE8F FFFF : JFFS2 file system (8.875MB)
+ * 2 : 0xFE90 0000 - 0xFECF FFFF : Ramdisk file system (4MB)
+ * 3 : 0xFED0 0000 - 0xFEEF FFFF : Kernel (2MB)
+ * 4 : 0xFEF0 0000 - 0xFEFF FFFF : U-Boot (1MB)
+ */
+#ifdef CONFIG_MPC8360E_PB
+#define WINDOW_ADDR 0xFE000000
+#define WINDOW_SIZE 0x01000000
+#endif
+
+/* partition_info gives details on the logical partitions that the split the
+ * single flash device into. If the size if zero we use up to the end of the
+ * device. */
+static struct mtd_partition partition_info[]={
+	{
+		.name		= "HRCW",
+		.offset 	= 0,
+		.size		= 0x020000,
+		.mask_flags	= MTD_WRITEABLE
+	},
+	{
+		.name		= "JFFS2",
+		.offset		= MTDPART_OFS_APPEND,
+#ifdef CONFIG_MPC834x
+		.size		= 0x5E0000
+#endif
+#ifdef CONFIG_MPC8360E_PB
+		.size		= 0x8E0000
+#endif
+	},
+#ifdef CONFIG_MPC8360E_PB
+	{
+		.name           = "Ramdisk",
+		.offset         = MTDPART_OFS_APPEND,
+		.size           = 0x400000
+	},
+#endif
+	{
+		.name		= "Kernel",
+		.offset		= MTDPART_OFS_APPEND,
+#ifdef CONFIG_MPC834x
+		.size		= 0x100000
+#endif
+#ifdef CONFIG_MPC8360E_PB
+		.size		= 0x200000
+#endif
+	},
+	{
+		.name		= "U-Boot",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= 0x100000,
+		.mask_flags	= MTD_WRITEABLE
+    }
+};
+
+#define PARTITION_NUM (sizeof(partition_info)/sizeof(struct mtd_partition))
+
+static struct mtd_info *mymtd;
+
+
+struct map_info mpc83xx_map = {
+#ifdef CONFIG_MPC834x
+	.name		= "MPC8349MDS Flash Map Info",
+#endif
+#ifdef CONFIG_MPC8360E_PB
+	.name		= "MPC8360E PB Flash Map Info",
+#endif
+	.size		= WINDOW_SIZE,
+	.phys		= WINDOW_ADDR,
+	.bankwidth	= 2,
+};
+
+int __init init_mpc83xx_mtd(void)
+{
+	char *board;
+#ifdef CONFIG_MPC834x
+	board = "MPC8349MDS";
+#endif
+#ifdef CONFIG_MPC8360E_PB
+	board = "MPC8360E PB"; 
+#endif
+	printk(KERN_NOTICE "%s flash device: %x at %x Partition number %d\n",
+			board,WINDOW_SIZE, WINDOW_ADDR, PARTITION_NUM);
+	mpc83xx_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
+
+	if (!mpc83xx_map.virt) {
+		printk("Failed to ioremap\n");
+		return -EIO;
+	}
+	simple_map_init(&mpc83xx_map);
+	
+	mymtd = do_map_probe("cfi_probe", &mpc83xx_map);
+	if (mymtd) {
+		mymtd->owner = THIS_MODULE;
+                add_mtd_partitions(mymtd, partition_info, PARTITION_NUM);
+		printk(KERN_NOTICE "%s flash device initialized\n", board);
+		return 0;
+	}
+
+	iounmap((void *)mpc83xx_map.virt);
+	return -ENXIO;
+}
+
+static void __exit cleanup_mpc83xx_mtd(void)
+{
+	if (mymtd) {
+		del_mtd_device(mymtd);
+		map_destroy(mymtd);
+	}
+	if (mpc83xx_map.virt) {
+		iounmap((void *)mpc83xx_map.virt);
+		mpc83xx_map.virt = 0;
+	}
+}
+
+module_init(init_mpc83xx_mtd);
+module_exit(cleanup_mpc83xx_mtd);
+
+MODULE_AUTHOR("FSL");
+MODULE_DESCRIPTION("MTD map driver for Freescale MPC83xx board");
+MODULE_LICENSE("GPL");

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/7] mtd: Add map file for mpc83xx boards
  2006-06-28 14:23 [PATCH 2/7] mtd: Add map file for mpc83xx boards Li Yang-r58472
@ 2006-06-28 14:27 ` David Woodhouse
  2006-07-10 13:04   ` hinko.kocevar
  0 siblings, 1 reply; 3+ messages in thread
From: David Woodhouse @ 2006-06-28 14:27 UTC (permalink / raw)
  To: Li Yang-r58472
  Cc: Phillips Kim-R1AAHA, Yin Olivia-r63875,
	'linux-kernel@vger.kernel.org', linuxppc-dev,
	'linux-mtd@lists.infradead.org', Chu hanjin-r52514

On Wed, 2006-06-28 at 22:23 +0800, Li Yang-r58472 wrote:
> Flash mapping file for MPC83xx MDS platforms.

I'm not accepting any more individual map drivers unless they're
absolutely necessary, which this one isn't.

Use a platform device and physmap. Or better still, extend physmap to
handle of_devices too and just stick the flash information in the device
tree.

-- 
dwmw2

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/7] mtd: Add map file for mpc83xx boards
  2006-06-28 14:27 ` David Woodhouse
@ 2006-07-10 13:04   ` hinko.kocevar
  0 siblings, 0 replies; 3+ messages in thread
From: hinko.kocevar @ 2006-07-10 13:04 UTC (permalink / raw)
  To: 'linux-mtd@lists.infradead.org'

[-- Attachment #1: Type: text/plain, Size: 1001 bytes --]

David Woodhouse wrote:
> Use a platform device and physmap. Or better still, extend physmap to
> handle of_devices too and just stick the flash information in the device
> tree.
> 

Hi,

I would like to make flash map driver with physmap or platform device, 
but am not really sure where to start. Is there an implementation 
already in place, like an example? If I understand this correctly when 
using physmap there is no need to create drivers/mtd/maps/xxxx-flash.c file?

I've tried to use platform device like in arch/arm/mach-pxa/lubbock.c, 
but I haven't seen any MTD device upon boot - instead I had to use 
drivers/mtd/maps/lubbock.c like flash map to make /porc/mtd show something.

I've attached my PXA ARM board with some bits from lubbock.c for flash 
platform device. If someone spots whats missing there let me know!

best regards,
hinko

-- 
ČETRTA POT, d.o.o., Kranj
Planina 3
4000 Kranj
Slovenija
Tel. +386 (0) 4 280 66 37
E-mail: hinko.kocevar@cetrtapot.si
Http: www.cetrtapot.si


[-- Attachment #2: trizeps2.c.diff --]
[-- Type: text/x-patch, Size: 6835 bytes --]

diff -urN linux-2.6.17-clean/arch/arm/mach-pxa/trizeps2.c linux-2.6.17-stab2/arch/arm/mach-pxa/trizeps2.c
--- linux-2.6.17-clean/arch/arm/mach-pxa/trizeps2.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.17-stab2/arch/arm/mach-pxa/trizeps2.c	2006-07-03 18:24:59.000000000 +0200
@@ -0,0 +1,278 @@
+/*
+ *  linux/arch/arm/mach-pxa/trizeps2.c
+ *
+ *  Support for the Keith & Koep Trizeps2 PXA25x CPU module.
+ *
+ *  Author:	Hinko Kocevar
+ *  Created:	Jun 29, 2006
+ *  Copyright:	Hinko Kocevar <hinkocevar@gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/sysdev.h>
+#include <linux/major.h>
+#include <linux/fb.h>
+#include <linux/interrupt.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/setup.h>
+#include <asm/memory.h>
+#include <asm/mach-types.h>
+#include <asm/hardware.h>
+#include <asm/irq.h>
+#include <asm/sizes.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/mach/irq.h>
+#include <asm/mach/flash.h>
+
+
+#include <asm/arch/bitfield.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/trizeps2.h>
+#include <asm/arch/pxafb.h>
+
+#include "generic.h"
+
+#define DEBUG_TRIZEPS2
+#ifdef DEBUG_TRIZEPS2
+#define DPRINTK(fmt, args...) printk("%s: " fmt, __FUNCTION__ , ## args)
+#else
+#define DPRINTK( x... )
+#endif
+
+
+/*
+ * Backlight power control is connected to pin 37
+ * on NetTerm 40-pin LCD connector (unused IRQ_PIC
+ */
+static void trizeps2_backlight_power(int on)
+{
+    if (on)
+    {
+#ifdef CONFIG_ARCH_TRIZEPS2_KK_NETTERM
+        /* enable backlight, set GPIO0 low */
+        GPCR(0) |= GPIO_bit(0);
+        /* GPIO0 output */
+        GPDR(0) |= GPIO_bit(0);
+#elif CONFIG_ARCH_TRIZEPS2_IM_GREENFLASH1
+        /* enable LCD, set GPIO1 high */
+        GPSR(1) |= GPIO_bit(1);
+        /* GPIO1 output */
+        GPDR(1) |= GPIO_bit(1);
+#endif
+    }
+    else
+    {
+#ifdef CONFIG_ARCH_TRIZEPS2_KK_NETTERM
+	/* disable backlight, set GPIO0 high */
+	GPSR(0) |= GPIO_bit(0);
+	/* GPIO0 input */
+	/* GPDR(0) &= ~GPIO_bit(0); */
+#elif CONFIG_ARCH_TRIZEPS2_IM_GREENFLASH1
+	/* disable LCD, set GPIO1 low */
+	GPCR(1) |= GPIO_bit(1);
+#endif
+    }
+}
+
+/*
+ * LCD power control is connected to pin 25 on
+ * NetTerm 40-pin LCD connector (L_DISP)
+ *
+ * LCD power control is connected to GPIO0 on
+ * GreenFLASH1 board (LCD_ON).
+ */
+static void trizeps2_lcd_power(int on)
+{
+    if (on)
+    {
+#ifdef CONFIG_ARCH_TRIZEPS2_KK_NETTERM
+	/* enable LCD, set GPIO1 high */
+	GPSR(1) |= GPIO_bit(1);
+	/* GPIO1 output */
+	GPDR(1) |= GPIO_bit(1);
+#elif CONFIG_ARCH_TRIZEPS2_IM_GREENFLASH1
+	/* enable LCD, set GPIO0 high */
+	GPSR(0) |= GPIO_bit(0);
+	/* GPIO0 output */
+	GPDR(0) |= GPIO_bit(0);
+#endif
+    }
+    else
+    {
+#ifdef CONFIG_ARCH_TRIZEPS2_KK_NETTERM
+	/* disable LCD, set GPIO1 low */
+	GPCR(1) |= GPIO_bit(1);
+#elif CONFIG_ARCH_TRIZEPS2_IM_GREENFLASH1
+	/* disable LCD, set GPIO0 low */
+	GPCR(0) |= GPIO_bit(0);
+	/* GPIO0 input */
+	/* GPDR(0) &= ~GPIO_bit(0); */
+#endif
+    }
+}
+    
+
+static void __init trizeps2_init_irq(void)
+{
+	pxa_init_irq();
+
+	pxa_gpio_mode(GPIO19_DREQ1 | GPIO_ALT_FN_1_IN);
+	pxa_gpio_mode(GPIO46_STRXD_MD);
+	pxa_gpio_mode(GPIO47_STTXD_MD);
+
+	/* 
+	 * NOTE:
+	 * disable IRQ PROBE of GPIO0 and GPIO1 to make sure
+	 * LCD and BL is not powered off in probe_irq_on().
+	 */
+	set_irq_flags(1, IRQF_VALID);
+	set_irq_flags(2, IRQF_VALID);
+
+	set_irq_flags(61, IRQF_VALID);  // disable PROBE
+}
+
+static struct platform_device trizeps2_audio_device = {
+	.name	= "pxa2xx-ac97",
+	.id		= -1,
+};
+
+static struct resource smc91x_resources[] = {
+	[0] = {
+		.name	= "smc91x-regs",
+		.start	= TRIZEPS2_ETH_PHYS,    /*0x0c000300*/
+		.end	= 0x0c0fffff,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= TRIZEPS2_ETH_IRQ,
+		.end	= TRIZEPS2_ETH_IRQ,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device smc91x_device = {
+	.name	= "smc91x",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(smc91x_resources),
+	.resource	= smc91x_resources,
+};
+
+static struct resource flash_resources[] = {
+	[0] = {
+		.start	= 0x00000000,
+		.end	= SZ_16M - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct mtd_partition trizeps2_partitions[] = {
+	{
+		.name =		"Bootloader",
+		.size =		0x00060000,
+		.offset =	0,
+		.mask_flags =	MTD_WRITEABLE  /* force read-only */
+	},{
+		.name =		"Kernel",
+		.size =		0x00200000,
+		.offset =	0x00060000,
+	},{
+		.name =		"Filesystem",
+		.size =		MTDPART_SIZ_FULL,
+		.offset =	0x00260000
+	}
+};
+
+static struct flash_platform_data trizeps2_flash_data[1] = {
+	{
+		.map_name	= "cfi_probe",
+		.parts		= trizeps2_partitions,
+		.nr_parts	= ARRAY_SIZE(trizeps2_partitions),
+	    	.width		= 2,
+		.name		= "application-flash",
+	}, 
+};
+
+static struct platform_device trizeps2_flash_device[1] = {
+	{
+		.name		= "pxa2xx-flash",
+		.id		= 0,
+		.dev = {
+			.platform_data = &trizeps2_flash_data[0],
+		},
+		.resource = &flash_resources[0],
+		.num_resources = 1,
+	},
+};
+
+static struct platform_device *devices[] __initdata = {
+	&trizeps2_audio_device,
+	&smc91x_device,
+	&trizeps2_flash_device[0],
+};
+
+/*
+ * Hitachi SX14Q LCD properties struct
+ */
+static struct pxafb_mach_info hitachi_sx14q __initdata = {
+	.pixclock		= 173521,
+	.xres			= 320,
+	.yres			= 240,
+	.bpp			= 8,
+	.hsync_len		= 1,
+	.left_margin		= 1,
+	.right_margin		= 1,
+	.vsync_len		= 10,
+	.upper_margin		= 0,
+	.lower_margin		= 0,
+	.sync			= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+	.cmap_greyscale		= 0,
+	.cmap_inverse		= 0,
+	.cmap_static		= 0,
+	.lccr0			= LCCR0_Pas | LCCR0_Sngl | LCCR0_Color,
+	.lccr3			= LCCR3_PCP | LCCR3_Acb(255),
+	.pxafb_backlight_power	= trizeps2_backlight_power,
+	.pxafb_lcd_power	= trizeps2_lcd_power,
+};
+
+static void __init trizeps2_init(void)
+{
+	set_pxa_fb_info(&hitachi_sx14q);
+	(void) platform_add_devices(devices, ARRAY_SIZE(devices));
+}
+
+static void __init trizeps2_map_io(void)
+{
+	pxa_map_io();
+
+	/* This is for the SMC chip select */
+	pxa_gpio_mode(GPIO79_nCS_3_MD);
+
+	/* setup sleep mode values */
+	PWER  = 0x00000002;
+	PFER  = 0x00000000;
+	PRER  = 0x00000002;
+	PGSR0 = 0x00008000;
+	PGSR1 = 0x003F0202;
+	PGSR2 = 0x0001C000;
+	PCFR |= PCFR_OPDE;
+}
+
+MACHINE_START(TRIZEPS2, "Keith & Koep Trizeps2 PXA25x CPU module")
+	/* Maintainer: Hinko Kocevar */
+	.phys_io	= 0x40000000,
+	.io_pg_offst	= (io_p2v(0x40000000) >> 18) & 0xfffc,
+	.map_io		= trizeps2_map_io,
+	.init_irq	= trizeps2_init_irq,
+	.timer		= &pxa_timer,
+	.init_machine	= trizeps2_init,
+MACHINE_END

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-07-10 13:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-28 14:23 [PATCH 2/7] mtd: Add map file for mpc83xx boards Li Yang-r58472
2006-06-28 14:27 ` David Woodhouse
2006-07-10 13:04   ` hinko.kocevar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox