summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-uclass.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-10-20 21:31:47 -0600
committerBin Meng <bmeng.cn@gmail.com>2019-11-03 07:20:26 +0800
commitc53b318e1bad2e0d5c2b846fadfc79ec77bfc5f7 (patch)
tree9fb3cf72abed73813d8a9885b59d4a66b7503b1b /drivers/spi/spi-uclass.c
parente1500a6ce29a8424cc0c0a2fa82e694419941dd1 (diff)
downloadu-boot-c53b318e1bad2e0d5c2b846fadfc79ec77bfc5f7.tar.gz
u-boot-c53b318e1bad2e0d5c2b846fadfc79ec77bfc5f7.tar.xz
u-boot-c53b318e1bad2e0d5c2b846fadfc79ec77bfc5f7.zip
spi: Add support for memory-mapped flash
On x86 platforms the SPI flash can be mapped into memory so that the contents can be read with normal memory accesses. Add a new SPI method to find the location of the SPI flash in memory. This differs from the existing device-tree "memory-map" mechanism in that the location can be discovered at run-time. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/spi/spi-uclass.c')
-rw-r--r--drivers/spi/spi-uclass.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index 947516073e..665611f7e2 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -92,6 +92,20 @@ int dm_spi_xfer(struct udevice *dev, unsigned int bitlen,
return spi_get_ops(bus)->xfer(dev, bitlen, dout, din, flags);
}
+int dm_spi_get_mmap(struct udevice *dev, ulong *map_basep, uint *map_sizep,
+ uint *offsetp)
+{
+ struct udevice *bus = dev->parent;
+ struct dm_spi_ops *ops = spi_get_ops(bus);
+
+ if (bus->uclass->uc_drv->id != UCLASS_SPI)
+ return -EOPNOTSUPP;
+ if (!ops->get_mmap)
+ return -ENOSYS;
+
+ return ops->get_mmap(dev, map_basep, map_sizep, offsetp);
+}
+
int spi_claim_bus(struct spi_slave *slave)
{
return log_ret(dm_spi_claim_bus(slave->dev));