summaryrefslogtreecommitdiff
path: root/sys/dev/pci/if_qwx_pci.c
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2024-01-11 09:52:20 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2024-01-11 09:52:20 +0000
commit66d8e4611e7b7782c6bd968b072223990078dd54 (patch)
tree2f65ee87af9b84ce08913cb954e6a3225f1cec25 /sys/dev/pci/if_qwx_pci.c
parenta49492db20a57f346e63bbeb862761e015d2f77b (diff)
handle MHI M1->M2 state transitions in qwx(4)
When the device signals transition to state M1, the MHI driver may set the device into M2 state to save power. The MHI device will be woken up again by the driver ringing the wake doorbell register before doing PCI reads/writes, which qwx(4) already implements.
Diffstat (limited to 'sys/dev/pci/if_qwx_pci.c')
-rw-r--r--sys/dev/pci/if_qwx_pci.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sys/dev/pci/if_qwx_pci.c b/sys/dev/pci/if_qwx_pci.c
index bb52dd929dd..eb6776678d1 100644
--- a/sys/dev/pci/if_qwx_pci.c
+++ b/sys/dev/pci/if_qwx_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_qwx_pci.c,v 1.1 2023/12/28 17:36:29 stsp Exp $ */
+/* $OpenBSD: if_qwx_pci.c,v 1.2 2024/01/11 09:52:19 stsp Exp $ */
/*
* Copyright 2023 Stefan Sperling <stsp@openbsd.org>
@@ -455,6 +455,7 @@ int qwx_mhi_await_device_ready(struct qwx_softc *);
void qwx_mhi_ready_state_transition(struct qwx_pci_softc *);
void qwx_mhi_ee_amss_state_transition(struct qwx_pci_softc *);
void qwx_mhi_mission_mode_state_transition(struct qwx_pci_softc *);
+void qwx_mhi_low_power_mode_state_transition(struct qwx_pci_softc *);
void qwx_mhi_set_state(struct qwx_softc *, uint32_t);
void qwx_mhi_init_mmio(struct qwx_pci_softc *);
int qwx_mhi_fw_load_bhi(struct qwx_pci_softc *, uint8_t *, size_t);
@@ -2921,6 +2922,14 @@ qwx_mhi_mission_mode_state_transition(struct qwx_pci_softc *psc)
}
void
+qwx_mhi_low_power_mode_state_transition(struct qwx_pci_softc *psc)
+{
+ struct qwx_softc *sc = &psc->sc_sc;
+
+ qwx_mhi_set_state(sc, MHI_STATE_M2);
+}
+
+void
qwx_mhi_set_state(struct qwx_softc *sc, uint32_t state)
{
uint32_t reg;
@@ -3397,6 +3406,12 @@ qwx_mhi_state_change(void *arg)
psc->mhi_state = mhi_state;
qwx_mhi_mission_mode_state_transition(psc);
break;
+ case MHI_STATE_M1:
+ DNPRINTF(QWX_D_MHI, "%s: new MHI state M1\n",
+ sc->sc_dev.dv_xname);
+ psc->mhi_state = mhi_state;
+ qwx_mhi_low_power_mode_state_transition(psc);
+ break;
case MHI_STATE_SYS_ERR:
DNPRINTF(QWX_D_MHI,
"%s: new MHI state SYS ERR\n",