From 952ee722ff3e76fd82a065b2cc272b46ed9c22f9 Mon Sep 17 00:00:00 2001 From: kettenis Date: Wed, 26 Jul 2023 11:09:24 +0000 Subject: [PATCH] Shutd down the power domains suring suspend. ok patrick@, tobhe@ --- sys/arch/arm64/dev/apldma.c | 23 +++++++++++++++++++++-- sys/arch/arm64/dev/aplmca.c | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/sys/arch/arm64/dev/apldma.c b/sys/arch/arm64/dev/apldma.c index f842f9f5148..01fd2693d41 100644 --- a/sys/arch/arm64/dev/apldma.c +++ b/sys/arch/arm64/dev/apldma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apldma.c,v 1.5 2022/11/26 21:35:22 kettenis Exp $ */ +/* $OpenBSD: apldma.c,v 1.6 2023/07/26 11:09:24 kettenis Exp $ */ /* * Copyright (c) 2022 Mark Kettenis * @@ -110,9 +110,11 @@ struct apldma_softc *apldma_sc; int apldma_match(struct device *, void *, void *); void apldma_attach(struct device *, struct device *, void *); +int apldma_activate(struct device *, int); const struct cfattach apldma_ca = { - sizeof (struct apldma_softc), apldma_match, apldma_attach + sizeof (struct apldma_softc), apldma_match, apldma_attach, NULL, + apldma_activate }; struct cfdriver apldma_cd = { @@ -197,6 +199,23 @@ unmap: bus_space_unmap(sc->sc_iot, sc->sc_ioh, faa->fa_reg[0].size); } +int +apldma_activate(struct device *self, int act) +{ + struct apldma_softc *sc = (struct apldma_softc *)self; + + switch (act) { + case DVACT_SUSPEND: + power_domain_disable(sc->sc_node); + break; + case DVACT_RESUME: + power_domain_enable(sc->sc_node); + break; + } + + return 0; +} + void apldma_fill_descriptors(struct apldma_channel *ac) { diff --git a/sys/arch/arm64/dev/aplmca.c b/sys/arch/arm64/dev/aplmca.c index 88cb4358b61..95da05e4726 100644 --- a/sys/arch/arm64/dev/aplmca.c +++ b/sys/arch/arm64/dev/aplmca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aplmca.c,v 1.6 2023/02/03 13:20:21 kettenis Exp $ */ +/* $OpenBSD: aplmca.c,v 1.7 2023/07/26 11:09:24 kettenis Exp $ */ /* * Copyright (c) 2022 Mark Kettenis * @@ -152,9 +152,11 @@ const struct audio_hw_if aplmca_hw_if = { int aplmca_match(struct device *, void *, void *); void aplmca_attach(struct device *, struct device *, void *); +int aplmca_activate(struct device *, int); const struct cfattach aplmca_ca = { - sizeof (struct aplmca_softc), aplmca_match, aplmca_attach + sizeof (struct aplmca_softc), aplmca_match, aplmca_attach, NULL, + aplmca_activate }; struct cfdriver aplmca_cd = { @@ -223,6 +225,32 @@ aplmca_attach(struct device *parent, struct device *self, void *aux) } } +int +aplmca_activate(struct device *self, int act) +{ + struct aplmca_softc *sc = (struct aplmca_softc *)self; + int i; + + switch (act) { + case DVACT_SUSPEND: + for (i = 0; i < sc->sc_nclusters; i++) { + if (sc->sc_ad[i].ad_ac) + power_domain_disable_idx(sc->sc_node, i + 1); + } + power_domain_disable_idx(sc->sc_node, 0); + break; + case DVACT_RESUME: + power_domain_enable_idx(sc->sc_node, 0); + for (i = 0; i < sc->sc_nclusters; i++) { + if (sc->sc_ad[i].ad_ac) + power_domain_enable_idx(sc->sc_node, i + 1); + } + break; + } + + return 0; +} + int aplmca_dai_init(struct aplmca_softc *sc, int port) { -- 2.20.1