diff options
author | Igor Grinberg <grinberg@compulab.co.il> | 2011-05-03 19:22:09 +0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2011-05-12 13:52:06 +0400 |
commit | bc593f5d787d0a015539e21868302fb44a47c3e3 (patch) | |
tree | 75feac78712ae08e38b678c0dae62cb75765ddb0 /arch/arm/mach-omap2/board-igep0030.c | |
parent | 9e18630b689d658d65bf59508bfec084f61ff5c6 (diff) | |
download | linux-bc593f5d787d0a015539e21868302fb44a47c3e3.tar.xz |
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-igep0030.c')
-rw-r--r-- | arch/arm/mach-omap2/board-igep0030.c | 93 |
1 files changed, 44 insertions, 49 deletions
diff --git a/arch/arm/mach-omap2/board-igep0030.c b/arch/arm/mach-omap2/board-igep0030.c index 512a7eb9c2da..83f6be2a0dea 100644 --- a/arch/arm/mach-omap2/board-igep0030.c +++ b/arch/arm/mach-omap2/board-igep0030.c @@ -269,49 +269,43 @@ static void __init igep3_leds_init(void) } #else +static struct gpio igep3_gpio_leds[] __initdata = { + { IGEP3_GPIO_LED0_RED, GPIOF_OUT_INIT_HIGH, "gpio-led:red:d0" }, + { IGEP3_GPIO_LED0_GREEN, GPIOF_OUT_INIT_HIGH, "gpio-led:green:d0" }, + { IGEP3_GPIO_LED1_RED, GPIOF_OUT_INIT_HIGH, "gpio-led:red:d1" }, +}; + static inline void igep3_leds_init(void) { - if ((gpio_request(IGEP3_GPIO_LED0_RED, "gpio-led:red:d0") == 0) && - (gpio_direction_output(IGEP3_GPIO_LED0_RED, 1) == 0)) { - gpio_export(IGEP3_GPIO_LED0_RED, 0); - gpio_set_value(IGEP3_GPIO_LED0_RED, 1); - } else - pr_warning("IGEP3: Could not obtain gpio GPIO_LED0_RED\n"); - - if ((gpio_request(IGEP3_GPIO_LED0_GREEN, "gpio-led:green:d0") == 0) && - (gpio_direction_output(IGEP3_GPIO_LED0_GREEN, 1) == 0)) { - gpio_export(IGEP3_GPIO_LED0_GREEN, 0); - gpio_set_value(IGEP3_GPIO_LED0_GREEN, 1); - } else - pr_warning("IGEP3: Could not obtain gpio GPIO_LED0_GREEN\n"); - - if ((gpio_request(IGEP3_GPIO_LED1_RED, "gpio-led:red:d1") == 0) && - (gpio_direction_output(IGEP3_GPIO_LED1_RED, 1) == 0)) { - gpio_export(IGEP3_GPIO_LED1_RED, 0); - gpio_set_value(IGEP3_GPIO_LED1_RED, 1); - } else - pr_warning("IGEP3: Could not obtain gpio GPIO_LED1_RED\n"); + if (gpio_request_array(igep3_gpio_leds, ARRAY_SIZE(igep3_gpio_leds))) { + pr_warning("IGEP3: Could not obtain leds gpios\n"); + return; + } + gpio_export(IGEP3_GPIO_LED0_RED, 0); + gpio_export(IGEP3_GPIO_LED0_GREEN, 0); + gpio_export(IGEP3_GPIO_LED1_RED, 0); } #endif static int igep3_twl4030_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio) { - /* gpio + 0 is "mmc0_cd" (input/IRQ) */ - mmc[0].gpio_cd = gpio + 0; - omap2_hsmmc_init(mmc); +#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE) + int ret; /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */ -#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE) - if ((gpio_request(gpio+TWL4030_GPIO_MAX+1, "gpio-led:green:d1") == 0) - && (gpio_direction_output(gpio + TWL4030_GPIO_MAX + 1, 1) == 0)) { - gpio_export(gpio + TWL4030_GPIO_MAX + 1, 0); - gpio_set_value(gpio + TWL4030_GPIO_MAX + 1, 0); - } else + ret = gpio_request_one(gpio + TWL4030_GPIO_MAX + 1, GPIOF_OUT_INIT_HIGH, + "gpio-led:green:d1"); + if (ret) pr_warning("IGEP3: Could not obtain gpio GPIO_LED1_GREEN\n"); + else + gpio_export(gpio + TWL4030_GPIO_MAX + 1, 0); #else igep3_gpio_leds[3].gpio = gpio + TWL4030_GPIO_MAX + 1; #endif + /* gpio + 0 is "mmc0_cd" (input/IRQ) */ + mmc[0].gpio_cd = gpio + 0; + omap2_hsmmc_init(mmc); return 0; }; @@ -358,35 +352,36 @@ static int __init igep3_i2c_init(void) } #if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE) +static struct gpio igep3_wlan_bt_gpios[] __initdata = { + { IGEP3_GPIO_WIFI_NPD, GPIOF_OUT_INIT_HIGH, "GPIO_WIFI_NPD" }, + { IGEP3_GPIO_WIFI_NRESET, GPIOF_OUT_INIT_HIGH, "GPIO_WIFI_NRESET" }, + { IGEP3_GPIO_BT_NRESET, GPIOF_OUT_INIT_HIGH, "GPIO_BT_NRESET" }, +}; static void __init igep3_wifi_bt_init(void) { + int err; + /* Configure MUX values for W-LAN + Bluetooth GPIO's */ omap_mux_init_gpio(IGEP3_GPIO_WIFI_NPD, OMAP_PIN_OUTPUT); omap_mux_init_gpio(IGEP3_GPIO_WIFI_NRESET, OMAP_PIN_OUTPUT); omap_mux_init_gpio(IGEP3_GPIO_BT_NRESET, OMAP_PIN_OUTPUT); /* Set GPIO's for W-LAN + Bluetooth combo module */ - if ((gpio_request(IGEP3_GPIO_WIFI_NPD, "GPIO_WIFI_NPD") == 0) && - (gpio_direction_output(IGEP3_GPIO_WIFI_NPD, 1) == 0)) { - gpio_export(IGEP3_GPIO_WIFI_NPD, 0); - } else - pr_warning("IGEP3: Could not obtain gpio GPIO_WIFI_NPD\n"); - - if ((gpio_request(IGEP3_GPIO_WIFI_NRESET, "GPIO_WIFI_NRESET") == 0) && - (gpio_direction_output(IGEP3_GPIO_WIFI_NRESET, 1) == 0)) { - gpio_export(IGEP3_GPIO_WIFI_NRESET, 0); - gpio_set_value(IGEP3_GPIO_WIFI_NRESET, 0); - udelay(10); - gpio_set_value(IGEP3_GPIO_WIFI_NRESET, 1); - } else - pr_warning("IGEP3: Could not obtain gpio GPIO_WIFI_NRESET\n"); - - if ((gpio_request(IGEP3_GPIO_BT_NRESET, "GPIO_BT_NRESET") == 0) && - (gpio_direction_output(IGEP3_GPIO_BT_NRESET, 1) == 0)) { - gpio_export(IGEP3_GPIO_BT_NRESET, 0); - } else - pr_warning("IGEP3: Could not obtain gpio GPIO_BT_NRESET\n"); + err = gpio_request_array(igep3_wlan_bt_gpios, + ARRAY_SIZE(igep3_wlan_bt_gpios)); + if (err) { + pr_warning("IGEP3: Could not obtain WIFI/BT gpios\n"); + return; + } + + gpio_export(IGEP3_GPIO_WIFI_NPD, 0); + gpio_export(IGEP3_GPIO_WIFI_NRESET, 0); + gpio_export(IGEP3_GPIO_BT_NRESET, 0); + + gpio_set_value(IGEP3_GPIO_WIFI_NRESET, 0); + udelay(10); + gpio_set_value(IGEP3_GPIO_WIFI_NRESET, 1); } #else void __init igep3_wifi_bt_init(void) {} |