diff mbox

[U-Boot,07/18] net: macb: Convert to driver model

Message ID 1462257612-28746-8-git-send-email-sjg@chromium.org
State Accepted
Commit f1dcc19b213df97127df9c6f4bec296ae2f91f38
Delegated to: Andreas Bießmann
Headers show

Commit Message

Simon Glass May 3, 2016, 6:40 a.m. UTC
Add driver-model support to this driver. The old code remains for now so
that we can convert boards one at a time.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/net/macb.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 119 insertions(+)

Comments

Heiko Schocher May 3, 2016, 7:53 a.m. UTC | #1
Hello Simon,

Am 03.05.2016 um 08:40 schrieb Simon Glass:
> Add driver-model support to this driver. The old code remains for now so
> that we can convert boards one at a time.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>   drivers/net/macb.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 119 insertions(+)

Thanks!

Reviewed-by: Heiko Schocher <hs@denx.de>

tested on the smartweb, corvus, taurus and axm board

Tested-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
Joe Hershberger May 3, 2016, 8:54 p.m. UTC | #2
On Tue, May 3, 2016 at 1:40 AM, Simon Glass <sjg@chromium.org> wrote:
> Add driver-model support to this driver. The old code remains for now so
> that we can convert boards one at a time.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

But with a nit...

> ---

<snip>

> +static const struct eth_ops macb_eth_ops = {
> +       .start  = macb_start,
> +       .send   = macb_send,
> +       .recv   = macb_recv,
> +       .stop   = macb_stop,
> +       .free_pkt       = macb_free_pkt,
> +       .write_hwaddr   = macb_write_hwaddr,
> +};
> +
> +static int macb_eth_probe(struct udevice *dev)
> +{
> +       struct eth_pdata *pdata = dev_get_platdata(dev);
> +       struct macb_device *macb = dev_get_priv(dev);
> +
> +       macb->regs = (void *)pdata->iobase;
> +
> +       _macb_eth_initialize(macb);
> +#if defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB)
> +       miiphy_register(dev->name, macb_miiphy_read, macb_miiphy_write);

It's unfortunate that you're proliferating the oldest phy API. My
semantic patch can come along and clean it up later as long as this is
in before I run it again.

> +       macb->bus = miiphy_get_dev_by_name(dev->name);
> +#endif
> +
> +       return 0;
> +}
Wenyou Yang May 4, 2016, 7:29 a.m. UTC | #3
Hi,

On 2016/5/3 15:53, Heiko Schocher wrote:
> Hello Simon,
>
> Am 03.05.2016 um 08:40 schrieb Simon Glass:
>> Add driver-model support to this driver. The old code remains for now so
>> that we can convert boards one at a time.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>   drivers/net/macb.c | 119 
>> +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 119 insertions(+)
>
> Thanks!
>
> Reviewed-by: Heiko Schocher <hs@denx.de>
>
> tested on the smartweb, corvus, taurus and axm board
>
> Tested-by: Heiko Schocher <hs@denx.de>

I tried to test this patch series on SAMA5D2 Xplained board, but I have 
the following compile warning , did you experience it.

----8<-----------
drivers/net/macb.c: In function 'macb_phy_init':
drivers/net/macb.c:487:9: warning: passing argument 3 of 'phy_connect' 
from incompatible pointer type [enabled by default]
In file included from include/miiphy.h:22:0,
                  from drivers/net/macb.c:36:
include/phy.h:226:20: note: expected 'struct udevice *' but argument is 
of type 'const struct device **'
--->8----------------

>
> bye,
> Heiko

Best Regards,
Wenyou Yang
Wenyou Yang May 4, 2016, 7:32 a.m. UTC | #4
Hi

> -----Original Message-----

> From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Heiko

> Schocher

> Sent: 2016年5月3日 15:54

> To: Simon Glass <sjg@chromium.org>

> Cc: U-Boot Mailing List <u-boot@lists.denx.de>; Joe Hershberger

> <joe.hershberger@ni.com>

> Subject: Re: [U-Boot] [PATCH 07/18] net: macb: Convert to driver model

> 

> Hello Simon,

> 

> Am 03.05.2016 um 08:40 schrieb Simon Glass:

> > Add driver-model support to this driver. The old code remains for now

> > so that we can convert boards one at a time.

> >

> > Signed-off-by: Simon Glass <sjg@chromium.org>

> > ---

> >

> >   drivers/net/macb.c | 119

> +++++++++++++++++++++++++++++++++++++++++++++++++++++

> >   1 file changed, 119 insertions(+)

