summaryrefslogtreecommitdiff
path: root/include/spi.h
diff options
context:
space:
mode:
authorTom Rini <trini@ti.com>2013-03-20 14:55:10 -0400
committerTom Rini <trini@ti.com>2013-03-20 14:55:10 -0400
commit8b906a9f0b3fd0d4421e08c4fa62f61a01289611 (patch)
tree049acc34fee9692c0c394b8d1697d97257c0a074 /include/spi.h
parent3c47f2f4871c345c20b9d986b11fec550ef6cc9f (diff)
parent1e7133e99e27c4f02998e7eb87fa43424d48152b (diff)
downloadu-boot-imx-8b906a9f0b3fd0d4421e08c4fa62f61a01289611.zip
u-boot-imx-8b906a9f0b3fd0d4421e08c4fa62f61a01289611.tar.gz
u-boot-imx-8b906a9f0b3fd0d4421e08c4fa62f61a01289611.tar.bz2
Merge branch 'spi' of git://git.denx.de/u-boot-x86
Diffstat (limited to 'include/spi.h')
-rw-r--r--include/spi.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/include/spi.h b/include/spi.h
index 60e85db..3fe2e1e 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.
*