From owner-dev-commits-src-all@freebsd.org Fri May 21 16:04:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A7D5B636575; Fri, 21 May 2021 16:04:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FmryZ1lw8z3JZ6; Fri, 21 May 2021 16:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0D415144FB; Fri, 21 May 2021 16:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14LG4KF3005201; Fri, 21 May 2021 16:04:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14LG4Klp005200; Fri, 21 May 2021 16:04:20 GMT (envelope-from git) Date: Fri, 21 May 2021 16:04:20 GMT Message-Id: <202105211604.14LG4Klp005200@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 115e71a45714 - main - arm: allwinner: aw_mmc: Check regulators status before enabling/disabling them MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 115e71a4571459e69001b5017ec19532e9d60e1b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 16:04:22 -0000 The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=115e71a4571459e69001b5017ec19532e9d60e1b commit 115e71a4571459e69001b5017ec19532e9d60e1b Author: Emmanuel Vadot AuthorDate: 2021-05-16 14:24:31 +0000 Commit: Emmanuel Vadot CommitDate: 2021-05-21 15:39:47 +0000 arm: allwinner: aw_mmc: Check regulators status before enabling/disabling them Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30294 --- 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, ®_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, ®_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, ®_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, ®_status); + if (rv == 0 && reg_status != REGULATOR_STATUS_ENABLED) + regulator_enable(sc->mmc_helper.vqmmc_supply); + } aw_mmc_init(sc); break; };