From patchwork Mon Apr 21 21:49:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 4026641 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 357049F387 for ; Mon, 21 Apr 2014 21:50:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 66B4420357 for ; Mon, 21 Apr 2014 21:50:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9017A201EF for ; Mon, 21 Apr 2014 21:50:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755056AbaDUVtx (ORCPT ); Mon, 21 Apr 2014 17:49:53 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:40032 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755031AbaDUVtq (ORCPT ); Mon, 21 Apr 2014 17:49:46 -0400 Received: by mail-wi0-f175.google.com with SMTP id cc10so2361003wib.14 for ; Mon, 21 Apr 2014 14:49:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=S6lqrF/97D0uZshDdNpACdLi/ow6SABkfQsUo90iBB8=; b=Z5HCTeNC/i6nHvpl7H+YIzAJ9B6xqOqjRf6EXqSseH09J0AcC/iHf/rMC08nJHIVlQ cVcstMwyjcpEnW9H2yw8GNk5/SWBiToTtKnXeCb1fihdFjbRrG4e9f33ABzml9p+eBD7 ledIghU1sC2VpxUOfRX7G/JGt+LjYOMI5NGAwNoy3KplDK7MzW0qux4v9UT5bF0aIpln DEsL6ToL70tmNczLd4WnYshEl/3Og81HZamOZOM/C2wUPjqcMigeFynq9Gf7NfZFtsBw R4lBi+ZaftOr76bcEYEOaC6Hlas0jk+daPEV4+rq8cpY6L7VELJxl5nohO3oJzcpzmtw +oyA== X-Gm-Message-State: ALoCoQlfpjyNBZK3IYWlaWBrTuZfvgo3Ios6FPgmGxT4pKEowJpGHjYWF54ImD6oLz0W14Q6JRKD X-Received: by 10.180.8.136 with SMTP id r8mr15493924wia.60.1398116985477; Mon, 21 Apr 2014 14:49:45 -0700 (PDT) Received: from srinivas-Inspiron-N5050.dlink.com (host-78-149-8-254.as13285.net. [78.149.8.254]) by mx.google.com with ESMTPSA id nb8sm2037329wic.18.2014.04.21.14.49.44 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Apr 2014 14:49:45 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: linux-mmc@vger.kernel.org Cc: Russell King , Chris Ball , Ulf Hansson , linux-kernel@vger.kernel.org, agross@quicinc.com, linux-arm-msm@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH RFC 12/12] mmc: mmci: Add Qcom specific pio_read function. Date: Mon, 21 Apr 2014 22:49:38 +0100 Message-Id: <1398116978-31772-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1398116624-31052-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1398116624-31052-1-git-send-email-srinivas.kandagatla@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. This patch implements qcom_pio_read function so as existing mmci_pio_read is not suitable for Qcom SOCs. Signed-off-by: Srinivas Kandagatla --- drivers/mmc/host/mmci.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 8fcd8ef..585888e 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1047,6 +1047,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; @@ -1168,8 +1191,12 @@ 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 (host->hw_designer == AMBA_VENDOR_QCOM) + 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);