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: 21863 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C540F23FC4 for ; Fri, 29 Nov 2013 12:19:46 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id ld13sf21201753vcb.9 for ; Fri, 29 Nov 2013 04:19:46 -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=Xfxgo1VW9hmTpb73vQP1KBiV+brTfi2dPVkY7SxMqiw=; b=HQTIEdKe+yx3WGwuBQvjbu1epUYc/qzJTXf4MMfq+agnyc4stYuESef0/h2diZ1gyZ Lus9H1fVIi994KsONJrLQ0hDufd3LvRBynvG2z6UyT4WpAbjtcqdghgZWRqBzWRYG2pZ 1zBqXdZOATaTY9rIbIIidZcHAcmneeg6vtUSYOxVOvar70DbgSWcQ22tbv06qG78PNtQ ow2b75lPJbtnq3SsZisge77qH4iC4+qwTOpGK8SM+zL2mSAsTPYeyvug3JGnL0xCRynP 2HJnQ2Jz78zySMhvjAmLSMY4j6s0d3wJ4MTEh1AxlJsR9cflOQumSmF9dF7mX1E6UHWo 5PZw== X-Gm-Message-State: ALoCoQmsw8Pn+h0WZGutOFK7pyZnn8eZo3RFJxn7aeBVFCC51VKeinZanU5usJhMlsU6RV8IvI56 X-Received: by 10.236.209.134 with SMTP id s6mr21441111yho.40.1385727586647; Fri, 29 Nov 2013 04:19:46 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.117.69 with SMTP id kc5ls3850625qeb.42.gmail; Fri, 29 Nov 2013 04:19:46 -0800 (PST) X-Received: by 10.58.189.165 with SMTP id gj5mr25297vec.71.1385727586544; Fri, 29 Nov 2013 04:19:46 -0800 (PST) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id at4si24781836ved.113.2013.11.29.04.19.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 04:19:46 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id lh4so6494968vcb.23 for ; Fri, 29 Nov 2013 04:19:46 -0800 (PST) X-Received: by 10.52.75.99 with SMTP id b3mr30191vdw.80.1385727586421; Fri, 29 Nov 2013 04:19:46 -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 u4csp87385vcz; Fri, 29 Nov 2013 04:19:46 -0800 (PST) X-Received: by 10.49.1.10 with SMTP id 10mr86305029qei.6.1385727585930; Fri, 29 Nov 2013 04:19:45 -0800 (PST) Received: from mail-yh0-f51.google.com (mail-yh0-f51.google.com [209.85.213.51]) by mx.google.com with ESMTPS id k3si21824440qao.122.2013.11.29.04.19.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 04:19:45 -0800 (PST) Received-SPF: neutral (google.com: 209.85.213.51 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.213.51; Received: by mail-yh0-f51.google.com with SMTP id c41so5137328yho.10 for ; Fri, 29 Nov 2013 04:19:45 -0800 (PST) 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 Cc: linus.walleij@linaro.org, linux-mtd@lists.infradead.org, angus.clark@st.com, Lee Jones 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-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.220.178 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 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;