From patchwork Thu Aug 22 11:16:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1151502 X-Patchwork-Delegate: van.freenix@gmail.com 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="x6OpYAqG"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46DhpT1qpTz9s3Z for ; Thu, 22 Aug 2019 21:17:53 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id E777AC220A3; Thu, 22 Aug 2019 11:17:22 +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 56659C220A2; Thu, 22 Aug 2019 11:17:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8B97DC220A4; Thu, 22 Aug 2019 11:17:01 +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 8F6FBC2205E for ; Thu, 22 Aug 2019 11:16:59 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id g67so5358370wme.1 for ; Thu, 22 Aug 2019 04:16:59 -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:in-reply-to:references :in-reply-to:references; bh=QtEP7WhmvsWQAgUKBMaCogJtNH4r/lFCC3o0pE2SfDg=; b=x6OpYAqGzWsFDXLh/cvzN9pYcvi63DjqyW5j/biGc2GxjPbmIw6aCZ7sG2ydJCf3bu tZI2+gLU3s2X+w+zVSljVLtzZZpqOV1gW1BhIg2lyM0+0YMBY/+712J4b+0932vKhnNq ycDRIGXxhWx/cEu/T1VMXz6HoQgn6dN8Z0SDhD20IpIYSHu9veNWZj6XjvofYrIBK74s d98RZEh4S0ToOaW5lPdDA/qm9F+EiLX7L+DIfFaSSi981N/rNZ4D/vi01RRSTTXiXyGw JHQ9/zEkdFgt7uQu9Ale2NV7XQ8rnjtm7zgUEiH3C7ZQ+xSzFdiM+/MHReyEuzObwsDe P0sw== 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 :in-reply-to:references:in-reply-to:references; bh=QtEP7WhmvsWQAgUKBMaCogJtNH4r/lFCC3o0pE2SfDg=; b=FC0if/EtHopd6cwZfvJ1w5eu0VSyBkRz74fhwzxThIBYqOAld4glWKXpLJgH5Mv9NW 8/vvLL+3t3/MxH/RdRxZrPJKwXw5fzA5bNcMoVIabRmmrpnzbbtODc0NBSmqrzBKzD73 MgF696j0rsTUyBxWSMoezUpQDu3FIM4kBPwJ6nZREStLNVpb4mUrU+DFrexP0aWYbx1Z xF+KYVlp7WVC/bYNCPiVXPEXYk5PsXXufxoM93E22jPDvTRA4r9HlXByf79inbTwrdtn AWfR2ttpPZSqhDXuD4Adlk8lR+Gni8QIhFvgmUm6b7nnYD4Ar1kHXtAMqjHDkVewg5YI gYAQ== X-Gm-Message-State: APjAAAUUzifKImStkNnAEXDfDkrcmql5LnHqR2P7sbpnoVRsHEag9wti 5rr+49g21Jxg24NKokNou8oTVn9ibBPgTg== X-Google-Smtp-Source: APXvYqxG0JL0tnh20JwqQrb2wq/LLtQwaeE9kC0k9YqIrenq0iUMhb6ML4KCkPbep2VlQRD8I6F0Qg== X-Received: by 2002:a1c:f518:: with SMTP id t24mr5461230wmh.98.1566472618955; Thu, 22 Aug 2019 04:16:58 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id n8sm21942847wro.89.2019.08.22.04.16.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Aug 2019 04:16:58 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, t.karthik.reddy@xilinx.com Date: Thu, 22 Aug 2019 13:16:50 +0200 Message-Id: <4bbaca25a0daab2bd68caeefc6ca0e86e444446a.1566472608.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: git@xilinx.com Subject: [U-Boot] [PATCH 2/2] mmc: sdhci: Add support for dt caps & caps mask 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 The sdhci capabilities registers can be incorrect. The sdhci-caps-mask and sdhci-caps dt properties specify which bits of the registers are incorrect and what their values should be. This patch makes the sdhci driver use those properties to correct the caps. Also use "dev_read_u64_default" instead of "dev_read_u32_array" for caps mask. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- drivers/mmc/sdhci.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 2779bca93f08..fbc576fd726e 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -711,17 +711,19 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, { u32 caps, caps_1 = 0; #if CONFIG_IS_ENABLED(DM_MMC) - u32 mask[2] = {0}; - int ret; - ret = dev_read_u32_array(host->mmc->dev, "sdhci-caps-mask", - mask, 2); - if (ret && ret != -1) - return ret; - - caps = ~mask[1] & sdhci_readl(host, SDHCI_CAPABILITIES); + u64 dt_caps, dt_caps_mask; + + dt_caps_mask = dev_read_u64_default(host->mmc->dev, + "sdhci-caps-mask", 0); + dt_caps = dev_read_u64_default(host->mmc->dev, + "sdhci-caps", 0); + caps = ~(u32)dt_caps_mask & + sdhci_readl(host, SDHCI_CAPABILITIES); + caps |= (u32)dt_caps; #else caps = sdhci_readl(host, SDHCI_CAPABILITIES); #endif + debug("%s, caps: 0x%x\n", __func__, caps); #ifdef CONFIG_MMC_SDHCI_SDMA if (!(caps & SDHCI_CAN_DO_SDMA)) { @@ -762,10 +764,13 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, /* Check whether the clock multiplier is supported or not */ if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) { #if CONFIG_IS_ENABLED(DM_MMC) - caps_1 = ~mask[0] & sdhci_readl(host, SDHCI_CAPABILITIES_1); + caps_1 = ~(u32)(dt_caps_mask >> 32) & + sdhci_readl(host, SDHCI_CAPABILITIES_1); + caps_1 |= (u32)(dt_caps >> 32); #else caps_1 = sdhci_readl(host, SDHCI_CAPABILITIES_1); #endif + debug("%s, caps_1: 0x%x\n", __func__, caps_1); host->clk_mul = (caps_1 & SDHCI_CLOCK_MUL_MASK) >> SDHCI_CLOCK_MUL_SHIFT; }