aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2
diff options
context:
space:
mode:
authorMike Rapoport <mike@compulab.co.il>2011-04-24 18:09:07 -0400
committerTony Lindgren <tony@atomide.com>2011-05-03 05:53:37 -0400
commit9a3f39ff36e11ea6b6c8b5f90337a864cb7e81f6 (patch)
treebdce8353ab8670fa603d5ace590c2a467df3537d /arch/arm/mach-omap2
parentfbd8071c188e3053fb318d78214e54d4615d93f2 (diff)
omap: move detection of NAND CS to common-board-devices
and reduce amount of copy/paste Signed-off-by: Mike Rapoport <mike@compulab.co.il> CC: Oleg Drokin <green@linuxhacker.ru> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2')
-rw-r--r--arch/arm/mach-omap2/board-devkit8000.c43
-rw-r--r--arch/arm/mach-omap2/board-omap3beagle.c45
-rw-r--r--arch/arm/mach-omap2/board-omap3touchbook.c45
-rw-r--r--arch/arm/mach-omap2/board-overo.c42
-rw-r--r--arch/arm/mach-omap2/common-board-devices.c57
-rw-r--r--arch/arm/mach-omap2/common-board-devices.h11
6 files changed, 67 insertions, 176 deletions
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index 983f44b78777..e7dc057600d5 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -97,13 +97,6 @@ static struct mtd_partition devkit8000_nand_partitions[] = {
97 }, 97 },
98}; 98};
99 99
100static struct omap_nand_platform_data devkit8000_nand_data = {
101 .options = NAND_BUSWIDTH_16,
102 .parts = devkit8000_nand_partitions,
103 .nr_parts = ARRAY_SIZE(devkit8000_nand_partitions),
104 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
105};
106
107static struct omap2_hsmmc_info mmc[] = { 100static struct omap2_hsmmc_info mmc[] = {
108 { 101 {
109 .mmc = 1, 102 .mmc = 1,
@@ -516,39 +509,6 @@ static struct platform_device *devkit8000_devices[] __initdata = {
516 &omap_dm9000_dev, 509 &omap_dm9000_dev,
517}; 510};
518 511
519static void __init devkit8000_flash_init(void)
520{
521 u8 cs = 0;
522 u8 nandcs = GPMC_CS_NUM + 1;
523
524 /* find out the chip-select on which NAND exists */
525 while (cs < GPMC_CS_NUM) {
526 u32 ret = 0;
527 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
528
529 if ((ret & 0xC00) == 0x800) {
530 printk(KERN_INFO "Found NAND on CS%d\n", cs);
531 if (nandcs > GPMC_CS_NUM)
532 nandcs = cs;
533 }
534 cs++;
535 }
536
537 if (nandcs > GPMC_CS_NUM) {
538 printk(KERN_INFO "NAND: Unable to find configuration "
539 "in GPMC\n ");
540 return;
541 }
542
543 if (nandcs < GPMC_CS_NUM) {
544 devkit8000_nand_data.cs = nandcs;
545
546 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
547 if (gpmc_nand_init(&devkit8000_nand_data) < 0)
548 printk(KERN_ERR "Unable to register NAND device\n");
549 }
550}
551
552static struct omap_musb_board_data musb_board_data = { 512static struct omap_musb_board_data musb_board_data = {
553 .interface_type = MUSB_INTERFACE_ULPI, 513 .interface_type = MUSB_INTERFACE_ULPI,
554 .mode = MUSB_OTG, 514 .mode = MUSB_OTG,
@@ -740,7 +700,8 @@ static void __init devkit8000_init(void)
740 700
741 usb_musb_init(&musb_board_data); 701 usb_musb_init(&musb_board_data);
742 usbhs_init(&usbhs_bdata); 702 usbhs_init(&usbhs_bdata);
743 devkit8000_flash_init(); 703 omap_nand_flash_init(NAND_BUSWIDTH_16, devkit8000_nand_partitions,
704 ARRAY_SIZE(devkit8000_nand_partitions));
744 705
745 /* Ensure SDRC pins are mux'd for self-refresh */ 706 /* Ensure SDRC pins are mux'd for self-refresh */
746 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT); 707 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 13a16649d42c..ce3bc2d1164c 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -174,15 +174,6 @@ static struct mtd_partition omap3beagle_nand_partitions[] = {
174 }, 174 },
175}; 175};
176 176
177static struct omap_nand_platform_data omap3beagle_nand_data = {
178 .options = NAND_BUSWIDTH_16,
179 .parts = omap3beagle_nand_partitions,
180 .nr_parts = ARRAY_SIZE(omap3beagle_nand_partitions),
181 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
182 .nand_setup = NULL,
183 .dev_ready = NULL,
184};
185
186/* DSS */ 177/* DSS */
187 178
188static int beagle_enable_dvi(struct omap_dss_device *dssdev) 179static int beagle_enable_dvi(struct omap_dss_device *dssdev)
@@ -542,39 +533,6 @@ static struct platform_device *omap3_beagle_devices[] __initdata = {
542 &keys_gpio, 533 &keys_gpio,
543}; 534};
544 535
545static void __init omap3beagle_flash_init(void)
546{
547 u8 cs = 0;
548 u8 nandcs = GPMC_CS_NUM + 1;
549
550 /* find out the chip-select on which NAND exists */
551 while (cs < GPMC_CS_NUM) {
552 u32 ret = 0;
553 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
554
555 if ((ret & 0xC00) == 0x800) {
556 printk(KERN_INFO "Found NAND on CS%d\n", cs);
557 if (nandcs > GPMC_CS_NUM)
558 nandcs = cs;
559 }
560 cs++;
561 }
562
563 if (nandcs > GPMC_CS_NUM) {
564 printk(KERN_INFO "NAND: Unable to find configuration "
565 "in GPMC\n ");
566 return;
567 }
568
569 if (nandcs < GPMC_CS_NUM) {
570 omap3beagle_nand_data.cs = nandcs;
571
572 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
573 if (gpmc_nand_init(&omap3beagle_nand_data) < 0)
574 printk(KERN_ERR "Unable to register NAND device\n");
575 }
576}
577
578static const struct usbhs_omap_board_data usbhs_bdata __initconst = { 536static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
579 537
580 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, 538 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
@@ -662,7 +620,8 @@ static void __init omap3_beagle_init(void)
662 620
663 usb_musb_init(&musb_board_data); 621 usb_musb_init(&musb_board_data);
664 usbhs_init(&usbhs_bdata); 622 usbhs_init(&usbhs_bdata);
665 omap3beagle_flash_init(); 623 omap_nand_flash_init(NAND_BUSWIDTH_16, omap3beagle_nand_partitions,
624 ARRAY_SIZE(omap3beagle_nand_partitions));
666 625
667 /* Ensure SDRC pins are mux'd for self-refresh */ 626 /* Ensure SDRC pins are mux'd for self-refresh */
668 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT); 627 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index 0a9b3299427a..d770802900b2 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -96,15 +96,6 @@ static struct mtd_partition omap3touchbook_nand_partitions[] = {
96 }, 96 },
97}; 97};
98 98
99static struct omap_nand_platform_data omap3touchbook_nand_data = {
100 .options = NAND_BUSWIDTH_16,
101 .parts = omap3touchbook_nand_partitions,
102 .nr_parts = ARRAY_SIZE(omap3touchbook_nand_partitions),
103 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
104 .nand_setup = NULL,
105 .dev_ready = NULL,
106};
107
108#include "sdram-micron-mt46h32m32lf-6.h" 99#include "sdram-micron-mt46h32m32lf-6.h"
109 100
110static struct omap2_hsmmc_info mmc[] = { 101static struct omap2_hsmmc_info mmc[] = {
@@ -396,39 +387,6 @@ static struct platform_device *omap3_touchbook_devices[] __initdata = {
396 &keys_gpio, 387 &keys_gpio,
397}; 388};
398 389
399static void __init omap3touchbook_flash_init(void)
400{
401 u8 cs = 0;
402 u8 nandcs = GPMC_CS_NUM + 1;
403
404 /* find out the chip-select on which NAND exists */
405 while (cs < GPMC_CS_NUM) {
406 u32 ret = 0;
407 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
408
409 if ((ret & 0xC00) == 0x800) {
410 printk(KERN_INFO "Found NAND on CS%d\n", cs);
411 if (nandcs > GPMC_CS_NUM)
412 nandcs = cs;
413 }
414 cs++;
415 }
416
417 if (nandcs > GPMC_CS_NUM) {
418 printk(KERN_INFO "NAND: Unable to find configuration "
419 "in GPMC\n ");
420 return;
421 }
422
423 if (nandcs < GPMC_CS_NUM) {
424 omap3touchbook_nand_data.cs = nandcs;
425
426 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
427 if (gpmc_nand_init(&omap3touchbook_nand_data) < 0)
428 printk(KERN_ERR "Unable to register NAND device\n");
429 }
430}
431
432static const struct usbhs_omap_board_data usbhs_bdata __initconst = { 390static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
433 391
434 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, 392 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
@@ -491,7 +449,8 @@ static void __init omap3_touchbook_init(void)
491 omap_ads7846_init(4, OMAP3_TS_GPIO, 310, &ads7846_pdata); 449 omap_ads7846_init(4, OMAP3_TS_GPIO, 310, &ads7846_pdata);
492 usb_musb_init(&musb_board_data); 450 usb_musb_init(&musb_board_data);
493 usbhs_init(&usbhs_bdata); 451 usbhs_init(&usbhs_bdata);
494 omap3touchbook_flash_init(); 452 omap_nand_flash_init(NAND_BUSWIDTH_16, omap3touchbook_nand_partitions,
453 ARRAY_SIZE(omap3touchbook_nand_partitions));
495 454
496 /* Ensure SDRC pins are mux'd for self-refresh */ 455 /* Ensure SDRC pins are mux'd for self-refresh */
497 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT); 456 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 809d3944f549..7ad2d7fea8d8 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -304,45 +304,6 @@ static struct mtd_partition overo_nand_partitions[] = {
304 }, 304 },
305}; 305};
306 306
307static struct omap_nand_platform_data overo_nand_data = {
308 .parts = overo_nand_partitions,
309 .nr_parts = ARRAY_SIZE(overo_nand_partitions),
310 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
311};
312
313static void __init overo_flash_init(void)
314{
315 u8 cs = 0;
316 u8 nandcs = GPMC_CS_NUM + 1;
317
318 /* find out the chip-select on which NAND exists */
319 while (cs < GPMC_CS_NUM) {
320 u32 ret = 0;
321 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
322
323 if ((ret & 0xC00) == 0x800) {
324 printk(KERN_INFO "Found NAND on CS%d\n", cs);
325 if (nandcs > GPMC_CS_NUM)
326 nandcs = cs;
327 }
328 cs++;
329 }
330
331 if (nandcs > GPMC_CS_NUM) {
332 printk(KERN_INFO "NAND: Unable to find configuration "
333 "in GPMC\n ");
334 return;
335 }
336
337 if (nandcs < GPMC_CS_NUM) {
338 overo_nand_data.cs = nandcs;
339
340 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
341 if (gpmc_nand_init(&overo_nand_data) < 0)
342 printk(KERN_ERR "Unable to register NAND device\n");
343 }
344}
345
346static struct omap2_hsmmc_info mmc[] = { 307static struct omap2_hsmmc_info mmc[] = {
347 { 308 {
348 .mmc = 1, 309 .mmc = 1,
@@ -604,7 +565,8 @@ static void __init overo_init(void)
604 overo_i2c_init(); 565 overo_i2c_init();
605 omap_display_init(&overo_dss_data); 566 omap_display_init(&overo_dss_data);
606 omap_serial_init(); 567 omap_serial_init();
607 overo_flash_init(); 568 omap_nand_flash_init(0, overo_nand_partitions,
569 ARRAY_SIZE(overo_nand_partitions));
608 usb_musb_init(&musb_board_data); 570 usb_musb_init(&musb_board_data);
609 usbhs_init(&usbhs_bdata); 571 usbhs_init(&usbhs_bdata);
610 overo_spi_init(); 572 overo_spi_init();
diff --git a/arch/arm/mach-omap2/common-board-devices.c b/arch/arm/mach-omap2/common-board-devices.c
index cea31dda3a73..e94903b2c65b 100644
--- a/arch/arm/mach-omap2/common-board-devices.c
+++ b/arch/arm/mach-omap2/common-board-devices.c
@@ -29,6 +29,7 @@
29 29
30#include <plat/i2c.h> 30#include <plat/i2c.h>
31#include <plat/mcspi.h> 31#include <plat/mcspi.h>
32#include <plat/nand.h>
32 33
33#include "common-board-devices.h" 34#include "common-board-devices.h"
34 35
@@ -49,6 +50,8 @@ void __init omap_pmic_init(int bus, u32 clkrate,
49 omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1); 50 omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1);
50} 51}
51 52
53#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
54 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
52static struct omap2_mcspi_device_config ads7846_mcspi_config = { 55static struct omap2_mcspi_device_config ads7846_mcspi_config = {
53 .turbo_mode = 0, 56 .turbo_mode = 0,
54 .single_channel = 1, /* 0: slave, 1: master */ 57 .single_channel = 1, /* 0: slave, 1: master */
@@ -104,3 +107,57 @@ void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
104 107
105 spi_register_board_info(&ads7846_spi_board_info, 1); 108 spi_register_board_info(&ads7846_spi_board_info, 1);
106} 109}
110#else
111void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
112 struct ads7846_platform_data *board_pdata)
113{
114}
115#endif
116
117#if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
118static struct omap_nand_platform_data nand_data = {
119 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
120};
121
122void __init omap_nand_flash_init(int options, struct mtd_partition *parts,
123 int nr_parts)
124{
125 u8 cs = 0;
126 u8 nandcs = GPMC_CS_NUM + 1;
127
128 /* find out the chip-select on which NAND exists */
129 while (cs < GPMC_CS_NUM) {
130 u32 ret = 0;
131 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
132
133 if ((ret & 0xC00) == 0x800) {
134 printk(KERN_INFO "Found NAND on CS%d\n", cs);
135 if (nandcs > GPMC_CS_NUM)
136 nandcs = cs;
137 }
138 cs++;
139 }
140
141 if (nandcs > GPMC_CS_NUM) {
142 printk(KERN_INFO "NAND: Unable to find configuration "
143 "in GPMC\n ");
144 return;
145 }
146
147 if (nandcs < GPMC_CS_NUM) {
148 nand_data.cs = nandcs;
149 nand_data.parts = parts;
150 nand_data.nr_parts = nr_parts;
151 nand_data.options = options;
152
153 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
154 if (gpmc_nand_init(&nand_data) < 0)
155 printk(KERN_ERR "Unable to register NAND device\n");
156 }
157}
158#else
159void __init omap_nand_flash_init(int options, struct mtd_partition *parts,
160 int nr_parts)
161{
162}
163#endif
diff --git a/arch/arm/mach-omap2/common-board-devices.h b/arch/arm/mach-omap2/common-board-devices.h
index 0ec3e07239fc..eb80b3b0ef47 100644
--- a/arch/arm/mach-omap2/common-board-devices.h
+++ b/arch/arm/mach-omap2/common-board-devices.h
@@ -2,6 +2,7 @@
2#define __OMAP_COMMON_BOARD_DEVICES__ 2#define __OMAP_COMMON_BOARD_DEVICES__
3 3
4struct twl4030_platform_data; 4struct twl4030_platform_data;
5struct mtd_partition;
5 6
6void omap_pmic_init(int bus, u32 clkrate, const char *pmic_type, int pmic_irq, 7void omap_pmic_init(int bus, u32 clkrate, const char *pmic_type, int pmic_irq,
7 struct twl4030_platform_data *pmic_data); 8 struct twl4030_platform_data *pmic_data);
@@ -25,18 +26,10 @@ static inline void omap4_pmic_init(const char *pmic_type,
25 omap_pmic_init(1, 400, pmic_type, OMAP44XX_IRQ_SYS_1N, pmic_data); 26 omap_pmic_init(1, 400, pmic_type, OMAP44XX_IRQ_SYS_1N, pmic_data);
26} 27}
27 28
28#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
29 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
30struct ads7846_platform_data; 29struct ads7846_platform_data;
31 30
32void omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce, 31void omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
33 struct ads7846_platform_data *board_pdata); 32 struct ads7846_platform_data *board_pdata);
34#else 33void omap_nand_flash_init(int opts, struct mtd_partition *parts, int n_parts);
35static inline void omap_ads7846_init(int bus_num,
36 int gpio_pendown, int gpio_debounce,
37 struct ads7846_platform_data *board_data)
38{
39}
40#endif
41 34
42#endif /* __OMAP_COMMON_BOARD_DEVICES__ */ 35#endif /* __OMAP_COMMON_BOARD_DEVICES__ */