| .. | .. |
|---|
| 4 | 4 | */ |
|---|
| 5 | 5 | |
|---|
| 6 | 6 | #include <linux/bitfield.h> |
|---|
| 7 | +#include <linux/delay.h> |
|---|
| 7 | 8 | #include <linux/clk.h> |
|---|
| 8 | 9 | #include <linux/clk-provider.h> |
|---|
| 9 | 10 | #include <linux/device.h> |
|---|
| .. | .. |
|---|
| 150 | 151 | |
|---|
| 151 | 152 | static int g12a_enable_internal_mdio(struct g12a_mdio_mux *priv) |
|---|
| 152 | 153 | { |
|---|
| 154 | + u32 value; |
|---|
| 153 | 155 | int ret; |
|---|
| 154 | 156 | |
|---|
| 155 | 157 | /* Enable the phy clock */ |
|---|
| .. | .. |
|---|
| 163 | 165 | |
|---|
| 164 | 166 | /* Initialize ephy control */ |
|---|
| 165 | 167 | 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); |
|---|
| 173 | 176 | writel(PHY_CNTL2_USE_INTERNAL | |
|---|
| 174 | 177 | PHY_CNTL2_SMI_SRC_MAC | |
|---|
| 175 | 178 | PHY_CNTL2_RX_CLK_EPHY, |
|---|
| 176 | 179 | priv->regs + ETH_PHY_CNTL2); |
|---|
| 177 | 180 | |
|---|
| 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 | + |
|---|
| 178 | 187 | return 0; |
|---|
| 179 | 188 | } |
|---|
| 180 | 189 | |
|---|