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

2019-11-05 Thread Jean-Jacques Hiblot


On 05/11/2019 14:05, Vignesh Raghavendra wrote:

Hi JJ,

On 05/11/19 5:20 PM, Jean-Jacques Hiblot wrote:

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 

---

[...]

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, );
+   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);
+   }

Is "u-boot,mux-autoprobe" a required property? The fact that its in DT
makes me think its optional. If that's the case, above printf() should
be reduced to debug() to avoid confusion


Thanks Vignesh. It was for debug and forgot to remove it.





+   }
+}
+
  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)
  {


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


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

2019-11-05 Thread Vignesh Raghavendra
Hi JJ,

On 05/11/19 5:20 PM, Jean-Jacques Hiblot wrote:
> 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 
> 
> ---
[...]
> 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, );
> + 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);
> + }

Is "u-boot,mux-autoprobe" a required property? The fact that its in DT
makes me think its optional. If that's the case, above printf() should
be reduced to debug() to avoid confusion

> + }
> +}
> +
>  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)
>  {
> 

-- 
Regards
Vignesh
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


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

2019-11-05 Thread Jean-Jacques Hiblot
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 

---

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 
 #endif
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -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, );
+   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

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot