From patchwork Wed Oct 9 15:24:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Poddar, Sourav" X-Patchwork-Id: 3009421 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 027739F243 for ; Wed, 9 Oct 2013 15:25:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A51C820268 for ; Wed, 9 Oct 2013 15:25:53 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D112220260 for ; Wed, 9 Oct 2013 15:25:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1VTve1-0002Wh-2w; Wed, 09 Oct 2013 15:25:49 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1VTvdz-0002WR-II for spi-devel-general@lists.sourceforge.net; Wed, 09 Oct 2013 15:25:47 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of ti.com designates 192.94.94.41 as permitted sender) client-ip=192.94.94.41; envelope-from=sourav.poddar@ti.com; helo=bear.ext.ti.com; Received: from bear.ext.ti.com ([192.94.94.41]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1VTvdy-0003k5-K0 for spi-devel-general@lists.sourceforge.net; Wed, 09 Oct 2013 15:25:47 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r99FPDAO026756; Wed, 9 Oct 2013 10:25:13 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id r99FPCjN029312; Wed, 9 Oct 2013 10:25:13 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Wed, 9 Oct 2013 10:25:12 -0500 Received: from a0131647.apr.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id r99FOpRV002968; Wed, 9 Oct 2013 10:25:10 -0500 From: Sourav Poddar To: , , Subject: [RFC/PATCH 3/3] drivers: mtd: devices: Add memory mapped read support. Date: Wed, 9 Oct 2013 20:54:44 +0530 Message-ID: <1381332284-21822-4-git-send-email-sourav.poddar@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1381332284-21822-1-git-send-email-sourav.poddar@ti.com> References: <1381332284-21822-1-git-send-email-sourav.poddar@ti.com> MIME-Version: 1.0 X-Spam-Score: -1.7 (-) X-Headers-End: 1VTvdy-0003k5-K0 Cc: spi-devel-general@lists.sourceforge.net, Sourav Poddar , linux-mtd@lists.infradead.org, balbi@ti.com X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add memory mapped flash read support. In memory mapped, only the len, from and t->rx_buf is required from the flash side, while other configuration will be taken care of from the respective controller side with the help of the transfer flag(memory_map). Signed-off-by: Sourav Poddar --- drivers/mtd/devices/m25p80.c | 13 +++++++++++-- include/linux/spi/spi.h | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index dc9bcbf..9d09bad 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -102,6 +102,7 @@ struct m25p { u8 *command; bool fast_read; bool quad_read; + bool mmap_read; }; static inline struct m25p *mtd_to_m25p(struct mtd_info *mtd) @@ -440,10 +441,15 @@ static int m25p80_quad_read(struct mtd_info *mtd, loff_t from, size_t len, spi_message_init(&m); memset(t, 0, (sizeof(t))); + if (flash->mmap_read) + t[0].memory_map = 1; t[0].tx_buf = flash->command; - t[0].len = m25p_cmdsz(flash) + (flash->quad_read ? 1 : 0); + t[0].len = flash->mmap_read ? from : m25p_cmdsz(flash) + + (flash->quad_read ? 1 : 0); spi_message_add_tail(&t[0], &m); + if (flash->mmap_read) + t[1].memory_map = 1; t[1].rx_buf = buf; t[1].len = len; t[1].rx_nbits = SPI_NBITS_QUAD; @@ -470,7 +476,7 @@ static int m25p80_quad_read(struct mtd_info *mtd, loff_t from, size_t len, spi_sync(flash->spi, &m); - *retlen = m.actual_length - m25p_cmdsz(flash) - + *retlen = flash->mmap_read ? len : m.actual_length - m25p_cmdsz(flash) - (flash->quad_read ? 1 : 0); mutex_unlock(&flash->lock); @@ -1207,6 +1213,9 @@ static int m25p_probe(struct spi_device *spi) if (spi->mode && SPI_RX_QUAD) flash->quad_read = true; + if (spi->mode && SPI_RX_MMAP) + flash->mmap_read = true; + flash->command = kmalloc(MAX_CMD_SIZE + (flash->fast_read ? 1 : (flash->quad_read ? 1 : 0)), GFP_KERNEL); if (!flash->command) { diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 4d634d6..a6ffb52 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -91,6 +91,7 @@ struct spi_device { #define SPI_TX_QUAD 0x200 /* transmit with 4 wires */ #define SPI_RX_DUAL 0x400 /* receive with 2 wires */ #define SPI_RX_QUAD 0x800 /* receive with 4 wires */ +#define SPI_RX_MMAP 0x1000 /* Memory mapped read */ u8 bits_per_word; int irq; void *controller_state; @@ -557,6 +558,7 @@ struct spi_transfer { u16 delay_usecs; u32 speed_hz; + bool memory_map; struct list_head transfer_list; };