From owner-svn-src-all@FreeBSD.ORG Wed Feb 19 05:35:42 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 651BE499; Wed, 19 Feb 2014 05:35:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 35EFA1A7B; Wed, 19 Feb 2014 05:35:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s1J5ZgAb052743; Wed, 19 Feb 2014 05:35:42 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s1J5ZgOE052742; Wed, 19 Feb 2014 05:35:42 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201402190535.s1J5ZgOE052742@svn.freebsd.org> From: Adrian Chadd Date: Wed, 19 Feb 2014 05:35:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262203 - head/sys/dev/etherswitch/arswitch X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Feb 2014 05:35:42 -0000 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.