diff mbox

[U-Boot,RFC,12/13] dm: sunxi: Support driver model for Ethernet

Message ID 1425227620-6656-12-git-send-email-sjg@chromium.org
State RFC
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass March 1, 2015, 4:33 p.m. UTC
Adjust the Ethernet initialisation code to support driver model.
It is no-longer necessary to call designware_initialize(). The device will
be probed when it is used. The PHY type and GMAC base will come from the
device tree.

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

 board/sunxi/gmac.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Joe Hershberger March 1, 2015, 5:51 p.m. UTC | #1
Hi Simon,

On Sun, Mar 1, 2015 at 10:33 AM, Simon Glass <sjg@chromium.org> wrote:
>
> Adjust the Ethernet initialisation code to support driver model.
> It is no-longer necessary to call designware_initialize(). The device will
> be probed when it is used. The PHY type and GMAC base will come from the
> device tree.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  board/sunxi/gmac.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/board/sunxi/gmac.c b/board/sunxi/gmac.c
> index 8849132..ce7831d 100644
> --- a/board/sunxi/gmac.c
> +++ b/board/sunxi/gmac.c
> @@ -80,11 +80,16 @@ int sunxi_gmac_initialize(bd_t *bis)
>                 sunxi_gpio_set_cfgpin(pin, SUN6I_GPA0_GMAC);
>  #endif
>
> -#ifdef CONFIG_RGMII
> +#ifdef CONFIG_DM_ETH
> +       printf("eth init\n");

Why do we want to print here?

> +       return 0;
> +#else
> +# ifdef CONFIG_RGMII
>         return designware_initialize(SUNXI_GMAC_BASE,
PHY_INTERFACE_MODE_RGMII);
> -#elif defined CONFIG_GMII
> +# elif defined CONFIG_GMII
>         return designware_initialize(SUNXI_GMAC_BASE,
PHY_INTERFACE_MODE_GMII);
> -#else
> +# else
>         return designware_initialize(SUNXI_GMAC_BASE,
PHY_INTERFACE_MODE_MII);
> +# endif
>  #endif
>  }
> --
> 2.2.0.rc0.207.ga3a616c
>
Ian Campbell March 3, 2015, 8:40 a.m. UTC | #2
On Sun, 2015-03-01 at 09:33 -0700, Simon Glass wrote:
> Adjust the Ethernet initialisation code to support driver model.
> It is no-longer necessary to call designware_initialize(). The device will
> be probed when it is used. The PHY type and GMAC base will come from the
> device tree.

I wonder if for this sort of thing designware_initialize couldn't become
a nop so we can avoid some level of ifdefs?

Anyway, that's just minor, of larger concern is all the CONFIG_RGMII and
CONFIG_GMII stuff which is just above the context here. Doesn't that
need to become DM driven for this to be useful?

In fact, doesn't the pinmux generally need to become DM driven?

Or is this just a partial stepping stone to DM Ethernet support and not
a complete transition? (I wonder if I am confusing Device Model with
Device Tree here and this is all about the former, albeit the former is
often driven from the latter...)

> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>  board/sunxi/gmac.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/board/sunxi/gmac.c b/board/sunxi/gmac.c
> index 8849132..ce7831d 100644
> --- a/board/sunxi/gmac.c
> +++ b/board/sunxi/gmac.c
> @@ -80,11 +80,16 @@ int sunxi_gmac_initialize(bd_t *bis)
>  		sunxi_gpio_set_cfgpin(pin, SUN6I_GPA0_GMAC);
>  #endif
>  
> -#ifdef CONFIG_RGMII
> +#ifdef CONFIG_DM_ETH
> +	printf("eth init\n");
> +	return 0;
> +#else
> +# ifdef CONFIG_RGMII
>  	return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_RGMII);
> -#elif defined CONFIG_GMII
> +# elif defined CONFIG_GMII
>  	return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_GMII);
> -#else
> +# else
>  	return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_MII);
> +# endif
>  #endif
>  }
Simon Glass March 3, 2015, 11:40 p.m. UTC | #3
Hi Ian,

On 3 March 2015 at 01:40, Ian Campbell <ijc+uboot@hellion.org.uk> wrote:
> On Sun, 2015-03-01 at 09:33 -0700, Simon Glass wrote:
>> Adjust the Ethernet initialisation code to support driver model.
>> It is no-longer necessary to call designware_initialize(). The device will
>> be probed when it is used. The PHY type and GMAC base will come from the
>> device tree.
>
> I wonder if for this sort of thing designware_initialize couldn't become
> a nop so we can avoid some level of ifdefs?

I would rather not, since the intent is to delete the whole function.
Once all sunxi uses driver model for Ethernet we can drop the call in
gmac.c.

>
> Anyway, that's just minor, of larger concern is all the CONFIG_RGMII and
> CONFIG_GMII stuff which is just above the context here. Doesn't that
> need to become DM driven for this to be useful?
>

Yes

> In fact, doesn't the pinmux generally need to become DM driven?
>

Yes

> Or is this just a partial stepping stone to DM Ethernet support and not
> a complete transition? (I wonder if I am confusing Device Model with
> Device Tree here and this is all about the former, albeit the former is
> often driven from the latter...)
>

Yes this is Ethernet only. If we create a pinctl or funcmux framework
we could implement this, but it is in fact a separate issue from
Ethernet.

>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>  board/sunxi/gmac.c | 11 ++++++++---
>>  1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/board/sunxi/gmac.c b/board/sunxi/gmac.c
>> index 8849132..ce7831d 100644
>> --- a/board/sunxi/gmac.c
>> +++ b/board/sunxi/gmac.c
>> @@ -80,11 +80,16 @@ int sunxi_gmac_initialize(bd_t *bis)
>>               sunxi_gpio_set_cfgpin(pin, SUN6I_GPA0_GMAC);
>>  #endif
>>
>> -#ifdef CONFIG_RGMII
>> +#ifdef CONFIG_DM_ETH
>> +     printf("eth init\n");
>> +     return 0;
>> +#else
>> +# ifdef CONFIG_RGMII
>>       return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_RGMII);
>> -#elif defined CONFIG_GMII
>> +# elif defined CONFIG_GMII
>>       return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_GMII);
>> -#else
>> +# else
>>       return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_MII);
>> +# endif
>>  #endif
>>  }
>
>

Regards,
Simon
diff mbox

Patch

diff --git a/board/sunxi/gmac.c b/board/sunxi/gmac.c
index 8849132..ce7831d 100644
--- a/board/sunxi/gmac.c
+++ b/board/sunxi/gmac.c
@@ -80,11 +80,16 @@  int sunxi_gmac_initialize(bd_t *bis)
 		sunxi_gpio_set_cfgpin(pin, SUN6I_GPA0_GMAC);
 #endif
 
-#ifdef CONFIG_RGMII
+#ifdef CONFIG_DM_ETH
+	printf("eth init\n");
+	return 0;
+#else
+# ifdef CONFIG_RGMII
 	return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_RGMII);
-#elif defined CONFIG_GMII
+# elif defined CONFIG_GMII
 	return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_GMII);
-#else
+# else
 	return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_MII);
+# endif
 #endif
 }