From: kettenis Date: Sun, 26 May 2024 18:06:21 +0000 (+0000) Subject: Clear interrupt status to prevent power down after resume initiated by X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=456d6666057a2bbd831065fb68f77c5a5d8367d1;p=openbsd Clear interrupt status to prevent power down after resume initiated by pressing the power button. ok patrick@ --- diff --git a/sys/dev/fdt/dwmshc.c b/sys/dev/fdt/dwmshc.c index 4ae27743114..9122af114b0 100644 --- a/sys/dev/fdt/dwmshc.c +++ b/sys/dev/fdt/dwmshc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwmshc.c,v 1.5 2023/06/20 09:26:36 kettenis Exp $ */ +/* $OpenBSD: dwmshc.c,v 1.6 2024/05/26 18:06:21 kettenis Exp $ */ /* * Copyright (c) 2023 David Gwynne @@ -250,6 +250,7 @@ dwmshc_attach(struct device *parent, struct device *self, void *aux) SET(sdhc->sc_flags, SDHC_F_NOPWR0); SET(capmask, (uint64_t)SDHC_DDR50_SUPP << 32); + SET(capmask, (uint64_t)SDHC_HIGH_SPEED_SUPP); sdhc_host_found(sdhc, sc->sc_iot, sc->sc_ioh, sc->sc_ios, 1, capmask, capset); diff --git a/sys/dev/fdt/fanpwr.c b/sys/dev/fdt/fanpwr.c index 0e8b35a34fe..cfebb5a63fc 100644 --- a/sys/dev/fdt/fanpwr.c +++ b/sys/dev/fdt/fanpwr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fanpwr.c,v 1.8 2023/11/12 12:41:43 patrick Exp $ */ +/* $OpenBSD: fanpwr.c,v 1.9 2024/05/26 18:06:21 kettenis Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * @@ -30,6 +30,7 @@ /* Registers */ #define FAN53555_VSEL0 0x00 #define FAN53555_VSEL1 0x01 +#define FAN53555_VSEL_BUCK_EN 0x80 #define FAN53555_VSEL_NSEL_MASK 0x3f #define FAN53555_CONTROL 0x02 #define FAN53555_CONTROL_SLEW_MASK (0x7 << 4) @@ -107,7 +108,11 @@ fanpwr_attach(struct device *parent, struct device *self, void *aux) struct i2c_attach_args *ia = aux; int node = *(int *)ia->ia_cookie; uint32_t voltage, ramp_delay; + uint8_t vsel_sleep_en; + uint8_t vsel_sleep; uint8_t id1, id2; + uint8_t vsel; + int snode; pinctrl_byname(node, "default"); @@ -133,23 +138,36 @@ fanpwr_attach(struct device *parent, struct device *self, void *aux) } if (sc->sc_id == FANPWR_TCS4525) { - if (OF_getpropint(node, "fcs,suspend-voltage-selector", 0)) + if (OF_getpropint(node, "fcs,suspend-voltage-selector", 0)) { sc->sc_vsel = TCS4525_VSEL0; - else + vsel_sleep = TCS4525_VSEL1; + } else { sc->sc_vsel = TCS4525_VSEL1; + vsel_sleep = TCS4525_VSEL0; + } sc->sc_vsel_nsel_mask = TCS4525_VSEL_NSEL_MASK; + vsel_sleep_en = vsel_sleep; } else if (sc->sc_id == FANPWR_RK8602) { - if (OF_getpropint(node, "fcs,suspend-voltage-selector", 0)) + if (OF_getpropint(node, "fcs,suspend-voltage-selector", 0)) { sc->sc_vsel = RK8602_VSEL0; - else + vsel_sleep = RK8602_VSEL1; + vsel_sleep_en = FAN53555_VSEL1; + } else { sc->sc_vsel = RK8602_VSEL1; + vsel_sleep = RK8602_VSEL0; + vsel_sleep_en = FAN53555_VSEL0; + } sc->sc_vsel_nsel_mask = RK8602_VSEL_NSEL_MASK; } else { - if (OF_getpropint(node, "fcs,suspend-voltage-selector", 0)) + if (OF_getpropint(node, "fcs,suspend-voltage-selector", 0)) { sc->sc_vsel = FAN53555_VSEL0; - else + vsel_sleep = FAN53555_VSEL1; + } else { sc->sc_vsel = FAN53555_VSEL1; + vsel_sleep = FAN53555_VSEL0; + } sc->sc_vsel_nsel_mask = FAN53555_VSEL_NSEL_MASK; + vsel_sleep_en = vsel_sleep; } id1 = fanpwr_read(sc, FAN53555_ID1); @@ -246,6 +264,27 @@ fanpwr_attach(struct device *parent, struct device *self, void *aux) regulator_register(&sc->sc_rd); printf("\n"); + + snode = OF_getnodebyname(node, "regulator-state-mem"); + if (snode) { + vsel = fanpwr_read(sc, vsel_sleep_en); + if (OF_getpropbool(snode, "regulator-on-in-suspend")) + vsel |= FAN53555_VSEL_BUCK_EN; + if (OF_getpropbool(snode, "regulator-off-in-suspend")) + vsel &= ~FAN53555_VSEL_BUCK_EN; + fanpwr_write(sc, vsel_sleep_en, vsel); + + voltage = OF_getpropint(snode, + "regulator-suspend-min-microvolt", 0); + voltage = OF_getpropint(snode, + "regulator-suspend-microvolt", voltage); + if (voltage > 0) { + vsel = fanpwr_read(sc, vsel_sleep); + vsel &= ~sc->sc_vsel_nsel_mask; + vsel |= (voltage - vsel_sleep) / sc->sc_vstep; + fanpwr_write(sc, vsel_sleep, vsel); + } + } } uint8_t diff --git a/sys/dev/fdt/rkpmic.c b/sys/dev/fdt/rkpmic.c index 8aa7f3b8228..cec42e25a18 100644 --- a/sys/dev/fdt/rkpmic.c +++ b/sys/dev/fdt/rkpmic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rkpmic.c,v 1.16 2024/05/26 13:40:54 kettenis Exp $ */ +/* $OpenBSD: rkpmic.c,v 1.17 2024/05/26 18:06:21 kettenis Exp $ */ /* * Copyright (c) 2017 Mark Kettenis * @@ -534,6 +534,7 @@ rkpmic_activate(struct device *self, int act) val &= ~RK809_PMIC_SYS_CFG3_SLP_FUN_MASK; val |= RK809_PMIC_SYS_CFG3_SLP_FUN_NONE; rkpmic_reg_write(sc, RK809_PMIC_SYS_CFG3, val); + rkpmic_reg_write(sc, RK809_PMIC_INT_STS0, 0xff); } break; }