2013-10-27 16:14:58

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 0/4] wl1251 device tree support

Hi,

The following patchset adds device tree support to
the spi variant of the wl1251 driver.

Some notes:

The first patch is from Luciano's wilink DT support
patchset [0].

The third patch (vio regulator support) is optional. N900's
wifi also worked without this patch, but its probably cleaner
to have it.

The patchset has been tested using DT boot with the Nokia N900
and connecting to my wlan access point.

[0] https://lkml.org/lkml/2013/7/3/333

-- Sebastian

Luciano Coelho (1):
wl1251: split wl251 platform data to a separate structure

Sebastian Reichel (3):
wl1251: move power GPIO handling into the driver
wl1251: spi: add vio regulator support
wl1251: spi: add device tree support

.../devicetree/bindings/net/wireless/ti,wl1251.txt | 36 +++++++++++
arch/arm/mach-omap2/board-omap3pandora.c | 6 +-
arch/arm/mach-omap2/board-rx51-peripherals.c | 15 ++---
drivers/net/wireless/ti/wilink_platform_data.c | 37 +++++++++--
drivers/net/wireless/ti/wl1251/sdio.c | 31 +++++++---
drivers/net/wireless/ti/wl1251/spi.c | 71 ++++++++++++++++------
drivers/net/wireless/ti/wl1251/wl1251.h | 4 +-
include/linux/wl12xx.h | 24 +++++++-
8 files changed, 175 insertions(+), 49 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt

--
1.8.4.rc3



2013-10-27 16:14:54

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 1/4] wl1251: split wl251 platform data to a separate structure

From: Luciano Coelho <[email protected]>

Move the wl1251 part of the wl12xx platform data structure into a new
structure specifically for wl1251. Change the platform data built-in
block and board files accordingly.

Cc: Tony Lindgren <[email protected]>
Signed-off-by: Luciano Coelho <[email protected]>
Acked-by: Tony Lindgren <[email protected]>
Reviewed-by: Felipe Balbi <[email protected]>
---
arch/arm/mach-omap2/board-omap3pandora.c | 4 +--
arch/arm/mach-omap2/board-rx51-peripherals.c | 2 +-
drivers/net/wireless/ti/wilink_platform_data.c | 37 +++++++++++++++++++++-----
drivers/net/wireless/ti/wl1251/sdio.c | 12 ++++-----
drivers/net/wireless/ti/wl1251/spi.c | 2 +-
include/linux/wl12xx.h | 22 ++++++++++++++-
6 files changed, 62 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index de1bc6b..24f3c1b 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -536,7 +536,7 @@ static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {

static void __init pandora_wl1251_init(void)
{
- struct wl12xx_platform_data pandora_wl1251_pdata;
+ struct wl1251_platform_data pandora_wl1251_pdata;
int ret;

memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata));
@@ -550,7 +550,7 @@ static void __init pandora_wl1251_init(void)
goto fail_irq;

pandora_wl1251_pdata.use_eeprom = true;
- ret = wl12xx_set_platform_data(&pandora_wl1251_pdata);
+ ret = wl1251_set_platform_data(&pandora_wl1251_pdata);
if (ret < 0)
goto fail_irq;

diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 65e3627..0d8e7d2 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -82,7 +82,7 @@ enum {
RX51_SPI_MIPID, /* LCD panel */
};

-static struct wl12xx_platform_data wl1251_pdata;
+static struct wl1251_platform_data wl1251_pdata;
static struct tsc2005_platform_data tsc2005_pdata;

#if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
diff --git a/drivers/net/wireless/ti/wilink_platform_data.c b/drivers/net/wireless/ti/wilink_platform_data.c
index 998e958..a92bd3e 100644
--- a/drivers/net/wireless/ti/wilink_platform_data.c
+++ b/drivers/net/wireless/ti/wilink_platform_data.c
@@ -23,17 +23,17 @@
#include <linux/err.h>
#include <linux/wl12xx.h>

-static struct wl12xx_platform_data *platform_data;
+static struct wl12xx_platform_data *wl12xx_platform_data;

