From patchwork Thu Sep 21 14:29:59 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: 113262 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1965143edb; Thu, 21 Sep 2017 07:41:17 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAH0ws4djxPnM5y4u5eNWkJ4DT5gHWEJDURZjnvxW7ClDaNDaahPTt7IaalUIVDgkutrl7N X-Received: by 10.80.130.164 with SMTP id 33mr1387142edg.223.1506004876816; Thu, 21 Sep 2017 07:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506004876; cv=none; d=google.com; s=arc-20160816; b=Vw6b1nf9CE/LNucQWnM/d0MqAa+cURY4fnHKKGoETkyighUsUkzC1dYE3+RSSsB8Cc 489RbVPYU+Xbf5ILJDqol21yYcD8t+QWZyniM9fUPmB2+tS6zrcFe3P6Hd4Bza1t/90x f46BOPvJRe3q2VXPNKldJcxHlBa45BaJ90CR86VQuXGb/cCR1pxzGDIieFFfbiilA3S1 TB0RLoO82Fxxl3AYTadvE8s/Lfrh8HvgSGMpnou8pArN/c0yZrM5YoOOwb5GwrEnPPyQ oK5Q6f2xBEFiuO81vZsvau+Fqzb09Nnhu/YzRRygaxI79wfriuRL+8tHCwW343brkv8W oZIQ== 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=VEKnA2bjsXj33xEO3laRB/OighirXcUVypCzz9fpCYo=; b=e5BTCg3hCHyGMH09SnHEBmLideScIX4lbZabfF68oNVI5DXhykRiSZ43F5drxmEPh/ nwk9QcJROOn+ZfSJoeocy2GZrAQaYznhpK3sXpIpOxPEW5SOKuDPN5UKpkdaBbEuKaX2 BNiFusYSuIwpVqpq+1ey4HAVQ0J9Cr9nr3aVGbcq09573g6I/0pweP5JTyLRN+1yBeqj U6O4mGOONs7+avuYK0JnraGtuU7LxTJm6+y0j7AwuJ/rD+oSNvtLyZqYSL/lUVsUNogt 9aJx6wzO6Mv4Z88JXZCsUXgDdJ4RIVjQnFOwpyiAWQm7jq6bUZQpcfmjq7AoGGYrJPHB Q6dw== 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=f27aPRqu; 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 j7si1130125edh.504.2017.09.21.07.41.16; Thu, 21 Sep 2017 07:41:16 -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=f27aPRqu; 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 5311EC21F14; Thu, 21 Sep 2017 14:37:16 +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 83512C21FF9; Thu, 21 Sep 2017 14:33:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 51237C21E41; Thu, 21 Sep 2017 14:31: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 D3B59C21FEA for ; Thu, 21 Sep 2017 14:31:51 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8LEUnrf032481; Thu, 21 Sep 2017 09:30:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1506004249; bh=uGHpL8onwZDomzKprZnBokdV9n4cieq8NeeM7RszJy0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=f27aPRquy28T/ZHbQ3UM0hnc9s1dvLuyWe3HA4CzyS8YrICwXIStGeW0MLcFOTN2d U9+Hnf3CTq4pQ6Do2T5+IvdSMo69xpk98/ax6FztF6xfXFYfHadwXnYBrY/eFofRch oul3rpTdSchcChMtMNXNW452halosw/JttUnWWP0= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEUiAh028772; Thu, 21 Sep 2017 09:30:44 -0500 Received: from DFLE100.ent.ti.com (10.64.6.21) by DFLE104.ent.ti.com (10.64.6.25) 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:44 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE100.ent.ti.com (10.64.6.21) 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:44 -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 v8LEUgt3000905; Thu, 21 Sep 2017 09:30:43 -0500 From: Jean-Jacques Hiblot To: , , , Date: Thu, 21 Sep 2017 16:29:59 +0200 Message-ID: <1506004213-22620-13-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 12/26] mmc: make mmc_set_ios() return status 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 set_ios callback has a return value of 'int' but the mmc_set_ios() function ignore this. Modify mmc_set_ios() and the callers of mmc_set_ios() to to return the error status. Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Simon Glass --- drivers/mmc/mmc.c | 16 ++++++++++------ include/mmc.h | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 7361447..536cd7f 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1196,14 +1196,18 @@ static inline int bus_width(uint cap) } #if !CONFIG_IS_ENABLED(DM_MMC) -static void mmc_set_ios(struct mmc *mmc) +static int mmc_set_ios(struct mmc *mmc) { + int ret = 0; + if (mmc->cfg->ops->set_ios) - mmc->cfg->ops->set_ios(mmc); + ret = mmc->cfg->ops->set_ios(mmc); + + return ret; } #endif -void mmc_set_clock(struct mmc *mmc, uint clock) +int mmc_set_clock(struct mmc *mmc, uint clock) { if (clock > mmc->cfg->f_max) clock = mmc->cfg->f_max; @@ -1213,14 +1217,14 @@ void mmc_set_clock(struct mmc *mmc, uint clock) mmc->clock = clock; - mmc_set_ios(mmc); + return mmc_set_ios(mmc); } -static void mmc_set_bus_width(struct mmc *mmc, uint width) +static int mmc_set_bus_width(struct mmc *mmc, uint width) { mmc->bus_width = width; - mmc_set_ios(mmc); + return mmc_set_ios(mmc); } #if CONFIG_IS_ENABLED(MMC_VERBOSE) || defined(DEBUG) diff --git a/include/mmc.h b/include/mmc.h index 988bf17..3e57887 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -549,7 +549,7 @@ int mmc_unbind(struct udevice *dev); int mmc_initialize(bd_t *bis); int mmc_init(struct mmc *mmc); int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size); -void mmc_set_clock(struct mmc *mmc, uint clock); +int mmc_set_clock(struct mmc *mmc, uint clock); struct mmc *find_mmc_device(int dev_num); int mmc_set_dev(int dev_num); void print_mmc_devices(char separator); 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; From patchwork Thu Sep 21 14:30:02 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: 113267 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2112133qgf; Thu, 21 Sep 2017 07:45:25 -0700 (PDT) X-Google-Smtp-Source: AOwi7QA7h9rh+FV9XQKpYnTZBcS60Rcy9XE/H2eArRVW+1fVVtrA/hg+zsoet/Od0enomkV8ZIdS X-Received: by 10.80.208.208 with SMTP id g16mr1437336edf.246.1506005125465; Thu, 21 Sep 2017 07:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506005125; cv=none; d=google.com; s=arc-20160816; b=f4RbDlC5sYatWUV6X7eyPaVPLxaIKyYk0++2xZIRG259Qzh/fTYidd82I309W6ZSUc dHSkBOQyjdPvV8HhzSUlF5x/bFvvwfWcq4dwwYmD6mcuBD/r4DSiOIyZvlypvR2za4dz WTaUSQA3g50UxT9ak/EV/G3+81MCt5b23dox0hpR8QP+BSUbeZu2BJBySzfujBJyX39N QD/urXe9R2oze6wGyw9CpliFKuLgQImZmCz14S3D7QmJ/lnk3P3mIEhmcGGFKojeEjfi 1KmO6B+zPFYneo5KA+bcbKNGJ/NZrrvfBgRLc+kzcOd6KOimp0jhLqAJ7cAAszyOmneq Hd8A== 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=ey50nhY9ljIhGAhWSxdsSyUfdlorzD3z2QOPoeEY8m0=; b=eoIx1wxFauIzPtQ+H1C/Ip0nsgs6Z0zxQ1xOXSdgJtt2UicfJ83WRIpUuOC1LwgnlV CSQ5w9aMg2SIcnQiWSOHaT0OpeUutVvV4aXVQSNG7ifyL3AeIP5Zd1T5TRrGZFpgWuIN Fp0faFg0vKqR6YRp5jtCzHH+wbZICaw4FQRlppb3vKB3D6AyZRHhIvsfH8+QVL2DQiGo nwkL2fJE8fE+o+JMBejleiOJhpcMao/G7RoCVQMYI64Qm3IMnBoUoq1Arc25FA5eMCgE 5qoyM4S1gau0JAPRJmI0lZ96eq/DPlRyb8hO8JJbj/HLjyiCpPoUaB2Xou4mSIuBFc8+ lQ7w== 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=OvopDU7m; 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 q7si1387010edk.133.2017.09.21.07.45.24; Thu, 21 Sep 2017 07:45:25 -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=OvopDU7m; 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 79352C22071; Thu, 21 Sep 2017 14:41:09 +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 C0693C22024; Thu, 21 Sep 2017 14:41:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 414A0C2201E; Thu, 21 Sep 2017 14:32:02 +0000 (UTC) Received: from fllnx209.ext.ti.com (fllnx209.ext.ti.com [198.47.19.16]) by lists.denx.de (Postfix) with ESMTPS id 67853C21DE8 for ; Thu, 21 Sep 2017 14:31:58 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8LEUudX032518; Thu, 21 Sep 2017 09:30:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1506004256; bh=dKZ+yBw45etXUSBH/wCAno0KXwqw5GQBUoJfEDv5Qyw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=OvopDU7m0p020rnu1thbdCL2w3Ls3ynaG06Cl2xYgvHyE0Zt/GsnQCKroPCoAcACD 9NBdW2igPdPtQaMc1sBJ7L8YZ9/yih9Ivhi9bM1LEeOeHMjlE64OB2dNqyL3+4BQgs DOtlXsQKn8ygLkqNK0VlQxnsMwVmJKS7sSdxKAzk= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEUpNn028848; Thu, 21 Sep 2017 09:30:51 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE100.ent.ti.com (10.64.6.21) 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:51 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE111.ent.ti.com (10.64.6.32) 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:50 -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 v8LEUnbk000995; Thu, 21 Sep 2017 09:30:50 -0500 From: Jean-Jacques Hiblot To: , , , Date: Thu, 21 Sep 2017 16:30:02 +0200 Message-ID: <1506004213-22620-16-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 15/26] mmc: add power cyle support in 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 mmc/sd specification requires vdd to be disabled for 1 ms and then enabled again during power cycle. Add a function in mmc core to perform power cycle and set the io signal to it's initial state. Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Jean-Jacques Hiblot --- drivers/mmc/mmc.c | 88 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 71 insertions(+), 17 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index fd93691..65a3d8e 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -31,6 +31,7 @@ static const unsigned int sd_au_size[] = { }; static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage); +static int mmc_power_cycle(struct mmc *mmc); #if CONFIG_IS_ENABLED(MMC_TINY) static struct mmc mmc_static; @@ -1920,25 +1921,83 @@ static int mmc_power_init(struct mmc *mmc) &mmc->vqmmc_supply); if (ret) debug("%s: No vqmmc supply\n", mmc->dev->name); +#endif +#else /* !CONFIG_DM_MMC */ + /* + * Driver model should use a regulator, as above, rather than calling + * out to board code. + */ + board_mmc_power_init(); +#endif + return 0; +} + +/* + * put the host in the initial state: + * - turn on Vdd (card power supply) + * - configure the bus width and clock to minimal values + */ +static void mmc_set_initial_state(struct mmc *mmc) +{ + int err; + + /* 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("mmc: failed to set signal voltage\n"); + + mmc_select_mode(mmc, MMC_LEGACY); + mmc_set_bus_width(mmc, 1); + mmc_set_clock(mmc, 0); +} +static int mmc_power_on(struct mmc *mmc) +{ +#if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_REGULATOR) if (mmc->vmmc_supply) { - ret = regulator_set_enable(mmc->vmmc_supply, true); + int ret = regulator_set_enable(mmc->vmmc_supply, true); + if (ret) { puts("Error enabling VMMC supply\n"); return ret; } } #endif -#else /* !CONFIG_DM_MMC */ - /* - * Driver model should use a regulator, as above, rather than calling - * out to board code. - */ - board_mmc_power_init(); + return 0; +} + +static int mmc_power_off(struct mmc *mmc) +{ +#if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_REGULATOR) + if (mmc->vmmc_supply) { + int ret = regulator_set_enable(mmc->vmmc_supply, false); + + if (ret) { + puts("Error disabling VMMC supply\n"); + return ret; + } + } #endif return 0; } +static int mmc_power_cycle(struct mmc *mmc) +{ + int ret; + + ret = mmc_power_off(mmc); + if (ret) + return ret; + /* + * SD spec recommends at least 1ms of delay. Let's wait for 2ms + * to be on the safer side. + */ + udelay(2000); + return mmc_power_on(mmc); +} + int mmc_start_init(struct mmc *mmc) { bool no_card; @@ -1967,6 +2026,10 @@ int mmc_start_init(struct mmc *mmc) if (err) return err; + err = mmc_power_on(mmc); + if (err) + return err; + #if CONFIG_IS_ENABLED(DM_MMC) /* The device has already been probed ready for use */ #else @@ -1977,16 +2040,7 @@ int mmc_start_init(struct mmc *mmc) #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); - + mmc_set_initial_state(mmc); mmc_send_init_stream(mmc); /* Reset the Card */ From patchwork Thu Sep 21 14:30:03 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: 113261 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1963817edb; Thu, 21 Sep 2017 07:39:58 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDseoGTnx0DfQkpkm6XKv9/AdQhTorcm+KCzOOLDRzY42uAOdVseqsNJs8GbISVHXR5r62E X-Received: by 10.80.144.202 with SMTP id d10mr1452524eda.254.1506004798841; Thu, 21 Sep 2017 07:39:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506004798; cv=none; d=google.com; s=arc-20160816; b=0liL76ZiduxnIfq9thkJ7Jgonzm8NdqQPjNVMvhT7xTKEYn/MO3V5p0HutcHuEA5SK xmQPEfsMeewx17pfjhI4UFwH1hY4IH5grm+3auL/OqvXzVfm7Oim70c6mMswaQWhbm5G b/s8MJ+TXG79MU+MlGo2vzxLOPlDfQiniU57upCaXqF2qQ/tRaVttmGWN1Ijqy9ypprB tX6GUXl2IZm0zndiGKOBn/SkiMs+f4agVRLrpHhtmHEVIGsQBg1w8/yjCPBZQS1jPXHj wkuUDPafPPU+5fuY+OaSSLQI0Pe6X25pM7f2N914dJr/P9zoME2S887aJueYqBZa6ofW 3sQQ== 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=e2Epp2iARyCkMRhGHocRaFf8mYUhltDVe/o7ukuUxBw=; b=jNGplbPACDxY3uaZmZQOY43ToEQGFqMJHf2JXWnZ05XAaftGksMU0ihEoHgXiE87ZE Os4bUj/wRf2pLWzM+EIathSGpphgbITDQqrq4GGO8LdpX4JfQlG/r+q/zD+ILth5sYuY YhCDGCC7lCVSfwvPSSh0ZjGiYwZtb1aFRR/UXF2F1a3yoa8GgReDm5QXntK4SBoUm793 oIl1WBC877QPO3kdlIbHfpXYoRUoGdcrFXdjdQkrN8+MsVoKdqRNeKeJ94Jowhka2ZSv gVQtc5VQ2uaGIAqBAyhcOwaCBKyP5YDmDAEn6o7dcdDzduZQl3LmlZ1fFWQ47Jnj/GE1 vuFA== 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=te/4QAvk; 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 c54si1657693edb.86.2017.09.21.07.39.58; Thu, 21 Sep 2017 07:39:58 -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=te/4QAvk; 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 7675DC2200C; Thu, 21 Sep 2017 14:33:19 +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 94E7DC21FED; Thu, 21 Sep 2017 14:31:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B83B5C21E26; Thu, 21 Sep 2017 14:31:01 +0000 (UTC) Received: from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by lists.denx.de (Postfix) with ESMTPS id 686DBC21F29 for ; Thu, 21 Sep 2017 14:30:55 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8LEUrJ8002906; Thu, 21 Sep 2017 09:30:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1506004253; bh=K/1ytV+kbJP91flCpWSRiJro8WE1E6mPMBoZPTHK2f4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=te/4QAvkZc9WkraHCNbPtZjScir+lDiz3ri/Z9xQ1KRsq1q22rA7tTO5yl2NPEo7B +7zL6iyqvmHIQTaIeIdfXGu0onNqjgOAPEh6+h1HP/VICrgdLd4ZMvpJt8hC4Br3a3 3ll8rtDldWFRD4iJZBi+KrLb2Jqc8AWdBfLEttoU= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEUrKj019948; Thu, 21 Sep 2017 09:30:53 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE100.ent.ti.com (10.64.6.21) 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:53 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE111.ent.ti.com (10.64.6.32) 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:53 -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 v8LEUpGV016484; Thu, 21 Sep 2017 09:30:52 -0500 From: Jean-Jacques Hiblot To: , , , Date: Thu, 21 Sep 2017 16:30:03 +0200 Message-ID: <1506004213-22620-17-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 16/26] mmc: add a new mmc parameter to disable mmc clock 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 mmc clock has to be disabled in certain cases like during the voltage switch sequence. Modify mmc_set_clock function to take disable as an argument that signifies if the clock has to be enabled or disabled. Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Jean-Jacques Hiblot --- drivers/mmc/fsl_esdhc.c | 2 +- drivers/mmc/mmc.c | 11 ++++++----- include/mmc.h | 12 +++++++++++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index cc188c4..6b52c6a 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -665,7 +665,7 @@ static int esdhc_init_common(struct fsl_esdhc_priv *priv, struct mmc *mmc) #endif /* Set the initial clock speed */ - mmc_set_clock(mmc, 400000); + mmc_set_clock(mmc, 400000, false); /* Disable the BRR and BWR bits in IRQSTAT */ esdhc_clrbits32(®s->irqstaten, IRQSTATEN_BRR | IRQSTATEN_BWR); diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 65a3d8e..1c941a2 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1214,7 +1214,7 @@ static int mmc_set_ios(struct mmc *mmc) } #endif -int mmc_set_clock(struct mmc *mmc, uint clock) +int mmc_set_clock(struct mmc *mmc, uint clock, bool disable) { if (clock > mmc->cfg->f_max) clock = mmc->cfg->f_max; @@ -1223,6 +1223,7 @@ int mmc_set_clock(struct mmc *mmc, uint clock) clock = mmc->cfg->f_min; mmc->clock = clock; + mmc->clk_disable = disable; return mmc_set_ios(mmc); } @@ -1322,7 +1323,7 @@ static int sd_select_mode_and_width(struct mmc *mmc) /* configure the bus mode (host) */ mmc_select_mode(mmc, mwt->mode); - mmc_set_clock(mmc, mmc->tran_speed); + mmc_set_clock(mmc, mmc->tran_speed, false); err = sd_read_ssr(mmc); if (!err) @@ -1333,7 +1334,7 @@ static int sd_select_mode_and_width(struct mmc *mmc) error: /* revert to a safer bus speed */ mmc_select_mode(mmc, SD_LEGACY); - mmc_set_clock(mmc, mmc->tran_speed); + mmc_set_clock(mmc, mmc->tran_speed, false); } } } @@ -1476,7 +1477,7 @@ static int mmc_select_mode_and_width(struct mmc *mmc) /* configure the bus mode (host) */ mmc_select_mode(mmc, mwt->mode); - mmc_set_clock(mmc, mmc->tran_speed); + mmc_set_clock(mmc, mmc->tran_speed, false); /* do a transfer to check the configuration */ err = mmc_read_and_compare_ext_csd(mmc); @@ -1950,7 +1951,7 @@ static void mmc_set_initial_state(struct mmc *mmc) mmc_select_mode(mmc, MMC_LEGACY); mmc_set_bus_width(mmc, 1); - mmc_set_clock(mmc, 0); + mmc_set_clock(mmc, 0, false); } static int mmc_power_on(struct mmc *mmc) diff --git a/include/mmc.h b/include/mmc.h index bd096ae..8d6e0f8 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -472,6 +472,7 @@ struct mmc { void *priv; uint has_init; int high_capacity; + bool clk_disable; /* true if the clock can be turned off */ uint bus_width; uint clock; enum mmc_voltage signal_voltage; @@ -567,7 +568,16 @@ int mmc_unbind(struct udevice *dev); int mmc_initialize(bd_t *bis); int mmc_init(struct mmc *mmc); int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size); -int mmc_set_clock(struct mmc *mmc, uint clock); + +/** + * mmc_set_clock() - change the bus clock + * @mmc: MMC struct + * @clock: bus frequency in Hz + * @disable: flag indicating if the clock must on or off + * @return 0 if OK, -ve on error + */ +int mmc_set_clock(struct mmc *mmc, uint clock, bool disable); + struct mmc *find_mmc_device(int dev_num); int mmc_set_dev(int dev_num); void print_mmc_devices(char separator); From patchwork Thu Sep 21 14:30:04 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: 113263 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1965222edb; Thu, 21 Sep 2017 07:41:22 -0700 (PDT) X-Google-Smtp-Source: AOwi7QA38uAy8+gsB3jXdSNtnOx6qdqf+IP9YeMoRMpfiMnPNnWkUCbnIfcq52WUIhjQUVOy6956 X-Received: by 10.80.159.36 with SMTP id b33mr1381466edf.163.1506004882762; Thu, 21 Sep 2017 07:41:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506004882; cv=none; d=google.com; s=arc-20160816; b=SFfXMKLXgkTrCoecyS3FTRpr3XuIuhLabHba4Xgp0t3wAFNmEm06285JzTPVLFj/E8 9bYvcD8bbi6MGAFuoYAFHLiphb6NbAkssXTb09meHmA1m07QrNVoQLj7KC9k7JwWuKPW vnhBKli3WYMhx0JP3NTQLJvTxwVeU8635OvnmD84/geb3QY0hChXUDpBRptZBKKu/XJ7 Jn734GllgUQ3mwsOMHNTiBtpzQRZwswwXYGeVgnmalddAy3fhdLIrVQ9DDrs5L8Ginki gvXQwQYPY2goYtF1+PKT3QFAABYhmJ0DjgSArIDaFxvyj5gjoJ1lF+vII3DsaEA4A3mR U76g== 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=nay9cUaIbhsAnRZtB5Llkj4wIDOwzifTjZex0bn/Tho=; b=LKeBmui/kX8p/bRJ1FNBzq72lDt+GF+YbZx3XsjXdz2KJUKb+fwnZ2d7+aAvXYt0ic OOR7EcoB3G4LKFJuhfceIjv5prqvLB2ulXAI+7ADgutRyIPwkRwi6Wl1PpXnSx4Z5nWD GlvA+KvHfJTSuyoKex7kyYZlNdOdWYXmCwxz6A88O7fqgiFe8H7nzSbIICkPWkdEj3yU 9e50B6ZmucQdG8mQe8tu55pJeCfpbX1hAZk1ckRa04v170nmShSNdyoTcHvYp/gr4zSk KBhre1QN50n7gZ4EKyCcJsp9dSHCTncdmff56oBxd4V+1S1eR5dgWQC3X4xJGkYvB/dm iBRg== 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=c1V+DDJu; 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 u90si511006edc.191.2017.09.21.07.41.22; Thu, 21 Sep 2017 07:41:22 -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=c1V+DDJu; 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 460EFC21DD0; Thu, 21 Sep 2017 14:38:06 +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 6422BC21F9D; Thu, 21 Sep 2017 14:34:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 017C7C21E3B; Thu, 21 Sep 2017 14:32:07 +0000 (UTC) Received: from fllnx209.ext.ti.com (fllnx209.ext.ti.com [198.47.19.16]) by lists.denx.de (Postfix) with ESMTPS id C54DCC21FF8 for ; Thu, 21 Sep 2017 14:32:03 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8LEV1kg032533; Thu, 21 Sep 2017 09:31:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1506004261; bh=F2Y2IsWB24n5MRCcPxfmuaSkg1kruAKFTGrlaUFhN+I=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=c1V+DDJuyR/5LbpwyI44zlNTDZEx4yZOeMHgMddd3iOl1K/FkeWLjgnhFKpnOcXif C5zAEu4y8oth97xZmad6IPysWtI4wj90jowtbeunS723h0NexB/tYr7ZiDqGNOvTUJ 3BGn0k8yJmHGOZMkXeP9nfduV7m6BEnSczwUCti8= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEUuwT028920; Thu, 21 Sep 2017 09:30:56 -0500 Received: from DLEE111.ent.ti.com (157.170.170.22) 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:55 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE111.ent.ti.com (157.170.170.22) 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:56 -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 v8LEUsVW016509; Thu, 21 Sep 2017 09:30:55 -0500 From: Jean-Jacques Hiblot To: , , , Date: Thu, 21 Sep 2017 16:30:04 +0200 Message-ID: <1506004213-22620-18-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 17/26] mmc: disable the mmc clock during power off 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 There is no point in having the mmc clock enabled during power off. Disable the mmc clock. This is similar to how it's programmed in Linux Kernel. Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Vignesh R Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Simon Glass --- drivers/mmc/mmc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 1c941a2..1f9730e 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1971,6 +1971,7 @@ static int mmc_power_on(struct mmc *mmc) static int mmc_power_off(struct mmc *mmc) { + mmc_set_clock(mmc, 1, true); #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_REGULATOR) if (mmc->vmmc_supply) { int ret = regulator_set_enable(mmc->vmmc_supply, false); From patchwork Thu Sep 21 14:30:05 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: 113265 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2109628qgf; Thu, 21 Sep 2017 07:42:53 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAXX5pin//df3oxvYM6HxmiB4LMGhP/Hp3idZzDNkyJ5LieszuDJ70VHxd/n8CirPWArxSs X-Received: by 10.80.179.247 with SMTP id t52mr1393100edd.237.1506004973680; Thu, 21 Sep 2017 07:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506004973; cv=none; d=google.com; s=arc-20160816; b=JaHnlPo8qdaBIBFcjG5ll3s1Cu3XOYLFUdFe89OoFdVlGXWTMACferOeI7wGDDENlH iGM4ekrNCLFVuWHWFwCm0epNBAKeZTWy+bsEwbHPVpblhRf+YrGcjoDlwj6BUnCCxA2M oPha9oCiaruvYpSZCut3U33nngSmV3EoKVmE6SCdgpcd9AXTmGx3JvM/l5Vftw82P/qG NkN/T0eW6+F5VqiTpnBTUNWtDdDoYKAGF92QZlJjBUWI/AYFjkoyoS4CqcOiGveCb50J tVO9N7c4IruOaAKV6EMlPPz2xzZaA/KbsTSS2E2oroHP1bSpSixL8VNAYXlEBIQjM7yy pH4w== 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=OlrCuy+REpJseH6S03jrGsFVybSLDq/FR7vEWhajWlM=; b=0WDTZJqx3imuQUflAOq0EI41hQBSPN9HU3lhCSTeT2V8aRFIeDyRInDTKoAoVJnL6k DukwiiXRqbFllXCxMthVPBoDMg4BEzxPNL4weV/7smEgw8keIQaCoZtAONbBD6BhYq7p gZLWENBCoTz5EpLwGzZlEXXzEeKeeb5zIQW65e1+XNDoxW+N8CFyJ+P+d/HkoolKkz1j os0313lAXAvG6oPDTHQK/Rds//PSWFtoNCHcroNKN83khrEJbmX76+wnQ0CyC/NLK2fm exAHN5noHEXVAPC0PpDrrbU/WbjTVDfTufJWzS/BrsL8slcHYMeOVLWmN5bHNrL81XXb /cmQ== 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=kC6dHHei; 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 l17si1526491eda.40.2017.09.21.07.42.53; Thu, 21 Sep 2017 07:42:53 -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=kC6dHHei; 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 43A6FC2205E; Thu, 21 Sep 2017 14:33:55 +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 9036FC2201A; Thu, 21 Sep 2017 14:31:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EAD3DC21FFC; Thu, 21 Sep 2017 14:31:06 +0000 (UTC) Received: from fllnx210.ext.ti.com (fllnx210.ext.ti.com [198.47.19.17]) by lists.denx.de (Postfix) with ESMTPS id 93A1EC21E54 for ; Thu, 21 Sep 2017 14:31:00 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8LEUwnT000414; Thu, 21 Sep 2017 09:30:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1506004258; bh=ErXj4KX0mAkuGR2mQV9WLgGM8M00zM+0fE0KUrh1CH4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=kC6dHHei18Xgyp7uCioBF0+dxB8mypgPXiWL7ZOLLbtqk8MfNMByNFYbaWnbdRDEH Jcq136T0UOQDuGhmJQSoiOLsMfWjkvRJiW8UhEwjv2A6RFRo5iQpuldDfrXfMCvlSS JdpObH63/6eToS+6VFHeT2HA2263eVLmPYeWiimE= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEUwRv028958; Thu, 21 Sep 2017 09:30:58 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE102.ent.ti.com (157.170.170.32) 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:58 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE101.ent.ti.com (157.170.170.31) 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:58 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEUuTY030995; Thu, 21 Sep 2017 09:30:57 -0500 From: Jean-Jacques Hiblot To: , , , Date: Thu, 21 Sep 2017 16:30:05 +0200 Message-ID: <1506004213-22620-19-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 18/26] mmc: Add a execute_tuning() callback to the mmc operations. 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 Tuning is a mandatory step in the initialization of SDR104 and HS200 modes. This callback execute the tuning process. Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Jean-Jacques Hiblot --- drivers/mmc/mmc-uclass.c | 14 ++++++++++++++ drivers/mmc/mmc.c | 5 +++++ include/mmc.h | 11 +++++++++++ 3 files changed, 30 insertions(+) diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 9c6a8ba..60cc0ac 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -92,6 +92,20 @@ int mmc_getcd(struct mmc *mmc) return dm_mmc_get_cd(mmc->dev); } +int dm_mmc_execute_tuning(struct udevice *dev, uint opcode) +{ + struct dm_mmc_ops *ops = mmc_get_ops(dev); + + if (!ops->execute_tuning) + return -ENOSYS; + return ops->execute_tuning(dev, opcode); +} + +int mmc_execute_tuning(struct mmc *mmc, uint opcode) +{ + return dm_mmc_execute_tuning(mmc->dev, opcode); +} + struct mmc *mmc_get_mmc_dev(struct udevice *dev) { struct mmc_uclass_priv *upriv; diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 1f9730e..3e2e549 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1199,6 +1199,11 @@ static inline int bus_width(uint cap) } #if !CONFIG_IS_ENABLED(DM_MMC) +static int mmc_execute_tuning(struct mmc *mmc, uint opcode) +{ + return -ENOTSUPP; +} + static void mmc_send_init_stream(struct mmc *mmc) { } diff --git a/include/mmc.h b/include/mmc.h index 8d6e0f8..56fa869 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -383,6 +383,15 @@ struct dm_mmc_ops { * @return 0 if write-enabled, 1 if write-protected, -ve on error */ int (*get_wp)(struct udevice *dev); + + /** + * execute_tuning() - Start the tuning process + * + * @dev: Device to start the tuning + * @opcode: Command opcode to send + * @return 0 if OK, -ve on error + */ + int (*execute_tuning)(struct udevice *dev, uint opcode); }; #define mmc_get_ops(dev) ((struct dm_mmc_ops *)(dev)->driver->ops) @@ -393,12 +402,14 @@ int dm_mmc_set_ios(struct udevice *dev); void dm_mmc_send_init_stream(struct udevice *dev); int dm_mmc_get_cd(struct udevice *dev); int dm_mmc_get_wp(struct udevice *dev); +int dm_mmc_execute_tuning(struct udevice *dev, uint opcode); /* Transition functions for compatibility */ int mmc_set_ios(struct mmc *mmc); void mmc_send_init_stream(struct mmc *mmc); int mmc_getcd(struct mmc *mmc); int mmc_getwp(struct mmc *mmc); +int mmc_execute_tuning(struct mmc *mmc, uint opcode); #else struct mmc_ops { From patchwork Thu Sep 21 14:30:06 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: 113260 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1961798edb; Thu, 21 Sep 2017 07:37:55 -0700 (PDT) X-Google-Smtp-Source: AOwi7QB25qNZjIahLnecq0rmGVjdr9JR2XCJvgxlqex42Q2x7itfX+ItlxedtoSbT00r8SQjmzr7 X-Received: by 10.80.158.34 with SMTP id z31mr1419834ede.183.1506004674974; Thu, 21 Sep 2017 07:37:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506004674; cv=none; d=google.com; s=arc-20160816; b=mep/Xtr9GylYLS5nSD/u4ngmKaqBfukE08S4CEe+tkoeoE9w8p3og+ZAEsTS/X0j/t Cwk5zUMov0xn9yaZpW45uP8/BeZfEw14mJIQKkT0l+ipcSxdAa4M8tmwjqcpEGS48H1N cggP/u0aWC1mkypkEnXdPaLrg8TrOruOm5VlNiaEV2cS+PWXIEB4eks/OMmNpFT1qnL2 U6PZmOgezfjZd0p4HfDF4P4Fj47vGyVTgI6vfNvxXLELC4x5kfNYopjsHZo7Um6pqLB6 CmfksOuYdT3yShtVD4l7kOQG8pJRETiV21McGpejeQxixhZL810dHkLCOXObKUkDyPOY GaMw== 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=p2AyTBRuCbfna5zsDxdSpmLWyy2Z7UGO7qsXQ7+1Z7U=; b=ZFyYe//YbKr9o9VrNaoE/c8pcOIxzgABYiUtrqTd8JXOkmHpPAVkXY9JmzrdPrJRHw neXqwmmPSjnT3+VeCQcIOdEx08pjKAyktWlhxMiPB0joMrNXaFI3l1zIqXAhuvdHIseu zrBVDExb29VbyH3wXiGdJ2eLhPXMG1lMPjeYYPglehGscLBgdtKrH4jj2OydGEAZTbE/ dBZ3AxvW087/T51yM9KDgKjM96k9H0YR99p5M9H8cb6hz6jNT+N1HRhQnZ1tJMNy59Nk 6JFwtR987eOuz0rSA8iBB/ap902oDMqMPo/dc2TiiOVE3fUbe3upB18rEKLCAUZsOVkJ 0ZQg== 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=moimMoV5; 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 w25si1578402edd.51.2017.09.21.07.37.54; Thu, 21 Sep 2017 07:37:54 -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=moimMoV5; 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 90DE0C22009; Thu, 21 Sep 2017 14:35:26 +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 2D20BC22031; Thu, 21 Sep 2017 14:32:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6225EC22029; Thu, 21 Sep 2017 14:31:09 +0000 (UTC) Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by lists.denx.de (Postfix) with ESMTPS id B417DC21FD8 for ; Thu, 21 Sep 2017 14:31:02 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8LEV0kj029513; Thu, 21 Sep 2017 09:31:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1506004260; bh=bCpPxlrUmLWlMAnUe4EuTZWkrc9NTR7RynAwbDW1bgA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=moimMoV5WDlor+ELfmWlYMvKjNgYlVSsg5r4gj82fytBonfJBJxFb9miX/Y+6CZ5E hhkiy/nqt197XtIniErEBd+2lBoV4dwDTqvzhOHhmpdeI4Aoww8/wRcZO6DbrVklOJ SNmmSkXG5q/F3e7tGnA9R3JoeZC6Ywt+/Tscbti8= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEV0jx020046; Thu, 21 Sep 2017 09:31:00 -0500 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE103.ent.ti.com (10.64.6.24) 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:31:00 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE105.ent.ti.com (10.64.6.26) 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:31:00 -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 v8LEUwRg016550; Thu, 21 Sep 2017 09:30:59 -0500 From: Jean-Jacques Hiblot To: , , , Date: Thu, 21 Sep 2017 16:30:06 +0200 Message-ID: <1506004213-22620-20-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 19/26] mmc: add HS200 support in 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 HS200 to the list of supported modes and introduce tuning in the MMC startup process. Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Simon Glass --- drivers/mmc/mmc.c | 22 ++++++++++++++++++++-- include/mmc.h | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 3e2e549..c663709 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -621,6 +621,10 @@ static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode) case MMC_HS_52: case MMC_DDR_52: speed_bits = EXT_CSD_TIMING_HS; + break; + case MMC_HS_200: + speed_bits = EXT_CSD_TIMING_HS200; + break; case MMC_LEGACY: speed_bits = EXT_CSD_TIMING_LEGACY; break; @@ -667,9 +671,12 @@ static int mmc_get_capabilities(struct mmc *mmc) mmc->card_caps |= MMC_MODE_4BIT | MMC_MODE_8BIT; - cardtype = ext_csd[EXT_CSD_CARD_TYPE] & 0xf; + cardtype = ext_csd[EXT_CSD_CARD_TYPE] & 0x3f; - /* High Speed is set, there are two types: 52MHz and 26MHz */ + if (cardtype & (EXT_CSD_CARD_TYPE_HS200_1_2V | + EXT_CSD_CARD_TYPE_HS200_1_8V)) { + mmc->card_caps |= MMC_MODE_HS200; + } if (cardtype & EXT_CSD_CARD_TYPE_52) { if (cardtype & EXT_CSD_CARD_TYPE_DDR_52) mmc->card_caps |= MMC_MODE_DDR_52MHz; @@ -1268,6 +1275,7 @@ void mmc_dump_capabilities(const char *text, uint caps) struct mode_width_tuning { enum bus_mode mode; uint widths; + uint tuning; }; static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage) @@ -1383,6 +1391,7 @@ static const struct mode_width_tuning mmc_modes_by_pref[] = { { .mode = MMC_HS_200, .widths = MMC_MODE_8BIT | MMC_MODE_4BIT, + .tuning = MMC_CMD_SEND_TUNING_BLOCK_HS200 }, { .mode = MMC_DDR_52, @@ -1484,6 +1493,15 @@ static int mmc_select_mode_and_width(struct mmc *mmc) mmc_select_mode(mmc, mwt->mode); mmc_set_clock(mmc, mmc->tran_speed, false); + /* execute tuning if needed */ + if (mwt->tuning) { + err = mmc_execute_tuning(mmc, mwt->tuning); + if (err) { + debug("tuning failed\n"); + goto error; + } + } + /* do a transfer to check the configuration */ err = mmc_read_and_compare_ext_csd(mmc); if (!err) diff --git a/include/mmc.h b/include/mmc.h index 56fa869..407fddf 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -56,6 +56,7 @@ #define MMC_MODE_HS (MMC_CAP(MMC_HS) | MMC_CAP(SD_HS)) #define MMC_MODE_HS_52MHz MMC_CAP(MMC_HS_52) #define MMC_MODE_DDR_52MHz MMC_CAP(MMC_DDR_52) +#define MMC_MODE_HS200 MMC_CAP(MMC_HS_200) #define MMC_MODE_8BIT BIT(30) #define MMC_MODE_4BIT BIT(29) @@ -86,6 +87,7 @@ #define MMC_CMD_SET_BLOCKLEN 16 #define MMC_CMD_READ_SINGLE_BLOCK 17 #define MMC_CMD_READ_MULTIPLE_BLOCK 18 +#define MMC_CMD_SEND_TUNING_BLOCK_HS200 21 #define MMC_CMD_SET_BLOCK_COUNT 23 #define MMC_CMD_WRITE_SINGLE_BLOCK 24 #define MMC_CMD_WRITE_MULTIPLE_BLOCK 25 @@ -113,6 +115,13 @@ #define SD_CMD_APP_SEND_OP_COND 41 #define SD_CMD_APP_SEND_SCR 51 +static inline bool mmc_is_tuning_cmd(uint cmdidx) +{ + if (cmdidx == MMC_CMD_SEND_TUNING_BLOCK_HS200) + return true; + return false; +} + /* SCR definitions in different words */ #define SD_HIGHSPEED_BUSY 0x00020000 #define SD_HIGHSPEED_SUPPORTED 0x00020000 @@ -210,6 +219,13 @@ #define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \ | EXT_CSD_CARD_TYPE_DDR_1_2V) +#define EXT_CSD_CARD_TYPE_HS200_1_8V BIT(4) /* Card can run at 200MHz */ + /* SDR mode @1.8V I/O */ +#define EXT_CSD_CARD_TYPE_HS200_1_2V BIT(5) /* Card can run at 200MHz */ + /* SDR mode @1.2V I/O */ +#define EXT_CSD_CARD_TYPE_HS200 (EXT_CSD_CARD_TYPE_HS200_1_8V | \ + EXT_CSD_CARD_TYPE_HS200_1_2V) + #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 */ #define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */ @@ -219,6 +235,8 @@ #define EXT_CSD_TIMING_LEGACY 0 /* no high speed */ #define EXT_CSD_TIMING_HS 1 /* HS */ +#define EXT_CSD_TIMING_HS200 2 /* HS200 */ + #define EXT_CSD_BOOT_ACK_ENABLE (1 << 6) #define EXT_CSD_BOOT_PARTITION_ENABLE (1 << 3) #define EXT_CSD_PARTITION_ACCESS_ENABLE (1 << 0) From patchwork Thu Sep 21 14:30:10 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: 113268 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2112623qgf; Thu, 21 Sep 2017 07:45:52 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAZ5+MNip+bzTqAGsuurtyxTSGmMabC9fYDgqF9I0rcAgGT6Zkgv1+X9wjLhaQTlTlXZqy5 X-Received: by 10.80.150.69 with SMTP id y63mr1462202eda.75.1506005152472; Thu, 21 Sep 2017 07:45:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506005152; cv=none; d=google.com; s=arc-20160816; b=kOhj9D/tpMc7QlX9eZB5pwTESrOfBi6hWeH9iGEvSnxgVfewwJoBgWhdefICDrtsAS pvJwlzX25wg8Al8v6D6VBrrSyq4e1TYo1xvW8eripdoh3U69agGGSSA9wEK3TwsXe9Nk rG0R2oqCizScuQNbrZDsm7nlAZlJGMjlH6QaZY3y0S5xxJIL8xpSGGRiNt8c4rn1h2S9 fJuE7Ui85W3/N/wak53465Y6LbpV4Ab+KJ2GEa8anwUokIa1B1d6l1HryuKdjw0y69rq hXD+pNQ+fXuWV51t4gm8HagQ+pW+RS/6MPEEV/AW5GbjlFtDzJp+H69AA+494sDy6o0K B0Fg== 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=FHywQd5e4pRa4+PC63CKDOE01x+SQw2SzFY+a0Tunew=; b=ZDcsi66KKIHSwA2ywh/EsKCtTflqzsttwQm2QwxxplcyyhmnMcNQFS9P6iWx8YMIR0 zVOcYDlBUpFToqsM9xH1OJPkmFA5i+WtV2LQqKbdXT+mQvMbCsaxMANQoUDj0Rqks3CU Ne2+I4WsLs6FhWqQrJwZS9O1A8QD9o4nzPvUcv5Fck+bUP1/bgLNU0YVBk0aHTj3ShB1 wL3coriu99sU3oAesN6qHxno+vyXvIxLYd4Jt/1puUD0ReV6D5/o/P9Da12ecDjG+pbs RkWHQfjPgyTVS8Z9ZUDZPRUzGvgrvNWgHLDDkIv6PEz5qHwaFhGDEbzoCdkRvf5QVIRh cRWg== 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=v1PCcgHX; 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 a10si1521946edh.459.2017.09.21.07.45.52; Thu, 21 Sep 2017 07:45:52 -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=v1PCcgHX; 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 EC5A5C2208D; Thu, 21 Sep 2017 14:34:43 +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 A7755C21E3B; Thu, 21 Sep 2017 14:32:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E0354C21E78; Thu, 21 Sep 2017 14:31:18 +0000 (UTC) Received: from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by lists.denx.de (Postfix) with ESMTPS id 98BF7C22012 for ; Thu, 21 Sep 2017 14:31:12 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8LEVAbx002971; Thu, 21 Sep 2017 09:31:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1506004270; bh=aDxGCQF+JQ6H5+zNl3D4EQ+pWu9BLualohyPFFbj11o=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=v1PCcgHX5FXH53OgEIKdi85u761emw+FuVwNDdCHKeDMShav0cklkilHHvtn8BHNn mPHZqLlpC9Rb07hyXJB2NHBJOJlK4zb32rNmAKZuZmyyWkzhI/y4QUatE0WLdmTdg+ xsvZRSZKrfcIQMxg2e+PgvaMc6a0QAijmemE6v/o= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEVAUb020674; Thu, 21 Sep 2017 09:31:10 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE108.ent.ti.com (10.64.6.29) 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:31:10 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE109.ent.ti.com (10.64.6.30) 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:31:10 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEV8c6012050; Thu, 21 Sep 2017 09:31:09 -0500 From: Jean-Jacques Hiblot To: , , , Date: Thu, 21 Sep 2017 16:30:10 +0200 Message-ID: <1506004213-22620-24-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 23/26] mmc: Retry some MMC cmds on failure 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 With certain SD cards like Kingston 8GB/16GB UHS card, it is seen that MMC_CMD_ALL_SEND_CID cmd fails on first attempt, but succeeds subsequently. Therefore, retry MMC_CMD_ALL_SEND_CID cmd a few time as done in Linux kernel. Similarly, it is seen that MMC_CMD_SET_BLOCKLEN may fail on first attempt, therefore retry this cmd a few times as done in kernel. To make it clear that those are optionnal workarounds, a new Kconfig option 'MMC_QUIRKS' is added (enabled by default). Signed-off-by: Vignesh R Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Jean-Jacques Hiblot --- drivers/mmc/Kconfig | 9 +++++++++ drivers/mmc/mmc.c | 41 +++++++++++++++++++++++++++++++++++++++-- include/mmc.h | 4 ++++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index 3d577e0..78e58d4 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -33,6 +33,15 @@ config SPL_DM_MMC if MMC +config MMC_QUIRKS + bool "Enable quirks" + default y + help + Some cards and hosts may sometimes behave unexpectedly (quirks). + This option enable workarounds to handle those quirks. Some of them + are enabled by default, other may require additionnal flags or are + enabled by the host driver. + config MMC_VERBOSE bool "Output more information about the MMC" default y diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index c5eaeaf..6d1bf94 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -279,6 +279,7 @@ int mmc_send_status(struct mmc *mmc, int timeout) int mmc_set_blocklen(struct mmc *mmc, int len) { struct mmc_cmd cmd; + int err; if (mmc->ddr_mode) return 0; @@ -287,7 +288,24 @@ int mmc_set_blocklen(struct mmc *mmc, int len) cmd.resp_type = MMC_RSP_R1; cmd.cmdarg = len; - return mmc_send_cmd(mmc, &cmd, NULL); + err = mmc_send_cmd(mmc, &cmd, NULL); + +#ifdef CONFIG_MMC_QUIRKS + if (err && (mmc->quirks & MMC_QUIRK_RETRY_SET_BLOCKLEN)) { + int retries = 4; + /* + * It has been seen that SET_BLOCKLEN may fail on the first + * attempt, let's try a few more time + */ + do { + err = mmc_send_cmd(mmc, &cmd, NULL); + if (!err) + break; + } while (retries--); + } +#endif + + return err; } static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start, @@ -1881,7 +1899,6 @@ static int mmc_startup(struct mmc *mmc) cmd.resp_type = MMC_RSP_R1; cmd.cmdarg = 1; err = mmc_send_cmd(mmc, &cmd, NULL); - if (err) return err; } @@ -1895,6 +1912,21 @@ static int mmc_startup(struct mmc *mmc) err = mmc_send_cmd(mmc, &cmd, NULL); +#ifdef CONFIG_MMC_QUIRKS + if (err && (mmc->quirks & MMC_QUIRK_RETRY_SEND_CID)) { + int retries = 4; + /* + * It has been seen that SEND_CID may fail on the first + * attempt, let's try a few more time + */ + do { + err = mmc_send_cmd(mmc, &cmd, NULL); + if (!err) + break; + } while (retries--); + } +#endif + if (err) return err; @@ -2239,6 +2271,11 @@ int mmc_start_init(struct mmc *mmc) if (err) return err; +#ifdef CONFIG_MMC_QUIRKS + mmc->quirks = MMC_QUIRK_RETRY_SET_BLOCKLEN | + MMC_QUIRK_RETRY_SEND_CID; +#endif + err = mmc_power_cycle(mmc); if (err) { /* diff --git a/include/mmc.h b/include/mmc.h index a8901bf..a9ebc88 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -306,6 +306,9 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) #define ENHNCD_SUPPORT (0x2) #define PART_ENH_ATTRIB (0x1f) +#define MMC_QUIRK_RETRY_SEND_CID BIT(0) +#define MMC_QUIRK_RETRY_SET_BLOCKLEN BIT(1) + enum mmc_voltage { MMC_SIGNAL_VOLTAGE_000 = 0, MMC_SIGNAL_VOLTAGE_120, @@ -591,6 +594,7 @@ struct mmc { * operating mode due to limitations when * accessing the boot partitions */ + u32 quirks; }; struct mmc_hwpart_conf { From patchwork Thu Sep 21 14:30:13 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: 113264 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2108272qgf; Thu, 21 Sep 2017 07:41:36 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDDZIW08xk08JNyeu5Jt7PNKCjeUuS7+EVkgWsgcyzwFk+j0ph8NTo5UdrNRCgI2af7eeeL X-Received: by 10.80.144.202 with SMTP id d10mr1459011eda.254.1506004896856; Thu, 21 Sep 2017 07:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506004896; cv=none; d=google.com; s=arc-20160816; b=G9PyORibwHZwvZwU5YIQY4qYFv3gvl/A8VvYLRnDVmBfkKx4R8VPhJQK2XXwj+xSUO 1VwQORGnFOTbE2JUx6e8ohnuhbz7JTioLP1H/s75xFqToV3GuEsS1b75B7vlGbmi36FV jpnyTBp6sAMv8roFRHHKm27Gj0K8dTCnO7fRriT2Ff4kguZ+ouC1oBtN0umb27c1Pxbm /1ksjAIDUzkIYY1vUSd/isCrHJjWFGFj9iY4CuSmwTnOZNAWov93QQPBiioNuLoolYQH JmZ8Hk+rstv2sCu43klyzyMw4C4SueAqmDaL5c1YLQNnKsAKhAl21DC2vuF5jAkdi/fd /lIw== 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=pdimkN7sRqMo5c03gmCAHv/wpxc4OSSPgTyMPU4Ut9I=; b=M0zVt1wzmbvoDE/hYk6eMp/9Gbrrt3aBtK0k9P1pGy9KQCgKMA/boQ2sDrK0yYHlh9 B89Y1vDdR6x4WsQTumJYMwTX7Bdee4X01cTbU7xgtF221HFazEAqgGpLGsPsFjDhZD0V yqaU1KJ4Vt0h74iav3E3+5xxD8H+97ukbsundd+3IVFoRdmVWi/gXWNV1y0D24jeUQ61 JmIH3EwZqdBc+PVQIMQFHPBQsA7Y9+KbAMePXmSKvX7sHj7atqzDUJ9DFSjtWNs1BLPr QwJDrW6SKbm5fqVSXrSQIjZaMKQKXd2EKSf8zlGBZZ249cARcbnsWFDfLZ6/6Sb5xfRf AHMw== 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=gxAgFzbm; 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 7si377979edf.105.2017.09.21.07.41.36; Thu, 21 Sep 2017 07:41:36 -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=gxAgFzbm; 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 73668C21EAB; Thu, 21 Sep 2017 14:36:01 +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 14F08C2200A; Thu, 21 Sep 2017 14:32:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4ADA5C22017; Thu, 21 Sep 2017 14:31:26 +0000 (UTC) Received: from fllnx210.ext.ti.com (fllnx210.ext.ti.com [198.47.19.17]) by lists.denx.de (Postfix) with ESMTPS id ACF0BC21FF9 for ; Thu, 21 Sep 2017 14:31:19 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8LEVHtE000526; Thu, 21 Sep 2017 09:31:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1506004277; bh=+aSH85jPIil0YmIkCkhAsqUZSCCr/rsYvtOv6r2ERTo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=gxAgFzbmAcaYw+FsgC4xBP7HVXJ/xXFnhK/nBVat2eq1XCRWO5JnXsa214ogtzP0z HKYCWQOQ10cIPniIHOII+QXaPPo1xaqobzLR11qm4FS2Q9CXeGwGDPwFX1ciyPqwkQ eIBlGeRnjPk9KJ2sbUx2TR5ggvjQi+QUvBj+iG2Y= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEVHCa029640; Thu, 21 Sep 2017 09:31:17 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE105.ent.ti.com (10.64.6.26) 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:31:17 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE108.ent.ti.com (10.64.6.29) 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:31:17 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEVFk3031471; Thu, 21 Sep 2017 09:31:16 -0500 From: Jean-Jacques Hiblot To: , , , Date: Thu, 21 Sep 2017 16:30:13 +0200 Message-ID: <1506004213-22620-27-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 26/26] dm: mmc: Add a library function to parse generic dt binding 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 to parse host controller dt node and set mmc_config. This function can be used by mmc controller drivers to set the generic mmc_config. This function can be extended to set other UHS mode caps once UHS mode support is added. Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Jean-Jacques Hiblot --- drivers/mmc/mmc-uclass.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ include/mmc.h | 1 + 2 files changed, 47 insertions(+) diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 7856e0a..e30cde7 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -120,6 +120,52 @@ int mmc_execute_tuning(struct mmc *mmc, uint opcode) return dm_mmc_execute_tuning(mmc->dev, opcode); } +int mmc_of_parse(const void *fdt, int node, struct mmc_config *cfg) +{ + int val; + + val = fdtdec_get_int(fdt, node, "bus-width", 1); + + switch (val) { + case 0x8: + cfg->host_caps |= MMC_MODE_8BIT; + /* fall through */ + case 0x4: + cfg->host_caps |= MMC_MODE_4BIT; + /* fall through */ + case 0x1: + cfg->host_caps |= MMC_MODE_1BIT; + break; + default: + printf("error: %s invalid bus-width property %d\n", + fdt_get_name(fdt, node, NULL), val); + return -ENOENT; + } + + cfg->f_max = fdtdec_get_int(fdt, node, "max-frequency", 52000000); + + if (fdtdec_get_bool(fdt, node, "cap-sd-highspeed")) + cfg->host_caps |= MMC_CAP(SD_HS); + if (fdtdec_get_bool(fdt, node, "cap-mmc-highspeed")) + cfg->host_caps |= MMC_CAP(MMC_HS); + if (fdtdec_get_bool(fdt, node, "sd-uhs-sdr12")) + cfg->host_caps |= MMC_CAP(UHS_SDR12); + if (fdtdec_get_bool(fdt, node, "sd-uhs-sdr25")) + cfg->host_caps |= MMC_CAP(UHS_SDR25); + if (fdtdec_get_bool(fdt, node, "sd-uhs-sdr50")) + cfg->host_caps |= MMC_CAP(UHS_SDR50); + if (fdtdec_get_bool(fdt, node, "sd-uhs-sdr104")) + cfg->host_caps |= MMC_CAP(UHS_SDR104); + if (fdtdec_get_bool(fdt, node, "sd-uhs-ddr50")) + cfg->host_caps |= MMC_CAP(UHS_DDR50); + if (fdtdec_get_bool(fdt, node, "mmc-ddr-1_8v")) + cfg->host_caps |= MMC_CAP(MMC_DDR_52); + if (fdtdec_get_bool(fdt, node, "mmc-hs200-1_8v")) + cfg->host_caps |= MMC_CAP(MMC_HS_200); + + return 0; +} + struct mmc *mmc_get_mmc_dev(struct udevice *dev) { struct mmc_uclass_priv *upriv; diff --git a/include/mmc.h b/include/mmc.h index 79be6b4..6230a32 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -651,6 +651,7 @@ int mmc_unbind(struct udevice *dev); int mmc_initialize(bd_t *bis); int mmc_init(struct mmc *mmc); int mmc_send_tuning(struct mmc *mmc, u32 opcode, int *cmd_error); +int mmc_of_parse(const void *fdt, int node, struct mmc_config *cfg); int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size); /**