Skip to content

Commit 8d4597b

Browse files
cristiccdavem330
authored andcommitted
net: stmmac: dwmac-starfive: Add support for JH7100 SoC
Add a missing quirk to enable support for the StarFive JH7100 SoC. Additionally, for greater flexibility in operation, allow using the rgmii-rxid and rgmii-txid phy modes. Co-developed-by: Emil Renner Berthing <[email protected]> Signed-off-by: Emil Renner Berthing <[email protected]> Signed-off-by: Cristian Ciocaltea <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 53e41b7 commit 8d4597b

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

drivers/net/ethernet/stmicro/stmmac/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ config DWMAC_STARFIVE
165165
help
166166
Support for ethernet controllers on StarFive RISC-V SoCs
167167

168-
This selects the StarFive platform specific glue layer support for
169-
the stmmac device driver. This driver is used for StarFive JH7110
170-
ethernet controller.
168+
This selects the StarFive platform specific glue layer support
169+
for the stmmac device driver. This driver is used for the
170+
StarFive JH7100 and JH7110 ethernet controllers.
171171

172172
config DWMAC_STI
173173
tristate "STi GMAC support"

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,20 @@
1515

1616
#include "stmmac_platform.h"
1717

18-
#define STARFIVE_DWMAC_PHY_INFT_RGMII 0x1
19-
#define STARFIVE_DWMAC_PHY_INFT_RMII 0x4
20-
#define STARFIVE_DWMAC_PHY_INFT_FIELD 0x7U
18+
#define STARFIVE_DWMAC_PHY_INFT_RGMII 0x1
19+
#define STARFIVE_DWMAC_PHY_INFT_RMII 0x4
20+
#define STARFIVE_DWMAC_PHY_INFT_FIELD 0x7U
21+
22+
#define JH7100_SYSMAIN_REGISTER49_DLYCHAIN 0xc8
23+
24+
struct starfive_dwmac_data {
25+
unsigned int gtxclk_dlychain;
26+
};
2127

2228
struct starfive_dwmac {
2329
struct device *dev;
2430
struct clk *clk_tx;
31+
const struct starfive_dwmac_data *data;
2532
};
2633

2734
static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
@@ -67,6 +74,8 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
6774

6875
case PHY_INTERFACE_MODE_RGMII:
6976
case PHY_INTERFACE_MODE_RGMII_ID:
77+
case PHY_INTERFACE_MODE_RGMII_RXID:
78+
case PHY_INTERFACE_MODE_RGMII_TXID:
7079
mode = STARFIVE_DWMAC_PHY_INFT_RGMII;
7180
break;
7281

@@ -89,6 +98,14 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
8998
if (err)
9099
return dev_err_probe(dwmac->dev, err, "error setting phy mode\n");
91100

101+
if (dwmac->data) {
102+
err = regmap_write(regmap, JH7100_SYSMAIN_REGISTER49_DLYCHAIN,
103+
dwmac->data->gtxclk_dlychain);
104+
if (err)
105+
return dev_err_probe(dwmac->dev, err,
106+
"error selecting gtxclk delay chain\n");
107+
}
108+
92109
return 0;
93110
}
94111

@@ -114,6 +131,8 @@ static int starfive_dwmac_probe(struct platform_device *pdev)
114131
if (!dwmac)
115132
return -ENOMEM;
116133

134+
dwmac->data = device_get_match_data(&pdev->dev);
135+
117136
dwmac->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx");
118137
if (IS_ERR(dwmac->clk_tx))
119138
return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_tx),
@@ -144,8 +163,13 @@ static int starfive_dwmac_probe(struct platform_device *pdev)
144163
return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
145164
}
146165

166+
static const struct starfive_dwmac_data jh7100_data = {
167+
.gtxclk_dlychain = 4,
168+
};
169+
147170
static const struct of_device_id starfive_dwmac_match[] = {
148-
{ .compatible = "starfive,jh7110-dwmac" },
171+
{ .compatible = "starfive,jh7100-dwmac", .data = &jh7100_data },
172+
{ .compatible = "starfive,jh7110-dwmac" },
149173
{ /* sentinel */ }
150174
};
151175
MODULE_DEVICE_TABLE(of, starfive_dwmac_match);

0 commit comments

Comments
 (0)