aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/board-igep0020.c
diff options
context:
space:
mode:
authorIgor Grinberg <grinberg@compulab.co.il>2011-05-03 11:22:09 -0400
committerTony Lindgren <tony@atomide.com>2011-05-12 05:52:06 -0400
commitbc593f5d787d0a015539e21868302fb44a47c3e3 (patch)
tree75feac78712ae08e38b678c0dae62cb75765ddb0 /arch/arm/mach-omap2/board-igep0020.c
parent9e18630b689d658d65bf59508bfec084f61ff5c6 (diff)
arm: omap2plus: GPIO cleanup
use gpio_request_<one|array>() instead of multiple gpiolib calls, remove unneeded variables, etc. Signed-off-by: Igor Grinberg <grinberg@compulab.co.il> 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.c143
1 files changed, 72 insertions, 71 deletions
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index 2c9a9197d2b2..c62c297e0a3d 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -78,22 +78,22 @@ static void __init igep2_get_revision(void)
78 78
79 omap_mux_init_gpio(IGEP2_GPIO_LED1_RED, OMAP_PIN_INPUT); 79 omap_mux_init_gpio(IGEP2_GPIO_LED1_RED, OMAP_PIN_INPUT);
80 80
81 if ((gpio_request(IGEP2_GPIO_LED1_RED, "GPIO_HW0_REV") == 0) && 81 if (gpio_request_one(IGEP2_GPIO_LED1_RED, GPIOF_IN, "GPIO_HW0_REV")) {
82 (gpio_direction_input(IGEP2_GPIO_LED1_RED) == 0)) {
83 ret = gpio_get_value(IGEP2_GPIO_LED1_RED);
84 if (ret == 0) {
85 pr_info("IGEP2: Hardware Revision C (B-NON compatible)\n");
86 hwrev = IGEP2_BOARD_HWREV_C;
87 } else if (ret == 1) {
88 pr_info("IGEP2: Hardware Revision B/C (B compatible)\n");
89 hwrev = IGEP2_BOARD_HWREV_B;
90 } else {
91 pr_err("IGEP2: Unknown Hardware Revision\n");
92 hwrev = -1;
93 }
94 } else {
95 pr_warning("IGEP2: Could not obtain gpio GPIO_HW0_REV\n"); 82 pr_warning("IGEP2: Could not obtain gpio GPIO_HW0_REV\n");
96 pr_err("IGEP2: Unknown Hardware Revision\n"); 83 pr_err("IGEP2: Unknown Hardware Revision\n");
84 return;
85 }
86
87 ret = gpio_get_value(IGEP2_GPIO_LED1_RED);
88 if (ret == 0) {
89 pr_info("IGEP2: Hardware Revision C (B-NON compatible)\n");
90 hwrev = IGEP2_BOARD_HWREV_C;
91 } else if (ret == 1) {
92 pr_info("IGEP2: Hardware Revision B/C (B compatible)\n");
93 hwrev = IGEP2_BOARD_HWREV_B;
94 } else {
95 pr_err("IGEP2: Unknown Hardware Revision\n");
96 hwrev = -1;
97 } 97 }
98 98
99 gpio_free(IGEP2_GPIO_LED1_RED); 99 gpio_free(IGEP2_GPIO_LED1_RED);
@@ -339,32 +339,35 @@ static void __init igep2_leds_init(void)
339} 339}
340 340
341#else 341#else
342static struct gpio igep2_gpio_leds[] __initdata = {
343 { IGEP2_GPIO_LED0_RED, GPIOF_OUT_INIT_LOW, "gpio-led:red:d0" },
344 { IGEP2_GPIO_LED0_GREEN, GPIOF_OUT_INIT_LOW, "gpio-led:green:d0" },
345 { IGEP2_GPIO_LED1_RED, GPIOF_OUT_INIT_LOW, "gpio-led:red:d1" },
346};
347
342static inline void igep2_leds_init(void) 348static inline void igep2_leds_init(void)
343{ 349{
344 if ((gpio_request(IGEP2_GPIO_LED0_RED, "gpio-led:red:d0") == 0) && 350 if (gpio_request_array(igep2_gpio_leds, ARRAY_SIZE(igep2_gpio_leds))) {
345 (gpio_direction_output(IGEP2_GPIO_LED0_RED, 0) == 0)) 351 pr_warning("IGEP v2: Could not obtain leds gpios\n");
346 gpio_export(IGEP2_GPIO_LED0_RED, 0); 352 return;
347 else 353 }
348 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
349
350 if ((gpio_request(IGEP2_GPIO_LED0_GREEN, "gpio-led:green:d0") == 0) &&
351 (gpio_direction_output(IGEP2_GPIO_LED0_GREEN, 0) == 0))
352 gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
353 else
354 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
355
356 if ((gpio_request(IGEP2_GPIO_LED1_RED, "gpio-led:red:d1") == 0) &&
357 (gpio_direction_output(IGEP2_GPIO_LED1_RED, 0) == 0))
358 gpio_export(IGEP2_GPIO_LED1_RED, 0);
359 else
360 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
361 354
355 gpio_export(IGEP2_GPIO_LED0_RED, 0);
356 gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
357 gpio_export(IGEP2_GPIO_LED1_RED, 0);
362} 358}
363#endif 359#endif
364 360
361static struct gpio igep2_twl_gpios[] = {
362 { -EINVAL, GPIOF_IN, "GPIO_EHCI_NOC" },
363 { -EINVAL, GPIOF_OUT_INIT_LOW, "GPIO_USBH_CPEN" },
364};
365
365static int igep2_twl_gpio_setup(struct device *dev, 366static int igep2_twl_gpio_setup(struct device *dev,
366 unsigned gpio, unsigned ngpio) 367 unsigned gpio, unsigned ngpio)
367{ 368{
369 int ret;
370
368 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 371 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
369 mmc[0].gpio_cd = gpio + 0; 372 mmc[0].gpio_cd = gpio + 0;
370 omap2_hsmmc_init(mmc); 373 omap2_hsmmc_init(mmc);
@@ -373,22 +376,20 @@ static int igep2_twl_gpio_setup(struct device *dev,
373 * REVISIT: need ehci-omap hooks for external VBUS 376 * REVISIT: need ehci-omap hooks for external VBUS
374 * power switch and overcurrent detect 377 * power switch and overcurrent detect
375 */ 378 */
376 if ((gpio_request(gpio + 1, "GPIO_EHCI_NOC") < 0) || 379 igep2_twl_gpios[0].gpio = gpio + 1;
377 (gpio_direction_input(gpio + 1) < 0))
378 pr_err("IGEP2: Could not obtain gpio for EHCI NOC");
379 380
380 /* 381 /* TWL4030_GPIO_MAX + 0 == ledA, GPIO_USBH_CPEN (out, active low) */
381 * TWL4030_GPIO_MAX + 0 == ledA, GPIO_USBH_CPEN 382 igep2_twl_gpios[1].gpio = gpio + TWL4030_GPIO_MAX;
382 * (out, active low) 383
383 */ 384 ret = gpio_request_array(igep2_twl_gpios, ARRAY_SIZE(igep2_twl_gpios));
384 if ((gpio_request(gpio + TWL4030_GPIO_MAX, "GPIO_USBH_CPEN") < 0) || 385 if (ret < 0)
385 (gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0) < 0))
386 pr_err("IGEP2: Could not obtain gpio for USBH_CPEN"); 386 pr_err("IGEP2: Could not obtain gpio for USBH_CPEN");
387 387
388 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */ 388 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
389#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE) 389#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
390 if ((gpio_request(gpio+TWL4030_GPIO_MAX+1, "gpio-led:green:d1") == 0) 390 ret = gpio_request_one(gpio + TWL4030_GPIO_MAX + 1, GPIOF_OUT_INIT_HIGH,
391 && (gpio_direction_output(gpio + TWL4030_GPIO_MAX + 1, 1) == 0)) 391 "gpio-led:green:d1");
392 if (ret == 0)
392 gpio_export(gpio + TWL4030_GPIO_MAX + 1, 0); 393 gpio_export(gpio + TWL4030_GPIO_MAX + 1, 0);
393 else 394 else
394 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_GREEN\n"); 395 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_GREEN\n");
@@ -469,8 +470,9 @@ static struct regulator_init_data igep2_vpll2 = {
469 470
470static void __init igep2_display_init(void) 471static void __init igep2_display_init(void)
471{ 472{
472 if (gpio_request(IGEP2_GPIO_DVI_PUP, "GPIO_DVI_PUP") && 473 int err = gpio_request_one(IGEP2_GPIO_DVI_PUP, GPIOF_OUT_INIT_HIGH,
473 gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1)) 474 "GPIO_DVI_PUP");
475 if (err)
474 pr_err("IGEP v2: Could not obtain gpio GPIO_DVI_PUP\n"); 476 pr_err("IGEP v2: Could not obtain gpio GPIO_DVI_PUP\n");
475} 477}
476 478
@@ -577,44 +579,43 @@ static struct omap_board_mux board_mux[] __initdata = {
577#endif 579#endif
578 580
579#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE) 581#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
582static struct gpio igep2_wlan_bt_gpios[] __initdata = {
583 { -EINVAL, GPIOF_OUT_INIT_HIGH, "GPIO_WIFI_NPD" },
584 { -EINVAL, GPIOF_OUT_INIT_HIGH, "GPIO_WIFI_NRESET" },
585 { -EINVAL, GPIOF_OUT_INIT_HIGH, "GPIO_BT_NRESET" },
586};
580 587
581static void __init igep2_wlan_bt_init(void) 588static void __init igep2_wlan_bt_init(void)
582{ 589{
583 unsigned npd, wreset, btreset; 590 int err;
584 591
585 /* GPIO's for WLAN-BT combo depends on hardware revision */ 592 /* GPIO's for WLAN-BT combo depends on hardware revision */
586 if (hwrev == IGEP2_BOARD_HWREV_B) { 593 if (hwrev == IGEP2_BOARD_HWREV_B) {
587 npd = IGEP2_RB_GPIO_WIFI_NPD; 594 igep2_wlan_bt_gpios[0].gpio = IGEP2_RB_GPIO_WIFI_NPD;
588 wreset = IGEP2_RB_GPIO_WIFI_NRESET; 595 igep2_wlan_bt_gpios[1].gpio = IGEP2_RB_GPIO_WIFI_NRESET;
589 btreset = IGEP2_RB_GPIO_BT_NRESET; 596 igep2_wlan_bt_gpios[2].gpio = IGEP2_RB_GPIO_BT_NRESET;
590 } else if (hwrev == IGEP2_BOARD_HWREV_C) { 597 } else if (hwrev == IGEP2_BOARD_HWREV_C) {
591 npd = IGEP2_RC_GPIO_WIFI_NPD; 598 igep2_wlan_bt_gpios[0].gpio = IGEP2_RC_GPIO_WIFI_NPD;
592 wreset = IGEP2_RC_GPIO_WIFI_NRESET; 599 igep2_wlan_bt_gpios[1].gpio = IGEP2_RC_GPIO_WIFI_NRESET;
593 btreset = IGEP2_RC_GPIO_BT_NRESET; 600 igep2_wlan_bt_gpios[2].gpio = IGEP2_RC_GPIO_BT_NRESET;
594 } else 601 } else
595 return; 602 return;
596 603
597 /* Set GPIO's for WLAN-BT combo module */ 604 err = gpio_request_array(igep2_wlan_bt_gpios,
598 if ((gpio_request(npd, "GPIO_WIFI_NPD") == 0) && 605 ARRAY_SIZE(igep2_wlan_bt_gpios));
599 (gpio_direction_output(npd, 1) == 0)) { 606 if (err) {
600 gpio_export(npd, 0); 607 pr_warning("IGEP2: Could not obtain WIFI/BT gpios\n");
601 } else 608 return;
602 pr_warning("IGEP2: Could not obtain gpio GPIO_WIFI_NPD\n"); 609 }
603 610
604 if ((gpio_request(wreset, "GPIO_WIFI_NRESET") == 0) && 611 gpio_export(igep2_wlan_bt_gpios[0].gpio, 0);
605 (gpio_direction_output(wreset, 1) == 0)) { 612 gpio_export(igep2_wlan_bt_gpios[1].gpio, 0);
606 gpio_export(wreset, 0); 613 gpio_export(igep2_wlan_bt_gpios[2].gpio, 0);
607 gpio_set_value(wreset, 0); 614
608 udelay(10); 615 gpio_set_value(igep2_wlan_bt_gpios[1].gpio, 0);
609 gpio_set_value(wreset, 1); 616 udelay(10);
610 } else 617 gpio_set_value(igep2_wlan_bt_gpios[1].gpio, 1);
611 pr_warning("IGEP2: Could not obtain gpio GPIO_WIFI_NRESET\n");
612 618
613 if ((gpio_request(btreset, "GPIO_BT_NRESET") == 0) &&
614 (gpio_direction_output(btreset, 1) == 0)) {
615 gpio_export(btreset, 0);
616 } else
617 pr_warning("IGEP2: Could not obtain gpio GPIO_BT_NRESET\n");
618} 619}
619#else 620#else
620static inline void __init igep2_wlan_bt_init(void) { } 621static inline void __init igep2_wlan_bt_init(void) { }