Skip to content

Commit 3c466d6

Browse files
Bartosz Golaszewskikuba-moo
authored andcommitted
net: stmmac: qcom-ethqos: enable SGMII loopback during DMA reset on sa8775p-ride-r3
On sa8775p-ride-r3 the RX clocks from the AQR115C PHY are not available at the time of the DMA reset. We can however extract the RX clock from the internal SERDES block. Once the link is up, we can revert to the previous state. The AQR115C PHY doesn't support in-band signalling so we can count on getting the link up notification and safely reuse existing callbacks which are already used by another HW quirk workaround which enables the functional clock to avoid a DMA reset due to timeout. Only enable loopback on revision 3 of the board - check the phy_mode to make sure. Signed-off-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 61e9be0 commit 3c466d6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define RGMII_IO_MACRO_CONFIG2 0x1C
2222
#define RGMII_IO_MACRO_DEBUG1 0x20
2323
#define EMAC_SYSTEM_LOW_POWER_DEBUG 0x28
24+
#define EMAC_WRAPPER_SGMII_PHY_CNTRL1 0xf4
2425

2526
/* RGMII_IO_MACRO_CONFIG fields */
2627
#define RGMII_CONFIG_FUNC_CLK_EN BIT(30)
@@ -79,6 +80,9 @@
7980
#define ETHQOS_MAC_CTRL_SPEED_MODE BIT(14)
8081
#define ETHQOS_MAC_CTRL_PORT_SEL BIT(15)
8182

83+
/* EMAC_WRAPPER_SGMII_PHY_CNTRL1 bits */
84+
#define SGMII_PHY_CNTRL1_SGMII_TX_TO_RX_LOOPBACK_EN BIT(3)
85+
8286
#define SGMII_10M_RX_CLK_DVDR 0x31
8387

8488
struct ethqos_emac_por {
@@ -95,6 +99,7 @@ struct ethqos_emac_driver_data {
9599
bool has_integrated_pcs;
96100
u32 dma_addr_width;
97101
struct dwmac4_addrs dwmac4_addrs;
102+
bool needs_sgmii_loopback;
98103
};
99104

100105
struct qcom_ethqos {
@@ -114,6 +119,7 @@ struct qcom_ethqos {
114119
unsigned int num_por;
115120
bool rgmii_config_loopback_en;
116121
bool has_emac_ge_3;
122+
bool needs_sgmii_loopback;
117123
};
118124

119125
static int rgmii_readl(struct qcom_ethqos *ethqos, unsigned int offset)
@@ -191,8 +197,22 @@ ethqos_update_link_clk(struct qcom_ethqos *ethqos, unsigned int speed)
191197
clk_set_rate(ethqos->link_clk, ethqos->link_clk_rate);
192198
}
193199

200+
static void
201+
qcom_ethqos_set_sgmii_loopback(struct qcom_ethqos *ethqos, bool enable)
202+
{
203+
if (!ethqos->needs_sgmii_loopback ||
204+
ethqos->phy_mode != PHY_INTERFACE_MODE_2500BASEX)
205+
return;
206+
207+
rgmii_updatel(ethqos,
208+
SGMII_PHY_CNTRL1_SGMII_TX_TO_RX_LOOPBACK_EN,
209+
enable ? SGMII_PHY_CNTRL1_SGMII_TX_TO_RX_LOOPBACK_EN : 0,
210+
EMAC_WRAPPER_SGMII_PHY_CNTRL1);
211+
}
212+
194213
static void ethqos_set_func_clk_en(struct qcom_ethqos *ethqos)
195214
{
215+
qcom_ethqos_set_sgmii_loopback(ethqos, true);
196216
rgmii_updatel(ethqos, RGMII_CONFIG_FUNC_CLK_EN,
197217
RGMII_CONFIG_FUNC_CLK_EN, RGMII_IO_MACRO_CONFIG);
198218
}
@@ -277,6 +297,7 @@ static const struct ethqos_emac_driver_data emac_v4_0_0_data = {
277297
.has_emac_ge_3 = true,
278298
.link_clk_name = "phyaux",
279299
.has_integrated_pcs = true,
300+
.needs_sgmii_loopback = true,
280301
.dma_addr_width = 36,
281302
.dwmac4_addrs = {
282303
.dma_chan = 0x00008100,
@@ -682,6 +703,7 @@ static void ethqos_fix_mac_speed(void *priv, unsigned int speed, unsigned int mo
682703
{
683704
struct qcom_ethqos *ethqos = priv;
684705

706+
qcom_ethqos_set_sgmii_loopback(ethqos, false);
685707
ethqos->speed = speed;
686708
ethqos_update_link_clk(ethqos, speed);
687709
ethqos_configure(ethqos);
@@ -820,6 +842,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
820842
ethqos->num_por = data->num_por;
821843
ethqos->rgmii_config_loopback_en = data->rgmii_config_loopback_en;
822844
ethqos->has_emac_ge_3 = data->has_emac_ge_3;
845+
ethqos->needs_sgmii_loopback = data->needs_sgmii_loopback;
823846

824847
ethqos->link_clk = devm_clk_get(dev, data->link_clk_name ?: "rgmii");
825848
if (IS_ERR(ethqos->link_clk))

0 commit comments

Comments
 (0)