Skip to content

Commit e8d35ce

Browse files
author
CKI KWF Bot
committed
Merge: Add support for Synopsis DWMAC IP on NXP Automotive SoCs S32G2xx/S32G3xx/S32R45
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1502 JIRA: https://issues.redhat.com/browse/RHEL-116889 ARK-MR: cki-project/kernel-ark!4222 The SoC series S32G2xx and S32G3xx feature one DWMAC instance, the SoC S32R45 has two instances. The series adds the support for it. Signed-off-by: Alessandro Carminati <acarmina@redhat.com> Approved-by: Michal Schmidt <mschmidt@redhat.com> Approved-by: Jared Kangas <jkangas@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 4eb646b + 5e6c8a8 commit e8d35ce

File tree

21 files changed

+375
-114
lines changed

21 files changed

+375
-114
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
# Copyright 2021-2024 NXP
3+
%YAML 1.2
4+
---
5+
$id: http://devicetree.org/schemas/net/nxp,s32-dwmac.yaml#
6+
$schema: http://devicetree.org/meta-schemas/core.yaml#
7+
8+
title: NXP S32G2xx/S32G3xx/S32R45 GMAC ethernet controller
9+
10+
maintainers:
11+
- Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
12+
13+
description:
14+
This device is a Synopsys DWC IP, integrated on NXP S32G/R SoCs.
15+
The SoC series S32G2xx and S32G3xx feature one DWMAC instance,
16+
the SoC S32R45 has two instances. The devices can use RGMII/RMII/MII
17+
interface over Pinctrl device or the output can be routed
18+
to the embedded SerDes for SGMII connectivity.
19+
20+
properties:
21+
compatible:
22+
oneOf:
23+
- const: nxp,s32g2-dwmac
24+
- items:
25+
- enum:
26+
- nxp,s32g3-dwmac
27+
- nxp,s32r45-dwmac
28+
- const: nxp,s32g2-dwmac
29+
30+
reg:
31+
items:
32+
- description: Main GMAC registers
33+
- description: GMAC PHY mode control register
34+
35+
interrupts:
36+
maxItems: 1
37+
38+
interrupt-names:
39+
const: macirq
40+
41+
clocks:
42+
items:
43+
- description: Main GMAC clock
44+
- description: Transmit clock
45+
- description: Receive clock
46+
- description: PTP reference clock
47+
48+
clock-names:
49+
items:
50+
- const: stmmaceth
51+
- const: tx
52+
- const: rx
53+
- const: ptp_ref
54+
55+
required:
56+
- clocks
57+
- clock-names
58+
59+
allOf:
60+
- $ref: snps,dwmac.yaml#
61+
62+
unevaluatedProperties: false
63+
64+
examples:
65+
- |
66+
#include <dt-bindings/interrupt-controller/arm-gic.h>
67+
#include <dt-bindings/interrupt-controller/irq.h>
68+
#include <dt-bindings/phy/phy.h>
69+
bus {
70+
#address-cells = <2>;
71+
#size-cells = <2>;
72+
73+
ethernet@4033c000 {
74+
compatible = "nxp,s32g2-dwmac";
75+
reg = <0x0 0x4033c000 0x0 0x2000>, /* gmac IP */
76+
<0x0 0x4007c004 0x0 0x4>; /* GMAC_0_CTRL_STS */
77+
interrupt-parent = <&gic>;
78+
interrupts = <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>;
79+
interrupt-names = "macirq";
80+
snps,mtl-rx-config = <&mtl_rx_setup>;
81+
snps,mtl-tx-config = <&mtl_tx_setup>;
82+
clocks = <&clks 24>, <&clks 17>, <&clks 16>, <&clks 15>;
83+
clock-names = "stmmaceth", "tx", "rx", "ptp_ref";
84+
phy-mode = "rgmii-id";
85+
phy-handle = <&phy0>;
86+
87+
mtl_rx_setup: rx-queues-config {
88+
snps,rx-queues-to-use = <5>;
89+
};
90+
91+
mtl_tx_setup: tx-queues-config {
92+
snps,tx-queues-to-use = <5>;
93+
};
94+
95+
mdio {
96+
#address-cells = <1>;
97+
#size-cells = <0>;
98+
compatible = "snps,dwmac-mdio";
99+
100+
phy0: ethernet-phy@0 {
101+
reg = <0>;
102+
};
103+
};
104+
};
105+
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ properties:
6666
- ingenic,x2000-mac
6767
- loongson,ls2k-dwmac
6868
- loongson,ls7a-dwmac
69+
- nxp,s32g2-dwmac
6970
- qcom,qcs404-ethqos
7071
- qcom,sa8775p-ethqos
7172
- qcom,sc8280xp-ethqos

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,6 +2832,13 @@ F: arch/arm64/boot/dts/freescale/s32g*.dts*
28322832
F: drivers/pinctrl/nxp/
28332833
F: drivers/rtc/rtc-s32g.c
28342834

2835+
ARM/NXP S32G/S32R DWMAC ETHERNET DRIVER
2836+
M: Jan Petrous <jan.petrous@oss.nxp.com>
2837+
L: NXP S32 Linux Team <s32@nxp.com>
2838+
S: Maintained
2839+
F: Documentation/devicetree/bindings/net/nxp,s32-dwmac.yaml
2840+
F: drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
2841+
28352842
ARM/Orion SoC/Technologic Systems TS-78xx platform support
28362843
M: Alexander Clouter <alex@digriz.org.uk>
28372844
L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)

