From patchwork Thu Sep 21 14:30:00 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: 113266 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2110107qgf; Thu, 21 Sep 2017 07:43:22 -0700 (PDT) X-Google-Smtp-Source: AOwi7QA8c+1xwrnZPxJMCI/iQ9f8OnprnsrOou43r0ZuuKnStnlauPxFRCF6ldrTH+ujarqp5yhv X-Received: by 10.80.211.18 with SMTP id g18mr1406520edh.85.1506005001923; Thu, 21 Sep 2017 07:43:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506005001; cv=none; d=google.com; s=arc-20160816; b=bSdPEmi4Af3Fqnhmp6RxwWXiLhlHTWY3P3ehJbUP+M/xku6MOl57ZSy3Nf+Sk+I4Sy yFQzgvcH/zlZtRTWYin0trHFdRyFNiC/Bf/gVoDs4Zc5I5DGYnnjgg9yTNBzl2/B4jqH 2bK+zSuvWL2Ts4v9sMTqiaMHrWje/UawWLK2Q99uiC8nca0g+A/PzXj7oabAYjWuvL0q Xe8vqGCl7YrR8VyYln8el6vT+1NRgJc373mjq1b7Kb+KacaEPo1GFqUCAcxaJRJHGrOC 2dnVP7lnhHqMjNS5PouuIQ9Vw6ze8FOd7PC38qif4ktliVEQQ4ilf4QcWZNqoajUnfPp a/6g== 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=MHFBmS96/Kkr13kJzIyYqJqnwC85eDQcQ9nQjyvAOb8=; b=oVYRxonfJaR3eOqHbI5BB4VpBX5E+K+uUnESCD26VR5Ra4s7p721sDMYsf7qpyOcyB ABycoxbPHCElr8w0mIJsjvOEUEZycojLymrrqmS5VQkS0BzcL/YbefwIS24ZqeFLnKQH 9V8OD+TpAEDsEfMJ+aFrawoXzToemP+ftHzA6yPagjOjcRVZWWifVqsU5TS66LmOXBue NAN8NvLwHnGsJN/kOk45FwpZWtES+zYWn6qxZZCxsoQvY7TekmPLMjp9JK4Vjwyh8wDl HUk64kFZNcLLv+8bFViLp0zBSEc4yny3igbuqmN0U9D1Z9z4LBet5I9vsYwcbfoQLVo2 mmMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=g/wEeBMD; 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=QUARANTINE 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 m13si1537163edi.514.2017.09.21.07.43.21; Thu, 21 Sep 2017 07:43:21 -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 header.s=ti-com-17Q1 header.b=g/wEeBMD; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: by lists.denx.de (Postfix, from userid 105) id 87A4FC22039; Thu, 21 Sep 2017 14:34:11 +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 F0AA9C21F52; Thu, 21 Sep 2017 14:31:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 50818C2202E; Thu, 21 Sep 2017 14:30:54 +0000 (UTC) Received: from fllnx210.ext.ti.com (fllnx210.ext.ti.com [198.47.19.17]) by lists.denx.de (Postfix) with ESMTPS id 4447EC21E28 for ; Thu, 21 Sep 2017 14:30:49 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8LEUlbr000377; Thu, 21 Sep 2017 09:30:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1506004247; bh=+Pe0zj/9yX2c/sleIqyFyUQyVy9MoyToooyFFHZCEIk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=g/wEeBMD4KjOeBCUZ+70+Dt+MtlWlhTd13pIljLAV+MaED/Rt9RojzdC2tV5WXUJi 1sDclEQiSq8+sK7wIVC+p8Ma1v1pbgBnBqrQnokClswc5FuzqOKeNMFtgHG/hDcYG3 AffwttUffGWvmmOgLU/Pq0DHJaz+/TSiUx54v5Lk= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEUl15019865; Thu, 21 Sep 2017 09:30:47 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Thu, 21 Sep 2017 09:30:46 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Thu, 21 Sep 2017 09:30:46 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEUjxX016438; Thu, 21 Sep 2017 09:30:45 -0500 From: Jean-Jacques Hiblot To: , , , Date: Thu, 21 Sep 2017 16:30:00 +0200 Message-ID: <1506004213-22620-14-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506004213-22620-1-git-send-email-jjhiblot@ti.com> References: <1506004213-22620-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 13/26] 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 | 16 ++++++++++++++++ include/mmc.h | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 536cd7f..46ec5e1 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -30,6 +30,8 @@ static const unsigned int sd_au_size[] = { 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; struct mmc *find_mmc_device(int dev_num) @@ -1257,6 +1259,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, @@ -1964,6 +1972,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 3e57887..e524963 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -272,6 +272,13 @@ #define ENHNCD_SUPPORT (0x2) #define PART_ENH_ATTRIB (0x1f) +enum mmc_voltage { + MMC_SIGNAL_VOLTAGE_000 = 0, + MMC_SIGNAL_VOLTAGE_120, + MMC_SIGNAL_VOLTAGE_180, + MMC_SIGNAL_VOLTAGE_330 +}; + /* Maximum block size for MMC */ #define MMC_MAX_BLOCK_LEN 512 @@ -457,6 +464,7 @@ struct mmc { int high_capacity; uint bus_width; uint clock; + enum mmc_voltage signal_voltage; uint card_caps; uint ocr; uint dsr;