Skip to content

Commit 06cd3d4

Browse files
committed
Merge branch 'net-stmmac-qcom-ethqos-enable-2-5g-ethernet-on-sa8775p-ride'
Bartosz Golaszewski says: ==================== net: stmmac: qcom-ethqos: enable 2.5G ethernet on sa8775p-ride Here are the changes required to enable 2.5G ethernet on sa8775p-ride. As advised by Andrew Lunn and Russell King, I am reusing the existing stmmac infrastructure to enable the SGMII loopback and so I dropped the patches adding new callbacks to the driver core. I also added more details to the commit message and made sure the workaround is only enabled on Rev 3 of the board (with AQR115C PHY). Also: dropped any mentions of the OCSGMII mode. v2: https://lore.kernel.org/[email protected] v1: https://lore.kernel.org/[email protected] ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 946b6c4 + 3c466d6 commit 06cd3d4

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

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

Lines changed: 34 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,
@@ -665,6 +686,14 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos)
665686
return val;
666687
}
667688

689+
static void qcom_ethqos_speed_mode_2500(struct net_device *ndev, void *data)
690+
{
691+
struct stmmac_priv *priv = netdev_priv(ndev);
692+
693+
priv->plat->max_speed = 2500;
694+
priv->plat->phy_interface = PHY_INTERFACE_MODE_2500BASEX;
695+
}
696+
668697
static int ethqos_configure(struct qcom_ethqos *ethqos)
669698
{
670699
return ethqos->configure_func(ethqos);
@@ -674,6 +703,7 @@ static void ethqos_fix_mac_speed(void *priv, unsigned int speed, unsigned int mo
674703
{
675704
struct qcom_ethqos *ethqos = priv;
676705

706+
qcom_ethqos_set_sgmii_loopback(ethqos, false);
677707
ethqos->speed = speed;
678708
ethqos_update_link_clk(ethqos, speed);
679709
ethqos_configure(ethqos);
@@ -787,6 +817,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
787817
case PHY_INTERFACE_MODE_RGMII_TXID:
788818
ethqos->configure_func = ethqos_configure_rgmii;
789819
break;
820+
case PHY_INTERFACE_MODE_2500BASEX:
821+
plat_dat->speed_mode_2500 = qcom_ethqos_speed_mode_2500;
822+
fallthrough;
790823
case PHY_INTERFACE_MODE_SGMII:
791824
ethqos->configure_func = ethqos_configure_sgmii;
792825
break;
@@ -809,6 +842,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
809842
ethqos->num_por = data->num_por;
810843
ethqos->rgmii_config_loopback_en = data->rgmii_config_loopback_en;
811844
ethqos->has_emac_ge_3 = data->has_emac_ge_3;
845+
ethqos->needs_sgmii_loopback = data->needs_sgmii_loopback;
812846

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

0 commit comments

Comments
 (0)