diff options
author | adrian <adrian@FreeBSD.org> | 2014-02-19 04:23:01 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2014-02-19 04:23:01 +0000 |
commit | d6af13f80d8392642c3f3ee893c525c7008ca036 (patch) | |
tree | faad82f3f28cf69887c951087220938f88918c01 | |
parent | a631141dcb4060ca08313279280ceb2bee9539dd (diff) | |
download | FreeBSD-src-d6af13f80d8392642c3f3ee893c525c7008ca036.zip FreeBSD-src-d6af13f80d8392642c3f3ee893c525c7008ca036.tar.gz |
Add in a flag to control whether the low or high data word of a register access
is latched in first.
The AR8327 apparently requires the low data word be latched in first.
Obtained from: Linux OpenWRT
-rw-r--r-- | sys/dev/etherswitch/arswitch/arswitch_reg.c | 15 | ||||
-rw-r--r-- | sys/dev/etherswitch/arswitch/arswitchvar.h | 1 |
2 files changed, 14 insertions, 2 deletions
diff --git a/sys/dev/etherswitch/arswitch/arswitch_reg.c b/sys/dev/etherswitch/arswitch/arswitch_reg.c index 3eb0600..3251da8 100644 --- a/sys/dev/etherswitch/arswitch/arswitch_reg.c +++ b/sys/dev/etherswitch/arswitch/arswitch_reg.c @@ -172,10 +172,21 @@ arswitch_readreg(device_t dev, int addr) int arswitch_writereg(device_t dev, int addr, int value) { + struct arswitch_softc *sc; + int r; + + sc = device_get_softc(dev); /* XXX Check the first write too? */ - arswitch_writereg_msb(dev, addr, value); - return (arswitch_writereg_lsb(dev, addr, value)); + if (sc->mii_lo_first) { + r = arswitch_writereg_lsb(dev, addr, value); + r |= arswitch_writereg_msb(dev, addr, value); + } else { + r = arswitch_writereg_msb(dev, addr, value); + r |= arswitch_writereg_lsb(dev, addr, value); + } + + return r; } int diff --git a/sys/dev/etherswitch/arswitch/arswitchvar.h b/sys/dev/etherswitch/arswitch/arswitchvar.h index 91d755a..10a942d 100644 --- a/sys/dev/etherswitch/arswitch/arswitchvar.h +++ b/sys/dev/etherswitch/arswitch/arswitchvar.h @@ -53,6 +53,7 @@ struct arswitch_softc { int is_mii; /* PHY mode is MII (XXX which PHY?) */ int page; int is_internal_switch; + int mii_lo_first; ar8x16_switch_type sc_switchtype; char *ifname[AR8X16_NUM_PHYS]; device_t miibus[AR8X16_NUM_PHYS]; |