Skip to contentSkip to conversation

Qualcomm: cleanup OF_LIVE fixup and fix RB1/2

PATCH In review Caleb Connolly 5 participants 21 messages Apr 11, 2025 – May 6, 2025

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

v2 cover Qualcomm: cleanup OF_LIVE fixup and fix RB1/2

Introduce a new event to signal that the live tree has been built, allowing boards to perform fixups on the tree before devices are bound. Crucially this allows for devices to be enabled or disabled, but also allows for properties that are parsed during the bind stage to be modified (such as dr_mode for dwc3).

With this in place, mach-snapdragon is switched over to use the event and some hacky U-Boot specific DT overrides (which had to be undone prior to booting an image) are removed in favour of fixing up the livetree (which is not passed on to further boot stages).

Finally, some minor fixes are made for the QCM2290 RB1 board, the sdcard is enabled and it now uses USB host mode in U-Boot like it's bigger sibling the RB2.

---
Changes in v2:
- Rename EVT_OF_LIVE_INIT to EVT_OF_LIVE_BUILT
- Pass the root node through as event data in EVT_OF_LIVE_BUILT
- Handle errors from event_notify()
- Additional minor fixes to mach-snapdragon/of_fixup.c
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Caleb Connolly (8):
event: signal when livetree has been built
mach-snapdragon: use EVT_OF_LIVE_INIT to apply DT fixups
mach-snapdragon: of_fixup: skip disabled USB nodes
mach-snapdragon: of_fixup: remove confusing log message
mach-snapdragon: of_fixup: update comment
mach-snapdragon: of_fixup: set dr_mode for RB1/2 boards clk/qcom: qcm2290: show clock name in set_rate()
pinctrl: qcom: qcm2290: fix off by 1 in pin_count

 arch/arm/dts/qrb4210-rb2-u-boot.dtsi   |  6 ---
 arch/arm/mach-snapdragon/board.c       |  1 -
 arch/arm/mach-snapdragon/of_fixup.c    | 71 +++++++++++++++++++---------------
 arch/arm/mach-snapdragon/qcom-priv.h   | 14 -------
 common/event.c                         |  3 ++
 drivers/clk/qcom/clock-qcm2290.c       |  2 +-
 drivers/pinctrl/qcom/pinctrl-qcm2290.c |  2 +-
 include/event.h                        | 18 +++++++++
 lib/of_live.c                          | 11 ++++++
 9 files changed, 74 insertions(+), 54 deletions(-)

---
base-commit: 45acd9d2d4ec84775d09c73aab75a4fd989beb41
change-id: 20250409-livetree-fixup-0d7451cc3af3

Caleb Connolly <[email protected]>

#1 lore raw

PATCH v2 1/8 event: signal when livetree has been built

OF_LIVE offers a variety of benefits, one of them being that the live tree can be modified without caring about the underlying FDT. This is particularly valuable for working around U-Boot limitations like lacking USB superspeed support on Qualcomm platforms, no runtime OTG, or peripherals like the sdcard being broken (and displaying potentially worrying error messages).

Add an event to signal when the live tree has been built so that we can apply fixups to it directly before devices are bound.

---
 common/event.c  |  3 +++
 include/event.h | 18 ++++++++++++++++++
 lib/of_live.c   | 11 +++++++++++
 3 files changed, 32 insertions(+)
common/event.c +3 -0
index dda569d447851f559a83f98fb7b1f3543156eab5..8d7513eb10b61919e1e784481dfdcc076be14986 100644
@@ -47,8 +47,11 @@ const char *const type_name[] = {
 	"ft_fixup",
 
 	/* main loop events */
 	"main_loop",
+
+	/* livetree has been built */
+	"of_live_init",
 };
 
 _Static_assert(ARRAY_SIZE(type_name) == EVT_COUNT, "event type_name size");
 #endif
include/event.h +18 -0
index 75141a192a48b0931667632f41be8ff4d6139f7c..1d267f1d10547642d381fa287ab4981a2bf03543 100644
@@ -152,8 +152,17 @@ enum event_t {
 	 * A non-zero return value causes the boot to fail.
 	 */
 	EVT_MAIN_LOOP,
 
+	/**
+	 * @EVT_OF_LIVE_BUILT:
+	 * This event is triggered immediately after the live device tree has been
+	 * built. This allows for machine specific fixups to be done to the live tree
+	 * (like disabling known-unsupported devices) before it is used. This
+	 * event is only available if OF_LIVE is enabled and is only used after relocation.
+	 */
+	EVT_OF_LIVE_BUILT,
+
 	/**
 	 * @EVT_COUNT:
 	 * This constants holds the maximum event number + 1 and is used when
 	 * looping over all event classes.
@@ -202,8 +211,17 @@ union event_data {
 	struct event_ft_fixup {
 		oftree tree;
 		struct bootm_headers *images;
 	} ft_fixup;
+
+	/**
+	 * struct event_of_live_built - livetree has been built
+	 *
+	 * @root: The root node of the live device tree
+	 */
+	struct event_of_live_built {
+		struct device_node *root;
+	} of_live_built;
 };
 
 /**
  * struct event - an event that can be sent and received
lib/of_live.c +11 -0
index 90b9459ede313e492e28c8556c730f3bd8aaa9df..c1620616513c2e32448b4a6d156a9162d97c76b7 100644
@@ -10,8 +10,9 @@
 
 #define LOG_CATEGORY	LOGC_DT
 
 #include <abuf.h>
+#include <event.h>
 #include <log.h>
 #include <linux/libfdt.h>
 #include <of_live.h>
 #include <malloc.h>
@@ -320,8 +321,9 @@ int unflatten_device_tree(const void *blob, struct device_node **mynodes)
 
 int of_live_build(const void *fdt_blob, struct device_node **rootp)
 {
 	int ret;
+	union event_data evt;
 
 	debug("%s: start\n", __func__);
 	ret = unflatten_device_tree(fdt_blob, rootp);
 	if (ret) {
@@ -334,8 +336,17 @@ int of_live_build(const void *fdt_blob, struct device_node **rootp)
 		return ret;
 	}
 	debug("%s: stop\n", __func__);
 
+	if (CONFIG_IS_ENABLED(EVENT)) {
+		evt.of_live_built.root = *rootp;
+		ret = event_notify(EVT_OF_LIVE_BUILT, &evt, sizeof(evt));
+		if (ret) {
+			log_debug("Failed to notify livetree build event: err=%d\n", ret);
+			return ret;
+		}
+	}
+
 	return ret;
 }
 
 void of_live_free(struct device_node *root)
Signature · 1 line
2.49.0
#2 lore raw

Re: [PATCH v2 1/8] event: signal when livetree has been built

Quoted 22 lines · Caleb Connolly

OF_LIVE offers a variety of benefits, one of them being that the live tree can be modified without caring about the underlying FDT. This is particularly valuable for working around U-Boot limitations like lacking USB superspeed support on Qualcomm platforms, no runtime OTG, or peripherals like the sdcard being broken (and displaying potentially worrying error messages).

Add an event to signal when the live tree has been built so that we can apply fixups to it directly before devices are bound.

---
  common/event.c  |  3 +++
  include/event.h | 18 ++++++++++++++++++
  lib/of_live.c   | 11 +++++++++++
  3 files changed, 32 insertions(+)
common/event.c +0 -0
index dda569d447851f559a83f98fb7b1f3543156eab5..8d7513eb10b61919e1e784481dfdcc076be14986 100644

common/event.c const char *const type_name[] = { · line 53

Quoted 7 lines
common/event.c +3 -0
@@ -47,8 +47,11 @@ const char *const type_name[] = {
  	"ft_fixup",
 
  	/* main loop events */
  	"main_loop",
+
+	/* livetree has been built */
+	"of_live_init",

