From patchwork Wed Sep 11 13:49:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1161001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="Nrep9Sg/"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46T3DJ2ZwNz9s00 for ; Wed, 11 Sep 2019 23:49:36 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id C5679C21E5B; Wed, 11 Sep 2019 13:49:29 +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_MSPIKE_H2, 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 C615FC21DB3; Wed, 11 Sep 2019 13:49:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0C2CAC21DB3; Wed, 11 Sep 2019 13:49:27 +0000 (UTC) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by lists.denx.de (Postfix) with ESMTPS id AAB02C21DAF for ; Wed, 11 Sep 2019 13:49:27 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id 7so3589318wme.1 for ; Wed, 11 Sep 2019 06:49:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id; bh=QYFx2/oWVk1XGp7Q5VstJrFxZ5Bvvb+oUZeIjD7Xqvc=; b=Nrep9Sg/q+L0Fn1JuqRc2spmVm6I+Rb0SgYcZbpU+oB5hDmcW09Y/3yPBHWLOOZZBI 6TVle/5OiLeny6zYrl6cNi5aBLLZ7dVTCzFaxB3HXjCa/SVDb4YbBc9EanepjD+lJ2ca Kltk2/KUGZgcEqEreSgWelX+YOMovX9eNI2Fj/LzRPCHaalAk/9yqmj92bUxPvawyk6K h61D4TGKJhhcn1oXs6ODqwrB2nGCjMEGtjF7FrK6gP1wJvOkoFQiJLrmPkp7PeOlRoIv LOR5hNWvSns/f6qwWgEg9NrNC31RhyBoW5Ar4GHc9duTphHm31KiLB93ZF43uUMg7zGK ii7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=QYFx2/oWVk1XGp7Q5VstJrFxZ5Bvvb+oUZeIjD7Xqvc=; b=q+DDZtqx+xq+2hM2q5sHi1hvm3pCeQ48IihgLaj8dYs5nF50lixDqeWvf2Faubp0D0 DXfY5zfSrv3jx5G/U8Rnrb2guNhMHxZ+V0mPlGVWQMjxnBCrF0V3w+tzlrd7TrpLp63P ImeSFmi41p59iaIBzSsgKeKT5K22jIZ59O14Vp2X0eZAje7a2aghZqZCxKqT+/LL9bMR BVqlQUI73X0xvmCLJf1wNqHT6HdFVbh6V8ru5lwreSNbhXOJf9dRnDrcdbAJ9S5AvisZ djzk3dpjwiwcuzQbSxdXnJjUZXJ5G3d5sX9I2sQ+etOHEEZ5z0JyEjYz3iUrxTioC5oJ 8KCQ== X-Gm-Message-State: APjAAAWXg4vyf5MRwcvIULTUjjyrTLyfdfa0GYToqHJYEaZrjmxpxMmU F01gqnHxmIiyFnsvO1JLXXUsfRlljbUf6YPu X-Google-Smtp-Source: APXvYqwImKwgmMVM2VXaudCOdlbU7tgDRzEusv3p2bVw7Hm1pqFt5D86hxtWphWG4rWgkijk8oBp2A== X-Received: by 2002:a1c:80c6:: with SMTP id b189mr4338265wmd.34.1568209766985; Wed, 11 Sep 2019 06:49:26 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id y14sm2690691wrh.0.2019.09.11.06.49.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2019 06:49:26 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Wed, 11 Sep 2019 15:49:24 +0200 Message-Id: <2eabee23243f240ed0999311e4cc50e5b0154fb6.1568209763.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 Cc: York Sun , T Karthik Reddy , Marek Vasut Subject: [U-Boot] [RFC PATCH] mmc: sdhci: add support for switching to UHS-I modes on ZynqMP Platform 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: T Karthik Reddy This patch adds support for switching to UHS-I modes on ZynqMP platform. There is one issue with the ZynqMP ZCU102 where it is not able to power cycle the SD card. Due to this once the card is initialized in UHS-I mode it cannot be reinitialized in UHS-I mode again. So to solve this issue there are some of the checks are made in place to ensure that the card operates in UHS-I mode even on reinitialization. This will enable the SD host controller to run SD at UHS-I mode in u-boot if it was running at UHS-I mode already. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- drivers/mmc/mmc.c | 20 ++++++++++++++++++++ include/mmc.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index c8f71cd0c1b6..3d25f11942ff 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1711,6 +1711,26 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps) /* Restrict card's capabilities by what the host can do */ caps = card_caps & mmc->host_caps; + /* + * If the card is already in 1.8V and the system doesn't have + * mechanism to power cycle the SD card, it will respond with no 1.8V + * supported in OCR response. Below check will confirm if the above + * condition has occurred. + * + * If the host is supporting UHS modes and the card is supporting SD + * specification 3.0 and above, it can operate at UHS modes. + */ +#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) + if (!uhs_en && !(mmc_host_is_spi(mmc)) && + mmc->scr[0] & SD_SCR0_SPEC3 && + (mmc->card_caps & MMC_MODE_MASK) >= MMC_CAP(UHS_SDR50) && + (mmc->host_caps & MMC_MODE_MASK) >= MMC_CAP(UHS_SDR50)) { + uhs_en = true; + err = mmc_set_signal_voltage(mmc, MMC_SIGNAL_VOLTAGE_180); + if (err) + return err; + } +#endif if (!uhs_en) caps &= ~UHS_CAPS; diff --git a/include/mmc.h b/include/mmc.h index 686ba0065654..e959ffef2948 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -66,6 +66,7 @@ #define MMC_MODE_HS200 MMC_CAP(MMC_HS_200) #define MMC_MODE_HS400 MMC_CAP(MMC_HS_400) #define MMC_MODE_HS400_ES MMC_CAP(MMC_HS_400_ES) +#define MMC_MODE_MASK (MMC_CAP(MMC_MODES_END) - 1) #define MMC_CAP_NONREMOVABLE BIT(14) #define MMC_CAP_NEEDS_POLL BIT(15) @@ -140,6 +141,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) /* SCR definitions in different words */ #define SD_HIGHSPEED_BUSY 0x00020000 #define SD_HIGHSPEED_SUPPORTED 0x00020000 +#define SD_SCR0_SPEC3 BIT(15) #define UHS_SDR12_BUS_SPEED 0 #define HIGH_SPEED_BUS_SPEED 1