Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2620048imm; Fri, 24 Aug 2018 02:23:34 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb/mKJc8mpWEAjGa7ZQeuj+as1EFN/cqe0NselbKhhziXg43J/AoQlS1JCV/ULiXmF6s0Lk X-Received: by 2002:a62:8704:: with SMTP id i4-v6mr1065378pfe.62.1535102614637; Fri, 24 Aug 2018 02:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535102614; cv=none; d=google.com; s=arc-20160816; b=zvugXMHvcsJ/YIVF05DQ3V+75DfW2Y9ZASnK/vZSBeL6WhgnsPZUsCV72uKAZp2sQR +2XzbRVhKTy+wpLcYBPM/0qc+dJ6b74WKwY188/zslJLhJJyJa4oftXz0SuRizi7VmeF 1d2aVBeuAtDM3lgFNEFTpYoP1+xJpK5uUpTtl7Fgo7EDssvdBVn1MFRYTifCIDtSbacK xJpfHRB0qKlyLaJJWlwaof+4n46JQ4gWD+WD3ME1NxQpULWEMvB/tVl9YhC0oOASzVQG FD0rgG6SkyDcL/so5uFde5UqRb2/GR50MBN/iS+/FEOBgcpo9Xiob5PBY/SMKSFpo1ZF 8r6A== 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=VLyWTs4wkn6Lk1EZkxQq2kCYTxna3ww596giwJ8qsjk=; b=QKmIkcTHQfragMoWve8Jzet2DqAQN2eB7mfmyMnmmmYal8iImHjW8tqrn8u6aPoaod 1lgFgghlZpXJP298nyj1vls/LbCiWtTpOsgVTPaiF2c5NjEzxUspEnebv5fTca3p1h9L cSedKhyr30qs29Ky8IxwR9EvGROgFLqRvjmrz4e5X3tcfep5atzVGe9lmjwZFo6Pf/7p qbIEUE9iEkuQVD9Fd/EGGKyuysFdoq/MjPTd9BLMHvSEXv2GQmfxkbjV7YJZ+qQSYk/H Ngb5O9dLkGpXI/vPmCZs7/WHHbAqXPton7DSiig87cP8SL+Wk2c0KBq79te1Uf4FvbVN +cGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eaSFFO0r; 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 f13-v6si6404995pln.512.2018.08.24.02.23.19; Fri, 24 Aug 2018 02:23:34 -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=eaSFFO0r; 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 S1727753AbeHXMzL (ORCPT + 99 others); Fri, 24 Aug 2018 08:55:11 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34089 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726423AbeHXMzL (ORCPT ); Fri, 24 Aug 2018 08:55:11 -0400 Received: by mail-pl1-f194.google.com with SMTP id f6-v6so849597plo.1 for ; Fri, 24 Aug 2018 02: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=VLyWTs4wkn6Lk1EZkxQq2kCYTxna3ww596giwJ8qsjk=; b=eaSFFO0rjDeVblmfXrJh6DRbfNO94vDFPn62rsymhsBfMK7eMwJ4Mtzd7Qut8sn/c/ gtwc6jmiRkAe3iYjMptFUqsw7KpmBZOR31Fc8GBX4AVxuAYUJjKUF85eHtb3yD/io+4V H9D+YMhP+kY4utkm8/zLIc5B3CYzdl3VXlfMA= 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=VLyWTs4wkn6Lk1EZkxQq2kCYTxna3ww596giwJ8qsjk=; b=kTH1B1bMKYdMOsjn387jUB6pqWFqaQUxTN++jetq/4EOCWvdInc7YizCUxWLT9Gx1I RaTLZDkz2PPNBbwyikT22sP43ZrxpOJ5rICl8bxKvlOfZlY6ShXreeUe//Vq55NHiXn/ Oc57E2/RuB48cHAoyIAit1BKu3BraTx9TrcCeodiMRRK9qXiiO7GMOGAEEQKDav2UMlF kepU/ldmkINkKYxelO6FXkkCdo/dPCGnDeRjXBzbogfnJtMHYoSqFUGLJC10j6vdrn0f yDJf6qyvqV9nw9095784ZYAoN6jtlrOJG1QwUV3YVZL2eyyVq7MBkZrAZ3HLt/u2xhBb htYQ== X-Gm-Message-State: APzg51DWR4C6755Js7N8aIYo1JhReQ1VJVveso8vNeBW9iTLyegyhnTi tFHrRrbaJ8BzO5XhgU2sVf1raA== X-Received: by 2002:a17:902:4324:: with SMTP id i33-v6mr865592pld.43.1535102485071; Fri, 24 Aug 2018 02:21:25 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id g6-v6sm9520314pfb.11.2018.08.24.02.21.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Aug 2018 02: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 , Jason Wu , Chunyan Zhang , Chunyan Zhang Subject: [PATCH V6 3/9] mmc: sdhci: Change SDMA address register for v4 mode Date: Fri, 24 Aug 2018 17:20:22 +0800 Message-Id: <1535102428-20332-4-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535102428-20332-1-git-send-email-zhang.chunyan@linaro.org> References: <1535102428-20332-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 | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index a50842c..df283ca 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -727,7 +727,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; @@ -735,6 +735,17 @@ 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) @@ -994,8 +1005,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)); } } @@ -2823,7 +2833,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; @@ -2831,12 +2841,12 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask) * Force update to the next DMA block boundary. */ dmanow = (dmanow & - ~(SDHCI_DEFAULT_BOUNDARY_SIZE - 1)) + + ~((dma_addr_t)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 %pad, transferred 0x%06x bytes, next %pad\n", + &dmastart, host->data->bytes_xfered, &dmanow); + sdhci_set_sdma_addr(host, dmanow); } if (intmask & SDHCI_INT_DATA_END) { @@ -3583,8 +3593,8 @@ int sdhci_setup_host(struct sdhci_host *host) } } - /* SDMA does not support 64-bit DMA */ - if (host->flags & SDHCI_USE_64_BIT_DMA) + /* SDMA does not support 64-bit DMA if v4 mode not set */ + if ((host->flags & SDHCI_USE_64_BIT_DMA) && !host->v4_mode) host->flags &= ~SDHCI_USE_SDMA; if (host->flags & SDHCI_USE_ADMA) { -- 2.7.4