diff mbox

[v2] ARM: sunxi: dt: add EMAC aliases

Message ID 1384625849-29849-1-git-send-email-emilio@elopez.com.ar
State New
Headers show

Commit Message

Emilio López Nov. 16, 2013, 6:17 p.m. UTC
U-Boot uses the ethernet0 alias to locate the right node to fill in
the MAC address of the first ethernet interface. This patch adds the
alias on all the sunxi SoCs with EMAC. In this way, people using
ethernet in U-Boot (eg, for tftp) can keep a consistent address on both
U-Boot and Linux with no additional effort.

Signed-off-by: Emilio López <emilio@elopez.com.ar>
---

v1->v2:
   add to dtsi instead of dts as suggested by Maxime; it's easier to 
   maintain on the long run.

 arch/arm/boot/dts/sun4i-a10.dtsi  | 4 ++++
 arch/arm/boot/dts/sun5i-a10s.dtsi | 4 ++++
 arch/arm/boot/dts/sun7i-a20.dtsi  | 4 ++++
 3 files changed, 12 insertions(+)

Comments

Michal Suchanek Nov. 16, 2013, 11:37 p.m. UTC | #1
Unfortunately,

a20 has two Ethernets so you can't alias both to ethernet0.

This has to be done on a per-board basis.

Thanks

Michal

