diff options
author | Ladislav Michl <ladis@linux-mips.org> | 2009-12-11 19:16:33 -0500 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2009-12-11 19:16:33 -0500 |
commit | 414f552ad872e19a7471644317a60f3cbba25ced (patch) | |
tree | 441f388dffb45868e3898893aa1b22e2a3a60f59 | |
parent | e2b18e3018630d80eda54508e697d613283d57ac (diff) |
omap1: Use gen_nand
Since omapnand driver never find its way into mainline, switch to gen_nand instead.
Following patch is compile tested only, but it is based on code I wrote for
NetStar board and runtime tested it there.
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Cc: Imre Deak <imre.deak@nokia.com>
Cc: Brian Swetland <swetland@google.com>
Cc: Kevin Hilman <kjh@hilman.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r-- | arch/arm/mach-omap1/board-fsample.c | 50 | ||||
-rw-r--r-- | arch/arm/mach-omap1/board-h2.c | 49 | ||||
-rw-r--r-- | arch/arm/mach-omap1/board-h3.c | 56 | ||||
-rw-r--r-- | arch/arm/mach-omap1/board-perseus2.c | 48 |
4 files changed, 152 insertions, 51 deletions
diff --git a/arch/arm/mach-omap1/board-fsample.c b/arch/arm/mach-omap1/board-fsample.c index 91e7b2f2bc05..7e70c3c08da6 100644 --- a/arch/arm/mach-omap1/board-fsample.c +++ b/arch/arm/mach-omap1/board-fsample.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <mach/gpio.h> | 31 | #include <mach/gpio.h> |
32 | #include <plat/mux.h> | 32 | #include <plat/mux.h> |
33 | #include <plat/fpga.h> | 33 | #include <plat/fpga.h> |
34 | #include <plat/nand.h> | ||
35 | #include <plat/keypad.h> | 34 | #include <plat/keypad.h> |
36 | #include <plat/common.h> | 35 | #include <plat/common.h> |
37 | #include <plat/board.h> | 36 | #include <plat/board.h> |
@@ -174,8 +173,40 @@ static struct platform_device nor_device = { | |||
174 | .resource = &nor_resource, | 173 | .resource = &nor_resource, |
175 | }; | 174 | }; |
176 | 175 | ||
177 | static struct omap_nand_platform_data nand_data = { | 176 | static void nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl) |
178 | .options = NAND_SAMSUNG_LP_OPTIONS, | 177 | { |
178 | struct nand_chip *this = mtd->priv; | ||
179 | unsigned long mask; | ||
180 | |||
181 | if (cmd == NAND_CMD_NONE) | ||
182 | return; | ||
183 | |||
184 | mask = (ctrl & NAND_CLE) ? 0x02 : 0; | ||
185 | if (ctrl & NAND_ALE) | ||
186 | mask |= 0x04; | ||
187 | writeb(cmd, (unsigned long)this->IO_ADDR_W | mask); | ||
188 | } | ||
189 | |||
190 | #define FSAMPLE_NAND_RB_GPIO_PIN 62 | ||
191 | |||
192 | static int nand_dev_ready(struct mtd_info *mtd) | ||
193 | { | ||
194 | return gpio_get_value(FSAMPLE_NAND_RB_GPIO_PIN); | ||
195 | } | ||
196 | |||
197 | static const char *part_probes[] = { "cmdlinepart", NULL }; | ||
198 | |||
199 | static struct platform_nand_data nand_data = { | ||
200 | .chip = { | ||
201 | .nr_chips = 1, | ||
202 | .chip_offset = 0, | ||
203 | .options = NAND_SAMSUNG_LP_OPTIONS, | ||
204 | .part_probe_types = part_probes, | ||
205 | }, | ||
206 | .ctrl = { | ||
207 | .cmd_ctrl = nand_cmd_ctl, | ||
208 | .dev_ready = nand_dev_ready, | ||
209 | }, | ||
179 | }; | 210 | }; |
180 | 211 | ||
181 | static struct resource nand_resource = { | 212 | static struct resource nand_resource = { |
@@ -185,7 +216,7 @@ static struct resource nand_resource = { | |||
185 | }; | 216 | }; |
186 | 217 | ||
187 | static struct platform_device nand_device = { | 218 | static struct platform_device nand_device = { |
188 | .name = "omapnand", | 219 | .name = "gen_nand", |
189 | .id = 0, | 220 | .id = 0, |
190 | .dev = { | 221 | .dev = { |
191 | .platform_data = &nand_data, | 222 | .platform_data = &nand_data, |
@@ -243,13 +274,6 @@ static struct platform_device *devices[] __initdata = { | |||
243 | &lcd_device, | 274 | &lcd_device, |
244 | }; | 275 | }; |
245 | 276 | ||
246 | #define P2_NAND_RB_GPIO_PIN 62 | ||
247 | |||
248 | static int nand_dev_ready(struct omap_nand_platform_data *data) | ||
249 | { | ||
250 | return gpio_get_value(P2_NAND_RB_GPIO_PIN); | ||
251 | } | ||
252 | |||
253 | static struct omap_lcd_config fsample_lcd_config __initdata = { | 277 | static struct omap_lcd_config fsample_lcd_config __initdata = { |
254 | .ctrl_name = "internal", | 278 | .ctrl_name = "internal", |
255 | }; | 279 | }; |
@@ -260,9 +284,9 @@ static struct omap_board_config_kernel fsample_config[] = { | |||
260 | 284 | ||
261 | static void __init omap_fsample_init(void) | 285 | static void __init omap_fsample_init(void) |
262 | { | 286 | { |
263 | if (gpio_request(P2_NAND_RB_GPIO_PIN, "NAND ready") < 0) | 287 | if (gpio_request(FSAMPLE_NAND_RB_GPIO_PIN, "NAND ready") < 0) |
264 | BUG(); | 288 | BUG(); |
265 | nand_data.dev_ready = nand_dev_ready; | 289 | gpio_direction_input(FSAMPLE_NAND_RB_GPIO_PIN); |
266 | 290 | ||
267 | omap_cfg_reg(L3_1610_FLASH_CS2B_OE); | 291 | omap_cfg_reg(L3_1610_FLASH_CS2B_OE); |
268 | omap_cfg_reg(M8_1610_FLASH_CS2B_WE); | 292 | omap_cfg_reg(M8_1610_FLASH_CS2B_WE); |
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c index eeafe6ed15cb..fa7cecea19f9 100644 --- a/arch/arm/mach-omap1/board-h2.c +++ b/arch/arm/mach-omap1/board-h2.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #include <plat/mux.h> | 41 | #include <plat/mux.h> |
42 | #include <plat/dma.h> | 42 | #include <plat/dma.h> |
43 | #include <plat/tc.h> | 43 | #include <plat/tc.h> |
44 | #include <plat/nand.h> | ||
45 | #include <plat/irda.h> | 44 | #include <plat/irda.h> |
46 | #include <plat/usb.h> | 45 | #include <plat/usb.h> |
47 | #include <plat/keypad.h> | 46 | #include <plat/keypad.h> |
@@ -180,11 +179,43 @@ static struct mtd_partition h2_nand_partitions[] = { | |||
180 | }, | 179 | }, |
181 | }; | 180 | }; |
182 | 181 | ||
183 | /* dip switches control NAND chip access: 8 bit, 16 bit, or neither */ | 182 | static void h2_nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl) |
184 | static struct omap_nand_platform_data h2_nand_data = { | 183 | { |
185 | .options = NAND_SAMSUNG_LP_OPTIONS, | 184 | struct nand_chip *this = mtd->priv; |
186 | .parts = h2_nand_partitions, | 185 | unsigned long mask; |
187 | .nr_parts = ARRAY_SIZE(h2_nand_partitions), | 186 | |
187 | if (cmd == NAND_CMD_NONE) | ||
188 | return; | ||
189 | |||
190 | mask = (ctrl & NAND_CLE) ? 0x02 : 0; | ||
191 | if (ctrl & NAND_ALE) | ||
192 | mask |= 0x04; | ||
193 | writeb(cmd, (unsigned long)this->IO_ADDR_W | mask); | ||
194 | } | ||
195 | |||
196 | #define H2_NAND_RB_GPIO_PIN 62 | ||
197 | |||
198 | static int h2_nand_dev_ready(struct mtd_info *mtd) | ||
199 | { | ||
200 | return gpio_get_value(H2_NAND_RB_GPIO_PIN); | ||
201 | } | ||
202 | |||
203 | static const char *h2_part_probes[] = { "cmdlinepart", NULL }; | ||
204 | |||
205 | struct platform_nand_data h2_nand_platdata = { | ||
206 | .chip = { | ||
207 | .nr_chips = 1, | ||
208 | .chip_offset = 0, | ||
209 | .nr_partitions = ARRAY_SIZE(h2_nand_partitions), | ||
210 | .partitions = h2_nand_partitions, | ||
211 | .options = NAND_SAMSUNG_LP_OPTIONS, | ||
212 | .part_probe_types = h2_part_probes, | ||
213 | }, | ||
214 | .ctrl = { | ||
215 | .cmd_ctrl = h2_nand_cmd_ctl, | ||
216 | .dev_ready = h2_nand_dev_ready, | ||
217 | |||
218 | }, | ||
188 | }; | 219 | }; |
189 | 220 | ||
190 | static struct resource h2_nand_resource = { | 221 | static struct resource h2_nand_resource = { |
@@ -192,10 +223,10 @@ static struct resource h2_nand_resource = { | |||
192 | }; | 223 | }; |
193 | 224 | ||
194 | static struct platform_device h2_nand_device = { | 225 | static struct platform_device h2_nand_device = { |
195 | .name = "omapnand", | 226 | .name = "gen_nand", |
196 | .id = 0, | 227 | .id = 0, |
197 | .dev = { | 228 | .dev = { |
198 | .platform_data = &h2_nand_data, | 229 | .platform_data = &h2_nand_platdata, |
199 | }, | 230 | }, |
200 | .num_resources = 1, | 231 | .num_resources = 1, |
201 | .resource = &h2_nand_resource, | 232 | .resource = &h2_nand_resource, |
@@ -378,8 +409,6 @@ static struct omap_board_config_kernel h2_config[] __initdata = { | |||
378 | { OMAP_TAG_LCD, &h2_lcd_config }, | 409 | { OMAP_TAG_LCD, &h2_lcd_config }, |
379 | }; | 410 | }; |
380 | 411 | ||
381 | #define H2_NAND_RB_GPIO_PIN 62 | ||
382 | |||
383 | static void __init h2_init(void) | 412 | static void __init h2_init(void) |
384 | { | 413 | { |
385 | /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped | 414 | /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped |
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c index e0aee66e43e6..6a7f9c391cf1 100644 --- a/arch/arm/mach-omap1/board-h3.c +++ b/arch/arm/mach-omap1/board-h3.c | |||
@@ -43,7 +43,6 @@ | |||
43 | #include <mach/irqs.h> | 43 | #include <mach/irqs.h> |
44 | #include <plat/mux.h> | 44 | #include <plat/mux.h> |
45 | #include <plat/tc.h> | 45 | #include <plat/tc.h> |
46 | #include <plat/nand.h> | ||
47 | #include <plat/usb.h> | 46 | #include <plat/usb.h> |
48 | #include <plat/keypad.h> | 47 | #include <plat/keypad.h> |
49 | #include <plat/dma.h> | 48 | #include <plat/dma.h> |
@@ -182,11 +181,43 @@ static struct mtd_partition nand_partitions[] = { | |||
182 | }, | 181 | }, |
183 | }; | 182 | }; |
184 | 183 | ||
185 | /* dip switches control NAND chip access: 8 bit, 16 bit, or neither */ | 184 | static void nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl) |
186 | static struct omap_nand_platform_data nand_data = { | 185 | { |
187 | .options = NAND_SAMSUNG_LP_OPTIONS, | 186 | struct nand_chip *this = mtd->priv; |
188 | .parts = nand_partitions, | 187 | unsigned long mask; |
189 | .nr_parts = ARRAY_SIZE(nand_partitions), | 188 | |
189 | if (cmd == NAND_CMD_NONE) | ||
190 | return; | ||
191 | |||
192 | mask = (ctrl & NAND_CLE) ? 0x02 : 0; | ||
193 | if (ctrl & NAND_ALE) | ||
194 | mask |= 0x04; | ||
195 | writeb(cmd, (unsigned long)this->IO_ADDR_W | mask); | ||
196 | } | ||
197 | |||
198 | #define H3_NAND_RB_GPIO_PIN 10 | ||
199 | |||
200 | static int nand_dev_ready(struct mtd_info *mtd) | ||
201 | { | ||
202 | return gpio_get_value(H3_NAND_RB_GPIO_PIN); | ||
203 | } | ||
204 | |||
205 | static const char *part_probes[] = { "cmdlinepart", NULL }; | ||
206 | |||
207 | struct platform_nand_data nand_platdata = { | ||
208 | .chip = { | ||
209 | .nr_chips = 1, | ||
210 | .chip_offset = 0, | ||
211 | .nr_partitions = ARRAY_SIZE(nand_partitions), | ||
212 | .partitions = nand_partitions, | ||
213 | .options = NAND_SAMSUNG_LP_OPTIONS, | ||
214 | .part_probe_types = part_probes, | ||
215 | }, | ||
216 | .ctrl = { | ||
217 | .cmd_ctrl = nand_cmd_ctl, | ||
218 | .dev_ready = nand_dev_ready, | ||
219 | |||
220 | }, | ||
190 | }; | 221 | }; |
191 | 222 | ||
192 | static struct resource nand_resource = { | 223 | static struct resource nand_resource = { |
@@ -194,10 +225,10 @@ static struct resource nand_resource = { | |||
194 | }; | 225 | }; |
195 | 226 | ||
196 | static struct platform_device nand_device = { | 227 | static struct platform_device nand_device = { |
197 | .name = "omapnand", | 228 | .name = "gen_nand", |
198 | .id = 0, | 229 | .id = 0, |
199 | .dev = { | 230 | .dev = { |
200 | .platform_data = &nand_data, | 231 | .platform_data = &nand_platdata, |
201 | }, | 232 | }, |
202 | .num_resources = 1, | 233 | .num_resources = 1, |
203 | .resource = &nand_resource, | 234 | .resource = &nand_resource, |
@@ -342,13 +373,6 @@ static struct i2c_board_info __initdata h3_i2c_board_info[] = { | |||
342 | }, | 373 | }, |
343 | }; | 374 | }; |
344 | 375 | ||
345 | #define H3_NAND_RB_GPIO_PIN 10 | ||
346 | |||
347 | static int nand_dev_ready(struct omap_nand_platform_data *data) | ||
348 | { | ||
349 | return gpio_get_value(H3_NAND_RB_GPIO_PIN); | ||
350 | } | ||
351 | |||
352 | static void __init h3_init(void) | 376 | static void __init h3_init(void) |
353 | { | 377 | { |
354 | /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped | 378 | /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped |
@@ -366,7 +390,7 @@ static void __init h3_init(void) | |||
366 | nand_resource.end += SZ_4K - 1; | 390 | nand_resource.end += SZ_4K - 1; |
367 | if (gpio_request(H3_NAND_RB_GPIO_PIN, "NAND ready") < 0) | 391 | if (gpio_request(H3_NAND_RB_GPIO_PIN, "NAND ready") < 0) |
368 | BUG(); | 392 | BUG(); |
369 | nand_data.dev_ready = nand_dev_ready; | 393 | gpio_direction_input(H3_NAND_RB_GPIO_PIN); |
370 | 394 | ||
371 | /* GPIO10 Func_MUX_CTRL reg bit 29:27, Configure V2 to mode1 as GPIO */ | 395 | /* GPIO10 Func_MUX_CTRL reg bit 29:27, Configure V2 to mode1 as GPIO */ |
372 | /* GPIO10 pullup/down register, Enable pullup on GPIO10 */ | 396 | /* GPIO10 pullup/down register, Enable pullup on GPIO10 */ |
diff --git a/arch/arm/mach-omap1/board-perseus2.c b/arch/arm/mach-omap1/board-perseus2.c index b9ea31289b50..1387a4f15da9 100644 --- a/arch/arm/mach-omap1/board-perseus2.c +++ b/arch/arm/mach-omap1/board-perseus2.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <mach/gpio.h> | 31 | #include <mach/gpio.h> |
32 | #include <plat/mux.h> | 32 | #include <plat/mux.h> |
33 | #include <plat/fpga.h> | 33 | #include <plat/fpga.h> |
34 | #include <plat/nand.h> | ||
35 | #include <plat/keypad.h> | 34 | #include <plat/keypad.h> |
36 | #include <plat/common.h> | 35 | #include <plat/common.h> |
37 | #include <plat/board.h> | 36 | #include <plat/board.h> |
@@ -141,8 +140,40 @@ static struct platform_device nor_device = { | |||
141 | .resource = &nor_resource, | 140 | .resource = &nor_resource, |
142 | }; | 141 | }; |
143 | 142 | ||
144 | static struct omap_nand_platform_data nand_data = { | 143 | static void nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl) |
145 | .options = NAND_SAMSUNG_LP_OPTIONS, | 144 | { |
145 | struct nand_chip *this = mtd->priv; | ||
146 | unsigned long mask; | ||
147 | |||
148 | if (cmd == NAND_CMD_NONE) | ||
149 | return; | ||
150 | |||
151 | mask = (ctrl & NAND_CLE) ? 0x02 : 0; | ||
152 | if (ctrl & NAND_ALE) | ||
153 | mask |= 0x04; | ||
154 | writeb(cmd, (unsigned long)this->IO_ADDR_W | mask); | ||
155 | } | ||
156 | |||
157 | #define P2_NAND_RB_GPIO_PIN 62 | ||
158 | |||
159 | static int nand_dev_ready(struct mtd_info *mtd) | ||
160 | { | ||
161 | return gpio_get_value(P2_NAND_RB_GPIO_PIN); | ||
162 | } | ||
163 | |||
164 | static const char *part_probes[] = { "cmdlinepart", NULL }; | ||
165 | |||
166 | static struct platform_nand_data nand_data = { | ||
167 | .chip = { | ||
168 | .nr_chips = 1, | ||
169 | .chip_offset = 0, | ||
170 | .options = NAND_SAMSUNG_LP_OPTIONS, | ||
171 | .part_probe_types = part_probes, | ||
172 | }, | ||
173 | .ctrl = { | ||
174 | .cmd_ctrl = nand_cmd_ctl, | ||
175 | .dev_ready = nand_dev_ready, | ||
176 | }, | ||
146 | }; | 177 | }; |
147 | 178 | ||
148 | static struct resource nand_resource = { | 179 | static struct resource nand_resource = { |
@@ -152,7 +183,7 @@ static struct resource nand_resource = { | |||
152 | }; | 183 | }; |
153 | 184 | ||
154 | static struct platform_device nand_device = { | 185 | static struct platform_device nand_device = { |
155 | .name = "omapnand", | 186 | .name = "gen_nand", |
156 | .id = 0, | 187 | .id = 0, |
157 | .dev = { | 188 | .dev = { |
158 | .platform_data = &nand_data, | 189 | .platform_data = &nand_data, |
@@ -211,13 +242,6 @@ static struct platform_device *devices[] __initdata = { | |||
211 | &lcd_device, | 242 | &lcd_device, |
212 | }; | 243 | }; |
213 | 244 | ||
214 | #define P2_NAND_RB_GPIO_PIN 62 | ||
215 | |||
216 | static int nand_dev_ready(struct omap_nand_platform_data *data) | ||
217 | { | ||
218 | return gpio_get_value(P2_NAND_RB_GPIO_PIN); | ||
219 | } | ||
220 | |||
221 | static struct omap_lcd_config perseus2_lcd_config __initdata = { | 245 | static struct omap_lcd_config perseus2_lcd_config __initdata = { |
222 | .ctrl_name = "internal", | 246 | .ctrl_name = "internal", |
223 | }; | 247 | }; |
@@ -230,7 +254,7 @@ static void __init omap_perseus2_init(void) | |||
230 | { | 254 | { |
231 | if (gpio_request(P2_NAND_RB_GPIO_PIN, "NAND ready") < 0) | 255 | if (gpio_request(P2_NAND_RB_GPIO_PIN, "NAND ready") < 0) |
232 | BUG(); | 256 | BUG(); |
233 | nand_data.dev_ready = nand_dev_ready; | 257 | gpio_direction_input(P2_NAND_RB_GPIO_PIN); |
234 | 258 | ||
235 | omap_cfg_reg(L3_1610_FLASH_CS2B_OE); | 259 | omap_cfg_reg(L3_1610_FLASH_CS2B_OE); |
236 | omap_cfg_reg(M8_1610_FLASH_CS2B_WE); | 260 | omap_cfg_reg(M8_1610_FLASH_CS2B_WE); |