[U-Boot] [UBOOT][PATCHv3 4/7] driver: mtd: spi: Add memory mapped read support
Sourav Poddar
sourav.poddar at ti.com
Wed Sep 18 14:21:25 CEST 2013
Qspi controller can have a memory mapped port which can be used for
data read. Added support to enable memory mapped port read.
This patch enables the following:
- It enables exchange of memory map address between mtd and qspi
through the introduction of "memory_map" flag.
- Add support to communicate to the driver that memory mapped
transfer is to be started through introduction of new flags like
"SPI_XFER_MEM_MAP" and "SPI_XFER_MEM_MAP_END".
This will enable the spi controller to do memory mapped configurations
if required.
Signed-off-by: Sourav Poddar <sourav.poddar at ti.com>
---
drivers/mtd/spi/spansion.c | 1 +
drivers/mtd/spi/spi_flash.c | 4 ++++
include/spi.h | 3 +++
3 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/spi/spansion.c b/drivers/mtd/spi/spansion.c
index fa7ac8c..9d801a3 100644
--- a/drivers/mtd/spi/spansion.c
+++ b/drivers/mtd/spi/spansion.c
@@ -136,6 +136,7 @@ struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode)
flash->page_size = 256;
flash->sector_size = 256 * params->pages_per_sector;
flash->size = flash->sector_size * params->nr_sectors;
+ flash->memory_map = spi->memory_map;
return flash;
}
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 993a9d4..5ad2dc1 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -287,7 +287,9 @@ int spi_flash_cmd_read_quad(struct spi_flash *flash, u32 offset,
/* Handle memory-mapped SPI */
if (flash->memory_map) {
+ spi_xfer(flash->spi, 0, NULL, NULL, SPI_XFER_MEM_MAP);
memcpy(data, flash->memory_map + offset, len);
+ spi_xfer(flash->spi, 0, NULL, NULL, SPI_XFER_MEM_MAP_END);
return 0;
}
@@ -338,7 +340,9 @@ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
/* Handle memory-mapped SPI */
if (flash->memory_map) {
+ spi_xfer(flash->spi, 0, NULL, NULL, SPI_XFER_MEM_MAP);
memcpy(data, flash->memory_map + offset, len);
+ spi_xfer(flash->spi, 0, NULL, NULL, SPI_XFER_MEM_MAP_END);
return 0;
}
diff --git a/include/spi.h b/include/spi.h
index 9d4b2dc..559722f 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -28,6 +28,8 @@
#define SPI_XFER_BEGIN 0x01 /* Assert CS before transfer */
#define SPI_XFER_END 0x02 /* Deassert CS after transfer */
#define SPI_QUAD 0x04 /* Use QUAD read command */
+#define SPI_XFER_MEM_MAP 0x08 /* Memory Mapped start */
+#define SPI_XFER_MEM_MAP_END 0x10 /* Memory Mapped End */
/* Header byte that marks the start of the message */
#define SPI_PREAMBLE_END_BYTE 0xec
@@ -47,6 +49,7 @@ struct spi_slave {
unsigned int cs;
unsigned int max_write_size;
bool quad_enable;
+ void *memory_map;
};
/*-----------------------------------------------------------------------
--
1.7.1
More information about the U-Boot
mailing list