aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorSebastian Reichel <sre@debian.org>2014-02-14 18:05:53 -0500
committerJohn W. Linville <linville@tuxdriver.com>2014-02-28 14:08:26 -0500
commit1d207cd30b65fdd60d952cb9e100b6f776564f06 (patch)
treed7da13786239fa133a95c7cb0452877a9e2763d9 /drivers/net
parent946651cba26779864bcdbd7e12502f5a36c2de37 (diff)
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: Sebastian Reichel <sre@debian.org> Reviewed-by: Pavel Machek <pavel@ucw.cz> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/ti/wl1251/sdio.c21
-rw-r--r--drivers/net/wireless/ti/wl1251/spi.c33
-rw-r--r--drivers/net/wireless/ti/wl1251/wl1251.h2
3 files changed, 38 insertions, 18 deletions
diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
index b75a37a58313..b661f896e9fe 100644
--- a/drivers/net/wireless/ti/wl1251/sdio.c
+++ b/drivers/net/wireless/ti/wl1251/sdio.c
@@ -28,6 +28,7 @@
28#include <linux/wl12xx.h> 28#include <linux/wl12xx.h>
29#include <linux/irq.h> 29#include <linux/irq.h>
30#include <linux/pm_runtime.h> 30#include <linux/pm_runtime.h>
31#include <linux/gpio.h>
31 32
32#include "wl1251.h" 33#include "wl1251.h"
33 34
@@ -182,8 +183,9 @@ static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable)
182 * callback in case it wants to do any additional setup, 183 * callback in case it wants to do any additional setup,
183 * for example enabling clock buffer for the module. 184 * for example enabling clock buffer for the module.
184 */ 185 */
185 if (wl->set_power) 186 if (gpio_is_valid(wl->power_gpio))
186 wl->set_power(true); 187 gpio_set_value(wl->power_gpio, true);
188
187 189
188 ret = pm_runtime_get_sync(&func->dev); 190 ret = pm_runtime_get_sync(&func->dev);
189 if (ret < 0) { 191 if (ret < 0) {
@@ -203,8 +205,8 @@ static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable)
203 if (ret < 0) 205 if (ret < 0)
204 goto out; 206 goto out;
205 207
206 if (wl->set_power) 208 if (gpio_is_valid(wl->power_gpio))
207 wl->set_power(false); 209 gpio_set_value(wl->power_gpio, false);
208 } 210 }
209 211
210out: 212out:
@@ -256,11 +258,20 @@ static int wl1251_sdio_probe(struct sdio_func *func,
256 258
257 wl1251_board_data = wl1251_get_platform_data(); 259 wl1251_board_data = wl1251_get_platform_data();
258 if (!IS_ERR(wl1251_board_data)) { 260 if (!IS_ERR(wl1251_board_data)) {
259 wl->set_power = wl1251_board_data->set_power; 261 wl->power_gpio = wl1251_board_data->power_gpio;
260 wl->irq = wl1251_board_data->irq; 262 wl->irq = wl1251_board_data->irq;
261 wl->use_eeprom = wl1251_board_data->use_eeprom; 263 wl->use_eeprom = wl1251_board_data->use_eeprom;
262 } 264 }
263 265
266 if (gpio_is_valid(wl->power_gpio)) {
267 ret = devm_gpio_request(&func->dev, wl->power_gpio,
268 "wl1251 power");
269 if (ret) {
270 wl1251_error("Failed to request gpio: %d\n", ret);
271 goto disable;
272 }
273 }
274
264 if (wl->irq) { 275 if (wl->irq) {
265 irq_set_status_flags(wl->irq, IRQ_NOAUTOEN); 276 irq_set_status_flags(wl->irq, IRQ_NOAUTOEN);
266 ret = request_irq(wl->irq, wl1251_line_irq, 0, "wl1251", wl); 277 ret = request_irq(wl->irq, wl1251_line_irq, 0, "wl1251", wl);
diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c
index 62403a147592..6abcbc3f7fc7 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -26,6 +26,7 @@
26#include <linux/crc7.h> 26#include <linux/crc7.h>
27#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
28#include <linux/wl12xx.h> 28#include <linux/wl12xx.h>
29#include <linux/gpio.h>
29 30
30#include "wl1251.h" 31#include "wl1251.h"
31#include "reg.h" 32#include "reg.h"
@@ -221,8 +222,8 @@ static void wl1251_spi_disable_irq(struct wl1251 *wl)
221 222
222static int wl1251_spi_set_power(struct wl1251 *wl, bool enable) 223static int wl1251_spi_set_power(struct wl1251 *wl, bool enable)
223{ 224{
224 if (wl->set_power) 225 if (gpio_is_valid(wl->power_gpio))
225 wl->set_power(enable); 226 gpio_set_value(wl->power_gpio, enable);
226 227
227 return 0; 228 return 0;
228} 229}
@@ -271,22 +272,33 @@ static int wl1251_spi_probe(struct spi_device *spi)
271 goto out_free; 272 goto out_free;
272 } 273 }
273 274
274 wl->set_power = pdata->set_power; 275 wl->power_gpio = pdata->power_gpio;
275 if (!wl->set_power) { 276
276 wl1251_error("set power function missing in platform data"); 277 if (gpio_is_valid(wl->power_gpio)) {
277 return -ENODEV; 278 ret = devm_gpio_request_one(&spi->dev, wl->power_gpio,
279 GPIOF_OUT_INIT_LOW, "wl1251 power");
280 if (ret) {
281 wl1251_error("Failed to request gpio: %d\n", ret);
282 goto out_free;
283 }
284 } else {
285 wl1251_error("set power gpio missing in platform data");
286 ret = -ENODEV;
287 goto out_free;
278 } 288 }
279 289
280 wl->irq = spi->irq; 290 wl->irq = spi->irq;
281 if (wl->irq < 0) { 291 if (wl->irq < 0) {
282 wl1251_error("irq missing in platform data"); 292 wl1251_error("irq missing in platform data");
283 return -ENODEV; 293 ret = -ENODEV;
294 goto out_free;
284 } 295 }
285 296
286 wl->use_eeprom = pdata->use_eeprom; 297 wl->use_eeprom = pdata->use_eeprom;
287 298
288 irq_set_status_flags(wl->irq, IRQ_NOAUTOEN); 299 irq_set_status_flags(wl->irq, IRQ_NOAUTOEN);
289 ret = request_irq(wl->irq, wl1251_irq, 0, DRIVER_NAME, wl); 300 ret = devm_request_irq(&spi->dev, wl->irq, wl1251_irq, 0,
301 DRIVER_NAME, wl);
290 if (ret < 0) { 302 if (ret < 0) {
291 wl1251_error("request_irq() failed: %d", ret); 303 wl1251_error("request_irq() failed: %d", ret);
292 goto out_free; 304 goto out_free;
@@ -296,13 +308,10 @@ static int wl1251_spi_probe(struct spi_device *spi)
296 308
297 ret = wl1251_init_ieee80211(wl); 309 ret = wl1251_init_ieee80211(wl);
298 if (ret) 310 if (ret)
299 goto out_irq; 311 goto out_free;
300 312
301 return 0; 313 return 0;
302 314
303 out_irq:
304 free_irq(wl->irq, wl);
305
306 out_free: 315 out_free:
307 ieee80211_free_hw(hw); 316 ieee80211_free_hw(hw);
308 317
diff --git a/drivers/net/wireless/ti/wl1251/wl1251.h b/drivers/net/wireless/ti/wl1251/wl1251.h
index 235617a7716d..389fe25af1b6 100644
--- a/drivers/net/wireless/ti/wl1251/wl1251.h
+++ b/drivers/net/wireless/ti/wl1251/wl1251.h
@@ -276,7 +276,7 @@ struct wl1251 {
276 void *if_priv; 276 void *if_priv;
277 const struct wl1251_if_operations *if_ops; 277 const struct wl1251_if_operations *if_ops;
278 278
279 void (*set_power)(bool enable); 279 int power_gpio;
280 int irq; 280 int irq;
281 bool use_eeprom; 281 bool use_eeprom;
282 282