Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] net: ethernet: stmmac: Enable interface clocks on probe for IPQ806x
@ 2020-05-21 11:49 Jonathan McDowell
  2020-05-22 23:07 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan McDowell @ 2020-05-21 11:49 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, netdev
  Cc: linux-kernel, linux-arm-msm, Sergey Sergeev, Marcel Ziswiler

The ipq806x_gmac_probe() function enables the PTP clock but not the
appropriate interface clocks. This means that if the bootloader hasn't
done so attempting to bring up the interface will fail with an error
like:

[   59.028131] ipq806x-gmac-dwmac 37600000.ethernet: Failed to reset the dma
[   59.028196] ipq806x-gmac-dwmac 37600000.ethernet eth1: stmmac_hw_setup: DMA engine initialization failed
[   59.034056] ipq806x-gmac-dwmac 37600000.ethernet eth1: stmmac_open: Hw setup failed

This patch, a slightly cleaned up version of one posted by Sergey
Sergeev in:

https://forum.openwrt.org/t/support-for-mikrotik-rb3011uias-rm/4064/257

correctly enables the clock; we have already configured the source just
before this.

Tested on a MikroTik RB3011.

Signed-off-by: Jonathan McDowell <noodles@earth.li>

---

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
index 6ae13dc19510..02102c781a8c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
@@ -319,6 +319,19 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
 	/* Enable PTP clock */
 	regmap_read(gmac->nss_common, NSS_COMMON_CLK_GATE, &val);
 	val |= NSS_COMMON_CLK_GATE_PTP_EN(gmac->id);
+	switch (gmac->phy_mode) {
+	case PHY_INTERFACE_MODE_RGMII:
+		val |= NSS_COMMON_CLK_GATE_RGMII_RX_EN(gmac->id) |
+			NSS_COMMON_CLK_GATE_RGMII_TX_EN(gmac->id);
+		break;
+	case PHY_INTERFACE_MODE_SGMII:
+		val |= NSS_COMMON_CLK_GATE_GMII_RX_EN(gmac->id) |
+				NSS_COMMON_CLK_GATE_GMII_TX_EN(gmac->id);
+		break;
+	default:
+		/* We don't get here; the switch above will have errored out */
+		unreachable();
+	}
 	regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val);
 
 	if (gmac->phy_mode == PHY_INTERFACE_MODE_SGMII) {

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: ethernet: stmmac: Enable interface clocks on probe for IPQ806x
  2020-05-21 11:49 [PATCH] net: ethernet: stmmac: Enable interface clocks on probe for IPQ806x Jonathan McDowell
@ 2020-05-22 23:07 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-05-22 23:07 UTC (permalink / raw)
  To: noodles
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, netdev, linux-kernel,
	linux-arm-msm, adron, marcel

From: Jonathan McDowell <noodles@earth.li>
Date: Thu, 21 May 2020 12:49:34 +0100

> The ipq806x_gmac_probe() function enables the PTP clock but not the
> appropriate interface clocks. This means that if the bootloader hasn't
> done so attempting to bring up the interface will fail with an error
> like:
> 
> [   59.028131] ipq806x-gmac-dwmac 37600000.ethernet: Failed to reset the dma
> [   59.028196] ipq806x-gmac-dwmac 37600000.ethernet eth1: stmmac_hw_setup: DMA engine initialization failed
> [   59.034056] ipq806x-gmac-dwmac 37600000.ethernet eth1: stmmac_open: Hw setup failed
> 
> This patch, a slightly cleaned up version of one posted by Sergey
> Sergeev in:
> 
> https://forum.openwrt.org/t/support-for-mikrotik-rb3011uias-rm/4064/257
> 
> correctly enables the clock; we have already configured the source just
> before this.
> 
> Tested on a MikroTik RB3011.
> 
> Signed-off-by: Jonathan McDowell <noodles@earth.li>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-21 11:49 [PATCH] net: ethernet: stmmac: Enable interface clocks on probe for IPQ806x Jonathan McDowell
2020-05-22 23:07 ` David Miller

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org
	public-inbox-index linux-arm-msm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git