> 

> Thanks!

> 

> Reviewed-by: Heiko Schocher <hs@denx.de>

> 

> tested on the smartweb, corvus, taurus and axm board

> 

> Tested-by: Heiko Schocher <hs@denx.de>


I tried to test this patch series on SAMA5D2 Xplained board, but I have the compile warning below. Did you experience it?

---8<---------
drivers/net/macb.c: In function 'macb_phy_init':
drivers/net/macb.c:487:9: warning: passing argument 3 of 'phy_connect' from incompatible pointer type [enabled by default]
In file included from include/miiphy.h:22:0,
                 from drivers/net/macb.c:36:
include/phy.h:226:20: note: expected 'struct udevice *' but argument is of type 'const struct device **'
--->8--------

Thanks.

> 

> bye,

> Heiko

> --

> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk

> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

> _______________________________________________

> U-Boot mailing list

> U-Boot@lists.denx.de

> http://lists.denx.de/mailman/listinfo/u-boot



Best Regards,
Wenyou Yang
Simon Glass May 5, 2016, 2:38 a.m. UTC | #5
Hi Joe,

On 3 May 2016 at 14:54, Joe Hershberger <joe.hershberger@gmail.com> wrote:
> On Tue, May 3, 2016 at 1:40 AM, Simon Glass <sjg@chromium.org> wrote:
>> Add driver-model support to this driver. The old code remains for now so
>> that we can convert boards one at a time.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>
> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
>
> But with a nit...
>
>> ---
>
> <snip>
>
>> +static const struct eth_ops macb_eth_ops = {
>> +       .start  = macb_start,
>> +       .send   = macb_send,
>> +       .recv   = macb_recv,
>> +       .stop   = macb_stop,
>> +       .free_pkt       = macb_free_pkt,
>> +       .write_hwaddr   = macb_write_hwaddr,
>> +};
>> +
>> +static int macb_eth_probe(struct udevice *dev)
>> +{
>> +       struct eth_pdata *pdata = dev_get_platdata(dev);
>> +       struct macb_device *macb = dev_get_priv(dev);
>> +
>> +       macb->regs = (void *)pdata->iobase;
>> +
>> +       _macb_eth_initialize(macb);
>> +#if defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB)
>> +       miiphy_register(dev->name, macb_miiphy_read, macb_miiphy_write);
>
> It's unfortunate that you're proliferating the oldest phy API. My
> semantic patch can come along and clean it up later as long as this is
> in before I run it again.

OK, hopefully that will work.

>
>> +       macb->bus = miiphy_get_dev_by_name(dev->name);
>> +#endif
>> +
>> +       return 0;
>> +}

Regards,
Simon
Simon Glass May 5, 2016, 2:38 a.m. UTC | #6
Hi,

On 4 May 2016 at 01:32, Yang, Wenyou <Wenyou.Yang@atmel.com> wrote:
>
> Hi
>
> > -----Original Message-----
> > From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Heiko
> > Schocher
> > Sent: 2016年5月3日 15:54
> > To: Simon Glass <sjg@chromium.org>
> > Cc: U-Boot Mailing List <u-boot@lists.denx.de>; Joe Hershberger
> > <joe.hershberger@ni.com>
> > Subject: Re: [U-Boot] [PATCH 07/18] net: macb: Convert to driver model
> >
> > Hello Simon,
> >
> > Am 03.05.2016 um 08:40 schrieb Simon Glass:
> > > Add driver-model support to this driver. The old code remains for now
> > > so that we can convert boards one at a time.
> > >
> > > Signed-off-by: Simon Glass <sjg@chromium.org>
> > > ---
> > >
> > >   drivers/net/macb.c | 119
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++
> > >   1 file changed, 119 insertions(+)
> >
> > Thanks!
> >
> > Reviewed-by: Heiko Schocher <hs@denx.de>
> >
> > tested on the smartweb, corvus, taurus and axm board
> >
> > Tested-by: Heiko Schocher <hs@denx.de>
>
> I tried to test this patch series on SAMA5D2 Xplained board, but I have the compile warning below. Did you experience it?
>
> ---8<---------
> drivers/net/macb.c: In function 'macb_phy_init':
> drivers/net/macb.c:487:9: warning: passing argument 3 of 'phy_connect' from incompatible pointer type [enabled by default]
> In file included from include/miiphy.h:22:0,
>                  from drivers/net/macb.c:36:
> include/phy.h:226:20: note: expected 'struct udevice *' but argument is of type 'const struct device **'
> --->8--------

