Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp91808imm; Sun, 8 Jul 2018 20:22:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcbKZXCgE9LctU6ainbEXal6TGT6xMJH7FlknFwb9SzXp+ee13pM0/ILRf1URmPTVJiwUc4 X-Received: by 2002:a63:2c8e:: with SMTP id s136-v6mr9287273pgs.390.1531106566369; Sun, 08 Jul 2018 20:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531106566; cv=none; d=google.com; s=arc-20160816; b=zfc21PVP6dESeDQ+yKyqRror3zl9PcpwkcUs7CtJkSs+nLEuNP4SHJ46Gr4OKD5ym0 ZV/3fZVdcxgjFTId1CA/4f5wxxxrnLH9iGn55MFmllyWqfUMnw/JkkTobxMrr+EdfeId TqFY6sNVxczG75YCxIla9KlmZf9A7Aqea8q9JPaYg4opS1zlyhhu8ieCTMXAwzF5d+4y 0a+pGz+yfnnwR1uhPvt+B6NJrCK8njP+q9/k+rdKDfnNTv+810o9VjL8R630MHLgHvR2 KkkIeZWKjBu9dQvxKdaCO/EJCqStLt2xUrQECBvURsLK2eUPmj5LqEFph4d0joUCb/mR BL5Q== 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=U2m4J5ZcFgcmYhx2M7R/05FBJ9kdju3nRv1lZnT2H/c=; b=O0LahmX10AO+SFYgpCw1Tt1wXdSdQS8MMjwXfsXv61Q2awYBDdmMbThhYUEZ+QVlGm fT61LLQGwvN7UHtU4LKvS5nvwuorYr1Y+zHyjaOUrW0VbvVa2HyEXTHdvMp6K+In9Z6c PYln19yByb2XQlFB8CGTkGRtJqboEmuFnYJFiOZ1a187rDlg1JkEKiXBjuRGa35bWrb1 VJgkq1I+9BuuTNdJunE3ZS2iAlcExEq8LtKyrVhfFhjsAUklqa0LOw3rFdUWxv7+7tov g7yYbULMmPiCZehbEJtbKd4Zzz1dF4/Xn7nRrT0z9Sk7bn/NS/qVEEJ7OiOiAlmS448z NQ/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NCwRjkju; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 be9-v6si13809230plb.67.2018.07.08.20.22.32; Sun, 08 Jul 2018 20:22:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NCwRjkju; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933320AbeGIDV2 (ORCPT + 99 others); Sun, 8 Jul 2018 23:21:28 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:38468 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933267AbeGIDVZ (ORCPT ); Sun, 8 Jul 2018 23:21:25 -0400 Received: by mail-pl0-f66.google.com with SMTP id b1-v6so5344465pls.5 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=j+JOS/iwJ6YOi22zMOfXmuTNIImxCC7ro5xTD024SSNqkSj8zyA0Gepns/U4YyI66h OqEkU8wIdmwi77hsJmsJ0An6Miwnx1V1WCfB3Ge5awl5rwR3NATBScHWkzCqKE/2AEnz G8ryEg6hCIq+Wxy5EIDVAwy/6Z0yMQ1+bZSCILRsgcwAoP+EDJByDB8xeg/6kvIqGr2S dr44d7RkFFthX30WYZKIIjY6DgM8f2cKYzVaqBTO3KtMBDLO3xz8XdfW+LUm8/75NF60 FkImDAd/3wtA7jVMhSFPdjWiDpWkeUNuoRO+YPkEwq3LN5AM4Sq6LRalj6JK15U7T0qv 9a3w== X-Gm-Message-State: APt69E2BGUyL5ACtHNrHuLAsQ+PxQTrf4PBRvVkv4rBA2wweOa5EnSds EwuelA0h+uDKpuZN3I5lKqapXw== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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) { -- 2.7.4