diff mbox

[U-Boot,2/2] sunxi: A64: (re-)add sun8i emac DT nodes

Message ID 1495414773-3466-3-git-send-email-andre.przywara@arm.com
State Changes Requested
Delegated to: Tom Rini
Headers show

Commit Message

Andre Przywara May 22, 2017, 12:59 a.m. UTC
As the kernel DT does not have an Ethernet driver and bindings, lets
(re-)add the DT bindings for U-Boot's sun8i EMAC Ethernet driver, which
got lost when syncing the kernel DT to U-Boot.
This slightly updates the DT nodes to adapt to the new DT (clock and
reset nodes), but keeps the rest the same to let it work with the
existing U-Boot driver.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 arch/arm/dts/sun50i-a64-pine64-plus.dts | 14 +++++++++++++-
 arch/arm/dts/sun50i-a64-pine64.dts      |  1 +
 arch/arm/dts/sun50i-a64.dtsi            | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 1 deletion(-)

Comments

Maxime Ripard May 22, 2017, 6:52 a.m. UTC | #1
On Mon, May 22, 2017 at 01:59:33AM +0100, Andre Przywara wrote:
> As the kernel DT does not have an Ethernet driver and bindings, lets
> (re-)add the DT bindings for U-Boot's sun8i EMAC Ethernet driver, which
> got lost when syncing the kernel DT to U-Boot.
> This slightly updates the DT nodes to adapt to the new DT (clock and
> reset nodes), but keeps the rest the same to let it work with the
> existing U-Boot driver.
> 
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Maxime
Tom Rini May 22, 2017, 8:49 p.m. UTC | #2
On Mon, May 22, 2017 at 01:59:33AM +0100, Andre Przywara wrote:
> As the kernel DT does not have an Ethernet driver and bindings, lets
> (re-)add the DT bindings for U-Boot's sun8i EMAC Ethernet driver, which
> got lost when syncing the kernel DT to U-Boot.
> This slightly updates the DT nodes to adapt to the new DT (clock and
> reset nodes), but keeps the rest the same to let it work with the
> existing U-Boot driver.
> 
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
>  arch/arm/dts/sun50i-a64-pine64-plus.dts | 14 +++++++++++++-
>  arch/arm/dts/sun50i-a64-pine64.dts      |  1 +
>  arch/arm/dts/sun50i-a64.dtsi            | 33 +++++++++++++++++++++++++++++++++

NAK, please start making use of -u-boot.dtsi files for these so they
won't keep getting lost.
Andre Przywara May 23, 2017, 9:32 a.m. UTC | #3
Hi Tom,

On 22/05/17 21:49, Tom Rini wrote:
> On Mon, May 22, 2017 at 01:59:33AM +0100, Andre Przywara wrote:
>> As the kernel DT does not have an Ethernet driver and bindings, lets
>> (re-)add the DT bindings for U-Boot's sun8i EMAC Ethernet driver, which
>> got lost when syncing the kernel DT to U-Boot.
>> This slightly updates the DT nodes to adapt to the new DT (clock and
>> reset nodes), but keeps the rest the same to let it work with the
>> existing U-Boot driver.
>>
>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>> ---
>>  arch/arm/dts/sun50i-a64-pine64-plus.dts | 14 +++++++++++++-
>>  arch/arm/dts/sun50i-a64-pine64.dts      |  1 +
>>  arch/arm/dts/sun50i-a64.dtsi            | 33 +++++++++++++++++++++++++++++++++
> 
> NAK, please start making use of -u-boot.dtsi files for these so they
> won't keep getting lost.

Ah, thanks for the heads up, wasn't aware of that.
I changed this patch, it looks quite neat now since this non-standard
binding is now in a separate file and the original .dts files match
exactly the Linux versions. Also it is expected that we will need to
change these nodes anyway to match the upcoming Linux Ethernet bindings.

One thing I noticed is that the binman/ node got lost with this
approach, is that because the -u-boot.dtsi scheme can only deal with one
addon file and stops looking on the first hit (skipping sunxi-u-boot.dtsi)?