No I don't see that problem. I did a full build test. What is the
board config name you are using?
>
> Thanks.
>
> >
> > bye,
> > Heiko
> > --
> > DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> > _______________________________________________
> > U-Boot mailing list
> > U-Boot@lists.denx.de
> > http://lists.denx.de/mailman/listinfo/u-boot
>
>
> Best Regards,
> Wenyou Yang

Regards,
Simon
Wenyou Yang May 5, 2016, 3:15 a.m. UTC | #7
Hi Simon,

> -----Original Message-----

> From: sjg@google.com [mailto:sjg@google.com] On Behalf Of Simon Glass

> Sent: 2016年5月5日 10:38

> To: Yang, Wenyou <Wenyou.Yang@atmel.com>

> Cc: hs@denx.de; U-Boot Mailing List <u-boot@lists.denx.de>; Joe Hershberger

> <joe.hershberger@ni.com>

> Subject: Re: [U-Boot] [PATCH 07/18] net: macb: Convert to driver model

> 

> Hi,

> 

> On 4 May 2016 at 01:32, Yang, Wenyou <Wenyou.Yang@atmel.com> wrote:

> >

> > Hi

> >

> > > -----Original Message-----

> > > From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of

> > > Heiko Schocher

> > > Sent: 2016年5月3日 15:54

> > > To: Simon Glass <sjg@chromium.org>

> > > Cc: U-Boot Mailing List <u-boot@lists.denx.de>; Joe Hershberger

> > > <joe.hershberger@ni.com>

> > > Subject: Re: [U-Boot] [PATCH 07/18] net: macb: Convert to driver

> > > model

> > >

> > > Hello Simon,

> > >

> > > Am 03.05.2016 um 08:40 schrieb Simon Glass:

> > > > Add driver-model support to this driver. The old code remains for

> > > > now so that we can convert boards one at a time.

> > > >

> > > > Signed-off-by: Simon Glass <sjg@chromium.org>

> > > > ---

> > > >

> > > >   drivers/net/macb.c | 119

> > > +++++++++++++++++++++++++++++++++++++++++++++++++++++

> > > >   1 file changed, 119 insertions(+)

> > >

> > > Thanks!

> > >

> > > Reviewed-by: Heiko Schocher <hs@denx.de>

> > >

> > > tested on the smartweb, corvus, taurus and axm board

> > >

> > > Tested-by: Heiko Schocher <hs@denx.de>

> >

> > I tried to test this patch series on SAMA5D2 Xplained board, but I have the

> compile warning below. Did you experience it?

> >

> > ---8<---------

> > drivers/net/macb.c: In function 'macb_phy_init':

> > drivers/net/macb.c:487:9: warning: passing argument 3 of 'phy_connect'

> > from incompatible pointer type [enabled by default] In file included from

> include/miiphy.h:22:0,

> >                  from drivers/net/macb.c:36:

> > include/phy.h:226:20: note: expected 'struct udevice *' but argument is of type

> 'const struct device **'

> > --->8--------

> 

> No I don't see that problem. I did a full build test. What is the board config name

> you are using?


The board is SAMA5D2 Xplained board, the .config file is attached.

I noticed that in include/phy.h file,  phy_connect() has different prototype for enabling CONFIG_DM_ETH or not.

So, I think this issue should be exist.

> >

> > Thanks.

> >

> > >

> > > bye,

> > > Heiko

> > > --

> > > DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk

> > > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell,

> > > Germany _______________________________________________

> > > U-Boot mailing list

> > > U-Boot@lists.denx.de

> > > http://lists.denx.de/mailman/listinfo/u-boot

> >

> >

> > Best Regards,

> > Wenyou Yang

> 

> Regards,

> Simon



Best Regards,
Wenyou Yang
Simon Glass May 5, 2016, 3:18 a.m. UTC | #8
Hi,

