From patchwork Mon Jun 20 04:26:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 9186569 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 12DAA607D1 for ; Mon, 20 Jun 2016 04:38:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7FA422BF1 for ; Mon, 20 Jun 2016 04:38:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D84FA23F88; Mon, 20 Jun 2016 04:38:34 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 173BE22BF1 for ; Mon, 20 Jun 2016 04:38:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751369AbcFTEic (ORCPT ); Mon, 20 Jun 2016 00:38:32 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:34874 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750835AbcFTEib (ORCPT ); Mon, 20 Jun 2016 00:38:31 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O9102XA7YZFGQD0@mailout1.samsung.com> for linux-mmc@vger.kernel.org; Mon, 20 Jun 2016 13:26:03 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 05.B0.05161.B5077675; Mon, 20 Jun 2016 13:26:03 +0900 (KST) X-AuditID: cbfee68f-f79476d000001429-86-5767705b9692 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 91.FE.04429.B5077675; Sun, 19 Jun 2016 21:26:03 -0700 (MST) Received: from localhost.localdomain ([10.113.62.216]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O9100A6UYZFMQ20@mmp1.samsung.com>; Mon, 20 Jun 2016 13:26:03 +0900 (KST) From: Jaehoon Chung To: linux-mmc@vger.kernel.org Cc: ulf.hansson@linaro.org, shawn.lin@rock-chips.com, Jaehoon Chung Subject: [PATCH 3/3] mmc: dw_mmc: prevent to set the wrong value Date: Mon, 20 Jun 2016 13:26:01 +0900 Message-id: <1466396761-29503-1-git-send-email-jh80.chung@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDLMWRmVeSWpSXmKPExsWyRsSkUDe6ID3c4HOXscWNX22sFkf+9zNa 3HmyntXi+NpwBxaPO9f2sHn8nbWfxaNvyypGj8+b5AJYorhsUlJzMstSi/TtErgyvr4ULvgn WNGwbB57A+Mivi5GTg4JAROJezN3skDYYhIX7q1n62Lk4hASWMEosXRLBxtMUcecnVCJpYwS 2w7vgHJ+MEr86mhjBaliE9CR2P7tOBOILSIgK/HzzwWwbmaBOIlFR3+ydzFycAgLOEhMa+cA MVkEVCWu7ucAqeAVcJOYcH4yE8QuOYmTxyazgoyXEHjMJrHq4HZGkASLgIDEt8mHWEB6JYDG bzrADFEvKXFwxQ2WCYyCCxgZVjGKphYkFxQnpRcZ6xUn5haX5qXrJefnbmIEBuLpf8/6dzDe PWB9iFGAg1GJh3eCVHq4EGtiWXFl7iFGU6ANE5mlRJPzgeGeVxJvaGxm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TU Yi4qTgQAUNkK5YwCAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If there ins no vqmmc, voltage should not be changed. Then it nees to maintain the previous status for USH_REG register. To use the standard spec, it should be returned error when voltage can't switch. Note: Dwmmc controller will not make any exception case.(like exynos.) If card isn't working well after appling this patch, it needs to check the regulator side. Signed-off-by: Jaehoon Chung --- drivers/mmc/host/dw_mmc.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 6efda0b..16e0793 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1403,33 +1403,37 @@ static int dw_mci_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios) struct dw_mci_slot *slot = mmc_priv(mmc); struct dw_mci *host = slot->host; const struct dw_mci_drv_data *drv_data = host->drv_data; - u32 uhs; + u32 uhs = 0; u32 v18 = SDMMC_UHS_18V << slot->id; int ret; if (drv_data && drv_data->switch_voltage) return drv_data->switch_voltage(mmc, ios); - /* - * Program the voltage. Note that some instances of dw_mmc may use - * the UHS_REG for this. For other instances (like exynos) the UHS_REG - * does no harm but you need to set the regulator directly. Try both. - */ + if (IS_ERR(mmc->supply.vqmmc)) { + dev_dbg(&mmc->class_dev, + "vqmmc not avaiable.(Skip the switching voltage)\n"); + return -EINVAL; + } + + ret = mmc_regulator_set_vqmmc(mmc, ios); + if (ret) { + dev_err(&mmc->class_dev, + "Regulator set error %d - %s V\n", + ret, uhs & v18 ? "1.8" : "3.3"); + return ret; + } + uhs = mci_readl(host, UHS_REG); - if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330) + switch(ios->signal_voltage) { + case MMC_SIGNAL_VOLTAGE_330: uhs &= ~v18; - else + break; + case MMC_SIGNAL_VOLTAGE_180: uhs |= v18; - - if (!IS_ERR(mmc->supply.vqmmc)) { - ret = mmc_regulator_set_vqmmc(mmc, ios); - - if (ret) { - dev_dbg(&mmc->class_dev, - "Regulator set error %d - %s V\n", - ret, uhs & v18 ? "1.8" : "3.3"); - return ret; - } + break; + default: + uhs &= ~v18; } mci_writel(host, UHS_REG, uhs);