diff mbox series

[v4,2/7] dm: board: complete the initialization of the muxes in initr_dm()

Message ID 20201016104636.14138-3-p.yadav@ti.com
State Accepted
Commit 90a979d7887ba75b05143f6704c9638e775635e2
Delegated to: Tom Rini
Headers show
Series drivers: Add a framework for MUX drivers | expand

Commit Message

Pratyush Yadav Oct. 16, 2020, 10:46 a.m. UTC
From: Jean-Jacques Hiblot <jjhiblot@ti.com>

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@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
---

Notes:
    No changes in v4.

 common/board_r.c         | 12 ++++++++++++
 drivers/mux/mux-uclass.c | 23 +++++++++++++++++++++++
 include/mux.h            | 12 ++++++++++++
 3 files changed, 47 insertions(+)

Comments

Tom Rini Oct. 28, 2020, 6:50 p.m. UTC | #1
On Fri, Oct 16, 2020 at 04:16:31PM +0530, Pratyush Yadav wrote:

> From: Jean-Jacques Hiblot <jjhiblot@ti.com>
> 
> 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@ti.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Pratyush Yadav <p.yadav@ti.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/common/board_r.c b/common/board_r.c
index 9b2fec701a..b9217b2e27 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -46,6 +46,7 @@ 
 #include <miiphy.h>
 #endif
 #include <mmc.h>
+#include <mux.h>
 #include <nand.h>
 #include <of_live.h>
 #include <onenand_uboot.h>
@@ -341,6 +342,17 @@  static int initr_dm_devices(void)
 			return ret;
 	}
 
+	if (IS_ENABLED(CONFIG_MULTIPLEXER)) {
+		/*
+		 * Initialize the multiplexer controls to their default state.
+		 * This must be done early as other drivers may unknowingly
+		 * rely on it.
+		 */
+		ret = dm_mux_init();
+		if (ret)
+			return ret;
+	}
+
 	return 0;
 }
 
diff --git a/drivers/mux/mux-uclass.c b/drivers/mux/mux-uclass.c
index 3c89e0a389..3dad466101 100644
--- a/drivers/mux/mux-uclass.c
+++ b/drivers/mux/mux-uclass.c
@@ -303,6 +303,29 @@  static int mux_uclass_post_probe(struct udevice *dev)
 	return 0;
 }
 
+int dm_mux_init(void)
+{
+	struct uclass *uc;
+	struct udevice *dev;
+	int ret;
+
+	ret = uclass_get(UCLASS_MUX, &uc);
+	if (ret < 0) {
+		log_debug("unable to get MUX uclass\n");
+		return ret;
+	}
+	uclass_foreach_dev(dev, uc) {
+		if (dev_read_bool(dev, "u-boot,mux-autoprobe")) {
+			ret = device_probe(dev);
+			if (ret)
+				log_debug("unable to probe device %s\n",
+					  dev->name);
+		}
+	}
+
+	return 0;
+}
+
 UCLASS_DRIVER(mux) = {
 	.id		= UCLASS_MUX,
 	.name		= "mux",
diff --git a/include/mux.h b/include/mux.h
index 85eb7d42fc..23844f480a 100644
--- a/include/mux.h
+++ b/include/mux.h
@@ -109,6 +109,13 @@  void mux_control_put(struct mux_control *mux);
  */
 struct mux_control *devm_mux_control_get(struct udevice *dev,
 					 const char *mux_name);
+/**
+ * dm_mux_init() - Initialize the multiplexer controls to their default state.
+ *
+ * Return: 0 if OK, -errno otherwise.
+ */
+int dm_mux_init(void);
+
 #else
 unsigned int mux_control_states(struct mux_control *mux)
 {
@@ -142,6 +149,11 @@  struct mux_control *devm_mux_control_get(struct udevice *dev,
 {
 	return NULL;
 }
+
+int dm_mux_init(void)
+{
+	return -ENOSYS;
+}
 #endif
 
 #endif