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)
This commit is contained in:
loos 2013-07-23 14:02:38 +00:00
parent e4f13850f7
commit f2b6d4ff80
4 changed files with 9 additions and 27 deletions

View File

@ -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);
}

View File

@ -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--; ) {

View File

@ -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

View File

@ -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;