Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp396534imm; Thu, 30 Aug 2018 01:23:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZoAco5IrELbemJOVfsbmS7xL+4nYPU7HeN8N2JgzHALmwxaMWgZTbayR6UVwDyyTZqOND3 X-Received: by 2002:a63:fe02:: with SMTP id p2-v6mr8933835pgh.148.1535617424350; Thu, 30 Aug 2018 01:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535617424; cv=none; d=google.com; s=arc-20160816; b=Dns2uI7orKi0AQruU3bJqa2mmegPnimE/hH8HGF/4n+dLsW+6JDlE31eCNtQzbaZ+G 0VTRM3l6QXq6Dw6ALefWIbgYHv7E3C3W3iyhhpSjgWmUa3cG7EpdIqlPJJVODStB+5d8 lGT0CA0KValdKuFS8EJ7T3krzjX3+RezT+aEnBeFc5sG4p5+9iox+6My/GPIxlqQaDB/ qSMoLdZrKtrisjBRlKtxj0dOiOpnx0+qrVghl/RXe/pYdHEJTQvQUVLCqhqkUf5iANrJ EDJfamF8dN3HlSwgfp59O6bOAmIj/n430E+98Y1diJfcoTEQUzrL7/dm9RGIzR+Fw9RZ XRUQ== 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=wj6LwXf/jUT8nmKoqSVJBo3vcF/egS7nUByoGr88L4Q=; b=t8aiAfvK14JhqhZ9YBytAmd1QcAumDylDVOvXTa9HLqsKRe4wDyfdBL3n+goQrJf8Y dIiHnJwBXKGnoVt9dlVmAwB0VQtVAX7csUhsSB1+OgfYq6n98+1ESdlVyYPWSbbaz4c8 qOcxWbIceQgaMwbUWdxMXU/UfSF6gLhBIbUj2MClnL7sgkl4BnIRzZ21nth/W7HF4YOi rqppnPcf/Lf59PHqySS7TAqKk8cmEicGz58uXun2xIOnRGJo8k39c2xhEdWOKzu/TES5 5fEzMzNdzLZPNkpfQMcAClqVdojmrfQX1f7STmw/VWeI79ObIYp6jBAgC/o49d+pM61H Tqow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jon+xq5T; 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 y2-v6si4622239pli.100.2018.08.30.01.23.29; Thu, 30 Aug 2018 01:23:44 -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=jon+xq5T; 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 S1728022AbeH3MXJ (ORCPT + 99 others); Thu, 30 Aug 2018 08:23:09 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34037 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728007AbeH3MXJ (ORCPT ); Thu, 30 Aug 2018 08:23:09 -0400 Received: by mail-pg1-f194.google.com with SMTP id d19-v6so3573822pgv.1 for ; Thu, 30 Aug 2018 01:22:10 -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=wj6LwXf/jUT8nmKoqSVJBo3vcF/egS7nUByoGr88L4Q=; b=jon+xq5Tky6PYU/p0fvDZeq0yrKRr3lHslFiLxKk450BYuaRzVEsYsxXsAsYXegIG5 8Kmzr+9KpbIYCYhKyFpVSoniiB021+DE5InFWFWTz0N7ZqWdy6Xbch6prxLHJM86+3ZS z0KfP3QTQSkvbD8m2VW7QwF8dd3dJm48hmAfA= 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=wj6LwXf/jUT8nmKoqSVJBo3vcF/egS7nUByoGr88L4Q=; b=bkcNfbExZVbwzepXt3OW3CLqYnTyEwchBsh2JOIhEbGAymaSaWrzvwNAvWwuw5EfCP elkjYuOzRdbY9qnoeUHp5tsn2GFh94lBQX3fqqET+kPHnXkvmBJVk4wnhmQaMkrvzJii E+b/IG5VL6tjZeh6KuAimqocye/6KkQ4tQlPFjC8vFl6u6iLEJiHUniReDWNC+OKjRah A1bMVpvPNuwMuaM+uycbAkw3wN/k3Q9hdonZL2XPSHieg2dbpdHZTe+o6KJhOkvIwTrI gx+rZ05d0VDSfoF9MZyXKgTocWTit9ktjfvQr3T0/MxJ+Yuqg10hpjFoEy46XuHbwkPN uWeA== X-Gm-Message-State: APzg51CJ7StVMDarRCO5vqF0yfu7cy4+FavjniDoPLTX7ghsmUxu6aL0 wKCQHRb1yyb7TIGQDt/Y4E+aDw== X-Received: by 2002:a65:650f:: with SMTP id x15-v6mr8942680pgv.127.1535617330612; Thu, 30 Aug 2018 01:22:10 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id j22-v6sm8224885pfh.45.2018.08.30.01.22.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Aug 2018 01:22:09 -0700 (PDT) From: Chunyan Zhang To: Ulf Hansson , Adrian Hunter , Rob Herring 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 V8 3/9] mmc: sdhci: Change SDMA address register for v4 mode Date: Thu, 30 Aug 2018 16:21:39 +0800 Message-Id: <1535617305-16952-4-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535617305-16952-1-git-send-email-zhang.chunyan@linaro.org> References: <1535617305-16952-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 Acked-by: Adrian Hunter --- 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 0c61105..6fb70da 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)); } } @@ -2830,7 +2840,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; @@ -2838,12 +2848,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) { @@ -3590,8 +3600,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