summaryrefslogtreecommitdiff
path: root/sys/dev/fdt
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2024-05-15 22:54:04 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2024-05-15 22:54:04 +0000
commit7ebeadb61ca6936aaa91310510cccf9fd4607bc8 (patch)
treeef09dc549311278e6b5ceaebdc81aaba52b7187d /sys/dev/fdt
parent1281c09c3cc9616589ac7fabf079e655debdeacb (diff)
Recent OpenSBI versions implement shutdown and reboot through the DA9063
PMIC, but expect the I2C controller to remain enabled. Adjust ociic(4) such that this is the case. ok jca@
Diffstat (limited to 'sys/dev/fdt')
-rw-r--r--sys/dev/fdt/ociic.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/sys/dev/fdt/ociic.c b/sys/dev/fdt/ociic.c
index 0f165fb0623..3722cf10be1 100644
--- a/sys/dev/fdt/ociic.c
+++ b/sys/dev/fdt/ociic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ociic.c,v 1.3 2022/04/06 18:59:28 naddy Exp $ */
+/* $OpenBSD: ociic.c,v 1.4 2024/05/15 22:54:03 kettenis Exp $ */
/*
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
*
@@ -53,6 +53,13 @@
#define I2C_SR_TIP (1 << 1)
#define I2C_SR_IF (1 << 0)
+/*
+ * OpenSBI on the SiFive HiFive Unmatched board implements reboot and
+ * powerdown functionality through the Dialog DA9063 Power Management
+ * IC over I2C. The code expects the I2C controller to be enabled so
+ * we have to make sure we leave it in that state.
+ */
+
struct ociic_softc {
struct device sc_dev;
bus_space_tag_t sc_iot;
@@ -156,6 +163,8 @@ ociic_attach(struct device *parent, struct device *self, void *aux)
ociic_write(sc, I2C_PRER_HI, div >> 8);
}
+ ociic_set(sc, I2C_CTR, I2C_CTR_EN);
+
sc->sc_ic.ic_cookie = sc;
sc->sc_ic.ic_acquire_bus = ociic_acquire_bus;
sc->sc_ic.ic_release_bus = ociic_release_bus;
@@ -174,18 +183,12 @@ ociic_attach(struct device *parent, struct device *self, void *aux)
int
ociic_acquire_bus(void *cookie, int flags)
{
- struct ociic_softc *sc = cookie;
-
- ociic_set(sc, I2C_CTR, I2C_CTR_EN);
return 0;
}
void
ociic_release_bus(void *cookie, int flags)
{
- struct ociic_softc *sc = cookie;
-
- ociic_clr(sc, I2C_CTR, I2C_CTR_EN);
}
int