diff options
author | Sebastian Reichel <sre@debian.org> | 2014-02-14 18:05:55 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2014-02-28 14:08:27 -0500 |
commit | 07bbca6f142d02b4b09d66ed3c2cde36c77057ad (patch) | |
tree | 9c5b988777a0c7787d2f8f5e2522636f44463e48 | |
parent | e4c2e09e1534835c749de362b9b38e2d8b286236 (diff) |
wl1251: spi: add device tree support
Add device tree support for the spi variant of wl1251.
Signed-off-by: Sebastian Reichel <sre@debian.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/ti/wl1251/spi.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c index 0a8aacceedd1..b06d36d99362 100644 --- a/drivers/net/wireless/ti/wl1251/spi.c +++ b/drivers/net/wireless/ti/wl1251/spi.c | |||
@@ -27,6 +27,8 @@ | |||
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 | #include <linux/gpio.h> |
30 | #include <linux/of.h> | ||
31 | #include <linux/of_gpio.h> | ||
30 | #include <linux/regulator/consumer.h> | 32 | #include <linux/regulator/consumer.h> |
31 | 33 | ||
32 | #include "wl1251.h" | 34 | #include "wl1251.h" |
@@ -240,13 +242,13 @@ static const struct wl1251_if_operations wl1251_spi_ops = { | |||
240 | 242 | ||
241 | static int wl1251_spi_probe(struct spi_device *spi) | 243 | static int wl1251_spi_probe(struct spi_device *spi) |
242 | { | 244 | { |
243 | struct wl1251_platform_data *pdata; | 245 | struct wl1251_platform_data *pdata = dev_get_platdata(&spi->dev); |
246 | struct device_node *np = spi->dev.of_node; | ||
244 | struct ieee80211_hw *hw; | 247 | struct ieee80211_hw *hw; |
245 | struct wl1251 *wl; | 248 | struct wl1251 *wl; |
246 | int ret; | 249 | int ret; |
247 | 250 | ||
248 | pdata = dev_get_platdata(&spi->dev); | 251 | if (!np && !pdata) { |
249 | if (!pdata) { | ||
250 | wl1251_error("no platform data"); | 252 | wl1251_error("no platform data"); |
251 | return -ENODEV; | 253 | return -ENODEV; |
252 | } | 254 | } |
@@ -273,7 +275,18 @@ static int wl1251_spi_probe(struct spi_device *spi) | |||
273 | goto out_free; | 275 | goto out_free; |
274 | } | 276 | } |
275 | 277 | ||
276 | wl->power_gpio = pdata->power_gpio; | 278 | if (np) { |
279 | wl->use_eeprom = of_property_read_bool(np, "ti,wl1251-has-eeprom"); | ||
280 | wl->power_gpio = of_get_named_gpio(np, "ti,power-gpio", 0); | ||
281 | } else if (pdata) { | ||
282 | wl->power_gpio = pdata->power_gpio; | ||
283 | wl->use_eeprom = pdata->use_eeprom; | ||
284 | } | ||
285 | |||
286 | if (wl->power_gpio == -EPROBE_DEFER) { | ||
287 | ret = -EPROBE_DEFER; | ||
288 | goto out_free; | ||
289 | } | ||
277 | 290 | ||
278 | if (gpio_is_valid(wl->power_gpio)) { | 291 | if (gpio_is_valid(wl->power_gpio)) { |
279 | ret = devm_gpio_request_one(&spi->dev, wl->power_gpio, | 292 | ret = devm_gpio_request_one(&spi->dev, wl->power_gpio, |
@@ -295,8 +308,6 @@ static int wl1251_spi_probe(struct spi_device *spi) | |||
295 | goto out_free; | 308 | goto out_free; |
296 | } | 309 | } |
297 | 310 | ||
298 | wl->use_eeprom = pdata->use_eeprom; | ||
299 | |||
300 | irq_set_status_flags(wl->irq, IRQ_NOAUTOEN); | 311 | irq_set_status_flags(wl->irq, IRQ_NOAUTOEN); |
301 | ret = devm_request_irq(&spi->dev, wl->irq, wl1251_irq, 0, | 312 | ret = devm_request_irq(&spi->dev, wl->irq, wl1251_irq, 0, |
302 | DRIVER_NAME, wl); | 313 | DRIVER_NAME, wl); |