Re: [PATCH 2/3] OMAP: SDP: Introducing 'board-sdp-flash.c' for flash init

2010-02-05 Thread Vimal Singh
On Fri, Feb 5, 2010 at 5:20 AM, Tony Lindgren  wrote:
> * Vimal Singh  [100112 22:51]:
>> From 994785b066a9bd4fbaf7753cb6ab7317440afd36 Mon Sep 17 00:00:00 2001
>> From: Vimal Singh 
>> Date: Tue, 12 Jan 2010 17:22:42 +0530
>> Subject: [PATCH] OMAP: SDP: Introducing 'board-sdp-flash.c' for flash init
>>
>> This patch adds 'board-sdp-flash.c', which could be utilized
>> by boards similar to 3430SDP. (For ex: 2430sdp, 36030sdp).
>>
>> This file does initialization for all three flash devices present
>> in SDP boards (NOR, NAND, OneNAND), by finding there 'cs' number
>> dynamically using switch setting information (S8: 1-4).
>> This also expects partition information from core board files (for
>> ex: board-3430sdp.c). Which allows to choose different default
>> partitions for different boards.
>>
>> A new structure is created for this purpose: 'flash_partitions'
>> in 'mach/board-sdp.h'. This has two members:
>> 1. struct mtd_partition *parts
>> 2. int nr_parts
>>
>> A board file is expected to fill this structure and pass it to
>> 'sdp-flsash-init'. Partition information should be passed in
>> structure array of 'flash_partitions'. Partition information should
>> be passed in below sequence in array:
>> NOR
>> OneNAND
>> NAND
>
> 
>
>> +__init board_nand_init(struct flash_partitions sdp_nand_parts, u8 cs)
>> +{
>> +     sdp_nand_data.cs                = cs;
>> +     sdp_nand_data.parts             = sdp_nand_parts.parts;
>> +     sdp_nand_data.nr_parts          = sdp_nand_parts.nr_parts;
>> +
>> +     sdp_nand_data.gpmc_cs_baseaddr  = (void *)(OMAP34XX_GPMC_VIRT +
>> +                                                     GPMC_CS0_BASE +
>> +                                                     cs * GPMC_CS_SIZE);
>> +     sdp_nand_data.gpmc_baseaddr      = (void *) (OMAP34XX_GPMC_VIRT);
>> +
>> +     gpmc_nand_init(&sdp_nand_data);
>> +}
>
> Related to the comments for gpmc-nand.c, you can now get rid of the
> gpmc_cs_baseaddr hardcoding in the board-*.c files. The address gets
> assigned by gpmc_cs_request based on the chip select and size.

This (gpmc_cs_baseaddr) is passed to OMAP NAND driver (nand/omap2.c)
for its uses.
This is base address to GPMC Registers for CS where NAND is present.
And this will be used by functions like "omap_hwcontrol" to access
GPMC NAND COMMAND, GPMC NAND ADDRESS and GPMC NAND DATA etc CS
specific registers.

And of course, nand driver should not know at which 'cs' nand device
is connected, correct?
So, this information is passed from board.



-- 
Regards,
Vimal Singh
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] OMAP: SDP: Introducing 'board-sdp-flash.c' for flash init

2010-02-04 Thread Tony Lindgren
* Vimal Singh  [100112 22:51]:
> From 994785b066a9bd4fbaf7753cb6ab7317440afd36 Mon Sep 17 00:00:00 2001
> From: Vimal Singh 
> Date: Tue, 12 Jan 2010 17:22:42 +0530
> Subject: [PATCH] OMAP: SDP: Introducing 'board-sdp-flash.c' for flash init
> 
> This patch adds 'board-sdp-flash.c', which could be utilized
> by boards similar to 3430SDP. (For ex: 2430sdp, 36030sdp).
> 
> This file does initialization for all three flash devices present
> in SDP boards (NOR, NAND, OneNAND), by finding there 'cs' number
> dynamically using switch setting information (S8: 1-4).
> This also expects partition information from core board files (for
> ex: board-3430sdp.c). Which allows to choose different default
> partitions for different boards.
> 
> A new structure is created for this purpose: 'flash_partitions'
> in 'mach/board-sdp.h'. This has two members:
> 1. struct mtd_partition *parts
> 2. int nr_parts
> 
> A board file is expected to fill this structure and pass it to
> 'sdp-flsash-init'. Partition information should be passed in
> structure array of 'flash_partitions'. Partition information should
> be passed in below sequence in array:
> NOR
> OneNAND
> NAND



> +__init board_nand_init(struct flash_partitions sdp_nand_parts, u8 cs)
> +{
> + sdp_nand_data.cs= cs;
> + sdp_nand_data.parts = sdp_nand_parts.parts;
> + sdp_nand_data.nr_parts  = sdp_nand_parts.nr_parts;
> +
> + sdp_nand_data.gpmc_cs_baseaddr  = (void *)(OMAP34XX_GPMC_VIRT +
> + GPMC_CS0_BASE +
> + cs * GPMC_CS_SIZE);
> + sdp_nand_data.gpmc_baseaddr  = (void *) (OMAP34XX_GPMC_VIRT);
> +
> + gpmc_nand_init(&sdp_nand_data);
> +}

Related to the comments for gpmc-nand.c, you can now get rid of the
gpmc_cs_baseaddr hardcoding in the board-*.c files. The address gets
assigned by gpmc_cs_request based on the chip select and size.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] OMAP: SDP: Introducing 'board-sdp-flash.c' for flash init

