VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   30 Branches   50 Tags
author: Emil Renner Berthing <kernel@esmil.dk> 2021-09-29 20:50:22 +0200 committer: Emil Renner Berthing <emil.renner.berthing@canonical.com> 2023-07-20 20:53:36 +0200 commit: dcb870ae060c36800b6e9982730ef341ccf3f6dc parent: 6b607a8ab83b77939c872bc3fcb4947acfa391d2
Commit Summary:
net: stmmac: dwmac-starfive: Add JH7100 support
Diffstat:
1 file changed, 13 insertions, 0 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
index 4f51a7889642..389eb03c8d32 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
@@ -17,6 +17,10 @@
 #define STARFIVE_DWMAC_PHY_INFT_RMII	0x4
 #define STARFIVE_DWMAC_PHY_INFT_FIELD	0x7U
 
+#define JH7100_SYSMAIN_REGISTER28 0x70
+/* The value below is not a typo, just really bad naming by StarFive ¯\_(ツ)_/¯ */
+#define JH7100_SYSMAIN_REGISTER49 0xc8
+
 struct starfive_dwmac {
 	struct device *dev;
 	struct clk *clk_tx;
@@ -56,6 +60,7 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
 	struct regmap *regmap;
 	unsigned int args[2];
 	unsigned int mode;
+	u32 gtxclk_dlychain;
 	int err;
 
 	switch (plat_dat->interface) {
@@ -65,6 +70,7 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
 
 	case PHY_INTERFACE_MODE_RGMII:
 	case PHY_INTERFACE_MODE_RGMII_ID:
+	case PHY_INTERFACE_MODE_RGMII_TXID:
 		mode = STARFIVE_DWMAC_PHY_INFT_RGMII;
 		break;
 
@@ -87,6 +93,12 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
 	if (err)
 		return dev_err_probe(dwmac->dev, err, "error setting phy mode\n");
 
+	if (!of_property_read_u32(dwmac->dev->of_node, "starfive,gtxclk-dlychain", &gtxclk_dlychain)) {
+		err = regmap_write(regmap, JH7100_SYSMAIN_REGISTER49, gtxclk_dlychain);
+		if (err)
+			return dev_err_probe(dwmac->dev, err, "error selecting gtxclk delay chain\n");
+	}
+
 	return 0;
 }
 
@@ -149,6 +161,7 @@ static int starfive_dwmac_probe(struct platform_device *pdev)
 }
 
 static const struct of_device_id starfive_dwmac_match[] = {
+	{ .compatible = "starfive,jh7100-dwmac"	},
 	{ .compatible = "starfive,jh7110-dwmac"	},
 	{ /* sentinel */ }
 };