Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6482199imm; Mon, 23 Jul 2018 19:49:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfOCoazPQ4ZE+bi8SQ8fOYS7I8C4bQN0kVoAb3mXgUd1vd3LLSqH/uU6H16+fEXThekISSQ X-Received: by 2002:a63:214f:: with SMTP id s15-v6mr14365078pgm.267.1532400583318; Mon, 23 Jul 2018 19:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532400583; cv=none; d=google.com; s=arc-20160816; b=Nc628OvEHmf7oaKhprJFX2n0v99rc7qwwLNDI1OwL7SZFPPcZSxCbhBjjMO3AbOe+Z xqREr3wV/oFTbqrA11HxkOkv81m/N7QQ8qXpnsZ4dKL6ByazFBryQSQRb7dkRTzyyQzs PrYrhFaQaTQpPk6e2hJsowafcsN5QH3HFkxX02WbUE3byw5n2r950A3RiM4fHwXHAdLY 73GJznf4fo7TuEQSfallSOFZbapBRLV4JN59TibaodRIprF8grG+3D7ZSH73t6dtWRtz HfWOj4y99aL66t3tTocVT+wVkX02RK+9V1ksD9oURIOPW1vf9vxYZ+s7TiqNORQAAm0r mAGA== 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=6DV7W+akCn1JXYX6cY44SjkWu2aP6JR6coSCc77p/6o=; b=hd9HvX89YPEvU4LZDKjEGO37iY3oyeZq1yBBACcrObBqN/tWkIDy6O5qNw7u0zvLgL a+8dxTU5/eDyg/bu6dUpWYb6ZUo2bJmLBxqsBHVMoMCCiSda+vxtWu+WbyG3zgWQV3AQ 71vSFkbGZZwIxbPd0y06EAVmhPN1XRPbt+5OcFQbiwLH1W+5+qvUlPByc4/+ovXpuvR+ ri7tQA8RxUuK1XWpwqfq+9/9mbVVsjzFD518dWH8ANhQ1DZetfUxBkYiC9BkgorF31py 7HxThUZsC8UkbSwcHqRdIFcq04jLccSx/1NnJWnAYLxJPtCjJM2wTsFXdIbljuvKY7Jm 2ipg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TbtQrpn+; 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 z28-v6si11067369pfa.161.2018.07.23.19.49.26; Mon, 23 Jul 2018 19:49:43 -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=TbtQrpn+; 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 S2388408AbeGXDwo (ORCPT + 99 others); Mon, 23 Jul 2018 23:52:44 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36301 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388365AbeGXDwo (ORCPT ); Mon, 23 Jul 2018 23:52:44 -0400 Received: by mail-pg1-f194.google.com with SMTP id s7-v6so1761269pgv.3 for ; Mon, 23 Jul 2018 19:48:33 -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=6DV7W+akCn1JXYX6cY44SjkWu2aP6JR6coSCc77p/6o=; b=TbtQrpn+LgjRf/TuRvt4dBxGop97AHuQroyZdrBFltWxxr6cK/nly01S9TEkc+0+zu XCZi5CC3dTZBNrjIyV3BVEOBWBN7Qj0m4qrWxfzVLNyBqob9S5+0+dXQt36KVZOJW9MJ R4fYmP/hny1RRfe59R8HOhOuaRmBuHKrxLYgA= 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=6DV7W+akCn1JXYX6cY44SjkWu2aP6JR6coSCc77p/6o=; b=DfWGb2D4dwEeviNHjn6NOJpVg4kOFklvWBUD7EtNhB+kqO7HV51Vhe2CR0POS8iX2m UDUXlEBDLLqv/H5RA2ZNl4pwFEPE3/n8F/PVV1zx0eW2ong3HaN8ylWZcQi2/5qBQkQj 7R5IgvOloZDMRKWnoa9sk6ocLA33+chPD+Ora2CtzE8UcpZGq7t/MzY22cEVRCuYWQ40 Ega+XMmCdvwwLRjLgzfkp7xhg31yQpSfv6+1kGWTM/Ng6JeP9tHBG00qxBoYi8I9Pshm yFTszbkHPUjZ/9S2ilvXzy3JiUbYXaRdATHSVTVen7MxjWFzEzS0/XXITmYCTDk+kYZg kz7w== X-Gm-Message-State: AOUpUlFqyyI0s4gpjcAFx8Kn3zydnfyy1t1yUVvsBA/Agei9DbNLnr6N k1gSSS3vBhFmiuxvkzU5lRMNKA== X-Received: by 2002:aa7:8713:: with SMTP id b19-v6mr15686241pfo.151.1532400512758; Mon, 23 Jul 2018 19:48:32 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id k12-v6sm16540836pfj.30.2018.07.23.19.48.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Jul 2018 19:48:31 -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 , zhang.lyra@gmail.com Subject: [PATCH V4 2/7] mmc: sdhci: Change SDMA address register for v4 mode Date: Tue, 24 Jul 2018 10:47:59 +0800 Message-Id: <1532400479-23216-1-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532340508-8749-3-git-send-email-zhang.chunyan@linaro.org> References: <1532340508-8749-3-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 | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index cab5350..b7ad8e5 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -729,7 +729,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; @@ -737,6 +737,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) @@ -996,8 +1008,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)); } } @@ -2824,7 +2835,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; @@ -2832,12 +2843,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) { @@ -3581,8 +3592,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