From patchwork Fri Dec 6 14:24:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Poddar, Sourav" X-Patchwork-Id: 298025 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0D2AF2C0090 for ; Sat, 7 Dec 2013 01:25:48 +1100 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VowLd-00056F-0R; Fri, 06 Dec 2013 14:25:41 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VowLb-0007Lt-6X; Fri, 06 Dec 2013 14:25:39 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VowLV-0007Je-MX for linux-mtd@lists.infradead.org; Fri, 06 Dec 2013 14:25:35 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id rB6EP4kU023399; Fri, 6 Dec 2013 08:25:04 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id rB6EP4EF029334; Fri, 6 Dec 2013 08:25:04 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Fri, 6 Dec 2013 08:25:04 -0600 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 rB6EOqh7000982; Fri, 6 Dec 2013 08:25:01 -0600 From: Sourav Poddar To: , , , Subject: [PATCHv2 01/10] spi/spi.h: Add get_buf/put_buf support in spi master. Date: Fri, 6 Dec 2013 19:54:42 +0530 Message-ID: <1386339891-32717-2-git-send-email-sourav.poddar@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1386339891-32717-1-git-send-email-sourav.poddar@ti.com> References: <1386339891-32717-1-git-send-email-sourav.poddar@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131206_092533_811561_45FDF35A X-CRM114-Status: GOOD ( 13.34 ) X-Spam-Score: -7.1 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [198.47.26.153 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: devicetree@vger.kernel.org, balbi@ti.com, linux-mtd@lists.infradead.org, bcousson@baylibre.com, Sourav Poddar , linux-omap@vger.kernel.org, dwmw2@infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add get_buf, put_buf api support in spi master. This can be used in a scenario where spi controller supports memory mapped operations(typically with flash devices). So, the memcpy needs top be done in slave devices which need the required memory mapped address. These api can be used to get that master address. These can also be used to turm the master controller clock, as usually the clocks get turned in spi core. But, in memory mapped case, we will bypass the spi core and hence needa way out to turn on the controller clock. Add configure from slave api, which can be used to configure the master controller with slave specific information. Add slave info struct, that can be filled with slave properties required by master controller for its register configuration. Signed-off-by: Sourav Poddar --- v1->v2: - Added a slave info structure. - Merge all other header related patches into this. include/linux/spi/spi.h | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 8c62ba7..c91d883 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -31,6 +31,14 @@ */ extern struct bus_type spi_bus_type; +/* For SPI flash */ +struct slave_info { + u8 read_opcode; + u8 program_opcode; + u8 addr_width; + u8 dummy_cycles; +}; + /** * struct spi_device - Master side proxy for an SPI slave device * @dev: Driver model representation of the device. @@ -73,6 +81,7 @@ extern struct bus_type spi_bus_type; struct spi_device { struct device dev; struct spi_master *master; + struct slave_info info; /* flash devices */ u32 max_speed_hz; u8 chip_select; u16 mode; @@ -291,6 +300,14 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) * number. Any individual value may be -ENOENT for CS lines that * are not GPIOs (driven by the SPI controller itself). * + * @get_buf: used for memory mapped cases, when the slave device wants to + * know the address to be used for memcopy. + * @put_buf: Used for memory mapped cases after get_buf, after the memcpy + * has finished. + * @configure_from_slave: Used when SPI controller has registers which need + * to be configured from slave specifics information(typical use case for + * SPI flash device). + * @mmap: Used to show that controller supports memory mapped operation. * Each SPI master controller can communicate with one or more @spi_device * children. These make a small bus, sharing MOSI, MISO and SCK signals * but not chip select signals. Each device may be configured to use a @@ -421,8 +438,13 @@ struct spi_master { int (*transfer_one)(struct spi_master *master, struct spi_device *spi, struct spi_transfer *transfer); + int __iomem *(*get_buf)(struct spi_master *master); + void (*put_buf)(struct spi_master *master); + void (*configure_from_slave)(struct spi_device *spi); + /* gpio chip select */ int *cs_gpios; + bool mmap; }; static inline void *spi_master_get_devdata(struct spi_master *master)