From patchwork Wed Apr 1 19:57:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 11469497 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1BEE792C for ; Wed, 1 Apr 2020 19:57:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 00C76206F6 for ; Wed, 1 Apr 2020 19:57:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732780AbgDAT5v (ORCPT ); Wed, 1 Apr 2020 15:57:51 -0400 Received: from mail-out.m-online.net ([212.18.0.9]:40894 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732397AbgDAT5v (ORCPT ); Wed, 1 Apr 2020 15:57:51 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 48sxnT0GlGz1qrM4; Wed, 1 Apr 2020 21:57:49 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 48sxnS72hDz1r0cc; Wed, 1 Apr 2020 21:57:48 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id vkW5HCdeRclL; Wed, 1 Apr 2020 21:57:47 +0200 (CEST) X-Auth-Info: 7/hv+VCPFKvVjy94/A1BvDumeSgcAfnzFKsYwubnSIY= Received: from desktop.lan (ip-86-49-35-8.net.upcbroadband.cz [86.49.35.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Wed, 1 Apr 2020 21:57:47 +0200 (CEST) From: Marek Vasut To: linux-mmc@vger.kernel.org Cc: Marek Vasut , Alexandre Torgue , Linus Walleij , Ludovic Barre , Manivannan Sadhasivam , Maxime Coquelin , Patrice Chotard , Patrick Delaunay , Russell King , Ulf Hansson , linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH 3/3] mmc: mmci: Switch to mmc_set_signal_voltage() Date: Wed, 1 Apr 2020 21:57:22 +0200 Message-Id: <20200401195722.208157-3-marex@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200401195722.208157-1-marex@denx.de> References: <20200401195722.208157-1-marex@denx.de> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Instead of reimplementing the logic in mmc_set_signal_voltage(), use the mmc code function directly. This fixes a real issue on STM32MP1 where, if the eMMC is supplied with VccQ=1.8 V, the post voltage switch code will spin indefinitelly waiting for the voltage switch to complete, even though no voltage switch really happened. But since mmc_set_signal_voltage() would return 0, then the condition for calling .post_sig_volt_switch() is not satisfied if the switch did not happen. Signed-off-by: Marek Vasut Cc: Alexandre Torgue Cc: Linus Walleij Cc: Ludovic Barre Cc: Manivannan Sadhasivam Cc: Maxime Coquelin Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Russell King Cc: Ulf Hansson Cc: linux-stm32@st-md-mailman.stormreply.com To: linux-mmc@vger.kernel.org --- drivers/mmc/host/mmci.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 647567def612..b8c8f0e623de 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1861,31 +1861,15 @@ static int mmci_get_cd(struct mmc_host *mmc) static int mmci_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios) { struct mmci_host *host = mmc_priv(mmc); - int ret = 0; - - if (!IS_ERR(mmc->supply.vqmmc)) { + int ret; - switch (ios->signal_voltage) { - case MMC_SIGNAL_VOLTAGE_330: - ret = regulator_set_voltage(mmc->supply.vqmmc, - 2700000, 3600000); - break; - case MMC_SIGNAL_VOLTAGE_180: - ret = regulator_set_voltage(mmc->supply.vqmmc, - 1700000, 1950000); - break; - case MMC_SIGNAL_VOLTAGE_120: - ret = regulator_set_voltage(mmc->supply.vqmmc, - 1100000, 1300000); - break; - } + ret = mmc_regulator_set_vqmmc(mmc, ios); - if (!ret && host->ops && host->ops->post_sig_volt_switch) - ret = host->ops->post_sig_volt_switch(host, ios); + if (!ret && host->ops && host->ops->post_sig_volt_switch) + ret = host->ops->post_sig_volt_switch(host, ios); - if (ret) - dev_warn(mmc_dev(mmc), "Voltage switch failed\n"); - } + if (ret < 0) + dev_warn(mmc_dev(mmc), "Voltage switch failed\n"); return ret; }