"of_live_built" ?

Quoted 87 lines
common/event.c +0 -0
  };
 
  _Static_assert(ARRAY_SIZE(type_name) == EVT_COUNT, "event type_name size");
  #endif
include/event.h +18 -0
index 75141a192a48b0931667632f41be8ff4d6139f7c..1d267f1d10547642d381fa287ab4981a2bf03543 100644
@@ -152,8 +152,17 @@ enum event_t {
  	 * A non-zero return value causes the boot to fail.
  	 */
  	EVT_MAIN_LOOP,
 
+	/**
+	 * @EVT_OF_LIVE_BUILT:
+	 * This event is triggered immediately after the live device tree has been
+	 * built. This allows for machine specific fixups to be done to the live tree
+	 * (like disabling known-unsupported devices) before it is used. This
+	 * event is only available if OF_LIVE is enabled and is only used after relocation.
+	 */
+	EVT_OF_LIVE_BUILT,
+
  	/**
  	 * @EVT_COUNT:
  	 * This constants holds the maximum event number + 1 and is used when
  	 * looping over all event classes.
@@ -202,8 +211,17 @@ union event_data {
  	struct event_ft_fixup {
  		oftree tree;
  		struct bootm_headers *images;
  	} ft_fixup;
+
+	/**
+	 * struct event_of_live_built - livetree has been built
+	 *
+	 * @root: The root node of the live device tree
+	 */
+	struct event_of_live_built {
+		struct device_node *root;
+	} of_live_built;
  };
 
  /**
   * struct event - an event that can be sent and received
lib/of_live.c +11 -0
index 90b9459ede313e492e28c8556c730f3bd8aaa9df..c1620616513c2e32448b4a6d156a9162d97c76b7 100644
@@ -10,8 +10,9 @@
 
  #define LOG_CATEGORY	LOGC_DT
 
  #include <abuf.h>
+#include <event.h>
  #include <log.h>
  #include <linux/libfdt.h>
  #include <of_live.h>
  #include <malloc.h>
@@ -320,8 +321,9 @@ int unflatten_device_tree(const void *blob, struct device_node **mynodes)
 
  int of_live_build(const void *fdt_blob, struct device_node **rootp)
  {
  	int ret;
+	union event_data evt;
 
  	debug("%s: start\n", __func__);
  	ret = unflatten_device_tree(fdt_blob, rootp);
  	if (ret) {
@@ -334,8 +336,17 @@ int of_live_build(const void *fdt_blob, struct device_node **rootp)
  		return ret;
  	}
  	debug("%s: stop\n", __func__);
 
+	if (CONFIG_IS_ENABLED(EVENT)) {
+		evt.of_live_built.root = *rootp;
+		ret = event_notify(EVT_OF_LIVE_BUILT, &evt, sizeof(evt));
+		if (ret) {
+			log_debug("Failed to notify livetree build event: err=%d\n", ret);
+			return ret;
+		}
+	}
+
  	return ret;
  }
 
  void of_live_free(struct device_node *root)
#3 lore raw

Re: [PATCH v2 1/8] event: signal when livetree has been built

In reply to Caleb Connolly

Hi Caleb,

Quoted 39 lines · Caleb Connolly

OF_LIVE offers a variety of benefits, one of them being that the live tree can be modified without caring about the underlying FDT. This is particularly valuable for working around U-Boot limitations like lacking USB superspeed support on Qualcomm platforms, no runtime OTG, or peripherals like the sdcard being broken (and displaying potentially worrying error messages).

Add an event to signal when the live tree has been built so that we can apply fixups to it directly before devices are bound.

---
 common/event.c  |  3 +++
 include/event.h | 18 ++++++++++++++++++
 lib/of_live.c   | 11 +++++++++++
 3 files changed, 32 insertions(+)
common/event.c +3 -0
index dda569d447851f559a83f98fb7b1f3543156eab5..8d7513eb10b61919e1e784481dfdcc076be14986 100644
@@ -47,8 +47,11 @@ const char *const type_name[] = {
        "ft_fixup",
 
        /* main loop events */
        "main_loop",
+
+       /* livetree has been built */
+       "of_live_init",
 };
 
 _Static_assert(ARRAY_SIZE(type_name) == EVT_COUNT, "event type_name size");
 #endif
include/event.h +0 -0
index 75141a192a48b0931667632f41be8ff4d6139f7c..1d267f1d10547642d381fa287ab4981a2bf03543 100644

include/event.h enum event_t { · line 161

Quoted 10 lines
include/event.h +6 -0
@@ -152,8 +152,17 @@ enum event_t {
         * A non-zero return value causes the boot to fail.
         */
        EVT_MAIN_LOOP,
 
+       /**
+        * @EVT_OF_LIVE_BUILT:
+        * This event is triggered immediately after the live device tree has been
+        * built. This allows for machine specific fixups to be done to the live tree
+        * (like disabling known-unsupported devices) before it is used. This
+        * event is only available if OF_LIVE is enabled and is only used after relocation.

Add a bit more detail, e.g.: before it is used by U-Boot post-relocation. This means it is possible to affect the devices bound by driver model.

You should also note that the flattree is inactive when livetree is used and any changes may eventually be passed onto the OS, if it doesn't have its own devicetree. This is the point we were discussing on the other thread.

Quoted 53 lines
include/event.h +12 -0
+        */
+       EVT_OF_LIVE_BUILT,
+
        /**
         * @EVT_COUNT:
         * This constants holds the maximum event number + 1 and is used when
         * looping over all event classes.
@@ -202,8 +211,17 @@ union event_data {
        struct event_ft_fixup {
                oftree tree;
                struct bootm_headers *images;
        } ft_fixup;
+
+       /**
+        * struct event_of_live_built - livetree has been built
+        *
+        * @root: The root node of the live device tree
+        */
+       struct event_of_live_built {
+               struct device_node *root;
+       } of_live_built;
 };
 
 /**
  * struct event - an event that can be sent and received
lib/of_live.c +2 -0
index 90b9459ede313e492e28c8556c730f3bd8aaa9df..c1620616513c2e32448b4a6d156a9162d97c76b7 100644
@@ -10,8 +10,9 @@
 
 #define LOG_CATEGORY   LOGC_DT
 
 #include <abuf.h>
+#include <event.h>
 #include <log.h>
 #include <linux/libfdt.h>
 #include <of_live.h>
 #include <malloc.h>
@@ -320,8 +321,9 @@ int unflatten_device_tree(const void *blob, struct device_node **mynodes)
 
 int of_live_build(const void *fdt_blob, struct device_node **rootp)
 {
        int ret;
+       union event_data evt;
 
        debug("%s: start\n", __func__);
        ret = unflatten_device_tree(fdt_blob, rootp);
        if (ret) {
@@ -334,8 +336,17 @@ int of_live_build(const void *fdt_blob, struct device_node **rootp)
                return ret;
        }
        debug("%s: stop\n", __func__);

lib/of_live.c int of_live_build(const void *fdt_blob, struct device_node **rootp) · line 348

Quoted 10 lines
lib/of_live.c +9 -0
 
+       if (CONFIG_IS_ENABLED(EVENT)) {
+               evt.of_live_built.root = *rootp;
+               ret = event_notify(EVT_OF_LIVE_BUILT, &evt, sizeof(evt));
+               if (ret) {
+                       log_debug("Failed to notify livetree build event: err=%d\n", ret);
+                       return ret;
+               }
+       }
+

This should move to the caller of this function. We should also have a sandbox test for this feature, e.g. catch the event and add a node/prop and check in a test in test-fdt.c (or similar) that it is present.

I'm not sure if you need to update test_event_dump.py but since CI presumably passes, I guess not.

Quoted 8 lines
lib/of_live.c +0 -1
        return ret;
 }
 
 void of_live_free(struct device_node *root)
 
--

2.49.0

Regards,
Simon

#4 lore raw

Re: [PATCH v2 1/8] event: signal when livetree has been built

Hi Simon,

Quoted 46 lines · Simon Glass

Hi Caleb,

Quoted 43 lines · Caleb Connolly

OF_LIVE offers a variety of benefits, one of them being that the live tree can be modified without caring about the underlying FDT. This is particularly valuable for working around U-Boot limitations like lacking USB superspeed support on Qualcomm platforms, no runtime OTG, or peripherals like the sdcard being broken (and displaying potentially worrying error messages).

Add an event to signal when the live tree has been built so that we can apply fixups to it directly before devices are bound.

---
  common/event.c  |  3 +++
  include/event.h | 18 ++++++++++++++++++
  lib/of_live.c   | 11 +++++++++++
  3 files changed, 32 insertions(+)
common/event.c +3 -0
index dda569d447851f559a83f98fb7b1f3543156eab5..8d7513eb10b61919e1e784481dfdcc076be14986 100644
@@ -47,8 +47,11 @@ const char *const type_name[] = {
         "ft_fixup",
 
         /* main loop events */
         "main_loop",
+
+       /* livetree has been built */
+       "of_live_init",
  };
 
  _Static_assert(ARRAY_SIZE(type_name) == EVT_COUNT, "event type_name size");
  #endif