On May 4, 2016 21:15, "Yang, Wenyou" <Wenyou.Yang@atmel.com> wrote:
>
> Hi Simon,
>
> > -----Original Message-----
> > From: sjg@google.com [mailto:sjg@google.com] On Behalf Of Simon Glass
> > Sent: 2016年5月5日 10:38
> > To: Yang, Wenyou <Wenyou.Yang@atmel.com>
> > Cc: hs@denx.de; U-Boot Mailing List <u-boot@lists.denx.de>; Joe
Hershberger
> > <joe.hershberger@ni.com>
> > Subject: Re: [U-Boot] [PATCH 07/18] net: macb: Convert to driver model
> >
> > Hi,
> >
> > On 4 May 2016 at 01:32, Yang, Wenyou <Wenyou.Yang@atmel.com> wrote:
> > >
> > > Hi
> > >
> > > > -----Original Message-----
> > > > From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of
> > > > Heiko Schocher
> > > > Sent: 2016年5月3日 15:54
> > > > To: Simon Glass <sjg@chromium.org>
> > > > Cc: U-Boot Mailing List <u-boot@lists.denx.de>; Joe Hershberger
> > > > <joe.hershberger@ni.com>
> > > > Subject: Re: [U-Boot] [PATCH 07/18] net: macb: Convert to driver
> > > > model
> > > >
> > > > Hello Simon,
> > > >
> > > > Am 03.05.2016 um 08:40 schrieb Simon Glass:
> > > > > Add driver-model support to this driver. The old code remains for
> > > > > now so that we can convert boards one at a time.
> > > > >
> > > > > Signed-off-by: Simon Glass <sjg@chromium.org>
> > > > > ---
> > > > >
> > > > >   drivers/net/macb.c | 119
> > > > +++++++++++++++++++++++++++++++++++++++++++++++++++++
> > > > >   1 file changed, 119 insertions(+)
> > > >
> > > > Thanks!
> > > >
> > > > Reviewed-by: Heiko Schocher <hs@denx.de>
> > > >
> > > > tested on the smartweb, corvus, taurus and axm board
> > > >
> > > > Tested-by: Heiko Schocher <hs@denx.de>
> > >
> > > I tried to test this patch series on SAMA5D2 Xplained board, but I
have the
> > compile warning below. Did you experience it?
> > >
> > > ---8<---------
> > > drivers/net/macb.c: In function 'macb_phy_init':
> > > drivers/net/macb.c:487:9: warning: passing argument 3 of 'phy_connect'
> > > from incompatible pointer type [enabled by default] In file included
from
> > include/miiphy.h:22:0,
> > >                  from drivers/net/macb.c:36:
> > > include/phy.h:226:20: note: expected 'struct udevice *' but argument
is of type
> > 'const struct device **'
> > > --->8--------
> >
> > No I don't see that problem. I did a full build test. What is the board
config name
> > you are using?
>
> The board is SAMA5D2 Xplained board, the .config file is attached.
>
> I noticed that in include/phy.h file,  phy_connect() has different
prototype for enabling CONFIG_DM_ETH or not.
>
> So, I think this issue should be exist.

Is that board in mainline?

>
> > >
> > > Thanks.
> > >
> > > >
> > > > bye,
> > > > Heiko
> > > > --
> > > > DENX Software Engineering GmbH,      Managing Director: Wolfgang
Denk
> > > > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell,
> > > > Germany _______________________________________________
> > > > U-Boot mailing list
> > > > U-Boot@lists.denx.de
> > > > http://lists.denx.de/mailman/listinfo/u-boot

Regards,
Simon
Wenyou Yang May 5, 2016, 3:37 a.m. UTC | #9
Hi,

