From patchwork Thu May 15 09:38:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 30240 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E4E7C20446 for ; Thu, 15 May 2014 09:38:20 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id lj1sf4246988pab.1 for ; Thu, 15 May 2014 02:38:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=s1/XFBJh8JeA19bUmP+lB51xDm2+kHheu1abfWMlgE0=; b=ViXTXpHaKDSZp0GcQlAtNP68cC5wDsZfpTVeUOpdTi93vzUk4hEZJMg44wTlAEzBsw 7DPvtdVXiVazxv0p1PuqUSmUabakKCO8ye5w+/gXWCubiqBRX/Lg1BXRMbv6qBU89SV6 +ALePmGS5Ejp1xaHZ7bPSRWcS1PTt+tokfHUiB4kYHk5wbny2LiZ/OPUIT21owA1rwpU uJkdShu3+xSpgg7gsMAXs5ybPLXTFXP4EsiQk7e1FI+LSwb9Z4CZ+oXkGPSa77IXl69N E6f7gZPl5C3t1qBaW0Hk29sU4V9cJdzkkmWOHPRH1s+1EzSZ3DUfNvZaIwQdaQRikae+ v97Q== X-Gm-Message-State: ALoCoQnNLofb3kNODEnwJzDp+gyLKmw49Bqoqgw93LhTMZy1f+7Vf42MXhUxj9rDl6YqbGXzR5R2 X-Received: by 10.68.202.99 with SMTP id kh3mr4465841pbc.8.1400146700274; Thu, 15 May 2014 02:38:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.229 with SMTP id j92ls122262qgf.14.gmail; Thu, 15 May 2014 02:38:20 -0700 (PDT) X-Received: by 10.221.4.66 with SMTP id ob2mr1224551vcb.28.1400146700132; Thu, 15 May 2014 02:38:20 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id eb17si833614veb.130.2014.05.15.02.38.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 May 2014 02:38:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.179 as permitted sender) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id oy12so926140veb.38 for ; Thu, 15 May 2014 02:38:20 -0700 (PDT) X-Received: by 10.58.122.164 with SMTP id lt4mr7666075veb.2.1400146700054; Thu, 15 May 2014 02:38:20 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp307902vcb; Thu, 15 May 2014 02:38:19 -0700 (PDT) X-Received: by 10.66.65.204 with SMTP id z12mr11153831pas.60.1400146698178; Thu, 15 May 2014 02:38:18 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dg5si2396609pbc.222.2014.05.15.02.38.17; Thu, 15 May 2014 02:38:17 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754993AbaEOJiN (ORCPT + 27 others); Thu, 15 May 2014 05:38:13 -0400 Received: from mail-we0-f171.google.com ([74.125.82.171]:64069 "EHLO mail-we0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754956AbaEOJiJ (ORCPT ); Thu, 15 May 2014 05:38:09 -0400 Received: by mail-we0-f171.google.com with SMTP id w62so788706wes.30 for ; Thu, 15 May 2014 02:38:08 -0700 (PDT) X-Received: by 10.180.98.37 with SMTP id ef5mr7071957wib.24.1400146688112; Thu, 15 May 2014 02:38:08 -0700 (PDT) Received: from srini-ThinkPad-X1-Carbon-2nd.dlink.com (host-78-145-240-98.as13285.net. [78.145.240.98]) by mx.google.com with ESMTPSA id fo10sm8862245wib.12.2014.05.15.02.38.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 May 2014 02:38:07 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Russell King , Ulf Hansson , linux-mmc@vger.kernel.org Cc: Chris Ball , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linus.walleij@linaro.org, Srinivas Kandagatla Subject: [PATCH v2 14/14] mmc: mmci: Add Qcom specific pio_read function. Date: Thu, 15 May 2014 10:38:04 +0100 Message-Id: <1400146684-30384-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1400146447-29803-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1400146447-29803-1-git-send-email-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: srinivas.kandagatla@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Srinivas Kandagatla MCIFIFOCNT register behaviour on Qcom chips is very different than the other pl180 integrations. MCIFIFOCNT register contains the number of words that are still waiting to be transferred through the FIFO. It keeps decrementing once the host CPU reads the MCIFIFO. With the existing logic and the MCIFIFOCNT behaviour, mmci_pio_read will loop forever, as the FIFOCNT register will always return transfer size before reading the FIFO. Also the data sheet states that "This register is only useful for debug purposes and should not be used for normal operation since it does not reflect data which may or may not be in the pipeline". This patch implements qcom_pio_read function so as existing mmci_pio_read is not suitable for Qcom SOCs. qcom_pio_read function is only selected based on qcom_fifo flag in variant data structure. Signed-off-by: Srinivas Kandagatla --- drivers/mmc/host/mmci.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index cf58fec1..94b99d6 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -77,6 +77,7 @@ static unsigned int fmax = 515633; * are not ignored. * @explicit_mclk_control: enable explicit mclk control in driver. * @qcom_cclk_is_mclk: enable iff card clock is multimedia card adapter clock. + * @qcom_fifo: enables qcom specific fifo pio read function. */ struct variant_data { unsigned int clkreg; @@ -101,6 +102,7 @@ struct variant_data { bool mclk_delayed_writes; bool explicit_mclk_control; bool qcom_cclk_is_mclk; + bool qcom_fifo; }; static struct variant_data variant_arm = { @@ -211,6 +213,7 @@ static struct variant_data variant_qcom = { .mclk_delayed_writes = true, .explicit_mclk_control = true, .qcom_cclk_is_mclk = true, + .qcom_fifo = true, }; static inline u32 mmci_readl(struct mmci_host *host, u32 off) @@ -1026,6 +1029,29 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, } } +static int mmci_qcom_pio_read(struct mmci_host *host, char *buffer, + unsigned int remain) +{ + uint32_t *ptr = (uint32_t *) buffer; + int count = 0; + struct variant_data *variant = host->variant; + int fifo_size = variant->fifosize; + + if (remain % 4) + remain = ((remain >> 2) + 1) << 2; + + while (readl(host->base + MMCISTATUS) & MCI_RXDATAAVLBL) { + *ptr = readl(host->base + MMCIFIFO + (count % fifo_size)); + ptr++; + count += sizeof(uint32_t); + + remain -= sizeof(uint32_t); + if (remain == 0) + break; + } + return count; +} + static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int remain) { void __iomem *base = host->base; @@ -1147,8 +1173,13 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id) remain = sg_miter->length; len = 0; - if (status & MCI_RXACTIVE) - len = mmci_pio_read(host, buffer, remain); + if (status & MCI_RXACTIVE) { + if (variant->qcom_fifo) + len = mmci_qcom_pio_read(host, buffer, remain); + else + len = mmci_pio_read(host, buffer, remain); + } + if (status & MCI_TXACTIVE) len = mmci_pio_write(host, buffer, remain, status);