Skip to content

Commit 8c4d92e

Browse files
Bartosz Golaszewskikuba-moo
authored andcommitted
net: stmmac: dwmac-qcom-ethqos: add support for emac4 on sa8775p platforms
sa8775p uses EMAC version 4, add the relevant defines, rename the has_emac3 switch to has_emac_ge_3 (has emac greater-or-equal than 3) and add the new compatible. Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d0e3d29 commit 8c4d92e

File tree

1 file changed

+51
-14
lines changed

1 file changed

+51
-14
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ struct ethqos_emac_driver_data {
8888
const struct ethqos_emac_por *por;
8989
unsigned int num_por;
9090
bool rgmii_config_loopback_en;
91-
bool has_emac3;
91+
bool has_emac_ge_3;
9292
const char *link_clk_name;
93+
bool has_integrated_pcs;
9394
struct dwmac4_addrs dwmac4_addrs;
9495
};
9596

@@ -108,7 +109,7 @@ struct qcom_ethqos {
108109
const struct ethqos_emac_por *por;
109110
unsigned int num_por;
110111
bool rgmii_config_loopback_en;
111-
bool has_emac3;
112+
bool has_emac_ge_3;
112113
};
113114

114115
static int rgmii_readl(struct qcom_ethqos *ethqos, unsigned int offset)
@@ -202,7 +203,7 @@ static const struct ethqos_emac_driver_data emac_v2_3_0_data = {
202203
.por = emac_v2_3_0_por,
203204
.num_por = ARRAY_SIZE(emac_v2_3_0_por),
204205
.rgmii_config_loopback_en = true,
205-
.has_emac3 = false,
206+
.has_emac_ge_3 = false,
206207
};
207208