On 2016/5/5 11:18, Simon Glass wrote:
>
> Hi,
>
> On May 4, 2016 21:15, "Yang, Wenyou" <Wenyou.Yang@atmel.com 
> <mailto:Wenyou.Yang@atmel.com>> wrote:
> >
> > Hi Simon,
> >
> > > -----Original Message-----
> > > From: sjg@google.com <mailto:sjg@google.com> 
> [mailto:sjg@google.com <mailto:sjg@google.com>] On Behalf Of Simon Glass
> > > Sent: 2016年5月5日 10:38
> > > To: Yang, Wenyou <Wenyou.Yang@atmel.com 
> <mailto:Wenyou.Yang@atmel.com>>
> > > Cc: hs@denx.de <mailto:hs@denx.de>; U-Boot Mailing List 
> <u-boot@lists.denx.de <mailto:u-boot@lists.denx.de>>; Joe Hershberger
> > > <joe.hershberger@ni.com <mailto:joe.hershberger@ni.com>>
> > > Subject: Re: [U-Boot] [PATCH 07/18] net: macb: Convert to driver model
> > >
> > > Hi,
> > >
> > > On 4 May 2016 at 01:32, Yang, Wenyou <Wenyou.Yang@atmel.com 
> <mailto:Wenyou.Yang@atmel.com>> wrote:
> > > >
> > > > Hi
> > > >
> > > > > -----Original Message-----
> > > > > From: U-Boot [mailto:u-boot-bounces@lists.denx.de 
> <mailto:u-boot-bounces@lists.denx.de>] On Behalf Of
> > > > > Heiko Schocher
> > > > > Sent: 2016年5月3日 15:54
> > > > > To: Simon Glass <sjg@chromium.org <mailto:sjg@chromium.org>>
> > > > > Cc: U-Boot Mailing List <u-boot@lists.denx.de 
> <mailto:u-boot@lists.denx.de>>; Joe Hershberger
> > > > > <joe.hershberger@ni.com <mailto:joe.hershberger@ni.com>>
> > > > > Subject: Re: [U-Boot] [PATCH 07/18] net: macb: Convert to driver
> > > > > model
> > > > >
> > > > > Hello Simon,
> > > > >
> > > > > Am 03.05.2016 um 08:40 schrieb Simon Glass:
> > > > > > Add driver-model support to this driver. The old code 
> remains for
> > > > > > now so that we can convert boards one at a time.
> > > > > >
> > > > > > Signed-off-by: Simon Glass <sjg@chromium.org 
> <mailto:sjg@chromium.org>>
> > > > > > ---
> > > > > >
> > > > > >   drivers/net/macb.c | 119
> > > > > +++++++++++++++++++++++++++++++++++++++++++++++++++++
> > > > > >   1 file changed, 119 insertions(+)
> > > > >
> > > > > Thanks!
> > > > >
> > > > > Reviewed-by: Heiko Schocher <hs@denx.de <mailto:hs@denx.de>>
> > > > >
> > > > > tested on the smartweb, corvus, taurus and axm board
> > > > >
> > > > > Tested-by: Heiko Schocher <hs@denx.de <mailto:hs@denx.de>>
> > > >
> > > > I tried to test this patch series on SAMA5D2 Xplained board, but 
> I have the
> > > compile warning below. Did you experience it?
> > > >
> > > > ---8<---------
> > > > drivers/net/macb.c: In function 'macb_phy_init':
> > > > drivers/net/macb.c:487:9: warning: passing argument 3 of 
> 'phy_connect'
> > > > from incompatible pointer type [enabled by default] In file 
> included from
> > > include/miiphy.h:22:0,
> > > >                  from drivers/net/macb.c:36:
> > > > include/phy.h:226:20: note: expected 'struct udevice *' but 
> argument is of type
> > > 'const struct device **'
> > > > --->8--------
> > >
> > > No I don't see that problem. I did a full build test. What is the 
> board config name
> > > you are using?
> >
> > The board is SAMA5D2 Xplained board, the .config file is attached.
> >
> > I noticed that in include/phy.h file,  phy_connect() has different 
> prototype for enabling CONFIG_DM_ETH or not.
> >
> > So, I think this issue should be exist.
>
> Is that board in mainline?
>
Yes, in mainline.

The type of 'dev' parameter of phy_connect() is struct udevice *, 
instead of struct eth_device * when enabling CONFIG_DM_ETH.

> >
> > > >
> > > > Thanks.
> > > >
> > > > >
> > > > > bye,
> > > > > Heiko
> > > > > --
> > > > > DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
> > > > > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell,
> > > > > Germany _______________________________________________
> > > > > U-Boot mailing list
> > > > > U-Boot@lists.denx.de <mailto:U-Boot@lists.denx.de>
> > > > > http://lists.denx.de/mailman/listinfo/u-boot
>
> Regards,
> Simon
>

Best Regards,
Wenyou Yang
Simon Glass May 5, 2016, 5:19 p.m. UTC | #10
Hi,

