MCPcopy Create free account
hub / github.com/F-Stack/f-stack / awg_miibus_readreg

Function awg_miibus_readreg

freebsd/arm/allwinner/if_awg.c:235–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233 */
234
235static int
236awg_miibus_readreg(device_t dev, int phy, int reg)
237{
238 struct awg_softc *sc;
239 int retry, val;
240
241 sc = device_get_softc(dev);
242 val = 0;
243
244 WR4(sc, EMAC_MII_CMD,
245 (sc->mdc_div_ratio_m << MDC_DIV_RATIO_M_SHIFT) |
246 (phy << PHY_ADDR_SHIFT) |
247 (reg << PHY_REG_ADDR_SHIFT) |
248 MII_BUSY);
249 for (retry = MII_BUSY_RETRY; retry > 0; retry--) {
250 if ((RD4(sc, EMAC_MII_CMD) & MII_BUSY) == 0) {
251 val = RD4(sc, EMAC_MII_DATA);
252 break;
253 }
254 DELAY(10);
255 }
256
257 if (retry == 0)
258 device_printf(dev, "phy read timeout, phy=%d reg=%d\n",
259 phy, reg);
260
261 return (val);
262}
263
264static int
265awg_miibus_writereg(device_t dev, int phy, int reg, int val)

Callers

nothing calls this directly

Calls 5

device_get_softcFunction · 0.85
device_printfFunction · 0.85
WR4Function · 0.50
RD4Function · 0.50
DELAYFunction · 0.50

Tested by

no test coverage detected