From patchwork Mon Apr 16 14:23:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 10343067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2153F601D7 for ; Mon, 16 Apr 2018 14:28:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11641287A4 for ; Mon, 16 Apr 2018 14:28:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06646287A7; Mon, 16 Apr 2018 14:28:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8180C287A4 for ; Mon, 16 Apr 2018 14:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=QIL5vTcvaYhs7gII3QRsUip9TNy58oGC9qmMZ9FZuaw=; b=o2UDkOX6KQc6aFdhw1aQBGZmOZ HbyFWG4xlhjTT+2vw9ERq8ipPOe2KDzmHgtq77BhroFVKDELKt29tvoTQxs5rA7sf4MchHeNCSNk8 Ji4LRthi8BfzXd/YfQr9wX/OO2p7L10tMZ4xEqXFv7ajSVzJ9R60UlM7lmpdSi6OGEHLa2VM9YOcV fuYduwG355uz5j76jjW7lfoOHdeQ2ys8YLvddUa8U5N3cI5H0Tl8wS42xI+jsKGtr0Dg9LdL3787/ m7bKIy7jpozApkWOO6AGvEFXTUVI/Uw2QztHtOqMF9BKakRaTexlejalSWQj5Z0TkYV15v/XaAwgd dNa5NGfQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f8574-0000nN-C3; Mon, 16 Apr 2018 14:28:10 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f852n-0005WS-A1 for linux-arm-kernel@lists.infradead.org; Mon, 16 Apr 2018 14:23:51 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 6FF6E20DB5; Mon, 16 Apr 2018 16:23:20 +0200 (CEST) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id 3669820DBE; Mon, 16 Apr 2018 16:23:10 +0200 (CEST) From: Maxime Ripard To: Chen-Yu Tsai , Maxime Ripard , ulf.hansson@linaro.org Subject: [PATCH v3 5/7] mmc: sunxi: Move the card power configuration to a function Date: Mon, 16 Apr 2018 16:23:03 +0200 Message-Id: <138e91cbbe9c5f5de71b76a9e66e76b68c7122f2.1523888566.git-series.maxime.ripard@bootlin.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180416_072345_575530_9D4ACC16 X-CRM114-Status: GOOD ( 13.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni , linux-mmc@vger.kernel.org, Quentin Schulz , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In order to improve readibility and reusability, let's move the card setup to a small function called by our .set_ios hook. Signed-off-by: Maxime Ripard --- drivers/mmc/host/sunxi-mmc.c | 40 +++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c index 3c1ab46cc60a..0165da0d022a 100644 --- a/drivers/mmc/host/sunxi-mmc.c +++ b/drivers/mmc/host/sunxi-mmc.c @@ -888,17 +888,15 @@ static void sunxi_mmc_set_clk(struct sunxi_mmc_host *host, struct mmc_ios *ios) /* Android code had a usleep_range(50000, 55000); here */ } -static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) +static void sunxi_mmc_card_power(struct sunxi_mmc_host *host, + struct mmc_ios *ios) { - struct sunxi_mmc_host *host = mmc_priv(mmc); - u32 rval; + struct mmc_host *mmc = host->mmc; - /* Set the power state */ switch (ios->power_mode) { - case MMC_POWER_ON: - break; - case MMC_POWER_UP: + dev_dbg(mmc_dev(mmc), "Powering card up\n"); + if (!IS_ERR(mmc->supply.vmmc)) { host->ferror = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, @@ -916,25 +914,37 @@ static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) } host->vqmmc_enabled = true; } - - host->ferror = sunxi_mmc_init_host(host); - if (host->ferror) - return; - - dev_dbg(mmc_dev(mmc), "power on!\n"); break; case MMC_POWER_OFF: - dev_dbg(mmc_dev(mmc), "power off!\n"); - sunxi_mmc_reset_host(host); + dev_dbg(mmc_dev(mmc), "Powering card off\n"); + if (!IS_ERR(mmc->supply.vmmc)) mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0); if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) regulator_disable(mmc->supply.vqmmc); + host->vqmmc_enabled = false; break; + + default: + dev_dbg(mmc_dev(mmc), "Ignoring unknown card power state\n"); + break; } +} + +static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) +{ + struct sunxi_mmc_host *host = mmc_priv(mmc); + + if (ios->power_mode == MMC_POWER_OFF) + sunxi_mmc_reset_host(host); + + sunxi_mmc_card_power(host, ios); + + if (ios->power_mode == MMC_POWER_UP) + sunxi_mmc_init_host(host); sunxi_mmc_set_bus_width(host, ios->bus_width); sunxi_mmc_set_clk(host, ios);