From patchwork Mon Jul 9 03:19:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 141359 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2166620ljj; Sun, 8 Jul 2018 20:21:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeth0kRjn74W64shXfVT58IqXe/KWeMqJoHThhxT3gKSHrS5C6ngxj6s5mvnACVXQkGAN45 X-Received: by 2002:a65:6699:: with SMTP id b25-v6mr12830491pgw.426.1531106475849; Sun, 08 Jul 2018 20:21:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531106475; cv=none; d=google.com; s=arc-20160816; b=HzX4Xv6aJyd0y2IGqkyJ+kT6etTx/rzmBvOFb9JbTxIdkBPrpxjPTkWT5FGi6BRuf7 gyErtpWFmn1zdZW9HZIraoTSb3khaqq6zyRaRRcHrbCQeKxblfAeqe0voeFAZzyOICwU Wk/V/Xz7WfamNJzOE0bCwsxLqBpT9wfWIesvnlyxmdmTDyVtDHCXqKZ/u7H01vqG7A6e zgr5tEDRrG9DVee1Klex31EGqhVAhP/jDMBBuo1EL52kOJCEY3peIH+hgLosgESVUW+A wgyJwd+Wy6HybRx41g1BLqlNZ+99Fjw7y0DDaQnhyGOiQULstsgLFFuXnS7lGKsqMXgo n9YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=BBJFPB65rkJWoNmat+DoaMMdrx+TsZwzg6yOlUtiJro=; b=IJrQ8jnTyPKYwnFl7EPVpgOK4a6aK+0VBobWgOZLZ4BviR6JkXTyNz1Fbw8Z5HvNup SogLHlYzoYAxbc0JhJHSKAB8jolgW5nhtvq7u5zjNrrZNqwE8+DYMDzrmywxtyf6He4M /HRTSfDVKwrrLbUEoUA5PmY7jWYTfw3Kflltt5zjcL6jHxU7xDa7VJSI60/wdRXGV4KR Q8h+h3q3/0qsjjHaLyv2pw5yl+NLMcpX6sbfT+iTes3Jg0UdFmLzQp8V5kM0jCDZo3jP CNrHHgYYVxj+xRqHhyo6H5fX6eOJC6aDFjAcrPzKHxJMaBPBFo1NTo0VihyJQIpvhcAt rKqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SnDeB14O; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b59-v6si13998654plb.107.2018.07.08.20.21.15; Sun, 08 Jul 2018 20:21:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SnDeB14O; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933057AbeGIDVO (ORCPT + 6 others); Sun, 8 Jul 2018 23:21:14 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:46495 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932720AbeGIDVN (ORCPT ); Sun, 8 Jul 2018 23:21:13 -0400 Received: by mail-pl0-f66.google.com with SMTP id 30-v6so5337999pld.13 for ; Sun, 08 Jul 2018 20:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=m8EGOwYzbAaIOxZaEvnUYFUSYffN46UUlc+QT9vs7J0=; b=SnDeB14O4ouu5FqBo7ZA6JwLGffg1pBsdrCcsOZKb+5AUdmAmtItFbIWWm1ARuQy+0 Y+JwbECOQRn8SikMb7kBQtTxuJFuGs33ZLQ5yrEWWVuFg8lGD53ncXevzAiHwO59483l 280KN37WNutY8dBL7Cci/QzL3X8gHXTQkXZ7k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=m8EGOwYzbAaIOxZaEvnUYFUSYffN46UUlc+QT9vs7J0=; b=qvHXhc9ugd3LO4W5l2rpHAYqVNqRIwGUZkpUCzsJzvDKKDkNAXUA4gLHW1hjQtxB5B BZNhZGTGStQy7yEywS/oWtEtVq53Qy/Cm78BVbQlNxiVd25dQ2HLeWiPFc0MD0IRyJR5 sUXmVDLjA0ya7hKow7lst3aR4bhkQuDc4OC1g6S+oAyYv1vtyR+tXNXZzful4DYJ5n0Q bFpRfCudTys5KeM0sTWVBTjQ4x96OdxDMnpD1U+BNj0DQdB6robj8O7PX/+Ki6rxD8qZ saN6SWqwbo3R8EFgId0X+KNvlzo4BGmfKeAS1TDngL84wyiwa9G2A6vYwrOd7I6vgSsg 6Urg== X-Gm-Message-State: APt69E1vpBaBw247zFCdECkXj3pd4M4cvsIQygmIY/Bk708ZWqd3t5NF G7ikeYxzmzFvGiWdHgLIAURUlA== X-Received: by 2002:a17:902:294a:: with SMTP id g68-v6mr19351024plb.58.1531106473171; Sun, 08 Jul 2018 20:21:13 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id e82-v6sm41458950pfk.87.2018.07.08.20.20.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Jul 2018 20:21:12 -0700 (PDT) From: Chunyan Zhang To: Ulf Hansson , Adrian Hunter Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Orson Zhai , Baolin Wang , Billows Wu , zhang.lyra@gmail.com Subject: [PATCH V3 1/7] mmc: sdhci: add sd host v4 mode Date: Mon, 9 Jul 2018 11:19:52 +0800 Message-Id: <1531106398-14062-2-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531106398-14062-1-git-send-email-zhang.chunyan@linaro.org> References: <1531106398-14062-1-git-send-email-zhang.chunyan@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org For SD host controller version 4.00 or later ones, there're two modes of implementation - Version 3.00 compatible mode or Version 4 mode. This patch introduced an interface to enable v4 mode. Signed-off-by: Chunyan Zhang --- drivers/mmc/host/sdhci.c | 11 +++++++++++ drivers/mmc/host/sdhci.h | 5 +++++ 2 files changed, 16 insertions(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 1c828e0..525862f 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -3321,6 +3321,17 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev, EXPORT_SYMBOL_GPL(sdhci_alloc_host); +/* + * Vendor's Host Controller which supports v4 mode can call + * this function to enable v4 mode before calling + * __sdhci_add_host(). + */ +void sdhci_enable_v4_mode(struct sdhci_host *host) +{ + host->v4_mode = true; +} +EXPORT_SYMBOL_GPL(sdhci_enable_v4_mode); + static int sdhci_set_dma_mask(struct sdhci_host *host) { struct mmc_host *mmc = host->mmc; diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 23966f8..e98249b 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -184,6 +184,7 @@ #define SDHCI_CTRL_DRV_TYPE_D 0x0030 #define SDHCI_CTRL_EXEC_TUNING 0x0040 #define SDHCI_CTRL_TUNED_CLK 0x0080 +#define SDHCI_CTRL_V4_MODE 0x1000 #define SDHCI_CTRL_PRESET_VAL_ENABLE 0x8000 #define SDHCI_CAPABILITIES 0x40 @@ -566,6 +567,9 @@ struct sdhci_host { u64 data_timeout; unsigned long private[0] ____cacheline_aligned; + + /* Host Version 4 Enable */ + bool v4_mode; }; struct sdhci_ops { @@ -747,5 +751,6 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error, int *data_error); void sdhci_dumpregs(struct sdhci_host *host); +void sdhci_enable_v4_mode(struct sdhci_host *host); #endif /* __SDHCI_HW_H */ From patchwork Mon Jul 9 03:19:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 141360 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2166790ljj; Sun, 8 Jul 2018 20:21:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe24fJ/+9FGr7HqKWXIVtINlrQb5AsAHVAX/tCbERfsoV/6JfCLEpf9VOuNRhXlvR/3PWS+ X-Received: by 2002:a63:8c0b:: with SMTP id m11-v6mr17534999pgd.372.1531106489040; Sun, 08 Jul 2018 20:21:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531106489; cv=none; d=google.com; s=arc-20160816; b=JCy0hlsaAz3/m9bjR2Ts6LeQFj/05ITHZ8fBi8pwYpQ9yJG90MFxbrwPlv7LVNlE4i RInGEkqxlTTgQEvoGYIv+2eaGc5668AgR1TtS8pD0SH8o6NebziAOZXD5gO/Qhb6HwPv Z29whCxYPpm7dkstmMwMOY6la7Hq6BNERT+BrfZh0osyvc3GtzhfROv9aB5n6Zow4vh7 koU0H9s9AhKt+J7/mMItuueww8eXoFOFg+MnGMPPyK4X11ODE2LrQEz5K8EgQz0pG9EG Ka47siu0st83K+yGxMT0twZ3888u9eAMsZ+D80NwTvedNc+agekA6V4lrdUGWVunjmeY uNEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=q2qnE+d0psJIKurjAu2lfNrbqvVLnoTtcmJ8tnItulU=; b=ZSgHsp1YUmcucw8xrCzw51s75tlSNYb5vxaloG4n/D+H5+zKBQMNrxdxw0SYont5PY Z/iJ+OZrCO0vb8z++VKpTxX2MVFei/NR4t7t3gLgQRK6Y+sPwyVqyVh2Dr97dlqO9Ls7 oL6Ri1zn3Rr0x2oBZOpoJQzMxBImxE4eI+D15gWZ006XHARRS4SL3dxxeY9DO5Dl9POd auOrMTtoMdU8xCk2iXBDXL4quj2QdqzxpKsIfECTrSTwAcbXiBg6qphF1dMxgufMXyNn 94gBjzmxb/GliuphQmjbnFaXkTL5T8uxR3fRX3bN+zyirwoyShjD3+b/ER05R9jtEMa3 J8kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NCwRjkju; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d16-v6si14485506pfe.267.2018.07.08.20.21.28; Sun, 08 Jul 2018 20:21:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NCwRjkju; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933275AbeGIDV1 (ORCPT + 6 others); Sun, 8 Jul 2018 23:21:27 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:40501 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933040AbeGIDVZ (ORCPT ); Sun, 8 Jul 2018 23:21:25 -0400 Received: by mail-pl0-f65.google.com with SMTP id t6-v6so5346050plo.7 for ; Sun, 08 Jul 2018 20:21:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U2m4J5ZcFgcmYhx2M7R/05FBJ9kdju3nRv1lZnT2H/c=; b=NCwRjkjuDvXljol15IfJUAYGd5eP9IJLE6Xn4+R69HtiXMl/QbUfPKwKM8VIwBIU1c +fsRR91DTxuWi6ibW2lki58VeGggjf6JFsg7s8F1EauwYSlc1DPLYjyhjDQBZDFEM04G jnZ5IcWqgPgQhvZ9KGyi6pVsmhnkAoH/cXKD8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U2m4J5ZcFgcmYhx2M7R/05FBJ9kdju3nRv1lZnT2H/c=; b=gM1IlNaeT1LSPsYjHiM3a5EAabRiaI85H3aA4aJOAGLc7D8GwiYH6vwCD0Tdp+YZHk fbcPb9nEo4iHBBS2ZMs0pUthHdyAqMWwEZyXxH+gJ9tqT6ZmnvYFri/xNPWwUbzZxy1A IcG3ar7CcxVBbqMcBPDBJWFegFRxvYs4vnes+4L1EvKz8mhH7mGOFWVL4vJNkF7Sl7aI kNKwjr5XaTuRz3PMJh04/3w7HMJk//R/znUpJlaGIErQ5svtKq4KvoGHjbVN3S+nleQT GCcT4aMiSb5aYbi4WHPxMwnec7FLmJhX2tmYvS27w/HJ5ZjTN2beZI8N9jz2i5SJscXl 9zZg== X-Gm-Message-State: APt69E2l3K10N9z7vydLzPhALPWkN+rwa/+jwy56E1/rt9CQMrPlmjSS LXvmVi32j2Wxv7aGJxErce3qmQ== X-Received: by 2002:a17:902:7782:: with SMTP id o2-v6mr18925446pll.93.1531106485077; Sun, 08 Jul 2018 20:21:25 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id e82-v6sm41458950pfk.87.2018.07.08.20.21.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Jul 2018 20:21:24 -0700 (PDT) From: Chunyan Zhang To: Ulf Hansson , Adrian Hunter Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Orson Zhai , Baolin Wang , Billows Wu , zhang.lyra@gmail.com Subject: [PATCH V3 2/7] mmc: sdhci: made changes for System Address register of SDMA Date: Mon, 9 Jul 2018 11:19:53 +0800 Message-Id: <1531106398-14062-3-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531106398-14062-1-git-send-email-zhang.chunyan@linaro.org> References: <1531106398-14062-1-git-send-email-zhang.chunyan@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org According to the SD host controller specification version 4.10, when Host Version 4 is enabled, SDMA uses ADMA System Address register (05Fh-058h) instead of using SDMA System Address register to support both 32-bit and 64-bit addressing. Signed-off-by: Chunyan Zhang --- drivers/mmc/host/sdhci.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 525862f..c7de6a5 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -701,7 +701,7 @@ static void sdhci_adma_table_post(struct sdhci_host *host, } } -static u32 sdhci_sdma_address(struct sdhci_host *host) +static dma_addr_t sdhci_sdma_address(struct sdhci_host *host) { if (host->bounce_buffer) return host->bounce_addr; @@ -709,6 +709,18 @@ static u32 sdhci_sdma_address(struct sdhci_host *host) return sg_dma_address(host->data->sg); } +static void sdhci_set_sdma_addr(struct sdhci_host *host, dma_addr_t addr) +{ + if (host->v4_mode) { + sdhci_writel(host, addr, SDHCI_ADMA_ADDRESS); + if (host->flags & SDHCI_USE_64_BIT_DMA) + sdhci_writel(host, (u64)addr >> 32, SDHCI_ADMA_ADDRESS_HI); + } else { + sdhci_writel(host, addr, SDHCI_DMA_ADDRESS); + } + +} + static unsigned int sdhci_target_timeout(struct sdhci_host *host, struct mmc_command *cmd, struct mmc_data *data) @@ -968,8 +980,7 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) SDHCI_ADMA_ADDRESS_HI); } else { WARN_ON(sg_cnt != 1); - sdhci_writel(host, sdhci_sdma_address(host), - SDHCI_DMA_ADDRESS); + sdhci_set_sdma_addr(host, sdhci_sdma_address(host)); } } @@ -2796,7 +2807,7 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask) * some controllers are faulty, don't trust them. */ if (intmask & SDHCI_INT_DMA_END) { - u32 dmastart, dmanow; + dma_addr_t dmastart, dmanow; dmastart = sdhci_sdma_address(host); dmanow = dmastart + host->data->bytes_xfered; @@ -2807,9 +2818,9 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask) ~(SDHCI_DEFAULT_BOUNDARY_SIZE - 1)) + SDHCI_DEFAULT_BOUNDARY_SIZE; host->data->bytes_xfered = dmanow - dmastart; - DBG("DMA base 0x%08x, transferred 0x%06x bytes, next 0x%08x\n", - dmastart, host->data->bytes_xfered, dmanow); - sdhci_writel(host, dmanow, SDHCI_DMA_ADDRESS); + DBG("DMA base 0x%016llx, transferred 0x%06x bytes, next 0x%016llx\n", + (u64)dmastart, host->data->bytes_xfered, (u64)dmanow); + sdhci_set_sdma_addr(host, dmanow); } if (intmask & SDHCI_INT_DATA_END) { From patchwork Mon Jul 9 03:19:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 141363 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2167140ljj; Sun, 8 Jul 2018 20:22:03 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcvXZK3kpS8oXefNDXC+yGV5pURlNZLY0v48eNk1zdEm8sa9xai/3BRHF75z4YGL8XzCGgT X-Received: by 2002:a62:e18:: with SMTP id w24-v6mr19639012pfi.145.1531106523089; Sun, 08 Jul 2018 20:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531106523; cv=none; d=google.com; s=arc-20160816; b=Dq2fKEtRwkSFQZAmM5f9VmP2kuzqaAh4g3AjmHY4PWn7gOdf/xamsxNaFenj9Q7SfQ 2Bp96CCT70y+uKAT32qaMczb/SI7firkOW1jNZmxsp/DB4Zz4IvDVSMnbV1pRA/tCJHF 3ldfJyMSkvzh2R4ykq5PnVZWSFSznplA7Dzc8CImwPgO5sFCiAJTwN2ituf669BFZjxL Avkh6IdVBwwQQyhiE7T+DNG99FEjs88fuX1866s/cP6k7y8fUiOyrunblVbvz0KBmCz5 VDUDhQSHZFZJO7kS8cFVWpJ6bgsqQiEbMatGPaTPBdsf4APvvY2by5X7KNXxqlomuBCM WO7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=dZTY46EcY/a632sV7OpmQl03btKKNrwTdanpP0HI/4I=; b=iiPT28cwqWH9y74PzRythKA7Eip8bwA71UEO9eujPJfkobMnCRWRwm4Lmf4G5rSLSm E858WNuSgIBr45rFkBxMCtjuzkMmrusX9xwe5iCHowS/3nuDSVgtcSVPMzUTWBuKrDNa jb6+IxSQiMEqO4mfvjunEX6pZG/uwA7NhxSTqorFJlTKtnHc7acR60NWRU+lCabcuuc0 kGvKx8HW6yeD6SRZk64i5sP4ScGS27k6V1Za3v5nN6aiDJaHqzOTY3O+jUHgSAXHEiOB akq/XvWqU+whQdlJzbWfDia/O3E8611M9IOFxSa7tDTRb0MwXKrl+L8O1QxFEoirU2wQ Tv5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eExNJfwr; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b23-v6si13219207pls.341.2018.07.08.20.22.02; Sun, 08 Jul 2018 20:22:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eExNJfwr; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754442AbeGIDWB (ORCPT + 6 others); Sun, 8 Jul 2018 23:22:01 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:41849 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754375AbeGIDWA (ORCPT ); Sun, 8 Jul 2018 23:22:00 -0400 Received: by mail-pl0-f65.google.com with SMTP id w8-v6so5343258ply.8 for ; Sun, 08 Jul 2018 20:22:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ey789fHEvUYxMIfFWvZa0+J79sna2Fb1Og/8oPpUtLc=; b=eExNJfwrcCCDcUfslT48vdm3LZaaKmHx7HmOx8tCxk8d+e++fQyDtDmNGDCLgIKRAk CsG3xcfTCHM31RHCebwLP8iaD2cfetFa9cQ0cLoHrwdwxV7LwD/36lPt8sryH0efLYDM KVvERUpn913AFY875wb6IB7XVBbXfeGrQ19Aw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ey789fHEvUYxMIfFWvZa0+J79sna2Fb1Og/8oPpUtLc=; b=azHGmAnZ1v2t0F1J+5ivrFjhdPfNFMlxwKN4BTgGTDEM8DLOiwzA6F/9FGSdD6EjAD gcUUcsSqzNBPxUlV2jhFxAmBwguEMnFyfBFeKVmWsgjAF1OIId34SlUe2xo2HDLSXTAF bANG2+TMqjRl9NgXur3n918XsXo+WUPvcyrc0CZP5muV3ma8vNbV8wH7pnBSJAp+CLFt xJq5IObNiGu8pKzKCqtVOsWOBbPErx5spCVXfxQi50WcpZKBgv3L2GCbxKw/FlaGfml2 3Qy89+icRuDnGokJQWVLCe50oX5UzPZ83zgITAFUBV776SlK+zfPCUU2ZKm+gt4xRn8t cheA== X-Gm-Message-State: APt69E2KtGjNhJbuG66DCcO5vmDpmAqntgv6MF7F1Q8wwYV0FIIMr5D/ sIq+LuJoBvJCYjzSPnkMlVoYGQ== X-Received: by 2002:a17:902:2006:: with SMTP id n6-v6mr18808377pla.325.1531106519740; Sun, 08 Jul 2018 20:21:59 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id e82-v6sm41458950pfk.87.2018.07.08.20.21.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Jul 2018 20:21:58 -0700 (PDT) From: Chunyan Zhang To: Ulf Hansson , Adrian Hunter Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Orson Zhai , Baolin Wang , Billows Wu , zhang.lyra@gmail.com Subject: [PATCH V3 5/7] mmc: sdhci: add Auto CMD Auto Select support Date: Mon, 9 Jul 2018 11:19:56 +0800 Message-Id: <1531106398-14062-6-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531106398-14062-1-git-send-email-zhang.chunyan@linaro.org> References: <1531106398-14062-1-git-send-email-zhang.chunyan@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org As SD Host Controller Specification v4.10 documents: Host Controller Version 4.10 defines this "Auto CMD Auto Select" mode. Selection of Auto CMD depends on setting of CMD23 Enable in the Host Control 2 register which indicates whether card supports CMD23. If CMD23 Enable =1, Auto CMD23 is used and if CMD23 Enable =0, Auto CMD12 is used. In case of Version 4.10 or later, use of Auto CMD Auto Select is recommended rather than use of Auto CMD12 Enable or Auto CMD23 Enable. This patch add this new mode support. Signed-off-by: Chunyan Zhang --- drivers/mmc/host/sdhci.c | 39 ++++++++++++++++++++++++++++----------- drivers/mmc/host/sdhci.h | 2 ++ 2 files changed, 30 insertions(+), 11 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index f64e766..1ca3871 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1033,6 +1033,33 @@ static inline bool sdhci_auto_cmd12(struct sdhci_host *host, !mrq->cap_cmd_during_tfr; } +static inline void sdhci_auto_cmd_enable(struct sdhci_host *host, + struct mmc_command *cmd, + u16 *mode) +{ + /* + * In case of Version 4.10 or later, use of 'Auto CMD Auto + * Select' is recommended rather than use of 'Auto CMD12 + * Enable' or 'Auto CMD23 Enable'. + */ + if (host->version >= SDHCI_SPEC_410) { + *mode |= SDHCI_TRNS_AUTO_SEL; + return; + } + + /* + * If we are sending CMD23, CMD12 never gets sent + * on successful completion (so no Auto-CMD12). + */ + if (sdhci_auto_cmd12(host, cmd->mrq) && + (cmd->opcode != SD_IO_RW_EXTENDED)) { + *mode |= SDHCI_TRNS_AUTO_CMD12; + } else if (cmd->mrq->sbc && (host->flags & SDHCI_AUTO_CMD23)) { + *mode |= SDHCI_TRNS_AUTO_CMD23; + sdhci_writel(host, cmd->mrq->sbc->arg, SDHCI_ARGUMENT2); + } +} + static void sdhci_set_transfer_mode(struct sdhci_host *host, struct mmc_command *cmd) { @@ -1059,17 +1086,7 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host, if (mmc_op_multi(cmd->opcode) || data->blocks > 1) { mode = SDHCI_TRNS_BLK_CNT_EN | SDHCI_TRNS_MULTI; - /* - * If we are sending CMD23, CMD12 never gets sent - * on successful completion (so no Auto-CMD12). - */ - if (sdhci_auto_cmd12(host, cmd->mrq) && - (cmd->opcode != SD_IO_RW_EXTENDED)) - mode |= SDHCI_TRNS_AUTO_CMD12; - else if (cmd->mrq->sbc && (host->flags & SDHCI_AUTO_CMD23)) { - mode |= SDHCI_TRNS_AUTO_CMD23; - sdhci_writel(host, cmd->mrq->sbc->arg, SDHCI_ARGUMENT2); - } + sdhci_auto_cmd_enable(host, cmd, &mode); } if (data->flags & MMC_DATA_READ) diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 889e48b..8263ac6 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -42,6 +42,7 @@ #define SDHCI_TRNS_BLK_CNT_EN 0x02 #define SDHCI_TRNS_AUTO_CMD12 0x04 #define SDHCI_TRNS_AUTO_CMD23 0x08 +#define SDHCI_TRNS_AUTO_SEL 0x0C #define SDHCI_TRNS_READ 0x10 #define SDHCI_TRNS_MULTI 0x20 @@ -185,6 +186,7 @@ #define SDHCI_CTRL_DRV_TYPE_D 0x0030 #define SDHCI_CTRL_EXEC_TUNING 0x0040 #define SDHCI_CTRL_TUNED_CLK 0x0080 +#define SDHCI_CMD23_ENABLE 0x0800 #define SDHCI_CTRL_V4_MODE 0x1000 #define SDHCI_CTRL_64BIT_ADDR 0x2000 #define SDHCI_CTRL_PRESET_VAL_ENABLE 0x8000