When the switch is set to operate in the Multi Chip Addressing Mode we

cannot access the GLOBAL2 register directly.

Despite the comment in code (which was misleading), the indirect access is
only used to read the switch CONFIG data from the scrap register and not
for the GLOBAL2 access.

Use the dsa data to define when the switch is in the Multi Chip Addressing
Mode (a even address different than zero).

While here fix a typo.

Sponsored by:	Rubicon Communications, LLC (Netgate)
This commit is contained in:
Luiz Otavio O Souza 2017-04-30 07:51:31 +00:00
parent 948dad6add
commit ebde1aafa8

View File

@ -214,7 +214,6 @@ e6000sw_probe(device_t dev)
e6000sw_softc_t *sc;
const char *description;
unsigned int id;
uint16_t dev_addr;
phandle_t dsa_node, switch_node;
dsa_node = fdt_find_compatible(OF_finddevice("/"),
@ -229,21 +228,11 @@ e6000sw_probe(device_t dev)
sc->dev = dev;
sc->node = switch_node;
/* Read ADDR[4:1]n using indirect access */
MDIO_WRITE(dev, REG_GLOBAL2, SCR_AND_MISC_REG,
SCR_AND_MISC_PTR_CFG);
dev_addr = MDIO_READ(dev, REG_GLOBAL2, SCR_AND_MISC_REG) &
SCR_AND_MISC_DATA_CFG_MASK;
if (dev_addr != 0) {
sc->multi_chip = true;
device_printf(dev, "multi-chip addresing mode\n");
} else {
device_printf(dev, "single-chip addressing mode\n");
}
if (OF_getencprop(sc->node, "reg", &sc->sw_addr,
sizeof(sc->sw_addr)) < 0)
return (ENXIO);
if (sc->sw_addr != 0 && (sc->sw_addr % 2) == 0)
sc->multi_chip = true;
/* Lock is necessary due to assertions. */
sx_init(&sc->sx, "e6000sw");
@ -368,6 +357,11 @@ e6000sw_attach(device_t dev)
err = 0;
sc = device_get_softc(dev);
if (sc->multi_chip)
device_printf(dev, "multi-chip addressing mode\n");
else
device_printf(dev, "single-chip addressing mode\n");
E6000SW_LOCK(sc);
e6000sw_setup(dev, sc);
bzero(member_ports, sizeof(member_ports));