Re: [PATCH 2/3] wlcore/wl12xx: spi: add device tree support
On Wed, Dec 23, 2015 at 10:35:43AM +0200, Uri Mashiach wrote: > Add DT support for the wl1271 SPI WiFi. > > Add documentation file for the wl1271 SPI WiFi. > > Signed-off-by: Uri Mashiach> Acked-by: Igor Grinberg > --- > .../bindings/net/wireless/ti,wlcore,spi.txt| 35 +++ For the binding: Acked-by: Rob Herring -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/3] wlcore/wl12xx: spi: add device tree support
On 12/23/2015 10:35 AM, Uri Mashiach wrote: > Add DT support for the wl1271 SPI WiFi. > > Add documentation file for the wl1271 SPI WiFi. > > Signed-off-by: Uri Mashiach> Acked-by: Igor Grinberg > --- > .../bindings/net/wireless/ti,wlcore,spi.txt| 35 +++ > drivers/net/wireless/ti/wlcore/spi.c | 67 > +++--- > 2 files changed, 95 insertions(+), 7 deletions(-) > create mode 100644 > Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt > > diff --git a/Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt > b/Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt > new file mode 100644 > index 000..a3e7eb7 > --- /dev/null > +++ b/Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt > @@ -0,0 +1,35 @@ > +* Texas Instruments wl1271 wireless lan controller > + > +The wl1271 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,wl1271" > +- reg : Chip select address of device > +- spi-max-frequency : Maximum SPI clocking speed of device in Hz > +- ref-clock-frequency : Reference clock frequency > +- interrupts : Should contain interrupt line and trigger type It's good to describe here number of IRQ lines your device have and IRQ types (edge/level) > +- interrupt-parent :Should be the phandle for the interrupt controller interrupt-parent is not required (also interrupts-extended can be used) > +that services interrupts for this device > +- vwlan-supply :Point the node of the regulator that controls the > wl1271 chip WLAN_EN pin Pls, use gpio if this is required just to toggle WLAN_EN pin. [ti,] power-gpio or en-gpio > + > +Optional properties: > +- clock-xtal : boolean, clock is generated from XTAL > + > +- Please consult Documentation/devicetree/bindings/spi/spi-bus.txt > + for optional SPI connection related properties,just > + > +Examples: > + > + { > + wl1271@1 { > + compatible = "ti,wl1271"; > + > + reg = <1>; > + spi-max-frequency = <4800>; > + clock-xtal; > + interrupt-parent = <>; > + interrupts = <8 IRQ_TYPE_LEVEL_HIGH>; > + wifi-supply = <_fixed>; > + }; > +}; > diff --git a/drivers/net/wireless/ti/wlcore/spi.c > b/drivers/net/wireless/ti/wlcore/spi.c > index d3a4bcb..7281f5a 100644 > --- a/drivers/net/wireless/ti/wlcore/spi.c > +++ b/drivers/net/wireless/ti/wlcore/spi.c > @@ -30,6 +30,7 @@ > #include > #include > #include > +#include > #include > > #include "wlcore.h" > @@ -357,6 +358,54 @@ static struct wl1271_if_operations spi_ops = { > .set_block_size = NULL, > }; > > +#ifdef CONFIG_OF > +static const struct of_device_id wlcore_spi_of_match_table[] = { > + { .compatible = "ti,wl1271" }, > + { } > +}; > + > +/** > + * wlcore_probe_of - DT node parsing. > + * @spi: SPI slave device parameters. > + * @res: resource parameters. > + * @glue: wl12xx SPI bus to slave device glue parameters. > + * @pdev_data: wlcore device parameters > + */ > +static int wlcore_probe_of(struct spi_device *spi, struct resource *res, > +struct wl12xx_spi_glue *glue, > +struct wlcore_platdev_data *pdev_data) > +{ > + struct device_node *dt_node = spi->dev.of_node; > + int ret; > + > + ret = of_irq_to_resource(dt_node, 0, [0]); > + if (spi->irq != ret) { > + dev_err(glue->dev, "can't get interrupt resource\n"); > + return -EINVAL; > + } SPI core will parse IRQ for you (see below) > + > + if (of_find_property(dt_node, "clock-xtal", NULL)) > + pdev_data->ref_clock_xtal = true; > + > + ret = of_property_read_u32(dt_node, "ref-clock-frequency", > +_data->ref_clock_freq); > + if (IS_ERR_VALUE(ret)) { > + dev_err(glue->dev, > + "can't get reference clock frequency (%d)\n", ret); > + return ret; > + } > + > + return 0; > +} > +#else /* CONFIG_OF */ > +static int wlcore_probe_of(struct spi_device *spi, struct resource *res, > +struct wl12xx_spi_glue *glue, > +struct wlcore_platdev_data *pdev_data) > +{ > + return -ENODATA; > +} > +#endif /* CONFIG_OF */ > + > static int wl1271_probe(struct spi_device *spi) > { > struct wl12xx_spi_glue *glue; > @@ -365,8 +414,7 @@ static int wl1271_probe(struct spi_device *spi) > int ret; > > memset(_data, 0x00, sizeof(pdev_data)); > - > - /* TODO: add DT parsing when needed */ > + memset(res, 0x00, sizeof(res)); > > pdev_data.if_ops = _ops; > > @@ -390,6 +438,13 @@ static int wl1271_probe(struct spi_device *spi)
Re: [PATCH 2/3] wlcore/wl12xx: spi: add device tree support
Hi Grygorii, On 12/23/2015 12:25 PM, Grygorii Strashko wrote: On 12/23/2015 10:35 AM, Uri Mashiach wrote: Add DT support for the wl1271 SPI WiFi. Add documentation file for the wl1271 SPI WiFi. Signed-off-by: Uri MashiachAcked-by: Igor Grinberg --- .../bindings/net/wireless/ti,wlcore,spi.txt| 35 +++ drivers/net/wireless/ti/wlcore/spi.c | 67 +++--- 2 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt diff --git a/Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt b/Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt new file mode 100644 index 000..a3e7eb7 --- /dev/null +++ b/Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt @@ -0,0 +1,35 @@ +* Texas Instruments wl1271 wireless lan controller + +The wl1271 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,wl1271" +- reg : Chip select address of device +- spi-max-frequency : Maximum SPI clocking speed of device in Hz +- ref-clock-frequency : Reference clock frequency +- interrupts : Should contain interrupt line and trigger type It's good to describe here number of IRQ lines your device have and IRQ types (edge/level) Maybe IRQ type should be provided by dts file (IRQ_TYPE_LEVEL_HIGH/IRQ_TYPE_EDGE_RISING...) to enable support for additional controllers? +- interrupt-parent :Should be the phandle for the interrupt controller interrupt-parent is not required (also interrupts-extended can be used) Will be done in v2. +that services interrupts for this device +- vwlan-supply :Point the node of the regulator that controls the wl1271 chip WLAN_EN pin Pls, use gpio if this is required just to toggle WLAN_EN pin. [ti,] power-gpio or en-gpio The controller's power might need toggling in some board implementation. Maybe GPIO and regulator should be implemented? + +Optional properties: +- clock-xtal : boolean, clock is generated from XTAL + +- Please consult Documentation/devicetree/bindings/spi/spi-bus.txt + for optional SPI connection related properties,just + +Examples: + + { + wl1271@1 { + compatible = "ti,wl1271"; + + reg = <1>; + spi-max-frequency = <4800>; + clock-xtal; + interrupt-parent = <>; + interrupts = <8 IRQ_TYPE_LEVEL_HIGH>; + wifi-supply = <_fixed>; + }; +}; diff --git a/drivers/net/wireless/ti/wlcore/spi.c b/drivers/net/wireless/ti/wlcore/spi.c index d3a4bcb..7281f5a 100644 --- a/drivers/net/wireless/ti/wlcore/spi.c +++ b/drivers/net/wireless/ti/wlcore/spi.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "wlcore.h" @@ -357,6 +358,54 @@ static struct wl1271_if_operations spi_ops = { .set_block_size = NULL, }; +#ifdef CONFIG_OF +static const struct of_device_id wlcore_spi_of_match_table[] = { + { .compatible = "ti,wl1271" }, + { } +}; + +/** + * wlcore_probe_of - DT node parsing. + * @spi: SPI slave device parameters. + * @res: resource parameters. + * @glue: wl12xx SPI bus to slave device glue parameters. + * @pdev_data: wlcore device parameters + */ +static int wlcore_probe_of(struct spi_device *spi, struct resource *res, + struct wl12xx_spi_glue *glue, + struct wlcore_platdev_data *pdev_data) +{ + struct device_node *dt_node = spi->dev.of_node; + int ret; + + ret = of_irq_to_resource(dt_node, 0, [0]); + if (spi->irq != ret) { + dev_err(glue->dev, "can't get interrupt resource\n"); + return -EINVAL; + } SPI core will parse IRQ for you (see below) + + if (of_find_property(dt_node, "clock-xtal", NULL)) + pdev_data->ref_clock_xtal = true; + + ret = of_property_read_u32(dt_node, "ref-clock-frequency", + _data->ref_clock_freq); + if (IS_ERR_VALUE(ret)) { + dev_err(glue->dev, + "can't get reference clock frequency (%d)\n", ret); + return ret; + } + + return 0; +} +#else /* CONFIG_OF */ +static int wlcore_probe_of(struct spi_device *spi, struct resource *res, + struct wl12xx_spi_glue *glue, + struct wlcore_platdev_data *pdev_data) +{ + return -ENODATA; +} +#endif /* CONFIG_OF */ + static int wl1271_probe(struct spi_device *spi) { struct wl12xx_spi_glue *glue; @@ -365,8 +414,7 @@ static int wl1271_probe(struct spi_device *spi) int ret; memset(_data, 0x00, sizeof(pdev_data)); - - /* TODO:
Re: [PATCH 2/3] wlcore/wl12xx: spi: add device tree support
* Uri Mashiach[151223 06:38]: > On 12/23/2015 12:25 PM, Grygorii Strashko wrote: > > >>+that services interrupts for this device > >>+- vwlan-supply :Point the node of the regulator that controls the > >>wl1271 chip WLAN_EN pin > > > >Pls, use gpio if this is required just to toggle WLAN_EN pin. > > > >[ti,] power-gpio or en-gpio > > > > > > The controller's power might need toggling in some board implementation. > Maybe GPIO and regulator should be implemented? Yes a regulator for wlcore is best here because to properly control it and the wait needed. Regards, Tony -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/3] wlcore/wl12xx: spi: add device tree support
Hi Grygorii, On 12/23/2015 12:25 PM, Grygorii Strashko wrote: On 12/23/2015 10:35 AM, Uri Mashiach wrote: Add DT support for the wl1271 SPI WiFi. Add documentation file for the wl1271 SPI WiFi. Signed-off-by: Uri MashiachAcked-by: Igor Grinberg --- .../bindings/net/wireless/ti,wlcore,spi.txt| 35 +++ drivers/net/wireless/ti/wlcore/spi.c | 67 +++--- 2 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt diff --git a/Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt b/Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt new file mode 100644 index 000..a3e7eb7 --- /dev/null +++ b/Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt @@ -0,0 +1,35 @@ +* Texas Instruments wl1271 wireless lan controller + +The wl1271 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,wl1271" +- reg : Chip select address of device +- spi-max-frequency : Maximum SPI clocking speed of device in Hz +- ref-clock-frequency : Reference clock frequency +- interrupts : Should contain interrupt line and trigger type It's good to describe here number of IRQ lines your device have and IRQ types (edge/level) +- interrupt-parent :Should be the phandle for the interrupt controller interrupt-parent is not required (also interrupts-extended can be used) +that services interrupts for this device +- vwlan-supply :Point the node of the regulator that controls the wl1271 chip WLAN_EN pin Pls, use gpio if this is required just to toggle WLAN_EN pin. [ti,] power-gpio or en-gpio + +Optional properties: +- clock-xtal : boolean, clock is generated from XTAL + +- Please consult Documentation/devicetree/bindings/spi/spi-bus.txt + for optional SPI connection related properties,just + +Examples: + + { + wl1271@1 { + compatible = "ti,wl1271"; + + reg = <1>; + spi-max-frequency = <4800>; + clock-xtal; + interrupt-parent = <>; + interrupts = <8 IRQ_TYPE_LEVEL_HIGH>; + wifi-supply = <_fixed>; + }; +}; diff --git a/drivers/net/wireless/ti/wlcore/spi.c b/drivers/net/wireless/ti/wlcore/spi.c index d3a4bcb..7281f5a 100644 --- a/drivers/net/wireless/ti/wlcore/spi.c +++ b/drivers/net/wireless/ti/wlcore/spi.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "wlcore.h" @@ -357,6 +358,54 @@ static struct wl1271_if_operations spi_ops = { .set_block_size = NULL, }; +#ifdef CONFIG_OF +static const struct of_device_id wlcore_spi_of_match_table[] = { + { .compatible = "ti,wl1271" }, + { } +}; + +/** + * wlcore_probe_of - DT node parsing. + * @spi: SPI slave device parameters. + * @res: resource parameters. + * @glue: wl12xx SPI bus to slave device glue parameters. + * @pdev_data: wlcore device parameters + */ +static int wlcore_probe_of(struct spi_device *spi, struct resource *res, + struct wl12xx_spi_glue *glue, + struct wlcore_platdev_data *pdev_data) +{ + struct device_node *dt_node = spi->dev.of_node; + int ret; + + ret = of_irq_to_resource(dt_node, 0, [0]); + if (spi->irq != ret) { + dev_err(glue->dev, "can't get interrupt resource\n"); + return -EINVAL; + } SPI core will parse IRQ for you (see below) The IRQ type should be stored in res[0].flags. Is there an alternative to of_irq_to_resource() for getting the IRQ type? + + if (of_find_property(dt_node, "clock-xtal", NULL)) + pdev_data->ref_clock_xtal = true; + + ret = of_property_read_u32(dt_node, "ref-clock-frequency", + _data->ref_clock_freq); + if (IS_ERR_VALUE(ret)) { + dev_err(glue->dev, + "can't get reference clock frequency (%d)\n", ret); + return ret; + } + + return 0; +} +#else /* CONFIG_OF */ +static int wlcore_probe_of(struct spi_device *spi, struct resource *res, + struct wl12xx_spi_glue *glue, + struct wlcore_platdev_data *pdev_data) +{ + return -ENODATA; +} +#endif /* CONFIG_OF */ + static int wl1271_probe(struct spi_device *spi) { struct wl12xx_spi_glue *glue; @@ -365,8 +414,7 @@ static int wl1271_probe(struct spi_device *spi) int ret; memset(_data, 0x00, sizeof(pdev_data)); - - /* TODO: add DT parsing when needed */ + memset(res, 0x00, sizeof(res)); pdev_data.if_ops = _ops; @@ -390,6 +438,13 @@ static int wl1271_probe(struct
[PATCH 2/3] wlcore/wl12xx: spi: add device tree support
Add DT support for the wl1271 SPI WiFi. Add documentation file for the wl1271 SPI WiFi. Signed-off-by: Uri MashiachAcked-by: Igor Grinberg --- .../bindings/net/wireless/ti,wlcore,spi.txt| 35 +++ drivers/net/wireless/ti/wlcore/spi.c | 67 +++--- 2 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt diff --git a/Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt b/Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt new file mode 100644 index 000..a3e7eb7 --- /dev/null +++ b/Documentation/devicetree/bindings/net/wireless/ti,wlcore,spi.txt @@ -0,0 +1,35 @@ +* Texas Instruments wl1271 wireless lan controller + +The wl1271 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,wl1271" +- reg : Chip select address of device +- spi-max-frequency : Maximum SPI clocking speed of device in Hz +- ref-clock-frequency : Reference clock frequency +- interrupts : Should contain interrupt line and trigger type +- interrupt-parent :Should be the phandle for the interrupt controller +that services interrupts for this device +- vwlan-supply :Point the node of the regulator that controls the wl1271 chip WLAN_EN pin + +Optional properties: +- clock-xtal : boolean, clock is generated from XTAL + +- Please consult Documentation/devicetree/bindings/spi/spi-bus.txt + for optional SPI connection related properties, + +Examples: + + { + wl1271@1 { + compatible = "ti,wl1271"; + + reg = <1>; + spi-max-frequency = <4800>; + clock-xtal; + interrupt-parent = <>; + interrupts = <8 IRQ_TYPE_LEVEL_HIGH>; + wifi-supply = <_fixed>; + }; +}; diff --git a/drivers/net/wireless/ti/wlcore/spi.c b/drivers/net/wireless/ti/wlcore/spi.c index d3a4bcb..7281f5a 100644 --- a/drivers/net/wireless/ti/wlcore/spi.c +++ b/drivers/net/wireless/ti/wlcore/spi.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "wlcore.h" @@ -357,6 +358,54 @@ static struct wl1271_if_operations spi_ops = { .set_block_size = NULL, }; +#ifdef CONFIG_OF +static const struct of_device_id wlcore_spi_of_match_table[] = { + { .compatible = "ti,wl1271" }, + { } +}; + +/** + * wlcore_probe_of - DT node parsing. + * @spi: SPI slave device parameters. + * @res: resource parameters. + * @glue: wl12xx SPI bus to slave device glue parameters. + * @pdev_data: wlcore device parameters + */ +static int wlcore_probe_of(struct spi_device *spi, struct resource *res, + struct wl12xx_spi_glue *glue, + struct wlcore_platdev_data *pdev_data) +{ + struct device_node *dt_node = spi->dev.of_node; + int ret; + + ret = of_irq_to_resource(dt_node, 0, [0]); + if (spi->irq != ret) { + dev_err(glue->dev, "can't get interrupt resource\n"); + return -EINVAL; + } + + if (of_find_property(dt_node, "clock-xtal", NULL)) + pdev_data->ref_clock_xtal = true; + + ret = of_property_read_u32(dt_node, "ref-clock-frequency", + _data->ref_clock_freq); + if (IS_ERR_VALUE(ret)) { + dev_err(glue->dev, + "can't get reference clock frequency (%d)\n", ret); + return ret; + } + + return 0; +} +#else /* CONFIG_OF */ +static int wlcore_probe_of(struct spi_device *spi, struct resource *res, + struct wl12xx_spi_glue *glue, + struct wlcore_platdev_data *pdev_data) +{ + return -ENODATA; +} +#endif /* CONFIG_OF */ + static int wl1271_probe(struct spi_device *spi) { struct wl12xx_spi_glue *glue; @@ -365,8 +414,7 @@ static int wl1271_probe(struct spi_device *spi) int ret; memset(_data, 0x00, sizeof(pdev_data)); - - /* TODO: add DT parsing when needed */ + memset(res, 0x00, sizeof(res)); pdev_data.if_ops = _ops; @@ -390,6 +438,13 @@ static int wl1271_probe(struct spi_device *spi) return PTR_ERR(glue->reg); } + ret = wlcore_probe_of(spi, [0], glue, _data); + if (IS_ERR_VALUE(ret)) { + dev_err(glue->dev, + "can't get device tree parameters (%d)\n", ret); + return ret; + } + ret = spi_setup(spi); if (ret < 0) { dev_err(glue->dev, "spi_setup failed\n"); @@ -404,10 +459,6 @@ static int wl1271_probe(struct spi_device *spi) glue->core->dev.parent = >dev; - memset(res, 0x00, sizeof(res)); - -