From patchwork Thu Jan 23 10:30:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 23576 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 07AD2218BD for ; Thu, 23 Jan 2014 10:31:53 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id oy12sf2926784veb.10 for ; Thu, 23 Jan 2014 02:31:53 -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=E94TNbr3hfNILZCfSLdL0bu88AtVXFJzOQsDo1EuuIE=; b=et9nAcJphSC2lypBT43o8C6vr3NQNLHjETNNojAch/GoZgWLFgy0yfyT2cmIfGGshT EpQfTwOUDjSfe6GIi0ncR76eNN17u2mCJU3W5sEp/KyAfyBZWxYTLH4ZwnKAXJe30qRx yvj/gIX3AvXVpSH21n5eGwmEmXXLjOXlk7kdsGidWYHAQ4sUsw2WMED+81YQl0WEOP3c UrdUQUFW6omvyiM4pD8Kdgtuv6bkFFh5EyfQBQxRN0xbNBoRQS7oygnJLK7SldlBjeGI D/QrIPksaNCFyC/9pJrtRe57G7LHdJjvQ7fVm7vRE6y0IxzukYPNyDZEdSPCdNjpCNWg 3+MQ== X-Gm-Message-State: ALoCoQmdPP4KWsrcwiWtheXJaO66r4Y42P6zrcamWvzmDwo4ddRM8YO6ROso71RjqmCg2NYjMEdM X-Received: by 10.236.82.110 with SMTP id n74mr2139551yhe.57.1390473113176; Thu, 23 Jan 2014 02:31:53 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.11 with SMTP id p11ls294342qga.41.gmail; Thu, 23 Jan 2014 02:31:53 -0800 (PST) X-Received: by 10.220.193.70 with SMTP id dt6mr4104229vcb.17.1390473113099; Thu, 23 Jan 2014 02:31:53 -0800 (PST) Received: from mail-vb0-f42.google.com (mail-vb0-f42.google.com [209.85.212.42]) by mx.google.com with ESMTPS id sm10si3834992vec.81.2014.01.23.02.31.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 02:31:53 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.42 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.42; Received: by mail-vb0-f42.google.com with SMTP id i3so943049vbh.1 for ; Thu, 23 Jan 2014 02:31:53 -0800 (PST) X-Received: by 10.220.110.210 with SMTP id o18mr47294vcp.49.1390473113026; Thu, 23 Jan 2014 02:31:53 -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 u4csp15911vcz; Thu, 23 Jan 2014 02:31:52 -0800 (PST) X-Received: by 10.180.187.229 with SMTP id fv5mr7283065wic.24.1390473112029; Thu, 23 Jan 2014 02:31:52 -0800 (PST) Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) by mx.google.com with ESMTPS id ep1si8898678wib.30.2014.01.23.02.31.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 02:31:52 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.181 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.181; Received: by mail-we0-f181.google.com with SMTP id u56so928763wes.40 for ; Thu, 23 Jan 2014 02:31:51 -0800 (PST) X-Received: by 10.194.241.228 with SMTP id wl4mr6202108wjc.2.1390473111540; Thu, 23 Jan 2014 02:31:51 -0800 (PST) Received: from localhost.localdomain ([80.76.198.141]) by mx.google.com with ESMTPSA id ay6sm21257831wjb.23.2014.01.23.02.31.49 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 02:31:50 -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, computersforpeace@gmail.com, Angus.Clark@st.com, DCG_UPD_stlinux_kernel@list.st.com, olivier.clergeaud@st.com, Lee Jones Subject: [PATCH RESEND v4 05/37] mtd: st_spi_fsm: Supply a method to read from the FSM's FIFO Date: Thu, 23 Jan 2014 10:30:53 +0000 Message-Id: <1390473085-24626-6-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1390473085-24626-1-git-send-email-lee.jones@linaro.org> References: <1390473085-24626-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.42 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 c7daeca..0eba759 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -274,6 +274,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;