Skip to content

Commit 7e7fcfb

Browse files
Russell King (Oracle)kuba-moo
authored andcommitted
net: stmmac: imx: fix iMX93 register definitions
When looking at the iMX93 documentation, the definitions in the driver do not correspond with the documentation, which makes the driver confusing. The driver, for example, re-uses a definition for bit 0 for two different registers, where this bit have completely different purposes. Fix this by renaming the second register, and adding a definition that reflects the true purpose of bit 0 in the first register (EQOS enable.) Replace MX93_GPR_ENET_QOS_INTF_MODE_MASK with MX93_GPR_ENET_QOS_ENABLE and MX93_GPR_ENET_QOS_INTF_SEL_MASK as MX93_GPR_ENET_QOS_INTF_MODE_MASK is not a register field. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Link: https://patch.msgid.link/E1vnaGl-00000007i9f-0ZMw@rmk-PC.armlinux.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 85d05e2 commit 7e7fcfb

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
#define GPR_ENET_QOS_CLK_TX_CLK_SEL (0x1 << 20)
2929
#define GPR_ENET_QOS_RGMII_EN (0x1 << 21)
3030

31-
#define MX93_GPR_ENET_QOS_INTF_MODE_MASK GENMASK(3, 0)
3231
#define MX93_GPR_ENET_QOS_INTF_SEL_MASK GENMASK(3, 1)
33-
#define MX93_GPR_ENET_QOS_CLK_GEN_EN (0x1 << 0)
34-
#define MX93_GPR_ENET_QOS_CLK_SEL_MASK BIT_MASK(0)
35-
#define MX93_GPR_CLK_SEL_OFFSET (4)
32+
#define MX93_GPR_ENET_QOS_ENABLE BIT(0)
33+
34+
#define MX93_ENET_CLK_SEL_OFFSET (4)
35+
#define MX93_ENET_QOS_CLK_TX_SEL_MASK BIT_MASK(0)
3636

3737
#define DMA_BUS_MODE 0x00001000
3838
#define DMA_BUS_MODE_SFT_RESET (0x1 << 0)
@@ -95,17 +95,18 @@ static int imx93_set_intf_mode(struct imx_priv_data *dwmac, u8 phy_intf_sel)
9595
if (phy_intf_sel == PHY_INTF_SEL_RMII && dwmac->rmii_refclk_ext) {
9696
ret = regmap_clear_bits(dwmac->intf_regmap,
9797
dwmac->intf_reg_off +
98-
MX93_GPR_CLK_SEL_OFFSET,
99-
MX93_GPR_ENET_QOS_CLK_SEL_MASK);
98+
MX93_ENET_CLK_SEL_OFFSET,
99+
MX93_ENET_QOS_CLK_TX_SEL_MASK);
100100
if (ret)
101101
return ret;
102102
}
103103

104104
val = FIELD_PREP(MX93_GPR_ENET_QOS_INTF_SEL_MASK, phy_intf_sel) |
105-
MX93_GPR_ENET_QOS_CLK_GEN_EN;
105+
MX93_GPR_ENET_QOS_ENABLE;
106106

107107
return regmap_update_bits(dwmac->intf_regmap, dwmac->intf_reg_off,
108-
MX93_GPR_ENET_QOS_INTF_MODE_MASK, val);
108+
MX93_GPR_ENET_QOS_INTF_SEL_MASK |
109+
MX93_GPR_ENET_QOS_ENABLE, val);
109110
};
110111

111112
static int imx_dwmac_clks_config(void *priv, bool enabled)
@@ -205,17 +206,19 @@ static void imx93_dwmac_fix_speed(void *priv, int speed, unsigned int mode)
205206
old_ctrl = readl(dwmac->base_addr + MAC_CTRL_REG);
206207
ctrl = old_ctrl & ~CTRL_SPEED_MASK;
207208
regmap_update_bits(dwmac->intf_regmap, dwmac->intf_reg_off,
208-
MX93_GPR_ENET_QOS_INTF_MODE_MASK, 0);
209+
MX93_GPR_ENET_QOS_INTF_SEL_MASK |
210+
MX93_GPR_ENET_QOS_ENABLE, 0);
209211
writel(ctrl, dwmac->base_addr + MAC_CTRL_REG);
210212

211213
/* Ensure the settings for CTRL are applied. */
212214
readl(dwmac->base_addr + MAC_CTRL_REG);
213215

214216
usleep_range(10, 20);
215217
iface &= MX93_GPR_ENET_QOS_INTF_SEL_MASK;
216-
iface |= MX93_GPR_ENET_QOS_CLK_GEN_EN;
218+
iface |= MX93_GPR_ENET_QOS_ENABLE;
217219
regmap_update_bits(dwmac->intf_regmap, dwmac->intf_reg_off,
218-
MX93_GPR_ENET_QOS_INTF_MODE_MASK, iface);
220+
MX93_GPR_ENET_QOS_INTF_SEL_MASK |
221+
MX93_GPR_ENET_QOS_ENABLE, iface);
219222

220223
writel(old_ctrl, dwmac->base_addr + MAC_CTRL_REG);
221224
}

0 commit comments

Comments
 (0)