Skip to contentSkip to conversation

net: Add support for Qualcomm ethqos

PATCH In review Vinod Koul 5 participants 13 messages Jan 21, 2019 – Feb 12, 2019

Subsystems (9)
lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

v3 cover net: Add support for Qualcomm ethqos

Some Qualcomm SoCs sport a ethqos controller which use DW ip, so add the glue driver which uses stmmac driver along with DT bindings for this device.

This controller supports rgmii mode and doesn't work with existing phy drivers as they do not remove the phy delay delay in this mode, so fix the two phy drivers tested with this.

Changes in v3:
- Add description in DT and rename the file and compatible as suggested by Rob
- Update changelog for QCA8K driver
- Update AT803x phy disable delay for all RGMxx modes

Changes in v2:
- Fix the example in dt-binding
- Remove DT property for disable the delay and disable delay for RGMII mode in AT803x and QCA8K PHY drivers

Vinod Koul (5):
dt-bindings: net: Add Qualcomm ethqos binding
net: stmmac: Add driver for Qualcomm ethqos
MAINTAINER: Add entry for Qualcomm ETHQOS ethernet driver
net: phy: at803x: Disable phy delay for RGMII mode
net: dsa: qca8k: disable delay for RGMII mode

 .../devicetree/bindings/net/qcom,ethqos.txt   |  64 ++
 MAINTAINERS                                   |   8 +
 drivers/net/dsa/qca8k.c                       |  16 +-
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  10 +
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
 .../stmicro/stmmac/dwmac-qcom-ethqos.c        | 545 ++++++++++++++++++
 drivers/net/phy/at803x.c                      |  22 +-
 7 files changed, 644 insertions(+), 22 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/qcom,ethqos.txt
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH v3 1/5 dt-bindings: net: Add Qualcomm ethqos binding

Add support for Qualcomm ethqos found in some SoCs like QCS404.

---
 .../devicetree/bindings/net/qcom,ethqos.txt   | 64 +++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/qcom,ethqos.txt
Documentation/devicetree/bindings/net/qcom,ethqos.txt new file +64 -0
new file mode 100644
index 000000000000..fcf5035810b5
@@ -0,0 +1,64 @@
+Qualcomm Ethernet ETHQOS device
+
+This documents dwmmac based ethernet device which supports Gigabit
+ethernet for version v2.3.0 onwards.
+
+This device has following properties:
+
+Required properties:
+
+- compatible: Should be qcom,qcs404-ethqos"
+
+- reg: Address and length of the register set for the device
+
+- reg-names: Should contain register names "stmmaceth", "rgmii"
+
+- clocks: Should contain phandle to clocks
+
+- clock-names: Should contain clock names "stmmaceth", "pclk",
+		"ptp_ref", "rgmii"
+
+- interrupts: Should contain phandle to interrupts
+
+- interrupt-names: Should contain interrupt names "macirq", "eth_lpi"
+
+Rest of the properties are defined in stmmac.txt file in same directory
+
+
+Example:
+
+ethernet: ethernet@7a80000 {
+	compatible = "qcom,qcs404-ethqos";
+	reg = <0x07a80000 0x10000>,
+		<0x07a96000 0x100>;
+	reg-names = "stmmaceth", "rgmii";
+	clock-names = "stmmaceth", "pclk", "ptp_ref", "rgmii";
+	clocks = <&gcc GCC_ETH_AXI_CLK>,
+		<&gcc GCC_ETH_SLAVE_AHB_CLK>,
+		<&gcc GCC_ETH_PTP_CLK>,
+		<&gcc GCC_ETH_RGMII_CLK>;
+	interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>,
+			<GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>;
+	interrupt-names = "macirq", "eth_lpi";
+	snps,reset-gpio = <&tlmm 60 GPIO_ACTIVE_LOW>;
+	snps,reset-active-low;
+
+	snps,txpbl = <8>;
+	snps,rxpbl = <2>;
+	snps,aal;
+	snps,tso;
+
+	phy-handle = <&phy1>;
+	phy-mode = "rgmii";
+
+	mdio {
+		#address-cells = <0x1>;
+		#size-cells = <0x0>;
+		compatible = "snps,dwmac-mdio";
+		phy1: phy@4 {
+			device_type = "ethernet-phy";
+			reg = <0x4>;
+		};
+	};
+
+};
Signature · 1 line
2.20.1
maintainer Reviewed-by on v3 1/5
#2 lore raw

Re: [PATCH v3 1/5] dt-bindings: net: Add Qualcomm ethqos binding

Quoted 8 lines · Vinod Koul

Add support for Qualcomm ethqos found in some SoCs like QCS404.

---
 .../devicetree/bindings/net/qcom,ethqos.txt   | 64 +++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/qcom,ethqos.txt
author
#3 lore raw

PATCH v3 2/5 net: stmmac: Add driver for Qualcomm ethqos

In reply to Vinod Koul

Add glue driver to support Qualcomm ETHQOS using stmmac driver.

This is based on downstream driver written by Siddarth Gupta, Sunil Kumar Paidimarri, Rahul Ankushrao Kawadgave, Nisha Menon, Jagadeesh Babu Challagundla, Chaitanya Pratapa, Lakshit Tyagi, Suraj Jaiswal, Sneh Shah and Ventrapragada Ravi Kanth

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  10 +
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
 .../stmicro/stmmac/dwmac-qcom-ethqos.c        | 545 ++++++++++++++++++
 3 files changed, 556 insertions(+)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
drivers/net/ethernet/stmicro/stmmac/Kconfig +10 -0
index 6209cc1fb305..f194235153f9 100644
@@ -105,6 +105,16 @@ config DWMAC_OXNAS
 	  This selects the Oxford Semiconductor OXNASSoC glue layer support for
 	  the stmmac device driver. This driver is used for OX820.
 
+config DWMAC_QCOM_ETHQOS
+	tristate "Qualcomm ETHQOS support"
+	default ARCH_QCOM
+	depends on OF && (ARCH_QCOM || COMPILE_TEST)
+	help
+	  Support for the Qualcomm ETHQOS core.
+
+	  This selects the Qualcomm ETHQOS glue layer support for the
+	  stmmac device driver.
+
 config DWMAC_ROCKCHIP
 	tristate "Rockchip dwmac support"
 	default ARCH_ROCKCHIP
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -0
index bf09701d2623..c529c21e9bdd 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_DWMAC_LPC18XX)	+= dwmac-lpc18xx.o
 obj-$(CONFIG_DWMAC_MEDIATEK)	+= dwmac-mediatek.o
 obj-$(CONFIG_DWMAC_MESON)	+= dwmac-meson.o dwmac-meson8b.o
 obj-$(CONFIG_DWMAC_OXNAS)	+= dwmac-oxnas.o
+obj-$(CONFIG_DWMAC_QCOM_ETHQOS)	+= dwmac-qcom-ethqos.o
 obj-$(CONFIG_DWMAC_ROCKCHIP)	+= dwmac-rk.o
 obj-$(CONFIG_DWMAC_SOCFPGA)	+= dwmac-altr-socfpga.o
 obj-$(CONFIG_DWMAC_STI)		+= dwmac-sti.o
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c new file +545 -0

545 lines not on this page · raw message

Signature · 1 line
2.20.1
author
#4 lore raw

PATCH v3 3/5 MAINTAINER: Add entry for Qualcomm ETHQOS ethernet driver

In reply to Vinod Koul

Add myself and Niklas as maintainers for this driver

---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
index 32d444476a90..b0af43cda327 100644
@@ -12605,6 +12605,14 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/net/ethernet/qualcomm/emac/
 
+QUALCOMM ETHQOS ETHERNET DRIVER
+M:	Vinod Koul <[email protected]>
+M:	Niklas Cassel <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+F:	Documentation/devicetree/bindings/net/qcom,dwmac.txt
+
 QUALCOMM GENERIC INTERFACE I2C DRIVER
 M:	Alok Chauhan <[email protected]>
 M:	Karthikeyan Ramasubramanian <[email protected]>
Signature · 1 line
2.20.1
author
#5 lore raw

PATCH v3 4/5 net: phy: at803x: Disable phy delay for RGMII mode

In reply to Vinod Koul

For RGMII mode, phy delay should be disabled. Add this case along with disable delay routines.

---
 drivers/net/phy/at803x.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/net/phy/at803x.c +12 -10
index f9432d053a22..8ff12938ab47 100644
@@ -110,16 +110,16 @@ static int at803x_debug_reg_mask(struct phy_device *phydev, u16 reg,
 	return phy_write(phydev, AT803X_DEBUG_DATA, val);
 }
 
-static inline int at803x_enable_rx_delay(struct phy_device *phydev)
+static inline int at803x_disable_rx_delay(struct phy_device *phydev)
 {
-	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0, 0,
-					AT803X_DEBUG_RX_CLK_DLY_EN);
+	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0,
+				     AT803X_DEBUG_RX_CLK_DLY_EN, 0);
 }
 
-static inline int at803x_enable_tx_delay(struct phy_device *phydev)
+static inline int at803x_disable_tx_delay(struct phy_device *phydev)
 {
-	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5, 0,
-					AT803X_DEBUG_TX_CLK_DLY_EN);
+	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5,
+				     AT803X_DEBUG_TX_CLK_DLY_EN, 0);
 }
 
 /* save relevant PHY registers to private copy */
@@ -256,15 +256,17 @@ static int at803x_config_init(struct phy_device *phydev)
 		return ret;
 
 	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
-			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
-		ret = at803x_enable_rx_delay(phydev);
+			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+			phydev->interface == PHY_INTERFACE_MODE_RGMII) {
+		ret = at803x_disable_rx_delay(phydev);
 		if (ret < 0)
 			return ret;
 	}
 
 	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
-			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
-		ret = at803x_enable_tx_delay(phydev);
+			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+			phydev->interface == PHY_INTERFACE_MODE_RGMII) {
+		ret = at803x_disable_tx_delay(phydev);
 		if (ret < 0)
 			return ret;
 	}
Signature · 1 line
2.20.1
#6 lore raw

Re: [v3,4/5] net: phy: at803x: Disable phy delay for RGMII mode

Vinod,

Quoted 2 lines · Vinod Koul

For RGMII mode, phy delay should be disabled. Add this case along with disable delay routines.

In next-20190211 I need to revert this patch to get cpsw networking to work on am335x-evmsk. The board uses AR8031_AL1A PHY, which is handled by the phy/at803x.c

On next-20190211:

[    3.374601] net eth0: initializing cpsw version 1.12 (0)
[    3.384484] Atheros 8031 ethernet 4a101000.mdio:00: attached PHY driver [Atheros 8031 ethernet] (mii_bus:phy_addr=4a101000.mdio:00, irq=POLL)
[    3.400041] cpsw 4a100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[    3.410813] mmc1: new SDIO card at address 0001
[    3.439362] IP-Config: Complete:
[    3.442649]      device=eth0, hwaddr=bc:6a:29:7d:2c:a9, ipaddr=10.0.0.90, mask=255.255.255.0, gw=10.0.0.1
[    3.452840]      host=10.0.0.90, domain=, nis-domain=(none)
[    3.458462]      bootserver=10.0.0.30, rootserver=10.0.0.30, rootpath=
[    3.466296] vwl1271: disabling
[    3.470195] ALSA device list:
[    3.473189]   #0: AM335x-EVMSK

After reverting this patch:

