Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-08-19 Thread Wenyou.Yang
Hi Jagan,

> -Original Message-
> From: Jagan Teki [mailto:jagannadh.t...@gmail.com]
> Sent: 2016年8月19日 19:36
> To: Wenyou Yang - A41535 <wenyou.y...@microchip.com>
> Cc: Wenyou Yang - A41535 <wenyou.y...@microchip.com>; u-
> b...@lists.denx.de
> Subject: Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the 
> spi
> driver
> 
> On 8 August 2016 at 06:14,  <wenyou.y...@microchip.com> wrote:
> > Hi Jagan,
> >
> >> -Original Message-
> >> From: Jagan Teki [mailto:jagannadh.t...@gmail.com]
> >> Sent: 2016年8月6日 21:00
> >> To: Wenyou Yang <wenyou.y...@atmel.com>
> >> Cc: U-Boot Mailing List <u-boot@lists.denx.de>
> >> Subject: Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support
> >> for the spi driver
> >>
> >> On 31 July 2016 at 17:05, Jagan Teki <jagannadh.t...@gmail.com> wrote:
> >> > On 29 July 2016 at 06:08, Wenyou Yang <wenyou.y...@atmel.com> wrote:
> >> >> Add driver model support while retaining the existing legacy code.
> >> >> This allows the driver to support boards that have converted to
> >> >> driver model as well as those that have not.
> >>
> >> Need some info - how many boards still pending to use this driver to use 
> >> it in
> dm?
> >
> > For now, only sama5d2_xplained has used this drive in dm, other boards
> > with AT91 SoC has not used dm driver, such as at91sam9g20ek, at91sam9x5ek,
> at91sam9m10g45ek, sama5d3xek. sama5d4ek, 
> 
> Please convert these boards to dm as well, because driver still have non-dm 
> code
> never know when it gets removed.

Okay, we will convert them.

Thank you for your reminder.

> 
> thanks!
> --
> Jagan.


Best Regards,
Wenyou Yang
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-08-19 Thread Jagan Teki
On 19 August 2016 at 18:26, Andreas Bießmann  wrote:
> On 2016-08-19 14:48, Jagan Teki wrote:
>>



>
> It would be hard to verify it, if you would have taken that task ... So I'll
> do it, with a lower priority sometime next months.

OK.

thanks!
-- 
Jagan.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-08-19 Thread Andreas Bießmann

On 2016-08-19 14:48, Jagan Teki wrote:
On 19 August 2016 at 18:16, Andreas Bießmann  
wrote:




non-dm code has to live for some time since this is a shared driver 
for
avr32 and arm architecture of atmel SoC. Unfortunately avr32 still 
lacks

dm
support in u-boot. I have some prepared patches but AFAIR there was 
a
problem with early malloc ... after that I had no time to get it 
done.


Beside that I also insist on converting the remaining at91 boards to 
dm.
Since there are some boards I would suggest a time frame until end 
of

this
year.



OK, look like avr32 should be a blocker here since at91 boards can do
at-least. What is the plan on avr32, shall I look in to it?



I hope I can look for it in next couple of month. So v2016.11 should 
be

doable, maybe v2017.01. Do you have some avr32 hardware to verify it?


Don't have.


It would be hard to verify it, if you would have taken that task ... So 
I'll do it, with a lower priority sometime next months.


Andreas



thanks!

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-08-19 Thread Jagan Teki
On 19 August 2016 at 18:16, Andreas Bießmann <andr...@biessmann.org> wrote:
> Hi Jagan,
>
>
> On 2016-08-19 14:10, Jagan Teki wrote:
>>
>> Hi Andreas,
>>
>> On 19 August 2016 at 17:20, Andreas Bießmann <andr...@biessmann.de> wrote:
>>>
>>> Hi Jagan,
>>>
>>> On 2016-08-19 13:35, Jagan Teki wrote:
>>>>
>>>>
>>>> On 8 August 2016 at 06:14,  <wenyou.y...@microchip.com> wrote:
>>>>>
>>>>>
>>>>> Hi Jagan,
>>>>>
>>>>>> -Original Message-
>>>>>> From: Jagan Teki [mailto:jagannadh.t...@gmail.com]
>>>>>> Sent: 2016年8月6日 21:00
>>>>>> To: Wenyou Yang <wenyou.y...@atmel.com>
>>>>>> Cc: U-Boot Mailing List <u-boot@lists.denx.de>
>>>>>> Subject: Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support
>>>>>> for
>>>>>> the spi
>>>>>> driver
>>>>>>
>>>>>> On 31 July 2016 at 17:05, Jagan Teki <jagannadh.t...@gmail.com> wrote:
>>>>>> > On 29 July 2016 at 06:08, Wenyou Yang <wenyou.y...@atmel.com> wrote:
>>>>>> >> Add driver model support while retaining the existing legacy code.
>>>>>> >> This allows the driver to support boards that have converted to
>>>>>> >> driver model as well as those that have not.
>>>>>>
>>>>>> Need some info - how many boards still pending to use this driver to
>>>>>> use
>>>>>> it in dm?
>>>>>
>>>>>
>>>>>
>>>>> For now, only sama5d2_xplained has used this drive in dm, other boards
>>>>> with AT91 SoC has not used dm driver,
>>>>> such as at91sam9g20ek, at91sam9x5ek, at91sam9m10g45ek, sama5d3xek.
>>>>> sama5d4ek, 
>>>>
>>>>
>>>>
>>>> Please convert these boards to dm as well, because driver still have
>>>> non-dm code never know when it gets removed.
>>>
>>>
>>>
>>> non-dm code has to live for some time since this is a shared driver for
>>> avr32 and arm architecture of atmel SoC. Unfortunately avr32 still lacks
>>> dm
>>> support in u-boot. I have some prepared patches but AFAIR there was a
>>> problem with early malloc ... after that I had no time to get it done.
>>>
>>> Beside that I also insist on converting the remaining at91 boards to dm.
>>> Since there are some boards I would suggest a time frame until end of
>>> this
>>> year.
>>
>>
>> OK, look like avr32 should be a blocker here since at91 boards can do
>> at-least. What is the plan on avr32, shall I look in to it?
>
>
> I hope I can look for it in next couple of month. So v2016.11 should be
> doable, maybe v2017.01. Do you have some avr32 hardware to verify it?

