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>
This commit is contained in:
Sebastian Reichel 2014-02-15 00:05:55 +01:00 committed by John W. Linville
parent e4c2e09e15
commit 07bbca6f14
1 changed files with 17 additions and 6 deletions

View File

@ -27,6 +27,8 @@
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/wl12xx.h> #include <linux/wl12xx.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include "wl1251.h" #include "wl1251.h"
@ -240,13 +242,13 @@ static const struct wl1251_if_operations wl1251_spi_ops = {
static int wl1251_spi_probe(struct spi_device *spi) static int wl1251_spi_probe(struct spi_device *spi)
{ {
struct wl1251_platform_data *pdata; struct wl1251_platform_data *pdata = dev_get_platdata(&spi->dev);
struct device_node *np = spi->dev.of_node;
struct ieee80211_hw *hw; struct ieee80211_hw *hw;
struct wl1251 *wl; struct wl1251 *wl;
int ret; int ret;
pdata = dev_get_platdata(&spi->dev); if (!np && !pdata) {
if (!pdata) {
wl1251_error("no platform data"); wl1251_error("no platform data");
return -ENODEV; return -ENODEV;
} }
@ -273,7 +275,18 @@ static int wl1251_spi_probe(struct spi_device *spi)
goto out_free; goto out_free;
} }
wl->power_gpio = pdata->power_gpio; if (np) {
wl->use_eeprom = of_property_read_bool(np, "ti,wl1251-has-eeprom");
wl->power_gpio = of_get_named_gpio(np, "ti,power-gpio", 0);
} else if (pdata) {
wl->power_gpio = pdata->power_gpio;
wl->use_eeprom = pdata->use_eeprom;
}
if (wl->power_gpio == -EPROBE_DEFER) {
ret = -EPROBE_DEFER;
goto out_free;
}
if (gpio_is_valid(wl->power_gpio)) { if (gpio_is_valid(wl->power_gpio)) {
ret = devm_gpio_request_one(&spi->dev, wl->power_gpio, ret = devm_gpio_request_one(&spi->dev, wl->power_gpio,
@ -295,8 +308,6 @@ static int wl1251_spi_probe(struct spi_device *spi)
goto out_free; goto out_free;
} }
wl->use_eeprom = pdata->use_eeprom;
irq_set_status_flags(wl->irq, IRQ_NOAUTOEN); irq_set_status_flags(wl->irq, IRQ_NOAUTOEN);
ret = devm_request_irq(&spi->dev, wl->irq, wl1251_irq, 0, ret = devm_request_irq(&spi->dev, wl->irq, wl1251_irq, 0,
DRIVER_NAME, wl); DRIVER_NAME, wl);