dts: socfpga: Add ethernet support on Altera's SOCFPGA platform
Subsystems (6)
PATCH 1/2 dts: socfpga: Add ethernet support on Altera's SOCFPGA platform
From: Dinh Nguyen <[email protected]>
The STMMAC Ethernet controller in SOCFPGA requires setting a register for the phy-mode that is outside of the ethernet IP. This register resides in the System Manager block. So we define a new DTS binding "altr,sysmgr-phy-mask". This binding's property is a bitmask that can be used to set the correct register bit.
--- .../bindings/net/stmmac-altr-socfpga.txt | 43 ++++++++++++++++++++ arch/arm/boot/dts/socfpga_cyclone5.dts | 19 +++++++++ 2 files changed, 62 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/stmmac-altr-socfpga.txt
Documentation/devicetree/bindings/net/stmmac-altr-socfpga.txt new file +43 -0
@@ -0,0 +1,43 @@ +* Altera SOCFPGA specific extensions to the STMicroelectronics + 10/100/1000 Ethernet driver (GMAC) + +This file documents an additional property that is required for the Altera +SOCFPGA implementation of the STMMAC Ethernet driver. Please refer to the core +properties of the STMMAC driver as documented in stmmac.txt. + +Required Properties: + +* compatible: should be + - "altr,socfpga-stmmac": for controllers with Altera SOCFPGA specific + extensions. + +* altr,sysmgr-phy-mask: This property contains the bitmask that is needed to + set the appropriate register bits for the phy-mode in the System Manager. + The value should be: + -Ethernet Controller 1 (gmac0) = 0x3 + -Ethernet Controller 2 (gmac1) = 0xC + +Example: + + gmac0: ethernet at ff700000 { + compatible = "altr,socfpga-stmmac", "snps,dwmac-3.70a", "snps,dwmac"; + reg = <0xff700000 0x2000>; + interrupts = <0 115 4>; + interrupt-names = "macirq""; + mac-address = [000000000000]; /* Filled in by U-Boot */ + phy-mode = "gmii"; + + /* PHY Skew settings */ + rxd0-skew-ps = <0>; + rxd0-skew-ps = <0>; + rxd1-skew-ps = <0>; + rxd2-skew-ps = <0>; + rxd3-skew-ps = <0>; + txen-skew-ps = <0>; + txc-skew-ps = <2600>; + rxdv-skew-ps = <0>; + rxc-skew-ps = <2000>; + + altr,sysmgr-phy-mask = <0x3>; + status = "okay"; + };
arch/arm/boot/dts/socfpga_cyclone5.dts +19 -0
@@ -95,3 +95,22 @@ }; }; }; + +&gmac1 { + phy-mode = "rgmii"; + snps,phy-addr = <0xffffffff>; /* probe for phy addr */ + + rxd0-skew-ps = <0>; + rxd0-skew-ps = <0>; + rxd1-skew-ps = <0>; + rxd2-skew-ps = <0>; + rxd3-skew-ps = <0>; + txen-skew-ps = <0>; + txc-skew-ps = <2600>; + rxdv-skew-ps = <0>; + rxc-skew-ps = <2000>; + + altr,sysmgr-phy-mask = <0xC>; + status = "okay"; +}; +
Signature · 1 line
1.7.9.5
PATCH 2/2 arm: socfpga: Add platform initialization for ethernet
From: Dinh Nguyen <[email protected]>
In order to correctly enable ethernet support on SOCFGPA, a couple of platform specific initializations steps must be done.
1) Use the phy-mode DTS property to set the appropriate bits in a system manager register.
2) The ethernet IP should only be brought out of reset when initialized.
--- arch/arm/mach-socfpga/core.h | 9 +++++ arch/arm/mach-socfpga/socfpga.c | 72 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 80 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/core.h +9 -0
@@ -28,6 +28,15 @@#define RSTMGR_CTRL_SWCOLDRSTREQ 0x1/* Cold Reset */ #define RSTMGR_CTRL_SWWARMRSTREQ 0x2/* Warm Reset */ +/* Peripheral Module Reset Register bits */ +#define RSTMGR_PERMODRST_EMAC0 0x1 +#define RSTMGR_PERMODRST_EMAC1 0x2 + +#define SYSMGR_EMACGRP_CTRL_OFFSET 0x60 +#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII 0x0 +#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII 0x1 +#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RMII 0x2 +extern void socfpga_secondary_startup (void );extern void __iomem *socfpga_scu_base_addr;
arch/arm/mach-socfpga/socfpga.c +71 -1
97 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 1/2 dts: socfpga: Add ethernet support on Altera's SOCFPGA platform
In reply to dinguyen at altera.comQuoted 9 lines · dinguyen at altera.com
From: Dinh Nguyen <[email protected]>
The STMMAC Ethernet controller in SOCFPGA requires setting a register for the phy-mode that is outside of the ethernet IP. This register resides in the System Manager block. So we define a new DTS binding "altr,sysmgr-phy-mask". This binding's property is a bitmask that can be used to set the correct register bit.
Documentation/devicetree/bindings/net/stmmac-altr-socfpga.txt line 18
Quoted 6 lines
Documentation/devicetree/bindings/net/stmmac-altr-socfpga.txt +5
-0+* altr,sysmgr-phy-mask: This property contains the bitmask that is needed to + set the appropriate register bits for the phy-mode in the System Manager. + The value should be: + -Ethernet Controller 1 (gmac0) = 0x3 + -Ethernet Controller 2 (gmac1) = 0xC
Wouldn't you need a phandle to the sysmgr node so that the driver could be located, and a register number within its register block too? Or, does sysmgr know which register to poke? If so, couldn't the API take just a device index rather than a bitmask instead, and calculate the mask itself?
PATCH 1/2 dts: socfpga: Add ethernet support on Altera's SOCFPGA platform
Hi Stephen,
Quoted 19 lines · Stephen Warren
Documentation/devicetree/bindings/net/stmmac-altr-socfpga.txt line 18
Quoted 13 lines · dinguyen at altera.com
From: Dinh Nguyen <[email protected]>
The STMMAC Ethernet controller in SOCFPGA requires setting a register for the phy-mode that is outside of the ethernet IP. This register resides in the System Manager block. So we define a new DTS binding "altr,sysmgr-phy-mask". This binding's property is a bitmask that can be used to set the correct register bit.
Documentation/devicetree/bindings/net/stmmac-altr-socfpga.txt +5
-0+* altr,sysmgr-phy-mask: This property contains the bitmask that is needed to + set the appropriate register bits for the phy-mode in the System Manager. + The value should be: + -Ethernet Controller 1 (gmac0) = 0x3 + -Ethernet Controller 2 (gmac1) = 0xCWouldn't you need a phandle to the sysmgr node so that the driver could be located, and a register number within its register block too? Or, does sysmgr know which register to poke? If so, couldn't the API take just a device index rather than a bitmask instead, and calculate the mask itself?
The function that pokes this register is a platform specific init function call from the driver, so the function knows which register in the the sysmgr to poke. The first byte of the register has controls for both ethernet controllers. I thought it would be better to use a mask to be used to differentiate between each controller.
Thanks,
Dinh