[    3.374636] net eth0: initializing cpsw version 1.12 (0)
[    3.384534] Atheros 8031 ethernet 4a101000.mdio:00: attached PHY driver [Atheros 8031 ethernet] (mii_bus:phy_addr=4a101000.mdio:00, irq=POLL)
[    3.400125] cpsw 4a100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[    3.410866] mmc1: new SDIO card at address 0001
[    3.439379] IP-Config: Complete:
[    3.442666]      device=eth0, hwaddr=bc:6a:29:7d:2c:a9, ipaddr=10.0.0.90, mask=255.255.255.0, gw=10.0.0.1
[    3.452865]      host=10.0.0.90, domain=, nis-domain=(none)
[    3.458482]      bootserver=10.0.0.30, rootserver=10.0.0.30, rootpath=
[    3.466334] vwl1271: disabling
[    3.470245] ALSA device list:
[    3.473241]   #0: AM335x-EVMSK
[    3.501052] VFS: Mounted root (nfs filesystem) readonly on device 0:15.
[    3.508694] devtmpfs: mounted
[    3.514546] Freeing unused kernel memory: 1024K
[    3.520567] Run /sbin/init as init process

and the board boots to nfsroot fine.

Quoted 45 lines
---
 drivers/net/phy/at803x.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/net/phy/at803x.c +9 -8
index f9432d053a22..8ff12938ab47 100644
@@ -110,16 +110,16 @@ static int at803x_debug_reg_mask(struct phy_device *phydev, u16 reg,
 	return phy_write(phydev, AT803X_DEBUG_DATA, val);
 }
 
-static inline int at803x_enable_rx_delay(struct phy_device *phydev)
+static inline int at803x_disable_rx_delay(struct phy_device *phydev)
 {
-	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0, 0,
-					AT803X_DEBUG_RX_CLK_DLY_EN);
+	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0,
+				     AT803X_DEBUG_RX_CLK_DLY_EN, 0);
 }
 
-static inline int at803x_enable_tx_delay(struct phy_device *phydev)
+static inline int at803x_disable_tx_delay(struct phy_device *phydev)
 {
-	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5, 0,
-					AT803X_DEBUG_TX_CLK_DLY_EN);
+	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5,
+				     AT803X_DEBUG_TX_CLK_DLY_EN, 0);
 }
 
 /* save relevant PHY registers to private copy */
@@ -256,15 +256,17 @@ static int at803x_config_init(struct phy_device *phydev)
 		return ret;
 
 	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
-			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
-		ret = at803x_enable_rx_delay(phydev);
+			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+			phydev->interface == PHY_INTERFACE_MODE_RGMII) {
+		ret = at803x_disable_rx_delay(phydev);
 		if (ret < 0)
 			return ret;
 	}

drivers/net/phy/at803x.c static int at803x_config_init(struct phy_device *phydev) · line 272

Quoted 10 lines
drivers/net/phy/at803x.c +3 -2
 
 	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
-			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
-		ret = at803x_enable_tx_delay(phydev);
+			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+			phydev->interface == PHY_INTERFACE_MODE_RGMII) {
+		ret = at803x_disable_tx_delay(phydev);
 		if (ret < 0)
 			return ret;
 	}

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

author
#7 lore raw

Re: [v3,4/5] net: phy: at803x: Disable phy delay for RGMII mode

Hi Peter,

Quoted 9 lines · Peter Ujfalusi

Vinod,

Quoted 2 lines · Vinod Koul

For RGMII mode, phy delay should be disabled. Add this case along with disable delay routines.

In next-20190211 I need to revert this patch to get cpsw networking to work on am335x-evmsk. The board uses AR8031_AL1A PHY, which is handled by the phy/at803x.c

I see that DTS specifies that you are using phy-mode = "rgmii-txid". RGMII mode implies that we should not have any delay in the phy, so this patch does the right thing.

In the previous version of the patch I did propose to add a DT entry so that current users who are wrongly using this would not be impacted but the suggestion was to get them fixed.

