Page MenuHomeFreeBSD

D59189.diff
No OneTemporary

D59189.diff

diff --git a/sys/dev/etherswitch/e6000sw/e6000sw.c b/sys/dev/etherswitch/e6000sw/e6000sw.c
--- a/sys/dev/etherswitch/e6000sw/e6000sw.c
+++ b/sys/dev/etherswitch/e6000sw/e6000sw.c
@@ -110,7 +110,9 @@
.es_name = "Marvell 6000 series switch"
};
+#ifndef FDT
static void e6000sw_identify(driver_t *, device_t);
+#endif
static int e6000sw_probe(device_t);
#ifdef FDT
static int e6000sw_parse_fixed_link(e6000sw_softc_t *, phandle_t, uint32_t);
@@ -162,7 +164,9 @@
static device_method_t e6000sw_methods[] = {
/* device interface */
+#ifndef FDT
DEVMETHOD(device_identify, e6000sw_identify),
+#endif
DEVMETHOD(device_probe, e6000sw_probe),
DEVMETHOD(device_attach, e6000sw_attach),
DEVMETHOD(device_detach, e6000sw_detach),
@@ -201,6 +205,7 @@
MODULE_DEPEND(e6000sw, mdio, 1, 1, 1);
MODULE_DEPEND(e6000sw, etherswitch, 1, 1, 1);
+#ifndef FDT
static void
e6000sw_identify(driver_t *driver, device_t parent)
{
@@ -208,127 +213,30 @@
if (device_find_child(parent, "e6000sw", DEVICE_UNIT_ANY) == NULL)
BUS_ADD_CHILD(parent, 0, "e6000sw", DEVICE_UNIT_ANY);
}
+#endif
static int
e6000sw_probe(device_t dev)
{
- e6000sw_softc_t *sc;
- const char *description;
-#ifdef FDT
- phandle_t switch_node;
-#else
- int is_6190 = 0;
- int is_6190x = 0;
+#ifndef FDT
+ int sw_addr;
#endif
- sc = device_get_softc(dev);
- sc->dev = dev;
-
#ifdef FDT
- switch_node = ofw_bus_find_compatible(OF_finddevice("/"),
- "marvell,mv88e6085");
- if (switch_node == 0) {
- switch_node = ofw_bus_find_compatible(OF_finddevice("/"),
- "marvell,mv88e6190");
-
- if (switch_node == 0)
- return (ENXIO);
-
- /*
- * Trust DTS and fix the port register offset for the MV88E6190
- * detection bellow.
- */
- sc->swid = MV88E6190;
- }
-
- if (bootverbose)
- device_printf(dev, "Found switch_node: 0x%x\n", switch_node);
-
- sc->node = switch_node;
-
- if (OF_getencprop(sc->node, "reg", &sc->sw_addr,
- sizeof(sc->sw_addr)) < 0)
+ if (!ofw_bus_status_okay(dev))
return (ENXIO);
-#else
- if (resource_int_value(device_get_name(sc->dev),
- device_get_unit(sc->dev), "addr", &sc->sw_addr) != 0)
+ if (!ofw_bus_is_compatible(dev, "marvell,mv88e6085") &&
+ !ofw_bus_is_compatible(dev, "marvell,mv88e6190"))
return (ENXIO);
- if (resource_int_value(device_get_name(sc->dev),
- device_get_unit(sc->dev), "is6190", &is_6190) != 0) {
- /*
- * Check "is8190" to keep backward compatibility with
- * older setups.
- */
- resource_int_value(device_get_name(sc->dev),
- device_get_unit(sc->dev), "is8190", &is_6190);
- }
- resource_int_value(device_get_name(sc->dev),
- device_get_unit(sc->dev), "is6190x", &is_6190x);
- if (is_6190 != 0 && is_6190x != 0) {
- device_printf(dev,
- "Cannot configure conflicting variants (6190 / 6190x)\n");
- return (ENXIO);
- }
- if (is_6190 != 0)
- sc->swid = MV88E6190;
- else if (is_6190x != 0)
- sc->swid = MV88E6190X;
-#endif
- if (sc->sw_addr < 0 || sc->sw_addr > 32)
+#else
+ if (resource_int_value(device_get_name(dev), device_get_unit(dev),
+ "addr", &sw_addr) != 0)
return (ENXIO);
-
- /*
- * Create temporary lock, just to satisfy assertions,
- * when obtaining the switch ID. Destroy immediately afterwards.
- */
- sx_init(&sc->sx, "e6000sw_tmp");
- E6000SW_LOCK(sc);
- sc->swid = e6000sw_readreg(sc, REG_PORT(sc, 0), SWITCH_ID) & 0xfff0;
- E6000SW_UNLOCK(sc);
- sx_destroy(&sc->sx);
-
- switch (sc->swid) {
- case MV88E6141:
- description = "Marvell 88E6141";
- sc->phy_base = 0x10;
- sc->num_ports = 6;
- break;
- case MV88E6341:
- description = "Marvell 88E6341";
- sc->phy_base = 0x10;
- sc->num_ports = 6;
- break;
- case MV88E6352:
- description = "Marvell 88E6352";
- sc->num_ports = 7;
- break;
- case MV88E6171:
- description = "Marvell 88E6171";
- sc->num_ports = 7;
- break;
- case MV88E6172:
- description = "Marvell 88E6172";
- sc->num_ports = 7;
- break;
- case MV88E6176:
- description = "Marvell 88E6176";
- sc->num_ports = 7;
- break;
- case MV88E6190:
- description = "Marvell 88E6190";
- sc->num_ports = 11;
- break;
- case MV88E6190X:
- description = "Marvell 88E6190X";
- sc->num_ports = 11;
- break;
- default:
- device_printf(dev, "Unrecognized device, id 0x%x.\n", sc->swid);
+ if (sw_addr < 0 || sw_addr > 32)
return (ENXIO);
- }
-
- device_set_desc(dev, description);
+#endif
+ device_set_desc(dev, "Marvell 88E6xxx MDIO switch");
return (BUS_PROBE_DEFAULT);
}
@@ -533,14 +441,98 @@
{
bool sgmii;
e6000sw_softc_t *sc;
+ const char *description;
#ifdef FDT
phandle_t child, ports;
+#else
+ int is_6190 = 0;
+ int is_6190x = 0;
#endif
int err, port;
uint32_t reg;
err = 0;
sc = device_get_softc(dev);
+ sc->dev = dev;
+
+#ifdef FDT
+ sc->node = ofw_bus_get_node(dev);
+ if (OF_getencprop(sc->node, "reg", &sc->sw_addr,
+ sizeof(sc->sw_addr)) < 0)
+ return (ENXIO);
+ if (ofw_bus_is_compatible(dev, "marvell,mv88e6190"))
+ sc->swid = MV88E6190;
+#else
+ if (resource_int_value(device_get_name(dev), device_get_unit(dev),
+ "addr", &sc->sw_addr) != 0)
+ return (ENXIO);
+ if (resource_int_value(device_get_name(dev), device_get_unit(dev),
+ "is6190", &is_6190) != 0) {
+ /* Check "is8190" to keep back-compat with older setups. */
+ resource_int_value(device_get_name(dev), device_get_unit(dev),
+ "is8190", &is_6190);
+ }
+ resource_int_value(device_get_name(dev), device_get_unit(dev),
+ "is6190x", &is_6190x);
+ if (is_6190 != 0 && is_6190x != 0) {
+ device_printf(dev,
+ "Cannot configure conflicting variants (6190 / 6190x)\n");
+ return (ENXIO);
+ }
+ if (is_6190 != 0)
+ sc->swid = MV88E6190;
+ else if (is_6190x != 0)
+ sc->swid = MV88E6190X;
+#endif
+ if (sc->sw_addr < 0 || sc->sw_addr > 32)
+ return (ENXIO);
+
+ sx_init(&sc->sx, "e6000sw");
+
+ E6000SW_LOCK(sc);
+ sc->swid = e6000sw_readreg(sc, REG_PORT(sc, 0), SWITCH_ID) & 0xfff0;
+ switch (sc->swid) {
+ case MV88E6141:
+ description = "Marvell 88E6141";
+ sc->phy_base = 0x10;
+ sc->num_ports = 6;
+ break;
+ case MV88E6341:
+ description = "Marvell 88E6341";
+ sc->phy_base = 0x10;
+ sc->num_ports = 6;
+ break;
+ case MV88E6352:
+ description = "Marvell 88E6352";
+ sc->num_ports = 7;
+ break;
+ case MV88E6171:
+ description = "Marvell 88E6171";
+ sc->num_ports = 7;
+ break;
+ case MV88E6172:
+ description = "Marvell 88E6172";
+ sc->num_ports = 7;
+ break;
+ case MV88E6176:
+ description = "Marvell 88E6176";
+ sc->num_ports = 7;
+ break;
+ case MV88E6190:
+ description = "Marvell 88E6190";
+ sc->num_ports = 11;
+ break;
+ case MV88E6190X:
+ description = "Marvell 88E6190X";
+ sc->num_ports = 11;
+ break;
+ default:
+ device_printf(dev, "Unrecognized device, id 0x%x.\n", sc->swid);
+ E6000SW_UNLOCK(sc);
+ sx_destroy(&sc->sx);
+ return (ENXIO);
+ }
+ device_set_desc(dev, description);
/*
* According to the Linux source code, all of the Switch IDs we support
@@ -553,9 +545,6 @@
else
device_printf(dev, "single-chip addressing mode\n");
- sx_init(&sc->sx, "e6000sw");
-
- E6000SW_LOCK(sc);
e6000sw_setup(dev, sc);
sc->sc_tq = taskqueue_create("e6000sw_taskq", M_NOWAIT,
diff --git a/sys/modules/mdio/Makefile b/sys/modules/mdio/Makefile
--- a/sys/modules/mdio/Makefile
+++ b/sys/modules/mdio/Makefile
@@ -3,6 +3,6 @@
KMOD= mdio
SRCS= mdio.c
SRCS+= mdio_if.c mdio_if.h
-SRCS+= device_if.h bus_if.h
+SRCS+= device_if.h bus_if.h ofw_bus_if.h opt_platform.h
.include <bsd.kmod.mk>

File Metadata

Mime Type
text/plain
Expires
Fri, Sep 4, 5:27 AM (12 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37810131
Default Alt Text
D59189.diff (7 KB)

Event Timeline