2010-01-12 Thread Vimal Singh
>From 994785b066a9bd4fbaf7753cb6ab7317440afd36 Mon Sep 17 00:00:00 2001
From: Vimal Singh 
Date: Tue, 12 Jan 2010 17:22:42 +0530
Subject: [PATCH] OMAP: SDP: Introducing 'board-sdp-flash.c' for flash init

This patch adds 'board-sdp-flash.c', which could be utilized
by boards similar to 3430SDP. (For ex: 2430sdp, 36030sdp).

This file does initialization for all three flash devices present
in SDP boards (NOR, NAND, OneNAND), by finding there 'cs' number
dynamically using switch setting information (S8: 1-4).
This also expects partition information from core board files (for
ex: board-3430sdp.c). Which allows to choose different default
partitions for different boards.

A new structure is created for this purpose: 'flash_partitions'
in 'mach/board-sdp.h'. This has two members:
1. struct mtd_partition *parts
2. int nr_parts

A board file is expected to fill this structure and pass it to
'sdp-flsash-init'. Partition information should be passed in
structure array of 'flash_partitions'. Partition information should
be passed in below sequence in array:
NOR
OneNAND
NAND

Signed-off-by: Vimal Singh 
---
 arch/arm/mach-omap2/board-sdp-flash.c|  295 ++
 arch/arm/mach-omap2/include/mach/board-sdp.h |   22 ++
 arch/arm/plat-omap/include/plat/gpmc.h   |2 +
 3 files changed, 319 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/board-sdp-flash.c
 create mode 100644 arch/arm/mach-omap2/include/mach/board-sdp.h

diff --git a/arch/arm/mach-omap2/board-sdp-flash.c
b/arch/arm/mach-omap2/board-sdp-flash.c
new file mode 100644
index 000..54ef19f
--- /dev/null
+++ b/arch/arm/mach-omap2/board-sdp-flash.c
@@ -0,0 +1,295 @@
+/*
+ * board-sdp-flash.c
+ * Modified from mach-omap2/board-3430sdp-flash.c
+ *
+ * Copyright (C) 2009 Nokia Corporation
+ * Copyright (C) 2009 Texas Instruments
+ *
+ * Vimal Singh 
+ *
+ * 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 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define REG_FPGA_REV   0x10
+#define REG_FPGA_DIP_SWITCH_INPUT2 0x60
+#define MAX_SUPPORTED_GPMC_CONFIG  3
+
+#define DEBUG_BASE 0x0800 /* debug board */
+
+#define PDC_NOR1
+#define PDC_NAND   2
+#define PDC_ONENAND3
+#define DBG_MPDB   4
+
+/* various memory sizes */
+#define FLASH_SIZE_SDPV1   SZ_64M  /* NOR flash (64 Meg aligned) */
+#define FLASH_SIZE_SDPV2   SZ_128M /* NOR flash (256 Meg aligned) */
+
+/*
+ * SDP3430 V2 Board CS organization
+ * Different from SDP3430 V1. Now 4 switches used to specify CS
+ *
+ * See also the Switch S8 settings in the comments.
+ *
+ * REVISIT: Add support for 2430 SDP
+ */
+static const unsigned char chip_sel_sdp[][GPMC_CS_NUM] = {
+   {PDC_NOR, PDC_NAND, PDC_ONENAND, DBG_MPDB, 0, 0, 0, 0}, /* S8: */
+   {PDC_ONENAND, PDC_NAND, PDC_NOR, DBG_MPDB, 0, 0, 0, 0}, /* S8:1110 */
+   {PDC_NAND, PDC_ONENAND, PDC_NOR, DBG_MPDB, 0, 0, 0, 0}, /* S8:1101 */
+};
+
+static void omap_set_vpp(struct map_info *map, int enable)
+{
+   static int  count;
+   u32 l;
+
+   if (cpu_class_is_omap1()) {
+   if (enable) {
+   if (count++ == 0) {
+   l = omap_readl(EMIFS_CONFIG);
+   l |= OMAP_EMIFS_CONFIG_WP;
+   omap_writel(l, EMIFS_CONFIG);
+   }
+   } else {
+   if (count && (--count == 0)) {
+   l = omap_readl(EMIFS_CONFIG);
+   l &= ~OMAP_EMIFS_CONFIG_WP;
+   omap_writel(l, EMIFS_CONFIG);
+   }
+   }
+   }
+}
+
+static struct physmap_flash_data sdp_nor_data = {
+   .width  = 2,
+   .set_vpp= omap_set_vpp,
+};
+
+static struct resource sdp_nor_resource = {
+   .flags  = IORESOURCE_MEM,
+};
+
+static struct platform_device sdp_nor_device = {
+   .name   = "physmap-flash",
+   .id = 0,
+   .dev= {
+   .platform_data = &sdp_nor_data,
+   },
+   .num_resources  = 1,
+   .resource   = &sdp_nor_resource,
+};
+
+static void
+__init board_nor_init(struct flash_partitions sdp_nor_parts, u8 cs)
+{
+   int err;
+
+   sdp_nor_data.parts  = sdp_nor_parts.parts;
+   sdp_nor_data.nr_parts   = sdp_nor_parts.nr_parts;
+
+   /* Configure start address and size of NOR device */
+   if (omap_rev() >= OMAP3430_REV_ES1_0) {
+   err = gpmc_cs_request(cs, FLASH_SIZE_SDPV2 - 1,
+   (unsigned long *)&sdp_nor_resource.start);
+   sdp_nor_resource.end = sdp_nor_resource.start
+