On 4 May 2016 at 21:37, Yang, Wenyou <wenyou.yang@atmel.com> wrote:
> Hi,
>
>
> On 2016/5/5 11:18, Simon Glass wrote:
>
> Hi,
>
> On May 4, 2016 21:15, "Yang, Wenyou" <Wenyou.Yang@atmel.com> wrote:
>>
>> Hi Simon,
>>
>> > -----Original Message-----
>> > From: sjg@google.com [mailto:sjg@google.com] On Behalf Of Simon Glass
>> > Sent: 2016年5月5日 10:38
>> > To: Yang, Wenyou <Wenyou.Yang@atmel.com>
>> > Cc: hs@denx.de; U-Boot Mailing List <u-boot@lists.denx.de>; Joe
>> > Hershberger
>> > <joe.hershberger@ni.com>
>> > Subject: Re: [U-Boot] [PATCH 07/18] net: macb: Convert to driver model
>> >
>> > Hi,
>> >
>> > On 4 May 2016 at 01:32, Yang, Wenyou <Wenyou.Yang@atmel.com> wrote:
>> > >
>> > > Hi
>> > >
>> > > > -----Original Message-----
>> > > > From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of
>> > > > Heiko Schocher
>> > > > Sent: 2016年5月3日 15:54
>> > > > To: Simon Glass <sjg@chromium.org>
>> > > > Cc: U-Boot Mailing List <u-boot@lists.denx.de>; Joe Hershberger
>> > > > <joe.hershberger@ni.com>
>> > > > Subject: Re: [U-Boot] [PATCH 07/18] net: macb: Convert to driver
>> > > > model
>> > > >
>> > > > Hello Simon,
>> > > >
>> > > > Am 03.05.2016 um 08:40 schrieb Simon Glass:
>> > > > > Add driver-model support to this driver. The old code remains for
>> > > > > now so that we can convert boards one at a time.
>> > > > >
>> > > > > Signed-off-by: Simon Glass <sjg@chromium.org>
>> > > > > ---
>> > > > >
>> > > > >   drivers/net/macb.c | 119
>> > > > +++++++++++++++++++++++++++++++++++++++++++++++++++++
>> > > > >   1 file changed, 119 insertions(+)
>> > > >
>> > > > Thanks!
>> > > >
>> > > > Reviewed-by: Heiko Schocher <hs@denx.de>
>> > > >
>> > > > tested on the smartweb, corvus, taurus and axm board
>> > > >
>> > > > Tested-by: Heiko Schocher <hs@denx.de>
>> > >
>> > > I tried to test this patch series on SAMA5D2 Xplained board, but I
>> > > have the
>> > compile warning below. Did you experience it?
>> > >
>> > > ---8<---------
>> > > drivers/net/macb.c: In function 'macb_phy_init':
>> > > drivers/net/macb.c:487:9: warning: passing argument 3 of 'phy_connect'
>> > > from incompatible pointer type [enabled by default] In file included
>> > > from
>> > include/miiphy.h:22:0,
>> > >                  from drivers/net/macb.c:36:
>> > > include/phy.h:226:20: note: expected 'struct udevice *' but argument
>> > > is of type
>> > 'const struct device **'
>> > > --->8--------
>> >
>> > No I don't see that problem. I did a full build test. What is the board
>> > config name
>> > you are using?
>>
>> The board is SAMA5D2 Xplained board, the .config file is attached.
>>
>> I noticed that in include/phy.h file,  phy_connect() has different
>> prototype for enabling CONFIG_DM_ETH or not.
>>
>> So, I think this issue should be exist.
>
> Is that board in mainline?
>
> Yes, in mainline.
>
> The type of 'dev' parameter of phy_connect() is struct udevice *, instead of
> struct eth_device * when enabling CONFIG_DM_ETH.

OK, sounds like it needs a patch. Can you fix it when you enable
DM_ETH for that board?

Regards,
Simon
Wenyou Yang May 6, 2016, 7:10 a.m. UTC | #11
Hi Simon,

> -----Original Message-----

> From: sjg@google.com [mailto:sjg@google.com] On Behalf Of Simon Glass

> Sent: 2016年5月6日 1:19

> To: Yang, Wenyou <Wenyou.Yang@atmel.com>

> Cc: U-Boot Mailing List <u-boot@lists.denx.de>; Joe Hershberger

> <joe.hershberger@ni.com>; hs@denx.de

> Subject: Re: [U-Boot] [PATCH 07/18] net: macb: Convert to driver model

> 

> Hi,

> 

> On 4 May 2016 at 21:37, Yang, Wenyou <wenyou.yang@atmel.com> wrote:

> > Hi,

> >

> >

> > On 2016/5/5 11:18, Simon Glass wrote:

> >

> > Hi,

> >

> > On May 4, 2016 21:15, "Yang, Wenyou" <Wenyou.Yang@atmel.com> wrote:

> >>

> >> Hi Simon,

> >>

> >> > -----Original Message-----

> >> > From: sjg@google.com [mailto:sjg@google.com] On Behalf Of Simon

> >> > Glass

> >> > Sent: 2016年5月5日 10:38

> >> > To: Yang, Wenyou <Wenyou.Yang@atmel.com>

> >> > Cc: hs@denx.de; U-Boot Mailing List <u-boot@lists.denx.de>; Joe

> >> > Hershberger <joe.hershberger@ni.com>

> >> > Subject: Re: [U-Boot] [PATCH 07/18] net: macb: Convert to driver

> >> > model

> >> >

> >> > Hi,

> >> >

> >> > On 4 May 2016 at 01:32, Yang, Wenyou <Wenyou.Yang@atmel.com> wrote:

> >> > >