So in you case do you need rgmii-txd mode if so why should the delay be enabled for this? We can add a patch that enabled delay for your controller but that cant be rgmii mode.

Thanks

Quoted 93 lines

On next-20190211:

[    3.374601] net eth0: initializing cpsw version 1.12 (0)
[    3.384484] Atheros 8031 ethernet 4a101000.mdio:00: attached PHY driver [Atheros 8031 ethernet] (mii_bus:phy_addr=4a101000.mdio:00, irq=POLL)
[    3.400041] cpsw 4a100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[    3.410813] mmc1: new SDIO card at address 0001
[    3.439362] IP-Config: Complete:
[    3.442649]      device=eth0, hwaddr=bc:6a:29:7d:2c:a9, ipaddr=10.0.0.90, mask=255.255.255.0, gw=10.0.0.1
[    3.452840]      host=10.0.0.90, domain=, nis-domain=(none)
[    3.458462]      bootserver=10.0.0.30, rootserver=10.0.0.30, rootpath=
[    3.466296] vwl1271: disabling
[    3.470195] ALSA device list:
[    3.473189]   #0: AM335x-EVMSK

After reverting this patch:

[    3.374636] net eth0: initializing cpsw version 1.12 (0)
[    3.384534] Atheros 8031 ethernet 4a101000.mdio:00: attached PHY driver [Atheros 8031 ethernet] (mii_bus:phy_addr=4a101000.mdio:00, irq=POLL)
[    3.400125] cpsw 4a100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[    3.410866] mmc1: new SDIO card at address 0001
[    3.439379] IP-Config: Complete:
[    3.442666]      device=eth0, hwaddr=bc:6a:29:7d:2c:a9, ipaddr=10.0.0.90, mask=255.255.255.0, gw=10.0.0.1
[    3.452865]      host=10.0.0.90, domain=, nis-domain=(none)
[    3.458482]      bootserver=10.0.0.30, rootserver=10.0.0.30, rootpath=
[    3.466334] vwl1271: disabling
[    3.470245] ALSA device list:
[    3.473241]   #0: AM335x-EVMSK
[    3.501052] VFS: Mounted root (nfs filesystem) readonly on device 0:15.
[    3.508694] devtmpfs: mounted
[    3.514546] Freeing unused kernel memory: 1024K
[    3.520567] Run /sbin/init as init process

and the board boots to nfsroot fine.

Quoted 45 lines
---
 drivers/net/phy/at803x.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/net/phy/at803x.c +9 -8
index f9432d053a22..8ff12938ab47 100644
@@ -110,16 +110,16 @@ static int at803x_debug_reg_mask(struct phy_device *phydev, u16 reg,
 	return phy_write(phydev, AT803X_DEBUG_DATA, val);
 }
 
-static inline int at803x_enable_rx_delay(struct phy_device *phydev)
+static inline int at803x_disable_rx_delay(struct phy_device *phydev)
 {
-	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0, 0,
-					AT803X_DEBUG_RX_CLK_DLY_EN);
+	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0,
+				     AT803X_DEBUG_RX_CLK_DLY_EN, 0);
 }
 
-static inline int at803x_enable_tx_delay(struct phy_device *phydev)
+static inline int at803x_disable_tx_delay(struct phy_device *phydev)
 {
-	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5, 0,
-					AT803X_DEBUG_TX_CLK_DLY_EN);
+	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5,
+				     AT803X_DEBUG_TX_CLK_DLY_EN, 0);
 }
 
 /* save relevant PHY registers to private copy */
@@ -256,15 +256,17 @@ static int at803x_config_init(struct phy_device *phydev)
 		return ret;
 
 	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
-			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
-		ret = at803x_enable_rx_delay(phydev);
+			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+			phydev->interface == PHY_INTERFACE_MODE_RGMII) {
+		ret = at803x_disable_rx_delay(phydev);
 		if (ret < 0)
 			return ret;
 	}

drivers/net/phy/at803x.c static int at803x_config_init(struct phy_device *phydev) · line 272

