Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Mohd Ayaan Anwar
Mon, 23 Nov 2026 18:41
[PATCH RFC net-next 2/2] net: stmmac: qcom-ethqos: add RMII support
Author: Mohd Ayaan Anwar
Date: Mon, 23 Nov 2026 18:41
Date: Mon, 23 Nov 2026 18:41
123 lines
20350 bytes
20350 bytes
The Qualcomm ETHQOS core supports RMII in MAC master mode. Add support
for it by programming the required IO_MACRO registers and running its
link clock at the 50 MHz reference rate required by RMII.
A brief explanation of the programmed IO_MACRO bitfield configurations:
- INTF_SEL = 1 selects the RMII interface rather than RGMII (00) /
MII (10).
- DDR_MODE = 0 selects SDR rather than DDR.
- CLK_DIVIDE_SEL = 1 selects TX_CLK as the divider source.
- TX_CLK_PHASE_SHIFT_EN = 0 implies the use of normal divided clock
instead of the phase-shifted clock.
Signed-off-by: Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>
---
.../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 49 ++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
index d24509a4b4d7..683c6c3f3f37 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
@@ -71,6 +71,7 @@
/* RGMII_IO_MACRO_CONFIG2 fields */
#define RGMII_CONFIG2_RSVD_CONFIG15 GENMASK(31, 17)
#define RGMII_CONFIG2_RGMII_CLK_SEL_CFG BIT(16)
+#define RGMII_CONFIG2_RGMII_CFG_REV1 BIT(15)
#define RGMII_CONFIG2_TX_TO_RX_LOOPBACK_EN BIT(13)
#define RGMII_CONFIG2_CLK_DIVIDE_SEL BIT(12)
#define RGMII_CONFIG2_RX_PROG_SWAP BIT(7)
@@ -81,6 +82,7 @@
#define SGMII_PHY_CNTRL1_SGMII_TX_TO_RX_LOOPBACK_EN BIT(3)
#define SGMII_10M_RX_CLK_DVDR 0x31
+#define RMII_REF_CLK_RATE 50000000
struct qcom_ethqos;
@@ -182,6 +184,9 @@ static int ethqos_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i,
struct qcom_ethqos *ethqos = bsp_priv;
long rate;
+ if (interface == PHY_INTERFACE_MODE_RMII)
+ return clk_set_rate(ethqos->link_clk, RMII_REF_CLK_RATE);
+
if (!phy_interface_mode_is_rgmii(interface))
return 0;
@@ -523,6 +528,38 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos, int speed)
return 0;
}
+static void ethqos_rmii_macro_init(struct qcom_ethqos *ethqos)
+{
+ rgmii_clrmask(ethqos, RGMII_CONFIG_POS_NEG_DATA_SEL,
+ RGMII_IO_MACRO_CONFIG);
+ rgmii_updatel(ethqos, RGMII_CONFIG_INTF_SEL,
+ FIELD_PREP(RGMII_CONFIG_INTF_SEL, 1),
+ RGMII_IO_MACRO_CONFIG);
+ rgmii_setmask(ethqos, RGMII_CONFIG_BYPASS_TX_ID_EN,
+ RGMII_IO_MACRO_CONFIG);
+ rgmii_setmask(ethqos, RGMII_CONFIG_LOOPBACK_EN,
+ RGMII_IO_MACRO_CONFIG);
+ rgmii_clrmask(ethqos, RGMII_CONFIG_DDR_MODE, RGMII_IO_MACRO_CONFIG);
+
+ rgmii_setmask(ethqos, RGMII_CONFIG2_RGMII_CFG_REV1,
+ RGMII_IO_MACRO_CONFIG2);
+ rgmii_clrmask(ethqos, RGMII_CONFIG2_TX_TO_RX_LOOPBACK_EN,
+ RGMII_IO_MACRO_CONFIG2);
+ rgmii_setmask(ethqos, RGMII_CONFIG2_CLK_DIVIDE_SEL,
+ RGMII_IO_MACRO_CONFIG2);
+ rgmii_clrmask(ethqos, RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN,
+ RGMII_IO_MACRO_CONFIG2);
+}
+
+static void ethqos_fix_mac_speed_rmii(void *bsp_priv,
+ phy_interface_t interface, int speed,
+ unsigned int mode)
+{
+ struct qcom_ethqos *ethqos = bsp_priv;
+
+ ethqos_rmii_macro_init(ethqos);
+}
+
static void ethqos_fix_mac_speed_rgmii(void *bsp_priv,
phy_interface_t interface, int speed,
unsigned int mode)
@@ -710,6 +747,13 @@ static int ethqos_clks_config(void *priv, bool enabled)
*/
qcom_ethqos_set_sgmii_loopback(ethqos, true);
ethqos_set_func_clk_en(ethqos);
+
+ /* The RMII PHY has no clock until the I/O macro drives the
+ * 50 MHz reference, so it needs to be programmed during probe
+ * itself.
+ */
+ if (ethqos->phy_mode == PHY_INTERFACE_MODE_RMII)
+ ethqos_rmii_macro_init(ethqos);
} else {
clk_disable_unprepare(ethqos->link_clk);
}
@@ -771,6 +815,9 @@ static int ethqos_hlos_setup(struct qcom_ethqos *ethqos,
ethqos_set_func_clk_en(ethqos);
switch (ethqos->phy_mode) {
+ case PHY_INTERFACE_MODE_RMII:
+ plat_dat->fix_mac_speed = ethqos_fix_mac_speed_rmii;
+ break;
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_RXID:
@@ -897,6 +944,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
ethqos->phy_mode = plat_dat->phy_interface;
switch (ethqos->phy_mode) {
+ case PHY_INTERFACE_MODE_RMII:
+ break;
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_RXID:
--
2.34.1
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads