b/arch/arm/mach-omap2/board-4430sdp.c
@@ -825,10 +825,11 @@ static void __init omap4_sdp4430_wifi_init(void)
int ret;
omap4_sdp4430_wifi_mux_init();
- omap4_sdp4430_wlan_data.irq = gpio_to_irq(GPIO_WIFI_IRQ);
- ret = wl12xx_set_platform_data(&omap4_sdp4430_wlan_data);
+
+ ret = wl12xx_board_init(&omap4_sdp4430_wlan_data, GPIO_WIFI_IRQ);
if (ret)
- pr_err("Error setting wl12xx data: %d\n", ret);
+ return;
+
ret = platform_device_register(&omap_vwlan_device);
if (ret)
pr_err("Error registering wl12xx device: %d\n", ret);
b/arch/arm/mach-omap2/board-omap3evm.c
@@ -636,10 +636,10 @@ static void __init omap3_evm_wl12xx_init(void)
int ret;
/* WL12xx WLAN Init */
- omap3evm_wlan_data.irq = gpio_to_irq(OMAP3EVM_WLAN_IRQ_GPIO);
- ret = wl12xx_set_platform_data(&omap3evm_wlan_data);
+ ret = wl12xx_board_init(&omap3evm_wlan_data, OMAP3EVM_WLAN_IRQ_GPIO);
if (ret)
- pr_err("error setting wl12xx data: %d\n", ret);
+ return;
+
ret = platform_device_register(&omap3evm_wlan_regulator);
if (ret)
pr_err("error registering wl12xx device: %d\n", ret);
b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -543,13 +543,10 @@ static void __init pandora_wl1251_init(void)
if (ret < 0)
goto fail;
- pandora_wl1251_pdata.irq = gpio_to_irq(PANDORA_WIFI_IRQ_GPIO);
- if (pandora_wl1251_pdata.irq < 0)
- goto fail_irq;
-
pandora_wl1251_pdata.use_eeprom = true;
- ret = wl12xx_set_platform_data(&pandora_wl1251_pdata);
- if (ret < 0)
+
+ ret = wl12xx_board_init(&pandora_wl1251_pdata, PANDORA_WIFI_IRQ_GPIO);
+ if (ret)
goto fail_irq;
return;
b/arch/arm/mach-omap2/board-omap4panda.c
@@ -486,24 +486,32 @@ static void omap4_panda_init_rev(void)
}
}
+static void __init omap4_panda_wlan_init(void)
+{
+ int ret;
+
+ ret = wl12xx_board_init(&omap_panda_wlan_data, GPIO_WIFI_IRQ);
+ if (ret)
+ return;
+
+ ret = platform_device_register(&omap_vwlan_device);
+ if (ret)
+ pr_err("error registering wl12xx's fixed regulator: %d\n", ret);
+}
+
static void __init omap4_panda_init(void)
{
int package = OMAP_PACKAGE_CBS;
- int ret;
if (omap_rev() == OMAP4430_REV_ES1_0)
package = OMAP_PACKAGE_CBL;
omap4_mux_init(board_mux, NULL, package);
- omap_panda_wlan_data.irq = gpio_to_irq(GPIO_WIFI_IRQ);
- ret = wl12xx_set_platform_data(&omap_panda_wlan_data);
- if (ret)
- pr_err("error setting wl12xx data: %d\n", ret);
+ omap4_panda_wlan_init();
omap4_panda_init_rev();
omap4_panda_i2c_init();
platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices));
- platform_device_register(&omap_vwlan_device);
omap_serial_init();
omap_sdrc_init(NULL, NULL);
omap4_twl6030_hsmmc_init(mmc);
b/arch/arm/mach-omap2/board-zoom-peripherals.c
@@ -286,19 +286,24 @@ static void enable_board_wakeup_source(void)
OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
}
-void __init zoom_peripherals_init(void)
+static void __init zoom_wlan_init(void)
{
int ret;
- omap_zoom_wlan_data.irq = gpio_to_irq(OMAP_ZOOM_WLAN_IRQ_GPIO);
- ret = wl12xx_set_platform_data(&omap_zoom_wlan_data);
+ ret = wl12xx_board_init(&omap_zoom_wlan_data, OMAP_ZOOM_WLAN_IRQ_GPIO);
+ if (ret)
+ return;
+ ret = platform_device_register(&omap_vwlan_device);
if (ret)
- pr_err("error setting wl12xx data: %d\n", ret);
+ pr_err("error registering wl12xx's fixed regulator: %d\n", ret);
+}
+void __init zoom_peripherals_init(void)
+{
omap_hsmmc_init(mmc);
+ zoom_wlan_init();
omap_i2c_init();
- platform_device_register(&omap_vwlan_device);
usb_musb_init(NULL);
enable_board_wakeup_source();
omap_serial_init();
b/arch/arm/mach-omap2/common-board-devices.c
@@ -23,6 +23,7 @@
#include <linux/gpio.h>
#include <linux/spi/spi.h>
#include <linux/spi/ads7846.h>
+#include <linux/wl12xx.h>
#include <linux/platform_data/spi-omap2-mcspi.h>
#include <linux/platform_data/mtd-nand-omap2.h>
@@ -141,3 +142,35 @@ void __init omap_nand_flash_init(int options,
struct mtd_partition *parts,
{
}
#endif
+
+#ifdef CONFIG_WL12XX_PLATFORM_DATA
+int __init wl12xx_board_init(struct wl12xx_platform_data *wlan_data, int gpio)
+{
+ int ret;
+
+ wlan_data->irq = gpio_to_irq(gpio);
+ if (wlan_data->irq < 0) {
+ ret = wlan_data->irq;
+ pr_err("wl12xx: gpio_to_irq(%d) failed: %d\n", gpio, ret);
+ return ret;
+ }
+
+ ret = wl12xx_set_platform_data(wlan_data);
+ /* bail out silently in case wl12xx isn't configured */
+ if (ret == -ENOSYS)
+ return ret;
+
+ /* bail out verbosely on any other error */
+ if (ret) {
+ pr_err("error setting wl12xx data: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+#else /* !CONFIG_WL12XX_PLATFORM_DATA */
+int __init wl12xx_board_init(struct wl12xx_platform_data *wlan_data, int gpio)
+{
+ return 0;
+}
+#endif
b/arch/arm/mach-omap2/common-board-devices.h
@@ -7,9 +7,11 @@
struct mtd_partition;
struct ads7846_platform_data;
+struct wl12xx_platform_data;
void omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
struct ads7846_platform_data *board_pdata);
void omap_nand_flash_init(int opts, struct mtd_partition *parts, int n_parts);
+int wl12xx_board_init(struct wl12xx_platform_data *wlan_data, int gpio);
#endif /* __OMAP_COMMON_BOARD_DEVICES__ */