Cheers,
Andre.
Tom Rini May 23, 2017, 11:16 a.m. UTC | #4
On Tue, May 23, 2017 at 10:32:06AM +0100, Andre Przywara wrote:
> Hi Tom,
> 
> On 22/05/17 21:49, Tom Rini wrote:
> > On Mon, May 22, 2017 at 01:59:33AM +0100, Andre Przywara wrote:
> >> As the kernel DT does not have an Ethernet driver and bindings, lets
> >> (re-)add the DT bindings for U-Boot's sun8i EMAC Ethernet driver, which
> >> got lost when syncing the kernel DT to U-Boot.
> >> This slightly updates the DT nodes to adapt to the new DT (clock and
> >> reset nodes), but keeps the rest the same to let it work with the
> >> existing U-Boot driver.
> >>
> >> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> >> ---
> >>  arch/arm/dts/sun50i-a64-pine64-plus.dts | 14 +++++++++++++-
> >>  arch/arm/dts/sun50i-a64-pine64.dts      |  1 +
> >>  arch/arm/dts/sun50i-a64.dtsi            | 33 +++++++++++++++++++++++++++++++++
> > 
> > NAK, please start making use of -u-boot.dtsi files for these so they
> > won't keep getting lost.
> 
> Ah, thanks for the heads up, wasn't aware of that.
> I changed this patch, it looks quite neat now since this non-standard
> binding is now in a separate file and the original .dts files match
> exactly the Linux versions. Also it is expected that we will need to
> change these nodes anyway to match the upcoming Linux Ethernet bindings.
> 
> One thing I noticed is that the binman/ node got lost with this
> approach, is that because the -u-boot.dtsi scheme can only deal with one
> addon file and stops looking on the first hit (skipping sunxi-u-boot.dtsi)?

Ah, I think we've found another problem to fix then, yes.  Today we only
allow one -u-boot.dtsi, but really we should allow for N of them, and
allow for more specific ones (ie board-u-boot.dtsi) to override less
specific (ie soc-u-boot.dtsi) ones, just like regular DTS files, thanks!
diff mbox

Patch

diff --git a/arch/arm/dts/sun50i-a64-pine64-plus.dts b/arch/arm/dts/sun50i-a64-pine64-plus.dts
index 790d14d..948cb19 100644
--- a/arch/arm/dts/sun50i-a64-pine64-plus.dts
+++ b/arch/arm/dts/sun50i-a64-pine64-plus.dts
@@ -46,5 +46,17 @@ 
 	model = "Pine64+";
 	compatible = "pine64,pine64-plus", "allwinner,sun50i-a64";
 
-	/* TODO: Camera, Ethernet PHY, touchscreen, etc. */
+	/* TODO: Camera, touchscreen, etc. */
+};
+
+&emac {
+	pinctrl-names = "default";
+	pinctrl-0 = <&rgmii_pins>;
+	phy-mode = "rgmii";
+	phy = <&phy1>;
+	status = "okay";
+
+	phy1: ethernet-phy@1 {
+		reg = <1>;
+	};
 };
diff --git a/arch/arm/dts/sun50i-a64-pine64.dts b/arch/arm/dts/sun50i-a64-pine64.dts
index c680ed3..6c15040 100644
--- a/arch/arm/dts/sun50i-a64-pine64.dts
+++ b/arch/arm/dts/sun50i-a64-pine64.dts
@@ -52,6 +52,7 @@ 
 
 	aliases {
 		serial0 = &uart0;
+		ethernet0 = &emac;
 	};
 
 	chosen {
diff --git a/arch/arm/dts/sun50i-a64.dtsi b/arch/arm/dts/sun50i-a64.dtsi
index c7f669f..121e660 100644
--- a/arch/arm/dts/sun50i-a64.dtsi
+++ b/arch/arm/dts/sun50i-a64.dtsi
@@ -295,6 +295,25 @@ 
 				pins = "PG8", "PG9";
 				function = "uart1";
 			};
+
+			rmii_pins: rmii_pins {
+				allwinner,pins = "PD10", "PD11", "PD13", "PD14",
+						 "PD17", "PD18", "PD19", "PD20",
+						 "PD22", "PD23";
+				allwinner,function = "emac";
+				allwinner,drive = <3>;
+				allwinner,pull = <0>;
+			};
+
+			rgmii_pins: rgmii_pins {
+				allwinner,pins = "PD8", "PD9", "PD10", "PD11",
+						 "PD12", "PD13", "PD15",
+						 "PD16", "PD17", "PD18", "PD19",
+						 "PD20", "PD21", "PD22", "PD23";
+				allwinner,function = "emac";
+				allwinner,drive = <3>;
+				allwinner,pull = <0>;
+			};
 		};
 
 		uart0: serial@1c28000 {
@@ -423,5 +442,19 @@ 
 			interrupt-controller;
 			#interrupt-cells = <3>;
 		};
+
+		emac: ethernet@01c30000 {
+			compatible = "allwinner,sun50i-a64-emac";
+			reg = <0x01c30000 0x2000>, <0x01c00030 0x4>;
+			reg-names = "emac", "syscon";
+			interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
+			resets = <&ccu RST_BUS_EMAC>;
+			reset-names = "ahb";
+			clocks = <&ccu CLK_BUS_EMAC>;
+			clock-names = "ahb";
+			status = "disabled";
+			#address-cells = <1>;
+			#size-cells = <0>;
+		};
 	};
 };