208209
static const struct ethqos_emac_por emac_v2_1_0_por[] = {
@@ -218,7 +219,7 @@ static const struct ethqos_emac_driver_data emac_v2_1_0_data = {
218219
.por = emac_v2_1_0_por,
219220
.num_por = ARRAY_SIZE(emac_v2_1_0_por),
220221
.rgmii_config_loopback_en = false,
221-
.has_emac3 = false,
222+
.has_emac_ge_3 = false,
222223
};
223224

224225
static const struct ethqos_emac_por emac_v3_0_0_por[] = {
@@ -234,7 +235,41 @@ static const struct ethqos_emac_driver_data emac_v3_0_0_data = {
234235
.por = emac_v3_0_0_por,
235236
.num_por = ARRAY_SIZE(emac_v3_0_0_por),
236237
.rgmii_config_loopback_en = false,
237-
.has_emac3 = true,
238+
.has_emac_ge_3 = true,
239+
.dwmac4_addrs = {
240+
.dma_chan = 0x00008100,
241+
.dma_chan_offset = 0x1000,
242+
.mtl_chan = 0x00008000,
243+
.mtl_chan_offset = 0x1000,
244+
.mtl_ets_ctrl = 0x00008010,
245+
.mtl_ets_ctrl_offset = 0x1000,
246+
.mtl_txq_weight = 0x00008018,
247+
.mtl_txq_weight_offset = 0x1000,
248+
.mtl_send_slp_cred = 0x0000801c,
249+
.mtl_send_slp_cred_offset = 0x1000,
250+
.mtl_high_cred = 0x00008020,
251+
.mtl_high_cred_offset = 0x1000,
252+
.mtl_low_cred = 0x00008024,
253+
.mtl_low_cred_offset = 0x1000,
254+
},
255+
};
256+
257+
static const struct ethqos_emac_por emac_v4_0_0_por[] = {
258+
{ .offset = RGMII_IO_MACRO_CONFIG, .value = 0x40c01343 },
259+
{ .offset = SDCC_HC_REG_DLL_CONFIG, .value = 0x2004642c },
260+
{ .offset = SDCC_HC_REG_DDR_CONFIG, .value = 0x80040800 },
261+
{ .offset = SDCC_HC_REG_DLL_CONFIG2, .value = 0x00200000 },
262+
{ .offset = SDCC_USR_CTL, .value = 0x00010800 },
263+
{ .offset = RGMII_IO_MACRO_CONFIG2, .value = 0x00002060 },
264+
};
265+
266+
static const struct ethqos_emac_driver_data emac_v4_0_0_data = {
267+
.por = emac_v4_0_0_por,
268+
.num_por = ARRAY_SIZE(emac_v3_0_0_por),
269+
.rgmii_config_loopback_en = false,
270+
.has_emac_ge_3 = true,
271+
.link_clk_name = "phyaux",
272+
.has_integrated_pcs = true,
238273
.dwmac4_addrs = {
239274
.dma_chan = 0x00008100,
240275
.dma_chan_offset = 0x1000,
@@ -275,7 +310,7 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos)
275310
rgmii_updatel(ethqos, SDCC_DLL_CONFIG_DLL_EN,
276311
SDCC_DLL_CONFIG_DLL_EN, SDCC_HC_REG_DLL_CONFIG);
277312

278-
if (!ethqos->has_emac3) {
313+
if (!ethqos->has_emac_ge_3) {
279314
rgmii_updatel(ethqos, SDCC_DLL_MCLK_GATING_EN,
280315
0, SDCC_HC_REG_DLL_CONFIG);
281316

@@ -316,7 +351,7 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos)
316351
rgmii_updatel(ethqos, SDCC_DLL_CONFIG2_DDR_CAL_EN,
317352
SDCC_DLL_CONFIG2_DDR_CAL_EN, SDCC_HC_REG_DLL_CONFIG2);
318353

319-
if (!ethqos->has_emac3) {
354+
if (!ethqos->has_emac_ge_3) {
320355
rgmii_updatel(ethqos, SDCC_DLL_CONFIG2_DLL_CLOCK_DIS,
321356
0, SDCC_HC_REG_DLL_CONFIG2);
322357

@@ -386,7 +421,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos)
386421
/* PRG_RCLK_DLY = TCXO period * TCXO_CYCLES_CNT / 2 * RX delay ns,
387422
* in practice this becomes PRG_RCLK_DLY = 52 * 4 / 2 * RX delay ns
388423
*/
389-
if (ethqos->has_emac3) {
424+
if (ethqos->has_emac_ge_3) {
390425
/* 0.9 ns */
391426
rgmii_updatel(ethqos, SDCC_DDR_CONFIG_PRG_RCLK_DLY,
392427
115, SDCC_HC_REG_DDR_CONFIG);
@@ -421,7 +456,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos)
421456
rgmii_updatel(ethqos, RGMII_CONFIG2_RSVD_CONFIG15,
422457
0, RGMII_IO_MACRO_CONFIG2);
423458

424-
if (ethqos->has_emac3)
459+
if (ethqos->has_emac_ge_3)
425460
rgmii_updatel(ethqos, RGMII_CONFIG2_RX_PROG_SWAP,
426461
RGMII_CONFIG2_RX_PROG_SWAP,
427462
RGMII_IO_MACRO_CONFIG2);
@@ -461,7 +496,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos)
461496
RGMII_IO_MACRO_CONFIG);
462497
rgmii_updatel(ethqos, RGMII_CONFIG2_RSVD_CONFIG15,
463498
0, RGMII_IO_MACRO_CONFIG2);
464-
if (ethqos->has_emac3)
499+
if (ethqos->has_emac_ge_3)
465500
rgmii_updatel(ethqos, RGMII_CONFIG2_RX_PROG_SWAP,
466501
RGMII_CONFIG2_RX_PROG_SWAP,
467502
RGMII_IO_MACRO_CONFIG2);
@@ -510,7 +545,7 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos)
510545
rgmii_updatel(ethqos, SDCC_DLL_CONFIG_PDN,
511546
SDCC_DLL_CONFIG_PDN, SDCC_HC_REG_DLL_CONFIG);
512547

513-
if (ethqos->has_emac3) {
548+
if (ethqos->has_emac_ge_3) {
514549
if (ethqos->speed == SPEED_1000) {
515550
rgmii_writel(ethqos, 0x1800000, SDCC_TEST_CTL);
516551
rgmii_writel(ethqos, 0x2C010800, SDCC_USR_CTL);
@@ -540,7 +575,7 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos)
540575
SDCC_HC_REG_DLL_CONFIG);
541576

542577
/* Set USR_CTL bit 26 with mask of 3 bits */
543-
if (!ethqos->has_emac3)
578+
if (!ethqos->has_emac_ge_3)
544579
rgmii_updatel(ethqos, GENMASK(26, 24), BIT(26),
545580
SDCC_USR_CTL);
546581

@@ -719,7 +754,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
719754
ethqos->por = data->por;
720755
ethqos->num_por = data->num_por;
721756
ethqos->rgmii_config_loopback_en = data->rgmii_config_loopback_en;
722-
ethqos->has_emac3 = data->has_emac3;
757+
ethqos->has_emac_ge_3 = data->has_emac_ge_3;
723758

724759
ethqos->link_clk = devm_clk_get(dev, data->link_clk_name ?: "rgmii");
725760
if (IS_ERR(ethqos->link_clk)) {
@@ -749,12 +784,13 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
749784
plat_dat->fix_mac_speed = ethqos_fix_mac_speed;
750785
plat_dat->dump_debug_regs = rgmii_dump;
751786
plat_dat->has_gmac4 = 1;
752-
if (ethqos->has_emac3)
787+
if (ethqos->has_emac_ge_3)
753788
plat_dat->dwmac4_addrs = &data->dwmac4_addrs;
754789
plat_dat->pmt = 1;
755790
plat_dat->tso_en = of_property_read_bool(np, "snps,tso");
756791
if (of_device_is_compatible(np, "qcom,qcs404-ethqos"))
757792
plat_dat->rx_clk_runs_in_lpi = 1;
793+
plat_dat->has_integrated_pcs = data->has_integrated_pcs;
758794

759795
if (ethqos->serdes_phy) {
760796
plat_dat->serdes_powerup = qcom_ethqos_serdes_powerup;
@@ -775,6 +811,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
775811

776812
static const struct of_device_id qcom_ethqos_match[] = {
777813
{ .compatible = "qcom,qcs404-ethqos", .data = &emac_v2_3_0_data},
814+
{ .compatible = "qcom,sa8775p-ethqos", .data = &emac_v4_0_0_data},
778815
{ .compatible = "qcom,sc8280xp-ethqos", .data = &emac_v3_0_0_data},
779816
{ .compatible = "qcom,sm8150-ethqos", .data = &emac_v2_1_0_data},
780817
{ }

0 commit comments

Comments
 (0)