sunxi: R40: add support for gigabit ethernet
Subsystems (3)
PATCH 1/1 sunxi: R40: add support for gigabit ethernet
This patch adds support for the gigabit interface found on the Allwinner R40/V40 CPU.
It does not support the 100Mbit interface (EMAC).
Fixes:
- add GMAC gating clock and reset control
- GPIO mux settings
- device tree entries
Tested on BananaPi M2 Berry (R40), custom board (V40).
--- arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts | 14 ++++++++++ arch/arm/dts/sun8i-r40.dtsi | 37 +++++++++++++++++++++++++++ arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 10 +++++++- board/sunxi/gmac.c | 5 +++- configs/Bananapi_M2_Ultra_defconfig | 4 +++ drivers/net/sun8i_emac.c | 2 ++ 6 files changed, 70 insertions(+), 2 deletions(-)
arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts +14 -0
@@ -67,3 +67,17 @@ pinctrl-0 = <&uart0_pb_pins>; status = "okay"; }; + +&gmac { + pinctrl-names = "default"; + pinctrl-0 = <&gmac_pins_rgmii>; + status = "okay"; + phy-handle = <&rgmii_phy>; +}; + +&mdio { + rgmii_phy: ethernet-phy at 1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; +};
arch/arm/dts/sun8i-r40.dtsi +37 -0
@@ -114,6 +114,12 @@ #size-cells = <1>; ranges; + syscon: syscon at 1c00000 { + compatible = "allwinner,sun8i-r40-system-controller", + "syscon"; + reg = <0x01c00000 0x1000>; + }; + pio: pinctrl at 1c20800 { compatible = "allwinner,sun8i-r40-pinctrl"; reg = <0x01c20800 0x400>;
@@ -126,6 +132,15 @@ #interrupt-cells = <3>; #gpio-cells = <3>; + gmac_pins_rgmii: gmac_rgmii { + pins = "PA0", "PA1", "PA2", + "PA3", "PA4", "PA5", "PA6", + "PA7", "PA8", "PA10", + "PA11", "PA12", "PA13", + "PA15", "PA16"; + function = "gmac"; + }; + i2c0_pins: i2c0_pins { pins = "PB0", "PB1"; function = "i2c0";
@@ -159,6 +174,28 @@ #size-cells = <0>; }; + gmac: ethernet at 01c50000 { + compatible = "allwinner,sun8i-h3-emac"; + syscon = <&syscon>; + reg = <0x01c50000 0x2000>; + interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "macirq"; + clocks = <&osc24M>, <&osc24M>; + clock-names = "stmmaceth", "allwinner_gmac_tx"; + #address-cells = <1>; + #size-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&gmac_pins_rgmii>; + phy-mode = "rgmii"; + status = "disabled"; + + mdio: mdio { + #address-cells = <1>; + #size-cells = <0>; + compatible = "snps,dwmac-mdio"; + }; + }; + gic: interrupt-controller at 1c81000 { compatible = "arm,cortex-a7-gic", "arm,cortex-a15-gic"; reg = <0x01c81000 0x1000>,
arch/arm/include/asm/arch-sunxi/clock_sun6i.h +9 -1
@@ -61,7 +61,11 @@ struct sunxi_ccm_reg {u32 reserved11;u32 sata_clk_cfg;/* 0xc8 SATA clock control (R40 only) */ u32 usb_clk_cfg;/* 0xcc USB clock control */ -u32 gmac_clk_cfg;/* 0xd0 GMAC clock control */ +#ifndef CONFIG_MACH_SUN8I_R40 +u32 gmac_clk_cfg;/* 0xd0 GMAC clock control (not for R40) */ +#else +u32 cir0_clk_cfg;/* 0xd0 CIR0 clock control (R40 only) */ +#endif u32 reserved12[7 ];u32 mdfs_clk_cfg;/* 0xf0 MDFS clock control */ u32 dram_clk_cfg;/* 0xf4 DRAM configuration clock control */
@@ -104,7 +108,11 @@ struct sunxi_ccm_reg {u32 mtc_clk_cfg;/* 0x158 MTC module clock */ u32 mbus0_clk_cfg;/* 0x15c MBUS0 module clock */ u32 mbus1_clk_cfg;/* 0x160 MBUS1 module clock */ +#ifndef CONFIG_MACH_SUN8I_R40 u32 reserved16; +#else +u32 gmac_clk_cfg;/* 0x164 GMAC clock control (only R40) */ +#endif u32 mipi_dsi_clk_cfg;/* 0x168 MIPI DSI clock control */ u32 mipi_csi_clk_cfg;/* 0x16c MIPI CSI clock control */ u32 reserved17[4 ];
board/sunxi/gmac.c +4 -1
@@ -13,7 +13,10 @@ void eth_init_board(void) (struct sunxi_ccm_reg *)SUNXI_CCM_BASE ;/* Set up clock gating */ -#ifdef CONFIG_SUNXI_GEN_SUN6I +#if defined(CONFIG_MACH_SUN8I_R40 ) +setbits_le32 (&ccm->ahb_reset1_cfg,0x1 <<AHB_RESET_OFFSET_GMAC ); +setbits_le32 (&ccm->ahb_gate1,0x1 <<AHB_GATE_OFFSET_GMAC ); +#elif defined(CONFIG_SUNXI_GEN_SUN6I )setbits_le32 (&ccm->ahb_reset0_cfg,0x1 <<AHB_RESET_OFFSET_GMAC );setbits_le32 (&ccm->ahb_gate0,0x1 <<AHB_GATE_OFFSET_GMAC );#else
configs/Bananapi_M2_Ultra_defconfig +4 -0
@@ -17,3 +17,7 @@ CONFIG_AXP_DLDO4_VOLT=2500 CONFIG_AXP_ELDO3_VOLT=1200 CONFIG_SCSI=y CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y +CONFIG_SUN8I_EMAC=y +CONFIG_RGMII=y +CONFIG_SUN7I_GMAC=y +CONFIG_MACPWR="PA17"
drivers/net/sun8i_emac.c +2 -0
@@ -68,6 +68,8 @@#if defined(CONFIG_MACH_SUNXI_H3_H5 )#define SUN8I_GPD8_GMAC 2 +#elif defined(CONFIG_MACH_SUN8I_R40 ) +#define SUN8I_GPD8_GMAC 5#else #define SUN8I_GPD8_GMAC 4#endif
Signature · 1 line
2.14.1
PATCH 1/1 sunxi: R40: add support for gigabit ethernet
Quoted 110 lines · Lothar Felten
This patch adds support for the gigabit interface found on the Allwinner R40/V40 CPU.
It does not support the 100Mbit interface (EMAC).Fixes:
- add GMAC gating clock and reset control
- GPIO mux settings
- device tree entriesTested on BananaPi M2 Berry (R40), custom board (V40).
Signed-off-by Lothar Felten <[email protected]>--- arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts | 14 ++++++++++ arch/arm/dts/sun8i-r40.dtsi | 37 +++++++++++++++++++++++++++ arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 10 +++++++- board/sunxi/gmac.c | 5 +++- configs/Bananapi_M2_Ultra_defconfig | 4 +++ drivers/net/sun8i_emac.c | 2 ++ 6 files changed, 70 insertions(+), 2 deletions(-)arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts +14
-0@@ -67,3 +67,17 @@ pinctrl-0 = <&uart0_pb_pins>; status = "okay"; }; + +&gmac { + pinctrl-names = "default"; + pinctrl-0 = <&gmac_pins_rgmii>; + status = "okay"; + phy-handle = <&rgmii_phy>; +}; + +&mdio { + rgmii_phy: ethernet-phy at 1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; +};arch/arm/dts/sun8i-r40.dtsi +37
-0@@ -114,6 +114,12 @@ #size-cells = <1>; ranges; + syscon: syscon at 1c00000 { + compatible = "allwinner,sun8i-r40-system-controller", + "syscon"; + reg = <0x01c00000 0x1000>; + }; + pio: pinctrl at 1c20800 { compatible = "allwinner,sun8i-r40-pinctrl"; reg = <0x01c20800 0x400>;@@ -126,6 +132,15 @@ #interrupt-cells = <3>; #gpio-cells = <3>; + gmac_pins_rgmii: gmac_rgmii { + pins = "PA0", "PA1", "PA2", + "PA3", "PA4", "PA5", "PA6", + "PA7", "PA8", "PA10", + "PA11", "PA12", "PA13", + "PA15", "PA16"; + function = "gmac"; + }; + i2c0_pins: i2c0_pins { pins = "PB0", "PB1"; function = "i2c0";@@ -159,6 +174,28 @@ #size-cells = <0>; }; + gmac: ethernet at 01c50000 { + compatible = "allwinner,sun8i-h3-emac"; + syscon = <&syscon>; + reg = <0x01c50000 0x2000>; + interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "macirq"; + clocks = <&osc24M>, <&osc24M>; + clock-names = "stmmaceth", "allwinner_gmac_tx"; + #address-cells = <1>; + #size-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&gmac_pins_rgmii>; + phy-mode = "rgmii"; + status = "disabled"; + + mdio: mdio { + #address-cells = <1>; + #size-cells = <0>; + compatible = "snps,dwmac-mdio"; + }; + }; + gic: interrupt-controller at 1c81000 { compatible = "arm,cortex-a7-gic", "arm,cortex-a15-gic"; reg = <0x01c81000 0x1000>,arch/arm/include/asm/arch-sunxi/clock_sun6i.h +0
-0
arch/arm/include/asm/arch-sunxi/clock_sun6i.h struct sunxi_ccm_reg { · line 64
Quoted 5 lines
arch/arm/include/asm/arch-sunxi/clock_sun6i.h +1
-1@@ -61,7 +61,11 @@ struct sunxi_ccm_reg {u32 reserved11;u32 sata_clk_cfg;/* 0xc8 SATA clock control (R40 only) */ u32 usb_clk_cfg;/* 0xcc USB clock control */ -u32 gmac_clk_cfg;/* 0xd0 GMAC clock control */ +#ifndef CONFIG_MACH_SUN8I_R40
You should use positive logic for this type of thing (where you have both cases).
arch/arm/include/asm/arch-sunxi/clock_sun6i.h struct sunxi_ccm_reg { · line 111
Quoted 12 lines
arch/arm/include/asm/arch-sunxi/clock_sun6i.h +5
-0+u32 gmac_clk_cfg;/* 0xd0 GMAC clock control (not for R40) */ +#else +u32 cir0_clk_cfg;/* 0xd0 CIR0 clock control (R40 only) */ +#endif u32 reserved12[7 ];u32 mdfs_clk_cfg;/* 0xf0 MDFS clock control */ u32 dram_clk_cfg;/* 0xf4 DRAM configuration clock control */ @@ -104,7 +108,11 @@ struct sunxi_ccm_reg {u32 mtc_clk_cfg;/* 0x158 MTC module clock */ u32 mbus0_clk_cfg;/* 0x15c MBUS0 module clock */ u32 mbus1_clk_cfg;/* 0x160 MBUS1 module clock */ +#ifndef CONFIG_MACH_SUN8I_R40
Use positive logic.
Quoted 55 lines
arch/arm/include/asm/arch-sunxi/clock_sun6i.h +3
-0u32 reserved16; +#else +u32 gmac_clk_cfg;/* 0x164 GMAC clock control (only R40) */ +#endif u32 mipi_dsi_clk_cfg;/* 0x168 MIPI DSI clock control */ u32 mipi_csi_clk_cfg;/* 0x16c MIPI CSI clock control */ u32 reserved17[4 ];board/sunxi/gmac.c +4
-1@@ -13,7 +13,10 @@ void eth_init_board(void) (struct sunxi_ccm_reg *)SUNXI_CCM_BASE ;/* Set up clock gating */ -#ifdef CONFIG_SUNXI_GEN_SUN6I +#if defined(CONFIG_MACH_SUN8I_R40 ) +setbits_le32 (&ccm->ahb_reset1_cfg,0x1 <<AHB_RESET_OFFSET_GMAC ); +setbits_le32 (&ccm->ahb_gate1,0x1 <<AHB_GATE_OFFSET_GMAC ); +#elif defined(CONFIG_SUNXI_GEN_SUN6I )setbits_le32 (&ccm->ahb_reset0_cfg,0x1 <<AHB_RESET_OFFSET_GMAC );setbits_le32 (&ccm->ahb_gate0,0x1 <<AHB_GATE_OFFSET_GMAC );#else configs/Bananapi_M2_Ultra_defconfig +4
-0@@ -17,3 +17,7 @@ CONFIG_AXP_DLDO4_VOLT=2500 CONFIG_AXP_ELDO3_VOLT=1200 CONFIG_SCSI=y CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y +CONFIG_SUN8I_EMAC=y +CONFIG_RGMII=y +CONFIG_SUN7I_GMAC=y +CONFIG_MACPWR="PA17"drivers/net/sun8i_emac.c +2
-1@@ -68,6 +68,8 @@#if defined(CONFIG_MACH_SUNXI_H3_H5 )#define SUN8I_GPD8_GMAC 2 +#elif defined(CONFIG_MACH_SUN8I_R40 ) +#define SUN8I_GPD8_GMAC 5#else #define SUN8I_GPD8_GMAC 4#endif --2.14.1
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 1/1 sunxi: R40: add support for gigabit ethernet
In reply to Lothar FeltenHi Lothar,
Quoted 12 lines · Lothar Felten
This patch adds support for the gigabit interface found on the Allwinner R40/V40 CPU.
It does not support the 100Mbit interface (EMAC).Fixes:
- add GMAC gating clock and reset control
- GPIO mux settings
- device tree entriesTested on BananaPi M2 Berry (R40), custom board (V40).
Signed-off-by Lothar Felten <[email protected]>
Quoted 8 lines
--- arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts | 14 ++++++++++ arch/arm/dts/sun8i-r40.dtsi | 37 +++++++++++++++++++++++++++ arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 10 +++++++- board/sunxi/gmac.c | 5 +++- configs/Bananapi_M2_Ultra_defconfig | 4 +++ drivers/net/sun8i_emac.c | 2 ++ 6 files changed, 70 insertions(+), 2 deletions(-)
This patch looks mostly correct, but it should be split into multiple, smaller patches, one per logical change. This would mean something like:
- One to add the clock / reset changes
- One to add the pinctrl change
- One to add the DTSI bits
- And one to enable it on the BPI M2-U (with the config and DTS changes).
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180417/c0e64faa/attachment.sig>