From 8af74edc30bb60a90a5c4d2769ff3129b187796e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 23 Jan 2018 17:14:56 +0100 Subject: drivers: spi: allow limiting reads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some SPI controllers it's not possible to keep the CS active between transfers and they are limited to a known number of bytes. This splits spi_flash reads into different iterations in order to respect the SPI controller limits. Signed-off-by: Álvaro Fernández Rojas Reviewed-by: Simon Glass Reviewed-by: Daniel Schwierzeck Reviewed-by: Jagan Teki --- include/spi.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/spi.h') diff --git a/include/spi.h b/include/spi.h index 08c7480fda9..4787454e59e 100644 --- a/include/spi.h +++ b/include/spi.h @@ -86,6 +86,8 @@ struct dm_spi_slave_platdata { * @cs: ID of the chip select connected to the slave. * @mode: SPI mode to use for this slave (see SPI mode flags) * @wordlen: Size of SPI word in number of bits + * @max_read_size: If non-zero, the maximum number of bytes which can + * be read at once. * @max_write_size: If non-zero, the maximum number of bytes which can * be written at once, excluding command bytes. * @memory_map: Address of read-only SPI flash access. @@ -102,6 +104,7 @@ struct spi_slave { #endif uint mode; unsigned int wordlen; + unsigned int max_read_size; unsigned int max_write_size; void *memory_map; -- cgit v1.2.3 From 6c94bd12c4adca45033ef89daafa66fbfc9acd17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 23 Jan 2018 17:14:57 +0100 Subject: drivers: spi: consider command bytes when sending transfers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Command bytes are part of the written bytes and they should be taken into account when sending a spi transfer. Signed-off-by: Álvaro Fernández Rojas Reviewed-by: Simon Glass Reviewed-by: Daniel Schwierzeck Reviewed-by: Jagan Teki --- include/spi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/spi.h') diff --git a/include/spi.h b/include/spi.h index 4787454e59e..5a7df1c7063 100644 --- a/include/spi.h +++ b/include/spi.h @@ -89,7 +89,7 @@ struct dm_spi_slave_platdata { * @max_read_size: If non-zero, the maximum number of bytes which can * be read at once. * @max_write_size: If non-zero, the maximum number of bytes which can - * be written at once, excluding command bytes. + * be written at once. * @memory_map: Address of read-only SPI flash access. * @flags: Indication of SPI flags. */ -- cgit v1.2.3 From c5b88f29ba46997e1cae39153980cae475b87b82 Mon Sep 17 00:00:00 2001 From: Mario Six Date: Mon, 15 Jan 2018 11:08:36 +0100 Subject: spi: Remove obsolete spi_base_setup_slave_fdt 0efc024 ("spi_flash: Add spi_flash_probe_fdt() to locate SPI by FDT node") added a helper function spi_base_setup_slave_fdt to to set up a SPI slave from a given FDT blob. The only user was the exynos SPI driver. But commit 73186c9 ("dm: exynos: Convert SPI to driver model") removed the use of this function, hence rendering it obsolete. Remove this function, as well as the CONFIG_OF_SPI option, which guarded only this function. Reviewed-by: Simon Glass Reviewed-by: Jagan Teki Signed-off-by: Mario Six --- include/spi.h | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'include/spi.h') diff --git a/include/spi.h b/include/spi.h index 5a7df1c7063..b2a80a56096 100644 --- a/include/spi.h +++ b/include/spi.h @@ -330,20 +330,6 @@ static inline int spi_w8r8(struct spi_slave *slave, unsigned char byte) */ struct spi_slave *spi_setup_slave_fdt(const void *blob, int slave_node, int spi_node); - -/** - * spi_base_setup_slave_fdt() - helper function to set up a SPI slace - * - * This decodes SPI properties from the slave node to determine the - * chip select and SPI parameters. - * - * @blob: Device tree blob - * @busnum: Bus number to use - * @node: Device tree node for the SPI bus - */ -struct spi_slave *spi_base_setup_slave_fdt(const void *blob, int busnum, - int node); - #ifdef CONFIG_DM_SPI /** -- cgit v1.2.3 From 184fa1c8da54d3c5305b3e1975e284e01de68bea Mon Sep 17 00:00:00 2001 From: Mario Six Date: Mon, 15 Jan 2018 11:08:38 +0100 Subject: spi: Remove spi_setup_slave_fdt A previous patch removed the spi_flash_probe_fdt function, which contained the last call of the spi_setup_slave_fdt function, which is now equally obsolete. This patch removes the function. Reviewed-by: Simon Glass Reviewed-by: Jagan Teki Signed-off-by: Mario Six --- include/spi.h | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'include/spi.h') diff --git a/include/spi.h b/include/spi.h index b2a80a56096..f5bac8d002a 100644 --- a/include/spi.h +++ b/include/spi.h @@ -317,19 +317,6 @@ static inline int spi_w8r8(struct spi_slave *slave, unsigned char byte) return ret < 0 ? ret : din[1]; } -/** - * Set up a SPI slave for a particular device tree node - * - * This calls spi_setup_slave() with the correct bus number. Call - * spi_free_slave() to free it later. - * - * @param blob: Device tree blob - * @param slave_node: Slave node to use - * @param spi_node: SPI peripheral node to use - * @return pointer to new spi_slave structure - */ -struct spi_slave *spi_setup_slave_fdt(const void *blob, int slave_node, - int spi_node); #ifdef CONFIG_DM_SPI /** -- cgit v1.2.3