Re: [PATCH] wlcore: spi: add wl18xx support

2016-04-07 Thread Kalle Valo
"Reizer, Eyal"  writes:

>> >  static const struct of_device_id wlcore_spi_of_match_table[] = {
>> > -  { .compatible = "ti,wl1271" },
>> > +  { .compatible = "ti,wl1271", .data = _data},
>> > +  { .compatible = "ti,wl1273", .data = _data},
>> > +  { .compatible = "ti,wl1281", .data = _data},
>> > +  { .compatible = "ti,wl1283", .data = _data},
>> > +  { .compatible = "ti,wl1801", .data = _data},
>> > +  { .compatible = "ti,wl1805", .data = _data},
>> > +  { .compatible = "ti,wl1807", .data = _data},
>> > +  { .compatible = "ti,wl1831", .data = _data},
>> > +  { .compatible = "ti,wl1835", .data = _data},
>> > +  { .compatible = "ti,wl1837", .data = _data},
>> >{ }
>> 
>> Shouldn't you also update bindings/net/wireless/ti,wlcore,spi.txt? Now it 
>> only
>> mentions about ti,wl1271 and not anything about the rest.
>
> You are right! Will be fixed in v2

Thanks. Also remember to CC devicetree list.

-- 
Kalle Valo


RE: [PATCH] wlcore: spi: add wl18xx support

2016-04-07 Thread Reizer, Eyal


> -Original Message-
> From: Kalle Valo [mailto:kv...@codeaurora.org]
> Sent: Thursday, April 07, 2016 3:25 PM
> To: Eyal Reizer
> Cc: linux-wirel...@vger.kernel.org; netdev@vger.kernel.org; linux-
> ker...@vger.kernel.org; Reizer, Eyal; devicet...@vger.kernel.org
> Subject: Re: [PATCH] wlcore: spi: add wl18xx support
> 
> Eyal Reizer <eyalrei...@gmail.com> writes:
> 
> > Add support for using with both wl12xx and wl18xx.
> >
> > - all wilink family needs special init command for entering wspi mode.
> >   extra clock cycles should be sent after the spi init command while the
> >   cs pin is high.
> > - switch to controling the cs pin from the spi driver for achieveing the
> >   above.
> > - the selected cs gpio is read from the spi device-tree node using the
> >   cs-gpios field and setup as a gpio.
> > - See the example below for specifying the cs gpio using the cs-gpios
> > entry
> >
> >{
> > status = "okay";
> > pinctrl-names = "default";
> > pinctrl-0 = <_pins>;
> > cs-gpios = < 5 0>;
> > #address-cells = <1>;
> > #size-cells = <0>;
> > wlcore: wlcore@0 {
> > compatible = "ti,wl1835";
> > vwlan-supply = <_en_reg>;
> > spi-max-frequency = <4800>;
> > reg = <0>;  /* chip select 0 on spi0, ie spi0.0 */
> > interrupt-parent = <>;
> > interrupts = <27 IRQ_TYPE_EDGE_RISING>;
> > };
> > };
> >
> > Signed-off-by: Eyal Reizer <ey...@ti.com>
> 
> [...]
> 
> >  static const struct of_device_id wlcore_spi_of_match_table[] = {
> > -   { .compatible = "ti,wl1271" },
> > +   { .compatible = "ti,wl1271", .data = _data},
> > +   { .compatible = "ti,wl1273", .data = _data},
> > +   { .compatible = "ti,wl1281", .data = _data},
> > +   { .compatible = "ti,wl1283", .data = _data},
> > +   { .compatible = "ti,wl1801", .data = _data},
> > +   { .compatible = "ti,wl1805", .data = _data},
> > +   { .compatible = "ti,wl1807", .data = _data},
> > +   { .compatible = "ti,wl1831", .data = _data},
> > +   { .compatible = "ti,wl1835", .data = _data},
> > +   { .compatible = "ti,wl1837", .data = _data},
> > { }
> 
> Shouldn't you also update bindings/net/wireless/ti,wlcore,spi.txt? Now it only
> mentions about ti,wl1271 and not anything about the rest.

You are right! 
Will be fixed in v2

> 
> Adding devicetree list for further comments.
> 
> --
> Kalle Valo

Best Regards,
Eyal


Re: [PATCH] wlcore: spi: add wl18xx support

2016-04-07 Thread Kalle Valo
Eyal Reizer  writes:

> Add support for using with both wl12xx and wl18xx.
>
> - all wilink family needs special init command for entering wspi mode.
>   extra clock cycles should be sent after the spi init command while the
>   cs pin is high.
> - switch to controling the cs pin from the spi driver for achieveing the
>   above.
> - the selected cs gpio is read from the spi device-tree node using the
>   cs-gpios field and setup as a gpio.
> - See the example below for specifying the cs gpio using the cs-gpios entry
>
>  {
>   status = "okay";
>   pinctrl-names = "default";
>   pinctrl-0 = <_pins>;
>   cs-gpios = < 5 0>;
>   #address-cells = <1>;
>   #size-cells = <0>;
>   wlcore: wlcore@0 {
>   compatible = "ti,wl1835";
>   vwlan-supply = <_en_reg>;
>   spi-max-frequency = <4800>;
>   reg = <0>;  /* chip select 0 on spi0, ie spi0.0 */
>   interrupt-parent = <>;
>   interrupts = <27 IRQ_TYPE_EDGE_RISING>;
>   };
> };
>
> Signed-off-by: Eyal Reizer 

[...]

>  static const struct of_device_id wlcore_spi_of_match_table[] = {
> - { .compatible = "ti,wl1271" },
> + { .compatible = "ti,wl1271", .data = _data},
> + { .compatible = "ti,wl1273", .data = _data},
> + { .compatible = "ti,wl1281", .data = _data},
> + { .compatible = "ti,wl1283", .data = _data},
> + { .compatible = "ti,wl1801", .data = _data},
> + { .compatible = "ti,wl1805", .data = _data},
> + { .compatible = "ti,wl1807", .data = _data},
> + { .compatible = "ti,wl1831", .data = _data},
> + { .compatible = "ti,wl1835", .data = _data},
> + { .compatible = "ti,wl1837", .data = _data},
>   { }

Shouldn't you also update bindings/net/wireless/ti,wlcore,spi.txt? Now
it only mentions about ti,wl1271 and not anything about the rest.

Adding devicetree list for further comments.

-- 
Kalle Valo


Re: [PATCH] wlcore: spi: add wl18xx support

2016-04-07 Thread Kalle Valo
"Reizer, Eyal"  writes:

> Ping on this patch
>
>> -Original Message-
>> From: Eyal Reizer [mailto:eyalrei...@gmail.com]
>> Sent: Wednesday, March 30, 2016 4:07 PM
>> To: kv...@codeaurora.org; linux-wirel...@vger.kernel.org;
>> netdev@vger.kernel.org; linux-ker...@vger.kernel.org
>> Cc: Reizer, Eyal
>> Subject: [PATCH] wlcore: spi: add wl18xx support

Please edit your quotes and don't top most. A oneliner and then followed
by almost 400 lines unnecessary text for example makes it harder to use
patchwork:

https://patchwork.kernel.org/patch/8696181/

-- 
Kalle Valo


RE: [PATCH] wlcore: spi: add wl18xx support

2016-04-06 Thread Reizer, Eyal
Ping on this patch

> -Original Message-
> From: Eyal Reizer [mailto:eyalrei...@gmail.com]
> Sent: Wednesday, March 30, 2016 4:07 PM
> To: kv...@codeaurora.org; linux-wirel...@vger.kernel.org;
> netdev@vger.kernel.org; linux-ker...@vger.kernel.org
> Cc: Reizer, Eyal
> Subject: [PATCH] wlcore: spi: add wl18xx support
> 
> Add support for using with both wl12xx and wl18xx.
> 
> - all wilink family needs special init command for entering wspi mode.
>   extra clock cycles should be sent after the spi init command while the
>   cs pin is high.
> - switch to controling the cs pin from the spi driver for achieveing the
>   above.
> - the selected cs gpio is read from the spi device-tree node using the
>   cs-gpios field and setup as a gpio.
> - See the example below for specifying the cs gpio using the cs-gpios entry
> 
>  {
>   status = "okay";
>   pinctrl-names = "default";
>   pinctrl-0 = <_pins>;
>   cs-gpios = < 5 0>;
>   #address-cells = <1>;
>   #size-cells = <0>;
>   wlcore: wlcore@0 {
>   compatible = "ti,wl1835";
>   vwlan-supply = <_en_reg>;
>   spi-max-frequency = <4800>;
>   reg = <0>;  /* chip select 0 on spi0, ie spi0.0 */
>   interrupt-parent = <>;
>   interrupts = <27 IRQ_TYPE_EDGE_RISING>;
>   };
> };
> 
> Signed-off-by: Eyal Reizer 
> ---
>  drivers/net/wireless/ti/wlcore/spi.c |  176
> ++
>  1 file changed, 157 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/net/wireless/ti/wlcore/spi.c
> b/drivers/net/wireless/ti/wlcore/spi.c
> index 96d9c9d..6c5a369 100644
> --- a/drivers/net/wireless/ti/wlcore/spi.c
> +++ b/drivers/net/wireless/ti/wlcore/spi.c
> @@ -32,6 +32,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  #include "wlcore.h"
>  #include "wl12xx_80211.h"
> @@ -70,16 +71,30 @@
>  #define WSPI_MAX_CHUNK_SIZE4092
> 
>  /*
> - * only support SPI for 12xx - this code should be reworked when 18xx
> - * support is introduced
> + * wl18xx driver aggregation buffer size is (13 * PAGE_SIZE) compared
> + to
> + * (4 * PAGE_SIZE) for wl12xx, so use the larger buffer needed for
> + wl18xx
>   */
> -#define SPI_AGGR_BUFFER_SIZE (4 * PAGE_SIZE)
> +#define SPI_AGGR_BUFFER_SIZE (13 * PAGE_SIZE)
> 
>  /* Maximum number of SPI write chunks */  #define
> WSPI_MAX_NUM_OF_CHUNKS \
>   ((SPI_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE) + 1)
> 
> 
> +struct wilink_familiy_data {
> + char name[8];
> +};
> +
> +const struct wilink_familiy_data *wilink_data;
> +
> +static const struct wilink_familiy_data wl18xx_data = {
> + .name = "wl18xx",
> +};
> +
> +static const struct wilink_familiy_data wl12xx_data = {
> + .name = "wl12xx",
> +};
> +
>  struct wl12xx_spi_glue {
>   struct device *dev;
>   struct platform_device *core;
> @@ -120,6 +135,8 @@ static void wl12xx_spi_init(struct device *child)
>   struct spi_transfer t;
>   struct spi_message m;
>   u8 *cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL);
> + struct spi_device *spi = (struct spi_device *)glue->dev;
> + struct spi_master *master = spi->master;
> 
>   if (!cmd) {
>   dev_err(child->parent,
> @@ -127,6 +144,15 @@ static void wl12xx_spi_init(struct device *child)
>   return;
>   }
> 
> + if (!master->cs_gpios) {
> + dev_err(child->parent,
> + "spi chip select pin missing in platform data!\n");
> + return;
> + }
> +
> + /* Drive CS line low */
> + gpio_direction_output(master->cs_gpios[0], 0);
> +
>   memset(, 0, sizeof(t));
>   spi_message_init();
> 
> @@ -163,6 +189,26 @@ static void wl12xx_spi_init(struct device *child)
>   spi_message_add_tail(, );
> 
>   spi_sync(to_spi_device(glue->dev), );
> +
> + /* Send extra clocks with CS high. this is required by the wilink
> +  * family in order for successfully enter WSPI mode
> +  */
> + gpio_direction_output(master->cs_gpios[0], 1);
> +
> + memset(, 0, sizeof(m));
> + spi_message_init();
> +
> + cmd[0] = 0xff;
> + cmd[1] = 0xff;
> + cmd[2] = 0xff;
> + cmd[3] = 0xff;
> + swab32s((u32 *)cmd);
> +
> + t.tx_buf = cmd;
> + t.len = 4;
> + spi_message_add_tail(, );
> + spi_sync(to_spi_device(glue->dev), );
> +
>   kfree(cmd);
>  }
> 
> @@ -213,6 +259,16 @@ static int __must_check
> wl12xx_spi_raw_read(struct device *child, int addr,
>   u32 *busy_buf;
>   u32 *cmd;
>   u32 chunk_len;
> + struct spi_device *spi = (struct spi_device *)glue->dev;
> + struct spi_master *master = spi->master;
> +
> + if (!master->cs_gpios) {
> + dev_err(child->parent,
> + "spi chip select pin missing in platform data!\n");
> + return -EINVAL;
> + }
> + /* Drive CS line low */
> + gpio_direction_output(master->cs_gpios[0], 0);
> 
>   while (len > 0) {
> 

Re: [PATCH] wlcore: spi: add wl18xx support

2016-03-30 Thread Emmanuel Grumbach
On Wed, Mar 30, 2016 at 3:58 PM, Eyal Reizer  wrote:
>
> From: Eyal 

Are you trying to hide or something? :)

>
> Add support for using with both wl12xx and wl18xx.
>
> - all wilink family needs special init command for entering wspi mode.
>   extra clock cycles should be sent after the spi init command while the
>   cs pin is high.
> - switch to controling the cs pin from the spi driver for achieveing the
>   above.
> - the selected cs gpio is read from the spi device-tree node using the
>   cs-gpios field and setup as a gpio.
> - See the example below for specifying the cs gpio using the cs-gpios entry
>
>{
> status = "okay";
> pinctrl-names = "default";
> pinctrl-0 = <_pins>;
> cs-gpios = < 5 0>;
> #address-cells = <1>;
> #size-cells = <0>;
> wlcore: wlcore@0 {
> compatible = "ti,wl1835";
> vwlan-supply = <_en_reg>;
> spi-max-frequency = <4800>;
> reg = <0>;  /* chip select 0 on spi0, ie spi0.0 */
> interrupt-parent = <>;
> interrupts = <27 IRQ_TYPE_EDGE_RISING>;
> };
> };
>
> Signed-off-by: Eyal Reizer 
> ---
>  drivers/net/wireless/ti/wlcore/spi.c |  176 
> ++
>  1 file changed, 157 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/net/wireless/ti/wlcore/spi.c 
> b/drivers/net/wireless/ti/wlcore/spi.c
> index 96d9c9d..6c5a369 100644
> --- a/drivers/net/wireless/ti/wlcore/spi.c
> +++ b/drivers/net/wireless/ti/wlcore/spi.c
> @@ -32,6 +32,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #include "wlcore.h"
>  #include "wl12xx_80211.h"
> @@ -70,16 +71,30 @@
>  #define WSPI_MAX_CHUNK_SIZE4092
>
>  /*
> - * only support SPI for 12xx - this code should be reworked when 18xx
> - * support is introduced
> + * wl18xx driver aggregation buffer size is (13 * PAGE_SIZE) compared to
> + * (4 * PAGE_SIZE) for wl12xx, so use the larger buffer needed for wl18xx
>   */
> -#define SPI_AGGR_BUFFER_SIZE (4 * PAGE_SIZE)
> +#define SPI_AGGR_BUFFER_SIZE (13 * PAGE_SIZE)
>
>  /* Maximum number of SPI write chunks */
>  #define WSPI_MAX_NUM_OF_CHUNKS \
> ((SPI_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE) + 1)
>
>
> +struct wilink_familiy_data {
> +   char name[8];
> +};
> +
> +const struct wilink_familiy_data *wilink_data;
> +
> +static const struct wilink_familiy_data wl18xx_data = {
> +   .name = "wl18xx",
> +};
> +
> +static const struct wilink_familiy_data wl12xx_data = {
> +   .name = "wl12xx",
> +};
> +
>  struct wl12xx_spi_glue {
> struct device *dev;
> struct platform_device *core;
> @@ -120,6 +135,8 @@ static void wl12xx_spi_init(struct device *child)
> struct spi_transfer t;
> struct spi_message m;
> u8 *cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL);
> +   struct spi_device *spi = (struct spi_device *)glue->dev;
> +   struct spi_master *master = spi->master;
>
> if (!cmd) {
> dev_err(child->parent,
> @@ -127,6 +144,15 @@ static void wl12xx_spi_init(struct device *child)
> return;
> }
>
> +   if (!master->cs_gpios) {
> +   dev_err(child->parent,
> +   "spi chip select pin missing in platform data!\n");
> +   return;
> +   }
> +
> +   /* Drive CS line low */
> +   gpio_direction_output(master->cs_gpios[0], 0);
> +
> memset(, 0, sizeof(t));
> spi_message_init();
>
> @@ -163,6 +189,26 @@ static void wl12xx_spi_init(struct device *child)
> spi_message_add_tail(, );
>
> spi_sync(to_spi_device(glue->dev), );
> +
> +   /* Send extra clocks with CS high. this is required by the wilink
> +* family in order for successfully enter WSPI mode
> +*/
> +   gpio_direction_output(master->cs_gpios[0], 1);
> +
> +   memset(, 0, sizeof(m));
> +   spi_message_init();
> +
> +   cmd[0] = 0xff;
> +   cmd[1] = 0xff;
> +   cmd[2] = 0xff;
> +   cmd[3] = 0xff;
> +   swab32s((u32 *)cmd);
> +
> +   t.tx_buf = cmd;
> +   t.len = 4;
> +   spi_message_add_tail(, );
> +   spi_sync(to_spi_device(glue->dev), );
> +
> kfree(cmd);
>  }
>
> @@ -213,6 +259,16 @@ static int __must_check wl12xx_spi_raw_read(struct 
> device *child, int addr,
> u32 *busy_buf;
> u32 *cmd;
> u32 chunk_len;
> +   struct spi_device *spi = (struct spi_device *)glue->dev;
> +   struct spi_master *master = spi->master;
> +
> +   if (!master->cs_gpios) {
> +   dev_err(child->parent,
> +   "spi chip select pin missing in platform data!\n");
> +   return -EINVAL;
> +   }
> +   /* Drive CS line low */
> +   gpio_direction_output(master->cs_gpios[0], 0);
>
> while (len > 0) {
> chunk_len = min_t(size_t,