diff options
Diffstat (limited to 'include/spi.h')
| -rw-r--r-- | include/spi.h | 44 | 
1 files changed, 44 insertions, 0 deletions
| diff --git a/include/spi.h b/include/spi.h index 60e85db9a..3fe2e1eab 100644 --- a/include/spi.h +++ b/include/spi.h @@ -49,10 +49,13 @@   *   *   bus:	ID of the bus that the slave is attached to.   *   cs:	ID of the chip select connected to the slave. + *   max_write_size:	If non-zero, the maximum number of bytes which can + *		be written at once, excluding command bytes.   */  struct spi_slave {  	unsigned int	bus;  	unsigned int	cs; +	unsigned int max_write_size;  };  /*----------------------------------------------------------------------- @@ -62,6 +65,47 @@ struct spi_slave {   */  void spi_init(void); +/** + * spi_do_alloc_slave - Allocate a new SPI slave (internal) + * + * Allocate and zero all fields in the spi slave, and set the bus/chip + * select. Use the helper macro spi_alloc_slave() to call this. + * + * @offset: Offset of struct spi_slave within slave structure + * @size: Size of slave structure + * @bus: Bus ID of the slave chip. + * @cs: Chip select ID of the slave chip on the specified bus. + */ +void *spi_do_alloc_slave(int offset, int size, unsigned int bus, +			 unsigned int cs); + +/** + * spi_alloc_slave - Allocate a new SPI slave + * + * Allocate and zero all fields in the spi slave, and set the bus/chip + * select. + * + * @_struct: Name of structure to allocate (e.g. struct tegra_spi). This + *	structure must contain a member 'struct spi_slave *slave'. + * @bus: Bus ID of the slave chip. + * @cs: Chip select ID of the slave chip on the specified bus. + */ +#define spi_alloc_slave(_struct, bus, cs) \ +	spi_do_alloc_slave(offsetof(_struct, slave), \ +			    sizeof(_struct), bus, cs) + +/** + * spi_alloc_slave_base - Allocate a new SPI slave with no private data + * + * Allocate and zero all fields in the spi slave, and set the bus/chip + * select. + * + * @bus: Bus ID of the slave chip. + * @cs: Chip select ID of the slave chip on the specified bus. + */ +#define spi_alloc_slave_base(bus, cs) \ +	spi_do_alloc_slave(0, sizeof(struct spi_slave), bus, cs) +  /*-----------------------------------------------------------------------   * Set up communications parameters for a SPI slave.   * |