int __init wl12xx_set_platform_data(const struct wl12xx_platform_data *data)
{
- if (platform_data)
+ if (wl12xx_platform_data)
return -EBUSY;
if (!data)
return -EINVAL;

- platform_data = kmemdup(data, sizeof(*data), GFP_KERNEL);
- if (!platform_data)
+ wl12xx_platform_data = kmemdup(data, sizeof(*data), GFP_KERNEL);
+ if (!wl12xx_platform_data)
return -ENOMEM;

return 0;
@@ -41,9 +41,34 @@ int __init wl12xx_set_platform_data(const struct wl12xx_platform_data *data)

struct wl12xx_platform_data *wl12xx_get_platform_data(void)
{
- if (!platform_data)
+ if (!wl12xx_platform_data)
return ERR_PTR(-ENODEV);

- return platform_data;
+ return wl12xx_platform_data;
}
EXPORT_SYMBOL(wl12xx_get_platform_data);
+
+static struct wl1251_platform_data *wl1251_platform_data;
+
+int __init wl1251_set_platform_data(const struct wl1251_platform_data *data)
+{
+ if (wl1251_platform_data)
+ return -EBUSY;
+ if (!data)
+ return -EINVAL;
+
+ wl1251_platform_data = kmemdup(data, sizeof(*data), GFP_KERNEL);
+ if (!wl1251_platform_data)
+ return -ENOMEM;
+
+ return 0;
+}
+
+struct wl1251_platform_data *wl1251_get_platform_data(void)
+{
+ if (!wl1251_platform_data)
+ return ERR_PTR(-ENODEV);
+
+ return wl1251_platform_data;
+}
+EXPORT_SYMBOL(wl1251_get_platform_data);
diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
index e2b3d9c..b75a37a 100644
--- a/drivers/net/wireless/ti/wl1251/sdio.c
+++ b/drivers/net/wireless/ti/wl1251/sdio.c
@@ -227,7 +227,7 @@ static int wl1251_sdio_probe(struct sdio_func *func,
struct wl1251 *wl;
struct ieee80211_hw *hw;
struct wl1251_sdio *wl_sdio;
- const struct wl12xx_platform_data *wl12xx_board_data;
+ const struct wl1251_platform_data *wl1251_board_data;

hw = wl1251_alloc_hw();
if (IS_ERR(hw))
@@ -254,11 +254,11 @@ static int wl1251_sdio_probe(struct sdio_func *func,
wl->if_priv = wl_sdio;
wl->if_ops = &wl1251_sdio_ops;

- wl12xx_board_data = wl12xx_get_platform_data();
- if (!IS_ERR(wl12xx_board_data)) {
- wl->set_power = wl12xx_board_data->set_power;
- wl->irq = wl12xx_board_data->irq;
- wl->use_eeprom = wl12xx_board_data->use_eeprom;
+ wl1251_board_data = wl1251_get_platform_data();
+ if (!IS_ERR(wl1251_board_data)) {
+ wl->set_power = wl1251_board_data->set_power;
+ wl->irq = wl1251_board_data->irq;
+ wl->use_eeprom = wl1251_board_data->use_eeprom;
}

if (wl->irq) {
diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c
index c7dc6fe..6bbbfe6 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -238,7 +238,7 @@ static const struct wl1251_if_operations wl1251_spi_ops = {

static int wl1251_spi_probe(struct spi_device *spi)
{
- struct wl12xx_platform_data *pdata;
+ struct wl1251_platform_data *pdata;
struct ieee80211_hw *hw;
struct wl1251 *wl;
int ret;
diff --git a/include/linux/wl12xx.h b/include/linux/wl12xx.h
index a54fe82..b516b4f 100644
--- a/include/linux/wl12xx.h
+++ b/include/linux/wl12xx.h
@@ -48,11 +48,15 @@ enum {
WL12XX_TCXOCLOCK_33_6 = 7, /* 33.6 MHz */
};

-struct wl12xx_platform_data {
+struct wl1251_platform_data {
void (*set_power)(bool enable);
/* SDIO only: IRQ number if WLAN_IRQ line is used, 0 for SDIO IRQs */
int irq;
bool use_eeprom;
+};
+
+struct wl12xx_platform_data {
+ int irq;
int board_ref_clock;
int board_tcxo_clock;
unsigned long platform_quirks;
@@ -68,6 +72,10 @@ int wl12xx_set_platform_data(const struct wl12xx_platform_data *data);

struct wl12xx_platform_data *wl12xx_get_platform_data(void);

+int wl1251_set_platform_data(const struct wl1251_platform_data *data);
+
+struct wl1251_platform_data *wl1251_get_platform_data(void);
+
#else

static inline
@@ -82,6 +90,18 @@ struct wl12xx_platform_data *wl12xx_get_platform_data(void)
return ERR_PTR(-ENODATA);
}

+static inline
+int wl1251_set_platform_data(const struct wl1251_platform_data *data)
+{
+ return -ENOSYS;
+}
+
+static inline
+struct wl1251_platform_data *wl1251_get_platform_data(void)
+{
+ return ERR_PTR(-ENODATA);
+}
+
#endif

#endif
--
1.8.4.rc3


2013-10-28 17:15:34

by Grazvydas Ignotas

[permalink] [raw]
Subject: Re: [PATCH 4/4] wl1251: spi: add device tree support

On Mon, Oct 28, 2013 at 8:37 AM, Kumar Gala <[email protected]> wrote:
> On Oct 27, 2013, at 11:14 AM, Sebastian Reichel wrote:
> > +++ b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
> > @@ -0,0 +1,36 @@
> > +* Texas Instruments wl1251 controller
> > +
> > +The wl1251 chip can be connected via SPI or via SDIO. The linux
> > +kernel currently only supports device tree for the SPI variant.
> > +
>
> From the binding I have no idea what this chip actually does, also we don't normally reference linux kernel support in bindings specs (so please remove it).
>
> However, what would expect the SDIO binding to look like? Or more specifically, how would you distinguish the SPI vs SDIO binding/connection? I'm wondering if the compatible should be something like "ti,wl1251-spi" and than the sdio can be "ti,wl1251-sdio"

When connected to SDIO, it doesn't act as standard SDIO device and
can't be probed (standard SDIO registers missing), so information has
to come some other way. That used to partially come through
platform_data and partially through a callback from mmc subsystem (see
pandora_wl1251_init_card() in
arch/arm/mach-omap2/board-omap3pandora.c). I don't know much about DT,
but maybe the information that comes from SDIO registers on "normal"
SDIO devices should come through DT in this case too? I don't really
know how that should be integrated with mmc subsystem though..

> > +Required properties:
> > +- compatible : Should be "ti,wl1251"
>
> reg is not listed as a required prop.
>
> > +- interrupts : Should contain interrupt line
> > +- interrupt-parent : Should be the phandle for the interrupt
> > + controller that services interrupts for this device
> > +- vio-supply : phandle to regulator providing VIO
> > +- power-gpio : GPIO connected to chip's PMEN pin
>
> should be vendor prefixed: ti,power-gpio
>
> > +- For additional required properties on SPI, please consult
> > + Documentation/devicetree/bindings/spi/spi-bus.txt
> > +
> > +Optional properties:
> > +- ti,use-eeprom : If found, configuration will be loaded from eeprom.
>
> can you be a bit more specific on what cfg will be loaded. Also, is this property a boolean, if so how do I know which eeprom the cfg is loaded from (is it one that is directly connected to the wl1251?

wl1251 is a wifi chip that can have an optional eeprom connected to it
to store things like calibration stuff and MAC address, and that
eeprom is usually inside a single module with some additional radio
related chips. If the eeprom is connected (like the module on pandora
board has), the driver can issue command to the firmware running on
chip to load that data on it's startup, alternatively the driver can
load calibration from other storage (like it happens on N900).


GraÅžvydas

2013-10-29 08:28:41

by Kumar Gala

[permalink] [raw]
Subject: Re: [PATCH 4/4] wl1251: spi: add device tree support


On Oct 28, 2013, at 5:38 PM, Tomasz Figa wrote:

> On Monday 28 of October 2013 01:37:34 Kumar Gala wrote:
>> On Oct 27, 2013, at 11:14 AM, Sebastian Reichel wrote:
>>> Add device tree support for the spi variant of wl1251
>>> and document the binding.
>>>
>>> Signed-off-by: Sebastian Reichel <[email protected]>
>>> ---
>>> .../devicetree/bindings/net/wireless/ti,wl1251.txt | 36
>>> ++++++++++++++++++++++ drivers/net/wireless/ti/wl1251/spi.c
>>> | 23 ++++++++++---- 2 files changed, 53 insertions(+), 6
>>> deletions(-)
>>> create mode 100644
>>> Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
>>>
>>> diff --git
>>> a/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
>>> b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt new
>>> file mode 100644
>>> index 0000000..5f8a154
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
>>> @@ -0,0 +1,36 @@
>>> +* Texas Instruments wl1251 controller
>>> +
>>> +The wl1251 chip can be connected via SPI or via SDIO. The linux
>>> +kernel currently only supports device tree for the SPI variant.
>>> +
>>
>> From the binding I have no idea what this chip actually does, also we
>> don't normally reference linux kernel support in bindings specs (so
>> please remove it).
>>
>> However, what would expect the SDIO binding to look like? Or more
>> specifically, how would you distinguish the SPI vs SDIO
>> binding/connection? I'm wondering if the compatible should be
>> something like "ti,wl1251-spi" and than the sdio can be
>> "ti,wl1251-sdio"
>
> Well, you can easily distinguish an SDIO device from an SPI device by its
> parent node, but...
>
> The binding for SDIO might require different set of properties (other than
> ones inherited from generic SDIO or SPI bindings) than one for SPI. So
> probably different compatible values might be justified.
>
> Did we already have such case before? (maybe some I2C + SPI devices?)
>
>>> +Required properties:
>>> +- compatible : Should be "ti,wl1251"
>>
>> reg is not listed as a required prop.
>
> It is implied by SPI bindings, but it might be a good idea to have this
> stated here as well.
>
>>
>>> +- interrupts : Should contain interrupt line
>>> +- interrupt-parent : Should be the phandle for the interrupt
>>> + controller that services interrupts for this device
>>> +- vio-supply : phandle to regulator providing VIO
>>> +- power-gpio : GPIO connected to chip's PMEN pin
>>
>> should be vendor prefixed: ti,power-gpio
>
> Hmm, out of curiosity, is it a rule for this kind of properties? I can see
> both cases with and without prefixes when grepping for "-gpios" in
> Documentation/devicetree/bindings. We should really have such things
> written down somewhere.

Agreed, it should be part of the various docs we are suppose to produce for review and binding creation guidelines.

>>> +- For additional required properties on SPI, please consult
>>> + Documentation/devicetree/bindings/spi/spi-bus.txt
>>> +
>>> +Optional properties:
>>> +- ti,use-eeprom : If found, configuration will be loaded from eeprom.
>>
>> can you be a bit more specific on what cfg will be loaded. Also, is
>> this property a boolean, if so how do I know which eeprom the cfg is
>> loaded from (is it one that is directly connected to the wl1251?
>
> Maybe one from ti,has-eeprom or ti,config-eeprom would be better name for
> this property?

Probably, ti,wl1251-has-eeprom or something like that would be better. However, I'm not going to get too caught up on names of properties.

- k

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation


2013-10-28 06:37:37

by Kumar Gala

[permalink] [raw]
Subject: Re: [PATCH 4/4] wl1251: spi: add device tree support


On Oct 27, 2013, at 11:14 AM, Sebastian Reichel wrote:

> Add device tree support for the spi variant of wl1251
> and document the binding.
>
> Signed-off-by: Sebastian Reichel <[email protected]>
> ---
> .../devicetree/bindings/net/wireless/ti,wl1251.txt | 36 ++++++++++++++++++++++
> drivers/net/wireless/ti/wl1251/spi.c | 23 ++++++++++----
> 2 files changed, 53 insertions(+), 6 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
>
> diff --git a/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
> new file mode 100644
> index 0000000..5f8a154
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
> @@ -0,0 +1,36 @@
> +* Texas Instruments wl1251 controller
> +
> +The wl1251 chip can be connected via SPI or via SDIO. The linux
> +kernel currently only supports device tree for the SPI variant.
> +

>From the binding I have no idea what this chip actually does, also we don't normally reference linux kernel support in bindings specs (so please remove it).

However, what would expect the SDIO binding to look like? Or more specifically, how would you distinguish the SPI vs SDIO binding/connection? I'm wondering if the compatible should be something like "ti,wl1251-spi" and than the sdio can be "ti,wl1251-sdio"

> +Required properties:
> +- compatible : Should be "ti,wl1251"

reg is not listed as a required prop.

> +- interrupts : Should contain interrupt line
> +- interrupt-parent : Should be the phandle for the interrupt
> + controller that services interrupts for this device
> +- vio-supply : phandle to regulator providing VIO
> +- power-gpio : GPIO connected to chip's PMEN pin

should be vendor prefixed: ti,power-gpio

> +- For additional required properties on SPI, please consult
> + Documentation/devicetree/bindings/spi/spi-bus.txt
> +
> +Optional properties:
> +- ti,use-eeprom : If found, configuration will be loaded from eeprom.

can you be a bit more specific on what cfg will be loaded. Also, is this property a boolean, if so how do I know which eeprom the cfg is loaded from (is it one that is directly connected to the wl1251?

> +
> +Examples:
> +
> +&spi1 {
> + wl1251_spi@0 {
> + compatible = "ti,wl1251";
> +
> + reg = <0>;
> + spi-max-frequency = <48000000>;
> + spi-cpol;
> + spi-cpha;
> +
> + interrupt-parent = <&gpio2>;
> + interrupts = <10 IRQ_TYPE_NONE>; /* gpio line 42 */
> +
> + vio-supply = <&vio>;
> + power-gpio = <&gpio3 23 GPIO_ACTIVE_HIGH>; /* 87 */
> + };
> +};

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation


2013-10-28 22:38:40

by Tomasz Figa

[permalink] [raw]
Subject: Re: [PATCH 4/4] wl1251: spi: add device tree support

On Monday 28 of October 2013 01:37:34 Kumar Gala wrote:
> On Oct 27, 2013, at 11:14 AM, Sebastian Reichel wrote:
> > Add device tree support for the spi variant of wl1251
> > and document the binding.
> >
> > Signed-off-by: Sebastian Reichel <[email protected]>
> > ---
> > .../devicetree/bindings/net/wireless/ti,wl1251.txt | 36
> > ++++++++++++++++++++++ drivers/net/wireless/ti/wl1251/spi.c
> > | 23 ++++++++++---- 2 files changed, 53 insertions(+), 6
> > deletions(-)
> > create mode 100644
> > Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
> >
> > diff --git
> > a/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
> > b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt new
> > file mode 100644
> > index 0000000..5f8a154
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
> > @@ -0,0 +1,36 @@
> > +* Texas Instruments wl1251 controller
> > +
> > +The wl1251 chip can be connected via SPI or via SDIO. The linux
> > +kernel currently only supports device tree for the SPI variant.
> > +
>
> From the binding I have no idea what this chip actually does, also we
> don't normally reference linux kernel support in bindings specs (so
> please remove it).
>
> However, what would expect the SDIO binding to look like? Or more
> specifically, how would you distinguish the SPI vs SDIO
> binding/connection? I'm wondering if the compatible should be
> something like "ti,wl1251-spi" and than the sdio can be
> "ti,wl1251-sdio"

Well, you can easily distinguish an SDIO device from an SPI device by its
parent node, but...

The binding for SDIO might require different set of properties (other than
ones inherited from generic SDIO or SPI bindings) than one for SPI. So
probably different compatible values might be justified.

Did we already have such case before? (maybe some I2C + SPI devices?)

> > +Required properties:
> > +- compatible : Should be "ti,wl1251"
>
> reg is not listed as a required prop.

It is implied by SPI bindings, but it might be a good idea to have this
stated here as well.

>
> > +- interrupts : Should contain interrupt line
> > +- interrupt-parent : Should be the phandle for the interrupt
> > + controller that services interrupts for this device
> > +- vio-supply : phandle to regulator providing VIO
> > +- power-gpio : GPIO connected to chip's PMEN pin
>
> should be vendor prefixed: ti,power-gpio

Hmm, out of curiosity, is it a rule for this kind of properties? I can see
both cases with and without prefixes when grepping for "-gpios" in
Documentation/devicetree/bindings. We should really have such things
written down somewhere.

>
> > +- For additional required properties on SPI, please consult
> > + Documentation/devicetree/bindings/spi/spi-bus.txt
> > +
> > +Optional properties:
> > +- ti,use-eeprom : If found, configuration will be loaded from eeprom.
>
> can you be a bit more specific on what cfg will be loaded. Also, is
> this property a boolean, if so how do I know which eeprom the cfg is
> loaded from (is it one that is directly connected to the wl1251?

Maybe one from ti,has-eeprom or ti,config-eeprom would be better name for
this property?

Best regards,
Tomasz


2013-10-28 19:30:48

by Kumar Gala

[permalink] [raw]
Subject: Re: [PATCH 4/4] wl1251: spi: add device tree support


On Oct 28, 2013, at 12:15 PM, Grazvydas Ignotas wrote:

> On Mon, Oct 28, 2013 at 8:37 AM, Kumar Gala <[email protected]> wrote:
>> On Oct 27, 2013, at 11:14 AM, Sebastian Reichel wrote:
>>> +++ b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
>>> @@ -0,0 +1,36 @@
>>> +* Texas Instruments wl1251 controller
>>> +
>>> +The wl1251 chip can be connected via SPI or via SDIO. The linux
>>> +kernel currently only supports device tree for the SPI variant.
>>> +
>>
>> From the binding I have no idea what this chip actually does, also we don't normally reference linux kernel support in bindings specs (so please remove it).
>>
>> However, what would expect the SDIO binding to look like? Or more specifically, how would you distinguish the SPI vs SDIO binding/connection? I'm wondering if the compatible should be something like "ti,wl1251-spi" and than the sdio can be "ti,wl1251-sdio"
>
> When connected to SDIO, it doesn't act as standard SDIO device and
> can't be probed (standard SDIO registers missing), so information has
> to come some other way. That used to partially come through
> platform_data and partially through a callback from mmc subsystem (see
> pandora_wl1251_init_card() in
> arch/arm/mach-omap2/board-omap3pandora.c). I don't know much about DT,
> but maybe the information that comes from SDIO registers on "normal"
> SDIO devices should come through DT in this case too? I don't really
> know how that should be integrated with mmc subsystem though..

Ok, my point is still valid that we can use a different compatible for the SDIO case even if its no standard SDIO vs the SPI case.

>
>>> +Required properties:
>>> +- compatible : Should be "ti,wl1251"
>>
>> reg is not listed as a required prop.
>>
>>> +- interrupts : Should contain interrupt line
>>> +- interrupt-parent : Should be the phandle for the interrupt
>>> + controller that services interrupts for this device
>>> +- vio-supply : phandle to regulator providing VIO
>>> +- power-gpio : GPIO connected to chip's PMEN pin
>>
>> should be vendor prefixed: ti,power-gpio
>>
>>> +- For additional required properties on SPI, please consult
>>> + Documentation/devicetree/bindings/spi/spi-bus.txt
>>> +
>>> +Optional properties:
>>> +- ti,use-eeprom : If found, configuration will be loaded from eeprom.
>>
>> can you be a bit more specific on what cfg will be loaded. Also, is this property a boolean, if so how do I know which eeprom the cfg is loaded from (is it one that is directly connected to the wl1251?
>
> wl1251 is a wifi chip that can have an optional eeprom connected to it
> to store things like calibration stuff and MAC address, and that
> eeprom is usually inside a single module with some additional radio
> related chips. If the eeprom is connected (like the module on pandora
> board has), the driver can issue command to the firmware running on
> chip to load that data on it's startup, alternatively the driver can
> load calibration from other storage (like it happens on N900).

So sounds like a boolean. I think just adding that its a boolean and maybe something like "configuration (calibration data, MAC addr, etc..)"

- k

>
>
> Gra?vydas
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation


2013-10-27 16:14:53

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 4/4] wl1251: spi: add device tree support

Add device tree support for the spi variant of wl1251
and document the binding.

Signed-off-by: Sebastian Reichel <[email protected]>
---
.../devicetree/bindings/net/wireless/ti,wl1251.txt | 36 ++++++++++++++++++++++
drivers/net/wireless/ti/wl1251/spi.c | 23 ++++++++++----
2 files changed, 53 insertions(+), 6 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt

diff --git a/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
new file mode 100644
index 0000000..5f8a154
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
@@ -0,0 +1,36 @@
+* Texas Instruments wl1251 controller
+
+The wl1251 chip can be connected via SPI or via SDIO. The linux
+kernel currently only supports device tree for the SPI variant.
+
+Required properties:
+- compatible : Should be "ti,wl1251"
+- interrupts : Should contain interrupt line
+- interrupt-parent : Should be the phandle for the interrupt
+ controller that services interrupts for this device
+- vio-supply : phandle to regulator providing VIO
+- power-gpio : GPIO connected to chip's PMEN pin
+- For additional required properties on SPI, please consult
+ Documentation/devicetree/bindings/spi/spi-bus.txt
+
+Optional properties:
+- ti,use-eeprom : If found, configuration will be loaded from eeprom.
+
+Examples:
+
+&spi1 {
+ wl1251_spi@0 {
+ compatible = "ti,wl1251";
+
+ reg = <0>;
+ spi-max-frequency = <48000000>;
+ spi-cpol;
+ spi-cpha;
+
+ interrupt-parent = <&gpio2>;
+ interrupts = <10 IRQ_TYPE_NONE>; /* gpio line 42 */
+
+ vio-supply = <&vio>;
+ power-gpio = <&gpio3 23 GPIO_ACTIVE_HIGH>; /* 87 */
+ };
+};
diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c
index efea57a..ee6ce4c 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -27,6 +27,8 @@
#include <linux/spi/spi.h>
#include <linux/wl12xx.h>
#include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
#include <linux/regulator/consumer.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)
{
- struct wl1251_platform_data *pdata;
+ struct wl1251_platform_data *pdata = spi->dev.platform_data;
+ struct device_node *np = spi->dev.of_node;
struct ieee80211_hw *hw;
struct wl1251 *wl;
int ret;

- pdata = spi->dev.platform_data;
- if (!pdata) {
+ if (!np && !pdata) {
wl1251_error("no platform data");
return -ENODEV;
}
@@ -273,7 +275,18 @@ static int wl1251_spi_probe(struct spi_device *spi)
goto out_free;
}

- wl->power_gpio = pdata->power_gpio;
+ if (np) {
+ wl->use_eeprom = of_property_read_bool(np, "ti,use-eeprom");
+ wl->power_gpio = of_get_named_gpio(np, "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)) {
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;
}

- wl->use_eeprom = pdata->use_eeprom;
-
irq_set_status_flags(wl->irq, IRQ_NOAUTOEN);
ret = devm_request_irq(&spi->dev, wl->irq, wl1251_irq, 0,
DRIVER_NAME, wl);
--
1.8.4.rc3


2013-10-27 16:14:53

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 3/4] wl1251: spi: add vio regulator support

This patch adds support for requesting the regulator powering
the vio pin.

The patch also adds the regulator for the all boards using the
wl1251 in spi mode (only the Nokia N900).

Signed-off-by: Sebastian Reichel <[email protected]>
---
arch/arm/mach-omap2/board-rx51-peripherals.c | 2 ++
drivers/net/wireless/ti/wl1251/spi.c | 19 +++++++++++++++++--
drivers/net/wireless/ti/wl1251/wl1251.h | 2 ++
3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index b9d95dd..a791fef 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -552,6 +552,8 @@ static struct regulator_consumer_supply rx51_vio_supplies[] = {
REGULATOR_SUPPLY("vio", "2-0063"),
/* lis3lv02d */
REGULATOR_SUPPLY("Vdd_IO", "3-001d"),
+ /* wl1251 */
+ REGULATOR_SUPPLY("vio", "spi4.0"),
};

static struct regulator_consumer_supply rx51_vaux1_consumers[] = {
diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c
index 9a2df9d..efea57a 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -27,6 +27,7 @@
#include <linux/spi/spi.h>
#include <linux/wl12xx.h>
#include <linux/gpio.h>
+#include <linux/regulator/consumer.h>

#include "wl1251.h"
#include "reg.h"
@@ -306,13 +307,26 @@ static int wl1251_spi_probe(struct spi_device *spi)

irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);

- ret = wl1251_init_ieee80211(wl);
+ wl->vio = devm_regulator_get(&spi->dev, "vio");
+ if (IS_ERR(wl->vio)) {
+ ret = PTR_ERR(wl->vio);
+ wl1251_error("vio regulator missing: %d", ret);
+ goto out_free;
+ }
+
+ ret = regulator_enable(wl->vio);
if (ret)
goto out_free;

+ ret = wl1251_init_ieee80211(wl);
+ if (ret)
+ goto disable_regulator;
+
return 0;

- out_free:
+disable_regulator:
+ regulator_disable(wl->vio);
+out_free:
ieee80211_free_hw(hw);

return ret;
@@ -324,6 +338,7 @@ static int wl1251_spi_remove(struct spi_device *spi)

free_irq(wl->irq, wl);
wl1251_free_hw(wl);
+ regulator_disable(wl->vio);

return 0;
}
diff --git a/drivers/net/wireless/ti/wl1251/wl1251.h b/drivers/net/wireless/ti/wl1251/wl1251.h
index 5e9808c..010718b 100644
--- a/drivers/net/wireless/ti/wl1251/wl1251.h
+++ b/drivers/net/wireless/ti/wl1251/wl1251.h
@@ -279,6 +279,8 @@ struct wl1251 {
int irq;
bool use_eeprom;

+ struct regulator *vio;
+
spinlock_t wl_lock;

enum wl1251_state state;
--
1.8.4.rc3


2013-10-27 16:14:53

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 2/4] 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 <[email protected]>
---
arch/arm/mach-omap2/board-omap3pandora.c | 2 ++
arch/arm/mach-omap2/board-rx51-peripherals.c | 11 ++--------
drivers/net/wireless/ti/wl1251/sdio.c | 21 +++++++++++++-----
drivers/net/wireless/ti/wl1251/spi.c | 33 ++++++++++++++++++----------
drivers/net/wireless/ti/wl1251/wl1251.h | 2 +-
include/linux/wl12xx.h | 2 +-
6 files changed, 43 insertions(+), 28 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index 24f3c1b..cf18340 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -541,6 +541,8 @@ static void __init pandora_wl1251_init(void)

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");
if (ret < 0)
goto fail;
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 0d8e7d2..b9d95dd 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -1164,13 +1164,7 @@ static inline void board_smc91x_init(void)

#endif

-static void rx51_wl1251_set_power(bool enable)
-{
- gpio_set_value(RX51_WL1251_POWER_GPIO, enable);
-}
-
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" },
};

@@ -1187,17 +1181,16 @@ static void __init rx51_init_wl1251(void)
if (irq < 0)
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;

return;

err_irq:
gpio_free(RX51_WL1251_IRQ_GPIO);
- gpio_free(RX51_WL1251_POWER_GPIO);
error:
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
diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
index b75a37a..b661f89 100644
--- a/drivers/net/wireless/ti/wl1251/sdio.c
+++ b/drivers/net/wireless/ti/wl1251/sdio.c
@@ -28,6 +28,7 @@
#include <linux/wl12xx.h>
#include <linux/irq.h>
#include <linux/pm_runtime.h>
+#include <linux/gpio.h>

#include "wl1251.h"

@@ -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,
* for example enabling clock buffer for the module.
*/
- if (wl->set_power)
- wl->set_power(true);
+ if (gpio_is_valid(wl->power_gpio))
+ gpio_set_value(wl->power_gpio, true);
+

ret = pm_runtime_get_sync(&func->dev);
if (ret < 0) {
@@ -203,8 +205,8 @@ static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable)
if (ret < 0)
goto out;

- if (wl->set_power)
- wl->set_power(false);
+ if (gpio_is_valid(wl->power_gpio))
+ gpio_set_value(wl->power_gpio, false);
}

out:
@@ -256,11 +258,20 @@ static int wl1251_sdio_probe(struct sdio_func *func,

wl1251_board_data = wl1251_get_platform_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->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) {
irq_set_status_flags(wl->irq, IRQ_NOAUTOEN);
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 6bbbfe6..9a2df9d 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -26,6 +26,7 @@
#include <linux/crc7.h>
#include <linux/spi/spi.h>
#include <linux/wl12xx.h>
+#include <linux/gpio.h>

#include "wl1251.h"
#include "reg.h"
@@ -221,8 +222,8 @@ static void wl1251_spi_disable_irq(struct wl1251 *wl)

static int wl1251_spi_set_power(struct wl1251 *wl, bool enable)
{
- if (wl->set_power)
- wl->set_power(enable);
+ if (gpio_is_valid(wl->power_gpio))
+ gpio_set_value(wl->power_gpio, enable);

return 0;
}
@@ -271,22 +272,33 @@ static int wl1251_spi_probe(struct spi_device *spi)
goto out_free;
}

- wl->set_power = pdata->set_power;
- if (!wl->set_power) {
- wl1251_error("set power function missing in platform data");
- return -ENODEV;
+ wl->power_gpio = pdata->power_gpio;
+
+ if (gpio_is_valid(wl->power_gpio)) {
+ 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;
if (wl->irq < 0) {
wl1251_error("irq missing in platform data");
- return -ENODEV;
+ ret = -ENODEV;
+ goto out_free;
}

wl->use_eeprom = pdata->use_eeprom;

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) {
wl1251_error("request_irq() failed: %d", ret);
goto out_free;
@@ -296,13 +308,10 @@ static int wl1251_spi_probe(struct spi_device *spi)

ret = wl1251_init_ieee80211(wl);
if (ret)
- goto out_irq;
+ goto out_free;

return 0;

- out_irq:
- free_irq(wl->irq, wl);
-
out_free:
ieee80211_free_hw(hw);

diff --git a/drivers/net/wireless/ti/wl1251/wl1251.h b/drivers/net/wireless/ti/wl1251/wl1251.h
index fd02060..5e9808c 100644
--- a/drivers/net/wireless/ti/wl1251/wl1251.h
+++ b/drivers/net/wireless/ti/wl1251/wl1251.h
@@ -275,7 +275,7 @@ struct wl1251 {
void *if_priv;
const struct wl1251_if_operations *if_ops;

- void (*set_power)(bool enable);
+ int power_gpio;
int irq;
bool use_eeprom;

diff --git a/include/linux/wl12xx.h b/include/linux/wl12xx.h
index b516b4f..a9c723b 100644
--- a/include/linux/wl12xx.h
+++ b/include/linux/wl12xx.h
@@ -49,7 +49,7 @@ enum {
};

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 */
int irq;
bool use_eeprom;
--
1.8.4.rc3


2013-11-05 12:13:55

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 1/4] wl1251: split wl251 platform data to a separate structure

On Sun 2013-10-27 17:14:26, Sebastian Reichel wrote:
> From: Luciano Coelho <[email protected]>
>
> Move the wl1251 part of the wl12xx platform data structure into a new
> structure specifically for wl1251. Change the platform data built-in
> block and board files accordingly.
>
> Cc: Tony Lindgren <[email protected]>
> Signed-off-by: Luciano Coelho <[email protected]>
> Acked-by: Tony Lindgren <[email protected]>
> Reviewed-by: Felipe Balbi <[email protected]>

Reviewed-by: Pavel Machek <[email protected]>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2013-11-14 23:22:38

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 1/4] wl1251: split wl251 platform data to a separate structure

* Sebastian Reichel <[email protected]> [131114 15:04]:
> On Thu, Nov 14, 2013 at 10:51:33AM -0800, Tony Lindgren wrote:
> > [...]
> >
> > If this is not going into v3.13, these will cause conflicts
> > with the mach-omap2/board-*.c files for v3.14.
> >
> > So it might be best to do a minimal header patch first that
> > can be merged in by both linux-omap and wireless trees.
>
> I guess this patch is pretty minimal. It also seems to be acked by
> the involved Maintainers, so maybe just merge Patch 1 without the
> other patches?
>
> This does not solve the problem with the struct modification from
> the second patch, but I guess it's the more intrusive patch.

Once at least the first two patches are ready, how about I queue
them after -rc1 and set up an immutable branch that can be merged
in by linux-omap tree and the wireless tree?

Regards,

Tony

2013-11-05 13:11:34

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 2/4] wl1251: move power GPIO handling into the driver

On Sun 2013-10-27 17:14:27, Sebastian Reichel wrote:
> 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 <[email protected]>

Reviewed-by: Pavel Machek <[email protected]>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2013-11-14 23:03:51

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 1/4] wl1251: split wl251 platform data to a separate structure

On Thu, Nov 14, 2013 at 10:51:33AM -0800, Tony Lindgren wrote:
> [...]
>
> If this is not going into v3.13, these will cause conflicts
> with the mach-omap2/board-*.c files for v3.14.
>
> So it might be best to do a minimal header patch first that
> can be merged in by both linux-omap and wireless trees.

I guess this patch is pretty minimal. It also seems to be acked by
the involved Maintainers, so maybe just merge Patch 1 without the
other patches?

This does not solve the problem with the struct modification from
the second patch, but I guess it's the more intrusive patch.

-- Sebastian


Attachments:
(No filename) (598.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2013-11-15 14:56:34

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 1/4] wl1251: split wl251 platform data to a separate structure

On Fri, Nov 15, 2013 at 09:32:55AM -0500, John W. Linville wrote:
> On Thu, Nov 14, 2013 at 03:22:18PM -0800, Tony Lindgren wrote:
> > * Sebastian Reichel <[email protected]> [131114 15:04]:
> > > On Thu, Nov 14, 2013 at 10:51:33AM -0800, Tony Lindgren wrote:
> > > > [...]
> > > >
> > > > If this is not going into v3.13, these will cause conflicts
> > > > with the mach-omap2/board-*.c files for v3.14.
> > > >
> > > > So it might be best to do a minimal header patch first that
> > > > can be merged in by both linux-omap and wireless trees.
> > >
> > > I guess this patch is pretty minimal. It also seems to be acked by
> > > the involved Maintainers, so maybe just merge Patch 1 without the
> > > other patches?
> > >
> > > This does not solve the problem with the struct modification from
> > > the second patch, but I guess it's the more intrusive patch.
> >
> > Once at least the first two patches are ready, how about I queue
> > them after -rc1 and set up an immutable branch that can be merged
> > in by linux-omap tree and the wireless tree?
>
> That sounds reasonable to me.

So what changes do you request for those patches? I will try to
update them as soon as possible.

-- Sebastian


Attachments:
(No filename) (1.17 kB)
signature.asc (836.00 B)
Digital signature
Download all attachments

2013-11-05 13:12:34

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 3/4] wl1251: spi: add vio regulator support

On Sun 2013-10-27 17:14:28, Sebastian Reichel wrote:
> This patch adds support for requesting the regulator powering
> the vio pin.
>
> The patch also adds the regulator for the all boards using the
> wl1251 in spi mode (only the Nokia N900).
>
> Signed-off-by: Sebastian Reichel <[email protected]>

Reviewed-by: Pavel Machek <[email protected]>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2013-11-15 14:45:33

by John W. Linville

[permalink] [raw]
Subject: Re: [PATCH 1/4] wl1251: split wl251 platform data to a separate structure

On Thu, Nov 14, 2013 at 03:22:18PM -0800, Tony Lindgren wrote:
> * Sebastian Reichel <[email protected]> [131114 15:04]:
> > On Thu, Nov 14, 2013 at 10:51:33AM -0800, Tony Lindgren wrote:
> > > [...]
> > >
> > > If this is not going into v3.13, these will cause conflicts
> > > with the mach-omap2/board-*.c files for v3.14.
> > >
> > > So it might be best to do a minimal header patch first that
> > > can be merged in by both linux-omap and wireless trees.
> >
> > I guess this patch is pretty minimal. It also seems to be acked by
> > the involved Maintainers, so maybe just merge Patch 1 without the
> > other patches?
> >
> > This does not solve the problem with the struct modification from
> > the second patch, but I guess it's the more intrusive patch.
>
> Once at least the first two patches are ready, how about I queue
> them after -rc1 and set up an immutable branch that can be merged
> in by linux-omap tree and the wireless tree?

That sounds reasonable to me.

--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.

2013-11-14 18:51:54

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 1/4] wl1251: split wl251 platform data to a separate structure

* Sebastian Reichel <[email protected]> [131027 09:15]:
> From: Luciano Coelho <[email protected]>
>
> Move the wl1251 part of the wl12xx platform data structure into a new
> structure specifically for wl1251. Change the platform data built-in
> block and board files accordingly.
>
> Cc: Tony Lindgren <[email protected]>
> Signed-off-by: Luciano Coelho <[email protected]>
> Acked-by: Tony Lindgren <[email protected]>
> Reviewed-by: Felipe Balbi <[email protected]>
> ---
> arch/arm/mach-omap2/board-omap3pandora.c | 4 +--
> arch/arm/mach-omap2/board-rx51-peripherals.c | 2 +-
> drivers/net/wireless/ti/wilink_platform_data.c | 37 +++++++++++++++++++++-----
> drivers/net/wireless/ti/wl1251/sdio.c | 12 ++++-----
> drivers/net/wireless/ti/wl1251/spi.c | 2 +-
> include/linux/wl12xx.h | 22 ++++++++++++++-
> 6 files changed, 62 insertions(+), 17 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
> index de1bc6b..24f3c1b 100644
> --- a/arch/arm/mach-omap2/board-omap3pandora.c
> +++ b/arch/arm/mach-omap2/board-omap3pandora.c
> @@ -536,7 +536,7 @@ static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
>
> static void __init pandora_wl1251_init(void)
> {
> - struct wl12xx_platform_data pandora_wl1251_pdata;
> + struct wl1251_platform_data pandora_wl1251_pdata;
> int ret;
>
> memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata));
> @@ -550,7 +550,7 @@ static void __init pandora_wl1251_init(void)
> goto fail_irq;
>
> pandora_wl1251_pdata.use_eeprom = true;
> - ret = wl12xx_set_platform_data(&pandora_wl1251_pdata);
> + ret = wl1251_set_platform_data(&pandora_wl1251_pdata);
> if (ret < 0)
> goto fail_irq;
>
> diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
> index 65e3627..0d8e7d2 100644
> --- a/arch/arm/mach-omap2/board-rx51-peripherals.c
> +++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
> @@ -82,7 +82,7 @@ enum {
> RX51_SPI_MIPID, /* LCD panel */
> };
>
> -static struct wl12xx_platform_data wl1251_pdata;
> +static struct wl1251_platform_data wl1251_pdata;
> static struct tsc2005_platform_data tsc2005_pdata;
>
> #if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)

If this is not going into v3.13, these will cause conflicts
with the mach-omap2/board-*.c files for v3.14.

So it might be best to do a minimal header patch first that
can be merged in by both linux-omap and wireless trees.

Regards,

Tony

2013-12-06 00:22:34

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCHv2 3/5] wl1251: spi: add vio regulator support

This patch adds support for requesting the regulator powering
the vio pin.

Signed-off-by: Sebastian Reichel <[email protected]>
Reviewed-by: Pavel Machek <[email protected]>
---
drivers/net/wireless/ti/wl1251/spi.c | 19 +++++++++++++++++--
drivers/net/wireless/ti/wl1251/wl1251.h | 2 ++
2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c
index 6abcbc3..0a8aacc 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -27,6 +27,7 @@
#include <linux/spi/spi.h>
#include <linux/wl12xx.h>
#include <linux/gpio.h>
+#include <linux/regulator/consumer.h>

#include "wl1251.h"
#include "reg.h"
@@ -306,13 +307,26 @@ static int wl1251_spi_probe(struct spi_device *spi)

irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);

- ret = wl1251_init_ieee80211(wl);
+ wl->vio = devm_regulator_get(&spi->dev, "vio");
+ if (IS_ERR(wl->vio)) {
+ ret = PTR_ERR(wl->vio);
+ wl1251_error("vio regulator missing: %d", ret);
+ goto out_free;
+ }
+
+ ret = regulator_enable(wl->vio);
if (ret)
goto out_free;

+ ret = wl1251_init_ieee80211(wl);
+ if (ret)
+ goto disable_regulator;
+
return 0;

- out_free:
+disable_regulator:
+ regulator_disable(wl->vio);
+out_free:
ieee80211_free_hw(hw);

return ret;
@@ -324,6 +338,7 @@ static int wl1251_spi_remove(struct spi_device *spi)

free_irq(wl->irq, wl);
wl1251_free_hw(wl);
+ regulator_disable(wl->vio);

return 0;
}
diff --git a/drivers/net/wireless/ti/wl1251/wl1251.h b/drivers/net/wireless/ti/wl1251/wl1251.h
index f396a95..b0bfdf5 100644
--- a/drivers/net/wireless/ti/wl1251/wl1251.h
+++ b/drivers/net/wireless/ti/wl1251/wl1251.h
@@ -279,6 +279,8 @@ struct wl1251 {
int irq;
bool use_eeprom;

+ struct regulator *vio;
+
spinlock_t wl_lock;

enum wl1251_state state;
--
1.8.4.3


2013-12-10 03:28:22

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 1/4] wl1251: split wl251 platform data to a separate structure

* John W. Linville <[email protected]> [131115 06:46]:
> On Thu, Nov 14, 2013 at 03:22:18PM -0800, Tony Lindgren wrote:
> > * Sebastian Reichel <[email protected]> [131114 15:04]:
> > > On Thu, Nov 14, 2013 at 10:51:33AM -0800, Tony Lindgren wrote:
> > > > [...]
> > > >
> > > > If this is not going into v3.13, these will cause conflicts
> > > > with the mach-omap2/board-*.c files for v3.14.
> > > >
> > > > So it might be best to do a minimal header patch first that
> > > > can be merged in by both linux-omap and wireless trees.
> > >
> > > I guess this patch is pretty minimal. It also seems to be acked by
> > > the involved Maintainers, so maybe just merge Patch 1 without the
> > > other patches?
> > >
> > > This does not solve the problem with the struct modification from
> > > the second patch, but I guess it's the more intrusive patch.
> >
> > Once at least the first two patches are ready, how about I queue
> > them after -rc1 and set up an immutable branch that can be merged
> > in by linux-omap tree and the wireless tree?
>
> That sounds reasonable to me.

OK sorry it took a while, I was chasing bugs and did not get around
to doing this until now. I've applied only the first two patches from
the v2 set of patches later on in this thread against v3.13-rc1 into
a signed tag wl1251-pdata-signed here:

http://git.kernel.org/cgit/linux/kernel/git/tmlind/linux-omap.git/tag/?id=wl1251-pdata-signed

John, please feel free to pull the branch above also into the wireless
tree so you can apply the remaining wl1251 patches from Sebastian.
This way things keep working without creating merge conflicts with the
linux-omap tree.

Regards,

Tony

2013-12-06 00:22:26

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCHv2 1/5] wl1251: split wl251 platform data to a separate structure

