From patchwork Thu Mar 20 09:20:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 26638 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3CFA6202E0 for ; Thu, 20 Mar 2014 09:21:29 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id j7sf1288541qaq.10 for ; Thu, 20 Mar 2014 02:21:28 -0700 (PDT) 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=/+InIGditRV7rAy+1g+46xNp7IVkEKi1ng1jD19Q/1A=; b=Kpz4wuU6owcP8L6yHugf1m8Ak02jZu8yIGOo52O8xBA6hjFa14IiCUSYrc4882JtxS eaLu+cDOcewgnnOt1GO5ehV+rO/l/gkeYXPd5/xAV4F9fVMMvH/HWI/tlcHpbBpSO9GN cVvsi4f66hHtlWcvMA9ZkuvTb94vDEa/DJ7KOj6f95B8rexLBHdF7J0NruaEj9y1I6ix P7JT+IABjyICnFdSinsDpd1jVH4VH0BdBZnODieugP/H+UgqkQWoGMthEqtObDr96fxn 3UdO7TONOs0b36DSDWKaWjGRU2beoPhR0ovkGU9+c9wmo+65QmLNpKbAEVX/9ujOrrkH bZkw== X-Gm-Message-State: ALoCoQkp7jRgbBmO/EnZkSccvfh+iVe9OG2LkdfZmwMpp31c+Ha9GOcgnTdFd9rdu640mnOGhcKP X-Received: by 10.58.57.4 with SMTP id e4mr6771445veq.24.1395307288709; Thu, 20 Mar 2014 02:21:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.246 with SMTP id j109ls157361qgf.13.gmail; Thu, 20 Mar 2014 02:21:28 -0700 (PDT) X-Received: by 10.52.242.167 with SMTP id wr7mr3801168vdc.32.1395307288594; Thu, 20 Mar 2014 02:21:28 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id or7si293568vcb.61.2014.03.20.02.21.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 02:21:28 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.180 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.180; Received: by mail-vc0-f180.google.com with SMTP id lf12so591806vcb.39 for ; Thu, 20 Mar 2014 02:21:28 -0700 (PDT) X-Received: by 10.220.95.139 with SMTP id d11mr20398390vcn.21.1395307288521; Thu, 20 Mar 2014 02:21:28 -0700 (PDT) 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.78.9 with SMTP id i9csp372497vck; Thu, 20 Mar 2014 02:21:28 -0700 (PDT) X-Received: by 10.180.19.35 with SMTP id b3mr1827223wie.20.1395307287531; Thu, 20 Mar 2014 02:21:27 -0700 (PDT) Received: from mail-we0-f170.google.com (mail-we0-f170.google.com [74.125.82.170]) by mx.google.com with ESMTPS id cv5si847276wjc.74.2014.03.20.02.21.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 02:21:27 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.170 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.170; Received: by mail-we0-f170.google.com with SMTP id w61so368304wes.15 for ; Thu, 20 Mar 2014 02:21:27 -0700 (PDT) X-Received: by 10.180.73.173 with SMTP id m13mr1767448wiv.52.1395307287005; Thu, 20 Mar 2014 02:21:27 -0700 (PDT) Received: from lee--X1.home (host109-148-116-196.range109-148.btcentralplus.com. [109.148.116.196]) by mx.google.com with ESMTPSA id di9sm4735120wid.6.2014.03.20.02.21.25 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 02:21:26 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, computersforpeace@gmail.com Cc: linux-mtd@lists.infradead.org, dwmw2@infradead.org, Angus.Clark@st.com, Lee Jones Subject: [PATCH v6 05/36] mtd: st_spi_fsm: Supply a method to read from the FSM's FIFO Date: Thu, 20 Mar 2014 09:20:37 +0000 Message-Id: <1395307268-12721-6-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395307268-12721-1-git-send-email-lee.jones@linaro.org> References: <1395307268-12721-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.180 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. Acked-by Angus Clark 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 5e22c86..73e0f27 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -281,6 +281,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;