Don't have.

thanks!
-- 
Jagan.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-08-19 Thread Andreas Bießmann

Hi Jagan,

On 2016-08-19 14:10, Jagan Teki wrote:

Hi Andreas,

On 19 August 2016 at 17:20, Andreas Bießmann <andr...@biessmann.de> 
wrote:

Hi Jagan,

On 2016-08-19 13:35, Jagan Teki wrote:


On 8 August 2016 at 06:14,  <wenyou.y...@microchip.com> wrote:


Hi Jagan,


-Original Message-
From: Jagan Teki [mailto:jagannadh.t...@gmail.com]
Sent: 2016年8月6日 21:00
To: Wenyou Yang <wenyou.y...@atmel.com>
Cc: U-Boot Mailing List <u-boot@lists.denx.de>
Subject: Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support 
for

the spi
driver

On 31 July 2016 at 17:05, Jagan Teki <jagannadh.t...@gmail.com> 
wrote:

> On 29 July 2016 at 06:08, Wenyou Yang <wenyou.y...@atmel.com> wrote:
>> Add driver model support while retaining the existing legacy code.
>> This allows the driver to support boards that have converted to
>> driver model as well as those that have not.

Need some info - how many boards still pending to use this driver 
to use

it in dm?



For now, only sama5d2_xplained has used this drive in dm, other 
boards

with AT91 SoC has not used dm driver,
such as at91sam9g20ek, at91sam9x5ek, at91sam9m10g45ek, sama5d3xek.
sama5d4ek, 



Please convert these boards to dm as well, because driver still have
non-dm code never know when it gets removed.



non-dm code has to live for some time since this is a shared driver 
for
avr32 and arm architecture of atmel SoC. Unfortunately avr32 still 
lacks dm

support in u-boot. I have some prepared patches but AFAIR there was a
problem with early malloc ... after that I had no time to get it done.

Beside that I also insist on converting the remaining at91 boards to 
dm.
Since there are some boards I would suggest a time frame until end of 
this

year.


OK, look like avr32 should be a blocker here since at91 boards can do
at-least. What is the plan on avr32, shall I look in to it?


I hope I can look for it in next couple of month. So v2016.11 should be 
doable, maybe v2017.01. Do you have some avr32 hardware to verify it?


Andreas



thanks!

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-08-19 Thread Jagan Teki
On 8 August 2016 at 06:14,  <wenyou.y...@microchip.com> wrote:
> Hi Jagan,
>
>> -Original Message-
>> From: Jagan Teki [mailto:jagannadh.t...@gmail.com]
>> Sent: 2016年8月6日 21:00
>> To: Wenyou Yang <wenyou.y...@atmel.com>
>> Cc: U-Boot Mailing List <u-boot@lists.denx.de>
>> Subject: Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the 
>> spi
>> driver
>>
>> On 31 July 2016 at 17:05, Jagan Teki <jagannadh.t...@gmail.com> wrote:
>> > On 29 July 2016 at 06:08, Wenyou Yang <wenyou.y...@atmel.com> wrote:
>> >> Add driver model support while retaining the existing legacy code.
>> >> This allows the driver to support boards that have converted to
>> >> driver model as well as those that have not.
>>
>> Need some info - how many boards still pending to use this driver to use it 
>> in dm?
>
> For now, only sama5d2_xplained has used this drive in dm, other boards with 
> AT91 SoC has not used dm driver,
> such as at91sam9g20ek, at91sam9x5ek, at91sam9m10g45ek, sama5d3xek. sama5d4ek, 
> 

Please convert these boards to dm as well, because driver still have
non-dm code never know when it gets removed.

thanks!
-- 
Jagan.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-08-18 Thread Andreas Bießmann

Hi Wenyou,

On 2016-08-18 03:16, wenyou.y...@microchip.com wrote:

Hi Andreas,


-Original Message-
From: Andreas Bießmann [mailto:andr...@biessmann.org]
Sent: 2016年8月16日 5:15
To: Wenyou Yang ; U-Boot Mailing List 
Cc: Simon Glass ; Jagan Teki 
Subject: Re: [PATCH v7] dm: at91: Add driver model support for the spi 
driver


Hi Wenyou,

On 29.07.16 02:38, Wenyou Yang wrote:
> Add driver model support while retaining the existing legacy code.
> This allows the driver to support boards that have converted to driver
> model as well as those that have not.
>
> Signed-off-by: Wenyou Yang 
> Reviewed-by: Simon Glass 