From: Luciano Coelho <[email protected]>

Move the wl1251 part of the wl12xx platform data structure into a new
structure specifically for wl1251. Change the platform data built-in
block and board files accordingly.

Signed-off-by: Luciano Coelho <[email protected]>
Acked-by: Tony Lindgren <[email protected]>
Reviewed-by: Felipe Balbi <[email protected]>
Reviewed-by: Sebastian Reichel <[email protected]>
Reviewed-by: Pavel Machek <[email protected]>
---
arch/arm/mach-omap2/board-omap3pandora.c | 4 +--
arch/arm/mach-omap2/board-rx51-peripherals.c | 2 +-
drivers/net/wireless/ti/wilink_platform_data.c | 37 +++++++++++++++++++++-----
drivers/net/wireless/ti/wl1251/sdio.c | 12 ++++-----
drivers/net/wireless/ti/wl1251/spi.c | 2 +-
include/linux/wl12xx.h | 22 ++++++++++++++-
6 files changed, 62 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index de1bc6b..24f3c1b 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -536,7 +536,7 @@ static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {

static void __init pandora_wl1251_init(void)
{
- struct wl12xx_platform_data pandora_wl1251_pdata;
+ struct wl1251_platform_data pandora_wl1251_pdata;
int ret;

memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata));
@@ -550,7 +550,7 @@ static void __init pandora_wl1251_init(void)
goto fail_irq;