include/event.h +0 -0
index 75141a192a48b0931667632f41be8ff4d6139f7c..1d267f1d10547642d381fa287ab4981a2bf03543 100644
@@ -152,8 +152,17 @@ enum event_t {
          * A non-zero return value causes the boot to fail.
          */
         EVT_MAIN_LOOP,
 
Quoted 10 lines

include/event.h enum event_t { · line 161

Quoted 6 lines
include/event.h +6 -0
+       /**
+        * @EVT_OF_LIVE_BUILT:
+        * This event is triggered immediately after the live device tree has been
+        * built. This allows for machine specific fixups to be done to the live tree
+        * (like disabling known-unsupported devices) before it is used. This
+        * event is only available if OF_LIVE is enabled and is only used after relocation.

Add a bit more detail, e.g.: before it is used by U-Boot post-relocation. This means it is possible to affect the devices bound by driver model.

I think this is really implied and made obvious by context clues. IF there comes a time where we build the live tree more than once (e.g. to build it as part of the DT_FIXUP_PROTOCOL for some reason) then the extra info you propose adding would no longer be correct, where the current wording would remain correct.

Quoted 5 lines

You should also note that the flattree is inactive when livetree is used and any changes may eventually be passed onto the OS, if it doesn't have its own devicetree. This is the point we were discussing on the other thread.

This information is totally irrelevant though, and there is no broad agreement with your proposed changes. The livetree API is also set up so that one could build multiple livetrees (for whatever reason), this event is modelled to reflect that (where you can see in my v1 patches that the event assumed you would only ever build the global tree).

Quoted 55 lines
Quoted 55 lines
include/event.h +12 -0
+        */
+       EVT_OF_LIVE_BUILT,
+
         /**
          * @EVT_COUNT:
          * This constants holds the maximum event number + 1 and is used when
          * looping over all event classes.
@@ -202,8 +211,17 @@ union event_data {
         struct event_ft_fixup {
                 oftree tree;
                 struct bootm_headers *images;
         } ft_fixup;
+
+       /**
+        * struct event_of_live_built - livetree has been built
+        *
+        * @root: The root node of the live device tree
+        */
+       struct event_of_live_built {
+               struct device_node *root;
+       } of_live_built;
  };
 
  /**
   * struct event - an event that can be sent and received
lib/of_live.c +2 -0
index 90b9459ede313e492e28c8556c730f3bd8aaa9df..c1620616513c2e32448b4a6d156a9162d97c76b7 100644
@@ -10,8 +10,9 @@
 
  #define LOG_CATEGORY   LOGC_DT
 
  #include <abuf.h>
+#include <event.h>
  #include <log.h>
  #include <linux/libfdt.h>
  #include <of_live.h>
  #include <malloc.h>
@@ -320,8 +321,9 @@ int unflatten_device_tree(const void *blob, struct device_node **mynodes)
 
  int of_live_build(const void *fdt_blob, struct device_node **rootp)
  {
         int ret;
+       union event_data evt;
 
         debug("%s: start\n", __func__);
         ret = unflatten_device_tree(fdt_blob, rootp);
         if (ret) {
@@ -334,8 +336,17 @@ int of_live_build(const void *fdt_blob, struct device_node **rootp)
                 return ret;
         }
         debug("%s: stop\n", __func__);
 
Quoted 11 lines

lib/of_live.c int of_live_build(const void *fdt_blob, struct device_node **rootp) · line 348

Quoted 9 lines
lib/of_live.c +9 -0
+       if (CONFIG_IS_ENABLED(EVENT)) {
+               evt.of_live_built.root = *rootp;
+               ret = event_notify(EVT_OF_LIVE_BUILT, &evt, sizeof(evt));
+               if (ret) {
+                       log_debug("Failed to notify livetree build event: err=%d\n", ret);
+                       return ret;
+               }
+       }
+

This should move to the caller of this function. We should also have a

Why move it to the caller? Then every caller would need to signal the event and we'd pointlessly duplicate code. The event signals that /a/ livetree has been built. Today this only happens once and we make the assumption that this livetree is to be used by U-Boot and only U-Boot.

Should this assumption become incorrect in the future, it would be trivial to introduce a variable to the event_data that describes what the livetree is and/or where it will be used so that anyone catching the event can decide what to do.

Since we don't yet know any other usecases, it would be overzealous to try and capture this information since we just don't know what's important.

Quoted 3 lines

sandbox test for this feature, e.g. catch the event and add a node/prop and check in a test in test-fdt.c (or similar) that it is present.

What would this test other than that the event is sent? We already have tests for the event framework...

Quoted 14 lines

I'm not sure if you need to update test_event_dump.py but since CI presumably passes, I guess not.>

Quoted 8 lines
lib/of_live.c +0 -1
         return ret;
  }
 
  void of_live_free(struct device_node *root)
 
--

2.49.0

Regards,
Simon

Signature · 1 line
Caleb (they/them)
#5 lore raw

Re: [PATCH v2 1/8] event: signal when livetree has been built

Hi Caleb,

Quoted 61 lines · Caleb Connolly

Hi Simon,

Quoted 46 lines · Simon Glass

Hi Caleb,

Quoted 43 lines · Caleb Connolly

OF_LIVE offers a variety of benefits, one of them being that the live tree can be modified without caring about the underlying FDT. This is particularly valuable for working around U-Boot limitations like lacking USB superspeed support on Qualcomm platforms, no runtime OTG, or peripherals like the sdcard being broken (and displaying potentially worrying error messages).

Add an event to signal when the live tree has been built so that we can apply fixups to it directly before devices are bound.

---
  common/event.c  |  3 +++
  include/event.h | 18 ++++++++++++++++++
  lib/of_live.c   | 11 +++++++++++
  3 files changed, 32 insertions(+)
common/event.c +3 -0
index dda569d447851f559a83f98fb7b1f3543156eab5..8d7513eb10b61919e1e784481dfdcc076be14986 100644
@@ -47,8 +47,11 @@ const char *const type_name[] = {
         "ft_fixup",
 
         /* main loop events */
         "main_loop",
+
+       /* livetree has been built */
+       "of_live_init",
  };
 
  _Static_assert(ARRAY_SIZE(type_name) == EVT_COUNT, "event type_name size");
  #endif
