aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSander Vanheule <sander@svanheule.net>2020-07-19 20:01:48 +0200
committerPetr Štetiar <ynezz@true.cz>2020-11-23 22:53:15 +0100
commit8dd2a1715b0a59407cf90c0708fc2bc199e110b5 (patch)
tree2574fe249fed357cfc0457dbaa1522876781714e
parentc0af4a0ca259022d9d2dedcfb31e11ab46e443c2 (diff)
downloadupstream-8dd2a1715b0a59407cf90c0708fc2bc199e110b5.tar.gz
upstream-8dd2a1715b0a59407cf90c0708fc2bc199e110b5.tar.bz2
upstream-8dd2a1715b0a59407cf90c0708fc2bc199e110b5.zip
ath79: ensure QCA956x gmac0 mux selects sgmii
Some bootloaders do not set up gmac0 properly, leaving it disconnected from the sgmii interface. If the user specificies phy-mode sgmii, then use the gmac-config/device node to ensure the mux is configured correctly. Signed-off-by: Sander Vanheule <sander@svanheule.net>
-rw-r--r--target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
index d611007a86..7b292cc005 100644
--- a/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
+++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
@@ -665,6 +665,37 @@ out:
of_node_put(np);
}
+static void ag71xx_mux_select_sgmii_qca956x(struct device_node *np)
+{
+ struct device_node *np_dev;
+ void __iomem *gmac_base;
+ u32 t;
+
+ np = of_get_child_by_name(np, "gmac-config");
+ if (!np)
+ return;
+
+ np_dev = of_parse_phandle(np, "device", 0);
+ if (!np_dev)
+ goto out;
+
+ gmac_base = of_iomap(np_dev, 0);
+ if (!gmac_base) {
+ pr_err("%pOF: can't map GMAC registers\n", np_dev);
+ goto err_iomap;
+ }
+
+ t = __raw_readl(gmac_base + QCA956X_GMAC_REG_ETH_CFG);
+ t |= QCA956X_ETH_CFG_GE0_SGMII;
+ __raw_writel(t, gmac_base + QCA956X_GMAC_REG_ETH_CFG);
+
+ iounmap(gmac_base);
+err_iomap:
+ of_node_put(np_dev);
+out:
+ of_node_put(np);
+}
+
static void ath79_mii_ctrl_set_if(struct ag71xx *ag, unsigned int mii_if)
{
u32 t;
@@ -1566,6 +1597,10 @@ static int ag71xx_probe(struct platform_device *pdev)
return ag->phy_if_mode;
}
+ if (of_device_is_compatible(np, "qca,qca9560-eth") &&
+ ag->phy_if_mode == PHY_INTERFACE_MODE_SGMII)
+ ag71xx_mux_select_sgmii_qca956x(np);
+
if (of_property_read_u32(np, "qca,mac-idx", &ag->mac_idx))
ag->mac_idx = -1;
if (ag->mii_base)