Skip to contentSkip to conversation

ARM: sunxi: dt: add EMAC aliases

PATCH Superseded Emilio López 3 participants 9 messages Nov 15, 2013 – Nov 18, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: sunxi: dt: add EMAC aliases

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 boards with EMAC and an ethernet port. 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.

---

Hi everyone,

I have tested this on a cubieboard2 and found it to work as intended, and I don't see why it wouldn't work on the other boards, given that the U-Boot codebase is shared. It may be worth submitting this for 3.13-rc0, but I'm not the one that has to make that call :)

Cheers,

Emilio

 arch/arm/boot/dts/sun4i-a10-a1000.dts            | 1 +
 arch/arm/boot/dts/sun4i-a10-cubieboard.dts       | 1 +
 arch/arm/boot/dts/sun4i-a10-hackberry.dts        | 4 ++++
 arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts | 4 ++++
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts      | 4 ++++
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts  | 4 ++++
 6 files changed, 18 insertions(+)
arch/arm/boot/dts/sun4i-a10-a1000.dts +1 -0
index eb4d73b..6e56986 100644
@@ -20,6 +20,7 @@
 
 	aliases {
 		serial0 = &uart0;
+		ethernet0 = &emac;
 	};
 
 	soc at 01c00000 {
arch/arm/boot/dts/sun4i-a10-cubieboard.dts +1 -0
index 425a7db..c2e251d 100644
@@ -20,6 +20,7 @@
 	aliases {
 		serial0 = &uart0;
 		serial1 = &uart1;
+		ethernet0 = &emac;
 	};
 
 	chosen {
arch/arm/boot/dts/sun4i-a10-hackberry.dts +4 -0
index b3ae51f..551ccbd 100644
@@ -18,6 +18,10 @@
 	model = "Miniand Hackberry";
 	compatible = "miniand,hackberry", "allwinner,sun4i-a10";
 
+	aliases {
+		ethernet0 = &emac;
+	};
+
 	chosen {
 		bootargs = "earlyprintk console=ttyS0,115200";
 	};
arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts +4 -0
index 88ec795..bb48737 100644
@@ -18,6 +18,10 @@
 	model = "Olimex A10s-Olinuxino Micro";
 	compatible = "olimex,a10s-olinuxino-micro", "allwinner,sun5i-a10s";
 
+	aliases {
+		ethernet0 = &emac;
+	};
+
 	soc at 01c00000 {
 		emac: ethernet at 01c0b000 {
 			pinctrl-names = "default";
arch/arm/boot/dts/sun7i-a20-cubieboard2.dts +4 -0
index 15e625e..cad4c19 100644
@@ -18,6 +18,10 @@
 	model = "Cubietech Cubieboard2";
 	compatible = "cubietech,cubieboard2", "allwinner,sun7i-a20";
 
+	aliases {
+		ethernet0 = &emac;
+	};
+
 	soc at 01c00000 {
 		emac: ethernet at 01c0b000 {
 			pinctrl-names = "default";
arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts +4 -0
index 9e77855..39e1fd0 100644
@@ -18,6 +18,10 @@
 	model = "Olimex A20-Olinuxino Micro";
 	compatible = "olimex,a20-olinuxino-micro", "allwinner,sun7i-a20";
 
+	aliases {
+		ethernet0 = &emac;
+	};
+
 	soc at 01c00000 {
 		emac: ethernet at 01c0b000 {
 			pinctrl-names = "default";
Signature · 1 line
1.8.4.2
#1 lore raw

PATCH 1/1 ARM: sunxi: dt: add EMAC aliases

Hi Emilio,

Quoted 20 lines · Emilio L?pez

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 boards with EMAC and an ethernet port. 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.

---

Hi everyone,

I have tested this on a cubieboard2 and found it to work as intended, and I don't see why it wouldn't work on the other boards, given that the U-Boot codebase is shared. It may be worth submitting this for 3.13-rc0, but I'm not the one that has to make that call :)

Cheers,

Emilio

Quoted 7 lines
 arch/arm/boot/dts/sun4i-a10-a1000.dts            | 1 +
 arch/arm/boot/dts/sun4i-a10-cubieboard.dts       | 1 +
 arch/arm/boot/dts/sun4i-a10-hackberry.dts        | 4 ++++
 arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts | 4 ++++
 arch/arm/boot/dts/sun7i-a20-cubieboard2.dts      | 4 ++++
 arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts  | 4 ++++
 6 files changed, 18 insertions(+)

I think it would make more sense to add it to the dtsi.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131116/aeaed47a/attachment.sig>
#2 lore raw

PATCH v2 1/1 ARM: sunxi: dt: add EMAC aliases

In reply to Emilio López

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.

---

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(+)
arch/arm/boot/dts/sun4i-a10.dtsi +4 -0
index 09e7b43..23374da 100644
@@ -15,6 +15,10 @@
 / {
 	interrupt-parent = <&intc>;
 
+	aliases {
+		ethernet0 = &emac;
+	};
+
 	cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;
arch/arm/boot/dts/sun5i-a10s.dtsi +4 -0
index 9326b64..e95ab43 100644
@@ -16,6 +16,10 @@
 / {
 	interrupt-parent = <&intc>;
 
+	aliases {
+		ethernet0 = &emac;
+	};
+
 	cpus {
 		cpu at 0 {
 			compatible = "arm,cortex-a8";
arch/arm/boot/dts/sun7i-a20.dtsi +4 -0
index c645a0f..6bea2b84 100644
@@ -16,6 +16,10 @@
 / {
 	interrupt-parent = <&gic>;
 
+	aliases {
+		ethernet0 = &emac;
+	};
+
 	cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;
Signature · 1 line
1.8.4.2
#3 lore raw

PATCH v2 1/1 ARM: sunxi: dt: add EMAC aliases

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

Quoted 66 lines · Emilio L?pez

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.

---

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

1.8.4.2

#4 lore raw

PATCH v2 1/1 ARM: sunxi: dt: add EMAC aliases

Hi,

El 16/11/13 20:37, Michal Suchanek escribi?:

Quoted 6 lines

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

#5 lore raw

PATCH v2 1/1 ARM: sunxi: dt: add EMAC aliases

Hi,

Quoted 7 lines · Emilio L?pez

Hi,

El 16/11/13 20:37, Michal Suchanek escribi?:

Quoted 4 lines

Unfortunately,

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

Quoted 8 lines
Quoted 2 lines

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

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131117/ffd0ff45/attachment.sig>
#6 lore raw

PATCH v2 1/1 ARM: sunxi: dt: add EMAC aliases

Quoted 19 lines · Maxime Ripard

Hi,

Quoted 7 lines · Emilio L?pez

Hi,

El 16/11/13 20:37, Michal Suchanek escribi?:

Quoted 4 lines

Unfortunately,

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

Quoted 8 lines
Quoted 2 lines

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.

Quoted 3 lines

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

#7 lore raw

PATCH v2 1/1 ARM: sunxi: dt: add EMAC aliases

Quoted 6 lines · Michal Suchanek
Quoted 6 lines
Quoted 5 lines

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.

Quoted 8 lines
Quoted 3 lines

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?

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131118/6e37df2d/attachment.sig>
#8 lore raw

PATCH v2 1/1 ARM: sunxi: dt: add EMAC aliases

In reply to Emilio López
Quoted 7 lines · Emilio L?pez

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.

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

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131117/346dec6e/attachment.sig>