diff options
author | Javier Martinez Canillas <javier@dowhile0.org> | 2012-05-09 17:19:14 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2012-05-09 17:19:14 -0400 |
commit | a42cf2c6c6ea0ec0237d555b95467c149e20e696 (patch) | |
tree | 10ebf21470817ee254dea7b780d4c46aa7dc567e /arch/arm/mach-omap2/board-igep0020.c | |
parent | 8259573b322ee87d4aad26d4a3ecb737b94da272 (diff) |
ARM: OMAP3: igep0020: Add support for Micron NAND Flash storage memory
IGEP-based boards can have two different flash memories, a OneNAND or
a NAND device. The boot configuration pins (sys_boot) are used to
specify which memory is available.
Also, this patch removes unnecesary code for registering the OneNAND.
Signed-off-by: Javier Martinez Canillas <javier@dowhile0.org>
Acked-by: Enric Balletbo i Serra <eballetbo@gmail.com>
Tested-by: Enric Balletbo i Serra <eballetbo@gmail.com>
[tony@atomide.com: fixed up a minor checkpatch warning]
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/board-igep0020.c')
-rw-r--r-- | arch/arm/mach-omap2/board-igep0020.c | 74 |
1 files changed, 31 insertions, 43 deletions
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c index 930c0d380435..16ec5c89e035 100644 --- a/arch/arm/mach-omap2/board-igep0020.c +++ b/arch/arm/mach-omap2/board-igep0020.c | |||
@@ -24,6 +24,8 @@ | |||
24 | #include <linux/i2c/twl.h> | 24 | #include <linux/i2c/twl.h> |
25 | #include <linux/mmc/host.h> | 25 | #include <linux/mmc/host.h> |
26 | 26 | ||
27 | #include <linux/mtd/nand.h> | ||
28 | |||
27 | #include <asm/mach-types.h> | 29 | #include <asm/mach-types.h> |
28 | #include <asm/mach/arch.h> | 30 | #include <asm/mach/arch.h> |
29 | 31 | ||
@@ -39,6 +41,8 @@ | |||
39 | #include "hsmmc.h" | 41 | #include "hsmmc.h" |
40 | #include "sdram-numonyx-m65kxxxxam.h" | 42 | #include "sdram-numonyx-m65kxxxxam.h" |
41 | #include "common-board-devices.h" | 43 | #include "common-board-devices.h" |
44 | #include "board-flash.h" | ||
45 | #include "control.h" | ||
42 | 46 | ||
43 | #define IGEP2_SMSC911X_CS 5 | 47 | #define IGEP2_SMSC911X_CS 5 |
44 | #define IGEP2_SMSC911X_GPIO 176 | 48 | #define IGEP2_SMSC911X_GPIO 176 |
@@ -60,6 +64,10 @@ | |||
60 | #define IGEP3_GPIO_LED1_RED 16 | 64 | #define IGEP3_GPIO_LED1_RED 16 |
61 | #define IGEP3_GPIO_USBH_NRESET 183 | 65 | #define IGEP3_GPIO_USBH_NRESET 183 |
62 | 66 | ||
67 | #define IGEP_SYSBOOT_MASK 0x1f | ||
68 | #define IGEP_SYSBOOT_NAND 0x0f | ||
69 | #define IGEP_SYSBOOT_ONENAND 0x10 | ||
70 | |||
63 | /* | 71 | /* |
64 | * IGEP2 Hardware Revision Table | 72 | * IGEP2 Hardware Revision Table |
65 | * | 73 | * |
@@ -110,8 +118,10 @@ static void __init igep2_get_revision(void) | |||
110 | gpio_free(IGEP2_GPIO_LED1_RED); | 118 | gpio_free(IGEP2_GPIO_LED1_RED); |
111 | } | 119 | } |
112 | 120 | ||
113 | #if defined(CONFIG_MTD_ONENAND_OMAP2) || \ | 121 | #if defined(CONFIG_MTD_ONENAND_OMAP2) || \ |
114 | defined(CONFIG_MTD_ONENAND_OMAP2_MODULE) | 122 | defined(CONFIG_MTD_ONENAND_OMAP2_MODULE) || \ |
123 | defined(CONFIG_MTD_NAND_OMAP2) || \ | ||
124 | defined(CONFIG_MTD_NAND_OMAP2_MODULE) | ||
115 | 125 | ||
116 | #define ONENAND_MAP 0x20000000 | 126 | #define ONENAND_MAP 0x20000000 |
117 | 127 | ||
@@ -123,7 +133,7 @@ static void __init igep2_get_revision(void) | |||
123 | * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048) | 133 | * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048) |
124 | */ | 134 | */ |
125 | 135 | ||
126 | static struct mtd_partition igep_onenand_partitions[] = { | 136 | static struct mtd_partition igep_flash_partitions[] = { |
127 | { | 137 | { |
128 | .name = "X-Loader", | 138 | .name = "X-Loader", |
129 | .offset = 0, | 139 | .offset = 0, |
@@ -151,50 +161,28 @@ static struct mtd_partition igep_onenand_partitions[] = { | |||
151 | }, | 161 | }, |
152 | }; | 162 | }; |
153 | 163 | ||
154 | static struct omap_onenand_platform_data igep_onenand_data = { | 164 | static inline u32 igep_get_sysboot_value(void) |
155 | .parts = igep_onenand_partitions, | 165 | { |
156 | .nr_parts = ARRAY_SIZE(igep_onenand_partitions), | 166 | return omap_ctrl_readl(OMAP343X_CONTROL_STATUS) & IGEP_SYSBOOT_MASK; |
157 | .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */ | 167 | } |
158 | }; | ||
159 | |||
160 | static struct platform_device igep_onenand_device = { | ||
161 | .name = "omap2-onenand", | ||
162 | .id = -1, | ||
163 | .dev = { | ||
164 | .platform_data = &igep_onenand_data, | ||
165 | }, | ||
166 | }; | ||
167 | 168 | ||
168 | static void __init igep_flash_init(void) | 169 | static void __init igep_flash_init(void) |
169 | { | 170 | { |
170 | u8 cs = 0; | 171 | u32 mux; |
171 | u8 onenandcs = GPMC_CS_NUM + 1; | 172 | mux = igep_get_sysboot_value(); |
172 | 173 | ||
173 | for (cs = 0; cs < GPMC_CS_NUM; cs++) { | 174 | if (mux == IGEP_SYSBOOT_NAND) { |
174 | u32 ret; | 175 | pr_info("IGEP: initializing NAND memory device\n"); |
175 | ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); | 176 | board_nand_init(igep_flash_partitions, |
176 | 177 | ARRAY_SIZE(igep_flash_partitions), | |
177 | /* Check if NAND/oneNAND is configured */ | 178 | 0, NAND_BUSWIDTH_16); |
178 | if ((ret & 0xC00) == 0x800) | 179 | } else if (mux == IGEP_SYSBOOT_ONENAND) { |
179 | /* NAND found */ | 180 | pr_info("IGEP: initializing OneNAND memory device\n"); |
180 | pr_err("IGEP: Unsupported NAND found\n"); | 181 | board_onenand_init(igep_flash_partitions, |
181 | else { | 182 | ARRAY_SIZE(igep_flash_partitions), 0); |
182 | ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); | 183 | } else { |
183 | if ((ret & 0x3F) == (ONENAND_MAP >> 24)) | 184 | pr_err("IGEP: Flash: unsupported sysboot sequence found\n"); |
184 | /* ONENAND found */ | ||
185 | onenandcs = cs; | ||
186 | } | ||
187 | } | ||
188 | |||
189 | if (onenandcs > GPMC_CS_NUM) { | ||
190 | pr_err("IGEP: Unable to find configuration in GPMC\n"); | ||
191 | return; | ||
192 | } | 185 | } |
193 | |||
194 | igep_onenand_data.cs = onenandcs; | ||
195 | |||
196 | if (platform_device_register(&igep_onenand_device) < 0) | ||
197 | pr_err("IGEP: Unable to register OneNAND device\n"); | ||
198 | } | 186 | } |
199 | 187 | ||
200 | #else | 188 | #else |