include/event.h +0 -0
index 75141a192a48b0931667632f41be8ff4d6139f7c..1d267f1d10547642d381fa287ab4981a2bf03543 100644
@@ -152,8 +152,17 @@ enum event_t {
          * A non-zero return value causes the boot to fail.
          */
         EVT_MAIN_LOOP,
 
Quoted 10 lines

include/event.h enum event_t { · line 161

Quoted 6 lines
include/event.h +6 -0
+       /**
+        * @EVT_OF_LIVE_BUILT:
+        * This event is triggered immediately after the live device tree has been
+        * built. This allows for machine specific fixups to be done to the live tree
+        * (like disabling known-unsupported devices) before it is used. This
+        * event is only available if OF_LIVE is enabled and is only used after relocation.

Add a bit more detail, e.g.: before it is used by U-Boot post-relocation. This means it is possible to affect the devices bound by driver model.

Quoted 5 lines

I think this is really implied and made obvious by context clues. IF there comes a time where we build the live tree more than once (e.g. to build it as part of the DT_FIXUP_PROTOCOL for some reason) then the extra info you propose adding would no longer be correct, where the current wording would remain correct.

OK, leave it alone if you like.

Quoted 7 lines
Quoted 6 lines

You should also note that the flattree is inactive when livetree is used and any changes may eventually be passed onto the OS, if it doesn't have its own devicetree. This is the point we were discussing on the other thread.

Quoted 5 lines

This information is totally irrelevant though, and there is no broad agreement with your proposed changes. The livetree API is also set up so that one could build multiple livetrees (for whatever reason), this event is modelled to reflect that (where you can see in my v1 patches that the event assumed you would only ever build the global tree).

Hmmm, if Linaro is going to block livetree fixups then we are going to have a problem. I have not heard that, but let me know.

Quoted 73 lines
Quoted 56 lines
Quoted 56 lines
include/event.h +12 -0
+        */
+       EVT_OF_LIVE_BUILT,
+
         /**
          * @EVT_COUNT:
          * This constants holds the maximum event number + 1 and is used when
          * looping over all event classes.
@@ -202,8 +211,17 @@ union event_data {
         struct event_ft_fixup {
                 oftree tree;
                 struct bootm_headers *images;
         } ft_fixup;
+
+       /**
+        * struct event_of_live_built - livetree has been built
+        *
+        * @root: The root node of the live device tree
+        */
+       struct event_of_live_built {
+               struct device_node *root;
+       } of_live_built;
  };
 
  /**
   * struct event - an event that can be sent and received
lib/of_live.c +2 -0
index 90b9459ede313e492e28c8556c730f3bd8aaa9df..c1620616513c2e32448b4a6d156a9162d97c76b7 100644
@@ -10,8 +10,9 @@
 
  #define LOG_CATEGORY   LOGC_DT
 
  #include <abuf.h>
+#include <event.h>
  #include <log.h>
  #include <linux/libfdt.h>
  #include <of_live.h>
  #include <malloc.h>
@@ -320,8 +321,9 @@ int unflatten_device_tree(const void *blob, struct device_node **mynodes)
 
  int of_live_build(const void *fdt_blob, struct device_node **rootp)
  {
         int ret;
+       union event_data evt;
 
         debug("%s: start\n", __func__);
         ret = unflatten_device_tree(fdt_blob, rootp);
         if (ret) {
@@ -334,8 +336,17 @@ int of_live_build(const void *fdt_blob, struct device_node **rootp)
                 return ret;
         }
         debug("%s: stop\n", __func__);
 
Quoted 11 lines

lib/of_live.c int of_live_build(const void *fdt_blob, struct device_node **rootp) · line 348

Quoted 9 lines
lib/of_live.c +9 -0
+       if (CONFIG_IS_ENABLED(EVENT)) {
+               evt.of_live_built.root = *rootp;
+               ret = event_notify(EVT_OF_LIVE_BUILT, &evt, sizeof(evt));
+               if (ret) {
+                       log_debug("Failed to notify livetree build event: err=%d\n", ret);
+                       return ret;
+               }
+       }
+

This should move to the caller of this function. We should also have a

Why move it to the caller? Then every caller would need to signal the event and we'd pointlessly duplicate code. The event signals that /a/ livetree has been built. Today this only happens once and we make the assumption that this livetree is to be used by U-Boot and only U-Boot.

Quoted 7 lines

Should this assumption become incorrect in the future, it would be trivial to introduce a variable to the event_data that describes what the livetree is and/or where it will be used so that anyone catching the event can decide what to do.

Since we don't yet know any other usecases, it would be overzealous to try and capture this information since we just don't know what's important.

There is (and will only ever be) one caller. At this point I really don't mind what you do.

Quoted 7 lines
Quoted 4 lines

sandbox test for this feature, e.g. catch the event and add a node/prop and check in a test in test-fdt.c (or similar) that it is present.

What would this test other than that the event is sent? We already have tests for the event framework...

If the CI tests pass, then it's fine.

Quoted 4 lines
Quoted 4 lines

I'm not sure if you need to update test_event_dump.py but since CI presumably passes, I guess not.>

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
lib/of_live.c +0 -1
         return ret;
  }
 
  void of_live_free(struct device_node *root)
 
--

2.49.0

Regards,
Simon

#6 lore raw

PATCH v2 2/8 mach-snapdragon: use EVT_OF_LIVE_INIT to apply DT fixups

In reply to Caleb Connolly

This will now apply fixups prior to devices being bound, which makes it possible to enable/disable devices and adjust more properties that might be read before devices probe.

---
 arch/arm/mach-snapdragon/board.c     |  1 -
 arch/arm/mach-snapdragon/of_fixup.c  | 25 ++++++++++++++++---------
 arch/arm/mach-snapdragon/qcom-priv.h | 14 --------------
 3 files changed, 16 insertions(+), 24 deletions(-)
arch/arm/mach-snapdragon/board.c +0 -1
index deae4d323789eab75d5fe735159b4cd820c02c45..3ab75f0fce02ecffd476ebe2aa606b1a9024bbec 100644
@@ -305,9 +305,8 @@ void __weak qcom_board_init(void)
 
 int board_init(void)
 {
 	show_psci_version();
-	qcom_of_fixup_nodes();
 	qcom_board_init();
 	return 0;
 }
 
arch/arm/mach-snapdragon/of_fixup.c +16 -9
index 1ea0c18c2f2789a8aa054cd95bb9e4308d6b3384..70399307bcbda1e067230f00af6ba859a98c7ac0 100644
@@ -21,8 +21,9 @@
 
 #include <dt-bindings/input/linux-event-codes.h>
 #include <dm/of_access.h>
 #include <dm/of.h>
+#include <event.h>
 #include <fdt_support.h>
 #include <linux/errno.h>
 #include <stdlib.h>
 #include <time.h>
@@ -31,9 +32,9 @@
  * USB controllers. Rather than requiring source level DT changes, we fix up
  * DT here. This improves compatibility with upstream DT and simplifies the
  * porting process for new devices.
  */
-static int fixup_qcom_dwc3(struct device_node *glue_np)
+static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np)
 {
 	struct device_node *dwc3;
 	int ret, len, hsphy_idx = 1;
 	const __be32 *phandles;
@@ -100,11 +101,11 @@ static int fixup_qcom_dwc3(struct device_node *glue_np)
 
 	return 0;
 }
 
-static void fixup_usb_nodes(void)
+static void fixup_usb_nodes(struct device_node *root)
 {
-	struct device_node *glue_np = NULL;
+	struct device_node *glue_np = root;
 	int ret;
 
 	while ((glue_np = of_find_compatible_node(glue_np, NULL, "qcom,dwc3"))) {
 		ret = fixup_qcom_dwc3(glue_np);
@@ -113,16 +114,16 @@ static void fixup_usb_nodes(void)
 	}
 }
 
 /* Remove all references to the rpmhpd device */
