[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree

zrouter-src-freebsd at zrouter.org zrouter-src-freebsd at zrouter.org
Wed Jan 11 15:32:25 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/435470dfbe3d
changeset: 273:435470dfbe3d
user:      ray at terran.dlink.ua
date:      Wed Jan 11 16:55:12 2012 +0200
description:
Add hints.ar8x16_switch.0.mii_mode variable support.

diffstat:

 head/sys/dev/switch/ar8x16_switch.c |  35 +++++++++++++----------------------
 1 files changed, 13 insertions(+), 22 deletions(-)

diffs (90 lines):

diff -r 1d2b8a9197bd -r 435470dfbe3d head/sys/dev/switch/ar8x16_switch.c
--- a/head/sys/dev/switch/ar8x16_switch.c	Wed Jan 11 16:13:34 2012 +0200
+++ b/head/sys/dev/switch/ar8x16_switch.c	Wed Jan 11 16:55:12 2012 +0200
@@ -236,18 +236,12 @@
 static int
 ar8x16_switch_probe(device_t dev)
 {
+	struct ar8x16_switch_softc *sc;
 	struct child_res_avl *res;
-	struct ar8x16_switch_softc *sc;
 	char	name[64];
 
-
 	res = device_get_ivars(dev);
 
-	/* ar8x16 use PHYs for access */
-	if (!res->phys)
-		return (ENXIO);
-//model SWITCHFW AR8X16		0x0101 Atheros AR8x16 switch family
-
 	sc = device_get_softc(dev);
 	sc->parent = device_get_parent(dev); /* switchX device */
 	sc->sc_dev = dev;
@@ -267,6 +261,7 @@
 	sprintf(name, "Unknown AR8x16 like Ethernet switch (%02x.%02x)",
 		sc->devid, sc->revid);
 	device_set_desc_copy(dev, name);
+
 	return (BUS_PROBE_DEFAULT);
 }
 
@@ -277,23 +272,12 @@
 
 	WRITE4(sc, AR8X16_REG_MODE, AR8X16_MODE_DIR_615_MY);
 
-	/* Set the interface type: rgmii, gmii - We only support rgmii atm. */
 	mode = READ4(sc, AR8X16_REG_MODE);
-#if 0
-	/* XXX: set what we need, instead of failing on unsupported */
-	if (mode == AR8X16_MODE_GMII) {
-		device_printf(sc->sc_dev, "Unsupported MII mode.\n");
-		return (ENXIO);
-	}
 	if (sc->sc_mii_mode != mode) {
-		device_printf(sc->sc_dev, "Initializing the Switch.\n");
-		if (sc->sc_mii_mode == AR8X16_MODE_RGMII_PORT4_ISO) {
-			device_printf(sc->sc_dev,
-			    "Switch port 4 is isolated.\n");
-		}
+		device_printf(sc->sc_dev, "Initializing the switch mode.\n");
 		WRITE4(sc, AR8X16_REG_MODE, sc->sc_mii_mode);
 	}
-#endif
+
 	/* Standard Atheros magic */
 	/* XXX, find what magic in those value,
 	 * somewhere I(ray) already seen it, but forget where */
@@ -306,23 +290,30 @@
 ar8x16_init(device_t dev)
 {
 	struct ar8x16_switch_softc *sc;
+	uint32_t config_reg;
 	int port, err;
 
 	sc = device_get_softc(dev);
 
+	resource_int_value(device_get_name(dev), device_get_unit(dev),
+	    "mii_mode", &sc->sc_mii_mode);
+
 	/* AR8316 specific init routine */
 	if (sc->devid == 8316) {
 		/* XXX - Default setting for RSPRO */
 		/* XXX - Need to "isolate" of isolate bits :),
 		 * seems port1 (first Physical) isolate on set 0x400 bit
 		 */
-		sc->sc_mii_mode = AR8X16_MODE_RGMII_PORT4_ISO;
+		if (sc->sc_mii_mode == 0)
+			sc->sc_mii_mode = AR8X16_MODE_RGMII_PORT4_ISO;
 		err = ar8316_init(sc);
 		if (err != 0)
 			return (err);
 	}
 	if ((sc->devid == 8216) && (sc->revid == 2)) {
-		WRITE4(sc, AR8X16_REG_MODE, AR8X16_MODE_RGMII_PORT4_SWITCH);
+		if (sc->sc_mii_mode == 0)
+			sc->sc_mii_mode = AR8X16_MODE_RGMII_PORT4_SWITCH;
+		WRITE4(sc, AR8X16_REG_MODE, sc->sc_mii_mode);
 	}
 
 	/* Reset the switch */


More information about the Zrouter-src-freebsd mailing list