diff mbox

[U-Boot,1/2] net: fm: fix spi flash probe for using driver model

Message ID 1469011169-39131-1-git-send-email-Qianyu.Gong@nxp.com
State Superseded
Delegated to: York Sun
Headers show

Commit Message

Gong Qianyu July 20, 2016, 10:39 a.m. UTC
The current code would always use the speed and mode set by
CONFIG_ENV_SPI_MAX_HZ and CONFIG_ENV_SPI_MODE. But if using
SPI driver model it should get the values from DT.

Signed-off-by: Gong Qianyu <Qianyu.Gong@nxp.com>
---
 drivers/net/fm/fm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

York Sun July 27, 2016, 5:34 p.m. UTC | #1
On 07/20/2016 03:51 AM, Gong Qianyu wrote:
> The current code would always use the speed and mode set by
> CONFIG_ENV_SPI_MAX_HZ and CONFIG_ENV_SPI_MODE. But if using
> SPI driver model it should get the values from DT.
>
> Signed-off-by: Gong Qianyu <Qianyu.Gong@nxp.com>
> ---
>  drivers/net/fm/fm.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c
> index 00cdfd4..6308d22 100644
> --- a/drivers/net/fm/fm.c
> +++ b/drivers/net/fm/fm.c
> @@ -371,8 +371,18 @@ int fm_init_common(int index, struct ccsr_fman *reg)
>  	void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
>  	int ret = 0;
>
> +#ifdef CONFIG_DM_SPI_FLASH
> +	struct udevice *new;
> +
> +	/* Will get the speed and mode from Device Tree */
> +	ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
> +				     0, 0, &new);
> +
> +	ucode_flash = dev_get_uclass_priv(new);
> +#else
>  	ucode_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
>  			CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
> +#endif
>  	if (!ucode_flash)
>  		printf("SF: probe for ucode failed\n");
>  	else {
>

Why not just use spi_flash_probe() with speed and mode passed as 0?

York
Gong Qianyu July 28, 2016, 2:36 a.m. UTC | #2
> -----Original Message-----
> From: york sun
> Sent: Thursday, July 28, 2016 1:35 AM
> To: Qianyu Gong <qianyu.gong@nxp.com>; u-boot@lists.denx.de; Prabhakar
> Kushwaha <prabhakar.kushwaha@nxp.com>; Mingkai Hu <mingkai.hu@nxp.com>
> Cc: Shaohui Xie <shaohui.xie@nxp.com>; Zhiqiang Hou <zhiqiang.hou@nxp.com>;
> Wenbin Song <wenbin.song@nxp.com>
> Subject: Re: [PATCH 1/2] net: fm: fix spi flash probe for using driver model
> 
> On 07/20/2016 03:51 AM, Gong Qianyu wrote:
> > The current code would always use the speed and mode set by
> > CONFIG_ENV_SPI_MAX_HZ and CONFIG_ENV_SPI_MODE. But if using SPI driver
> > model it should get the values from DT.
> >
> > Signed-off-by: Gong Qianyu <Qianyu.Gong@nxp.com>
> > ---
> >  drivers/net/fm/fm.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c index
> > 00cdfd4..6308d22 100644
> > --- a/drivers/net/fm/fm.c
> > +++ b/drivers/net/fm/fm.c
> > @@ -371,8 +371,18 @@ int fm_init_common(int index, struct ccsr_fman *reg)
> >  	void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
> >  	int ret = 0;
> >
> > +#ifdef CONFIG_DM_SPI_FLASH
> > +	struct udevice *new;
> > +
> > +	/* Will get the speed and mode from Device Tree */
> > +	ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS,
> CONFIG_ENV_SPI_CS,
> > +				     0, 0, &new);
> > +
> > +	ucode_flash = dev_get_uclass_priv(new); #else
> >  	ucode_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
> CONFIG_ENV_SPI_CS,
> >  			CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
> > +#endif
> >  	if (!ucode_flash)
> >  		printf("SF: probe for ucode failed\n");
> >  	else {
> >
> 
> Why not just use spi_flash_probe() with speed and mode passed as 0?
> 
> York

As Simon said spi_flash_probe() "is an old-style function and would be removed
when all SPI flash drivers use dm", so I think for dm spi_flash_probe_bus_cs()
should be used.


Regards,
Qianyu
Jagan Teki July 28, 2016, 1:35 p.m. UTC | #3
On 28 July 2016 at 08:06, Qianyu Gong <qianyu.gong@nxp.com> wrote:
>
>
>> -----Original Message-----
>> From: york sun
>> Sent: Thursday, July 28, 2016 1:35 AM
>> To: Qianyu Gong <qianyu.gong@nxp.com>; u-boot@lists.denx.de; Prabhakar
>> Kushwaha <prabhakar.kushwaha@nxp.com>; Mingkai Hu <mingkai.hu@nxp.com>
>> Cc: Shaohui Xie <shaohui.xie@nxp.com>; Zhiqiang Hou <zhiqiang.hou@nxp.com>;
>> Wenbin Song <wenbin.song@nxp.com>
>> Subject: Re: [PATCH 1/2] net: fm: fix spi flash probe for using driver model
>>
>> On 07/20/2016 03:51 AM, Gong Qianyu wrote:
>> > The current code would always use the speed and mode set by
>> > CONFIG_ENV_SPI_MAX_HZ and CONFIG_ENV_SPI_MODE. But if using SPI driver
>> > model it should get the values from DT.
>> >
>> > Signed-off-by: Gong Qianyu <Qianyu.Gong@nxp.com>
>> > ---
>> >  drivers/net/fm/fm.c | 10 ++++++++++
>> >  1 file changed, 10 insertions(+)
>> >
>> > diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c index
>> > 00cdfd4..6308d22 100644
>> > --- a/drivers/net/fm/fm.c
>> > +++ b/drivers/net/fm/fm.c
>> > @@ -371,8 +371,18 @@ int fm_init_common(int index, struct ccsr_fman *reg)
>> >     void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
>> >     int ret = 0;
>> >
>> > +#ifdef CONFIG_DM_SPI_FLASH
>> > +   struct udevice *new;
>> > +
>> > +   /* Will get the speed and mode from Device Tree */

Below one look good phrase for me.
/* speed and mode will be read from DT */

>> > +   ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS,
>> CONFIG_ENV_SPI_CS,
>> > +                                0, 0, &new);
>> > +
>> > +   ucode_flash = dev_get_uclass_priv(new); #else
>> >     ucode_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
>> CONFIG_ENV_SPI_CS,
>> >                     CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
>> > +#endif
>> >     if (!ucode_flash)
>> >             printf("SF: probe for ucode failed\n");
>> >     else {
>> >
>>
>> Why not just use spi_flash_probe() with speed and mode passed as 0?
>>
>> York
>
> As Simon said spi_flash_probe() "is an old-style function and would be removed
> when all SPI flash drivers use dm", so I think for dm spi_flash_probe_bus_cs()
> should be used.

Correct!

Reviewed-by: Jagan Teki <jteki@openedev.com>
Gong Qianyu July 29, 2016, 11 a.m. UTC | #4
Hi Jagan,

Thanks. I'll fix it in the next version.

Regards,
Qianyu

> -----Original Message-----
> From: Jagan Teki [mailto:jagannadh.teki@gmail.com]
> Sent: Thursday, July 28, 2016 9:36 PM
> To: Qianyu Gong <qianyu.gong@nxp.com>
> Cc: york sun <york.sun@nxp.com>; u-boot@lists.denx.de; Prabhakar Kushwaha
> <prabhakar.kushwaha@nxp.com>; Zhiqiang Hou <zhiqiang.hou@nxp.com>;
> Wenbin Song <wenbin.song@nxp.com>; Mingkai Hu <mingkai.hu@nxp.com>
> Subject: Re: [U-Boot] [PATCH 1/2] net: fm: fix spi flash probe for using driver
> model
> 
> On 28 July 2016 at 08:06, Qianyu Gong <qianyu.gong@nxp.com> wrote:
> >
> >
> >> -----Original Message-----
> >> From: york sun
> >> Sent: Thursday, July 28, 2016 1:35 AM
> >> To: Qianyu Gong <qianyu.gong@nxp.com>; u-boot@lists.denx.de;
> >> Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>; Mingkai Hu
> >> <mingkai.hu@nxp.com>
> >> Cc: Shaohui Xie <shaohui.xie@nxp.com>; Zhiqiang Hou
> >> <zhiqiang.hou@nxp.com>; Wenbin Song <wenbin.song@nxp.com>
> >> Subject: Re: [PATCH 1/2] net: fm: fix spi flash probe for using
> >> driver model
> >>
> >> On 07/20/2016 03:51 AM, Gong Qianyu wrote:
> >> > The current code would always use the speed and mode set by
> >> > CONFIG_ENV_SPI_MAX_HZ and CONFIG_ENV_SPI_MODE. But if using SPI
> >> > driver model it should get the values from DT.
> >> >
> >> > Signed-off-by: Gong Qianyu <Qianyu.Gong@nxp.com>
> >> > ---
> >> >  drivers/net/fm/fm.c | 10 ++++++++++
> >> >  1 file changed, 10 insertions(+)
> >> >
> >> > diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c index
> >> > 00cdfd4..6308d22 100644
> >> > --- a/drivers/net/fm/fm.c
> >> > +++ b/drivers/net/fm/fm.c
> >> > @@ -371,8 +371,18 @@ int fm_init_common(int index, struct ccsr_fman
> *reg)
> >> >     void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
> >> >     int ret = 0;
> >> >
> >> > +#ifdef CONFIG_DM_SPI_FLASH
> >> > +   struct udevice *new;
> >> > +
> >> > +   /* Will get the speed and mode from Device Tree */
> 
> Below one look good phrase for me.
> /* speed and mode will be read from DT */
> 
> >> > +   ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS,
> >> CONFIG_ENV_SPI_CS,
> >> > +                                0, 0, &new);
> >> > +
> >> > +   ucode_flash = dev_get_uclass_priv(new); #else
> >> >     ucode_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
> >> CONFIG_ENV_SPI_CS,
> >> >                     CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
> >> > +#endif
> >> >     if (!ucode_flash)
> >> >             printf("SF: probe for ucode failed\n");
> >> >     else {
> >> >
> >>
> >> Why not just use spi_flash_probe() with speed and mode passed as 0?
> >>
> >> York
> >
> > As Simon said spi_flash_probe() "is an old-style function and would be
> > removed when all SPI flash drivers use dm", so I think for dm
> > spi_flash_probe_bus_cs() should be used.
> 
> Correct!
> 
> Reviewed-by: Jagan Teki <jteki@openedev.com>
> 
> --
> Jagan.
York Sun Aug. 2, 2016, 4:08 p.m. UTC | #5
On 07/29/2016 04:00 AM, Qianyu Gong wrote:
> Hi Jagan,
>
> Thanks. I'll fix it in the next version.
>

Qianyu,

Is there anything you need to fix?

York
Gong Qianyu Aug. 3, 2016, 3:29 a.m. UTC | #6
Hi York,

> -----Original Message-----
> From: york sun
> Sent: Wednesday, August 03, 2016 12:08 AM
> To: Qianyu Gong <qianyu.gong@nxp.com>; 'Jagan Teki'
> <jagannadh.teki@gmail.com>
> Cc: u-boot@lists.denx.de; Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>;
> Zhiqiang Hou <zhiqiang.hou@nxp.com>; Wenbin Song <wenbin.song@nxp.com>;
> Mingkai Hu <mingkai.hu@nxp.com>
> Subject: Re: [U-Boot] [PATCH 1/2] net: fm: fix spi flash probe for using driver
> model
> 
> On 07/29/2016 04:00 AM, Qianyu Gong wrote:
> > Hi Jagan,
> >
> > Thanks. I'll fix it in the next version.
> >
> 
> Qianyu,
> 
> Is there anything you need to fix?
> 
> York

Yes. I just sent the v2 patch.
And I also dropped the [PATCH 2/2]. I think I should first move the related SPI macros to 
defconfig before removing those env defines.


Regards,
Qianyu
diff mbox

Patch

diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c
index 00cdfd4..6308d22 100644
--- a/drivers/net/fm/fm.c
+++ b/drivers/net/fm/fm.c
@@ -371,8 +371,18 @@  int fm_init_common(int index, struct ccsr_fman *reg)
 	void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
 	int ret = 0;
 
+#ifdef CONFIG_DM_SPI_FLASH
+	struct udevice *new;
+
+	/* Will get the speed and mode from Device Tree */
+	ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
+				     0, 0, &new);
+
+	ucode_flash = dev_get_uclass_priv(new);
+#else
 	ucode_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
 			CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
+#endif
 	if (!ucode_flash)
 		printf("SF: probe for ucode failed\n");
 	else {