On 5/19/20 3:45 PM, Bin Meng wrote: > On Tue, May 19, 2020 at 9:43 PM Marek Vasut <marek.va...@gmail.com> wrote: >> >> On 5/19/20 3:33 PM, Bin Meng wrote: >>> On Tue, May 19, 2020 at 8:40 PM Marek Vasut <marek.va...@gmail.com> wrote: >>>> >>>> Add weak function which is called right after fdtdec_setup() configured >>>> the U-Boot DT. This permits board-specific adjustments to the U-Boot DT >>>> before U-Boot starts parsing the DT. This could be used e.g. to patch in >>>> various custom nodes or merge in DT fragments from prior-stage firmware. >>>> >>>> Signed-off-by: Marek Vasut <marek.vasut+rene...@gmail.com> >>>> Cc: Nobuhiro Iwamatsu <iwama...@nigauri.org> >>>> Cc: Simon Glass <s...@chromium.org> >>>> Cc: Tom Rini <tr...@konsulko.com> >>>> --- >>>> V2: Add the function to fdtdec.h >>>> --- >>>> include/fdtdec.h | 5 +++++ >>>> lib/fdtdec.c | 11 ++++++++++- >>>> 2 files changed, 15 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/include/fdtdec.h b/include/fdtdec.h >>>> index 166f29c55b..abd6d42671 100644 >>>> --- a/include/fdtdec.h >>>> +++ b/include/fdtdec.h >>>> @@ -1155,6 +1155,11 @@ int fdtdec_set_carveout(void *blob, const char >>>> *node, const char *prop_name, >>>> */ >>>> int fdtdec_setup(void); >>>> >>>> +/** >>>> + * Perform board-specific early DT adjustments >>>> + */ >>>> +int fdtdec_board_setup(const void *fdt_blob); >>>> + >>>> #if CONFIG_IS_ENABLED(MULTI_DTB_FIT) >>>> /** >>>> * fdtdec_resetup() - Set up the device tree again >>>> diff --git a/lib/fdtdec.c b/lib/fdtdec.c >>>> index 0a3b860782..f366dcedb8 100644 >>>> --- a/lib/fdtdec.c >>>> +++ b/lib/fdtdec.c >>>> @@ -1472,8 +1472,14 @@ int fdtdec_set_carveout(void *blob, const char >>>> *node, const char *prop_name, >>>> return 0; >>>> } >>>> >>>> +__weak int fdtdec_board_setup(const void *fdt_blob) >>>> +{ >>>> + return 0; >>>> +} >>>> + >>>> int fdtdec_setup(void) >>>> { >>>> + int ret; >>>> #if CONFIG_IS_ENABLED(OF_CONTROL) >>>> # if CONFIG_IS_ENABLED(MULTI_DTB_FIT) >>>> void *fdt_blob; >>>> @@ -1526,7 +1532,10 @@ int fdtdec_setup(void) >>>> # endif >>>> #endif >>>> >>>> - return fdtdec_prepare_fdt(); >>>> + ret = fdtdec_prepare_fdt(); >>>> + if (!ret) >>>> + ret = fdtdec_board_setup(gd->fdt_blob); >>>> + return ret; >>>> } >>> >>> There is already a CONFIG_OF_BOARD_FIXUP (fix_fdt) in board_f.c >>> >>> Should we consider moving that into fdtdec_setup()? >> >> This one is run much earlier and this is the only fitting location. > > I know. I was asking should we move the existing one into > fdtdec_setup(). The basically do the same.
Sure, send a patch, but let's do that after the release to avoid breakage. I suspect there are various cornercases just waiting to be triggered. -- Best regards, Marek Vasut