From patchwork Sat Jun 13 20:24:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 6603421 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 633719F2F4 for ; Sat, 13 Jun 2015 20:25:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5283D206FA for ; Sat, 13 Jun 2015 20:25:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2DA1A206F9 for ; Sat, 13 Jun 2015 20:25:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751187AbbFMUZF (ORCPT ); Sat, 13 Jun 2015 16:25:05 -0400 Received: from mail-qk0-f178.google.com ([209.85.220.178]:34319 "EHLO mail-qk0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751125AbbFMUZE (ORCPT ); Sat, 13 Jun 2015 16:25:04 -0400 Received: by qkdm188 with SMTP id m188so12432147qkd.1 for ; Sat, 13 Jun 2015 13:25:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=631PmCF43a+EtI+Ky12CZG8Mn4YAJIdspDaPb5oVM6k=; b=kXKX/YZWI4zhtKTcU/WJX/EYFXsV3sIhLYE1Y3KydhYE0X8HUma6mjDqVinwPETCAX aKI0g6uLklc/TZ6DRlBlSing28qIqg0Q2Tr2djDCFlB3ntGuKs78mSt5IuDQpoyskKN2 RLF6WIlb5BCNRxBvN6iJmqA1GpvwxseRiXvjPkYWTloeYRyhtWM2b9FivyuHdyoyXOdA VHMIJl37QbJkJQMZQIpKJUhXjkNahwMhMBRziQPezLXVYnc6YoJB6T/jaa287B2i+1Gw TlwD6eUVdC58vzVjU0XxdcM67PXOfqLRB8Gn9PZStKSjrspQyYv8dEuKzCXBa2moUGc9 Xa5A== X-Received: by 10.140.88.5 with SMTP id s5mr15972560qgd.59.1434227103601; Sat, 13 Jun 2015 13:25:03 -0700 (PDT) Received: from localhost.localdomain ([189.101.187.123]) by mx.google.com with ESMTPSA id 17sm3657202qhd.45.2015.06.13.13.24.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 13 Jun 2015 13:25:02 -0700 (PDT) From: Fabio Estevam To: ulf.hansson@linaro.org Cc: aisheng.dong@freescale.com, kevin.lemoi@savant.com, otavio@ossystems.com.br, kernel@pengutronix.de, linux@arm.linux.org.uk, chuanxiao.dong@intel.com, linux-mmc@vger.kernel.org, Fabio Estevam Subject: [PATCH v2] mmc: core: Do not set mmc voltage to 1.8V when 'no-1-8-v' is present Date: Sat, 13 Jun 2015 17:24:27 -0300 Message-Id: <1434227067-9600-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabio Estevam Since commit 312449efd16bb06 ("mmc: core: Fix sequence for I/O voltage in DDR mode for eMMC") the mmc voltage is set to 1.8V inside mmc_select_hs_ddr(), even if 'no-1-8-v' property is present. This causes the following error on a mx6sl board with the 'no-1-8-v' property passed in the device tree: mmc0: power class selection to bus width 8 ddr 4 failed mmc0: error -110 whilst initialising MMC card Fix this problem by only setting the mmc voltage to 1.8V if the 'no-1-8-v' property is absent. Reported-by: Kevin Lemoi Signed-off-by: Fabio Estevam Acked-by: Otavio Salvador --- Changes since v1: - Fix it in the core code instead of doing it inside the sdhci imx code drivers/mmc/core/host.c | 2 ++ drivers/mmc/core/mmc.c | 8 +++++++- include/linux/mmc/host.h | 1 + include/linux/mmc/mmc.h | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 01fa1ed..736c985 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -527,6 +527,8 @@ int mmc_of_parse(struct mmc_host *host) host->caps2 |= MMC_CAP2_HS400_1_8V | MMC_CAP2_HS200_1_8V_SDR; if (of_find_property(np, "mmc-hs400-1_2v", &len)) host->caps2 |= MMC_CAP2_HS400_1_2V | MMC_CAP2_HS200_1_2V_SDR; + if (of_find_property(np, "no-1-8-v", &len)) + host->caps2 |= MMC_CAP_3_3V_ONLY_DDR; host->dsr_req = !of_property_read_u32(np, "dsr", &host->dsr); if (host->dsr_req && (host->dsr & ~0xffff)) { diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index e726903..e76b9af 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -205,6 +205,10 @@ static void mmc_select_card_type(struct mmc_card *card) avail_type |= EXT_CSD_CARD_TYPE_DDR_1_8V; } + if (caps2 & MMC_CAP_3_3V_ONLY_DDR && + card_type & EXT_CSD_CARD_TYPE_DDR_1_8V) + avail_type |= EXT_CSD_CARD_TYPE_DDR_3_3V_ONLY; + if (caps & MMC_CAP_1_2V_DDR && card_type & EXT_CSD_CARD_TYPE_DDR_1_2V) { hs_max_dtr = MMC_HIGH_DDR_MAX_DTR; @@ -1028,7 +1032,9 @@ static int mmc_select_hs_ddr(struct mmc_card *card) 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); + if (!(card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_3_3V_ONLY)) + err = __mmc_set_signal_voltage(host, + MMC_SIGNAL_VOLTAGE_180); /* make sure vccq is 3.3v after switching disaster */ if (err) diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 1369e54..5aa999f 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -289,6 +289,7 @@ struct mmc_host { #define MMC_CAP2_HSX00_1_2V (MMC_CAP2_HS200_1_2V_SDR | MMC_CAP2_HS400_1_2V) #define MMC_CAP2_SDIO_IRQ_NOTHREAD (1 << 17) #define MMC_CAP2_NO_WRITE_PROTECT (1 << 18) /* No physical write protect pin, assume that card is always read-write */ +#define MMC_CAP_3_3V_ONLY_DDR (1 << 19) /* Only supports 3.3V DDR */ mmc_pm_flag_t pm_caps; /* supported pm features */ diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index 15f2c4a..b3cbd3c 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h @@ -380,6 +380,7 @@ struct _mmc_csd { #define EXT_CSD_CARD_TYPE_HS400_1_2V (1<<7) /* Card can run at 200MHz DDR, 1.2V */ #define EXT_CSD_CARD_TYPE_HS400 (EXT_CSD_CARD_TYPE_HS400_1_8V | \ EXT_CSD_CARD_TYPE_HS400_1_2V) +#define EXT_CSD_CARD_TYPE_DDR_3_3V_ONLY (1<<8) #define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */ #define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */