Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Feb 2014 05:35:42 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r262203 - head/sys/dev/etherswitch/arswitch
Message-ID:  <201402190535.s1J5ZgOE052742@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Wed Feb 19 05:35:41 2014
New Revision: 262203
URL: http://svnweb.freebsd.org/changeset/base/262203

Log:
  Change arswitch_ports_init() to arswitch_port_init(), and teach it to take
  a single port to setup.
  
  This may end up later being used as part of some logic to program
  the PHY for a single port, rather than having to reinitialise them
  all at once.
  
  Tested:
  
  * DB120

Modified:
  head/sys/dev/etherswitch/arswitch/arswitch.c

Modified: head/sys/dev/etherswitch/arswitch/arswitch.c
==============================================================================
--- head/sys/dev/etherswitch/arswitch/arswitch.c	Wed Feb 19 05:09:47 2014	(r262202)
+++ head/sys/dev/etherswitch/arswitch/arswitch.c	Wed Feb 19 05:35:41 2014	(r262203)
@@ -224,24 +224,23 @@ arswitch_set_vlan_mode(struct arswitch_s
 }
 
 static void
-arswitch_ports_init(struct arswitch_softc *sc)
+arswitch_port_init(struct arswitch_softc *sc, int port)
 {
-	int port;
 
 	/* Port0 - CPU */
-	arswitch_writereg(sc->sc_dev, AR8X16_REG_PORT_STS(0),
-	    (AR8X16_IS_SWITCH(sc, AR8216) ?
-	    AR8X16_PORT_STS_SPEED_100 : AR8X16_PORT_STS_SPEED_1000) |
-	    (AR8X16_IS_SWITCH(sc, AR8216) ? 0 : AR8X16_PORT_STS_RXFLOW) |
-	    (AR8X16_IS_SWITCH(sc, AR8216) ? 0 : AR8X16_PORT_STS_TXFLOW) |
-	    AR8X16_PORT_STS_RXMAC |
-	    AR8X16_PORT_STS_TXMAC |
-	    AR8X16_PORT_STS_DUPLEX);
-	arswitch_writereg(sc->sc_dev, AR8X16_REG_PORT_CTRL(0),
-	    arswitch_readreg(sc->sc_dev, AR8X16_REG_PORT_CTRL(0)) &
-	    ~AR8X16_PORT_CTRL_HEADER);
-
-	for (port = 1; port <= sc->numphys; port++) { 
+	if (port == AR8X16_PORT_CPU) {
+		arswitch_writereg(sc->sc_dev, AR8X16_REG_PORT_STS(0),
+		    (AR8X16_IS_SWITCH(sc, AR8216) ?
+		    AR8X16_PORT_STS_SPEED_100 : AR8X16_PORT_STS_SPEED_1000) |
+		    (AR8X16_IS_SWITCH(sc, AR8216) ? 0 : AR8X16_PORT_STS_RXFLOW) |
+		    (AR8X16_IS_SWITCH(sc, AR8216) ? 0 : AR8X16_PORT_STS_TXFLOW) |
+		    AR8X16_PORT_STS_RXMAC |
+		    AR8X16_PORT_STS_TXMAC |
+		    AR8X16_PORT_STS_DUPLEX);
+		arswitch_writereg(sc->sc_dev, AR8X16_REG_PORT_CTRL(0),
+		    arswitch_readreg(sc->sc_dev, AR8X16_REG_PORT_CTRL(0)) &
+		    ~AR8X16_PORT_CTRL_HEADER);
+	} else {
 		/* Set ports to auto negotiation. */
 		arswitch_writereg(sc->sc_dev, AR8X16_REG_PORT_STS(port),
 		    AR8X16_PORT_STS_LINK_AUTO);
@@ -256,6 +255,7 @@ arswitch_attach(device_t dev)
 {
 	struct arswitch_softc *sc;
 	int err = 0;
+	int port;
 
 	sc = device_get_softc(dev);
 
@@ -319,7 +319,9 @@ arswitch_attach(device_t dev)
 		return (err);
 
 	/* Initialize the switch ports. */
-	arswitch_ports_init(sc);
+	for (port = 0; port <= sc->numphys; port++) {
+		arswitch_port_init(sc, port);
+	}
 
 	/*
 	 * Attach the PHYs and complete the bus enumeration.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402190535.s1J5ZgOE052742>