Quoted 10 lines
drivers/net/phy/at803x.c +3 -2
 
 	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
-			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
-		ret = at803x_enable_tx_delay(phydev);
+			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+			phydev->interface == PHY_INTERFACE_MODE_RGMII) {
+		ret = at803x_disable_tx_delay(phydev);
 		if (ret < 0)
 			return ret;
 	}

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

Signature · 1 line
~Vinod
#8 lore raw

Re: [v3,4/5] net: phy: at803x: Disable phy delay for RGMII mode

Hi Vinod,

Quoted 9 lines · Vinod Koul

Hi Peter,

Quoted 6 lines · Peter Ujfalusi

Vinod,

Quoted 2 lines · Vinod Koul

For RGMII mode, phy delay should be disabled. Add this case along with disable delay routines.

Quoted 7 lines
Quoted 3 lines

In next-20190211 I need to revert this patch to get cpsw networking to work on am335x-evmsk. The board uses AR8031_AL1A PHY, which is handled by the phy/at803x.c

I see that DTS specifies that you are using phy-mode = "rgmii-txid". RGMII mode implies that we should not have any delay in the phy, so this patch does the right thing.

Right, on am335x-evmsk:

[    3.393406] at803x_config_init: phydev->interface: 11

So PHY_INTERFACE_MODE_RGMII_TXID.

Quoted 7 lines

In the previous version of the patch I did propose to add a DT entry so that current users who are wrongly using this would not be impacted but the suggestion was to get them fixed.

So in you case do you need rgmii-txd mode if so why should the delay be enabled for this? We can add a patch that enabled delay for your controller but that cant be rgmii mode.

I'm not too familiar with the networking, but the AR8031 datasheet does tell that the debug_5:bit8 is 0 by default (rgmii tx clock delay disable).

In the errata document of am335x (http://www.ti.com/lit/pdf/sprz360),
1.0.10 I believe tells that the delay needs to be enabled on the rgmii ethernet PHY because the internal delay is not working (?) and advises that the delay might need to be enabled on the rgmii PHY.

The PHY_INTERFACE_MODE_RGMII_TXID delay was enabled in the PHY driver since 2013 (1ca6d1b1aef4628ff0fe458135ddb008d134ad8f)

To me it looks like that when AR8031 is used with am335x the 'rgmii tx clock delay' needs to be enabled.

Sekhar, Roger: any insights, thoughts?

Quoted 98 lines

Thanks

Quoted 93 lines

On next-20190211:

[    3.374601] net eth0: initializing cpsw version 1.12 (0)
[    3.384484] Atheros 8031 ethernet 4a101000.mdio:00: attached PHY driver [Atheros 8031 ethernet] (mii_bus:phy_addr=4a101000.mdio:00, irq=POLL)
[    3.400041] cpsw 4a100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[    3.410813] mmc1: new SDIO card at address 0001
[    3.439362] IP-Config: Complete:
[    3.442649]      device=eth0, hwaddr=bc:6a:29:7d:2c:a9, ipaddr=10.0.0.90, mask=255.255.255.0, gw=10.0.0.1
[    3.452840]      host=10.0.0.90, domain=, nis-domain=(none)
[    3.458462]      bootserver=10.0.0.30, rootserver=10.0.0.30, rootpath=
[    3.466296] vwl1271: disabling
[    3.470195] ALSA device list:
[    3.473189]   #0: AM335x-EVMSK

After reverting this patch:

[    3.374636] net eth0: initializing cpsw version 1.12 (0)
[    3.384534] Atheros 8031 ethernet 4a101000.mdio:00: attached PHY driver [Atheros 8031 ethernet] (mii_bus:phy_addr=4a101000.mdio:00, irq=POLL)
[    3.400125] cpsw 4a100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[    3.410866] mmc1: new SDIO card at address 0001
[    3.439379] IP-Config: Complete:
[    3.442666]      device=eth0, hwaddr=bc:6a:29:7d:2c:a9, ipaddr=10.0.0.90, mask=255.255.255.0, gw=10.0.0.1
[    3.452865]      host=10.0.0.90, domain=, nis-domain=(none)
[    3.458482]      bootserver=10.0.0.30, rootserver=10.0.0.30, rootpath=
[    3.466334] vwl1271: disabling
[    3.470245] ALSA device list:
[    3.473241]   #0: AM335x-EVMSK
[    3.501052] VFS: Mounted root (nfs filesystem) readonly on device 0:15.
[    3.508694] devtmpfs: mounted
[    3.514546] Freeing unused kernel memory: 1024K
[    3.520567] Run /sbin/init as init process

and the board boots to nfsroot fine.

Quoted 45 lines
---
 drivers/net/phy/at803x.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/net/phy/at803x.c +9 -8
index f9432d053a22..8ff12938ab47 100644
@@ -110,16 +110,16 @@ static int at803x_debug_reg_mask(struct phy_device *phydev, u16 reg,
 	return phy_write(phydev, AT803X_DEBUG_DATA, val);
 }
 
-static inline int at803x_enable_rx_delay(struct phy_device *phydev)
+static inline int at803x_disable_rx_delay(struct phy_device *phydev)
 {
-	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0, 0,
-					AT803X_DEBUG_RX_CLK_DLY_EN);
+	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0,
+				     AT803X_DEBUG_RX_CLK_DLY_EN, 0);
 }
 
