1 From abb45a2477f533cd4aab3085defdff131e2e8c4f Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Mon, 6 May 2024 14:32:46 +0200
4 Subject: [PATCH] net: stmmac: dwmac-ipq806x: account for rgmii-txid/rxid/id
7 Currently the ipq806x dwmac driver is almost always used attached to the
8 CPU port of a switch and phy-mode was always set to "rgmii" or "sgmii".
10 Some device came up with a special configuration where the PHY is
11 directly attached to the GMAC port and in those case phy-mode needs to
12 be set to "rgmii-id" to make the PHY correctly work and receive packets.
14 Since the driver supports only "rgmii" and "sgmii" mode, when "rgmii-id"
15 (or variants) mode is set, the mode is rejected and probe fails.
17 Add support also for these phy-modes to correctly setup PHYs that requires
18 delay applied to tx/rx.
20 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
21 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
22 Signed-off-by: David S. Miller <davem@davemloft.net>
24 drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c | 12 ++++++++++++
25 1 file changed, 12 insertions(+)
27 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
28 +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
29 @@ -171,6 +171,9 @@ static int ipq806x_gmac_set_speed(struct
31 switch (gmac->phy_mode) {
32 case PHY_INTERFACE_MODE_RGMII:
33 + case PHY_INTERFACE_MODE_RGMII_ID:
34 + case PHY_INTERFACE_MODE_RGMII_RXID:
35 + case PHY_INTERFACE_MODE_RGMII_TXID:
36 div = get_clk_div_rgmii(gmac, speed);
37 clk_bits = NSS_COMMON_CLK_GATE_RGMII_RX_EN(gmac->id) |
38 NSS_COMMON_CLK_GATE_RGMII_TX_EN(gmac->id);
39 @@ -412,6 +415,9 @@ static int ipq806x_gmac_probe(struct pla
40 val |= NSS_COMMON_GMAC_CTL_CSYS_REQ;
41 switch (gmac->phy_mode) {
42 case PHY_INTERFACE_MODE_RGMII:
43 + case PHY_INTERFACE_MODE_RGMII_ID:
44 + case PHY_INTERFACE_MODE_RGMII_RXID:
45 + case PHY_INTERFACE_MODE_RGMII_TXID:
46 val |= NSS_COMMON_GMAC_CTL_PHY_IFACE_SEL;
48 case PHY_INTERFACE_MODE_SGMII:
49 @@ -427,6 +433,9 @@ static int ipq806x_gmac_probe(struct pla
50 val &= ~(1 << NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id));
51 switch (gmac->phy_mode) {
52 case PHY_INTERFACE_MODE_RGMII:
53 + case PHY_INTERFACE_MODE_RGMII_ID:
54 + case PHY_INTERFACE_MODE_RGMII_RXID:
55 + case PHY_INTERFACE_MODE_RGMII_TXID:
56 val |= NSS_COMMON_CLK_SRC_CTRL_RGMII(gmac->id) <<
57 NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id);
59 @@ -444,6 +453,9 @@ static int ipq806x_gmac_probe(struct pla
60 val |= NSS_COMMON_CLK_GATE_PTP_EN(gmac->id);
61 switch (gmac->phy_mode) {
62 case PHY_INTERFACE_MODE_RGMII:
63 + case PHY_INTERFACE_MODE_RGMII_ID:
64 + case PHY_INTERFACE_MODE_RGMII_RXID:
65 + case PHY_INTERFACE_MODE_RGMII_TXID:
66 val |= NSS_COMMON_CLK_GATE_RGMII_RX_EN(gmac->id) |
67 NSS_COMMON_CLK_GATE_RGMII_TX_EN(gmac->id);