Skip to content

Commit 51e4eca

Browse files
committed
Merge branch 'add-starfive-jhb100-soc-sgmii-gmac-support'
Minda Chen says: ==================== Add StarFive jhb100 soc SGMII GMAC support jhb100 is a Starfive new RISC-V SoC for datacenter BMC (BaseBoard Managent Controller). Similar with Aspeed 27x0. The jhb100 minimal system upstream is in progress: https://patchwork.kernel.org/project/linux-riscv/cover/20260508053632.818548-1-changhuang.liang@starfivetech.com/ jhb100 GMAC still using designware GMAC core like JH7100 and JH7110, and contains 2 SGMII interfaces, 1 RGMII/RMII interface, 1 RMII interface. In JH7100/JH7110 dwmac-starfive.c have supported RGMII/RMII interface. So require to add SGMII support to dwmac-starfive.c for JHB100. SGMII serdes PHY has been integrated in JHB100 and do not have driver setting. In JHB100 EVB board, SGMII connect with motorcomm YT8531s external PHY and support RJ45 ethernet port. ==================== Link: https://patch.msgid.link/20260527084108.121416-1-minda.chen@starfivetech.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 3b09ff5 + 7e9ea8d commit 51e4eca

2 files changed

Lines changed: 65 additions & 25 deletions

File tree

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

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,32 @@ properties:
3131
- const: starfive,jh7110-dwmac
3232
- const: snps,dwmac-5.20
3333
- items:
34-
- const: starfive,jh8100-dwmac
34+
- const: starfive,jhb100-dwmac
3535
- const: starfive,jh7110-dwmac
3636
- const: snps,dwmac-5.20
3737

3838
reg:
3939
maxItems: 1
4040

4141
clocks:
42+
minItems: 5
4243
items:
4344
- description: GMAC main clock
4445
- description: GMAC AHB clock
4546
- description: PTP clock
4647
- description: TX clock
4748
- description: GTX clock
49+
- description: SGMII RX clock
4850

4951
clock-names:
52+
minItems: 5
5053
items:
5154
- const: stmmaceth
5255
- const: pclk
5356
- const: ptp_ref
5457
- const: tx
5558
- const: gtx
59+
- const: sgmii_rx
5660

5761
starfive,tx-use-rgmii-clk:
5862
description:
@@ -111,29 +115,34 @@ allOf:
111115
contains:
112116
const: starfive,jh7110-dwmac
113117
then:
114-
properties:
115-
interrupts:
116-
minItems: 3
117-
maxItems: 3
118-
119-
interrupt-names:
120-
minItems: 3
121-
maxItems: 3
122-
123118
if:
124119
properties:
125120
compatible:
126121
contains:
127-
const: starfive,jh8100-dwmac
122+
const: starfive,jhb100-dwmac
128123
then:
129124
properties:
125+
interrupts:
126+
maxItems: 1
127+
128+
interrupt-names:
129+
const: macirq
130+
130131
resets:
131132
maxItems: 1
132133

133134
reset-names:
134135
const: stmmaceth
135136
else:
136137
properties:
138+
interrupts:
139+
minItems: 3
140+
maxItems: 3
141+
142+
interrupt-names:
143+
minItems: 3
144+
maxItems: 3
145+
137146
resets:
138147
minItems: 2
139148

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

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct starfive_dwmac_data {
2626
struct starfive_dwmac {
2727
struct device *dev;
2828
const struct starfive_dwmac_data *data;
29+
struct clk *sgmii_rx;
2930
};
3031

3132
static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
@@ -68,6 +69,25 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
6869
return 0;
6970
}
7071

72+
static int stmmac_starfive_sgmii_set_clk_rate(void *bsp_priv, struct clk *clk_tx_i,
73+
phy_interface_t __maybe_unused interface,
74+
int speed)
75+
{
76+
struct starfive_dwmac *dwmac = bsp_priv;
77+
long rate = rgmii_clock(speed);
78+
int ret;
79+
80+
/* MAC clock rate the same as RGMII */
81+
if (rate < 0)
82+
return -EINVAL;
83+
84+
ret = clk_set_rate(clk_tx_i, rate);
85+
if (ret)
86+
return ret;
87+
88+
return clk_set_rate(dwmac->sgmii_rx, rate);
89+
}
90+
7191
static int starfive_dwmac_probe(struct platform_device *pdev)
7292
{
7393
struct plat_stmmacenet_data *plat_dat;
@@ -102,23 +122,34 @@ static int starfive_dwmac_probe(struct platform_device *pdev)
102122
return dev_err_probe(&pdev->dev, PTR_ERR(clk_gtx),
103123
"error getting gtx clock\n");
104124

105-
/* Generally, the rgmii_tx clock is provided by the internal clock,
106-
* which needs to match the corresponding clock frequency according
107-
* to different speeds. If the rgmii_tx clock is provided by the
108-
* external rgmii_rxin, there is no need to configure the clock
109-
* internally, because rgmii_rxin will be adaptively adjusted.
110-
*/
111-
if (!device_property_read_bool(&pdev->dev, "starfive,tx-use-rgmii-clk"))
112-
plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
113-
114125
dwmac->dev = &pdev->dev;
115-
plat_dat->flags |= STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP;
116126
plat_dat->bsp_priv = dwmac;
117-
plat_dat->dma_cfg->dche = true;
127+
/* generic sgmii, 1000_BASEX not support yet */
128+
if (plat_dat->phy_interface == PHY_INTERFACE_MODE_SGMII) {
129+
dwmac->sgmii_rx = devm_clk_get_enabled(&pdev->dev, "sgmii_rx");
130+
if (IS_ERR(dwmac->sgmii_rx))
131+
return dev_err_probe(&pdev->dev,
132+
PTR_ERR(dwmac->sgmii_rx),
133+
"error getting sgmii rx clock\n");
134+
plat_dat->set_clk_tx_rate = stmmac_starfive_sgmii_set_clk_rate;
135+
} else {
136+
/*
137+
* Generally, the rgmii_tx clock is provided by the internal clock,
138+
* which needs to match the corresponding clock frequency according
139+
* to different speeds. If the rgmii_tx clock is provided by the
140+
* external rgmii_rxin, there is no need to configure the clock
141+
* internally, because rgmii_rxin will be adaptively adjusted.
142+
*/
143+
if (!device_property_read_bool(&pdev->dev, "starfive,tx-use-rgmii-clk"))
144+
plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
145+
146+
err = starfive_dwmac_set_mode(plat_dat);
147+
if (err)
148+
return err;
149+
}
118150

119-
err = starfive_dwmac_set_mode(plat_dat);
120-
if (err)
121-
return err;
151+
plat_dat->flags |= (STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP | STMMAC_FLAG_SPH_DISABLE);
152+
plat_dat->dma_cfg->dche = true;
122153

123154
return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
124155
}

0 commit comments

Comments
 (0)