[U-Boot] [PATCH v10 23/27] board_r: initialize spi_nor
Jagan Teki
jagan at amarulasolutions.com
Thu Dec 28 06:12:29 UTC 2017
initialize spi-nor framework during boot, so-that detected
buses can appears at boot log.
Signed-off-by: Suneel Garapati <suneelglinux at gmail.com>
Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
---
common/board_r.c | 13 +++++++++++++
drivers/mtd/spi-nor/spi-nor-uclass.c | 17 +++++++++++++++++
include/linux/mtd/spi-nor.h | 1 +
3 files changed, 31 insertions(+)
diff --git a/common/board_r.c b/common/board_r.c
index 09167c1..8030548 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -42,6 +42,7 @@
#include <scsi.h>
#include <serial.h>
#include <spi.h>
+#include <linux/mtd/spi-nor.h>
#include <stdio_dev.h>
#include <timer.h>
#include <trace.h>
@@ -400,6 +401,15 @@ static int initr_spi(void)
}
#endif
+#ifdef CONFIG_MTD_SPI_NOR
+static int initr_spi_nor(void)
+{
+ puts("SPI-NOR: ");
+ spi_nor_init();
+ return 0;
+}
+#endif
+
#ifdef CONFIG_CMD_NAND
/* go init the NAND */
static int initr_nand(void)
@@ -762,6 +772,9 @@ static init_fnc_t init_sequence_r[] = {
#ifdef CONFIG_PPC
initr_spi,
#endif
+#ifdef CONFIG_MTD_SPI_NOR
+ initr_spi_nor,
+#endif
#ifdef CONFIG_CMD_NAND
initr_nand,
#endif
diff --git a/drivers/mtd/spi-nor/spi-nor-uclass.c b/drivers/mtd/spi-nor/spi-nor-uclass.c
index 919682d..8a37be0 100644
--- a/drivers/mtd/spi-nor/spi-nor-uclass.c
+++ b/drivers/mtd/spi-nor/spi-nor-uclass.c
@@ -15,6 +15,23 @@
DECLARE_GLOBAL_DATA_PTR;
+int spi_nor_init(void)
+{
+ struct udevice *bus;
+
+ for (uclass_first_device(UCLASS_SPI_NOR, &bus);
+ bus;
+ uclass_next_device(&bus)) {
+ ;
+ }
+
+#ifndef CONFIG_SPL_BUILD
+ print_spi_nor_devices(',');
+#endif
+
+ return 0;
+}
+
struct spi_nor *spi_nor_get_spi_nor_dev(struct udevice *dev)
{
struct spi_nor_uclass_priv *upriv;
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 9c3da70..2e8e52d 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -218,5 +218,6 @@ int get_spi_nor_num(void);
struct spi_nor *spi_nor_get_spi_nor_dev(struct udevice *dev);
struct mtd_info *spi_nor_get_mtd_info(struct spi_nor *nor);
void print_spi_nor_devices(char separator);
+int spi_nor_init(void);
#endif /* __MTD_SPI_NOR_H */
--
2.7.4
More information about the U-Boot
mailing list