From patchwork Fri May 30 16:20:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 4272231 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 E6EEC9F1D6 for ; Fri, 30 May 2014 16:21:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0457D20170 for ; Fri, 30 May 2014 16:21:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EC642201C0 for ; Fri, 30 May 2014 16:21:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933718AbaE3QU7 (ORCPT ); Fri, 30 May 2014 12:20:59 -0400 Received: from mail-we0-f179.google.com ([74.125.82.179]:46381 "EHLO mail-we0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933646AbaE3QU6 (ORCPT ); Fri, 30 May 2014 12:20:58 -0400 Received: by mail-we0-f179.google.com with SMTP id q59so2208462wes.24 for ; Fri, 30 May 2014 09:20:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=QeWQZrPqQcXFHd/bcHMLF7fLPvUVw63TRmEMKKfCmIQ=; b=QSU6ElGWkdJN9KsTFVWoepgBG2FRyzeP3IcKfN4FZ8atN4k80c6mo3zR+UukaA21y4 L2F7gxaT9n2kvhrUcTBWx6NPxuNg0LOnjTofo1G6yb7p72j/oRU1cC53MgssauRx7ToE PqErBw01DzqB+m0utb4J0kBSWibFUQZ2oEEkSAGtV1do5v/KJXnuIjK1PcTzD/Pp3yKi cuvmOYWyeKglvbbVOSVtaIQE2KkV3uZP9QjRhvbD3Nw5RCgrgw4zAnInP7wzllwSNFXf mzqHkMuw21uPmKXTUTUrhTsYLvpQy8ujBJg/QUHxvY3iPPTGJ87dWiNfslI6quQ2sLJo d0qg== X-Gm-Message-State: ALoCoQkjCiK5oJSV4AsQqRmRq2FEqjXxVUrQqWbvgtgaer9bmCUIX2Yl9IaR3EhDD3R8jIwjvrfx X-Received: by 10.194.82.170 with SMTP id j10mr23567926wjy.63.1401466854474; Fri, 30 May 2014 09:20:54 -0700 (PDT) Received: from [192.168.1.101] (host-78-149-4-211.as13285.net. [78.149.4.211]) by mx.google.com with ESMTPSA id ds9sm4341425wib.20.2014.05.30.09.20.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 09:20:53 -0700 (PDT) Message-ID: <5388AFE3.4@linaro.org> Date: Fri, 30 May 2014 17:20:51 +0100 From: Srinivas Kandagatla User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Ulf Hansson CC: Russell King , linux-mmc , Chris Ball , "linux-kernel@vger.kernel.org" , "linux-arm-msm@vger.kernel.org" , Linus Walleij Subject: Re: [PATCH v4 13/13] mmc: mmci: Add Qcom specific pio_read function. References: <1401284608-16428-1-git-send-email-srinivas.kandagatla@linaro.org> <1401284886-16978-1-git-send-email-srinivas.kandagatla@linaro.org> <53886F25.8060509@linaro.org> In-Reply-To: <53886F25.8060509@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 Hi Ulf, Managed to reuse the existing mmci_pio_read function with some minor modifications, Issue was with reading full fifo sizes which was creating the issue. On 30/05/14 12:44, Srinivas Kandagatla wrote: > That sounds sensible.. I will try it. >> >>> + *ptr = readl(host->base + MMCIFIFO + (count % >>> fsize)); >> >> This looks strange. :-) Depending on the count you will read an offset >> into the FIFO? Seems like a very awkward implementation of a FIFO in >> the HW. :-) >> > I got into weird issues when I tried using the mmci_pio_read, the fifo > implementation seems to be different. I dont have full details on the > fifo behaviour. > > Most of this logic is inherited from 3.4 qcom andriod kernel. > >> BTW, what does "MCI_RXDATAAVLBL" actually mean for the Qcom variant? > > It means, At least 1 word in the RX FIFO. SW can read 1 word only from > the FIFO. > >> How much data could you expect in the FIFO when this status is >> triggered? > >> Are there no option of reading a number of words, depending on what >> type FIFO IRQ that was raised? > There are RXFIFO_HALF_FULL and RXFIFO_FULL bits in status register, but > I never tried to use them. Might be worth a try before I send next > version patches. > the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -73,6 +73,7 @@ static unsigned int fmax = 515633; * @busy_detect: true if busy detection on dat0 is supported * @pwrreg_nopower: bits in MMCIPOWER don't controls ext. power supply * @explicit_mclk_control: enable explicit mclk control in driver. + * @qcom_fifo: enables qcom specific fifo pio read logic. */ struct variant_data { unsigned int clkreg; @@ -95,6 +96,7 @@ struct variant_data { bool busy_detect; bool pwrreg_nopower; bool explicit_mclk_control; + bool qcom_fifo; }; static struct variant_data variant_arm = { @@ -990,15 +992,33 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, } } +static int mmci_get_rx_fifocnt(struct mmci_host *host, u32 status, int remain) +{ + return remain - (readl(host->base + MMCIFIFOCNT) << 2); +} + +static int mmci_qcom_get_rx_fifocnt(struct mmci_host *host, u32 status, int r) +{ + /* + * on qcom SDCC4 only 8 words are used in each burst so only 8 addresses + * from the fifo range should be used + */ + if (status & MCI_RXFIFOHALFFULL) + return host->variant->fifohalfsize; + else + return 4; +} + static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int remain) { void __iomem *base = host->base; char *ptr = buffer; - u32 status; + int hf = host->variant->fifohalfsize; int host_remain = host->size; + u32 status = readl(host->base + MMCISTATUS); do { - int count = host_remain - (readl(base + MMCIFIFOCNT) << 2); + int count = host->get_rx_fifocnt(host, status, host_remain); if (count > remain) count = remain; @@ -1488,6 +1508,11 @@ static int mmci_probe(struct amba_device *dev, if (ret) goto host_free; + if (variant->qcom_fifo) + host->get_rx_fifocnt = mmci_qcom_get_rx_fifocnt; + else + host->get_rx_fifocnt = mmci_get_rx_fifocnt; + host->plat = plat; host->variant = variant; host->mclk = clk_get_rate(host->clk); diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h index b5f0810..5f76670 100644 --- a/drivers/mmc/host/mmci.h +++ b/drivers/mmc/host/mmci.h @@ -229,6 +229,7 @@ struct mmci_host { /* pio stuff */ struct sg_mapping_iter sg_miter; unsigned int size; + int (*get_rx_fifocnt)(struct mmci_host *h, u32 status, int remain); #ifdef CONFIG_DMA_ENGINE -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in