From patchwork Fri May 12 18:16:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 99726 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp444359qge; Fri, 12 May 2017 11:28:27 -0700 (PDT) X-Received: by 10.80.183.100 with SMTP id g91mr4480415ede.86.1494613707660; Fri, 12 May 2017 11:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494613707; cv=none; d=google.com; s=arc-20160816; b=w3a4Hs07jvAs241yZTDl3TTtVS7SNaFFeuNTxMb2ebC/3NLm8AD2xP3KQ8blxQViCL GkICfM1ryPvCjRC3waLXczcysM1rA9c7tqQ73psf2ckwGSHnu7EdxKX7X30VnUBK9Bg7 YdQMNEklS93q/9kln7woP7mkqI8aaTqJJ5Jf4ZlQQ1ELv7kOBcYnfpcEShs44KNJX5WW bg9DHJadQUoaBdn/+PQ3IfBlJvOJvypfn1gNDrrGSQo2Ik6LRB1X/lbD9iA4/EHI2Vyq uDbEKr/C5Bpq6T9PjtEfIl9vecg+WgSbwT8pLK5qN/KRuazjVG/ivd1Kq8SL4l/3oBd3 cD+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=s22L61f70iYG8QKeFckvnOwZhGgFZSjnaFSkRyHgATY=; b=a3jiWmG5o0hYBgtlR3/1q0dT3FKaHT0IL7Gf9fMahLSfRAItGz+5VVgHI1nY23bEdw KIw6wxjCIZucfpRo/z1oBQzQQ3KL7S7mwAEIRvNywhJb1ZgkSYZZSX84Ftl5lohl92a7 ueYBhIUS81rbzB3Qj1WrlQ4sDUpmUwVIcmi1rRqxN4s+JkzlpdM2BscUUtIHMb6naKRK GDH9LwgI6jVvI7W1f+uanf9+NrD9nBFtGmRe2rt6Y6hFraDu5Ooq4/2b3ORMORNarMLk zEQCNN+LPMKPcnOorsMewPBi0Zzj2QPYsFgRTyambmC9+0aWM1VVJ1eP+U3CmObaR6Pm oz3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id r4si5257962edr.245.2017.05.12.11.28.27; Fri, 12 May 2017 11:28:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ti.com Received: by lists.denx.de (Postfix, from userid 105) id 35E7DC21FE4; Fri, 12 May 2017 18:22:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D9C29C22032; Fri, 12 May 2017 18:19:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CE95AC2202C; Fri, 12 May 2017 18:17:55 +0000 (UTC) Received: from fllnx209.ext.ti.com (fllnx209.ext.ti.com [198.47.19.16]) by lists.denx.de (Postfix) with ESMTPS id 6C16CC22025 for ; Fri, 12 May 2017 18:17:49 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v4CIH2mr003483; Fri, 12 May 2017 13:17:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1494613022; bh=f94Kd5TPP3XSEozfef8kJEU9bgrnlf69TQy/huk0XAE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=impq3oEf9em2COPtt/4HF4DoDcHwYtkVe2vveGJnG0g7bHkLCDOj9XEZjOXv0Nrju aJsUxMQ/F39gWEsu/JZZnIizsoneG8S0DWnf3I+kv9UUZMtt5GmZMkKLni2JATZt2n gQyHfmiC9jC9OdskzYBqhnGDDqE63RWIIy9nBXfg= Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v4CIGvaE015154; Fri, 12 May 2017 13:16:57 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.294.0; Fri, 12 May 2017 13:16:57 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v4CIGuZY002903; Fri, 12 May 2017 13:16:57 -0500 From: Jean-Jacques Hiblot To: , , , , Date: Fri, 12 May 2017 20:16:30 +0200 Message-ID: <1494613000-8156-13-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1494613000-8156-1-git-send-email-jjhiblot@ti.com> References: <1494613000-8156-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 12/22] mmc: Enable signal voltage to be selected from mmc core X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Kishon Vijay Abraham I Add a new function *mmc_set_signal_voltage* in mmc core which can be used during mmc initialization to select the signal voltage. Platform driver should use the set_ios callback function to select the signal voltage. Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Jean-Jacques Hiblot --- drivers/mmc/mmc.c | 15 +++++++++++++++ include/mmc.h | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 2ae6f1c..10af81d 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -29,6 +29,7 @@ static const unsigned int sd_au_size[] = { SZ_4M / 512, SZ_8M / 512, (SZ_8M + SZ_4M) / 512, SZ_16M / 512, (SZ_16M + SZ_8M) / 512, SZ_32M / 512, SZ_64M / 512, }; +static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage); #if CONFIG_IS_ENABLED(MMC_TINY) static struct mmc mmc_static; @@ -1247,6 +1248,12 @@ struct mode_width_tuning { uint widths; }; +static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage) +{ + mmc->signal_voltage = signal_voltage; + return mmc_set_ios(mmc); +} + static const struct mode_width_tuning sd_modes_by_pref[] = { { .mode = SD_HS, @@ -1935,6 +1942,14 @@ int mmc_start_init(struct mmc *mmc) return err; #endif mmc->ddr_mode = 0; + + /* First try to set 3.3V. If it fails set to 1.8V */ + err = mmc_set_signal_voltage(mmc, MMC_SIGNAL_VOLTAGE_330); + if (err != 0) + err = mmc_set_signal_voltage(mmc, MMC_SIGNAL_VOLTAGE_180); + if (err != 0) + printf("failed to set signal voltage\n"); + mmc_set_bus_width(mmc, 1); mmc_set_clock(mmc, 1); diff --git a/include/mmc.h b/include/mmc.h index 9f20eb4..89cb26c 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -266,6 +266,10 @@ #define ENHNCD_SUPPORT (0x2) #define PART_ENH_ATTRIB (0x1f) +#define MMC_SIGNAL_VOLTAGE_330 1 +#define MMC_SIGNAL_VOLTAGE_180 2 +#define MMC_SIGNAL_VOLTAGE_120 3 + /* Maximum block size for MMC */ #define MMC_MAX_BLOCK_LEN 512 @@ -452,6 +456,7 @@ struct mmc { int high_capacity; uint bus_width; uint clock; + uint signal_voltage; uint card_caps; uint ocr; uint dsr;