Re: [RFC PATCH] dts: automatically build necessary .dtb files

2022-02-08 Thread Simon Glass
On Tue, 8 Feb 2022 at 08:15, Simon Glass  wrote:
>
> On Mon, 24 Jan 2022 at 14:15, Rasmus Villemoes
>  wrote:
> >
> > On 24/01/2022 18.57, Simon Glass wrote:
> > > Hi,
> > >
> > > On Mon, 24 Jan 2022 at 09:02, Tom Rini  wrote:
> > >>
> > >> On Mon, Jan 10, 2022 at 02:34:41PM +0100, Rasmus Villemoes wrote:
> > >>
> > >>> When building for a custom board, it is quite common to maintain a
> > >>> private branch which include some defconfig and .dts files. But to
> > >>> hook up those .dts files requires modifying a file "belonging" to
> > >>> upstream U-Boot, the arch/*/dts/Makefile. Forward-porting that branch
> > >>> to a newer upstream then often results in a conflict which, while it
> > >>> is trivial to resolve by hand, makes it harder to have a CI do "try to
> > >>> build our board against latest upstream".
> > >>>
> > >>> The .config usually includes information on precisely what .dtb(s) are
> > >>> needed, so to avoid having to modify the Makefile, simply add the
> > >>> files in (SPL_)OF_LIST to dtb-y.
> > >>>
> > >>> A technicality is that (SPL_)OF_LIST is not always defined, so rework
> > >>> the Kconfig symbols so that (SPL_)OF_LIST is always defined (when
> > >>> (SPL_)OF_CONTROL), but only prompted for in the cases which used to be
> > >>> their "depends on".
> > >>>
> > >>> nios2 and microblaze already have something like this in their
> > >>> dts/Makefile, and the rationale in commit 41f59f68539 is similar to
> > >>> the above. So this simply generalizes existing practice. Followup
> > >>> patches could remove the logic in those two makefiles, just as there's
> > >>> potential for moving some common boilerplate from all the
> > >>> arch/*/dts/Makefile files to the new scripts/Makefile.dts.
> > >>>
> > >>> Signed-off-by: Rasmus Villemoes 
> > >>> ---
> > >>>  arch/arc/dts/Makefile| 2 ++
> > >>>  arch/arm/dts/Makefile| 2 ++
> > >>>  arch/m68k/dts/Makefile   | 2 ++
> > >>>  arch/microblaze/dts/Makefile | 2 ++
> > >>>  arch/mips/dts/Makefile   | 2 ++
> > >>>  arch/nds32/dts/Makefile  | 2 ++
> > >>>  arch/nios2/dts/Makefile  | 2 ++
> > >>>  arch/powerpc/dts/Makefile| 2 ++
> > >>>  arch/riscv/dts/Makefile  | 2 ++
> > >>>  arch/sandbox/dts/Makefile| 2 ++
> > >>>  arch/sh/dts/Makefile | 2 ++
> > >>>  arch/x86/dts/Makefile| 2 ++
> > >>>  arch/xtensa/dts/Makefile | 2 ++
> > >>>  dts/Kconfig  | 8 
> > >>>  scripts/Makefile.dts | 3 +++
> > >>>  15 files changed, 33 insertions(+), 4 deletions(-)
> > >>>  create mode 100644 scripts/Makefile.dts
>
> Reviewed-by: Simon Glass 

Applied to u-boot-dm, thanks!


Re: [RFC PATCH] dts: automatically build necessary .dtb files

2022-02-08 Thread Simon Glass
On Mon, 24 Jan 2022 at 14:15, Rasmus Villemoes
 wrote:
>
> On 24/01/2022 18.57, Simon Glass wrote:
> > Hi,
> >
> > On Mon, 24 Jan 2022 at 09:02, Tom Rini  wrote:
> >>
> >> On Mon, Jan 10, 2022 at 02:34:41PM +0100, Rasmus Villemoes wrote:
> >>
> >>> When building for a custom board, it is quite common to maintain a
> >>> private branch which include some defconfig and .dts files. But to
> >>> hook up those .dts files requires modifying a file "belonging" to
> >>> upstream U-Boot, the arch/*/dts/Makefile. Forward-porting that branch
> >>> to a newer upstream then often results in a conflict which, while it
> >>> is trivial to resolve by hand, makes it harder to have a CI do "try to
> >>> build our board against latest upstream".
> >>>
> >>> The .config usually includes information on precisely what .dtb(s) are
> >>> needed, so to avoid having to modify the Makefile, simply add the
> >>> files in (SPL_)OF_LIST to dtb-y.
> >>>
> >>> A technicality is that (SPL_)OF_LIST is not always defined, so rework
> >>> the Kconfig symbols so that (SPL_)OF_LIST is always defined (when
> >>> (SPL_)OF_CONTROL), but only prompted for in the cases which used to be
> >>> their "depends on".
> >>>
> >>> nios2 and microblaze already have something like this in their
> >>> dts/Makefile, and the rationale in commit 41f59f68539 is similar to
> >>> the above. So this simply generalizes existing practice. Followup
> >>> patches could remove the logic in those two makefiles, just as there's
> >>> potential for moving some common boilerplate from all the
> >>> arch/*/dts/Makefile files to the new scripts/Makefile.dts.
> >>>
> >>> Signed-off-by: Rasmus Villemoes 
> >>> ---
> >>>  arch/arc/dts/Makefile| 2 ++
> >>>  arch/arm/dts/Makefile| 2 ++
> >>>  arch/m68k/dts/Makefile   | 2 ++
> >>>  arch/microblaze/dts/Makefile | 2 ++
> >>>  arch/mips/dts/Makefile   | 2 ++
> >>>  arch/nds32/dts/Makefile  | 2 ++
> >>>  arch/nios2/dts/Makefile  | 2 ++
> >>>  arch/powerpc/dts/Makefile| 2 ++
> >>>  arch/riscv/dts/Makefile  | 2 ++
> >>>  arch/sandbox/dts/Makefile| 2 ++
> >>>  arch/sh/dts/Makefile | 2 ++
> >>>  arch/x86/dts/Makefile| 2 ++
> >>>  arch/xtensa/dts/Makefile | 2 ++
> >>>  dts/Kconfig  | 8 
> >>>  scripts/Makefile.dts | 3 +++
> >>>  15 files changed, 33 insertions(+), 4 deletions(-)
> >>>  create mode 100644 scripts/Makefile.dts

Reviewed-by: Simon Glass 


Re: [RFC PATCH] dts: automatically build necessary .dtb files

2022-01-24 Thread Rasmus Villemoes
On 24/01/2022 18.57, Simon Glass wrote:
> Hi,
> 
> On Mon, 24 Jan 2022 at 09:02, Tom Rini  wrote:
>>
>> On Mon, Jan 10, 2022 at 02:34:41PM +0100, Rasmus Villemoes wrote:
>>
>>> When building for a custom board, it is quite common to maintain a
>>> private branch which include some defconfig and .dts files. But to
>>> hook up those .dts files requires modifying a file "belonging" to
>>> upstream U-Boot, the arch/*/dts/Makefile. Forward-porting that branch
>>> to a newer upstream then often results in a conflict which, while it
>>> is trivial to resolve by hand, makes it harder to have a CI do "try to
>>> build our board against latest upstream".
>>>
>>> The .config usually includes information on precisely what .dtb(s) are
>>> needed, so to avoid having to modify the Makefile, simply add the
>>> files in (SPL_)OF_LIST to dtb-y.
>>>
>>> A technicality is that (SPL_)OF_LIST is not always defined, so rework
>>> the Kconfig symbols so that (SPL_)OF_LIST is always defined (when
>>> (SPL_)OF_CONTROL), but only prompted for in the cases which used to be
>>> their "depends on".
>>>
>>> nios2 and microblaze already have something like this in their
>>> dts/Makefile, and the rationale in commit 41f59f68539 is similar to
>>> the above. So this simply generalizes existing practice. Followup
>>> patches could remove the logic in those two makefiles, just as there's
>>> potential for moving some common boilerplate from all the
>>> arch/*/dts/Makefile files to the new scripts/Makefile.dts.
>>>
>>> Signed-off-by: Rasmus Villemoes 
>>> ---
>>>  arch/arc/dts/Makefile| 2 ++
>>>  arch/arm/dts/Makefile| 2 ++
>>>  arch/m68k/dts/Makefile   | 2 ++
>>>  arch/microblaze/dts/Makefile | 2 ++
>>>  arch/mips/dts/Makefile   | 2 ++
>>>  arch/nds32/dts/Makefile  | 2 ++
>>>  arch/nios2/dts/Makefile  | 2 ++
>>>  arch/powerpc/dts/Makefile| 2 ++
>>>  arch/riscv/dts/Makefile  | 2 ++
>>>  arch/sandbox/dts/Makefile| 2 ++
>>>  arch/sh/dts/Makefile | 2 ++
>>>  arch/x86/dts/Makefile| 2 ++
>>>  arch/xtensa/dts/Makefile | 2 ++
>>>  dts/Kconfig  | 8 
>>>  scripts/Makefile.dts | 3 +++
>>>  15 files changed, 33 insertions(+), 4 deletions(-)
>>>  create mode 100644 scripts/Makefile.dts
>>>
>>> diff --git a/arch/arc/dts/Makefile b/arch/arc/dts/Makefile
>>> index 515fe1fe53..532a8131c5 100644
>>> --- a/arch/arc/dts/Makefile
>>> +++ b/arch/arc/dts/Makefile
>>> @@ -8,6 +8,8 @@ dtb-$(CONFIG_TARGET_EMSDP) +=  emsdp.dtb
>>>  dtb-$(CONFIG_TARGET_HSDK) +=  hsdk.dtb hsdk-4xd.dtb
>>>  dtb-$(CONFIG_TARGET_IOT_DEVKIT) +=  iot_devkit.dtb
>>>
>>> +include $(srctree)/scripts/Makefile.dts
>>> +
>>>  targets += $(dtb-y)
>>>
>>>  DTC_FLAGS += -R 4 -p 0x1000
>>> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
>>> index b3e2a9c9d7..ef58be0381 100644
>>> --- a/arch/arm/dts/Makefile
>>> +++ b/arch/arm/dts/Makefile
>>> @@ -1163,6 +1163,8 @@ dtb-$(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE) += 
>>> imx8mm-cl-iot-gate-optee.dtb
>>>
>>>  dtb-$(CONFIG_TARGET_EA_LPC3250DEVKITV2) += lpc3250-ea3250.dtb
>>>
>>> +include $(srctree)/scripts/Makefile.dts
>>> +
>>>  targets += $(dtb-y)
>>>
>>>  # Add any required device tree compiler flags here
>>> diff --git a/arch/m68k/dts/Makefile b/arch/m68k/dts/Makefile
>>> index fdd435bc34..7988522eb9 100644
>>> --- a/arch/m68k/dts/Makefile
>>> +++ b/arch/m68k/dts/Makefile
>>> @@ -18,6 +18,8 @@ dtb-$(CONFIG_TARGET_M5373EVB) += M5373EVB.dtb
>>>  dtb-$(CONFIG_TARGET_AMCORE) += amcore.dtb
>>>  dtb-$(CONFIG_TARGET_STMARK2) += stmark2.dtb
>>>
>>> +include $(srctree)/scripts/Makefile.dts
>>> +
>>>  targets += $(dtb-y)
>>>
>>>  DTC_FLAGS += -R 4 -p 0x1000
>>> diff --git a/arch/microblaze/dts/Makefile b/arch/microblaze/dts/Makefile
>>> index 4690dc1b9f..427a8f9aac 100644
>>> --- a/arch/microblaze/dts/Makefile
>>> +++ b/arch/microblaze/dts/Makefile
>>> @@ -2,6 +2,8 @@
>>>
>>>  dtb-y += $(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)).dtb
>>>
>>> +include $(srctree)/scripts/Makefile.dts
>>> +
>>>  targets += $(dtb-y)
>>>
>>>  DTC_FLAGS += -R 4 -p 0x1000
>>> diff --git a/arch/mips/dts/Makefile b/arch/mips/dts/Makefile
>>> index 215283cfa0..95144b24dc 100644
>>> --- a/arch/mips/dts/Makefile
>>> +++ b/arch/mips/dts/Makefile
>>> @@ -34,6 +34,8 @@ dtb-$(CONFIG_SOC_JR2) += jr2_pcb110.dtb jr2_pcb111.dtb 
>>> serval2_pcb112.dtb
>>>  dtb-$(CONFIG_SOC_SERVALT) += servalt_pcb116.dtb
>>>  dtb-$(CONFIG_SOC_SERVAL) += serval_pcb105.dtb serval_pcb106.dtb
>>>
>>> +include $(srctree)/scripts/Makefile.dts
>>> +
>>>  targets += $(dtb-y)
>>>
>>>  # Add any required device tree compiler flags here
>>> diff --git a/arch/nds32/dts/Makefile b/arch/nds32/dts/Makefile
>>> index a8e23ad9ad..5a09e3b45b 100644
>>> --- a/arch/nds32/dts/Makefile
>>> +++ b/arch/nds32/dts/Makefile
>>> @@ -2,6 +2,8 @@
>>>
>>>  dtb-$(CONFIG_TARGET_ADP_AG101P) += ag101p.dtb
>>>  dtb-$(CONFIG_TARGET_ADP_AE3XX) += ae3xx.dtb
>>> +include $(srctree)/scripts/Makefile.dts
>>> +
>>>  targets += $(dtb-y)
>>>
>>>  DTC_FLAGS +

Re: [RFC PATCH] dts: automatically build necessary .dtb files

2022-01-24 Thread Simon Glass
Hi,

On Mon, 24 Jan 2022 at 09:02, Tom Rini  wrote:
>
> On Mon, Jan 10, 2022 at 02:34:41PM +0100, Rasmus Villemoes wrote:
>
> > When building for a custom board, it is quite common to maintain a
> > private branch which include some defconfig and .dts files. But to
> > hook up those .dts files requires modifying a file "belonging" to
> > upstream U-Boot, the arch/*/dts/Makefile. Forward-porting that branch
> > to a newer upstream then often results in a conflict which, while it
> > is trivial to resolve by hand, makes it harder to have a CI do "try to
> > build our board against latest upstream".
> >
> > The .config usually includes information on precisely what .dtb(s) are
> > needed, so to avoid having to modify the Makefile, simply add the
> > files in (SPL_)OF_LIST to dtb-y.
> >
> > A technicality is that (SPL_)OF_LIST is not always defined, so rework
> > the Kconfig symbols so that (SPL_)OF_LIST is always defined (when
> > (SPL_)OF_CONTROL), but only prompted for in the cases which used to be
> > their "depends on".
> >
> > nios2 and microblaze already have something like this in their
> > dts/Makefile, and the rationale in commit 41f59f68539 is similar to
> > the above. So this simply generalizes existing practice. Followup
> > patches could remove the logic in those two makefiles, just as there's
> > potential for moving some common boilerplate from all the
> > arch/*/dts/Makefile files to the new scripts/Makefile.dts.
> >
> > Signed-off-by: Rasmus Villemoes 
> > ---
> >  arch/arc/dts/Makefile| 2 ++
> >  arch/arm/dts/Makefile| 2 ++
> >  arch/m68k/dts/Makefile   | 2 ++
> >  arch/microblaze/dts/Makefile | 2 ++
> >  arch/mips/dts/Makefile   | 2 ++
> >  arch/nds32/dts/Makefile  | 2 ++
> >  arch/nios2/dts/Makefile  | 2 ++
> >  arch/powerpc/dts/Makefile| 2 ++
> >  arch/riscv/dts/Makefile  | 2 ++
> >  arch/sandbox/dts/Makefile| 2 ++
> >  arch/sh/dts/Makefile | 2 ++
> >  arch/x86/dts/Makefile| 2 ++
> >  arch/xtensa/dts/Makefile | 2 ++
> >  dts/Kconfig  | 8 
> >  scripts/Makefile.dts | 3 +++
> >  15 files changed, 33 insertions(+), 4 deletions(-)
> >  create mode 100644 scripts/Makefile.dts
> >
> > diff --git a/arch/arc/dts/Makefile b/arch/arc/dts/Makefile
> > index 515fe1fe53..532a8131c5 100644
> > --- a/arch/arc/dts/Makefile
> > +++ b/arch/arc/dts/Makefile
> > @@ -8,6 +8,8 @@ dtb-$(CONFIG_TARGET_EMSDP) +=  emsdp.dtb
> >  dtb-$(CONFIG_TARGET_HSDK) +=  hsdk.dtb hsdk-4xd.dtb
> >  dtb-$(CONFIG_TARGET_IOT_DEVKIT) +=  iot_devkit.dtb
> >
> > +include $(srctree)/scripts/Makefile.dts
> > +
> >  targets += $(dtb-y)
> >
> >  DTC_FLAGS += -R 4 -p 0x1000
> > diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> > index b3e2a9c9d7..ef58be0381 100644
> > --- a/arch/arm/dts/Makefile
> > +++ b/arch/arm/dts/Makefile
> > @@ -1163,6 +1163,8 @@ dtb-$(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE) += 
> > imx8mm-cl-iot-gate-optee.dtb
> >
> >  dtb-$(CONFIG_TARGET_EA_LPC3250DEVKITV2) += lpc3250-ea3250.dtb
> >
> > +include $(srctree)/scripts/Makefile.dts
> > +
> >  targets += $(dtb-y)
> >
> >  # Add any required device tree compiler flags here
> > diff --git a/arch/m68k/dts/Makefile b/arch/m68k/dts/Makefile
> > index fdd435bc34..7988522eb9 100644
> > --- a/arch/m68k/dts/Makefile
> > +++ b/arch/m68k/dts/Makefile
> > @@ -18,6 +18,8 @@ dtb-$(CONFIG_TARGET_M5373EVB) += M5373EVB.dtb
> >  dtb-$(CONFIG_TARGET_AMCORE) += amcore.dtb
> >  dtb-$(CONFIG_TARGET_STMARK2) += stmark2.dtb
> >
> > +include $(srctree)/scripts/Makefile.dts
> > +
> >  targets += $(dtb-y)
> >
> >  DTC_FLAGS += -R 4 -p 0x1000
> > diff --git a/arch/microblaze/dts/Makefile b/arch/microblaze/dts/Makefile
> > index 4690dc1b9f..427a8f9aac 100644
> > --- a/arch/microblaze/dts/Makefile
> > +++ b/arch/microblaze/dts/Makefile
> > @@ -2,6 +2,8 @@
> >
> >  dtb-y += $(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)).dtb
> >
> > +include $(srctree)/scripts/Makefile.dts
> > +
> >  targets += $(dtb-y)
> >
> >  DTC_FLAGS += -R 4 -p 0x1000
> > diff --git a/arch/mips/dts/Makefile b/arch/mips/dts/Makefile
> > index 215283cfa0..95144b24dc 100644
> > --- a/arch/mips/dts/Makefile
> > +++ b/arch/mips/dts/Makefile
> > @@ -34,6 +34,8 @@ dtb-$(CONFIG_SOC_JR2) += jr2_pcb110.dtb jr2_pcb111.dtb 
> > serval2_pcb112.dtb
> >  dtb-$(CONFIG_SOC_SERVALT) += servalt_pcb116.dtb
> >  dtb-$(CONFIG_SOC_SERVAL) += serval_pcb105.dtb serval_pcb106.dtb
> >
> > +include $(srctree)/scripts/Makefile.dts
> > +
> >  targets += $(dtb-y)
> >
> >  # Add any required device tree compiler flags here
> > diff --git a/arch/nds32/dts/Makefile b/arch/nds32/dts/Makefile
> > index a8e23ad9ad..5a09e3b45b 100644
> > --- a/arch/nds32/dts/Makefile
> > +++ b/arch/nds32/dts/Makefile
> > @@ -2,6 +2,8 @@
> >
> >  dtb-$(CONFIG_TARGET_ADP_AG101P) += ag101p.dtb
> >  dtb-$(CONFIG_TARGET_ADP_AE3XX) += ae3xx.dtb
> > +include $(srctree)/scripts/Makefile.dts
> > +
> >  targets += $(dtb-y)
> >
> >  DTC_FLAGS += -R 4 -p 0x1000
> > diff --git a/arch/nios2/dts/

Re: [RFC PATCH] dts: automatically build necessary .dtb files

2022-01-24 Thread Tom Rini
On Mon, Jan 10, 2022 at 02:34:41PM +0100, Rasmus Villemoes wrote:

> When building for a custom board, it is quite common to maintain a
> private branch which include some defconfig and .dts files. But to
> hook up those .dts files requires modifying a file "belonging" to
> upstream U-Boot, the arch/*/dts/Makefile. Forward-porting that branch
> to a newer upstream then often results in a conflict which, while it
> is trivial to resolve by hand, makes it harder to have a CI do "try to
> build our board against latest upstream".
> 
> The .config usually includes information on precisely what .dtb(s) are
> needed, so to avoid having to modify the Makefile, simply add the
> files in (SPL_)OF_LIST to dtb-y.
> 
> A technicality is that (SPL_)OF_LIST is not always defined, so rework
> the Kconfig symbols so that (SPL_)OF_LIST is always defined (when
> (SPL_)OF_CONTROL), but only prompted for in the cases which used to be
> their "depends on".
> 
> nios2 and microblaze already have something like this in their
> dts/Makefile, and the rationale in commit 41f59f68539 is similar to
> the above. So this simply generalizes existing practice. Followup
> patches could remove the logic in those two makefiles, just as there's
> potential for moving some common boilerplate from all the
> arch/*/dts/Makefile files to the new scripts/Makefile.dts.
> 
> Signed-off-by: Rasmus Villemoes 
> ---
>  arch/arc/dts/Makefile| 2 ++
>  arch/arm/dts/Makefile| 2 ++
>  arch/m68k/dts/Makefile   | 2 ++
>  arch/microblaze/dts/Makefile | 2 ++
>  arch/mips/dts/Makefile   | 2 ++
>  arch/nds32/dts/Makefile  | 2 ++
>  arch/nios2/dts/Makefile  | 2 ++
>  arch/powerpc/dts/Makefile| 2 ++
>  arch/riscv/dts/Makefile  | 2 ++
>  arch/sandbox/dts/Makefile| 2 ++
>  arch/sh/dts/Makefile | 2 ++
>  arch/x86/dts/Makefile| 2 ++
>  arch/xtensa/dts/Makefile | 2 ++
>  dts/Kconfig  | 8 
>  scripts/Makefile.dts | 3 +++
>  15 files changed, 33 insertions(+), 4 deletions(-)
>  create mode 100644 scripts/Makefile.dts
> 
> diff --git a/arch/arc/dts/Makefile b/arch/arc/dts/Makefile
> index 515fe1fe53..532a8131c5 100644
> --- a/arch/arc/dts/Makefile
> +++ b/arch/arc/dts/Makefile
> @@ -8,6 +8,8 @@ dtb-$(CONFIG_TARGET_EMSDP) +=  emsdp.dtb
>  dtb-$(CONFIG_TARGET_HSDK) +=  hsdk.dtb hsdk-4xd.dtb
>  dtb-$(CONFIG_TARGET_IOT_DEVKIT) +=  iot_devkit.dtb
>  
> +include $(srctree)/scripts/Makefile.dts
> +
>  targets += $(dtb-y)
>  
>  DTC_FLAGS += -R 4 -p 0x1000
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index b3e2a9c9d7..ef58be0381 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -1163,6 +1163,8 @@ dtb-$(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE) += 
> imx8mm-cl-iot-gate-optee.dtb
>  
>  dtb-$(CONFIG_TARGET_EA_LPC3250DEVKITV2) += lpc3250-ea3250.dtb
>  
> +include $(srctree)/scripts/Makefile.dts
> +
>  targets += $(dtb-y)
>  
>  # Add any required device tree compiler flags here
> diff --git a/arch/m68k/dts/Makefile b/arch/m68k/dts/Makefile
> index fdd435bc34..7988522eb9 100644
> --- a/arch/m68k/dts/Makefile
> +++ b/arch/m68k/dts/Makefile
> @@ -18,6 +18,8 @@ dtb-$(CONFIG_TARGET_M5373EVB) += M5373EVB.dtb
>  dtb-$(CONFIG_TARGET_AMCORE) += amcore.dtb
>  dtb-$(CONFIG_TARGET_STMARK2) += stmark2.dtb
>  
> +include $(srctree)/scripts/Makefile.dts
> +
>  targets += $(dtb-y)
>  
>  DTC_FLAGS += -R 4 -p 0x1000
> diff --git a/arch/microblaze/dts/Makefile b/arch/microblaze/dts/Makefile
> index 4690dc1b9f..427a8f9aac 100644
> --- a/arch/microblaze/dts/Makefile
> +++ b/arch/microblaze/dts/Makefile
> @@ -2,6 +2,8 @@
>  
>  dtb-y += $(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)).dtb
>  
> +include $(srctree)/scripts/Makefile.dts
> +
>  targets += $(dtb-y)
>  
>  DTC_FLAGS += -R 4 -p 0x1000
> diff --git a/arch/mips/dts/Makefile b/arch/mips/dts/Makefile
> index 215283cfa0..95144b24dc 100644
> --- a/arch/mips/dts/Makefile
> +++ b/arch/mips/dts/Makefile
> @@ -34,6 +34,8 @@ dtb-$(CONFIG_SOC_JR2) += jr2_pcb110.dtb jr2_pcb111.dtb 
> serval2_pcb112.dtb
>  dtb-$(CONFIG_SOC_SERVALT) += servalt_pcb116.dtb
>  dtb-$(CONFIG_SOC_SERVAL) += serval_pcb105.dtb serval_pcb106.dtb
>  
> +include $(srctree)/scripts/Makefile.dts
> +
>  targets += $(dtb-y)
>  
>  # Add any required device tree compiler flags here
> diff --git a/arch/nds32/dts/Makefile b/arch/nds32/dts/Makefile
> index a8e23ad9ad..5a09e3b45b 100644
> --- a/arch/nds32/dts/Makefile
> +++ b/arch/nds32/dts/Makefile
> @@ -2,6 +2,8 @@
>  
>  dtb-$(CONFIG_TARGET_ADP_AG101P) += ag101p.dtb
>  dtb-$(CONFIG_TARGET_ADP_AE3XX) += ae3xx.dtb
> +include $(srctree)/scripts/Makefile.dts
> +
>  targets += $(dtb-y)
>  
>  DTC_FLAGS += -R 4 -p 0x1000
> diff --git a/arch/nios2/dts/Makefile b/arch/nios2/dts/Makefile
> index 0014acfdfb..2b29fa90f6 100644
> --- a/arch/nios2/dts/Makefile
> +++ b/arch/nios2/dts/Makefile
> @@ -2,6 +2,8 @@
>  
>  dtb-y += $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%).dtb
>  
> +include $(srctree)/scripts/Makefile.dts
> +
>  targets +

[RFC PATCH] dts: automatically build necessary .dtb files

2022-01-10 Thread Rasmus Villemoes
When building for a custom board, it is quite common to maintain a
private branch which include some defconfig and .dts files. But to
hook up those .dts files requires modifying a file "belonging" to
upstream U-Boot, the arch/*/dts/Makefile. Forward-porting that branch
to a newer upstream then often results in a conflict which, while it
is trivial to resolve by hand, makes it harder to have a CI do "try to
build our board against latest upstream".

The .config usually includes information on precisely what .dtb(s) are
needed, so to avoid having to modify the Makefile, simply add the
files in (SPL_)OF_LIST to dtb-y.

A technicality is that (SPL_)OF_LIST is not always defined, so rework
the Kconfig symbols so that (SPL_)OF_LIST is always defined (when
(SPL_)OF_CONTROL), but only prompted for in the cases which used to be
their "depends on".

nios2 and microblaze already have something like this in their
dts/Makefile, and the rationale in commit 41f59f68539 is similar to
the above. So this simply generalizes existing practice. Followup
patches could remove the logic in those two makefiles, just as there's
potential for moving some common boilerplate from all the
arch/*/dts/Makefile files to the new scripts/Makefile.dts.

Signed-off-by: Rasmus Villemoes 
---
 arch/arc/dts/Makefile| 2 ++
 arch/arm/dts/Makefile| 2 ++
 arch/m68k/dts/Makefile   | 2 ++
 arch/microblaze/dts/Makefile | 2 ++
 arch/mips/dts/Makefile   | 2 ++
 arch/nds32/dts/Makefile  | 2 ++
 arch/nios2/dts/Makefile  | 2 ++
 arch/powerpc/dts/Makefile| 2 ++
 arch/riscv/dts/Makefile  | 2 ++
 arch/sandbox/dts/Makefile| 2 ++
 arch/sh/dts/Makefile | 2 ++
 arch/x86/dts/Makefile| 2 ++
 arch/xtensa/dts/Makefile | 2 ++
 dts/Kconfig  | 8 
 scripts/Makefile.dts | 3 +++
 15 files changed, 33 insertions(+), 4 deletions(-)
 create mode 100644 scripts/Makefile.dts

diff --git a/arch/arc/dts/Makefile b/arch/arc/dts/Makefile
index 515fe1fe53..532a8131c5 100644
--- a/arch/arc/dts/Makefile
+++ b/arch/arc/dts/Makefile
@@ -8,6 +8,8 @@ dtb-$(CONFIG_TARGET_EMSDP) +=  emsdp.dtb
 dtb-$(CONFIG_TARGET_HSDK) +=  hsdk.dtb hsdk-4xd.dtb
 dtb-$(CONFIG_TARGET_IOT_DEVKIT) +=  iot_devkit.dtb
 
+include $(srctree)/scripts/Makefile.dts
+
 targets += $(dtb-y)
 
 DTC_FLAGS += -R 4 -p 0x1000
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index b3e2a9c9d7..ef58be0381 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1163,6 +1163,8 @@ dtb-$(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE) += 
imx8mm-cl-iot-gate-optee.dtb
 
 dtb-$(CONFIG_TARGET_EA_LPC3250DEVKITV2) += lpc3250-ea3250.dtb
 
+include $(srctree)/scripts/Makefile.dts
+
 targets += $(dtb-y)
 
 # Add any required device tree compiler flags here
diff --git a/arch/m68k/dts/Makefile b/arch/m68k/dts/Makefile
index fdd435bc34..7988522eb9 100644
--- a/arch/m68k/dts/Makefile
+++ b/arch/m68k/dts/Makefile
@@ -18,6 +18,8 @@ dtb-$(CONFIG_TARGET_M5373EVB) += M5373EVB.dtb
 dtb-$(CONFIG_TARGET_AMCORE) += amcore.dtb
 dtb-$(CONFIG_TARGET_STMARK2) += stmark2.dtb
 
