diff mbox

[U-Boot,v5,10/32] mtd: spi-nor: Add spi_flash_probe for mtd-dm-spi-nor

Message ID 1455131307-25406-11-git-send-email-jteki@openedev.com
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Jagan Teki Feb. 10, 2016, 7:08 p.m. UTC
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 <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
 drivers/mtd/spi-nor/spi-nor-probe.c | 15 +++++++++++++++
 include/spi_flash.h                 |  4 ++++
 2 files changed, 19 insertions(+)
diff mbox

Patch

diff --git a/drivers/mtd/spi-nor/spi-nor-probe.c b/drivers/mtd/spi-nor/spi-nor-probe.c
index c808a7d..9bc61ea 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(sjg@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 a458820..1dcce13 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -196,6 +196,10 @@  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);
+
 #else
 struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
 		unsigned int max_hz, unsigned int spi_mode);