From patchwork Wed Jan 8 13:46:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 22941 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7C4DB202E2 for ; Wed, 8 Jan 2014 13:48:31 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id x8sf2258864vbf.3 for ; Wed, 08 Jan 2014 05:48:30 -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=G0k5kfN+xfHkvHv613duEH+FY/HXDEYDjmbMwelPaSTUfqPbQ2Daz6F2zlhogGYG8M A1URSTGU9u9aTS7ypQnBzhA4G1yr4XBwDacpD1YrcY0CM3zr1ex9OKYbsPIL14S1xd92 R8ii0GblX6U1uY2QrCpJ2GMtAHaJrj1D4DunWem5cIbRMOnxvI3ZiAv+MLFg1n4Y0z6d T9nKMDaiFVDUwNND/VWiY4IBPJZ+Bdram9ZoixAvKcUPyrj7zU+t78ORd6qGAok2uFRQ gIcm/SnrhqOcPEASzrYmQyvHlokvq2/aBtEvIb6Qbqv912xJAvF2EgCoKfqpSXhLBV7y cVGQ== X-Gm-Message-State: ALoCoQnJ9ckJB8GhkAHWbcPOI5qFle/3PIgJV7ELyrX3lQo2RO0mTNFYuENpg2Scon1c4rh15Sc+ X-Received: by 10.236.128.243 with SMTP id f79mr963115yhi.27.1389188910633; Wed, 08 Jan 2014 05:48:30 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.106 with SMTP id 10ls564102qed.55.gmail; Wed, 08 Jan 2014 05:48:30 -0800 (PST) X-Received: by 10.58.90.230 with SMTP id bz6mr9732916veb.21.1389188910487; Wed, 08 Jan 2014 05:48:30 -0800 (PST) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id sg4si596108vdc.105.2014.01.08.05.48.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:30 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id oy12so1274447veb.1 for ; Wed, 08 Jan 2014 05:48:30 -0800 (PST) X-Received: by 10.58.134.40 with SMTP id ph8mr2518268veb.61.1389188910381; Wed, 08 Jan 2014 05:48:30 -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.59.13.131 with SMTP id ey3csp226590ved; Wed, 8 Jan 2014 05:48:29 -0800 (PST) X-Received: by 10.194.93.3 with SMTP id cq3mr82822267wjb.26.1389188909329; Wed, 08 Jan 2014 05:48:29 -0800 (PST) Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by mx.google.com with ESMTPS id q19si30451987wjw.168.2014.01.08.05.48.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:29 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.179 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.179; Received: by mail-wi0-f179.google.com with SMTP id z2so2088209wiv.0 for ; Wed, 08 Jan 2014 05:48:28 -0800 (PST) X-Received: by 10.194.85.75 with SMTP id f11mr13045652wjz.47.1389188908753; Wed, 08 Jan 2014 05:48:28 -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 j9sm48125217wjx.18.2014.01.08.05.48.27 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:27 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: computersforpeace@gmail.com, angus.clark@st.com, Lee Jones Subject: [PATCH v4 05/37] mtd: st_spi_fsm: Supply a method to read from the FSM's FIFO Date: Wed, 8 Jan 2014 13:46:48 +0000 Message-Id: <1389188840-14306-6-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1389188840-14306-1-git-send-email-lee.jones@linaro.org> References: <1389188840-14306-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.128.170 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;