+include $(srctree)/scripts/Makefile.dts
+
 targets += $(dtb-y)
 
 DTC_FLAGS += -R 4 -p 0x1000
diff --git a/arch/microblaze/dts/Makefile b/arch/microblaze/dts/Makefile
index 4690dc1b9f..427a8f9aac 100644
--- a/arch/microblaze/dts/Makefile
+++ b/arch/microblaze/dts/Makefile
@@ -2,6 +2,8 @@
 
 dtb-y += $(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)).dtb
 
+include $(srctree)/scripts/Makefile.dts
+
 targets += $(dtb-y)
 
 DTC_FLAGS += -R 4 -p 0x1000
diff --git a/arch/mips/dts/Makefile b/arch/mips/dts/Makefile
index 215283cfa0..95144b24dc 100644
--- a/arch/mips/dts/Makefile
+++ b/arch/mips/dts/Makefile
@@ -34,6 +34,8 @@ dtb-$(CONFIG_SOC_JR2) += jr2_pcb110.dtb jr2_pcb111.dtb 
serval2_pcb112.dtb
 dtb-$(CONFIG_SOC_SERVALT) += servalt_pcb116.dtb
 dtb-$(CONFIG_SOC_SERVAL) += serval_pcb105.dtb serval_pcb106.dtb
 
+include $(srctree)/scripts/Makefile.dts
+
 targets += $(dtb-y)
 
 # Add any required device tree compiler flags here
diff --git a/arch/nds32/dts/Makefile b/arch/nds32/dts/Makefile
index a8e23ad9ad..5a09e3b45b 100644
--- a/arch/nds32/dts/Makefile
+++ b/arch/nds32/dts/Makefile
@@ -2,6 +2,8 @@
 
 dtb-$(CONFIG_TARGET_ADP_AG101P) += ag101p.dtb
 dtb-$(CONFIG_TARGET_ADP_AE3XX) += ae3xx.dtb
+include $(srctree)/scripts/Makefile.dts
+
 targets += $(dtb-y)
 
 DTC_FLAGS += -R 4 -p 0x1000
diff --git a/arch/nios2/dts/Makefile b/arch/nios2/dts/Makefile
index 0014acfdfb..2b29fa90f6 100644
--- a/arch/nios2/dts/Makefile
+++ b/arch/nios2/dts/Makefile
@@ -2,6 +2,8 @@
 
 dtb-y += $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%).dtb
 
+include $(srctree)/scripts/Makefile.dts
+
 targets += $(dtb-y)
 
 DTC_FLAGS += -R 4 -p 0x1000
diff --git a/arch/powerpc/dts/Makefile b/arch/powerpc/dts/Makefile
index ceaa8ce5c8..6f0e4d69f2 100644
--- a/arch/powerpc/dts/Makefile
+++ b/arch/powerpc/dts/Makefile
@@ -29,6 +29,8 @@ dtb-$(CONFIG_TARGET_TUXX1) += kmtuxa1.dtb
 dtb-$(CONFIG_TARGET_MCR3000) += mcr3000.dtb
 dtb-$(CONFIG_TARGET_GA