-static inline int at803x_enable_tx_delay(struct phy_device *phydev)
+static inline int at803x_disable_tx_delay(struct phy_device *phydev)
 {
-	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5, 0,
-					AT803X_DEBUG_TX_CLK_DLY_EN);
+	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5,
+				     AT803X_DEBUG_TX_CLK_DLY_EN, 0);
 }
 
 /* save relevant PHY registers to private copy */
@@ -256,15 +256,17 @@ static int at803x_config_init(struct phy_device *phydev)
 		return ret;
 
 	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
-			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
-		ret = at803x_enable_rx_delay(phydev);
+			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+			phydev->interface == PHY_INTERFACE_MODE_RGMII) {
+		ret = at803x_disable_rx_delay(phydev);
 		if (ret < 0)
 			return ret;
 	}

drivers/net/phy/at803x.c static int at803x_config_init(struct phy_device *phydev) · line 272

Quoted 10 lines
drivers/net/phy/at803x.c +3 -2
 
 	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
-			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
-		ret = at803x_enable_tx_delay(phydev);
+			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+			phydev->interface == PHY_INTERFACE_MODE_RGMII) {
+		ret = at803x_disable_tx_delay(phydev);
 		if (ret < 0)
 			return ret;
 	}

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

author
#9 lore raw

Re: [v3,4/5] net: phy: at803x: Disable phy delay for RGMII mode

In reply to Vinod Koul

Hi again,

Quoted 17 lines · Vinod Koul

Hi Peter,

Quoted 9 lines · Peter Ujfalusi

Vinod,

Quoted 2 lines · Vinod Koul

For RGMII mode, phy delay should be disabled. Add this case along with disable delay routines.

In next-20190211 I need to revert this patch to get cpsw networking to work on am335x-evmsk. The board uses AR8031_AL1A PHY, which is handled by the phy/at803x.c

I see that DTS specifies that you are using phy-mode = "rgmii-txid". RGMII mode implies that we should not have any delay in the phy, so this patch does the right thing.

Quoted 7 lines

In the previous version of the patch I did propose to add a DT entry so that current users who are wrongly using this would not be impacted but the suggestion was to get them fixed.

So in you case do you need rgmii-txd mode if so why should the delay be enabled for this? We can add a patch that enabled delay for your controller but that cant be rgmii mode.

Relooking at this again and seeing the mode definitions in Documentation/devicetree/bindings/net/ethernet.txt,
I think I have got it wrong.. (thanks to Niklas for discussion)

