Introduce bwn(4) support for the bhnd(4) bus.

Currently, bwn(4) relies on the siba_bwn(4) bus driver to provide support
for the on-chip SSB interconnect found in Broadcom's older PCI(e) Wi-Fi
adapters. Non-PCI Wi-Fi adapters, as well as the newer BCMA interconnect
found in post-2009 Broadcom Wi-Fi hardware, are not supported by
siba_bwn(4).

The bhnd(4) bus driver (also used by the FreeBSD/MIPS Broadcom port)
provides a unified kernel interface to a superset of the hardware supported
by siba_bwn; by attaching bwn(4) via bhnd(4), we can support both modern
PCI(e) Wi-Fi devices based on the BCMA backplane interconnect, as well as
Broadcom MIPS WiSoCs that include a D11 MAC core directly attached to their
SSB or BCMA backplane.

This diff introduces opt-in bwn(4) support for bhnd(4) by providing:

 - A small bwn(4) driver subclass, if_bwn_bhnd, that attaches via
   bhnd(4) instead of siba_bwn(4).
 - A bhndb(4)-based PCI host bridge driver, if_bwn_pci, that optionally
   probes at a higher priority than the siba_bwn(4) PCI driver.
 - A set of compatibility shims that perform translation of bwn(4)'s
   siba_bwn function calls into their bhnd(9) API equivalents when bwn(4)
   is attached via a bhnd(4) bus parent. When bwn(4) is attached via
   siba_bwn(4), all siba_bwn function calls are simply passed through to
   their original implementations.

To test bwn(4) with bhnd(4), place the following lines in loader.conf(5):

  hw.bwn_pci.preferred="1"

  if_bwn_pci_load="YES
  bwn_v4_ucode_load="YES"
  bwn_v4_lp_ucode_load="YES"

To verify that bwn(4) is using bhnd(4), you can check dmesg:

  bwn0: <Broadcom 802.11 MAC/PHY/Radio, rev 15> ... on bhnd0

... or devinfo(8):

pcib2
  pci2
    bwn_pci0
      bhndb0
        bhnd0
          bwn0
          ...

bwn(4)/bhnd(4) has been tested for regressions with most chipsets currently
supported by bwn(4), including:

  - BCM4312
  - BCM4318
  - BCM4321

With minimal changes to the DMA code (not included in this commit), I was
also able to test support for newer BCMA devices by bringing up basic
working Wi-Fi on two previously unsupported, BCMA-based N-PHY chipsets:

  - BCM43224
  - BCM43225

Approved by:	adrian (mentor, implicit)
Sponsored by:	The FreeBSD Foundation & Plausible Labs
Differential Revision:	https://reviews.freebsd.org/D13041
This commit is contained in:
Landon J. Fuller 2017-12-02 02:21:27 +00:00
parent 89c3a53299
commit 8d14ca9c99
25 changed files with 3592 additions and 366 deletions

View File

@ -1312,15 +1312,17 @@ dev/bwi/if_bwi_pci.c optional bwi pci
# XXX Work around clang warnings, until maintainer approves fix.
dev/bwn/if_bwn.c optional bwn siba_bwn \
compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}"
dev/bwn/if_bwn_pci.c optional bwn pci bhnd
dev/bwn/if_bwn_bhnd.c optional bwn bhnd
dev/bwn/if_bwn_pci.c optional bwn pci bhnd bhndb
dev/bwn/if_bwn_phy_common.c optional bwn siba_bwn
dev/bwn/if_bwn_phy_g.c optional bwn siba_bwn \
compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED} ${NO_WCONSTANT_CONVERSION}"
dev/bwn/if_bwn_phy_lp.c optional bwn siba_bwn \
compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}"
dev/bwn/if_bwn_phy_n.c optional bwn siba_bwn
dev/bwn/if_bwn_siba.c optional bwn siba_bwn
dev/bwn/if_bwn_siba_compat.c optional bwn bhnd !bwn_use_siba
dev/bwn/if_bwn_util.c optional bwn siba_bwn
dev/bwn/bwn_mac.c optional bwn bhnd
dev/cardbus/cardbus.c optional cardbus
dev/cardbus/cardbus_cis.c optional cardbus
dev/cardbus/cardbus_device.c optional cardbus

View File

@ -850,6 +850,7 @@ BWI_DEBUG_VERBOSE opt_bwi.h
# options for the Brodacom BCM43xx driver (bwn)
BWN_DEBUG opt_bwn.h
BWN_GPL_PHY opt_bwn.h
BWN_USE_SIBA opt_bwn.h
# Options for the SIBA driver
SIBA_DEBUG opt_siba.h

View File

@ -1,174 +0,0 @@
/*-
* Copyright (c) 2015 Landon Fuller <landon@landonf.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGES.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_bwn.h"
#include "opt_wlan.h"
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/systm.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
#include <dev/bhnd/bhnd.h>
#include <dev/bhnd/bhnd_ids.h>
#include "bhnd_nvram_map.h"
struct bwn_softc {
int mem_rid;
struct bhnd_resource *mem_res;
int intr_rid;
struct resource *intr_res;
};
static const struct bwn_device {
uint16_t vendor;
uint16_t device;
} bwn_devices[] = {
{ BHND_MFGID_BCM, BHND_COREID_D11 },
{ BHND_MFGID_INVALID, BHND_COREID_INVALID }
};
static int
bwn_probe(device_t dev)
{
const struct bwn_device *id;
for (id = bwn_devices; id->device != BHND_COREID_INVALID; id++)
{
if (bhnd_get_vendor(dev) == id->vendor &&
bhnd_get_device(dev) == id->device)
{
device_set_desc(dev, bhnd_get_device_name(dev));
return (BUS_PROBE_DEFAULT);
}
}
return (ENXIO);
}
static int
bwn_attach(device_t dev)
{
struct bwn_softc *sc;
int error;
sc = device_get_softc(dev);
/* Allocate device resources */
sc->mem_rid = 0;
sc->mem_res = bhnd_alloc_resource_any(dev, SYS_RES_MEMORY,
&sc->mem_rid, RF_ACTIVE);
if (sc->mem_res == NULL) {
device_printf(dev, "failed to allocate device registers\n");
error = ENXIO;
goto cleanup;
}
sc->intr_rid = 0;
sc->intr_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->intr_rid,
RF_ACTIVE|RF_SHAREABLE);
if (sc->intr_res == NULL) {
device_printf(dev, "failed to allocate device interrupt\n");
error = ENXIO;
goto cleanup;
}
// TODO
uint8_t macaddr[6];
error = bhnd_nvram_getvar_array(dev, BHND_NVAR_MACADDR, macaddr,
sizeof(macaddr), BHND_NVRAM_TYPE_UINT8_ARRAY);
if (error)
device_printf(dev, "error fetching macaddr: %d\n", error);
else
device_printf(dev, "got macaddr %6D\n", macaddr, ":");
return (0);
cleanup:
if (sc->mem_res != NULL)
bhnd_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid,
sc->mem_res);
if (sc->intr_res != NULL)
bus_release_resource(dev, SYS_RES_IRQ, sc->intr_rid,
sc->intr_res);
return (error);
}
static int
bwn_detach(device_t dev)
{
struct bwn_softc *sc;
sc = device_get_softc(dev);
bhnd_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem_res);
bus_release_resource(dev, SYS_RES_IRQ, sc->intr_rid, sc->intr_res);
return (0);
}
static int
bwn_suspend(device_t dev)
{
return (0);
}
static int
bwn_resume(device_t dev)
{
return (0);
}
static device_method_t bwn_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, bwn_probe),
DEVMETHOD(device_attach, bwn_attach),
DEVMETHOD(device_detach, bwn_detach),
DEVMETHOD(device_suspend, bwn_suspend),
DEVMETHOD(device_resume, bwn_resume),
DEVMETHOD_END
};
static devclass_t bwn_devclass;
DEFINE_CLASS_0(bwn, bwn_driver, bwn_methods, sizeof(struct bwn_softc));
DRIVER_MODULE(bwn_mac, bhnd, bwn_driver, bwn_devclass, 0, 0);
MODULE_DEPEND(bwn_mac, bhnd, 1, 1, 1);
MODULE_VERSION(bwn_mac, 1);

View File

@ -67,9 +67,6 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/siba/siba_ids.h>
#include <dev/siba/sibareg.h>
#include <dev/siba/sibavar.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>
@ -77,6 +74,8 @@ __FBSDID("$FreeBSD$");
#include <net80211/ieee80211_phy.h>
#include <net80211/ieee80211_ratectl.h>
#include <dev/bwn/if_bwn_siba.h>
#include <dev/bwn/if_bwnreg.h>
#include <dev/bwn/if_bwnvar.h>
@ -498,10 +497,30 @@ static const struct siba_devid bwn_devs[] = {
SIBA_DEV(BROADCOM, 80211, 16, "Revision 16")
};
static const struct bwn_bus_ops *
bwn_get_bus_ops(device_t dev)
{
#if BWN_USE_SIBA
return (NULL);
#else
devclass_t bus_cls;
bus_cls = device_get_devclass(device_get_parent(dev));
if (bus_cls == devclass_find("bhnd"))
return (&bwn_bhnd_bus_ops);
else
return (&bwn_siba_bus_ops);
#endif
}
static int
bwn_probe(device_t dev)
{
int i;
struct bwn_softc *sc;
int i;
sc = device_get_softc(dev);
sc->sc_bus_ops = bwn_get_bus_ops(dev);
for (i = 0; i < nitems(bwn_devs); i++) {
if (siba_get_vendor(dev) == bwn_devs[i].sd_vendor &&
@ -513,7 +532,7 @@ bwn_probe(device_t dev)
return (ENXIO);
}
static int
int
bwn_attach(device_t dev)
{
struct bwn_mac *mac;
@ -525,6 +544,13 @@ bwn_attach(device_t dev)
sc->sc_debug = bwn_debug;
#endif
sc->sc_bus_ops = bwn_get_bus_ops(dev);
if ((error = BWN_BUS_OPS_ATTACH(dev))) {
device_printf(sc->sc_dev,
"bus-specific initialization failed (%d)\n", error);
return (error);
}
if ((sc->sc_flags & BWN_FLAG_ATTACHED) == 0) {
bwn_attach_pre(sc);
bwn_sprom_bugfixes(dev);
@ -631,6 +657,7 @@ bwn_attach(device_t dev)
if (msic == BWN_MSI_MESSAGES && bwn_msi_disable == 0)
pci_release_msi(dev);
fail0:
BWN_BUS_OPS_DETACH(dev);
free(mac, M_DEVBUF);
return (error);
}
@ -716,7 +743,7 @@ bwn_phy_detach(struct bwn_mac *mac)
mac->mac_phy.detach(mac);
}
static int
int
bwn_detach(device_t dev)
{
struct bwn_softc *sc = device_get_softc(dev);
@ -756,6 +783,7 @@ bwn_detach(device_t dev)
mbufq_drain(&sc->sc_snd);
bwn_release_firmware(mac);
BWN_LOCK_DESTROY(sc);
BWN_BUS_OPS_DETACH(dev);
return (0);
}
@ -1153,37 +1181,31 @@ 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)));
if (bwn_is_bus_siba(mac)) {
uint32_t high;
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;
}
#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",
__func__,
high,
have_a,
have_bg,
siba_get_pci_device(sc->sc_dev),
siba_get_chipid(sc->sc_dev));
#endif
} else {
device_printf(sc->sc_dev, "%s: not siba; bailing\n", __func__);
error = ENXIO;
goto fail;
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;
}
#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",
__func__,
high,
have_a,
have_bg,
siba_get_pci_device(sc->sc_dev),
siba_get_chipid(sc->sc_dev));
#endif
/*
* Guess at whether it has A-PHY or G-PHY.
* This is just used for resetting the core to probe things;
@ -1339,8 +1361,6 @@ bwn_attach_core(struct bwn_mac *mac)
/*
* Reset - SIBA.
*
* XXX TODO: implement BCMA version!
*/
void
bwn_reset_core(struct bwn_mac *mac, int g_mode)
@ -2267,7 +2287,6 @@ bwn_chip_init(struct bwn_mac *mac)
bwn_mac_phy_clock_set(mac, true);
/* SIBA powerup */
/* XXX TODO: BCMA powerup */
BWN_WRITE_2(mac, BWN_POWERUP_DELAY, siba_get_cc_powerdelay(sc->sc_dev));
return (error);
}
@ -4717,10 +4736,10 @@ bwn_rf_turnoff(struct bwn_mac *mac)
}
/*
* SSB PHY reset.
* PHY reset.
*/
static void
bwn_phy_reset_siba(struct bwn_mac *mac)
bwn_phy_reset(struct bwn_mac *mac)
{
struct bwn_softc *sc = mac->mac_sc;
@ -4733,17 +4752,6 @@ bwn_phy_reset_siba(struct bwn_mac *mac)
DELAY(1000);
}
static void
bwn_phy_reset(struct bwn_mac *mac)
{
if (bwn_is_bus_siba(mac)) {
bwn_phy_reset_siba(mac);
} else {
BWN_ERRPRINTF(mac->mac_sc, "%s: unknown bus!\n", __func__);
}
}
static int
bwn_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
{
@ -7471,7 +7479,7 @@ static device_method_t bwn_methods[] = {
DEVMETHOD(device_resume, bwn_resume),
DEVMETHOD_END
};
static driver_t bwn_driver = {
driver_t bwn_driver = {
"bwn",
bwn_methods,
sizeof(struct bwn_softc)
@ -7479,6 +7487,7 @@ static driver_t bwn_driver = {
static devclass_t bwn_devclass;
DRIVER_MODULE(bwn, siba_bwn, bwn_driver, bwn_devclass, 0, 0);
MODULE_DEPEND(bwn, siba_bwn, 1, 1, 1);
MODULE_DEPEND(bwn, gpiobus, 1, 1, 1);
MODULE_DEPEND(bwn, wlan, 1, 1, 1); /* 802.11 media layer */
MODULE_DEPEND(bwn, firmware, 1, 1, 1); /* firmware support */
MODULE_DEPEND(bwn, wlan_amrr, 1, 1, 1);

107
sys/dev/bwn/if_bwn_bhnd.c Normal file
View File

@ -0,0 +1,107 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2016 Landon Fuller <landonf@FreeBSD.org>
* Copyright (c) 2017 The FreeBSD Foundation
* All rights reserved.
*
* Portions of this software were developed by Landon Fuller
* under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_bwn.h"
#include "opt_wlan.h"
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/systm.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_llc.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>
#include <net80211/ieee80211_regdomain.h>
#include <net80211/ieee80211_phy.h>
#include <net80211/ieee80211_ratectl.h>
#include <dev/bhnd/bhnd.h>
#include <dev/bhnd/bhnd_ids.h>
#include "if_bwnvar.h"
/* Supported device identifiers */
static const struct bhnd_device bwn_devices[] = {
{{
BHND_MATCH_CORE (BHND_MFGID_BCM, BHND_COREID_D11),
BHND_MATCH_CORE_REV (HWREV_RANGE(5, 16))
}},
BHND_DEVICE_END
};
static int
bwn_bhnd_probe(device_t dev)
{
const struct bhnd_device *id;
id = bhnd_device_lookup(dev, bwn_devices, sizeof(bwn_devices[0]));
if (id == NULL)
return (ENXIO);
bhnd_set_default_core_desc(dev);
return (BUS_PROBE_DEFAULT);
}
static device_method_t bwn_bhnd_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, bwn_bhnd_probe),
DEVMETHOD_END
};
static devclass_t bwn_devclass;
DEFINE_CLASS_1(bwn, bwn_bhnd_driver, bwn_bhnd_methods, sizeof(struct bwn_softc),
bwn_driver);
DRIVER_MODULE(bwn_bhnd, bhnd, bwn_bhnd_driver, bwn_devclass, 0, 0);
MODULE_DEPEND(bwn_bhnd, bhnd, 1, 1, 1);
MODULE_VERSION(bwn_bhnd, 1);

View File

@ -1,4 +1,6 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2015-2016 Landon Fuller <landonf@FreeBSD.org>
* All rights reserved.
*
@ -6,25 +8,22 @@
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGES.
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
@ -61,17 +60,8 @@ TUNABLE_INT("hw.bwn_pci.preferred", &prefer_new_driver);
/* SIBA Devices */
static const struct bwn_pci_device siba_devices[] = {
BWN_BCM_DEV(BCM4301, "BCM4301 802.11b",
BWN_QUIRK_ENET_HW_UNPOPULATED),
BWN_BCM_DEV(BCM4306, "BCM4306 802.11b/g", 0),
BWN_BCM_DEV(BCM4306_D11G, "BCM4306 802.11g", 0),
BWN_BCM_DEV(BCM4306_D11A, "BCM4306 802.11a",
BWN_QUIRK_WLAN_DUALCORE),
BWN_BCM_DEV(BCM4306_D11DUAL, "BCM4306 802.11a/b",
BWN_QUIRK_WLAN_DUALCORE),
BWN_BCM_DEV(BCM4306_D11G_ID2, "BCM4306 802.11g", 0),
BWN_BCM_DEV(BCM4307, "BCM4307 802.11b", 0),
BWN_BCM_DEV(BCM4311_D11G, "BCM4311 802.11b/g", 0),
@ -88,7 +78,7 @@ static const struct bwn_pci_device siba_devices[] = {
BWN_QUIRK_USBH_UNPOPULATED),
BWN_BCM_DEV(BCM4321_D11N2G, "BCM4321 802.11n 2GHz",
BWN_QUIRK_USBH_UNPOPULATED),
BWN_BCM_DEV(BCM4321_D11N2G, "BCM4321 802.11n 5GHz",
BWN_BCM_DEV(BCM4321_D11N5G, "BCM4321 802.11n 5GHz",
BWN_QUIRK_UNTESTED|BWN_QUIRK_USBH_UNPOPULATED),
BWN_BCM_DEV(BCM4322_D11N, "BCM4322 802.11n Dual-Band", 0),
@ -107,6 +97,7 @@ static const struct bwn_pci_device bcma_devices[] = {
BWN_BCM_DEV(BCM4331_D11N, "BCM4331 802.11n Dual-Band", 0),
BWN_BCM_DEV(BCM4331_D11N2G, "BCM4331 802.11n 2GHz", 0),
BWN_BCM_DEV(BCM4331_D11N5G, "BCM4331 802.11n 5GHz", 0),
BWN_BCM_DEV(BCM43224_D11N, "BCM43224 802.11n Dual-Band", 0),
BWN_BCM_DEV(BCM43225_D11N2G, "BCM43225 802.11n 2GHz", 0),
{ 0, 0, NULL, 0}
@ -210,7 +201,12 @@ bwn_pci_attach(device_t dev)
static int
bwn_pci_detach(device_t dev)
{
return (bus_generic_detach(dev));
int error;
if ((error = bus_generic_detach(dev)))
return (error);
return (device_delete_children(dev));
}
static void
@ -297,11 +293,14 @@ static device_method_t bwn_pci_methods[] = {
static devclass_t bwn_pci_devclass;
DEFINE_CLASS_0(bwn_pci, bwn_pci_driver, bwn_pci_methods, sizeof(struct bwn_pci_softc));
DRIVER_MODULE(bwn_pci, pci, bwn_pci_driver, bwn_pci_devclass, NULL, NULL);
DEFINE_CLASS_0(bwn_pci, bwn_pci_driver, bwn_pci_methods,
sizeof(struct bwn_pci_softc));
DRIVER_MODULE_ORDERED(bwn_pci, pci, bwn_pci_driver, bwn_pci_devclass, NULL,
NULL, SI_ORDER_ANY);
DRIVER_MODULE(bhndb, bwn_pci, bhndb_pci_driver, bhndb_devclass, NULL, NULL);
MODULE_DEPEND(bwn_pci, bwn, 1, 1, 1);
MODULE_DEPEND(bwn_pci, bhnd, 1, 1, 1);
MODULE_DEPEND(bwn_pci, bhndb, 1, 1, 1);
MODULE_DEPEND(bwn_pci, bhndb_pci, 1, 1, 1);
MODULE_DEPEND(bwn_pci, bcma_bhndb, 1, 1, 1);

View File

@ -1,4 +1,6 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2015-2016 Landon Fuller <landonf@FreeBSD.org>
* All rights reserved.
*
@ -6,25 +8,22 @@
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
* redistribution must be conditioned upon including a substantially
* similar Disclaimer requirement for further binary redistribution.
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGES.
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/

View File

@ -66,9 +66,6 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/siba/siba_ids.h>
#include <dev/siba/sibareg.h>
#include <dev/siba/sibavar.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>
@ -76,6 +73,8 @@ __FBSDID("$FreeBSD$");
#include <net80211/ieee80211_phy.h>
#include <net80211/ieee80211_ratectl.h>
#include <dev/bwn/if_bwn_siba.h>
#include <dev/bwn/if_bwnreg.h>
#include <dev/bwn/if_bwnvar.h>
@ -149,17 +148,12 @@ bwn_phy_force_clock(struct bwn_mac *mac, int force)
/* XXX Only for N, HT and AC PHYs */
/* XXX bhnd bus */
if (bwn_is_bus_siba(mac)) {
tmp = siba_read_4(sc->sc_dev, SIBA_TGSLOW);
if (force)
tmp |= SIBA_TGSLOW_FGC;
else
tmp &= ~SIBA_TGSLOW_FGC;
siba_write_4(sc->sc_dev, SIBA_TGSLOW, tmp);
} else {
BWN_ERRPRINTF(sc, "%s: unknown bus!\n", __func__);
}
tmp = siba_read_4(sc->sc_dev, SIBA_TGSLOW);
if (force)
tmp |= SIBA_TGSLOW_FGC;
else
tmp &= ~SIBA_TGSLOW_FGC;
siba_write_4(sc->sc_dev, SIBA_TGSLOW, tmp);
}
int
@ -184,17 +178,12 @@ bwn_mac_phy_clock_set(struct bwn_mac *mac, int enabled)
struct bwn_softc *sc = mac->mac_sc;
uint32_t val;
/* XXX bhnd bus */
if (bwn_is_bus_siba(mac)) {
val = siba_read_4(sc->sc_dev, SIBA_TGSLOW);
if (enabled)
val |= BWN_TGSLOW_MACPHYCLKEN;
else
val &= ~BWN_TGSLOW_MACPHYCLKEN;
siba_write_4(sc->sc_dev, SIBA_TGSLOW, val);
} else {
BWN_ERRPRINTF(sc, "%s: unknown bus!\n", __func__);
}
val = siba_read_4(sc->sc_dev, SIBA_TGSLOW);
if (enabled)
val |= BWN_TGSLOW_MACPHYCLKEN;
else
val &= ~BWN_TGSLOW_MACPHYCLKEN;
siba_write_4(sc->sc_dev, SIBA_TGSLOW, val);
}
/* http://bcm-v4.sipsolutions.net/802.11/PHY/BmacCorePllReset */
@ -203,13 +192,8 @@ bwn_wireless_core_phy_pll_reset(struct bwn_mac *mac)
{
struct bwn_softc *sc = mac->mac_sc;
/* XXX bhnd bus */
if (bwn_is_bus_siba(mac)) {
siba_cc_write32(sc->sc_dev, SIBA_CC_CHIPCTL_ADDR, 0);
siba_cc_mask32(sc->sc_dev, SIBA_CC_CHIPCTL_DATA, ~0x4);
siba_cc_set32(sc->sc_dev, SIBA_CC_CHIPCTL_DATA, 0x4);
siba_cc_mask32(sc->sc_dev, SIBA_CC_CHIPCTL_DATA, ~0x4);
} else {
BWN_ERRPRINTF(sc, "%s: unknown bus!\n", __func__);
}
siba_cc_write32(sc->sc_dev, SIBA_CC_CHIPCTL_ADDR, 0);
siba_cc_mask32(sc->sc_dev, SIBA_CC_CHIPCTL_DATA, ~0x4);
siba_cc_set32(sc->sc_dev, SIBA_CC_CHIPCTL_DATA, 0x4);
siba_cc_mask32(sc->sc_dev, SIBA_CC_CHIPCTL_DATA, ~0x4);
}

View File

@ -65,9 +65,6 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/siba/siba_ids.h>
#include <dev/siba/sibareg.h>
#include <dev/siba/sibavar.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>
@ -75,6 +72,8 @@ __FBSDID("$FreeBSD$");
#include <net80211/ieee80211_phy.h>
#include <net80211/ieee80211_ratectl.h>
#include <dev/bwn/if_bwn_siba.h>
#include <dev/bwn/if_bwnreg.h>
#include <dev/bwn/if_bwnvar.h>

View File

@ -65,9 +65,6 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/siba/siba_ids.h>
#include <dev/siba/sibareg.h>
#include <dev/siba/sibavar.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>
@ -75,6 +72,8 @@ __FBSDID("$FreeBSD$");
#include <net80211/ieee80211_phy.h>
#include <net80211/ieee80211_ratectl.h>
#include <dev/bwn/if_bwn_siba.h>
#include <dev/bwn/if_bwnreg.h>
#include <dev/bwn/if_bwnvar.h>

View File

@ -65,9 +65,6 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/siba/siba_ids.h>
#include <dev/siba/sibareg.h>
#include <dev/siba/sibavar.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>
@ -75,6 +72,8 @@ __FBSDID("$FreeBSD$");
#include <net80211/ieee80211_phy.h>
#include <net80211/ieee80211_ratectl.h>
#include <dev/bwn/if_bwn_siba.h>
#include <dev/bwn/if_bwnreg.h>
#include <dev/bwn/if_bwnvar.h>

171
sys/dev/bwn/if_bwn_siba.c Normal file
View File

@ -0,0 +1,171 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2016 Landon Fuller <landonf@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/systm.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#define BWN_USE_SIBA 1
#include "if_bwn_siba.h"
/** Legacy siba(4) bus operations */
static int
bwn_siba_bus_ops_init(device_t dev)
{
return (0);
}
static void
bwn_siba_bus_ops_fini(device_t dev)
{
}
const struct bwn_bus_ops bwn_siba_bus_ops = {
.init = bwn_siba_bus_ops_init,
.fini = bwn_siba_bus_ops_fini,
.pci_find_cap = pci_find_cap,
.pci_alloc_msi = pci_alloc_msi,
.pci_release_msi = pci_release_msi,
.pci_msi_count = pci_msi_count,
.get_vendor = siba_get_vendor,
.get_device = siba_get_device,
.get_revid = siba_get_revid,
.get_pci_vendor = siba_get_pci_vendor,
.get_pci_device = siba_get_pci_device,
.get_pci_subvendor = siba_get_pci_subvendor,
.get_pci_subdevice = siba_get_pci_subdevice,
.get_pci_revid = siba_get_pci_revid,
.get_chipid = siba_get_chipid,
.get_chiprev = siba_get_chiprev,
.get_chippkg = siba_get_chippkg,
.get_type = siba_get_type,
.get_cc_pmufreq = siba_get_cc_pmufreq,
.get_cc_caps = siba_get_cc_caps,
.get_cc_powerdelay = siba_get_cc_powerdelay,
.get_pcicore_revid = siba_get_pcicore_revid,
.sprom_get_rev = siba_sprom_get_rev,
.sprom_get_mac_80211bg = siba_sprom_get_mac_80211bg,
.sprom_get_mac_80211a = siba_sprom_get_mac_80211a,
.sprom_get_brev = siba_sprom_get_brev,
.sprom_get_ccode = siba_sprom_get_ccode,
.sprom_get_ant_a = siba_sprom_get_ant_a,
.sprom_get_ant_bg = siba_sprom_get_ant_bg,
.sprom_get_pa0b0 = siba_sprom_get_pa0b0,
.sprom_get_pa0b1 = siba_sprom_get_pa0b1,
.sprom_get_pa0b2 = siba_sprom_get_pa0b2,
.sprom_get_gpio0 = siba_sprom_get_gpio0,
.sprom_get_gpio1 = siba_sprom_get_gpio1,
.sprom_get_gpio2 = siba_sprom_get_gpio2,
.sprom_get_gpio3 = siba_sprom_get_gpio3,
.sprom_get_maxpwr_bg = siba_sprom_get_maxpwr_bg,
.sprom_set_maxpwr_bg = siba_sprom_set_maxpwr_bg,
.sprom_get_rxpo2g = siba_sprom_get_rxpo2g,
.sprom_get_rxpo5g = siba_sprom_get_rxpo5g,
.sprom_get_tssi_bg = siba_sprom_get_tssi_bg,
.sprom_get_tri2g = siba_sprom_get_tri2g,
.sprom_get_tri5gl = siba_sprom_get_tri5gl,
.sprom_get_tri5g = siba_sprom_get_tri5g,
.sprom_get_tri5gh = siba_sprom_get_tri5gh,
.sprom_get_rssisav2g = siba_sprom_get_rssisav2g,
.sprom_get_rssismc2g = siba_sprom_get_rssismc2g,
.sprom_get_rssismf2g = siba_sprom_get_rssismf2g,
.sprom_get_bxa2g = siba_sprom_get_bxa2g,
.sprom_get_rssisav5g = siba_sprom_get_rssisav5g,
.sprom_get_rssismc5g = siba_sprom_get_rssismc5g,
.sprom_get_rssismf5g = siba_sprom_get_rssismf5g,
.sprom_get_bxa5g = siba_sprom_get_bxa5g,
.sprom_get_cck2gpo = siba_sprom_get_cck2gpo,
.sprom_get_ofdm2gpo = siba_sprom_get_ofdm2gpo,
.sprom_get_ofdm5glpo = siba_sprom_get_ofdm5glpo,
.sprom_get_ofdm5gpo = siba_sprom_get_ofdm5gpo,
.sprom_get_ofdm5ghpo = siba_sprom_get_ofdm5ghpo,
.sprom_get_bf_lo = siba_sprom_get_bf_lo,
.sprom_set_bf_lo = siba_sprom_set_bf_lo,
.sprom_get_bf_hi = siba_sprom_get_bf_hi,
.sprom_get_bf2_lo = siba_sprom_get_bf2_lo,
.sprom_get_bf2_hi = siba_sprom_get_bf2_hi,
.sprom_get_fem_2ghz_tssipos = siba_sprom_get_fem_2ghz_tssipos,
.sprom_get_fem_2ghz_extpa_gain = siba_sprom_get_fem_2ghz_extpa_gain,
.sprom_get_fem_2ghz_pdet_range = siba_sprom_get_fem_2ghz_pdet_range,
.sprom_get_fem_2ghz_tr_iso = siba_sprom_get_fem_2ghz_tr_iso,
.sprom_get_fem_2ghz_antswlut = siba_sprom_get_fem_2ghz_antswlut,
.sprom_get_fem_5ghz_extpa_gain = siba_sprom_get_fem_5ghz_extpa_gain,
.sprom_get_fem_5ghz_pdet_range = siba_sprom_get_fem_5ghz_pdet_range,
.sprom_get_fem_5ghz_antswlut = siba_sprom_get_fem_5ghz_antswlut,
.sprom_get_txpid_2g_0 = siba_sprom_get_txpid_2g_0,
.sprom_get_txpid_2g_1 = siba_sprom_get_txpid_2g_1,
.sprom_get_txpid_5gl_0 = siba_sprom_get_txpid_5gl_0,
.sprom_get_txpid_5gl_1 = siba_sprom_get_txpid_5gl_1,
.sprom_get_txpid_5g_0 = siba_sprom_get_txpid_5g_0,
.sprom_get_txpid_5g_1 = siba_sprom_get_txpid_5g_1,
.sprom_get_txpid_5gh_0 = siba_sprom_get_txpid_5gh_0,
.sprom_get_txpid_5gh_1 = siba_sprom_get_txpid_5gh_1,
.sprom_get_stbcpo = siba_sprom_get_stbcpo,
.sprom_get_cddpo = siba_sprom_get_cddpo,
.powerup = siba_powerup,
.powerdown = siba_powerdown,
.read_2 = siba_read_2,
.write_2 = siba_write_2,
.read_4 = siba_read_4,
.write_4 = siba_write_4,
.dev_up = siba_dev_up,
.dev_down = siba_dev_down,
.dev_isup = siba_dev_isup,
.pcicore_intr = siba_pcicore_intr,
.dma_translation = siba_dma_translation,
.read_multi_2 = siba_read_multi_2,
.read_multi_4 = siba_read_multi_4,
.write_multi_2 = siba_write_multi_2,
.write_multi_4 = siba_write_multi_4,
.barrier = siba_barrier,
.cc_pmu_set_ldovolt = siba_cc_pmu_set_ldovolt,
.cc_pmu_set_ldoparef = siba_cc_pmu_set_ldoparef,
.gpio_set = siba_gpio_set,
.gpio_get = siba_gpio_get,
.fix_imcfglobug = siba_fix_imcfglobug,
.sprom_get_core_power_info = siba_sprom_get_core_power_info,
.sprom_get_mcs2gpo = siba_sprom_get_mcs2gpo,
.sprom_get_mcs5glpo = siba_sprom_get_mcs5glpo,
.sprom_get_mcs5gpo = siba_sprom_get_mcs5gpo,
.sprom_get_mcs5ghpo = siba_sprom_get_mcs5ghpo,
.pmu_spuravoid_pllupdate = siba_pmu_spuravoid_pllupdate,
.cc_set32 = siba_cc_set32,
.cc_mask32 = siba_cc_mask32,
.cc_write32 = siba_cc_write32,
};

491
sys/dev/bwn/if_bwn_siba.h Normal file
View File

@ -0,0 +1,491 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2016 Landon J. Fuller <landonf@FreeBSD.org>.
* Copyright (c) 2007 Bruce M. Simpson.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _IF_BWN_SIBA_H_
#define _IF_BWN_SIBA_H_
/** If true, expose legacy siba_pci headers directly. Otherwise,
* we expose our siba/bhnd compatibility shims. */
#ifndef BWN_USE_SIBA
#define BWN_USE_SIBA 0
#endif
struct bwn_softc;
struct siba_sprom_core_pwr_info;
/*
* Legacy siba(4) bus API compatibility shims.
*/
struct bwn_bus_ops {
/* bus-specific initialization/finalization */
int (*init)(device_t);
void (*fini)(device_t);
/* compatibility shims */
int (*pci_find_cap)(device_t, int, int *);
int (*pci_alloc_msi)(device_t, int *);
int (*pci_release_msi)(device_t);
int (*pci_msi_count)(device_t);
uint16_t (*get_vendor)(device_t);
uint16_t (*get_device)(device_t);
uint8_t (*get_revid)(device_t);
uint16_t (*get_pci_vendor)(device_t);
uint16_t (*get_pci_device)(device_t);
uint16_t (*get_pci_subvendor)(device_t);
uint16_t (*get_pci_subdevice)(device_t);
uint8_t (*get_pci_revid)(device_t);
uint16_t (*get_chipid)(device_t);
uint16_t (*get_chiprev)(device_t);
uint8_t (*get_chippkg)(device_t);
enum siba_type (*get_type)(device_t);
uint32_t (*get_cc_pmufreq)(device_t);
uint32_t (*get_cc_caps)(device_t);
uint16_t (*get_cc_powerdelay)(device_t);
uint8_t (*get_pcicore_revid)(device_t);
uint8_t (*sprom_get_rev)(device_t);
uint8_t *(*sprom_get_mac_80211bg)(device_t);
uint8_t *(*sprom_get_mac_80211a)(device_t);
uint8_t (*sprom_get_brev)(device_t);
uint8_t (*sprom_get_ccode)(device_t);
uint8_t (*sprom_get_ant_a)(device_t);
uint8_t (*sprom_get_ant_bg)(device_t);
uint16_t (*sprom_get_pa0b0)(device_t);
uint16_t (*sprom_get_pa0b1)(device_t);
uint16_t (*sprom_get_pa0b2)(device_t);
uint8_t (*sprom_get_gpio0)(device_t);
uint8_t (*sprom_get_gpio1)(device_t);
uint8_t (*sprom_get_gpio2)(device_t);
uint8_t (*sprom_get_gpio3)(device_t);
uint16_t (*sprom_get_maxpwr_bg)(device_t);
void (*sprom_set_maxpwr_bg)(device_t, uint16_t);
uint8_t (*sprom_get_rxpo2g)(device_t);
uint8_t (*sprom_get_rxpo5g)(device_t);
uint8_t (*sprom_get_tssi_bg)(device_t);
uint8_t (*sprom_get_tri2g)(device_t);
uint8_t (*sprom_get_tri5gl)(device_t);
uint8_t (*sprom_get_tri5g)(device_t);
uint8_t (*sprom_get_tri5gh)(device_t);
uint8_t (*sprom_get_rssisav2g)(device_t);
uint8_t (*sprom_get_rssismc2g)(device_t);
uint8_t (*sprom_get_rssismf2g)(device_t);
uint8_t (*sprom_get_bxa2g)(device_t);
uint8_t (*sprom_get_rssisav5g)(device_t);
uint8_t (*sprom_get_rssismc5g)(device_t);
uint8_t (*sprom_get_rssismf5g)(device_t);
uint8_t (*sprom_get_bxa5g)(device_t);
uint16_t (*sprom_get_cck2gpo)(device_t);
uint32_t (*sprom_get_ofdm2gpo)(device_t);
uint32_t (*sprom_get_ofdm5glpo)(device_t);
uint32_t (*sprom_get_ofdm5gpo)(device_t);
uint32_t (*sprom_get_ofdm5ghpo)(device_t);
uint16_t (*sprom_get_bf_lo)(device_t);
void (*sprom_set_bf_lo)(device_t, uint16_t);
uint16_t (*sprom_get_bf_hi)(device_t);
uint16_t (*sprom_get_bf2_lo)(device_t);
uint16_t (*sprom_get_bf2_hi)(device_t);
uint8_t (*sprom_get_fem_2ghz_tssipos)(device_t);
uint8_t (*sprom_get_fem_2ghz_extpa_gain)(device_t);
uint8_t (*sprom_get_fem_2ghz_pdet_range)(device_t);
uint8_t (*sprom_get_fem_2ghz_tr_iso)(device_t);
uint8_t (*sprom_get_fem_2ghz_antswlut)(device_t);
uint8_t (*sprom_get_fem_5ghz_extpa_gain)(device_t);
uint8_t (*sprom_get_fem_5ghz_pdet_range)(device_t);
uint8_t (*sprom_get_fem_5ghz_antswlut)(device_t);
uint8_t (*sprom_get_txpid_2g_0)(device_t);
uint8_t (*sprom_get_txpid_2g_1)(device_t);
uint8_t (*sprom_get_txpid_5gl_0)(device_t);
uint8_t (*sprom_get_txpid_5gl_1)(device_t);
uint8_t (*sprom_get_txpid_5g_0)(device_t);
uint8_t (*sprom_get_txpid_5g_1)(device_t);
uint8_t (*sprom_get_txpid_5gh_0)(device_t);
uint8_t (*sprom_get_txpid_5gh_1)(device_t);
uint16_t (*sprom_get_stbcpo)(device_t);
uint16_t (*sprom_get_cddpo)(device_t);
void (*powerup)(device_t, int);
int (*powerdown)(device_t);
uint16_t (*read_2)(device_t, uint16_t);
void (*write_2)(device_t, uint16_t, uint16_t);
uint32_t (*read_4)(device_t, uint16_t);
void (*write_4)(device_t, uint16_t, uint32_t);
void (*dev_up)(device_t, uint32_t);
void (*dev_down)(device_t, uint32_t);
int (*dev_isup)(device_t);
void (*pcicore_intr)(device_t);
uint32_t (*dma_translation)(device_t);
void (*read_multi_2)(device_t, void *, size_t, uint16_t);
void (*read_multi_4)(device_t, void *, size_t, uint16_t);
void (*write_multi_2)(device_t, const void *, size_t, uint16_t);
void (*write_multi_4)(device_t, const void *, size_t, uint16_t);
void (*barrier)(device_t, int);
void (*cc_pmu_set_ldovolt)(device_t, int, uint32_t);
void (*cc_pmu_set_ldoparef)(device_t, uint8_t);
void (*gpio_set)(device_t, uint32_t);
uint32_t (*gpio_get)(device_t);
void (*fix_imcfglobug)(device_t);
int (*sprom_get_core_power_info)(device_t, int, struct siba_sprom_core_pwr_info *);
int (*sprom_get_mcs2gpo)(device_t, uint16_t *);
int (*sprom_get_mcs5glpo)(device_t, uint16_t *);
int (*sprom_get_mcs5gpo)(device_t, uint16_t *);
int (*sprom_get_mcs5ghpo)(device_t, uint16_t *);
void (*pmu_spuravoid_pllupdate)(device_t, int);
void (*cc_set32)(device_t, uint32_t, uint32_t);
void (*cc_mask32)(device_t, uint32_t, uint32_t);
void (*cc_write32)(device_t, uint32_t, uint32_t);
};
#if BWN_USE_SIBA
#include <dev/siba/siba_ids.h>
#include <dev/siba/sibareg.h>
#include <dev/siba/sibavar.h>
#define BWN_BUS_OPS_ATTACH(_dev) (0)
#define BWN_BUS_OPS_DETACH(_dev)
#else /* !BWN_USE_SIBA */
struct bwn_bus_ops;
extern const struct bwn_bus_ops bwn_siba_bus_ops;
extern const struct bwn_bus_ops bwn_bhnd_bus_ops;
/*
* Declared in:
* /usr/home/landonf/Documents/Code/FreeBSD/svn/head/sys/dev/siba/siba_ids.h
*/
struct siba_devid {
uint16_t sd_vendor;
uint16_t sd_device;
uint8_t sd_rev;
char *sd_desc;
};
#define SIBA_DEV(_vendor, _cid, _rev, _msg) \
{ SIBA_VID_##_vendor, SIBA_DEVID_##_cid, _rev, _msg }
#define SIBA_DEVID_80211 0x812
#define SIBA_VID_BROADCOM 0x4243
/*
* Declared in:
* /usr/home/landonf/Documents/Code/FreeBSD/svn/head/sys/dev/siba/sibareg.h
*/
#define SIBA_CC_CAPS_PMU 0x10000000
#define SIBA_CC_CHIPCTL 0x0028
#define SIBA_CC_CHIPCTL_ADDR 0x0650
#define SIBA_CC_CHIPCTL_DATA 0x0654
#define SIBA_DMA_TRANSLATION_MASK 0xc0000000
#define SIBA_TGSLOW 0x0f98
#define SIBA_TGSLOW_FGC 0x00020000
#define SIBA_TGSHIGH 0x0f9c
#define SIBA_TGSHIGH_DMA64 0x10000000
#define SIBA_BOARDVENDOR_DELL 0x1028
#define SIBA_BOARDVENDOR_BCM 0x14e4
#define SIBA_BOARD_BCM4309G 0x0421
#define SIBA_BOARD_BU4306 0x0416
#define SIBA_BOARD_BCM4321 0x046d
#define SIBA_CHIPPACK_BCM4712S 1
/*
* Declared in:
* /usr/home/landonf/Documents/Code/FreeBSD/svn/head/sys/dev/siba/sibavar.h
*/
enum siba_type {
SIBA_TYPE_SSB /* unused */,
SIBA_TYPE_PCI,
SIBA_TYPE_PCMCIA
};
/* TODO: need a real country code table */
enum {
SIBA_CCODE_JAPAN,
SIBA_CCODE_UNKNOWN
};
struct siba_sprom_core_pwr_info {
uint8_t itssi_2g;
uint8_t itssi_5g;
uint8_t maxpwr_2g;
uint8_t maxpwr_5gl;
uint8_t maxpwr_5g;
uint8_t maxpwr_5gh;
int16_t pa_2g[3];
int16_t pa_5gl[4];
int16_t pa_5g[4];
int16_t pa_5gh[4];
};
#define SIBA_LDO_PAREF 0
#define BWN_BUS_OPS_SC(_sc) \
((_sc)->sc_bus_ops)
#define BWN_BUS_OPS(_dev) \
BWN_BUS_OPS_SC((struct bwn_softc *)device_get_softc(_dev))
#define BWN_BUS_OPS_ATTACH(_dev) \
BWN_BUS_OPS(_dev)->init(_dev)
#define BWN_BUS_OPS_DETACH(_dev) \
BWN_BUS_OPS(_dev)->fini(_dev)
#define pci_find_cap(_dev, capability, capreg) \
BWN_BUS_OPS(_dev)->pci_find_cap(_dev, capability, capreg)
#define pci_alloc_msi(_dev, count) \
BWN_BUS_OPS(_dev)->pci_alloc_msi(_dev, count)
#define pci_release_msi(_dev) \
BWN_BUS_OPS(_dev)->pci_release_msi(_dev)
#define pci_msi_count(_dev) \
BWN_BUS_OPS(_dev)->pci_msi_count(_dev)
#define siba_get_vendor(_dev) \
BWN_BUS_OPS(_dev)->get_vendor(_dev)
#define siba_get_device(_dev) \
BWN_BUS_OPS(_dev)->get_device(_dev)
#define siba_get_revid(_dev) \
BWN_BUS_OPS(_dev)->get_revid(_dev)
#define siba_get_pci_vendor(_dev) \
BWN_BUS_OPS(_dev)->get_pci_vendor(_dev)
#define siba_get_pci_device(_dev) \
BWN_BUS_OPS(_dev)->get_pci_device(_dev)
#define siba_get_pci_subvendor(_dev) \
BWN_BUS_OPS(_dev)->get_pci_subvendor(_dev)
#define siba_get_pci_subdevice(_dev) \
BWN_BUS_OPS(_dev)->get_pci_subdevice(_dev)
#define siba_get_pci_revid(_dev) \
BWN_BUS_OPS(_dev)->get_pci_revid(_dev)
#define siba_get_chipid(_dev) \
BWN_BUS_OPS(_dev)->get_chipid(_dev)
#define siba_get_chiprev(_dev) \
BWN_BUS_OPS(_dev)->get_chiprev(_dev)
#define siba_get_chippkg(_dev) \
BWN_BUS_OPS(_dev)->get_chippkg(_dev)
#define siba_get_type(_dev) \
BWN_BUS_OPS(_dev)->get_type(_dev)
#define siba_get_cc_pmufreq(_dev) \
BWN_BUS_OPS(_dev)->get_cc_pmufreq(_dev)
#define siba_get_cc_caps(_dev) \
BWN_BUS_OPS(_dev)->get_cc_caps(_dev)
#define siba_get_cc_powerdelay(_dev) \
BWN_BUS_OPS(_dev)->get_cc_powerdelay(_dev)
#define siba_get_pcicore_revid(_dev) \
BWN_BUS_OPS(_dev)->get_pcicore_revid(_dev)
#define siba_sprom_get_rev(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_rev(_dev)
#define siba_sprom_get_mac_80211bg(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_mac_80211bg(_dev)
#define siba_sprom_get_mac_80211a(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_mac_80211a(_dev)
#define siba_sprom_get_brev(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_brev(_dev)
#define siba_sprom_get_ccode(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_ccode(_dev)
#define siba_sprom_get_ant_a(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_ant_a(_dev)
#define siba_sprom_get_ant_bg(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_ant_bg(_dev)
#define siba_sprom_get_pa0b0(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_pa0b0(_dev)
#define siba_sprom_get_pa0b1(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_pa0b1(_dev)
#define siba_sprom_get_pa0b2(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_pa0b2(_dev)
#define siba_sprom_get_gpio0(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_gpio0(_dev)
#define siba_sprom_get_gpio1(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_gpio1(_dev)
#define siba_sprom_get_gpio2(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_gpio2(_dev)
#define siba_sprom_get_gpio3(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_gpio3(_dev)
#define siba_sprom_get_maxpwr_bg(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_maxpwr_bg(_dev)
#define siba_sprom_set_maxpwr_bg(_dev, t) \
BWN_BUS_OPS(_dev)->sprom_set_maxpwr_bg(_dev, t)
#define siba_sprom_get_rxpo2g(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_rxpo2g(_dev)
#define siba_sprom_get_rxpo5g(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_rxpo5g(_dev)
#define siba_sprom_get_tssi_bg(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_tssi_bg(_dev)
#define siba_sprom_get_tri2g(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_tri2g(_dev)
#define siba_sprom_get_tri5gl(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_tri5gl(_dev)
#define siba_sprom_get_tri5g(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_tri5g(_dev)
#define siba_sprom_get_tri5gh(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_tri5gh(_dev)
#define siba_sprom_get_rssisav2g(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_rssisav2g(_dev)
#define siba_sprom_get_rssismc2g(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_rssismc2g(_dev)
#define siba_sprom_get_rssismf2g(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_rssismf2g(_dev)
#define siba_sprom_get_bxa2g(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_bxa2g(_dev)
#define siba_sprom_get_rssisav5g(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_rssisav5g(_dev)
#define siba_sprom_get_rssismc5g(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_rssismc5g(_dev)
#define siba_sprom_get_rssismf5g(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_rssismf5g(_dev)
#define siba_sprom_get_bxa5g(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_bxa5g(_dev)
#define siba_sprom_get_cck2gpo(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_cck2gpo(_dev)
#define siba_sprom_get_ofdm2gpo(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_ofdm2gpo(_dev)
#define siba_sprom_get_ofdm5glpo(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_ofdm5glpo(_dev)
#define siba_sprom_get_ofdm5gpo(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_ofdm5gpo(_dev)
#define siba_sprom_get_ofdm5ghpo(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_ofdm5ghpo(_dev)
#define siba_sprom_get_bf_lo(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_bf_lo(_dev)
#define siba_sprom_set_bf_lo(_dev, t) \
BWN_BUS_OPS(_dev)->sprom_set_bf_lo(_dev, t)
#define siba_sprom_get_bf_hi(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_bf_hi(_dev)
#define siba_sprom_get_bf2_lo(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_bf2_lo(_dev)
#define siba_sprom_get_bf2_hi(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_bf2_hi(_dev)
#define siba_sprom_get_fem_2ghz_tssipos(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_fem_2ghz_tssipos(_dev)
#define siba_sprom_get_fem_2ghz_extpa_gain(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_fem_2ghz_extpa_gain(_dev)
#define siba_sprom_get_fem_2ghz_pdet_range(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_fem_2ghz_pdet_range(_dev)
#define siba_sprom_get_fem_2ghz_tr_iso(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_fem_2ghz_tr_iso(_dev)
#define siba_sprom_get_fem_2ghz_antswlut(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_fem_2ghz_antswlut(_dev)
#define siba_sprom_get_fem_5ghz_extpa_gain(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_fem_5ghz_extpa_gain(_dev)
#define siba_sprom_get_fem_5ghz_pdet_range(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_fem_5ghz_pdet_range(_dev)
#define siba_sprom_get_fem_5ghz_antswlut(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_fem_5ghz_antswlut(_dev)
#define siba_sprom_get_txpid_2g_0(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_txpid_2g_0(_dev)
#define siba_sprom_get_txpid_2g_1(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_txpid_2g_1(_dev)
#define siba_sprom_get_txpid_5gl_0(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_txpid_5gl_0(_dev)
#define siba_sprom_get_txpid_5gl_1(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_txpid_5gl_1(_dev)
#define siba_sprom_get_txpid_5g_0(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_txpid_5g_0(_dev)
#define siba_sprom_get_txpid_5g_1(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_txpid_5g_1(_dev)
#define siba_sprom_get_txpid_5gh_0(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_txpid_5gh_0(_dev)
#define siba_sprom_get_txpid_5gh_1(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_txpid_5gh_1(_dev)
#define siba_sprom_get_stbcpo(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_stbcpo(_dev)
#define siba_sprom_get_cddpo(_dev) \
BWN_BUS_OPS(_dev)->sprom_get_cddpo(_dev)
#define siba_powerup(_dev, _arg1) \
BWN_BUS_OPS(_dev)->powerup(_dev, _arg1)
#define siba_powerdown(_dev) \
BWN_BUS_OPS(_dev)->powerdown(_dev)
#define siba_read_2(_dev, _arg1) \
BWN_BUS_OPS(_dev)->read_2(_dev, _arg1)
#define siba_write_2(_dev, _arg1, _arg2) \
BWN_BUS_OPS(_dev)->write_2(_dev, _arg1, _arg2)
#define siba_read_4(_dev, _arg1) \
BWN_BUS_OPS(_dev)->read_4(_dev, _arg1)
#define siba_write_4(_dev, _arg1, _arg2) \
BWN_BUS_OPS(_dev)->write_4(_dev, _arg1, _arg2)
#define siba_dev_up(_dev, _arg1) \
BWN_BUS_OPS(_dev)->dev_up(_dev, _arg1)
#define siba_dev_down(_dev, _arg1) \
BWN_BUS_OPS(_dev)->dev_down(_dev, _arg1)
#define siba_dev_isup(_dev) \
BWN_BUS_OPS(_dev)->dev_isup(_dev)
#define siba_pcicore_intr(_dev) \
BWN_BUS_OPS(_dev)->pcicore_intr(_dev)
#define siba_dma_translation(_dev) \
BWN_BUS_OPS(_dev)->dma_translation(_dev)
#define siba_read_multi_2(_dev, _arg1, _arg2, _arg3) \
BWN_BUS_OPS(_dev)->read_multi_2(_dev, _arg1, _arg2, _arg3)
#define siba_read_multi_4(_dev, _arg1, _arg2, _arg3) \
BWN_BUS_OPS(_dev)->read_multi_4(_dev, _arg1, _arg2, _arg3)
#define siba_write_multi_2(_dev, _arg1, _arg2, _arg3) \
BWN_BUS_OPS(_dev)->write_multi_2(_dev, _arg1, _arg2, _arg3)
#define siba_write_multi_4(_dev, _arg1, _arg2, _arg3) \
BWN_BUS_OPS(_dev)->write_multi_4(_dev, _arg1, _arg2, _arg3)
#define siba_barrier(_dev, _arg1) \
BWN_BUS_OPS(_dev)->barrier(_dev, _arg1)
#define siba_cc_pmu_set_ldovolt(_dev, _arg1, _arg2) \
BWN_BUS_OPS(_dev)->cc_pmu_set_ldovolt(_dev, _arg1, _arg2)
#define siba_cc_pmu_set_ldoparef(_dev, _arg1) \
BWN_BUS_OPS(_dev)->cc_pmu_set_ldoparef(_dev, _arg1)
#define siba_gpio_set(_dev, _arg1) \
BWN_BUS_OPS(_dev)->gpio_set(_dev, _arg1)
#define siba_gpio_get(_dev) \
BWN_BUS_OPS(_dev)->gpio_get(_dev)
#define siba_fix_imcfglobug(_dev) \
BWN_BUS_OPS(_dev)->fix_imcfglobug(_dev)
#define siba_sprom_get_core_power_info(_dev, _arg1, _arg2) \
BWN_BUS_OPS(_dev)->sprom_get_core_power_info(_dev, _arg1, _arg2)
#define siba_sprom_get_mcs2gpo(_dev, _arg1) \
BWN_BUS_OPS(_dev)->sprom_get_mcs2gpo(_dev, _arg1)
#define siba_sprom_get_mcs5glpo(_dev, _arg1) \
BWN_BUS_OPS(_dev)->sprom_get_mcs5glpo(_dev, _arg1)
#define siba_sprom_get_mcs5gpo(_dev, _arg1) \
BWN_BUS_OPS(_dev)->sprom_get_mcs5gpo(_dev, _arg1)
#define siba_sprom_get_mcs5ghpo(_dev, _arg1) \
BWN_BUS_OPS(_dev)->sprom_get_mcs5ghpo(_dev, _arg1)
#define siba_pmu_spuravoid_pllupdate(_dev, _arg1) \
BWN_BUS_OPS(_dev)->pmu_spuravoid_pllupdate(_dev, _arg1)
#define siba_cc_set32(_dev, _arg1, _arg2) \
BWN_BUS_OPS(_dev)->cc_set32(_dev, _arg1, _arg2)
#define siba_cc_mask32(_dev, _arg1, _arg2) \
BWN_BUS_OPS(_dev)->cc_mask32(_dev, _arg1, _arg2)
#define siba_cc_write32(_dev, _arg1, _arg2) \
BWN_BUS_OPS(_dev)->cc_write32(_dev, _arg1, _arg2)
#endif /* BWN_USE_SIBA */
#endif /* _IF_BWN_SIBA_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,102 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2016 Landon J. Fuller <landonf@FreeBSD.org>.
* Copyright (c) 2017 The FreeBSD Foundation
* All rights reserved.
*
* Portions of this software were developed by Landon Fuller
* under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _IF_BWN_SIBA_COMPAT_H_
#define _IF_BWN_SIBA_COMPAT_H_
#define BWN_USE_SIBA 0
#include "if_bwn_siba.h"
#include "if_bwnvar.h"
#define BWN_BHND_NUM_CORE_PWR 4
/**
* Compatiblity shim state.
*/
struct bwn_bhnd_ctx {
device_t chipc_dev; /**< ChipCommon device */
device_t gpio_dev; /**< GPIO device */
device_t pmu_dev; /**< PMU device, or NULL if no PMU */
uint32_t pmu_cctl_addr; /**< chipctrl_addr target of
reads/writes to/from the
chipctrl_data register */
uint8_t sromrev; /**< SROM format revision */
/* NVRAM variables for which bwn(4) expects the bus to manage storage
* for (and in some cases, allow writes). */
uint8_t mac_80211bg[6]; /**< D11 unit 0 */
uint8_t mac_80211a[6]; /**< D11 unit 1 */
uint32_t boardflags; /**< boardflags (bwn-writable) */
uint8_t pa0maxpwr; /**< 2GHz max power (bwn-writable) */
};
/**
* Return the bwn(4) device's bhnd compatiblity context.
*/
static inline struct bwn_bhnd_ctx *
bwn_bhnd_get_ctx(device_t dev)
{
struct bwn_softc *sc = device_get_softc(dev);
return (sc->sc_bus_ctx);
}
/**
* Fetch an NVRAM variable via bhnd_nvram_getvar_*().
*/
#define BWN_BHND_NVRAM_FETCH_VAR(_dev, _type, _name, _result) \
do { \
int error; \
\
error = bhnd_nvram_getvar_ ## _type(_dev, _name, _result); \
if (error) { \
panic("NVRAM variable %s unreadable: %d", _name, \
error); \
} \
} while(0)
/**
* Fetch and return an NVRAM variable via bhnd_nvram_getvar_*().
*/
#define BWN_BHND_NVRAM_RETURN_VAR(_dev, _type, _name) \
do { \
_type ## _t value; \
BWN_BHND_NVRAM_FETCH_VAR(_dev, _type, _name, &value); \
return (value); \
} while(0)
#endif /* _IF_BWN_SIBA_COMPAT_H_ */

View File

@ -65,9 +65,6 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/siba/siba_ids.h>
#include <dev/siba/sibareg.h>
#include <dev/siba/sibavar.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>
@ -75,6 +72,8 @@ __FBSDID("$FreeBSD$");
#include <net80211/ieee80211_phy.h>
#include <net80211/ieee80211_ratectl.h>
#include <dev/bwn/if_bwn_siba.h>
#include <dev/bwn/if_bwnreg.h>
#include <dev/bwn/if_bwnvar.h>

View File

@ -34,10 +34,16 @@
#ifndef _IF_BWNVAR_H
#define _IF_BWNVAR_H
struct siba_dev_softc;
#include "if_bwn_siba.h"
struct bwn_softc;
struct bwn_mac;
extern driver_t bwn_driver;
int bwn_attach(device_t dev);
int bwn_detach(device_t dev);
#define N(a) (sizeof(a) / sizeof(a[0]))
#define BWN_ALIGN 0x1000
#define BWN_BUS_SPACE_MAXADDR_30BIT 0x3fffffff
@ -1005,6 +1011,12 @@ struct bwn_vap {
struct bwn_softc {
device_t sc_dev;
const struct bwn_bus_ops *sc_bus_ops;
#if !BWN_USE_SIBA
void *sc_bus_ctx;
struct bhnd_resource *sc_mem_res;
int sc_mem_rid;
#endif /* !BWN_USE_SIBA */
struct mtx sc_mtx;
struct ieee80211com sc_ic;
struct mbufq sc_snd;
@ -1152,14 +1164,4 @@ bwn_get_chan_power(struct bwn_mac *mac, struct ieee80211_channel *c)
return c->ic_maxpower / 2;
}
/*
* For now there's no bhnd bus support. Places where it matters
* should call this routine so we can start logging things.
*/
static inline int
bwn_is_bus_siba(struct bwn_mac *mac)
{
return 1;
}
#endif /* !_IF_BWNVAR_H */

View File

@ -62,9 +62,6 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/siba/siba_ids.h>
#include <dev/siba/sibareg.h>
#include <dev/siba/sibavar.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>
@ -6138,10 +6135,7 @@ static void bwn_nphy_superswitch_init(struct bwn_mac *mac, bool init)
BWN_PHY_WRITE(mac, BWN_NPHY_GPIO_LOOEN, 0);
BWN_PHY_WRITE(mac, BWN_NPHY_GPIO_HIOEN, 0);
/* XXX handle bhnd bus */
if (bwn_is_bus_siba(mac)) {
siba_gpio_set(sc->sc_dev, 0xfc00);
}
siba_gpio_set(sc->sc_dev, 0xfc00);
BWN_WRITE_SETMASK4(mac, BWN_MACCTL, ~BWN_MACCTL_GPOUT_MASK, 0);
BWN_WRITE_SETMASK2(mac, BWN_GPIO_MASK, ~0, 0xFC00);
@ -6175,10 +6169,7 @@ static int bwn_phy_initn(struct bwn_mac *mac)
if ((mac->mac_phy.rev >= 3) &&
(siba_sprom_get_bf_lo(sc->sc_dev) & BWN_BFL_EXTLNA) &&
(bwn_current_band(mac) == BWN_BAND_2G)) {
/* XXX bhnd bus */
if (bwn_is_bus_siba(mac)) {
siba_cc_set32(sc->sc_dev, SIBA_CC_CHIPCTL, 0x40);
}
siba_cc_set32(sc->sc_dev, SIBA_CC_CHIPCTL, 0x40);
}
nphy->use_int_tx_iq_lo_cal = bwn_nphy_ipa(mac) ||
phy->rev >= 7 ||
@ -6380,11 +6371,8 @@ static void bwn_nphy_pmu_spur_avoid(struct bwn_mac *mac, bool avoid)
{
struct bwn_softc *sc = mac->mac_sc;
/* XXX bhnd */
if (bwn_is_bus_siba(mac)) {
DPRINTF(sc, BWN_DEBUG_RESET, "%s: spuravoid %d\n", __func__, avoid);
siba_pmu_spuravoid_pllupdate(sc->sc_dev, avoid);
}
DPRINTF(sc, BWN_DEBUG_RESET, "%s: spuravoid %d\n", __func__, avoid);
siba_pmu_spuravoid_pllupdate(sc->sc_dev, avoid);
}
/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ChanspecSetup */
@ -6635,8 +6623,7 @@ bwn_nphy_op_prepare_structs(struct bwn_mac *mac)
if (mac->mac_phy.rev >= 2 &&
(siba_sprom_get_bf2_lo(sc->sc_dev) & BWN_BFL2_TXPWRCTRL_EN)) {
nphy->txpwrctrl = true;
if (bwn_is_bus_siba(mac) &&
(siba_get_type(sc->sc_dev) == SIBA_TYPE_PCI)) {
if (siba_get_type(sc->sc_dev) == SIBA_TYPE_PCI) {
if ((siba_get_pci_device(sc->sc_dev) == 0x4328) ||
(siba_get_pci_device(sc->sc_dev) == 0x432a))
nphy->pwg_gain_5ghz = true;

View File

@ -60,9 +60,6 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/siba/siba_ids.h>
#include <dev/siba/sibareg.h>
#include <dev/siba/sibavar.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>

View File

@ -61,9 +61,6 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/siba/siba_ids.h>
#include <dev/siba/sibareg.h>
#include <dev/siba/sibavar.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>

View File

@ -61,9 +61,6 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/siba/siba_ids.h>
#include <dev/siba/sibareg.h>
#include <dev/siba/sibavar.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>

View File

@ -62,9 +62,6 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/siba/siba_ids.h>
#include <dev/siba/sibareg.h>
#include <dev/siba/sibavar.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>

View File

@ -62,9 +62,6 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/siba/siba_ids.h>
#include <dev/siba/sibareg.h>
#include <dev/siba/sibavar.h>
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>

View File

@ -4,6 +4,7 @@
KMOD= if_bwn
SRCS= if_bwn.c if_bwnreg.h if_bwnvar.h
SRCS+= if_bwn_siba.c if_bwn_bhnd.c if_bwn_siba_compat.c
SRCS+= if_bwn_util.c
# PHY
@ -11,8 +12,15 @@ SRCS+= if_bwn_phy_common.c
SRCS+= if_bwn_phy_g.c if_bwn_phy_lp.c
SRCS+= if_bwn_phy_n.c
# BHND
SRCS+= bhnd_bus_if.h \
bhnd_chipc_if.h \
bhnd_pmu_if.h \
bhnd_pwrctl_if.h
SRCS+= bhnd_nvram_map.h
# Other
SRCS+= device_if.h bus_if.h pci_if.h opt_bwn.h opt_wlan.h
SRCS+= device_if.h bus_if.h gpio_if.h pci_if.h opt_bwn.h opt_wlan.h
# The following need the BWN_GPL_PHY kenrel option to opt-in
# to the GPL'd 802.11n PHY support for this driver.

View File

@ -3,9 +3,10 @@
.PATH: ${SRCTOP}/sys/dev/bwn
KMOD= if_bwn_pci
SRCS= if_bwn_pci.c bwn_mac.c
SRCS= if_bwn_pci.c
SRCS+= bhnd_bus_if.h bhndb_bus_if.h \
bhndb_if.h bhnd_nvram_map.h
bhndb_if.h
SRCS+= device_if.h bus_if.h pci_if.h \
opt_bwn.h opt_wlan.h opt_global.h