From owner-svn-src-all@FreeBSD.ORG Wed Oct 16 04:15:04 2013 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 ESMTP id F28ED7E9; Wed, 16 Oct 2013 04:15:03 +0000 (UTC) (envelope-from adrian@FreeBSD.org) 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 DEC932E05; Wed, 16 Oct 2013 04:15:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9G4F3Yc041061; Wed, 16 Oct 2013 04:15:03 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9G4F3BQ041060; Wed, 16 Oct 2013 04:15:03 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201310160415.r9G4F3BQ041060@svn.freebsd.org> From: Adrian Chadd Date: Wed, 16 Oct 2013 04:15:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r256582 - 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.14 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, 16 Oct 2013 04:15:04 -0000 Author: adrian Date: Wed Oct 16 04:15:03 2013 New Revision: 256582 URL: http://svnweb.freebsd.org/changeset/base/256582 Log: Add support for the AR9340 switch to the switch framework. * Do the hardware setup in the right order! * Modify/improve the chip probe check so it can actually probe the 7240/9340 directly (although it's not yet used..) * Initialise and fetch the is_mii option * Fix some debugging whilst I'm here. This is enough to get things off the ground. Tested: * AR9344 SoC Modified: head/sys/dev/etherswitch/arswitch/arswitch.c Modified: head/sys/dev/etherswitch/arswitch/arswitch.c ============================================================================== --- head/sys/dev/etherswitch/arswitch/arswitch.c Wed Oct 16 04:11:42 2013 (r256581) +++ head/sys/dev/etherswitch/arswitch/arswitch.c Wed Oct 16 04:15:03 2013 (r256582) @@ -64,6 +64,7 @@ #include #include #include +#include #include "mdio_if.h" #include "miibus_if.h" @@ -93,23 +94,34 @@ arswitch_probe(device_t dev) if (ar7240_probe(dev) == 0) { chipname = "AR7240"; sc->sc_switchtype = AR8X16_SWITCH_AR7240; + sc->is_internal_switch = 1; + id = 0; + goto done; + } + + /* AR9340 probe */ + if (ar9340_probe(dev) == 0) { + chipname = "AR9340"; + sc->sc_switchtype = AR8X16_SWITCH_AR9340; + sc->is_internal_switch = 1; id = 0; goto done; } /* AR8xxx probe */ id = arswitch_readreg(dev, AR8X16_REG_MASK_CTRL); - switch ((id & AR8X16_MASK_CTRL_VER_MASK) >> - AR8X16_MASK_CTRL_VER_SHIFT) { - case 1: + switch (id & (AR8X16_MASK_CTRL_VER_MASK | AR8X16_MASK_CTRL_REV_MASK)) { + case 0x0101: chipname = "AR8216"; sc->sc_switchtype = AR8X16_SWITCH_AR8216; break; - case 2: + case 0x0201: chipname = "AR8226"; sc->sc_switchtype = AR8X16_SWITCH_AR8226; break; - case 16: + /* 0x0301 - AR8236 */ + case 0x1000: + case 0x1001: chipname = "AR8316"; sc->sc_switchtype = AR8X16_SWITCH_AR8316; break; @@ -118,8 +130,8 @@ arswitch_probe(device_t dev) } done: - DPRINTF(dev, "chipname=%s, rev=%02x\n", chipname, - id & AR8X16_MASK_CTRL_REV_MASK); + + DPRINTF(dev, "chipname=%s, id=%08x\n", chipname, id); if (chipname != NULL) { snprintf(desc, sizeof(desc), "Atheros %s Ethernet Switch", @@ -250,6 +262,8 @@ arswitch_attach(device_t dev) */ if (AR8X16_IS_SWITCH(sc, AR7240)) ar7240_attach(sc); + else if (AR8X16_IS_SWITCH(sc, AR9340)) + ar9340_attach(sc); else if (AR8X16_IS_SWITCH(sc, AR8216)) ar8216_attach(sc); else if (AR8X16_IS_SWITCH(sc, AR8226)) @@ -267,6 +281,7 @@ arswitch_attach(device_t dev) sc->phy4cpu = 1; sc->is_rgmii = 1; sc->is_gmii = 0; + sc->is_mii = 0; (void) resource_int_value(device_get_name(dev), device_get_unit(dev), "numphys", &sc->numphys); @@ -276,6 +291,8 @@ arswitch_attach(device_t dev) "is_rgmii", &sc->is_rgmii); (void) resource_int_value(device_get_name(dev), device_get_unit(dev), "is_gmii", &sc->is_gmii); + (void) resource_int_value(device_get_name(dev), device_get_unit(dev), + "is_mii", &sc->is_mii); if (sc->numphys > AR8X16_NUM_PHYS) sc->numphys = AR8X16_NUM_PHYS; @@ -284,6 +301,10 @@ arswitch_attach(device_t dev) if (arswitch_reset(dev)) return (ENXIO); + err = sc->hal.arswitch_hw_setup(sc); + if (err != 0) + return (err); + err = sc->hal.arswitch_hw_global_setup(sc); if (err != 0) return (err); @@ -303,10 +324,6 @@ arswitch_attach(device_t dev) if (err != 0) return (err); - err = sc->hal.arswitch_hw_setup(sc); - if (err != 0) - return (err); - bus_generic_probe(dev); bus_enumerate_hinted_children(dev); err = bus_generic_attach(dev); @@ -435,7 +452,7 @@ arswitch_miipollstat(struct arswitch_sof AR8X16_REG_PORT_STS(arswitch_portforphy(i))); #if 0 DPRINTF(sc->sc_dev, "p[%d]=%b\n", - arge_portforphy(i), + i, portstatus, "\20\3TXMAC\4RXMAC\5TXFLOW\6RXFLOW\7" "DUPLEX\11LINK_UP\12LINK_AUTO\13LINK_PAUSE");