pandora_wl1251_pdata.use_eeprom = true;
- ret = wl12xx_set_platform_data(&pandora_wl1251_pdata);
+ ret = wl1251_set_platform_data(&pandora_wl1251_pdata);
if (ret < 0)
goto fail_irq;

diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index dbf3ae5..01e8bef 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -84,7 +84,7 @@ enum {
RX51_SPI_MIPID, /* LCD panel */
};

-static struct wl12xx_platform_data wl1251_pdata;
+static struct wl1251_platform_data wl1251_pdata;
static struct tsc2005_platform_data tsc2005_pdata;

#if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
diff --git a/drivers/net/wireless/ti/wilink_platform_data.c b/drivers/net/wireless/ti/wilink_platform_data.c
index 998e958..a92bd3e 100644
--- a/drivers/net/wireless/ti/wilink_platform_data.c
+++ b/drivers/net/wireless/ti/wilink_platform_data.c
@@ -23,17 +23,17 @@
#include <linux/err.h>
#include <linux/wl12xx.h>

-static struct wl12xx_platform_data *platform_data;
+static struct wl12xx_platform_data *wl12xx_platform_data;

int __init wl12xx_set_platform_data(const struct wl12xx_platform_data *data)
{
- if (platform_data)
+ if (wl12xx_platform_data)
return -EBUSY;
if (!data)
return -EINVAL;

- platform_data = kmemdup(data, sizeof(*data), GFP_KERNEL);
- if (!platform_data)
+ wl12xx_platform_data = kmemdup(data, sizeof(*data), GFP_KERNEL);
+ if (!wl12xx_platform_data)
return -ENOMEM;

return 0;
@@ -41,9 +41,34 @@ int __init wl12xx_set_platform_data(const struct wl12xx_platform_data *data)

struct wl12xx_platform_data *wl12xx_get_platform_data(void)
{
- if (!platform_data)
+ if (!wl12xx_platform_data)
return ERR_PTR(-ENODEV);

- return platform_data;
+ return wl12xx_platform_data;
}
EXPORT_SYMBOL(wl12xx_get_platform_data);
+
+static struct wl1251_platform_data *wl1251_platform_data;
+
+int __init wl1251_set_platform_data(const struct wl1251_platform_data *data)
+{
+ if (wl1251_platform_data)
+ return -EBUSY;
+ if (!data)
+ return -EINVAL;
+
+ wl1251_platform_data = kmemdup(data, sizeof(*data), GFP_KERNEL);
+ if (!wl1251_platform_data)
+ return -ENOMEM;
+
+ return 0;
+}
+
+struct wl1251_platform_data *wl1251_get_platform_data(void)
+{
+ if (!wl1251_platform_data)
+ return ERR_PTR(-ENODEV);
+
+ return wl1251_platform_data;
+}
+EXPORT_SYMBOL(wl1251_get_platform_data);
diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
index e2b3d9c..b75a37a 100644
--- a/drivers/net/wireless/ti/wl1251/sdio.c
+++ b/drivers/net/wireless/ti/wl1251/sdio.c
@@ -227,7 +227,7 @@ static int wl1251_sdio_probe(struct sdio_func *func,
struct wl1251 *wl;
struct ieee80211_hw *hw;
struct wl1251_sdio *wl_sdio;
- const struct wl12xx_platform_data *wl12xx_board_data;
+ const struct wl1251_platform_data *wl1251_board_data;

hw = wl1251_alloc_hw();
if (IS_ERR(hw))
@@ -254,11 +254,11 @@ static int wl1251_sdio_probe(struct sdio_func *func,
wl->if_priv = wl_sdio;
wl->if_ops = &wl1251_sdio_ops;

- wl12xx_board_data = wl12xx_get_platform_data();
- if (!IS_ERR(wl12xx_board_data)) {
- wl->set_power = wl12xx_board_data->set_power;
- wl->irq = wl12xx_board_data->irq;
- wl->use_eeprom = wl12xx_board_data->use_eeprom;
+ wl1251_board_data = wl1251_get_platform_data();
+ if (!IS_ERR(wl1251_board_data)) {
+ wl->set_power = wl1251_board_data->set_power;
+ wl->irq = wl1251_board_data->irq;
+ wl->use_eeprom = wl1251_board_data->use_eeprom;
}

if (wl->irq) {
diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c
index 1342f81..62403a1 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -238,7 +238,7 @@ static const struct wl1251_if_operations wl1251_spi_ops = {

static int wl1251_spi_probe(struct spi_device *spi)
{
- struct wl12xx_platform_data *pdata;
+ struct wl1251_platform_data *pdata;
struct ieee80211_hw *hw;
struct wl1251 *wl;
int ret;
diff --git a/include/linux/wl12xx.h b/include/linux/wl12xx.h
index a54fe82..b516b4f 100644
--- a/include/linux/wl12xx.h
+++ b/include/linux/wl12xx.h
@@ -48,11 +48,15 @@ enum {
WL12XX_TCXOCLOCK_33_6 = 7, /* 33.6 MHz */
};

-struct wl12xx_platform_data {
+struct wl1251_platform_data {
void (*set_power)(bool enable);
/* SDIO only: IRQ number if WLAN_IRQ line is used, 0 for SDIO IRQs */
int irq;
bool use_eeprom;
+};
+
+struct wl12xx_platform_data {
+ int irq;
int board_ref_clock;
int board_tcxo_clock;
unsigned long platform_quirks;
@@ -68,6 +72,10 @@ int wl12xx_set_platform_data(const struct wl12xx_platform_data *data);

struct wl12xx_platform_data *wl12xx_get_platform_data(void);

+int wl1251_set_platform_data(const struct wl1251_platform_data *data);
+
+struct wl1251_platform_data *wl1251_get_platform_data(void);
+
#else

static inline
@@ -82,6 +90,18 @@ struct wl12xx_platform_data *wl12xx_get_platform_data(void)
return ERR_PTR(-ENODATA);
}

+static inline
+int wl1251_set_platform_data(const struct wl1251_platform_data *data)
+{
+ return -ENOSYS;
+}
+
+static inline
+struct wl1251_platform_data *wl1251_get_platform_data(void)
+{
+ return ERR_PTR(-ENODATA);
+}
+
#endif

#endif
--
1.8.4.3


2013-12-06 00:22:46

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCHv2 5/5] Documentation: dt: wireless: Add wl1251

Add device tree binding documentation for Texas Instrument's wl1251
wireless lan chip. For now only the SPI binding is documented.

Signed-off-by: Sebastian Reichel <[email protected]>
---
.../devicetree/bindings/net/wireless/ti,wl1251.txt | 39 ++++++++++++++++++++++
1 file changed, 39 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt

diff --git a/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
new file mode 100644
index 0000000..189ae5c
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
@@ -0,0 +1,39 @@
+* Texas Instruments wl1251 wireless lan controller
+
+The wl1251 chip can be connected via SPI or via SDIO. This
+document describes the binding for the SPI connected chip.
+
+Required properties:
+- compatible : Should be "ti,wl1251"
+- reg : Chip select address of device
+- spi-max-frequency : Maximum SPI clocking speed of device in Hz
+- interrupts : Should contain interrupt line
+- interrupt-parent : Should be the phandle for the interrupt controller
+ that services interrupts for this device
+- vio-supply : phandle to regulator providing VIO
+- ti,power-gpio : GPIO connected to chip's PMEN pin
+
+Optional properties:
+- ti,wl1251-has-eeprom : boolean, the wl1251 has an eeprom connected, which
+ provides configuration data (calibration, MAC, ...)
+- Please consult Documentation/devicetree/bindings/spi/spi-bus.txt
+ for optional SPI connection related properties,
+
+Examples:
+
+&spi1 {
+ wl1251@0 {
+ compatible = "ti,wl1251";
+
+ reg = <0>;
+ spi-max-frequency = <48000000>;
+ spi-cpol;
+ spi-cpha;
+
+ interrupt-parent = <&gpio2>;
+ interrupts = <10 IRQ_TYPE_NONE>; /* gpio line 42 */
+
+ vio-supply = <&vio>;
+ ti,power-gpio = <&gpio3 23 GPIO_ACTIVE_HIGH>; /* 87 */
+ };
+};
--
1.8.4.3


2013-12-06 00:22:25

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCHv2 0/5] wl1251 device tree support

Hi,

The following patchset adds device tree support to
the spi variant of the wl1251 driver.

Changes since v1 [0]:
* Added some Reviewed-By: Pavel Machek
* Splitted DT binding documentation into its own patch
* Added ti, prefix to power-gpio
* Renamed ti,use-eeprom to ti,wl1251-has-eeprom
* Updated description for ti,wl1251-has-eeprom
* Removed boardcode update from regulator patch to avoid
useless merge conflicts (all relevant boardcode will be
removed in 3.14).

[0] https://lkml.org/lkml/2013/10/27/112

-- Sebastian

Luciano Coelho (1):
wl1251: split wl251 platform data to a separate structure

Sebastian Reichel (4):
wl1251: move power GPIO handling into the driver
wl1251: spi: add vio regulator support
wl1251: spi: add device tree support
Documentation: dt: wireless: Add wl1251

.../devicetree/bindings/net/wireless/ti,wl1251.txt | 39 ++++++++++++
arch/arm/mach-omap2/board-omap3pandora.c | 6 +-
arch/arm/mach-omap2/board-rx51-peripherals.c | 13 +---
drivers/net/wireless/ti/wilink_platform_data.c | 37 +++++++++--
drivers/net/wireless/ti/wl1251/sdio.c | 31 +++++++---
drivers/net/wireless/ti/wl1251/spi.c | 71 ++++++++++++++++------
drivers/net/wireless/ti/wl1251/wl1251.h | 4 +-
include/linux/wl12xx.h | 24 +++++++-
8 files changed, 176 insertions(+), 49 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt

--
1.8.4.3


2013-12-06 00:22:45

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCHv2 2/5] 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 <[email protected]>
Reviewed-by: Pavel Machek <[email protected]>
---
arch/arm/mach-omap2/board-omap3pandora.c | 2 ++
arch/arm/mach-omap2/board-rx51-peripherals.c | 11 ++--------
drivers/net/wireless/ti/wl1251/sdio.c | 21 +++++++++++++-----
drivers/net/wireless/ti/wl1251/spi.c | 33 ++++++++++++++++++----------
drivers/net/wireless/ti/wl1251/wl1251.h | 2 +-
include/linux/wl12xx.h | 2 +-
6 files changed, 43 insertions(+), 28 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index 24f3c1b..cf18340 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -541,6 +541,8 @@ static void __init pandora_wl1251_init(void)

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");
if (ret < 0)
goto fail;
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 01e8bef..6538184 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -1166,13 +1166,7 @@ static inline void board_smc91x_init(void)

#endif

-static void rx51_wl1251_set_power(bool enable)
-{
- gpio_set_value(RX51_WL1251_POWER_GPIO, enable);
-}
-
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" },
};

@@ -1189,17 +1183,16 @@ static void __init rx51_init_wl1251(void)
if (irq < 0)
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;

return;

err_irq:
gpio_free(RX51_WL1251_IRQ_GPIO);
- gpio_free(RX51_WL1251_POWER_GPIO);
error:
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
diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
index b75a37a..b661f89 100644
--- a/drivers/net/wireless/ti/wl1251/sdio.c
+++ b/drivers/net/wireless/ti/wl1251/sdio.c
@@ -28,6 +28,7 @@
#include <linux/wl12xx.h>
#include <linux/irq.h>
#include <linux/pm_runtime.h>
+#include <linux/gpio.h>

#include "wl1251.h"

@@ -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,
* for example enabling clock buffer for the module.
*/
- if (wl->set_power)
- wl->set_power(true);
+ if (gpio_is_valid(wl->power_gpio))
+ gpio_set_value(wl->power_gpio, true);
+

ret = pm_runtime_get_sync(&func->dev);
if (ret < 0) {
@@ -203,8 +205,8 @@ static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable)
if (ret < 0)
goto out;

- if (wl->set_power)
- wl->set_power(false);
+ if (gpio_is_valid(wl->power_gpio))
+ gpio_set_value(wl->power_gpio, false);
}

out:
@@ -256,11 +258,20 @@ static int wl1251_sdio_probe(struct sdio_func *func,

wl1251_board_data = wl1251_get_platform_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->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) {
irq_set_status_flags(wl->irq, IRQ_NOAUTOEN);
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 62403a1..6abcbc3 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -26,6 +26,7 @@
#include <linux/crc7.h>
#include <linux/spi/spi.h>
#include <linux/wl12xx.h>
+#include <linux/gpio.h>

#include "wl1251.h"
#include "reg.h"
@@ -221,8 +222,8 @@ static void wl1251_spi_disable_irq(struct wl1251 *wl)

static int wl1251_spi_set_power(struct wl1251 *wl, bool enable)
{
- if (wl->set_power)
- wl->set_power(enable);
+ if (gpio_is_valid(wl->power_gpio))
+ gpio_set_value(wl->power_gpio, enable);

return 0;
}
@@ -271,22 +272,33 @@ static int wl1251_spi_probe(struct spi_device *spi)
goto out_free;
}

- wl->set_power = pdata->set_power;
- if (!wl->set_power) {
- wl1251_error("set power function missing in platform data");
- return -ENODEV;
+ wl->power_gpio = pdata->power_gpio;
+
+ if (gpio_is_valid(wl->power_gpio)) {
+ 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;
if (wl->irq < 0) {
wl1251_error("irq missing in platform data");
- return -ENODEV;
+ ret = -ENODEV;
+ goto out_free;
}

wl->use_eeprom = pdata->use_eeprom;

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) {
wl1251_error("request_irq() failed: %d", ret);
goto out_free;
@@ -296,13 +308,10 @@ static int wl1251_spi_probe(struct spi_device *spi)

ret = wl1251_init_ieee80211(wl);
if (ret)
- goto out_irq;
+ goto out_free;

return 0;

- out_irq:
- free_irq(wl->irq, wl);
-
out_free:
ieee80211_free_hw(hw);

diff --git a/drivers/net/wireless/ti/wl1251/wl1251.h b/drivers/net/wireless/ti/wl1251/wl1251.h
index 2c3bd1b..f396a95 100644
--- a/drivers/net/wireless/ti/wl1251/wl1251.h
+++ b/drivers/net/wireless/ti/wl1251/wl1251.h
@@ -275,7 +275,7 @@ struct wl1251 {
void *if_priv;
const struct wl1251_if_operations *if_ops;

- void (*set_power)(bool enable);
+ int power_gpio;
int irq;
bool use_eeprom;

diff --git a/include/linux/wl12xx.h b/include/linux/wl12xx.h
index b516b4f..a9c723b 100644
--- a/include/linux/wl12xx.h
+++ b/include/linux/wl12xx.h
@@ -49,7 +49,7 @@ enum {
};

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 */
int irq;
bool use_eeprom;
--
1.8.4.3


2013-12-06 00:22:42

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCHv2 4/5] wl1251: spi: add device tree support

Add device tree support for the spi variant of wl1251.

Signed-off-by: Sebastian Reichel <[email protected]>
---
drivers/net/wireless/ti/wl1251/spi.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c
index 0a8aacc..b06d36d 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -27,6 +27,8 @@
#include <linux/spi/spi.h>
#include <linux/wl12xx.h>
#include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
#include <linux/regulator/consumer.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)
{
- 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 wl1251 *wl;
int ret;

- pdata = dev_get_platdata(&spi->dev);
- if (!pdata) {
+ if (!np && !pdata) {
wl1251_error("no platform data");
return -ENODEV;
}
@@ -273,7 +275,18 @@ static int wl1251_spi_probe(struct spi_device *spi)
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)) {
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;
}

- wl->use_eeprom = pdata->use_eeprom;
-
irq_set_status_flags(wl->irq, IRQ_NOAUTOEN);
ret = devm_request_irq(&spi->dev, wl->irq, wl1251_irq, 0,
DRIVER_NAME, wl);
--
1.8.4.3


2014-01-17 17:44:25

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCHv2 0/5] wl1251 device tree support

* John W. Linville <[email protected]> [140117 07:17]:
> On Fri, Jan 17, 2014 at 02:45:15AM +0100, Sebastian Reichel wrote:
> > On Mon, Jan 06, 2014 at 11:57:09PM +0100, Sebastian Reichel wrote:
> > > Hi John,
> > >
> > > > The following patchset adds device tree support to
> > > > the spi variant of the wl1251 driver.
> > > >
> > > > Luciano Coelho (1):
> > > > wl1251: split wl251 platform data to a separate structure
> > > >
> > > > Sebastian Reichel (4):
> > > > wl1251: move power GPIO handling into the driver
> > > > wl1251: spi: add vio regulator support
> > > > wl1251: spi: add device tree support
> > > > Documentation: dt: wireless: Add wl1251
> > >
> > > What's the status of this patchset? Tony prepared an immutable
> > > branch for patches 1+2 [0]. I think the other patches are also ok
> > > (at least there were no more complains from the DT binding
> > > maintainers). It would be nice to have wl1251 DT support in 3.14.
> > >
> > > [0] http://www.spinics.net/lists/linux-omap/msg101165.html
> > >
> > > -- Sebastian
> >
> > ping? I can't see it on wireless-next.
>
> I can't pull it because the branch is based on a later source than
> that of wireless-next.

Hmm I thought v3.13-rc1 was the base we agreed on the immutable branch.
Care to explain what the issue is merging it in?

AFAIK merging it fast forwards your branch to v3.13-rc1 and then
you just need to do the pull request against v3.13-rc1.

Regards,

Tony

2014-01-17 01:45:22

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCHv2 0/5] wl1251 device tree support

On Mon, Jan 06, 2014 at 11:57:09PM +0100, Sebastian Reichel wrote:
> Hi John,
>
> > The following patchset adds device tree support to
> > the spi variant of the wl1251 driver.
> >
> > Luciano Coelho (1):
> > wl1251: split wl251 platform data to a separate structure
> >
> > Sebastian Reichel (4):
> > wl1251: move power GPIO handling into the driver
> > wl1251: spi: add vio regulator support
> > wl1251: spi: add device tree support
> > Documentation: dt: wireless: Add wl1251
>
> What's the status of this patchset? Tony prepared an immutable
> branch for patches 1+2 [0]. I think the other patches are also ok
> (at least there were no more complains from the DT binding
> maintainers). It would be nice to have wl1251 DT support in 3.14.
>
> [0] http://www.spinics.net/lists/linux-omap/msg101165.html
>
> -- Sebastian

ping? I can't see it on wireless-next.

-- Sebastian


Attachments:
(No filename) (892.00 B)
signature.asc (819.00 B)
Digital signature
Download all attachments

2014-01-17 15:15:18

by John W. Linville

[permalink] [raw]
Subject: Re: [PATCHv2 0/5] wl1251 device tree support

On Fri, Jan 17, 2014 at 02:45:15AM +0100, Sebastian Reichel wrote:
> On Mon, Jan 06, 2014 at 11:57:09PM +0100, Sebastian Reichel wrote:
> > Hi John,
> >
> > > The following patchset adds device tree support to
> > > the spi variant of the wl1251 driver.
> > >
> > > Luciano Coelho (1):
> > > wl1251: split wl251 platform data to a separate structure
> > >
> > > Sebastian Reichel (4):
> > > wl1251: move power GPIO handling into the driver
> > > wl1251: spi: add vio regulator support
> > > wl1251: spi: add device tree support
> > > Documentation: dt: wireless: Add wl1251
> >
> > What's the status of this patchset? Tony prepared an immutable
> > branch for patches 1+2 [0]. I think the other patches are also ok
> > (at least there were no more complains from the DT binding
> > maintainers). It would be nice to have wl1251 DT support in 3.14.
> >
> > [0] http://www.spinics.net/lists/linux-omap/msg101165.html
> >
> > -- Sebastian
>
> ping? I can't see it on wireless-next.

I can't pull it because the branch is based on a later source than
that of wireless-next.

--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.

2014-01-17 19:30:21

by John W. Linville

[permalink] [raw]
Subject: Re: [PATCHv2 0/5] wl1251 device tree support

On Fri, Jan 17, 2014 at 09:44:16AM -0800, Tony Lindgren wrote:
> * John W. Linville <[email protected]> [140117 07:17]:
> > On Fri, Jan 17, 2014 at 02:45:15AM +0100, Sebastian Reichel wrote:
> > > On Mon, Jan 06, 2014 at 11:57:09PM +0100, Sebastian Reichel wrote:
> > > > Hi John,
> > > >
> > > > > The following patchset adds device tree support to
> > > > > the spi variant of the wl1251 driver.
> > > > >
> > > > > Luciano Coelho (1):
> > > > > wl1251: split wl251 platform data to a separate structure
> > > > >
> > > > > Sebastian Reichel (4):
> > > > > wl1251: move power GPIO handling into the driver
> > > > > wl1251: spi: add vio regulator support
> > > > > wl1251: spi: add device tree support
> > > > > Documentation: dt: wireless: Add wl1251
> > > >
> > > > What's the status of this patchset? Tony prepared an immutable
> > > > branch for patches 1+2 [0]. I think the other patches are also ok
> > > > (at least there were no more complains from the DT binding
> > > > maintainers). It would be nice to have wl1251 DT support in 3.14.
> > > >
> > > > [0] http://www.spinics.net/lists/linux-omap/msg101165.html
> > > >
> > > > -- Sebastian
> > >
> > > ping? I can't see it on wireless-next.
> >
> > I can't pull it because the branch is based on a later source than
> > that of wireless-next.
>
> Hmm I thought v3.13-rc1 was the base we agreed on the immutable branch.
> Care to explain what the issue is merging it in?

I think I was clear -- "the branch is based on a later source than
that of wireless-next".

> AFAIK merging it fast forwards your branch to v3.13-rc1 and then
> you just need to do the pull request against v3.13-rc1.

It's not a forward, it's a merge. And I don't want to do that in
the wireless-next tree right now.

Are you sending that branch for 3.14? Is there some reason that I
have to have it in wireless-next?

John
--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.

2014-01-25 00:09:35

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCHv2 0/5] wl1251 device tree support

* John W. Linville <[email protected]> [140124 16:03]:
> On Fri, Jan 24, 2014 at 10:53:22PM +0100, Sebastian Reichel wrote:
> > On Sat, Jan 18, 2014 at 09:47:06AM -0800, Tony Lindgren wrote:
> > > [...]
> > >
> > > The reason was for keeping things building and git bisect working.
> > >
> > > I do have wl1251-pdata-signed as the base for branch
> > > omap-for-v3.14/omap3-board-removal. However the board removal was
> > > considered too early for v3.14, so that's been postponed. This is
> > > because people are still updating their systems to device tree
> > > based booting. So I can redo my omap-for-v3.14/omap3-board-removal
> > > against v3.14.
> > >
> > > So if you want to, feel free to pick all the wl12xx patches to your
> > > wireless tree. AFAIK my omap-for-v3.14/omap3-board-removal is the
> > > only other user for those patches, and that I can redo that on
> > > v3.14.
> > >
> > > So for the arch/arm/*omap* touching patches, feel free to add:
> > >
> > > Acked-by: Tony Lindgren <[email protected]>
> >
> > Another ping. If this does not go into 3.14 via wireless tree
> > it will become complicated for 3.15 again.
>
> It's too late for new networking features in 3.14. Why wouldn't Tony
> send it via his tree?

It's mostly drivers/net/wireless related to patch the wl12xx driver
further.

> At any rate, I don't have the patches. If you still want them through
> the wireless tree (for 3.15) then you'll need to resend them.

Sebastian, please resend the whole series to John and feel free
to add my acks. It's best that John picks them all up, otherwise
we'll have the same issue for v3.15. It seems that we should have
just taken the merge conflict rather than going back and forth
with this.

Cheers,

Tony

2014-01-18 17:47:12

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCHv2 0/5] wl1251 device tree support

* John W. Linville <[email protected]> [140117 11:32]:
> On Fri, Jan 17, 2014 at 09:44:16AM -0800, Tony Lindgren wrote:
> > * John W. Linville <[email protected]> [140117 07:17]:
> > > On Fri, Jan 17, 2014 at 02:45:15AM +0100, Sebastian Reichel wrote:
> > > > On Mon, Jan 06, 2014 at 11:57:09PM +0100, Sebastian Reichel wrote:
> > > > > Hi John,
> > > > >
> > > > > > The following patchset adds device tree support to
> > > > > > the spi variant of the wl1251 driver.
> > > > > >
> > > > > > Luciano Coelho (1):
> > > > > > wl1251: split wl251 platform data to a separate structure
> > > > > >
> > > > > > Sebastian Reichel (4):
> > > > > > wl1251: move power GPIO handling into the driver
> > > > > > wl1251: spi: add vio regulator support
> > > > > > wl1251: spi: add device tree support
> > > > > > Documentation: dt: wireless: Add wl1251
> > > > >
> > > > > What's the status of this patchset? Tony prepared an immutable
> > > > > branch for patches 1+2 [0]. I think the other patches are also ok
> > > > > (at least there were no more complains from the DT binding
> > > > > maintainers). It would be nice to have wl1251 DT support in 3.14.
> > > > >
> > > > > [0] http://www.spinics.net/lists/linux-omap/msg101165.html
> > > > >
> > > > > -- Sebastian
> > > >
> > > > ping? I can't see it on wireless-next.
> > >
> > > I can't pull it because the branch is based on a later source than
> > > that of wireless-next.
> >
> > Hmm I thought v3.13-rc1 was the base we agreed on the immutable branch.
> > Care to explain what the issue is merging it in?
>
> I think I was clear -- "the branch is based on a later source than
> that of wireless-next".

OK so it's the..

> > AFAIK merging it fast forwards your branch to v3.13-rc1 and then
> > you just need to do the pull request against v3.13-rc1.
>
> It's not a forward, it's a merge. And I don't want to do that in
> the wireless-next tree right now.

..merge part that you have problem. Fine with me.

> Are you sending that branch for 3.14? Is there some reason that I
> have to have it in wireless-next?

The reason was for keeping things building and git bisect working.

I do have wl1251-pdata-signed as the base for branch
omap-for-v3.14/omap3-board-removal. However the board removal was
considered too early for v3.14, so that's been postponed. This is
because people are still updating their systems to device tree
based booting. So I can redo my omap-for-v3.14/omap3-board-removal
against v3.14.

So if you want to, feel free to pick all the wl12xx patches to your
wireless tree. AFAIK my omap-for-v3.14/omap3-board-removal is the
only other user for those patches, and that I can redo that on
v3.14.

So for the arch/arm/*omap* touching patches, feel free to add:

Acked-by: Tony Lindgren <[email protected]>

2014-01-25 00:00:55

by John W. Linville

[permalink] [raw]
Subject: Re: [PATCHv2 0/5] wl1251 device tree support

On Fri, Jan 24, 2014 at 10:53:22PM +0100, Sebastian Reichel wrote:
> On Sat, Jan 18, 2014 at 09:47:06AM -0800, Tony Lindgren wrote:
> > [...]
> >
> > The reason was for keeping things building and git bisect working.
> >
> > I do have wl1251-pdata-signed as the base for branch
> > omap-for-v3.14/omap3-board-removal. However the board removal was
> > considered too early for v3.14, so that's been postponed. This is
> > because people are still updating their systems to device tree
> > based booting. So I can redo my omap-for-v3.14/omap3-board-removal
> > against v3.14.
> >
> > So if you want to, feel free to pick all the wl12xx patches to your
> > wireless tree. AFAIK my omap-for-v3.14/omap3-board-removal is the
> > only other user for those patches, and that I can redo that on
> > v3.14.
> >
> > So for the arch/arm/*omap* touching patches, feel free to add:
> >
> > Acked-by: Tony Lindgren <[email protected]>
>
> Another ping. If this does not go into 3.14 via wireless tree
> it will become complicated for 3.15 again.

It's too late for new networking features in 3.14. Why wouldn't Tony
send it via his tree?

At any rate, I don't have the patches. If you still want them through
the wireless tree (for 3.15) then you'll need to resend them.

John
--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.

2014-01-06 22:57:15

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCHv2 0/5] wl1251 device tree support

Hi John,

> The following patchset adds device tree support to
> the spi variant of the wl1251 driver.
>
> Luciano Coelho (1):
> wl1251: split wl251 platform data to a separate structure
>
> Sebastian Reichel (4):
> wl1251: move power GPIO handling into the driver
> wl1251: spi: add vio regulator support
> wl1251: spi: add device tree support
> Documentation: dt: wireless: Add wl1251

What's the status of this patchset? Tony prepared an immutable
branch for patches 1+2 [0]. I think the other patches are also ok
(at least there were no more complains from the DT binding
maintainers). It would be nice to have wl1251 DT support in 3.14.

[0] http://www.spinics.net/lists/linux-omap/msg101165.html

-- Sebastian


Attachments:
(No filename) (727.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2014-01-24 21:53:38

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCHv2 0/5] wl1251 device tree support

On Sat, Jan 18, 2014 at 09:47:06AM -0800, Tony Lindgren wrote:
> [...]
>
> The reason was for keeping things building and git bisect working.
>
> I do have wl1251-pdata-signed as the base for branch
> omap-for-v3.14/omap3-board-removal. However the board removal was
> considered too early for v3.14, so that's been postponed. This is
> because people are still updating their systems to device tree
> based booting. So I can redo my omap-for-v3.14/omap3-board-removal
> against v3.14.
>
> So if you want to, feel free to pick all the wl12xx patches to your
> wireless tree. AFAIK my omap-for-v3.14/omap3-board-removal is the
> only other user for those patches, and that I can redo that on
> v3.14.
>
> So for the arch/arm/*omap* touching patches, feel free to add:
>
> Acked-by: Tony Lindgren <[email protected]>

Another ping. If this does not go into 3.14 via wireless tree
it will become complicated for 3.15 again.

-- Sebastian


Attachments:
(No filename) (939.00 B)
signature.asc (819.00 B)
Digital signature
Download all attachments

2014-02-14 23:07:01

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCHv2 3/5] wl1251: spi: add vio regulator support

This patch adds support for requesting the regulator powering
the vio pin.

Signed-off-by: Sebastian Reichel <[email protected]>
Reviewed-by: Pavel Machek <[email protected]>
---
drivers/net/wireless/ti/wl1251/spi.c | 19 +++++++++++++++++--
drivers/net/wireless/ti/wl1251/wl1251.h | 2 ++
2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c
index 6abcbc3..0a8aacc 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -27,6 +27,7 @@
#include <linux/spi/spi.h>
#include <linux/wl12xx.h>
#include <linux/gpio.h>
+#include <linux/regulator/consumer.h>

#include "wl1251.h"
#include "reg.h"
@@ -306,13 +307,26 @@ static int wl1251_spi_probe(struct spi_device *spi)

irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);

- ret = wl1251_init_ieee80211(wl);
+ wl->vio = devm_regulator_get(&spi->dev, "vio");
+ if (IS_ERR(wl->vio)) {
+ ret = PTR_ERR(wl->vio);
+ wl1251_error("vio regulator missing: %d", ret);
+ goto out_free;
+ }
+
+ ret = regulator_enable(wl->vio);
if (ret)
goto out_free;

+ ret = wl1251_init_ieee80211(wl);
+ if (ret)
+ goto disable_regulator;
+
return 0;

- out_free:
+disable_regulator:
+ regulator_disable(wl->vio);
+out_free:
ieee80211_free_hw(hw);

return ret;
@@ -324,6 +338,7 @@ static int wl1251_spi_remove(struct spi_device *spi)

free_irq(wl->irq, wl);
wl1251_free_hw(wl);
+ regulator_disable(wl->vio);

return 0;
}
diff --git a/drivers/net/wireless/ti/wl1251/wl1251.h b/drivers/net/wireless/ti/wl1251/wl1251.h
index 389fe25..16dae52 100644
--- a/drivers/net/wireless/ti/wl1251/wl1251.h
+++ b/drivers/net/wireless/ti/wl1251/wl1251.h
@@ -280,6 +280,8 @@ struct wl1251 {
int irq;
bool use_eeprom;

+ struct regulator *vio;
+
spinlock_t wl_lock;

enum wl1251_state state;
--
1.8.5.3


2014-02-14 23:06:53

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCHv2 1/5] wl1251: split wl251 platform data to a separate structure

From: Luciano Coelho <[email protected]>

Move the wl1251 part of the wl12xx platform data structure into a new
structure specifically for wl1251. Change the platform data built-in
block and board files accordingly.

Signed-off-by: Luciano Coelho <[email protected]>
Acked-by: Tony Lindgren <[email protected]>
Reviewed-by: Felipe Balbi <[email protected]>
Reviewed-by: Sebastian Reichel <[email protected]>
Reviewed-by: Pavel Machek <[email protected]>
---
arch/arm/mach-omap2/board-omap3pandora.c | 4 +--
arch/arm/mach-omap2/board-rx51-peripherals.c | 2 +-
drivers/net/wireless/ti/wilink_platform_data.c | 37 +++++++++++++++++++++-----
drivers/net/wireless/ti/wl1251/sdio.c | 12 ++++-----
drivers/net/wireless/ti/wl1251/spi.c | 2 +-
include/linux/wl12xx.h | 22 ++++++++++++++-
6 files changed, 62 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index de1bc6b..24f3c1b 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -536,7 +536,7 @@ static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {

static void __init pandora_wl1251_init(void)
{
- struct wl12xx_platform_data pandora_wl1251_pdata;
+ struct wl1251_platform_data pandora_wl1251_pdata;
int ret;

memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata));
@@ -550,7 +550,7 @@ static void __init pandora_wl1251_init(void)
goto fail_irq;

pandora_wl1251_pdata.use_eeprom = true;
- ret = wl12xx_set_platform_data(&pandora_wl1251_pdata);
+ ret = wl1251_set_platform_data(&pandora_wl1251_pdata);
if (ret < 0)
goto fail_irq;

diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 8760bbe..e05e740 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -84,7 +84,7 @@ enum {
RX51_SPI_MIPID, /* LCD panel */
};

-static struct wl12xx_platform_data wl1251_pdata;
+static struct wl1251_platform_data wl1251_pdata;
static struct tsc2005_platform_data tsc2005_pdata;

#if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
diff --git a/drivers/net/wireless/ti/wilink_platform_data.c b/drivers/net/wireless/ti/wilink_platform_data.c
index 998e958..a92bd3e 100644
--- a/drivers/net/wireless/ti/wilink_platform_data.c
+++ b/drivers/net/wireless/ti/wilink_platform_data.c
@@ -23,17 +23,17 @@
#include <linux/err.h>
#include <linux/wl12xx.h>

-static struct wl12xx_platform_data *platform_data;
+static struct wl12xx_platform_data *wl12xx_platform_data;

int __init wl12xx_set_platform_data(const struct wl12xx_platform_data *data)
{
- if (platform_data)
+ if (wl12xx_platform_data)
return -EBUSY;
if (!data)
return -EINVAL;

- platform_data = kmemdup(data, sizeof(*data), GFP_KERNEL);
- if (!platform_data)
+ wl12xx_platform_data = kmemdup(data, sizeof(*data), GFP_KERNEL);
+ if (!wl12xx_platform_data)
return -ENOMEM;

return 0;
@@ -41,9 +41,34 @@ int __init wl12xx_set_platform_data(const struct wl12xx_platform_data *data)

struct wl12xx_platform_data *wl12xx_get_platform_data(void)
{
- if (!platform_data)
+ if (!wl12xx_platform_data)
return ERR_PTR(-ENODEV);

- return platform_data;
+ return wl12xx_platform_data;
}
EXPORT_SYMBOL(wl12xx_get_platform_data);
+
+static struct wl1251_platform_data *wl1251_platform_data;
+
+int __init wl1251_set_platform_data(const struct wl1251_platform_data *data)
+{
+ if (wl1251_platform_data)
+ return -EBUSY;
+ if (!data)
+ return -EINVAL;
+
+ wl1251_platform_data = kmemdup(data, sizeof(*data), GFP_KERNEL);
+ if (!wl1251_platform_data)
+ return -ENOMEM;
+
+ return 0;
+}
+
+struct wl1251_platform_data *wl1251_get_platform_data(void)
+{
+ if (!wl1251_platform_data)
+ return ERR_PTR(-ENODEV);
+
+ return wl1251_platform_data;
+}
+EXPORT_SYMBOL(wl1251_get_platform_data);
diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
index e2b3d9c..b75a37a 100644
--- a/drivers/net/wireless/ti/wl1251/sdio.c
+++ b/drivers/net/wireless/ti/wl1251/sdio.c
@@ -227,7 +227,7 @@ static int wl1251_sdio_probe(struct sdio_func *func,
struct wl1251 *wl;
struct ieee80211_hw *hw;
struct wl1251_sdio *wl_sdio;
- const struct wl12xx_platform_data *wl12xx_board_data;
+ const struct wl1251_platform_data *wl1251_board_data;

hw = wl1251_alloc_hw();
if (IS_ERR(hw))
@@ -254,11 +254,11 @@ static int wl1251_sdio_probe(struct sdio_func *func,
wl->if_priv = wl_sdio;
wl->if_ops = &wl1251_sdio_ops;

- wl12xx_board_data = wl12xx_get_platform_data();
- if (!IS_ERR(wl12xx_board_data)) {
- wl->set_power = wl12xx_board_data->set_power;
- wl->irq = wl12xx_board_data->irq;
- wl->use_eeprom = wl12xx_board_data->use_eeprom;
+ wl1251_board_data = wl1251_get_platform_data();
+ if (!IS_ERR(wl1251_board_data)) {
+ wl->set_power = wl1251_board_data->set_power;
+ wl->irq = wl1251_board_data->irq;
+ wl->use_eeprom = wl1251_board_data->use_eeprom;
}

if (wl->irq) {
diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c
index 1342f81..62403a1 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -238,7 +238,7 @@ static const struct wl1251_if_operations wl1251_spi_ops = {

static int wl1251_spi_probe(struct spi_device *spi)
{
- struct wl12xx_platform_data *pdata;
+ struct wl1251_platform_data *pdata;
struct ieee80211_hw *hw;
struct wl1251 *wl;
int ret;
diff --git a/include/linux/wl12xx.h b/include/linux/wl12xx.h
index a54fe82..b516b4f 100644
--- a/include/linux/wl12xx.h
+++ b/include/linux/wl12xx.h
@@ -48,11 +48,15 @@ enum {
WL12XX_TCXOCLOCK_33_6 = 7, /* 33.6 MHz */
};

-struct wl12xx_platform_data {
+struct wl1251_platform_data {
void (*set_power)(bool enable);
/* SDIO only: IRQ number if WLAN_IRQ line is used, 0 for SDIO IRQs */
int irq;
bool use_eeprom;
+};
+
+struct wl12xx_platform_data {
+ int irq;
int board_ref_clock;
int board_tcxo_clock;
unsigned long platform_quirks;
@@ -68,6 +72,10 @@ int wl12xx_set_platform_data(const struct wl12xx_platform_data *data);

struct wl12xx_platform_data *wl12xx_get_platform_data(void);

+int wl1251_set_platform_data(const struct wl1251_platform_data *data);
+
+struct wl1251_platform_data *wl1251_get_platform_data(void);
+
#else

static inline
@@ -82,6 +90,18 @@ struct wl12xx_platform_data *wl12xx_get_platform_data(void)
return ERR_PTR(-ENODATA);
}

+static inline
+int wl1251_set_platform_data(const struct wl1251_platform_data *data)
+{
+ return -ENOSYS;
+}
+
+static inline
+struct wl1251_platform_data *wl1251_get_platform_data(void)
+{
+ return ERR_PTR(-ENODATA);
+}
+
#endif

#endif
--
1.8.5.3


2014-02-14 23:07:07

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCHv2 5/5] Documentation: dt: wireless: Add wl1251

Add device tree binding documentation for Texas Instrument's wl1251
wireless lan chip. For now only the SPI binding is documented.

Signed-off-by: Sebastian Reichel <[email protected]>
---
.../devicetree/bindings/net/wireless/ti,wl1251.txt | 39 ++++++++++++++++++++++
1 file changed, 39 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt

diff --git a/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
new file mode 100644
index 0000000..189ae5c
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
@@ -0,0 +1,39 @@
+* Texas Instruments wl1251 wireless lan controller
+
+The wl1251 chip can be connected via SPI or via SDIO. This
+document describes the binding for the SPI connected chip.
+
+Required properties:
+- compatible : Should be "ti,wl1251"
+- reg : Chip select address of device
+- spi-max-frequency : Maximum SPI clocking speed of device in Hz
+- interrupts : Should contain interrupt line
+- interrupt-parent : Should be the phandle for the interrupt controller
+ that services interrupts for this device
+- vio-supply : phandle to regulator providing VIO
+- ti,power-gpio : GPIO connected to chip's PMEN pin
+
+Optional properties:
+- ti,wl1251-has-eeprom : boolean, the wl1251 has an eeprom connected, which
+ provides configuration data (calibration, MAC, ...)
+- Please consult Documentation/devicetree/bindings/spi/spi-bus.txt
+ for optional SPI connection related properties,
+
+Examples:
+
+&spi1 {
+ wl1251@0 {
+ compatible = "ti,wl1251";
+
+ reg = <0>;
+ spi-max-frequency = <48000000>;
+ spi-cpol;
+ spi-cpha;
+
+ interrupt-parent = <&gpio2>;
+ interrupts = <10 IRQ_TYPE_NONE>; /* gpio line 42 */
+
+ vio-supply = <&vio>;
+ ti,power-gpio = <&gpio3 23 GPIO_ACTIVE_HIGH>; /* 87 */
+ };
+};
--
1.8.5.3


2014-02-14 23:06:43

by Sebastian Reichel

[permalink] [raw]
Subject: [RESEND] [PATCHv2 0/5] wl1251 device tree support

Hi John,

The following patchset adds device tree support to the spi variant of the
wl1251 driver, which is used in the Nokia N900. Tony requested, that you
take the whole series even if that may introduce merge conflicts:

> Sebastian, please resend the whole series to John and feel free to add my
> acks. It's best that John picks them all up, otherwise we'll have the same
> issue for v3.15. It seems that we should have just taken the merge conflict
> rather than going back and forth with this.

-- Sebastian

Luciano Coelho (1):
wl1251: split wl251 platform data to a separate structure

Sebastian Reichel (4):
wl1251: move power GPIO handling into the driver
wl1251: spi: add vio regulator support
wl1251: spi: add device tree support
Documentation: dt: wireless: Add wl1251

.../devicetree/bindings/net/wireless/ti,wl1251.txt | 39 ++++++++++++
arch/arm/mach-omap2/board-omap3pandora.c | 6 +-
arch/arm/mach-omap2/board-rx51-peripherals.c | 13 +---
drivers/net/wireless/ti/wilink_platform_data.c | 37 +++++++++--
drivers/net/wireless/ti/wl1251/sdio.c | 31 +++++++---
drivers/net/wireless/ti/wl1251/spi.c | 71 ++++++++++++++++------
drivers/net/wireless/ti/wl1251/wl1251.h | 4 +-
include/linux/wl12xx.h | 24 +++++++-
8 files changed, 176 insertions(+), 49 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt

--
1.8.5.3


2014-02-14 23:07:04

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCHv2 4/5] wl1251: spi: add device tree support

Add device tree support for the spi variant of wl1251.

Signed-off-by: Sebastian Reichel <[email protected]>
---
drivers/net/wireless/ti/wl1251/spi.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ti/wl1251/spi.c b/drivers/net/wireless/ti/wl1251/spi.c
index 0a8aacc..b06d36d 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -27,6 +27,8 @@
#include <linux/spi/spi.h>
#include <linux/wl12xx.h>
#include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
#include <linux/regulator/consumer.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)
{
- 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 wl1251 *wl;
int ret;

- pdata = dev_get_platdata(&spi->dev);
- if (!pdata) {
+ if (!np && !pdata) {
wl1251_error("no platform data");
return -ENODEV;
}
@@ -273,7 +275,18 @@ static int wl1251_spi_probe(struct spi_device *spi)
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)) {
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;
}

- wl->use_eeprom = pdata->use_eeprom;
-
irq_set_status_flags(wl->irq, IRQ_NOAUTOEN);
ret = devm_request_irq(&spi->dev, wl->irq, wl1251_irq, 0,
DRIVER_NAME, wl);
--
1.8.5.3


2014-02-26 19:44:40

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [RESEND] [PATCHv2 0/5] wl1251 device tree support

Hi John,

On Sat, Feb 15, 2014 at 12:05:51AM +0100, Sebastian Reichel wrote:
> The following patchset adds device tree support to the spi variant of the
> wl1251 driver, which is used in the Nokia N900. Tony requested, that you
> take the whole series even if that may introduce merge conflicts:
>
> > Sebastian, please resend the whole series to John and feel free to add my
> > acks. It's best that John picks them all up, otherwise we'll have the same
> > issue for v3.15. It seems that we should have just taken the merge conflict
> > rather than going back and forth with this.

ping! Is there still anything wrong with this patchset?

-- Sebastian


Attachments:
(No filename) (656.00 B)
signature.asc (819.00 B)
Digital signature
Download all attachments

2014-02-14 23:06:58

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCHv2 2/5] 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 <[email protected]>
Reviewed-by: Pavel Machek <[email protected]>
Acked-by: Tony Lindgren <[email protected]>
---
arch/arm/mach-omap2/board-omap3pandora.c | 2 ++
arch/arm/mach-omap2/board-rx51-peripherals.c | 11 ++--------
drivers/net/wireless/ti/wl1251/sdio.c | 21 +++++++++++++-----
drivers/net/wireless/ti/wl1251/spi.c | 33 ++++++++++++++++++----------
drivers/net/wireless/ti/wl1251/wl1251.h | 2 +-
include/linux/wl12xx.h | 2 +-
6 files changed, 43 insertions(+), 28 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index 24f3c1b..cf18340 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -541,6 +541,8 @@ static void __init pandora_wl1251_init(void)

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");
if (ret < 0)
goto fail;
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index e05e740..ddfc8df 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -1173,13 +1173,7 @@ static inline void board_smc91x_init(void)

#endif

-static void rx51_wl1251_set_power(bool enable)
-{
- gpio_set_value(RX51_WL1251_POWER_GPIO, enable);
-}
-
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" },
};

@@ -1196,17 +1190,16 @@ static void __init rx51_init_wl1251(void)
if (irq < 0)
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;

return;

err_irq:
gpio_free(RX51_WL1251_IRQ_GPIO);
- gpio_free(RX51_WL1251_POWER_GPIO);
error:
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
diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
index b75a37a..b661f89 100644
--- a/drivers/net/wireless/ti/wl1251/sdio.c
+++ b/drivers/net/wireless/ti/wl1251/sdio.c
@@ -28,6 +28,7 @@
#include <linux/wl12xx.h>
#include <linux/irq.h>
#include <linux/pm_runtime.h>
+#include <linux/gpio.h>

#include "wl1251.h"

@@ -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,
* for example enabling clock buffer for the module.
*/
- if (wl->set_power)
- wl->set_power(true);
+ if (gpio_is_valid(wl->power_gpio))
+ gpio_set_value(wl->power_gpio, true);
+

ret = pm_runtime_get_sync(&func->dev);
if (ret < 0) {
@@ -203,8 +205,8 @@ static int wl1251_sdio_set_power(struct wl1251 *wl, bool enable)
if (ret < 0)
goto out;

- if (wl->set_power)
- wl->set_power(false);
+ if (gpio_is_valid(wl->power_gpio))
+ gpio_set_value(wl->power_gpio, false);
}

out:
@@ -256,11 +258,20 @@ static int wl1251_sdio_probe(struct sdio_func *func,

wl1251_board_data = wl1251_get_platform_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->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) {
irq_set_status_flags(wl->irq, IRQ_NOAUTOEN);
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 62403a1..6abcbc3 100644
--- a/drivers/net/wireless/ti/wl1251/spi.c
+++ b/drivers/net/wireless/ti/wl1251/spi.c
@@ -26,6 +26,7 @@
#include <linux/crc7.h>
#include <linux/spi/spi.h>
#include <linux/wl12xx.h>
+#include <linux/gpio.h>

#include "wl1251.h"
#include "reg.h"
@@ -221,8 +222,8 @@ static void wl1251_spi_disable_irq(struct wl1251 *wl)

static int wl1251_spi_set_power(struct wl1251 *wl, bool enable)
{
- if (wl->set_power)
- wl->set_power(enable);
+ if (gpio_is_valid(wl->power_gpio))
+ gpio_set_value(wl->power_gpio, enable);

return 0;
}
@@ -271,22 +272,33 @@ static int wl1251_spi_probe(struct spi_device *spi)
goto out_free;
}

- wl->set_power = pdata->set_power;
- if (!wl->set_power) {
- wl1251_error("set power function missing in platform data");
- return -ENODEV;
+ wl->power_gpio = pdata->power_gpio;
+
+ if (gpio_is_valid(wl->power_gpio)) {
+ 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;
if (wl->irq < 0) {
wl1251_error("irq missing in platform data");
- return -ENODEV;
+ ret = -ENODEV;
+ goto out_free;
}

wl->use_eeprom = pdata->use_eeprom;

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) {
wl1251_error("request_irq() failed: %d", ret);
goto out_free;
@@ -296,13 +308,10 @@ static int wl1251_spi_probe(struct spi_device *spi)

ret = wl1251_init_ieee80211(wl);
if (ret)
- goto out_irq;
+ goto out_free;

return 0;

- out_irq:
- free_irq(wl->irq, wl);
-
out_free:
ieee80211_free_hw(hw);

diff --git a/drivers/net/wireless/ti/wl1251/wl1251.h b/drivers/net/wireless/ti/wl1251/wl1251.h
index 235617a..389fe25 100644
--- a/drivers/net/wireless/ti/wl1251/wl1251.h
+++ b/drivers/net/wireless/ti/wl1251/wl1251.h
@@ -276,7 +276,7 @@ struct wl1251 {
void *if_priv;
const struct wl1251_if_operations *if_ops;

- void (*set_power)(bool enable);
+ int power_gpio;
int irq;
bool use_eeprom;

diff --git a/include/linux/wl12xx.h b/include/linux/wl12xx.h
index b516b4f..a9c723b 100644
--- a/include/linux/wl12xx.h
+++ b/include/linux/wl12xx.h
@@ -49,7 +49,7 @@ enum {
};

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 */
int irq;
bool use_eeprom;
--
1.8.5.3


2014-03-13 17:30:13

by John W. Linville

[permalink] [raw]
Subject: Re: [RESEND] [PATCHv2 0/5] wl1251 device tree support

On Thu, Mar 13, 2014 at 06:00:39PM +0100, Sebastian Reichel wrote:
> Hi,
>
> On Wed, Feb 26, 2014 at 08:44:36PM +0100, Sebastian Reichel wrote:
> > On Sat, Feb 15, 2014 at 12:05:51AM +0100, Sebastian Reichel wrote:
> > > The following patchset adds device tree support to the spi variant of the
> > > wl1251 driver, which is used in the Nokia N900. Tony requested, that you
> > > take the whole series even if that may introduce merge conflicts:
> > >
> > > > Sebastian, please resend the whole series to John and feel free to add my
> > > > acks. It's best that John picks them all up, otherwise we'll have the same
> > > > issue for v3.15. It seems that we should have just taken the merge conflict
> > > > rather than going back and forth with this.
> >
> > ping! Is there still anything wrong with this patchset?
>
> ping! This patchset is quite old now. Please pull it into
> wireless-next, so that it can appear in 3.15.
>
> -- Sebastian

These are already in wireless-next...

commit edb6e3ec374d5630dfc7a93ddd5c0f4864e98a9d
Author: Sebastian Reichel <[email protected]>
Date: Sat Feb 15 00:05:56 2014 +0100

Documentation: dt: wireless: Add wl1251

Add device tree binding documentation for Texas Instrument's wl1251
wireless lan chip. For now only the SPI binding is documented.

Signed-off-by: Sebastian Reichel <[email protected]>
Signed-off-by: John W. Linville <[email protected]>

commit 07bbca6f142d02b4b09d66ed3c2cde36c77057ad
Author: Sebastian Reichel <[email protected]>
Date: Sat Feb 15 00:05:55 2014 +0100

wl1251: spi: add device tree support

Add device tree support for the spi variant of wl1251.

Signed-off-by: Sebastian Reichel <[email protected]>
Signed-off-by: John W. Linville <[email protected]>

commit e4c2e09e1534835c749de362b9b38e2d8b286236
Author: Sebastian Reichel <[email protected]>
Date: Sat Feb 15 00:05:54 2014 +0100

wl1251: spi: add vio regulator support

This patch adds support for requesting the regulator powering
the vio pin.

Signed-off-by: Sebastian Reichel <[email protected]>
Reviewed-by: Pavel Machek <[email protected]>
Signed-off-by: John W. Linville <[email protected]>

commit 1d207cd30b65fdd60d952cb9e100b6f776564f06
Author: Sebastian Reichel <[email protected]>
Date: Sat Feb 15 00:05:53 2014 +0100

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 <[email protected]>
Reviewed-by: Pavel Machek <[email protected]>
Acked-by: Tony Lindgren <[email protected]>
Signed-off-by: John W. Linville <[email protected]>

commit 946651cba26779864bcdbd7e12502f5a36c2de37
Author: Luciano Coelho <[email protected]>
Date: Sat Feb 15 00:05:52 2014 +0100

wl1251: split wl251 platform data to a separate structure

Move the wl1251 part of the wl12xx platform data structure into a new
structure specifically for wl1251. Change the platform data built-in
block and board files accordingly.

Signed-off-by: Luciano Coelho <[email protected]>
Acked-by: Tony Lindgren <[email protected]>
Reviewed-by: Felipe Balbi <[email protected]>
Reviewed-by: Sebastian Reichel <[email protected]>
Reviewed-by: Pavel Machek <[email protected]>
Signed-off-by: John W. Linville <[email protected]>

--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.

2014-03-13 18:01:59

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [RESEND] [PATCHv2 0/5] wl1251 device tree support

On Thu, Mar 13, 2014 at 01:27:27PM -0400, John W. Linville wrote:
> On Thu, Mar 13, 2014 at 06:00:39PM +0100, Sebastian Reichel wrote:
> > Hi,
> >
> > On Wed, Feb 26, 2014 at 08:44:36PM +0100, Sebastian Reichel wrote:
> > > On Sat, Feb 15, 2014 at 12:05:51AM +0100, Sebastian Reichel wrote:
> > > > The following patchset adds device tree support to the spi variant of the
> > > > wl1251 driver, which is used in the Nokia N900. Tony requested, that you
> > > > take the whole series even if that may introduce merge conflicts:
> > > >
> > > > > Sebastian, please resend the whole series to John and feel free to add my
> > > > > acks. It's best that John picks them all up, otherwise we'll have the same
> > > > > issue for v3.15. It seems that we should have just taken the merge conflict
> > > > > rather than going back and forth with this.
> > >
> > > ping! Is there still anything wrong with this patchset?
> >
> > ping! This patchset is quite old now. Please pull it into
> > wireless-next, so that it can appear in 3.15.
> >
> > -- Sebastian
>
> These are already in wireless-next...

oops, sorry for the noise. I have checked the git repository and my
mailbox before sending another ping, but overlooked the commits.

Thanks for applying them.

-- Sebastian


Attachments:
(No filename) (1.24 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2014-03-13 17:00:44

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [RESEND] [PATCHv2 0/5] wl1251 device tree support

Hi,

On Wed, Feb 26, 2014 at 08:44:36PM +0100, Sebastian Reichel wrote:
> On Sat, Feb 15, 2014 at 12:05:51AM +0100, Sebastian Reichel wrote:
> > The following patchset adds device tree support to the spi variant of the
> > wl1251 driver, which is used in the Nokia N900. Tony requested, that you
> > take the whole series even if that may introduce merge conflicts:
> >
> > > Sebastian, please resend the whole series to John and feel free to add my
> > > acks. It's best that John picks them all up, otherwise we'll have the same
> > > issue for v3.15. It seems that we should have just taken the merge conflict
> > > rather than going back and forth with this.
>
> ping! Is there still anything wrong with this patchset?

ping! This patchset is quite old now. Please pull it into
wireless-next, so that it can appear in 3.15.

-- Sebastian


Attachments:
(No filename) (845.00 B)
signature.asc (819.00 B)
Digital signature
Download all attachments