From patchwork Thu Nov 14 14:22:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 21502 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f199.google.com (mail-pd0-f199.google.com [209.85.192.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2B7D123FDD for ; Thu, 14 Nov 2013 14:23:04 +0000 (UTC) Received: by mail-pd0-f199.google.com with SMTP id g10sf3768274pdj.6 for ; Thu, 14 Nov 2013 06:23:03 -0800 (PST) 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=dMUehk/pwTdy1D3wpLNnzygjujdPP61uWN6bJ83zsCE=; b=G1S+PORZDmVxNqcFatBIi2a+BzH2NPgJoOHM7a3HLMz1OS4E15niULKKI/L7IExaJ2 cN4Zos17LE7IfdzbpXbdZ/B0DytAsCycaCDhXbzHJIa3MeqxcTCp29z8Sy0kv1jxVA8H TOSMcvvcPGZo+fMUsaR7M1FF5Rc4myFtXQ28OM01rDx74ZGUNswKGI55gghTQi2kqKjp 60RtlxpgqEtTqhFi8nEKBhf75QNLsqUjydL5mawrc6/1zhO4MIbsrYobdQEudW5/YvKI uJHDIFtBiqfzehH2tKLzOudAvjDcWRAsBB33iuqXO6lgC0GRFbofOLBoxip/IRr8dXAC QcRw== X-Gm-Message-State: ALoCoQlwuqYIY85Lygo+F892IqJUX7A+KfOL9oCbkYOZzjL49Hgzqd1VIMMuFN7nLJcM15OWT76N X-Received: by 10.68.189.41 with SMTP id gf9mr671484pbc.3.1384438983461; Thu, 14 Nov 2013 06:23:03 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.4.228 with SMTP id n4ls1033766qen.71.gmail; Thu, 14 Nov 2013 06:23:03 -0800 (PST) X-Received: by 10.220.86.69 with SMTP id r5mr934583vcl.9.1384438983358; Thu, 14 Nov 2013 06:23:03 -0800 (PST) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by mx.google.com with ESMTPS id gq10si17159893vdc.17.2013.11.14.06.23.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Nov 2013 06:23:03 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.41; Received: by mail-vb0-f41.google.com with SMTP id w8so1752188vbj.14 for ; Thu, 14 Nov 2013 06:23:03 -0800 (PST) X-Received: by 10.52.249.3 with SMTP id yq3mr31633vdc.55.1384438983252; Thu, 14 Nov 2013 06:23:03 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp319808vcz; Thu, 14 Nov 2013 06:23:02 -0800 (PST) X-Received: by 10.60.44.193 with SMTP id g1mr1591843oem.47.1384438982546; Thu, 14 Nov 2013 06:23:02 -0800 (PST) Received: from mail-ob0-f173.google.com (mail-ob0-f173.google.com [209.85.214.173]) by mx.google.com with ESMTPS id bx5si9313992oec.39.2013.11.14.06.23.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Nov 2013 06:23:02 -0800 (PST) Received-SPF: neutral (google.com: 209.85.214.173 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.214.173; Received: by mail-ob0-f173.google.com with SMTP id wm4so2239519obc.32 for ; Thu, 14 Nov 2013 06:23:02 -0800 (PST) X-Received: by 10.182.24.69 with SMTP id s5mr1625940obf.35.1384438982179; Thu, 14 Nov 2013 06:23:02 -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 z5sm5585965obg.13.2013.11.14.06.23.00 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Nov 2013 06:23:01 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: linus.walleij@linaro.org, dwmw2@infradead.org, linux-mtd@lists.infradead.org, angus.clark@st.com, Lee Jones Subject: [PATCH 05/10] mtd: st_spi_fsm: Supply a method to read from the FSM's FIFO Date: Thu, 14 Nov 2013 14:22:31 +0000 Message-Id: <1384438956-31153-6-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1384438956-31153-1-git-send-email-lee.jones@linaro.org> References: <1384438956-31153-1-git-send-email-lee.jones@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 02619ee..a1c2857 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -94,6 +94,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 void stfsm_clear_fifo(struct stfsm *fsm) { uint32_t avail;