On 16 November 2013 19:17, Emilio López <emilio@elopez.com.ar> wrote:
> U-Boot uses the ethernet0 alias to locate the right node to fill in
> the MAC address of the first ethernet interface. This patch adds the
> alias on all the sunxi SoCs with EMAC. In this way, people using
> ethernet in U-Boot (eg, for tftp) can keep a consistent address on both
> U-Boot and Linux with no additional effort.
>
> Signed-off-by: Emilio López <emilio@elopez.com.ar>
> ---
>
> v1->v2:
>    add to dtsi instead of dts as suggested by Maxime; it's easier to
>    maintain on the long run.
>
>  arch/arm/boot/dts/sun4i-a10.dtsi  | 4 ++++
>  arch/arm/boot/dts/sun5i-a10s.dtsi | 4 ++++
>  arch/arm/boot/dts/sun7i-a20.dtsi  | 4 ++++
>  3 files changed, 12 insertions(+)
>
> diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
> index 09e7b43..23374da 100644
> --- a/arch/arm/boot/dts/sun4i-a10.dtsi
> +++ b/arch/arm/boot/dts/sun4i-a10.dtsi
> @@ -15,6 +15,10 @@
>  / {
>         interrupt-parent = <&intc>;
>
> +       aliases {
> +               ethernet0 = &emac;
> +       };
> +
>         cpus {
>                 #address-cells = <1>;
>                 #size-cells = <0>;
> diff --git a/arch/arm/boot/dts/sun5i-a10s.dtsi b/arch/arm/boot/dts/sun5i-a10s.dtsi
> index 9326b64..e95ab43 100644
> --- a/arch/arm/boot/dts/sun5i-a10s.dtsi
> +++ b/arch/arm/boot/dts/sun5i-a10s.dtsi
> @@ -16,6 +16,10 @@
>  / {
>         interrupt-parent = <&intc>;
>
> +       aliases {
> +               ethernet0 = &emac;
> +       };
> +
>         cpus {
>                 cpu@0 {
>                         compatible = "arm,cortex-a8";
> diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
> index c645a0f..6bea2b84 100644
> --- a/arch/arm/boot/dts/sun7i-a20.dtsi
> +++ b/arch/arm/boot/dts/sun7i-a20.dtsi
> @@ -16,6 +16,10 @@
>  / {
>         interrupt-parent = <&gic>;
>
> +       aliases {
> +               ethernet0 = &emac;
> +       };
> +
>         cpus {
>                 #address-cells = <1>;
>                 #size-cells = <0>;
> --
> 1.8.4.2
>
Emilio López Nov. 16, 2013, 11:48 p.m. UTC | #2
Hi,

El 16/11/13 20:37, Michal Suchanek escribió:
> Unfortunately,
>
> a20 has two Ethernets so you can't alias both to ethernet0.
>
> This has to be done on a per-board basis.
>

That was my first thought, and partly why I did it per-board on v1 (the 
other part being that some boards do not have a phy, so having an 
ethernet0 alias felt "wrong"). But after some quick testing, it appears 
that aliases are overridable, so we could just add ethernet0 = &gmac; on 
qualifying boards when the gmac support is ready.

Cheers,

Emilio
Maxime Ripard Nov. 17, 2013, 8:38 a.m. UTC | #3
Hi,

On Sat, Nov 16, 2013 at 08:48:48PM -0300, Emilio López wrote:
> Hi,
> 
> El 16/11/13 20:37, Michal Suchanek escribió:
> >Unfortunately,
> >
> >a20 has two Ethernets so you can't alias both to ethernet0.
> >
> >This has to be done on a per-board basis.
> >
> 
> That was my first thought, and partly why I did it per-board on v1
> (the other part being that some boards do not have a phy, so having
> an ethernet0 alias felt "wrong"). But after some quick testing, it
> appears that aliases are overridable, so we could just add ethernet0
> = &gmac; on qualifying boards when the gmac support is ready.

Or we will just add it as ethernet1. U-boot is able to put the
mac-address in the DT for every ethernet* nodes for as much ethernet
nodes as you need.

Maxime
Maxime Ripard Nov. 17, 2013, 8:52 a.m. UTC | #4
On Sat, Nov 16, 2013 at 03:17:29PM -0300, Emilio López wrote:
> U-Boot uses the ethernet0 alias to locate the right node to fill in
> the MAC address of the first ethernet interface. This patch adds the
> alias on all the sunxi SoCs with EMAC. In this way, people using
> ethernet in U-Boot (eg, for tftp) can keep a consistent address on both
> U-Boot and Linux with no additional effort.
> 
> Signed-off-by: Emilio López <emilio@elopez.com.ar>

Applied to my sunxi/dt-for-3.14 branch.

Thanks!
Maxime
Michal Suchanek Nov. 18, 2013, 1:07 p.m. UTC | #5
On 17 November 2013 09:38, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> Hi,
>
> On Sat, Nov 16, 2013 at 08:48:48PM -0300, Emilio López wrote:
>> Hi,
>>
>> El 16/11/13 20:37, Michal Suchanek escribió:
>> >Unfortunately,
>> >
>> >a20 has two Ethernets so you can't alias both to ethernet0.
>> >
>> >This has to be done on a per-board basis.
>> >
>>
>> That was my first thought, and partly why I did it per-board on v1
>> (the other part being that some boards do not have a phy, so having
>> an ethernet0 alias felt "wrong"). But after some quick testing, it
>> appears that aliases are overridable, so we could just add ethernet0
>> = &gmac; on qualifying boards when the gmac support is ready.
>
> Or we will just add it as ethernet1. U-boot is able to put the
> mac-address in the DT for every ethernet* nodes for as much ethernet
> nodes as you need.

I guess that would be fine for CT and CB2 which can have only one
physical ethernet (unless there are pins for adding another PHY) but
if there is ever board with two ethernets you want only one of them to
 get the mac address from u-boot.

Thanks

Michal
Maxime Ripard Nov. 18, 2013, 1:14 p.m. UTC | #6
On Mon, Nov 18, 2013 at 02:07:07PM +0100, Michal Suchanek wrote:
> >> That was my first thought, and partly why I did it per-board on v1
> >> (the other part being that some boards do not have a phy, so having
> >> an ethernet0 alias felt "wrong"). But after some quick testing, it
> >> appears that aliases are overridable, so we could just add ethernet0
> >> = &gmac; on qualifying boards when the gmac support is ready.
> >
> > Or we will just add it as ethernet1. U-boot is able to put the
> > mac-address in the DT for every ethernet* nodes for as much ethernet
> > nodes as you need.
> 
> I guess that would be fine for CT and CB2 which can have only one
> physical ethernet (unless there are pins for adding another PHY) but
> if there is ever board with two ethernets you want only one of them to
>  get the mac address from u-boot.

I'm not sure to get why. ethernet0 would get ethaddr, ethernet1 would
get eth1addr. How is that an issue?
diff mbox

Patch

diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
index 09e7b43..23374da 100644
--- a/arch/arm/boot/dts/sun4i-a10.dtsi
+++ b/arch/arm/boot/dts/sun4i-a10.dtsi
@@ -15,6 +15,10 @@ 
 / {
 	interrupt-parent = <&intc>;
 
+	aliases {
+		ethernet0 = &emac;
+	};
+
 	cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;
diff --git a/arch/arm/boot/dts/sun5i-a10s.dtsi b/arch/arm/boot/dts/sun5i-a10s.dtsi
index 9326b64..e95ab43 100644
--- a/arch/arm/boot/dts/sun5i-a10s.dtsi
+++ b/arch/arm/boot/dts/sun5i-a10s.dtsi
@@ -16,6 +16,10 @@ 
 / {
 	interrupt-parent = <&intc>;
 
+	aliases {
+		ethernet0 = &emac;
+	};
+
 	cpus {
 		cpu@0 {
 			compatible = "arm,cortex-a8";
diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
index c645a0f..6bea2b84 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -16,6 +16,10 @@ 
 / {
 	interrupt-parent = <&gic>;
 
+	aliases {
+		ethernet0 = &emac;
+	};
+
 	cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;