summaryrefslogtreecommitdiffstats
path: root/sys/dev/etherswitch
diff options
context:
space:
mode:
authorloos <loos@FreeBSD.org>2013-07-23 14:02:38 +0000
committerloos <loos@FreeBSD.org>2013-07-23 14:02:38 +0000
commitf2b6d4ff8043c142ebc1952e5e9e82cebe630993 (patch)
treeb1002e3e652a1ad1f3941efbe1bd6422481e1c03 /sys/dev/etherswitch
parente4f13850f70c2edd8f1918455575694b72741b3e (diff)
downloadFreeBSD-src-f2b6d4ff8043c142ebc1952e5e9e82cebe630993.zip
FreeBSD-src-f2b6d4ff8043c142ebc1952e5e9e82cebe630993.tar.gz
Fix the arswitch instability problem. It turns out that the
arswitch_writereg() routine was writing the registers in the wrong order. Revert -r241918 as the root problem is now fixed. Remove another workaround from arswitch_ar7240.c. Simplify and fix the code on arswitch_writephy() by using arswitch_writereg(). While here remove a redundant declaration from arswitchvar.h. Approved by: adrian (mentor)
Diffstat (limited to 'sys/dev/etherswitch')
-rw-r--r--sys/dev/etherswitch/arswitch/arswitch_7240.c6
-rw-r--r--sys/dev/etherswitch/arswitch/arswitch_phy.c9
-rw-r--r--sys/dev/etherswitch/arswitch/arswitch_reg.c19
-rw-r--r--sys/dev/etherswitch/arswitch/arswitchvar.h2
4 files changed, 9 insertions, 27 deletions
diff --git a/sys/dev/etherswitch/arswitch/arswitch_7240.c b/sys/dev/etherswitch/arswitch/arswitch_7240.c
index c8f6426..63a8910 100644
--- a/sys/dev/etherswitch/arswitch/arswitch_7240.c
+++ b/sys/dev/etherswitch/arswitch/arswitch_7240.c
@@ -75,12 +75,6 @@ ar7240_hw_setup(struct arswitch_softc *sc)
arswitch_writereg(sc->sc_dev, AR8X16_REG_CPU_PORT,
AR8X16_CPU_PORT_EN | AR8X16_CPU_MIRROR_DIS);
- /*
- * Let things settle; probing PHY4 doesn't seem reliable
- * without a litle delay.
- */
- DELAY(1000);
-
return (0);
}
diff --git a/sys/dev/etherswitch/arswitch/arswitch_phy.c b/sys/dev/etherswitch/arswitch/arswitch_phy.c
index f896d42..8e190e2 100644
--- a/sys/dev/etherswitch/arswitch/arswitch_phy.c
+++ b/sys/dev/etherswitch/arswitch/arswitch_phy.c
@@ -127,16 +127,13 @@ arswitch_writephy(device_t dev, int phy, int reg, int data)
return (ENXIO);
ARSWITCH_LOCK(sc);
- err = arswitch_writereg_lsb(dev, AR8X16_REG_MDIO_CTRL,
- (data & AR8X16_MDIO_CTRL_DATA_MASK));
- if (err != 0)
- goto out;
- err = arswitch_writereg_msb(dev, AR8X16_REG_MDIO_CTRL,
+ err = arswitch_writereg(dev, AR8X16_REG_MDIO_CTRL,
AR8X16_MDIO_CTRL_BUSY |
AR8X16_MDIO_CTRL_MASTER_EN |
AR8X16_MDIO_CTRL_CMD_WRITE |
(phy << AR8X16_MDIO_CTRL_PHY_ADDR_SHIFT) |
- (reg << AR8X16_MDIO_CTRL_REG_ADDR_SHIFT));
+ (reg << AR8X16_MDIO_CTRL_REG_ADDR_SHIFT) |
+ (data & AR8X16_MDIO_CTRL_DATA_MASK));
if (err != 0)
goto out;
for (timeout = 100; timeout--; ) {
diff --git a/sys/dev/etherswitch/arswitch/arswitch_reg.c b/sys/dev/etherswitch/arswitch/arswitch_reg.c
index 4ec71ba..2c31c9f 100644
--- a/sys/dev/etherswitch/arswitch/arswitch_reg.c
+++ b/sys/dev/etherswitch/arswitch/arswitch_reg.c
@@ -72,17 +72,10 @@ arswitch_split_setpage(device_t dev, uint32_t addr, uint16_t *phy,
*phy = (((addr) >> 6) & 0x07) | 0x10;
*reg = ((addr) >> 1) & 0x1f;
- /*
- * The earlier code would only switch the page
- * over if the page were different. Experiments have
- * shown that this is unstable.
- *
- * Hence, the page is always set here.
- *
- * See PR kern/172968
- */
- MDIO_WRITEREG(device_get_parent(dev), 0x18, 0, page);
- sc->page = page;
+ if (sc->page != page) {
+ MDIO_WRITEREG(device_get_parent(dev), 0x18, 0, page);
+ sc->page = page;
+ }
}
/*
@@ -171,8 +164,8 @@ arswitch_writereg(device_t dev, int addr, int value)
{
/* XXX Check the first write too? */
- arswitch_writereg_lsb(dev, addr, value);
- return (arswitch_writereg_msb(dev, addr, value));
+ arswitch_writereg_msb(dev, addr, value);
+ return (arswitch_writereg_lsb(dev, addr, value));
}
int
diff --git a/sys/dev/etherswitch/arswitch/arswitchvar.h b/sys/dev/etherswitch/arswitch/arswitchvar.h
index 40e38a4..caf1c1f 100644
--- a/sys/dev/etherswitch/arswitch/arswitchvar.h
+++ b/sys/dev/etherswitch/arswitch/arswitchvar.h
@@ -42,8 +42,6 @@ typedef enum {
#define AR8X16_IS_SWITCH(_sc, _type) \
(!!((_sc)->sc_switchtype == AR8X16_SWITCH_ ## _type))
-struct arswitch_softc;
-
struct arswitch_softc {
struct mtx sc_mtx; /* serialize access to softc */
device_t sc_dev;
OpenPOWER on IntegriCloud