Re: [PATCH v1 01/17] riscv: cpu: jh7110: Add support for jh7110 SoC

2022-12-27 Thread yanhong wang



On 2022/12/26 21:54, Bin Meng wrote:
> On Mon, Dec 26, 2022 at 3:32 PM yanhong wang
>  wrote:
>>
>>
>>
>> On 2022/12/22 17:22, Bin Meng wrote:
>> > On Mon, Dec 12, 2022 at 10:51 AM Yanhong Wang
>> >  wrote:
>> >>
>> >> Add StarFive JH7110 SoC to support RISC-V arch.
>> >>
>> >> Signed-off-by: Yanhong Wang 
>> >> ---
>> >>  arch/riscv/cpu/jh7110/Makefile| 10 
>> >>  arch/riscv/cpu/jh7110/cpu.c   | 23 
>> >>  arch/riscv/cpu/jh7110/dram.c  | 38 +
>> >>  arch/riscv/cpu/jh7110/spl.c   | 56 +++
>> >>  .../include/asm/arch-jh7110/jh7110-regs.h | 20 +++
>> >>  arch/riscv/include/asm/arch-jh7110/spl.h  | 13 +
>> >>  6 files changed, 160 insertions(+)
>> >>  create mode 100644 arch/riscv/cpu/jh7110/Makefile
>> >>  create mode 100644 arch/riscv/cpu/jh7110/cpu.c
>> >>  create mode 100644 arch/riscv/cpu/jh7110/dram.c
>> >>  create mode 100644 arch/riscv/cpu/jh7110/spl.c
>> >>  create mode 100644 arch/riscv/include/asm/arch-jh7110/jh7110-regs.h
>> >>  create mode 100644 arch/riscv/include/asm/arch-jh7110/spl.h
>> >>
>> >> diff --git a/arch/riscv/cpu/jh7110/Makefile 
>> >> b/arch/riscv/cpu/jh7110/Makefile
>> >> new file mode 100644
>> >> index 00..951c95631e
>> >> --- /dev/null
>> >> +++ b/arch/riscv/cpu/jh7110/Makefile
>> >> @@ -0,0 +1,10 @@
>> >> +# SPDX-License-Identifier: GPL-2.0+
>> >> +#
>> >> +# Copyright (C) 2022 StarFive Technology Co., Ltd.
>> >> +
>> >> +ifeq ($(CONFIG_SPL_BUILD),y)
>> >> +obj-y += spl.o
>> >> +else
>> >> +obj-y += cpu.o
>> >> +obj-y += dram.o
>> >> +endif
>> >> diff --git a/arch/riscv/cpu/jh7110/cpu.c b/arch/riscv/cpu/jh7110/cpu.c
>> >> new file mode 100644
>> >> index 00..5da71908c0
>> >> --- /dev/null
>> >> +++ b/arch/riscv/cpu/jh7110/cpu.c
>> >> @@ -0,0 +1,23 @@
>> >> +// SPDX-License-Identifier: GPL-2.0+
>> >> +/*
>> >> + * Copyright (C) 2022 StarFive Technology Co., Ltd.
>> >> + * Author: Yanhong Wang 
>> >
>> > nits: use space instead of tab between "Author" and the name
>> > please fix this globally.
>> >
>>
>>
>> I will fix.
>> >> + */
>> >> +
>> >> +#include 
>> >> +#include 
>> >> +
>> >> +/*
>> >> + * cleanup_before_linux() is called just before we call linux
>> >> + * it prepares the processor for linux
>> >> + *
>> >> + * we disable interrupt and caches.
>> >> + */
>> >> +int cleanup_before_linux(void)
>> >> +{
>> >> +   disable_interrupts();
>> >> +
>> >> +   cache_flush();
>> >> +
>> >> +   return 0;
>> >> +}
>> >> diff --git a/arch/riscv/cpu/jh7110/dram.c b/arch/riscv/cpu/jh7110/dram.c
>> >> new file mode 100644
>> >> index 00..4ce91aee9d
>> >> --- /dev/null
>> >> +++ b/arch/riscv/cpu/jh7110/dram.c
>> >> @@ -0,0 +1,38 @@
>> >> +// SPDX-License-Identifier: GPL-2.0+
>> >> +/*
>> >> + * Copyright (C) 2022 StarFive Technology Co., Ltd.
>> >> + * Author: Yanhong Wang 
>> >> + */
>> >> +
>> >> +#include 
>> >> +#include 
>> >> +#include 
>> >> +#include 
>> >> +
>> >> +DECLARE_GLOBAL_DATA_PTR;
>> >> +
>> >> +int dram_init(void)
>> >> +{
>> >> +   return fdtdec_setup_mem_size_base();
>> >> +}
>> >> +
>> >> +int dram_init_banksize(void)
>> >> +{
>> >> +   return fdtdec_setup_memory_banksize();
>> >> +}
>> >> +
>> >> +phys_size_t board_get_usable_ram_top(phys_size_t total_size)
>> >> +{
>> >> +   /*
>> >> +* Ensure that we run from first 4GB so that all
>> >> +* addresses used by U-Boot are 32bit addresses.
>> >> +*
>> >> +* This in-turn ensures that 32bit DMA capable
>> >> +* devices work fine because DMA mapping APIs will
>> >> +* provide 32bit DMA addresses only.
>> >> +*/
>> >> +   if (IS_ENABLED(CONFIG_64BIT) && gd->ram_top > SZ_4G)
>> >> +   return SZ_4G;
>> >> +
>> >> +   return gd->ram_top;
>> >> +}
>> >> diff --git a/arch/riscv/cpu/jh7110/spl.c b/arch/riscv/cpu/jh7110/spl.c
>> >> new file mode 100644
>> >> index 00..a0aacacf7b
>> >> --- /dev/null
>> >> +++ b/arch/riscv/cpu/jh7110/spl.c
>> >> @@ -0,0 +1,56 @@
>> >> +// SPDX-License-Identifier: GPL-2.0+
>> >> +/*
>> >> + * Copyright (C) 2022 StarFive Technology Co., Ltd.
>> >> + * Author: Yanhong Wang
>> >> + *
>> >
>> > remove this line
>> >
>>
>> I will fix.
>>
>> >> + */
>> >> +
>> >> +#include 
>> >> +#include 
>> >> +#include 
>> >> +
>> >> +#define CSR_U74_FEATURE_DISABLE0x7c1
>> >> +
>> >> +int spl_soc_init(void)
>> >> +{
>> >> +   int ret;
>> >> +   struct udevice *dev;
>> >> +
>> >> +   /* DDR init */
>> >> +   ret = uclass_get_device(UCLASS_RAM, 0, );
>> >> +   if (ret) {
>> >> +   debug("DRAM init failed: %d\n", ret);
>> >> +   return ret;
>> >> +   }
>> >> +
>> >> +   /* flash init */
>> >> +   ret = uclass_get_device(UCLASS_SPI_FLASH, 0, );
>> >
>> > Why is this needed?
>>
>> This is not necessary. It will be removed in the next version.
>>
>> >
>> >> +   if (ret) {
>> >> +  

Re: [PATCH] riscv: bypass malloc when spl fit boots from ram

2022-12-27 Thread Rick Chen
> On 12/27/22 21:22, Rick Chen wrote:
> > Hi Samuel,
> >
> > Samuel Holland  於 2022年12月28日 週三 上午10:47寫道:
> >>
> >> On 12/22/22 01:21, Rick Chen wrote:
> >>> When fit image boots from ram, the payload will
> >>> be prepared in the address of SPL_LOAD_FIT_ADDRESS.
> >>> In spl fit generic flow, it will malloc another
> >>> memory address and copy whole fit image to this
> >>> malloc address.  But it is un-necessary for booting
> >>> from RAM.
> >>
> >> This should mostly be solved by using `mkimage -E` or binman's
> >> `fit,external-offset`. Then only the FIT structure, without any data,
> >> will be copied.
> >>
> >>> This patch improves this flow by declare the
> >>> board_spl_fit_buffer_addr() to replace the original one.
> >>> The larger image size (eq: Kernel Image 10~20MB), it
> >>> can save more booting time.
> >>>
> >>> Also enhance memcpy function by checking source and
> >>> destination address. If they are the same address,
> >>> just return and don't copy data anymore.
> >>>
> >>> Signed-off-by: Rick Chen 
> >>> ---
> >>>  arch/riscv/lib/memcpy.S |  2 ++
> >>>  arch/riscv/lib/spl.c| 16 
> >>>  2 files changed, 18 insertions(+)
> >>>
> >>> diff --git a/arch/riscv/lib/memcpy.S b/arch/riscv/lib/memcpy.S
> >>> index 00672c19ad..9884077c93 100644
> >>> --- a/arch/riscv/lib/memcpy.S
> >>> +++ b/arch/riscv/lib/memcpy.S
> >>> @@ -9,6 +9,7 @@
> >>>  /* void *memcpy(void *, const void *, size_t) */
> >>>  ENTRY(__memcpy)
> >>>  WEAK(memcpy)
> >>> + beq a0, a1, .copy_end
> >>
> >> I see one call to memcpy() in common/spl/spl_ram.c. I think it would
> >> make more sense to do the check there instead of adding a branch to
> >> every memcpy() call.
> >
> > There is not only one memcpy being called in spl_ram.c during spl
> > booting progress, but also in spl_fit.c .
>
> Either your FIT uses external data, and the one in spl_ram.c is trivial,
> or it uses internal data, and the one in spl_fit.c is unavoidable.
> Either way, there is only one place where this change makes a difference.
>
> > Otherwise I prefer not to modify it in generic flow level but arch
> > level, because the src and dest checking
> > may not be necessary for other booting devices.
>
> I see arch/arm/lib/memcpy.S has similar logic, so other code may be
> depending on this optimization, and there is precedent for this change.
>
> >>
> >>>   /* Save for return value */
> >>>   mv  t6, a0
> >>>
> >>> @@ -121,6 +122,7 @@ WEAK(memcpy)
> >>>  2:
> >>>
> >>>   mv  a0, t6
> >>> +.copy_end:
> >>>   ret
> >>>
> >>>  .Lmisaligned_word_copy:
> >>> diff --git a/arch/riscv/lib/spl.c b/arch/riscv/lib/spl.c
> >>> index f4d3b67e5d..18f86ee207 100644
> >>> --- a/arch/riscv/lib/spl.c
> >>> +++ b/arch/riscv/lib/spl.c
> >>> @@ -61,3 +61,19 @@ void __noreturn jump_to_image_no_args(struct 
> >>> spl_image_info *spl_image)
> >>>  #endif
> >>>   image_entry(gd->arch.boot_hart, fdt_blob);
> >>>  }
> >>> +
> >>> +#ifdef CONFIG_SPL_RAM_SUPPORT
> >>> +struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
> >>> +{
> >>> + return (void *)(CONFIG_SPL_LOAD_FIT_ADDRESS + offset);
> >>> +}
> >>> +
> >>> +void *board_spl_fit_buffer_addr(ulong fit_size, int sectors, int bl_len)
> >>> +{
> >>> + void *buf;
> >>> +
> >>> + buf = spl_get_load_buffer(0, sectors * bl_len);
> >>> +
> >>> + return buf;
> >>> +}
> >>> +#endif
> >>
> >> You cannot provide strong definitions of these functions at an
> >> architecture level, as this prevents any board from overriding them.
> >
> > Originally I wanted to put it in arch/riscv/cpu/ax25/spl.c .
> > However It is a fundamental improvement for spl_ram flow, but not
> > likely a private change.
> > That's why I put it here, so that all boards of RISC-V can be benefited.
>
> This change isn't in any way specific to RISC-V. If you want to make
> this generic, it would belong in spl_ram.c. But I still think it is
> inappropriate to provide a strong definition of board_* functions
> outside board code.

OK, I will move it to arch/riscv/cpu/ax25/spl.c.

>
> Regards,
> Samuel
>


Re: [PATCH] riscv: bypass malloc when spl fit boots from ram

2022-12-27 Thread Samuel Holland
On 12/27/22 21:22, Rick Chen wrote:
> Hi Samuel,
> 
> Samuel Holland  於 2022年12月28日 週三 上午10:47寫道:
>>
>> On 12/22/22 01:21, Rick Chen wrote:
>>> When fit image boots from ram, the payload will
>>> be prepared in the address of SPL_LOAD_FIT_ADDRESS.
>>> In spl fit generic flow, it will malloc another
>>> memory address and copy whole fit image to this
>>> malloc address.  But it is un-necessary for booting
>>> from RAM.
>>
>> This should mostly be solved by using `mkimage -E` or binman's
>> `fit,external-offset`. Then only the FIT structure, without any data,
>> will be copied.
>>
>>> This patch improves this flow by declare the
>>> board_spl_fit_buffer_addr() to replace the original one.
>>> The larger image size (eq: Kernel Image 10~20MB), it
>>> can save more booting time.
>>>
>>> Also enhance memcpy function by checking source and
>>> destination address. If they are the same address,
>>> just return and don't copy data anymore.
>>>
>>> Signed-off-by: Rick Chen 
>>> ---
>>>  arch/riscv/lib/memcpy.S |  2 ++
>>>  arch/riscv/lib/spl.c| 16 
>>>  2 files changed, 18 insertions(+)
>>>
>>> diff --git a/arch/riscv/lib/memcpy.S b/arch/riscv/lib/memcpy.S
>>> index 00672c19ad..9884077c93 100644
>>> --- a/arch/riscv/lib/memcpy.S
>>> +++ b/arch/riscv/lib/memcpy.S
>>> @@ -9,6 +9,7 @@
>>>  /* void *memcpy(void *, const void *, size_t) */
>>>  ENTRY(__memcpy)
>>>  WEAK(memcpy)
>>> + beq a0, a1, .copy_end
>>
>> I see one call to memcpy() in common/spl/spl_ram.c. I think it would
>> make more sense to do the check there instead of adding a branch to
>> every memcpy() call.
> 
> There is not only one memcpy being called in spl_ram.c during spl
> booting progress, but also in spl_fit.c .

Either your FIT uses external data, and the one in spl_ram.c is trivial,
or it uses internal data, and the one in spl_fit.c is unavoidable.
Either way, there is only one place where this change makes a difference.

> Otherwise I prefer not to modify it in generic flow level but arch
> level, because the src and dest checking
> may not be necessary for other booting devices.

I see arch/arm/lib/memcpy.S has similar logic, so other code may be
depending on this optimization, and there is precedent for this change.

>>
>>>   /* Save for return value */
>>>   mv  t6, a0
>>>
>>> @@ -121,6 +122,7 @@ WEAK(memcpy)
>>>  2:
>>>
>>>   mv  a0, t6
>>> +.copy_end:
>>>   ret
>>>
>>>  .Lmisaligned_word_copy:
>>> diff --git a/arch/riscv/lib/spl.c b/arch/riscv/lib/spl.c
>>> index f4d3b67e5d..18f86ee207 100644
>>> --- a/arch/riscv/lib/spl.c
>>> +++ b/arch/riscv/lib/spl.c
>>> @@ -61,3 +61,19 @@ void __noreturn jump_to_image_no_args(struct 
>>> spl_image_info *spl_image)
>>>  #endif
>>>   image_entry(gd->arch.boot_hart, fdt_blob);
>>>  }
>>> +
>>> +#ifdef CONFIG_SPL_RAM_SUPPORT
>>> +struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
>>> +{
>>> + return (void *)(CONFIG_SPL_LOAD_FIT_ADDRESS + offset);
>>> +}
>>> +
>>> +void *board_spl_fit_buffer_addr(ulong fit_size, int sectors, int bl_len)
>>> +{
>>> + void *buf;
>>> +
>>> + buf = spl_get_load_buffer(0, sectors * bl_len);
>>> +
>>> + return buf;
>>> +}
>>> +#endif
>>
>> You cannot provide strong definitions of these functions at an
>> architecture level, as this prevents any board from overriding them.
> 
> Originally I wanted to put it in arch/riscv/cpu/ax25/spl.c .
> However It is a fundamental improvement for spl_ram flow, but not
> likely a private change.
> That's why I put it here, so that all boards of RISC-V can be benefited.

