Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5625274imm; Mon, 23 Jul 2018 03:10:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgpchp6MaSy9iyrXPAlo4lPY8sU3F4Kc5bss3r/GlqL16D+CrPgJOCLwFl0S05hPpprzG2x3p X-Received: by 2002:a63:4450:: with SMTP id t16-v6mr11658795pgk.102.1532340650180; Mon, 23 Jul 2018 03:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532340650; cv=none; d=google.com; s=arc-20160816; b=HuoP5uIGNFbDmcHhZ6+q+ktWtc6cm5nGv2NIel2LYJzp61IueAfwDQTw5+7ffYibYZ iQZOAohDq+QctxgP82gZlWmj7+kcl4ul81Xz6mZBdJZlhK5yDRiSAbfwvGi2qUartP+t 46mCOen+FT7uGOWrGc/rRB7R4RXkR5a1Ps0nUQUFkKzPz9ID4RUVtK+m8+NHdZv8dFoq KG7gXj3fN9ZwHL3AptWC9qllkmW9SN2OUBeOcgJAJ9O35/0uzVDJan4JLWpc+Z/AVF6H C786UPp0nYzDioH8Btq8aZlSnyRnapHM0B11y9InZ0o1wT6AgwXKbGF7N3cmBY9iTUV5 Ae0w== 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=Vwl51bqmcDS8wp+lU1pZalSc7Z3bokmXBYlYRayzf+k=; b=RX1277DRMzWA2o61185qA9AV5cQw4XRctBU7jYMB8uXJNgtzC/jkRjt3J+BYAbdkBc XwHkT48y4Ki6SYBC5aHKixjtcKH+rzskfIKDsxho5KokXjDJNEMxxyJdeWmNi6jWea0i Npb+gGOX9geTq1pvDTqyCgQJZbSC9du9n3utgtkTuBCACaPaoJ5sZvBrtw+upUAffRQO Ll/3MCYb9aMcru3OBcb26R/EW8LuOiS8Of5Jq0TkKUIEsCqtLkQbeBoj3Kw13bgoZq95 vuhlVYs9/7pj+rVKl1rn4wAHBKJHWw/2vCDuVka0jzfdWkWQafXBSnJALWGU150A2hOv /noA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aafJerS+; 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 bc5-v6si7742205plb.413.2018.07.23.03.10.35; Mon, 23 Jul 2018 03:10:50 -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=aafJerS+; 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 S2388402AbeGWLJy (ORCPT + 99 others); Mon, 23 Jul 2018 07:09:54 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35609 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388246AbeGWLJy (ORCPT ); Mon, 23 Jul 2018 07:09:54 -0400 Received: by mail-pf1-f196.google.com with SMTP id q7-v6so12376pff.2 for ; Mon, 23 Jul 2018 03:09:27 -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=Vwl51bqmcDS8wp+lU1pZalSc7Z3bokmXBYlYRayzf+k=; b=aafJerS+Wy98Bqo54iiJlRRZ4XSAOzDYKbZmcV904pGjNkYIXGPlN5ERHKshAVYb+P rBSye5CXK+IrnLSQNwvnPqy/SrWY9XFvGR96twNi3hVDMB92dIXj8Lp0UzcPOd9Du1z3 ugMc20CHPyUB9xiuV/yTi2YA0W/pcQgkmzycE= 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=Vwl51bqmcDS8wp+lU1pZalSc7Z3bokmXBYlYRayzf+k=; b=tmXyUpJQyu5Zk/a67DO6XBv0qtMM/33pISo4OoMzfbhwfzgXC1h/62Gqpq2nLqwTNU VJMxdIJyQQKg9zKwKgaAlUY1baQpx0IZzXkRGwZGSau1dVLxd9Pil8fdku1CtjK6+Dzh bk/Pog8u+QIUz8zOw1DUCVyIQy3XevhnA6AKiiCixEkF3VrJr5byc7jcpv5rn0hY/Jsd 87xKiwZmnyn1XMhHgHyIRdJCqc1P0CZwI0RzCTjAUfzhVR6ejfcopr3oD05qvRtHp0Z7 D3K9WyBknrqOY/i5efSDONScL/Cc+aIiknvM5wbBHKdmSPHxRZFmfI67q7lSFOg1hZPV jVXg== X-Gm-Message-State: AOUpUlErjOen+cimKRYXfPkhds7OwEu52DgCSgtiicwlXQQVYPBX0US5 hcALH1hhohc2KFE9rcL/hT8NBA== X-Received: by 2002:a65:6203:: with SMTP id d3-v6mr11649605pgv.420.1532340567315; Mon, 23 Jul 2018 03:09:27 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id e82-v6sm13470698pfk.87.2018.07.23.03.09.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Jul 2018 03:09:26 -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 4/7] mmc: sdhci: add 32-bit block count support for v4 mode Date: Mon, 23 Jul 2018 18:08:25 +0800 Message-Id: <1532340508-8749-5-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532340508-8749-1-git-send-email-zhang.chunyan@linaro.org> References: <1532340508-8749-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 Host Controller Version 4.10 re-defines SDMA System Address register as 32-bit Block Count for v4 mode, and SDMA uses ADMA System Address register (05Fh-058h) instead if v4 mode is enabled. Also when using 32-bit block count, 16-bit block count register need to be set to zero. Signed-off-by: Chunyan Zhang --- drivers/mmc/host/sdhci.c | 15 ++++++++++++++- drivers/mmc/host/sdhci.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index ce71afa..5acea3d 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -956,6 +956,7 @@ static void sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd) static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) { + u32 reg; struct mmc_data *data = cmd->data; host->data_timeout = 0; @@ -1070,7 +1071,19 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) /* Set the DMA boundary value and block size */ sdhci_writew(host, SDHCI_MAKE_BLKSZ(host->sdma_boundary, data->blksz), SDHCI_BLOCK_SIZE); - sdhci_writew(host, data->blocks, SDHCI_BLOCK_COUNT); + + /* + * For Version 4.10 onwards, if v4 mode is enabled, 16-bit Block Count + * register need to be set to zero, 32-bit Block Count register would + * be selected. + */ + if (host->version >= SDHCI_SPEC_410 && host->v4_mode) { + if (sdhci_readw(host, SDHCI_BLOCK_COUNT)) + sdhci_writew(host, 0, SDHCI_BLOCK_COUNT); + sdhci_writew(host, data->blocks, SDHCI_32BIT_BLK_CNT); + } else { + sdhci_writew(host, data->blocks, SDHCI_BLOCK_COUNT); + } } static inline bool sdhci_auto_cmd12(struct sdhci_host *host, diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 23318ff..81aae07 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -28,6 +28,7 @@ #define SDHCI_DMA_ADDRESS 0x00 #define SDHCI_ARGUMENT2 SDHCI_DMA_ADDRESS +#define SDHCI_32BIT_BLK_CNT SDHCI_DMA_ADDRESS #define SDHCI_BLOCK_SIZE 0x04 #define SDHCI_MAKE_BLKSZ(dma, blksz) (((dma & 0x7) << 12) | (blksz & 0xFFF)) -- 2.7.4