So in case of rgmii mode delay should be disabled and in case of rgmii-id/rxid/txid it should be enabled. I will send a patch to address this shortly, please do test.

Thanks

Signature · 1 line
~Vinod
#10 lore raw

Re: [v3,4/5] net: phy: at803x: Disable phy delay for RGMII mode

In reply to Peter Ujfalusi
Quoted 8 lines · Peter Ujfalusi
Quoted 2 lines · Vinod Koul

For RGMII mode, phy delay should be disabled. Add this case along with disable delay routines.

In next-20190211 I need to revert this patch to get cpsw networking to work on am335x-evmsk. The board uses AR8031_AL1A PHY, which is handled by the phy/at803x.c

I'm having flashbacks:

[PATCH 1/2] net: phy: at803x: Fix RGMII RX and TX clock delays setup
https://www.spinics.net/lists/netdev/msg445053.html

Quirks of the Atheros 8035 PHY
https://www.spinics.net/lists/netdev/msg444527.html

See also
http://patchwork.ozlabs.org/project/netdev/list/?submitter=67482&state=*

Regards.

author
#11 lore raw

PATCH v3 5/5 net: dsa: qca8k: disable delay for RGMII mode

In reply to Vinod Koul

In RGMII mode we should not have any delay in port MAC, so disable the delay.

---
 drivers/net/dsa/qca8k.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/net/dsa/qca8k.c +4 -12
index 7e97e620bd44..a4b6cda38016 100644
@@ -420,7 +420,7 @@ qca8k_mib_init(struct qca8k_priv *priv)
 static int
 qca8k_set_pad_ctrl(struct qca8k_priv *priv, int port, int mode)
 {
-	u32 reg;
+	u32 reg, val;
 
 	switch (port) {
 	case 0:
@@ -439,17 +439,9 @@ qca8k_set_pad_ctrl(struct qca8k_priv *priv, int port, int mode)
 	 */
 	switch (mode) {
 	case PHY_INTERFACE_MODE_RGMII:
-		qca8k_write(priv, reg,
-			    QCA8K_PORT_PAD_RGMII_EN |
-			    QCA8K_PORT_PAD_RGMII_TX_DELAY(3) |
-			    QCA8K_PORT_PAD_RGMII_RX_DELAY(3));
-
-		/* According to the datasheet, RGMII delay is enabled through
-		 * PORT5_PAD_CTRL for all ports, rather than individual port
-		 * registers
-		 */
-		qca8k_write(priv, QCA8K_REG_PORT5_PAD_CTRL,
-			    QCA8K_PORT_PAD_RGMII_RX_DELAY_EN);
+		/* RGMII mode means no delay so don't enable the delay */
+		val = QCA8K_PORT_PAD_RGMII_EN;
+		qca8k_write(priv, reg, val);
 		break;
 	case PHY_INTERFACE_MODE_SGMII:
 		qca8k_write(priv, reg, QCA8K_PORT_PAD_SGMII_EN);
Signature · 1 line
2.20.1
maintainer
#12 lore raw
In reply to Vinod Koul

From: Vinod Koul <[email protected]>
Date: Mon, 21 Jan 2019 14:43:13 +0530

Quoted 14 lines

Some Qualcomm SoCs sport a ethqos controller which use DW ip, so add the glue driver which uses stmmac driver along with DT bindings for this device.

This controller supports rgmii mode and doesn't work with existing phy drivers as they do not remove the phy delay delay in this mode, so fix the two phy drivers tested with this.

Changes in v3:
- Add description in DT and rename the file and compatible as suggested by Rob
- Update changelog for QCA8K driver
- Update AT803x phy disable delay for all RGMxx modes

Quoted 4 lines

Changes in v2:
- Fix the example in dt-binding
- Remove DT property for disable the delay and disable delay for RGMII mode in AT803x and QCA8K PHY drivers

Series applied, thanks.