diff mbox

[PATCHv2,01/10] spi/spi.h: Add get_buf/put_buf support in spi master.

Message ID 1386339891-32717-2-git-send-email-sourav.poddar@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Poddar, Sourav Dec. 6, 2013, 2:24 p.m. UTC
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 <sourav.poddar@ti.com>
---
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(-)

Comments

Mark Brown Dec. 19, 2013, 1:31 p.m. UTC | #1
On Fri, Dec 06, 2013 at 07:54:42PM +0530, Sourav Poddar wrote:
> Add get_buf, put_buf api support in spi master.

Please add this stuff along with the code implementing it.

> +	void	(*configure_from_slave)(struct spi_device *spi);
> +

I don't understand this API at all - it takes no parameters and doesn't
have a possibility of returning any error codes?
diff mbox

Patch

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)