Skip to content

Commit bc34d10

Browse files
committed
Merge branch 'stmmac-jh7100'
Cristian Ciocaltea says: ==================== StarFive DWMAC support for JH7100 This is just a subset of the initial patch series [1] adding networking support for StarFive JH7100 SoC. [1]: https://lore.kernel.org/lkml/[email protected]/ Changes in v4: - Rebased series onto next-20240125 - Added R-b tag from Rob in PATCH 1 - v3: https://lore.kernel.org/lkml/[email protected]/ Changes in v3: - Optimized jh7110 resets & reset-names properties (Rob) - Added R-b tag from Jacob in PATCH 1 - v2: https://lore.kernel.org/lkml/[email protected]/ Changes in v2: - Add the missing binding patch (Conor) - v1: https://lore.kernel.org/lkml/[email protected]/ ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents ccf1445 + 8d4597b commit bc34d10

File tree

4 files changed

+88
-33
lines changed

4 files changed

+88
-33
lines changed

Documentation/devicetree/bindings/net/snps,dwmac.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ properties:
9595
- snps,dwmac-5.20
9696
- snps,dwxgmac
9797
- snps,dwxgmac-2.10
98+
- starfive,jh7100-dwmac
9899
- starfive,jh7110-dwmac
99100

100101
reg:
@@ -144,10 +145,12 @@ properties:
144145
- description: AHB reset
145146

146147
reset-names:
147-
minItems: 1
148-
items:
149-
- const: stmmaceth
150-
- const: ahb
148+
oneOf:
149+
- items:
150+
- enum: [stmmaceth, ahb]
151+
- items:
152+
- const: stmmaceth
153+
- const: ahb
151154

152155
power-domains:
153156
maxItems: 1

Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,20 @@ select:
1616
compatible:
1717
contains:
1818
enum:
19+
- starfive,jh7100-dwmac
1920
- starfive,jh7110-dwmac
2021
required:
2122
- compatible
2223

2324
properties:
2425
compatible:
25-
items:
26-
- enum:
27-
- starfive,jh7110-dwmac
28-
- const: snps,dwmac-5.20
26+
oneOf:
27+
- items:
28+
- const: starfive,jh7100-dwmac
29+
- const: snps,dwmac
30+
- items:
31+
- const: starfive,jh7110-dwmac
32+
- const: snps,dwmac-5.20
2933

3034
reg:
3135
maxItems: 1
@@ -46,24 +50,6 @@ properties:
4650
- const: tx
4751
- const: gtx
4852

49-
interrupts:
50-
minItems: 3
51-
maxItems: 3
52-
53-
interrupt-names:
54-
minItems: 3
55-
maxItems: 3
56-
57-
resets:
58-
items:
59-
- description: MAC Reset signal.
60-
- description: AHB Reset signal.
61-
62-
reset-names:
63-
items:
64-
- const: stmmaceth
65-
- const: ahb
66-
6753
starfive,tx-use-rgmii-clk:
6854
description:
6955
Tx clock is provided by external rgmii clock.
@@ -94,6 +80,48 @@ required:
9480
allOf:
9581
- $ref: snps,dwmac.yaml#
9682

83+
- if:
84+
properties:
85+
compatible:
86+
contains:
87+
const: starfive,jh7100-dwmac
88+
then:
89+
properties:
90+
interrupts:
91+
minItems: 2
92+
maxItems: 2
93+
94+
interrupt-names:
95+
minItems: 2
96+
maxItems: 2
97+
98+
resets:
99+
maxItems: 1
100+
101+
reset-names:
102+
const: ahb
103+
104+
- if:
105+
properties:
106+
compatible:
107+
contains:
108+
const: starfive,jh7110-dwmac
109+
then:
110+
properties:
111+
interrupts:
112+
minItems: 3
113+
maxItems: 3
114+
115+
interrupt-names:
116+
minItems: 3
117+
maxItems: 3
118+
119+
resets:
120+
minItems: 2
121+
122+
reset-names:
123+
minItems: 2
124+
97125
unevaluatedProperties: false
98126

99127
examples:

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)