diff options
author | Simon Glass <sjg@chromium.org> | 2013-12-03 16:43:24 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2013-12-09 12:22:12 -0700 |
commit | 0efc02499f9131bd7e1689ebb8d626ef12387de4 (patch) | |
tree | d6b4296f983ebe381432d7db3b12e4368ec0efe9 /drivers/mtd | |
parent | 7b3efc66996b6686ad393b706c323990afa31930 (diff) | |
download | u-boot-imx-0efc02499f9131bd7e1689ebb8d626ef12387de4.zip u-boot-imx-0efc02499f9131bd7e1689ebb8d626ef12387de4.tar.gz u-boot-imx-0efc02499f9131bd7e1689ebb8d626ef12387de4.tar.bz2 |
spi_flash: Add spi_flash_probe_fdt() to locate SPI by FDT node
This allows us to put the SPI flash chip inside the SPI interface node,
with U-Boot finding the correct bus and chip select automatically.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/spi/sf_probe.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index 5eb8ffe..ca12715 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -285,16 +285,13 @@ int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash) } #endif /* CONFIG_OF_CONTROL */ -struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, - unsigned int max_hz, unsigned int spi_mode) +static struct spi_flash *spi_flash_probe_slave(struct spi_slave *spi) { - struct spi_slave *spi; struct spi_flash *flash = NULL; u8 idcode[5]; int ret; /* Setup spi_slave */ - spi = spi_setup_slave(bus, cs, max_hz, spi_mode); if (!spi) { printf("SF: Failed to set up slave\n"); return NULL; @@ -358,6 +355,26 @@ err_claim_bus: return NULL; } +struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, + unsigned int max_hz, unsigned int spi_mode) +{ + struct spi_slave *spi; + + spi = spi_setup_slave(bus, cs, max_hz, spi_mode); + return spi_flash_probe_slave(spi); +} + +#ifdef CONFIG_OF_SPI_FLASH +struct spi_flash *spi_flash_probe_fdt(const void *blob, int slave_node, + int spi_node) +{ + struct spi_slave *spi; + + spi = spi_setup_slave_fdt(blob, slave_node, spi_node); + return spi_flash_probe_slave(spi); +} +#endif + void spi_flash_free(struct spi_flash *flash) { spi_free_slave(flash->spi); |