drivers/net/ethernet/apm/xgene/xgene_enet_hw.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -421,18 +421,12 @@ static void xgene_enet_configure_clock(struct xgene_enet_pdata *pdata)
421421

422422
if (dev->of_node) {
423423
struct clk *parent = clk_get_parent(pdata->clk);
424+
long rate = rgmii_clock(pdata->phy_speed);
424425

425-
switch (pdata->phy_speed) {
426-
case SPEED_10:
427-
clk_set_rate(parent, 2500000);
428-
break;
429-
case SPEED_100:
430-
clk_set_rate(parent, 25000000);
431-
break;
432-
default:
433-
clk_set_rate(parent, 125000000);
434-
break;
435-
}
426+
if (rate < 0)
427+
rate = 125000000;
428+
429+
clk_set_rate(parent, rate);
436430
}
437431
#ifdef CONFIG_ACPI
438432
else {

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -530,19 +530,9 @@ static void macb_set_tx_clk(struct macb *bp, int speed)
530530
if (bp->phy_interface == PHY_INTERFACE_MODE_MII)
531531
return;
532532

533-
switch (speed) {
534-
case SPEED_10:
535-
rate = 2500000;
536-
break;
537-
case SPEED_100:
538-
rate = 25000000;
539-
break;
540-
case SPEED_1000:
541-
rate = 125000000;
542-
break;
543-
default:
533+
rate = rgmii_clock(speed);
534+
if (rate < 0)
544535
return;
545-
}
546536

547537
rate_rounded = clk_round_rate(bp->tx_clk, rate);
548538
if (rate_rounded < 0)

drivers/net/ethernet/stmicro/stmmac/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ config DWMAC_RZN1
154154
the stmmac device driver. This support can make use of a custom MII
155155
converter PCS device.
156156

157+
config DWMAC_S32
158+
tristate "NXP S32G/S32R GMAC support"
159+
default ARCH_S32
160+
depends on OF && (ARCH_S32 || COMPILE_TEST)
161+
help
162+
Support for ethernet controller on NXP S32CC SOCs.
163+
164+
This selects NXP SoC glue layer support for the stmmac
165+
device driver. This driver is used for the S32CC series
166+
SOCs GMAC ethernet controller, ie. S32G2xx, S32G3xx and
167+
S32R45.
168+
157169
config DWMAC_SOCFPGA
158170
tristate "SOCFPGA dwmac support"
159171
default ARCH_INTEL_SOCFPGA

drivers/net/ethernet/stmicro/stmmac/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ obj-$(CONFIG_DWMAC_MESON) += dwmac-meson.o dwmac-meson8b.o
2222
obj-$(CONFIG_DWMAC_QCOM_ETHQOS) += dwmac-qcom-ethqos.o
2323
obj-$(CONFIG_DWMAC_ROCKCHIP) += dwmac-rk.o
2424
obj-$(CONFIG_DWMAC_RZN1) += dwmac-rzn1.o
25+
obj-$(CONFIG_DWMAC_S32) += dwmac-s32.o
2526
obj-$(CONFIG_DWMAC_SOCFPGA) += dwmac-altr-socfpga.o
2627
obj-$(CONFIG_DWMAC_STARFIVE) += dwmac-starfive.o
2728
obj-$(CONFIG_DWMAC_STI) += dwmac-sti.o

drivers/net/ethernet/stmicro/stmmac/common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ struct stmmac_safety_stats {
257257
#define CSR_F_150M 150000000
258258
#define CSR_F_250M 250000000
259259
#define CSR_F_300M 300000000
260+
#define CSR_F_500M 500000000
261+
#define CSR_F_800M 800000000
260262

261263
#define MAC_CSR_H_FRQ_MASK 0x20
262264

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static void imx_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mod
186186
{
187187
struct plat_stmmacenet_data *plat_dat;
188188
struct imx_priv_data *dwmac = priv;
189-
unsigned long rate;
189+
long rate;
190190
int err;
191191

192192
plat_dat = dwmac->plat_dat;
@@ -196,17 +196,8 @@ static void imx_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mod
196196
(plat_dat->mac_interface == PHY_INTERFACE_MODE_MII))
197197
return;
198198

199-
switch (speed) {
200-
case SPEED_1000:
201-
rate = 125000000;
202-
break;
203-
case SPEED_100:
204-
rate = 25000000;
205-
break;
206-
case SPEED_10:
207-
rate = 2500000;
208-
break;
209-
default:
199+
rate = rgmii_clock(speed);
200+
if (rate < 0) {
210201
dev_err(dwmac->dev, "invalid speed %u\n", speed);
211202
return;
212203
}

drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,13 @@ struct intel_dwmac_data {
3131
static void kmb_eth_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
3232
{
3333
struct intel_dwmac *dwmac = priv;
34-
unsigned long rate;
34+
long rate;
3535
int ret;
3636

37-
rate = clk_get_rate(dwmac->tx_clk);
38-
39-
switch (speed) {
40-
case SPEED_1000:
41-
rate = 125000000;
42-
break;
43-
44-
case SPEED_100:
45-
rate = 25000000;
46-
break;
47-
48-
case SPEED_10:
49-
rate = 2500000;
50-
break;
51-
52-
default:
37+
rate = rgmii_clock(speed);
38+
if (rate < 0) {
5339
dev_err(dwmac->dev, "Invalid speed\n");
54-
break;
40+
return;
5541
}
5642

5743
ret = clk_set_rate(dwmac->tx_clk, rate);

0 commit comments

Comments
 (0)