Commit 1d207cd3 authored by Sebastian Reichel's avatar Sebastian Reichel Committed by John W. Linville

wl1251: move power GPIO handling into the driver

Move the power GPIO handling from the board code into
the driver. This is a dependency for device tree support.
Signed-off-by: default avatarSebastian Reichel <sre@debian.org>
Reviewed-by: default avatarPavel Machek <pavel@ucw.cz>
Acked-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 946651cb
...@@ -541,6 +541,8 @@ static void __init pandora_wl1251_init(void) ...@@ -541,6 +541,8 @@ static void __init pandora_wl1251_init(void)
memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata)); memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata));
pandora_wl1251_pdata.power_gpio = -1;
ret = gpio_request_one(PANDORA_WIFI_IRQ_GPIO, GPIOF_IN, "wl1251 irq"); ret = gpio_request_one(PANDORA_WIFI_IRQ_GPIO, GPIOF_IN, "wl1251 irq");
if (ret < 0) if (ret < 0)
goto fail; goto fail;
......
...@@ -1173,13 +1173,7 @@ static inline void board_smc91x_init(void) ...@@ -1173,13 +1173,7 @@ static inline void board_smc91x_init(void)
#endif #endif
static void rx51_wl1251_set_power(bool enable)
{
gpio_set_value(RX51_WL1251_POWER_GPIO, enable);
}
static struct gpio rx51_wl1251_gpios[] __initdata = { static struct gpio rx51_wl1251_gpios[] __initdata = {
{ RX51_WL1251_POWER_GPIO, GPIOF_OUT_INIT_LOW, "wl1251 power" },
{ RX51_WL1251_IRQ_GPIO, GPIOF_IN, "wl1251 irq" }, { RX51_WL1251_IRQ_GPIO, GPIOF_IN, "wl1251 irq" },
}; };
...@@ -1196,17 +1190,16 @@ static void __init rx51_init_wl1251(void) ...@@ -1196,17 +1190,16 @@ static void __init rx51_init_wl1251(void)
if (irq < 0) if (irq < 0)
goto err_irq; goto err_irq;
wl1251_pdata.set_power = rx51_wl1251_set_power; wl1251_pdata.power_gpio = RX51_WL1251_POWER_GPIO;
rx51_peripherals_spi_board_info[RX51_SPI_WL1251].irq = irq; rx51_peripherals_spi_board_info[RX51_SPI_WL1251].irq = irq;
return; return;
err_irq: err_irq:
gpio_free(RX51_WL1251_IRQ_GPIO); gpio_free(RX51_WL1251_IRQ_GPIO);
gpio_free(RX51_WL1251_POWER_GPIO);
error: error:
printk(KERN_ERR "wl1251 board initialisation failed\n"); printk(KERN_ERR "wl1251 board initialisation failed\n");
wl1251_pdata.set_power = NULL; wl1251_pdata.power_gpio = -1;
/* /*
* Now rx51_peripherals_spi_board_info[1].irq is zero and * Now rx51_peripherals_spi_board_info[1].irq is zero and
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/wl12xx.h> #include <linux/wl12xx.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/gpio.h>
#include "wl1251.h" #include "wl1251.h"
...@@ -182,8 +183,9 @@ static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable) ...@@ -182,8 +183,9 @@ static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable)
* callback in case it wants to do any additional setup, * callback in case it wants to do any additional setup,
* for example enabling clock buffer for the module. * for example enabling clock buffer for the module.
*/ */
if (wl->set_power) if (gpio_is_valid(wl->power_gpio))
wl->set_power(true); gpio_set_value(wl->power_gpio, true);
ret = pm_runtime_get_sync(&func->dev); ret = pm_runtime_get_sync(&func->dev);
if (ret < 0) { if (ret < 0) {
...@@ -203,8 +205,8 @@ static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable) ...@@ -203,8 +205,8 @@ static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable)
if (ret < 0) if (ret < 0)
goto out; goto out;
if (wl->set_power) if (gpio_is_valid(wl->power_gpio))
wl->set_power(false); gpio_set_value(wl->power_gpio, false);
} }
out: out:
...@@ -256,11 +258,20 @@ static int wl1251_sdio_probe(struct sdio_func *func, ...@@ -256,11 +258,20 @@ static int wl1251_sdio_probe(struct sdio_func *func,
wl1251_board_data = wl1251_get_platform_data(); wl1251_board_data = wl1251_get_platform_data();
if (!IS_ERR(wl1251_board_data)) { if (!IS_ERR(wl1251_board_data)) {
wl->set_power = wl1251_board_data->set_power; wl->power_gpio = wl1251_board_data->power_gpio;
wl->irq = wl1251_board_data->irq; wl->irq = wl1251_board_data->irq;
wl->use_eeprom = wl1251_board_data->use_eeprom; wl->use_eeprom = wl1251_board_data->use_eeprom;
} }
if (gpio_is_valid(wl->power_gpio)) {
ret = devm_gpio_request(&func->dev, wl->power_gpio,
"wl1251 power");
if (ret) {
wl1251_error("Failed to request gpio: %d\n", ret);
goto disable;
}
}
if (wl->irq) { if (wl->irq) {
irq_set_status_flags(wl->irq, IRQ_NOAUTOEN); irq_set_status_flags(wl->irq, IRQ_NOAUTOEN);
ret = request_irq(wl->irq, wl1251_line_irq, 0, "wl1251", wl); ret = request_irq(wl->irq, wl1251_line_irq, 0, "wl1251", wl);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/crc7.h> #include <linux/crc7.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/wl12xx.h> #include <linux/wl12xx.h>
#include <linux/gpio.h>
#include "wl1251.h" #include "wl1251.h"
#include "reg.h" #include "reg.h"
...@@ -221,8 +222,8 @@ static void wl1251_spi_disable_irq(struct wl1251 *wl) ...@@ -221,8 +222,8 @@ static void wl1251_spi_disable_irq(struct wl1251 *wl)
static int wl1251_spi_set_power(struct wl1251 *wl, bool enable) static int wl1251_spi_set_power(struct wl1251 *wl, bool enable)
{ {
if (wl->set_power) if (gpio_is_valid(wl->power_gpio))
wl->set_power(enable); gpio_set_value(wl->power_gpio, enable);
return 0; return 0;
} }
...@@ -271,22 +272,33 @@ static int wl1251_spi_probe(struct spi_device *spi) ...@@ -271,22 +272,33 @@ static int wl1251_spi_probe(struct spi_device *spi)
goto out_free; goto out_free;
} }
wl->set_power = pdata->set_power; wl->power_gpio = pdata->power_gpio;
if (!wl->set_power) {
wl1251_error("set power function missing in platform data"); if (gpio_is_valid(wl->power_gpio)) {
return -ENODEV; ret = devm_gpio_request_one(&spi->dev, wl->power_gpio,
GPIOF_OUT_INIT_LOW, "wl1251 power");
if (ret) {
wl1251_error("Failed to request gpio: %d\n", ret);
goto out_free;
}
} else {
wl1251_error("set power gpio missing in platform data");
ret = -ENODEV;
goto out_free;
} }
wl->irq = spi->irq; wl->irq = spi->irq;
if (wl->irq < 0) { if (wl->irq < 0) {
wl1251_error("irq missing in platform data"); wl1251_error("irq missing in platform data");
return -ENODEV; ret = -ENODEV;
goto out_free;
} }
wl->use_eeprom = pdata->use_eeprom; wl->use_eeprom = pdata->use_eeprom;
irq_set_status_flags(wl->irq, IRQ_NOAUTOEN); irq_set_status_flags(wl->irq, IRQ_NOAUTOEN);
ret = request_irq(wl->irq, wl1251_irq, 0, DRIVER_NAME, wl); ret = devm_request_irq(&spi->dev, wl->irq, wl1251_irq, 0,
DRIVER_NAME, wl);
if (ret < 0) { if (ret < 0) {
wl1251_error("request_irq() failed: %d", ret); wl1251_error("request_irq() failed: %d", ret);
goto out_free; goto out_free;
...@@ -296,13 +308,10 @@ static int wl1251_spi_probe(struct spi_device *spi) ...@@ -296,13 +308,10 @@ static int wl1251_spi_probe(struct spi_device *spi)
ret = wl1251_init_ieee80211(wl); ret = wl1251_init_ieee80211(wl);
if (ret) if (ret)
goto out_irq; goto out_free;
return 0; return 0;
out_irq:
free_irq(wl->irq, wl);
out_free: out_free:
ieee80211_free_hw(hw); ieee80211_free_hw(hw);
......
...@@ -276,7 +276,7 @@ struct wl1251 { ...@@ -276,7 +276,7 @@ struct wl1251 {
void *if_priv; void *if_priv;
const struct wl1251_if_operations *if_ops; const struct wl1251_if_operations *if_ops;
void (*set_power)(bool enable); int power_gpio;
int irq; int irq;
bool use_eeprom; bool use_eeprom;
......
...@@ -49,7 +49,7 @@ enum { ...@@ -49,7 +49,7 @@ enum {
}; };
struct wl1251_platform_data { struct wl1251_platform_data {
void (*set_power)(bool enable); int power_gpio;
/* SDIO only: IRQ number if WLAN_IRQ line is used, 0 for SDIO IRQs */ /* SDIO only: IRQ number if WLAN_IRQ line is used, 0 for SDIO IRQs */
int irq; int irq;
bool use_eeprom; bool use_eeprom;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment