From owner-svn-src-head@freebsd.org Tue May 24 04:59:03 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9D64DB47D48; Tue, 24 May 2016 04:59:03 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4661A1EB8; Tue, 24 May 2016 04:59:03 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4O4wwHe032267; Tue, 24 May 2016 04:58:58 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4O4wweK032266; Tue, 24 May 2016 04:58:58 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201605240458.u4O4wweK032266@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Tue, 24 May 2016 04:58:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300563 - head/sys/dev/bwn X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 May 2016 04:59:03 -0000 Author: adrian Date: Tue May 24 04:58:58 2016 New Revision: 300563 URL: https://svnweb.freebsd.org/changeset/base/300563 Log: [bwn] begin separating out the attach path from the SIBA specific bits. * convert phy_getinfo() to take a "gmode" flag, rather than the siba TGSHIGH flags and then check for 2GHz. This should ensure that gmode is set correctly even on DUALPHY NICs. * move the siba_powerup() call and the TGSHIGH decoding into a call to bwn_is_bus_siba(), and return an error if it's called on anything else. We don't yet do anything else, but when we do.. Tested: * BCM4322, 11a STA Modified: head/sys/dev/bwn/if_bwn.c Modified: head/sys/dev/bwn/if_bwn.c ============================================================================== --- head/sys/dev/bwn/if_bwn.c Tue May 24 04:55:00 2016 (r300562) +++ head/sys/dev/bwn/if_bwn.c Tue May 24 04:58:58 2016 (r300563) @@ -1148,46 +1148,41 @@ bwn_attach_core(struct bwn_mac *mac) { struct bwn_softc *sc = mac->mac_sc; int error, have_bg = 0, have_a = 0; - uint32_t high; KASSERT(siba_get_revid(sc->sc_dev) >= 5, ("unsupported revision %d", siba_get_revid(sc->sc_dev))); - siba_powerup(sc->sc_dev, 0); + if (bwn_is_bus_siba(mac)) { + uint32_t high; - high = siba_read_4(sc->sc_dev, SIBA_TGSHIGH); + siba_powerup(sc->sc_dev, 0); + high = siba_read_4(sc->sc_dev, SIBA_TGSHIGH); + have_a = (high & BWN_TGSHIGH_HAVE_5GHZ) ? 1 : 0; + have_bg = (high & BWN_TGSHIGH_HAVE_2GHZ) ? 1 : 0; + if (high & BWN_TGSHIGH_DUALPHY) { + have_bg = 1; + have_a = 1; + } + } else { + device_printf(sc->sc_dev, "%s: not siba; bailing\n", __func__); + error = ENXIO; + goto fail; + } /* * Guess at whether it has A-PHY or G-PHY. * This is just used for resetting the core to probe things; * we will re-guess once it's all up and working. - * - * XXX TODO: there's the TGSHIGH DUALPHY flag based on - * the PHY revision. */ - bwn_reset_core(mac, !!(high & BWN_TGSHIGH_HAVE_2GHZ)); + bwn_reset_core(mac, have_bg); /* * Get the PHY version. */ - error = bwn_phy_getinfo(mac, high); + error = bwn_phy_getinfo(mac, have_bg); if (error) goto fail; - /* XXX TODO need bhnd */ - if (bwn_is_bus_siba(mac)) { - have_a = (high & BWN_TGSHIGH_HAVE_5GHZ) ? 1 : 0; - have_bg = (high & BWN_TGSHIGH_HAVE_2GHZ) ? 1 : 0; - if (high & BWN_TGSHIGH_DUALPHY) { - have_bg = 1; - have_a = 1; - } - } else { - device_printf(sc->sc_dev, "%s: not siba; bailing\n", __func__); - error = ENXIO; - goto fail; - } - #if 0 device_printf(sc->sc_dev, "%s: high=0x%08x, have_a=%d, have_bg=%d," " deviceid=0x%04x, siba_deviceid=0x%04x\n", @@ -1379,7 +1374,7 @@ bwn_reset_core(struct bwn_mac *mac, int } static int -bwn_phy_getinfo(struct bwn_mac *mac, int tgshigh) +bwn_phy_getinfo(struct bwn_mac *mac, int gmode) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_softc *sc = mac->mac_sc; @@ -1387,7 +1382,7 @@ bwn_phy_getinfo(struct bwn_mac *mac, int /* PHY */ tmp = BWN_READ_2(mac, BWN_PHYVER); - phy->gmode = !! (tgshigh & BWN_TGSHIGH_HAVE_2GHZ); + phy->gmode = gmode; phy->rf_on = 1; phy->analog = (tmp & BWN_PHYVER_ANALOG) >> 12; phy->type = (tmp & BWN_PHYVER_TYPE) >> 8;