[U-Boot] [PATCH v2 2/4] dm: board: complete the initialization of the muxes in initr_dm()

Jean-Jacques Hiblot jjhiblot at ti.com
Tue Nov 5 11:50:17 UTC 2019


This will probe the multiplexer devices that have a "u-boot,mux-autoprobe"
property. As a consequence they will be put in their idle state.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>

---

Changes in v2:
- insert the mux initialization in init_sequence_r[], just before the
console is initialized as its serial port may be muxed
- moved the definition of dm_mux_init() in this commit

 common/board_r.c         | 16 ++++++++++++++++
 drivers/mux/mux-uclass.c | 22 ++++++++++++++++++++++
 include/mux.h            |  2 ++
 3 files changed, 40 insertions(+)

diff --git a/common/board_r.c b/common/board_r.c
index c1ecb06b74..3d410f3504 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -32,6 +32,7 @@
 #include <miiphy.h>
 #endif
 #include <mmc.h>
+#include <mux.h>
 #include <nand.h>
 #include <of_live.h>
 #include <onenand_uboot.h>
@@ -178,6 +179,18 @@ static int initr_serial(void)
 	return 0;
 }
 
+#if CONFIG_MULTIPLEXER
+static int initr_mux(void)
+{
+	/*
+	 * Initialize the multiplexer controls to their default state.
+	 * This must be done early as other drivers may unknowingly rely on it.
+	 */
+	dm_mux_init();
+	return 0;
+}
+#endif
+
 #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS)
 static int initr_trap(void)
 {
@@ -691,6 +704,9 @@ static init_fnc_t init_sequence_r[] = {
 #endif
 #ifdef CONFIG_EFI_LOADER
 	efi_memory_init,
+#endif
+#if CONFIG_MULTIPLEXER
+	initr_mux,
 #endif
 	stdio_init_tables,
 	initr_serial,
diff --git a/drivers/mux/mux-uclass.c b/drivers/mux/mux-uclass.c
index 6aaf4dc964..71392e9e50 100644
--- a/drivers/mux/mux-uclass.c
+++ b/drivers/mux/mux-uclass.c
@@ -262,6 +262,28 @@ int mux_uclass_post_probe(struct udevice *dev)
 	return 0;
 }
 
+void dm_mux_init(void)
+{
+	struct uclass *uc;
+	struct udevice *dev;
+	int ret;
+
+	ret = uclass_get(UCLASS_MUX, &uc);
+	if (ret < 0) {
+		debug("unable to get MUX uclass\n");
+		return;
+	}
+	uclass_foreach_dev(dev, uc) {
+		if (dev_read_bool(dev, "u-boot,mux-autoprobe")) {
+			ret = device_probe(dev);
+			if (ret)
+				debug("unable to probe device %s\n", dev->name);
+		} else {
+			printf("not found for dev %s\n", dev->name);
+		}
+	}
+}
+
 UCLASS_DRIVER(mux) = {
 	.id		= UCLASS_MUX,
 	.name		= "mux",
diff --git a/include/mux.h b/include/mux.h
index 060f71a47c..2467723951 100644
--- a/include/mux.h
+++ b/include/mux.h
@@ -75,6 +75,8 @@ void mux_control_put(struct mux_control *mux);
 
 struct mux_control *devm_mux_control_get(struct udevice *dev,
 					 const char *mux_name);
+void dm_mux_init(void);
+
 #else
 unsigned int mux_control_states(struct mux_control *mux)
 {
-- 
2.17.1



More information about the U-Boot mailing list