> >> > > Hi

> >> > >

> >> > > > -----Original Message-----

> >> > > > From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of

> >> > > > Heiko Schocher

> >> > > > Sent: 2016年5月3日 15:54

> >> > > > To: Simon Glass <sjg@chromium.org>

> >> > > > Cc: U-Boot Mailing List <u-boot@lists.denx.de>; Joe Hershberger

> >> > > > <joe.hershberger@ni.com>

> >> > > > Subject: Re: [U-Boot] [PATCH 07/18] net: macb: Convert to

> >> > > > driver model

> >> > > >

> >> > > > Hello Simon,

> >> > > >

> >> > > > Am 03.05.2016 um 08:40 schrieb Simon Glass:

> >> > > > > Add driver-model support to this driver. The old code remains

> >> > > > > for now so that we can convert boards one at a time.

> >> > > > >

> >> > > > > Signed-off-by: Simon Glass <sjg@chromium.org>

> >> > > > > ---

> >> > > > >

> >> > > > >   drivers/net/macb.c | 119

> >> > > > +++++++++++++++++++++++++++++++++++++++++++++++++++++

> >> > > > >   1 file changed, 119 insertions(+)

> >> > > >

> >> > > > Thanks!

> >> > > >

> >> > > > Reviewed-by: Heiko Schocher <hs@denx.de>

> >> > > >

> >> > > > tested on the smartweb, corvus, taurus and axm board

> >> > > >

> >> > > > Tested-by: Heiko Schocher <hs@denx.de>

> >> > >

> >> > > I tried to test this patch series on SAMA5D2 Xplained board, but

> >> > > I have the

> >> > compile warning below. Did you experience it?

> >> > >

> >> > > ---8<---------

> >> > > drivers/net/macb.c: In function 'macb_phy_init':

> >> > > drivers/net/macb.c:487:9: warning: passing argument 3 of 'phy_connect'

> >> > > from incompatible pointer type [enabled by default] In file

> >> > > included from

> >> > include/miiphy.h:22:0,

> >> > >                  from drivers/net/macb.c:36:

> >> > > include/phy.h:226:20: note: expected 'struct udevice *' but

> >> > > argument is of type

> >> > 'const struct device **'

> >> > > --->8--------

> >> >

> >> > No I don't see that problem. I did a full build test. What is the

> >> > board config name you are using?

> >>

> >> The board is SAMA5D2 Xplained board, the .config file is attached.

> >>

> >> I noticed that in include/phy.h file,  phy_connect() has different

> >> prototype for enabling CONFIG_DM_ETH or not.

> >>

> >> So, I think this issue should be exist.

> >

> > Is that board in mainline?

> >

> > Yes, in mainline.

> >

> > The type of 'dev' parameter of phy_connect() is struct udevice *,

> > instead of struct eth_device * when enabling CONFIG_DM_ETH.

> 

> OK, sounds like it needs a patch. Can you fix it when you enable DM_ETH for that

> board?


Okay, I will try to fix it.


Best Regards,
Wenyou Yang
diff mbox

Patch

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index ecdfc1b..63fb466 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -4,6 +4,7 @@ 
  * SPDX-License-Identifier:	GPL-2.0+
  */
 #include <common.h>
+#include <dm.h>
 
 /*
  * The u-boot networking stack is a little weird.  It seems like the
@@ -28,7 +29,9 @@ 
  */
 
 #include <net.h>
+#ifndef CONFIG_DM_ETH
 #include <netdev.h>
+#endif
 #include <malloc.h>
 #include <miiphy.h>
 
@@ -100,11 +103,15 @@  struct macb_device {
 	unsigned long		dummy_desc_dma;
 
 	const struct device	*dev;
+#ifndef CONFIG_DM_ETH
 	struct eth_device	netdev;
+#endif
 	unsigned short		phy_addr;
 	struct mii_dev		*bus;
 };
+#ifndef CONFIG_DM_ETH
 #define to_macb(_nd) container_of(_nd, struct macb_device, netdev)