This change isn't in any way specific to RISC-V. If you want to make
this generic, it would belong in spl_ram.c. But I still think it is
inappropriate to provide a strong definition of board_* functions
outside board code.

Regards,
Samuel



Re: [PATCH] riscv: bypass malloc when spl fit boots from ram

2022-12-27 Thread Rick Chen
Hi Samuel,

Samuel Holland  於 2022年12月28日 週三 上午10:47寫道:
>
> On 12/22/22 01:21, Rick Chen wrote:
> > When fit image boots from ram, the payload will
> > be prepared in the address of SPL_LOAD_FIT_ADDRESS.
> > In spl fit generic flow, it will malloc another
> > memory address and copy whole fit image to this
> > malloc address.  But it is un-necessary for booting
> > from RAM.
>
> This should mostly be solved by using `mkimage -E` or binman's
> `fit,external-offset`. Then only the FIT structure, without any data,
> will be copied.
>
> > This patch improves this flow by declare the
> > board_spl_fit_buffer_addr() to replace the original one.
> > The larger image size (eq: Kernel Image 10~20MB), it
> > can save more booting time.
> >
> > Also enhance memcpy function by checking source and
> > destination address. If they are the same address,
> > just return and don't copy data anymore.
> >
> > Signed-off-by: Rick Chen 
> > ---
> >  arch/riscv/lib/memcpy.S |  2 ++
> >  arch/riscv/lib/spl.c| 16 
> >  2 files changed, 18 insertions(+)
> >
> > diff --git a/arch/riscv/lib/memcpy.S b/arch/riscv/lib/memcpy.S
> > index 00672c19ad..9884077c93 100644
> > --- a/arch/riscv/lib/memcpy.S
> > +++ b/arch/riscv/lib/memcpy.S
> > @@ -9,6 +9,7 @@
> >  /* void *memcpy(void *, const void *, size_t) */
> >  ENTRY(__memcpy)
> >  WEAK(memcpy)
> > + beq a0, a1, .copy_end
>
> I see one call to memcpy() in common/spl/spl_ram.c. I think it would
> make more sense to do the check there instead of adding a branch to
> every memcpy() call.

There is not only one memcpy being called in spl_ram.c during spl
booting progress, but also in spl_fit.c .
Otherwise I prefer not to modify it in generic flow level but arch
level, because the src and dest checking
may not be necessary for other booting devices.

>
> >   /* Save for return value */
> >   mv  t6, a0
> >
> > @@ -121,6 +122,7 @@ WEAK(memcpy)
> >  2:
> >
> >   mv  a0, t6
> > +.copy_end:
> >   ret
> >
> >  .Lmisaligned_word_copy:
> > diff --git a/arch/riscv/lib/spl.c b/arch/riscv/lib/spl.c
> > index f4d3b67e5d..18f86ee207 100644
> > --- a/arch/riscv/lib/spl.c
> > +++ b/arch/riscv/lib/spl.c
> > @@ -61,3 +61,19 @@ void __noreturn jump_to_image_no_args(struct 
> > spl_image_info *spl_image)
> >  #endif
> >   image_entry(gd->arch.boot_hart, fdt_blob);
> >  }
> > +
> > +#ifdef CONFIG_SPL_RAM_SUPPORT
> > +struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
> > +{
> > + return (void *)(CONFIG_SPL_LOAD_FIT_ADDRESS + offset);
> > +}
> > +
> > +void *board_spl_fit_buffer_addr(ulong fit_size, int sectors, int bl_len)
> > +{
> > + void *buf;
> > +
> > + buf = spl_get_load_buffer(0, sectors * bl_len);
> > +
> > + return buf;
> > +}
> > +#endif
>
> You cannot provide strong definitions of these functions at an
> architecture level, as this prevents any board from overriding them.

Originally I wanted to put it in arch/riscv/cpu/ax25/spl.c .
However It is a fundamental improvement for spl_ram flow, but not
likely a private change.
That's why I put it here, so that all boards of RISC-V can be benefited.

Thanks,
Rick

>
> Regards,
> Samuel
>


Re: [PATCH] riscv: bypass malloc when spl fit boots from ram

2022-12-27 Thread Samuel Holland
On 12/22/22 01:21, Rick Chen wrote:
> When fit image boots from ram, the payload will
> be prepared in the address of SPL_LOAD_FIT_ADDRESS.
> In spl fit generic flow, it will malloc another
> memory address and copy whole fit image to this
> malloc address.  But it is un-necessary for booting
> from RAM.

This should mostly be solved by using `mkimage -E` or binman's
`fit,external-offset`. Then only the FIT structure, without any data,
will be copied.

> This patch improves this flow by declare the
> board_spl_fit_buffer_addr() to replace the original one.
> The larger image size (eq: Kernel Image 10~20MB), it
> can save more booting time.
> 
> Also enhance memcpy function by checking source and
> destination address. If they are the same address,
> just return and don't copy data anymore.
> 
> Signed-off-by: Rick Chen 
> ---
>  arch/riscv/lib/memcpy.S |  2 ++
>  arch/riscv/lib/spl.c| 16 
>  2 files changed, 18 insertions(+)
> 
> diff --git a/arch/riscv/lib/memcpy.S b/arch/riscv/lib/memcpy.S
> index 00672c19ad..9884077c93 100644
> --- a/arch/riscv/lib/memcpy.S
> +++ b/arch/riscv/lib/memcpy.S
> @@ -9,6 +9,7 @@
>  /* void *memcpy(void *, const void *, size_t) */
>  ENTRY(__memcpy)
>  WEAK(memcpy)
> + beq a0, a1, .copy_end

I see one call to memcpy() in common/spl/spl_ram.c. I think it would
make more sense to do the check there instead of adding a branch to
every memcpy() call.

>   /* Save for return value */
>   mv  t6, a0
>  
> @@ -121,6 +122,7 @@ WEAK(memcpy)
>  2:
>  
>   mv  a0, t6
> +.copy_end:
>   ret
>  
>  .Lmisaligned_word_copy:
> diff --git a/arch/riscv/lib/spl.c b/arch/riscv/lib/spl.c
> index f4d3b67e5d..18f86ee207 100644
> --- a/arch/riscv/lib/spl.c
> +++ b/arch/riscv/lib/spl.c
> @@ -61,3 +61,19 @@ void __noreturn jump_to_image_no_args(struct 
> spl_image_info *spl_image)
>  #endif
>   image_entry(gd->arch.boot_hart, fdt_blob);
>  }
> +
> +#ifdef CONFIG_SPL_RAM_SUPPORT
> +struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
> +{
> + return (void *)(CONFIG_SPL_LOAD_FIT_ADDRESS + offset);
> +}
> +
> +void *board_spl_fit_buffer_addr(ulong fit_size, int sectors, int bl_len)
> +{
> + void *buf;
> +
> + buf = spl_get_load_buffer(0, sectors * bl_len);
> +
> + return buf;
> +}
> +#endif

You cannot provide strong definitions of these functions at an
architecture level, as this prevents any board from overriding them.

Regards,
Samuel



[PATCH] SoC: sdm845: find and save KASLR to env variables

2022-12-27 Thread Dzmitry Sankouski
KASLR address is needed to boot fully functional Android.
KASLR is set by primary bootloader, and since u-boot is used
as a secondary bootloader(replacing kernel) on sdm845 platform,
KASLR may be found by comparing memory chunks at relocaddr over
supposed KASLR range.

Signed-off-by: Dzmitry Sankouski 
---
 arch/arm/mach-snapdragon/init_sdm845.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm/mach-snapdragon/init_sdm845.c 
b/arch/arm/mach-snapdragon/init_sdm845.c
index 5f53c21947..1f88502394 100644
--- a/arch/arm/mach-snapdragon/init_sdm845.c
+++ b/arch/arm/mach-snapdragon/init_sdm845.c
@@ -78,5 +78,23 @@ __weak int misc_init_r(void)
env_set("key_power", "0");
}
 
+   /*
+* search for kaslr address, set by primary bootloader by searching 
first
+* 0x100 relocated bytes at u-boot's initial load address range
+*/
+   uintptr_t start = gd->ram_base;
+   uintptr_t end = start + 0x80;
+   u8 *addr = (u8 *)start;
+   phys_addr_t *relocaddr = (phys_addr_t *)gd->relocaddr;
+   u32 block_size = 0x1000;
+
+   while (memcmp(addr, relocaddr, 0x100) && (uintptr_t)addr < end)
+   addr += block_size;
+
+   if ((uintptr_t)addr >= end)
+   printf("KASLR not found in range 0x%lx - 0x%lx", start, end);
+   else
+   env_set_addr("KASLR", addr);
+
return 0;
 }
-- 
2.30.2



[PATCH] board: starqltechn: enable serial console

2022-12-27 Thread Dzmitry Sankouski
It was temporary disabled due to problem with boot.
Issue was fixed in
commit f5ed6c9ccf3e ("uart: sdm845: Fix debug UART pinmux")

Signed-off-by: Dzmitry Sankouski 
---
 configs/starqltechn_defconfig | 4 ++--
 include/configs/sdm845.h  | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/configs/starqltechn_defconfig b/configs/starqltechn_defconfig
index 7955076d61..7a64f2a7a0 100644
--- a/configs/starqltechn_defconfig
+++ b/configs/starqltechn_defconfig
@@ -20,14 +20,14 @@ CONFIG_SYS_PBSIZE=532
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_BMP=y
 # CONFIG_NET is not set
