-/* $OpenBSD: bwfm.c,v 1.36 2018/02/06 02:23:04 patrick Exp $ */
+/* $OpenBSD: bwfm.c,v 1.37 2018/02/07 21:36:34 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
* Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se>
}
}
+int
+bwfm_chip_sr_capable(struct bwfm_softc *sc)
+{
+ struct bwfm_core *core;
+ uint32_t reg;
+
+ if (sc->sc_chip.ch_pmurev < 17)
+ return 0;
+
+ core = bwfm_chip_get_core(sc, BWFM_AGENT_CORE_CHIPCOMMON);
+ switch (sc->sc_chip.ch_chip) {
+ case BRCM_CC_4354_CHIP_ID:
+ case BRCM_CC_4356_CHIP_ID:
+ sc->sc_buscore_ops->bc_write(sc, core->co_base +
+ BWFM_CHIP_REG_CHIPCONTROL_ADDR, 3);
+ reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+ BWFM_CHIP_REG_CHIPCONTROL_DATA);
+ return (reg & (1 << 2)) != 0;
+ case BRCM_CC_43241_CHIP_ID:
+ case BRCM_CC_4335_CHIP_ID:
+ case BRCM_CC_4339_CHIP_ID:
+ sc->sc_buscore_ops->bc_write(sc, core->co_base +
+ BWFM_CHIP_REG_CHIPCONTROL_ADDR, 3);
+ reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+ BWFM_CHIP_REG_CHIPCONTROL_DATA);
+ return reg != 0;
+ case BRCM_CC_43430_CHIP_ID:
+ reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+ BWFM_CHIP_REG_SR_CONTROL1);
+ return reg != 0;
+ default:
+ reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+ BWFM_CHIP_REG_PMUCAPABILITIES_EXT);
+ if ((reg & BWFM_CHIP_REG_PMUCAPABILITIES_SR_SUPP) == 0)
+ return 0;
+
+ reg = sc->sc_buscore_ops->bc_read(sc, core->co_base +
+ BWFM_CHIP_REG_RETENTION_CTL);
+ return (reg & (BWFM_CHIP_REG_RETENTION_CTL_MACPHY_DIS |
+ BWFM_CHIP_REG_RETENTION_CTL_LOGIC_DIS)) == 0;
+ }
+}
+
/* RAM size helpers */
void
bwfm_chip_socram_ramsize(struct bwfm_softc *sc, struct bwfm_core *core)
-/* $OpenBSD: bwfmreg.h,v 1.14 2018/01/11 19:33:34 patrick Exp $ */
+/* $OpenBSD: bwfmreg.h,v 1.15 2018/02/07 21:36:34 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
* Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se>
#define BWFM_CHIP_REG_CAPABILITIES_EXT_AOB_PRESENT 0x00000040
#define BWFM_CHIP_REG_WATCHDOG 0x00000080
#define BWFM_CHIP_REG_EROMPTR 0x000000FC
+#define BWFM_CHIP_REG_SR_CAPABILITY 0x00000500
+#define BWFM_CHIP_REG_SR_CONTROL0 0x00000504
+#define BWFM_CHIP_REG_SR_CONTROL1 0x00000508
#define BWFM_CHIP_REG_PMUCONTROL 0x00000600
#define BWFM_CHIP_REG_PMUCONTROL_RES_MASK 0x00006000
#define BWFM_CHIP_REG_PMUCONTROL_RES_SHIFT 13
#define BWFM_CHIP_REG_PMUCONTROL_RES_RELOAD 0x2
#define BWFM_CHIP_REG_PMUCAPABILITIES 0x00000604
#define BWFM_CHIP_REG_PMUCAPABILITIES_REV_MASK 0x000000ff
+#define BWFM_CHIP_REG_PMUCAPABILITIES_EXT 0x0000064C
+#define BWFM_CHIP_REG_PMUCAPABILITIES_SR_SUPP (1 << 1)
+#define BWFM_CHIP_REG_CHIPCONTROL_ADDR 0x00000650
+#define BWFM_CHIP_REG_CHIPCONTROL_DATA 0x00000654
+#define BWFM_CHIP_REG_RETENTION_CTL 0x00000670
+#define BWFM_CHIP_REG_RETENTION_CTL_MACPHY_DIS (1 << 26)
+#define BWFM_CHIP_REG_RETENTION_CTL_LOGIC_DIS (1 << 27)
/* Agent registers */
#define BWFM_AGENT_IOCTL 0x0408
-/* $OpenBSD: bwfmvar.h,v 1.9 2018/02/05 10:30:04 patrick Exp $ */
+/* $OpenBSD: bwfmvar.h,v 1.10 2018/02/07 21:36:34 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
* Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se>
int bwfm_chip_attach(struct bwfm_softc *);
int bwfm_chip_set_active(struct bwfm_softc *, uint32_t);
void bwfm_chip_set_passive(struct bwfm_softc *);
+int bwfm_chip_sr_capable(struct bwfm_softc *);
struct bwfm_core *bwfm_chip_get_core(struct bwfm_softc *, int);
struct bwfm_core *bwfm_chip_get_pmu(struct bwfm_softc *);
void bwfm_rx(struct bwfm_softc *, struct mbuf *);