-static void fixup_power_domains(void)
+static void fixup_power_domains(struct device_node *root)
 {
 	struct device_node *pd = NULL, *np = NULL;
 	struct property *prop;
 	const __be32 *val;
 
 	/* All Qualcomm platforms name the rpm(h)pd "power-controller" */
-	for_each_of_allnodes(pd) {
+	for_each_of_allnodes_from(root, pd) {
 		if (pd->name && !strcmp("power-controller", pd->name))
 			break;
 	}
 
@@ -132,9 +133,9 @@ static void fixup_power_domains(void)
 		return;
 	}
 
 	/* Remove all references to the power domain controller */
-	for_each_of_allnodes(np) {
+	for_each_of_allnodes_from(root, np) {
 		if (!(prop = of_find_property(np, "power-domains", NULL)))
 			continue;
 
 		val = prop->value;
@@ -149,14 +150,20 @@ static void fixup_power_domains(void)
 		func(__VA_ARGS__); \
 		debug(#func " took %lluus\n", timer_get_us() - start); \
 	} while (0)
 
-void qcom_of_fixup_nodes(void)
+static int qcom_of_fixup_nodes(void * __maybe_unused ctx, struct event *event)
 {
-	time_call(fixup_usb_nodes);
-	time_call(fixup_power_domains);
+	struct device_node *root = event->data.of_live_built.root;
+
+	time_call(fixup_usb_nodes, root);
+	time_call(fixup_power_domains, root);
+
+	return 0;
 }
 
+EVENT_SPY_FULL(EVT_OF_LIVE_BUILT, qcom_of_fixup_nodes);
+
 int ft_board_setup(void *blob, struct bd_info __maybe_unused *bd)
 {
 	struct fdt_header *fdt = blob;
 	int node;
arch/arm/mach-snapdragon/qcom-priv.h +0 -14
index 74d39197b89f4e769299b06214c26ee829ecdce0..4f398e2ba374f27811afd2ccf6e72037d0f9ee7f 100644
@@ -8,19 +8,5 @@ void qcom_configure_capsule_updates(void);
 #else
 void qcom_configure_capsule_updates(void) {}
 #endif /* EFI_HAVE_CAPSULE_SUPPORT */
 
-#if CONFIG_IS_ENABLED(OF_LIVE)
-/**
- * qcom_of_fixup_nodes() - Fixup Qualcomm DT nodes
- *
- * Adjusts nodes in the live tree to improve compatibility with U-Boot.
- */
-void qcom_of_fixup_nodes(void);
-#else
-static inline void qcom_of_fixup_nodes(void)
-{
-	log_debug("Unable to dynamically fixup USB nodes, please enable CONFIG_OF_LIVE\n");
-}
-#endif /* OF_LIVE */
-
 #endif /* __QCOM_PRIV_H__ */
Signature · 1 line
2.49.0
#7 lore raw

Re: [PATCH v2 2/8] mach-snapdragon: use EVT_OF_LIVE_INIT to apply DT fixups

Hi,

Quoted 3 lines · Caleb Connolly

This will now apply fixups prior to devices being bound, which makes it possible to enable/disable devices and adjust more properties that might be read before devices probe.

Subject should be EVT_OF_LIVE_BUILT

Neil

Quoted 140 lines
---
  arch/arm/mach-snapdragon/board.c     |  1 -
  arch/arm/mach-snapdragon/of_fixup.c  | 25 ++++++++++++++++---------
  arch/arm/mach-snapdragon/qcom-priv.h | 14 --------------
  3 files changed, 16 insertions(+), 24 deletions(-)
arch/arm/mach-snapdragon/board.c +0 -1
index deae4d323789eab75d5fe735159b4cd820c02c45..3ab75f0fce02ecffd476ebe2aa606b1a9024bbec 100644
@@ -305,9 +305,8 @@ void __weak qcom_board_init(void)
 
  int board_init(void)
  {
  	show_psci_version();
-	qcom_of_fixup_nodes();
  	qcom_board_init();
  	return 0;
  }
 
arch/arm/mach-snapdragon/of_fixup.c +16 -9
index 1ea0c18c2f2789a8aa054cd95bb9e4308d6b3384..70399307bcbda1e067230f00af6ba859a98c7ac0 100644
@@ -21,8 +21,9 @@
 
  #include <dt-bindings/input/linux-event-codes.h>
  #include <dm/of_access.h>
  #include <dm/of.h>
+#include <event.h>
  #include <fdt_support.h>
  #include <linux/errno.h>
  #include <stdlib.h>
  #include <time.h>
@@ -31,9 +32,9 @@
   * USB controllers. Rather than requiring source level DT changes, we fix up
   * DT here. This improves compatibility with upstream DT and simplifies the
   * porting process for new devices.
   */
-static int fixup_qcom_dwc3(struct device_node *glue_np)
+static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np)
  {
  	struct device_node *dwc3;
  	int ret, len, hsphy_idx = 1;
  	const __be32 *phandles;
@@ -100,11 +101,11 @@ static int fixup_qcom_dwc3(struct device_node *glue_np)
 
  	return 0;
  }
 
-static void fixup_usb_nodes(void)
+static void fixup_usb_nodes(struct device_node *root)
  {
-	struct device_node *glue_np = NULL;
+	struct device_node *glue_np = root;
  	int ret;
 
  	while ((glue_np = of_find_compatible_node(glue_np, NULL, "qcom,dwc3"))) {
  		ret = fixup_qcom_dwc3(glue_np);
@@ -113,16 +114,16 @@ static void fixup_usb_nodes(void)
  	}
  }
 
  /* Remove all references to the rpmhpd device */
-static void fixup_power_domains(void)
+static void fixup_power_domains(struct device_node *root)
  {
  	struct device_node *pd = NULL, *np = NULL;
  	struct property *prop;
  	const __be32 *val;
 
  	/* All Qualcomm platforms name the rpm(h)pd "power-controller" */
-	for_each_of_allnodes(pd) {
+	for_each_of_allnodes_from(root, pd) {
  		if (pd->name && !strcmp("power-controller", pd->name))
  			break;
  	}
 
@@ -132,9 +133,9 @@ static void fixup_power_domains(void)
  		return;
  	}
 
  	/* Remove all references to the power domain controller */
-	for_each_of_allnodes(np) {
+	for_each_of_allnodes_from(root, np) {
  		if (!(prop = of_find_property(np, "power-domains", NULL)))
  			continue;
 
  		val = prop->value;
@@ -149,14 +150,20 @@ static void fixup_power_domains(void)
  		func(__VA_ARGS__); \
  		debug(#func " took %lluus\n", timer_get_us() - start); \
  	} while (0)
 
-void qcom_of_fixup_nodes(void)
+static int qcom_of_fixup_nodes(void * __maybe_unused ctx, struct event *event)
  {
-	time_call(fixup_usb_nodes);
-	time_call(fixup_power_domains);
+	struct device_node *root = event->data.of_live_built.root;
+
+	time_call(fixup_usb_nodes, root);
+	time_call(fixup_power_domains, root);
+
+	return 0;
  }
 
+EVENT_SPY_FULL(EVT_OF_LIVE_BUILT, qcom_of_fixup_nodes);
+
  int ft_board_setup(void *blob, struct bd_info __maybe_unused *bd)
  {
  	struct fdt_header *fdt = blob;
  	int node;
arch/arm/mach-snapdragon/qcom-priv.h +0 -14
index 74d39197b89f4e769299b06214c26ee829ecdce0..4f398e2ba374f27811afd2ccf6e72037d0f9ee7f 100644
@@ -8,19 +8,5 @@ void qcom_configure_capsule_updates(void);
  #else
  void qcom_configure_capsule_updates(void) {}
  #endif /* EFI_HAVE_CAPSULE_SUPPORT */
 
-#if CONFIG_IS_ENABLED(OF_LIVE)
-/**
- * qcom_of_fixup_nodes() - Fixup Qualcomm DT nodes
- *
- * Adjusts nodes in the live tree to improve compatibility with U-Boot.
- */
-void qcom_of_fixup_nodes(void);
-#else
-static inline void qcom_of_fixup_nodes(void)
-{
-	log_debug("Unable to dynamically fixup USB nodes, please enable CONFIG_OF_LIVE\n");
-}
-#endif /* OF_LIVE */
-
  #endif /* __QCOM_PRIV_H__ */
#8 lore raw

PATCH v2 3/8 mach-snapdragon: of_fixup: skip disabled USB nodes

In reply to Caleb Connolly

There's no need to waste time fixing up nodes that aren't used on this device. Skip them.

---
 arch/arm/mach-snapdragon/of_fixup.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-snapdragon/of_fixup.c +3 -1
index 70399307bcbda1e067230f00af6ba859a98c7ac0..dcd09ee7cac3e02287647c9e6df5575651e18e85 100644
@@ -107,9 +107,11 @@ static void fixup_usb_nodes(struct device_node *root)
 	struct device_node *glue_np = root;
 	int ret;
 
 	while ((glue_np = of_find_compatible_node(glue_np, NULL, "qcom,dwc3"))) {
-		ret = fixup_qcom_dwc3(glue_np);
+		if (!of_device_is_available(glue_np))
+			continue;
+		ret = fixup_qcom_dwc3(root, glue_np);
 		if (ret)
 			log_warning("Failed to fixup node %s: %d\n", glue_np->name, ret);
 	}
 }
Signature · 1 line
2.49.0
#9 lore raw

PATCH v2 4/8 mach-snapdragon: of_fixup: remove confusing log message

In reply to Caleb Connolly

The debug log here had the logic completely backwards, even though the code is actually correct. Remove it since it's extraneous anyway.

---
 arch/arm/mach-snapdragon/of_fixup.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
arch/arm/mach-snapdragon/of_fixup.c +5 -4
index dcd09ee7cac3e02287647c9e6df5575651e18e85..a5515c02d3de05944dfb7c1b2a5542631b517497 100644
@@ -72,13 +72,14 @@ static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np
 		log_err("Failed to read second phy name: %d\n", ret);
 		return ret;
 	}
 
-	if (!strncmp("usb3-phy", second_phy_name, strlen("usb3-phy"))) {
-		log_debug("Second phy isn't superspeed (is '%s') assuming first phy is SS\n",
-			  second_phy_name);
+	/*
+	 * Determine which phy is the superspeed phy by checking the name of the second phy
+	 * since it is typically the superspeed one.
+	 */
+	if (!strncmp("usb3-phy", second_phy_name, strlen("usb3-phy")))
 		hsphy_idx = 0;
-	}
 
 	/* Overwrite the "phys" property to only contain the high-speed phy */
 	ret = of_write_prop(dwc3, "phys", sizeof(*phandles), phandles + hsphy_idx);
 	if (ret) {
Signature · 1 line
2.49.0
Reviewed-by on v2 4/8
#10 lore raw

Re: [PATCH v2 4/8] mach-snapdragon: of_fixup: remove confusing log message

Quoted 22 lines · Caleb Connolly

The debug log here had the logic completely backwards, even though the code is actually correct. Remove it since it's extraneous anyway.

---
  arch/arm/mach-snapdragon/of_fixup.c | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)
arch/arm/mach-snapdragon/of_fixup.c +1 -3
index dcd09ee7cac3e02287647c9e6df5575651e18e85..a5515c02d3de05944dfb7c1b2a5542631b517497 100644
@@ -72,13 +72,14 @@ static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np
  		log_err("Failed to read second phy name: %d\n", ret);
  		return ret;
  	}
 
-	if (!strncmp("usb3-phy", second_phy_name, strlen("usb3-phy"))) {
-		log_debug("Second phy isn't superspeed (is '%s') assuming first phy is SS\n",
-			  second_phy_name);
+	/*

arch/arm/mach-snapdragon/of_fixup.c static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np · line 85

Quoted 10 lines
arch/arm/mach-snapdragon/of_fixup.c +4 -1
+	 * Determine which phy is the superspeed phy by checking the name of the second phy
+	 * since it is typically the superspeed one.
+	 */
+	if (!strncmp("usb3-phy", second_phy_name, strlen("usb3-phy")))
  		hsphy_idx = 0;
-	}
 
  	/* Overwrite the "phys" property to only contain the high-speed phy */
  	ret = of_write_prop(dwc3, "phys", sizeof(*phandles), phandles + hsphy_idx);
  	if (ret) {
#11 lore raw

PATCH v2 5/8 mach-snapdragon: of_fixup: update comment

In reply to Caleb Connolly

we don't rewrite the volume buttons any more.

---
 arch/arm/mach-snapdragon/of_fixup.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/mach-snapdragon/of_fixup.c +1 -2
index a5515c02d3de05944dfb7c1b2a5542631b517497..10053e48d88017d2179c96f2f3724c4d5dc4f3e2 100644
@@ -3,10 +3,9 @@
  * OF_LIVE devicetree fixup.
  *
  * This file implements runtime fixups for Qualcomm DT to improve
  * compatibility with U-Boot. This includes adjusting the USB nodes
- * to only use USB high-speed, as well as remapping volume buttons
- * to behave as up/down for navigating U-Boot.
+ * to only use USB high-speed.
  *
  * We use OF_LIVE for this rather than early FDT fixup for a couple
  * of reasons: it has a much nicer API, is most likely more efficient,
  * and our changes are only applied to U-Boot. This allows us to use a
Signature · 1 line
2.49.0
Reviewed-by on v2 5/8
#12 lore raw

Re: [PATCH v2 5/8] mach-snapdragon: of_fixup: update comment

Quoted 14 lines · Caleb Connolly

we don't rewrite the volume buttons any more.

---
  arch/arm/mach-snapdragon/of_fixup.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/mach-snapdragon/of_fixup.c +0 -0
index a5515c02d3de05944dfb7c1b2a5542631b517497..10053e48d88017d2179c96f2f3724c4d5dc4f3e2 100644
@@ -3,10 +3,9 @@
   * OF_LIVE devicetree fixup.

arch/arm/mach-snapdragon/of_fixup.c line 11

Quoted 10 lines
arch/arm/mach-snapdragon/of_fixup.c +1 -2
   *
   * This file implements runtime fixups for Qualcomm DT to improve
   * compatibility with U-Boot. This includes adjusting the USB nodes
- * to only use USB high-speed, as well as remapping volume buttons
- * to behave as up/down for navigating U-Boot.
+ * to only use USB high-speed.
   *
   * We use OF_LIVE for this rather than early FDT fixup for a couple
   * of reasons: it has a much nicer API, is most likely more efficient,
   * and our changes are only applied to U-Boot. This allows us to use a
#13 lore raw

PATCH v2 6/8 mach-snapdragon: of_fixup: set dr_mode for RB1/2 boards

In reply to Caleb Connolly

The RB1 and RB2 have a single USB controller which is manually muxed between a type-c port and an internal USB hub via a DIP switch. OTG is supported in Linux, but the DWC3 driver in U-Boot can only handle a single mode, and defaults to peripheral mode.

We did hack around this on the RB2, but the RB1 got left out.

Now that we can fix up the live tree before devices are bound, drop the DTS hacks and do the fixup at runtime instead.

---
 arch/arm/dts/qrb4210-rb2-u-boot.dtsi |  6 ------
 arch/arm/mach-snapdragon/of_fixup.c  | 28 ++++++++++++++--------------
 2 files changed, 14 insertions(+), 20 deletions(-)
arch/arm/dts/qrb4210-rb2-u-boot.dtsi deleted +0 -6
deleted file mode 100644
index 7d1375f38c44d7bd54c022fa3d390f666a35d6ee..0000000000000000000000000000000000000000
@@ -1,6 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-
-/* This is usually OTG but U-Boot doesn't support that properly */
-&usb_dwc3 {
-	dr_mode = "host";
-};
arch/arm/mach-snapdragon/of_fixup.c +14 -14
index 10053e48d88017d2179c96f2f3724c4d5dc4f3e2..b398c6b7b9fdaddc03324921e6b955919f9c7675 100644
@@ -98,8 +98,21 @@ static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np
 		log_err("Failed to set 'maximum-speed' property: %d\n", ret);
 		return ret;
 	}
 
+	/*
+	 * The RB1/2 boards only have a single USB controller and it's muxed between the type-C port
+	 * and a USB hub. Since we can't do OTG in U-Boot properly we prefer to put it into host mode.
+	 */
+	if (of_device_is_compatible(root, "qcom,qrb4210-rb2", NULL, NULL) ||
+	    of_device_is_compatible(root, "qcom,qrb2210-rb1", NULL, NULL)) {
+		ret = of_write_prop(dwc3, "dr_mode", sizeof("host"), "host");
+		if (ret) {
+			log_err("Failed to set 'dr_mode' property: %d\n", ret);
+			return ret;
+		}
+	}
+
 	return 0;
 }
 
 static void fixup_usb_nodes(struct device_node *root)
@@ -164,21 +177,8 @@ static int qcom_of_fixup_nodes(void * __maybe_unused ctx, struct event *event)
 }
 
 EVENT_SPY_FULL(EVT_OF_LIVE_BUILT, qcom_of_fixup_nodes);
 
-int ft_board_setup(void *blob, struct bd_info __maybe_unused *bd)
+int ft_board_setup(void __maybe_unused *blob, struct bd_info __maybe_unused *bd)
 {
-	struct fdt_header *fdt = blob;
-	int node;
-
-	/* On RB1/2 we need to fix-up the dr_mode */
-	if (!fdt_node_check_compatible(fdt, 0, "qcom,qrb4210-rb2") ||
-	    !fdt_node_check_compatible(fdt, 0, "qcom,qrb2210-rb1")) {
-		fdt_for_each_node_by_compatible(node, blob, 0, "snps,dwc3") {
-			log_debug("%s: Setting 'dr_mode' to OTG\n", fdt_get_name(blob, node, NULL));
-			fdt_setprop_string(fdt, node, "dr_mode", "otg");
-			break;
-		}
-	}
-
 	return 0;
 }
Signature · 1 line
2.49.0
#14 lore raw

PATCH v2 7/8 clk/qcom: qcm2290: show clock name in set_rate()

In reply to Caleb Connolly

The device name is always clk_qcom... Not very useful.

---
 drivers/clk/qcom/clock-qcm2290.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/clock-qcm2290.c +1 -1
index 1326b770c3ebd723120de4b6657aafac726023d6..fad104fb91aec8917de66b63dd546926c8856011 100644
@@ -87,9 +87,9 @@ static ulong qcm2290_set_rate(struct clk *clk, ulong rate)
 {
 	struct msm_clk_priv *priv = dev_get_priv(clk->dev);
 	const struct freq_tbl *freq;
 
-	debug("%s: clk %s rate %lu\n", __func__, clk->dev->name, rate);
+	debug("%s: clk %s rate %lu\n", __func__, qcm2290_clks[clk->id].name, rate);
 
 	switch (clk->id) {
 	case GCC_QUPV3_WRAP0_S4_CLK: /*UART2*/
 		freq = qcom_find_freq(ftbl_gcc_qupv3_wrap0_s0_clk_src, rate);
Signature · 1 line
2.49.0
#15 lore raw

PATCH v2 8/8 pinctrl: qcom: qcm2290: fix off by 1 in pin_count

In reply to Caleb Connolly

There are 134 pins not 133, oops! This fixes the sdcard on the RB1 as the pins now all get configured correctly.

Fixes 0ecb8cfcb930 ("pinctrl: qcom: add qcm2290 pinctrl driver")
---
 drivers/pinctrl/qcom/pinctrl-qcm2290.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/qcom/pinctrl-qcm2290.c +1 -1
index 0c2222ce663e6d584d229e7521f88fedf8aa19da..84f76b63b93ad78182524661dba561672feb4c85 100644
@@ -44,9 +44,9 @@ static int qcm2290_get_function_mux(__maybe_unused unsigned int pin, unsigned in
 }
 
 struct msm_pinctrl_data qcm2290_data = {
 	.pin_data = {
-		.pin_count = 133,
+		.pin_count = 134,
 		.special_pins_start = 127,
 	},
 	.functions_count = ARRAY_SIZE(msm_pinctrl_functions),
 	.get_function_name = qcm2290_get_function_name,
Signature · 1 line
2.49.0
#16 lore raw

Re: [PATCH v2 8/8] pinctrl: qcom: qcm2290: fix off by 1 in pin_count

Hi Casey,

Quoted 12 lines · Caleb Connolly

There are 134 pins not 133, oops! This fixes the sdcard on the RB1 as the pins now all get configured correctly.

Fixes 0ecb8cfcb930 ("pinctrl: qcom: add qcm2290 pinctrl driver")
---
 drivers/pinctrl/qcom/pinctrl-qcm2290.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I think this is an independent fix for SD card to work on RB1. Can you queue it for v2025.07?

Also, I am not sure if you are planning this complete series for v2025.07. If not then can we atleast have a DT override for USB DR mode to make it work on RB1 in v2025.07?

-Sumit

Quoted 19 lines
drivers/pinctrl/qcom/pinctrl-qcm2290.c +1 -1
index 0c2222ce663e6d584d229e7521f88fedf8aa19da..84f76b63b93ad78182524661dba561672feb4c85 100644
@@ -44,9 +44,9 @@ static int qcm2290_get_function_mux(__maybe_unused unsigned int pin, unsigned in
 }
 
 struct msm_pinctrl_data qcm2290_data = {
 	.pin_data = {
-		.pin_count = 133,
+		.pin_count = 134,
 		.special_pins_start = 127,
 	},
 	.functions_count = ARRAY_SIZE(msm_pinctrl_functions),
 	.get_function_name = qcm2290_get_function_name,
Signature · 2 lines
-- 
2.49.0
#17 lore raw
In reply to Caleb Connolly
Quoted 6 lines · Caleb Connolly

Introduce a new event to signal that the live tree has been built, allowing boards to perform fixups on the tree before devices are bound. Crucially this allows for devices to be enabled or disabled, but also allows for properties that are parsed during the bind stage to be modified (such as dr_mode for dwc3).

Quoted 6 lines

With this in place, mach-snapdragon is switched over to use the event and some hacky U-Boot specific DT overrides (which had to be undone prior to booting an image) are removed in favour of fixing up the livetree (which is not passed on to further boot stages).

[...]

Applied to u-boot/master, thanks!

[1/8] event: signal when livetree has been built

      commit: 993a9db918af451c68851522c8770e582b717629
[2/8] mach-snapdragon: use EVT_OF_LIVE_INIT to apply DT fixups
      commit: 5a1dfb27f9170d35a475ea8be46b5d7c037ee837
[3/8] mach-snapdragon: of_fixup: skip disabled USB nodes
      commit: 0ec337d03410a4a0b7402ae72968470cf63f0c55
[4/8] mach-snapdragon: of_fixup: remove confusing log message
      commit: a6cc4ef343dc39c17fd5b833d983aff2f26c94b7
[5/8] mach-snapdragon: of_fixup: update comment
      commit: 9bc7eef9bf58c4c1d453cba81060dc61375f5354
[6/8] mach-snapdragon: of_fixup: set dr_mode for RB1/2 boards
      commit: 3b983cf48e70ecb6aadca788d0d91a021340c802
[7/8] clk/qcom: qcm2290: show clock name in set_rate()
      commit: 229fd3f9a8d4dbaad7c9a2e9c1b62d14d0753b0b
[8/8] pinctrl: qcom: qcm2290: fix off by 1 in pin_count
      commit: 2803a466a96153ab01c5789321e48397b6bae9c7
Signature · 1 line
Tom
#18 lore raw

Hi Tom,

Quoted 34 lines · Tom Rini
Quoted 6 lines · Caleb Connolly

Introduce a new event to signal that the live tree has been built, allowing boards to perform fixups on the tree before devices are bound. Crucially this allows for devices to be enabled or disabled, but also allows for properties that are parsed during the bind stage to be modified (such as dr_mode for dwc3).

Quoted 6 lines

With this in place, mach-snapdragon is switched over to use the event and some hacky U-Boot specific DT overrides (which had to be undone prior to booting an image) are removed in favour of fixing up the livetree (which is not passed on to further boot stages).

[...]

Applied to u-boot/master, thanks!

[1/8] event: signal when livetree has been built

      commit: 993a9db918af451c68851522c8770e582b717629
[2/8] mach-snapdragon: use EVT_OF_LIVE_INIT to apply DT fixups
      commit: 5a1dfb27f9170d35a475ea8be46b5d7c037ee837
[3/8] mach-snapdragon: of_fixup: skip disabled USB nodes
      commit: 0ec337d03410a4a0b7402ae72968470cf63f0c55
[4/8] mach-snapdragon: of_fixup: remove confusing log message
      commit: a6cc4ef343dc39c17fd5b833d983aff2f26c94b7
[5/8] mach-snapdragon: of_fixup: update comment
      commit: 9bc7eef9bf58c4c1d453cba81060dc61375f5354
[6/8] mach-snapdragon: of_fixup: set dr_mode for RB1/2 boards
      commit: 3b983cf48e70ecb6aadca788d0d91a021340c802
[7/8] clk/qcom: qcm2290: show clock name in set_rate()
      commit: 229fd3f9a8d4dbaad7c9a2e9c1b62d14d0753b0b
[8/8] pinctrl: qcom: qcm2290: fix off by 1 in pin_count
      commit: 2803a466a96153ab01c5789321e48397b6bae9c7
Quoted 3 lines

--
Tom

One of the patches in this series introduces the concept of two parallel devicetrees in U-Boot. So once we do move to livetree 'for real' it won't work. We did have a discussion on the series and I proposed a couple of alternatives, but have not heard back on those.

As always, I don't mind what is applied so long as we can change it later.

Regards,
Simon

#19 lore raw
Quoted 41 lines · Simon Glass

Hi Tom,

Quoted 34 lines · Tom Rini
Quoted 6 lines · Caleb Connolly

Introduce a new event to signal that the live tree has been built, allowing boards to perform fixups on the tree before devices are bound. Crucially this allows for devices to be enabled or disabled, but also allows for properties that are parsed during the bind stage to be modified (such as dr_mode for dwc3).

Quoted 6 lines

With this in place, mach-snapdragon is switched over to use the event and some hacky U-Boot specific DT overrides (which had to be undone prior to booting an image) are removed in favour of fixing up the livetree (which is not passed on to further boot stages).

[...]

Applied to u-boot/master, thanks!

[1/8] event: signal when livetree has been built

      commit: 993a9db918af451c68851522c8770e582b717629
[2/8] mach-snapdragon: use EVT_OF_LIVE_INIT to apply DT fixups
      commit: 5a1dfb27f9170d35a475ea8be46b5d7c037ee837
[3/8] mach-snapdragon: of_fixup: skip disabled USB nodes
      commit: 0ec337d03410a4a0b7402ae72968470cf63f0c55
[4/8] mach-snapdragon: of_fixup: remove confusing log message
      commit: a6cc4ef343dc39c17fd5b833d983aff2f26c94b7
[5/8] mach-snapdragon: of_fixup: update comment
      commit: 9bc7eef9bf58c4c1d453cba81060dc61375f5354
[6/8] mach-snapdragon: of_fixup: set dr_mode for RB1/2 boards
      commit: 3b983cf48e70ecb6aadca788d0d91a021340c802
[7/8] clk/qcom: qcm2290: show clock name in set_rate()
      commit: 229fd3f9a8d4dbaad7c9a2e9c1b62d14d0753b0b
[8/8] pinctrl: qcom: qcm2290: fix off by 1 in pin_count
      commit: 2803a466a96153ab01c5789321e48397b6bae9c7
Quoted 3 lines

--
Tom

Quoted 6 lines

One of the patches in this series introduces the concept of two parallel devicetrees in U-Boot. So once we do move to livetree 'for real' it won't work. We did have a discussion on the series and I proposed a couple of alternatives, but have not heard back on those.

As always, I don't mind what is applied so long as we can change it later.

Yes, it seemed we had reached the point where there was confusion over how things work, so we're going to move forward and see what's needed in the future.

Signature · 1 line
Tom
#20 lore raw

Hi Tom,

Quoted 48 lines · Tom Rini
Quoted 46 lines · Simon Glass

Hi Tom,

Quoted 34 lines · Tom Rini
Quoted 6 lines · Caleb Connolly

Introduce a new event to signal that the live tree has been built, allowing boards to perform fixups on the tree before devices are bound. Crucially this allows for devices to be enabled or disabled, but also allows for properties that are parsed during the bind stage to be modified (such as dr_mode for dwc3).

Quoted 6 lines

With this in place, mach-snapdragon is switched over to use the event and some hacky U-Boot specific DT overrides (which had to be undone prior to booting an image) are removed in favour of fixing up the livetree (which is not passed on to further boot stages).

[...]

Applied to u-boot/master, thanks!

[1/8] event: signal when livetree has been built

      commit: 993a9db918af451c68851522c8770e582b717629
[2/8] mach-snapdragon: use EVT_OF_LIVE_INIT to apply DT fixups
      commit: 5a1dfb27f9170d35a475ea8be46b5d7c037ee837
[3/8] mach-snapdragon: of_fixup: skip disabled USB nodes
      commit: 0ec337d03410a4a0b7402ae72968470cf63f0c55
[4/8] mach-snapdragon: of_fixup: remove confusing log message
      commit: a6cc4ef343dc39c17fd5b833d983aff2f26c94b7
[5/8] mach-snapdragon: of_fixup: update comment
      commit: 9bc7eef9bf58c4c1d453cba81060dc61375f5354
[6/8] mach-snapdragon: of_fixup: set dr_mode for RB1/2 boards
      commit: 3b983cf48e70ecb6aadca788d0d91a021340c802
[7/8] clk/qcom: qcm2290: show clock name in set_rate()
      commit: 229fd3f9a8d4dbaad7c9a2e9c1b62d14d0753b0b
[8/8] pinctrl: qcom: qcm2290: fix off by 1 in pin_count
      commit: 2803a466a96153ab01c5789321e48397b6bae9c7
Quoted 3 lines

--
Tom

One of the patches in this series introduces the concept of two parallel devicetrees in U-Boot. So once we do move to livetree 'for real' it won't work. We did have a discussion on the series and I proposed a couple of alternatives, but have not heard back on those.

Quoted 5 lines
Quoted 1 line

As always, I don't mind what is applied so long as we can change it later.

Yes, it seemed we had reached the point where there was confusion over how things work, so we're going to move forward and see what's needed in the future.

OK. I am not sure when I will get to doing more on the OF_LIVE migration, but it is a good reminder.

Regards,
Simon