While probing spi-nor in SPL spi_flash_probe is needed,
so add the flash probe code in spi-nor-probe.c

Cc: Simon Glass <s...@chromium.org>
Cc: Bin Meng <bmeng...@gmail.com>
Cc: Mugunthan V N <mugunthan...@ti.com>
Cc: Michal Simek <michal.si...@xilinx.com>
Cc: Siva Durga Prasad Paladugu <siva...@xilinx.com>
Signed-off-by: Jagan Teki <jt...@openedev.com>
---
 drivers/mtd/spi-nor/spi-nor-probe.c | 15 +++++++++++++++
 include/spi_flash.h                 |  6 ++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor-probe.c 
b/drivers/mtd/spi-nor/spi-nor-probe.c
index 532d8a7..713968b 100644
--- a/drivers/mtd/spi-nor/spi-nor-probe.c
+++ b/drivers/mtd/spi-nor/spi-nor-probe.c
@@ -9,6 +9,21 @@
 #include <spi.h>
 #include <spi_flash.h>
 
+/*
+ * TODO(s...@chromium.org): This is an old-style function. We should remove
+ * it when all SPI flash drivers use dm
+ */
+spi_flash_t *spi_flash_probe(unsigned int bus, unsigned int cs,
+                            unsigned int max_hz, unsigned int spi_mode)
+{
+       struct udevice *dev;
+
+       if (spi_flash_probe_bus_cs(bus, cs, max_hz, spi_mode, &dev))
+               return NULL;
+
+       return dev_get_uclass_priv(dev);
+}
+
 int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
                           unsigned int max_hz, unsigned int spi_mode,
                           struct udevice **devp)
diff --git a/include/spi_flash.h b/include/spi_flash.h
index d39941f..0350767 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -110,10 +110,16 @@ struct spi_flash {
 
 #if defined(CONFIG_MTD_SPI_NOR) && defined(CONFIG_DM_MTD_SPI_NOR)
 
+typedef struct mtd_info spi_flash_t;
+
 int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
                           unsigned int max_hz, unsigned int spi_mode,
                           struct udevice **devp);
 
+/* Compatibility function - this is the old U-Boot API */
+spi_flash_t *spi_flash_probe(unsigned int bus, unsigned int cs,
+                            unsigned int max_hz, unsigned int spi_mode);
+
 #endif
 
 struct dm_spi_flash_ops {
-- 
1.9.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to