summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/bwfm.c45
-rw-r--r--sys/dev/ic/bwfmreg.h12
-rw-r--r--sys/dev/ic/bwfmvar.h3
3 files changed, 57 insertions, 3 deletions
diff --git a/sys/dev/ic/bwfm.c b/sys/dev/ic/bwfm.c
index 0c7b7e371b3..8a52b3aa90d 100644
--- a/sys/dev/ic/bwfm.c
+++ b/sys/dev/ic/bwfm.c
@@ -1,4 +1,4 @@
-/* $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>
@@ -1025,6 +1025,49 @@ bwfm_chip_cm3_set_passive(struct bwfm_softc *sc)
}
}
+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)
diff --git a/sys/dev/ic/bwfmreg.h b/sys/dev/ic/bwfmreg.h
index f0ee714712f..3f04fe81a58 100644
--- a/sys/dev/ic/bwfmreg.h
+++ b/sys/dev/ic/bwfmreg.h
@@ -1,4 +1,4 @@
-/* $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>
@@ -51,12 +51,22 @@
#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
diff --git a/sys/dev/ic/bwfmvar.h b/sys/dev/ic/bwfmvar.h
index 55669bb2b26..6ac4bd24a54 100644
--- a/sys/dev/ic/bwfmvar.h
+++ b/sys/dev/ic/bwfmvar.h
@@ -1,4 +1,4 @@
-/* $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>
@@ -164,6 +164,7 @@ int bwfm_detach(struct bwfm_softc *, int);
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 *);