From patchwork Wed Jan 25 15:12:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 92458 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2253645qgi; Wed, 25 Jan 2017 07:12:32 -0800 (PST) X-Received: by 10.46.75.1 with SMTP id y1mr16020137lja.65.1485357152158; Wed, 25 Jan 2017 07:12:32 -0800 (PST) Return-Path: Received: from mail-lf0-x235.google.com (mail-lf0-x235.google.com. [2a00:1450:4010:c07::235]) by mx.google.com with ESMTPS id 18si14869886ljh.32.2017.01.25.07.12.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jan 2017 07:12:32 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::235 as permitted sender) client-ip=2a00:1450:4010:c07::235; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::235 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x235.google.com with SMTP id z134so130469487lff.3 for ; Wed, 25 Jan 2017 07:12:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=36UUnrlWweKthQBn0pAl0zZk9EbJmzeciJ+9jupVVLE=; b=EfIkrUPBosFQhCNFfiC4GgEcsnL0wU1FCLz7pXwiDeZlRK9yV21aORYpZLD+Kw1hWP R8XNsX+uDl7gGrk/imqixnwF+hNvT99WAjH0v6WfS2Qxm6a2wAOW5mPF51zEhM61yGis B5kn7VoUb4qNoLMim4RNOEUfTXbvGYn/lS6Xg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=36UUnrlWweKthQBn0pAl0zZk9EbJmzeciJ+9jupVVLE=; b=SLs7DsTGZP4C09hl3cfLSKH3uwY7S9/Yv20QRDgYdk5MRQs4/O6KOCiEncC5xIUFHJ wACC8CwTTh5BfE5VoLLBbVMgJMHosfaNyC2aceqFIivqZ0k3n3O7vwER4UKemnAhfDrU bosta7s9JXkp30hEH6Kw1tBOgnSBfFiJOh/Vf9Pg36d2irYRnYs4TdRe3a89Ic+yFcJY HFZf8b8F3iMb5xyjEufSAIyDoSIv6fNYULBKxKVM8A7CfWaXxtW+bm1vnrmliTSPCP9Y ZS1IWpfM+iDgYEIJhRPcnG6+ftk1SqYUGBetoG9PethbcGHXuSSPojGECozm+C+WNz4C FSpA== X-Gm-Message-State: AIkVDXJrXtlMuKVXTkhMuEyZuaE5ew0zXsV/FDLnBiDHHs1rrFQvHZXEDngWlRHccNFpM9FcwwI= X-Received: by 10.25.159.144 with SMTP id i138mr11876340lfe.148.1485357151721; Wed, 25 Jan 2017 07:12:31 -0800 (PST) Return-Path: Received: from uffe-Latitude-E6430s.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u126sm8397687lja.25.2017.01.25.07.12.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Jan 2017 07:12:30 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Shawn Lin , Stefan Wahren , Fabio Estevam , Jan Glauber Subject: [PATCH 1/6] mmc: core: Remove redundant code in mmc_set_signal_voltage() Date: Wed, 25 Jan 2017 16:12:18 +0100 Message-Id: <1485357143-23280-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485357143-23280-1-git-send-email-ulf.hansson@linaro.org> References: <1485357143-23280-1-git-send-email-ulf.hansson@linaro.org> The mmc_set_signal_voltage() function is used for SD/SDIO when switching to 1.8V for UHS mode. Therefore let's remove the redundant code dealing with MMC_SIGNAL_VOLTAGE_330. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 7 ------- 1 file changed, 7 deletions(-) -- 1.9.1 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 8c45825..bb819d4 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1654,13 +1654,6 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, u32 ocr) u32 clock; /* - * Send CMD11 only if the request is to switch the card to - * 1.8V signalling. - */ - if (signal_voltage == MMC_SIGNAL_VOLTAGE_330) - return __mmc_set_signal_voltage(host, signal_voltage); - - /* * If we cannot switch voltages, return failure so the caller * can continue without UHS mode */ From patchwork Wed Jan 25 15:12:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 92459 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2253649qgi; Wed, 25 Jan 2017 07:12:33 -0800 (PST) X-Received: by 10.46.0.228 with SMTP id e97mr16152158lji.49.1485357153370; Wed, 25 Jan 2017 07:12:33 -0800 (PST) Return-Path: Received: from mail-lf0-x230.google.com (mail-lf0-x230.google.com. [2a00:1450:4010:c07::230]) by mx.google.com with ESMTPS id 200si11988465lfh.408.2017.01.25.07.12.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jan 2017 07:12:33 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::230 as permitted sender) client-ip=2a00:1450:4010:c07::230; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::230 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x230.google.com with SMTP id x1so43802093lff.0 for ; Wed, 25 Jan 2017 07:12:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4G5TKxEikmI4GAr8h5D/p54uqqf/pr5e6XLyp3f4qtY=; b=clxznZ1Xrv2LUPOyRBYjCQPJzfrbf7rrsl7ztHFLVf8LuI83Gh/E0SUq2p9aJz0EWH /5eUQwhMePArcaT+8jbuqHSok9YcENhKrPBYuR8X1oyyvbzDXq8Cg9MaTw7n+7Rq6Zk/ J1ikVo+vhXJ/npGd48NBrtdAmAOqU/x6P9vdQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4G5TKxEikmI4GAr8h5D/p54uqqf/pr5e6XLyp3f4qtY=; b=lG+dcBxO4ZdoKUvnOUGt32ZHG9xcxiP2utNWl313HqT2irkPFt/DV7PD7rTFgwQyPm khLi8v8n6MwFnjCpegsWYVbZkb1RFGfw6CG8N7YIxonBYT5Gq+DLch1lEYJDx1zy6dMV 8xHnMAmDYcjNblDL16pP5xIYVAP+4lZNcUuBcqm+4XfCAnWcrqtn6qf/y4pwSASJWz9q 3Ho0QDhg+E2ay1q6rvseywNIgJekZP4BnPsUuPrH4h7Qx8AYGI4t5Uk76t05OeRkJ81E KzUBz99nWKpv/z8OZepudqJZT0QrKo9sPItznnEveSwkv9IC6a9GrmLMidhVsSr4fuj9 cvCw== X-Gm-Message-State: AIkVDXJwtJD5ntkKJF15w5NynswzMH92XG7VrEV8uMY9xZL6hYlXn3HHK1jP7AloX0g1ooAZcOg= X-Received: by 10.25.206.146 with SMTP id e140mr13617578lfg.94.1485357152947; Wed, 25 Jan 2017 07:12:32 -0800 (PST) Return-Path: Received: from uffe-Latitude-E6430s.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u126sm8397687lja.25.2017.01.25.07.12.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Jan 2017 07:12:32 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Shawn Lin , Stefan Wahren , Fabio Estevam , Jan Glauber Subject: [PATCH 2/6] mmc: core: Clarify usage of mmc_set_signal_voltage() Date: Wed, 25 Jan 2017 16:12:19 +0100 Message-Id: <1485357143-23280-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485357143-23280-1-git-send-email-ulf.hansson@linaro.org> References: <1485357143-23280-1-git-send-email-ulf.hansson@linaro.org> The mmc_set_signal_voltage() function is used for SD/SDIO when switching to 1.8V for UHS mode. To clarify this let's do the following changes. - We are always providing MMC_SIGNAL_VOLTAGE_180 as the signal_voltage parameter to the function. Then, let's just remove the parameter as it serves no purpose. - Rename the function to mmc_set_uhs_voltage(). Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 4 ++-- drivers/mmc/core/core.h | 2 +- drivers/mmc/core/sd.c | 3 +-- drivers/mmc/core/sdio.c | 3 +-- 4 files changed, 5 insertions(+), 7 deletions(-) -- 1.9.1 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index bb819d4..82c1a02 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1647,7 +1647,7 @@ int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage) } -int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, u32 ocr) +int mmc_set_uhs_voltage(struct mmc_host *host, u32 ocr) { struct mmc_command cmd = {}; int err = 0; @@ -1691,7 +1691,7 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, u32 ocr) host->ios.clock = 0; mmc_set_ios(host); - if (__mmc_set_signal_voltage(host, signal_voltage)) { + if (__mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180)) { /* * Voltages may not have been switched, but we've already * sent CMD11, so a power cycle is required anyway diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index 8a95c825..aee23f5 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -48,7 +48,7 @@ struct device_node *mmc_of_find_child_device(struct mmc_host *host, void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode); void mmc_set_bus_width(struct mmc_host *host, unsigned int width); u32 mmc_select_voltage(struct mmc_host *host, u32 ocr); -int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, u32 ocr); +int mmc_set_uhs_voltage(struct mmc_host *host, u32 ocr); int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); void mmc_set_timing(struct mmc_host *host, unsigned int timing); void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type); diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 8b4f139..89531b4 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -788,8 +788,7 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr) */ if (!mmc_host_is_spi(host) && rocr && ((*rocr & 0x41000000) == 0x41000000)) { - err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, - pocr); + err = mmc_set_uhs_voltage(host, pocr); if (err == -EAGAIN) { retries--; goto try_again; diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 261c886..a64a870 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -642,8 +642,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, * to make sure which speed mode should work. */ if (!powered_resume && (rocr & ocr & R4_18V_PRESENT)) { - err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, - ocr_card); + err = mmc_set_uhs_voltage(host, ocr_card); if (err == -EAGAIN) { mmc_sdio_resend_if_cond(host, card); retries--; From patchwork Wed Jan 25 15:12:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 92460 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2253694qgi; Wed, 25 Jan 2017 07:12:37 -0800 (PST) X-Received: by 10.46.7.10 with SMTP id 10mr16069078ljh.58.1485357157469; Wed, 25 Jan 2017 07:12:37 -0800 (PST) Return-Path: Received: from mail-lf0-x235.google.com (mail-lf0-x235.google.com. [2a00:1450:4010:c07::235]) by mx.google.com with ESMTPS id e142si14850200lfd.54.2017.01.25.07.12.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jan 2017 07:12:37 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::235 as permitted sender) client-ip=2a00:1450:4010:c07::235; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::235 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x235.google.com with SMTP id x1so43803275lff.0 for ; Wed, 25 Jan 2017 07:12:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VGtCg11iJk3y/2MYAhF1o+sobUg3Rz+S51oxeiZxvlE=; b=DIDYiZzRUeNUcISFgNAJHwNA6O0ALiRXP5uHkJd3tDLL6Q5hNXwDLc2j/87OUlIMSF FMwXnDe9pil1p3m+3sr1yXYHlYU4OZlEVIbXXjbLbflBo3iwga3qi8Vdz3HPI9RHOXEL WnI5CAedXSlUuv7mG0ZuEMyA26F1U935xUSu4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VGtCg11iJk3y/2MYAhF1o+sobUg3Rz+S51oxeiZxvlE=; b=QWQ7kqPsbxVybmVQAGvxFtIcj6ci55VO/PZp+MDFLCTAusf6Xz3hE6glKS2jBlVZfX hUpLGvrsbtVFO/s12ZdHT3dspIx7Ls3yVbwc+72QjnCzWI0CpjjTPXR7tbRRRC4v4LZ6 vmbp+KD0BWsjz4tR8rZQJcc0GM1DQIoXavFS/PiNaS2jVv8oPkDuadsqt3idKif8CaNp 7mbvEndTb5tB4Cjw9AHJxqMC+PPPJ09LHfnKB/PmxW6rxLU+LPxBhJWyTdatCbhc+5Y7 SEahwd/0asfN0PbBRz1LpjFsG3p6eMRH3NlrSAWUnD6EOua1MebrolBaXCmrk99AUUF9 VyCQ== X-Gm-Message-State: AIkVDXITrSYy/lKC8gBe3lcGX3YcSwuduF9wUwtMQECiR2RXaWyBU2lmbonOuv1VF6VTXcq4CsQ= X-Received: by 10.25.19.67 with SMTP id j64mr13569761lfi.34.1485357157014; Wed, 25 Jan 2017 07:12:37 -0800 (PST) Return-Path: Received: from uffe-Latitude-E6430s.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u126sm8397687lja.25.2017.01.25.07.12.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Jan 2017 07:12:33 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Shawn Lin , Stefan Wahren , Fabio Estevam , Jan Glauber Subject: [PATCH 3/6] mmc: core: Rename __mmc_set_signal_voltage() to mmc_set_signal_voltage() Date: Wed, 25 Jan 2017 16:12:20 +0100 Message-Id: <1485357143-23280-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485357143-23280-1-git-send-email-ulf.hansson@linaro.org> References: <1485357143-23280-1-git-send-email-ulf.hansson@linaro.org> Earlier the mmc_set_signal_voltage() existed, but since it has been renamed to mmc_set_uhs_voltage(), we can now use that name instead. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 10 +++++----- drivers/mmc/core/core.h | 2 +- drivers/mmc/core/mmc.c | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) -- 1.9.1 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 82c1a02..1d44aa2 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1631,7 +1631,7 @@ u32 mmc_select_voltage(struct mmc_host *host, u32 ocr) return ocr; } -int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage) +int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage) { int err = 0; int old_signal_voltage = host->ios.signal_voltage; @@ -1691,7 +1691,7 @@ int mmc_set_uhs_voltage(struct mmc_host *host, u32 ocr) host->ios.clock = 0; mmc_set_ios(host); - if (__mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180)) { + if (mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180)) { /* * Voltages may not have been switched, but we've already * sent CMD11, so a power cycle is required anyway @@ -1800,11 +1800,11 @@ void mmc_power_up(struct mmc_host *host, u32 ocr) mmc_set_initial_state(host); /* Try to set signal voltage to 3.3V but fall back to 1.8v or 1.2v */ - if (__mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330) == 0) + if (mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330) == 0) dev_dbg(mmc_dev(host), "Initial signal voltage of 3.3v\n"); - else if (__mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180) == 0) + else if (mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180) == 0) dev_dbg(mmc_dev(host), "Initial signal voltage of 1.8v\n"); - else if (__mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120) == 0) + else if (mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120) == 0) dev_dbg(mmc_dev(host), "Initial signal voltage of 1.2v\n"); /* diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index aee23f5..55f543f 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -49,7 +49,7 @@ struct device_node *mmc_of_find_child_device(struct mmc_host *host, void mmc_set_bus_width(struct mmc_host *host, unsigned int width); u32 mmc_select_voltage(struct mmc_host *host, u32 ocr); int mmc_set_uhs_voltage(struct mmc_host *host, u32 ocr); -int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); +int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); void mmc_set_timing(struct mmc_host *host, unsigned int timing); void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type); int mmc_select_drive_strength(struct mmc_card *card, unsigned int max_dtr, diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index b91abe0..5844f29 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1122,14 +1122,14 @@ static int mmc_select_hs_ddr(struct mmc_card *card) */ err = -EINVAL; if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_1_2V) - err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120); + err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120); if (err && (card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_1_8V)) - err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); + err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); /* make sure vccq is 3.3v after switching disaster */ if (err) - err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330); + err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330); return err; } @@ -1296,10 +1296,10 @@ static int mmc_select_hs400es(struct mmc_card *card) } if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400_1_2V) - err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120); + err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120); if (err && card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400_1_8V) - err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); + err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); /* If fails try again during next card power cycle */ if (err) @@ -1405,10 +1405,10 @@ static int mmc_select_hs200(struct mmc_card *card) old_signal_voltage = host->ios.signal_voltage; if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200_1_2V) - err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120); + err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120); if (err && card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200_1_8V) - err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); + err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); /* If fails try again during next card power cycle */ if (err) @@ -1450,7 +1450,7 @@ static int mmc_select_hs200(struct mmc_card *card) err: if (err) { /* fall back to the old signal voltage, if fails report error */ - if (__mmc_set_signal_voltage(host, old_signal_voltage)) + if (mmc_set_signal_voltage(host, old_signal_voltage)) err = -EIO; pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host), From patchwork Wed Jan 25 15:12:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 92461 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2253712qgi; Wed, 25 Jan 2017 07:12:38 -0800 (PST) X-Received: by 10.25.56.25 with SMTP id f25mr13948069lfa.83.1485357158857; Wed, 25 Jan 2017 07:12:38 -0800 (PST) Return-Path: Received: from mail-lf0-x233.google.com (mail-lf0-x233.google.com. [2a00:1450:4010:c07::233]) by mx.google.com with ESMTPS id r126si14890798lff.7.2017.01.25.07.12.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jan 2017 07:12:38 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::233 as permitted sender) client-ip=2a00:1450:4010:c07::233; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::233 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x233.google.com with SMTP id n124so130207067lfd.2 for ; Wed, 25 Jan 2017 07:12:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P3QgDdPRP3oAP4j3q1lM7jIO4BaD0eet05E6wGGWkwQ=; b=DnQvMb07Lf2rvFuRY14LsgEXImdKiahW95283hkY9cqwMrqX6VULugc1uWTMDZsbaf bCAtB44qr2PgLvz0K23Io1D2voE1ijLpZH8diML2ll3MOu5bqd4tktweFoWBqriReoSj dEeEqptxXWGBMMg1gf5AkS2fPp3LEkO48DD00= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=P3QgDdPRP3oAP4j3q1lM7jIO4BaD0eet05E6wGGWkwQ=; b=cbaMZkzeS9YgsPepD82rFEqAwjTTnC1m+xp7k6Ah5dvpOIWggfGG2EMAE1M8Nryv9W gLC/uviG2JPzIGfMjzv30y/WP8pwN4kLDMMMCvmHlk5PxdEMKbS7qtLTFwCLF/Yb7w2a cmfvd/ZBz/4HXc2G3zPK3DYlE6GZwaaxTTjpFIImqt/z7E2fVmdv+qA4cos8Fua4eoHR JuoEggWu/aQHQ5C3EoSBg3ZrjTTyCBRaYidR5vEg7gB9Qrv++XU1rhZfB5BhtA+/bj0I 71/8DoAnc5yQch3/bldAgyG56zQIYpqlR+EsexX3iiQa9VjxIhwv40q/nmZitao3iQNB I1ew== X-Gm-Message-State: AIkVDXIFrESzg9paCLSvk86ahvckvgBN8SMoKYi9q07MF1x1TOL3SD0ppBAgfJxess2gSBu7rGU= X-Received: by 10.46.87.73 with SMTP id r9mr16247765ljd.22.1485357158240; Wed, 25 Jan 2017 07:12:38 -0800 (PST) Return-Path: Received: from uffe-Latitude-E6430s.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u126sm8397687lja.25.2017.01.25.07.12.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Jan 2017 07:12:37 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Shawn Lin , Stefan Wahren , Fabio Estevam , Jan Glauber Subject: [PATCH 4/6] mmc: core: Invent MMC_CAP_3_3V_DDR Date: Wed, 25 Jan 2017 16:12:21 +0100 Message-Id: <1485357143-23280-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485357143-23280-1-git-send-email-ulf.hansson@linaro.org> References: <1485357143-23280-1-git-send-email-ulf.hansson@linaro.org> According the JEDEC specification an eMMC card supporting 1.8V vccq in DDR mode should also be capable of 3.3V. However, it's been reported that some mmc hosts supports 3.3V, but not 1.8V. Currently the mmc core implements an error handling when the host fails to set 1.8V for vccq, by falling back to 3.3V. Unfortunate, this seems to be insufficient for some mmc hosts. To enable these to use eMMC DDR mode let's invent a new mmc cap, MMC_CAP_3_3V_DDR, which tells whether they support the eMMC 3.3V DDR mode. In case MMC_CAP_3_3V_DDR is set, but not MMC_CAP_1_8V_DDR, let's change to remain on the 3.3V, as it's the default voltage level for vccq, set by the earlier power up sequence. As this change introduces MMC_CAP_3_3V_DDR, let's take the opportunity to do some re-formatting of the related defines in the header file. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc.c | 11 +++++++---- include/linux/mmc/host.h | 21 ++++++++++----------- 2 files changed, 17 insertions(+), 15 deletions(-) -- 1.9.1 diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 5844f29..f1a451e 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -213,7 +213,7 @@ static void mmc_select_card_type(struct mmc_card *card) avail_type |= EXT_CSD_CARD_TYPE_HS_52; } - if (caps & MMC_CAP_1_8V_DDR && + if (caps & (MMC_CAP_1_8V_DDR | MMC_CAP_3_3V_DDR) && card_type & EXT_CSD_CARD_TYPE_DDR_1_8V) { hs_max_dtr = MMC_HIGH_DDR_MAX_DTR; avail_type |= EXT_CSD_CARD_TYPE_DDR_1_8V; @@ -1120,11 +1120,14 @@ static int mmc_select_hs_ddr(struct mmc_card *card) * * WARNING: eMMC rules are NOT the same as SD DDR */ - err = -EINVAL; - if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_1_2V) + if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_1_2V) { err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120); + if (!err) + return 0; + } - if (err && (card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_1_8V)) + if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_1_8V && + host->caps & MMC_CAP_1_8V_DDR) err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); /* make sure vccq is 3.3v after switching disaster */ diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 97699d5..83f1c4a 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -259,17 +259,16 @@ struct mmc_host { #define MMC_CAP_NONREMOVABLE (1 << 8) /* Nonremovable e.g. eMMC */ #define MMC_CAP_WAIT_WHILE_BUSY (1 << 9) /* Waits while card is busy */ #define MMC_CAP_ERASE (1 << 10) /* Allow erase/trim commands */ -#define MMC_CAP_1_8V_DDR (1 << 11) /* can support */ - /* DDR mode at 1.8V */ -#define MMC_CAP_1_2V_DDR (1 << 12) /* can support */ - /* DDR mode at 1.2V */ -#define MMC_CAP_POWER_OFF_CARD (1 << 13) /* Can power off after boot */ -#define MMC_CAP_BUS_WIDTH_TEST (1 << 14) /* CMD14/CMD19 bus width ok */ -#define MMC_CAP_UHS_SDR12 (1 << 15) /* Host supports UHS SDR12 mode */ -#define MMC_CAP_UHS_SDR25 (1 << 16) /* Host supports UHS SDR25 mode */ -#define MMC_CAP_UHS_SDR50 (1 << 17) /* Host supports UHS SDR50 mode */ -#define MMC_CAP_UHS_SDR104 (1 << 18) /* Host supports UHS SDR104 mode */ -#define MMC_CAP_UHS_DDR50 (1 << 19) /* Host supports UHS DDR50 mode */ +#define MMC_CAP_3_3V_DDR (1 << 11) /* Host supports eMMC DDR 3.3V */ +#define MMC_CAP_1_8V_DDR (1 << 12) /* Host supports eMMC DDR 1.8V */ +#define MMC_CAP_1_2V_DDR (1 << 13) /* Host supports eMMC DDR 1.2V */ +#define MMC_CAP_POWER_OFF_CARD (1 << 14) /* Can power off after boot */ +#define MMC_CAP_BUS_WIDTH_TEST (1 << 15) /* CMD14/CMD19 bus width ok */ +#define MMC_CAP_UHS_SDR12 (1 << 16) /* Host supports UHS SDR12 mode */ +#define MMC_CAP_UHS_SDR25 (1 << 17) /* Host supports UHS SDR25 mode */ +#define MMC_CAP_UHS_SDR50 (1 << 18) /* Host supports UHS SDR50 mode */ +#define MMC_CAP_UHS_SDR104 (1 << 19) /* Host supports UHS SDR104 mode */ +#define MMC_CAP_UHS_DDR50 (1 << 20) /* Host supports UHS DDR50 mode */ #define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */ #define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */ #define MMC_CAP_DRIVER_TYPE_D (1 << 25) /* Host supports Driver Type D */ From patchwork Wed Jan 25 15:12:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 92462 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2253726qgi; Wed, 25 Jan 2017 07:12:40 -0800 (PST) X-Received: by 10.25.20.152 with SMTP id 24mr11451727lfu.152.1485357160042; Wed, 25 Jan 2017 07:12:40 -0800 (PST) Return-Path: Received: from mail-lf0-x22b.google.com (mail-lf0-x22b.google.com. [2a00:1450:4010:c07::22b]) by mx.google.com with ESMTPS id a9si12445000lfc.162.2017.01.25.07.12.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jan 2017 07:12:40 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) client-ip=2a00:1450:4010:c07::22b; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22b.google.com with SMTP id z134so130471615lff.3 for ; Wed, 25 Jan 2017 07:12:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VLqz8PBuJ7Dg9UxlvqY8lyrLP9qwsU5ZkE1sGfIm/p4=; b=fsYzcoK3IdbmR1/U/I3WzkNSNFPPHTiQjgcxj5WlqBM9Va8XlvAur7fX+XaLfjCEGh +8Stfa6w3HzQB1ZKWTpNYvoEIo9v8SmQ4gXVuQRRtl6yQNMQeevELoF6oENgsZq8gHOW 0U8nIUbSHoQvVQStMo9IWYRXy3Pb+jYJe6eKc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VLqz8PBuJ7Dg9UxlvqY8lyrLP9qwsU5ZkE1sGfIm/p4=; b=EUy7s4jMxUYR5U2ODlC/sKGGz1ko77g13e2ffUZoX9Ej6fLo+nKOh9Mg3OoPF+6Izv RBmerWGzxKsAcTKBf8qr0AZIj69B/UmaWn/deE3bfKDMo2ji/VA24SIhOnZc35ICM0lv okrIjisV67Km5kEKSuFmaUpjDpoHcmPrjiG8BhXbWKVvqKXIOvGAFAzYIpzx07of56i6 MxLbewYUG6/MEC9nrWy2kEV4KSmta74CtJecQqrSyWHwVAPSUIU3LElIvSp7U2XXzMD+ ymOEv8itImrbhDf4vIlQM6UllH9XyCPWxdg81bdJTqVMXnnrAFVuTyX7VMlSzCT2VGqH nQdw== X-Gm-Message-State: AIkVDXLrIWZkxT9u+ukuE3EdfcHCz/Yfjon76EtKUtKJqOHSgKjgc3g/6zZTHXfIDyL3UjtPucs= X-Received: by 10.46.84.29 with SMTP id i29mr835415ljb.63.1485357159607; Wed, 25 Jan 2017 07:12:39 -0800 (PST) Return-Path: Received: from uffe-Latitude-E6430s.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u126sm8397687lja.25.2017.01.25.07.12.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Jan 2017 07:12:38 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Shawn Lin , Stefan Wahren , Fabio Estevam , Jan Glauber , , Rob Herring Subject: [PATCH 5/6] mmc: dt: Document binding for eMMC DDR 3.3V I/O voltage support Date: Wed, 25 Jan 2017 16:12:22 +0100 Message-Id: <1485357143-23280-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485357143-23280-1-git-send-email-ulf.hansson@linaro.org> References: <1485357143-23280-1-git-send-email-ulf.hansson@linaro.org> Cc: Cc: Rob Herring Signed-off-by: Ulf Hansson --- Documentation/devicetree/bindings/mmc/mmc.txt | 1 + 1 file changed, 1 insertion(+) -- 1.9.1 diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt b/Documentation/devicetree/bindings/mmc/mmc.txt index 8a37782..c7f4a0e 100644 --- a/Documentation/devicetree/bindings/mmc/mmc.txt +++ b/Documentation/devicetree/bindings/mmc/mmc.txt @@ -40,6 +40,7 @@ Optional properties: - cap-mmc-hw-reset: eMMC hardware reset is supported - cap-sdio-irq: enable SDIO IRQ signalling on this interface - full-pwr-cycle: full power cycle of the card is supported +- mmc-ddr-3_3v: eMMC high-speed DDR mode(3.3V I/O) is supported - mmc-ddr-1_8v: eMMC high-speed DDR mode(1.8V I/O) is supported - mmc-ddr-1_2v: eMMC high-speed DDR mode(1.2V I/O) is supported - mmc-hs200-1_8v: eMMC HS200 mode(1.8V I/O) is supported From patchwork Wed Jan 25 15:12:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 92463 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2253744qgi; Wed, 25 Jan 2017 07:12:41 -0800 (PST) X-Received: by 10.46.33.136 with SMTP id h8mr16155902lji.57.1485357161820; Wed, 25 Jan 2017 07:12:41 -0800 (PST) Return-Path: Received: from mail-lf0-x234.google.com (mail-lf0-x234.google.com. [2a00:1450:4010:c07::234]) by mx.google.com with ESMTPS id k30si4111046lfi.236.2017.01.25.07.12.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jan 2017 07:12:41 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::234 as permitted sender) client-ip=2a00:1450:4010:c07::234; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::234 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x234.google.com with SMTP id x1so43804543lff.0 for ; Wed, 25 Jan 2017 07:12:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F9cXCwY0em5vGbNh8XhOIqGz5CQGf4w96WFhJis6QaE=; b=ddwH2E3VXlQ7IDqxYI9RUzfYgJny0aCjjaMet6X+b9VLIxCShXGfn8WalgiXDWn2Ni +A7Q/lUUCwf+42WwhO+OWAol6AORivz+ZRIlsLp1iWVAqNbZfXqODEyEtDRgcY+U0cDd KUGb2wBEhx7if815pKq27fDlRCQQpUL71AZZo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F9cXCwY0em5vGbNh8XhOIqGz5CQGf4w96WFhJis6QaE=; b=bjkX0NcEM0L+o296pD8x0v/Z753T6mxvvPpNym/VCQo/WDpL4W4d/79MFAVZyiIjYk hA3OHBwLSU1ke+PvTqN2E3wmYG1xl7FYIa1Bx3NlSGVMNgnGlKrBgIj341WiKtl5lfDJ hpIYwcHE5klm9BfdtqZR8HzZl7xiLcfXA4/tAKd8nSvO1il+xDa2v/V26MmtX/LSZ3wS SG6XEnkl0xu37/okSM2dbyeBlWmMTV7QSeVUSqDYcSJovZh/aaRG2x/0lvFwRa4+1tcK ftD12t7n1gTGmpESyuRydu7InHwOCWNM5iCkKbIdqwTJoMuJTjcj6H2Ov3Ue8rIiJOug eSfw== X-Gm-Message-State: AIkVDXLCZ+NZRtMDFGdtJbaFtmf0HLrQ40DbgQ+ga4Xpz33oNs4gHvZHbKDWe15B0Tymrgc+Xf4= X-Received: by 10.46.76.1 with SMTP id z1mr15279043lja.48.1485357161394; Wed, 25 Jan 2017 07:12:41 -0800 (PST) Return-Path: Received: from uffe-Latitude-E6430s.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u126sm8397687lja.25.2017.01.25.07.12.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Jan 2017 07:12:40 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Shawn Lin , Stefan Wahren , Fabio Estevam , Jan Glauber Subject: [PATCH 6/6] mmc: core: Extend mmc_of_parse() to check for mmc-ddr-3_3v Date: Wed, 25 Jan 2017 16:12:23 +0100 Message-Id: <1485357143-23280-7-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485357143-23280-1-git-send-email-ulf.hansson@linaro.org> References: <1485357143-23280-1-git-send-email-ulf.hansson@linaro.org> When mmc_of_parse() finds the binding, it sets the mmc cap, MMC_CAP_3_3V_DDR, which informs the core whether eMMC DDR at 3.3V I/O is supported by the mmc host. Signed-off-by: Ulf Hansson --- drivers/mmc/core/host.c | 2 ++ 1 file changed, 2 insertions(+) -- 1.9.1 diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 98f25ff..8f75a84 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -301,6 +301,8 @@ int mmc_of_parse(struct mmc_host *host) if (of_property_read_bool(np, "wakeup-source") || of_property_read_bool(np, "enable-sdio-wakeup")) /* legacy */ host->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; + if (of_property_read_bool(np, "mmc-ddr-3_3v")) + host->caps |= MMC_CAP_3_3V_DDR; if (of_property_read_bool(np, "mmc-ddr-1_8v")) host->caps |= MMC_CAP_1_8V_DDR; if (of_property_read_bool(np, "mmc-ddr-1_2v"))