This one breaks avr32 boards:

---8<---
02: dm: at91: Add driver model support for the spi driver
 avr32:  +   atngw100 atngw100mkii
+../drivers/spi/atmel_spi.c:17:31: error: asm/arch/at91_spi.h: No such
file or directory
+../drivers/spi/atmel_spi.c:18:22: error: asm/gpio.h: No such file or
directory
+make[2]: *** [drivers/spi/atmel_spi.o] Error 1
+make[1]: *** [drivers/spi] Error 2
+make: *** [sub-make] Error 2
--->8---


It seems this error is not introduced by this patch.


Well, I think it is introduced by this patch. This patch chenges the 
atmel_cpi driver in such a way that it breaks for avr32 architecture 
which has a slight different structure in files.



Can we apply this patch first?


No, not if it breaks AVR32.

Andreas





please fix this

Andreas

> ---
>
> Changes in v7:
>  - Move gpio_request_list_by_name() to _probe(), remove
>*_ofdata_to_platdata().
>
> Changes in v6:
>  - Remove the two flash related options.
>
> Changes in v5:
>  - Change clk_client.h -> clk.h to adapt to clk API conversion.
>
> Changes in v4:
>  - Collect Reviewed-by tag.
>  - Update the clk API based on [PATCH] clk: convert API to match
>reset/mailbox fstyle (http://patchwork.ozlabs.org/patch/625342/).
>  - Remove check on dev_get_parent() return.
>  - Fixed the return value, -ENODEV->-EINVAL.
>  - Retain #include  line.
>
> Changes in v3:
>  - Remove redundant log print.
>
> Changes in v2:
>  - Add clock support.
>
>  drivers/spi/Kconfig |   7 ++
>  drivers/spi/atmel_spi.c | 295
> 
>  2 files changed, 302 insertions(+)
>
> diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index
> aca385d..16ed231 100644
> --- a/drivers/spi/Kconfig
> +++ b/drivers/spi/Kconfig
> @@ -32,6 +32,13 @@ config ATH79_SPI
>  uses driver model and requires a device tree binding to operate.
>  please refer to doc/device-tree-bindings/spi/spi-ath79.txt.
>
> +config ATMEL_SPI
> +  bool "Atmel SPI driver"
> +  depends on ARCH_AT91
> +  help
> +Enable the Atmel SPI driver. This driver can be used to access
> +the SPI Flash, such as AT25DF321.
> +
>  config CADENCE_QSPI
>bool "Cadence QSPI driver"
>help
> diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index
> ed6278b..db40631 100644
> --- a/drivers/spi/atmel_spi.c
> +++ b/drivers/spi/atmel_spi.c
> @@ -4,6 +4,9 @@
>   * SPDX-License-Identifier:   GPL-2.0+
>   */
>  #include 
> +#include 
> +#include 
> +#include 
>  #include 
>  #include 
>
> @@ -11,9 +14,15 @@
>
>  #include 
>  #include 
> +#include 
> +#include 
>
>  #include "atmel_spi.h"
>
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#ifndef CONFIG_DM_SPI
> +
>  static int spi_has_wdrbt(struct atmel_spi_slave *slave)  {
>unsigned int ver;
> @@ -209,3 +218,289 @@ out:
>
>return 0;
>  }
> +
> +#else
> +
> +#define MAX_CS_COUNT  4
> +
> +struct atmel_spi_platdata {
> +  struct at91_spi *regs;
> +};
> +
> +struct atmel_spi_priv {
> +  unsigned int freq;  /* Default frequency */
> +  unsigned int mode;
> +  ulong bus_clk_rate;
> +  struct gpio_desc cs_gpios[MAX_CS_COUNT]; };
> +
> +static int atmel_spi_claim_bus(struct udevice *dev) {
> +  struct udevice *bus = dev_get_parent(dev);
> +  struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus);
> +  struct atmel_spi_priv *priv = dev_get_priv(bus);
> +  struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
> +  struct at91_spi *reg_base = bus_plat->regs;
> +  u32 cs = slave_plat->cs;
> +  u32 freq = priv->freq;
> +  u32 scbr, csrx, mode;
> +
> +  scbr = (priv->bus_clk_rate + freq - 1) / freq;
> +  if (scbr > ATMEL_SPI_CSRx_SCBR_MAX)
> +  return -EINVAL;
> +
> +  if (scbr < 1)
> +  scbr = 1;
> +
> +  csrx = ATMEL_SPI_CSRx_SCBR(scbr);
> +  csrx |= ATMEL_SPI_CSRx_BITS(ATMEL_SPI_BITS_8);
> +
> +  if (!(priv->mode & SPI_CPHA))
> +  csrx |= ATMEL_SPI_CSRx_NCPHA;
> +  if (priv->mode & SPI_CPOL)
> +  csrx |= ATMEL_SPI_CSRx_CPOL;
> +
> +  writel(csrx, _base->csr[cs]);
> +
> +  mode = ATMEL_SPI_MR_MSTR |
> + ATMEL_SPI_MR_MODFDIS |
> + ATMEL_SPI_MR_WDRBT |
> + ATMEL_SPI_MR_PCS(~(1 << cs));
> +
> +  writel(mode, _base->mr);
> +
> +  writel(ATMEL_SPI_CR_SPIEN, _base->cr);
> +
> +  return 0;
> 

Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-08-17 Thread Wenyou.Yang
Hi Andreas,

> -Original Message-
> From: Andreas Bießmann [mailto:andr...@biessmann.org]
> Sent: 2016年8月16日 5:15
> To: Wenyou Yang ; U-Boot Mailing List  b...@lists.denx.de>
> Cc: Simon Glass ; Jagan Teki 
> Subject: Re: [PATCH v7] dm: at91: Add driver model support for the spi driver
> 
> Hi Wenyou,
> 
> On 29.07.16 02:38, Wenyou Yang wrote:
> > Add driver model support while retaining the existing legacy code.
> > This allows the driver to support boards that have converted to driver
> > model as well as those that have not.
> >
> > Signed-off-by: Wenyou Yang 
> > Reviewed-by: Simon Glass 
> 
> This one breaks avr32 boards:
> 
> ---8<---
> 02: dm: at91: Add driver model support for the spi driver
>  avr32:  +   atngw100 atngw100mkii
> +../drivers/spi/atmel_spi.c:17:31: error: asm/arch/at91_spi.h: No such
> file or directory
> +../drivers/spi/atmel_spi.c:18:22: error: asm/gpio.h: No such file or
> directory
> +make[2]: *** [drivers/spi/atmel_spi.o] Error 1
> +make[1]: *** [drivers/spi] Error 2
> +make: *** [sub-make] Error 2
> --->8---

It seems this error is not introduced by this patch.

Can we apply this patch first?

> 
> please fix this
> 
> Andreas
> 
> > ---
> >
> > Changes in v7:
> >  - Move gpio_request_list_by_name() to _probe(), remove
> >*_ofdata_to_platdata().
> >
> > Changes in v6:
> >  - Remove the two flash related options.
> >
> > Changes in v5:
> >  - Change clk_client.h -> clk.h to adapt to clk API conversion.
> >
> > Changes in v4:
> >  - Collect Reviewed-by tag.
> >  - Update the clk API based on [PATCH] clk: convert API to match
> >reset/mailbox fstyle (http://patchwork.ozlabs.org/patch/625342/).
> >  - Remove check on dev_get_parent() return.
> >  - Fixed the return value, -ENODEV->-EINVAL.
> >  - Retain #include  line.
> >
> > Changes in v3:
> >  - Remove redundant log print.
> >
> > Changes in v2:
> >  - Add clock support.
> >
> >  drivers/spi/Kconfig |   7 ++
> >  drivers/spi/atmel_spi.c | 295
> > 
> >  2 files changed, 302 insertions(+)
> >
> > diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index
> > aca385d..16ed231 100644
> > --- a/drivers/spi/Kconfig
> > +++ b/drivers/spi/Kconfig
> > @@ -32,6 +32,13 @@ config ATH79_SPI
> >   uses driver model and requires a device tree binding to operate.
> >   please refer to doc/device-tree-bindings/spi/spi-ath79.txt.
> >
> > +config ATMEL_SPI
> > +   bool "Atmel SPI driver"
> > +   depends on ARCH_AT91
> > +   help
> > + Enable the Atmel SPI driver. This driver can be used to access
> > + the SPI Flash, such as AT25DF321.
> > +
> >  config CADENCE_QSPI
> > bool "Cadence QSPI driver"
> > help
> > diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index
> > ed6278b..db40631 100644
> > --- a/drivers/spi/atmel_spi.c
> > +++ b/drivers/spi/atmel_spi.c
> > @@ -4,6 +4,9 @@
> >   * SPDX-License-Identifier:GPL-2.0+
> >   */
> >  #include 
> > +#include 
> > +#include 
> > +#include 
> >  #include 
> >  #include 
> >
> > @@ -11,9 +14,15 @@
> >
> >  #include 
> >  #include 
> > +#include 
> > +#include 
> >
> >  #include "atmel_spi.h"
> >
> > +DECLARE_GLOBAL_DATA_PTR;
> > +
> > +#ifndef CONFIG_DM_SPI
> > +
> >  static int spi_has_wdrbt(struct atmel_spi_slave *slave)  {
> > unsigned int ver;
> > @@ -209,3 +218,289 @@ out:
> >
> > return 0;
> >  }
> > +
> > +#else
> > +
> > +#define MAX_CS_COUNT   4
> > +
> > +struct atmel_spi_platdata {
> > +   struct at91_spi *regs;
> > +};
> > +
> > +struct atmel_spi_priv {
> > +   unsigned int freq;  /* Default frequency */
> > +   unsigned int mode;
> > +   ulong bus_clk_rate;
> > +   struct gpio_desc cs_gpios[MAX_CS_COUNT]; };
> > +
> > +static int atmel_spi_claim_bus(struct udevice *dev) {
> > +   struct udevice *bus = dev_get_parent(dev);
> > +   struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus);
> > +   struct atmel_spi_priv *priv = dev_get_priv(bus);
> > +   struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
> > +   struct at91_spi *reg_base = bus_plat->regs;
> > +   u32 cs = slave_plat->cs;
> > +   u32 freq = priv->freq;
> > +   u32 scbr, csrx, mode;
> > +
> > +   scbr = (priv->bus_clk_rate + freq - 1) / freq;
> > +   if (scbr > ATMEL_SPI_CSRx_SCBR_MAX)
> > +   return -EINVAL;
> > +
> > +   if (scbr < 1)
> > +   scbr = 1;
> > +
> > +   csrx = ATMEL_SPI_CSRx_SCBR(scbr);
> > +   csrx |= ATMEL_SPI_CSRx_BITS(ATMEL_SPI_BITS_8);
> > +
> > +   if (!(priv->mode & SPI_CPHA))
> > +   csrx |= ATMEL_SPI_CSRx_NCPHA;
> > +   if (priv->mode & SPI_CPOL)
> > +   csrx |= ATMEL_SPI_CSRx_CPOL;
> > +
> > +   writel(csrx, _base->csr[cs]);
> > +
> > +   mode = ATMEL_SPI_MR_MSTR |
> > +  ATMEL_SPI_MR_MODFDIS |
> > +  ATMEL_SPI_MR_WDRBT |
> > +  ATMEL_SPI_MR_PCS(~(1 << cs));
> > +
> > +   

Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-08-15 Thread Andreas Bießmann
Hi Wenyou,

On 29.07.16 02:38, Wenyou Yang wrote:
> Add driver model support while retaining the existing legacy code.
> This allows the driver to support boards that have converted to
> driver model as well as those that have not.
> 
> Signed-off-by: Wenyou Yang 
> Reviewed-by: Simon Glass 

This one breaks avr32 boards:

---8<---
02: dm: at91: Add driver model support for the spi driver
 avr32:  +   atngw100 atngw100mkii
+../drivers/spi/atmel_spi.c:17:31: error: asm/arch/at91_spi.h: No such
file or directory
+../drivers/spi/atmel_spi.c:18:22: error: asm/gpio.h: No such file or
directory
+make[2]: *** [drivers/spi/atmel_spi.o] Error 1
+make[1]: *** [drivers/spi] Error 2
+make: *** [sub-make] Error 2
--->8---

please fix this

Andreas

> ---
> 
> Changes in v7:
>  - Move gpio_request_list_by_name() to _probe(), remove
>*_ofdata_to_platdata().
> 
> Changes in v6:
>  - Remove the two flash related options.
> 
> Changes in v5:
>  - Change clk_client.h -> clk.h to adapt to clk API conversion.
> 
> Changes in v4:
>  - Collect Reviewed-by tag.
>  - Update the clk API based on [PATCH] clk: convert API to match
>reset/mailbox fstyle (http://patchwork.ozlabs.org/patch/625342/).
>  - Remove check on dev_get_parent() return.
>  - Fixed the return value, -ENODEV->-EINVAL.
>  - Retain #include  line.
> 
> Changes in v3:
>  - Remove redundant log print.
> 
> Changes in v2:
>  - Add clock support.
> 
>  drivers/spi/Kconfig |   7 ++
>  drivers/spi/atmel_spi.c | 295 
> 
>  2 files changed, 302 insertions(+)
> 
> diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
> index aca385d..16ed231 100644
> --- a/drivers/spi/Kconfig
> +++ b/drivers/spi/Kconfig
> @@ -32,6 +32,13 @@ config ATH79_SPI
> uses driver model and requires a device tree binding to operate.
> please refer to doc/device-tree-bindings/spi/spi-ath79.txt.
>  
> +config ATMEL_SPI
> + bool "Atmel SPI driver"
> + depends on ARCH_AT91
> + help
> +   Enable the Atmel SPI driver. This driver can be used to access
> +   the SPI Flash, such as AT25DF321.
> +
>  config CADENCE_QSPI
>   bool "Cadence QSPI driver"
>   help
> diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
> index ed6278b..db40631 100644
> --- a/drivers/spi/atmel_spi.c
> +++ b/drivers/spi/atmel_spi.c
> @@ -4,6 +4,9 @@
>   * SPDX-License-Identifier:  GPL-2.0+
>   */
>  #include 
> +#include 
> +#include 
> +#include 
>  #include 
>  #include 
>  
> @@ -11,9 +14,15 @@
>  
>  #include 
>  #include 
> +#include 
> +#include 
>  
>  #include "atmel_spi.h"
>  
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#ifndef CONFIG_DM_SPI
> +
>  static int spi_has_wdrbt(struct atmel_spi_slave *slave)
>  {
>   unsigned int ver;
> @@ -209,3 +218,289 @@ out:
>  
>   return 0;
>  }
> +
> +#else
> +
> +#define MAX_CS_COUNT 4
> +
> +struct atmel_spi_platdata {
> + struct at91_spi *regs;
> +};
> +
> +struct atmel_spi_priv {
> + unsigned int freq;  /* Default frequency */
> + unsigned int mode;
> + ulong bus_clk_rate;
> + struct gpio_desc cs_gpios[MAX_CS_COUNT];
> +};
> +
> +static int atmel_spi_claim_bus(struct udevice *dev)
> +{
> + struct udevice *bus = dev_get_parent(dev);
> + struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus);
> + struct atmel_spi_priv *priv = dev_get_priv(bus);
> + struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
> + struct at91_spi *reg_base = bus_plat->regs;
> + u32 cs = slave_plat->cs;
> + u32 freq = priv->freq;
> + u32 scbr, csrx, mode;
> +
> + scbr = (priv->bus_clk_rate + freq - 1) / freq;
> + if (scbr > ATMEL_SPI_CSRx_SCBR_MAX)
> + return -EINVAL;
> +
> + if (scbr < 1)
> + scbr = 1;
> +
> + csrx = ATMEL_SPI_CSRx_SCBR(scbr);
> + csrx |= ATMEL_SPI_CSRx_BITS(ATMEL_SPI_BITS_8);
> +
> + if (!(priv->mode & SPI_CPHA))
> + csrx |= ATMEL_SPI_CSRx_NCPHA;
> + if (priv->mode & SPI_CPOL)
> + csrx |= ATMEL_SPI_CSRx_CPOL;
> +
> + writel(csrx, _base->csr[cs]);
> +
> + mode = ATMEL_SPI_MR_MSTR |
> +ATMEL_SPI_MR_MODFDIS |
> +ATMEL_SPI_MR_WDRBT |
> +ATMEL_SPI_MR_PCS(~(1 << cs));
> +
> + writel(mode, _base->mr);
> +
> + writel(ATMEL_SPI_CR_SPIEN, _base->cr);
> +
> + return 0;
> +}
> +
> +static int atmel_spi_release_bus(struct udevice *dev)
> +{
> + struct udevice *bus = dev_get_parent(dev);
> + struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus);
> +
> + writel(ATMEL_SPI_CR_SPIDIS, _plat->regs->cr);
> +
> + return 0;
> +}
> +
> +static void atmel_spi_cs_activate(struct udevice *dev)
> +{
> + struct udevice *bus = dev_get_parent(dev);
> + struct atmel_spi_priv *priv = dev_get_priv(bus);
> + struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
> + u32 cs = slave_plat->cs;
> +
> +   

Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-08-08 Thread Wenyou.Yang
Hi Jagan,

> -Original Message-
> From: Jagan Teki [mailto:jagannadh.t...@gmail.com]
> Sent: 2016年8月6日 21:00
> To: Wenyou Yang <wenyou.y...@atmel.com>
> Cc: U-Boot Mailing List <u-boot@lists.denx.de>
> Subject: Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the 
> spi
> driver
> 
> On 31 July 2016 at 17:05, Jagan Teki <jagannadh.t...@gmail.com> wrote:
> > On 29 July 2016 at 06:08, Wenyou Yang <wenyou.y...@atmel.com> wrote:
> >> Add driver model support while retaining the existing legacy code.
> >> This allows the driver to support boards that have converted to
> >> driver model as well as those that have not.
> 
> Need some info - how many boards still pending to use this driver to use it 
> in dm?

For now, only sama5d2_xplained has used this drive in dm, other boards with 
AT91 SoC has not used dm driver,
such as at91sam9g20ek, at91sam9x5ek, at91sam9m10g45ek, sama5d3xek. sama5d4ek, 



Best Regards,
Wenyou Yang
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-08-06 Thread Jagan Teki
On 31 July 2016 at 17:05, Jagan Teki  wrote:
> On 29 July 2016 at 06:08, Wenyou Yang  wrote:
>> Add driver model support while retaining the existing legacy code.
>> This allows the driver to support boards that have converted to
>> driver model as well as those that have not.

Need some info - how many boards still pending to use this driver to
use it in dm?

-- 
Jagan.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-07-31 Thread Jagan Teki
On 29 July 2016 at 06:08, Wenyou Yang  wrote:
> Add driver model support while retaining the existing legacy code.
> This allows the driver to support boards that have converted to
> driver model as well as those that have not.
>
> Signed-off-by: Wenyou Yang 
> Reviewed-by: Simon Glass 
> ---

Applied to u-boot-spi/master

-- 
Jagan.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-07-29 Thread Jagan Teki
On 29 July 2016 at 09:10, Heiko Schocher  wrote:
> Hello Wenyou,
>
>
> Am 29.07.2016 um 02:38 schrieb Wenyou Yang:
>>
>> Add driver model support while retaining the existing legacy code.
>> This allows the driver to support boards that have converted to
>> driver model as well as those that have not.
>>
>> Signed-off-by: Wenyou Yang 
>> Reviewed-by: Simon Glass 
>> ---
>>
>> Changes in v7:
>>   - Move gpio_request_list_by_name() to _probe(), remove
>> *_ofdata_to_platdata().
>>
>> Changes in v6:
>>   - Remove the two flash related options.
>>
>> Changes in v5:
>>   - Change clk_client.h -> clk.h to adapt to clk API conversion.
>>
>> Changes in v4:
>>   - Collect Reviewed-by tag.
>>   - Update the clk API based on [PATCH] clk: convert API to match
>> reset/mailbox fstyle (http://patchwork.ozlabs.org/patch/625342/).
>>   - Remove check on dev_get_parent() return.
>>   - Fixed the return value, -ENODEV->-EINVAL.
>>   - Retain #include  line.
>>
>> Changes in v3:
>>   - Remove redundant log print.
>>
>> Changes in v2:
>>   - Add clock support.
>>
>>   drivers/spi/Kconfig |   7 ++
>>   drivers/spi/atmel_spi.c | 295
>> 
>>   2 files changed, 302 insertions(+)
>
>
> Reviewed-by: Heiko Schocher 

Reviewed-by: Jagan Teki 

-- 
Jagan.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-07-28 Thread Heiko Schocher

Hello Wenyou,

Am 29.07.2016 um 02:38 schrieb Wenyou Yang:

Add driver model support while retaining the existing legacy code.
This allows the driver to support boards that have converted to
driver model as well as those that have not.

Signed-off-by: Wenyou Yang 
Reviewed-by: Simon Glass 
---

Changes in v7:
  - Move gpio_request_list_by_name() to _probe(), remove
*_ofdata_to_platdata().

Changes in v6:
  - Remove the two flash related options.

Changes in v5:
  - Change clk_client.h -> clk.h to adapt to clk API conversion.

Changes in v4:
  - Collect Reviewed-by tag.
  - Update the clk API based on [PATCH] clk: convert API to match
reset/mailbox fstyle (http://patchwork.ozlabs.org/patch/625342/).
  - Remove check on dev_get_parent() return.
  - Fixed the return value, -ENODEV->-EINVAL.
  - Retain #include  line.

Changes in v3:
  - Remove redundant log print.

Changes in v2:
  - Add clock support.

  drivers/spi/Kconfig |   7 ++
  drivers/spi/atmel_spi.c | 295 
  2 files changed, 302 insertions(+)


Reviewed-by: Heiko Schocher 

bye,
Heiko


diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index aca385d..16ed231 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -32,6 +32,13 @@ config ATH79_SPI
  uses driver model and requires a device tree binding to operate.
  please refer to doc/device-tree-bindings/spi/spi-ath79.txt.

+config ATMEL_SPI
+   bool "Atmel SPI driver"
+   depends on ARCH_AT91
+   help
+ Enable the Atmel SPI driver. This driver can be used to access
+ the SPI Flash, such as AT25DF321.
+
  config CADENCE_QSPI
bool "Cadence QSPI driver"
help
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index ed6278b..db40631 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -4,6 +4,9 @@
   * SPDX-License-Identifier:   GPL-2.0+
   */
  #include 
+#include 
+#include 
+#include 
  #include 
  #include 

@@ -11,9 +14,15 @@

  #include 
  #include 
+#include 
+#include 

  #include "atmel_spi.h"

+DECLARE_GLOBAL_DATA_PTR;
+
+#ifndef CONFIG_DM_SPI
+
  static int spi_has_wdrbt(struct atmel_spi_slave *slave)
  {
unsigned int ver;
@@ -209,3 +218,289 @@ out:

return 0;
  }
+
+#else
+
+#define MAX_CS_COUNT   4
+
+struct atmel_spi_platdata {
+   struct at91_spi *regs;
+};
+
+struct atmel_spi_priv {
+   unsigned int freq;  /* Default frequency */
+   unsigned int mode;
+   ulong bus_clk_rate;
+   struct gpio_desc cs_gpios[MAX_CS_COUNT];
+};
+
+static int atmel_spi_claim_bus(struct udevice *dev)
+{
+   struct udevice *bus = dev_get_parent(dev);
+   struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus);
+   struct atmel_spi_priv *priv = dev_get_priv(bus);
+   struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
+   struct at91_spi *reg_base = bus_plat->regs;
+   u32 cs = slave_plat->cs;
+   u32 freq = priv->freq;
+   u32 scbr, csrx, mode;
+
+   scbr = (priv->bus_clk_rate + freq - 1) / freq;
+   if (scbr > ATMEL_SPI_CSRx_SCBR_MAX)
+   return -EINVAL;
+
+   if (scbr < 1)
+   scbr = 1;
+
+   csrx = ATMEL_SPI_CSRx_SCBR(scbr);
+   csrx |= ATMEL_SPI_CSRx_BITS(ATMEL_SPI_BITS_8);
+
+   if (!(priv->mode & SPI_CPHA))
+   csrx |= ATMEL_SPI_CSRx_NCPHA;
+   if (priv->mode & SPI_CPOL)
+   csrx |= ATMEL_SPI_CSRx_CPOL;
+
+   writel(csrx, _base->csr[cs]);
+
+   mode = ATMEL_SPI_MR_MSTR |
+  ATMEL_SPI_MR_MODFDIS |
+  ATMEL_SPI_MR_WDRBT |
+  ATMEL_SPI_MR_PCS(~(1 << cs));
+
+   writel(mode, _base->mr);
+
+   writel(ATMEL_SPI_CR_SPIEN, _base->cr);
+
+   return 0;
+}
+
+static int atmel_spi_release_bus(struct udevice *dev)
+{
+   struct udevice *bus = dev_get_parent(dev);
+   struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus);
+
+   writel(ATMEL_SPI_CR_SPIDIS, _plat->regs->cr);
+
+   return 0;
+}
+
+static void atmel_spi_cs_activate(struct udevice *dev)
+{
+   struct udevice *bus = dev_get_parent(dev);
+   struct atmel_spi_priv *priv = dev_get_priv(bus);
+   struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
+   u32 cs = slave_plat->cs;
+
+   dm_gpio_set_value(>cs_gpios[cs], 0);
+}
+
+static void atmel_spi_cs_deactivate(struct udevice *dev)
+{
+   struct udevice *bus = dev_get_parent(dev);
+   struct atmel_spi_priv *priv = dev_get_priv(bus);
+   struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
+   u32 cs = slave_plat->cs;
+
+   dm_gpio_set_value(>cs_gpios[cs], 1);
+}
+
+static int atmel_spi_xfer(struct udevice *dev, unsigned int bitlen,
+ const void *dout, void *din, unsigned long flags)
+{
+   struct udevice *bus = dev_get_parent(dev);
+   

[U-Boot] [PATCH v7] dm: at91: Add driver model support for the spi driver

2016-07-28 Thread Wenyou Yang
Add driver model support while retaining the existing legacy code.
This allows the driver to support boards that have converted to
driver model as well as those that have not.

Signed-off-by: Wenyou Yang 
Reviewed-by: Simon Glass 
---

Changes in v7:
 - Move gpio_request_list_by_name() to _probe(), remove
   *_ofdata_to_platdata().

Changes in v6:
 - Remove the two flash related options.

Changes in v5:
 - Change clk_client.h -> clk.h to adapt to clk API conversion.

Changes in v4:
 - Collect Reviewed-by tag.
 - Update the clk API based on [PATCH] clk: convert API to match
   reset/mailbox fstyle (http://patchwork.ozlabs.org/patch/625342/).
 - Remove check on dev_get_parent() return.
 - Fixed the return value, -ENODEV->-EINVAL.
 - Retain #include  line.

Changes in v3:
 - Remove redundant log print.

Changes in v2:
 - Add clock support.

 drivers/spi/Kconfig |   7 ++
 drivers/spi/atmel_spi.c | 295 
 2 files changed, 302 insertions(+)

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index aca385d..16ed231 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -32,6 +32,13 @@ config ATH79_SPI
  uses driver model and requires a device tree binding to operate.
  please refer to doc/device-tree-bindings/spi/spi-ath79.txt.
 
+config ATMEL_SPI
+   bool "Atmel SPI driver"
+   depends on ARCH_AT91
+   help
+ Enable the Atmel SPI driver. This driver can be used to access
+ the SPI Flash, such as AT25DF321.
+
 config CADENCE_QSPI
bool "Cadence QSPI driver"
help
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index ed6278b..db40631 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -4,6 +4,9 @@
  * SPDX-License-Identifier:GPL-2.0+
  */
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -11,9 +14,15 @@
 
 #include 
 #include 
+#include 
+#include 
 
 #include "atmel_spi.h"
 
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifndef CONFIG_DM_SPI
+
 static int spi_has_wdrbt(struct atmel_spi_slave *slave)
 {
unsigned int ver;
@@ -209,3 +218,289 @@ out:
 
return 0;
 }
+
+#else
+
+#define MAX_CS_COUNT   4
+
+struct atmel_spi_platdata {
+   struct at91_spi *regs;
+};
+
+struct atmel_spi_priv {
+   unsigned int freq;  /* Default frequency */
+   unsigned int mode;
+   ulong bus_clk_rate;
+   struct gpio_desc cs_gpios[MAX_CS_COUNT];
+};
+
+static int atmel_spi_claim_bus(struct udevice *dev)
+{
+   struct udevice *bus = dev_get_parent(dev);
+   struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus);
+   struct atmel_spi_priv *priv = dev_get_priv(bus);
+   struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
+   struct at91_spi *reg_base = bus_plat->regs;
+   u32 cs = slave_plat->cs;
+   u32 freq = priv->freq;
+   u32 scbr, csrx, mode;
+
+   scbr = (priv->bus_clk_rate + freq - 1) / freq;
+   if (scbr > ATMEL_SPI_CSRx_SCBR_MAX)
+   return -EINVAL;
+
+   if (scbr < 1)
+   scbr = 1;
+
+   csrx = ATMEL_SPI_CSRx_SCBR(scbr);
+   csrx |= ATMEL_SPI_CSRx_BITS(ATMEL_SPI_BITS_8);
+
+   if (!(priv->mode & SPI_CPHA))
+   csrx |= ATMEL_SPI_CSRx_NCPHA;
+   if (priv->mode & SPI_CPOL)
+   csrx |= ATMEL_SPI_CSRx_CPOL;
+
+   writel(csrx, _base->csr[cs]);
+
+   mode = ATMEL_SPI_MR_MSTR |
+  ATMEL_SPI_MR_MODFDIS |
+  ATMEL_SPI_MR_WDRBT |
+  ATMEL_SPI_MR_PCS(~(1 << cs));
+
+   writel(mode, _base->mr);
+
+   writel(ATMEL_SPI_CR_SPIEN, _base->cr);
+
+   return 0;
+}
+
+static int atmel_spi_release_bus(struct udevice *dev)
+{
+   struct udevice *bus = dev_get_parent(dev);
+   struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus);
+
+   writel(ATMEL_SPI_CR_SPIDIS, _plat->regs->cr);
+
+   return 0;
+}
+
+static void atmel_spi_cs_activate(struct udevice *dev)
+{
+   struct udevice *bus = dev_get_parent(dev);
+   struct atmel_spi_priv *priv = dev_get_priv(bus);
+   struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
+   u32 cs = slave_plat->cs;
+
+   dm_gpio_set_value(>cs_gpios[cs], 0);
+}
+
+static void atmel_spi_cs_deactivate(struct udevice *dev)
+{
+   struct udevice *bus = dev_get_parent(dev);
+   struct atmel_spi_priv *priv = dev_get_priv(bus);
+   struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
+   u32 cs = slave_plat->cs;
+
+   dm_gpio_set_value(>cs_gpios[cs], 1);
+}
+
+static int atmel_spi_xfer(struct udevice *dev, unsigned int bitlen,
+ const void *dout, void *din, unsigned long flags)
+{
+   struct udevice *bus = dev_get_parent(dev);
+   struct atmel_spi_platdata *bus_plat = dev_get_platdata(bus);
+   struct at91_spi *reg_base = bus_plat->regs;
+
+   u32 len_tx,