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

Neil Armstrong neil.armstrong at linaro.org
Fri Apr 11 16:10:45 CEST 2025


Hi,

On 11/04/2025 14:47, Caleb Connolly wrote:
> 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

> 
> Signed-off-by: Caleb Connolly <caleb.connolly at linaro.org>
> ---
>   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(-)
> 
> diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c
> index deae4d323789eab75d5fe735159b4cd820c02c45..3ab75f0fce02ecffd476ebe2aa606b1a9024bbec 100644
> --- a/arch/arm/mach-snapdragon/board.c
> +++ b/arch/arm/mach-snapdragon/board.c
> @@ -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;
>   }
>   
> diff --git a/arch/arm/mach-snapdragon/of_fixup.c b/arch/arm/mach-snapdragon/of_fixup.c
> index 1ea0c18c2f2789a8aa054cd95bb9e4308d6b3384..70399307bcbda1e067230f00af6ba859a98c7ac0 100644
> --- a/arch/arm/mach-snapdragon/of_fixup.c
> +++ b/arch/arm/mach-snapdragon/of_fixup.c
> @@ -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;
> diff --git a/arch/arm/mach-snapdragon/qcom-priv.h b/arch/arm/mach-snapdragon/qcom-priv.h
> index 74d39197b89f4e769299b06214c26ee829ecdce0..4f398e2ba374f27811afd2ccf6e72037d0f9ee7f 100644
> --- a/arch/arm/mach-snapdragon/qcom-priv.h
> +++ b/arch/arm/mach-snapdragon/qcom-priv.h
> @@ -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__ */
> 



More information about the U-Boot mailing list