From 7ebeadb61ca6936aaa91310510cccf9fd4607bc8 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Wed, 15 May 2024 22:54:04 +0000 Subject: 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@ --- sys/dev/fdt/ociic.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'sys/dev/fdt') 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 * @@ -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 -- cgit v1.2.3