From patchwork Fri Nov 29 12:18:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 295283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B35662C00B6 for ; Fri, 29 Nov 2013 23:21:31 +1100 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VmN4F-0001D6-W3; Fri, 29 Nov 2013 12:21:08 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VmN41-0006yT-K0; Fri, 29 Nov 2013 12:20:53 +0000 Received: from mail-yh0-f42.google.com ([209.85.213.42]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VmN3C-0006hs-6q for linux-mtd@lists.infradead.org; Fri, 29 Nov 2013 12:20:12 +0000 Received: by mail-yh0-f42.google.com with SMTP id z6so6683557yhz.1 for ; Fri, 29 Nov 2013 04:19:45 -0800 (PST) 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=Xfxgo1VW9hmTpb73vQP1KBiV+brTfi2dPVkY7SxMqiw=; b=LgdqXa9Ea6CzBWz/lnWBJn8hFfykKWR9D2tNBGjPrZeRoOWfWW3lSf8zv7B8vFS+50 yPYnGTMWL/QDlONE4nql06jvglPfP9dMxVKeshZPowwBnkV8vaZy26BiHS2mhgC8/dGW Bqb87M+gT0M+PwkIeRwdZwiYLxrwp1b8EBhQAazwwbfS5RJJf8AYE7WBrpE0Bnod+Y1N JEXArcfeVqix1CJjDHjQquThVfK4hqYEGbI/mO+VDgXa0HqIS75QIDOa51lD0QaSsngv rSQBzO7BjDcwEqN2BYOM6R2PBzIoxqY5k2/H9btX+hWg1RvCSieWPHV2/JVM0dDBACGa geKQ== X-Gm-Message-State: ALoCoQmRiWWGRQhOVeCjjPgxIqrPmXdnpdq/yuIRWsz5I1ikYRqQytp+bVHAqcrpNPmxXbNj2L7z X-Received: by 10.236.150.202 with SMTP id z50mr2037259yhj.49.1385727585467; Fri, 29 Nov 2013 04:19:45 -0800 (PST) Received: from localhost.localdomain (cpc15-aztw25-2-0-cust493.aztw.cable.virginm.net. [92.233.57.238]) by mx.google.com with ESMTPSA id m29sm101911689yho.14.2013.11.29.04.19.43 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 04:19:45 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dwmw2@infradead.org Subject: [PATCH v3 05/36] mtd: st_spi_fsm: Supply a method to read from the FSM's FIFO Date: Fri, 29 Nov 2013 12:18:54 +0000 Message-Id: <1385727565-25794-6-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1385727565-25794-1-git-send-email-lee.jones@linaro.org> References: <1385727565-25794-1-git-send-email-lee.jones@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131129_072002_836590_F22C22EA X-CRM114-Status: GOOD ( 10.60 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.213.42 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: angus.clark@st.com, linus.walleij@linaro.org, Lee Jones , linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When invoked the driver will attempt to read any available data from the FSM's data register. Any data collected from this FIFO would have originated from the flash chip. Signed-off-by: Lee Jones --- drivers/mtd/devices/st_spi_fsm.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index 8ac8cd9..05fa834 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -81,6 +81,32 @@ static void stfsm_wait_seq(struct stfsm *fsm) dev_err(fsm->dev, "timeout on sequence completion\n"); } +static void stfsm_read_fifo(struct stfsm *fsm, uint32_t *buf, + const uint32_t size) +{ + uint32_t remaining = size >> 2; + uint32_t avail; + uint32_t words; + + dev_dbg(fsm->dev, "Reading %d bytes from FIFO\n", size); + + BUG_ON((((uint32_t)buf) & 0x3) || (size & 0x3)); + + while (remaining) { + for (;;) { + avail = stfsm_fifo_available(fsm); + if (avail) + break; + udelay(1); + } + words = min(avail, remaining); + remaining -= words; + + readsl(fsm->base + SPI_FAST_SEQ_DATA_REG, buf, words); + buf += words; + } +} + static int stfsm_set_mode(struct stfsm *fsm, uint32_t mode) { int ret, timeout = 10;