+#endif
 
 static int macb_is_gem(struct macb_device *macb)
 {
@@ -194,8 +201,13 @@  void __weak arch_get_mdio_control(const char *name)
 
 int macb_miiphy_read(const char *devname, u8 phy_adr, u8 reg, u16 *value)
 {
+#ifdef CONFIG_DM_ETH
+	struct udevice *dev = eth_get_dev_by_name(devname);
+	struct macb_device *macb = dev_get_priv(dev);
+#else
 	struct eth_device *dev = eth_get_dev_by_name(devname);
 	struct macb_device *macb = to_macb(dev);
+#endif
 
 	if (macb->phy_addr != phy_adr)
 		return -1;
@@ -208,8 +220,13 @@  int macb_miiphy_read(const char *devname, u8 phy_adr, u8 reg, u16 *value)
 
 int macb_miiphy_write(const char *devname, u8 phy_adr, u8 reg, u16 value)
 {
+#ifdef CONFIG_DM_ETH
+	struct udevice *dev = eth_get_dev_by_name(devname);
+	struct macb_device *macb = dev_get_priv(dev);
+#else
 	struct eth_device *dev = eth_get_dev_by_name(devname);
 	struct macb_device *macb = to_macb(dev);
+#endif
 
 	if (macb->phy_addr != phy_adr)
 		return -1;
@@ -764,6 +781,7 @@  static void _macb_eth_initialize(struct macb_device *macb)
 	macb_writel(macb, NCFGR, ncfgr);
 }
 
+#ifndef CONFIG_DM_ETH
 static int macb_send(struct eth_device *netdev, void *packet, int length)
 {
 	struct macb_device *macb = to_macb(netdev);
@@ -849,5 +867,106 @@  int macb_eth_initialize(int id, void *regs, unsigned int phy_addr)
 #endif
 	return 0;
 }
+#endif /* !CONFIG_DM_ETH */
+
+#ifdef CONFIG_DM_ETH
+
+static int macb_start(struct udevice *dev)
+{
+	struct macb_device *macb = dev_get_priv(dev);
+
+	return _macb_init(macb, dev->name);
+}
+
+static int macb_send(struct udevice *dev, void *packet, int length)
+{
+	struct macb_device *macb = dev_get_priv(dev);
+
+	return _macb_send(macb, dev->name, packet, length);
+}
+
+static int macb_recv(struct udevice *dev, int flags, uchar **packetp)
+{
+	struct macb_device *macb = dev_get_priv(dev);
+
+	macb->next_rx_tail = macb->rx_tail;
+	macb->wrapped = false;
+
+	return _macb_recv(macb, packetp);
+}
+
+static int macb_free_pkt(struct udevice *dev, uchar *packet, int length)
+{
+	struct macb_device *macb = dev_get_priv(dev);
+
+	reclaim_rx_buffers(macb, macb->next_rx_tail);
+
+	return 0;
+}
+
+static void macb_stop(struct udevice *dev)
+{
+	struct macb_device *macb = dev_get_priv(dev);
+
+	_macb_halt(macb);
+}
+
+static int macb_write_hwaddr(struct udevice *dev)
+{
+	struct eth_pdata *plat = dev_get_platdata(dev);
+	struct macb_device *macb = dev_get_priv(dev);
+
+	return _macb_write_hwaddr(macb, plat->enetaddr);
+}
+
+static const struct eth_ops macb_eth_ops = {
+	.start	= macb_start,
+	.send	= macb_send,
+	.recv	= macb_recv,
+	.stop	= macb_stop,
+	.free_pkt	= macb_free_pkt,
+	.write_hwaddr	= macb_write_hwaddr,
+};
+
+static int macb_eth_probe(struct udevice *dev)
+{
+	struct eth_pdata *pdata = dev_get_platdata(dev);
+	struct macb_device *macb = dev_get_priv(dev);
+
+	macb->regs = (void *)pdata->iobase;
+
+	_macb_eth_initialize(macb);
+#if defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB)
+	miiphy_register(dev->name, macb_miiphy_read, macb_miiphy_write);
+	macb->bus = miiphy_get_dev_by_name(dev->name);
+#endif
+
+	return 0;
+}
+
+static int macb_eth_ofdata_to_platdata(struct udevice *dev)
+{
+	struct eth_pdata *pdata = dev_get_platdata(dev);
+
+	pdata->iobase = dev_get_addr(dev);
+	return 0;
+}
+
+static const struct udevice_id macb_eth_ids[] = {
+	{ .compatible = "cdns,macb" },
+	{ }
+};
+
+U_BOOT_DRIVER(eth_macb) = {
+	.name	= "eth_macb",
+	.id	= UCLASS_ETH,
+	.of_match = macb_eth_ids,
+	.ofdata_to_platdata = macb_eth_ofdata_to_platdata,
+	.probe	= macb_eth_probe,
+	.ops	= &macb_eth_ops,
+	.priv_auto_alloc_size = sizeof(struct macb_device),
+	.platdata_auto_alloc_size = sizeof(struct eth_pdata),
+};
+#endif
 
 #endif