hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/net/mdio/mdio-mux-meson-g12a.c
....@@ -4,6 +4,7 @@
44 */
55
66 #include <linux/bitfield.h>
7
+#include <linux/delay.h>
78 #include <linux/clk.h>
89 #include <linux/clk-provider.h>
910 #include <linux/device.h>
....@@ -150,6 +151,7 @@
150151
151152 static int g12a_enable_internal_mdio(struct g12a_mdio_mux *priv)
152153 {
154
+ u32 value;
153155 int ret;
154156
155157 /* Enable the phy clock */
....@@ -163,18 +165,25 @@
163165
164166 /* Initialize ephy control */
165167 writel(EPHY_G12A_ID, priv->regs + ETH_PHY_CNTL0);
166
- writel(FIELD_PREP(PHY_CNTL1_ST_MODE, 3) |
167
- FIELD_PREP(PHY_CNTL1_ST_PHYADD, EPHY_DFLT_ADD) |
168
- FIELD_PREP(PHY_CNTL1_MII_MODE, EPHY_MODE_RMII) |
169
- PHY_CNTL1_CLK_EN |
170
- PHY_CNTL1_CLKFREQ |
171
- PHY_CNTL1_PHY_ENB,
172
- priv->regs + ETH_PHY_CNTL1);
168
+
169
+ /* Make sure we get a 0 -> 1 transition on the enable bit */
170
+ value = FIELD_PREP(PHY_CNTL1_ST_MODE, 3) |
171
+ FIELD_PREP(PHY_CNTL1_ST_PHYADD, EPHY_DFLT_ADD) |
172
+ FIELD_PREP(PHY_CNTL1_MII_MODE, EPHY_MODE_RMII) |
173
+ PHY_CNTL1_CLK_EN |
174
+ PHY_CNTL1_CLKFREQ;
175
+ writel(value, priv->regs + ETH_PHY_CNTL1);
173176 writel(PHY_CNTL2_USE_INTERNAL |
174177 PHY_CNTL2_SMI_SRC_MAC |
175178 PHY_CNTL2_RX_CLK_EPHY,
176179 priv->regs + ETH_PHY_CNTL2);
177180
181
+ value |= PHY_CNTL1_PHY_ENB;
182
+ writel(value, priv->regs + ETH_PHY_CNTL1);
183
+
184
+ /* The phy needs a bit of time to power up */
185
+ mdelay(10);
186
+
178187 return 0;
179188 }
180189