event: add an event for livetree fixups
PATCH 1/1 event: add an event for livetree fixups
Introduce a new EVT_OF_LIVE event to allow for the livetree to be modified before dm_init_and_scan(). Boards can perform fixups here to handle incompatibilities between U-Boot drivers and upstream DT.
This will be used by Qualcomm platforms in future patches to enable setting the dr_mode property if the board doesn't provide one. This has to be set before dm_init_and_scan() is called as this property effects the binding of drivers.
--- common/board_r.c | 1 + common/event.c | 2 ++ include/event.h | 12 ++++++++++++ 3 files changed, 15 insertions(+)
common/board_r.c +1 -0
@@ -217,8 +217,9 @@ static int initr_of_live(void) (struct device_node **)gd_of_root_ptr());bootstage_accum (BOOTSTAGE_ID_ACCUM_OF_LIVE );if (ret)return ret; +event_notify_null (EVT_OF_LIVE ); }return 0 ; }
common/event.c +2 -0
@@ -45,8 +45,10 @@ const char *const type_name[] = {/* fdt hooks */ "ft_fixup" , +"of_live" , +/* main loop events */ "main_loop", };
include/event.h +12 -0
@@ -144,8 +144,20 @@ enum event_t {* images fail. */ EVT_FT_FIXUP , +/** +* @EVT_OF_LIVE: +* This event is triggered when using CONFIG_OF_LIVE immediately after +* the live tree has been created. It has no parameters, the live tree +* can be accessed from gd->of_root, or using the of_* helpers. +* +* This is intended to be used for performing board specific fixups +* on the tree before it is used by U-Boot. It is much more efficient +* to access and modify than the FDT. +*/ + EVT_OF_LIVE, +/** * @EVT_MAIN_LOOP: * This event is triggered immediately before calling main_loop() which * is the entry point of the command line. Its parameter is NULL.
Signature · 1 line
2.44.0
Quoted 8 lines · Caleb Connolly
Introduce a new
EVT_OF_LIVEevent to allow for the livetree to be modified beforedm_init_and_scan(). Boards can perform fixups here to handle incompatibilities between U-Boot drivers and upstream DT.This will be used by Qualcomm platforms in future patches to enable setting the
dr_modeproperty if the board doesn't provide one. This has to be set beforedm_init_and_scan()is called as this property effects the binding of drivers.
This doesn't quite explain why the answer isn't "fix the device tree source" and instead "perform a live fixup". Thanks.
Signature · 1 line
Tom
Quoted 6 lines · Tom Rini
Quoted 4 lines · Caleb Connolly
Introduce a new
EVT_OF_LIVEevent to allow for the livetree to be modified beforedm_init_and_scan(). Boards can perform fixups here to handle incompatibilities between U-Boot drivers and upstream DT.
Quoted 7 lines
Quoted 4 lines
This will be used by Qualcomm platforms in future patches to enable setting the
dr_modeproperty if the board doesn't provide one. This has to be set beforedm_init_and_scan()is called as this property effects the binding of drivers.This doesn't quite explain why the answer isn't "fix the device tree source" and instead "perform a live fixup". Thanks.
Hi Tom,
I think the specifics here that make this difficult is that on some Qualcomm boards there is only one USB controller, which can be muxed either to a type-c port or to a USB hub via a DIP switch (the state of which cannot easily be read out).
The DT should therefore either not set dr_mode or set it to OTG. This is what Linux expects (and it can do proper role detection).
The dwc3 driver in U-Boot currently doesn't have the ability to dynamically mode switch, this is something I'd like to add (as it would let us easily flash these boards from U-Boot as well as boot from USB or ethernet), but in the mean time the only way to get these boards into host mode (which is the preferred default) is to modify the DT in a way that breaks Linux.
Hence the proposal in this patch.
If this is ok for you then I'll re-send with this additional context in the commit description.
Thanks and regards,
Signature · 1 line
// Caleb (they/them)
Quoted 34 lines · Caleb Connolly
Quoted 6 lines · Tom Rini
Quoted 4 lines · Caleb Connolly
Introduce a new
EVT_OF_LIVEevent to allow for the livetree to be modified beforedm_init_and_scan(). Boards can perform fixups here to handle incompatibilities between U-Boot drivers and upstream DT.Quoted 7 lines
Quoted 4 lines
This will be used by Qualcomm platforms in future patches to enable setting the
dr_modeproperty if the board doesn't provide one. This has to be set beforedm_init_and_scan()is called as this property effects the binding of drivers.This doesn't quite explain why the answer isn't "fix the device tree source" and instead "perform a live fixup". Thanks.
Hi Tom,
I think the specifics here that make this difficult is that on some Qualcomm boards there is only one USB controller, which can be muxed either to a type-c port or to a USB hub via a DIP switch (the state of which cannot easily be read out).
The DT should therefore either not set
dr_modeor set it to OTG. This is what Linux expects (and it can do proper role detection).The dwc3 driver in U-Boot currently doesn't have the ability to dynamically mode switch, this is something I'd like to add (as it would let us easily flash these boards from U-Boot as well as boot from USB or ethernet), but in the mean time the only way to get these boards into host mode (which is the preferred default) is to modify the DT in a way that breaks Linux.
Quoted 4 lines
Hence the proposal in this patch.
If this is ok for you then I'll re-send with this additional context in the commit description.
So this seems even more special cased than what I was thinking it was. Would it really be so hard to just add a dummy driver for a few compatibles in this case? I prefer having two or three real users of a use case before designing the abstraction for it. Thanks.
Signature · 1 line
Tom