Re: [PATCH 3/5] efi_loader: use correct type for AllocatePages, AllocatePool

2021-08-17 Thread AKASHI Takahiro
On Wed, Aug 18, 2021 at 06:50:40AM +0200, Heinrich Schuchardt wrote:
> Am 18. August 2021 03:45:28 MESZ schrieb AKASHI Takahiro 
> :
> >Heinrich,
> >
> >On Tue, Aug 17, 2021 at 06:02:23PM +0200, Heinrich Schuchardt wrote:
> >> Use enum efi_memory_type and enum_allocate_type in the definitions of the
> >> efi_allocate_pages(), efi_allocate_pool().
> >> 
> >> In the external UEFI API leave the type as int as the UEFI specification
> >> explicitly requires that enums use a 32bit type.
> >> 
> >> Signed-off-by: Heinrich Schuchardt 
> >> ---
> >>  include/efi_loader.h| 9 +
> >>  lib/efi_loader/efi_memory.c | 5 +++--
> >>  2 files changed, 8 insertions(+), 6 deletions(-)
> >> 
> >> diff --git a/include/efi_loader.h b/include/efi_loader.h
> >> index 32cb8d0f1e..c440962fe5 100644
> >> --- a/include/efi_loader.h
> >> +++ b/include/efi_loader.h
> >> @@ -676,13 +676,14 @@ struct efi_device_path *efi_get_dp_from_boot(const 
> >> efi_guid_t guid);
> >>  /* Generic EFI memory allocator, call this to get memory */
> >>  void *efi_alloc(uint64_t len, int memory_type);
> >>  /* More specific EFI memory allocator, called by EFI payloads */
> >> -efi_status_t efi_allocate_pages(int type, int memory_type, efi_uintn_t 
> >> pages,
> >> -  uint64_t *memory);
> >> +efi_status_t efi_allocate_pages(enum efi_allocate_type type,
> >> +  enum efi_memory_type memory_type,
> >> +  efi_uintn_t pages, uint64_t *memory);
> >>  /* EFI memory free function. */
> >>  efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages);
> >>  /* EFI memory allocator for small allocations */
> >> -efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size,
> >> - void **buffer);
> >> +efi_status_t efi_allocate_pool(enum efi_memory_type pool_type,
> >> + efi_uintn_t size, void **buffer);
> >>  /* EFI pool memory free function. */
> >>  efi_status_t efi_free_pool(void *buffer);
> >>  /* Returns the EFI memory map */
> >> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
> >> index be2f655dff..f4acbee4f9 100644
> >> --- a/lib/efi_loader/efi_memory.c
> >> +++ b/lib/efi_loader/efi_memory.c
> >> @@ -454,7 +454,8 @@ static uint64_t efi_find_free_memory(uint64_t len, 
> >> uint64_t max_addr)
> >>   * @memoryallocated memory
> >>   * @returnstatus code
> >>   */
> >> -efi_status_t efi_allocate_pages(int type, int memory_type,
> >> +efi_status_t efi_allocate_pages(enum efi_allocate_type type,
> >> +  enum efi_memory_type memory_type,
> >>efi_uintn_t pages, uint64_t *memory)
> >>  {
> >>u64 len = pages << EFI_PAGE_SHIFT;
> >> @@ -556,7 +557,7 @@ efi_status_t efi_free_pages(uint64_t memory, 
> >> efi_uintn_t pages)
> >>   * @buffer:   allocated memory
> >>   * Return:status code
> >>   */
> >> -efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void 
> >> **buffer)
> >> +efi_status_t efi_allocate_pool(enum efi_memory_type pool_type, 
> >> efi_uintn_t size, void **buffer)
> >
> >Given the purpose of this patch series, I think that the second argument
> >of this function should be renamed from "pool_type" to "memory_type"
> >which is also used in efi_allocate_pages() to avoid any confusion.
> >(and the description for @pool_type as well)
> 
> pool_type is the name used by the UEFI specification.

So what?

(for efi_allocate_pages())
!/*
! * Allocate memory pages.
! *
! * @typetype of allocation to be performed
! * @memory_type usage type of the allocated memory

!/**
! * efi_allocate_pool - allocate memory from pool
! *
! * @pool_type:  type of the pool from which memory is to be allocated

You give the same type of arguments different names and explanation.
I think that could be confusing.
It is worth noting that efi_allocate_pool() directly passes
the "pool_type" variable to efi_allocate_pages().

-Takahiro Akashi

> Best regards
> 
> Heinrich
> 
> >
> >Otherwise, it looks good.
> >
> >-Takahiro Akashi
> >
> >
> >>  {
> >>efi_status_t r;
> >>u64 addr;
> >> -- 
> >> 2.30.2
> >> 
> 


Re: U-Boot sunxi DM_I2C migration?

2021-08-17 Thread Samuel Holland
Hi all,

On 8/17/21 2:23 PM, Tom Rini wrote:
> On Thu, Aug 12, 2021 at 05:40:34PM -0400, Tom Rini wrote:
>> On Thu, Aug 12, 2021 at 10:22:07PM +0100, Andre Przywara wrote:
>>> On Thu, 12 Aug 2021 13:49:30 -0400
>>> Tom Rini  wrote:
>>>
>>> Hi Tom,
>>>
 As I try and migrate more CONFIG symbols to be Kconfig only, I see that
 sunxi is still using the legacy I2C drivers.  Is there something
 specific holding up migration?  Thanks!
>>>
>>> Do you mean a DM_I2C conversion, or just moving those base address
>>> symbols to Kconfig? The latter is rather easy, let me know if I should
>>> give it a shot.
>>>
>>> For DM_I2C, it's the usual sunxi issue: we are using both: DM_I2C and
>>> DT based probing for U-Boot proper, and hardcoded CONFIG_ symbols for
>>> the SPL. *Some* boards need the set up the PMIC early (for increasing
>>> the CPU frequency or setting the proper DRAM voltage), so this needs to
>>> be done in the SPL. I don't know how to fix this "properly",
>>> but introducing DM (and DT) into the SPL is surely not worth the
>>> trouble. Alternatively we could have a separate, cut-down SPL-only
>>> driver, like we have for SPI (arch/arm/mach-sunxi/spl_spi_sunxi.c),
>>> but not sure that's really better.
>>>
>>> If there is something in particular that annoys you about the
>>> situation, we could try to improve this particular issue instead?
>>> Moving the non-DM code into a separate file, maybe?
>>
>> I'm working on the symbols now (since it gets tricky).  The first
>> example I pulled out was Hummingbird_A31 which does have legacy I2C and
>> does not set DM_I2C, which is what set me down the more worrying path.
>> If you can confirm that no, really, it's just SPL that's not using
>> DM_I2C that's OK enough for now, we can sort out what the best but
>> probably still unideal solution is long term for SPL.
> 
> As I'm converting the symbols to Kconfig now (and adding
> SPL_SYS_I2C_LEGACY), what I'm seeing on sunxi is a whole lot of platform
> enabling the legacy driver in full U-Boot and not DM_I2C.  Now it's
> entirely possible the follow up solution really is just to switch to
> DM_I2C (and continue SPL_SYS_I2C_LEGACY) and it would be a fairly
> trivial switch.  But I'm not in a good position to make that change and
> test it, so I'm asking you to please, once I've posted this series to
> add SPL_SYS_I2C_LEGACY

I am aware of three places where sunxi boards use legacy I2C in U-Boot proper:
 - The i2c_soft usage enabled by CONFIG_VIDEO_LCD_PANEL_I2C
 - The axp_gpio driver (through pmic_bus_*)
 - do_poweroff() in drivers/power/axp*.c (through pmic_bus_write)

I have a patch series for converting all of these that I will be sending within
the next few days. The two tricky parts are:
 - I have no way to test either board that uses VIDEO_LCD_PANEL_I2C,
   so I do not want to rely on bus number ordering.
 - I am trying to arrange changes in an order that never breaks any
   functionality, so some driver must be temporarily compatible with
   both legacy and DM I2C.

I will rebase this on top of the Kconfig series before sending it.

Regards,
Samuel


Re: [RFC] imx8mm-evk: Generate a bootable flash.bin again

2021-08-17 Thread Heiko Schocher
Hello Fabio,

On 18.08.21 03:44, Fabio Estevam wrote:
> Hi Heiko,
> 
> On Tue, Aug 17, 2021 at 12:56 AM Heiko Schocher  wrote:
> 
>> I am unsure here, if it makes sense to overwrite flash.bin with the
>> binary which contains SPL and u-boot.itb. May others want to use
>> them (as I currently use them for signing them)
> 
> I thought about that too. Frieder suggested I use a different name for
> the SPL file, such as spl.bin.
> 
> I am concerned that renaming flash.bin to spl.bin may break i.MX8MM
> targets that do not use binman, such as the verdin-imx8mm board.

Hmm... okay, but I do not understand why spl code is named flash.bin
than?

spl.bin seems better to me.

>> Why not imx-boot as image name as in NXP sources?
> 
> NXP U-Boot also generates the final binary called "flash.bin"

What do you mean with "final binary"? The binary which contains
SPL and u-boot (and all other needed binaries)?

If so, is this really called flash.bin? So *same* name as "SPL only"
code? I could not believe this...

NXP code does this not for all imx8 derivates, see comment:

https://github.com/Freescale/meta-freescale/blob/master/recipes-bsp/u-boot/u-boot-fslc_2021.07.bb#L31

But yes, the container is named "flash.bin"...

> My main motivation for sending this RFC patch is to avoid imx8mm-evk
> breakage when people upgrade
> to U-Boor 2021.07.

U-Boot 2021.07 is broken? Or do you mean 2021.10?

Ah, *now* I got it commit "8996e6b7c6a1" introduced a SPL based "flash.bin"
through arch/arm/dts/imx8mm-evk-u-boot.dtsi:

+   flash {
+   mkimage {
+   args = "-n spl/u-boot-spl.cfgout -T imx8mimage -e 
0x7e1000";
+
+   blob {
+   filename = "u-boot-spl-ddr.bin";
+   };
+   };
+   };

-> now we have a "flash.bin" with SPL only code and a "flash.bin"
Makefile target which produces "flash.bin" which is a container
of SPL, U-Boot, dtb, atf, ... and may much more binaries...

:-(

Added Peng to cc, as he did this conversion for imx8mm-evk-u-boot.dtsi

> Prior to 2021.07: only flash.bin was required. Yocto recipe, for
> example, will no longer produce a bootable image
> after the upgrade to 2021.07. This is the breakage I would like to avoid.

I vote for renaming flash.bin (in SPL case) to spl.bin. It seems to
me there are many imx8*-u-boot.dtsi file now which use this part:

+   flash {
+   mkimage {
+   args = "-n spl/u-boot-spl.cfgout -T imx8mimage -e 
0x7e1000";
+
+   blob {
+   filename = "u-boot-spl-ddr.bin";
+   };
+   };
+   };

But may this rename is no problem, as all boards use the "flash.bin" container?

I don;t know...

bye,
Heiko
-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: EFI from usb HDD

2021-08-17 Thread AKASHI Takahiro
On Tue, Aug 17, 2021 at 09:20:31AM +0200, Michal Simek wrote:
> 
> 
> On 8/12/21 11:43 AM, AKASHI Takahiro wrote:
> > On Fri, Jul 30, 2021 at 08:22:18AM +0200, Michal Simek wrote:
> >>
> >>
> >> On 7/30/21 7:33 AM, AKASHI Takahiro wrote:
> >>> On Fri, Jul 30, 2021 at 06:41:01AM +0200, Michal Simek wrote:
> 
> 
>  On 7/30/21 4:35 AM, AKASHI Takahiro wrote:
> > On Thu, Jul 29, 2021 at 04:09:32PM +0200, Michal Simek wrote:
> >> Hi,
> >>
> >> On 6/10/21 2:59 PM, AKASHI Takahiro wrote:
> >>> On Thu, Jun 10, 2021 at 02:31:46PM +0200, Michal Simek wrote:
> 
> 
>  On 6/10/21 12:51 PM, Heinrich Schuchardt wrote:
> > On 6/10/21 12:04 PM, Michal Simek wrote:
> >> Hi,
> >>
> >> On 6/10/21 11:47 AM, Heinrich Schuchardt wrote:
> >>> On 6/10/21 10:44 AM, Michal Simek wrote:
>  Hi,
> 
>  I am playing with booting from USB via EFI. And I see very weird
>  behavior. I have burnt image with grub to USB flashdisk and I 
>  have
>  tested it on 3 zynqmp boards. zcu102, zcu104 and SOM Kria board.
>  On zcu102 grub is going to boot menu and everything is working 
>  fine as
>  expected.
>  On zcu104 and SOM Kria I am able to get grub not to menu. When I 
>  list
>  partitions in grub I see that only SDs are listed:
>  grub> ls
>  (hd0) (hd0,msdos1) (hd1) (hd1,msdos1)
> >>>
> >>> Hello Michal,
> >>>
> >>> thanks for sharing your observations.
> >>>
> >>> What devices do hd0 and hd1 relate to?
> >>>
> 
>  On zcu102(working board) I also see usb(gpt) partitions and SD.
>  grub> ls
>  (hd0) (hd0,gpt2) (hd0,gpt1) (hd1) (hd1,msdos1)
> 
> >>>
> >>> GPT and MBR partitioning are independent of the device type.
> >>>
> 
>  On zcu104 I see one more error message
>  "PE image measurement failed"
> >>>
> >>> This is related to CONFIG_EFI_TCG2_PROTOCOL=y. Do you have a 
> >>> TPMv2? This
> >>> will not stop disk enumeration.
> >>>
>  But I can't see it on SOM.
> 
>  U-Boot image is just the same for all boards. I am using generic
>  xilinx_zynqmp_virt_defconfig.
> 
>  When I compare DT description for USB between zcu102 and zcu104 
>  they
>  are
>  the same. SOM doesn't have usb enabled by default (but I enabled 
>  it)
>  but
>  grub starts which means that communication with USB is fine.
> 
>  It is based on my latest patches available here.
>  u-boot/custodians/u-boot-microblaze.git (usb-efi-issue branch)
> 
>  Also when I list usb I see all partitions just fine.
>  ZynqMP> part list usb 0
> 
>  Partition Map for USB device 0  --   Partition Type: EFI
> 
>  Part    Start LBA   End LBA Name
>    Attributes
>    Type GUID
>    Partition GUID
>      1 0x0800  0x001007fe  "Microsoft basic data"
>    attrs:  0x
>    type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
>    type:   data
>    guid:   0e7f8b3d-296b-4720-be9d-c4687d3c4a77
>      2 0x00100800  0x001197fe  "Microsoft basic data"
>    attrs:  0x
>    type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
>    type:   data
>    guid:   8892eddc-231a-4e6e-a5e1-c310f4482fb7
> 
> 
>  Do you have any idea why on one system is working fine to get to 
>  menu
>  and on others there is an issue to get all partitions even 
>  u-boot is
>  able to see them and can work with them.
> 
>  Thanks,
>  Michal
> 
> >>>
> >>> Where is the GRUB binary? - If it is in EFI/boot/bootaa64.efi, it 
> >>> could
> >>> be that the USB sub-system is simply not initialized yet when the 
> >>> boot
> >>> manager is called by distroboot.
> >>>
> >>> For testing partition detection in the UEFI sub-system it is 
> >>> enough
> >>> to run
> >>>
> >>>  efidebug devices
> >>>
> >>> Until yesterday we had a problem with partition numbers >= 10, cf.
> >>>
> >>> efi_loader: partition numbers are hexadecimal
> >>> 

Re: [PATCH 3/5] efi_loader: use correct type for AllocatePages, AllocatePool

2021-08-17 Thread Heinrich Schuchardt
Am 18. August 2021 03:45:28 MESZ schrieb AKASHI Takahiro 
:
>Heinrich,
>
>On Tue, Aug 17, 2021 at 06:02:23PM +0200, Heinrich Schuchardt wrote:
>> Use enum efi_memory_type and enum_allocate_type in the definitions of the
>> efi_allocate_pages(), efi_allocate_pool().
>> 
>> In the external UEFI API leave the type as int as the UEFI specification
>> explicitly requires that enums use a 32bit type.
>> 
>> Signed-off-by: Heinrich Schuchardt 
>> ---
>>  include/efi_loader.h| 9 +
>>  lib/efi_loader/efi_memory.c | 5 +++--
>>  2 files changed, 8 insertions(+), 6 deletions(-)
>> 
>> diff --git a/include/efi_loader.h b/include/efi_loader.h
>> index 32cb8d0f1e..c440962fe5 100644
>> --- a/include/efi_loader.h
>> +++ b/include/efi_loader.h
>> @@ -676,13 +676,14 @@ struct efi_device_path *efi_get_dp_from_boot(const 
>> efi_guid_t guid);
>>  /* Generic EFI memory allocator, call this to get memory */
>>  void *efi_alloc(uint64_t len, int memory_type);
>>  /* More specific EFI memory allocator, called by EFI payloads */
>> -efi_status_t efi_allocate_pages(int type, int memory_type, efi_uintn_t 
>> pages,
>> -uint64_t *memory);
>> +efi_status_t efi_allocate_pages(enum efi_allocate_type type,
>> +enum efi_memory_type memory_type,
>> +efi_uintn_t pages, uint64_t *memory);
>>  /* EFI memory free function. */
>>  efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages);
>>  /* EFI memory allocator for small allocations */
>> -efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size,
>> -   void **buffer);
>> +efi_status_t efi_allocate_pool(enum efi_memory_type pool_type,
>> +   efi_uintn_t size, void **buffer);
>>  /* EFI pool memory free function. */
>>  efi_status_t efi_free_pool(void *buffer);
>>  /* Returns the EFI memory map */
>> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
>> index be2f655dff..f4acbee4f9 100644
>> --- a/lib/efi_loader/efi_memory.c
>> +++ b/lib/efi_loader/efi_memory.c
>> @@ -454,7 +454,8 @@ static uint64_t efi_find_free_memory(uint64_t len, 
>> uint64_t max_addr)
>>   * @memory  allocated memory
>>   * @return  status code
>>   */
>> -efi_status_t efi_allocate_pages(int type, int memory_type,
>> +efi_status_t efi_allocate_pages(enum efi_allocate_type type,
>> +enum efi_memory_type memory_type,
>>  efi_uintn_t pages, uint64_t *memory)
>>  {
>>  u64 len = pages << EFI_PAGE_SHIFT;
>> @@ -556,7 +557,7 @@ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t 
>> pages)
>>   * @buffer: allocated memory
>>   * Return:  status code
>>   */
>> -efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void 
>> **buffer)
>> +efi_status_t efi_allocate_pool(enum efi_memory_type pool_type, efi_uintn_t 
>> size, void **buffer)
>
>Given the purpose of this patch series, I think that the second argument
>of this function should be renamed from "pool_type" to "memory_type"
>which is also used in efi_allocate_pages() to avoid any confusion.
>(and the description for @pool_type as well)

pool_type is the name used by the UEFI specification.

Best regards

Heinrich

>
>Otherwise, it looks good.
>
>-Takahiro Akashi
>
>
>>  {
>>  efi_status_t r;
>>  u64 addr;
>> -- 
>> 2.30.2
>> 



Re: [PATCH 11/13] Convert CONFIG_SYS_I2C_SOFT et al to Kconfig

2021-08-17 Thread Samuel Holland
Hi Tom,

On 8/17/21 4:59 PM, Tom Rini wrote:
> This converts the following to Kconfig:
>CONFIG_SYS_I2C_SOFT
>CONFIG_SYS_I2C_SOFT_SPEED
>CONFIG_SYS_I2C_SOFT_SLAVE
> 
> Signed-off-by: Tom Rini 
> ---
>  board/sunxi/board.c  |  2 +-
>  configs/Colombus_defconfig   |  3 +++
>  configs/UTOO_P66_defconfig   |  3 +++
>  configs/ethernut5_defconfig  |  2 ++
>  configs/km_kirkwood_128m16_defconfig |  2 ++
>  configs/km_kirkwood_defconfig|  2 ++
>  configs/km_kirkwood_pci_defconfig|  2 ++
>  configs/kmcoge5un_defconfig  |  2 ++
>  configs/kmnusa_defconfig |  2 ++
>  configs/kmsuse2_defconfig|  2 ++
>  configs/snapper9260_defconfig|  2 ++
>  configs/snapper9g20_defconfig|  2 ++
>  drivers/i2c/Kconfig  | 19 +++
>  include/configs/ethernut5.h  |  3 ---
>  include/configs/km/km_arm.h  |  4 
>  include/configs/snapper9260.h|  3 ---
>  include/configs/sunxi-common.h   |  5 +
>  17 files changed, 45 insertions(+), 15 deletions(-)
> 
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index 1a46100e408d..2b7d655678d0 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -47,7 +47,7 @@
>  #include 
>  #include 
>  
> -#if defined CONFIG_VIDEO_LCD_PANEL_I2C && !(defined CONFIG_SPL_BUILD)
> +#if defined(CONFIG_VIDEO_LCD_PANEL_I2C)

The soft i2c bus is only used by a DM driver (sunxi_de), and DM is not enabled
in SPL, so this bus is not needed in SPL.

This worked because the condition for CONFIG_SYS_I2C_SOFT, and thus for
compiling the driver, also included !(defined CONFIG_SPL_BUILD).

Your change will increase the size of SPL, but I think it should be fine. The
increase will be temporary, as I am working on a patch series to finish the
DM_I2C conversion for sunxi.

Cheers,
Samuel

> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> index 958b850da4a8..4f7049a4de61 100644
> --- a/include/configs/sunxi-common.h
> +++ b/include/configs/sunxi-common.h
> @@ -205,10 +205,7 @@
>  #endif
>  #endif
>  
> -#if defined CONFIG_VIDEO_LCD_PANEL_I2C && !(defined CONFIG_SPL_BUILD)

(this condition here)

> -#define CONFIG_SYS_I2C_SOFT
> -#define CONFIG_SYS_I2C_SOFT_SPEED5
> -#define CONFIG_SYS_I2C_SOFT_SLAVE0x00
> +#if defined(CONFIG_VIDEO_LCD_PANEL_I2C)
>  /* We use pin names in Kconfig and sunxi_name_to_gpio() */
>  #define CONFIG_SOFT_I2C_GPIO_SDA soft_i2c_gpio_sda
>  #define CONFIG_SOFT_I2C_GPIO_SCL soft_i2c_gpio_scl
> 



Re: [PATCH 05/13] siemens: Move CONFIG_SYS_I2C_EEPROM_ADDR usage out of CONFIG namespace

2021-08-17 Thread Heiko Schocher
Hello Tom,

On 17.08.21 23:59, Tom Rini wrote:
> The instances of CONFIG_SYS_I2C_EEPROM_ADDR on these platforms doesn't
> match up with the rest of the EERPOM related defines in U-Boot.  Move
> these out of the CONFIG namespace rather than make complex Kconfig
> logic.
> 
> Cc: Samuel Egli 
> Cc: Anatolij Gustschin 
> Cc: Heiko Schocher 
> Signed-off-by: Tom Rini 
> ---
>  board/siemens/common/board.c |  3 ++-
>  board/siemens/draco/board.c  | 12 
>  include/configs/draco.h  |  4 
>  3 files changed, 10 insertions(+), 9 deletions(-)

Reviewed-by: Heiko Schocher 

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: [PATCH 03/13] arm: shc: Change CONFIG_SYS_I2C_EEPROM_ADDR to EEPROM_ADDR

2021-08-17 Thread Heiko Schocher
Hello Tom,

On 17.08.21 23:59, Tom Rini wrote:
> The shc platforms do not make use of the rest of the EEPROM
> infrastructure.  Rather than make more elaborate Kconfig logic, remove
> this setting from the CONFIG namespace.
> 
> Cc: Heiko Schocher 
> Signed-off-by: Tom Rini 
> ---
>  board/bosch/shc/board.c  | 5 +++--
>  include/configs/am335x_shc.h | 1 -
>  2 files changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Heiko Schocher 

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: [PATCH 3/5] efi_loader: use correct type for AllocatePages, AllocatePool

2021-08-17 Thread AKASHI Takahiro
Heinrich,

On Tue, Aug 17, 2021 at 06:02:23PM +0200, Heinrich Schuchardt wrote:
> Use enum efi_memory_type and enum_allocate_type in the definitions of the
> efi_allocate_pages(), efi_allocate_pool().
> 
> In the external UEFI API leave the type as int as the UEFI specification
> explicitly requires that enums use a 32bit type.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  include/efi_loader.h| 9 +
>  lib/efi_loader/efi_memory.c | 5 +++--
>  2 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 32cb8d0f1e..c440962fe5 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -676,13 +676,14 @@ struct efi_device_path *efi_get_dp_from_boot(const 
> efi_guid_t guid);
>  /* Generic EFI memory allocator, call this to get memory */
>  void *efi_alloc(uint64_t len, int memory_type);
>  /* More specific EFI memory allocator, called by EFI payloads */
> -efi_status_t efi_allocate_pages(int type, int memory_type, efi_uintn_t pages,
> - uint64_t *memory);
> +efi_status_t efi_allocate_pages(enum efi_allocate_type type,
> + enum efi_memory_type memory_type,
> + efi_uintn_t pages, uint64_t *memory);
>  /* EFI memory free function. */
>  efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages);
>  /* EFI memory allocator for small allocations */
> -efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size,
> -void **buffer);
> +efi_status_t efi_allocate_pool(enum efi_memory_type pool_type,
> +efi_uintn_t size, void **buffer);
>  /* EFI pool memory free function. */
>  efi_status_t efi_free_pool(void *buffer);
>  /* Returns the EFI memory map */
> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
> index be2f655dff..f4acbee4f9 100644
> --- a/lib/efi_loader/efi_memory.c
> +++ b/lib/efi_loader/efi_memory.c
> @@ -454,7 +454,8 @@ static uint64_t efi_find_free_memory(uint64_t len, 
> uint64_t max_addr)
>   * @memory   allocated memory
>   * @return   status code
>   */
> -efi_status_t efi_allocate_pages(int type, int memory_type,
> +efi_status_t efi_allocate_pages(enum efi_allocate_type type,
> + enum efi_memory_type memory_type,
>   efi_uintn_t pages, uint64_t *memory)
>  {
>   u64 len = pages << EFI_PAGE_SHIFT;
> @@ -556,7 +557,7 @@ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t 
> pages)
>   * @buffer:  allocated memory
>   * Return:   status code
>   */
> -efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void 
> **buffer)
> +efi_status_t efi_allocate_pool(enum efi_memory_type pool_type, efi_uintn_t 
> size, void **buffer)

Given the purpose of this patch series, I think that the second argument
of this function should be renamed from "pool_type" to "memory_type"
which is also used in efi_allocate_pages() to avoid any confusion.
(and the description for @pool_type as well)

Otherwise, it looks good.

-Takahiro Akashi


>  {
>   efi_status_t r;
>   u64 addr;
> -- 
> 2.30.2
> 


Re: [RFC] imx8mm-evk: Generate a bootable flash.bin again

2021-08-17 Thread Fabio Estevam
Hi Heiko,

On Tue, Aug 17, 2021 at 12:56 AM Heiko Schocher  wrote:

> I am unsure here, if it makes sense to overwrite flash.bin with the
> binary which contains SPL and u-boot.itb. May others want to use
> them (as I currently use them for signing them)

I thought about that too. Frieder suggested I use a different name for
the SPL file, such as spl.bin.

I am concerned that renaming flash.bin to spl.bin may break i.MX8MM
targets that do not use binman, such as the verdin-imx8mm board.

> Why not imx-boot as image name as in NXP sources?

NXP U-Boot also generates the final binary called "flash.bin"

My main motivation for sending this RFC patch is to avoid imx8mm-evk
breakage when people upgrade
to U-Boor 2021.07.

Prior to 2021.07: only flash.bin was required. Yocto recipe, for
example, will no longer produce a bootable image
after the upgrade to 2021.07. This is the breakage I would like to avoid.

Thanks


Re: u-boot & ZFS

2021-08-17 Thread Tom Rini
On Tue, Aug 17, 2021 at 06:03:10PM +0200, ChrisO wrote:

> Hi
> 
> I searched for u-boot ZFS references and all I found was several years old, 
> but I suppose u-boot can cope with ZFS.
> So, my question is: is it possible to boot Linux from ZFS or at least boot 
> from let's say SD-card with ext4 FS and mount a ZFS volume as root filesystem?
> I had a look at Armbian, installed all needed, user-space and kernel modules. 
> After booting from SD card I can use ZFS on attached SATA SSD w/o any problem.
> I also see ZFS libs and kernel modules in initrd,  so it looks like the 
> necessary things are there.
> Don't know where to start.
> I would be very thankful for any help.

The general easy answer is to have /boot that is separate from the
rootfs and using a filesystem more commonly supported.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/2] imx8mm-cl-iot-gate: Do not build fip.bin by default

2021-08-17 Thread Paul Liu
Hi Fabio,

Can I know your Compulab's hardware PN?
Something like "IOTG-IMX8-D2-NA16-WB-FATPM".

Yours,
Paul



On Wed, 18 Aug 2021 at 02:32, Fabio Estevam  wrote:

> Hi Paul,
>
> On Mon, Aug 16, 2021 at 9:50 PM Paul Liu  wrote:
> >
> > Hi Fabio,
> >
> > It looks good to me. Thanks a lot.
>
> I have sent a v2 with such a proposal.
>
> I would appreciate it if you could review and test booting the two
> defconfigs.
>
> Thanks,
>
> Fabio Estevam
>


u-boot & ZFS

2021-08-17 Thread ChrisO


Hi

I searched for u-boot ZFS references and all I found was several years old, but 
I suppose u-boot can cope with ZFS.
So, my question is: is it possible to boot Linux from ZFS or at least boot from 
let's say SD-card with ext4 FS and mount a ZFS volume as root filesystem?
I had a look at Armbian, installed all needed, user-space and kernel modules. 
After booting from SD card I can use ZFS on attached SATA SSD w/o any problem.
I also see ZFS libs and kernel modules in initrd,  so it looks like the 
necessary things are there.
Don't know where to start.
I would be very thankful for any help.

Regards.
Chris


[PATCH 12/13] Convert CONFIG_SYS_I2C_MVTWSI to Kconfig

2021-08-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_I2C_MVTWSI

Signed-off-by: Tom Rini 
---
 arch/arm/mach-kirkwood/include/mach/config.h | 1 -
 configs/A10-OLinuXino-Lime_defconfig | 1 +
 configs/A10s-OLinuXino-M_defconfig   | 1 +
 configs/A13-OLinuXinoM_defconfig | 1 +
 configs/A13-OLinuXino_defconfig  | 1 +
 configs/A20-OLinuXino-Lime2-eMMC_defconfig   | 1 +
 configs/A20-OLinuXino-Lime2_defconfig| 1 +
 configs/A20-OLinuXino-Lime_defconfig | 1 +
 configs/A20-OLinuXino_MICRO-eMMC_defconfig   | 1 +
 configs/A20-OLinuXino_MICRO_defconfig| 1 +
 configs/A20-Olimex-SOM-EVB_defconfig | 1 +
 configs/A20-Olimex-SOM204-EVB-eMMC_defconfig | 1 +
 configs/A20-Olimex-SOM204-EVB_defconfig  | 1 +
 configs/Ainol_AW1_defconfig  | 1 +
 configs/Ampe_A76_defconfig   | 1 +
 configs/Auxtek-T003_defconfig| 1 +
 configs/Auxtek-T004_defconfig| 1 +
 configs/Bananapi_M2_Ultra_defconfig  | 1 +
 configs/Bananapi_defconfig   | 1 +
 configs/Bananapro_defconfig  | 1 +
 configs/CHIP_defconfig   | 1 +
 configs/CHIP_pro_defconfig   | 1 +
 configs/Chuwi_V7_CW0825_defconfig| 1 +
 configs/Colombus_defconfig   | 1 +
 configs/Cubieboard2_defconfig| 1 +
 configs/Cubieboard_defconfig | 1 +
 configs/Cubietruck_defconfig | 1 +
 configs/Cubietruck_plus_defconfig| 1 +
 configs/Empire_electronix_d709_defconfig | 1 +
 configs/Empire_electronix_m712_defconfig | 1 +
 configs/Hyundai_A7HD_defconfig   | 1 +
 configs/Itead_Ibox_A20_defconfig | 1 +
 configs/Lamobo_R1_defconfig  | 1 +
 configs/Linksprite_pcDuino3_Nano_defconfig   | 1 +
 configs/Linksprite_pcDuino3_defconfig| 1 +
 configs/Linksprite_pcDuino_defconfig | 1 +
 configs/MK808C_defconfig | 1 +
 configs/MSI_Primo73_defconfig| 1 +
 configs/Marsboard_A10_defconfig  | 1 +
 configs/Mele_A1000_defconfig | 1 +
 configs/Mele_M3_defconfig| 1 +
 configs/Mele_M5_defconfig| 1 +
 configs/Mini-X_defconfig | 1 +
 configs/Orangepi_defconfig   | 1 +
 configs/Orangepi_mini_defconfig  | 1 +
 configs/UTOO_P66_defconfig   | 1 +
 configs/Wexler_TAB7200_defconfig | 1 +
 configs/Wits_Pro_A20_DKT_defconfig   | 1 +
 configs/Wobo_i5_defconfig| 1 +
 configs/Yones_Toptech_BD1078_defconfig   | 1 +
 configs/ba10_tv_box_defconfig| 1 +
 configs/bananapi_m1_plus_defconfig   | 1 +
 configs/bananapi_m2_berry_defconfig  | 1 +
 configs/d2net_v2_defconfig   | 1 +
 configs/db-88f6720_defconfig | 1 +
 configs/db-88f6820-gp_defconfig  | 1 +
 configs/db-mv784mp-gp_defconfig  | 1 +
 configs/difrnce_dit4350_defconfig| 1 +
 configs/ds414_defconfig  | 1 +
 configs/dserve_dsrv9703c_defconfig   | 1 +
 configs/edminiv2_defconfig   | 1 +
 configs/i12-tvbox_defconfig  | 1 +
 configs/iNet_3F_defconfig| 1 +
 configs/iNet_3W_defconfig| 1 +
 configs/iNet_86VS_defconfig  | 1 +
 configs/icnova-a20-swac_defconfig| 1 +
 configs/inet1_defconfig  | 1 +
 configs/inet97fv2_defconfig  | 1 +
 configs/inet98v_rev2_defconfig   | 1 +
 configs/inet9f_rev03_defconfig   | 1 +
 configs/inetspace_v2_defconfig   | 1 +
 configs/jesurun_q5_defconfig | 1 +
 configs/km_kirkwood_128m16_defconfig | 1 +
 configs/km_kirkwood_defconfig| 1 +
 configs/km_kirkwood_pci_defconfig| 1 +
 configs/kmcoge5un_defconfig  | 1 +
 configs/kmnusa_defconfig | 1 +
 configs/kmsuse2_defconfig| 1 +
 configs/maxbcm_defconfig | 1 +
 configs/mk802_a10s_defconfig | 1 +
 configs/mk802_defconfig  | 1 +
 configs/mk802ii_defconfig| 1 +
 configs/net2big_v2_defconfig | 1 +
 configs/netspace_lite_v2_defconfig   | 1 +
 configs/netspace_max_v2_defconfig| 1 +
 configs/netspace_mini_v2_defconfig   | 1 +
 configs/netspace_v2_defconfig| 1 +
 configs/orangepi_2_defconfig | 1 +
 configs/orangepi_pc2_defconfig   | 1 +
 configs/orangepi_pc_defconfig| 1 +
 configs/orangepi_pc_plus_defconfig   | 1 +
 configs/orangepi_plus2e_defconfig| 1 +
 configs/orangepi_plus_defconfig  | 1 +
 configs/orangepi_zero2_defconfig | 1 +
 

[PATCH 13/13] i2c: Remove unused additional legacy soft i2c bus support

2021-08-17 Thread Tom Rini
Currently the legacy software i2c support is only used for a single bus.
Remove all of the extra and unused support.  Also update the README to
not reference that, and finish removing some already badly auto-edited
related text.

Signed-off-by: Tom Rini 
---
 README | 14 
 drivers/i2c/soft_i2c.c | 77 --
 2 files changed, 91 deletions(-)

diff --git a/README b/README
index 1c1db9809878..a16afea4c94c 100644
--- a/README
+++ b/README
@@ -1466,20 +1466,6 @@ The following options need to be configured:
Note: This is deprecated in favour of driver model. Use
CONFIG_DM_I2C instead.
 
-   This enable the legacy i2c subsystem, and will allow you to use
-   i2c commands at the u-boot command line (as long as you set
-   CONFIG_SYS_I2C_SOFT_SPEED and CONFIG_SYS_I2C_SOFT_SLAVE
-   for defining speed and slave address
- - activate second bus with I2C_SOFT_DECLARATIONS2 define
-   CONFIG_SYS_I2C_SOFT_SPEED_2 and CONFIG_SYS_I2C_SOFT_SLAVE_2
-   for defining speed and slave address
- - activate third bus with I2C_SOFT_DECLARATIONS3 define
-   CONFIG_SYS_I2C_SOFT_SPEED_3 and CONFIG_SYS_I2C_SOFT_SLAVE_3
-   for defining speed and slave address
- - activate fourth bus with I2C_SOFT_DECLARATIONS4 define
-   CONFIG_SYS_I2C_SOFT_SPEED_4 and CONFIG_SYS_I2C_SOFT_SLAVE_4
-   for defining speed and slave address
-
- drivers/i2c/fsl_i2c.c:
  - activate i2c driver with CONFIG_SYS_I2C_FSL
define CONFIG_SYS_FSL_I2C_OFFSET for setting the register
diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
index db69c18cb6de..c72839eb0111 100644
--- a/drivers/i2c/soft_i2c.c
+++ b/drivers/i2c/soft_i2c.c
@@ -438,80 +438,3 @@ U_BOOT_I2C_ADAP_COMPLETE(soft00, soft_i2c_init, 
soft_i2c_probe,
 soft_i2c_read, soft_i2c_write, NULL,
 CONFIG_SYS_I2C_SOFT_SPEED, CONFIG_SYS_I2C_SOFT_SLAVE,
 0)
-#if defined(I2C_SOFT_DECLARATIONS2)
-U_BOOT_I2C_ADAP_COMPLETE(soft01, soft_i2c_init, soft_i2c_probe,
-soft_i2c_read, soft_i2c_write, NULL,
-CONFIG_SYS_I2C_SOFT_SPEED_2,
-CONFIG_SYS_I2C_SOFT_SLAVE_2,
-1)
-#endif
-#if defined(I2C_SOFT_DECLARATIONS3)
-U_BOOT_I2C_ADAP_COMPLETE(soft02, soft_i2c_init, soft_i2c_probe,
-soft_i2c_read, soft_i2c_write, NULL,
-CONFIG_SYS_I2C_SOFT_SPEED_3,
-CONFIG_SYS_I2C_SOFT_SLAVE_3,
-2)
-#endif
-#if defined(I2C_SOFT_DECLARATIONS4)
-U_BOOT_I2C_ADAP_COMPLETE(soft03, soft_i2c_init, soft_i2c_probe,
-soft_i2c_read, soft_i2c_write, NULL,
-CONFIG_SYS_I2C_SOFT_SPEED_4,
-CONFIG_SYS_I2C_SOFT_SLAVE_4,
-3)
-#endif
-#if defined(I2C_SOFT_DECLARATIONS5)
-U_BOOT_I2C_ADAP_COMPLETE(soft04, soft_i2c_init, soft_i2c_probe,
-soft_i2c_read, soft_i2c_write, NULL,
-CONFIG_SYS_I2C_SOFT_SPEED_5,
-CONFIG_SYS_I2C_SOFT_SLAVE_5,
-4)
-#endif
-#if defined(I2C_SOFT_DECLARATIONS6)
-U_BOOT_I2C_ADAP_COMPLETE(soft05, soft_i2c_init, soft_i2c_probe,
-soft_i2c_read, soft_i2c_write, NULL,
-CONFIG_SYS_I2C_SOFT_SPEED_6,
-CONFIG_SYS_I2C_SOFT_SLAVE_6,
-5)
-#endif
-#if defined(I2C_SOFT_DECLARATIONS7)
-U_BOOT_I2C_ADAP_COMPLETE(soft06, soft_i2c_init, soft_i2c_probe,
-soft_i2c_read, soft_i2c_write, NULL,
-CONFIG_SYS_I2C_SOFT_SPEED_7,
-CONFIG_SYS_I2C_SOFT_SLAVE_7,
-6)
-#endif
-#if defined(I2C_SOFT_DECLARATIONS8)
-U_BOOT_I2C_ADAP_COMPLETE(soft07, soft_i2c_init, soft_i2c_probe,
-soft_i2c_read, soft_i2c_write, NULL,
-CONFIG_SYS_I2C_SOFT_SPEED_8,
-CONFIG_SYS_I2C_SOFT_SLAVE_8,
-7)
-#endif
-#if defined(I2C_SOFT_DECLARATIONS9)
-U_BOOT_I2C_ADAP_COMPLETE(soft08, soft_i2c_init, soft_i2c_probe,
-soft_i2c_read, soft_i2c_write, NULL,
-CONFIG_SYS_I2C_SOFT_SPEED_9,
-CONFIG_SYS_I2C_SOFT_SLAVE_9,
-8)
-#endif
-#if defined(I2C_SOFT_DECLARATIONS10)
-U_BOOT_I2C_ADAP_COMPLETE(soft09, soft_i2c_init, soft_i2c_probe,
-soft_i2c_read, soft_i2c_write, NULL,
-CONFIG_SYS_I2C_SOFT_SPEED_10,
-CONFIG_SYS_I2C_SOFT_SLAVE_10,
-9)
-#endif
-#if 

[PATCH 06/13] Convert CONFIG_ID_EEPROM to Kconfig

2021-08-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_ID_EEPROM

Signed-off-by: Tom Rini 
---
 arch/arm/cpu/armv8/fsl-layerscape/Kconfig   | 5 +
 arch/powerpc/cpu/mpc85xx/Kconfig| 1 +
 common/Kconfig  | 6 ++
 common/board_r.c| 2 +-
 configs/MPC8548CDS_36BIT_defconfig  | 1 +
 configs/MPC8548CDS_defconfig| 1 +
 configs/MPC8548CDS_legacy_defconfig | 1 +
 configs/P1010RDB-PB_36BIT_NAND_defconfig| 1 +
 configs/P1010RDB-PB_36BIT_NOR_defconfig | 1 +
 configs/P1010RDB-PB_36BIT_SDCARD_defconfig  | 1 +
 configs/P1010RDB-PB_36BIT_SPIFLASH_defconfig| 1 +
 configs/P1010RDB-PB_NAND_defconfig  | 1 +
 configs/P1010RDB-PB_NOR_defconfig   | 1 +
 configs/P1010RDB-PB_SDCARD_defconfig| 1 +
 configs/P1010RDB-PB_SPIFLASH_defconfig  | 1 +
 configs/P2041RDB_NAND_defconfig | 1 +
 configs/P2041RDB_SDCARD_defconfig   | 1 +
 configs/P2041RDB_SPIFLASH_defconfig | 1 +
 configs/P2041RDB_defconfig  | 1 +
 configs/P3041DS_NAND_defconfig  | 1 +
 configs/P3041DS_SDCARD_defconfig| 1 +
 configs/P3041DS_SPIFLASH_defconfig  | 1 +
 configs/P3041DS_defconfig   | 1 +
 configs/P4080DS_SDCARD_defconfig| 1 +
 configs/P4080DS_SPIFLASH_defconfig  | 1 +
 configs/P4080DS_defconfig   | 1 +
 configs/P5040DS_NAND_defconfig  | 1 +
 configs/P5040DS_SDCARD_defconfig| 1 +
 configs/P5040DS_SPIFLASH_defconfig  | 1 +
 configs/P5040DS_defconfig   | 1 +
 configs/T1024RDB_NAND_defconfig | 1 +
 configs/T1024RDB_SDCARD_defconfig   | 1 +
 configs/T1024RDB_SPIFLASH_defconfig | 1 +
 configs/T1024RDB_defconfig  | 1 +
 configs/ls1012aqds_qspi_defconfig   | 1 +
 configs/ls1012aqds_tfa_SECURE_BOOT_defconfig| 1 +
 configs/ls1012aqds_tfa_defconfig| 1 +
 configs/ls1021aiot_qspi_defconfig   | 1 +
 configs/ls1021aiot_sdcard_defconfig | 1 +
 configs/ls1021aqds_ddr4_nor_defconfig   | 1 +
 configs/ls1021aqds_ddr4_nor_lpuart_defconfig| 1 +
 configs/ls1021aqds_nand_defconfig   | 1 +
 configs/ls1021aqds_nor_SECURE_BOOT_defconfig| 1 +
 configs/ls1021aqds_nor_defconfig| 1 +
 configs/ls1021aqds_nor_lpuart_defconfig | 1 +
 configs/ls1021aqds_qspi_defconfig   | 1 +
 configs/ls1021aqds_sdcard_ifc_defconfig | 1 +
 configs/ls1021aqds_sdcard_qspi_defconfig| 1 +
 configs/ls1021atsn_qspi_defconfig   | 1 +
 configs/ls1021atsn_sdcard_defconfig | 1 +
 configs/ls1021atwr_nor_SECURE_BOOT_defconfig| 1 +
 configs/ls1021atwr_nor_defconfig| 1 +
 configs/ls1021atwr_nor_lpuart_defconfig | 1 +
 configs/ls1021atwr_qspi_defconfig   | 1 +
 configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig | 1 +
 configs/ls1021atwr_sdcard_ifc_defconfig | 1 +
 configs/ls1021atwr_sdcard_qspi_defconfig| 1 +
 configs/ls1028aqds_tfa_SECURE_BOOT_defconfig| 1 +
 configs/ls1028aqds_tfa_defconfig| 1 +
 configs/ls1028aqds_tfa_lpuart_defconfig | 1 +
 configs/ls1028ardb_tfa_SECURE_BOOT_defconfig| 1 +
 configs/ls1028ardb_tfa_defconfig| 1 +
 configs/lx2162aqds_tfa_SECURE_BOOT_defconfig| 1 +
 configs/lx2162aqds_tfa_defconfig| 1 +
 configs/lx2162aqds_tfa_verified_boot_defconfig  | 1 +
 configs/sifive_unmatched_defconfig  | 1 +
 include/configs/MPC8548CDS.h| 1 -
 include/configs/P1010RDB.h  | 1 -
 include/configs/P2041RDB.h  | 1 -
 include/configs/T102xRDB.h  | 1 -
 include/configs/T208xQDS.h  | 1 -
 include/configs/T208xRDB.h  | 1 -
 include/configs/corenet_ds.h| 1 -
 include/configs/ls1012aqds.h| 1 -
 include/configs/ls1021aiot.h| 1 -
 include/configs/ls1021aqds.h| 1 -
 include/configs/ls1021atsn.h| 1 -
 include/configs/ls1021atwr.h| 1 -
 include/configs/ls1028a_common.h| 1 -
 include/configs/ls1043aqds.h| 1 -
 include/configs/ls1043ardb.h| 1 -
 include/configs/ls1046afrwy.h   | 1 -
 include/configs/ls1046aqds.h| 1 -
 

[PATCH 07/13] i2c: S3C24X0: Finish Kconfig migration

2021-08-17 Thread Tom Rini
Finish moving this driver to Kconfig.
- Update the dependency logic for Exynos5 too
- Remove the unused CONFIG_SYS_I2C_S3C24X0_SPEED variable
- Drop CONFIG_SYS_I2C_S3C24X0_SLAVE as it's always set to 0.
- Move the internal SYS_I2C_S3C24X0_SLAVE define closer to the only user.

Cc: Jaehoon Chung 
Signed-off-by: Tom Rini 
---
 configs/arndale_defconfig| 1 +
 configs/odroid-xu3_defconfig | 1 +
 configs/peach-pi_defconfig   | 1 +
 configs/peach-pit_defconfig  | 1 +
 configs/smdk5250_defconfig   | 1 +
 configs/smdk5420_defconfig   | 1 +
 configs/snow_defconfig   | 1 +
 configs/spring_defconfig | 1 +
 drivers/i2c/Kconfig  | 2 +-
 drivers/i2c/s3c24x0_i2c.c| 8 ++--
 include/configs/exynos5-common.h | 5 -
 11 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/configs/arndale_defconfig b/configs/arndale_defconfig
index 133c0eb8884e..f475bdefe5f7 100644
--- a/configs/arndale_defconfig
+++ b/configs/arndale_defconfig
@@ -31,6 +31,7 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_I2C_S3C24X0=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_DW=y
 CONFIG_MMC_SDHCI=y
diff --git a/configs/odroid-xu3_defconfig b/configs/odroid-xu3_defconfig
index f56dfb7d8e2f..150eacdbebe8 100644
--- a/configs/odroid-xu3_defconfig
+++ b/configs/odroid-xu3_defconfig
@@ -42,6 +42,7 @@ CONFIG_ADC_EXYNOS=y
 CONFIG_DFU_MMC=y
 CONFIG_SET_DFU_ALT_INFO=y
 CONFIG_SYS_DFU_DATA_BUF_SIZE=0x200
+CONFIG_SYS_I2C_S3C24X0=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_DW=y
 CONFIG_MTD=y
diff --git a/configs/peach-pi_defconfig b/configs/peach-pi_defconfig
index 92d6be43f817..e8509d8dcbc2 100644
--- a/configs/peach-pi_defconfig
+++ b/configs/peach-pi_defconfig
@@ -38,6 +38,7 @@ CONFIG_USE_ENV_SPI_BUS=y
 CONFIG_ENV_SPI_BUS=1
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_I2C_CROS_EC_TUNNEL=y
+CONFIG_SYS_I2C_S3C24X0=y
 CONFIG_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=y
 CONFIG_CROS_EC_KEYB=y
diff --git a/configs/peach-pit_defconfig b/configs/peach-pit_defconfig
index 824a664904e8..aaec917c177f 100644
--- a/configs/peach-pit_defconfig
+++ b/configs/peach-pit_defconfig
@@ -37,6 +37,7 @@ CONFIG_USE_ENV_SPI_BUS=y
 CONFIG_ENV_SPI_BUS=1
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_I2C_CROS_EC_TUNNEL=y
+CONFIG_SYS_I2C_S3C24X0=y
 CONFIG_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=y
 CONFIG_CROS_EC_KEYB=y
diff --git a/configs/smdk5250_defconfig b/configs/smdk5250_defconfig
index 3ed1947fd682..d0a25139ac0f 100644
--- a/configs/smdk5250_defconfig
+++ b/configs/smdk5250_defconfig
@@ -38,6 +38,7 @@ CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_USE_ENV_SPI_BUS=y
 CONFIG_ENV_SPI_BUS=1
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_I2C_S3C24X0=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_DW=y
 CONFIG_MMC_SDHCI=y
diff --git a/configs/smdk5420_defconfig b/configs/smdk5420_defconfig
index 7b739400a5bf..e484b234dd0b 100644
--- a/configs/smdk5420_defconfig
+++ b/configs/smdk5420_defconfig
@@ -33,6 +33,7 @@ CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_USE_ENV_SPI_BUS=y
 CONFIG_ENV_SPI_BUS=1
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_I2C_S3C24X0=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_DW=y
 CONFIG_MMC_SDHCI=y
diff --git a/configs/snow_defconfig b/configs/snow_defconfig
index a5fbd1d346da..f91cfeda8b9c 100644
--- a/configs/snow_defconfig
+++ b/configs/snow_defconfig
@@ -43,6 +43,7 @@ CONFIG_USE_ENV_SPI_BUS=y
 CONFIG_ENV_SPI_BUS=1
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_I2C_CROS_EC_LDO=y
+CONFIG_SYS_I2C_S3C24X0=y
 CONFIG_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=y
 CONFIG_CROS_EC_KEYB=y
diff --git a/configs/spring_defconfig b/configs/spring_defconfig
index 53c375e5b4f2..dbebf0ba6191 100644
--- a/configs/spring_defconfig
+++ b/configs/spring_defconfig
@@ -43,6 +43,7 @@ CONFIG_USE_ENV_SPI_BUS=y
 CONFIG_ENV_SPI_BUS=1
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_I2C_CROS_EC_LDO=y
+CONFIG_SYS_I2C_S3C24X0=y
 CONFIG_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=y
 CONFIG_CROS_EC_KEYB=y
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 63d03a3cebfc..a50c1f38336d 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -449,7 +449,7 @@ config SYS_I2C_OCTEON
 
 config SYS_I2C_S3C24X0
bool "Samsung I2C driver"
-   depends on ARCH_EXYNOS4 && DM_I2C
+   depends on (ARCH_EXYNOS4 || ARCH_EXYNOS5) && DM_I2C
help
  Support for Samsung I2C controller as Samsung SoCs.
 
diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c
index 56f0f69885e4..e0f499d759f8 100644
--- a/drivers/i2c/s3c24x0_i2c.c
+++ b/drivers/i2c/s3c24x0_i2c.c
@@ -21,12 +21,6 @@
 #include 
 #include "s3c24x0_i2c.h"
 
-#ifndef CONFIG_SYS_I2C_S3C24X0_SLAVE
-#define SYS_I2C_S3C24X0_SLAVE_ADDR 0
-#else
-#define SYS_I2C_S3C24X0_SLAVE_ADDR CONFIG_SYS_I2C_S3C24X0_SLAVE
-#endif
-
 DECLARE_GLOBAL_DATA_PTR;
 
 /*
@@ -83,6 +77,8 @@ static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, 
int slaveadd)
writel(I2C_MODE_MT | I2C_TXRX_ENA, >iicstat);
 }
 
+#define 

[PATCH 09/13] eeprom: Drop CONFIG_ENV_EEPROM_IS_ON_I2C usage

2021-08-17 Thread Tom Rini
At this point in time, there's no systems with "U-Boot environment
exists on an EEPROM which is accessed over the I2C bus" that sets this
option.  Drop it.

Signed-off-by: Tom Rini 
---
 cmd/eeprom.c | 9 -
 env/Kconfig  | 4 
 include/configs/am335x_evm.h | 1 -
 include/configs/am335x_sl50.h| 1 -
 include/configs/am43xx_evm.h | 1 -
 include/configs/am57xx_evm.h | 1 -
 include/configs/baltos.h | 1 -
 include/configs/cm_fx6.h | 1 -
 include/configs/cm_t335.h| 1 -
 include/configs/cm_t43.h | 1 -
 include/configs/dra7xx_evm.h | 1 -
 include/configs/km/km_arm.h  | 1 -
 include/configs/ti_armv7_keystone2.h | 1 -
 13 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/cmd/eeprom.c b/cmd/eeprom.c
index efd6f3ac0325..447bc157fb74 100644
--- a/cmd/eeprom.c
+++ b/cmd/eeprom.c
@@ -53,13 +53,12 @@
  * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 (8-bit EEPROM page address) offset 
is
  *   0x0nxx for EEPROM address selectors and page number at n.
  */
-#if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
-#if !defined(CONFIG_SYS_I2C_EEPROM_ADDR_LEN) || \
-   (CONFIG_SYS_I2C_EEPROM_ADDR_LEN < 1) || \
-   (CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 2)
+#if !defined(CONFIG_SPI) && \
+   (!defined(CONFIG_SYS_I2C_EEPROM_ADDR_LEN) || \
+   (CONFIG_SYS_I2C_EEPROM_ADDR_LEN < 1) || \
+   (CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 2))
 #error CONFIG_SYS_I2C_EEPROM_ADDR_LEN must be 1 or 2
 #endif
-#endif
 
 #if CONFIG_IS_ENABLED(DM_I2C)
 static int eeprom_i2c_bus;
diff --git a/env/Kconfig b/env/Kconfig
index 67ff172e3a9b..504fdfa45d46 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -44,10 +44,6 @@ config ENV_IS_IN_EEPROM
  still be one byte because the extra address bits are hidden
  in the chip address.
 
- - CONFIG_ENV_EEPROM_IS_ON_I2C
- define this, if you have I2C and SPI activated, and your
- EEPROM, which holds the environment, is on the I2C bus.
-
  - CONFIG_I2C_ENV_EEPROM_BUS
  if you have an Environment on an EEPROM reached over
  I2C muxes, you can define here, how to reach this
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index ad5616d28fbd..c7277cb48a9a 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -168,7 +168,6 @@
 #define CONFIG_SYS_NS16550_COM50x481a8000  /* UART4 */
 #define CONFIG_SYS_NS16550_COM60x481aa000  /* UART5 */
 
-#define CONFIG_ENV_EEPROM_IS_ON_I2C
 #define CONFIG_SYS_I2C_EEPROM_ADDR 0x50/* Main EEPROM */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
 
diff --git a/include/configs/am335x_sl50.h b/include/configs/am335x_sl50.h
index 16849d870114..449621f99a8a 100644
--- a/include/configs/am335x_sl50.h
+++ b/include/configs/am335x_sl50.h
@@ -55,7 +55,6 @@
 #define CONFIG_SYS_NS16550_COM50x481a8000  /* UART4 */
 #define CONFIG_SYS_NS16550_COM60x481aa000  /* UART5 */
 
-#define CONFIG_ENV_EEPROM_IS_ON_I2C
 #define CONFIG_SYS_I2C_EEPROM_ADDR 0x50/* Main EEPROM */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
 
diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h
index 31a1c7e392f2..c0681316cffa 100644
--- a/include/configs/am43xx_evm.h
+++ b/include/configs/am43xx_evm.h
@@ -21,7 +21,6 @@
 #endif
 
 /* I2C Configuration */
-#define CONFIG_ENV_EEPROM_IS_ON_I2C
 #define CONFIG_SYS_I2C_EEPROM_ADDR 0x50/* Main EEPROM */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
 
diff --git a/include/configs/am57xx_evm.h b/include/configs/am57xx_evm.h
index c47ffccff159..88ade6a5a49f 100644
--- a/include/configs/am57xx_evm.h
+++ b/include/configs/am57xx_evm.h
@@ -22,7 +22,6 @@
 #define CONFIG_SYS_NS16550_COM2UART2_BASE  /* UART2 */
 #define CONFIG_SYS_NS16550_COM3UART3_BASE  /* UART3 */
 
-#define CONFIG_ENV_EEPROM_IS_ON_I2C
 #define CONFIG_SYS_I2C_EEPROM_ADDR 0x50/* Main EEPROM */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
 
diff --git a/include/configs/baltos.h b/include/configs/baltos.h
index 42a5abd1b41b..448b454126fe 100644
--- a/include/configs/baltos.h
+++ b/include/configs/baltos.h
@@ -204,7 +204,6 @@
 #define CONFIG_SYS_NS16550_COM50x481a8000  /* UART4 */
 #define CONFIG_SYS_NS16550_COM60x481aa000  /* UART5 */
 
-#define CONFIG_ENV_EEPROM_IS_ON_I2C
 #define CONFIG_SYS_I2C_EEPROM_ADDR 0x50/* Main EEPROM */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
 
diff --git a/include/configs/cm_fx6.h b/include/configs/cm_fx6.h
index a496a80e02e5..d1686d58ab61 100644
--- a/include/configs/cm_fx6.h
+++ b/include/configs/cm_fx6.h
@@ -201,7 +201,6 @@
 #define CONFIG_VIDEO_BMP_LOGO
 
 /* EEPROM */
-#define CONFIG_ENV_EEPROM_IS_ON_I2C
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define 

[PATCH 11/13] Convert CONFIG_SYS_I2C_SOFT et al to Kconfig

2021-08-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_I2C_SOFT
   CONFIG_SYS_I2C_SOFT_SPEED
   CONFIG_SYS_I2C_SOFT_SLAVE

Signed-off-by: Tom Rini 
---
 board/sunxi/board.c  |  2 +-
 configs/Colombus_defconfig   |  3 +++
 configs/UTOO_P66_defconfig   |  3 +++
 configs/ethernut5_defconfig  |  2 ++
 configs/km_kirkwood_128m16_defconfig |  2 ++
 configs/km_kirkwood_defconfig|  2 ++
 configs/km_kirkwood_pci_defconfig|  2 ++
 configs/kmcoge5un_defconfig  |  2 ++
 configs/kmnusa_defconfig |  2 ++
 configs/kmsuse2_defconfig|  2 ++
 configs/snapper9260_defconfig|  2 ++
 configs/snapper9g20_defconfig|  2 ++
 drivers/i2c/Kconfig  | 19 +++
 include/configs/ethernut5.h  |  3 ---
 include/configs/km/km_arm.h  |  4 
 include/configs/snapper9260.h|  3 ---
 include/configs/sunxi-common.h   |  5 +
 17 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 1a46100e408d..2b7d655678d0 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -47,7 +47,7 @@
 #include 
 #include 
 
-#if defined CONFIG_VIDEO_LCD_PANEL_I2C && !(defined CONFIG_SPL_BUILD)
+#if defined(CONFIG_VIDEO_LCD_PANEL_I2C)
 /* So that we can use pin names in Kconfig and sunxi_name_to_gpio() */
 int soft_i2c_gpio_sda;
 int soft_i2c_gpio_scl;
diff --git a/configs/Colombus_defconfig b/configs/Colombus_defconfig
index a6b3bd438a8c..0542520a0e25 100644
--- a/configs/Colombus_defconfig
+++ b/configs/Colombus_defconfig
@@ -17,6 +17,9 @@ CONFIG_VIDEO_LCD_PANEL_I2C_SDA="PA23"
 CONFIG_VIDEO_LCD_PANEL_I2C_SCL="PA24"
 CONFIG_VIDEO_LCD_PANEL_EDP_4_LANE_1620M_VIA_ANX9804=y
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SYS_I2C_SOFT=y
+CONFIG_SYS_I2C_SOFT_SPEED=5
+CONFIG_SYS_I2C_SOFT_SLAVE=0x00
 CONFIG_PHY_REALTEK=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
diff --git a/configs/UTOO_P66_defconfig b/configs/UTOO_P66_defconfig
index 78c40c067a0a..b9553b793720 100644
--- a/configs/UTOO_P66_defconfig
+++ b/configs/UTOO_P66_defconfig
@@ -21,6 +21,9 @@ CONFIG_VIDEO_LCD_BL_PWM="PB2"
 CONFIG_VIDEO_LCD_TL059WV5C0=y
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL_I2C=y
+CONFIG_SYS_I2C_SOFT=y
+CONFIG_SYS_I2C_SOFT_SPEED=5
+CONFIG_SYS_I2C_SOFT_SLAVE=0x00
 # CONFIG_REQUIRE_SERIAL_CONSOLE is not set
 CONFIG_CONS_INDEX=2
 CONFIG_USB_MUSB_HOST=y
diff --git a/configs/ethernut5_defconfig b/configs/ethernut5_defconfig
index 4da3c1d4f4c9..7b58b714eb06 100644
--- a/configs/ethernut5_defconfig
+++ b/configs/ethernut5_defconfig
@@ -55,6 +55,8 @@ CONFIG_DM=y
 CONFIG_CLK=y
 CONFIG_CLK_AT91=y
 CONFIG_AT91_GPIO=y
+CONFIG_SYS_I2C_SOFT=y
+CONFIG_SYS_I2C_SOFT_SLAVE=0
 CONFIG_MTD=y
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_MTD_RAW_NAND=y
diff --git a/configs/km_kirkwood_128m16_defconfig 
b/configs/km_kirkwood_128m16_defconfig
index 0597970746d6..b93fcbf80534 100644
--- a/configs/km_kirkwood_128m16_defconfig
+++ b/configs/km_kirkwood_128m16_defconfig
@@ -46,6 +46,8 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_NETCONSOLE=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_RAM=y
+CONFIG_SYS_I2C_SOFT=y
+CONFIG_SYS_I2C_SOFT_SLAVE=0x0
 CONFIG_SYS_I2C_EEPROM_ADDR=0x50
 # CONFIG_MMC is not set
 CONFIG_MTD=y
diff --git a/configs/km_kirkwood_defconfig b/configs/km_kirkwood_defconfig
index 7f982de136f2..0fe7a9d7a491 100644
--- a/configs/km_kirkwood_defconfig
+++ b/configs/km_kirkwood_defconfig
@@ -46,6 +46,8 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_NETCONSOLE=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_RAM=y
+CONFIG_SYS_I2C_SOFT=y
+CONFIG_SYS_I2C_SOFT_SLAVE=0x0
 CONFIG_SYS_I2C_EEPROM_ADDR=0x50
 # CONFIG_MMC is not set
 CONFIG_MTD=y
diff --git a/configs/km_kirkwood_pci_defconfig 
b/configs/km_kirkwood_pci_defconfig
index fb1b93db517d..5a49acba125a 100644
--- a/configs/km_kirkwood_pci_defconfig
+++ b/configs/km_kirkwood_pci_defconfig
@@ -47,6 +47,8 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_NETCONSOLE=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_RAM=y
+CONFIG_SYS_I2C_SOFT=y
+CONFIG_SYS_I2C_SOFT_SLAVE=0x0
 CONFIG_SYS_I2C_EEPROM_ADDR=0x50
 # CONFIG_MMC is not set
 CONFIG_MTD=y
diff --git a/configs/kmcoge5un_defconfig b/configs/kmcoge5un_defconfig
index ed9996c4c0f5..989dc6e45ac7 100644
--- a/configs/kmcoge5un_defconfig
+++ b/configs/kmcoge5un_defconfig
@@ -50,6 +50,8 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_NETCONSOLE=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_RAM=y
+CONFIG_SYS_I2C_SOFT=y
+CONFIG_SYS_I2C_SOFT_SLAVE=0x0
 CONFIG_SYS_I2C_EEPROM_ADDR=0x50
 # CONFIG_MMC is not set
 CONFIG_MTD=y
diff --git a/configs/kmnusa_defconfig b/configs/kmnusa_defconfig
index 9a1c4a48e61d..68d9b54113ec 100644
--- a/configs/kmnusa_defconfig
+++ b/configs/kmnusa_defconfig
@@ -50,6 +50,8 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_NETCONSOLE=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_RAM=y
+CONFIG_SYS_I2C_SOFT=y
+CONFIG_SYS_I2C_SOFT_SLAVE=0x0
 CONFIG_SYS_I2C_EEPROM_ADDR=0x50
 # CONFIG_MMC is not set
 CONFIG_MTD=y
diff --git 

[PATCH 08/13] cl-som-imx7: Enable CMD_EEPROM

2021-08-17 Thread Tom Rini
This platform defines everything needed to be able to use the
eeprom command.  In addition, board/compulab/common/eeprom.c is required
by the platform, and does not use CONFIG_ID_EEPROM to enable/disable
builing of it.  In order to migrate CONFIG symbols to Kconfig and to not
have to add complex logic to handle this case, enable CMD_EEPROM on this
board.

Cc: Uri Mashiach 
Signed-off-by: Tom Rini 
---
 configs/cl-som-imx7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/cl-som-imx7_defconfig b/configs/cl-som-imx7_defconfig
index f5d146038c1d..48fbacbb6f40 100644
--- a/configs/cl-som-imx7_defconfig
+++ b/configs/cl-som-imx7_defconfig
@@ -37,6 +37,7 @@ CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_EXPORTENV is not set
 # CONFIG_CMD_IMPORTENV is not set
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_EEPROM=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
-- 
2.17.1



[PATCH 05/13] siemens: Move CONFIG_SYS_I2C_EEPROM_ADDR usage out of CONFIG namespace

2021-08-17 Thread Tom Rini
The instances of CONFIG_SYS_I2C_EEPROM_ADDR on these platforms doesn't
match up with the rest of the EERPOM related defines in U-Boot.  Move
these out of the CONFIG namespace rather than make complex Kconfig
logic.

Cc: Samuel Egli 
Cc: Anatolij Gustschin 
Cc: Heiko Schocher 
Signed-off-by: Tom Rini 
---
 board/siemens/common/board.c |  3 ++-
 board/siemens/draco/board.c  | 12 
 include/configs/draco.h  |  4 
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/board/siemens/common/board.c b/board/siemens/common/board.c
index 1bdf404ac3eb..56283660d377 100644
--- a/board/siemens/common/board.c
+++ b/board/siemens/common/board.c
@@ -70,6 +70,7 @@ void sdram_init(void)
 #endif /* #ifdef CONFIG_SPL_BUILD */
 
 #ifndef CONFIG_SPL_BUILD
+#define FACTORYSET_EEPROM_ADDR 0x50
 /*
  * Basic board specific setup.  Pinmux has been handled already.
  */
@@ -87,7 +88,7 @@ int board_init(void)
gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
 
 #ifdef CONFIG_FACTORYSET
-   factoryset_read_eeprom(CONFIG_SYS_I2C_EEPROM_ADDR);
+   factoryset_read_eeprom(FACTORYSET_EEPROM_ADDR);
 #endif
 
gpmc_init();
diff --git a/board/siemens/draco/board.c b/board/siemens/draco/board.c
index af35bc188e31..f898bba4b0ee 100644
--- a/board/siemens/draco/board.c
+++ b/board/siemens/draco/board.c
@@ -132,12 +132,16 @@ struct am335x_nand_geometry {
u8 nand_bus;
 };
 
+#define EEPROM_ADDR0x50
+#define EEPROM_ADDR_DDR3   0x90
+#define EEPROM_ADDR_CHIP   0x120
+
 static int draco_read_nand_geometry(void)
 {
struct am335x_nand_geometry geo;
 
/* Read NAND geometry */
-   if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0x80, 2,
+   if (i2c_read(EEPROM_ADDR, 0x80, 2,
 (uchar *), sizeof(struct am335x_nand_geometry))) {
printf("Could not read the NAND geomtery; something 
fundamentally wrong on the I2C bus.\n");
return -EIO;
@@ -160,20 +164,20 @@ static int draco_read_nand_geometry(void)
 static int read_eeprom(void)
 {
/* Check if baseboard eeprom is available */
-   if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) {
+   if (i2c_probe(EEPROM_ADDR)) {
printf("Could not probe the EEPROM; something fundamentally 
wrong on the I2C bus.\n");
return 1;
}
 
 #ifdef CONFIG_SPL_BUILD
/* Read Siemens eeprom data (DDR3) */
-   if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, EEPROM_ADDR_DDR3, 2,
+   if (i2c_read(EEPROM_ADDR, EEPROM_ADDR_DDR3, 2,
 (uchar *), sizeof(struct ddr3_data))) {
printf("Could not read the EEPROM; something fundamentally 
wrong on the I2C bus.\nUse default DDR3 timings\n");
set_default_ddr3_timings();
}
/* Read Siemens eeprom data (CHIP) */
-   if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, EEPROM_ADDR_CHIP, 2,
+   if (i2c_read(EEPROM_ADDR, EEPROM_ADDR_CHIP, 2,
 (uchar *), sizeof(settings.chip)))
printf("Could not read chip settings\n");
 
diff --git a/include/configs/draco.h b/include/configs/draco.h
index 396eb7ded500..7c1f071d99ec 100644
--- a/include/configs/draco.h
+++ b/include/configs/draco.h
@@ -32,10 +32,6 @@
 /* I2C Configuration */
 #define CONFIG_SYS_I2C_SPEED   10
 
-#define CONFIG_SYS_I2C_EEPROM_ADDR  0x50
-#define EEPROM_ADDR_DDR3 0x90
-#define EEPROM_ADDR_CHIP 0x120
-
 #define CONFIG_FACTORYSET
 
 /* Define own nand partitions */
-- 
2.17.1



[PATCH 02/13] davinci: Drop CONFIG_MAC_ADDR_IN_EEPROM

2021-08-17 Thread Tom Rini
Looking over the current boards, there are no users of
CONFIG_MAC_ADDR_IN_EEPROM.  Further, omapl138_lcdk uses
CONFIG_NET_RANDOM_ETHADDR.  Drop various unused code paths.

Cc: Adam Ford 
Cc: Lokesh Vutla 
Signed-off-by: Tom Rini 
---
 .../mach-davinci/include/mach/davinci_misc.h  |  1 -
 arch/arm/mach-davinci/misc.c  | 27 
 board/davinci/da8xxevm/Kconfig|  9 
 board/davinci/da8xxevm/da850evm.c | 41 ++-
 board/davinci/da8xxevm/omapl138_lcdk.c| 29 -
 5 files changed, 3 insertions(+), 104 deletions(-)

diff --git a/arch/arm/mach-davinci/include/mach/davinci_misc.h 
b/arch/arm/mach-davinci/include/mach/davinci_misc.h
index 48b11f7a5c82..a40de0cc9c34 100644
--- a/arch/arm/mach-davinci/include/mach/davinci_misc.h
+++ b/arch/arm/mach-davinci/include/mach/davinci_misc.h
@@ -35,7 +35,6 @@ struct lpsc_resource {
const int   lpsc_no;
 };
 
-int dvevm_read_mac_address(uint8_t *buf);
 void davinci_sync_env_enetaddr(uint8_t *rom_enetaddr);
 int davinci_configure_pin_mux(const struct pinmux_config *pins, int n_pins);
 int davinci_configure_pin_mux_items(const struct pinmux_resource *item,
diff --git a/arch/arm/mach-davinci/misc.c b/arch/arm/mach-davinci/misc.c
index 90b38b7e020e..73fdd1f24329 100644
--- a/arch/arm/mach-davinci/misc.c
+++ b/arch/arm/mach-davinci/misc.c
@@ -41,33 +41,6 @@ int dram_init_banksize(void)
 #endif
 
 #ifdef CONFIG_DRIVER_TI_EMAC
-/*
- * Read ethernet MAC address from EEPROM for DVEVM compatible boards.
- * Returns 1 if found, 0 otherwise.
- */
-int dvevm_read_mac_address(uint8_t *buf)
-{
-#ifdef CONFIG_SYS_I2C_EEPROM_ADDR
-   /* Read MAC address. */
-   if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0x7F00,
-   CONFIG_SYS_I2C_EEPROM_ADDR_LEN, (uint8_t *) [0], 6))
-   goto i2cerr;
-
-   /* Check that MAC address is valid. */
-   if (!is_valid_ethaddr(buf))
-   goto err;
-
-   return 1; /* Found */
-
-i2cerr:
-   printf("Read from EEPROM @ 0x%02x failed\n",
-   CONFIG_SYS_I2C_EEPROM_ADDR);
-err:
-#endif /* CONFIG_SYS_I2C_EEPROM_ADDR */
-
-   return 0;
-}
-
 /*
  * Set the mii mode as MII or RMII
  */
diff --git a/board/davinci/da8xxevm/Kconfig b/board/davinci/da8xxevm/Kconfig
index bb1188b4ea2d..c5499a63fd36 100644
--- a/board/davinci/da8xxevm/Kconfig
+++ b/board/davinci/da8xxevm/Kconfig
@@ -22,15 +22,6 @@ config MAC_ADDR_IN_SPIFLASH
  their MAC address in SPI Flash from the factory
  Enable this option to read the MAC from SPI Flash
 
-config MAC_ADDR_IN_EEPROM
-   bool "MAC address in EEPROM"
-   help
- The DA850 EVM comes with SoM are programmed with
- their MAC address in SPI Flash from the factory,
- but the kit has an optional expansion board with
- EEPROM available.  Enable this option to read the
- MAC from the EEPROM
-
 endif
 
 endif
diff --git a/board/davinci/da8xxevm/da850evm.c 
b/board/davinci/da8xxevm/da850evm.c
index 6c75231ddf77..f6ce3367f86d 100644
--- a/board/davinci/da8xxevm/da850evm.c
+++ b/board/davinci/da8xxevm/da850evm.c
@@ -129,19 +129,12 @@ int misc_init_r(void)
 {
dspwake();
 
-#if defined(CONFIG_MAC_ADDR_IN_SPIFLASH) || defined(CONFIG_MAC_ADDR_IN_EEPROM)
-
-   uchar env_enetaddr[6];
-   int enetaddr_found;
+#if defined(CONFIG_MAC_ADDR_IN_SPIFLASH)
+   uchar env_enetaddr[6], buff[6];
+   int enetaddr_found, spi_mac_read;
 
enetaddr_found = eth_env_get_enetaddr("ethaddr", env_enetaddr);
 
-#endif
-
-#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
-   int spi_mac_read;
-   uchar buff[6];
-
spi_mac_read = get_mac_addr(buff);
buff[0] = 0;
 
@@ -173,34 +166,6 @@ int misc_init_r(void)
"with the MAC address in the 
environment\n");
printf("Default using MAC address from environment\n");
}
-
-#elif defined(CONFIG_MAC_ADDR_IN_EEPROM)
-   uint8_t enetaddr[8];
-   int eeprom_mac_read;
-
-   /* Read Ethernet MAC address from EEPROM */
-   eeprom_mac_read = dvevm_read_mac_address(enetaddr);
-
-   /*
-* MAC address not present in the environment
-* try and read the MAC address from EEPROM flash
-* and set it.
-*/
-   if (!enetaddr_found) {
-   if (eeprom_mac_read)
-   /* Set Ethernet MAC address from EEPROM */
-   davinci_sync_env_enetaddr(enetaddr);
-   } else {
-   /*
-* MAC address present in environment compare it with
-* the MAC address in EEPROM and warn on mismatch
-*/
-   if (eeprom_mac_read && memcmp(enetaddr, env_enetaddr, 6))
-   printf("Warning: MAC address in EEPROM don't match "
-   "with the MAC address in the 
environment\n");
-   printf("Default using MAC address from 

[PATCH 04/13] keymile: Use CONFIG_SYS_IVM_EEPROM_ADR

2021-08-17 Thread Tom Rini
As the code reads now, making this code path use
CONFIG_SYS_IVM_EEPROM_ADR rather than CONFIG_SYS_I2C_EEPROM_ADDR seems
to make sense as the rest of the EEPROM infrastructure isn't used on
these platforms.

Cc: Aleksandar Gerasimovski 
Signed-off-by: Tom Rini 
---
 board/keymile/common/ivm.c | 6 +++---
 include/configs/kmcent2.h  | 1 -
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c
index 14c70b9ad06e..ff550f7fe766 100644
--- a/board/keymile/common/ivm.c
+++ b/board/keymile/common/ivm.c
@@ -346,17 +346,17 @@ int ivm_read_eeprom(unsigned char *buf, int len, int 
mac_address_offset)
struct udevice *eedev = NULL;
 
ret = i2c_get_chip_for_busnum(CONFIG_KM_IVM_BUS,
- CONFIG_SYS_I2C_EEPROM_ADDR, 1, );
+ CONFIG_SYS_IVM_EEPROM_ADR, 1, );
if (ret) {
printf("failed to get device for EEPROM at address 0x%02x\n",
-  CONFIG_SYS_I2C_EEPROM_ADDR);
+  CONFIG_SYS_IVM_EEPROM_ADR);
return 1;
}
 
ret = dm_i2c_read(eedev, 0, buf, len);
if (ret != 0) {
printf("Error: Unable to read from I2C EEPROM at address 
%02X:%02X\n",
-  CONFIG_SYS_I2C_EEPROM_ADDR, 0);
+  CONFIG_SYS_IVM_EEPROM_ADR, 0);
return 1;
}
 #else
diff --git a/include/configs/kmcent2.h b/include/configs/kmcent2.h
index 51a01d860f0e..fe90aeb6e857 100644
--- a/include/configs/kmcent2.h
+++ b/include/configs/kmcent2.h
@@ -189,7 +189,6 @@
 #define CONFIG_SYS_SDRAM_SIZE  4096/* for fixed parameter use */
 
 #define CONFIG_SYS_LOAD_ADDR   0x200   /* default load address */
-#define CONFIG_SYS_I2C_EEPROM_ADDR CONFIG_SYS_IVM_EEPROM_ADR
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
 
 /**
-- 
2.17.1



[PATCH 01/13] kp_imx53: Switch to using a local namespace for ID EEPROM

2021-08-17 Thread Tom Rini
This platform does not use any of the standard EEPROM functionality and
instead provides its own.  Use a local namespace for the I2C related
defines to access the EEPROM.

Cc: Lukasz Majewski 
Signed-off-by: Tom Rini 
---
 board/k+p/kp_imx53/kp_id_rev.c | 9 ++---
 include/configs/kp_imx53.h | 3 ---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/board/k+p/kp_imx53/kp_id_rev.c b/board/k+p/kp_imx53/kp_id_rev.c
index 7103a3e0f2b5..9f93cf008ce8 100644
--- a/board/k+p/kp_imx53/kp_id_rev.c
+++ b/board/k+p/kp_imx53/kp_id_rev.c
@@ -64,6 +64,10 @@ void show_eeprom(void)
eth_env_set_enetaddr("ethaddr", p);
 }
 
+#define I2C_EEPROM_BUS_NUM 1
+#define I2C_EEPROM_ADDR0x50
+#define I2C_EEPROM_ADDR_LEN2
+
 int read_eeprom(void)
 {
struct udevice *dev;
@@ -72,9 +76,8 @@ int read_eeprom(void)
if (eeprom_has_been_read)
return 0;
 
-   ret = i2c_get_chip_for_busnum(CONFIG_SYS_EEPROM_BUS_NUM,
- CONFIG_SYS_I2C_EEPROM_ADDR,
- CONFIG_SYS_I2C_EEPROM_ADDR_LEN, );
+   ret = i2c_get_chip_for_busnum(I2C_EEPROM_BUS_NUM, I2C_EEPROM_ADDR,
+ I2C_EEPROM_ADDR_LEN, );
if (ret) {
printf("Cannot find EEPROM !\n");
return ret;
diff --git a/include/configs/kp_imx53.h b/include/configs/kp_imx53.h
index c94882846efa..87f4841af05c 100644
--- a/include/configs/kp_imx53.h
+++ b/include/configs/kp_imx53.h
@@ -20,9 +20,6 @@
 #define CONFIG_MXC_USB_FLAGS   0
 
 #define CONFIG_SYS_I2C_MXC
-#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50
-#define CONFIG_SYS_EEPROM_BUS_NUM 1
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
 
 /* Command definition */
 #define CONFIG_LOADADDR0x7200  /* loadaddr env var */
-- 
2.17.1



[PATCH 03/13] arm: shc: Change CONFIG_SYS_I2C_EEPROM_ADDR to EEPROM_ADDR

2021-08-17 Thread Tom Rini
The shc platforms do not make use of the rest of the EEPROM
infrastructure.  Rather than make more elaborate Kconfig logic, remove
this setting from the CONFIG namespace.

Cc: Heiko Schocher 
Signed-off-by: Tom Rini 
---
 board/bosch/shc/board.c  | 5 +++--
 include/configs/am335x_shc.h | 1 -
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/board/bosch/shc/board.c b/board/bosch/shc/board.c
index 13fd25e40710..a7a9775fdf4e 100644
--- a/board/bosch/shc/board.c
+++ b/board/bosch/shc/board.c
@@ -51,16 +51,17 @@ static int shc_eeprom_valid;
 /*
  * Read header information from EEPROM into global structure.
  */
+#define EEPROM_ADDR0x50
 static int read_eeprom(void)
 {
/* Check if baseboard eeprom is available */
-   if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) {
+   if (i2c_probe(EEPROM_ADDR)) {
puts("Could not probe the EEPROM; something fundamentally wrong 
on the I2C bus.\n");
return -ENODEV;
}
 
/* read the eeprom using i2c */
-   if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *),
+   if (i2c_read(EEPROM_ADDR, 0, 2, (uchar *),
 sizeof(header))) {
puts("Could not read the EEPROM; something fundamentally wrong 
on the I2C bus.\n");
return -EIO;
diff --git a/include/configs/am335x_shc.h b/include/configs/am335x_shc.h
index 387d50d51199..5b0eba9afa42 100644
--- a/include/configs/am335x_shc.h
+++ b/include/configs/am335x_shc.h
@@ -225,7 +225,6 @@
 #define CONFIG_NET_RETRY_COUNT 10
 
 /* I2C configuration */
-#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50/* Main EEPROM */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
 #define CONFIG_SYS_I2C_SPEED   40
 #define CONFIG_SYS_I2C_SLAVE   1
-- 
2.17.1



[PATCH 00/13] Migrate some I2C symbols to Kconfig

2021-08-17 Thread Tom Rini
This series is largely size neutral.  Aside from specific commits
calling out adding functionality, removing the unused differentiation
between CONFIG_SYS_DEF_EEPROM_ADDR and CONFIG_SYS_I2C_EEPROM_ADDR means
that in some cases we now have a default eeprom address available.  We
also now always ask about CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS so we
test for a non-zero value there.  This reduces the code size in a few
places as we remove if (something) { udelay(0); } calls.  There's also a
few places where the values didn't change, but now the optimizer
optimized things better.  Oh, and on UTOO_P66 we end up adding the
legacy software I2C driver to SPL.  I can't see how this was working as
intended before now.

I'm intending this to go in once I open -next, pending feedback.




[PATCH 1/2] drivers: mmc: Add wait_dat0 support for Freescale eSDHC driver

2021-08-17 Thread stcarlso
From: Stephen Carlson 

Adds an implementation of the wait_dat0 MMC operation for the Freescale
eSHDC driver, allowing the driver to continue when the card is ready
rather than waiting for the worst case time on each MMC switch operation.

Signed-off-by: Stephen Carlson 
---
 drivers/mmc/fsl_esdhc.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index 1d98fa65c4..f74289a677 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -1145,6 +1146,20 @@ int fsl_esdhc_hs400_prepare_ddr(struct udevice *dev)
return 0;
 }
 
+static int fsl_esdhc_wait_dat0(struct udevice *dev, int state,
+  int timeout_us)
+{
+   int ret;
+   u32 tmp;
+   struct fsl_esdhc_priv *priv = dev_get_priv(dev);
+   struct fsl_esdhc *regs = priv->esdhc_regs;
+
+   ret = readx_poll_timeout(esdhc_read32, >prsstat, tmp,
+!!(tmp & PRSSTAT_DAT0) == !!state,
+timeout_us);
+   return ret;
+}
+
 static const struct dm_mmc_ops fsl_esdhc_ops = {
.get_cd = fsl_esdhc_get_cd,
.send_cmd   = fsl_esdhc_send_cmd,
@@ -1154,6 +1169,7 @@ static const struct dm_mmc_ops fsl_esdhc_ops = {
 #endif
.reinit = fsl_esdhc_reinit,
.hs400_prepare_ddr = fsl_esdhc_hs400_prepare_ddr,
+   .wait_dat0 = fsl_esdhc_wait_dat0,
 };
 
 static const struct udevice_id fsl_esdhc_ids[] = {
-- 
2.17.1



[PATCH 0/2] drivers: mmc: Add wait_dat0 support for more devices

2021-08-17 Thread stcarlso
From: Stephen Carlson 

This patch adds eMMC driver support for polling the DAT0 data connection
on the Freescale LX devices and SDHCI compatible devices.

Polling until the card reports it is no longer busy increases eMMC
driver performance over the default behavior, which is to wait for the
worst case timeout specified by the card upon each mmc_switch operation.

This change has been tested on the Broadcom NS3 series (SDHCI) and
LX2160A series (Freescale/NXP eSDHC). U-Boot boot time savings depend on
the eMMC memory used, but can range from 100 to 500 ms or more.

Stephen Carlson (2):
  drivers: mmc: Add wait_dat0 support for Freescale eSDHC driver
  drivers: mmc: Add wait_dat0 support for sdhci driver

 drivers/mmc/fsl_esdhc.c | 16 
 drivers/mmc/sdhci.c | 20 
 include/sdhci.h |  2 ++
 3 files changed, 38 insertions(+)

-- 
2.17.1



[PATCH 2/2] drivers: mmc: Add wait_dat0 support for sdhci driver

2021-08-17 Thread stcarlso
From: Stephen Carlson 

Adds an implementation of the wait_dat0 MMC operation for the DM SDHCI
driver, allowing the driver to continue when the card is ready rather
than waiting for the worst case time on each MMC switch operation.

Signed-off-by: Stephen Carlson 
---
 drivers/mmc/sdhci.c | 20 
 include/sdhci.h |  2 ++
 2 files changed, 22 insertions(+)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index eea4701d8a..bb55e00ef5 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -775,6 +775,25 @@ static int sdhci_get_cd(struct udevice *dev)
return value;
 }
 
+static int sdhci_wait_dat0(struct udevice *dev, int state,
+  int timeout_us)
+{
+   int tmp;
+   struct mmc *mmc = mmc_get_mmc_dev(dev);
+   struct sdhci_host *host = mmc->priv;
+   unsigned long timeout = timer_get_us() + timeout_us;
+
+   // readx_poll_timeout is unsuitable because sdhci_readl accepts
+   // two arguments
+   do {
+   tmp = sdhci_readl(host, SDHCI_PRESENT_STATE);
+   if (!!(tmp & SDHCI_DATA_0_LVL_MASK) == !!state)
+   return 0;
+   } while (!timeout_us || !time_after(timer_get_us(), timeout));
+
+   return -ETIMEDOUT;
+}
+
 const struct dm_mmc_ops sdhci_ops = {
.send_cmd   = sdhci_send_command,
.set_ios= sdhci_set_ios,
@@ -783,6 +802,7 @@ const struct dm_mmc_ops sdhci_ops = {
 #ifdef MMC_SUPPORTS_TUNING
.execute_tuning = sdhci_execute_tuning,
 #endif
+   .wait_dat0  = sdhci_wait_dat0,
 };
 #else
 static const struct mmc_ops sdhci_ops = {
diff --git a/include/sdhci.h b/include/sdhci.h
index 0ae9471ad7..dd4eb41442 100644
--- a/include/sdhci.h
+++ b/include/sdhci.h
@@ -65,6 +65,8 @@
 #define  SDHCI_CARD_STATE_STABLE   BIT(17)
 #define  SDHCI_CARD_DETECT_PIN_LEVEL   BIT(18)
 #define  SDHCI_WRITE_PROTECT   BIT(19)
+#define  SDHCI_DATA_LVL_MASK   0x00F0
+#define   SDHCI_DATA_0_LVL_MASK BIT(20)
 
 #define SDHCI_HOST_CONTROL 0x28
 #define  SDHCI_CTRL_LEDBIT(0)
-- 
2.17.1



Re: U-Boot sunxi DM_I2C migration?

2021-08-17 Thread Tom Rini
On Thu, Aug 12, 2021 at 05:40:34PM -0400, Tom Rini wrote:
> On Thu, Aug 12, 2021 at 10:22:07PM +0100, Andre Przywara wrote:
> > On Thu, 12 Aug 2021 13:49:30 -0400
> > Tom Rini  wrote:
> > 
> > Hi Tom,
> > 
> > > As I try and migrate more CONFIG symbols to be Kconfig only, I see that
> > > sunxi is still using the legacy I2C drivers.  Is there something
> > > specific holding up migration?  Thanks!
> > 
> > Do you mean a DM_I2C conversion, or just moving those base address
> > symbols to Kconfig? The latter is rather easy, let me know if I should
> > give it a shot.
> > 
> > For DM_I2C, it's the usual sunxi issue: we are using both: DM_I2C and
> > DT based probing for U-Boot proper, and hardcoded CONFIG_ symbols for
> > the SPL. *Some* boards need the set up the PMIC early (for increasing
> > the CPU frequency or setting the proper DRAM voltage), so this needs to
> > be done in the SPL. I don't know how to fix this "properly",
> > but introducing DM (and DT) into the SPL is surely not worth the
> > trouble. Alternatively we could have a separate, cut-down SPL-only
> > driver, like we have for SPI (arch/arm/mach-sunxi/spl_spi_sunxi.c),
> > but not sure that's really better.
> > 
> > If there is something in particular that annoys you about the
> > situation, we could try to improve this particular issue instead?
> > Moving the non-DM code into a separate file, maybe?
> 
> I'm working on the symbols now (since it gets tricky).  The first
> example I pulled out was Hummingbird_A31 which does have legacy I2C and
> does not set DM_I2C, which is what set me down the more worrying path.
> If you can confirm that no, really, it's just SPL that's not using
> DM_I2C that's OK enough for now, we can sort out what the best but
> probably still unideal solution is long term for SPL.

As I'm converting the symbols to Kconfig now (and adding
SPL_SYS_I2C_LEGACY), what I'm seeing on sunxi is a whole lot of platform
enabling the legacy driver in full U-Boot and not DM_I2C.  Now it's
entirely possible the follow up solution really is just to switch to
DM_I2C (and continue SPL_SYS_I2C_LEGACY) and it would be a fairly
trivial switch.  But I'm not in a good position to make that change and
test it, so I'm asking you to please, once I've posted this series to
add SPL_SYS_I2C_LEGACY

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/2] imx8mm-cl-iot-gate: Do not build fip.bin by default

2021-08-17 Thread Fabio Estevam
Hi Paul,

On Mon, Aug 16, 2021 at 9:50 PM Paul Liu  wrote:
>
> Hi Fabio,
>
> It looks good to me. Thanks a lot.

I have sent a v2 with such a proposal.

I would appreciate it if you could review and test booting the two defconfigs.

Thanks,

Fabio Estevam


[PATCH v2] imx8mm-cl-iot-gate: Split the defconfigs

2021-08-17 Thread Fabio Estevam
Currently imx8mm-cl-iot-gate_defconfig fails to produce a working boot
binary due to the lack of fip.bin:

  BINMAN  all
Image 'main-section' is missing external blobs and is non-functional: blob-ext

Some images are invalid

To make the build process more consistent with the other i.MX8M targets,
split the defconfig in two:

- imx8mm-cl-iot-gate_defconfig: standard defconfig that only 
requires ATF / DDR firmware.

- imx8mm-cl-iot-gate-optee_defconfig: "more advanced" defconfig that
requires ATF / Optee / mbedtls / DDR firmware.

Signed-off-by: Fabio Estevam 
---
Changes since v1:
- Fix typo in commit log
- Add an entry in MAINTAINERS

 arch/arm/dts/Makefile |   2 +
 .../dts/imx8mm-cl-iot-gate-optee-u-boot.dtsi  | 255 ++
 arch/arm/dts/imx8mm-cl-iot-gate-optee.dts |   6 +
 arch/arm/dts/imx8mm-cl-iot-gate-u-boot.dtsi   |  14 +-
 arch/arm/mach-imx/imx8m/Kconfig   |   7 +
 board/compulab/imx8mm-cl-iot-gate/Kconfig |   2 +-
 board/compulab/imx8mm-cl-iot-gate/MAINTAINERS |   1 +
 configs/imx8mm-cl-iot-gate-optee_defconfig| 147 ++
 8 files changed, 420 insertions(+), 14 deletions(-)
 create mode 100644 arch/arm/dts/imx8mm-cl-iot-gate-optee-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-cl-iot-gate-optee.dts
 create mode 100644 configs/imx8mm-cl-iot-gate-optee_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index c42715ead4..88f52cd390 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1127,6 +1127,8 @@ dtb-$(CONFIG_TARGET_PRESIDIO_ASIC) += 
ca-presidio-engboard.dtb
 
 dtb-$(CONFIG_TARGET_IMX8MM_CL_IOT_GATE) += imx8mm-cl-iot-gate.dtb
 
+dtb-$(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE) += imx8mm-cl-iot-gate-optee.dtb
+
 dtb-$(CONFIG_TARGET_EA_LPC3250DEVKITV2) += lpc3250-ea3250.dtb
 
 targets += $(dtb-y)
diff --git a/arch/arm/dts/imx8mm-cl-iot-gate-optee-u-boot.dtsi 
b/arch/arm/dts/imx8mm-cl-iot-gate-optee-u-boot.dtsi
new file mode 100644
index 00..3226a244a9
--- /dev/null
+++ b/arch/arm/dts/imx8mm-cl-iot-gate-optee-u-boot.dtsi
@@ -0,0 +1,255 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2019 NXP
+ */
+
+/ {
+   binman: binman {
+   multiple-images;
+   };
+
+   wdt-reboot {
+   compatible = "wdt-reboot";
+   wdt = <>;
+   u-boot,dm-spl;
+   };
+
+   firmware {
+   optee {
+   compatible = "linaro,optee-tz";
+   method = "smc";
+   };
+   };
+};
+
+&{/soc@0} {
+   u-boot,dm-pre-reloc;
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+   /delete-property/ assigned-clocks;
+   /delete-property/ assigned-clock-parents;
+   /delete-property/ assigned-clock-rates;
+};
+
+_24m {
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+_uart3 {
+   u-boot,dm-spl;
+};
+
+_usdhc2_gpio {
+   u-boot,dm-spl;
+};
+
+_usdhc2 {
+   u-boot,dm-spl;
+};
+
+_usdhc3 {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+&{/soc@0/bus@3080/i2c@30a3/pmic@4b} {
+   u-boot,dm-spl;
+};
+
+&{/soc@0/bus@3080/i2c@30a3/pmic@4b/regulators} {
+   u-boot,dm-spl;
+};
+
+_i2c2 {
+   u-boot,dm-spl;
+};
+
+_pmic {
+   u-boot,dm-spl;
+};
+
+ {
+   phy-reset-gpios = < 22 GPIO_ACTIVE_LOW>;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot-spl-ddr {
+   filename = "u-boot-spl-ddr.bin";
+   pad-byte = <0xff>;
+   align-size = <4>;
+   align = <4>;
+
+   u-boot-spl {
+   align-end = <4>;
+   };
+
+   blob_1: blob-ext@1 {
+   filename = "lpddr4_pmu_train_1d_imem.bin";
+   size = <0x8000>;
+   };
+
+   blob_2: blob-ext@2 {
+   filename = "lpddr4_pmu_train_1d_dmem.bin";
+   size = <0x4000>;
+   };
+
+   blob_3: blob-ext@3 {
+   filename = "lpddr4_pmu_train_2d_imem.bin";
+   size = <0x8000>;
+   };
+
+   blob_4: blob-ext@4 {
+   filename = "lpddr4_pmu_train_2d_dmem.bin";
+   size = <0x4000>;
+   };
+   };
+
+   flash {
+   mkimage {
+   args = "-n spl/u-boot-spl.cfgout -T imx8mimage -e 
0x7e1000";
+
+ 

USB endpoints exclusion

2021-08-17 Thread Andy Shevchenko
Hi!

It seems already some of the platforms are using USB endpoints for
dedicated purposes (such as debugging). Those endpoints can't be used
for anything else (sounds like hw wired).

What is the solution in U-Boot (DTS + generic? code) to make this supported?

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 05/15] i.MX6: Enable Job ring driver model in U-Boot.

2021-08-17 Thread Sean Anderson




On 8/16/21 4:42 AM, Gaurav Jain wrote:

i.MX6(SX/UL) - added support for JR driver model.

removed sec_init() call, sec is initialized based on
job ring information processed from device tree.

Signed-off-by: Gaurav Jain 
---
  arch/arm/mach-imx/mx6/Kconfig |  8 
  arch/arm/mach-imx/mx6/soc.c   | 15 +++
  2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig
index 789a50d4e9..a7109bb512 100644
--- a/arch/arm/mach-imx/mx6/Kconfig
+++ b/arch/arm/mach-imx/mx6/Kconfig
@@ -378,6 +378,10 @@ config TARGET_MX6SXSABRESD
select DM
select DM_THERMAL
select SUPPORT_SPL
+   select FSL_CAAM
+   select FSL_BLOB
+   select MISC
+   select ARCH_MISC_INIT
  
  config TARGET_MX6SXSABREAUTO

bool "mx6sxsabreauto"
@@ -405,6 +409,10 @@ config TARGET_MX6UL_14X14_EVK
select DM_THERMAL
select SUPPORT_SPL
imply CMD_DM
+   select FSL_CAAM
+   select FSL_BLOB
+   select MISC
+   select ARCH_MISC_INIT
  
  config TARGET_MX6UL_ENGICAM

bool "Support Engicam GEAM6UL/Is.IoT"
diff --git a/arch/arm/mach-imx/mx6/soc.c b/arch/arm/mach-imx/mx6/soc.c
index aacfc854a2..3d8f649c23 100644
--- a/arch/arm/mach-imx/mx6/soc.c
+++ b/arch/arm/mach-imx/mx6/soc.c
@@ -4,6 +4,7 @@
   * Sascha Hauer, Pengutronix
   *
   * (C) Copyright 2009 Freescale Semiconductor, Inc.
+ * Copyright 2021 NXP
   */
  
  #include 

@@ -23,7 +24,8 @@
  #include 
  #include 
  #include 
-#include 
+#include 
+#include 
  #include 
  #include 
  
@@ -734,9 +736,14 @@ static void setup_serial_number(void)
  
  int arch_misc_init(void)

  {
-#ifdef CONFIG_FSL_CAAM
-   sec_init();
-#endif
+   struct udevice *dev;
+
+   uclass_find_first_device(UCLASS_MISC, );
+   for (; dev; uclass_find_next_device()) {
+   if (device_probe(dev))
+   continue;
+   }


Can you just do

uclass_get_device_by_driver(UCLASS_MISC, DM_GET_DRIVER(caam_jr), );

instead of probing all MISC devices?


+
setup_serial_number();
return 0;
  }



Re: [PATCH 0/3] common: Add fdt network helper

2021-08-17 Thread Simon Glass
Hi Tony,

On Sun, 15 Aug 2021 at 15:28, Tony Dinh  wrote:
>
> Hi Simon,
>
> On Sun, Aug 15, 2021 at 7:10 AM Simon Glass  wrote:
> >
> > Hi Tony,
> >
> > On Thu, 5 Aug 2021 at 22:49, Tony Dinh  wrote:
> > >
> > >
> > > At the moment, there is no common fdt helper function specific to 
> > > decoding network related
> > > information from FDTs. This new helper functional group fdt_support_net 
> > > is intended to be used
> > > by board-specific code within U-Boot for various network related chores.
> > >
> > > In this patch, create the 1st function fdt_get_phy_addr to parse the 
> > > device tree to find
> > > the PHY addess of a specific ethernet device.
> > >
> > >
> > > Tony Dinh (3):
> > >   Add fdt network helper header file
> > >   Add fdt network helper functions
> > >   Add fdt network helper to Makefile
> > >
> > >  common/Makefile   |  2 +-
> > >  common/fdt_support_net.c  | 46 +++
> > >  include/fdt_support_net.h | 39 +
> > >  3 files changed, 86 insertions(+), 1 deletion(-)
> > >  create mode 100644 common/fdt_support_net.c
> > >  create mode 100644 include/fdt_support_net.h
> >
> > Can this use livetre and also have some tests?
>
> I have not enabled livetree for any of the boards I have. So I just
> modeled this using the existing ./common/fdt_support.c!
>
> I do agree we should start using livetree in fdt helpers, if I
> understood it correctly, it should work for both flattree and

OK good, yes that's right.

> livetree. Perhaps we could have another patch series after this? I am
> preparing another Kirkwood board support patch that I could hold off
> submitting and enable livetree to use that as a vehicle for testing.

I think it is better to use livetree in this patch. For testing, you
can use sandbox for testing (see for example test/dm/ofnode.c)

Regards,
Simon


Re: [PATCH 01/15] crypto/fsl: Add support for CAAM Job ring driver model

2021-08-17 Thread Simon Glass
Hi,

On Mon, 16 Aug 2021 at 02:42, Gaurav Jain  wrote:
>
> added device tree support for job ring driver.
> sec is initialized based on job ring information processed
> from device tree.
>
> Signed-off-by: Gaurav Jain 
> ---
>  cmd/Kconfig |   1 +
>  drivers/crypto/fsl/Kconfig  |   7 +
>  drivers/crypto/fsl/Makefile |   2 +
>  drivers/crypto/fsl/jr.c | 314 +++-
>  drivers/crypto/fsl/jr.h |  14 ++
>  5 files changed, 229 insertions(+), 109 deletions(-)

I can't see the cover letter so will reply here.

This is UCLASS_MISC but it seems to be some sort of crypto
accelerator. What does it do? How is this modelled in Linux?

Regards,
Simon


[PATCH 1/5] efi_loader: use an enum for the memory allocation types

2021-08-17 Thread Heinrich Schuchardt
For type checking we need an enum.

Signed-off-by: Heinrich Schuchardt 
---
 include/efi.h | 34 --
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/include/efi.h b/include/efi.h
index 6417a9b8c5..4eb573a280 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -125,6 +125,34 @@ struct efi_table_hdr {
u32 reserved;
 };
 
+/* Allocation types for calls to boottime->allocate_pages*/
+/**
+ * enum efi_allocate_type - address restriction for memory allocation
+ */
+enum efi_allocate_type {
+   /**
+* @EFI_ALLOCATE_ANY_PAGES:
+* Allocate any block of sufficient size. Ignore memory address.
+*/
+   EFI_ALLOCATE_ANY_PAGES,
+   /**
+* @EFI_ALLOCATE_MAX_ADDRESS:
+* Allocate a memory block with an uppermost address less or equal
+* to the indicated address.
+*/
+   EFI_ALLOCATE_MAX_ADDRESS,
+   /**
+* @EFI_ALLOCATE_ADDRESS:
+* Allocate a memory block starting at the indicated address.
+*/
+   EFI_ALLOCATE_ADDRESS,
+   /**
+* @EFI_MAX_ALLOCATE_TYPE:
+* Value use for range checking.
+*/
+   EFI_MAX_ALLOCATE_TYPE,
+};
+
 /* Enumeration of memory types introduced in UEFI */
 enum efi_mem_type {
EFI_RESERVED_MEMORY_TYPE,
@@ -224,12 +252,6 @@ struct efi_mem_desc {
 
 #define EFI_MEMORY_DESCRIPTOR_VERSION 1
 
-/* Allocation types for calls to boottime->allocate_pages*/
-#define EFI_ALLOCATE_ANY_PAGES 0
-#define EFI_ALLOCATE_MAX_ADDRESS   1
-#define EFI_ALLOCATE_ADDRESS   2
-#define EFI_MAX_ALLOCATE_TYPE  3
-
 /* Types and defines for Time Services */
 #define EFI_TIME_ADJUST_DAYLIGHT 0x1
 #define EFI_TIME_IN_DAYLIGHT 0x2
-- 
2.30.2



[PATCH 5/5] efi_loader: use EfiBootServicesData for DP to text

2021-08-17 Thread Heinrich Schuchardt
Memory allocated in the implementation of the
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL must be of type EfiBootServicesData.

Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_loader/efi_device_path_to_text.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_device_path_to_text.c 
b/lib/efi_loader/efi_device_path_to_text.c
index d46327a1c9..57fa9d97f7 100644
--- a/lib/efi_loader/efi_device_path_to_text.c
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -34,7 +34,7 @@ static u16 *efi_str_to_u16(char *str)
efi_status_t ret;
 
len = sizeof(u16) * (utf8_utf16_strlen(str) + 1);
-   ret = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, len, (void **));
+   ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, len, (void **));
if (ret != EFI_SUCCESS)
return NULL;
dst = out;
-- 
2.30.2



[PATCH 0/5] efi_loader: user EfiBootServicesData for device path

2021-08-17 Thread Heinrich Schuchardt
When creating device paths or converting the device paths to text we must
memory of type EfiBootServiceData.

Change function definitions to use enums instead of int to avoid future
misuse of constants.

Heinrich Schuchardt (5):
  efi_loader: use an enum for the memory allocation types
  efi_loader rename enum efi_mem_type to efi_memory_type
  efi_loader: use correct type for AllocatePages, AllocatePool
  efi_loader: use EfiBootServicesData for device path
  efi_loader: use EfiBootServicesData for DP to text

 arch/x86/include/asm/hob.h   |  2 +-
 include/efi.h| 36 +++-
 include/efi_api.h|  2 +-
 include/efi_loader.h |  9 +++---
 lib/efi_loader/efi_device_path.c |  2 +-
 lib/efi_loader/efi_device_path_to_text.c |  2 +-
 lib/efi_loader/efi_memory.c  |  5 ++--
 7 files changed, 41 insertions(+), 17 deletions(-)

-- 
2.30.2



[PATCH 2/5] efi_loader rename enum efi_mem_type to efi_memory_type

2021-08-17 Thread Heinrich Schuchardt
Use the same name as in the UEFI specification to avoid confusion.

Signed-off-by: Heinrich Schuchardt 
---
 arch/x86/include/asm/hob.h | 2 +-
 include/efi.h  | 2 +-
 include/efi_api.h  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/hob.h b/arch/x86/include/asm/hob.h
index 56e11dbb28..2f5b6e24c2 100644
--- a/arch/x86/include/asm/hob.h
+++ b/arch/x86/include/asm/hob.h
@@ -91,7 +91,7 @@ struct hob_mem_alloc {
 * Type EFI_MEMORY_TYPE is defined in AllocatePages() in the UEFI 2.0
 * specification.
 */
-   enum efi_mem_type   mem_type;
+   enum efi_memory_typemem_type;
/* padding */
u8  reserved[4];
 };
diff --git a/include/efi.h b/include/efi.h
index 4eb573a280..18c13e0370 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -154,7 +154,7 @@ enum efi_allocate_type {
 };
 
 /* Enumeration of memory types introduced in UEFI */
-enum efi_mem_type {
+enum efi_memory_type {
EFI_RESERVED_MEMORY_TYPE,
/*
 * The code portions of a loaded application.
diff --git a/include/efi_api.h b/include/efi_api.h
index 38ac47f164..c8f959bb72 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -249,7 +249,7 @@ struct efi_memory_range {
 struct efi_memory_range_capsule {
struct efi_capsule_header *header;
/* EFI_MEMORY_TYPE: 0x8000-0x */
-   enum efi_mem_type os_requested_memory_type;
+   enum efi_memory_type os_requested_memory_type;
u64 number_of_memory_ranges;
struct efi_memory_range memory_ranges[];
 } __packed;
-- 
2.30.2



[PATCH 3/5] efi_loader: use correct type for AllocatePages, AllocatePool

2021-08-17 Thread Heinrich Schuchardt
Use enum efi_memory_type and enum_allocate_type in the definitions of the
efi_allocate_pages(), efi_allocate_pool().

In the external UEFI API leave the type as int as the UEFI specification
explicitly requires that enums use a 32bit type.

Signed-off-by: Heinrich Schuchardt 
---
 include/efi_loader.h| 9 +
 lib/efi_loader/efi_memory.c | 5 +++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 32cb8d0f1e..c440962fe5 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -676,13 +676,14 @@ struct efi_device_path *efi_get_dp_from_boot(const 
efi_guid_t guid);
 /* Generic EFI memory allocator, call this to get memory */
 void *efi_alloc(uint64_t len, int memory_type);
 /* More specific EFI memory allocator, called by EFI payloads */
-efi_status_t efi_allocate_pages(int type, int memory_type, efi_uintn_t pages,
-   uint64_t *memory);
+efi_status_t efi_allocate_pages(enum efi_allocate_type type,
+   enum efi_memory_type memory_type,
+   efi_uintn_t pages, uint64_t *memory);
 /* EFI memory free function. */
 efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages);
 /* EFI memory allocator for small allocations */
-efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size,
-  void **buffer);
+efi_status_t efi_allocate_pool(enum efi_memory_type pool_type,
+  efi_uintn_t size, void **buffer);
 /* EFI pool memory free function. */
 efi_status_t efi_free_pool(void *buffer);
 /* Returns the EFI memory map */
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index be2f655dff..f4acbee4f9 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -454,7 +454,8 @@ static uint64_t efi_find_free_memory(uint64_t len, uint64_t 
max_addr)
  * @memory allocated memory
  * @return status code
  */
-efi_status_t efi_allocate_pages(int type, int memory_type,
+efi_status_t efi_allocate_pages(enum efi_allocate_type type,
+   enum efi_memory_type memory_type,
efi_uintn_t pages, uint64_t *memory)
 {
u64 len = pages << EFI_PAGE_SHIFT;
@@ -556,7 +557,7 @@ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t 
pages)
  * @buffer:allocated memory
  * Return: status code
  */
-efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void **buffer)
+efi_status_t efi_allocate_pool(enum efi_memory_type pool_type, efi_uintn_t 
size, void **buffer)
 {
efi_status_t r;
u64 addr;
-- 
2.30.2



[PATCH 4/5] efi_loader: use EfiBootServicesData for device path

2021-08-17 Thread Heinrich Schuchardt
dp_alloc() was using a constant from the wrong enum resulting in creating
device paths in EfiReservedMemory.

Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_loader/efi_device_path.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 9c3ac712fe..cbdb466da4 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -68,7 +68,7 @@ static void *dp_alloc(size_t sz)
 {
void *buf;
 
-   if (efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, sz, ) !=
+   if (efi_allocate_pool(EFI_BOOT_SERVICES_DATA, sz, ) !=
EFI_SUCCESS) {
debug("EFI: ERROR: out of memory in %s\n", __func__);
return NULL;
-- 
2.30.2



Re: Fwd: New Defects reported by Coverity Scan for Das U-Boot

2021-08-17 Thread Tom Rini
On Tue, Aug 17, 2021 at 07:21:43AM +0200, Heinrich Schuchardt wrote:

> Hello Tom,
> 
> I suggest to mark these as invalid:
> 
> CID 338485
> CID 338490
> CID 338489

Done, thanks.

-- 
Tom


signature.asc
Description: PGP signature


U-Boot contributor call (17-Aug-21) in 45 minutes

2021-08-17 Thread Simon Glass
Hi,

No fixed agenda today.

Regards,
Simon

[1] https://bit.ly/3bFvwA1
or 
https://docs.google.com/document/d/1YBOMsbM19uSFyoJWnt7-PsOLBaevzQUgV-hiR88a5-o/edit#heading=h.flytinyefvov


[PATCH 4/4] configs: sama5d2: add qspi config for QSPI1

2021-08-17 Thread Eugen Hristev
From: Mihai Sain 

Add new config for storing environment from QSPI1.

Signed-off-by: Mihai Sain 
[eugen.hris...@microchip.com: cleanup and add MAINTAINERS entry]
Signed-off-by: Eugen Hristev 
---
 board/atmel/sama5d2_icp/MAINTAINERS |   1 +
 configs/sama5d2_icp_qspiflash_defconfig | 103 
 2 files changed, 104 insertions(+)
 create mode 100644 configs/sama5d2_icp_qspiflash_defconfig

diff --git a/board/atmel/sama5d2_icp/MAINTAINERS 
b/board/atmel/sama5d2_icp/MAINTAINERS
index db984b6ae4..4a65c65ec3 100644
--- a/board/atmel/sama5d2_icp/MAINTAINERS
+++ b/board/atmel/sama5d2_icp/MAINTAINERS
@@ -4,4 +4,5 @@ S: Maintained
 F: board/atmel/sama5d2_icp/
 F: include/configs/sama5d2_icp.h
 F: configs/sama5d2_icp_mmc_defconfig
+F: configs/sama5d2_icp_qspiflash_defconfig
 
diff --git a/configs/sama5d2_icp_qspiflash_defconfig 
b/configs/sama5d2_icp_qspiflash_defconfig
new file mode 100644
index 00..c3dd464d7f
--- /dev/null
+++ b/configs/sama5d2_icp_qspiflash_defconfig
@@ -0,0 +1,103 @@
+CONFIG_ARM=y
+CONFIG_ARCH_CPU_INIT=y
+CONFIG_ARCH_AT91=y
+CONFIG_SYS_TEXT_BASE=0x26f0
+CONFIG_TARGET_SAMA5D2_ICP=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_SYS_MEMTEST_START=0x2000
+CONFIG_SYS_MEMTEST_END=0x4000
+CONFIG_ENV_SIZE=0x4000
+CONFIG_DM_GPIO=y
+CONFIG_DEFAULT_DEVICE_TREE="at91-sama5d2_icp"
+CONFIG_DEBUG_UART_BOARD_INIT=y
+CONFIG_DEBUG_UART_BASE=0xf801c000
+CONFIG_DEBUG_UART_CLOCK=8300
+CONFIG_DEBUG_UART=y
+CONFIG_ENV_VARS_UBOOT_CONFIG=y
+CONFIG_SYS_BOOT_GET_CMDLINE=y
+CONFIG_SYS_BOOT_GET_KBD=y
+CONFIG_FIT=y
+CONFIG_SYS_EXTRA_OPTIONS="SAMA5D2"
+CONFIG_QSPI_BOOT=y
+CONFIG_SD_BOOT=y
+CONFIG_BOOTDELAY=3
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyS0,115200 earlycon earlyprintk=serial,ttyS0, 
ignore_loglevel root=/dev/mmcblk0p2 memtest=0 rootfstype=ext4 rw rootwait"
+CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_HUSH_PARSER=y
+CONFIG_CMD_CONFIG=y
+CONFIG_CMD_BOOTZ=y
+# CONFIG_CMD_IMI is not set
+CONFIG_CMD_EEPROM=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_SYS_ALT_MEMTEST=y
+CONFIG_CMD_CLK=y
+CONFIG_CMD_DM=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_SDRAM=y
+CONFIG_CMD_SF_TEST=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_GETTIME=y
+CONFIG_CMD_TIMER=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
+CONFIG_OF_CONTROL=y
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_USE_ENV_SPI_BUS=y
+CONFIG_ENV_SPI_BUS=2
+CONFIG_USE_ENV_SPI_CS=y
+CONFIG_ENV_SPI_CS=0
+CONFIG_USE_ENV_SPI_MAX_HZ=y
+CONFIG_ENV_SPI_MAX_HZ=6600
+CONFIG_USE_ENV_SPI_MODE=y
+CONFIG_ENV_SPI_MODE=0x0
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_DM=y
+CONFIG_CLK=y
+CONFIG_CLK_AT91=y
+CONFIG_AT91_UTMI=y
+CONFIG_AT91_H32MX=y
+CONFIG_AT91_GENERIC_CLK=y
+CONFIG_ATMEL_PIO4=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_AT91=y
+CONFIG_I2C_EEPROM=y
+CONFIG_MICROCHIP_FLEXCOM=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_ATMEL=y
+CONFIG_MTD=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SF_DEFAULT_BUS=2
+CONFIG_SF_DEFAULT_SPEED=6600
+CONFIG_SPI_FLASH_SFDP_SUPPORT=y
+CONFIG_SPI_FLASH_ATMEL=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_SST=y
+CONFIG_DM_ETH=y
+CONFIG_MACB=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_AT91PIO4=y
+CONFIG_DM_SERIAL=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_ATMEL_USART=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_ATMEL_QSPI=y
+CONFIG_TIMER=y
+CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_ATMEL_USBA=y
+CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_SPL_OF_LIBFDT=y
+# CONFIG_EFI_LOADER_HII is not set
-- 
2.25.1



[PATCH 3/4] ARM: dts: at91: sama5d2: fix dtc warning for ohci and ehci

2021-08-17 Thread Eugen Hristev
Fixed the following DTC build warning (reproducible with W=1)

arch/arm/dts/at91-sama5d2_icp.dtb: Warning (unit_address_format): 
/ahb/ohci@0040: unit name should not have leading 0s
arch/arm/dts/at91-sama5d2_icp.dtb: Warning (unit_address_format): 
/ahb/ehci@0050: unit name should not have leading 0s

Signed-off-by: Eugen Hristev 
---
 arch/arm/dts/at91-sama5d27_som1_ek.dts | 4 ++--
 arch/arm/dts/at91-sama5d2_ptc_ek.dts   | 4 ++--
 arch/arm/dts/at91-sama5d2_xplained.dts | 4 ++--
 arch/arm/dts/sama5d2.dtsi  | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm/dts/at91-sama5d27_som1_ek.dts 
b/arch/arm/dts/at91-sama5d27_som1_ek.dts
index ee851a1bef..efd1a5d197 100644
--- a/arch/arm/dts/at91-sama5d27_som1_ek.dts
+++ b/arch/arm/dts/at91-sama5d27_som1_ek.dts
@@ -68,7 +68,7 @@
};
 
ahb {
-   usb1: ohci@0040 {
+   usb1: ohci@40 {
num-ports = <3>;
atmel,vbus-gpio = < 42 0>;
pinctrl-names = "default";
@@ -76,7 +76,7 @@
status = "okay";
};
 
-   usb2: ehci@0050 {
+   usb2: ehci@50 {
status = "okay";
};
 
diff --git a/arch/arm/dts/at91-sama5d2_ptc_ek.dts 
b/arch/arm/dts/at91-sama5d2_ptc_ek.dts
index cd3711a02a..f45fb1ef26 100644
--- a/arch/arm/dts/at91-sama5d2_ptc_ek.dts
+++ b/arch/arm/dts/at91-sama5d2_ptc_ek.dts
@@ -76,7 +76,7 @@
status = "okay";
};
 
-   usb1: ohci@0040 {
+   usb1: ohci@40 {
num-ports = <3>;
atmel,vbus-gpio = <0
PIN_PB12 GPIO_ACTIVE_HIGH
@@ -87,7 +87,7 @@
status = "okay";
};
 
-   usb2: ehci@0050 {
+   usb2: ehci@50 {
status = "okay";
};
 
diff --git a/arch/arm/dts/at91-sama5d2_xplained.dts 
b/arch/arm/dts/at91-sama5d2_xplained.dts
index b733c4d4ce..e7c91c5fec 100644
--- a/arch/arm/dts/at91-sama5d2_xplained.dts
+++ b/arch/arm/dts/at91-sama5d2_xplained.dts
@@ -25,7 +25,7 @@
};
 
ahb {
-   usb1: ohci@0040 {
+   usb1: ohci@40 {
num-ports = <3>;
atmel,vbus-gpio = < 42 0>;
pinctrl-names = "default";
@@ -33,7 +33,7 @@
status = "okay";
};
 
-   usb2: ehci@0050 {
+   usb2: ehci@50 {
status = "okay";
};
 
diff --git a/arch/arm/dts/sama5d2.dtsi b/arch/arm/dts/sama5d2.dtsi
index 6fb2cb25f9..d8a125b073 100644
--- a/arch/arm/dts/sama5d2.dtsi
+++ b/arch/arm/dts/sama5d2.dtsi
@@ -32,7 +32,7 @@
#size-cells = <1>;
u-boot,dm-pre-reloc;
 
-   usb1: ohci@0040 {
+   usb1: ohci@40 {
compatible = "atmel,at91rm9200-ohci", "usb-ohci";
reg = <0x0040 0x10>;
clocks = <_clk>, <_clk>, <>;
@@ -40,7 +40,7 @@
status = "disabled";
};
 
-   usb2: ehci@0050 {
+   usb2: ehci@50 {
compatible = "atmel,at91sam9g45-ehci", "usb-ehci";
reg = <0x0050 0x10>;
clocks = <>, <_clk>;
-- 
2.25.1



[PATCH 1/4] ARM: dts: at91: sama5d2_icp: add QSPI1 device

2021-08-17 Thread Eugen Hristev
From: Mihai Sain 

Add support for sst26vf064b 64Mbit qspi-flash that is
present on sama5d2_icp board.

Signed-off-by: Mihai Sain 
[eugen.hris...@microchip.com: move u-boot properties to sama5d2_icp-u-boot.dtsi]
Signed-off-by: Eugen Hristev 
---
 arch/arm/dts/at91-sama5d2_icp-u-boot.dtsi | 16 +
 arch/arm/dts/at91-sama5d2_icp.dts | 29 +++
 2 files changed, 45 insertions(+)

diff --git a/arch/arm/dts/at91-sama5d2_icp-u-boot.dtsi 
b/arch/arm/dts/at91-sama5d2_icp-u-boot.dtsi
index 347fa813e9..68c27f229f 100644
--- a/arch/arm/dts/at91-sama5d2_icp-u-boot.dtsi
+++ b/arch/arm/dts/at91-sama5d2_icp-u-boot.dtsi
@@ -28,3 +28,19 @@
 _mikrobus1_uart {
u-boot,dm-pre-reloc;
 };
+
+_qspi1_sck_cs_default {
+   u-boot,dm-pre-reloc;
+};
+
+_qspi1_dat_default {
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   u-boot,dm-pre-reloc;
+
+   flash@0 {
+   u-boot,dm-pre-reloc;
+   };
+};
diff --git a/arch/arm/dts/at91-sama5d2_icp.dts 
b/arch/arm/dts/at91-sama5d2_icp.dts
index f81fa60171..2c6e91c1c7 100644
--- a/arch/arm/dts/at91-sama5d2_icp.dts
+++ b/arch/arm/dts/at91-sama5d2_icp.dts
@@ -33,6 +33,21 @@
};
 
apb {
+
+   qspi1: spi@f0024000 {
+   pinctrl-names = "default";
+   pinctrl-0 = <_qspi1_sck_cs_default 
_qspi1_dat_default>;
+   status = "okay";
+
+   flash@0 {
+   compatible = "jedec,spi-nor";
+   reg = <0>;
+   spi-max-frequency = <8300>;
+   spi-rx-bus-width = <4>;
+   spi-tx-bus-width = <4>;
+   };
+   };
+
uart0: serial@f801c000 { /* mikrobus1 uart */
pinctrl-names = "default";
pinctrl-0 = <_mikrobus1_uart>;
@@ -109,6 +124,20 @@
bias-pull-up;
};
 
+   pinctrl_qspi1_sck_cs_default: 
qspi1_sck_cs_default {
+   pinmux = ,
+;
+   bias-disable;
+   };
+
+   pinctrl_qspi1_dat_default: 
qspi1_dat_default {
+   pinmux = ,
+,
+,
+;
+   bias-pull-up;
+   };
+
pinctrl_sdmmc0_default: sdmmc0_default {
pinmux = ,
 ,
-- 
2.25.1



[PATCH 2/4] ARM: dts: at91: sama5d2_icp: cosmetic arrangement of the nodes

2021-08-17 Thread Eugen Hristev
Reorder the nodes following the kernel rules: nodes in a range are sorted
by ascending bus address, and when referenced by phandle, are ordered
alphabetically.

Signed-off-by: Eugen Hristev 
---
 arch/arm/dts/at91-sama5d2_icp-u-boot.dtsi | 23 +++--
 arch/arm/dts/at91-sama5d2_icp.dts | 25 ---
 2 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/arch/arm/dts/at91-sama5d2_icp-u-boot.dtsi 
b/arch/arm/dts/at91-sama5d2_icp-u-boot.dtsi
index 68c27f229f..b45de978c2 100644
--- a/arch/arm/dts/at91-sama5d2_icp-u-boot.dtsi
+++ b/arch/arm/dts/at91-sama5d2_icp-u-boot.dtsi
@@ -13,34 +13,35 @@
};
 };
 
- {
+_mikrobus1_uart {
u-boot,dm-pre-reloc;
 };
 
- { /* mikrobus1 uart */
+_qspi1_sck_cs_default {
u-boot,dm-pre-reloc;
 };
 
-_sdmmc0_default {
+_qspi1_dat_default {
u-boot,dm-pre-reloc;
 };
 
-_mikrobus1_uart {
+_sdmmc0_default {
u-boot,dm-pre-reloc;
 };
 
-_qspi1_sck_cs_default {
+ {
u-boot,dm-pre-reloc;
+
+   flash@0 {
+   u-boot,dm-pre-reloc;
+   };
 };
 
-_qspi1_dat_default {
+ {
u-boot,dm-pre-reloc;
 };
 
- {
+ { /* mikrobus1 uart */
u-boot,dm-pre-reloc;
-
-   flash@0 {
-   u-boot,dm-pre-reloc;
-   };
 };
+
diff --git a/arch/arm/dts/at91-sama5d2_icp.dts 
b/arch/arm/dts/at91-sama5d2_icp.dts
index 2c6e91c1c7..44522197ff 100644
--- a/arch/arm/dts/at91-sama5d2_icp.dts
+++ b/arch/arm/dts/at91-sama5d2_icp.dts
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+ OR MIT
 /*
  * at91-sama5d2_icp.dts - Device Tree file for SAMA5D2 ICP board
- * SAMA5D2 Industrial Connectivity Board
+ * SAMA5D2 Industrial Connectivity Platform
  *
  *  Copyright (c) 2018, Microchip Technology Inc.
  *2018, Eugen Hristev 
@@ -48,16 +48,16 @@
};
};
 
-   uart0: serial@f801c000 { /* mikrobus1 uart */
+   macb0: ethernet@f8008000 {
pinctrl-names = "default";
-   pinctrl-0 = <_mikrobus1_uart>;
+   pinctrl-0 = <_macb0_rmii 
_macb0_phy_irq _macb0_rst>;
+   phy-mode = "internal";
status = "okay";
};
 
-   macb0: ethernet@f8008000 {
+   uart0: serial@f801c000 { /* mikrobus1 uart */
pinctrl-names = "default";
-   pinctrl-0 = <_macb0_rmii 
_macb0_phy_irq _macb0_rst>;
-   phy-mode = "internal";
+   pinctrl-0 = <_mikrobus1_uart>;
status = "okay";
};
 
@@ -85,6 +85,7 @@
pagesize = <16>;
};
};
+
pioA: gpio@fc038000 {
status = "okay";
pinctrl {
@@ -124,6 +125,12 @@
bias-pull-up;
};
 
+   pinctrl_mikrobus1_uart: mikrobus1_uart {
+   pinmux = ,
+;
+   bias-disable;
+   };
+
pinctrl_qspi1_sck_cs_default: 
qspi1_sck_cs_default {
pinmux = ,
 ;
@@ -148,12 +155,6 @@
 ;
bias-disable;
};
-
-   pinctrl_mikrobus1_uart: mikrobus1_uart {
-   pinmux = ,
-;
-   bias-disable;
-   };
};
};
};
-- 
2.25.1



Re: [PATCH 00/11] Reduce usage of timestamp macros

2021-08-17 Thread Tom Rini
On Tue, Aug 17, 2021 at 01:02:41PM +0200, Pali Rohár wrote:
> On Monday 02 August 2021 15:18:27 Pali Rohár wrote:
> > Including timestamp.h (either directly or transitionally) cause build
> > system to recompile binaries at every 'make' run. This has disadvantage
> > in U-Boot development as for every small change 'make' recompiles lot of
> > other irrelevant files which were not touched / changed.
> > 
> > This patch series eliminate transitional / indirect usage of
> > timestamp.h by removing unneeded inclusion of header files, moving
> > timestamp values from macros to global variables, etc...
> > 
> > After these patches, U-Boot tools are not recompiled by every 'make' run,
> > which decrease time for incremental U-Boot recompilation.
> > 
> > Please test these patches, specially m68k and powerpc parts as I do not
> > have any of these boards.
> > 
> > Patch series depend on this patch (now marked as accepted):
> > http://patchwork.ozlabs.org/project/uboot/patch/20210710111001.32325-1-p...@kernel.org/
> 
> Hello! Is there anything else needed for this patch series?

This is likely going to wait for the next branch to open, thanks.

-- 
Tom


signature.asc
Description: PGP signature


Re: Pull request, u-boot-tegra/master

2021-08-17 Thread Tom Rini
On Mon, Aug 16, 2021 at 04:26:06PM -0700, Tom Warren wrote:

> Tom,
> 
> Please pull u-boot-tegra/master into U-Boot/master. Thanks.
> 
> The following changes since commit a0da2dda4ed9d0aee5265e9cd8876734f9f80e09:
> 
>   Prepare v2021.10-rc2 (2021-08-16 14:18:45 -0400)
> 
> are available in the git repository at:
> 
>   ssh://twarren@git-mirror-santaclara:12001/m/denx.de/u-boot-tegra.git
> 
> for you to fetch changes up to 5e39e20a1af916fee3aabd61eedafadf29a9edb9:
> 
>   board: apalis-tk1: launch toradex easy installer in usb recovery
> (2021-08-16 12:17:07 -0700)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2] arm: mvebu: a37xx: Define CONFIG_SYS_REF_CLK and use it instead of get_ref_clk()

2021-08-17 Thread Stefan Roese

Hi Marek,

On 17.08.21 14:50, Marek Behún wrote:

+#elif defined(CONFIG_ARMADA_3700)
+/* SAR values for Armada 3700 */
+#define MVEBU_TEST_PIN_LATCH_N MVEBU_REGISTER(0x13808)
+#define MVEBU_XTAL_MODE_MASK   BIT(9)
+#define CONFIG_SYS_REF_CLK ((readl(MVEBU_TEST_PIN_LATCH_N) & 
MVEBU_XTAL_MODE_MASK) ? \
+4000 : 2500)


Stefan,

we discussed this with Pali yesterday. For now, I am okay with it, but
I consider this bad design.


I have to admit, that I'm also not 100% happy. But I didn't want to
burden Pali with more cleanup here.


This either should be done via the clk API or, if we insist on keeping
it simple, via a static inline function, with caching via a static
variable, so that the register needs to be read only once (at least for
each compilation unit).

Regarding the clk API kernel has driver for armada-37xx-xtal. But I am
thinking about expanding the clk-fixed-mmio driver so that it would be
more generic and could be used for this.

What do you think?


I would very much welcome such a change / enhancement. This legacy type
input clock handling in MVEBU (and some other platforms) definitely
needs the get changed to "correct CLK API" handling.

Thanks,
Stefan


Re: [PATCH v2] arm: mvebu: a37xx: Define CONFIG_SYS_REF_CLK and use it instead of get_ref_clk()

2021-08-17 Thread Marek Behún
> > +#elif defined(CONFIG_ARMADA_3700)
> > +/* SAR values for Armada 3700 */
> > +#define MVEBU_TEST_PIN_LATCH_N MVEBU_REGISTER(0x13808)
> > +#define MVEBU_XTAL_MODE_MASK   BIT(9)
> > +#define CONFIG_SYS_REF_CLK ((readl(MVEBU_TEST_PIN_LATCH_N) & 
> > MVEBU_XTAL_MODE_MASK) ? \
> > +4000 : 2500)

Stefan,

we discussed this with Pali yesterday. For now, I am okay with it, but
I consider this bad design.

This either should be done via the clk API or, if we insist on keeping
it simple, via a static inline function, with caching via a static
variable, so that the register needs to be read only once (at least for
each compilation unit).

Regarding the clk API kernel has driver for armada-37xx-xtal. But I am
thinking about expanding the clk-fixed-mmio driver so that it would be
more generic and could be used for this.

What do you think?

Marek


Re: [PATCH v4 07/10] watchdog: wdt-uclass.c: handle all DM watchdogs in watchdog_reset()

2021-08-17 Thread Tom Rini
On Tue, Aug 17, 2021 at 11:28:39AM +0200, Stefan Roese wrote:
> On 12.08.21 15:48, Tom Rini wrote:
> > On Thu, Aug 12, 2021 at 08:40:21AM +0200, Wolfgang Denk wrote:
> > > Dear Tom,
> > > 
> > > In message <20210811124318.GT858@bill-the-cat> you wrote:
> > > > 
> > > > > This argument fits on all types or effors: they are supposed to
> > > > > never ever happen - at least in theory; in reality they do, and more
> > > > > often than we like.
> > > > > 
> > > > > And a proper error message is mandatory for correct error handling.
> > > > 
> > > > Error messages are a fine line to walk.  We've got to have been very
> > > > badly corrupted to go down this error path.  There's going to be lots of
> > > > other error messages popping out.  Saving a bit of .text is good.  It
> > > > makes it easier to justify spending a little .text later.
> > > 
> > > Letting errors slip through unnoticed when there is a trival way to
> > > at least inform the user of the problem is simply unacceptable.
> > > 
> > > Please do not let U-Boot degrade into such a crappy piece of code.
> > > 
> > > There are tons of other places where we don't even mention code
> > > size, so if you want to save on that, there are many bette4r places
> > > to save than error handling.
> > 
> > Alright, lets take a look at what kind of area of the code we're talking
> > about.  uclass_get is a pretty fundamental thing.  If that fails, your
> > system is on fire.  Things are massively corrupt.  Lets look at other
> > existing callers to see what happens.  Most callers check the return
> > code, like you need to, and pass it up the chain to deal with.  We have
> > a few board specific ones such as
> > board/Marvell/octeontx2/board.c::board_quiesce_devices() that is also
> > conceptually like the x530 case in the next part of the series.  That
> > does print on failure.  The rest of the ones that print an error message
> > are about commands and it's somewhat helpful there.
> > 
> > So yes, return codes need to be checked and passed.  But no, not every
> > single error path needs to print to the user along every part of an
> > error path either.
> > 
> > > > And here I agree, catch an error code, pass the error code back to the
> > > > caller.  That's far more important than making sure that every error
> > > > code we catch logs a message by default every time.
> > > 
> > > It does not matter where the error is reported - in the called
> > > function, or in some caller firther up the call tree.  But it _must_
> > > be reportet at least once.
> > > 
> > > So if we don't issue an error message here, we need to check and fix
> > > the callers, too.
> > 
> > That would be the next patch in the series where the BSP author isn't
> > currently checking the return value, and this series doesn't change
> > that.  Perhaps it should, and CC the maintainer.  But I think has been
> > said a few times over the course of this series, what exactly is one
> > going to do about the failure?  Getting specific for a moment, if you're
> > in the case of "shutdown the watchdog" and the watchdog doesn't shutdown
> > like you want it to, do you hang and hope the watchdog is alive to kick
> > things still?  hang and lock the system?  Figure the system is on fire
> > anyhow but add another message to the failure spew?
> > 
> > Again, I think the change that's needed to this patch is to make it
> > return the error code to the caller.  Let the caller decide.  And make
> > sure to CC the board maintainer on the next go-round so they can chime
> > in about that.
> 
> Getting back to this to hopefully get this decided:
> 
> It seems that we (most of us?) agree on this change, that wdt_stop_all()
> shall be changed to return an error code and the caller can decide what
> to do with it?
> 
> If yes, then Rasmus, could you please re-spin this patchset accordingly
> and send v6?

Yes, please and thanks.

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 2/2] imx53: usbarmory: Use ethernet driver model

2021-08-17 Thread andrej . rosano
From: Andrej Rosano 

Enable ethernet driver model as it is mandatory.

Signed-off-by: Andrej Rosano 
---
 configs/usbarmory_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/usbarmory_defconfig b/configs/usbarmory_defconfig
index 91eb3a4965..ea76068bbb 100644
--- a/configs/usbarmory_defconfig
+++ b/configs/usbarmory_defconfig
@@ -34,3 +34,4 @@ CONFIG_MXC_UART=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
 CONFIG_USB_EHCI_MX5=y
+CONFIG_DM_ETH=y
-- 
2.32.0



[PATCH 1/2] imx53: usbarmory: Add card detect configuration

2021-08-17 Thread andrej . rosano
From: Andrej Rosano 

After the enforcement of DM_MMC the microSD card is not detected. Fix by
correctly configuring the card detect in the devicetree.

Signed-off-by: Andrej Rosano 
---
 arch/arm/dts/imx53-usbarmory.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/dts/imx53-usbarmory.dts b/arch/arm/dts/imx53-usbarmory.dts
index f34993a490..433b62e736 100644
--- a/arch/arm/dts/imx53-usbarmory.dts
+++ b/arch/arm/dts/imx53-usbarmory.dts
@@ -91,6 +91,7 @@
  {
pinctrl-names = "default";
pinctrl-0 = <_esdhc1>;
+   broken-cd;
status = "okay";
 };
 
-- 
2.32.0



[PATCH] arm64: zynqmp: Enable sha1sum command

2021-08-17 Thread Michal Simek
Enable it for TPM usage.

Signed-off-by: Michal Simek 
---

 configs/xilinx_zynqmp_virt_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/xilinx_zynqmp_virt_defconfig 
b/configs/xilinx_zynqmp_virt_defconfig
index e68b7841fc9a..a8fd6629e7b9 100644
--- a/configs/xilinx_zynqmp_virt_defconfig
+++ b/configs/xilinx_zynqmp_virt_defconfig
@@ -40,6 +40,7 @@ CONFIG_CMD_THOR_DOWNLOAD=y
 CONFIG_CMD_NVEDIT_EFI=y
 CONFIG_CMD_MEMTEST=y
 CONFIG_SYS_ALT_MEMTEST=y
+CONFIG_CMD_SHA1SUM=y
 CONFIG_CMD_BIND=y
 CONFIG_CMD_CLK=y
 CONFIG_CMD_DFU=y
-- 
2.32.0



[PATCH] watchdog: versal: Include header file needed for dev_ functions

2021-08-17 Thread Michal Simek
From: Ashok Reddy Soma 

dev_dbg, dev_err and dev_warn seems to be moved to different header file.
Include dm/device_compat.h file to compile properly.

Signed-off-by: Ashok Reddy Soma 
Signed-off-by: Michal Simek 
---

 drivers/watchdog/xilinx_wwdt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/watchdog/xilinx_wwdt.c b/drivers/watchdog/xilinx_wwdt.c
index 11b30ae85df0..c8e6c60cdd22 100644
--- a/drivers/watchdog/xilinx_wwdt.c
+++ b/drivers/watchdog/xilinx_wwdt.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /* Refresh Register Masks */
-- 
2.32.0



Re: [PATCH 00/11] Reduce usage of timestamp macros

2021-08-17 Thread Pali Rohár
On Monday 02 August 2021 15:18:27 Pali Rohár wrote:
> Including timestamp.h (either directly or transitionally) cause build
> system to recompile binaries at every 'make' run. This has disadvantage
> in U-Boot development as for every small change 'make' recompiles lot of
> other irrelevant files which were not touched / changed.
> 
> This patch series eliminate transitional / indirect usage of
> timestamp.h by removing unneeded inclusion of header files, moving
> timestamp values from macros to global variables, etc...
> 
> After these patches, U-Boot tools are not recompiled by every 'make' run,
> which decrease time for incremental U-Boot recompilation.
> 
> Please test these patches, specially m68k and powerpc parts as I do not
> have any of these boards.
> 
> Patch series depend on this patch (now marked as accepted):
> http://patchwork.ozlabs.org/project/uboot/patch/20210710111001.32325-1-p...@kernel.org/

Hello! Is there anything else needed for this patch series?

> Pali Rohár (11):
>   Remove #include  from files which do not need it
>   Remove #include  from files which do not need it
>   efi_loader: Use directly version_string variable
>   version: Move version_string[] from version.h to version_string.h
>   m68k: mcf: Remove overloading version_string
>   version: Put version_string[] variable into section
> .text_version_string
>   powerpc: mpc: Put U-Boot version string at correct place by linker
> script
>   version: Do not make version_string[] variable as a weak
>   x86: quark: MRC: Remove U_BOOT_DATE and U_BOOT_TIME from debug log
>   version: Remove global macro U_BOOT_VERSION_STRING from version.h
>   Remove including timestamp.h in version.h
> 
>  arch/arm/mach-rockchip/px30-board-tpl.c   |  1 -
>  arch/arm/mach-rockchip/tpl.c  |  4 
>  arch/m68k/cpu/mcf5227x/start.S|  6 --
>  arch/m68k/cpu/mcf523x/start.S |  6 --
>  arch/m68k/cpu/mcf52x2/start.S |  6 --
>  arch/m68k/cpu/mcf530x/start.S |  8 ---
>  arch/m68k/cpu/mcf532x/start.S |  6 --
>  arch/m68k/cpu/mcf5445x/start.S|  7 ---
>  arch/nios2/cpu/start.S|  1 -
>  arch/powerpc/cpu/mpc83xx/start.S  | 10 +++--
>  arch/powerpc/cpu/mpc83xx/u-boot.lds   |  3 +++
>  arch/powerpc/cpu/mpc85xx/start.S  | 10 -
>  arch/powerpc/cpu/mpc85xx/u-boot-nand.lds  |  4 
>  arch/powerpc/cpu/mpc85xx/u-boot-spl.lds   |  4 
>  arch/powerpc/cpu/mpc85xx/u-boot.lds   |  4 
>  arch/powerpc/cpu/mpc8xx/start.S   |  9 
>  arch/x86/cpu/quark/mrc.c  |  4 +---
>  arch/x86/lib/acpi_table.c |  1 -
>  board/atmel/sama5d2_ptc_ek/sama5d2_ptc_ek.c   |  1 -
>  board/cssi/MCR3000/u-boot.lds |  2 ++
>  board/ge/b1x5v2/b1x5v2.c  |  2 +-
>  board/ge/bx50v3/bx50v3.c  |  2 +-
>  board/ge/mx53ppd/mx53ppd.c|  2 +-
>  board/l+g/vinco/vinco.c   |  1 -
>  board/renesas/grpeach/lowlevel_init.S |  1 -
>  .../work_92105/work_92105_display.c   |  1 +
>  cmd/version.c |  7 ++-
>  common/main.c |  2 +-
>  common/spl/spl.c  |  4 
>  doc/develop/version.rst   | 21 +++
>  drivers/rtc/emul_rtc.c|  2 +-
>  drivers/usb/gadget/f_rockusb.c|  1 -
>  drivers/video/cfb_console.c   |  3 +--
>  include/configs/bcmstb.h  |  1 -
>  include/version.h |  8 ---
>  include/version_string.h  |  8 +++
>  lib/display_options.c |  2 +-
>  lib/efi_loader/efi_tcg2.c |  7 +++
>  net/cdp.c |  3 ---
>  test/print_ut.c   |  2 +-
>  40 files changed, 75 insertions(+), 102 deletions(-)
>  create mode 100644 include/version_string.h
> 
> -- 
> 2.20.1
> 


[PATCH] lib: add crc16.o if CONFIG_MMC_SPI_CRC_ON for SPL build

2021-08-17 Thread Andreas Schwab
CONFIG_MMC_SPI_CRC_ON needs the crc16 functions, but it was not included
in an SPL build.  For non-SPL builds, crc16.o is already added
unconditionally.  This also removes CONFIG_SPL_YMODEM_SUPPORT from the
sifive board configs, which is only relevant for some ARM boards and was
only set for its side effect of adding crc16.o.
---
 configs/sifive_unleashed_defconfig | 1 -
 configs/sifive_unmatched_defconfig | 1 -
 lib/Makefile   | 1 +
 3 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/configs/sifive_unleashed_defconfig 
b/configs/sifive_unleashed_defconfig
index fd686dfadc..d6448dbf5e 100644
--- a/configs/sifive_unleashed_defconfig
+++ b/configs/sifive_unleashed_defconfig
@@ -22,7 +22,6 @@ CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_DM_RESET=y
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_SPL_YMODEM_SUPPORT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_CLK=y
diff --git a/configs/sifive_unmatched_defconfig 
b/configs/sifive_unmatched_defconfig
index 6c40a35bc2..59c4a383e0 100644
--- a/configs/sifive_unmatched_defconfig
+++ b/configs/sifive_unmatched_defconfig
@@ -20,7 +20,6 @@ CONFIG_DISPLAY_BOARDINFO=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_DM_RESET=y
-CONFIG_SPL_YMODEM_SUPPORT=y
 CONFIG_CMD_EEPROM=y
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_PWM=y
diff --git a/lib/Makefile b/lib/Makefile
index 8ba745faa0..2d29cdad1e 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -88,6 +88,7 @@ endif
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o
 obj-$(CONFIG_$(SPL_TPL_)HASH_SUPPORT) += crc16.o
+obj-$(CONFIG_MMC_SPI_CRC_ON) += crc16.o
 obj-y += net_utils.o
 endif
 obj-$(CONFIG_ADDR_MAP) += addr_map.o
-- 
2.33.0


-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


Re: [RFC] imx8mm-evk: Generate a bootable flash.bin again

2021-08-17 Thread Heiko Schocher
Hello Heiko,

On 17.08.21 11:37, Heiko Thiery wrote:
> Hi,
> 
> Am Di., 17. Aug. 2021 um 05:56 Uhr schrieb Heiko Schocher :
>>
>> Hello Fabio,
>>
>> On 16.08.21 17:21, Fabio Estevam wrote:
>>> After the convesion to binman in commit 8996e6b7c6a1 ("imx8mm_evk: switch
>>> to use binman to pack images"), it is necessary to flash both flash.bin and
>>> u-boot.itb to get a bootable system. Prior to this commit, only flash.bin
>>> was needed.
>>>
>>> Such new requirement breaks existing distro mechanisms to generate the
>>> final image because the extra u-boot.itb is now required.
>>>
>>> Generate a final flash.bin image that can be used again as a single
>>> bootable image to keep the original behavior.
>>>
>>> Suggested-by: Heiko Schocher 
>>> Signed-off-by: Fabio Estevam 
>>> ---
>>>  arch/arm/dts/imx8mm-evk-u-boot.dtsi | 15 +++
>>>  1 file changed, 15 insertions(+)
>>>
>>> diff --git a/arch/arm/dts/imx8mm-evk-u-boot.dtsi 
>>> b/arch/arm/dts/imx8mm-evk-u-boot.dtsi
>>> index f200afac9f..ad3056c7c8 100644
>>> --- a/arch/arm/dts/imx8mm-evk-u-boot.dtsi
>>> +++ b/arch/arm/dts/imx8mm-evk-u-boot.dtsi
>>> @@ -217,4 +217,19 @@
>>>   };
>>>   };
>>>   };
>>> +
>>> + imx-boot {
>>> + filename = "flash.bin";
>>
>> I am unsure here, if it makes sense to overwrite flash.bin with the
>> binary which contains SPL and u-boot.itb. May others want to use
>> them (as I currently use them for signing them)
>>
>> Why not imx-boot as image name as in NXP sources?
>> (Thats why I named it so in my "fast example approach")
> 
> Is it right that in that case a new u-boot makefile target has to be
> set? Currently flash.bin works because it is already set in
> "arch/arm/mach-imx/Makefile"?

No, I think not, that is binman magic ... binman creates the targets
which are defined in your DTS in the binman node, see:

u-boot:/tools/binman/README.rst

bye,
Heiko
-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


Re: [RFC] imx8mm-evk: Generate a bootable flash.bin again

2021-08-17 Thread Heiko Thiery
Hi,

Am Di., 17. Aug. 2021 um 05:56 Uhr schrieb Heiko Schocher :
>
> Hello Fabio,
>
> On 16.08.21 17:21, Fabio Estevam wrote:
> > After the convesion to binman in commit 8996e6b7c6a1 ("imx8mm_evk: switch
> > to use binman to pack images"), it is necessary to flash both flash.bin and
> > u-boot.itb to get a bootable system. Prior to this commit, only flash.bin
> > was needed.
> >
> > Such new requirement breaks existing distro mechanisms to generate the
> > final image because the extra u-boot.itb is now required.
> >
> > Generate a final flash.bin image that can be used again as a single
> > bootable image to keep the original behavior.
> >
> > Suggested-by: Heiko Schocher 
> > Signed-off-by: Fabio Estevam 
> > ---
> >  arch/arm/dts/imx8mm-evk-u-boot.dtsi | 15 +++
> >  1 file changed, 15 insertions(+)
> >
> > diff --git a/arch/arm/dts/imx8mm-evk-u-boot.dtsi 
> > b/arch/arm/dts/imx8mm-evk-u-boot.dtsi
> > index f200afac9f..ad3056c7c8 100644
> > --- a/arch/arm/dts/imx8mm-evk-u-boot.dtsi
> > +++ b/arch/arm/dts/imx8mm-evk-u-boot.dtsi
> > @@ -217,4 +217,19 @@
> >   };
> >   };
> >   };
> > +
> > + imx-boot {
> > + filename = "flash.bin";
>
> I am unsure here, if it makes sense to overwrite flash.bin with the
> binary which contains SPL and u-boot.itb. May others want to use
> them (as I currently use them for signing them)
>
> Why not imx-boot as image name as in NXP sources?
> (Thats why I named it so in my "fast example approach")

Is it right that in that case a new u-boot makefile target has to be
set? Currently flash.bin works because it is already set in
"arch/arm/mach-imx/Makefile"?

-- 
Heiko


Re: [PATCH v4 07/10] watchdog: wdt-uclass.c: handle all DM watchdogs in watchdog_reset()

2021-08-17 Thread Stefan Roese

On 12.08.21 15:48, Tom Rini wrote:

On Thu, Aug 12, 2021 at 08:40:21AM +0200, Wolfgang Denk wrote:

Dear Tom,

In message <20210811124318.GT858@bill-the-cat> you wrote:



This argument fits on all types or effors: they are supposed to
never ever happen - at least in theory; in reality they do, and more
often than we like.

And a proper error message is mandatory for correct error handling.


Error messages are a fine line to walk.  We've got to have been very
badly corrupted to go down this error path.  There's going to be lots of
other error messages popping out.  Saving a bit of .text is good.  It
makes it easier to justify spending a little .text later.


Letting errors slip through unnoticed when there is a trival way to
at least inform the user of the problem is simply unacceptable.

Please do not let U-Boot degrade into such a crappy piece of code.

There are tons of other places where we don't even mention code
size, so if you want to save on that, there are many bette4r places
to save than error handling.


Alright, lets take a look at what kind of area of the code we're talking
about.  uclass_get is a pretty fundamental thing.  If that fails, your
system is on fire.  Things are massively corrupt.  Lets look at other
existing callers to see what happens.  Most callers check the return
code, like you need to, and pass it up the chain to deal with.  We have
a few board specific ones such as
board/Marvell/octeontx2/board.c::board_quiesce_devices() that is also
conceptually like the x530 case in the next part of the series.  That
does print on failure.  The rest of the ones that print an error message
are about commands and it's somewhat helpful there.

So yes, return codes need to be checked and passed.  But no, not every
single error path needs to print to the user along every part of an
error path either.


And here I agree, catch an error code, pass the error code back to the
caller.  That's far more important than making sure that every error
code we catch logs a message by default every time.


It does not matter where the error is reported - in the called
function, or in some caller firther up the call tree.  But it _must_
be reportet at least once.

So if we don't issue an error message here, we need to check and fix
the callers, too.


That would be the next patch in the series where the BSP author isn't
currently checking the return value, and this series doesn't change
that.  Perhaps it should, and CC the maintainer.  But I think has been
said a few times over the course of this series, what exactly is one
going to do about the failure?  Getting specific for a moment, if you're
in the case of "shutdown the watchdog" and the watchdog doesn't shutdown
like you want it to, do you hang and hope the watchdog is alive to kick
things still?  hang and lock the system?  Figure the system is on fire
anyhow but add another message to the failure spew?

Again, I think the change that's needed to this patch is to make it
return the error code to the caller.  Let the caller decide.  And make
sure to CC the board maintainer on the next go-round so they can chime
in about that.


Getting back to this to hopefully get this decided:

It seems that we (most of us?) agree on this change, that wdt_stop_all()
shall be changed to return an error code and the caller can decide what
to do with it?

If yes, then Rasmus, could you please re-spin this patchset accordingly
and send v6?

Thanks,
Stefan


[PATCH] mtd: nand: mxs_nand_spl: Add nand_spl_adjust_offset

2021-08-17 Thread Ye Li
Since the mxs_nand_spl has implemented adjust read offset in
nand_spl_load_image, so we don't need to check the bad block in
nand_spl_adjust_offset. Directly return the offset to continue
read by nand_spl_load_image.

Signed-off-by: Ye Li 
---
 drivers/mtd/nand/raw/mxs_nand_spl.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c 
b/drivers/mtd/nand/raw/mxs_nand_spl.c
index 17f46ae..022c819 100644
--- a/drivers/mtd/nand/raw/mxs_nand_spl.c
+++ b/drivers/mtd/nand/raw/mxs_nand_spl.c
@@ -296,3 +296,8 @@ void nand_deselect(void)
 {
 }
 
+u32 nand_spl_adjust_offset(u32 sector, u32 offs)
+{
+   /* Handle the offset adjust in nand_spl_load_image,*/
+   return offs;
+}
-- 
2.7.4



[PATCH 2/2] mmc: fix device_remove when HS400_ES is enabled

2021-08-17 Thread Ye Li
HS400_ES is missed when down grade to HS mode during
device_remove the mmc device

Signed-off-by: Ye Li 
---
 drivers/mmc/mmc.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index a1fd533..3cb6fda 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2092,14 +2092,16 @@ static int mmc_select_mode_and_width(struct mmc *mmc, 
uint card_caps)
}
 
 #if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) || \
-CONFIG_IS_ENABLED(MMC_HS400_SUPPORT)
+CONFIG_IS_ENABLED(MMC_HS400_SUPPORT) || \
+CONFIG_IS_ENABLED(MMC_HS400_ES_SUPPORT)
/*
 * In case the eMMC is in HS200/HS400 mode, downgrade to HS mode
 * before doing anything else, since a transition from either of
 * the HS200/HS400 mode directly to legacy mode is not supported.
 */
if (mmc->selected_mode == MMC_HS_200 ||
-   mmc->selected_mode == MMC_HS_400)
+   mmc->selected_mode == MMC_HS_400 ||
+   mmc->selected_mode == MMC_HS_400_ES)
mmc_set_card_speed(mmc, MMC_HS, true);
else
 #endif
@@ -2952,7 +2954,7 @@ int mmc_deinit(struct mmc *mmc)
return sd_select_mode_and_width(mmc, caps_filtered);
} else {
caps_filtered = mmc->card_caps &
-   ~(MMC_CAP(MMC_HS_200) | MMC_CAP(MMC_HS_400));
+   ~(MMC_CAP(MMC_HS_200) | MMC_CAP(MMC_HS_400) | 
MMC_CAP(MMC_HS_400_ES));
 
return mmc_select_mode_and_width(mmc, caps_filtered);
}
-- 
2.7.4



[PATCH 1/2] mmc: fix switch issue with send_status disabled

2021-08-17 Thread Ye Li
When send_status is false or wait_dat0 is not supported, the switch
function should not send CMD13 but directly return.

Signed-off-by: Ye Li 
---
 drivers/mmc/mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 8078a89..a1fd533 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -823,7 +823,7 @@ static int __mmc_switch(struct mmc *mmc, u8 set, u8 index, 
u8 value,
 * capable of polling by using mmc_wait_dat0, then rely on waiting the
 * stated timeout to be sufficient.
 */
-   if (ret == -ENOSYS && !send_status) {
+   if (ret == -ENOSYS || !send_status) {
mdelay(timeout_ms);
return 0;
}
-- 
2.7.4



[PATCH] arm: imx8m: Fix pad DSE issue for i.MX8MM/MN/MP

2021-08-17 Thread Ye Li
According to 8MM/MN/MP reference manual, their pad registers only have
4 valid DSE values. And DSE2 and DSE4 are different with current
definitions in iomux-v3.h. Fix the issue to align with manual.

Signed-off-by: Ye Li 
Acked-by: Peng Fan 
---
 arch/arm/include/asm/mach-imx/iomux-v3.h | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/arch/arm/include/asm/mach-imx/iomux-v3.h 
b/arch/arm/include/asm/mach-imx/iomux-v3.h
index 1de7093..9330a32 100644
--- a/arch/arm/include/asm/mach-imx/iomux-v3.h
+++ b/arch/arm/include/asm/mach-imx/iomux-v3.h
@@ -87,15 +87,6 @@ typedef u64 iomux_v3_cfg_t;
 #define MUX_MODE_LPSR   ((iomux_v3_cfg_t)IOMUX_CONFIG_LPSR << \
MUX_MODE_SHIFT)
 #ifdef CONFIG_IMX8M
-#define PAD_CTL_DSE0   (0x0 << 0)
-#define PAD_CTL_DSE1   (0x1 << 0)
-#define PAD_CTL_DSE2   (0x2 << 0)
-#define PAD_CTL_DSE3   (0x3 << 0)
-#define PAD_CTL_DSE4   (0x4 << 0)
-#define PAD_CTL_DSE5   (0x5 << 0)
-#define PAD_CTL_DSE6   (0x6 << 0)
-#define PAD_CTL_DSE7   (0x7 << 0)
-
 #define PAD_CTL_FSEL0  (0x0 << 3)
 #define PAD_CTL_FSEL1  (0x1 << 3)
 #define PAD_CTL_FSEL2  (0x2 << 3)
@@ -105,8 +96,20 @@ typedef u64 iomux_v3_cfg_t;
 #define PAD_CTL_PUE(0x1 << 6)
 #define PAD_CTL_HYS(0x1 << 7)
 #if defined(CONFIG_IMX8MM) || defined(CONFIG_IMX8MN) || defined(CONFIG_IMX8MP)
+#define PAD_CTL_DSE1   (0x0 << 1)
+#define PAD_CTL_DSE2   (0x2 << 1)
+#define PAD_CTL_DSE4   (0x1 << 1)
+#define PAD_CTL_DSE6   (0x3 << 1)
 #define PAD_CTL_PE (0x1 << 8)
 #else
+#define PAD_CTL_DSE0   (0x0 << 0)
+#define PAD_CTL_DSE1   (0x1 << 0)
+#define PAD_CTL_DSE2   (0x2 << 0)
+#define PAD_CTL_DSE3   (0x3 << 0)
+#define PAD_CTL_DSE4   (0x4 << 0)
+#define PAD_CTL_DSE5   (0x5 << 0)
+#define PAD_CTL_DSE6   (0x6 << 0)
+#define PAD_CTL_DSE7   (0x7 << 0)
 #define PAD_CTL_LVTTL  (0x1 << 8)
 #endif
 
-- 
2.7.4



[PATCH] mmc: fsl_esdhc_imx: Fix clock disable issue

2021-08-17 Thread Ye Li
The SD clock disable is wrapped by MMC_SUPPORTS_TUNING. So it
only works when UHS is enabled. However, in SD initialization the
power cycle does not depends on UHS. But the power cycle needs
disable the SD clock before power down.
So this causes a problem when UHS is not enabled. Some cards can't
become ready (ACMD14 timeout) due to the clock is enabled during
power cycle.

Signed-off-by: Ye Li 
Reviewed-by: Haibo Chen 
---
 drivers/mmc/fsl_esdhc_imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index aabf395..7b67972 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -971,7 +971,6 @@ static int esdhc_set_ios_common(struct fsl_esdhc_priv 
*priv, struct mmc *mmc)
if (priv->clock != clock)
set_sysctl(priv, mmc, clock);
 
-#ifdef MMC_SUPPORTS_TUNING
if (mmc->clk_disable) {
 #ifdef CONFIG_FSL_USDHC
esdhc_clrbits32(>vendorspec, VENDORSPEC_CKEN);
@@ -987,6 +986,7 @@ static int esdhc_set_ios_common(struct fsl_esdhc_priv 
*priv, struct mmc *mmc)
 #endif
}
 
+#ifdef MMC_SUPPORTS_TUNING
/*
 * For HS400/HS400ES mode, make sure set the strobe dll in the
 * target clock rate. So call esdhc_set_strobe_dll() after the
-- 
2.7.4



[PATCH v3 3/4] board: sifive: use ccache driver instead of helper function

2021-08-17 Thread Zong Li
Invokes the common cache_init function to initialize ccache.

Signed-off-by: Zong Li 
---
 arch/riscv/cpu/fu540/Kconfig  |  2 +
 arch/riscv/cpu/fu540/Makefile |  1 -
 arch/riscv/cpu/fu540/cache.c  | 55 ---
 arch/riscv/cpu/fu740/Kconfig  |  2 +
 arch/riscv/cpu/fu740/Makefile |  1 -
 arch/riscv/cpu/fu740/cache.c  | 55 ---
 arch/riscv/include/asm/arch-fu540/cache.h | 14 --
 arch/riscv/include/asm/arch-fu740/cache.h | 14 --
 board/sifive/unleashed/unleashed.c| 12 +
 board/sifive/unmatched/unmatched.c| 11 +
 10 files changed, 8 insertions(+), 159 deletions(-)
 delete mode 100644 arch/riscv/cpu/fu540/cache.c
 delete mode 100644 arch/riscv/cpu/fu740/cache.c
 delete mode 100644 arch/riscv/include/asm/arch-fu540/cache.h
 delete mode 100644 arch/riscv/include/asm/arch-fu740/cache.h

diff --git a/arch/riscv/cpu/fu540/Kconfig b/arch/riscv/cpu/fu540/Kconfig
index 05463b2625..1604b412b4 100644
--- a/arch/riscv/cpu/fu540/Kconfig
+++ b/arch/riscv/cpu/fu540/Kconfig
@@ -19,6 +19,8 @@ config SIFIVE_FU540
imply SMP
imply CLK_SIFIVE
imply CLK_SIFIVE_PRCI
+   imply SIFIVE_CACHE
+   imply SIFIVE_CCACHE
imply SIFIVE_SERIAL
imply MACB
imply MII
diff --git a/arch/riscv/cpu/fu540/Makefile b/arch/riscv/cpu/fu540/Makefile
index 088205ef57..043fb961a5 100644
--- a/arch/riscv/cpu/fu540/Makefile
+++ b/arch/riscv/cpu/fu540/Makefile
@@ -8,5 +8,4 @@ obj-y += spl.o
 else
 obj-y += dram.o
 obj-y += cpu.o
-obj-y += cache.o
 endif
diff --git a/arch/riscv/cpu/fu540/cache.c b/arch/riscv/cpu/fu540/cache.c
deleted file mode 100644
index 0fc4ef6c00..00
--- a/arch/riscv/cpu/fu540/cache.c
+++ /dev/null
@@ -1,55 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2020 SiFive, Inc
- *
- * Authors:
- *   Pragnesh Patel 
- */
-
-#include 
-#include 
-#include 
-#include 
-
-/* Register offsets */
-#define L2_CACHE_CONFIG0x000
-#define L2_CACHE_ENABLE0x008
-
-#define MASK_NUM_WAYS  GENMASK(15, 8)
-#define NUM_WAYS_SHIFT 8
-
-DECLARE_GLOBAL_DATA_PTR;
-
-int cache_enable_ways(void)
-{
-   const void *blob = gd->fdt_blob;
-   int node;
-   fdt_addr_t base;
-   u32 config;
-   u32 ways;
-
-   volatile u32 *enable;
-
-   node = fdt_node_offset_by_compatible(blob, -1,
-"sifive,fu540-c000-ccache");
-
-   if (node < 0)
-   return node;
-
-   base = fdtdec_get_addr_size_auto_parent(blob, 0, node, "reg", 0,
-   NULL, false);
-   if (base == FDT_ADDR_T_NONE)
-   return FDT_ADDR_T_NONE;
-
-   config = readl((volatile u32 *)base + L2_CACHE_CONFIG);
-   ways = (config & MASK_NUM_WAYS) >> NUM_WAYS_SHIFT;
-
-   enable = (volatile u32 *)(base + L2_CACHE_ENABLE);
-
-   /* memory barrier */
-   mb();
-   (*enable) = ways - 1;
-   /* memory barrier */
-   mb();
-   return 0;
-}
diff --git a/arch/riscv/cpu/fu740/Kconfig b/arch/riscv/cpu/fu740/Kconfig
index 408195f149..049a0a0584 100644
--- a/arch/riscv/cpu/fu740/Kconfig
+++ b/arch/riscv/cpu/fu740/Kconfig
@@ -19,6 +19,8 @@ config SIFIVE_FU740
imply SMP
imply CLK_SIFIVE
imply CLK_SIFIVE_PRCI
+   imply SIFIVE_CACHE
+   imply SIFIVE_CCACHE
imply SIFIVE_SERIAL
imply MACB
imply MII
diff --git a/arch/riscv/cpu/fu740/Makefile b/arch/riscv/cpu/fu740/Makefile
index 5ef8ac18a7..1d1ad98ba7 100644
--- a/arch/riscv/cpu/fu740/Makefile
+++ b/arch/riscv/cpu/fu740/Makefile
@@ -8,5 +8,4 @@ obj-y += spl.o
 else
 obj-y += dram.o
 obj-y += cpu.o
-obj-y += cache.o
 endif
diff --git a/arch/riscv/cpu/fu740/cache.c b/arch/riscv/cpu/fu740/cache.c
deleted file mode 100644
index 680955c9e3..00
--- a/arch/riscv/cpu/fu740/cache.c
+++ /dev/null
@@ -1,55 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2020-2021 SiFive, Inc
- *
- * Authors:
- *   Pragnesh Patel 
- */
-
-#include 
-#include 
-#include 
-#include 
-
-/* Register offsets */
-#define L2_CACHE_CONFIG0x000
-#define L2_CACHE_ENABLE0x008
-
-#define MASK_NUM_WAYS  GENMASK(15, 8)
-#define NUM_WAYS_SHIFT 8
-
-DECLARE_GLOBAL_DATA_PTR;
-
-int cache_enable_ways(void)
-{
-   const void *blob = gd->fdt_blob;
-   int node;
-   fdt_addr_t base;
-   u32 config;
-   u32 ways;
-
-   volatile u32 *enable;
-
-   node = fdt_node_offset_by_compatible(blob, -1,
-"sifive,fu740-c000-ccache");
-
-   if (node < 0)
-   return node;
-
-   base = fdtdec_get_addr_size_auto_parent(blob, 0, node, "reg", 0,
-   NULL, false);
-   if (base == FDT_ADDR_T_NONE)
-   return FDT_ADDR_T_NONE;
-
-   config = readl((volatile u32 *)base + L2_CACHE_CONFIG);
-   ways 

[PATCH v3 4/4] riscv: lib: modify the indent

2021-08-17 Thread Zong Li
We usually use a space in function declaration, rather than a tab.

Signed-off-by: Zong Li 
Reviewed-by: Sean Anderson 
---
 arch/riscv/include/asm/cache.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/include/asm/cache.h b/arch/riscv/include/asm/cache.h
index 6ebb2b4329..b700ff5021 100644
--- a/arch/riscv/include/asm/cache.h
+++ b/arch/riscv/include/asm/cache.h
@@ -8,7 +8,7 @@
 #define _ASM_RISCV_CACHE_H
 
 /* cache */
-void   cache_flush(void);
+void cache_flush(void);
 int cache_init(void);
 
 /*
-- 
2.32.0



[PATCH v3 2/4] riscv: lib: introduce a cache_init interface

2021-08-17 Thread Zong Li
Add an interface for cache initialization. Each platform can overwrite
this weak function by their own implementation, such as sifive_cache in
this patch.

In sifive_cache, it invokes the generic cache_enable interface of cache
uclass to execute the relative implementation in SiFive ccache driver.

Signed-off-by: Zong Li 
---
 arch/riscv/Kconfig |  5 +
 arch/riscv/include/asm/cache.h |  1 +
 arch/riscv/lib/Makefile|  1 +
 arch/riscv/lib/cache.c |  5 +
 arch/riscv/lib/sifive_cache.c  | 27 +++
 5 files changed, 39 insertions(+)
 create mode 100644 arch/riscv/lib/sifive_cache.c

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 4b0c3dffa6..ec651fe0a4 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -179,6 +179,11 @@ config SPL_SIFIVE_CLINT
  The SiFive CLINT block holds memory-mapped control and status 
registers
  associated with software and timer interrupts.
 
+config SIFIVE_CACHE
+   bool
+   help
+ This enables the operations to configure SiFive cache
+
 config ANDES_PLIC
bool
depends on RISCV_MMODE || SPL_RISCV_MMODE
diff --git a/arch/riscv/include/asm/cache.h b/arch/riscv/include/asm/cache.h
index ec8fe201d3..6ebb2b4329 100644
--- a/arch/riscv/include/asm/cache.h
+++ b/arch/riscv/include/asm/cache.h
@@ -9,6 +9,7 @@
 
 /* cache */
 void   cache_flush(void);
+int cache_init(void);
 
 /*
  * The current upper bound for RISCV L1 data cache line sizes is 32 bytes.
diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile
index c4cc41434b..06020fcc2a 100644
--- a/arch/riscv/lib/Makefile
+++ b/arch/riscv/lib/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_BOOTI) += bootm.o image.o
 obj-$(CONFIG_CMD_GO) += boot.o
 obj-y  += cache.o
+obj-$(CONFIG_SIFIVE_CACHE) += sifive_cache.o
 ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y)
 obj-$(CONFIG_$(SPL_)SIFIVE_CLINT) += sifive_clint.o
 obj-$(CONFIG_ANDES_PLIC) += andes_plic.o
diff --git a/arch/riscv/lib/cache.c b/arch/riscv/lib/cache.c
index b1d42bcc2b..2cd66504c6 100644
--- a/arch/riscv/lib/cache.c
+++ b/arch/riscv/lib/cache.c
@@ -70,3 +70,8 @@ __weak int dcache_status(void)
 {
return 0;
 }
+
+__weak int cache_init(void)
+{
+   return 0;
+}
diff --git a/arch/riscv/lib/sifive_cache.c b/arch/riscv/lib/sifive_cache.c
new file mode 100644
index 00..94e84e024e
--- /dev/null
+++ b/arch/riscv/lib/sifive_cache.c
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 SiFive, Inc
+ */
+
+#include 
+#include 
+#include 
+
+int cache_init(void)
+{
+   struct udevice *dev;
+   int ret;
+
+   /* Enable ways of ccache */
+   ret = uclass_get_device_by_driver(UCLASS_CACHE,
+ DM_DRIVER_GET(sifive_ccache),
+ );
+   if (ret)
+   return log_msg_ret("Cannot enable cache ways", ret);
+
+   ret = cache_enable(dev);
+   if (ret)
+   return log_msg_ret("ccache enable failed", ret);
+
+   return 0;
+}
-- 
2.32.0



[PATCH v3 1/4] cache: add sifive composable cache driver

2021-08-17 Thread Zong Li
This driver is currently responsible for enabling all ccache ways.
Composable cache could be configure as RAM or cache, we will use it as
RAM at the beginning to put the u-boot SPL there. In u-boot proper
phrase, we will use the composable cache as cache, and try to enable the
cache ways.

Signed-off-by: Zong Li 
Reviewed-by: Sean Anderson 
---
 drivers/cache/Kconfig   |  7 +++
 drivers/cache/Makefile  |  1 +
 drivers/cache/cache-sifive-ccache.c | 75 +
 3 files changed, 83 insertions(+)
 create mode 100644 drivers/cache/cache-sifive-ccache.c

diff --git a/drivers/cache/Kconfig b/drivers/cache/Kconfig
index 1e452ad6d9..40f41a817c 100644
--- a/drivers/cache/Kconfig
+++ b/drivers/cache/Kconfig
@@ -39,4 +39,11 @@ config NCORE_CACHE
  controller. The driver initializes cache directories and coherent
  agent interfaces.
 
+config SIFIVE_CCACHE
+   bool "SiFive composable cache"
+   select CACHE
+   help
+ This driver is for SiFive Composable L2/L3 cache. It enables cache
+ ways of composable cache.
+
 endmenu
diff --git a/drivers/cache/Makefile b/drivers/cache/Makefile
index fed50be3f9..ad765774e3 100644
--- a/drivers/cache/Makefile
+++ b/drivers/cache/Makefile
@@ -4,3 +4,4 @@ obj-$(CONFIG_SANDBOX) += sandbox_cache.o
 obj-$(CONFIG_L2X0_CACHE) += cache-l2x0.o
 obj-$(CONFIG_NCORE_CACHE) += cache-ncore.o
 obj-$(CONFIG_V5L2_CACHE) += cache-v5l2.o
+obj-$(CONFIG_SIFIVE_CCACHE) += cache-sifive-ccache.o
diff --git a/drivers/cache/cache-sifive-ccache.c 
b/drivers/cache/cache-sifive-ccache.c
new file mode 100644
index 00..76c0ab26ae
--- /dev/null
+++ b/drivers/cache/cache-sifive-ccache.c
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2021 SiFive
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SIFIVE_CCACHE_CONFIG   0x000
+#define SIFIVE_CCACHE_CONFIG_WAYS  GENMASK(15, 8)
+
+#define SIFIVE_CCACHE_WAY_ENABLE   0x008
+
+struct sifive_ccache {
+   void __iomem *base;
+};
+
+static int sifive_ccache_enable(struct udevice *dev)
+{
+   struct sifive_ccache *priv = dev_get_priv(dev);
+   u32 config;
+   u32 ways;
+
+   /* Enable all ways of composable cache */
+   config = readl(priv->base + SIFIVE_CCACHE_CONFIG);
+   ways = FIELD_GET(SIFIVE_CCACHE_CONFIG_WAYS, config);
+
+   writel(ways - 1, priv->base + SIFIVE_CCACHE_WAY_ENABLE);
+
+   return 0;
+}
+
+static int sifive_ccache_get_info(struct udevice *dev, struct cache_info *info)
+{
+   struct sifive_ccache *priv = dev_get_priv(dev);
+
+   info->base = (phys_addr_t)priv->base;
+
+   return 0;
+}
+
+static const struct cache_ops sifive_ccache_ops = {
+   .enable = sifive_ccache_enable,
+   .get_info = sifive_ccache_get_info,
+};
+
+static int sifive_ccache_probe(struct udevice *dev)
+{
+   struct sifive_ccache *priv = dev_get_priv(dev);
+
+   priv->base = dev_read_addr_ptr(dev);
+   if (!priv->base)
+   return -EINVAL;
+
+   return 0;
+}
+
+static const struct udevice_id sifive_ccache_ids[] = {
+   { .compatible = "sifive,fu540-c000-ccache" },
+   { .compatible = "sifive,fu740-c000-ccache" },
+   {}
+};
+
+U_BOOT_DRIVER(sifive_ccache) = {
+   .name = "sifive_ccache",
+   .id = UCLASS_CACHE,
+   .of_match = sifive_ccache_ids,
+   .probe = sifive_ccache_probe,
+   .priv_auto = sizeof(struct sifive_ccache),
+   .ops = _ccache_ops,
+};
-- 
2.32.0



[PATCH v3 0/4] Support SiFive Composable cache driver

2021-08-17 Thread Zong Li
This patch set contains the SiFive composable cache support, and
indroduce an interface to do cache initialization, each platform can
overwrite it by their own implementation.

Changed in v3:
 - Combine some patches
 - Drop the subdirectories of vendor in lib/
 - Rebase codebase

Changed in v2:
 - Refine the ccache driver by Sean's suggestions
 - Introduce a common interface for cache initialization

Zong Li (4):
  cache: add sifive composable cache driver
  riscv: lib: introduce a cache_init interface
  board: sifive: use ccache driver instead of helper function
  riscv: lib: modify the indent

 arch/riscv/Kconfig|  5 ++
 arch/riscv/cpu/fu540/Kconfig  |  2 +
 arch/riscv/cpu/fu540/Makefile |  1 -
 arch/riscv/cpu/fu540/cache.c  | 55 -
 arch/riscv/cpu/fu740/Kconfig  |  2 +
 arch/riscv/cpu/fu740/Makefile |  1 -
 arch/riscv/cpu/fu740/cache.c  | 55 -
 arch/riscv/include/asm/arch-fu540/cache.h | 14 -
 arch/riscv/include/asm/arch-fu740/cache.h | 14 -
 arch/riscv/include/asm/cache.h|  3 +-
 arch/riscv/lib/Makefile   |  1 +
 arch/riscv/lib/cache.c|  5 ++
 arch/riscv/lib/sifive_cache.c | 27 
 board/sifive/unleashed/unleashed.c| 12 +---
 board/sifive/unmatched/unmatched.c| 11 +---
 drivers/cache/Kconfig |  7 +++
 drivers/cache/Makefile|  1 +
 drivers/cache/cache-sifive-ccache.c   | 75 +++
 18 files changed, 131 insertions(+), 160 deletions(-)
 delete mode 100644 arch/riscv/cpu/fu540/cache.c
 delete mode 100644 arch/riscv/cpu/fu740/cache.c
 delete mode 100644 arch/riscv/include/asm/arch-fu540/cache.h
 delete mode 100644 arch/riscv/include/asm/arch-fu740/cache.h
 create mode 100644 arch/riscv/lib/sifive_cache.c
 create mode 100644 drivers/cache/cache-sifive-ccache.c

-- 
2.32.0



Re: [PATCH v4 3/3] arm64: Kconfig: Enable usage of optimized memset/memcpy/memmove

2021-08-17 Thread Stefan Roese

On 13.08.21 11:38, Rasmus Villemoes wrote:

On 12/08/2021 16.47, Stefan Roese wrote:

This patch enables the use of the optimized memset(), memmove() &
memcpy() versions recently added on ARM64.

Signed-off-by: Stefan Roese 

  
+config USE_ARCH_MEMMOVE

+   bool "Use an assembly optimized implementation of memmove"
+   default y
+   depends on ARM64
+   help
+ Enable the generation of an optimized version of memmove.
+ Such an implementation may be faster under some conditions
+ but may increase the binary size.


Hm. I don't think you can allow making this separately (de)selectable,
since if the optimized memcpy is selected, the memmove comes
unconditionally for free [and it would be a bit silly to guard the
ENTRY_ALIAS() by a CONFIG check IMO]. So with USE_ARCH_MEMCPY=y,
USE_ARCH_MEMMOVE=n, I think you'd get a "multiple definitions of
memmove" error. So on arm64, I think USE_ARCH_MEMMOVE should simply be
an unchangeable alias for USE_ARCH_MEMCPY (and similarly for the SPL/TPL
variants).

In Kconfig, I think one could spell this

   bool "Use an ..." if !ARM64
   default USE_ARCH_MEMCPY if ARM64
   depends on ARM64


Thanks, I've incorporated this into v5 of this patchset.

Thanks,
Stefan


[PATCH v5 1/3] arm64: arch/arm/lib: Add optimized memset/memcpy/memmove functions

2021-08-17 Thread Stefan Roese
Ported from https://github.com/ARM-software/optimized-routines

These files are included from this repository, including the latest
git commit ID:
string/aarch64/memcpy.S: afd6244a1f8d
string/aarch64/memset.S: e823e3abf5f8
string/asmdefs.h: e823e3abf5f8

Note that memmove is also handled by the memcpy function.

Please note that when adding these optimized functions as default memset
memcpy functions in U-Boot, U-Boot fails to boot on the LX2160ARDB.
After the initial ATF output, no U-Boot output is shown on the serial
console. Some exception is triggered here in the very early boot process
as some of the assembler opcodes need the caches to be enabled.

Because of this, a follow-up patch will add a check to use a simple
non-optimized memset for the "cache disabled" case.

Note:
I also integrated and tested with the Linux versions of these optimized
functions. They are similar to the ones now integrated but these ARM
versions are still a small bit faster.

Signed-off-by: Stefan Roese 

---

(no changes since v3)

Changes in v3:
- Add memmove alias, as this function also handles it optimized

Changes in v2:
- Add file names and locations and git commit ID from imported files
  to the commit message

 arch/arm/lib/Makefile   |   5 +
 arch/arm/lib/asmdefs.h  |  98 +++
 arch/arm/lib/memcpy-arm64.S | 242 
 arch/arm/lib/memset-arm64.S | 116 +
 4 files changed, 461 insertions(+)
 create mode 100644 arch/arm/lib/asmdefs.h
 create mode 100644 arch/arm/lib/memcpy-arm64.S
 create mode 100644 arch/arm/lib/memset-arm64.S

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 7f6633271518..c48e1f622d3c 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -39,8 +39,13 @@ obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o
 obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 endif
+ifdef CONFIG_ARM64
+obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMSET) += memset-arm64.o
+obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMCPY) += memcpy-arm64.o
+else
 obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMSET) += memset.o
 obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMCPY) += memcpy.o
+endif
 obj-$(CONFIG_SEMIHOSTING) += semihosting.o
 
 obj-y  += bdinfo.o
diff --git a/arch/arm/lib/asmdefs.h b/arch/arm/lib/asmdefs.h
new file mode 100644
index ..d307a3a8a25c
--- /dev/null
+++ b/arch/arm/lib/asmdefs.h
@@ -0,0 +1,98 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Macros for asm code.
+ *
+ * Copyright (c) 2019, Arm Limited.
+ */
+
+#ifndef _ASMDEFS_H
+#define _ASMDEFS_H
+
+#if defined(__aarch64__)
+
+/* Branch Target Identitication support.  */
+#define BTI_C  hint34
+#define BTI_J  hint36
+/* Return address signing support (pac-ret).  */
+#define PACIASPhint25; .cfi_window_save
+#define AUTIASPhint29; .cfi_window_save
+
+/* GNU_PROPERTY_AARCH64_* macros from elf.h.  */
+#define FEATURE_1_AND 0xc000
+#define FEATURE_1_BTI 1
+#define FEATURE_1_PAC 2
+
+/* Add a NT_GNU_PROPERTY_TYPE_0 note.  */
+#define GNU_PROPERTY(type, value)  \
+  .section .note.gnu.property, "a";\
+  .p2align 3;  \
+  .word 4; \
+  .word 16;\
+  .word 5; \
+  .asciz "GNU";\
+  .word type;  \
+  .word 4; \
+  .word value; \
+  .word 0; \
+  .text
+
+/* If set then the GNU Property Note section will be added to
+   mark objects to support BTI and PAC-RET.  */
+#ifndef WANT_GNU_PROPERTY
+#define WANT_GNU_PROPERTY 1
+#endif
+
+#if WANT_GNU_PROPERTY
+/* Add property note with supported features to all asm files.  */
+GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_PAC)
+#endif
+
+#define ENTRY_ALIGN(name, alignment)   \
+  .global name;\
+  .type name,%function;\
+  .align alignment;\
+  name:\
+  .cfi_startproc;  \
+  BTI_C;
+
+#else
+
+#define END_FILE
+
+#define ENTRY_ALIGN(name, alignment)   \
+  .global name;\
+  .type name,%function;\
+  .align alignment;\
+  name:\
+  .cfi_startproc;
+
+#endif
+
+#define ENTRY(name)ENTRY_ALIGN(name, 6)
+
+#define ENTRY_ALIAS(name)  \
+  .global name;\
+  .type name,%function;\
+  name:
+
+#define END(name)  \
+  .cfi_endproc;\
+  .size name, .-name;
+
+#define L(l) .L ## l
+
+#ifdef __ILP32__
+  /* Sanitize padding bits of pointer arguments as per aapcs64 */
+#define PTR_ARG(n)  mov w##n, w##n
+#else
+#define PTR_ARG(n)
+#endif
+
+#ifdef __ILP32__
+  /* Sanitize padding bits of size arguments as per aapcs64 */
+#define SIZE_ARG(n)  mov w##n, w##n
+#else
+#define SIZE_ARG(n)
+#endif
+
+#endif
diff --git a/arch/arm/lib/memcpy-arm64.S 

[PATCH v5 3/3] arm64: Kconfig: Enable usage of optimized memset/memcpy/memmove

2021-08-17 Thread Stefan Roese
This patch enables the use of the optimized memset(), memmove() &
memcpy() versions recently added on ARM64.

Signed-off-by: Stefan Roese 

---

Changes in v5:
- memmove is now auto-selected (or deselected) with the memcpy
  Kconfig selection as it's entry is the same as memcpy for ARM64

Changes in v3:
- Add memmove as well

 arch/arm/Kconfig  | 37 +--
 arch/arm/include/asm/string.h |  4 
 2 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 55a9c3acef8d..0cf29c702dde 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -457,7 +457,6 @@ config ARM_CORTEX_CPU_IS_UP
 config USE_ARCH_MEMCPY
bool "Use an assembly optimized implementation of memcpy"
default y
-   depends on !ARM64
help
  Enable the generation of an optimized version of memcpy.
  Such an implementation may be faster under some conditions
@@ -466,7 +465,7 @@ config USE_ARCH_MEMCPY
 config SPL_USE_ARCH_MEMCPY
bool "Use an assembly optimized implementation of memcpy for SPL"
default y if USE_ARCH_MEMCPY
-   depends on !ARM64 && SPL
+   depends on SPL
help
  Enable the generation of an optimized version of memcpy.
  Such an implementation may be faster under some conditions
@@ -475,16 +474,42 @@ config SPL_USE_ARCH_MEMCPY
 config TPL_USE_ARCH_MEMCPY
bool "Use an assembly optimized implementation of memcpy for TPL"
default y if USE_ARCH_MEMCPY
-   depends on !ARM64 && TPL
+   depends on TPL
help
  Enable the generation of an optimized version of memcpy.
  Such an implementation may be faster under some conditions
  but may increase the binary size.
 
+config USE_ARCH_MEMMOVE
+   bool "Use an assembly optimized implementation of memmove" if !ARM64
+   default USE_ARCH_MEMCPY if ARM64
+   depends on ARM64
+   help
+ Enable the generation of an optimized version of memmove.
+ Such an implementation may be faster under some conditions
+ but may increase the binary size.
+
+config SPL_USE_ARCH_MEMMOVE
+   bool "Use an assembly optimized implementation of memmove for SPL" if 
!ARM64
+   default SPL_USE_ARCH_MEMCPY if ARM64
+   depends on SPL && ARM64
+   help
+ Enable the generation of an optimized version of memmove.
+ Such an implementation may be faster under some conditions
+ but may increase the binary size.
+
+config TPL_USE_ARCH_MEMMOVE
+   bool "Use an assembly optimized implementation of memmove for TPL" if 
!ARM64
+   default TPL_USE_ARCH_MEMCPY if ARM64
+   depends on TPL && ARM64
+   help
+ Enable the generation of an optimized version of memmove.
+ Such an implementation may be faster under some conditions
+ but may increase the binary size.
+
 config USE_ARCH_MEMSET
bool "Use an assembly optimized implementation of memset"
default y
-   depends on !ARM64
help
  Enable the generation of an optimized version of memset.
  Such an implementation may be faster under some conditions
@@ -493,7 +518,7 @@ config USE_ARCH_MEMSET
 config SPL_USE_ARCH_MEMSET
bool "Use an assembly optimized implementation of memset for SPL"
default y if USE_ARCH_MEMSET
-   depends on !ARM64 && SPL
+   depends on SPL
help
  Enable the generation of an optimized version of memset.
  Such an implementation may be faster under some conditions
@@ -502,7 +527,7 @@ config SPL_USE_ARCH_MEMSET
 config TPL_USE_ARCH_MEMSET
bool "Use an assembly optimized implementation of memset for TPL"
default y if USE_ARCH_MEMSET
-   depends on !ARM64 && TPL
+   depends on TPL
help
  Enable the generation of an optimized version of memset.
  Such an implementation may be faster under some conditions
diff --git a/arch/arm/include/asm/string.h b/arch/arm/include/asm/string.h
index 11eaa34fab8c..ead3f2c35643 100644
--- a/arch/arm/include/asm/string.h
+++ b/arch/arm/include/asm/string.h
@@ -19,7 +19,11 @@ extern char * strchr(const char * s, int c);
 #endif
 extern void * memcpy(void *, const void *, __kernel_size_t);
 
+#if CONFIG_IS_ENABLED(USE_ARCH_MEMMOVE)
+#define __HAVE_ARCH_MEMMOVE
+#else
 #undef __HAVE_ARCH_MEMMOVE
+#endif
 extern void * memmove(void *, const void *, __kernel_size_t);
 
 #undef __HAVE_ARCH_MEMCHR
-- 
2.33.0



[PATCH v5 0/3] arm64: Add optimized memset/memcpy/memove functions

2021-08-17 Thread Stefan Roese


On an NXP LX2160 based platform it has been noticed, that the currently
implemented memset/memcpy functions for aarch64 are suboptimal.
Especially the memset() for clearing the NXP MC firmware memory is very
expensive (time-wise).

This patchset now adds the optimized functions ported from this
repository:
https://github.com/ARM-software/optimized-routines

As the optimized memset function make use of the dc opcode, which needs
the caches to be enabled, an additional check is added and a simple
memset version is used in this case.

Please note that checkpatch.pl complains about some issue with this
imported file: arch/arm/lib/asmdefs.h
Since it's imported I did explicitly not make any changes here, to make
potential future sync'ing easer.

Here some numbers to see the speed improments:
Current original version:
-
memset() 32 Bytes, 16M times:
time: 0.446 seconds

memset() 16MiB, 256 times:
time: 1.076 seconds

memcpy() 512MiB:
time: 0.224 seconds

New optimized version:
--
memset() 32 Bytes, 16M times:
time: 0.287 seconds

memset() 16MiB, 256 times:
time: 0.292 seconds

memcpy() 512MiB:
time: 0.222 seconds

Summary:
The optimized memcpy is nearly identical to the original one. But the
optimized memset is much faster, for small and big sizes. Small sizes
factor ~1.6 and big sizes factor ~3.7.

Note: These measurements were done on the NXP LX2160ARDB board.

Thanks,
Stefan

Changes in v5:
- memmove is now auto-selected (or deselected) with the memcpy
  Kconfig selection as it's entry is the same as memcpy for ARM64

Changes in v4:
- Use macros instead of register names, following the optimized code
- Add zero size check

Changes in v3:
- Add memmove alias, as this function also handles it optimized
- Add memmove as well

Changes in v2:
- Add file names and locations and git commit ID from imported files
  to the commit message
- New patch

Stefan Roese (3):
  arm64: arch/arm/lib: Add optimized memset/memcpy/memmove functions
  arm64: memset-arm64: Use simple memset when cache is disabled
  arm64: Kconfig: Enable usage of optimized memset/memcpy/memmove

 arch/arm/Kconfig  |  37 +-
 arch/arm/include/asm/string.h |   4 +
 arch/arm/lib/Makefile |   5 +
 arch/arm/lib/asmdefs.h|  98 ++
 arch/arm/lib/memcpy-arm64.S   | 242 ++
 arch/arm/lib/memset-arm64.S   | 148 +
 6 files changed, 528 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/lib/asmdefs.h
 create mode 100644 arch/arm/lib/memcpy-arm64.S
 create mode 100644 arch/arm/lib/memset-arm64.S

-- 
2.33.0



[PATCH v5 2/3] arm64: memset-arm64: Use simple memset when cache is disabled

2021-08-17 Thread Stefan Roese
The optimized memset uses the dc opcode, which causes problems when the
cache is disabled. This patch adds a check if the cache is disabled and
uses a very simple memset implementation in this case. Otherwise the
optimized version is used.

Signed-off-by: Stefan Roese 

---

(no changes since v4)

Changes in v4:
- Use macros instead of register names, following the optimized code
- Add zero size check

Changes in v2:
- New patch

 arch/arm/lib/memset-arm64.S | 32 
 1 file changed, 32 insertions(+)

diff --git a/arch/arm/lib/memset-arm64.S b/arch/arm/lib/memset-arm64.S
index 710f6f582cad..ee9f9a96cfe6 100644
--- a/arch/arm/lib/memset-arm64.S
+++ b/arch/arm/lib/memset-arm64.S
@@ -11,6 +11,7 @@
  *
  */
 
+#include 
 #include "asmdefs.h"
 
 #define dstin  x0
@@ -25,6 +26,37 @@ ENTRY (memset)
PTR_ARG (0)
SIZE_ARG (2)
 
+   /*
+* The optimized memset uses the dc opcode, which causes problems
+* when the cache is disabled. Let's check if the cache is disabled
+* and use a very simple memset implementation in this case. Otherwise
+* jump to the optimized version.
+*/
+   switch_el x6, 3f, 2f, 1f
+3: mrs x6, sctlr_el3
+   b   0f
+2: mrs x6, sctlr_el2
+   b   0f
+1: mrs x6, sctlr_el1
+0:
+   tst x6, #CR_C
+   bne 9f
+
+   /*
+* A very "simple" memset implementation without the use of the
+* dc opcode. Can be run with caches disabled.
+*/
+   mov x3, #0x0
+   cmp count, x3   /* check for zero length */
+   beq 8f
+4: strbvalw, [dstin, x3]
+   add x3, x3, #0x1
+   cmp count, x3
+   bne 4b
+8: ret
+9:
+
+   /* Here the optimized memset version starts */
dup v0.16B, valw
add dstend, dstin, count
 
-- 
2.33.0



Re: [PATCH 1/1] kwbimage: check fopen() return value

2021-08-17 Thread Pali Rohár
On Tuesday 17 August 2021 07:03:20 Heinrich Schuchardt wrote:
> Always check the return value of fopen().
> 
> This resolves Coverity CID 338491:
> Null pointer dereferences (NULL_RETURNS)
> 
> Signed-off-by: Heinrich Schuchardt 

Reviewed-by: Pali Rohár 

> ---
>  tools/kwbimage.c | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/tools/kwbimage.c b/tools/kwbimage.c
> index 00cb338d64..2a10df773b 100644
> --- a/tools/kwbimage.c
> +++ b/tools/kwbimage.c
> @@ -832,6 +832,12 @@ static int kwb_dump_fuse_cmds(struct secure_hdr_v1 
> *sec_hdr)
>   if (!strcmp(e->name, "a38x")) {
>   FILE *out = fopen("kwb_fuses_a38x.txt", "w+");
> 
> + if (!out) {
> + fprintf(stderr, "Couldn't open eFuse settings: '%s': 
> %s\n",
> + "kwb_fuses_a38x.txt", strerror(errno));
> + return -ENOENT;
> + }
> +
>   kwb_dump_fuse_cmds_38x(out, sec_hdr);
>   fclose(out);
>   goto done;
> @@ -1060,6 +1066,11 @@ int export_pub_kak_hash(RSA *kak, struct secure_hdr_v1 
> *secure_hdr)
>   int res;
> 
>   hashf = fopen("pub_kak_hash.txt", "w");
> + if (!hashf) {
> + fprintf(stderr, "Couldn't open hash file: '%s': %s\n",
> + "pub_kak_hash.txt", strerror(errno));
> + return 1;
> + }
> 
>   res = kwb_export_pubkey(kak, _hdr->kak, hashf, "KAK");
> 
> --
> 2.30.2
> 


Re: [PATCH 1/1] kwbimage: check return value of image_get_csk_index

2021-08-17 Thread Pali Rohár
On Tuesday 17 August 2021 07:11:58 Heinrich Schuchardt wrote:
> image_get_csk_index() may return -1 in case of an error. Don't use this
> value as index.
> 
> This resolves Coverity CID 338488
> Memory - illegal accesses  (NEGATIVE_RETURNS)
> 
> Signed-off-by: Heinrich Schuchardt 

Reviewed-by: Pali Rohár 

> ---
>  tools/kwbimage.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/kwbimage.c b/tools/kwbimage.c
> index 2a10df773b..bf7fd135ac 100644
> --- a/tools/kwbimage.c
> +++ b/tools/kwbimage.c
> @@ -1087,7 +1087,7 @@ int kwb_sign_csk_with_kak(struct image_tool_params 
> *params,
>   int csk_idx = image_get_csk_index();
>   struct sig_v1 tmp_sig;
> 
> - if (csk_idx >= 16) {
> + if (csk_idx < 0 || csk_idx > 15) {
>   fprintf(stderr, "Invalid CSK index %d\n", csk_idx);
>   return 1;
>   }
> --
> 2.30.2
> 


Re: [PATCH v2] arm: mvebu: a37xx: Define CONFIG_SYS_REF_CLK and use it instead of get_ref_clk()

2021-08-17 Thread Stefan Roese

On 16.08.21 12:02, Pali Rohár wrote:

Like for all other mvebu platforms with CONFIG_SYS_TCLK macro, define
CONFIG_SYS_REF_CLK macro for a37xx with base reference clock value which is
read from latched reset register.

Replace all usages of get_ref_clk() function by this CONFIG_SYS_REF_CLK
macro and completely remove get_ref_clk() function.

Replace also custom open-coded implementation of determining reference
clock by CONFIG_SYS_REF_CLK in a37xx serial driver.

The only difference is that macro CONFIG_SYS_REF_CLK returns base reference
clock in Hz and old function get_ref_clk() returned it in MHz.

Signed-off-by: Pali Rohár 

---
Changes in v2:
* Do not remove MVEBU_TEST_PIN_LATCH_N and MVEBU_XTAL_MODE_MASK macros


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  arch/arm/mach-mvebu/armada3700/cpu.c   | 24 
  arch/arm/mach-mvebu/include/mach/cpu.h |  7 ---
  arch/arm/mach-mvebu/include/mach/soc.h |  6 ++
  drivers/clk/mvebu/armada-37xx-periph.c |  6 +++---
  drivers/clk/mvebu/armada-37xx-tbg.c|  4 ++--
  drivers/phy/marvell/comphy_a3700.c | 12 ++--
  drivers/serial/serial_mvebu_a3700.c| 11 ---
  drivers/watchdog/armada-37xx-wdt.c |  2 +-
  8 files changed, 22 insertions(+), 50 deletions(-)

diff --git a/arch/arm/mach-mvebu/armada3700/cpu.c 
b/arch/arm/mach-mvebu/armada3700/cpu.c
index 7702028ba19b..bdf8dc377528 100644
--- a/arch/arm/mach-mvebu/armada3700/cpu.c
+++ b/arch/arm/mach-mvebu/armada3700/cpu.c
@@ -23,12 +23,6 @@
  /* Armada 3700 */
  #define MVEBU_GPIO_NB_REG_BASE(MVEBU_REGISTER(0x13800))
  
-#define MVEBU_TEST_PIN_LATCH_N		(MVEBU_GPIO_NB_REG_BASE + 0x8)

-#define MVEBU_XTAL_MODE_MASK   BIT(9)
-#define MVEBU_XTAL_MODE_OFFS   9
-#define MVEBU_XTAL_CLOCK_25MHZ 0x0
-#define MVEBU_XTAL_CLOCK_40MHZ 0x1
-
  #define MVEBU_NB_WARM_RST_REG (MVEBU_GPIO_NB_REG_BASE + 0x40)
  #define MVEBU_NB_WARM_RST_MAGIC_NUM   0x1d1e
  
@@ -370,21 +364,3 @@ void reset_cpu(void)

 */
writel(MVEBU_NB_WARM_RST_MAGIC_NUM, MVEBU_NB_WARM_RST_REG);
  }
-
-/*
- * get_ref_clk
- *
- * return: reference clock in MHz (25 or 40)
- */
-u32 get_ref_clk(void)
-{
-   u32 regval;
-
-   regval = (readl(MVEBU_TEST_PIN_LATCH_N) & MVEBU_XTAL_MODE_MASK) >>
-   MVEBU_XTAL_MODE_OFFS;
-
-   if (regval == MVEBU_XTAL_CLOCK_25MHZ)
-   return 25;
-   else
-   return 40;
-}
diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h 
b/arch/arm/mach-mvebu/include/mach/cpu.h
index 79858858c259..9b8907e0fe55 100644
--- a/arch/arm/mach-mvebu/include/mach/cpu.h
+++ b/arch/arm/mach-mvebu/include/mach/cpu.h
@@ -183,12 +183,5 @@ int a3700_dram_init_banksize(void);
  /* A3700 PCIe regions fixer for device tree */
  int a3700_fdt_fix_pcie_regions(void *blob);
  
-/*

- * get_ref_clk
- *
- * return: reference clock in MHz (25 or 40)
- */
-u32 get_ref_clk(void);
-
  #endif /* __ASSEMBLY__ */
  #endif /* _MVEBU_CPU_H */
diff --git a/arch/arm/mach-mvebu/include/mach/soc.h 
b/arch/arm/mach-mvebu/include/mach/soc.h
index aab61f7c15cf..b03b6de3c6cd 100644
--- a/arch/arm/mach-mvebu/include/mach/soc.h
+++ b/arch/arm/mach-mvebu/include/mach/soc.h
@@ -210,6 +210,12 @@
  #define BOOT_FROM_SPI 0x3
  
  #define CONFIG_SYS_TCLK		25000	/* 250MHz */

+#elif defined(CONFIG_ARMADA_3700)
+/* SAR values for Armada 3700 */
+#define MVEBU_TEST_PIN_LATCH_N MVEBU_REGISTER(0x13808)
+#define MVEBU_XTAL_MODE_MASK   BIT(9)
+#define CONFIG_SYS_REF_CLK ((readl(MVEBU_TEST_PIN_LATCH_N) & 
MVEBU_XTAL_MODE_MASK) ? \
+4000 : 2500)
  #endif
  
  #endif /* _MVEBU_SOC_H */

diff --git a/drivers/clk/mvebu/armada-37xx-periph.c 
b/drivers/clk/mvebu/armada-37xx-periph.c
index 3b767d706009..f5b3f5a78414 100644
--- a/drivers/clk/mvebu/armada-37xx-periph.c
+++ b/drivers/clk/mvebu/armada-37xx-periph.c
@@ -14,7 +14,7 @@
  #include 
  #include 
  #include 
-#include 
+#include 
  #include 
  #include 
  
@@ -501,7 +501,7 @@ int armada_37xx_tbg_clk_dump(struct udevice *);
  
  int soc_clk_dump(void)

  {
-   printf("  xtal at %u00 Hz\n\n", get_ref_clk());
+   printf("  xtal at %u Hz\n\n", CONFIG_SYS_REF_CLK);
  
  	if (clk_dump("tbg@13200", armada_37xx_tbg_clk_dump))

return 1;
@@ -581,7 +581,7 @@ static int armada_37xx_periph_clk_probe(struct udevice *dev)
struct clk clk;
  
  		if (i == XTAL) {

-   priv->parents[i] = get_ref_clk() * 100;
+   priv->parents[i] = CONFIG_SYS_REF_CLK;
continue;
}
  
diff --git a/drivers/clk/mvebu/armada-37xx-tbg.c b/drivers/clk/mvebu/armada-37xx-tbg.c

index 054aff5e6aca..2ec60b15a6af 100644
--- a/drivers/clk/mvebu/armada-37xx-tbg.c
+++ b/drivers/clk/mvebu/armada-37xx-tbg.c
@@ -13,7 +13,7 @@
  #include 
  #include 
  #include 
-#include 
+#include 
  #include 
  
  #define NUM_TBG	4

@@ -122,7 +122,7 @@ static 

Re: [PATCH u-boot-mvebu v2 4/4] arm: mvebu: turris_omnia: disable MCU watchdog in board_late_init()

2021-08-17 Thread Stefan Roese

On 16.08.21 15:19, Marek Behún wrote:

Disable MCU watchdog in board_late_init() instead of board_init(), so
that it is disabled after U-Boot enables SOC watchdog instead of before.
This way there is no window when the board is vulnerable.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  board/CZ.NIC/turris_omnia/turris_omnia.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c 
b/board/CZ.NIC/turris_omnia/turris_omnia.c
index b0391c973d..bac78af04e 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -434,6 +434,11 @@ int board_init(void)
/* address of boot parameters */
gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
  
+	return 0;

+}
+
+int board_late_init(void)
+{
/*
 * If not booting from UART, MCU watchdog was not disabled in SPL,
 * disable it now.
@@ -441,11 +446,6 @@ int board_init(void)
if (get_boot_device() != BOOT_DEVICE_UART)
disable_mcu_watchdog();
  
-	return 0;

-}
-
-int board_late_init(void)
-{
set_regdomain();
handle_reset_button();
pci_init();




Viele Grüße,
Stefan

--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: s...@denx.de


Re: [PATCH u-boot-mvebu v2 3/4] arm: mvebu: turris_omnia: disable MCU watchdog in SPL when booting over UART

2021-08-17 Thread Stefan Roese

On 16.08.21 15:19, Marek Behún wrote:

When booting over UART, sending U-Boot proper may take too much time and
MCU watchdog will reset the board before U-Boot proper is loaded.

Better disable MCU watchdog in SPL when booting over UART.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  board/CZ.NIC/turris_omnia/turris_omnia.c | 17 -
  configs/turris_omnia_defconfig   |  1 +
  2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c 
b/board/CZ.NIC/turris_omnia/turris_omnia.c
index a84a409f43..b0391c973d 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -419,12 +419,27 @@ int board_early_init_f(void)
return 0;
  }
  
+void spl_board_init(void)

+{
+   /*
+* If booting from UART, disable MCU watchdog in SPL, since uploading
+* U-Boot proper can take too much time and trigger it.
+*/
+   if (get_boot_device() == BOOT_DEVICE_UART)
+   disable_mcu_watchdog();
+}
+
  int board_init(void)
  {
/* address of boot parameters */
gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
  
-	disable_mcu_watchdog();

+   /*
+* If not booting from UART, MCU watchdog was not disabled in SPL,
+* disable it now.
+*/
+   if (get_boot_device() != BOOT_DEVICE_UART)
+   disable_mcu_watchdog();
  
  	return 0;

  }
diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index cd443ceb30..67f8bdadaf 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -33,6 +33,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
  # CONFIG_DISPLAY_BOARDINFO is not set
  CONFIG_DISPLAY_BOARDINFO_LATE=y
  CONFIG_MISC_INIT_R=y
+CONFIG_SPL_BOARD_INIT=y
  CONFIG_SPL_I2C=y
  CONFIG_CMD_MEMTEST=y
  CONFIG_SYS_ALT_MEMTEST=y




Viele Grüße,
Stefan

--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: s...@denx.de


Re: [PATCH u-boot-mvebu v2 2/4] arm: mvebu: turris_omnia: don't guard by CONFIG_SPL_BUILD macro

2021-08-17 Thread Stefan Roese

On 16.08.21 15:19, Marek Behún wrote:

We do not need to guard code in board_init() and board_late_init()
functions with the CONFIG_SPL_BUILD macro, since these functions are not
called in SPL.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  board/CZ.NIC/turris_omnia/turris_omnia.c | 8 
  1 file changed, 8 deletions(-)

diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c 
b/board/CZ.NIC/turris_omnia/turris_omnia.c
index a7e5f56eed..a84a409f43 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -129,7 +129,6 @@ static int omnia_mcu_read(u8 cmd, void *buf, int len)
return dm_i2c_read(chip, cmd, buf, len);
  }
  
-#ifndef CONFIG_SPL_BUILD

  static int omnia_mcu_write(u8 cmd, const void *buf, int len)
  {
struct udevice *chip;
@@ -158,7 +157,6 @@ static bool disable_mcu_watchdog(void)
  
  	return true;

  }
-#endif
  
  static bool omnia_detect_sata(void)

  {
@@ -325,7 +323,6 @@ struct mv_ddr_topology_map *mv_ddr_topology_map_get(void)
return _topology_map_1g;
  }
  
-#ifndef CONFIG_SPL_BUILD

  static int set_regdomain(void)
  {
struct omnia_eeprom oep;
@@ -394,7 +391,6 @@ static void handle_reset_button(void)
}
}
  }
-#endif
  
  int board_early_init_f(void)

  {
@@ -428,19 +424,15 @@ int board_init(void)
/* address of boot parameters */
gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
  
-#ifndef CONFIG_SPL_BUILD

disable_mcu_watchdog();
-#endif
  
  	return 0;

  }
  
  int board_late_init(void)

  {
-#ifndef CONFIG_SPL_BUILD
set_regdomain();
handle_reset_button();
-#endif
pci_init();
  
  	return 0;





Viele Grüße,
Stefan

--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: s...@denx.de


Re: [PATCH u-boot-mvebu v2 1/4] arm: mvebu: Move get_boot_device() to cpu.c and make visible

2021-08-17 Thread Stefan Roese

On 16.08.21 15:19, Marek Behún wrote:

Move the function get_boot_device() from spl.c to cpu.c.

Make it visible, so that it may be used from other files.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  arch/arm/mach-mvebu/cpu.c  | 60 
  arch/arm/mach-mvebu/include/mach/cpu.h |  2 +
  arch/arm/mach-mvebu/spl.c  | 77 +++---
  3 files changed, 71 insertions(+), 68 deletions(-)

diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c
index 0b935c46fb..daf8bd66a0 100644
--- a/arch/arm/mach-mvebu/cpu.c
+++ b/arch/arm/mach-mvebu/cpu.c
@@ -14,6 +14,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  
  #define DDR_BASE_CS_OFF(n)	(0x + ((n) << 3))

@@ -80,6 +81,65 @@ int mvebu_soc_family(void)
return MVEBU_SOC_UNKNOWN;
  }
  
+u32 get_boot_device(void)

+{
+   u32 val;
+   u32 boot_device;
+
+   /*
+ * First check, if UART boot-mode is active. This can only
+ * be done, via the bootrom error register. Here the
+ * MSB marks if the UART mode is active.
+ */
+   val = readl(CONFIG_BOOTROM_ERR_REG);
+   boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
+   debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
+   if (boot_device == BOOTROM_ERR_MODE_UART)
+   return BOOT_DEVICE_UART;
+
+#ifdef CONFIG_ARMADA_38X
+   /*
+ * If the bootrom error code contains any other than zeros it's an
+ * error condition and the bootROM has fallen back to UART boot
+ */
+   boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
+   if (boot_device)
+   return BOOT_DEVICE_UART;
+#endif
+
+   /*
+ * Now check the SAR register for the strapped boot-device
+ */
+   val = readl(CONFIG_SAR_REG);/* SAR - Sample At Reset */
+   boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS;
+   debug("SAR_REG=0x%08x boot_device=0x%x\n", val, boot_device);
+   switch (boot_device) {
+#ifdef BOOT_FROM_NAND
+   case BOOT_FROM_NAND:
+   return BOOT_DEVICE_NAND;
+#endif
+#ifdef BOOT_FROM_MMC
+   case BOOT_FROM_MMC:
+   case BOOT_FROM_MMC_ALT:
+   return BOOT_DEVICE_MMC1;
+#endif
+   case BOOT_FROM_UART:
+#ifdef BOOT_FROM_UART_ALT
+   case BOOT_FROM_UART_ALT:
+#endif
+   return BOOT_DEVICE_UART;
+#ifdef BOOT_FROM_SATA
+   case BOOT_FROM_SATA:
+   case BOOT_FROM_SATA_ALT:
+   return BOOT_DEVICE_SATA;
+#endif
+   case BOOT_FROM_SPI:
+   return BOOT_DEVICE_SPI;
+   default:
+   return BOOT_DEVICE_BOOTROM;
+   };
+}
+
  #if defined(CONFIG_DISPLAY_CPUINFO)
  
  #if defined(CONFIG_ARMADA_375)

diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h 
b/arch/arm/mach-mvebu/include/mach/cpu.h
index 79858858c2..a7a62c7e7d 100644
--- a/arch/arm/mach-mvebu/include/mach/cpu.h
+++ b/arch/arm/mach-mvebu/include/mach/cpu.h
@@ -148,6 +148,8 @@ void __noreturn return_to_bootrom(void);
  int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks);
  #endif
  
+u32 get_boot_device(void);

+
  void get_sar_freq(struct sar_freq_modes *sar_freq);
  
  /*

diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index f0cf60bb14..8d6d4902f6 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -171,74 +171,6 @@ int spl_parse_board_header(struct spl_image_info 
*spl_image,
return 0;
  }
  
-static u32 get_boot_device(void)

-{
-   u32 val;
-   u32 boot_device;
-
-   /*
-* First check, if UART boot-mode is active. This can only
-* be done, via the bootrom error register. Here the
-* MSB marks if the UART mode is active.
-*/
-   val = readl(CONFIG_BOOTROM_ERR_REG);
-   boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
-   debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
-   if (boot_device == BOOTROM_ERR_MODE_UART)
-   return BOOT_DEVICE_UART;
-
-#ifdef CONFIG_ARMADA_38X
-   /*
-* If the bootrom error code contains any other than zeros it's an
-* error condition and the bootROM has fallen back to UART boot
-*/
-   boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
-   if (boot_device)
-   return BOOT_DEVICE_UART;
-#endif
-
-   /*
-* Now check the SAR register for the strapped boot-device
-*/
-   val = readl(CONFIG_SAR_REG);/* SAR - Sample At Reset */
-   boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS;
-   debug("SAR_REG=0x%08x boot_device=0x%x\n", val, boot_device);
-   switch (boot_device) {
-#ifdef BOOT_FROM_NAND
-   case BOOT_FROM_NAND:
-   return BOOT_DEVICE_NAND;
-#endif
-#ifdef BOOT_FROM_MMC
-   case BOOT_FROM_MMC:
-   case 

Re: EFI from usb HDD

2021-08-17 Thread Michal Simek



On 8/12/21 11:43 AM, AKASHI Takahiro wrote:
> On Fri, Jul 30, 2021 at 08:22:18AM +0200, Michal Simek wrote:
>>
>>
>> On 7/30/21 7:33 AM, AKASHI Takahiro wrote:
>>> On Fri, Jul 30, 2021 at 06:41:01AM +0200, Michal Simek wrote:


 On 7/30/21 4:35 AM, AKASHI Takahiro wrote:
> On Thu, Jul 29, 2021 at 04:09:32PM +0200, Michal Simek wrote:
>> Hi,
>>
>> On 6/10/21 2:59 PM, AKASHI Takahiro wrote:
>>> On Thu, Jun 10, 2021 at 02:31:46PM +0200, Michal Simek wrote:


 On 6/10/21 12:51 PM, Heinrich Schuchardt wrote:
> On 6/10/21 12:04 PM, Michal Simek wrote:
>> Hi,
>>
>> On 6/10/21 11:47 AM, Heinrich Schuchardt wrote:
>>> On 6/10/21 10:44 AM, Michal Simek wrote:
 Hi,

 I am playing with booting from USB via EFI. And I see very weird
 behavior. I have burnt image with grub to USB flashdisk and I have
 tested it on 3 zynqmp boards. zcu102, zcu104 and SOM Kria board.
 On zcu102 grub is going to boot menu and everything is working 
 fine as
 expected.
 On zcu104 and SOM Kria I am able to get grub not to menu. When I 
 list
 partitions in grub I see that only SDs are listed:
 grub> ls
 (hd0) (hd0,msdos1) (hd1) (hd1,msdos1)
>>>
>>> Hello Michal,
>>>
>>> thanks for sharing your observations.
>>>
>>> What devices do hd0 and hd1 relate to?
>>>

 On zcu102(working board) I also see usb(gpt) partitions and SD.
 grub> ls
 (hd0) (hd0,gpt2) (hd0,gpt1) (hd1) (hd1,msdos1)

>>>
>>> GPT and MBR partitioning are independent of the device type.
>>>

 On zcu104 I see one more error message
 "PE image measurement failed"
>>>
>>> This is related to CONFIG_EFI_TCG2_PROTOCOL=y. Do you have a TPMv2? 
>>> This
>>> will not stop disk enumeration.
>>>
 But I can't see it on SOM.

 U-Boot image is just the same for all boards. I am using generic
 xilinx_zynqmp_virt_defconfig.

 When I compare DT description for USB between zcu102 and zcu104 
 they
 are
 the same. SOM doesn't have usb enabled by default (but I enabled 
 it)
 but
 grub starts which means that communication with USB is fine.

 It is based on my latest patches available here.
 u-boot/custodians/u-boot-microblaze.git (usb-efi-issue branch)

 Also when I list usb I see all partitions just fine.
 ZynqMP> part list usb 0

 Partition Map for USB device 0  --   Partition Type: EFI

 Part    Start LBA   End LBA Name
   Attributes
   Type GUID
   Partition GUID
     1 0x0800  0x001007fe  "Microsoft basic data"
   attrs:  0x
   type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
   type:   data
   guid:   0e7f8b3d-296b-4720-be9d-c4687d3c4a77
     2 0x00100800  0x001197fe  "Microsoft basic data"
   attrs:  0x
   type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
   type:   data
   guid:   8892eddc-231a-4e6e-a5e1-c310f4482fb7


 Do you have any idea why on one system is working fine to get to 
 menu
 and on others there is an issue to get all partitions even u-boot 
 is
 able to see them and can work with them.

 Thanks,
 Michal

>>>
>>> Where is the GRUB binary? - If it is in EFI/boot/bootaa64.efi, it 
>>> could
>>> be that the USB sub-system is simply not initialized yet when the 
>>> boot
>>> manager is called by distroboot.
>>>
>>> For testing partition detection in the UEFI sub-system it is enough
>>> to run
>>>
>>>  efidebug devices
>>>
>>> Until yesterday we had a problem with partition numbers >= 10, cf.
>>>
>>> efi_loader: partition numbers are hexadecimal
>>> https://source.denx.de/u-boot/u-boot/-/commit/3dca77b1dc1b6dbf9c8b51572fe4b0553cef009f
>>>
>>>
>>>
>>> Block devices are enumerated in efi_disk_register(). Please, try to 
>>> add
>>> debug output there to elucidate the problem.
>>
>> I found where the problem is. First of all zcu102 didn't 

[PATCH] xilinx: zynqmp: Add debug messages for boot mode

2021-08-17 Thread Michal Simek
Add debug messages to see HW boot mode and also alternative boot mode in
logs directly.

Signed-off-by: Michal Simek 
---

 board/xilinx/zynqmp/zynqmp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index 27bb2b056c58..e43177ea4e48 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -518,6 +518,9 @@ static u8 __maybe_unused zynqmp_get_bootmode(void)
if (ret)
return -EINVAL;
 
+   debug("HW boot mode: %x\n", reg & BOOT_MODES_MASK);
+   debug("ALT boot mode: %x\n", reg >> BOOT_MODE_ALT_SHIFT);
+
if (reg >> BOOT_MODE_ALT_SHIFT)
reg >>= BOOT_MODE_ALT_SHIFT;
 
-- 
2.32.0



Re: [PATCH 1/1] kwbimage: check return value of image_get_csk_index

2021-08-17 Thread Stefan Roese

On 17.08.21 07:11, Heinrich Schuchardt wrote:

image_get_csk_index() may return -1 in case of an error. Don't use this
value as index.

This resolves Coverity CID 338488
Memory - illegal accesses  (NEGATIVE_RETURNS)

Signed-off-by: Heinrich Schuchardt 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  tools/kwbimage.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index 2a10df773b..bf7fd135ac 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -1087,7 +1087,7 @@ int kwb_sign_csk_with_kak(struct image_tool_params 
*params,
int csk_idx = image_get_csk_index();
struct sig_v1 tmp_sig;

-   if (csk_idx >= 16) {
+   if (csk_idx < 0 || csk_idx > 15) {
fprintf(stderr, "Invalid CSK index %d\n", csk_idx);
return 1;
}
--
2.30.2




Viele Grüße,
Stefan

--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: s...@denx.de


Re: [PATCH 1/1] kwbimage: check fopen() return value

2021-08-17 Thread Stefan Roese

On 17.08.21 07:03, Heinrich Schuchardt wrote:

Always check the return value of fopen().

This resolves Coverity CID 338491:
Null pointer dereferences (NULL_RETURNS)

Signed-off-by: Heinrich Schuchardt 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  tools/kwbimage.c | 11 +++
  1 file changed, 11 insertions(+)

diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index 00cb338d64..2a10df773b 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -832,6 +832,12 @@ static int kwb_dump_fuse_cmds(struct secure_hdr_v1 
*sec_hdr)
if (!strcmp(e->name, "a38x")) {
FILE *out = fopen("kwb_fuses_a38x.txt", "w+");

+   if (!out) {
+   fprintf(stderr, "Couldn't open eFuse settings: '%s': 
%s\n",
+   "kwb_fuses_a38x.txt", strerror(errno));
+   return -ENOENT;
+   }
+
kwb_dump_fuse_cmds_38x(out, sec_hdr);
fclose(out);
goto done;
@@ -1060,6 +1066,11 @@ int export_pub_kak_hash(RSA *kak, struct secure_hdr_v1 
*secure_hdr)
int res;

hashf = fopen("pub_kak_hash.txt", "w");
+   if (!hashf) {
+   fprintf(stderr, "Couldn't open hash file: '%s': %s\n",
+   "pub_kak_hash.txt", strerror(errno));
+   return 1;
+   }

res = kwb_export_pubkey(kak, _hdr->kak, hashf, "KAK");

--
2.30.2




Viele Grüße,
Stefan

--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: s...@denx.de


[PATCH] arm: dts: imx8mp: Delete default clocks for clock controller node

2021-08-17 Thread Ye Li
Since SPL has initialized clocks for bus and core. We don't need to
set the default clocks for clock controller node.

Signed-off-by: Ye Li 
---
 arch/arm/dts/imx8mp-u-boot.dtsi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/dts/imx8mp-u-boot.dtsi b/arch/arm/dts/imx8mp-u-boot.dtsi
index d61346d..a6ede2e 100644
--- a/arch/arm/dts/imx8mp-u-boot.dtsi
+++ b/arch/arm/dts/imx8mp-u-boot.dtsi
@@ -18,6 +18,9 @@
  {
u-boot,dm-spl;
u-boot,dm-pre-reloc;
+   /delete-property/ assigned-clocks;
+   /delete-property/ assigned-clock-parents;
+   /delete-property/ assigned-clock-rates;
 };
 
 _32k {
-- 
2.7.4



[PATCH v2] imx: spl: fix imx8m secure boot

2021-08-17 Thread Heiko Schocher
cherry-picked from NXP code:
719d665a87c6: ("MLK-20467 imx8m: Fix issue for booting signed image through 
uuu")

which fixes secure boot on imx8m based boards. Problem was
that FIT header and so IVT header too, was loaded to
memallocated address. So the ivt header address coded
in IVT itself does not fit with the real position.

Signed-off-by: Heiko Schocher 


---
replaces Series:
https://lists.denx.de/pipermail/u-boot/2021-August/457308.html

@Tim: could you please test this version on your hardware?

azure build:
https://dev.azure.com/hs0298/hs/_build/results?buildId=72=results

Works on sdcard and QSPI NOR boot on phycore-imx8mp board.


Changes in v2:
- use code from NXP commit 719d665 as Ye Li suggested.

 arch/arm/mach-imx/spl.c | 14 ++
 common/spl/spl_fit.c|  7 ++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index 36033d611c..59c6c3752d 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -334,6 +334,20 @@ void board_spl_fit_post_load(const void *fit)
 }
 #endif
 
+void *board_spl_fit_buffer_addr(ulong fit_size, int sectors, int bl_len)
+{
+   int align_len = ARCH_DMA_MINALIGN - 1;
+
+   /* Some devices like SDP, NOR, NAND, SPI are using bl_len =1, so their 
fit address
+* is different with SD/MMC, this cause mismatch with signed address. 
Thus, adjust
+* the bl_len to align with SD/MMC.
+*/
+   if (bl_len < 512)
+   bl_len = 512;
+
+   return  (void *)((CONFIG_SYS_TEXT_BASE - fit_size - bl_len -
+   align_len) & ~align_len);
+}
 #endif
 
 #if defined(CONFIG_MX6) && defined(CONFIG_SPL_OS_BOOT)
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index f41abca0cc..a4337d3c88 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -538,6 +538,11 @@ static void *spl_get_fit_load_buffer(size_t size)
return buf;
 }
 
+__weak void *board_spl_fit_buffer_addr(ulong fit_size, int sectors, int bl_len)
+{
+   return spl_get_fit_load_buffer(sectors * bl_len);
+}
+
 /*
  * Weak default function to allow customizing SPL fit loading for load-only
  * use cases by allowing to skip the parsing/processing of the FIT contents
@@ -631,7 +636,7 @@ static int spl_simple_fit_read(struct spl_fit_info *ctx,
 * For FIT with external data, data is not loaded in this step.
 */
sectors = get_aligned_image_size(info, size, 0);
-   buf = spl_get_fit_load_buffer(sectors * info->bl_len);
+   buf = board_spl_fit_buffer_addr(size, sectors, info->bl_len);
 
count = info->read(info, sector, sectors, buf);
ctx->fit = buf;
-- 
2.31.1