-/* $OpenBSD: if_bwfm_pci.c,v 1.63 2021/12/27 17:32:14 patrick Exp $ */
+/* $OpenBSD: if_bwfm_pci.c,v 1.64 2021/12/27 17:56:03 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
* Copyright (c) 2017 Patrick Wildt <patrick@blueri.se>
int sc_tx_pkts_full;
uint8_t sc_mbdata_done;
+ uint8_t sc_pcireg64;
};
struct bwfm_pci_dmamem {
bwfm_pci_ring_bell(struct bwfm_pci_softc *sc,
struct bwfm_pci_msgring *ring)
{
- struct bwfm_softc *bwfm = (void *)sc;
-
- if (bwfm->sc_chip.ch_chip == BRCM_CC_4378_CHIP_ID)
+ if (sc->sc_pcireg64)
bus_space_write_4(sc->sc_reg_iot, sc->sc_reg_ioh,
BWFM_PCI_64_PCIE2REG_H2D_MAILBOX_0, 1);
else
BWFM_PCI_PCIE2REG_CONFIGDATA, reg);
}
}
+ if (core->co_rev >= 64)
+ sc->sc_pcireg64 = 1;
reg = bwfm_pci_intr_status(sc);
if (reg != 0xffffffff)
bwfm_pci_intr(void *v)
{
struct bwfm_pci_softc *sc = (void *)v;
- struct bwfm_softc *bwfm = (void *)sc;
struct ifnet *ifp = &sc->sc_sc.sc_ic.ic_if;
struct mbuf_list ml = MBUF_LIST_INITIALIZER();
uint32_t status, mask;
status = bwfm_pci_intr_status(sc);
/* FIXME: interrupt status seems to be zero? */
- if (status == 0 && bwfm->sc_chip.ch_chip == BRCM_CC_4378_CHIP_ID)
+ if (status == 0 && sc->sc_pcireg64)
status |= BWFM_PCI_64_PCIE2REG_MAILBOXMASK_INT_D2H_DB;
if (status == 0)
return 0;
bwfm_pci_intr_disable(sc);
bwfm_pci_intr_ack(sc, status);
- if (bwfm->sc_chip.ch_chip != BRCM_CC_4378_CHIP_ID &&
+ if (!sc->sc_pcireg64 &&
(status & (BWFM_PCI_PCIE2REG_MAILBOXMASK_INT_FN0_0 |
BWFM_PCI_PCIE2REG_MAILBOXMASK_INT_FN0_1)))
bwfm_pci_handle_mb_data(sc);
mask = BWFM_PCI_PCIE2REG_MAILBOXMASK_INT_D2H_DB;
- if (bwfm->sc_chip.ch_chip == BRCM_CC_4378_CHIP_ID)
+ if (sc->sc_pcireg64)
mask = BWFM_PCI_64_PCIE2REG_MAILBOXMASK_INT_D2H_DB;
if (status & mask) {
void
bwfm_pci_intr_enable(struct bwfm_pci_softc *sc)
{
- struct bwfm_softc *bwfm = (void *)sc;
-
- if (bwfm->sc_chip.ch_chip == BRCM_CC_4378_CHIP_ID)
+ if (sc->sc_pcireg64)
bus_space_write_4(sc->sc_reg_iot, sc->sc_reg_ioh,
BWFM_PCI_64_PCIE2REG_MAILBOXMASK,
BWFM_PCI_64_PCIE2REG_MAILBOXMASK_INT_D2H_DB);
void
bwfm_pci_intr_disable(struct bwfm_pci_softc *sc)
{
- struct bwfm_softc *bwfm = (void *)sc;
-
- if (bwfm->sc_chip.ch_chip == BRCM_CC_4378_CHIP_ID)
+ if (sc->sc_pcireg64)
bus_space_write_4(sc->sc_reg_iot, sc->sc_reg_ioh,
BWFM_PCI_64_PCIE2REG_MAILBOXMASK, 0);
else
uint32_t
bwfm_pci_intr_status(struct bwfm_pci_softc *sc)
{
- struct bwfm_softc *bwfm = (void *)sc;
-
- if (bwfm->sc_chip.ch_chip == BRCM_CC_4378_CHIP_ID)
+ if (sc->sc_pcireg64)
return bus_space_read_4(sc->sc_reg_iot, sc->sc_reg_ioh,
BWFM_PCI_64_PCIE2REG_MAILBOXINT);
else
void
bwfm_pci_intr_ack(struct bwfm_pci_softc *sc, uint32_t status)
{
- struct bwfm_softc *bwfm = (void *)sc;
-
- if (bwfm->sc_chip.ch_chip == BRCM_CC_4378_CHIP_ID)
+ if (sc->sc_pcireg64)
bus_space_write_4(sc->sc_reg_iot, sc->sc_reg_ioh,
BWFM_PCI_64_PCIE2REG_MAILBOXINT, status);
else
uint32_t
bwfm_pci_intmask(struct bwfm_pci_softc *sc)
{
- struct bwfm_softc *bwfm = (void *)sc;
-
- if (bwfm->sc_chip.ch_chip == BRCM_CC_4378_CHIP_ID)
+ if (sc->sc_pcireg64)
return bus_space_read_4(sc->sc_reg_iot, sc->sc_reg_ioh,
BWFM_PCI_64_PCIE2REG_INTMASK);
else
void
bwfm_pci_hostready(struct bwfm_pci_softc *sc)
{
- struct bwfm_softc *bwfm = (void *)sc;
-
if ((sc->sc_shared_flags & BWFM_SHARED_INFO_HOSTRDY_DB1) == 0)
return;
- if (bwfm->sc_chip.ch_chip == BRCM_CC_4378_CHIP_ID)
+ if (sc->sc_pcireg64)
bus_space_write_4(sc->sc_reg_iot, sc->sc_reg_ioh,
BWFM_PCI_64_PCIE2REG_H2D_MAILBOX_1, 1);
else