summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2017-12-16 23:39:59 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2017-12-16 23:39:59 +0000
commit5b0108fd04996c40cccd9c11587cf34b89a5e1de (patch)
tree213eb3ea585ba43b25163c299d06b7a01443d017 /sys/dev/ic
parent8866d0b61a64763602d6483b5bef7f57ee4bf4fb (diff)
Implement setting the chip into active mode, as needed for setting up
the PCIe-based BCM43602's firmware in the PCI attachment driver.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/bwfm.c73
-rw-r--r--sys/dev/ic/bwfmvar.h4
2 files changed, 63 insertions, 14 deletions
diff --git a/sys/dev/ic/bwfm.c b/sys/dev/ic/bwfm.c
index 474e75c3730..7023976b139 100644
--- a/sys/dev/ic/bwfm.c
+++ b/sys/dev/ic/bwfm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bwfm.c,v 1.15 2017/12/16 23:32:56 patrick Exp $ */
+/* $OpenBSD: bwfm.c,v 1.16 2017/12/16 23:39:58 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
* Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se>
@@ -74,8 +74,11 @@ void bwfm_chip_ai_reset(struct bwfm_softc *, struct bwfm_core *,
void bwfm_chip_dmp_erom_scan(struct bwfm_softc *);
int bwfm_chip_dmp_get_regaddr(struct bwfm_softc *, uint32_t *,
uint32_t *, uint32_t *);
+int bwfm_chip_cr4_set_active(struct bwfm_softc *, uint32_t);
void bwfm_chip_cr4_set_passive(struct bwfm_softc *);
+int bwfm_chip_ca7_set_active(struct bwfm_softc *, uint32_t);
void bwfm_chip_ca7_set_passive(struct bwfm_softc *);
+int bwfm_chip_cm3_set_active(struct bwfm_softc *);
void bwfm_chip_cm3_set_passive(struct bwfm_softc *);
int bwfm_proto_bcdc_query_dcmd(struct bwfm_softc *, int,
@@ -562,21 +565,11 @@ bwfm_chip_attach(struct bwfm_softc *sc)
return 1;
}
- if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CR4) != NULL)
- bwfm_chip_cr4_set_passive(sc);
- if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CA7) != NULL)
- bwfm_chip_ca7_set_passive(sc);
- if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CM3) != NULL)
- bwfm_chip_cm3_set_passive(sc);
+ bwfm_chip_set_passive(sc);
if (sc->sc_buscore_ops->bc_reset) {
sc->sc_buscore_ops->bc_reset(sc);
- if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CR4) != NULL)
- bwfm_chip_cr4_set_passive(sc);
- if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CA7) != NULL)
- bwfm_chip_ca7_set_passive(sc);
- if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CM3) != NULL)
- bwfm_chip_cm3_set_passive(sc);
+ bwfm_chip_set_passive(sc);
}
/* TODO: get raminfo */
@@ -831,6 +824,48 @@ bwfm_chip_dmp_get_regaddr(struct bwfm_softc *sc, uint32_t *erom,
}
/* Core configuration */
+int
+bwfm_chip_set_active(struct bwfm_softc *sc, uint32_t rstvec)
+{
+ if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CR4) != NULL)
+ return bwfm_chip_cr4_set_active(sc, rstvec);
+ if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CA7) != NULL)
+ return bwfm_chip_ca7_set_active(sc, rstvec);
+ if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CM3) != NULL)
+ return bwfm_chip_cm3_set_active(sc);
+ return 1;
+}
+
+void
+bwfm_chip_set_passive(struct bwfm_softc *sc)
+{
+ if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CR4) != NULL) {
+ bwfm_chip_cr4_set_passive(sc);
+ return;
+ }
+ if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CA7) != NULL) {
+ bwfm_chip_ca7_set_passive(sc);
+ return;
+ }
+ if (bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CM3) != NULL) {
+ bwfm_chip_cm3_set_passive(sc);
+ return;
+ }
+}
+
+int
+bwfm_chip_cr4_set_active(struct bwfm_softc *sc, uint32_t rstvec)
+{
+ struct bwfm_core *core;
+
+ sc->sc_buscore_ops->bc_activate(sc, 0);
+ core = bwfm_chip_get_core(sc, BWFM_AGENT_CORE_ARM_CR4);
+ sc->sc_chip.ch_core_reset(sc, core,
+ BWFM_AGENT_IOCTL_ARMCR4_CPUHALT, 0, 0);
+
+ return 0;
+}
+
void
bwfm_chip_cr4_set_passive(struct bwfm_softc *sc)
{
@@ -844,12 +879,24 @@ bwfm_chip_cr4_set_passive(struct bwfm_softc *sc)
BWFM_AGENT_D11_IOCTL_PHYCLOCKEN);
}
+int
+bwfm_chip_ca7_set_active(struct bwfm_softc *sc, uint32_t rstvec)
+{
+ panic("%s: CA7 not supported", DEVNAME(sc));
+}
+
void
bwfm_chip_ca7_set_passive(struct bwfm_softc *sc)
{
panic("%s: CA7 not supported", DEVNAME(sc));
}
+int
+bwfm_chip_cm3_set_active(struct bwfm_softc *sc)
+{
+ panic("%s: cm3 not supported", DEVNAME(sc));
+}
+
void
bwfm_chip_cm3_set_passive(struct bwfm_softc *sc)
{
diff --git a/sys/dev/ic/bwfmvar.h b/sys/dev/ic/bwfmvar.h
index c7058a3be68..b2fd4126406 100644
--- a/sys/dev/ic/bwfmvar.h
+++ b/sys/dev/ic/bwfmvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bwfmvar.h,v 1.4 2017/12/16 23:29:48 patrick Exp $ */
+/* $OpenBSD: bwfmvar.h,v 1.5 2017/12/16 23:39:58 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
* Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se>
@@ -156,6 +156,8 @@ struct bwfm_softc {
void bwfm_attach(struct bwfm_softc *);
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 *);
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 *, char *, size_t);