public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] OMAP: FLASH: Move Flash specific device info in a separate board file
@ 2007-11-20 14:23 Choraria, Rohit
  2007-11-23 21:35 ` Tony Lindgren
  0 siblings, 1 reply; 2+ messages in thread
From: Choraria, Rohit @ 2007-11-20 14:23 UTC (permalink / raw)
  To: linux-omap-open-source

Hi,
This patch moves the SDP3430 NOR and OneNAND devices to a new file
board-3430sdp-flash.c. It also adds the support for ethernet on ES2 SDP.

Regards,
Rohit

Signed-off-by: Rohit Choraria <rohitkc@ti.com>
---
 arch/arm/mach-omap2/Makefile              |    3 
 arch/arm/mach-omap2/board-3430sdp-flash.c |  196 ++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/board-3430sdp.c       |   81 ++----------
 include/asm-arm/arch-omap/board-3430sdp.h |   16 +-
 include/asm-arm/arch-omap/gpmc.h          |   79 ++++++++----
 5 files changed, 278 insertions(+), 97 deletions(-)

Index: linux-omap/arch/arm/mach-omap2/board-3430sdp-flash.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-omap/arch/arm/mach-omap2/board-3430sdp-flash.c	2007-11-19 13:52:25.224981776 -0500
@@ -0,0 +1,196 @@
+/*
+ * linux/arch/arm/mach-omap2/board-3430sdp-flash.c
+ *
+ * Copyright (c) 2007 Texas Instruments
+ *
+ * Modified from mach-omap2/board-2430sdp-flash.c
+ * Author: Rohit Choraria <rohitkc@ti.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/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/onenand_regs.h>
+#include <linux/types.h>
+#include <linux/io.h>
+
+#include <asm/mach/flash.h>
+#include <asm/arch/onenand.h>
+#include <asm/arch/board.h>
+#include <asm/arch/gpmc.h>
+
+static struct mtd_partition sdp_nor_partitions[] = {
+	/* bootloader (U-Boot, etc) in first sector */
+	{
+		.name		= "Bootloader-NOR",
+		.offset		= 0,
+		.size		= SZ_256K,
+		.mask_flags	= MTD_WRITEABLE, /* force read-only */
+	},
+	/* bootloader params in the next sector */
+	{
+		.name		= "Params-NOR",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= SZ_256K,
+		.mask_flags	= 0,
+	},
+	/* kernel */
+	{
+		.name		= "Kernel-NOR",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= SZ_2M,
+		.mask_flags	= 0
+	},
+	/* file system */
+	{
+		.name		= "Filesystem-NOR",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= MTDPART_SIZ_FULL,
+		.mask_flags	= 0
+	}
+};
+
+static struct flash_platform_data sdp_nor_data = {
+	.map_name	= "cfi_probe",
+	.width		= 2,
+	.parts		= sdp_nor_partitions,
+	.nr_parts	= ARRAY_SIZE(sdp_nor_partitions),
+};
+
+static struct resource sdp_nor_resource = {
+	.start		= 0,
+	.end		= 0,
+	.flags		= IORESOURCE_MEM,
+};
+
+static struct platform_device sdp_nor_device = {
+	.name		= "omapflash",
+	.id		= 0,
+	.dev		= {
+			.platform_data  = &sdp_nor_data,
+	},
+	.num_resources	= 1,
+	.resource	= &sdp_nor_resource,
+};
+
+static int sdp_onenand_setup(void __iomem *);
+
+static struct mtd_partition sdp_onenand_partitions[] = {
+	{
+		.name		= "X-Loader-OneNAND",
+		.offset		= 0,
+		.size		= 4 * (64 * 2048),
+		.mask_flags	= MTD_WRITEABLE	 /* force read-only */
+	},
+	{
+		.name		= "U-Boot-OneNAND",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= 2 * (64 * 2048),
+		.mask_flags	= MTD_WRITEABLE	 /* force read-only */
+	},
+	{
+		.name		= "U-Boot Environment-OneNAND",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= 1 * (64 * 2048),
+	},
+	{
+		.name		= "Kernel-OneNAND",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= 16 * (64 * 2048),
+	},
+	{
+		.name		= "File System-OneNAND",
+		.offset		= MTDPART_OFS_APPEND,
+		.size		= MTDPART_SIZ_FULL,
+	},
+};
+
+static struct omap_onenand_platform_data sdp_onenand_data = {
+	.parts		= sdp_onenand_partitions,
+	.nr_parts	= ARRAY_SIZE(sdp_onenand_partitions),
+	.onenand_setup	= sdp_onenand_setup,
+	.dma_channel	= -1,	/* disable DMA in OMAP OneNAND driver */
+};
+
+static struct platform_device sdp_onenand_device = {
+	.name		= "omap2-onenand",
+	.id		= -1,
+	.dev = {
+		.platform_data = &sdp_onenand_data,
+	},
+};
+
+/*
+ * sdp_onenand_setup - The function configures the onenand flash.
+ * @onenand_base: Onenand base address
+ *
+ * @return int:	Currently always returning zero.
+ */
+static int sdp_onenand_setup(void __iomem *onenand_base)
+{
+	/* Onenand setup does nothing at present */
+	return 0;
+}
+/**
+ * sdp3430_flash_init - Identify devices connected to GPMC and register.
+ *
+ * @return - void.
+ */
+void __init sdp3430_flash_init(void)
+{
+	unsigned long	gpmc_base_add, gpmc_cs_base_add;
+	u8		cs = 0;
+	u8		onenandcs = GPMC_CS_NUM + 1;
+
+	gpmc_base_add	= OMAP34XX_GPMC_VIRT;
+
+	/* Configure start address and size of NOR device */
+	if (is_sil_rev_greater_than(OMAP3430_REV_ES1_0)) {
+		sdp_nor_resource.start = FLASH_BASE_SDPV2;
+		sdp_nor_resource.end   = FLASH_BASE_SDPV2
+						+ FLASH_SIZE_SDPV2 - 1;
+	} else {
+		sdp_nor_resource.start = FLASH_BASE_SDPV1;
+		sdp_nor_resource.end   = FLASH_BASE_SDPV1
+						+ FLASH_SIZE_SDPV1 - 1;
+	}
+
+	if (platform_device_register(&sdp_nor_device) < 0)
+		printk(KERN_ERR "Unable to register NOR device\n");
+
+	while (cs < GPMC_CS_NUM) {
+		u32 ret = 0;
+		gpmc_cs_base_add =
+			(gpmc_base_add + GPMC_CS0_BASE + (cs * GPMC_CS_SIZE));
+
+		/*
+		* xloader/Uboot would have programmed the oneNAND
+		* base address for us This is a ugly hack. The proper
+		* way of doing this is to pass the setup of u-boot up
+		* to kernel using kernel params - something on the
+		* lines of machineID. Check if oneNAND is configured
+		*/
+		ret = __raw_readl(gpmc_cs_base_add + GPMC_CS_CONFIG7);
+		if ((ret & 0x3F) == (ONENAND_MAP >> 24))
+			onenandcs = cs;
+		cs++;
+	}
+	if (onenandcs > GPMC_CS_NUM) {
+		printk(KERN_INFO "OneNAND: Unable to find configuration "
+				" in GPMC\n ");
+		return;
+	}
+
+	if (onenandcs < GPMC_CS_NUM) {
+		sdp_onenand_data.cs = onenandcs;
+		if (platform_device_register(&sdp_onenand_device) < 0)
+			printk(KERN_ERR "Unable to register OneNAND device\n");
+	}
+}
+
Index: linux-omap/arch/arm/mach-omap2/board-3430sdp.c
===================================================================
--- linux-omap.orig/arch/arm/mach-omap2/board-3430sdp.c	2007-11-19 14:14:03.000000000 -0500
+++ linux-omap/arch/arm/mach-omap2/board-3430sdp.c	2007-11-19 14:14:15.469794288 -0500
@@ -15,8 +15,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/partitions.h>
 #include <linux/delay.h>
 #include <linux/input.h>
 #include <linux/workqueue.h>
@@ -29,7 +27,6 @@
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
-#include <asm/mach/flash.h>
 
 #include <asm/arch/twl4030.h>
 #include <asm/arch/mcspi.h>
@@ -44,76 +41,21 @@
 #include <asm/io.h>
 #include <asm/delay.h>
 
-#define	SDP3430_FLASH_CS	0
 #define	SDP3430_SMC91X_CS	3
 
 #define ENABLE_VAUX3_DEDICATED	0x03
 #define ENABLE_VAUX3_DEV_GRP	0x20
 
-static struct mtd_partition sdp3430_partitions[] = {
-	/* bootloader (U-Boot, etc) in first sector */
-	{
-		  .name		= "bootloader",
-		  .offset		= 0,
-		  .size		= SZ_256K,
-		  .mask_flags	= MTD_WRITEABLE, /* force read-only */
-	},
-	/* bootloader params in the next sector */
-	{
-		  .name		= "params",
-		  .offset		= MTDPART_OFS_APPEND,
-		  .size		= SZ_128K,
-		  .mask_flags	= 0,
-	},
-	/* kernel */
-	{
-		  .name		= "kernel",
-		  .offset		= MTDPART_OFS_APPEND,
-		  .size		= SZ_2M,
-		  .mask_flags	= 0
-	},
-	/* file system */
-	{
-		  .name		= "filesystem",
-		  .offset		= MTDPART_OFS_APPEND,
-		  .size		= MTDPART_SIZ_FULL,
-		  .mask_flags	= 0
-	}
-};
-
-static struct flash_platform_data sdp3430_flash_data = {
-	.map_name	= "cfi_probe",
-	.width		= 2,
-	.parts		= sdp3430_partitions,
-	.nr_parts	= ARRAY_SIZE(sdp3430_partitions),
-};
-
-static struct resource sdp3430_flash_resource = {
-	.start		= FLASH_BASE,
-	.end		= FLASH_BASE + SZ_64M - 1,
-	.flags		= IORESOURCE_MEM,
-};
-
-static struct platform_device sdp3430_flash_device = {
-	.name		= "omapflash",
-	.id		= 0,
-	.dev		= {
-		.platform_data	= &sdp3430_flash_data,
-	},
-	.num_resources	= 1,
-	.resource	= &sdp3430_flash_resource,
-};
-
 static struct resource sdp3430_smc91x_resources[] = {
 	[0] = {
 		.start	= OMAP34XX_ETHR_START,
 		.end	= OMAP34XX_ETHR_START + SZ_4K,
-		.flags		= IORESOURCE_MEM,
+		.flags	= IORESOURCE_MEM,
 	},
 	[1] = {
-		.start		= OMAP_GPIO_IRQ(OMAP34XX_ETHR_GPIO_IRQ),
+		.start	= 0,
 		.end	= 0,
-		.flags		= IORESOURCE_IRQ,
+		.flags	= IORESOURCE_IRQ,
 	},
 };
 
@@ -256,7 +198,6 @@
 };
 static struct platform_device *sdp3430_devices[] __initdata = {
 	&sdp3430_smc91x_device,
-	&sdp3430_flash_device,
 	&sdp3430_kp_device,
 };
 
@@ -266,6 +207,7 @@
 	unsigned long cs_mem_base;
 	unsigned int rate;
 	struct clk *l3ck;
+	int eth_gpio = 0;
 
 	eth_cs	= SDP3430_SMC91X_CS;
 
@@ -284,12 +226,19 @@
 	sdp3430_smc91x_resources[0].end   = cs_mem_base + 0xf;
 	udelay(100);
 
-	if (omap_request_gpio(OMAP34XX_ETHR_GPIO_IRQ) < 0) {
+	if (is_sil_rev_greater_than(OMAP3430_REV_ES1_0))
+		eth_gpio = OMAP34XX_ETHR_GPIO_IRQ_SDPV2;
+	else
+		eth_gpio = OMAP34XX_ETHR_GPIO_IRQ_SDPV1;
+
+	sdp3430_smc91x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
+
+	if (omap_request_gpio(eth_gpio) < 0) {
 		printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
-			OMAP34XX_ETHR_GPIO_IRQ);
+			eth_gpio);
 		return;
 	}
-	omap_set_gpio_direction(OMAP34XX_ETHR_GPIO_IRQ, 1);
+	omap_set_gpio_direction(eth_gpio, 1);
 }
 
 static void __init omap_3430sdp_init_irq(void)
@@ -314,6 +263,7 @@
 	omap_register_i2c_bus(3, 400, NULL, 0);
 	return 0;
 }
+extern void __init sdp3430_flash_init(void);
 
 static void __init omap_3430sdp_init(void)
 {
@@ -322,6 +272,7 @@
 	omap_board_config_size = ARRAY_SIZE(sdp3430_config);
 	spi_register_board_info(sdp3430_spi_board_info,
 				ARRAY_SIZE(sdp3430_spi_board_info));
+	sdp3430_flash_init();
 	ads7846_dev_init();
 	omap_serial_init();
 }
Index: linux-omap/include/asm-arm/arch-omap/board-3430sdp.h
===================================================================
--- linux-omap.orig/include/asm-arm/arch-omap/board-3430sdp.h	2007-11-19 13:36:16.000000000 -0500
+++ linux-omap/include/asm-arm/arch-omap/board-3430sdp.h	2007-11-19 14:24:42.763431160 -0500
@@ -34,7 +34,8 @@
 /* Placeholder for 3430SDP specific defines */
 
 #define OMAP34XX_ETHR_START		DEBUG_BASE
-#define OMAP34XX_ETHR_GPIO_IRQ		29
+#define OMAP34XX_ETHR_GPIO_IRQ_SDPV1	29
+#define OMAP34XX_ETHR_GPIO_IRQ_SDPV2	6
 
 /*
  * GPIO used for TSC2046, TI's Touchscreen controller
@@ -55,10 +56,15 @@
  * OneNand Mapped to 0x20000000
  * Boot Mode(NAND/NOR). The other on CS1
  */
-#define FLASH_BASE	0x04000000  /* NOR flash (64 Meg aligned) */
-#define DEBUG_BASE	0x08000000  /* debug board */
-#define NAND_BASE	0x0C000000  /* NAND flash */
-#define ONENAND_MAP	0x20000000  /* OneNand flash */
+#define FLASH_BASE_SDPV1	0x04000000  /* NOR flash (64 Meg aligned) */
+#define FLASH_BASE_SDPV2	0x10000000  /* NOR flash (256 Meg aligned) */
+#define DEBUG_BASE		0x08000000  /* debug board */
+#define NAND_BASE		0x0C000000  /* NAND flash */
+#define ONENAND_MAP		0x20000000  /* OneNand flash */
+
+/* various memory sizes */
+#define FLASH_SIZE_SDPV1	SZ_64M
+#define FLASH_SIZE_SDPV2	SZ_128M
 
 #ifdef CONFIG_TWL4030_CORE
 
Index: linux-omap/arch/arm/mach-omap2/Makefile
===================================================================
--- linux-omap.orig/arch/arm/mach-omap2/Makefile	2007-11-19 13:37:33.000000000 -0500
+++ linux-omap/arch/arm/mach-omap2/Makefile	2007-11-19 14:22:32.974162128 -0500
@@ -28,7 +28,8 @@
 					   board-2430sdp-flash.o \
 					   board-2430sdp-usb.o
 obj-$(CONFIG_MACH_OMAP_2430OSK)		+= board-2430osk.o
-obj-$(CONFIG_MACH_OMAP_3430SDP)		+= board-3430sdp.o
+obj-$(CONFIG_MACH_OMAP_3430SDP)		+= board-3430sdp.o \
+					   board-3430sdp-flash.o
 obj-$(CONFIG_MACH_OMAP_APOLLON)		+= board-apollon.o \
 					   board-apollon-keys.o
 obj-$(CONFIG_MACH_NOKIA_N800)		+= board-n800.o board-n800-flash.o \
Index: linux-omap/include/asm-arm/arch-omap/gpmc.h
===================================================================
--- linux-omap.orig/include/asm-arm/arch-omap/gpmc.h	2007-11-19 13:36:16.000000000 -0500
+++ linux-omap/include/asm-arm/arch-omap/gpmc.h	2007-11-20 11:24:38.032203488 -0500
@@ -14,6 +14,36 @@
 /* Maximum Number of Chip Selects */
 #define GPMC_CS_NUM		8
 
+#define GPMC_REVISION		0x00
+#define GPMC_SYSCONFIG		0x10
+#define GPMC_SYSSTATUS		0x14
+#define GPMC_IRQSTATUS		0x18
+#define GPMC_IRQENABLE		0x1C
+#define GPMC_TIMEOUT_CTRL	0x40
+#define GPMC_ERR_ADDRESS	0x44
+#define GPMC_ERR_TYPE		0x48
+#define GPMC_CONFIG		0x50
+#define GPMC_STATUS		0x54
+#define GPMC_PREFETCH_CONFIG1	0x1e0
+#define GPMC_PREFETCH_CONFIG2	0x1e4
+#define GPMC_PREFETCH_CONTROL	0x1e8
+#define GPMC_PREFETCH_STATUS	0x1f0
+#define GPMC_ECC_CONFIG		0x1F4
+#define GPMC_ECC_CONTROL	0x1F8
+#define GPMC_ECC_SIZE_CONFIG	0x1FC
+#define GPMC_ECC1_RESULT	0x200
+#define GPMC_ECC2_RESULT	0x204
+#define GPMC_ECC3_RESULT	0x208
+#define GPMC_ECC4_RESULT	0x20C
+#define GPMC_ECC5_RESULT	0x210
+#define GPMC_ECC6_RESULT	0x214
+#define GPMC_ECC7_RESULT	0x218
+#define GPMC_ECC8_RESULT	0x21C
+#define GPMC_ECC9_RESULT	0x220
+
+#define GPMC_CS0_BASE		0x60
+#define GPMC_CS_SIZE		0x30
+
 #define GPMC_CS_CONFIG1		0x00
 #define GPMC_CS_CONFIG2		0x04
 #define GPMC_CS_CONFIG3		0x08
@@ -25,33 +55,30 @@
 #define GPMC_CS_NAND_ADDRESS	0x20
 #define GPMC_CS_NAND_DATA	0x24
 
-#define GPMC_CONFIG		0x50
-#define GPMC_STATUS		0x54
-
-#define GPMC_CONFIG1_WRAPBURST_SUPP     (1 << 31)
-#define GPMC_CONFIG1_READMULTIPLE_SUPP  (1 << 30)
-#define GPMC_CONFIG1_READTYPE_ASYNC     (0 << 29)
-#define GPMC_CONFIG1_READTYPE_SYNC      (1 << 29)
-#define GPMC_CONFIG1_WRITEMULTIPLE_SUPP (1 << 28)
-#define GPMC_CONFIG1_WRITETYPE_ASYNC    (0 << 27)
-#define GPMC_CONFIG1_WRITETYPE_SYNC     (1 << 27)
+#define GPMC_CONFIG1_WRAPBURST_SUPP	(1 << 31)
+#define GPMC_CONFIG1_READMULTIPLE_SUPP	(1 << 30)
+#define GPMC_CONFIG1_READTYPE_ASYNC	(0 << 29)
+#define GPMC_CONFIG1_READTYPE_SYNC	(1 << 29)
+#define GPMC_CONFIG1_WRITEMULTIPLE_SUPP	(1 << 28)
+#define GPMC_CONFIG1_WRITETYPE_ASYNC	(0 << 27)
+#define GPMC_CONFIG1_WRITETYPE_SYNC	(1 << 27)
 #define GPMC_CONFIG1_CLKACTIVATIONTIME(val) ((val & 3) << 25)
-#define GPMC_CONFIG1_PAGE_LEN(val)      ((val & 3) << 23)
-#define GPMC_CONFIG1_WAIT_READ_MON      (1 << 22)
-#define GPMC_CONFIG1_WAIT_WRITE_MON     (1 << 21)
-#define GPMC_CONFIG1_WAIT_MON_IIME(val) ((val & 3) << 18)
-#define GPMC_CONFIG1_WAIT_PIN_SEL(val)  ((val & 3) << 16)
-#define GPMC_CONFIG1_DEVICESIZE(val)    ((val & 3) << 12)
-#define GPMC_CONFIG1_DEVICESIZE_16      GPMC_CONFIG1_DEVICESIZE(1)
-#define GPMC_CONFIG1_DEVICETYPE(val)    ((val & 3) << 10)
-#define GPMC_CONFIG1_DEVICETYPE_NOR     GPMC_CONFIG1_DEVICETYPE(0)
-#define GPMC_CONFIG1_DEVICETYPE_NAND    GPMC_CONFIG1_DEVICETYPE(1)
-#define GPMC_CONFIG1_MUXADDDATA         (1 << 9)
-#define GPMC_CONFIG1_TIME_PARA_GRAN     (1 << 4)
-#define GPMC_CONFIG1_FCLK_DIV(val)      (val & 3)
-#define GPMC_CONFIG1_FCLK_DIV2          (GPMC_CONFIG1_FCLK_DIV(1))
-#define GPMC_CONFIG1_FCLK_DIV3          (GPMC_CONFIG1_FCLK_DIV(2))
-#define GPMC_CONFIG1_FCLK_DIV4          (GPMC_CONFIG1_FCLK_DIV(3))
+#define GPMC_CONFIG1_PAGE_LEN(val)	((val & 3) << 23)
+#define GPMC_CONFIG1_WAIT_READ_MON	(1 << 22)
+#define GPMC_CONFIG1_WAIT_WRITE_MON	(1 << 21)
+#define GPMC_CONFIG1_WAIT_MON_IIME(val)	((val & 3) << 18)
+#define GPMC_CONFIG1_WAIT_PIN_SEL(val)	((val & 3) << 16)
+#define GPMC_CONFIG1_DEVICESIZE(val)	((val & 3) << 12)
+#define GPMC_CONFIG1_DEVICESIZE_16	GPMC_CONFIG1_DEVICESIZE(1)
+#define GPMC_CONFIG1_DEVICETYPE(val)	((val & 3) << 10)
+#define GPMC_CONFIG1_DEVICETYPE_NOR	GPMC_CONFIG1_DEVICETYPE(0)
+#define GPMC_CONFIG1_DEVICETYPE_NAND	GPMC_CONFIG1_DEVICETYPE(1)
+#define GPMC_CONFIG1_MUXADDDATA		(1 << 9)
+#define GPMC_CONFIG1_TIME_PARA_GRAN	(1 << 4)
+#define GPMC_CONFIG1_FCLK_DIV(val)	(val & 3)
+#define GPMC_CONFIG1_FCLK_DIV2		(GPMC_CONFIG1_FCLK_DIV(1))
+#define GPMC_CONFIG1_FCLK_DIV3		(GPMC_CONFIG1_FCLK_DIV(2))
+#define GPMC_CONFIG1_FCLK_DIV4		(GPMC_CONFIG1_FCLK_DIV(3))
 
 /*
  * Note that all values in this struct are in nanoseconds, while

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

end of thread, other threads:[~2007-11-23 21:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-20 14:23 [PATCH] OMAP: FLASH: Move Flash specific device info in a separate board file Choraria, Rohit
2007-11-23 21:35 ` Tony Lindgren

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