git: e05134d0562c - stable/13 - arm: allwinner: aw_mmc: Check regulators status before enabling/disabling them

Emmanuel Vadot manu at FreeBSD.org
Thu Jul 22 17:17:08 UTC 2021


The branch stable/13 has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=e05134d0562cbcbac09e7ad7dafa093668e432f0

commit e05134d0562cbcbac09e7ad7dafa093668e432f0
Author:     Emmanuel Vadot <manu at FreeBSD.org>
AuthorDate: 2021-05-16 14:24:31 +0000
Commit:     Emmanuel Vadot <manu at FreeBSD.org>
CommitDate: 2021-07-22 17:09:44 +0000

    arm: allwinner: aw_mmc: Check regulators status before enabling/disabling them
    
    Sponsored by:   Diablotin Systems
    Differential Revision:  https://reviews.freebsd.org/D30294
    
    (cherry picked from commit 115e71a4571459e69001b5017ec19532e9d60e1b)
---
 sys/arm/allwinner/aw_mmc.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/sys/arm/allwinner/aw_mmc.c b/sys/arm/allwinner/aw_mmc.c
index f63b41f9b73c..0b3f19aea55f 100644
--- a/sys/arm/allwinner/aw_mmc.c
+++ b/sys/arm/allwinner/aw_mmc.c
@@ -1285,6 +1285,8 @@ aw_mmc_update_ios(device_t bus, device_t child)
 	struct mmc_ios *ios;
 	unsigned int clock;
 	uint32_t reg, div = 1;
+	int reg_status;
+	int rv;
 
 	sc = device_get_softc(bus);
 
@@ -1310,10 +1312,16 @@ aw_mmc_update_ios(device_t bus, device_t child)
 		if (__predict_false(aw_mmc_debug & AW_MMC_DEBUG_CARD))
 			device_printf(sc->aw_dev, "Powering down sd/mmc\n");
 
-		if (sc->mmc_helper.vmmc_supply)
-			regulator_disable(sc->mmc_helper.vmmc_supply);
-		if (sc->mmc_helper.vqmmc_supply)
-			regulator_disable(sc->mmc_helper.vqmmc_supply);
+		if (sc->mmc_helper.vmmc_supply) {
+			rv = regulator_status(sc->mmc_helper.vmmc_supply, &reg_status);
+			if (rv == 0 && reg_status == REGULATOR_STATUS_ENABLED)
+				regulator_disable(sc->mmc_helper.vmmc_supply);
+		}
+		if (sc->mmc_helper.vqmmc_supply) {
+			rv = regulator_status(sc->mmc_helper.vqmmc_supply, &reg_status);
+			if (rv == 0 && reg_status == REGULATOR_STATUS_ENABLED)
+				regulator_disable(sc->mmc_helper.vqmmc_supply);
+		}
 
 		aw_mmc_reset(sc);
 		break;
@@ -1321,10 +1329,16 @@ aw_mmc_update_ios(device_t bus, device_t child)
 		if (__predict_false(aw_mmc_debug & AW_MMC_DEBUG_CARD))
 			device_printf(sc->aw_dev, "Powering up sd/mmc\n");
 
-		if (sc->mmc_helper.vmmc_supply)
-			regulator_enable(sc->mmc_helper.vmmc_supply);
-		if (sc->mmc_helper.vqmmc_supply)
-			regulator_enable(sc->mmc_helper.vqmmc_supply);
+		if (sc->mmc_helper.vmmc_supply) {
+			rv = regulator_status(sc->mmc_helper.vmmc_supply, &reg_status);
+			if (rv == 0 && reg_status != REGULATOR_STATUS_ENABLED)
+				regulator_enable(sc->mmc_helper.vmmc_supply);
+		}
+		if (sc->mmc_helper.vqmmc_supply) {
+			rv = regulator_status(sc->mmc_helper.vqmmc_supply, &reg_status);
+			if (rv == 0 && reg_status != REGULATOR_STATUS_ENABLED)
+				regulator_enable(sc->mmc_helper.vqmmc_supply);
+		}
 		aw_mmc_init(sc);
 		break;
 	};


More information about the dev-commits-src-all mailing list