-# CONFIG_DM_STDIO is not set
 CONFIG_CLK=y
 CONFIG_MSM_GPIO=y
 CONFIG_QCOM_PMIC_GPIO=y
 CONFIG_PINCTRL=y
 CONFIG_DM_PMIC=y
 CONFIG_PMIC_QCOM=y
-# CONFIG_REQUIRE_SERIAL_CONSOLE is not set
+CONFIG_REQUIRE_SERIAL_CONSOLE=y
+CONFIG_MSM_GENI_SERIAL=y
 CONFIG_SPMI_MSM=y
 CONFIG_VIDEO=y
 CONFIG_SYS_WHITE_ON_BLACK=y
diff --git a/include/configs/sdm845.h b/include/configs/sdm845.h
index af5fe27e68..ec6cb3a13c 100644
--- a/include/configs/sdm845.h
+++ b/include/configs/sdm845.h
@@ -16,8 +16,9 @@
 #define CONFIG_EXTRA_ENV_SETTINGS \
"bootm_size=0x400\0"\
"bootm_low=0x8000\0"\
-   "stdout=vidconsole\0"   \
-   "stderr=vidconsole\0"   \
+   "stdin=serial\0"\
+   "stdout=serial,vidconsole\0"\
+   "stderr=serial,vidconsole\0"\
"preboot=source $prevbl_initrd_start_addr:prebootscript\0" \
"bootcmd=source $prevbl_initrd_start_addr:bootscript\0"
 
-- 
2.30.2



Re: [PATCH v2 2/2] test: compression: add zstd uncompression test

2022-12-27 Thread Maier, Brandon L Collins
Hi Sean,

> From: Sean Anderson  
> On 12/27/22 09:46, Brandon Maier wrote:
> > +static const unsigned long zstd_compressed_size = 197;
> 
> You can use ARRAY_SIZE (or sizeof) for this.

sizeof() - 1 as it's a string, but I had put the size here manually as that's 
what all the other tests do. I can switch them all to sizeof() if that is 
preferred.

> 
> --Sean
> 

Thanks,
Brandon


R: [PATCH] image: fit: Fix not verifying data configuration

2022-12-27 Thread Pegorer Massimo
Hi,

> Da: U-Boot  Per conto di Sean Anderson
> Inviato: venerdì 23 dicembre 2022 00:06
> 
> On 11/18/22 15:50, Simon Glass wrote:
> > Hi Sean,
> >
> > On Thu, 13 Oct 2022 at 09:41, Sean Anderson 
> > wrote:
> >>
> >>
> >>
> >> On 10/13/22 3:14 AM, Rasmus Villemoes wrote:
> >> > On 12/10/2022 18.28, Sean Anderson wrote:
> >> >> On 10/12/22 08:59, Simon Glass wrote:
> >> >>> Hi Sean,
> >> >>>
> >> >>> On Tue, 11 Oct 2022 at 17:25, Sean Anderson
> >> >>> 
> >> >>> wrote:
> >> 
> >>  When reading data from a FIT image, we must verify the
> >>  configuration we get it from. This is because when we have a key
> >>  with required = "conf", the image does not need any particular
> >>  signature or hash. The configuration is the only required 
> >>  verification, so
> >>  we must verify it.
> >> 
> >>  Users of fit_get_data_node are liable to load unsigned data
> >>  unless the user has set required = "image". Even then, they are
> >>  vulnerable to mix-and-match attacks. This also affects other
> >>  callers of fit_image_verify which don't first call
> >>  fit_config_verify, such as source and imxtract. I don't think
> >>  there is a backwards-compatible way to fix these interfaces.
> >>  Fundamentally, selecting data by image when images are not required
> >>  to be verified is unsafe.
> >> 
> >>  Fixes: 37feaf2f727 ("image: fit: Add some helpers for getting
> >>  data")
> >>  Signed-off-by: Sean Anderson 
> >>  ---
> >> 
> >>    boot/image-fit.c | 9 -
> >>    1 file changed, 8 insertions(+), 1 deletion(-)
> >> 
> >>  diff --git a/boot/image-fit.c b/boot/image-fit.c index
> >>  9c04ff78a15..632fd405e29 100644
> >>  --- a/boot/image-fit.c
> >>  +++ b/boot/image-fit.c
> >>  @@ -1948,7 +1948,14 @@ int fit_get_data_node(const void *fit,
> >>  const char *image_uname,
> >>    int fit_get_data_conf_prop(const void *fit, const char *prop_name,
> >>  const void **data, size_t *size)
> >>    {
> >>  -   int noffset = fit_conf_get_node(fit, NULL);
> >>  +   int ret, noffset = fit_conf_get_node(fit, NULL);
> >>  +
> >>  +   if (noffset < 0)
> >>  +   return noffset;
> >>  +
> >>  +   ret = fit_config_verify(fit, noffset);
> >>  +   if (ret)
> >>  +   return ret;
> >> 
> >>   noffset = fit_conf_get_prop_node(fit, noffset, prop_name);
> >>   return fit_get_data_tail(fit, noffset, data, size);
> >>  --
> >>  2.35.1.1320.gc452695387.dirty
> >> 
> >> >>>
> >> >>> This is supposed to work by first verifying the configuration
> >> >>> with fit_config_verify(). After that, images in that
> >> >>> configuration can be freely loaded, verified by the hash that each 
> >> >>> image
> >> >>> has.
> >> >>
> >> >> Well, this function was made to replaces several cases where code
> >> >> loaded a FIT image from somewhere, and then wanted to get data
> >> >> from an image based on the configuration. Typically they only want
> >> >> to extract one image, which is the common case for e.g. loading
> >> >> firmware. This idea of this function is to make the common case of
> >> >> "find me the image data from the default config and verify it"
> >> >> easier. If you look at the existing code which uses this function,
> >> >> they do not verify the configuration first. This is mainly because
> >> >> the original versions of this code which I replaced with this function 
> >> >> did
> >> >> not verify the configuration either.
> >> >>
> >> >> So while the above process works for an integrated verification
> >> >> process, like what is done by bootm, it doesn't really work for
> >> >> one-off loading of image data. In particular, the requirements to
> >> >> make this secure (using required = "image" for your key), are not
> >> >> default. When I was trying to determine whether the source command
> >> >> would be OK to use to load some configuration, I looked at it and
> >> >> saw that it did fit_image_verify. I thought that was fine, but if
> >> >> you use required = "config", then all that does is verify the hash.
> >> >
> >> > Yeah, so I've raised this problem with the "source" shell command
> >> > previously, but never got a satisfactory answer:
> >> >
> >> > https://lore.kernel.org/u-boot/7d711133-d513-5bcb-52f2-a9dbaa9ee...@prevas.dk/
> >> >
> >> > So does your patch now mean that it's possible to get a
> >> > bootscript-wrapped-in-a-FIT-image verified, possibly by adding some
> >> > dummy (or not so dummy?) "configurations" node? Can you give a
> >> > complete .its showing how I can build a verifiable boot script?
> >>
> >> No. I didn't convert source because it also checks to ensure that the
> >> image type is correct, which fit_get_data_node doesn't check.
> >> However, it still uses the image name to determine the data to
> >> source, which has all the 

[PATCH] CI: Rework rockchip jobs in Azure

2022-12-27 Thread Tom Rini
The rockchip job is getting close to the hard time limit in Azure for
the free tier. Split this in to 32bit and 64bit board jobs.

Signed-off-by: Tom Rini 
---
 .azure-pipelines.yml | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 21213369c6c5..ca29479745e6 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -535,8 +535,10 @@ stages:
   BUILDMAN: "uniphier"
 aarch64_catch_all:
   BUILDMAN: "aarch64 -x 
amlogic,bcm,imx8,imx9,k3,tegra,ls1,ls2,lx216,mvebu,uniphier,renesas,sunxi,samsung,socfpga,rk,versal,zynq"
-rockchip:
-  BUILDMAN: "rk"
+rockchip_32bit:
+  BUILDMAN: "rk -x aarch64"
+rockchip_64bit:
+  BUILDMAN: "rk"
 renesas:
   BUILDMAN: "renesas"
 zynq:
-- 
2.25.1



Re: [PATCH v2 2/2] test: compression: add zstd uncompression test

2022-12-27 Thread Sean Anderson
On 12/27/22 09:46, Brandon Maier wrote:
> +static const unsigned long zstd_compressed_size = 197;

You can use ARRAY_SIZE (or sizeof) for this.

--Sean




Re: [GIT PULL] Please pull u-boot-pmic master

2022-12-27 Thread Tom Rini
On Tue, Dec 27, 2022 at 10:19:37AM +0900, Jaehoon Chung wrote:

> Dear Tom,
> 
> Please pull u-boot-pmic master into u-boot master branch.
> If there is a problem, let me know, plz
> 
> Best Regards,
> Jaehoon Chung
> 
> CI: https://source.denx.de/u-boot/custodians/u-boot-pmic/-/pipelines/14522
> 
> 
> The following changes since commit e1befc8512fe4f67056a6e4b5cd2ab936abc35c6:
> 
>   Merge tag 'tpm-23122022' of 
> https://source.denx.de/u-boot/custodians/u-boot-tpm (2022-12-23 07:46:41 
> -0500)
> 
> are available in the Git repository at:
> 
>   g...@source.denx.de:u-boot/custodians/u-boot-pmic.git master
> 
> for you to fetch changes up to dbedf4a56b49544b0f9174856a14bd6be2d9e641:
> 
>   power: regulator: Add support for NPCM8xx (2022-12-26 15:44:00 +0900)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 2/3] eficonfig: refactor change boot order implementation

2022-12-27 Thread Ilias Apalodimas
On Sat, Dec 24, 2022 at 07:57:43AM +0900, Masahisa Kojima wrote:
> This commit removes the change boot order specific
> menu implementation. The change boot order implementation
> calls eficonfig_process_common() same as other menus.
>
> The change boot order menu requires own item_data_print
> and item_choice implementation, but display_statusline
> function can be a same function as other menus.
>
> Signed-off-by: Masahisa Kojima 
> ---
> Changes in v2:
> - add comment when the user key press is not valid
> - add const qualifier to eficonfig_change_boot_order_desc
>
>  cmd/eficonfig.c | 245 +---
>  1 file changed, 150 insertions(+), 95 deletions(-)
>
> diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> index 2fc486dac2..13929cb003 100644
> --- a/cmd/eficonfig.c
> +++ b/cmd/eficonfig.c
> @@ -24,6 +24,11 @@ static struct efi_simple_text_input_protocol *cin;
>  const char *eficonfig_menu_desc =
>   "  Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit";
>
> +static const char *eficonfig_change_boot_order_desc =
> + "  Press UP/DOWN to move, +/- to change orde\n"
> + "  Press SPACE to activate or deactivate the entry\n"
> + "  Select [Save] to complete, ESC/CTRL+C to quit";
> +
>  #define EFICONFIG_DESCRIPTION_MAX 32
>  #define EFICONFIG_OPTIONAL_DATA_MAX 64
>
> @@ -105,6 +110,17 @@ struct eficonfig_boot_order_data {
>   bool active;
>  };
>
> +/**
> + * struct eficonfig_save_boot_order_data - structure to be used to change 
> boot order
> + *
> + * @efi_menu:pointer to efimenu structure
> + * @selected:flag to indicate user selects "Save" entry
> + */
> +struct eficonfig_save_boot_order_data {
> + struct efimenu *efi_menu;
> + bool selected;
> +};
> +
>  /**
>   * eficonfig_print_msg() - print message
>   *
> @@ -173,10 +189,9 @@ void eficonfig_display_statusline(struct menu *m)
> "\n%s\n"
>  ANSI_CURSOR_POSITION ANSI_CLEAR_LINE ANSI_CURSOR_POSITION
>  "%s"
> -ANSI_CLEAR_LINE_TO_END ANSI_CURSOR_POSITION ANSI_CLEAR_LINE,
> +ANSI_CLEAR_LINE_TO_END,
>  1, 1, entry->efi_menu->menu_header, entry->efi_menu->count + 5, 
> 1,
> -entry->efi_menu->count + 6, 1, entry->efi_menu->menu_desc,
> -entry->efi_menu->count + 7, 1);
> +entry->efi_menu->count + 6, 1, entry->efi_menu->menu_desc);
>  }
>
>  /**
> @@ -1841,63 +1856,44 @@ out:
>  }
>
>  /**
> - * eficonfig_display_change_boot_order() - display the BootOrder list
> + * eficonfig_print_change_boot_order_entry() - print the boot option entry
>   *
> - * @efi_menu:pointer to the efimenu structure
> - * Return:   status code
> + * @data:pointer to the data associated with each menu entry
>   */
> -static void eficonfig_display_change_boot_order(struct efimenu *efi_menu)
> +static void eficonfig_print_change_boot_order_entry(void *data)
>  {
> - bool reverse;
> - struct list_head *pos, *n;
> - struct eficonfig_entry *entry;
> -
> - printf(ANSI_CLEAR_CONSOLE ANSI_CURSOR_POSITION
> -"\n  ** Change Boot Order **\n"
> -ANSI_CURSOR_POSITION
> -"  Press UP/DOWN to move, +/- to change order"
> -ANSI_CURSOR_POSITION
> -"  Press SPACE to activate or deactivate the entry"
> -ANSI_CURSOR_POSITION
> -"  Select [Save] to complete, ESC/CTRL+C to quit"
> -ANSI_CURSOR_POSITION ANSI_CLEAR_LINE,
> -1, 1, efi_menu->count + 5, 1, efi_menu->count + 6, 1,
> -efi_menu->count + 7, 1,  efi_menu->count + 8, 1);
> -
> - /* draw boot option list */
> - list_for_each_safe(pos, n, _menu->list) {
> - entry = list_entry(pos, struct eficonfig_entry, list);
> - reverse = (entry->num == efi_menu->active);
> + struct eficonfig_entry *entry = data;
> + int reverse = (entry->efi_menu->active == entry->num);

Why did we change this from bool?

[...]

> - printf(ANSI_CURSOR_POSITION, entry->num + 4, 7);
>  }
>
>  /**
> - * eficonfig_choice_change_boot_order() - handle the BootOrder update
> + * eficonfig_choice_change_boot_order() - user key input handler
>   *
> - * @efi_menu:pointer to the efimenu structure
> - * Return:   status code
> + * @data:pointer to the menu entry
> + * Return:   key string to identify the selected entry
>   */
> -static efi_status_t eficonfig_choice_change_boot_order(struct efimenu 
> *efi_menu)
>  }
>
> +/**
> + * eficonfig_process_save_boot_order() - callback function for "Save" entry
> + *
> + * @data:pointer to the data
> + * Return:   status code
> + */
> +static efi_status_t eficonfig_process_save_boot_order(void *data)
> +{
> + u32 count = 0;
> + efi_status_t ret;
> + efi_uintn_t size;
> + struct list_head *pos, *n;
> + u16 *new_bootorder;
> + struct efimenu *efi_menu;
> + struct eficonfig_entry *entry;
> + struct 

Re: [PATCH v2 3/3] eficonfig: add vertical scroll support

2022-12-27 Thread Ilias Apalodimas


This looks correct to me.
Heinrich can you check if that solves your scrolling issues?

On Sat, Dec 24, 2022 at 07:57:44AM +0900, Masahisa Kojima wrote:
> The current eficonfig menu does not support vertical scroll,
> so it can not display the menu entries greater than
> the console row size.
>
> This commit add the vertial scroll support.
> The console size is retrieved by
> SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode() service, then
> calculates the row size for menu entry by subtracting
> menu header and description row size from the console row size.
> "start" and "end" are added in the efimenu structure.
> "start" keeps the menu entry index at the top, "end" keeps
> the bottom menu entry index. item_data_print() menu function
> only draws the menu entry between "start" and "end".
>
> Signed-off-by: Masahisa Kojima 
> ---
> No update since v1
>
>  cmd/eficonfig.c  | 79 
>  include/efi_config.h |  4 +++
>  include/efi_loader.h |  1 +
>  3 files changed, 70 insertions(+), 14 deletions(-)
>
> diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> index 13929cb003..e289d95589 100644
> --- a/cmd/eficonfig.c
> +++ b/cmd/eficonfig.c
> @@ -29,8 +29,13 @@ static const char *eficonfig_change_boot_order_desc =
>   "  Press SPACE to activate or deactivate the entry\n"
>   "  Select [Save] to complete, ESC/CTRL+C to quit";
>
> +static struct efi_simple_text_output_protocol *cout;
> +static int avail_row;
> +
>  #define EFICONFIG_DESCRIPTION_MAX 32
>  #define EFICONFIG_OPTIONAL_DATA_MAX 64
> +#define EFICONFIG_MENU_HEADER_ROW_NUM 3
> +#define EFICONFIG_MENU_DESC_ROW_NUM 5
>
>  /**
>   * struct eficonfig_filepath_info - structure to be used to store file path
> @@ -156,18 +161,16 @@ void eficonfig_print_entry(void *data)
>   struct eficonfig_entry *entry = data;
>   int reverse = (entry->efi_menu->active == entry->num);
>
> - /* TODO: support scroll or page for many entries */
> + if (entry->efi_menu->start > entry->num || entry->efi_menu->end < 
> entry->num)
> + return;
>
> - /*
> -  * Move cursor to line where the entry will be drawn (entry->num)
> -  * First 3 lines(menu header) + 1 empty line
> -  */
> - printf(ANSI_CURSOR_POSITION, entry->num + 4, 7);
> + printf(ANSI_CURSOR_POSITION, (entry->num - entry->efi_menu->start) +
> +EFICONFIG_MENU_HEADER_ROW_NUM + 1, 7);
>
>   if (reverse)
>   puts(ANSI_COLOR_REVERSE);
>
> - printf("%s", entry->title);
> + printf(ANSI_CLEAR_LINE "%s", entry->title);
>
>   if (reverse)
>   puts(ANSI_COLOR_RESET);
> @@ -190,8 +193,8 @@ void eficonfig_display_statusline(struct menu *m)
>  ANSI_CURSOR_POSITION ANSI_CLEAR_LINE ANSI_CURSOR_POSITION
>  "%s"
>  ANSI_CLEAR_LINE_TO_END,
> -1, 1, entry->efi_menu->menu_header, entry->efi_menu->count + 5, 
> 1,
> -entry->efi_menu->count + 6, 1, entry->efi_menu->menu_desc);
> +1, 1, entry->efi_menu->menu_header, avail_row + 4, 1,
> +avail_row + 5, 1, entry->efi_menu->menu_desc);
>  }
>
>  /**
> @@ -213,13 +216,23 @@ char *eficonfig_choice_entry(void *data)
>
>   switch (key) {
>   case KEY_UP:
> - if (efi_menu->active > 0)
> + if (efi_menu->active > 0) {
>   --efi_menu->active;
> + if (efi_menu->start > efi_menu->active) {
> + efi_menu->start--;
> + efi_menu->end--;
> + }
> + }
>   /* no menu key selected, regenerate menu */
>   return NULL;
>   case KEY_DOWN:
> - if (efi_menu->active < efi_menu->count - 1)
> + if (efi_menu->active < efi_menu->count - 1) {
>   ++efi_menu->active;
> + if (efi_menu->end < efi_menu->active) {
> + efi_menu->start++;
> + efi_menu->end++;
> + }
> + }
>   /* no menu key selected, regenerate menu */
>   return NULL;
>   case KEY_SELECT:
> @@ -399,6 +412,8 @@ efi_status_t eficonfig_process_common(struct efimenu 
> *efi_menu,
>
>   efi_menu->delay = -1;
>   efi_menu->active = 0;
> + efi_menu->start = 0;
> + efi_menu->end = avail_row - 1;
>
>   if (menu_header) {
>   efi_menu->menu_header = strdup(menu_header);
> @@ -1865,7 +1880,11 @@ static void 
> eficonfig_print_change_boot_order_entry(void *data)
>   struct eficonfig_entry *entry = data;
>   int reverse = (entry->efi_menu->active == entry->num);
>
> - printf(ANSI_CURSOR_POSITION, entry->num + 4, 7);
> + if (entry->efi_menu->start > entry->num 

[PATCH v2 2/2] test: compression: add zstd uncompression test

2022-12-27 Thread Brandon Maier
Signed-off-by: Brandon Maier 
---
 test/Kconfig   |  2 +-
 test/compression.c | 71 ++
 2 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/test/Kconfig b/test/Kconfig
index a6b463e4d06..dd2f082ce63 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -64,7 +64,7 @@ endif
 config UT_COMPRESSION
bool "Unit test for compression"
depends on UNIT_TEST
-   depends on CMDLINE && GZIP_COMPRESSED && BZIP2 && LZMA && LZO && LZ4
+   depends on CMDLINE && GZIP_COMPRESSED && BZIP2 && LZMA && LZO && LZ4 && 
ZSTD
default y
help
  Enables tests for compression and decompression routines for simple
diff --git a/test/compression.c b/test/compression.c
index 82e29c9b86b..c3e8c8c51ae 100644
--- a/test/compression.c
+++ b/test/compression.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -22,6 +23,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -121,6 +123,23 @@ static const char lz4_compressed[] =
"\x9d\x12\x8c\x9d";
 static const unsigned long lz4_compressed_size = 276;
 
+/* zstd -19 -c /tmp/plain.txt > /tmp/plain.zst */
+static const char zstd_compressed[] =
+   "\x28\xb5\x2f\xfd\x64\x5e\x00\xbd\x05\x00\x02\x0e\x26\x1a\x70\x17"
+   "\xb8\x0d\x0c\x53\x5c\x9d\x97\xee\xa0\x5d\x84\x89\x3f\x5c\x7a\x78"
+   "\x00\x80\x80\x0f\xe8\xdf\xaf\x06\x66\xd0\x23\xa6\x7a\x64\x8e\xf4"
+   "\x0d\x5b\x47\x65\x26\x7e\x81\xdd\x0b\xe7\x5a\x95\x3d\x49\xcc\x67"
+   "\xe0\x2d\x46\x58\xb6\xac\x64\x16\xf2\xe0\xf8\x16\x17\xaf\xda\x8f"
+   "\x37\xc0\xc3\x0d\x3b\x89\x57\x15\x1e\x46\x46\x12\x9a\x84\xbe\xa6"
+   "\xab\xcf\x50\x90\x5f\x78\x01\xd2\xc0\x51\x72\x59\x0b\xea\xab\xf2"
+   "\xd4\x2b\x2d\x26\x7c\x10\x66\x78\x42\x64\x45\x3f\xa5\x15\x6f\xbd"
+   "\x4a\x61\xe1\xc8\x27\xc0\xe3\x95\x0c\xf9\xca\x7c\xf5\x13\x30\xc3"
+   "\x1a\x7c\x7d\xa4\x17\x0b\xff\x14\xa6\x7a\x95\xa0\x34\xbc\xce\x21"
+   "\x78\x36\x23\x33\x11\x09\x00\x60\x13\x00\x63\xa3\x8e\x28\x94\x55"
+   "\x15\xb6\x26\x68\x05\x4f\x23\x12\xee\x53\x55\x2d\x44\x2f\x54\x95"
+   "\x01\xe4\xf4\x6e\xfa";
+static const unsigned long zstd_compressed_size = 197;
+
 
 #define TEST_BUFFER_SIZE   512
 
@@ -296,6 +315,45 @@ static int uncompress_using_lz4(struct unit_test_state 
*uts,
return (ret != 0);
 }
 
+static int compress_using_zstd(struct unit_test_state *uts,
+  void *in, unsigned long in_size,
+  void *out, unsigned long out_max,
+  unsigned long *out_size)
+{
+   /* There is no zstd compression in u-boot, so fake it. */
+   ut_asserteq(in_size, strlen(plain));
+   ut_asserteq_mem(plain, in, in_size);
+
+   if (zstd_compressed_size > out_max)
+   return -1;
+
+   memcpy(out, zstd_compressed, zstd_compressed_size);
+   if (out_size)
+   *out_size = zstd_compressed_size;
+
+   return 0;
+}
+
+static int uncompress_using_zstd(struct unit_test_state *uts,
+void *in, unsigned long in_size,
+void *out, unsigned long out_max,
+unsigned long *out_size)
+{
+   struct abuf in_buf, out_buf;
+   int ret;
+
+   abuf_init_set(_buf, in, in_size);
+   abuf_init_set(_buf, out, out_max);
+
+   ret = zstd_decompress(_buf, _buf);
+   if (ret >= 0) {
+   *out_size = ret;
+   ret = 0;
+   }
+
+   return ret;
+}
+
 #define errcheck(statement) if (!(statement)) { \
fprintf(stderr, "\tFailed: %s\n", #statement); \
ret = 1; \
@@ -440,6 +498,13 @@ static int compression_test_lz4(struct unit_test_state 
*uts)
 }
 COMPRESSION_TEST(compression_test_lz4, 0);
 
+static int compression_test_zstd(struct unit_test_state *uts)
+{
+   return run_test(uts, "zstd", compress_using_zstd,
+   uncompress_using_zstd);
+}
+COMPRESSION_TEST(compression_test_zstd, 0);
+
 static int compress_using_none(struct unit_test_state *uts,
   void *in, unsigned long in_size,
   void *out, unsigned long out_max,
@@ -530,6 +595,12 @@ static int compression_test_bootm_lz4(struct 
unit_test_state *uts)
 }
 COMPRESSION_TEST(compression_test_bootm_lz4, 0);
 
+static int compression_test_bootm_zstd(struct unit_test_state *uts)
+{
+   return run_bootm_test(uts, IH_COMP_ZSTD, compress_using_zstd);
+}
+COMPRESSION_TEST(compression_test_bootm_zstd, 0);
+
 static int compression_test_bootm_none(struct unit_test_state *uts)
 {
return run_bootm_test(uts, IH_COMP_NONE, compress_using_none);
-- 
2.39.0



Re: [PATCH v2 1/3] eficonfig: refactor eficonfig_process_common function

2022-12-27 Thread Ilias Apalodimas
Hi Kojima-san


Overall I think the cleanup is nice and easier to maintain in the long
run.

On Sat, Dec 24, 2022 at 07:57:42AM +0900, Masahisa Kojima wrote:
> Current change boot order implementation does not call
> eficonfig_process_common() and call own menu functions
> for display_statusline, item_data_print and item_choice.
> Change boot order functionality should call
> eficonfig_process_common() to improve maintenanceability.
>
> This commit is a preparation to remove the change boot
> order specific implementation. The menu functions
> (display_statusline, item_data_print and item_choice) are
> added as argument of eficonfig_process_common().
> The menu description string displayed at the bottom of
> the menu is also added as argument.
>
> Signed-off-by: Masahisa Kojima 
> ---
> Changes in v2:
> - add const qualifier to eficonfig_menu_desc, change it to pointer
>
>  cmd/eficonfig.c   | 69 +--
>  cmd/eficonfig_sbkey.c | 18 +--
>  include/efi_config.h  | 13 +++-
>  3 files changed, 81 insertions(+), 19 deletions(-)
>
> diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> index ce7175a566..2fc486dac2 100644
> --- a/cmd/eficonfig.c
> +++ b/cmd/eficonfig.c
> @@ -21,6 +21,8 @@
>  #include 
>
>  static struct efi_simple_text_input_protocol *cin;
> +const char *eficonfig_menu_desc =
> + "  Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit";
>
>  #define EFICONFIG_DESCRIPTION_MAX 32
>  #define EFICONFIG_OPTIONAL_DATA_MAX 64
> @@ -133,7 +135,7 @@ void eficonfig_print_msg(char *msg)
>   *
>   * @data:pointer to the data associated with each menu entry
>   */
> -static void eficonfig_print_entry(void *data)
> +void eficonfig_print_entry(void *data)
>  {
>   struct eficonfig_entry *entry = data;
>   int reverse = (entry->efi_menu->active == entry->num);
> @@ -160,7 +162,7 @@ static void eficonfig_print_entry(void *data)
>   *
>   * @m:   pointer to the menu structure
>   */
> -static void eficonfig_display_statusline(struct menu *m)
> +void eficonfig_display_statusline(struct menu *m)
>  {
>   struct eficonfig_entry *entry;
>
> @@ -170,10 +172,11 @@ static void eficonfig_display_statusline(struct menu *m)
>   printf(ANSI_CURSOR_POSITION
> "\n%s\n"
>  ANSI_CURSOR_POSITION ANSI_CLEAR_LINE ANSI_CURSOR_POSITION
> -"  Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit"
> +"%s"
>  ANSI_CLEAR_LINE_TO_END ANSI_CURSOR_POSITION ANSI_CLEAR_LINE,
>  1, 1, entry->efi_menu->menu_header, entry->efi_menu->count + 5, 
> 1,
> -entry->efi_menu->count + 6, 1, entry->efi_menu->count + 7, 1);
> +entry->efi_menu->count + 6, 1, entry->efi_menu->menu_desc,
> +entry->efi_menu->count + 7, 1);
>  }
>
>  /**
> @@ -182,7 +185,7 @@ static void eficonfig_display_statusline(struct menu *m)
>   * @data:pointer to the efimenu structure
>   * Return:   key string to identify the selected entry
>   */
> -static char *eficonfig_choice_entry(void *data)
> +char *eficonfig_choice_entry(void *data)
>  {
>   int esc = 0;
>   struct list_head *pos, *n;
> @@ -358,9 +361,17 @@ out:
>   *
>   * @efi_menu:pointer to the efimenu structure
>   * @menu_header: pointer to the menu header string
> + * @menu_desc:   pointer to the menu description
> + * @display_statusline:  function pointer to draw statusline
> + * @item_data_print: function pointer to draw the menu item
> + * @item_choice: function pointer to handle the key press
>   * Return:   status code
>   */
> -efi_status_t eficonfig_process_common(struct efimenu *efi_menu, char 
> *menu_header)
> +efi_status_t eficonfig_process_common(struct efimenu *efi_menu,
> +   char *menu_header, const char *menu_desc,
> +   void (*display_statusline)(struct menu *),
> +   void (*item_data_print)(void *),
> +   char *(*item_choice)(void *))
>  {
>   struct menu *menu;
>   void *choice = NULL;
> @@ -379,10 +390,11 @@ efi_status_t eficonfig_process_common(struct efimenu 
> *efi_menu, char *menu_heade
>   if (!efi_menu->menu_header)
>   return EFI_OUT_OF_RESOURCES;
>   }
> + if (menu_desc)
> + efi_menu->menu_desc = menu_desc;
>
> - menu = menu_create(NULL, 0, 1, eficonfig_display_statusline,
> -eficonfig_print_entry, eficonfig_choice_entry,
> -efi_menu);
> + menu = menu_create(NULL, 0, 1, display_statusline, item_data_print,
> +item_choice, efi_menu);

menu_create doesn't check any pointers for item_data_print, item_choice, 
efi_menu
Should we check any of these here?

>   if (!menu)
>   return EFI_INVALID_PARAMETER;

[...]

Regards
/Ilias


[PATCH 4/5] video console: add 16x32 ter font from linux

2022-12-27 Thread Dzmitry Sankouski
Modern mobile phones typically have high pixel density.
Bootmenu is hardly readable on those with 8x16 font.

Add 16x32 ter font from linux, and allow font size configuration.
Set 16x32 font for starqltechn board.

Signed-off-by: Dzmitry Sankouski 
---
 configs/starqltechn_defconfig |1 +
 drivers/video/Kconfig |   23 +
 include/video_font.h  |6 +-
 include/video_font_ter16x32.h | 2068 +
 4 files changed, 2096 insertions(+), 2 deletions(-)
 create mode 100644 include/video_font_ter16x32.h

diff --git a/configs/starqltechn_defconfig b/configs/starqltechn_defconfig
index 59fc9ab151..9e9ca33089 100644
--- a/configs/starqltechn_defconfig
+++ b/configs/starqltechn_defconfig
@@ -12,6 +12,7 @@ CONFIG_FIT_VERBOSE=y
 CONFIG_BOOTDELAY=5
 CONFIG_CMD_BOOTMENU=y
 CONFIG_DM_KEYBOARD=y
+CONFIG_VIDEO_FONT_16x32=y
 CONFIG_USE_PREBOOT=y
 CONFIG_SAVE_PREV_BL_FDT_ADDR=n
 CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR=n
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index bc7f20cf64..3d531e69dc 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -15,6 +15,29 @@ config VIDEO
  through this.
 
 if VIDEO
+choice
+   prompt "Video font size"
+   default VIDEO_FONT_8x16
+
+config VIDEO_FONT_4X6
+   bool "4 x 6 font size"
+   help
+ Font for video console driver, 4 x 6 pixels.
+ Provides character bitmap data in header file.
+
+config VIDEO_FONT_8x16
+   bool "8 x 16 font size"
+   help
+ Font for video console driver, 8 x 16 pixels
+ Provides character bitmap data in header file.
+
+config VIDEO_FONT_16x32
+   bool "16 x 32 font size"
+   help
+ Font for video console driver, 16 x 32 pixels
+ Provides character bitmap data in header file.
+
+endchoice
 
 config VIDEO_LOGO
bool "Show the U-Boot logo on the display"
diff --git a/include/video_font.h b/include/video_font.h
index 5e23f70f85..86685bfaf1 100644
--- a/include/video_font.h
+++ b/include/video_font.h
@@ -7,10 +7,12 @@
 #ifndef _VIDEO_FONT_
 #define _VIDEO_FONT_
 
-#ifdef CONFIG_VIDEO_FONT_4X6
+#if defined(CONFIG_VIDEO_FONT_4X6)
 #include 
-#else
+#elif defined(CONFIG_VIDEO_FONT_8x16)
 #include 
+#elif defined(CONFIG_VIDEO_FONT_16x32)
+#include 
 #endif
 
 #endif /* _VIDEO_FONT_ */
diff --git a/include/video_font_ter16x32.h b/include/video_font_ter16x32.h
new file mode 100644
index 00..7c9c1b489a
--- /dev/null
+++ b/include/video_font_ter16x32.h
@@ -0,0 +1,2068 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copied from linux.
+ */
+
+#ifndef _VIDEO_FONT_DATA_
+#define _VIDEO_FONT_DATA_
+
+#define VIDEO_FONT_CHARS   256
+#define VIDEO_FONT_WIDTH   16
+#define VIDEO_FONT_BYTE_WIDTH  VIDEO_FONT_WIDTH / 8 + (VIDEO_FONT_WIDTH % 8 > 
0)
+#define VIDEO_FONT_HEIGHT  32
+#define VIDEO_FONT_CHAR_PIXEL_DATA_SIZEVIDEO_FONT_HEIGHT * 
VIDEO_FONT_BYTE_WIDTH
+#define VIDEO_FONT_SIZE(VIDEO_FONT_CHARS * VIDEO_FONT_HEIGHT \
+   * VIDEO_FONT_BYTE_WIDTH)
+
+static unsigned char __maybe_unused video_fontdata[VIDEO_FONT_SIZE] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x7f, 0xfc, 0x7f, 0xfc,
+   0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c,
+   0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c,
+   0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c,
+   0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c,
+   0x7f, 0xfc, 0x7f, 0xfc, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x7f, 0xfc,
+   0xf0, 0x1e, 0xe0, 0x0e, 0xe0, 0x0e, 0xe0, 0x0e,
+   0xee, 0xee, 0xee, 0xee, 0xe0, 0x0e, 0xe0, 0x0e,
+   0xe0, 0x0e, 0xe0, 0x0e, 0xef, 0xee, 0xe7, 0xce,
+   0xe0, 0x0e, 0xe0, 0x0e, 0xe0, 0x0e, 0xf0, 0x1e,
+   0x7f, 0xfc, 0x3f, 0xf8, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x7f, 0xfc,
+   0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe,
+   0xe3, 0x8e, 0xe3, 0x8e, 0xff, 0xfe, 0xff, 0xfe,
+   0xff, 0xfe, 0xff, 0xfe, 0xe0, 0x0e, 0xf0, 0x1e,
+   0xf8, 0x3e, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe,
+   0x7f, 0xfc, 0x3f, 0xf8, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2 */
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x78, 0x3c, 0xfc, 0x7e, 0xfe, 0xfe, 0xff, 0xfe,
+   0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe,
+   0x7f, 0xfc, 0x7f, 0xfc, 0x3f, 0xf8, 0x1f, 0xf0,
+   0x0f, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3 */
+   

Re: [PATCH V3 09/12] arm: dts: Add initial support for AM68 Starter Kit System on Module

2022-12-27 Thread Sinthu Raja M
On Tue, Dec 27, 2022 at 5:46 PM Sinthu Raja
 wrote:
>
> From: Sinthu Raja 
>
> AM68 Starter Kit (SK) is a low cost, small form factor board designed
> for TI’s AM68 SoC. TI’s AM68 SoC comprises of dual core A72, high
> performance vision accelerators, hardware accelerators, latest C71x
> DSP, high bandwidth real-time IPs for capture and display. The SoC is
> power optimized to provide best in class performance for industrial
> applications.
>
> AM68 SK supports the following interfaces:
> * 16 GB LPDDR4 RAM
> * x1 Gigabit Ethernet interface
> * x1 USB 3.1 Type-C port
> * x2 USB 3.1 Type-A ports
> * x1 PCIe M.2 M Key
> * 512 Mbit OSPI flash
> * x2 CSI2 Camera interface (RPi and TI Camera connector)
> * 40-pin Raspberry Pi GPIO header
>
> SK's System on Module (SoM) contains the SoC, PMIC, DDR and OSPI flash.
> Therefore, add support for the components present on the SoM.
>
> Schematics: https://www.ti.com/lit/zip/SPRR463
> TRM: http://www.ti.com/lit/pdf/spruj28
>
> Signed-off-by: Sinthu Raja 
> ---

Hi All,
The Kernel DTSI is under review and waiting to get merged.
Kernel Link: 
https://lore.kernel.org/linux-arm-kernel/20221115154832.19759-4-sinthu.r...@ti.com/T/#mbfef0638ffc4ecfa71304014efc03131b2b925a9

>  arch/arm/dts/k3-am68-sk-som.dtsi | 127 +++
>  1 file changed, 127 insertions(+)
>  create mode 100644 arch/arm/dts/k3-am68-sk-som.dtsi
>
> diff --git a/arch/arm/dts/k3-am68-sk-som.dtsi 
> b/arch/arm/dts/k3-am68-sk-som.dtsi
> new file mode 100644
> index 00..cb1c58fcd1
> --- /dev/null
> +++ b/arch/arm/dts/k3-am68-sk-som.dtsi
> @@ -0,0 +1,127 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
> + */
> +
> +/dts-v1/;
> +
> +#include "k3-j721s2.dtsi"
> +#include 
> +
> +/ {
> +   memory@8000 {
> +   device_type = "memory";
> +   /* 16 GB RAM */
> +   reg = <0x00 0x8000 0x00 0x8000>,
> + <0x08 0x8000 0x03 0x8000>;
> +   };
> +
> +   /* Reserving memory regions still pending */
> +   reserved_memory: reserved-memory {
> +   #address-cells = <2>;
> +   #size-cells = <2>;
> +   ranges;
> +
> +   secure_ddr: optee@9e80 {
> +   reg = <0x00 0x9e80 0x00 0x0180>;
> +   alignment = <0x1000>;
> +   no-map;
> +   };
> +   };
> +};
> +
> +_cluster0 {
> +   status = "disabled";
> +};
> +
> +_cluster1 {
> +   status = "disabled";
> +};
> +
> +_cluster2 {
> +   status = "disabled";
> +};
> +
> +_cluster3 {
> +   status = "disabled";
> +};
> +
> +_cluster4 {
> +   status = "disabled";
> +};
> +
> +_cluster5 {
> +   status = "disabled";
> +};
> +
> +_cluster6 {
> +   status = "disabled";
> +};
> +
> +_cluster7 {
> +   status = "disabled";
> +};
> +
> +_cluster8 {
> +   status = "disabled";
> +};
> +
> +_cluster9 {
> +   status = "disabled";
> +};
> +
> +_cluster10 {
> +   status = "disabled";
> +};
> +
> +_cluster11 {
> +   status = "disabled";
> +};
> +
> +_cluster0 {
> +   status = "disabled";
> +};
> +
> +_cluster1 {
> +   status = "disabled";
> +};
> +
> +_cluster2 {
> +   status = "disabled";
> +};
> +
> +_cluster3 {
> +   status = "disabled";
> +};
> +
> +_cluster4 {
> +   status = "disabled";
> +};
> +
> +_cluster5 {
> +   status = "disabled";
> +};
> +
> +_cluster6 {
> +   status = "disabled";
> +};
> +
> +_cluster7 {
> +   status = "disabled";
> +};
> +
> +_cluster8 {
> +   status = "disabled";
> +};
> +
> +_cluster9 {
> +   status = "disabled";
> +};
> +
> +_cluster10 {
> +   status = "disabled";
> +};
> +
> +_cluster11 {
> +   status = "disabled";
> +};
> --
> 2.36.1
>


-- 
With Regards
Sinthu Raja


[PATCH V3 12/12] include: configs: Update env for selecting right dtb

2022-12-27 Thread Sinthu Raja
From: Sinthu Raja 

Now that single defconfig shall be used for booting J721S2 EVM and
AM68 SK, the default device tree will not work for selecting dtb for
kernel. Update the findfdt env to select right dtb based on
board_name env variable.

Signed-off-by: Sinthu Raja 
Reviewed-by: Tom Rini 
---
 include/configs/j721s2_evm.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/configs/j721s2_evm.h b/include/configs/j721s2_evm.h
index 932d7d3c8c..715f03048a 100644
--- a/include/configs/j721s2_evm.h
+++ b/include/configs/j721s2_evm.h
@@ -32,6 +32,10 @@
"default_device_tree=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0"  \
"findfdt="  \
"setenv name_fdt ${default_device_tree};"   \
+   "if test $board_name = j721s2; then "   \
+   "setenv name_fdt k3-j721s2-common-proc-board.dtb; fi;" \
+   "if test $board_name = am68-sk; then "  \
+   "setenv name_fdt k3-am68-sk-base-board.dtb; fi;"\
"setenv fdtfile ${name_fdt}\0"  \
"name_kern=Image\0" \
"console=ttyS2,115200n8\0"  \
-- 
2.36.1



[PATCH V3 11/12] arm: dts: k3-am68-sk: Add r5 specific dt support

2022-12-27 Thread Sinthu Raja
From: Sinthu Raja 

Add initial support for AM68 SK device tree that runs on R5.

Signed-off-by: Sinthu Raja 
---
 arch/arm/dts/Makefile |   1 +
 arch/arm/dts/k3-am68-sk-r5-base-board.dts | 194 ++
 2 files changed, 195 insertions(+)
 create mode 100644 arch/arm/dts/k3-am68-sk-r5-base-board.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 6d49b7..be6e7b4e79 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1250,6 +1250,7 @@ dtb-$(CONFIG_SOC_K3_J721E) += 
k3-j721e-common-proc-board.dtb \
  k3-j721e-sk.dtb \
  k3-j721e-r5-sk.dtb
 dtb-$(CONFIG_SOC_K3_J721S2) += k3-am68-sk-base-board.dtb\
+  k3-am68-sk-r5-base-board.dtb\
   k3-j721s2-common-proc-board.dtb\
   k3-j721s2-r5-common-proc-board.dtb
 dtb-$(CONFIG_SOC_K3_AM642) += k3-am642-evm.dtb \
diff --git a/arch/arm/dts/k3-am68-sk-r5-base-board.dts 
b/arch/arm/dts/k3-am68-sk-r5-base-board.dts
new file mode 100644
index 00..46ee6c4422
--- /dev/null
+++ b/arch/arm/dts/k3-am68-sk-r5-base-board.dts
@@ -0,0 +1,194 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+/dts-v1/;
+
+#include "k3-am68-sk-som.dtsi"
+#include "k3-j721s2-ddr-evm-lp4-4266.dtsi"
+#include "k3-j721s2-ddr.dtsi"
+
+/ {
+   chosen {
+   firmware-loader = _loader0;
+   stdout-path = _uart8;
+   tick-timer = 
+   };
+
+   aliases {
+   remoteproc0 = 
+   remoteproc1 = _0;
+   };
+
+   fs_loader0: fs_loader@0 {
+   compatible = "u-boot,fs-loader";
+   u-boot,dm-pre-reloc;
+   };
+
+   a72_0: a72@0 {
+   compatible = "ti,am654-rproc";
+   reg = <0x0 0x00a9 0x0 0x10>;
+   power-domains = <_pds 61 TI_SCI_PD_EXCLUSIVE>,
+   <_pds 202 TI_SCI_PD_EXCLUSIVE>;
+   resets = <_reset 202 0>;
+   clocks = <_clks 61 1>;
+   assigned-clocks = <_clks 61 1>, <_clks 202 0>;
+   assigned-clock-parents = <_clks 61 2>;
+   assigned-clock-rates = <2>, <20>;
+   ti,sci = <>;
+   ti,sci-proc-id = <32>;
+   ti,sci-host-id = <10>;
+   u-boot,dm-spl;
+   };
+
+   clk_200mhz: dummy_clock_200mhz {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <2>;
+   u-boot,dm-spl;
+   };
+
+   clk_19_2mhz: dummy_clock_19_2mhz {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <1920>;
+   u-boot,dm-spl;
+   };
+};
+
+_mcu_wakeup {
+   sa3_secproxy: secproxy@4488 {
+   u-boot,dm-spl;
+   compatible = "ti,am654-secure-proxy";
+   reg = <0x0 0x4488 0x0 0x2>,
+ <0x0 0x4486 0x0 0x2>,
+ <0x0 0x4360 0x0 0x1>;
+   reg-names = "rt", "scfg", "target_data";
+   #mbox-cells = <1>;
+   };
+
+   mcu_secproxy: secproxy@2a38 {
+   compatible = "ti,am654-secure-proxy";
+   reg = <0x0 0x2a38 0x0 0x8>,
+ <0x0 0x2a40 0x0 0x8>,
+ <0x0 0x2a48 0x0 0x8>;
+   reg-names = "rt", "scfg", "target_data";
+   #mbox-cells = <1>;
+   u-boot,dm-spl;
+   };
+
+   sysctrler: sysctrler {
+   compatible = "ti,am654-system-controller";
+   mboxes= <_secproxy 4>, <_secproxy 5>, <_secproxy 5>;
+   mbox-names = "tx", "rx", "boot_notify";
+   u-boot,dm-spl;
+   };
+
+   dm_tifs: dm-tifs {
+   compatible = "ti,j721e-dm-sci";
+   ti,host-id = <3>;
+   ti,secure-host;
+   mbox-names = "rx", "tx";
+   mboxes= <_secproxy 21>,
+   <_secproxy 23>;
+   u-boot,dm-spl;
+   };
+};
+
+_pmx0 {
+   main_uart8_pins_default: main-uart8-pins-default {
+   pinctrl-single,pins = <
+   J721S2_IOPAD(0x0d0, PIN_INPUT, 11) /* (AF26) 
SPI0_CS1.UART8_RXD */
+   J721S2_IOPAD(0x0d4, PIN_OUTPUT, 11) /* (AH27) 
SPI0_CLK.UART8_TXD */
+   >;
+   };
+
+   main_mmc1_pins_default: main-mmc1-pins-default {
+   pinctrl-single,pins = <
+   J721S2_IOPAD(0x104, PIN_INPUT, 0) /* (P23) MMC1_CLK */
+   J721S2_IOPAD(0x108, PIN_INPUT, 0) /* (N24) MMC1_CMD */
+   J721S2_IOPAD(0x100, PIN_INPUT, 0) /* (###) MMC1_CLKLB */
+   J721S2_IOPAD(0x0fc, PIN_INPUT, 0) /* 

[PATCH V3 10/12] arm: dts: Add support for A72 specific AM68 Starter Kit Base Board

2022-12-27 Thread Sinthu Raja
From: Sinthu Raja 

The SK architecture comprises of baseboard and a SOM board. The
AM68 Starter Kit's baseboard contains most of the actual connectors,
power supply etc. The System on Module (SoM) is plugged on to the base
board. Therefore, add support for peripherals brought out in the base
board.

Schematics: https://www.ti.com/lit/zip/SPRR463

Signed-off-by: Sinthu Raja 
---
 arch/arm/dts/Makefile |   3 +-
 .../arm/dts/k3-am68-sk-base-board-u-boot.dtsi | 150 
 arch/arm/dts/k3-am68-sk-base-board.dts| 353 ++
 3 files changed, 505 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi
 create mode 100644 arch/arm/dts/k3-am68-sk-base-board.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 43951a7731..6d49b7 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1249,7 +1249,8 @@ dtb-$(CONFIG_SOC_K3_J721E) += 
k3-j721e-common-proc-board.dtb \
  k3-j7200-r5-common-proc-board.dtb \
  k3-j721e-sk.dtb \
  k3-j721e-r5-sk.dtb
-dtb-$(CONFIG_SOC_K3_J721S2) += k3-j721s2-common-proc-board.dtb\
+dtb-$(CONFIG_SOC_K3_J721S2) += k3-am68-sk-base-board.dtb\
+  k3-j721s2-common-proc-board.dtb\
   k3-j721s2-r5-common-proc-board.dtb
 dtb-$(CONFIG_SOC_K3_AM642) += k3-am642-evm.dtb \
  k3-am642-r5-evm.dtb \
diff --git a/arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi 
b/arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi
new file mode 100644
index 00..12faaae59b
--- /dev/null
+++ b/arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi
@@ -0,0 +1,150 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+/ {
+   chosen {
+   stdout-path = "serial2:115200n8";
+   tick-timer = 
+   };
+
+   aliases {
+   serial0 = _uart0;
+   serial1 = _uart0;
+   serial2 = _uart8;
+   i2c0 = _i2c0;
+   i2c1 = _i2c0;
+   i2c2 = _i2c1;
+   i2c3 = _i2c0;
+   ethernet0 = _port1;
+   mmc1 = _sdhci1;
+   };
+};
+
+_i2c0 {
+   u-boot,dm-spl;
+};
+
+_main {
+   u-boot,dm-spl;
+};
+
+_navss {
+   u-boot,dm-spl;
+};
+
+_mcu_wakeup {
+   u-boot,dm-spl;
+
+   timer1: timer@4040 {
+   compatible = "ti,omap5430-timer";
+   reg = <0x0 0x4040 0x0 0x80>;
+   ti,timer-alwon;
+   clock-frequency = <25000>;
+   u-boot,dm-spl;
+   };
+
+   chipid@4314 {
+   u-boot,dm-spl;
+   };
+};
+
+_navss {
+   u-boot,dm-spl;
+};
+
+_ringacc {
+   reg =   <0x0 0x2b80 0x0 0x40>,
+   <0x0 0x2b00 0x0 0x40>,
+   <0x0 0x2859 0x0 0x100>,
+   <0x0 0x2a50 0x0 0x4>,
+   <0x0 0x2844 0x0 0x4>;
+   reg-names = "rt", "fifos", "proxy_gcfg", "proxy_target", "cfg";
+   u-boot,dm-spl;
+};
+
+_udmap {
+   reg =   <0x0 0x285c 0x0 0x100>,
+   <0x0 0x284c 0x0 0x4000>,
+   <0x0 0x2a80 0x0 0x4>,
+   <0x0 0x284a 0x0 0x4000>,
+   <0x0 0x2aa0 0x0 0x4>,
+   <0x0 0x2840 0x0 0x2000>;
+   reg-names = "gcfg", "rchan", "rchanrt", "tchan",
+   "tchanrt", "rflow";
+   u-boot,dm-spl;
+};
+
+_proxy_main {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+   k3_sysreset: sysreset-controller {
+   compatible = "ti,sci-sysreset";
+   u-boot,dm-spl;
+   };
+};
+
+_pmx0 {
+   u-boot,dm-spl;
+};
+
+_uart8_pins_default {
+   u-boot,dm-spl;
+};
+
+_mmc1_pins_default {
+   u-boot,dm-spl;
+};
+
+_pmx0 {
+   u-boot,dm-spl;
+};
+
+_pds {
+   u-boot,dm-spl;
+};
+
+_clks {
+   u-boot,dm-spl;
+};
+
+_reset {
+   u-boot,dm-spl;
+};
+
+_uart8 {
+   u-boot,dm-spl;
+};
+
+_uart0 {
+   u-boot,dm-spl;
+};
+
+_uart0 {
+   u-boot,dm-spl;
+};
+
+_cpsw {
+   reg = <0x0 0x4600 0x0 0x20>,
+ <0x0 0x40f00200 0x0 0x8>;
+   reg-names = "cpsw_nuss", "mac_efuse";
+   /delete-property/ ranges;
+
+   cpsw-phy-sel@40f04040 {
+   compatible = "ti,am654-cpsw-phy-sel";
+   reg= <0x0 0x40f04040 0x0 0x4>;
+   reg-names = "gmii-sel";
+   };
+};
+
+_sdhci0 {
+   status = "disabled";
+};
+
+_sdhci1 {
+   u-boot,dm-spl;
+};
diff --git a/arch/arm/dts/k3-am68-sk-base-board.dts 
b/arch/arm/dts/k3-am68-sk-base-board.dts
new file mode 100644
index 00..8fc03324ab
--- /dev/null
+++ b/arch/arm/dts/k3-am68-sk-base-board.dts
@@ -0,0 +1,353 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ 

[PATCH V3 09/12] arm: dts: Add initial support for AM68 Starter Kit System on Module

2022-12-27 Thread Sinthu Raja
From: Sinthu Raja 

AM68 Starter Kit (SK) is a low cost, small form factor board designed
for TI’s AM68 SoC. TI’s AM68 SoC comprises of dual core A72, high
performance vision accelerators, hardware accelerators, latest C71x
DSP, high bandwidth real-time IPs for capture and display. The SoC is
power optimized to provide best in class performance for industrial
applications.

AM68 SK supports the following interfaces:
* 16 GB LPDDR4 RAM
* x1 Gigabit Ethernet interface
* x1 USB 3.1 Type-C port
* x2 USB 3.1 Type-A ports
* x1 PCIe M.2 M Key
* 512 Mbit OSPI flash
* x2 CSI2 Camera interface (RPi and TI Camera connector)
* 40-pin Raspberry Pi GPIO header

SK's System on Module (SoM) contains the SoC, PMIC, DDR and OSPI flash.
Therefore, add support for the components present on the SoM.

Schematics: https://www.ti.com/lit/zip/SPRR463
TRM: http://www.ti.com/lit/pdf/spruj28

Signed-off-by: Sinthu Raja 
---
 arch/arm/dts/k3-am68-sk-som.dtsi | 127 +++
 1 file changed, 127 insertions(+)
 create mode 100644 arch/arm/dts/k3-am68-sk-som.dtsi

diff --git a/arch/arm/dts/k3-am68-sk-som.dtsi b/arch/arm/dts/k3-am68-sk-som.dtsi
new file mode 100644
index 00..cb1c58fcd1
--- /dev/null
+++ b/arch/arm/dts/k3-am68-sk-som.dtsi
@@ -0,0 +1,127 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+/dts-v1/;
+
+#include "k3-j721s2.dtsi"
+#include 
+
+/ {
+   memory@8000 {
+   device_type = "memory";
+   /* 16 GB RAM */
+   reg = <0x00 0x8000 0x00 0x8000>,
+ <0x08 0x8000 0x03 0x8000>;
+   };
+
+   /* Reserving memory regions still pending */
+   reserved_memory: reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   secure_ddr: optee@9e80 {
+   reg = <0x00 0x9e80 0x00 0x0180>;
+   alignment = <0x1000>;
+   no-map;
+   };
+   };
+};
+
+_cluster0 {
+   status = "disabled";
+};
+
+_cluster1 {
+   status = "disabled";
+};
+
+_cluster2 {
+   status = "disabled";
+};
+
+_cluster3 {
+   status = "disabled";
+};
+
+_cluster4 {
+   status = "disabled";
+};
+
+_cluster5 {
+   status = "disabled";
+};
+
+_cluster6 {
+   status = "disabled";
+};
+
+_cluster7 {
+   status = "disabled";
+};
+
+_cluster8 {
+   status = "disabled";
+};
+
+_cluster9 {
+   status = "disabled";
+};
+
+_cluster10 {
+   status = "disabled";
+};
+
+_cluster11 {
+   status = "disabled";
+};
+
+_cluster0 {
+   status = "disabled";
+};
+
+_cluster1 {
+   status = "disabled";
+};
+
+_cluster2 {
+   status = "disabled";
+};
+
+_cluster3 {
+   status = "disabled";
+};
+
+_cluster4 {
+   status = "disabled";
+};
+
+_cluster5 {
+   status = "disabled";
+};
+
+_cluster6 {
+   status = "disabled";
+};
+
+_cluster7 {
+   status = "disabled";
+};
+
+_cluster8 {
+   status = "disabled";
+};
+
+_cluster9 {
+   status = "disabled";
+};
+
+_cluster10 {
+   status = "disabled";
+};
+
+_cluster11 {
+   status = "disabled";
+};
-- 
2.36.1



[PATCH V3 08/12] board: ti: j721s2: Add board_init and support for selecting DT based on EEPROM

2022-12-27 Thread Sinthu Raja
From: Sinthu Raja 

Add the board_init_f API for SPL and run the platform-required SoC
initialization.

Add the functionality for board name-based DTB selection from FIT
within SPL. This will make it easier to utilise one defconfig for
both the EVM and the SK.

Signed-off-by: Sinthu Raja 
---

Changes in V3:
=
Address review comments:
- Rework on DTB selection API clarity about mini-U-Boot vs EVM and family 
support as suggested.

v2: 
https://patchwork.ozlabs.org/project/uboot/cover/20221221135219.24702-9-sinthu.r...@ti.com/

 board/ti/j721s2/evm.c | 64 +++
 1 file changed, 64 insertions(+)

diff --git a/board/ti/j721s2/evm.c b/board/ti/j721s2/evm.c
index a7c4082a7a..a670332fc0 100644
--- a/board/ti/j721s2/evm.c
+++ b/board/ti/j721s2/evm.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "../common/board_detect.h"
 
@@ -202,3 +203,66 @@ int board_late_init(void)
 void spl_board_init(void)
 {
 }
+
+/* Support for the various EVM / SK families */
+#if defined(CONFIG_SPL_OF_LIST) && defined(CONFIG_TI_I2C_BOARD_DETECT)
+void do_dt_magic(void)
+{
+   int ret, rescan, mmc_dev = -1;
+   static struct mmc *mmc;
+
+   do_board_detect();
+
+   /*
+* Board detection has been done.
+* Let us see if another dtb wouldn't be a better match
+* for our board
+*/
+   if (IS_ENABLED(CONFIG_CPU_V7R)) {
+   ret = fdtdec_resetup();
+   if (!ret && rescan) {
+   dm_uninit();
+   dm_init_and_scan(true);
+   }
+   }
+
+   /*
+* Because of multi DTB configuration, the MMC device has
+* to be re-initialized after reconfiguring FDT inorder to
+* boot from MMC. Do this when boot mode is MMC and ROM has
+* not loaded SYSFW.
+*/
+   switch (spl_boot_device()) {
+   case BOOT_DEVICE_MMC1:
+   mmc_dev = 0;
+   break;
+   case BOOT_DEVICE_MMC2:
+   case BOOT_DEVICE_MMC2_2:
+   mmc_dev = 1;
+   break;
+   }
+
+   if (mmc_dev > 0 && !check_rom_loaded_sysfw()) {
+   ret = mmc_init_device(mmc_dev);
+   if (!ret) {
+   mmc = find_mmc_device(mmc_dev);
+   if (mmc) {
+   ret = mmc_init(mmc);
+   if (ret)
+   printf("mmc init failed with error: 
%d\n", ret);
+   }
+   }
+   }
+}
+#endif
+
+#ifdef CONFIG_SPL_BUILD
+void board_init_f(ulong dummy)
+{
+   k3_spl_init();
+#ifdef CONFIG_SPL_OF_LIST
+   do_dt_magic();
+#endif
+   k3_mem_init();
+}
+#endif
-- 
2.36.1



[PATCH V3 07/12] arch: mach-k3: Update board specific API name to K3 generic API name

2022-12-27 Thread Sinthu Raja
From: Sinthu Raja 

Although the board_init_f API initialises the SoC, the API name is
incorrectly specified and misleads the functionality. This file should
only include k3-specific functionality. Change the API's name to something
more K3-specific and separate the function to make it more modular.

Signed-off-by: Sinthu Raja 
Reviewed-by: Tom Rini 
---
 arch/arm/mach-k3/include/mach/sys_proto.h |  3 +++
 arch/arm/mach-k3/j721s2_init.c| 13 -
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-k3/include/mach/sys_proto.h 
b/arch/arm/mach-k3/include/mach/sys_proto.h
index 60287b261c..3d3d90d02d 100644
--- a/arch/arm/mach-k3/include/mach/sys_proto.h
+++ b/arch/arm/mach-k3/include/mach/sys_proto.h
@@ -19,4 +19,7 @@ int fdt_disable_node(void *blob, char *node_path);
 bool soc_is_j721e(void);
 bool soc_is_j7200(void);
 
+void k3_spl_init(void);
+void k3_mem_init(void);
+bool check_rom_loaded_sysfw(void);
 #endif
diff --git a/arch/arm/mach-k3/j721s2_init.c b/arch/arm/mach-k3/j721s2_init.c
index 0206b01d9e..09e55ed456 100644
--- a/arch/arm/mach-k3/j721s2_init.c
+++ b/arch/arm/mach-k3/j721s2_init.c
@@ -93,7 +93,7 @@ static void store_boot_info_from_rom(void)
   sizeof(struct rom_extended_boot_data));
 }
 
-void board_init_f(ulong dummy)
+void k3_spl_init(void)
 {
struct udevice *dev;
int ret;
@@ -154,6 +154,17 @@ void board_init_f(ulong dummy)
 
/* Output System Firmware version info */
k3_sysfw_print_ver();
+}
+
+bool check_rom_loaded_sysfw(void)
+{
+   return is_rom_loaded_sysfw();
+}
+
+void k3_mem_init(void)
+{
+   struct udevice *dev;
+   int ret;
 
if (IS_ENABLED(CONFIG_TARGET_J721S2_R5_EVM)) {
ret = uclass_get_device_by_name(UCLASS_MISC, "msmc", );
-- 
2.36.1



[PATCH V3 06/12] board: ti: j721s2: Add support for detecting multiple device trees

2022-12-27 Thread Sinthu Raja
From: Sinthu Raja 

Update the board_fit_config_name_match() to choose the right dtb
based on the board name read from EEPROM.

Also restrict multpile EEPROM reads by verifying if EEPROM is already
read

Signed-off-by: Sinthu Raja 
Reviewed-by: Tom Rini 
---
 board/ti/j721s2/evm.c | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/board/ti/j721s2/evm.c b/board/ti/j721s2/evm.c
index a3adb8704e..a7c4082a7a 100644
--- a/board/ti/j721s2/evm.c
+++ b/board/ti/j721s2/evm.c
@@ -72,16 +72,6 @@ int dram_init_banksize(void)
return 0;
 }
 
-#ifdef CONFIG_SPL_LOAD_FIT
-int board_fit_config_name_match(const char *name)
-{
-   if (!strcmp(name, "k3-j721s2-common-proc-board"))
-   return 0;
-
-   return -1;
-}
-#endif
-
 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
@@ -111,6 +101,9 @@ int do_board_detect(void)
 {
int ret;
 
+   if (board_ti_was_eeprom_read())
+   return 0;
+
ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
 CONFIG_EEPROM_CHIP_ADDRESS);
if (ret) {
@@ -179,6 +172,23 @@ static void setup_serial(void)
 }
 #endif
 
+#ifdef CONFIG_SPL_LOAD_FIT
+int board_fit_config_name_match(const char *name)
+{
+   bool eeprom_read = board_ti_was_eeprom_read();
+
+   if (!eeprom_read || board_is_j721s2_som()) {
+   if (!strcmp(name, "k3-j721s2-common-proc-board"))
+   return 0;
+   } else if (!eeprom_read || board_is_am68_sk_som()) {
+   if (!strcmp(name, "k3-am68-sk-base-board"))
+   return 0;
+   }
+
+   return -1;
+}
+#endif
+
 int board_late_init(void)
 {
if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {
-- 
2.36.1



[PATCH V3 05/12] board: ti: j721s2: Enable support for reading EEPROM at next alternate address

2022-12-27 Thread Sinthu Raja
From: Sinthu Raja 

J721S2 EVM has EEPROM populated at 0x50. AM68 SK has EEPROM populated at
next address 0x51 in order to be compatible with RPi. So start looking
for TI specific EEPROM at 0x50, if not found look for EEPROM at 0x51.

Signed-off-by: Sinthu Raja 
Reviewed-by: Tom Rini 
---
 board/ti/j721s2/evm.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/board/ti/j721s2/evm.c b/board/ti/j721s2/evm.c
index f223ccf2c6..a3adb8704e 100644
--- a/board/ti/j721s2/evm.c
+++ b/board/ti/j721s2/evm.c
@@ -113,9 +113,15 @@ int do_board_detect(void)
 
ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
 CONFIG_EEPROM_CHIP_ADDRESS);
-   if (ret)
-   pr_err("Reading on-board EEPROM at 0x%02x failed %d\n",
-  CONFIG_EEPROM_CHIP_ADDRESS, ret);
+   if (ret) {
+   printf("EEPROM not available at 0x%02x, trying to read at 
0x%02x\n",
+  CONFIG_EEPROM_CHIP_ADDRESS, CONFIG_EEPROM_CHIP_ADDRESS + 
1);
+   ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
+CONFIG_EEPROM_CHIP_ADDRESS + 
1);
+   if (ret)
+   pr_err("Reading on-board EEPROM at 0x%02x failed %d\n",
+   CONFIG_EEPROM_CHIP_ADDRESS + 1, ret);
+   }
 
return ret;
 }
-- 
2.36.1



[PATCH V3 04/12] board: ti: j721s2: Add support to update board_name for am68-sk

2022-12-27 Thread Sinthu Raja
From: Sinthu Raja 

Update setup_board_eeprom_env() to choose the right board name
for am68-sk.

Signed-off-by: Sinthu Raja 
Reviewed-by: Tom Rini 
---
 board/ti/j721s2/evm.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/board/ti/j721s2/evm.c b/board/ti/j721s2/evm.c
index e09adc8ad3..f223ccf2c6 100644
--- a/board/ti/j721s2/evm.c
+++ b/board/ti/j721s2/evm.c
@@ -26,8 +26,6 @@
 
 #include "../common/board_detect.h"
 
-#define board_is_j721s2_som()  board_ti_k3_is("J721S2X-PM1-SOM")
-
 DECLARE_GLOBAL_DATA_PTR;
 
 int board_init(void)
@@ -101,6 +99,14 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 #endif
 
 #ifdef CONFIG_TI_I2C_BOARD_DETECT
+/*
+ * Functions specific to EVM and SK designs of J721S2/AM68 family.
+ */
+
+#define board_is_j721s2_som()  board_ti_k3_is("J721S2X-PM1-SOM")
+
+#define board_is_am68_sk_som() board_ti_k3_is("AM68-SK-SOM")
+
 int do_board_detect(void)
 {
int ret;
@@ -136,6 +142,8 @@ static void setup_board_eeprom_env(void)
 
if (board_is_j721s2_som())
name = "j721s2";
+   else if (board_is_am68_sk_som())
+   name = "am68-sk";
else
printf("Unidentified board claims %s in eeprom header\n",
   board_ti_get_name());
-- 
2.36.1



[PATCH V3 03/12] configs: j721s2_evm: Enable configs to store env in MMC FAT partition

2022-12-27 Thread Sinthu Raja
From: Sinthu Raja 

J721S2 EVM used to store env on eMMC, since EVM and SK uses same
defconfig and there is no eMMC on SK, we need to keep env in an
interface which available on both EVM and SK. So, save env in FAT
partition of MMC SD Card.

Enable defconfigs relevant for storing env on FAT partition of MMC.

Signed-off-by: Sinthu Raja 
---
 configs/j721s2_evm_a72_defconfig | 3 ++-
 configs/j721s2_evm_r5_defconfig  | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/configs/j721s2_evm_a72_defconfig b/configs/j721s2_evm_a72_defconfig
index 75b4e52238..1db5b47a24 100644
--- a/configs/j721s2_evm_a72_defconfig
+++ b/configs/j721s2_evm_a72_defconfig
@@ -92,7 +92,8 @@ CONFIG_SPL_MULTI_DTB_FIT=y
 CONFIG_OF_LIST="k3-j721s2-common-proc-board k3-am68-sk-base-board"
 CONFIG_SPL_MULTI_DTB_FIT_NO_COMPRESSION=y
 CONFIG_ENV_OVERWRITE=y
-CONFIG_ENV_IS_IN_MMC=y
+CONFIG_ENV_IS_IN_FAT=y
+CONFIG_ENV_FAT_DEVICE_AND_PART="1:1"
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NET_RANDOM_ETHADDR=y
diff --git a/configs/j721s2_evm_r5_defconfig b/configs/j721s2_evm_r5_defconfig
index 7418dc2900..f7805e83e0 100644
--- a/configs/j721s2_evm_r5_defconfig
+++ b/configs/j721s2_evm_r5_defconfig
@@ -88,6 +88,7 @@ CONFIG_SPL_MULTI_DTB_FIT=y
 CONFIG_SPL_OF_LIST="k3-j721s2-r5-common-proc-board k3-am68-sk-r5-base-board"
 CONFIG_SPL_MULTI_DTB_FIT_NO_COMPRESSION=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_ENV_OVERWRITE=y
 CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_REGMAP=y
-- 
2.36.1



[PATCH V3 00/12] AM68: Add support for AM68 Starter Kit

2022-12-27 Thread Sinthu Raja
From: Sinthu Raja 

Hi All,
This series of patch add initial support for AM68 starter kit.
Design files can be referrred from https://www.ti.com/lit/zip/SPRR463

Refer below link to J721S2/AM68 Technical Reference Manual for further details:
http://www.ti.com/lit/pdf/spruj28

Link to kerenl patches:
https://lore.kernel.org/linux-arm-kernel/20221115154832.19759-4-sinthu.r...@ti.com/T/#mff5847ea8cdef49337d224b7147f877bcc833aee

Changes in V3:
=
Address review comments:
- Rework on DTB selection API clarity about mini-U-Boot vs EVM and family 
support as suggested.
  * board: ti: j721s2: Add board_init and support for selecting DT based
on EEPROM

Changes in V2:
=
Address review comments:
- Remove support for detecting multiple device trees using different DTB
- Remove board specific API from K3 generic file 
(arch/arm/mach-k3/j721s2_init.c) and moved to board specific file 
(board/ti/j721s2/evm.c).
  * arch: mach-k3: Update board specific API name to K3 generic API name
  * board: ti: j721s2: Add board_init and support for selecting DT based
on EEPROM
- Move board_is_xxx within CONFIG_TI_I2C_BOARD_DETECT block to maintain the 
"mini" U-Boot concept for this SoC.

V1: 
https://patchwork.ozlabs.org/project/uboot/cover/20221027104846.11820-1-sinthu.r...@ti.com/
V2: 
https://patchwork.ozlabs.org/project/uboot/cover/20221221135219.24702-1-sinthu.r...@ti.com/

Sinthu Raja (12):
  configs: j721s2_evm_r5: Enable support for building multiple dtbs into
FIT
  configs: j721s2_evm_a72: Enable support for building multiple dtbs
into FIT
  configs: j721s2_evm: Enable configs to store env in MMC FAT partition
  board: ti: j721s2: Add support to update board_name for am68-sk
  board: ti: j721s2: Enable support for reading EEPROM at next alternate
address
  board: ti: j721s2: Add support for detecting multiple device trees
  arch: mach-k3: Update board specific API name to K3 generic API name
  board: ti: j721s2: Add board_init and support for selecting DT based
on EEPROM
  arm: dts: Add initial support for AM68 Starter Kit System on Module
  arm: dts: Add support for A72 specific AM68 Starter Kit Base Board
  arm: dts: k3-am68-sk: Add r5 specific dt support
  include: configs: Update env for selecting right dtb

 arch/arm/dts/Makefile |   4 +-
 .../arm/dts/k3-am68-sk-base-board-u-boot.dtsi | 150 
 arch/arm/dts/k3-am68-sk-base-board.dts| 353 ++
 arch/arm/dts/k3-am68-sk-r5-base-board.dts | 194 ++
 arch/arm/dts/k3-am68-sk-som.dtsi  | 127 +++
 arch/arm/mach-k3/include/mach/sys_proto.h |   3 +
 arch/arm/mach-k3/j721s2_init.c|  13 +-
 board/ti/j721s2/evm.c | 118 +-
 configs/j721s2_evm_a72_defconfig  |   4 +-
 configs/j721s2_evm_r5_defconfig   |   4 +
 include/configs/j721s2_evm.h  |   4 +
 11 files changed, 956 insertions(+), 18 deletions(-)
 create mode 100644 arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi
 create mode 100644 arch/arm/dts/k3-am68-sk-base-board.dts
 create mode 100644 arch/arm/dts/k3-am68-sk-r5-base-board.dts
 create mode 100644 arch/arm/dts/k3-am68-sk-som.dtsi

-- 
2.36.1



[PATCH V3 01/12] configs: j721s2_evm_r5: Enable support for building multiple dtbs into FIT

2022-12-27 Thread Sinthu Raja
From: Sinthu Raja 

Enable configs for building multiple dtbs into a single fit image
and load the right dtb for next stage. This will help to use same
defconfig for both EVM and SK.

Signed-off-by: Sinthu Raja 
---
 configs/j721s2_evm_r5_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/j721s2_evm_r5_defconfig b/configs/j721s2_evm_r5_defconfig
index 2de5d87bdb..7418dc2900 100644
--- a/configs/j721s2_evm_r5_defconfig
+++ b/configs/j721s2_evm_r5_defconfig
@@ -84,6 +84,9 @@ CONFIG_CMD_TIME=y
 CONFIG_CMD_FAT=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
+CONFIG_SPL_MULTI_DTB_FIT=y
+CONFIG_SPL_OF_LIST="k3-j721s2-r5-common-proc-board k3-am68-sk-r5-base-board"
+CONFIG_SPL_MULTI_DTB_FIT_NO_COMPRESSION=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
-- 
2.36.1



[PATCH V3 02/12] configs: j721s2_evm_a72: Enable support for building multiple dtbs into FIT

2022-12-27 Thread Sinthu Raja
From: Sinthu Raja 

Enable configs for building multiple dtbs into a single fit image
and load the right dtb for next stage. Add k3-am68-sk-base-board
dtb along with evm dtb inside DTB FIT image. This helps to use same
defconfig for both EVM and SK

Signed-off-by: Sinthu Raja 
---
 configs/j721s2_evm_a72_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/j721s2_evm_a72_defconfig b/configs/j721s2_evm_a72_defconfig
index 2b2f80c4aa..75b4e52238 100644
--- a/configs/j721s2_evm_a72_defconfig
+++ b/configs/j721s2_evm_a72_defconfig
@@ -89,6 +89,7 @@ CONFIG_CMD_UBI=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_SPL_MULTI_DTB_FIT=y
+CONFIG_OF_LIST="k3-j721s2-common-proc-board k3-am68-sk-base-board"
 CONFIG_SPL_MULTI_DTB_FIT_NO_COMPRESSION=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_MMC=y
-- 
2.36.1