aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2012-02-20 12:43:29 -0500
committerTony Lindgren <tony@atomide.com>2012-02-20 13:00:39 -0500
commit3b972bf06c22f5abfa6586a8baf50321cd825965 (patch)
tree666fd47675069dae78337f648670a550c4f9f85b /arch
parent993e4fbd7822cdf874fcf9f1b054a323d67ccf97 (diff)
ARM: OMAP2+: Split omap2_hsmmc_init() to properly support I2C GPIO pins
Otherwise omap_device_build() and omap_mux related functions can't be marked as __init when twl is build as a module. If a board is using GPIO pins or regulators configured by an external chip, such as TWL PMIC on I2C bus, the board must mark those MMC controllers as deferred. Additionally both omap_hsmmc_init() and omap_hsmmc_late_init() must be called by the board. For MMC controllers using internal GPIO pins for card detect and regulators the slots don't need to be marked deferred. In this case calling omap_hsmmc_init() is sufficient. Only mark the MMC slots using gpio_cd or gpio_wd as deferred as noted by Igor Grinberg <grinberg@compulab.co.il>. Note that this patch does not change the behaviour for board-4430sdp.c board-omap4panda.c. These boards wrongly rely on the omap_hsmmc.c init function callback to configure the PMIC GPIO interrupt lines on external chip. If the PMIC interrupt lines are not configured during init, they will fail. Reported-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Rajendra Nayak <rnayak@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-omap2/board-2430sdp.c2
-rw-r--r--arch/arm/mach-omap2/board-3430sdp.c5
-rw-r--r--arch/arm/mach-omap2/board-4430sdp.c4
-rw-r--r--arch/arm/mach-omap2/board-am3517evm.c2
-rw-r--r--arch/arm/mach-omap2/board-cm-t35.c5
-rw-r--r--arch/arm/mach-omap2/board-devkit8000.c4
-rw-r--r--arch/arm/mach-omap2/board-igep0020.c6
-rw-r--r--arch/arm/mach-omap2/board-ldp.c2
-rw-r--r--arch/arm/mach-omap2/board-omap3beagle.c4
-rw-r--r--arch/arm/mach-omap2/board-omap3evm.c4
-rw-r--r--arch/arm/mach-omap2/board-omap3logic.c2
-rw-r--r--arch/arm/mach-omap2/board-omap3pandora.c5
-rw-r--r--arch/arm/mach-omap2/board-omap3stalker.c12
-rw-r--r--arch/arm/mach-omap2/board-omap3touchbook.c4
-rw-r--r--arch/arm/mach-omap2/board-omap4panda.c4
-rw-r--r--arch/arm/mach-omap2/board-overo.c3
-rw-r--r--arch/arm/mach-omap2/board-rm680.c2
-rw-r--r--arch/arm/mach-omap2/board-rx51-peripherals.c2
-rw-r--r--arch/arm/mach-omap2/board-zoom-peripherals.c4
-rw-r--r--arch/arm/mach-omap2/hsmmc.c119
-rw-r--r--arch/arm/mach-omap2/hsmmc.h12
21 files changed, 150 insertions, 57 deletions
diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index 7370983f809f..c8bda62900d8 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -279,7 +279,7 @@ static void __init omap_2430sdp_init(void)
279 platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices)); 279 platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
280 omap_serial_init(); 280 omap_serial_init();
281 omap_sdrc_init(NULL, NULL); 281 omap_sdrc_init(NULL, NULL);
282 omap2_hsmmc_init(mmc); 282 omap_hsmmc_init(mmc);
283 omap2_usbfs_init(&sdp2430_usb_config); 283 omap2_usbfs_init(&sdp2430_usb_config);
284 284
285 omap_mux_init_signal("usb0hs_stp", OMAP_PULL_ENA | OMAP_PULL_UP); 285 omap_mux_init_signal("usb0hs_stp", OMAP_PULL_ENA | OMAP_PULL_UP);
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 383717ba63b9..da75f239873e 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -232,11 +232,13 @@ static struct omap2_hsmmc_info mmc[] = {
232 */ 232 */
233 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, 233 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
234 .gpio_wp = 4, 234 .gpio_wp = 4,
235 .deferred = true,
235 }, 236 },
236 { 237 {
237 .mmc = 2, 238 .mmc = 2,
238 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, 239 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
239 .gpio_wp = 7, 240 .gpio_wp = 7,
241 .deferred = true,
240 }, 242 },
241 {} /* Terminator */ 243 {} /* Terminator */
242}; 244};
@@ -249,7 +251,7 @@ static int sdp3430_twl_gpio_setup(struct device *dev,
249 */ 251 */
250 mmc[0].gpio_cd = gpio + 0; 252 mmc[0].gpio_cd = gpio + 0;
251 mmc[1].gpio_cd = gpio + 1; 253 mmc[1].gpio_cd = gpio + 1;
252 omap2_hsmmc_init(mmc); 254 omap_hsmmc_late_init(mmc);
253 255
254 /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */ 256 /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */
255 gpio_request_one(gpio + 7, GPIOF_OUT_INIT_LOW, "sub_lcd_en_bkl"); 257 gpio_request_one(gpio + 7, GPIOF_OUT_INIT_LOW, "sub_lcd_en_bkl");
@@ -606,6 +608,7 @@ static void __init omap_3430sdp_init(void)
606 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); 608 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
607 omap_board_config = sdp3430_config; 609 omap_board_config = sdp3430_config;
608 omap_board_config_size = ARRAY_SIZE(sdp3430_config); 610 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
611 omap_hsmmc_init(mmc);
609 omap3430_i2c_init(); 612 omap3430_i2c_init();
610 omap_display_init(&sdp3430_dss_data); 613 omap_display_init(&sdp3430_dss_data);
611 if (omap_rev() > OMAP3430_REV_ES1_0) 614 if (omap_rev() > OMAP3430_REV_ES1_0)
diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c
index 4e9071589bfb..09ae257e86fd 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -491,9 +491,9 @@ static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
491{ 491{
492 struct omap2_hsmmc_info *c; 492 struct omap2_hsmmc_info *c;
493 493
494 omap2_hsmmc_init(controllers); 494 omap_hsmmc_init(controllers);
495 for (c = controllers; c->mmc; c++) 495 for (c = controllers; c->mmc; c++)
496 omap4_twl6030_hsmmc_set_late_init(c->dev); 496 omap4_twl6030_hsmmc_set_late_init(&c->pdev->dev);
497 497
498 return 0; 498 return 0;
499} 499}
diff --git a/arch/arm/mach-omap2/board-am3517evm.c b/arch/arm/mach-omap2/board-am3517evm.c
index 4b1cfe32e6ba..71138a1271d8 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -504,7 +504,7 @@ static void __init am3517_evm_init(void)
504 am3517_evm_musb_init(); 504 am3517_evm_musb_init();
505 505
506 /* MMC init function */ 506 /* MMC init function */
507 omap2_hsmmc_init(mmc); 507 omap_hsmmc_init(mmc);
508} 508}
509 509
510MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM") 510MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
index d73316ed4207..49e64057cb67 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -413,7 +413,7 @@ static struct omap2_hsmmc_info mmc[] = {
413 .caps = MMC_CAP_4_BIT_DATA, 413 .caps = MMC_CAP_4_BIT_DATA,
414 .gpio_cd = -EINVAL, 414 .gpio_cd = -EINVAL,
415 .gpio_wp = -EINVAL, 415 .gpio_wp = -EINVAL,
416 416 .deferred = true,
417 }, 417 },
418 { 418 {
419 .mmc = 2, 419 .mmc = 2,
@@ -471,7 +471,7 @@ static int cm_t35_twl_gpio_setup(struct device *dev, unsigned gpio,
471 471
472 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 472 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
473 mmc[0].gpio_cd = gpio + 0; 473 mmc[0].gpio_cd = gpio + 0;
474 omap2_hsmmc_init(mmc); 474 omap_hsmmc_late_init(mmc);
475 475
476 return 0; 476 return 0;
477} 477}
@@ -639,6 +639,7 @@ static void __init cm_t3x_common_init(void)
639 omap_serial_init(); 639 omap_serial_init();
640 omap_sdrc_init(mt46h32m32lf6_sdrc_params, 640 omap_sdrc_init(mt46h32m32lf6_sdrc_params,
641 mt46h32m32lf6_sdrc_params); 641 mt46h32m32lf6_sdrc_params);
642 omap_hsmmc_init(mmc);
642 cm_t35_init_i2c(); 643 cm_t35_init_i2c();
643 omap_ads7846_init(1, CM_T35_GPIO_PENDOWN, 0, NULL); 644 omap_ads7846_init(1, CM_T35_GPIO_PENDOWN, 0, NULL);
644 cm_t35_init_ethernet(); 645 cm_t35_init_ethernet();
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index e873063f4fda..11cd2a806093 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -100,6 +100,7 @@ static struct omap2_hsmmc_info mmc[] = {
100 .mmc = 1, 100 .mmc = 1,
101 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, 101 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
102 .gpio_wp = 29, 102 .gpio_wp = 29,
103 .deferred = true,
103 }, 104 },
104 {} /* Terminator */ 105 {} /* Terminator */
105}; 106};
@@ -228,7 +229,7 @@ static int devkit8000_twl_gpio_setup(struct device *dev,
228 229
229 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 230 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
230 mmc[0].gpio_cd = gpio + 0; 231 mmc[0].gpio_cd = gpio + 0;
231 omap2_hsmmc_init(mmc); 232 omap_hsmmc_late_init(mmc);
232 233
233 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */ 234 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
234 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1; 235 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
@@ -636,6 +637,7 @@ static void __init devkit8000_init(void)
636 637
637 omap_dm9000_init(); 638 omap_dm9000_init();
638 639
640 omap_hsmmc_init(mmc);
639 devkit8000_i2c_init(); 641 devkit8000_i2c_init();
640 platform_add_devices(devkit8000_devices, 642 platform_add_devices(devkit8000_devices,
641 ARRAY_SIZE(devkit8000_devices)); 643 ARRAY_SIZE(devkit8000_devices));
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index a59ace0ed560..e558800adfdf 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -295,6 +295,7 @@ static struct omap2_hsmmc_info mmc[] = {
295 .caps = MMC_CAP_4_BIT_DATA, 295 .caps = MMC_CAP_4_BIT_DATA,
296 .gpio_cd = -EINVAL, 296 .gpio_cd = -EINVAL,
297 .gpio_wp = -EINVAL, 297 .gpio_wp = -EINVAL,
298 .deferred = true,
298 }, 299 },
299#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE) 300#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
300 { 301 {
@@ -402,7 +403,7 @@ static int igep_twl_gpio_setup(struct device *dev,
402 403
403 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 404 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
404 mmc[0].gpio_cd = gpio + 0; 405 mmc[0].gpio_cd = gpio + 0;
405 omap2_hsmmc_init(mmc); 406 omap_hsmmc_late_init(mmc);
406 407
407 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */ 408 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
408#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE) 409#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
@@ -639,6 +640,9 @@ static void __init igep_init(void)
639 640
640 /* Get IGEP2 hardware revision */ 641 /* Get IGEP2 hardware revision */
641 igep2_get_revision(); 642 igep2_get_revision();
643
644 omap_hsmmc_init(mmc);
645
642 /* Register I2C busses and drivers */ 646 /* Register I2C busses and drivers */
643 igep_i2c_init(); 647 igep_i2c_init();
644 platform_add_devices(igep_devices, ARRAY_SIZE(igep_devices)); 648 platform_add_devices(igep_devices, ARRAY_SIZE(igep_devices));
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 2d2a61f7dcbf..b5bc9b2e2862 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -424,7 +424,7 @@ static void __init omap_ldp_init(void)
424 board_nand_init(ldp_nand_partitions, 424 board_nand_init(ldp_nand_partitions,
425 ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0); 425 ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0);
426 426
427 omap2_hsmmc_init(mmc); 427 omap_hsmmc_init(mmc);
428 ldp_display_init(); 428 ldp_display_init();
429} 429}
430 430
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 7ffcd2839e7b..78bfcd5d5a78 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -253,6 +253,7 @@ static struct omap2_hsmmc_info mmc[] = {
253 .mmc = 1, 253 .mmc = 1,
254 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, 254 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
255 .gpio_wp = -EINVAL, 255 .gpio_wp = -EINVAL,
256 .deferred = true,
256 }, 257 },
257 {} /* Terminator */ 258 {} /* Terminator */
258}; 259};
@@ -277,7 +278,7 @@ static int beagle_twl_gpio_setup(struct device *dev,
277 mmc[0].gpio_wp = beagle_config.mmc1_gpio_wp; 278 mmc[0].gpio_wp = beagle_config.mmc1_gpio_wp;
278 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 279 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
279 mmc[0].gpio_cd = gpio + 0; 280 mmc[0].gpio_cd = gpio + 0;
280 omap2_hsmmc_init(mmc); 281 omap_hsmmc_late_init(mmc);
281 282
282 /* 283 /*
283 * TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, XM active 284 * TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, XM active
@@ -521,6 +522,7 @@ static void __init omap3_beagle_init(void)
521{ 522{
522 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); 523 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
523 omap3_beagle_init_rev(); 524 omap3_beagle_init_rev();
525 omap_hsmmc_init(mmc);
524 omap3_beagle_i2c_init(); 526 omap3_beagle_i2c_init();
525 527
526 gpio_buttons[0].gpio = beagle_config.usr_button_gpio; 528 gpio_buttons[0].gpio = beagle_config.usr_button_gpio;
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index c775bead1497..3d585b81669a 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -317,6 +317,7 @@ static struct omap2_hsmmc_info mmc[] = {
317 .caps = MMC_CAP_4_BIT_DATA, 317 .caps = MMC_CAP_4_BIT_DATA,
318 .gpio_cd = -EINVAL, 318 .gpio_cd = -EINVAL,
319 .gpio_wp = 63, 319 .gpio_wp = 63,
320 .deferred = true,
320 }, 321 },
321#ifdef CONFIG_WL12XX_PLATFORM_DATA 322#ifdef CONFIG_WL12XX_PLATFORM_DATA
322 { 323 {
@@ -363,7 +364,7 @@ static int omap3evm_twl_gpio_setup(struct device *dev,
363 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 364 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
364 omap_mux_init_gpio(63, OMAP_PIN_INPUT); 365 omap_mux_init_gpio(63, OMAP_PIN_INPUT);
365 mmc[0].gpio_cd = gpio + 0; 366 mmc[0].gpio_cd = gpio + 0;
366 omap2_hsmmc_init(mmc); 367 omap_hsmmc_late_init(mmc);
367 368
368 /* 369 /*
369 * Most GPIOs are for USB OTG. Some are mostly sent to 370 * Most GPIOs are for USB OTG. Some are mostly sent to
@@ -644,6 +645,7 @@ static void __init omap3_evm_init(void)
644 omap_board_config = omap3_evm_config; 645 omap_board_config = omap3_evm_config;
645 omap_board_config_size = ARRAY_SIZE(omap3_evm_config); 646 omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
646 647
648 omap_hsmmc_init(mmc);
647 omap3_evm_i2c_init(); 649 omap3_evm_i2c_init();
648 650
649 omap_display_init(&omap3_evm_dss_data); 651 omap_display_init(&omap3_evm_dss_data);
diff --git a/arch/arm/mach-omap2/board-omap3logic.c b/arch/arm/mach-omap2/board-omap3logic.c
index 4198dd017d8f..2304ba340e99 100644
--- a/arch/arm/mach-omap2/board-omap3logic.c
+++ b/arch/arm/mach-omap2/board-omap3logic.c
@@ -128,7 +128,7 @@ static void __init board_mmc_init(void)
128 return; 128 return;
129 } 129 }
130 130
131 omap2_hsmmc_init(board_mmc_info); 131 omap_hsmmc_init(board_mmc_info);
132} 132}
133 133
134static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = { 134static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = {
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index 1644b73017fc..ace466bcd76d 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -273,6 +273,7 @@ static struct omap2_hsmmc_info omap3pandora_mmc[] = {
273 .gpio_cd = -EINVAL, 273 .gpio_cd = -EINVAL,
274 .gpio_wp = 126, 274 .gpio_wp = 126,
275 .ext_clock = 0, 275 .ext_clock = 0,
276 .deferred = true,
276 }, 277 },
277 { 278 {
278 .mmc = 2, 279 .mmc = 2,
@@ -281,6 +282,7 @@ static struct omap2_hsmmc_info omap3pandora_mmc[] = {
281 .gpio_wp = 127, 282 .gpio_wp = 127,
282 .ext_clock = 1, 283 .ext_clock = 1,
283 .transceiver = true, 284 .transceiver = true,
285 .deferred = true,
284 }, 286 },
285 { 287 {
286 .mmc = 3, 288 .mmc = 3,
@@ -300,7 +302,7 @@ static int omap3pandora_twl_gpio_setup(struct device *dev,
300 /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */ 302 /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
301 omap3pandora_mmc[0].gpio_cd = gpio + 0; 303 omap3pandora_mmc[0].gpio_cd = gpio + 0;
302 omap3pandora_mmc[1].gpio_cd = gpio + 1; 304 omap3pandora_mmc[1].gpio_cd = gpio + 1;
303 omap2_hsmmc_init(omap3pandora_mmc); 305 omap_hsmmc_late_init(omap3pandora_mmc);
304 306
305 /* gpio + 13 drives 32kHz buffer for wifi module */ 307 /* gpio + 13 drives 32kHz buffer for wifi module */
306 gpio_32khz = gpio + 13; 308 gpio_32khz = gpio + 13;
@@ -580,6 +582,7 @@ static struct omap_board_mux board_mux[] __initdata = {
580static void __init omap3pandora_init(void) 582static void __init omap3pandora_init(void)
581{ 583{
582 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); 584 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
585 omap_hsmmc_init(omap3pandora_mmc);
583 omap3pandora_i2c_init(); 586 omap3pandora_i2c_init();
584 pandora_wl1251_init(); 587 pandora_wl1251_init();
585 platform_add_devices(omap3pandora_devices, 588 platform_add_devices(omap3pandora_devices,
diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c
index cb089a46f62f..8eee9930ee5f 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -209,10 +209,11 @@ static struct regulator_init_data omap3stalker_vsim = {
209 209
210static struct omap2_hsmmc_info mmc[] = { 210static struct omap2_hsmmc_info mmc[] = {
211 { 211 {
212 .mmc = 1, 212 .mmc = 1,
213 .caps = MMC_CAP_4_BIT_DATA, 213 .caps = MMC_CAP_4_BIT_DATA,
214 .gpio_cd = -EINVAL, 214 .gpio_cd = -EINVAL,
215 .gpio_wp = 23, 215 .gpio_wp = 23,
216 .deferred = true,
216 }, 217 },
217 {} /* Terminator */ 218 {} /* Terminator */
218}; 219};
@@ -284,7 +285,7 @@ omap3stalker_twl_gpio_setup(struct device *dev,
284 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 285 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
285 omap_mux_init_gpio(23, OMAP_PIN_INPUT); 286 omap_mux_init_gpio(23, OMAP_PIN_INPUT);
286 mmc[0].gpio_cd = gpio + 0; 287 mmc[0].gpio_cd = gpio + 0;
287 omap2_hsmmc_init(mmc); 288 omap_hsmmc_late_init(mmc);
288 289
289 /* 290 /*
290 * Most GPIOs are for USB OTG. Some are mostly sent to 291 * Most GPIOs are for USB OTG. Some are mostly sent to
@@ -425,6 +426,7 @@ static void __init omap3_stalker_init(void)
425 omap_board_config = omap3_stalker_config; 426 omap_board_config = omap3_stalker_config;
426 omap_board_config_size = ARRAY_SIZE(omap3_stalker_config); 427 omap_board_config_size = ARRAY_SIZE(omap3_stalker_config);
427 428
429 omap_hsmmc_init(mmc);
428 omap3_stalker_i2c_init(); 430 omap3_stalker_i2c_init();
429 431
430 platform_add_devices(omap3_stalker_devices, 432 platform_add_devices(omap3_stalker_devices,
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index a0b851aafcca..ba9c118862e6 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -100,6 +100,7 @@ static struct omap2_hsmmc_info mmc[] = {
100 .mmc = 1, 100 .mmc = 1,
101 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, 101 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
102 .gpio_wp = 29, 102 .gpio_wp = 29,
103 .deferred = true,
103 }, 104 },
104 {} /* Terminator */ 105 {} /* Terminator */
105}; 106};
@@ -125,7 +126,7 @@ static int touchbook_twl_gpio_setup(struct device *dev,
125 } 126 }
126 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 127 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
127 mmc[0].gpio_cd = gpio + 0; 128 mmc[0].gpio_cd = gpio + 0;
128 omap2_hsmmc_init(mmc); 129 omap_hsmmc_late_init(mmc);
129 130
130 /* REVISIT: need ehci-omap hooks for external VBUS 131 /* REVISIT: need ehci-omap hooks for external VBUS
131 * power switch and overcurrent detect 132 * power switch and overcurrent detect
@@ -351,6 +352,7 @@ static void __init omap3_touchbook_init(void)
351 352
352 pm_power_off = omap3_touchbook_poweroff; 353 pm_power_off = omap3_touchbook_poweroff;
353 354
355 omap_hsmmc_init(mmc);
354 omap3_touchbook_i2c_init(); 356 omap3_touchbook_i2c_init();
355 platform_add_devices(omap3_touchbook_devices, 357 platform_add_devices(omap3_touchbook_devices,
356 ARRAY_SIZE(omap3_touchbook_devices)); 358 ARRAY_SIZE(omap3_touchbook_devices));
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index 28fc271f7031..bcc563c37b64 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -245,9 +245,9 @@ static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
245{ 245{
246 struct omap2_hsmmc_info *c; 246 struct omap2_hsmmc_info *c;
247 247
248 omap2_hsmmc_init(controllers); 248 omap_hsmmc_init(controllers);
249 for (c = controllers; c->mmc; c++) 249 for (c = controllers; c->mmc; c++)
250 omap4_twl6030_hsmmc_set_late_init(c->dev); 250 omap4_twl6030_hsmmc_set_late_init(&c->pdev->dev);
251 251
252 return 0; 252 return 0;
253} 253}
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 52c0cef77165..668533e2a379 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -407,8 +407,6 @@ static inline void __init overo_init_keys(void) { return; }
407static int overo_twl_gpio_setup(struct device *dev, 407static int overo_twl_gpio_setup(struct device *dev,
408 unsigned gpio, unsigned ngpio) 408 unsigned gpio, unsigned ngpio)
409{ 409{
410 omap2_hsmmc_init(mmc);
411
412#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) 410#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
413 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */ 411 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
414 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1; 412 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
@@ -505,6 +503,7 @@ static void __init overo_init(void)
505 int ret; 503 int ret;
506 504
507 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); 505 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
506 omap_hsmmc_init(mmc);
508 overo_i2c_init(); 507 overo_i2c_init();
509 omap_display_init(&overo_dss_data); 508 omap_display_init(&overo_dss_data);
510 omap_serial_init(); 509 omap_serial_init();
diff --git a/arch/arm/mach-omap2/board-rm680.c b/arch/arm/mach-omap2/board-rm680.c
index 8678b386c6a2..2d24c98f3d45 100644
--- a/arch/arm/mach-omap2/board-rm680.c
+++ b/arch/arm/mach-omap2/board-rm680.c
@@ -120,7 +120,7 @@ static void __init rm680_peripherals_init(void)
120 ARRAY_SIZE(rm680_peripherals_devices)); 120 ARRAY_SIZE(rm680_peripherals_devices));
121 rm680_i2c_init(); 121 rm680_i2c_init();
122 gpmc_onenand_init(board_onenand_data); 122 gpmc_onenand_init(board_onenand_data);
123 omap2_hsmmc_init(mmc); 123 omap_hsmmc_init(mmc);
124} 124}
125 125
126#ifdef CONFIG_OMAP_MUX 126#ifdef CONFIG_OMAP_MUX
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index acb4e77b39ef..0e9d89a2048f 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -1145,7 +1145,7 @@ void __init rx51_peripherals_init(void)
1145 1145
1146 partition = omap_mux_get("core"); 1146 partition = omap_mux_get("core");
1147 if (partition) 1147 if (partition)
1148 omap2_hsmmc_init(mmc); 1148 omap_hsmmc_init(mmc);
1149 1149
1150 rx51_charger_init(); 1150 rx51_charger_init();
1151} 1151}
diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c
index c126461836ac..3d39cdb2e250 100644
--- a/arch/arm/mach-omap2/board-zoom-peripherals.c
+++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
@@ -205,6 +205,7 @@ static struct omap2_hsmmc_info mmc[] = {
205 .caps = MMC_CAP_4_BIT_DATA, 205 .caps = MMC_CAP_4_BIT_DATA,
206 .gpio_wp = -EINVAL, 206 .gpio_wp = -EINVAL,
207 .power_saving = true, 207 .power_saving = true,
208 .deferred = true,
208 }, 209 },
209 { 210 {
210 .name = "internal", 211 .name = "internal",
@@ -233,7 +234,7 @@ static int zoom_twl_gpio_setup(struct device *dev,
233 234
234 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 235 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
235 mmc[0].gpio_cd = gpio + 0; 236 mmc[0].gpio_cd = gpio + 0;
236 omap2_hsmmc_init(mmc); 237 omap_hsmmc_late_init(mmc);
237 238
238 ret = gpio_request_one(LCD_PANEL_ENABLE_GPIO, GPIOF_OUT_INIT_LOW, 239 ret = gpio_request_one(LCD_PANEL_ENABLE_GPIO, GPIOF_OUT_INIT_LOW,
239 "lcd enable"); 240 "lcd enable");
@@ -301,6 +302,7 @@ void __init zoom_peripherals_init(void)
301 if (ret) 302 if (ret)
302 pr_err("error setting wl12xx data: %d\n", ret); 303 pr_err("error setting wl12xx data: %d\n", ret);
303 304
305 omap_hsmmc_init(mmc);
304 omap_i2c_init(); 306 omap_i2c_init();
305 platform_device_register(&omap_vwlan_device); 307 platform_device_register(&omap_vwlan_device);
306 usb_musb_init(NULL); 308 usb_musb_init(NULL);
diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
index 19dd1657245c..efb2fcbf9b3f 100644
--- a/arch/arm/mach-omap2/hsmmc.c
+++ b/arch/arm/mach-omap2/hsmmc.c
@@ -429,66 +429,131 @@ static int omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c,
429} 429}
430 430
431static int omap_hsmmc_done; 431static int omap_hsmmc_done;
432
433void omap_hsmmc_late_init(struct omap2_hsmmc_info *c)
434{
435 struct platform_device *pdev;
436 struct omap_mmc_platform_data *mmc_pdata;
437 int res;
438
439 if (omap_hsmmc_done != 1)
440 return;
441
442 omap_hsmmc_done++;
443
444 for (; c->mmc; c++) {
445 if (!c->deferred)
446 continue;
447
448 pdev = c->pdev;
449 if (!pdev)
450 continue;
451
452 mmc_pdata = pdev->dev.platform_data;
453 if (!mmc_pdata)
454 continue;
455
456 mmc_pdata->slots[0].switch_pin = c->gpio_cd;
457 mmc_pdata->slots[0].gpio_wp = c->gpio_wp;
458
459 res = omap_device_register(pdev);
460 if (res)
461 pr_err("Could not late init MMC %s\n",
462 c->name);
463 }
464}
465
432#define MAX_OMAP_MMC_HWMOD_NAME_LEN 16 466#define MAX_OMAP_MMC_HWMOD_NAME_LEN 16
433 467
434void omap_init_hsmmc(struct omap2_hsmmc_info *hsmmcinfo, int ctrl_nr) 468static void omap_hsmmc_init_one(struct omap2_hsmmc_info *hsmmcinfo,
469 int ctrl_nr)
435{ 470{
436 struct omap_hwmod *oh; 471 struct omap_hwmod *oh;
472 struct omap_hwmod *ohs[1];
473 struct omap_device *od;
437 struct platform_device *pdev; 474 struct platform_device *pdev;
438 char oh_name[MAX_OMAP_MMC_HWMOD_NAME_LEN]; 475 char oh_name[MAX_OMAP_MMC_HWMOD_NAME_LEN];
439 struct omap_mmc_platform_data *mmc_data; 476 struct omap_mmc_platform_data *mmc_data;
440 struct omap_mmc_dev_attr *mmc_dev_attr; 477 struct omap_mmc_dev_attr *mmc_dev_attr;
441 char *name; 478 char *name;
442 int l; 479 int res;
443 480
444 mmc_data = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL); 481 mmc_data = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL);
445 if (!mmc_data) { 482 if (!mmc_data) {
446 pr_err("Cannot allocate memory for mmc device!\n"); 483 pr_err("Cannot allocate memory for mmc device!\n");
447 goto done; 484 return;
448 } 485 }
449 486
450 if (omap_hsmmc_pdata_init(hsmmcinfo, mmc_data) < 0) { 487 res = omap_hsmmc_pdata_init(hsmmcinfo, mmc_data);
451 pr_err("%s fails!\n", __func__); 488 if (res < 0)
452 goto done; 489 goto free_mmc;
453 } 490
454 omap_hsmmc_mux(mmc_data, (ctrl_nr - 1)); 491 omap_hsmmc_mux(mmc_data, (ctrl_nr - 1));
455 492
456 name = "omap_hsmmc"; 493 name = "omap_hsmmc";
457 494 res = snprintf(oh_name, MAX_OMAP_MMC_HWMOD_NAME_LEN,
458 l = snprintf(oh_name, MAX_OMAP_MMC_HWMOD_NAME_LEN,
459 "mmc%d", ctrl_nr); 495 "mmc%d", ctrl_nr);
460 WARN(l >= MAX_OMAP_MMC_HWMOD_NAME_LEN, 496 WARN(res >= MAX_OMAP_MMC_HWMOD_NAME_LEN,
461 "String buffer overflow in MMC%d device setup\n", ctrl_nr); 497 "String buffer overflow in MMC%d device setup\n", ctrl_nr);
498
462 oh = omap_hwmod_lookup(oh_name); 499 oh = omap_hwmod_lookup(oh_name);
463 if (!oh) { 500 if (!oh) {
464 pr_err("Could not look up %s\n", oh_name); 501 pr_err("Could not look up %s\n", oh_name);
465 kfree(mmc_data->slots[0].name); 502 goto free_name;
466 goto done;
467 } 503 }
468 504 ohs[0] = oh;
469 if (oh->dev_attr != NULL) { 505 if (oh->dev_attr != NULL) {
470 mmc_dev_attr = oh->dev_attr; 506 mmc_dev_attr = oh->dev_attr;
471 mmc_data->controller_flags = mmc_dev_attr->flags; 507 mmc_data->controller_flags = mmc_dev_attr->flags;
472 } 508 }
473 509
474 pdev = omap_device_build(name, ctrl_nr - 1, oh, mmc_data, 510 pdev = platform_device_alloc(name, ctrl_nr - 1);
475 sizeof(struct omap_mmc_platform_data), NULL, 0, false); 511 if (!pdev) {
476 if (IS_ERR(pdev)) { 512 pr_err("Could not allocate pdev for %s\n", name);
477 WARN(1, "Can't build omap_device for %s:%s.\n", name, oh->name); 513 goto free_name;
478 kfree(mmc_data->slots[0].name);
479 goto done;
480 } 514 }
481 /* 515 dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id);
482 * return device handle to board setup code 516
483 * required to populate for regulator framework structure 517 od = omap_device_alloc(pdev, ohs, 1, NULL, 0);
484 */ 518 if (!od) {
485 hsmmcinfo->dev = &pdev->dev; 519 pr_err("Could not allocate od for %s\n", name);
520 goto put_pdev;
521 }
522
523 res = platform_device_add_data(pdev, mmc_data,
524 sizeof(struct omap_mmc_platform_data));
525 if (res) {
526 pr_err("Could not add pdata for %s\n", name);
527 goto put_pdev;
528 }
529
530 hsmmcinfo->pdev = pdev;
531
532 if (hsmmcinfo->deferred)
533 goto free_mmc;
534
535 res = omap_device_register(pdev);
536 if (res) {
537 pr_err("Could not register od for %s\n", name);
538 goto free_od;
539 }
540
541 goto free_mmc;
542
543free_od:
544 omap_device_delete(od);
545
546put_pdev:
547 platform_device_put(pdev);
548
549free_name:
550 kfree(mmc_data->slots[0].name);
486 551
487done: 552free_mmc:
488 kfree(mmc_data); 553 kfree(mmc_data);
489} 554}
490 555
491void omap2_hsmmc_init(struct omap2_hsmmc_info *controllers) 556void omap_hsmmc_init(struct omap2_hsmmc_info *controllers)
492{ 557{
493 u32 reg; 558 u32 reg;
494 559
@@ -521,7 +586,7 @@ void omap2_hsmmc_init(struct omap2_hsmmc_info *controllers)
521 } 586 }
522 587
523 for (; controllers->mmc; controllers++) 588 for (; controllers->mmc; controllers++)
524 omap_init_hsmmc(controllers, controllers->mmc); 589 omap_hsmmc_init_one(controllers, controllers->mmc);
525 590
526} 591}
527 592
diff --git a/arch/arm/mach-omap2/hsmmc.h b/arch/arm/mach-omap2/hsmmc.h
index c4409730c4bb..07831cc3c171 100644
--- a/arch/arm/mach-omap2/hsmmc.h
+++ b/arch/arm/mach-omap2/hsmmc.h
@@ -21,10 +21,11 @@ struct omap2_hsmmc_info {
21 bool no_off; /* power_saving and power is not to go off */ 21 bool no_off; /* power_saving and power is not to go off */
22 bool no_off_init; /* no power off when not in MMC sleep state */ 22 bool no_off_init; /* no power off when not in MMC sleep state */
23 bool vcc_aux_disable_is_sleep; /* Regulator off remapped to sleep */ 23 bool vcc_aux_disable_is_sleep; /* Regulator off remapped to sleep */
24 bool deferred; /* mmc needs a deferred probe */
24 int gpio_cd; /* or -EINVAL */ 25 int gpio_cd; /* or -EINVAL */
25 int gpio_wp; /* or -EINVAL */ 26 int gpio_wp; /* or -EINVAL */
26 char *name; /* or NULL for default */ 27 char *name; /* or NULL for default */
27 struct device *dev; /* returned: pointer to mmc adapter */ 28 struct platform_device *pdev; /* mmc controller instance */
28 int ocr_mask; /* temporary HACK */ 29 int ocr_mask; /* temporary HACK */
29 /* Remux (pad configuration) when powering on/off */ 30 /* Remux (pad configuration) when powering on/off */
30 void (*remux)(struct device *dev, int slot, int power_on); 31 void (*remux)(struct device *dev, int slot, int power_on);
@@ -34,11 +35,16 @@ struct omap2_hsmmc_info {
34 35
35#if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE) 36#if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
36 37
37void omap2_hsmmc_init(struct omap2_hsmmc_info *); 38void omap_hsmmc_init(struct omap2_hsmmc_info *);
39void omap_hsmmc_late_init(struct omap2_hsmmc_info *);
38 40
39#else 41#else
40 42
41static inline void omap2_hsmmc_init(struct omap2_hsmmc_info *info) 43static inline void omap_hsmmc_init(struct omap2_hsmmc_info *info)
44{
45}
46
47static inline void omap_hsmmc_late_init(struct omap2_hsmmc_info *info)
42{ 48{
43} 49}
44 50