From patchwork Tue Jun 21 05:35:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 9189545 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 0DD0A6089F for ; Tue, 21 Jun 2016 05:47:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F09A827F93 for ; Tue, 21 Jun 2016 05:47:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1BAC27F99; Tue, 21 Jun 2016 05:47:14 +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 1EE4F27F9C for ; Tue, 21 Jun 2016 05:47:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753466AbcFUFq4 (ORCPT ); Tue, 21 Jun 2016 01:46:56 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:44134 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752385AbcFUFqq (ORCPT ); Tue, 21 Jun 2016 01:46:46 -0400 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O9301SKTWVKTUB0@mailout2.samsung.com> for linux-mmc@vger.kernel.org; Tue, 21 Jun 2016 14:35:44 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.113]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id E8.13.05160.F22D8675; Tue, 21 Jun 2016 14:35:43 +0900 (KST) X-AuditID: cbfee68e-f79266d000001428-8e-5768d22fab96 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id CE.BE.02101.F22D8675; Tue, 21 Jun 2016 14:35:43 +0900 (KST) Received: from localhost.localdomain ([10.113.62.216]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O9300AJ0WVG1R00@mmp2.samsung.com>; Tue, 21 Jun 2016 14:35:43 +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 v2 3/3] mmc: dw_mmc: prevent to set the wrong value Date: Tue, 21 Jun 2016 14:35:39 +0900 Message-id: <1466487339-13211-3-git-send-email-jh80.chung@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1466487339-13211-1-git-send-email-jh80.chung@samsung.com> References: <1466487339-13211-1-git-send-email-jh80.chung@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGLMWRmVeSWpSXmKPExsWyRsSkUFf/Uka4weHbNhY3frWxWhz5389o cefJelaL42vDHVg87lzbw+bxd9Z+Fo++LasYPT5vkgtgieKySUnNySxLLdK3S+DKeDVRvmCR UMWlh/tZGxh38XUxcnJICJhIrFn7lwXCFpO4cG89WxcjF4eQwApGiVP3TzDDFO3YsZEdIjGL UeLmvzPMEM4PRokbO5rZQarYBHQktn87zgRiiwjISvz8c4ENxGYWiJNYdPQnWI2wgLPE3Y0z weIsAqoSu7c+YgWxeQXcJK5MvsIGsU1O4uSxyWBxTgF3iRuLOsFmCgHV/Gy5zAqyWELgN5vE zB9dzBCDBCS+TT4E9AMHUEJWYtMBqKslJQ6uuMEygVF4ASPDKkbR1ILk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KlzP2nHhm Pzlc4WxBvWOY/6otm+QEisSlttieVRR0TghY0sUx8ZBES+7jtp4tmizrGnj313K1nFluuP+o 1u9M292bk4Pu/1NiKc5INNRiLipOBADhFyxcpgIAAA== 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 --- Changelog V2: -Fix the typo 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 ec3f0a8..56c48fb 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1404,33 +1404,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 available.(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);