Re: [PATCH v2 0/2] Initial step for Linux DT sync on Qcom SoCs

2022-08-24 Thread Sumit Garg
On Tue, 16 Aug 2022 at 13:32, Sumit Garg  wrote:
>
> Hi Tom,
>
> On Thu, 4 Aug 2022 at 20:09, Sumit Garg  wrote:
> >
> > Hi,
> >
> > On Wed, 27 Jul 2022 at 13:52, Sumit Garg  wrote:
> > >
> > > This is an initial step towards achieving complete Linux DT sync on Qcom
> > > SoCs/boards. It syncs up DT compatibles for pinctrl and GPIO drivers.
> > >
> > > Changes in v2:
> > > - Separate patch for CONFIG_SDM845 check removal.
> > > - Fix pinctrl DT compatibles for db410c and db820c.
> > >
> >
> > Do we have any further comments on this?
> >
>
> I haven't heard any comments on this patch-set. Would it be fine with
> you to merge it?
>

Gentle ping.

-Sumit

>
> >
> > > Sumit Garg (2):
> > >   pinctrl: sdm845: Remove redundant CONFIG_SDM845 check
> > >   arm: dts: qcom: Sync pinctrl DT nodes with Linux bindings
> > >
> > >  arch/arm/dts/dragonboard410c-uboot.dtsi   |  2 +-
> > >  arch/arm/dts/dragonboard410c.dts  | 17 +++-
> > >  arch/arm/dts/dragonboard820c-uboot.dtsi   |  2 +-
> > >  arch/arm/dts/dragonboard820c.dts  |  4 +-
> > >  arch/arm/dts/qcom-ipq4019.dtsi| 18 +++--
> > >  arch/arm/dts/qcs404-evb.dts   |  2 +-
> > >  arch/arm/dts/sdm845.dtsi  |  2 +-
> > >  arch/arm/mach-ipq40xx/pinctrl-snapdragon.c| 31 ++-
> > >  arch/arm/mach-snapdragon/Makefile |  2 +-
> > >  arch/arm/mach-snapdragon/pinctrl-snapdragon.c | 39 ---
> > >  drivers/gpio/msm_gpio.c   | 10 +
> > >  11 files changed, 83 insertions(+), 46 deletions(-)
> > >
> > > --
> > > 2.25.1
> > >


[PATCH] mtd: nand: pxa3xx: simplify ECC hardware parameters

2022-08-24 Thread Chris Packham
Replace the if/else chain in pxa_ecc_init() with a lookup table. This
makes the code more concise and hopefully easier to follow. Remove the
unused ecc_layout tables and replace it with a single dummy one (the
pxa3xx driver has never used this but the mtd subsystem expects it to be
provided).

Tested on an Allied Telesis x530 switch with Micron MT29F2G08ABAEAWP
NAND Flash.

Signed-off-by: Chris Packham 
---
This code was taken from the Marvell SDK for the AC5/AC5X integrated
switch/CPU. There are other changes to support the SoC which I will
likely attempt to upstream soon but I think this stands on it's own
merit as a nice clean up.

Reports of testing on other combinations of hardware would be greatly
appreciated.

 drivers/mtd/nand/raw/pxa3xx_nand.c | 247 -
 1 file changed, 68 insertions(+), 179 deletions(-)

diff --git a/drivers/mtd/nand/raw/pxa3xx_nand.c 
b/drivers/mtd/nand/raw/pxa3xx_nand.c
index 9c29e8a6c214..fcd1b9c63614 100644
--- a/drivers/mtd/nand/raw/pxa3xx_nand.c
+++ b/drivers/mtd/nand/raw/pxa3xx_nand.c
@@ -330,89 +330,44 @@ static struct nand_bbt_descr bbt_mirror_descr = {
 };
 #endif
 
-static struct nand_ecclayout ecc_layout_2KB_bch4bit = {
-   .eccbytes = 32,
-   .eccpos = {
-   32, 33, 34, 35, 36, 37, 38, 39,
-   40, 41, 42, 43, 44, 45, 46, 47,
-   48, 49, 50, 51, 52, 53, 54, 55,
-   56, 57, 58, 59, 60, 61, 62, 63},
-   .oobfree = { {2, 30} }
+struct marvell_hw_ecc_layout {
+   int page_size;
+   int strength;
+   unsigned intecc_size;
+   unsigned intnfullchunks;
+   unsigned intchunk_size;
+   unsigned intspare_size;
+   unsigned intlast_chunk_size;
+   unsigned intlast_spare_size;
 };
 
-static struct nand_ecclayout ecc_layout_2KB_bch8bit = {
-   .eccbytes = 64,
-   .eccpos = {
-   32, 33, 34, 35, 36, 37, 38, 39,
-   40, 41, 42, 43, 44, 45, 46, 47,
-   48, 49, 50, 51, 52, 53, 54, 55,
-   56, 57, 58, 59, 60, 61, 62, 63,
-   64, 65, 66, 67, 68, 69, 70, 71,
-   72, 73, 74, 75, 76, 77, 78, 79,
-   80, 81, 82, 83, 84, 85, 86, 87,
-   88, 89, 90, 91, 92, 93, 94, 95},
-   .oobfree = { {1, 4}, {6, 26} }
+static const struct marvell_hw_ecc_layout nfc_layouts[] = {
+   /* page_size strength ecc_size nfullchunks chunk_size spare_size 
last_chunk last_spare */
+   { 512,  1,   8, 1, 512,8, 
0, 0  },
+   {2048,  1,  24, 1,2048,   40, 
0, 0  },
+
+   {2048,  4,  32, 1,2048,   32, 
0, 0  },
+   {2048,  8,  32, 1,1024,0,  
1024,32  },
+   {2048, 12,  32, 2, 704,0,   
640, 0  },
+   {2048, 16,  32, 4, 512,0, 
0,32  },
+   {4096,  4,  32, 2,2048,   32, 
0, 0  },
+   {4096,  8,  32, 4,1024,0, 
0,64  },
+   {4096, 12,  32, 5, 704,0,   
576,32  },
+   {4096, 16,  32, 8, 512,0, 
0,32  },
+
+   {8192,  4,  32, 4,2048,   32, 
0, 0  },
+   {8192,  8,  32, 8,1024,0, 
0,   160  },
+   {8192, 12,  32,11, 704,0,   
448,64  },
+   {8192, 16,  32,16, 512,0, 
0,32  },
+   { },
 };
 
-static struct nand_ecclayout ecc_layout_4KB_bch4bit = {
-   .eccbytes = 64,
-   .eccpos = {
-   32,  33,  34,  35,  36,  37,  38,  39,
-   40,  41,  42,  43,  44,  45,  46,  47,
-   48,  49,  50,  51,  52,  53,  54,  55,
-   56,  57,  58,  59,  60,  61,  62,  63,
-   96,  97,  98,  99,  100, 101, 102, 103,
-   104, 105, 106, 107, 108, 109, 110, 111,
-   112, 113, 114, 115, 116, 117, 118, 119,
-   120, 121, 122, 123, 124, 125, 126, 127},
-   /* Bootrom looks in bytes 0 & 5 for bad blocks */
-   .oobfree = { {6, 26}, { 64, 32} }
-};
-
-static struct nand_ecclayout ecc_layout_8KB_bch4bit = {
-   .eccbytes = 128,
-   .eccpos = {
-   32,  33,  34,  35,  36,  37,  38,  39,
-   40,  41,  42,  43,  44,  45,  46,  47,
-   48,  49,  50,  51,  52,  53,  54,  55,
-   56,  57,  58,  59,  60,  61,  62,  63,
-
-   96,  97,  98,  99,  100, 101, 

Re: [PATCH v13 5/9] bootmenu: add removable media entries

2022-08-24 Thread Masahisa Kojima
On Wed, 24 Aug 2022 at 23:17, Ilias Apalodimas
 wrote:
>
> Hi Kojima-san,
>
> Apologies for doing the review ad-hoc, but the patchset is huge.
> I'll try to send a more complete email tomorrow

No problem, thank you for your review.

>
> [...]
> >  #endif
> >
> > diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> > index 537f3f2bbc..92171c4894 100644
> > --- a/cmd/eficonfig.c
> > +++ b/cmd/eficonfig.c
> > @@ -1786,6 +1786,215 @@ static efi_status_t 
> > eficonfig_process_delete_boot_option(void *data)
> >   return ret;
> >  }
> >
> > +/**
> > + * eficonfig_enumerate_boot_option() - enumerate the possible bootable 
> > media
> > + *
> > + * @opt: pointer to the media boot option structure
> > + * @volume_handles:  pointer to the efi handles
> > + * @count:   number of efi handle
> > + * Return:   status code
> > + */
> > +efi_status_t eficonfig_enumerate_boot_option(struct 
> > eficonfig_media_boot_option *opt,
> > +  efi_handle_t *volume_handles, 
> > efi_status_t count)
> > +{
> > + u32 i;
> > + struct efi_handler *handler;
> > + efi_status_t ret = EFI_SUCCESS;
> > +
> > + for (i = 0; i < count; i++) {
> > + u16 *p;
> > + u16 dev_name[BOOTMENU_DEVICE_NAME_MAX];
> > + char *optional_data;
> > + struct efi_load_option lo;
> > + char buf[BOOTMENU_DEVICE_NAME_MAX];
> > + struct efi_device_path *device_path;
> > +
> > + ret = efi_search_protocol(volume_handles[i], 
> > _guid_device_path, );
> > + if (ret != EFI_SUCCESS)
> > + continue;
> > + ret = efi_protocol_open(handler, (void **)_path,
> > + efi_root, NULL, 
> > EFI_OPEN_PROTOCOL_GET_PROTOCOL);
> > + if (ret != EFI_SUCCESS)
> > + continue;
> > +
> > + ret = efi_disk_get_device_name(volume_handles[i], buf, 
> > BOOTMENU_DEVICE_NAME_MAX);
> > + if (ret != EFI_SUCCESS)
> > + continue;
> > +
> > + p = dev_name;
> > + utf8_utf16_strncpy(, buf, strlen(buf));
> > +
> > + lo.label = dev_name;
> > + lo.attributes = LOAD_OPTION_ACTIVE;
> > + lo.file_path = device_path;
> > + lo.file_path_length = efi_dp_size(device_path) + sizeof(END);
> > + /*
> > +  * Set the dedicated guid to optional_data, it is used to 
> > identify
> > +  * the boot option that automatically generated by the 
> > bootmenu.
> > +  * efi_serialize_load_option() expects optional_data is 
> > null-terminated
> > +  * utf8 string, so set the "1234567" string to allocate 
> > enough space
> > +  * to store guid, instead of realloc the load_option.
> > +  */
> > + lo.optional_data = "1234567";
> > + opt[i].size = efi_serialize_load_option(, (u8 
> > **)[i].lo);
> > + if (!opt[i].size) {
> > + ret = EFI_OUT_OF_RESOURCES;
> > + free(dev_name);
>
> This is a stack allocated variable.

I will fix it.

Thanks,
Masahisa Kojima

>
> > + goto out;
> > + }
> > + /* set the guid */
>
> [...]
>
> Thanks
> /Ilias


Re: [PATCH v13 5/9] bootmenu: add removable media entries

2022-08-24 Thread Masahisa Kojima
On Wed, 24 Aug 2022 at 22:25, Ilias Apalodimas
 wrote:
>
> Hi Kojima-san
>
> On Wed, Aug 24, 2022 at 03:37:36PM +0900, Masahisa Kojima wrote:
> > UEFI specification requires booting from removal media using
> > a architecture-specific default image name such as BOOTAA64.EFI.
> > This commit adds the removable media entries into bootmenu,
> > so that user can select the removable media and boot with
> > default image.
> >
> > The bootmenu automatically enumerates the possible bootable
> > media devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL,
> > add it as new UEFI boot option(BOOT) and update BootOrder
> > variable. This automatically generated UEFI boot option
> > has the dedicated guid in the optional_data to distinguish it from
> > the UEFI boot option user adds manually. This optional_data is
> > removed when the efi bootmgr loads the selected UEFI boot option.
> >
> > This commit also provides the BOOT variable maintenance feature.
> > Depending on the system hardware setup, some devices
> > may not exist at a later system boot, so bootmenu checks the
> > available device in each bootmenu invocation and automatically
> > removes the BOOT variable corrensponding to the non-existent
> > media device.
> >
>
> Maybe I am doing something wrong here and this has been discussed in the
> past, but here's what I get by testing this.
>
> - The automatic scanning of boot options seems to be happening only when
>   "Change boot order" menu is selected.  Isn't it better to do it on
>   eficonfig startup ?

In current design, we can not edit/delete the auto-generated boot options.
I can move automatic scanning of boot options into the eficonfig startup, but
it does not affect edit/delete boot options.
I just do automatic scanning of boot options just before it is used in
"Change Boot Order".

> - Although I can see a variable Boot which holds the device path of the
>   virtio disk that has the BOOTAA64.EFI file, I can't see that option in
>   the edit/delete menus

Is it the auto-generated boot option?
The auto-generate boot option is not listed in the edit/delete menu,
discussed with
Heinrich before[1].

[1] https://lore.kernel.org/u-boot/2d19f001-a3cb-735e-d615-2f23cb5b2...@gmx.de/

Thanks,
Masahisa Kojima

>
> Thanks
> /Ilias
> > Signed-off-by: Masahisa Kojima 
> > ---
> > Changes in v13:
> > - remove BootOrder variable dependency
> >
> > Changes in v12:
> > - move generate_media_device_boot_option into cmd/eficonfig.c and expose it
> > - remove unnecessary include file
> >
> > Changes in v11:
> > - update delete_boot_option() parameter
> >
> > Changes in v10:
> > - add function comment
> > - devname dynamic allocation removes, allocate in stack
> > - delete BOOT when updating BootOrder fails
> >
> > Changes in v9:
> > - update efi_disk_get_device_name() parameter to pass efi_handle_t
> > - add function comment
> >
> > Changes in v8:
> > - function and structure prefix is changed to "eficonfig"
> >
> > Changes in v7:
> > - rename prepare_media_device_entry() to generate_media_device_boot_option()
> >
> > Changes in v6:
> > - optional_data size is changed to 16bytes
> > - check the load option size before comparison
> > - remove guid included in optional_data of auto generated
> >   entry when loading
> >
> > Changes in v5:
> > - Return EFI_SUCCESS if there is no BootOrder defined
> > - correctly handle the case if no removable device found
> > - use guid to identify the automatically generated entry by bootmenu
> >
> >  cmd/bootmenu.c   |  22 +++-
> >  cmd/eficonfig.c  | 209 +++
> >  include/efi_config.h |   1 +
> >  include/efi_loader.h |  16 +++
> >  lib/efi_loader/efi_bootmgr.c |   4 +
> >  5 files changed, 246 insertions(+), 6 deletions(-)
> >
> > diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
> > index 704d36debe..3340be1632 100644
> > --- a/cmd/bootmenu.c
> > +++ b/cmd/bootmenu.c
> > @@ -7,7 +7,7 @@
> >  #include 
> >  #include 
> >  #include 
> > -#include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -220,7 +220,7 @@ static int prepare_bootmenu_entry(struct bootmenu_data 
> > *menu,
> >   return 1;
> >  }
> >
> > -#if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR))
> > +#if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR)) && 
> > (CONFIG_IS_ENABLED(CMD_EFICONFIG))
> >  /**
> >   * prepare_uefi_bootorder_entry() - generate the uefi bootmenu entries
> >   *
> > @@ -340,11 +340,21 @@ static struct bootmenu_data *bootmenu_create(int 
> > delay)
> >   if (ret < 0)
> >   goto cleanup;
> >
> > -#if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR))
> > +#if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR)) && 
> > (CONFIG_IS_ENABLED(CMD_EFICONFIG))
> >   if (i < MAX_COUNT - 1) {
> > - ret = prepare_uefi_bootorder_entry(menu, , );
> > - if (ret < 0 && ret != -ENOENT)
> > - goto cleanup;
> > + efi_status_t efi_ret;
> > +
> > + 

Re: [PATCH v13 1/9] eficonfig: menu-driven addition of UEFI boot option

2022-08-24 Thread Masahisa Kojima
On Wed, 24 Aug 2022 at 23:19, Ilias Apalodimas
 wrote:
>
> Kojima-san,
>
> [...]
>
> > +
> > +/**
> > + * eficonfig_init() - do required initialization for eficonfig command
> > + *
> > + * Return:   status code
> > + */
> > +static efi_status_t eficonfig_init(void)
> > +{
> > + efi_status_t ret;
>
>
> You need to initialize ret here to something.

Yes, I will fix it.

Thanks,
Masahisa Kojima

>
> > + static bool init;
> > + struct efi_handler *handler;
> > +
> > + if (!init) {
> > + ret = efi_search_protocol(efi_root, 
> > _guid_text_input_protocol, );
> > + if (ret != EFI_SUCCESS)
> > + return ret;
> > +
> > + ret = efi_protocol_open(handler, (void **), efi_root, 
> > NULL,
> > + EFI_OPEN_PROTOCOL_GET_PROTOCOL);
> > + if (ret != EFI_SUCCESS)
> > + return ret;
> > + }
>
> Because this code might never run
>
> > +
> > + init = true;
> > +
> > + return ret;
> > +}
> > +
> > +static const struct eficonfig_item maintenance_menu_items[] = {
>
> [...]
>
>
> Regards
> /Ilias


Re: [PATCH v13 1/9] eficonfig: menu-driven addition of UEFI boot option

2022-08-24 Thread Masahisa Kojima
On Wed, 24 Aug 2022 at 20:15, Ilias Apalodimas
 wrote:
>
> Hi Kojima-san,
>
> [...]
>
> > + * eficonfig_destroy() - destroy efimenu
> > + *
> > + * @efi_menu:pointer to the efimenu structure
> > + * @flag:flag to free the allocated data
> > + */
> > +static void eficonfig_destroy(struct efimenu *efi_menu, bool flag)
> > +{
> > + struct list_head *pos, *n;
> > + struct eficonfig_entry *entry;
> > +
> > + list_for_each_safe(pos, n, _menu->list) {
> > + entry = list_entry(pos, struct eficonfig_entry, list);
> > + free(entry->title);
> > + if (flag)
> > + free(entry->data);
>
> I don't we need this flag.  entry->data is either set to a valid pointer or
> NULL on append_entry().

There is a case that entry->data is still used after the menu is destroyed.

The following case, file_info is still used after eficonfig_destroy().
https://git.linaro.org/people/masahisa.kojima/u-boot.git/tree/cmd/eficonfig.c?h=kojima/eficonfig_upstream_v13#n953

Also there are the cases that a not-allocated pointer is set to entry->data.

In addition, this flag will be used to handle the following static menu entry
for secure boot key management series.

+   {"PK", eficonfig_process_set_secure_boot_pk, u"PK"},
+   {"KEK", eficonfig_process_set_secure_boot_key, u"KEK"},
+   {"db", eficonfig_process_set_secure_boot_key, u"db"},
+   {"dbx", eficonfig_process_set_secure_boot_key, u"dbx"},
+   {"Quit", eficonfig_process_quit},

The last parameter(u"PK", u"KEK") is set to entry->data, it will not be freed.

But this flag is a little tricky.

Thanks,
Masahisa Kojima





>
> > + list_del(>list);
> > + free(entry);
> > + }
> > + free(efi_menu->menu_header);
> > + free(efi_menu);
>
> [...]
>
> Regards
> /Ilias


Re: [PATCH] arm: mvebu: mbus: Fix mbus driver to work also after U-Boot relocation

2022-08-24 Thread Chris Packham
Hi Pali,

On 23/08/22 11:00, Pali Rohár wrote:
> On Wednesday 17 August 2022 08:17:36 Stefan Roese wrote:
>> On 10.08.22 14:46, Pali Rohár wrote:
>>> mbus driver is initialized from arch_cpu_init() callback which is called
>>> before relocation. This driver stores lot of functions and structure
>>> pointers into global variables, so it is data position dependent.
>>>
>>> Therefore after relocations all pointers are invalid and driver does not
>>> work anymore as all pointers referes to the old memory, which overlaps with
>>> CONFIG_SYS_LOAD_ADDR and ${loadaddr}.
>>>
>>> For example U-Boot fuse command crashes if loadaddr memory is cleared or
>>> rewritten by some image loaded by U-Boot load command.
>>>
>>> mw.w ${loadaddr} 0x0 1
>>> fuse read 0 1 2
>>>
>>> Fix this issue by removing of all mbus global variables in which are stored
>>> pointers to structures or functions which changes during relocation. And
>>> replace it by direct function calls (not via pointers). With this change
>>> fuse command finally works.
>>>
>>> Signed-off-by: Pali Rohár 
>> Reviewed-by: Stefan Roese 
>>
>> Thanks,
>> Stefan
> Stefan, this is something which is needed to have fixed. Could you test
> this change on your boards and prepare for merging to master branch?
>
> Chris, could you also test this change for possible regressions?
>
> I have tested it on A385 Turris Omnia.

I see I'm a little late to the testing party but I've just checked what 
was merged on an x530 and it's all good there.

>>> ---
>>>arch/arm/mach-kirkwood/include/mach/cpu.h |   3 -
>>>arch/arm/mach-mvebu/include/mach/cpu.h|   3 -
>>>arch/arm/mach-mvebu/mbus.c| 167 +-
>>>board/alliedtelesis/x530/x530.c   |   2 +-
>>>board/maxbcm/maxbcm.c |   8 +-
>>>board/theadorable/theadorable.c   |   4 +-
>>>include/linux/mbus.h  |  13 +-
>>>7 files changed, 75 insertions(+), 125 deletions(-)
>>>
>>> diff --git a/arch/arm/mach-kirkwood/include/mach/cpu.h 
>>> b/arch/arm/mach-kirkwood/include/mach/cpu.h
>>> index 71c546f9acf6..d8639c60352b 100644
>>> --- a/arch/arm/mach-kirkwood/include/mach/cpu.h
>>> +++ b/arch/arm/mach-kirkwood/include/mach/cpu.h
>>> @@ -144,9 +144,6 @@ struct kwgpio_registers {
>>> u32 irq_level;
>>>};
>>> -/* Needed for dynamic (board-specific) mbus configuration */
>>> -extern struct mvebu_mbus_state mbus_state;
>>> -
>>>/*
>>> * functions
>>> */
>>> diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h 
>>> b/arch/arm/mach-mvebu/include/mach/cpu.h
>>> index 689c96bd4eac..d9fa1f32aa52 100644
>>> --- a/arch/arm/mach-mvebu/include/mach/cpu.h
>>> +++ b/arch/arm/mach-mvebu/include/mach/cpu.h
>>> @@ -122,9 +122,6 @@ struct sar_freq_modes {
>>> u32 d_clk;
>>>};
>>> -/* Needed for dynamic (board-specific) mbus configuration */
>>> -extern struct mvebu_mbus_state mbus_state;
>>> -
>>>/*
>>> * functions
>>> */
>>> diff --git a/arch/arm/mach-mvebu/mbus.c b/arch/arm/mach-mvebu/mbus.c
>>> index 3b1b9f73ebf6..7092f6cc10c2 100644
>>> --- a/arch/arm/mach-mvebu/mbus.c
>>> +++ b/arch/arm/mach-mvebu/mbus.c
>>> @@ -88,31 +88,34 @@
>>>#define DOVE_DDR_BASE_CS_OFF(n) ((n) << 4)
>>> -struct mvebu_mbus_state;
>>> -
>>> -struct mvebu_mbus_soc_data {
>>> -   unsigned int num_wins;
>>> -   unsigned int num_remappable_wins;
>>> -   unsigned int (*win_cfg_offset)(const int win);
>>> -   void (*setup_cpu_target)(struct mvebu_mbus_state *s);
>>> -};
>>> -
>>> -struct mvebu_mbus_state mbus_state
>>> -   __section(".data");
>>>static struct mbus_dram_target_info mbus_dram_info
>>> __section(".data");
>>> +#if defined(CONFIG_ARCH_MVEBU)
>>> +   #define MVEBU_MBUS_NUM_WINS 20
>>> +   #define MVEBU_MBUS_NUM_REMAPPABLE_WINS 8
>>> +   #define MVEBU_MBUS_WIN_CFG_OFFSET(win) 
>>> armada_370_xp_mbus_win_offset(win)
>>> +#elif defined(CONFIG_ARCH_KIRKWOOD)
>>> +   #define MVEBU_MBUS_NUM_WINS 8
>>> +   #define MVEBU_MBUS_NUM_REMAPPABLE_WINS 4
>>> +   #define MVEBU_MBUS_WIN_CFG_OFFSET(win) orion5x_mbus_win_offset(win)
>>> +#else
>>> +   #error "No supported architecture"
>>> +#endif
>>> +
>>> +static unsigned int armada_370_xp_mbus_win_offset(int win);
>>> +static unsigned int orion5x_mbus_win_offset(int win);
>>> +
>>>/*
>>> * Functions to manipulate the address decoding windows
>>> */
>>> -static void mvebu_mbus_read_window(struct mvebu_mbus_state *mbus,
>>> -  int win, int *enabled, u64 *base,
>>> +static void mvebu_mbus_read_window(int win, int *enabled, u64 *base,
>>>u32 *size, u8 *target, u8 *attr,
>>>u64 *remap)
>>>{
>>> -   void __iomem *addr = mbus->mbuswins_base +
>>> -   mbus->soc->win_cfg_offset(win);
>>> +   void __iomem *addr = (void __iomem *)MVEBU_CPU_WIN_BASE +
>>> +   MVEBU_MBUS_WIN_CFG_OFFSET(win);
>>> u32 basereg = readl(addr + WIN_BASE_OFF);
>>> u32 

Re: [PATCH v13 6/9] eficonfig: add "Change Boot Order" menu entry

2022-08-24 Thread Masahisa Kojima
On Thu, 25 Aug 2022 at 09:11, Takahiro Akashi
 wrote:
>
> On Wed, Aug 24, 2022 at 03:37:37PM +0900, Masahisa Kojima wrote:
> > This commit adds the menu entry to update UEFI BootOrder variable.
> > User moves the entry with UP/DOWN key, changes the order
> > with PLUS/MINUS key, press SPACE to activate or deactivate
> > the entry, then finalizes the order by ENTER key.
> > If the entry is activated, the boot index is added into the
> > BootOrder variable in the order of the list.
> >
> > The U-Boot menu framework is well designed for static menu,
> > this commit implements the own menu display and key handling
> > for dynamically change the order of menu entry.
> >
> > Signed-off-by: Masahisa Kojima 
> > ---
> > No update since v12
>
> Well, a minor issue.
> When BootOrder is not defined, nothing happens by selecting
> "Change Boot Order". For "Edit" or "Delete Boot Option", however,
> it causes a menu transition and shows something like:
> ** Select Boot Option **
>
>   Quit
>
> even if no applicable option is available.
>
> I hope a consistent behavior for "Change Boot Order" as well,
> or printing some error message will be better.

I will fix it to have consistent behavior.

Thanks,
Masahisa Kojima

>
> -Takahiro Akashi
>
> > Changes in v12:
> > - enumerate removable media device
> >
> > Changes in v11:
> > - remove BootOrder variable dependency
> > - use ANSI_CURSOR_POSITION and ANSI_CLEAR_LINE instead of printf("\n")
> >   since current eficonfig implementation does not handle console size 
> > correctly.
> >   printf("\n") at the outside of console size breaks the console output.
> > - add KEY_SPACE to toggle the boot option active status
> >
> > No update since v9
> >
> > Changes in v9:
> > - add function comment
> >
> > Changes in v8:
> > - add "Save" and "Quit" entries
> >
> > Changes in v7:
> > - use UP/DOWN and PLUS/MINUS key to change to order
> >
> > no update in v6:
> >
> >  cmd/eficonfig.c | 351 +++-
> >  1 file changed, 350 insertions(+), 1 deletion(-)
> >
> > diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> > index 92171c4894..0922115138 100644
> > --- a/cmd/eficonfig.c
> > +++ b/cmd/eficonfig.c
> > @@ -91,6 +91,23 @@ struct eficonfig_boot_selection_data {
> >   int *selected;
> >  };
> >
> > +/**
> > + * struct eficonfig_boot_order - structure to be used to update BootOrder 
> > variable
> > + *
> > + * @num: index in the menu entry
> > + * @description: pointer to the description string
> > + * @boot_index:  boot option index
> > + * @active:  flag to include the boot option into BootOrder 
> > variable
> > + * @list:list structure
> > + */
> > +struct eficonfig_boot_order {
> > + u32 num;
> > + u16 *description;
> > + u32 boot_index;
> > + bool active;
> > + struct list_head list;
> > +};
> > +
> >  /**
> >   * eficonfig_print_msg() - print message
> >   *
> > @@ -1716,6 +1733,338 @@ out:
> >   return ret;
> >  }
> >
> > +/**
> > + * eficonfig_display_change_boot_order() - display the BootOrder list
> > + *
> > + * @efi_menu:pointer to the efimenu structure
> > + * Return:   status code
> > + */
> > +static void eficonfig_display_change_boot_order(struct efimenu *efi_menu)
> > +{
> > + bool reverse;
> > + struct list_head *pos, *n;
> > + struct eficonfig_boot_order *entry;
> > +
> > + printf(ANSI_CLEAR_CONSOLE ANSI_CURSOR_POSITION
> > +"\n  ** Change Boot Order **\n"
> > +ANSI_CURSOR_POSITION
> > +"  Press UP/DOWN to move, +/- to change order"
> > +ANSI_CURSOR_POSITION
> > +"  Press SPACE to activate or deactivate the entry"
> > +ANSI_CURSOR_POSITION
> > +"  Select [Save] to complete, ESC/CTRL+C to quit"
> > +ANSI_CURSOR_POSITION ANSI_CLEAR_LINE,
> > +1, 1, efi_menu->count + 5, 1, efi_menu->count + 6, 1,
> > +efi_menu->count + 7, 1,  efi_menu->count + 8, 1);
> > +
> > + /* draw boot option list */
> > + list_for_each_safe(pos, n, _menu->list) {
> > + entry = list_entry(pos, struct eficonfig_boot_order, list);
> > + reverse = (entry->num == efi_menu->active);
> > +
> > + printf(ANSI_CURSOR_POSITION, entry->num + 4, 7);
> > +
> > + if (reverse)
> > + puts(ANSI_COLOR_REVERSE);
> > +
> > + if (entry->num < efi_menu->count - 2) {
> > + if (entry->active)
> > + printf("[*]  ");
> > + else
> > + printf("[ ]  ");
> > + }
> > +
> > + printf("%ls", entry->description);
> > +
> > + if (reverse)
> > + puts(ANSI_COLOR_RESET);
> > + }
> > +}
> > +
> > +/**
> > + * eficonfig_choice_change_boot_order() - handle the BootOrder update
> > + *
> > + * @efi_menu:pointer to the efimenu structure

Re: [PATCH v13 8/9] doc:eficonfig: add documentation for eficonfig command

2022-08-24 Thread Masahisa Kojima
Hi Ilias,

On Wed, 24 Aug 2022 at 18:14, Ilias Apalodimas
 wrote:
>
> Hi Kojima-san
>
> On Wed, 24 Aug 2022 at 09:37, Masahisa Kojima
>  wrote:
> >
> > Add documentation for eficonfig command.
> >
> > Signed-off-by: Masahisa Kojima 
> > ---
> > Changes in v13:
> > - describe how to auto boot according to the UEFI Boot option
> >
> > Changes in v12:
> > - CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE condition is added
> >   to show newly added boot option
> >
> > No update since v10
> >
> > Changes in v10:
> > - describe how to boot system after editting by eficonfig
> >
> > Changes in v8:
> > - command name is changed from "efimenu" to "eficonfig"
> >
> > Newly created in v7
> >
> >  doc/usage/cmd/eficonfig.rst | 71 +
> >  doc/usage/index.rst |  1 +
> >  2 files changed, 72 insertions(+)
> >  create mode 100644 doc/usage/cmd/eficonfig.rst
> >
> > diff --git a/doc/usage/cmd/eficonfig.rst b/doc/usage/cmd/eficonfig.rst
> > new file mode 100644
> > index 00..48932fa16b
> > --- /dev/null
> > +++ b/doc/usage/cmd/eficonfig.rst
> > @@ -0,0 +1,71 @@
> > +.. SPDX-License-Identifier: GPL-2.0+
> > +.. (C) Copyright 2022, Masahisa Kojima 
> > +
> > +eficonfig command
> > +=
> > +
> > +Synopsis
> > +
> > +::
> > +
> > +eficonfig
> > +
> > +Description
> > +---
> > +
> > +The "eficonfig" command uses U-Boot menu interface and privides
>
> provides
>
> > +a menu-driven UEFI variable maintenance feature.
> > +The "eficonfig" has the following menu entries.
> > +
> > +Add Boot Option
> > +Add new UEFI Boot Option.
> > +User can edit description, file path, and optional_data.
> > +
> > +Edit Boot Option
> > +Edit the existing UEFI Boot Option
> > +User can edit description, file path, and optional_data.
> > +
> > +Change Boot Order
> > +Change the order of UEFI BootOrder variable.
> > +
> > +Delete Boot Option
> > +Delete the UEFI Boot Option
> > +
> > +Configuration
> > +-
> > +
> > +The "eficonfig" command is enabled by::
> > +
> > +CONFIG_CMD_EFICONFIG=y
> > +
> > +If CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE is enabled, user can not enter
> > +U-Boot console. In this case, bootmenu can be used to invoke "eficonfig"::
> > +
> > +CONFIG_USE_PREBOOT=y
> > +CONFIG_PREBOOT="setenv bootmenu_0 UEFI Maintenance Menu=eficonfig"
> > +
> > +How to boot the system with newly added UEFI Boot Option
> > +
> > +
> > +"eficonfig" command is responsible to configure the UEFI variables,
>
> is responsible for configuring
>
> > +not directly handle the system boot.
> > +The new Boot Option added by "eficonfig" is appended at the last entry
> > +of UEFI BootOrder variable, user may want to change the boot order
> > +through "Change Boot Order".
> > +If the bootmenu is enabled, CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE is 
> > enabled,
> > +and "eficonfig" is configured as preboot command, the newly added Boot 
> > Options
> > +are enumerated in the bootmenu when user exits from the eficonfig menu.
> > +User may select the entry in the bootmenu to boot the system, or follow
> > +the U-Boot configuration the system already has.
> > +
> > +Auto boot with the UEFI Boot Option
> > +'''
> > +
> > +To do auto boot according to the UEFI BootOrder variable,
> > +add "bootefi bootmgr" entry as a default or first bootmenu entry::
> > +
> > +CONFIG_PREBOOT="setenv bootmenu_0 UEFI Boot Manager=bootefi bootmgr; 
> > setenv bootmenu_1 UEFI Maintenance Menu=eficonfig"
> > +
> > +See also
> > +
> > +* :doc:`bootmenu` provides a simple mechanism for creating menus 
> > with different boot items
> > diff --git a/doc/usage/index.rst b/doc/usage/index.rst
> > index 28f9683a3e..09f2928970 100644
> > --- a/doc/usage/index.rst
> > +++ b/doc/usage/index.rst
> > @@ -35,6 +35,7 @@ Shell commands
> > cmd/conitrace
> > cmd/dm
> > cmd/echo
> > +   cmd/eficonfig
> > cmd/env
> > cmd/event
> > cmd/exception
> > --
> > 2.17.1
> >
>
> With these changes
>
> Reviewed-by: Ilias Apalodimas 

Thank you for your review. I will fix typos.

Regards,
Masahisa Kojima


Re: [PATCH v3 6/7] test: py: fru: add a test for the fru command

2022-08-24 Thread Simon Glass
Hi,

On Tue, 23 Aug 2022 at 14:53, Jae Hyun Yoo  wrote:
>
> Add a simple test for the 'fru' command.
>
> Signed-off-by: Jae Hyun Yoo 
> ---
> Changes from v2:
>  * Added CONFIG_CMD_FRU=y only into the sandbox_defconfig. (Simon)
>
> Changes from v1:
>  * Newly added in v2. (Heinrich)
>
>  configs/sandbox_defconfig |  1 +
>  test/py/tests/test_fru.py | 47 +++
>  2 files changed, 48 insertions(+)
>  create mode 100644 test/py/tests/test_fru.py

Can you just rely on the C test and not have this?

Regards,
Simon


Re: [PATCH v3 7/7] test: cmd: fru: add unit test for the fru command

2022-08-24 Thread Simon Glass
On Tue, 23 Aug 2022 at 14:53, Jae Hyun Yoo  wrote:
>
> Add test cases for the fru command.
>
> Signed-off-by: Jae Hyun Yoo 
> ---
> Changes from v2:
>  * Newly added in v3. (Simon)
>
>  include/test/suites.h |  1 +
>  test/cmd/Makefile |  1 +
>  test/cmd/fru.c| 84 +++
>  test/cmd_ut.c |  6 
>  4 files changed, 92 insertions(+)
>  create mode 100644 test/cmd/fru.c

Reviewed-by: Simon Glass 


Re: [PATCH v4 1/8] binman: add support for skipping file concatenation for mkimage

2022-08-24 Thread Simon Glass
Hi Quentin,

On Wed, 24 Aug 2022 at 09:29, Quentin Schulz
 wrote:
>
> Hi Simon,
>
> On 8/18/22 10:17, Simon Glass wrote:
> > Hi Quentin,
> >
> > On Wed, 3 Aug 2022 at 06:19, Quentin Schulz  wrote:
> >>
> >> From: Quentin Schulz 
> >>
> >> Some image types handled by mkimage require the datafiles to be passed
> >> independently (-d data1:data2) for specific handling of each. A
> >> concatenation of datafiles prior to passing them to mkimage wouldn't
> >> work.
> >>
> >> That is the case for rkspi for example which requires page alignment
> >> and only writing 2KB every 4KB.
> >>
> >> This adds the ability to tell binman to pass the datafiles without
> >> prior concatenation to mkimage, by adding the multiple-data-files
> >> boolean property to the mkimage node.
> >>
> >> Cc: Quentin Schulz 
> >> Reviewed-by: Simon Glass 
> >> Signed-off-by: Quentin Schulz 
> >> ---
> >>   tools/binman/entries.rst  | 22 +++
> >>   tools/binman/etype/mkimage.py | 41 +++
> >>   2 files changed, 59 insertions(+), 4 deletions(-)
> >
> > Somehow I missed this one, sorry.
> >
> > It needs a test (try 'binman test -T' to see that it breaks code coverage).
> >
>
> How do you see this test being implemented?
>
> I think it'd be best to mock calls to mkimage (or
> self.mkimage.run_cmd()) and check that the -d parameter has two entries
> separated by a colon but my limited knowledge of unittest.mock does not
> seem to guide me to the proper implementation.
>
> Another way would be to use a specific mkimage type that handles that
> kind of multiple files -d parameter and outputs something more or less
> reproducible, e.g. rkspi type. I don't like this too much even though
> it's much easier because we're bound to this type and the image type
> could change (I recall some endianness fixes a few months ago).
>

You should be able to call mkimage for real and check that it does the
right thing by looking at the output, in a simple way.

See for example testMkimage() and let me know if you need any other hints.

Regards,
Simon


Re: [PATCH v3 4/7] cmd: fru: add product info area parsing support

2022-08-24 Thread Simon Glass
Hi Jae,

On Tue, 23 Aug 2022 at 14:53, Jae Hyun Yoo  wrote:
>
> Add product info area parsing support. Custom board fields can be
> added dynamically using linked list so that each board support can
> utilize them in their own custom way.
>
> Signed-off-by: Jae Hyun Yoo 
> ---
> Changes from v2:
>  * Changed 'struct fru_board_info_member' to 'struct fru_common_info_member'.
>
> Changes from v1:
>  * Refactored using linked list instead of calling a custom parsing callback.
>
> Changes from RFC:
>  * Added manufacturer custom product info fields parsing flow.
>
>  cmd/fru.c |  28 --
>  include/fru.h |  34 ++-
>  lib/fru_ops.c | 244 +++---
>  3 files changed, 286 insertions(+), 20 deletions(-)
>

Please add tests for this code.

Regards,
Simon


Re: [PATCH] cmd: xxd: add new command

2022-08-24 Thread Simon Glass
On Wed, 24 Aug 2022 at 04:20, Roger Knecht  wrote:
>
> Add xxd command to print file content as hexdump to standard out
>
> Signed-off-by: Roger Knecht 
> ---
> The 'xxd' code has a lot in common with my ealier patch for 'cat'.
>
> Example:
> ```
> => xxd mmc 0:1 hello
> : 68 65 6c 6c 6f 20 77 6f 72 6c 64 0a 00 01 02 03  hello world.
> 0010: 04 05
> ```
>
>  MAINTAINERS|  7 +++
>  cmd/Kconfig|  5 ++
>  cmd/Makefile   |  1 +
>  cmd/xxd.c  | 85 ++
>  configs/sandbox64_defconfig|  1 +
>  configs/sandbox_defconfig  |  1 +
>  doc/usage/cmd/xxd.rst  | 50 ++
>  test/py/tests/test_xxd/conftest.py | 35 
>  test/py/tests/test_xxd/test_xxd.py | 23 
>  9 files changed, 208 insertions(+)
>  create mode 100644 cmd/xxd.c
>  create mode 100644 doc/usage/cmd/xxd.rst
>  create mode 100644 test/py/tests/test_xxd/conftest.py
>  create mode 100644 test/py/tests/test_xxd/test_xxd.py

Reviewed-by: Simon Glass 


Re: [PATCH] fdt_support: add optional board_rng_seed() hook

2022-08-24 Thread Simon Glass
Hi Rasmus,

On Tue, 23 Aug 2022 at 23:57, Rasmus Villemoes
 wrote:
>
> On 23/08/2022 16.35, Simon Glass wrote:
> > Hi Rasmus,
> >
> > On Tue, 23 Aug 2022 at 07:06, Rasmus Villemoes
> >  wrote:
> >>
> >> On 23/08/2022 15.38, Simon Glass wrote:
> >>
>  +/**
>  + * board_rng_seed() - Provide a seed to be passed via /chosen/rng-seed
>  + *
>  + * This function is called if CONFIG_BOARD_RNG_SEED is set, and must
>  + * be provided by the board. It should return, via @buf, some suitable
>  + * seed value to pass to the kernel.
>  + *
>  + * @param buf A struct abuf for returning the seed and its size.
>  + * @return0 if ok, negative on error.
>  + */
>  +int board_rng_seed(struct abuf *buf);
> >>>
> >>> Instead of yet another hook, can we use EVT_FT_FIXUP? An even better
> >>> option might be to use EVT_FT_FIXUP and then call a UCLASS_BOARD
> >>> method to obtain the information.
> >>
> >> I didn't know there was anything called EVT_FT_FIXUP, and from grepping,
> >> it seems suffer the same problem as ft_board_setup() as I mention,
> >> namely running after the command line (aka /chosen/bootargs) has been
> >> set up.
> >
> > If that is the only problem, then you could add another event for
> > doing an earlier fixup.
>
> Then I'd much rather just add a board_fdt_chosen() hook called early in
> fdt_chosen(), rather than having to enable yet another overcomplicated
> generic framework. But this was very much specifically targeted at
> rng-seed, because that's a generic, defined binding in /chosen, and I
> wanted to support that explicitly rather than having each board
> implement the logic for populating that - even if, due to its nature,
> the board must supply the actual value to put there.

You can put the event spy in generic code if you like. I am trying to
think more generic ways to handle things, since we have so many
'hooks'.

>
> >> Also, I can't see how it can actually affect the blob being passed to
> >> the kernel, doesn't
> >>
> >> fixup.tree = oftree_default();
> >> ret = event_notify(EVT_FT_FIXUP, , sizeof(fixup));
> >>
> >> mean that fixup.tree points at U-Boot's control fdt rather than the blob
> >> that will be passed as the kernel's fdt? That seems wrong.
> >
> > Yes that is wrong for many platforms. We should probably just change
> > it, but there is a complication.
> >
> > My recent series made a start at supporting writing to a DT using the
> > ofnode interface. See vbe_simple_test_base() for some comments on the
> > current state. You could require OF_LIVE to be enabled for your new
> > feature.
> >
> > Ideally I'd like to see ofnode used for all devicetree access, but it
> > will need to be done in stages. In the meantime we should try to head
> > in that direction.
>
> Huh? You'd need to deserialize the blob we've loaded (from FIT or uImage
> or given directly to a bootm command),

yes

> then have _all_ the various fixup
> functions (setting mac addresses, populating /chosen, all the various
> arch and board fixups etc.) modify that deserialized tree,

Well they only need to use ofnode.

>  and then at
> the end of the day, you need to serialize the tree again to pass to
> linux. I don't see how that could happen incrementally, and I don't see
> what advantage this would bring anyway.

Yes that's right. It can actually happen incrementally.

Unless there is very little going on, it is faster to modify the live
tree and then flatten it before calling Linux.

>
> All that has nothing at all to do with how U-Boot code accesses U-Boot's
> control DT.

As I mentioned, ofnode can now access any tree, at least when OF_LIVE
is enabled. But as you point out, there is lots of work to do here.

Regards,
Simon


Re: [PATCH] patman: do not hardcode coverage tool

2022-08-24 Thread Simon Glass
Hi Michal,

On Wed, 24 Aug 2022 at 00:43, Michal Suchanek  wrote:
>
> The coverage tool name varies across distributions.
>
> Add COVERAGE variable to specify the tool name.
>
> Also there is one place where prefix is prepended to the tool path,
> remove the prefix.
>
> Signed-off-by: Michal Suchanek 
> ---
>  tools/patman/test_util.py | 18 ++
>  1 file changed, 10 insertions(+), 8 deletions(-)

Reviewed-by: Simon Glass 

But please update the docs.

Regards,
Simon


Re: [PATCH] post: memory: Fix format strings

2022-08-24 Thread Simon Glass
On Tue, 23 Aug 2022 at 12:11, Sean Anderson  wrote:
>
> This fixes numerous cases of format strings not matching their
> arguments. Also keep the format strings on one line for easier grepping.
>
> Signed-off-by: Sean Anderson 
> ---
>
>  post/drivers/memory.c | 30 --
>  1 file changed, 12 insertions(+), 18 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH] tests: Do not hardcode sudo tool

2022-08-24 Thread Simon Glass
Hi Michal,

On Wed, 24 Aug 2022 at 00:48, Michal Suchanek  wrote:
>
> In some situations it may be needed to pass parameters to sudo or to use
> a different tool to gain root access. Add SUDO variable to specify the
> sudo tool.
>
> Signed-off-by: Michal Suchanek 
> ---
>  test/fs/fat-noncontig-test.sh |  9 +
>  test/fs/fs-test.sh| 26 ++
>  test/py/tests/test_fs/conftest.py |  8 +---
>  test/py/tests/test_ut.py  | 14 --
>  4 files changed, 32 insertions(+), 25 deletions(-)
>

Reviewed-by: Simon Glass 

But please can you update doc/develop/testing.rst ?

Regards,
Simon


Re: [PATCH] kbuild: add KBUILD_HOSTLDFLAGS to cmd_host-csingle

2022-08-24 Thread Simon Glass
On Wed, 24 Aug 2022 at 01:37, Heiko Thiery  wrote:
>
> When compiling executables from a single.c file, the linker is also
> invoked. Pass the flags like the other linker commands.
>
> cherry-pick kbuild change from Linux:
>
> 63185b46cdb3 (kbuild: use HOSTLDFLAGS for single .c executables)
>
> Signed-off-by: Heiko Thiery 
> ---
>  scripts/Makefile.host | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCH v13 6/9] eficonfig: add "Change Boot Order" menu entry

2022-08-24 Thread Takahiro Akashi
On Wed, Aug 24, 2022 at 03:37:37PM +0900, Masahisa Kojima wrote:
> This commit adds the menu entry to update UEFI BootOrder variable.
> User moves the entry with UP/DOWN key, changes the order
> with PLUS/MINUS key, press SPACE to activate or deactivate
> the entry, then finalizes the order by ENTER key.
> If the entry is activated, the boot index is added into the
> BootOrder variable in the order of the list.
> 
> The U-Boot menu framework is well designed for static menu,
> this commit implements the own menu display and key handling
> for dynamically change the order of menu entry.
> 
> Signed-off-by: Masahisa Kojima 
> ---
> No update since v12

Well, a minor issue.
When BootOrder is not defined, nothing happens by selecting
"Change Boot Order". For "Edit" or "Delete Boot Option", however,
it causes a menu transition and shows something like:
** Select Boot Option **

  Quit

even if no applicable option is available.

I hope a consistent behavior for "Change Boot Order" as well,
or printing some error message will be better.

-Takahiro Akashi

> Changes in v12:
> - enumerate removable media device
> 
> Changes in v11:
> - remove BootOrder variable dependency
> - use ANSI_CURSOR_POSITION and ANSI_CLEAR_LINE instead of printf("\n")
>   since current eficonfig implementation does not handle console size 
> correctly.
>   printf("\n") at the outside of console size breaks the console output.
> - add KEY_SPACE to toggle the boot option active status
> 
> No update since v9
> 
> Changes in v9:
> - add function comment
> 
> Changes in v8:
> - add "Save" and "Quit" entries
> 
> Changes in v7:
> - use UP/DOWN and PLUS/MINUS key to change to order
> 
> no update in v6:
> 
>  cmd/eficonfig.c | 351 +++-
>  1 file changed, 350 insertions(+), 1 deletion(-)
> 
> diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> index 92171c4894..0922115138 100644
> --- a/cmd/eficonfig.c
> +++ b/cmd/eficonfig.c
> @@ -91,6 +91,23 @@ struct eficonfig_boot_selection_data {
>   int *selected;
>  };
>  
> +/**
> + * struct eficonfig_boot_order - structure to be used to update BootOrder 
> variable
> + *
> + * @num: index in the menu entry
> + * @description: pointer to the description string
> + * @boot_index:  boot option index
> + * @active:  flag to include the boot option into BootOrder variable
> + * @list:list structure
> + */
> +struct eficonfig_boot_order {
> + u32 num;
> + u16 *description;
> + u32 boot_index;
> + bool active;
> + struct list_head list;
> +};
> +
>  /**
>   * eficonfig_print_msg() - print message
>   *
> @@ -1716,6 +1733,338 @@ out:
>   return ret;
>  }
>  
> +/**
> + * eficonfig_display_change_boot_order() - display the BootOrder list
> + *
> + * @efi_menu:pointer to the efimenu structure
> + * Return:   status code
> + */
> +static void eficonfig_display_change_boot_order(struct efimenu *efi_menu)
> +{
> + bool reverse;
> + struct list_head *pos, *n;
> + struct eficonfig_boot_order *entry;
> +
> + printf(ANSI_CLEAR_CONSOLE ANSI_CURSOR_POSITION
> +"\n  ** Change Boot Order **\n"
> +ANSI_CURSOR_POSITION
> +"  Press UP/DOWN to move, +/- to change order"
> +ANSI_CURSOR_POSITION
> +"  Press SPACE to activate or deactivate the entry"
> +ANSI_CURSOR_POSITION
> +"  Select [Save] to complete, ESC/CTRL+C to quit"
> +ANSI_CURSOR_POSITION ANSI_CLEAR_LINE,
> +1, 1, efi_menu->count + 5, 1, efi_menu->count + 6, 1,
> +efi_menu->count + 7, 1,  efi_menu->count + 8, 1);
> +
> + /* draw boot option list */
> + list_for_each_safe(pos, n, _menu->list) {
> + entry = list_entry(pos, struct eficonfig_boot_order, list);
> + reverse = (entry->num == efi_menu->active);
> +
> + printf(ANSI_CURSOR_POSITION, entry->num + 4, 7);
> +
> + if (reverse)
> + puts(ANSI_COLOR_REVERSE);
> +
> + if (entry->num < efi_menu->count - 2) {
> + if (entry->active)
> + printf("[*]  ");
> + else
> + printf("[ ]  ");
> + }
> +
> + printf("%ls", entry->description);
> +
> + if (reverse)
> + puts(ANSI_COLOR_RESET);
> + }
> +}
> +
> +/**
> + * eficonfig_choice_change_boot_order() - handle the BootOrder update
> + *
> + * @efi_menu:pointer to the efimenu structure
> + * Return:   status code
> + */
> +static efi_status_t eficonfig_choice_change_boot_order(struct efimenu 
> *efi_menu)
> +{
> + int esc = 0;
> + struct list_head *pos, *n;
> + struct eficonfig_boot_order *tmp;
> + enum bootmenu_key key = KEY_NONE;
> + struct eficonfig_boot_order *entry;
> +
> + while (1) {
> + bootmenu_loop(NULL, , );
> +
> + 

Re: [PATCH] configs: stih410-b2260: Fix SYS_HZ_CLOCK value

2022-08-24 Thread Grzegorz Szymaszek
Hi,

On Wed, Aug 24, 2022 at 05:06:59PM +0200, Patrice Chotard wrote:
> SYS_HZ_CLOCK was wrongly set to 1MHz whereas it's set to 750MHz
> by default by bootrom.

s/1MHz/1GHz/, it seems. Otherwise:
Reviewed-by: Grzegorz Szymaszek 


All the best

-- 
Grzegorz


signature.asc
Description: PGP signature


Re: [PATCH v4 1/8] binman: add support for skipping file concatenation for mkimage

2022-08-24 Thread Quentin Schulz

Hi Simon,

On 8/18/22 10:17, Simon Glass wrote:

Hi Quentin,

On Wed, 3 Aug 2022 at 06:19, Quentin Schulz  wrote:


From: Quentin Schulz 

Some image types handled by mkimage require the datafiles to be passed
independently (-d data1:data2) for specific handling of each. A
concatenation of datafiles prior to passing them to mkimage wouldn't
work.

That is the case for rkspi for example which requires page alignment
and only writing 2KB every 4KB.

This adds the ability to tell binman to pass the datafiles without
prior concatenation to mkimage, by adding the multiple-data-files
boolean property to the mkimage node.

Cc: Quentin Schulz 
Reviewed-by: Simon Glass 
Signed-off-by: Quentin Schulz 
---
  tools/binman/entries.rst  | 22 +++
  tools/binman/etype/mkimage.py | 41 +++
  2 files changed, 59 insertions(+), 4 deletions(-)


Somehow I missed this one, sorry.

It needs a test (try 'binman test -T' to see that it breaks code coverage).



How do you see this test being implemented?

I think it'd be best to mock calls to mkimage (or 
self.mkimage.run_cmd()) and check that the -d parameter has two entries 
separated by a colon but my limited knowledge of unittest.mock does not 
seem to guide me to the proper implementation.


Another way would be to use a specific mkimage type that handles that 
kind of multiple files -d parameter and outputs something more or less 
reproducible, e.g. rkspi type. I don't like this too much even though 
it's much easier because we're bound to this type and the image type 
could change (I recall some endianness fixes a few months ago).


Cheers,
Quentin


[PATCHv2 1/2] i2c: stm32f7: fix clearing the control register

2022-08-24 Thread Jorge Ramirez-Ortiz
Bits should be set to 0, not 1.

Signed-off-by: Jorge Ramirez-Ortiz 
Reviewed-by: Patrice Chotard 

---
 drivers/i2c/stm32f7_i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c
index bf2a6c9b4b..3a727e68ac 100644
--- a/drivers/i2c/stm32f7_i2c.c
+++ b/drivers/i2c/stm32f7_i2c.c
@@ -413,7 +413,7 @@ static int stm32_i2c_check_end_of_message(struct 
stm32_i2c_priv *i2c_priv)
setbits_le32(>icr, STM32_I2C_ICR_STOPCF);
 
/* Clear control register 2 */
-   setbits_le32(>cr2, STM32_I2C_CR2_RESET_MASK);
+   clrbits_le32(>cr2, STM32_I2C_CR2_RESET_MASK);
}
 
return ret;
-- 
2.34.1



Re: [PATCHv2 1/2] i2c: stm32f7: fix clearing the control register

2022-08-24 Thread Patrice CHOTARD
Hi Jorge

On 8/15/22 16:52, Jorge Ramirez-Ortiz wrote:
> Bits should be set to 0, not 1.
> 
> Signed-off-by: Jorge Ramirez-Ortiz 
> ---
>  drivers/i2c/stm32f7_i2c.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c
> index bf2a6c9b4b..3a727e68ac 100644
> --- a/drivers/i2c/stm32f7_i2c.c
> +++ b/drivers/i2c/stm32f7_i2c.c
> @@ -413,7 +413,7 @@ static int stm32_i2c_check_end_of_message(struct 
> stm32_i2c_priv *i2c_priv)
>   setbits_le32(>icr, STM32_I2C_ICR_STOPCF);
>  
>   /* Clear control register 2 */
> - setbits_le32(>cr2, STM32_I2C_CR2_RESET_MASK);
> + clrbits_le32(>cr2, STM32_I2C_CR2_RESET_MASK);
>   }
>  
>   return ret;


Reviewed-by: Patrice Chotard 
Thanks
Patrice


Re: [PATCH] ARM: stm32: Switch DHSOM to FMC2 EBI driver

2022-08-24 Thread Patrice CHOTARD
Hi Marek

On 8/23/22 19:27, Marek Vasut wrote:
> Perform long overdue conversion of ad-hoc FMC2 EBI bus initialization
> to upstream FMC2 EBI driver. No functional change.
> 
> Signed-off-by: Marek Vasut 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> ---
>  .../dts/stm32mp15xx-dhcom-picoitx-u-boot.dtsi |  8 ---
>  arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi| 14 -
>  .../stm32mp15xx-dhcor-drc-compact-u-boot.dtsi | 16 --
>  board/dhelectronics/dh_stm32mp1/board.c   | 52 ---
>  configs/stm32mp15_dhcom_basic_defconfig   |  1 +
>  configs/stm32mp15_dhcor_basic_defconfig   |  1 +
>  6 files changed, 2 insertions(+), 90 deletions(-)
> 
> diff --git a/arch/arm/dts/stm32mp15xx-dhcom-picoitx-u-boot.dtsi 
> b/arch/arm/dts/stm32mp15xx-dhcom-picoitx-u-boot.dtsi
> index 5bc6698f87f..0bcaec50198 100644
> --- a/arch/arm/dts/stm32mp15xx-dhcom-picoitx-u-boot.dtsi
> +++ b/arch/arm/dts/stm32mp15xx-dhcom-picoitx-u-boot.dtsi
> @@ -5,14 +5,6 @@
>  
>  #include "stm32mp15xx-dhcom-u-boot.dtsi"
>  
> -/ {
> - aliases {
> - /delete-property/ ethernet1;
> - };
> -};
> -
> -/delete-node/ 
> -
>  _hs {
>   dr_mode = "peripheral";
>  };
> diff --git a/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi 
> b/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi
> index ee747a52bb7..8a7156c93bf 100644
> --- a/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi
> +++ b/arch/arm/dts/stm32mp15xx-dhcom-u-boot.dtsi
> @@ -9,8 +9,6 @@
>  #include "stm32mp15-ddr3-dhsom-2x2Gb-1066-binG.dtsi"
>  #include "stm32mp15-ddr3-dhsom-2x4Gb-1066-binG.dtsi"
>  
> -/delete-node/ 
> -
>  / {
>   aliases {
>   i2c1 = 
> @@ -21,7 +19,6 @@
>   spi0 = 
>   usb0 = _hs;
>   eeprom0 = 
> - ethernet1 = 
>   };
>  
>   config {
> @@ -30,12 +27,6 @@
>   dh,som-coding-gpios = < 12 0>, < 13 0>, < 15 
> 0>;
>   dh,ddr3-coding-gpios = < 6 0>, < 7 0>;
>   };
> -
> - /* This is actually on FMC2, but we do not have bus driver for that */
> - ks8851: ks8851mll@6400 {
> - compatible = "micrel,ks8851-mll";
> - reg = <0x6400 0x2>;
> - };
>  };
>  
>   {
> @@ -74,11 +65,6 @@
>  };
>  
>   {
> - /* These should bound to FMC2 bus driver, but we do not have one */
> - pinctrl-0 = <_pins_b _pins_a>;
> - pinctrl-1 = <_sleep_pins_b _sleep_pins_a>;
> - pinctrl-names = "default", "sleep";
> -
>   mco2_pins_a: mco2-0 {
>   pins {
>   pinmux = ; /* MCO2 */
> diff --git a/arch/arm/dts/stm32mp15xx-dhcor-drc-compact-u-boot.dtsi 
> b/arch/arm/dts/stm32mp15xx-dhcor-drc-compact-u-boot.dtsi
> index 407fed56167..b6a6a78647a 100644
> --- a/arch/arm/dts/stm32mp15xx-dhcor-drc-compact-u-boot.dtsi
> +++ b/arch/arm/dts/stm32mp15xx-dhcor-drc-compact-u-boot.dtsi
> @@ -5,25 +5,16 @@
>  
>  #include "stm32mp15xx-dhcor-u-boot.dtsi"
>  
> -/delete-node/ 
> -
>  / {
>   aliases {
>   mmc0 = 
>   mmc1 = 
>   usb0 = _hs;
> - ethernet1 = 
>   };
>  
>   config {
>   dh,board-coding-gpios = < 9 0>, < 8 0>, < 3 
> 0>;
>   };
> -
> - /* This is actually on FMC2, but we do not have bus driver for that */
> - ks8851: ks8851mll@6400 {
> - compatible = "micrel,ks8851-mll";
> - reg = <0x6400 0x2>;
> - };
>  };
>  
>   {
> @@ -38,13 +29,6 @@
>   };
>  };
>  
> - {
> - /* These should bound to FMC2 bus driver, but we do not have one */
> - pinctrl-0 = <_pins_b>;
> - pinctrl-1 = <_sleep_pins_b>;
> - pinctrl-names = "default", "sleep";
> -};
> -
>   {
>   u-boot,dm-spl;
>   st,use-ckin;
> diff --git a/board/dhelectronics/dh_stm32mp1/board.c 
> b/board/dhelectronics/dh_stm32mp1/board.c
> index e3c7ed10492..9188f5381eb 100644
> --- a/board/dhelectronics/dh_stm32mp1/board.c
> +++ b/board/dhelectronics/dh_stm32mp1/board.c
> @@ -527,56 +527,6 @@ static void sysconf_init(void)
>  #endif
>  }
>  
> -static void board_init_fmc2(void)
> -{
> -#define STM32_FMC2_BCR1  0x0
> -#define STM32_FMC2_BTR1  0x4
> -#define STM32_FMC2_BWTR1 0x104
> -#define STM32_FMC2_BCR(x)((x) * 0x8 + STM32_FMC2_BCR1)
> -#define STM32_FMC2_BCRx_FMCENBIT(31)
> -#define STM32_FMC2_BCRx_WREN BIT(12)
> -#define STM32_FMC2_BCRx_RSVD BIT(7)
> -#define STM32_FMC2_BCRx_FACCEN   BIT(6)
> -#define STM32_FMC2_BCRx_MWID(n)  ((n) << 4)
> -#define STReviewed-by: Patrice Chotard 
> M32_FMC2_BCRx_MTYP(n)((n) << 2)
> -#define STM32_FMC2_BCRx_MUXENBIT(1)
> -#define STM32_FMC2_BCRx_MBKENBIT(0)
> -#define STM32_FMC2_BTR(x)((x) * 0x8 + STM32_FMC2_BTR1)
> -#define STM32_FMC2_BTRx_DATAHLD(n)   ((n) << 30)
> -#define STM32_FMC2_BTRx_BUSTURN(n)   ((n) << 16)
> -#define STM32_FMC2_BTRx_DATAST(n)((n) << 8)
> -#define 

Re: [PATCH v2 1/2] timer: sti: convert sti-timer to arm a9 global timer

2022-08-24 Thread Patrice CHOTARD
Hi William

On 8/24/22 06:44, William Zhang wrote:
> STI timer is actually ARM Cortex A9 global timer. Convert the driver to
> use generic global timer name and make it consistent with Linux kernel
> global timer driver. This also allows any A9 based device to use this
> driver.
> 
> Signed-off-by: William Zhang 
> ---
> 
> (no changes since v1)
> 
>  MAINTAINERS   |  2 +-
>  drivers/timer/Kconfig |  8 +++--
>  drivers/timer/Makefile|  2 +-
>  .../timer/{sti-timer.c => arm_global_timer.c} | 30 ++-
>  4 files changed, 23 insertions(+), 19 deletions(-)
>  rename drivers/timer/{sti-timer.c => arm_global_timer.c} (66%)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 1103bb068154..f7d77bb8cfa9 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -503,7 +503,7 @@ F:drivers/mmc/sti_sdhci.c
>  F:   drivers/reset/sti-reset.c
>  F:   drivers/serial/serial_sti_asc.c
>  F:   drivers/sysreset/sysreset_sti.c
> -F:   drivers/timer/sti-timer.c
> +F:   drivers/timer/arm_global_timer.c
>  F:   drivers/usb/host/dwc3-sti-glue.c
>  F:   include/dwc3-sti-glue.h
>  F:   include/dt-bindings/clock/stih407-clks.h
> diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
> index 20b5af7e260f..3e1d70fbb930 100644
> --- a/drivers/timer/Kconfig
> +++ b/drivers/timer/Kconfig
> @@ -215,12 +215,14 @@ config SANDBOX_TIMER
> Select this to enable an emulated timer for sandbox. It gets
> time from host os.
>  
> -config STI_TIMER
> - bool "STi timer support"
> +config ARM_GLOBAL_TIMER
> + bool "ARM Cortex A9 global timer support"
>   depends on TIMER
> + depends on ARM
>   default y if ARCH_STI
>   help
> -   Select this to enable a timer for STi devices.
> +   Select this to enable global timer found on ARM Cortex A9
> +   based devices.
>  
>  config STM32_TIMER
>   bool "STM32 timer support"
> diff --git a/drivers/timer/Makefile b/drivers/timer/Makefile
> index d9822a537009..d23569365408 100644
> --- a/drivers/timer/Makefile
> +++ b/drivers/timer/Makefile
> @@ -22,7 +22,7 @@ obj-$(CONFIG_RISCV_TIMER) += riscv_timer.o
>  obj-$(CONFIG_ROCKCHIP_TIMER) += rockchip_timer.o
>  obj-$(CONFIG_SANDBOX_TIMER)  += sandbox_timer.o
>  obj-$(CONFIG_$(SPL_)SIFIVE_CLINT) += sifive_clint_timer.o
> -obj-$(CONFIG_STI_TIMER)  += sti-timer.o
> +obj-$(CONFIG_ARM_GLOBAL_TIMER)   += arm_global_timer.o
>  obj-$(CONFIG_STM32_TIMER)+= stm32_timer.o
>  obj-$(CONFIG_X86_TSC_TIMER)  += tsc_timer.o
>  obj-$(CONFIG_MTK_TIMER)  += mtk_timer.o
> diff --git a/drivers/timer/sti-timer.c b/drivers/timer/arm_global_timer.c
> similarity index 66%
> rename from drivers/timer/sti-timer.c
> rename to drivers/timer/arm_global_timer.c
> index 87444a0650f6..065f10bb742b 100644
> --- a/drivers/timer/sti-timer.c
> +++ b/drivers/timer/arm_global_timer.c
> @@ -2,6 +2,8 @@
>  /*
>   * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
>   * Author(s): Patrice Chotard,  for 
> STMicroelectronics.
> + *
> + * ARM Cortext A9 global timer driver
>   */
>  
>  #include 
> @@ -13,13 +15,13 @@
>  #include 
>  #include 
>  
> -struct sti_timer_priv {
> +struct arm_global_timer_priv {
>   struct globaltimer *global_timer;
>  };
>  
> -static u64 sti_timer_get_count(struct udevice *dev)
> +static u64 arm_global_timer_get_count(struct udevice *dev)
>  {
> - struct sti_timer_priv *priv = dev_get_priv(dev);
> + struct arm_global_timer_priv *priv = dev_get_priv(dev);
>   struct globaltimer *global_timer = priv->global_timer;
>   u32 low, high;
>   u64 timer;
> @@ -37,10 +39,10 @@ static u64 sti_timer_get_count(struct udevice *dev)
>   return (u64)((timer << 32) | low);
>  }
>  
> -static int sti_timer_probe(struct udevice *dev)
> +static int arm_global_timer_probe(struct udevice *dev)
>  {
>   struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
> - struct sti_timer_priv *priv = dev_get_priv(dev);
> + struct arm_global_timer_priv *priv = dev_get_priv(dev);
>   struct clk clk;
>   int err;
>   ulong ret;
> @@ -66,20 +68,20 @@ static int sti_timer_probe(struct udevice *dev)
>   return 0;
>  }
>  
> -static const struct timer_ops sti_timer_ops = {
> - .get_count = sti_timer_get_count,
> +static const struct timer_ops arm_global_timer_ops = {
> + .get_count = arm_global_timer_get_count,
>  };
>  
> -static const struct udevice_id sti_timer_ids[] = {
> +static const struct udevice_id arm_global_timer_ids[] = {
>   { .compatible = "arm,cortex-a9-global-timer" },
>   {}
>  };
>  
> -U_BOOT_DRIVER(sti_timer) = {
> - .name = "sti_timer",
> +U_BOOT_DRIVER(arm_global_timer) = {
> + .name = "arm_global_timer",
>   .id = UCLASS_TIMER,
> - .of_match = sti_timer_ids,
> - .priv_auto  = sizeof(struct sti_timer_priv),
> - .probe = sti_timer_probe,
> - .ops = _timer_ops,
> + .of_match = 

[PATCH] configs: stih410-b2260: Fix SYS_HZ_CLOCK value

2022-08-24 Thread Patrice Chotard
SYS_HZ_CLOCK was wrongly set to 1MHz whereas it's set to 750MHz
by default by bootrom.

Signed-off-by: Patrice Chotard 
---

 include/configs/stih410-b2260.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/stih410-b2260.h b/include/configs/stih410-b2260.h
index b1a011bacb..1e966a2322 100644
--- a/include/configs/stih410-b2260.h
+++ b/include/configs/stih410-b2260.h
@@ -14,7 +14,7 @@
 #define CONFIG_SYS_SDRAM_BASE  PHYS_SDRAM_1
 #define PHYS_SDRAM_1_SIZE  0x3E00
 
-#define CONFIG_SYS_HZ_CLOCK10  /* 1 GHz */
+#define CONFIG_SYS_HZ_CLOCK75000   /* 750 MHz */
 
 /* Environment */
 
-- 
2.25.1



Using SYS_FLASH_AUTOPROTECT_LIST

2022-08-24 Thread Sergei Antonov
Hello!
Should CONFIG_SYS_FLASH_AUTOPROTECT_LIST be added to
scripts/config_whitelist.txt ?
I am trying to use it to auto-protect a critical area of flash and
'make' fails on config check:

 Error: You must add new CONFIG options using Kconfig
The following new ad-hoc CONFIG options were detected:
CONFIG_SYS_FLASH_AUTOPROTECT_LIST


Re: [PATCH v13 1/9] eficonfig: menu-driven addition of UEFI boot option

2022-08-24 Thread Ilias Apalodimas
Kojima-san,

[...]

> +
> +/**
> + * eficonfig_init() - do required initialization for eficonfig command
> + *
> + * Return:   status code
> + */
> +static efi_status_t eficonfig_init(void)
> +{
> + efi_status_t ret;


You need to initialize ret here to something.

> + static bool init;
> + struct efi_handler *handler;
> +
> + if (!init) {
> + ret = efi_search_protocol(efi_root, 
> _guid_text_input_protocol, );
> + if (ret != EFI_SUCCESS)
> + return ret;
> +
> + ret = efi_protocol_open(handler, (void **), efi_root, NULL,
> + EFI_OPEN_PROTOCOL_GET_PROTOCOL);
> + if (ret != EFI_SUCCESS)
> + return ret;
> + }

Because this code might never run

> +
> + init = true;
> +
> + return ret;
> +}
> +
> +static const struct eficonfig_item maintenance_menu_items[] = {
 
[...]


Regards
/Ilias


Re: [PATCH v13 5/9] bootmenu: add removable media entries

2022-08-24 Thread Ilias Apalodimas
Hi Kojima-san,

Apologies for doing the review ad-hoc, but the patchset is huge. 
I'll try to send a more complete email tomorrow

[...]
>  #endif
>  
> diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> index 537f3f2bbc..92171c4894 100644
> --- a/cmd/eficonfig.c
> +++ b/cmd/eficonfig.c
> @@ -1786,6 +1786,215 @@ static efi_status_t 
> eficonfig_process_delete_boot_option(void *data)
>   return ret;
>  }
>  
> +/**
> + * eficonfig_enumerate_boot_option() - enumerate the possible bootable media
> + *
> + * @opt: pointer to the media boot option structure
> + * @volume_handles:  pointer to the efi handles
> + * @count:   number of efi handle
> + * Return:   status code
> + */
> +efi_status_t eficonfig_enumerate_boot_option(struct 
> eficonfig_media_boot_option *opt,
> +  efi_handle_t *volume_handles, 
> efi_status_t count)
> +{
> + u32 i;
> + struct efi_handler *handler;
> + efi_status_t ret = EFI_SUCCESS;
> +
> + for (i = 0; i < count; i++) {
> + u16 *p;
> + u16 dev_name[BOOTMENU_DEVICE_NAME_MAX];
> + char *optional_data;
> + struct efi_load_option lo;
> + char buf[BOOTMENU_DEVICE_NAME_MAX];
> + struct efi_device_path *device_path;
> +
> + ret = efi_search_protocol(volume_handles[i], 
> _guid_device_path, );
> + if (ret != EFI_SUCCESS)
> + continue;
> + ret = efi_protocol_open(handler, (void **)_path,
> + efi_root, NULL, 
> EFI_OPEN_PROTOCOL_GET_PROTOCOL);
> + if (ret != EFI_SUCCESS)
> + continue;
> +
> + ret = efi_disk_get_device_name(volume_handles[i], buf, 
> BOOTMENU_DEVICE_NAME_MAX);
> + if (ret != EFI_SUCCESS)
> + continue;
> +
> + p = dev_name;
> + utf8_utf16_strncpy(, buf, strlen(buf));
> +
> + lo.label = dev_name;
> + lo.attributes = LOAD_OPTION_ACTIVE;
> + lo.file_path = device_path;
> + lo.file_path_length = efi_dp_size(device_path) + sizeof(END);
> + /*
> +  * Set the dedicated guid to optional_data, it is used to 
> identify
> +  * the boot option that automatically generated by the bootmenu.
> +  * efi_serialize_load_option() expects optional_data is 
> null-terminated
> +  * utf8 string, so set the "1234567" string to allocate enough 
> space
> +  * to store guid, instead of realloc the load_option.
> +  */
> + lo.optional_data = "1234567";
> + opt[i].size = efi_serialize_load_option(, (u8 **)[i].lo);
> + if (!opt[i].size) {
> + ret = EFI_OUT_OF_RESOURCES;
> + free(dev_name);

This is a stack allocated variable.

> + goto out;
> + }
> + /* set the guid */

[...]

Thanks
/Ilias


Re: [PATCH] spi: stm32_spi: Fix GPIO chipselect polarity handling

2022-08-24 Thread Patrice CHOTARD
Hi Marek

On 8/23/22 19:07, Marek Vasut wrote:
> The GPIO chipselect signal polarity is handled by the GPIO core code,
> the driver code is only responsible for asserting and deasserting the
> GPIO. Do not invert the GPIO polarity in the driver code.
> 
> For example, In case CS GPIO is active low, then the DT must contain
> GPIO_ACTIVE_LOW flag and the GPIO core code would set the GPIO accordingly.
> 
> Signed-off-by: Marek Vasut 
> Cc: Patrick Delaunay 
> Cc: Patrice Chotard 
> ---
>  drivers/spi/stm32_spi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/stm32_spi.c b/drivers/spi/stm32_spi.c
> index fe5419e8518..0cb24546ca9 100644
> --- a/drivers/spi/stm32_spi.c
> +++ b/drivers/spi/stm32_spi.c
> @@ -434,7 +434,7 @@ static int stm32_spi_xfer(struct udevice *slave, unsigned 
> int bitlen,
>  
>   slave_plat = dev_get_parent_plat(slave);
>   if (flags & SPI_XFER_BEGIN)
> - stm32_spi_set_cs(bus, slave_plat->cs, false);
> + stm32_spi_set_cs(bus, slave_plat->cs, true);
>  
>   /* Be sure to have data in fifo before starting data transfer */
>   if (priv->tx_buf)
> @@ -485,7 +485,7 @@ static int stm32_spi_xfer(struct udevice *slave, unsigned 
> int bitlen,
>   stm32_spi_stopxfer(bus);
>  
>   if (flags & SPI_XFER_END)
> - stm32_spi_set_cs(bus, slave_plat->cs, true);
> + stm32_spi_set_cs(bus, slave_plat->cs, false);
>  
>   return xfer_status;
>  }

It's a bit confusing as there is also the spi property "spi-cs-high" which also 
invert the polarity
in stm32_spi_set_cs() :

if (priv->cs_high)
enable = !enable;

return dm_gpio_set_value(>cs_gpios[cs], enable ? 1 : 0);

It's seems that chip select polarity can be managed at two different places.

Patrice


[PATCH v3 19/19] imx: kontron-sl-mx8mm: Prepare for I2C display detection in environment script

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

Enable the I2C bus and set a env variable for the reset GPIO of the touch
controller. This allows us to probe the panel in a script.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* none

Changes in v2:
* new patch
---
 arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi | 13 +++--
 arch/arm/dts/imx8mm-kontron-bl-osm-s-u-boot.dtsi  |  8 
 arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi|  8 
 board/kontron/sl-mx8mm/sl-mx8mm.c |  5 -
 4 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi 
b/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
index e7e900d4fa8..5b8b472159a 100644
--- a/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
@@ -48,8 +48,17 @@
 
  {
status = "okay";
-   u-boot,dm-spl;
-   u-boot,dm-pre-reloc;
+   pinctrl-names = "default";
+   pinctrl-0 = <_i2c2>;
+};
+
+ {
+   pinctrl_i2c2: i2c2grp {
+   fsl,pins = <
+   MX8MM_IOMUXC_I2C2_SCL_I2C2_SCL  0x41c3
+   MX8MM_IOMUXC_I2C2_SDA_I2C2_SDA  0x41c3
+   >;
+   };
 };
 
 _ecspi1 {
diff --git a/arch/arm/dts/imx8mm-kontron-bl-osm-s-u-boot.dtsi 
b/arch/arm/dts/imx8mm-kontron-bl-osm-s-u-boot.dtsi
index cd990b16720..fac24a21fbf 100644
--- a/arch/arm/dts/imx8mm-kontron-bl-osm-s-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-kontron-bl-osm-s-u-boot.dtsi
@@ -4,3 +4,11 @@
  */
 
 #include "imx8mm-kontron-bl-common-u-boot.dtsi"
+
+ {
+   pinctrl_touch: touchgrp {
+   fsl,pins = <
+   MX8MM_IOMUXC_SAI5_RXD2_GPIO3_IO23   0x19 /* Touch 
Reset */
+   >;
+   };
+};
diff --git a/arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi 
b/arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi
index cd990b16720..e9fa8d7b2a1 100644
--- a/arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi
@@ -4,3 +4,11 @@
  */
 
 #include "imx8mm-kontron-bl-common-u-boot.dtsi"
+
+ {
+   pinctrl_touch: touchgrp {
+   fsl,pins = <
+   MX8MM_IOMUXC_SAI1_TXD3_GPIO4_IO15   0x19 /* Touch 
Reset */
+   >;
+   };
+};
diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c 
b/board/kontron/sl-mx8mm/sl-mx8mm.c
index 641130112aa..4ac430b29a9 100644
--- a/board/kontron/sl-mx8mm/sl-mx8mm.c
+++ b/board/kontron/sl-mx8mm/sl-mx8mm.c
@@ -126,8 +126,11 @@ int board_late_init(void)
if (!fdt_node_check_compatible(gd->fdt_blob, 0, 
"kontron,imx8mm-n802x-som") ||
!fdt_node_check_compatible(gd->fdt_blob, 0, 
"kontron,imx8mm-osm-s")) {
env_set("som_type", "osm-s");
-   else
+   env_set("touch_rst_gpio", "111");
+   } else {
env_set("som_type", "sl");
+   env_set("touch_rst_gpio", "87");
+   }
 
return 0;
 }
-- 
2.37.2



[PATCH v3 18/19] imx: kontron-sl-mx8mm: Add support for Kontron Electronics SoM SL i.MX8MM OSM-S

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

This adds support for the Kontron Electronics SoM SL i.MX8MM OSM-S
and the matching baseboard BL i.MX8MM OSM-S.

The SoM hardware complies to the Open Standard Module (OSM) 1.0
specification, size S (https://sget.org/standards/osm).

The existing board configuration for the non-OSM SoM is reused and
allows to detect the SoM variant at runtime.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* fix OSM-S SoM name to match official name
* fix docs to match official board names
* adjust devicetree names and compatibles
* fix printing of RAM size
* add missing Makefile entry for new dtb
* fix hex numbers and unit addresses in SPI NOR partitions

Changes in v2:
* none
---
 arch/arm/dts/Makefile |   1 +
 .../dts/imx8mm-kontron-bl-common-u-boot.dtsi  | 139 +++
 .../dts/imx8mm-kontron-bl-osm-s-u-boot.dtsi   |   6 +
 arch/arm/dts/imx8mm-kontron-bl-osm-s.dts  | 376 ++
 arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi| 139 +--
 arch/arm/dts/imx8mm-kontron-osm-s.dtsi| 330 +++
 board/kontron/sl-mx8mm/sl-mx8mm.c |   7 +-
 board/kontron/sl-mx8mm/spl.c  |  25 +-
 configs/kontron-sl-mx8mm_defconfig|   2 +
 doc/board/kontron/sl-mx8mm.rst|  13 +-
 10 files changed, 893 insertions(+), 145 deletions(-)
 create mode 100644 arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-kontron-bl-osm-s-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-kontron-bl-osm-s.dts
 create mode 100644 arch/arm/dts/imx8mm-kontron-osm-s.dtsi

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 1e21dbcc7ec..93982968547 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -940,6 +940,7 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
imx8mm-icore-mx8mm-ctouch2.dtb \
imx8mm-icore-mx8mm-edimm2.2.dtb \
imx8mm-kontron-bl.dtb \
+   imx8mm-kontron-bl-osm-s.dtb \
imx8mm-mx8menlo.dtb \
imx8mm-venice.dtb \
imx8mm-venice-gw71xx-0x.dtb \
diff --git a/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi 
b/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
new file mode 100644
index 000..e7e900d4fa8
--- /dev/null
+++ b/arch/arm/dts/imx8mm-kontron-bl-common-u-boot.dtsi
@@ -0,0 +1,139 @@
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+/*
+ * Copyright (C) 2019 Kontron Electronics GmbH
+ */
+
+#include "imx8mm-u-boot.dtsi"
+
+/ {
+   aliases {
+   usb0 = 
+   usb1 = 
+   };
+
+   wdt-reboot {
+   compatible = "wdt-reboot";
+   wdt = <>;
+   u-boot,dm-spl;
+   };
+
+   firmware {
+   optee {
+   compatible = "linaro,optee-tz";
+   method = "smc";
+   };
+   };
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+_jr0 {
+   u-boot,dm-spl;
+};
+
+_jr1 {
+   u-boot,dm-spl;
+};
+
+_jr2 {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+};
+
+ {
+   status = "okay";
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+};
+
+_ecspi1 {
+   u-boot,dm-spl;
+};
+
+_i2c1 {
+   u-boot,dm-spl;
+};
+
+_pmic {
+   u-boot,dm-spl;
+};
+
+_uart3 {
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+};
+
+_usdhc1 {
+   u-boot,dm-spl;
+};
+
+_usdhc1_100mhz {
+   u-boot,dm-spl;
+};
+
+_usdhc1_200mhz {
+   u-boot,dm-spl;
+};
+
+_usdhc2 {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+&{/soc@0/bus@3080/i2c@30a2/pmic@25/regulators} {
+   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-pre-reloc;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+_wdog {
+   u-boot,dm-spl;
+};
diff --git a/arch/arm/dts/imx8mm-kontron-bl-osm-s-u-boot.dtsi 
b/arch/arm/dts/imx8mm-kontron-bl-osm-s-u-boot.dtsi
new file mode 100644
index 000..cd990b16720
--- /dev/null
+++ b/arch/arm/dts/imx8mm-kontron-bl-osm-s-u-boot.dtsi
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+/*
+ * Copyright (C) 2022 Kontron Electronics GmbH
+ */
+
+#include "imx8mm-kontron-bl-common-u-boot.dtsi"
diff --git a/arch/arm/dts/imx8mm-kontron-bl-osm-s.dts 
b/arch/arm/dts/imx8mm-kontron-bl-osm-s.dts
new file mode 100644
index 000..8b16bd68576
--- /dev/null
+++ b/arch/arm/dts/imx8mm-kontron-bl-osm-s.dts
@@ -0,0 +1,376 @@
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+/*
+ * Copyright (C) 2022 Kontron Electronics GmbH
+ */
+
+/dts-v1/;
+
+#include "imx8mm-kontron-osm-s.dtsi"
+
+/ {
+   model = "Kontron BL i.MX8MM OSM-S (N802X S)";
+   compatible = "kontron,imx8mm-bl-osm-s", "kontron,imx8mm-osm-s", 
"fsl,imx8mm";
+
+   

[PATCH v3 17/19] imx: kontron-sl-mx8mm: Simplify code in spl.c

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

Refactor the code a bit without any functional changes.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* fix printing of RAM size

Changes in v2:
* fix printf warning
* remove unused pinmux definitions
---
 board/kontron/sl-mx8mm/spl.c | 31 ++-
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/board/kontron/sl-mx8mm/spl.c b/board/kontron/sl-mx8mm/spl.c
index 00e63659f4a..403ab9a3ea2 100644
--- a/board/kontron/sl-mx8mm/spl.c
+++ b/board/kontron/sl-mx8mm/spl.c
@@ -39,11 +39,6 @@ static iomux_v3_cfg_t const i2c1_pads[] = {
IMX8MM_PAD_I2C1_SDA_I2C1_SDA | MUX_PAD_CTRL(I2C_PAD_CTRL) | 
MUX_MODE_SION
 };
 
-static iomux_v3_cfg_t const i2c2_pads[] = {
-   IMX8MM_PAD_I2C2_SCL_I2C2_SCL | MUX_PAD_CTRL(I2C_PAD_CTRL) | 
MUX_MODE_SION,
-   IMX8MM_PAD_I2C2_SDA_I2C2_SDA | MUX_PAD_CTRL(I2C_PAD_CTRL) | 
MUX_MODE_SION
-};
-
 int spl_board_boot_device(enum boot_device boot_dev_spl)
 {
switch (boot_dev_spl) {
@@ -109,41 +104,27 @@ static void spl_dram_init(void)
size = 1;
}
 
-   printf("Kontron SL i.MX8MM (N801X) module, %u GB RAM detected\n", size);
+   gd->ram_size = size;
writel(size, M4_BOOTROM_BASE_ADDR);
 }
 
-static int i2c_detect(u8 bus, u16 addr)
-{
-   struct udevice *udev;
-   int ret;
-
-   /*
-* Try to probe the touch controller to check if an LVDS panel is
-* connected.
-*/
-   ret = i2c_get_chip_for_busnum(bus, addr, 0, );
-   if (ret == 0)
-   return 0;
-
-   return 1;
-}
-
 int do_board_detect(void)
 {
+   gd->board_type = BOARD_TYPE_KTN_N801X;
+   printf("Kontron SL i.MX8MM (N801X) module, %u GB RAM detected\n",
+  (unsigned int)gd->ram_size);
+
/*
 * Check the I2C PMIC to detect the deprecated SoM with DA9063.
 */
imx_iomux_v3_setup_multiple_pads(i2c1_pads, ARRAY_SIZE(i2c1_pads));
 
-   if (i2c_detect(0, 0x58) == 0) {
+   if (i2c_get_chip_for_busnum(0, 0x58, 0, ) == 0) {
printf("### ATTENTION: DEPRECATED SOM REVISION (N8010 Rev0) 
DETECTED! ###\n");
printf("###  THIS HW IS NOT SUPPORTED AND BOOTING WILL PROBABLY 
FAIL  ###\n");
printf("### PLEASE UPGRADE TO LATEST MODULE 
  ###\n");
}
 
-   gd->board_type = BOARD_TYPE_KTN_N801X;
-
return 0;
 }
 
-- 
2.37.2



[PATCH v3 16/19] imx: kontron-sl-mx8mm: Use voltage rail names from schematic for PMIC regulator-names

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

Improve the naming of the regulators to contain the voltage rail
names from the schematic.

Suggested-by: Heiko Thiery 
Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* none

Changes in v2:
* none
---
 arch/arm/dts/imx8mm-kontron-sl.dtsi | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/arm/dts/imx8mm-kontron-sl.dtsi 
b/arch/arm/dts/imx8mm-kontron-sl.dtsi
index 7cfa7473475..0679728d248 100644
--- a/arch/arm/dts/imx8mm-kontron-sl.dtsi
+++ b/arch/arm/dts/imx8mm-kontron-sl.dtsi
@@ -106,7 +106,7 @@
 
regulators {
reg_vdd_soc: BUCK1 {
-   regulator-name = "buck1";
+   regulator-name = "+0V8_VDD_SOC (BUCK1)";
regulator-min-microvolt = <80>;
regulator-max-microvolt = <85>;
regulator-boot-on;
@@ -117,7 +117,7 @@
};
 
reg_vdd_arm: BUCK2 {
-   regulator-name = "buck2";
+   regulator-name = "+0V9_VDD_ARM (BUCK2)";
regulator-min-microvolt = <85>;
regulator-max-microvolt = <95>;
regulator-boot-on;
@@ -128,7 +128,7 @@
};
 
reg_vdd_dram: BUCK3 {
-   regulator-name = "buck3";
+   regulator-name = "+0V9_VDD_DRAM (BUCK3)";
regulator-min-microvolt = <85>;
regulator-max-microvolt = <95>;
regulator-boot-on;
@@ -136,7 +136,7 @@
};
 
reg_vdd_3v3: BUCK4 {
-   regulator-name = "buck4";
+   regulator-name = "+3V3 (BUCK4)";
regulator-min-microvolt = <330>;
regulator-max-microvolt = <330>;
regulator-boot-on;
@@ -144,7 +144,7 @@
};
 
reg_vdd_1v8: BUCK5 {
-   regulator-name = "buck5";
+   regulator-name = "+1V8 (BUCK5)";
regulator-min-microvolt = <180>;
regulator-max-microvolt = <180>;
regulator-boot-on;
@@ -152,7 +152,7 @@
};
 
reg_nvcc_dram: BUCK6 {
-   regulator-name = "buck6";
+   regulator-name = "+1V1_NVCC_DRAM (BUCK6)";
regulator-min-microvolt = <110>;
regulator-max-microvolt = <110>;
regulator-boot-on;
@@ -160,7 +160,7 @@
};
 
reg_nvcc_snvs: LDO1 {
-   regulator-name = "ldo1";
+   regulator-name = "+1V8_NVCC_SNVS (LDO1)";
regulator-min-microvolt = <180>;
regulator-max-microvolt = <180>;
regulator-boot-on;
@@ -168,7 +168,7 @@
};
 
reg_vdd_snvs: LDO2 {
-   regulator-name = "ldo2";
+   regulator-name = "+0V8_VDD_SNVS (LDO2)";
regulator-min-microvolt = <80>;
regulator-max-microvolt = <90>;
regulator-boot-on;
@@ -176,7 +176,7 @@
};
 
reg_vdda: LDO3 {
-   regulator-name = "ldo3";
+   regulator-name = "+1V8_VDDA (LDO3)";
regulator-min-microvolt = <180>;
regulator-max-microvolt = <180>;
regulator-boot-on;
@@ -184,7 +184,7 @@
};
 
reg_vdd_phy: LDO4 {
-   regulator-name = "ldo4";
+   regulator-name = "+0V9_VDD_PHY (LDO4)";
regulator-min-microvolt = <90>;
regulator-max-microvolt = <90>;
regulator-boot-on;
@@ -192,7 +192,7 @@
};
 
reg_nvcc_sd: LDO5 {
-   regulator-name = "ldo5";
+   regulator-name = "NVCC_SD (LDO5)";
regulator-min-microvolt = <180>;
 

[PATCH v3 14/19] imx: kontron-sl-mx8mm: Adjust devicetree names, compatibles and model strings

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

This adjusts the names of the boards and SoMs to the official naming
used by Kontron marketing. These changes also affect devicetree
names and compatibles. The same changes have been submitted to the
Linux kernel.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* also rename devicetree files and compatibles

Changes in v2:
* none
---
 arch/arm/dts/Makefile   | 2 +-
 ...on-n801x-s-u-boot.dtsi => imx8mm-kontron-bl-u-boot.dtsi} | 0
 .../{imx8mm-kontron-n801x-s.dts => imx8mm-kontron-bl.dts}   | 6 +++---
 ...imx8mm-kontron-n801x-som.dtsi => imx8mm-kontron-sl.dtsi} | 4 ++--
 board/kontron/sl-mx8mm/MAINTAINERS  | 2 +-
 board/kontron/sl-mx8mm/spl.c| 3 ++-
 configs/kontron-sl-mx8mm_defconfig  | 2 +-
 7 files changed, 10 insertions(+), 9 deletions(-)
 rename arch/arm/dts/{imx8mm-kontron-n801x-s-u-boot.dtsi => 
imx8mm-kontron-bl-u-boot.dtsi} (100%)
 rename arch/arm/dts/{imx8mm-kontron-n801x-s.dts => imx8mm-kontron-bl.dts} (97%)
 rename arch/arm/dts/{imx8mm-kontron-n801x-som.dtsi => imx8mm-kontron-sl.dtsi} 
(98%)

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 75d0664cc01..1e21dbcc7ec 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -939,7 +939,7 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
imx8mm-evk.dtb \
imx8mm-icore-mx8mm-ctouch2.dtb \
imx8mm-icore-mx8mm-edimm2.2.dtb \
-   imx8mm-kontron-n801x-s.dtb \
+   imx8mm-kontron-bl.dtb \
imx8mm-mx8menlo.dtb \
imx8mm-venice.dtb \
imx8mm-venice-gw71xx-0x.dtb \
diff --git a/arch/arm/dts/imx8mm-kontron-n801x-s-u-boot.dtsi 
b/arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi
similarity index 100%
rename from arch/arm/dts/imx8mm-kontron-n801x-s-u-boot.dtsi
rename to arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi
diff --git a/arch/arm/dts/imx8mm-kontron-n801x-s.dts 
b/arch/arm/dts/imx8mm-kontron-bl.dts
similarity index 97%
rename from arch/arm/dts/imx8mm-kontron-n801x-s.dts
rename to arch/arm/dts/imx8mm-kontron-bl.dts
index 23be1ec538b..ca533baedcd 100644
--- a/arch/arm/dts/imx8mm-kontron-n801x-s.dts
+++ b/arch/arm/dts/imx8mm-kontron-bl.dts
@@ -5,11 +5,11 @@
 
 /dts-v1/;
 
-#include "imx8mm-kontron-n801x-som.dtsi"
+#include "imx8mm-kontron-sl.dtsi"
 
 / {
-   model = "Kontron i.MX8MM N801X S";
-   compatible = "kontron,imx8mm-n801x-s", "kontron,imx8mm-n801x-som", 
"fsl,imx8mm";
+   model = "Kontron BL i.MX8MM (N801X S)";
+   compatible = "kontron,imx8mm-bl", "kontron,imx8mm-sl", "fsl,imx8mm";
 
aliases {
ethernet1 = 
diff --git a/arch/arm/dts/imx8mm-kontron-n801x-som.dtsi 
b/arch/arm/dts/imx8mm-kontron-sl.dtsi
similarity index 98%
rename from arch/arm/dts/imx8mm-kontron-n801x-som.dtsi
rename to arch/arm/dts/imx8mm-kontron-sl.dtsi
index 39c0ce19ef1..11a50cffc8c 100644
--- a/arch/arm/dts/imx8mm-kontron-n801x-som.dtsi
+++ b/arch/arm/dts/imx8mm-kontron-sl.dtsi
@@ -6,8 +6,8 @@
 #include "imx8mm.dtsi"
 
 / {
-   model = "Kontron i.MX8MM N801X SoM";
-   compatible = "kontron,imx8mm-n801x-som", "fsl,imx8mm";
+   model = "Kontron SL i.MX8MM (N801X SOM)";
+   compatible = "kontron,imx8mm-sl", "fsl,imx8mm";
 
memory@4000 {
device_type = "memory";
diff --git a/board/kontron/sl-mx8mm/MAINTAINERS 
b/board/kontron/sl-mx8mm/MAINTAINERS
index 5e68ae0305a..e4e12d3f558 100644
--- a/board/kontron/sl-mx8mm/MAINTAINERS
+++ b/board/kontron/sl-mx8mm/MAINTAINERS
@@ -1,7 +1,7 @@
 Kontron SL/BL i.MX8M Mini Boards (N801x)
 M: Frieder Schrempf 
 S: Maintained
-F: arch/arm/dts/imx8mm-kontron-n801x-*
+F: arch/arm/dts/imx8mm-kontron*
 F: board/kontron/sl-mx8mm
 F: configs/kontron-sl-mx8mm_defconfig
 F: doc/board/kontron/sl-mx8mm.rst
diff --git a/board/kontron/sl-mx8mm/spl.c b/board/kontron/sl-mx8mm/spl.c
index affdc136e10..00e63659f4a 100644
--- a/board/kontron/sl-mx8mm/spl.c
+++ b/board/kontron/sl-mx8mm/spl.c
@@ -150,7 +150,8 @@ int do_board_detect(void)
 int board_fit_config_name_match(const char *name)
 {
if (gd->board_type == BOARD_TYPE_KTN_N801X && is_imx8mm() &&
-   !strncmp(name, "imx8mm-kontron-n801x-s", 22))
+   (!strcmp(name, "imx8mm-kontron-n801x-s") ||
+!strcmp(name, "imx8mm-kontron-bl")))
return 0;
 
return -1;
diff --git a/configs/kontron-sl-mx8mm_defconfig 
b/configs/kontron-sl-mx8mm_defconfig
index a5c48a3fbca..b55243cf31b 100644
--- a/configs/kontron-sl-mx8mm_defconfig
+++ b/configs/kontron-sl-mx8mm_defconfig
@@ -11,7 +11,7 @@ CONFIG_ENV_SECT_SIZE=0x1
 CONFIG_IMX_CONFIG="board/kontron/sl-mx8mm/imximage.cfg"
 CONFIG_DM_GPIO=y
 CONFIG_SPL_DM_SPI=y
-CONFIG_DEFAULT_DEVICE_TREE="imx8mm-kontron-n801x-s"
+CONFIG_DEFAULT_DEVICE_TREE="imx8mm-kontron-bl"
 CONFIG_SPL_TEXT_BASE=0x7E1000
 CONFIG_TARGET_KONTRON_MX8MM=y
 CONFIG_SPL_MMC=y
-- 
2.37.2



[PATCH v3 15/19] imx: kontron-sl-mx8mm: Use the VSELECT signal to switch SD card IO voltage

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

It turns out that it is not necessary to declare the VSELECT signal as
GPIO and let the PMIC driver set it to a fixed high level. This switches
the voltage between 3.3V and 1.8V by setting the PMIC register for LDO5
accordingly.

Instead we can do it like other boards already do and simply mux the
VSELECT signal of the USDHC interface to the pin. This makes sure that
the correct voltage is selected by setting the PMIC's SD_VSEL input
to high or low accordingly.

Reported-by: Heiko Thiery 
Signed-off-by: Frieder Schrempf 
Reviewed-by: Heiko Thiery 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* none

Changes in v2:
* add Heiko's R-b tag (thanks!)
---
 arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi | 5 -
 arch/arm/dts/imx8mm-kontron-bl.dts | 3 +++
 arch/arm/dts/imx8mm-kontron-sl.dtsi| 2 --
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi 
b/arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi
index 2c62f05cec1..a42881d1a89 100644
--- a/arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi
+++ b/arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi
@@ -62,11 +62,6 @@
 
 _pmic {
u-boot,dm-spl;
-   fsl,pins = <
-   MX8MM_IOMUXC_GPIO1_IO00_GPIO1_IO0   0x141
-   /* Disable Pullup for SD_VSEL */
-   MX8MM_IOMUXC_GPIO1_IO04_GPIO1_IO4   0x41
-   >;
 };
 
 _uart3 {
diff --git a/arch/arm/dts/imx8mm-kontron-bl.dts 
b/arch/arm/dts/imx8mm-kontron-bl.dts
index ca533baedcd..a079322a379 100644
--- a/arch/arm/dts/imx8mm-kontron-bl.dts
+++ b/arch/arm/dts/imx8mm-kontron-bl.dts
@@ -321,6 +321,7 @@
MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d0
MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d0
MX8MM_IOMUXC_SD2_CD_B_GPIO2_IO120x019
+   MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT  0x1d0
>;
};
 
@@ -333,6 +334,7 @@
MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d4
MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d4
MX8MM_IOMUXC_SD2_CD_B_GPIO2_IO120x019
+   MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT  0x1d0
>;
};
 
@@ -345,6 +347,7 @@
MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2 0x1d6
MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3 0x1d6
MX8MM_IOMUXC_SD2_CD_B_GPIO2_IO120x019
+   MX8MM_IOMUXC_GPIO1_IO04_USDHC2_VSELECT  0x1d0
>;
};
 };
diff --git a/arch/arm/dts/imx8mm-kontron-sl.dtsi 
b/arch/arm/dts/imx8mm-kontron-sl.dtsi
index 11a50cffc8c..7cfa7473475 100644
--- a/arch/arm/dts/imx8mm-kontron-sl.dtsi
+++ b/arch/arm/dts/imx8mm-kontron-sl.dtsi
@@ -103,7 +103,6 @@
pinctrl-0 = <_pmic>;
interrupt-parent = <>;
interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
-   sd-vsel-gpios = < 4 GPIO_ACTIVE_HIGH>;
 
regulators {
reg_vdd_soc: BUCK1 {
@@ -246,7 +245,6 @@
pinctrl_pmic: pmicgrp {
fsl,pins = <
MX8MM_IOMUXC_GPIO1_IO00_GPIO1_IO0   0x141
-   MX8MM_IOMUXC_GPIO1_IO04_GPIO1_IO4   0x141
>;
};
 
-- 
2.37.2



[PATCH v3 13/19] imx: kontron-sl-mx8mm: Prepare for other i.MX8MM SoM types

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

This sets an env variable 'som_type' from the board code. It can
later be used by environment scripts, e. g. to select the proper
devicetree for the board.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* use "sl" instead of deprected "n801x" identifier

Changes in v2:
* add missing CONFIG_BOARD_LATE_INIT
---
 board/kontron/sl-mx8mm/sl-mx8mm.c  | 6 ++
 configs/kontron-sl-mx8mm_defconfig | 1 +
 2 files changed, 7 insertions(+)

diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c 
b/board/kontron/sl-mx8mm/sl-mx8mm.c
index 416c4cbb407..6e73edeb232 100644
--- a/board/kontron/sl-mx8mm/sl-mx8mm.c
+++ b/board/kontron/sl-mx8mm/sl-mx8mm.c
@@ -121,6 +121,12 @@ int board_init(void)
return 0;
 }
 
+int board_late_init(void)
+{
+   env_set("som_type", "sl");
+   return 0;
+}
+
 enum env_location env_get_location(enum env_operation op, int prio)
 {
enum boot_device boot_dev = get_boot_device();
diff --git a/configs/kontron-sl-mx8mm_defconfig 
b/configs/kontron-sl-mx8mm_defconfig
index 5dcee988478..a5c48a3fbca 100644
--- a/configs/kontron-sl-mx8mm_defconfig
+++ b/configs/kontron-sl-mx8mm_defconfig
@@ -31,6 +31,7 @@ CONFIG_SPL_LOAD_FIT=y
 # CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_BOARD_TYPES=y
+CONFIG_BOARD_LATE_INIT=y
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x91
 CONFIG_SPL_BSS_MAX_SIZE=0x2000
-- 
2.37.2



[PATCH v3 10/19] imx: kontron-sl-mx8mm: lpddr4_timing.c: Add spaces for proper alignment

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

Fix the spaces and alignment for easier tracking of changes and comparing
with configs generated by the tools.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* none

Changes in v2:
* none
---
 board/kontron/sl-mx8mm/lpddr4_timing.c | 2076 
 1 file changed, 1038 insertions(+), 1038 deletions(-)

diff --git a/board/kontron/sl-mx8mm/lpddr4_timing.c 
b/board/kontron/sl-mx8mm/lpddr4_timing.c
index 0eabb160185..a8dcaafb180 100644
--- a/board/kontron/sl-mx8mm/lpddr4_timing.c
+++ b/board/kontron/sl-mx8mm/lpddr4_timing.c
@@ -10,313 +10,313 @@
 
 struct dram_cfg_param ddr_ddrc_cfg[] = {
/** Initialize DDRC registers **/
-   {0x3d400304, 0x1},
-   {0x3d400030, 0x1},
-   {0x3d40, 0xa3080020},
-   {0x3d400020, 0x223},
-   {0x3d400024, 0x3a980},
-   {0x3d400064, 0x5b0087},
-   {0x3d4000d0, 0xc00305ba},
-   {0x3d4000d4, 0x94},
-   {0x3d4000dc, 0xd4002d},
-   {0x3d4000e0, 0x31},
-   {0x3d4000e8, 0x66004d},
-   {0x3d4000ec, 0x16004d},
-   {0x3d400100, 0x191e1920},
-   {0x3d400104, 0x60630},
-   {0x3d40010c, 0xb0b000},
-   {0x3d400110, 0xe04080e},
-   {0x3d400114, 0x2040c0c},
-   {0x3d400118, 0x1010007},
-   {0x3d40011c, 0x401},
-   {0x3d400130, 0x20600},
-   {0x3d400134, 0xc12},
-   {0x3d400138, 0xd8},
-   {0x3d400144, 0x96004b},
-   {0x3d400180, 0x2ee0017},
-   {0x3d400184, 0x2605b8e},
-   {0x3d400188, 0x0},
-   {0x3d400190, 0x497820a},
-   {0x3d400194, 0x80303},
-   {0x3d4001b4, 0x170a},
-   {0x3d4001a0, 0xe0400018},
-   {0x3d4001a4, 0xdf00e4},
-   {0x3d4001a8, 0x8000},
-   {0x3d4001b0, 0x11},
-   {0x3d4001c0, 0x1},
-   {0x3d4001c4, 0x1},
-   {0x3d4000f4, 0xc99},
-   {0x3d400108, 0x70e1617},
-   {0x3d400200, 0x17},
-   {0x3d40020c, 0x0},
-   {0x3d400210, 0x1f1f},
-   {0x3d400204, 0x80808},
-   {0x3d400214, 0x7070707},
-   {0x3d400218, 0x7070707},
-   {0x3d400250, 0x29001701},
-   {0x3d400254, 0x2c},
-   {0x3d40025c, 0x430},
-   {0x3d400264, 0x900093e7},
-   {0x3d40026c, 0x2005574},
-   {0x3d400400, 0x111},
-   {0x3d400408, 0x72ff},
-   {0x3d400494, 0x2100e07},
-   {0x3d400498, 0x620096},
-   {0x3d40049c, 0x1100e07},
-   {0x3d4004a0, 0xc8012c},
-   {0x3d402020, 0x21},
-   {0x3d402024, 0x7d00},
-   {0x3d402050, 0x20d040},
-   {0x3d402064, 0xc001c},
-   {0x3d4020dc, 0x84},
-   {0x3d4020e0, 0x31},
-   {0x3d4020e8, 0x66004d},
-   {0x3d4020ec, 0x16004d},
-   {0x3d402100, 0xa040305},
-   {0x3d402104, 0x30407},
-   {0x3d402108, 0x203060b},
-   {0x3d40210c, 0x505000},
-   {0x3d402110, 0x2040202},
-   {0x3d402114, 0x2030202},
-   {0x3d402118, 0x1010004},
-   {0x3d40211c, 0x301},
-   {0x3d402130, 0x20300},
-   {0x3d402134, 0xa12},
-   {0x3d402138, 0x1d},
-   {0x3d402144, 0x14000a},
-   {0x3d402180, 0x640004},
-   {0x3d402190, 0x3818200},
-   {0x3d402194, 0x80303},
-   {0x3d4021b4, 0x100},
-   {0x3d403020, 0x21},
-   {0x3d403024, 0x1f40},
-   {0x3d403050, 0x20d040},
-   {0x3d403064, 0x30007},
-   {0x3d4030dc, 0x84},
-   {0x3d4030e0, 0x31},
-   {0x3d4030e8, 0x66004d},
-   {0x3d4030ec, 0x16004d},
-   {0x3d403100, 0xa010102},
-   {0x3d403104, 0x30404},
-   {0x3d403108, 0x203060b},
-   {0x3d40310c, 0x505000},
-   {0x3d403110, 0x2040202},
-   {0x3d403114, 0x2030202},
-   {0x3d403118, 0x1010004},
-   {0x3d40311c, 0x301},
-   {0x3d403130, 0x20300},
-   {0x3d403134, 0xa12},
-   {0x3d403138, 0x8},
-   {0x3d403144, 0x50003},
-   {0x3d403180, 0x190004},
-   {0x3d403190, 0x3818200},
-   {0x3d403194, 0x80303},
-   {0x3d4031b4, 0x100},
-   {0x3d400028, 0x0},
+   { 0x3d400304, 0x1 },
+   { 0x3d400030, 0x1 },
+   { 0x3d40, 0xa3080020 },
+   { 0x3d400020, 0x223 },
+   { 0x3d400024, 0x3a980 },
+   { 0x3d400064, 0x5b0087 },
+   { 0x3d4000d0, 0xc00305ba },
+   { 0x3d4000d4, 0x94 },
+   { 0x3d4000dc, 0xd4002d },
+   { 0x3d4000e0, 0x31 },
+   { 0x3d4000e8, 0x66004d },
+   { 0x3d4000ec, 0x16004d },
+   { 0x3d400100, 0x191e1920 },
+   { 0x3d400104, 0x60630 },
+   { 0x3d40010c, 0xb0b000 },
+   { 0x3d400110, 0xe04080e },
+   { 0x3d400114, 0x2040c0c },
+   { 0x3d400118, 0x1010007 },
+   { 0x3d40011c, 0x401 },
+   { 0x3d400130, 0x20600 },
+   { 0x3d400134, 0xc12 },
+   { 0x3d400138, 0xd8 },
+   { 0x3d400144, 0x96004b },
+   { 0x3d400180, 0x2ee0017 },
+   { 0x3d400184, 0x2605b8e },
+   { 0x3d400188, 0x0 },
+   { 0x3d400190, 0x497820a },
+   { 0x3d400194, 0x80303 },
+   { 0x3d4001b4, 0x170a },
+   { 0x3d4001a0, 0xe0400018 },
+   { 0x3d4001a4, 0xdf00e4 },
+   { 0x3d4001a8, 

[PATCH v3 12/19] imx: kontron-sl-mx8mm: Use new LPDDR4 config parameters

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

These parameters are needed for stable performance on new hardware
with Nanya LPDDR4 chips.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* none

Changes in v2:
* none
---
 board/kontron/sl-mx8mm/lpddr4_timing.c | 184 +++--
 board/kontron/sl-mx8mm/spl.c   |   8 +-
 2 files changed, 55 insertions(+), 137 deletions(-)

diff --git a/board/kontron/sl-mx8mm/lpddr4_timing.c 
b/board/kontron/sl-mx8mm/lpddr4_timing.c
index cdde6ac0dc0..74b79c7a009 100644
--- a/board/kontron/sl-mx8mm/lpddr4_timing.c
+++ b/board/kontron/sl-mx8mm/lpddr4_timing.c
@@ -15,13 +15,13 @@ struct dram_cfg_param ddr_ddrc_cfg[] = {
{ 0x3d40, 0xa3080020 },
{ 0x3d400020, 0x223 },
{ 0x3d400024, 0x3a980 },
-   { 0x3d400064, 0x5b0087 },
+   { 0x3d400064, 0x5b00d2 },
{ 0x3d4000d0, 0xc00305ba },
{ 0x3d4000d4, 0x94 },
{ 0x3d4000dc, 0xd4002d },
{ 0x3d4000e0, 0x31 },
-   { 0x3d4000e8, 0x66004d },
-   { 0x3d4000ec, 0x16004d },
+   { 0x3d4000e8, 0x63004d },
+   { 0x3d4000ec, 0x15004d },
{ 0x3d400100, 0x191e1920 },
{ 0x3d400104, 0x60630 },
{ 0x3d40010c, 0xb0b000 },
@@ -88,30 +88,7 @@ struct dram_cfg_param ddr_ddrc_cfg[] = {
{ 0x3d402190, 0x3818200 },
{ 0x3d402194, 0x80303 },
{ 0x3d4021b4, 0x100 },
-   { 0x3d403020, 0x21 },
-   { 0x3d403024, 0x1f40 },
-   { 0x3d403050, 0x20d040 },
-   { 0x3d403064, 0x30007 },
-   { 0x3d4030dc, 0x84 },
-   { 0x3d4030e0, 0x31 },
-   { 0x3d4030e8, 0x66004d },
-   { 0x3d4030ec, 0x16004d },
-   { 0x3d403100, 0xa010102 },
-   { 0x3d403104, 0x30404 },
-   { 0x3d403108, 0x203060b },
-   { 0x3d40310c, 0x505000 },
-   { 0x3d403110, 0x2040202 },
-   { 0x3d403114, 0x2030202 },
-   { 0x3d403118, 0x1010004 },
-   { 0x3d40311c, 0x301 },
-   { 0x3d403130, 0x20300 },
-   { 0x3d403134, 0xa12 },
-   { 0x3d403138, 0x8 },
-   { 0x3d403144, 0x50003 },
-   { 0x3d403180, 0x190004 },
-   { 0x3d403190, 0x3818200 },
-   { 0x3d403194, 0x80303 },
-   { 0x3d4031b4, 0x100 },
+   { 0x3d4020f4, 0xc99 },
{ 0x3d400028, 0x0 },
 };
 
@@ -165,14 +142,6 @@ struct dram_cfg_param ddr_ddrphy_cfg[] = {
{ 0x11215f, 0x1ff },
{ 0x11305f, 0x1ff },
{ 0x11315f, 0x1ff },
-   { 0x21005f, 0x1ff },
-   { 0x21015f, 0x1ff },
-   { 0x21105f, 0x1ff },
-   { 0x21115f, 0x1ff },
-   { 0x21205f, 0x1ff },
-   { 0x21215f, 0x1ff },
-   { 0x21305f, 0x1ff },
-   { 0x21315f, 0x1ff },
{ 0x55, 0x1ff },
{ 0x1055, 0x1ff },
{ 0x2055, 0x1ff },
@@ -185,22 +154,16 @@ struct dram_cfg_param ddr_ddrphy_cfg[] = {
{ 0x9055, 0x1ff },
{ 0x200c5, 0x19 },
{ 0x1200c5, 0x7 },
-   { 0x2200c5, 0x7 },
{ 0x2002e, 0x2 },
{ 0x12002e, 0x2 },
-   { 0x22002e, 0x2 },
{ 0x90204, 0x0 },
{ 0x190204, 0x0 },
-   { 0x290204, 0x0 },
{ 0x20024, 0x1ab },
{ 0x2003a, 0x0 },
{ 0x120024, 0x1ab },
{ 0x2003a, 0x0 },
-   { 0x220024, 0x1ab },
-   { 0x2003a, 0x0 },
{ 0x20056, 0x3 },
{ 0x120056, 0x3 },
-   { 0x220056, 0x3 },
{ 0x1004d, 0xe00 },
{ 0x1014d, 0xe00 },
{ 0x1104d, 0xe00 },
@@ -217,54 +180,37 @@ struct dram_cfg_param ddr_ddrphy_cfg[] = {
{ 0x11214d, 0xe00 },
{ 0x11304d, 0xe00 },
{ 0x11314d, 0xe00 },
-   { 0x21004d, 0xe00 },
-   { 0x21014d, 0xe00 },
-   { 0x21104d, 0xe00 },
-   { 0x21114d, 0xe00 },
-   { 0x21204d, 0xe00 },
-   { 0x21214d, 0xe00 },
-   { 0x21304d, 0xe00 },
-   { 0x21314d, 0xe00 },
-   { 0x10049, 0xeba },
-   { 0x10149, 0xeba },
-   { 0x11049, 0xeba },
-   { 0x11149, 0xeba },
-   { 0x12049, 0xeba },
-   { 0x12149, 0xeba },
-   { 0x13049, 0xeba },
-   { 0x13149, 0xeba },
-   { 0x110049, 0xeba },
-   { 0x110149, 0xeba },
-   { 0x111049, 0xeba },
-   { 0x49, 0xeba },
-   { 0x112049, 0xeba },
-   { 0x112149, 0xeba },
-   { 0x113049, 0xeba },
-   { 0x113149, 0xeba },
-   { 0x210049, 0xeba },
-   { 0x210149, 0xeba },
-   { 0x211049, 0xeba },
-   { 0x211149, 0xeba },
-   { 0x212049, 0xeba },
-   { 0x212149, 0xeba },
-   { 0x213049, 0xeba },
-   { 0x213149, 0xeba },
-   { 0x43, 0x63 },
-   { 0x1043, 0x63 },
-   { 0x2043, 0x63 },
-   { 0x3043, 0x63 },
-   { 0x4043, 0x63 },
-   { 0x5043, 0x63 },
-   { 0x6043, 0x63 },
-   { 0x7043, 0x63 },
-   { 0x8043, 0x63 },
-   { 0x9043, 0x63 },
+   { 0x10049, 0x69a },
+   { 0x10149, 0x69a },
+   { 0x11049, 0x69a },
+   { 0x11149, 0x69a },
+   { 0x12049, 0x69a },
+   { 0x12149, 0x69a },
+   { 0x13049, 0x69a },
+   { 0x13149, 0x69a },
+   { 0x110049, 0x69a },
+   { 0x110149, 0x69a },
+  

[PATCH v3 11/19] imx: kontron-sl-mx8mm: Remove 100mt DDR setpoint

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

The new stable configuration is missing the 100mt setpoint, remove
it before updating the config to make sure the changes are separated
cleanly.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* none

Changes in v2:
* none
---
 arch/arm/dts/imx8mm-kontron-n801x-som.dtsi |  4 --
 board/kontron/sl-mx8mm/lpddr4_timing.c | 49 +-
 board/kontron/sl-mx8mm/spl.c   |  2 -
 3 files changed, 1 insertion(+), 54 deletions(-)

diff --git a/arch/arm/dts/imx8mm-kontron-n801x-som.dtsi 
b/arch/arm/dts/imx8mm-kontron-n801x-som.dtsi
index 3b66e560927..39c0ce19ef1 100644
--- a/arch/arm/dts/imx8mm-kontron-n801x-som.dtsi
+++ b/arch/arm/dts/imx8mm-kontron-n801x-som.dtsi
@@ -46,10 +46,6 @@
ddrc_opp_table: opp-table {
compatible = "operating-points-v2";
 
-   opp-25M {
-   opp-hz = /bits/ 64 <2500>;
-   };
-
opp-100M {
opp-hz = /bits/ 64 <1>;
};
diff --git a/board/kontron/sl-mx8mm/lpddr4_timing.c 
b/board/kontron/sl-mx8mm/lpddr4_timing.c
index a8dcaafb180..cdde6ac0dc0 100644
--- a/board/kontron/sl-mx8mm/lpddr4_timing.c
+++ b/board/kontron/sl-mx8mm/lpddr4_timing.c
@@ -1121,46 +1121,6 @@ struct dram_cfg_param ddr_fsp1_cfg[] = {
{ 0xd, 0x1 },
 };
 
-/* P2 message block paremeter for training firmware */
-struct dram_cfg_param ddr_fsp2_cfg[] = {
-   { 0xd, 0x0 },
-   { 0x54002, 0x102 },
-   { 0x54003, 0x64 },
-   { 0x54004, 0x2 },
-   { 0x54005, 0x2228 },
-   { 0x54006, 0x11 },
-   { 0x54008, 0x121f },
-   { 0x54009, 0xc8 },
-   { 0x5400b, 0x2 },
-   { 0x5400d, 0x100 },
-   { 0x54012, 0x310 },
-   { 0x54019, 0x84 },
-   { 0x5401a, 0x31 },
-   { 0x5401b, 0x4d66 },
-   { 0x5401c, 0x4d00 },
-   { 0x5401e, 0x16 },
-   { 0x5401f, 0x84 },
-   { 0x54020, 0x31 },
-   { 0x54021, 0x4d66 },
-   { 0x54022, 0x4d00 },
-   { 0x54024, 0x16 },
-   { 0x5402b, 0x1000 },
-   { 0x5402c, 0x3 },
-   { 0x54032, 0x8400 },
-   { 0x54033, 0x3100 },
-   { 0x54034, 0x6600 },
-   { 0x54035, 0x4d },
-   { 0x54036, 0x4d },
-   { 0x54037, 0x1600 },
-   { 0x54038, 0x8400 },
-   { 0x54039, 0x3100 },
-   { 0x5403a, 0x6600 },
-   { 0x5403b, 0x4d },
-   { 0x5403c, 0x4d },
-   { 0x5403d, 0x1600 },
-   { 0xd, 0x1 },
-};
-
 /* P0 2D message block paremeter for training firmware */
 struct dram_cfg_param ddr_fsp0_2d_cfg[] = {
{ 0xd, 0x0 },
@@ -1812,13 +1772,6 @@ struct dram_fsp_msg ddr_dram_fsp_msg[] = {
.fsp_cfg = ddr_fsp1_cfg,
.fsp_cfg_num = ARRAY_SIZE(ddr_fsp1_cfg),
},
-   {
-   /* P2 100mts 1D */
-   .drate = 100,
-   .fw_type = FW_1D_IMAGE,
-   .fsp_cfg = ddr_fsp2_cfg,
-   .fsp_cfg_num = ARRAY_SIZE(ddr_fsp2_cfg),
-},
{
/* P0 3000mts 2D */
.drate = 3000,
@@ -1840,5 +1793,5 @@ struct dram_timing_info dram_timing = {
.ddrphy_trained_csr_num = ARRAY_SIZE(ddr_ddrphy_trained_csr),
.ddrphy_pie = ddr_phy_pie,
.ddrphy_pie_num = ARRAY_SIZE(ddr_phy_pie),
-   .fsp_table = { 3000, 400, 100, },
+   .fsp_table = { 3000, 400, },
 };
diff --git a/board/kontron/sl-mx8mm/spl.c b/board/kontron/sl-mx8mm/spl.c
index 2a562f4ac97..447da13984e 100644
--- a/board/kontron/sl-mx8mm/spl.c
+++ b/board/kontron/sl-mx8mm/spl.c
@@ -95,8 +95,6 @@ static void spl_dram_init(void)
dram_timing.fsp_msg[1].fsp_cfg[22].val = 0x1;
dram_timing.fsp_msg[2].fsp_cfg[10].val = 0x110;
dram_timing.fsp_msg[2].fsp_cfg[22].val = 0x1;
-   dram_timing.fsp_msg[3].fsp_cfg[10].val = 0x110;
-   dram_timing.fsp_msg[3].fsp_cfg[22].val = 0x1;
 
if (!ddr_init(_timing)) {
if (check_ram_available(SZ_2G))
-- 
2.37.2



[PATCH v3 09/19] imx: kontron-sl-mx8mm: Enable bootaux command

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

Enable the bootaux command in order to be able to load a
binary into the M4 core when needed.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* none

Changes in v2:
* none
---
 configs/kontron-sl-mx8mm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/kontron-sl-mx8mm_defconfig 
b/configs/kontron-sl-mx8mm_defconfig
index 842a1a01e1a..5dcee988478 100644
--- a/configs/kontron-sl-mx8mm_defconfig
+++ b/configs/kontron-sl-mx8mm_defconfig
@@ -22,6 +22,7 @@ CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x1F
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
+CONFIG_IMX_BOOTAUX=y
 CONFIG_SYS_LOAD_ADDR=0x4200
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
-- 
2.37.2



[PATCH v3 08/19] imx: kontron-sl-mx8mm: Migrate to use CONFIG_EXTRA_ENV_TEXT

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

Move the environment from the board header to a separate text file
and also drop those variables that are already set in env_default.h
from the Kconfig options.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* none

Changes in v2:
* none
---
 board/kontron/sl-mx8mm/sl-mx8mm.env |  7 +++
 include/configs/kontron-sl-mx8mm.h  | 16 +---
 2 files changed, 8 insertions(+), 15 deletions(-)
 create mode 100644 board/kontron/sl-mx8mm/sl-mx8mm.env

diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.env 
b/board/kontron/sl-mx8mm/sl-mx8mm.env
new file mode 100644
index 000..ef6fc1f3428
--- /dev/null
+++ b/board/kontron/sl-mx8mm/sl-mx8mm.env
@@ -0,0 +1,7 @@
+kernel_addr_r=0x4200
+fdt_addr_r=0x4800
+fdtoverlay_addr_r=0x4900
+ramdisk_addr_r=0x4808
+scriptaddr=0x4000
+pxefile_addr_r=0x4010
+dfu_alt_info=sf 0:0=flash-bin raw 0x400 0x1f
diff --git a/include/configs/kontron-sl-mx8mm.h 
b/include/configs/kontron-sl-mx8mm.h
index 622ab597624..a2aedefcec2 100644
--- a/include/configs/kontron-sl-mx8mm.h
+++ b/include/configs/kontron-sl-mx8mm.h
@@ -50,20 +50,6 @@
 #define CONFIG_MALLOC_F_ADDR   0x93
 #endif
 
-#define ENV_MEM_LAYOUT_SETTINGS \
-   "loadaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
-   "kernel_addr_r=0x4200\0" \
-   "fdt_addr_r=0x4800\0" \
-   "fdtoverlay_addr_r=0x4900\0" \
-   "ramdisk_addr_r=0x4808\0" \
-   "scriptaddr=0x4000\0"\
-   "pxefile_addr_r=0x4010\0"
-
-#define CONFIG_EXTRA_ENV_SETTINGS \
-   "dfu_alt_info=sf 0:0=flash-bin raw 0x400 0x1f\0" \
-   "bootdelay=3\0" \
-   "hostname=" CONFIG_HOSTNAME "\0" \
-   ENV_MEM_LAYOUT_SETTINGS \
-   BOOTENV
+#define CONFIG_EXTRA_ENV_SETTINGS BOOTENV
 
 #endif /* __KONTRON_MX8MM_CONFIG_H */
-- 
2.37.2



[PATCH v3 07/19] imx: kontron-sl-mx8mm: Enable environment in MMC

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

In case we boot from SD card or eMMC, we also want to load
the environment from the according boot device.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* none

Changes in v2:
* none
---
 board/kontron/sl-mx8mm/sl-mx8mm.c  | 31 ++
 configs/kontron-sl-mx8mm_defconfig |  1 +
 2 files changed, 32 insertions(+)

diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c 
b/board/kontron/sl-mx8mm/sl-mx8mm.c
index fea93278374..416c4cbb407 100644
--- a/board/kontron/sl-mx8mm/sl-mx8mm.c
+++ b/board/kontron/sl-mx8mm/sl-mx8mm.c
@@ -4,10 +4,13 @@
  */
 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -117,3 +120,31 @@ int board_init(void)
 {
return 0;
 }
+
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+   enum boot_device boot_dev = get_boot_device();
+
+   if (prio)
+   return ENVL_UNKNOWN;
+
+   /*
+* Make sure that the environment is loaded from
+* the MMC if we are running from SD card or eMMC.
+*/
+   if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC) &&
+   (boot_dev == SD1_BOOT || boot_dev == SD2_BOOT))
+   return ENVL_MMC;
+
+   if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
+   return ENVL_SPI_FLASH;
+
+   return ENVL_NOWHERE;
+}
+
+#if defined(CONFIG_ENV_IS_IN_MMC)
+int board_mmc_get_env_dev(int devno)
+{
+   return devno;
+}
+#endif
diff --git a/configs/kontron-sl-mx8mm_defconfig 
b/configs/kontron-sl-mx8mm_defconfig
index 5c1dc754967..842a1a01e1a 100644
--- a/configs/kontron-sl-mx8mm_defconfig
+++ b/configs/kontron-sl-mx8mm_defconfig
@@ -72,6 +72,7 @@ CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
-- 
2.37.2



[PATCH v3 06/19] imx: kontron-sl-mx8mm: Add redundant environment and SPI NOR partitions

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

Enable the redundant environment feature to allow falling back in case of
storage corruption. The partition layout for the SPI NOR device is added
to the devicetree.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* fix hex numbers and unit addresses in partitions

Changes in v2:
* describe SPI NOR partitions in devicetree
* move environment to end of SPI NOR
---
 arch/arm/dts/imx8mm-kontron-n801x-som.dtsi | 21 +
 configs/kontron-sl-mx8mm_defconfig |  4 +++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/imx8mm-kontron-n801x-som.dtsi 
b/arch/arm/dts/imx8mm-kontron-n801x-som.dtsi
index 8f90eb02550..3b66e560927 100644
--- a/arch/arm/dts/imx8mm-kontron-n801x-som.dtsi
+++ b/arch/arm/dts/imx8mm-kontron-n801x-som.dtsi
@@ -70,6 +70,27 @@
compatible = "mxicy,mx25r1635f", "jedec,spi-nor";
spi-max-frequency = <8000>;
reg = <0>;
+
+   partitions {
+   compatible = "fixed-partitions";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   partition@0 {
+   label = "u-boot";
+   reg = <0x0 0x1e>;
+   };
+
+   partition@1e {
+   label = "env";
+   reg = <0x1e 0x1>;
+   };
+
+   partition@1f {
+   label = "env_redundant";
+   reg = <0x1f 0x1>;
+   };
+   };
};
 };
 
diff --git a/configs/kontron-sl-mx8mm_defconfig 
b/configs/kontron-sl-mx8mm_defconfig
index b67ab8668db..5c1dc754967 100644
--- a/configs/kontron-sl-mx8mm_defconfig
+++ b/configs/kontron-sl-mx8mm_defconfig
@@ -6,7 +6,7 @@ CONFIG_SPL_GPIO=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_ENV_SIZE=0x1
-CONFIG_ENV_OFFSET=0x1f
+CONFIG_ENV_OFFSET=0x1E
 CONFIG_ENV_SECT_SIZE=0x1
 CONFIG_IMX_CONFIG="board/kontron/sl-mx8mm/imximage.cfg"
 CONFIG_DM_GPIO=y
@@ -19,6 +19,7 @@ CONFIG_SPL_SERIAL=y
 CONFIG_SPL_DRIVERS_MISC=y
 CONFIG_BOOTCOUNT_BOOTLIMIT=3
 CONFIG_SPL=y
+CONFIG_ENV_OFFSET_REDUND=0x1F
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
 CONFIG_SYS_LOAD_ADDR=0x4200
@@ -72,6 +73,7 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_DM=y
-- 
2.37.2



[PATCH v3 05/19] imx: kontron-sl-mx8mm: Enable MTD command

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

Enable the MTD command to be used for the SPI NOR on the SoM.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* none

Changes in v2:
* new patch
---
 configs/kontron-sl-mx8mm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/kontron-sl-mx8mm_defconfig 
b/configs/kontron-sl-mx8mm_defconfig
index 90618022510..b67ab8668db 100644
--- a/configs/kontron-sl-mx8mm_defconfig
+++ b/configs/kontron-sl-mx8mm_defconfig
@@ -59,6 +59,7 @@ CONFIG_CMD_FUSE=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_WDT=y
 CONFIG_CMD_CACHE=y
-- 
2.37.2



[PATCH v3 04/19] imx: kontron-sl-mx8mm: Increase CONFIG_SYS_CBSIZE to 2K

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

This allows using the command line with longer lines like
large scripts in env variables.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* none

Changes in v2:
* new patch
---
 configs/kontron-sl-mx8mm_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/kontron-sl-mx8mm_defconfig 
b/configs/kontron-sl-mx8mm_defconfig
index 3e71e786072..90618022510 100644
--- a/configs/kontron-sl-mx8mm_defconfig
+++ b/configs/kontron-sl-mx8mm_defconfig
@@ -49,7 +49,7 @@ CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x58000
 CONFIG_SPL_WATCHDOG=y
 CONFIG_SPL_ATF=y
-CONFIG_SYS_CBSIZE=256
+CONFIG_SYS_CBSIZE=2048
 CONFIG_SYS_PBSIZE=276
 CONFIG_CMD_NVEDIT_EFI=y
 # CONFIG_CMD_LZMADEC is not set
-- 
2.37.2



[PATCH v3 03/19] imx: kontron-sl-mx8mm: Remove custom board_boot_order() workaround

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

Nowadays detecting the SPI NOR as boot device from the ROMAPI is
fixed and works even if the SPI NOR is used as fallback boot device.

Therefore we don't need this workaround anymore.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* none

Changes in v2:
* new patch
---
 board/kontron/sl-mx8mm/spl.c | 22 --
 1 file changed, 22 deletions(-)

diff --git a/board/kontron/sl-mx8mm/spl.c b/board/kontron/sl-mx8mm/spl.c
index c379d37f1e8..2a562f4ac97 100644
--- a/board/kontron/sl-mx8mm/spl.c
+++ b/board/kontron/sl-mx8mm/spl.c
@@ -238,25 +238,3 @@ void board_init_f(ulong dummy)
 
board_init_r(NULL, 0);
 }
-
-void board_boot_order(u32 *spl_boot_list)
-{
-   u32 bootdev = spl_boot_device();
-
-   /*
-* The default boot fuse settings use the SD card (MMC2) as primary
-* boot device, but allow SPI NOR as a fallback boot device.
-* We can't detect the fallback case and spl_boot_device() will return
-* BOOT_DEVICE_MMC2 despite the actual boot device being SPI NOR.
-* Therefore we try to load U-Boot proper vom SPI NOR after loading
-* from MMC has failed.
-*/
-   spl_boot_list[0] = bootdev;
-
-   switch (bootdev) {
-   case BOOT_DEVICE_MMC1:
-   case BOOT_DEVICE_MMC2:
-   spl_boot_list[1] = BOOT_DEVICE_SPI;
-   break;
-   }
-}
-- 
2.37.2



[PATCH v3 02/19] imx: kontron-sl-mx8mm: Add support for loading from SPI NOR in SPL

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

This was initially enabled, but got accidentally dropped while
migrating Kconfig options and resyncing the defconfig in:

commit 9802154a94d6 ("configs: Resync with savedefconfig")

Let's enable this again to be able to boot from SPI NOR.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* none

Changes in v2:
* new patch
---
 configs/kontron-sl-mx8mm_defconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/configs/kontron-sl-mx8mm_defconfig 
b/configs/kontron-sl-mx8mm_defconfig
index 954818adc0e..3e71e786072 100644
--- a/configs/kontron-sl-mx8mm_defconfig
+++ b/configs/kontron-sl-mx8mm_defconfig
@@ -19,6 +19,8 @@ CONFIG_SPL_SERIAL=y
 CONFIG_SPL_DRIVERS_MISC=y
 CONFIG_BOOTCOUNT_BOOTLIMIT=3
 CONFIG_SPL=y
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
+CONFIG_SPL_SPI=y
 CONFIG_SYS_LOAD_ADDR=0x4200
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
@@ -43,6 +45,8 @@ CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x300
 CONFIG_SPL_I2C=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_POWER=y
+CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0x58000
 CONFIG_SPL_WATCHDOG=y
 CONFIG_SPL_ATF=y
 CONFIG_SYS_CBSIZE=256
-- 
2.37.2



[PATCH v3 01/19] imx: kontron-sl-mx8mm: Remove LVDS board type and devicetrees

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

The display isn't and won't be used in U-Boot. Also the display setup
is not yet supported in mainline Linux, so even for cases where the
U-Boot devicetree is passed to the kernel there is currently no use
for this configuration.

Selecting the proper configuration in the kernel FIT image automatically
depending on the detected hardware can be handled by a script in the
environment.

Signed-off-by: Frieder Schrempf 
Reviewed-by: Fabio Estevam 
---
Changes in v3:
* none

Changes in v2:
* rebase on u-boot-imx/master
---
 arch/arm/dts/Makefile |   1 -
 .../imx8mm-kontron-n801x-s-lvds-u-boot.dtsi   |   6 -
 arch/arm/dts/imx8mm-kontron-n801x-s-lvds.dts  | 117 --
 .../dts/imx8mm-kontron-n801x-s-u-boot.dtsi| 140 -
 arch/arm/dts/imx8mm-kontron-n801x-u-boot.dtsi | 145 --
 board/kontron/sl-mx8mm/spl.c  |  46 +-
 configs/kontron-sl-mx8mm_defconfig|   1 -
 7 files changed, 141 insertions(+), 315 deletions(-)
 delete mode 100644 arch/arm/dts/imx8mm-kontron-n801x-s-lvds-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx8mm-kontron-n801x-s-lvds.dts
 delete mode 100644 arch/arm/dts/imx8mm-kontron-n801x-u-boot.dtsi

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 48cb1f52b7a..75d0664cc01 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -940,7 +940,6 @@ dtb-$(CONFIG_ARCH_IMX8M) += \
imx8mm-icore-mx8mm-ctouch2.dtb \
imx8mm-icore-mx8mm-edimm2.2.dtb \
imx8mm-kontron-n801x-s.dtb \
-   imx8mm-kontron-n801x-s-lvds.dtb \
imx8mm-mx8menlo.dtb \
imx8mm-venice.dtb \
imx8mm-venice-gw71xx-0x.dtb \
diff --git a/arch/arm/dts/imx8mm-kontron-n801x-s-lvds-u-boot.dtsi 
b/arch/arm/dts/imx8mm-kontron-n801x-s-lvds-u-boot.dtsi
deleted file mode 100644
index 4bf75722bfb..000
--- a/arch/arm/dts/imx8mm-kontron-n801x-s-lvds-u-boot.dtsi
+++ /dev/null
@@ -1,6 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2019 Kontron Electronics GmbH
- */
-
-#include "imx8mm-kontron-n801x-u-boot.dtsi"
diff --git a/arch/arm/dts/imx8mm-kontron-n801x-s-lvds.dts 
b/arch/arm/dts/imx8mm-kontron-n801x-s-lvds.dts
deleted file mode 100644
index 40c14734e22..000
--- a/arch/arm/dts/imx8mm-kontron-n801x-s-lvds.dts
+++ /dev/null
@@ -1,117 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2019 Kontron Electronics GmbH
- */
-
-#include "imx8mm-kontron-n801x-s.dts"
-
-/ {
-   model = "Kontron i.MX8MM N801X S LVDS";
-   compatible = "kontron,imx8mm-n801x-s-lvds", "fsl,imx8mm";
-
-   backlight: backlight {
-   compatible = "pwm-backlight";
-   pwms = < 0 5>; /* period = 500 ns => f = 200 Hz */
-   power-supply = <_vdd_24v>;
-   brightness-levels = <0 100>;
-   num-interpolated-steps = <100>;
-   default-brightness-level = <100>;
-   status = "okay";
-   };
-
-   reg_panel_pwr: regpanel-pwr {
-   compatible = "regulator-fixed";
-   regulator-name = "reg_panel_pwr";
-   regulator-always-on;
-   gpio = < 19 GPIO_ACTIVE_HIGH>;
-   enable-active-high;
-   };
-
-   reg_panel_rst: regpanel-rst {
-   compatible = "regulator-fixed";
-   regulator-name = "reg_panel_rst";
-   regulator-always-on;
-   gpio = < 20 GPIO_ACTIVE_HIGH>;
-   enable-active-high;
-   };
-
-   reg_panel_stby: regpanel-stby {
-   compatible = "regulator-fixed";
-   regulator-name = "reg_panel_stby";
-   regulator-always-on;
-   gpio = < 21 GPIO_ACTIVE_HIGH>;
-   enable-active-high;
-   };
-
-   reg_panel_hinv: regpanel-hinv {
-   compatible = "regulator-fixed";
-   regulator-name = "reg_panel_hinv";
-   regulator-always-on;
-   gpio = < 24 GPIO_ACTIVE_HIGH>;
-   enable-active-high;
-   };
-
-   reg_panel_vinv: regpanel-vinv {
-   compatible = "regulator-fixed";
-   regulator-name = "reg_panel_vinv";
-   gpio = < 25 GPIO_ACTIVE_HIGH>;
-   enable-active-high;
-   };
-
-   reg_vdd_24v: regulator-24v {
-   compatible = "regulator-fixed";
-   regulator-name = "reg-vdd-24v";
-   regulator-min-microvolt = <2400>;
-   regulator-max-microvolt = <2400>;
-   regulator-boot-on;
-   regulator-always-on;
-   status = "okay";
-   };
-};
-
- {
-   status = "okay";
-
-   gt911@5d {
-   compatible = "goodix,gt928";
-   reg = <0x5d>;
-   pinctrl-names = "default";
-   pinctrl-0 = <_touch>;
-   interrupt-parent = <>;
-   interrupts = <22 8>;
-   reset-gpios = < 23 

[PATCH v3 00/19] imx: kontron-sl-mx8mm: Improvements and OSM board support

2022-08-24 Thread Frieder Schrempf
From: Frieder Schrempf 

This set contains several improvements for the kontron-sl-mx8mm board
configuration (patches 1-17, 19) and support for a new SoM (patch 18,
including baseboard) that complies to the Open Standard Module (OSM) 1.0
hardware specification, size S (https://sget.org/standards/osm).

This also syncs the devicetrees with the pending changes in Linux (see [1]).

Changes in v3:
* add Fabio's R-b tags (Thanks!)
* fix OSM-S SoM name to match official name
* fix docs to match official board names
* adjust devicetree names and compatibles
* fix printing of RAM size
* add missing Makefile entry for new dtb
* fix hex numbers and unit addresses in SPI NOR partitions

Changes in v2:
* rebase on u-boot-imx/master
* new patches 2-5, 19
* fix printf warning in board/kontron/sl-mx8mm/spl.c
* remove unused pinmux definitions in board/kontron/sl-mx8mm/spl.c
* describe SPI NOR partitions in devicetree
* move environment to end of SPI NOR
* Add tags

[1] 
https://patchwork.kernel.org/project/linux-arm-kernel/cover/20220822080357.24478-1-frie...@fris.de/

Frieder Schrempf (19):
  imx: kontron-sl-mx8mm: Remove LVDS board type and devicetrees
  imx: kontron-sl-mx8mm: Add support for loading from SPI NOR in SPL
  imx: kontron-sl-mx8mm: Remove custom board_boot_order() workaround
  imx: kontron-sl-mx8mm: Increase CONFIG_SYS_CBSIZE to 2K
  imx: kontron-sl-mx8mm: Enable MTD command
  imx: kontron-sl-mx8mm: Add redundant environment and SPI NOR
partitions
  imx: kontron-sl-mx8mm: Enable environment in MMC
  imx: kontron-sl-mx8mm: Migrate to use CONFIG_EXTRA_ENV_TEXT
  imx: kontron-sl-mx8mm: Enable bootaux command
  imx: kontron-sl-mx8mm: lpddr4_timing.c: Add spaces for proper
alignment
  imx: kontron-sl-mx8mm: Remove 100mt DDR setpoint
  imx: kontron-sl-mx8mm: Use new LPDDR4 config parameters
  imx: kontron-sl-mx8mm: Prepare for other i.MX8MM SoM types
  imx: kontron-sl-mx8mm: Adjust devicetree names, compatibles and model
strings
  imx: kontron-sl-mx8mm: Use the VSELECT signal to switch SD card IO
voltage
  imx: kontron-sl-mx8mm: Use voltage rail names from schematic for PMIC
regulator-names
  imx: kontron-sl-mx8mm: Simplify code in spl.c
  imx: kontron-sl-mx8mm: Add support for Kontron Electronics SoM SL
i.MX8MM OSM-S
  imx: kontron-sl-mx8mm: Prepare for I2C display detection in
environment script

 arch/arm/dts/Makefile |4 +-
 ...i => imx8mm-kontron-bl-common-u-boot.dtsi} |   21 +-
 .../dts/imx8mm-kontron-bl-osm-s-u-boot.dtsi   |   14 +
 arch/arm/dts/imx8mm-kontron-bl-osm-s.dts  |  376 
 arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi|   14 +
 ...tron-n801x-s.dts => imx8mm-kontron-bl.dts} |9 +-
 .../imx8mm-kontron-n801x-s-lvds-u-boot.dtsi   |6 -
 arch/arm/dts/imx8mm-kontron-n801x-s-lvds.dts  |  117 -
 .../dts/imx8mm-kontron-n801x-s-u-boot.dtsi|6 -
 arch/arm/dts/imx8mm-kontron-osm-s.dtsi|  330 +++
 ...-n801x-som.dtsi => imx8mm-kontron-sl.dtsi} |   53 +-
 board/kontron/sl-mx8mm/MAINTAINERS|2 +-
 board/kontron/sl-mx8mm/lpddr4_timing.c| 1969 -
 board/kontron/sl-mx8mm/sl-mx8mm.c |   45 +
 board/kontron/sl-mx8mm/sl-mx8mm.env   |7 +
 board/kontron/sl-mx8mm/spl.c  |  115 +-
 configs/kontron-sl-mx8mm_defconfig|   19 +-
 doc/board/kontron/sl-mx8mm.rst|   13 +-
 include/configs/kontron-sl-mx8mm.h|   16 +-
 19 files changed, 1810 insertions(+), 1326 deletions(-)
 rename arch/arm/dts/{imx8mm-kontron-n801x-u-boot.dtsi => 
imx8mm-kontron-bl-common-u-boot.dtsi} (83%)
 create mode 100644 arch/arm/dts/imx8mm-kontron-bl-osm-s-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-kontron-bl-osm-s.dts
 create mode 100644 arch/arm/dts/imx8mm-kontron-bl-u-boot.dtsi
 rename arch/arm/dts/{imx8mm-kontron-n801x-s.dts => imx8mm-kontron-bl.dts} (96%)
 delete mode 100644 arch/arm/dts/imx8mm-kontron-n801x-s-lvds-u-boot.dtsi
 delete mode 100644 arch/arm/dts/imx8mm-kontron-n801x-s-lvds.dts
 delete mode 100644 arch/arm/dts/imx8mm-kontron-n801x-s-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mm-kontron-osm-s.dtsi
 rename arch/arm/dts/{imx8mm-kontron-n801x-som.dtsi => imx8mm-kontron-sl.dtsi} 
(87%)
 create mode 100644 board/kontron/sl-mx8mm/sl-mx8mm.env

-- 
2.37.2



Re: Please pull u-boot-marvell/master

2022-08-24 Thread Tom Rini
On Tue, Aug 23, 2022 at 05:09:56PM +0200, Stefan Roese wrote:

> Hi Tom,
> 
> please pull this next batch of mostly Marvell related patches:
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] configs: stm32: Enable CONFIG_DM_REGULATOR for stm32f769-disco

2022-08-24 Thread Patrice Chotard
Since commit 5bc6f8c2a97e("video: stm32: remove test on CONFIG_DM_REGULATOR")
backlight was broken with the following message at boot:
stm32-display-dsi dsi@40016c00: Warning: cannot get phy dsi supply
stm32_display display-controller@40016800: panel panel enable backlight error 
-38

DM_REGULATOR flag must be enabled to fix this issue

Signed-off-by: Patrice Chotard 
---

 configs/stm32f769-disco_defconfig | 1 +
 configs/stm32f769-disco_spl_defconfig | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/stm32f769-disco_defconfig 
b/configs/stm32f769-disco_defconfig
index c177bd8c73..c316ec7344 100644
--- a/configs/stm32f769-disco_defconfig
+++ b/configs/stm32f769-disco_defconfig
@@ -51,6 +51,7 @@ CONFIG_ETH_DESIGNWARE=y
 CONFIG_DW_ALTDESCRIPTOR=y
 CONFIG_MII=y
 # CONFIG_PINCTRL_FULL is not set
+CONFIG_DM_REGULATOR=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_STM32_QSPI=y
diff --git a/configs/stm32f769-disco_spl_defconfig 
b/configs/stm32f769-disco_spl_defconfig
index 7515574dfb..3c1563f140 100644
--- a/configs/stm32f769-disco_spl_defconfig
+++ b/configs/stm32f769-disco_spl_defconfig
@@ -72,6 +72,7 @@ CONFIG_ETH_DESIGNWARE=y
 CONFIG_DW_ALTDESCRIPTOR=y
 CONFIG_MII=y
 # CONFIG_PINCTRL_FULL is not set
+CONFIG_DM_REGULATOR=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_SPL_RAM=y
 CONFIG_SPECIFY_CONSOLE_INDEX=y
-- 
2.25.1



[PATCH] ARM: dts: stm32: Fix display-timings settings for stm32f746-disco

2022-08-24 Thread Patrice Chotard
Since commit ef4ce6df3289 "video: stm32: stm32_ltdc: fix data enable polarity"
The panel display output wasn't functional anymore.
Device tree display-timings de-active property value must be updated
to 1.

Signed-off-by: Patrice Chotard 
---

 arch/arm/dts/stm32f746-disco-u-boot.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/stm32f746-disco-u-boot.dtsi 
b/arch/arm/dts/stm32f746-disco-u-boot.dtsi
index f88466fa60..a4ce936d7d 100644
--- a/arch/arm/dts/stm32f746-disco-u-boot.dtsi
+++ b/arch/arm/dts/stm32f746-disco-u-boot.dtsi
@@ -58,7 +58,7 @@
vsync-len = <10>;
hsync-active = <0>;
vsync-active = <0>;
-   de-active = <0>;
+   de-active = <1>;
pixelclk-active = <1>;
};
};
-- 
2.25.1



Re: [PATCH] vbe: Enable command only with BOOTSTD_FULL

2022-08-24 Thread Ilias Apalodimas
On Tue, 23 Aug 2022 at 20:14, Simon Glass  wrote:
>
> Avoid enabling this command by default. This saves about 1KB of code
> space.
>
> Signed-off-by: Simon Glass 
> ---
>
>  cmd/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 211ebe9c878..8ea064b8d2f 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -333,7 +333,7 @@ config BOOTM_RTEMS
>  config CMD_VBE
> bool "vbe - Verified Boot for Embedded"
> depends on BOOTMETH_VBE
> -   default y
> +   default y if BOOTSTD_FULL
> help
>   Provides various subcommands related to VBE, such as listing the
>   available methods, looking at the state and changing which method
> --
> 2.37.2.609.g9ff673ca1a-goog
>

Reviewed-by: Ilias Apalodimas 


Re: [PATCH v13 5/9] bootmenu: add removable media entries

2022-08-24 Thread Ilias Apalodimas
Hi Kojima-san

On Wed, Aug 24, 2022 at 03:37:36PM +0900, Masahisa Kojima wrote:
> UEFI specification requires booting from removal media using
> a architecture-specific default image name such as BOOTAA64.EFI.
> This commit adds the removable media entries into bootmenu,
> so that user can select the removable media and boot with
> default image.
> 
> The bootmenu automatically enumerates the possible bootable
> media devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL,
> add it as new UEFI boot option(BOOT) and update BootOrder
> variable. This automatically generated UEFI boot option
> has the dedicated guid in the optional_data to distinguish it from
> the UEFI boot option user adds manually. This optional_data is
> removed when the efi bootmgr loads the selected UEFI boot option.
> 
> This commit also provides the BOOT variable maintenance feature.
> Depending on the system hardware setup, some devices
> may not exist at a later system boot, so bootmenu checks the
> available device in each bootmenu invocation and automatically
> removes the BOOT variable corrensponding to the non-existent
> media device.
> 

Maybe I am doing something wrong here and this has been discussed in the
past, but here's what I get by testing this.

- The automatic scanning of boot options seems to be happening only when 
  "Change boot order" menu is selected.  Isn't it better to do it on
  eficonfig startup ?
- Although I can see a variable Boot which holds the device path of the
  virtio disk that has the BOOTAA64.EFI file, I can't see that option in
  the edit/delete menus
 
Thanks
/Ilias
> Signed-off-by: Masahisa Kojima 
> ---
> Changes in v13:
> - remove BootOrder variable dependency
> 
> Changes in v12:
> - move generate_media_device_boot_option into cmd/eficonfig.c and expose it
> - remove unnecessary include file
> 
> Changes in v11:
> - update delete_boot_option() parameter
> 
> Changes in v10:
> - add function comment
> - devname dynamic allocation removes, allocate in stack
> - delete BOOT when updating BootOrder fails
> 
> Changes in v9:
> - update efi_disk_get_device_name() parameter to pass efi_handle_t
> - add function comment
> 
> Changes in v8:
> - function and structure prefix is changed to "eficonfig"
> 
> Changes in v7:
> - rename prepare_media_device_entry() to generate_media_device_boot_option()
> 
> Changes in v6:
> - optional_data size is changed to 16bytes
> - check the load option size before comparison
> - remove guid included in optional_data of auto generated
>   entry when loading
> 
> Changes in v5:
> - Return EFI_SUCCESS if there is no BootOrder defined
> - correctly handle the case if no removable device found
> - use guid to identify the automatically generated entry by bootmenu
> 
>  cmd/bootmenu.c   |  22 +++-
>  cmd/eficonfig.c  | 209 +++
>  include/efi_config.h |   1 +
>  include/efi_loader.h |  16 +++
>  lib/efi_loader/efi_bootmgr.c |   4 +
>  5 files changed, 246 insertions(+), 6 deletions(-)
> 
> diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
> index 704d36debe..3340be1632 100644
> --- a/cmd/bootmenu.c
> +++ b/cmd/bootmenu.c
> @@ -7,7 +7,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -220,7 +220,7 @@ static int prepare_bootmenu_entry(struct bootmenu_data 
> *menu,
>   return 1;
>  }
>  
> -#if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR))
> +#if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR)) && 
> (CONFIG_IS_ENABLED(CMD_EFICONFIG))
>  /**
>   * prepare_uefi_bootorder_entry() - generate the uefi bootmenu entries
>   *
> @@ -340,11 +340,21 @@ static struct bootmenu_data *bootmenu_create(int delay)
>   if (ret < 0)
>   goto cleanup;
>  
> -#if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR))
> +#if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR)) && 
> (CONFIG_IS_ENABLED(CMD_EFICONFIG))
>   if (i < MAX_COUNT - 1) {
> - ret = prepare_uefi_bootorder_entry(menu, , );
> - if (ret < 0 && ret != -ENOENT)
> - goto cleanup;
> + efi_status_t efi_ret;
> +
> + /*
> +  * UEFI specification requires booting from removal media using
> +  * a architecture-specific default image name such as 
> BOOTAA64.EFI.
> +  */
> + efi_ret = eficonfig_generate_media_device_boot_option();
> + if (efi_ret != EFI_SUCCESS && efi_ret != EFI_NOT_FOUND)
> + goto cleanup;
> +
> + ret = prepare_uefi_bootorder_entry(menu, , );
> + if (ret < 0 && ret != -ENOENT)
> + goto cleanup;
>   }
>  #endif
>  
> diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> index 537f3f2bbc..92171c4894 100644
> --- a/cmd/eficonfig.c
> +++ b/cmd/eficonfig.c
> @@ -1786,6 +1786,215 @@ static efi_status_t 
> eficonfig_process_delete_boot_option(void *data)
>   return ret;
>  }
>  
> 

RE: [RFC PATCH 1/1] net: xilinx: handle internal PHY/PCS

2022-08-24 Thread Katakam, Harini
Hi Nikita,

> -Original Message-
> From: Simek, Michal 
> Sent: Thursday, August 11, 2022 1:16 PM
> To: Nikita Shubin ; Agarwal, Swati
> ; Pandey, Radhey Shyam
> 
> Cc: li...@yadro.com; Nikita Shubin ; Joe
> Hershberger ; Ramon Fried
> ; u-boot@lists.denx.de
> Subject: Re: [RFC PATCH 1/1] net: xilinx: handle internal PHY/PCS
> 
> Hi Nikita,
> 
> On 8/2/22 12:53, Nikita Shubin wrote:
> > From: Nikita Shubin 
> >
> > In SGMII/1000BaseX Xilinx AXI Ethernet may also have an Internal PHY
> > (PCS) in addition to external PHY, in that case we should also set at
> > least BMCR_ANENABLE.
> >
> > PCS are not visible until axinet bringup, so init should be done
> > after, controller is brought up, then we should poll BMSR_ANEGCOMPLETE
> > prior to polling the external PHY.
> >
> > The PCS handling relies on "pcs-handle" device tree handle which
> > serves the similar purpose in Linux device tree.
> >
> > Signed-off-by: Nikita Shubin 
> > ---

> > @@ -540,6 +565,20 @@ static int axiemac_start(struct udevice *dev)
> > return -1;
> > }
> >
> > +   if (pcsdev) {
> > +   /* It looks like we need a bit of delay for core to come up
> > +* may be we could poll MgtRdy or PhyRstCmplt bit
> > +* in 0x0010, but 1 msec is no a big deal.
> > +*/
> > +   udelay(1000);
> > +   ret = phywrite(priv, pcsdev->addr, MII_BMCR,
> > +   BMCR_ANENABLE | BMCR_FULLDPLX |
> BMCR_SPEED1000);

Thanks for the patch.
Could you please confirm that BMCR_ISOLATE is also being handled in
the autonegotiation path? For ex., the equivalent in linux can be found
here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/phy/phylink.c#n3050

Could you also please handle the SGMII/1000BaseX standard selection
in the PCS PMA IP? For reference, please see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/xilinx/xilinx_axienet_main.c#n1619

Regards,
Harini


Re: [PATCH v2] arm: bcmbca: add bcm63138 SoC support

2022-08-24 Thread Philippe REYNES

Hi William,


Le 06/08/2022 à 03:25, William Zhang a écrit :

BCM63138 is an ARM A9 based DSL Broadband SoC. It is part of the BCA
(Broadband Carrier Access origin) chipset family so it's added under
ARCH_BCMBCA platform. This initial support includes a bare-bone
implementation and dts with CPU subsystem, memory, ARM A9 global timer
and Broadcom uart.

This SoC is supported in the linux-next git repository so the dts and
dtsi files are stripped down version of linux copies with mininum blocks
needed by u-boot.

The u-boot image can be loaded from flash or network to the entry point
address in the memory and boot from there to the console.

This patch applies on top of the my previous patch [1].

[1] https://lists.denx.de/pipermail/u-boot/2022-August/490570.html

Signed-off-by: William Zhang 
Reviewed-by: Florian Fainelli 



Reviewed-by: Philippe Reynes 




---

Changes in v2:
- Drop bcmbca timer and use ARM A9 global timer instead as it is already
supported in u-boot
- Add Florian reviewed-by tag for v1 patch

  MAINTAINERS|   1 +
  arch/arm/dts/Makefile  |   2 +
  arch/arm/dts/bcm63138.dtsi | 149 +
  arch/arm/dts/bcm963138.dts |  30 +
  arch/arm/mach-bcmbca/Kconfig   |   9 ++
  arch/arm/mach-bcmbca/Makefile  |   1 +
  arch/arm/mach-bcmbca/bcm63138/Kconfig  |  17 +++
  arch/arm/mach-bcmbca/bcm63138/Makefile |   5 +
  board/broadcom/bcmbca/Kconfig  |   7 ++
  configs/bcm963138_defconfig|  22 
  include/configs/bcm963138.h|  12 ++
  11 files changed, 255 insertions(+)
  create mode 100644 arch/arm/dts/bcm63138.dtsi
  create mode 100644 arch/arm/dts/bcm963138.dts
  create mode 100644 arch/arm/mach-bcmbca/bcm63138/Kconfig
  create mode 100644 arch/arm/mach-bcmbca/bcm63138/Makefile
  create mode 100644 configs/bcm963138_defconfig
  create mode 100644 include/configs/bcm963138.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 8c3a7d77f17d..2a27d15705cb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -219,6 +219,7 @@ F:  board/broadcom/bcmbca/
  F:drivers/timer/bcmbca-timer.c
  N:bcmbca
  N:bcm[9]?47622
+N: bcm[9]?63138
  N:bcm[9]?63148
  N:bcm[9]?63178
  N:bcm[9]?6756
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index b8d136bd129b..f4fa6f517744 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1165,6 +1165,8 @@ dtb-$(CONFIG_ARCH_BCMSTB) += bcm7xxx.dtb
  
  dtb-$(CONFIG_BCM47622) += \

bcm947622.dtb
+dtb-$(CONFIG_BCM63138) += \
+   bcm963138.dtb
  dtb-$(CONFIG_BCM63148) += \
bcm963148.dtb
  dtb-$(CONFIG_BCM63178) += \
diff --git a/arch/arm/dts/bcm63138.dtsi b/arch/arm/dts/bcm63138.dtsi
new file mode 100644
index ..42b442aec9f4
--- /dev/null
+++ b/arch/arm/dts/bcm63138.dtsi
@@ -0,0 +1,149 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Broadcom BCM63138 DSL SoCs Device Tree
+ */
+
+#include 
+#include 
+
+/ {
+   compatible = "brcm,bcm63138", "brcm,bcmbca";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   interrupt-parent = <>;
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a9";
+   next-level-cache = <>;
+   reg = <0>;
+   enable-method = "brcm,bcm63138";
+   };
+
+   cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a9";
+   next-level-cache = <>;
+   reg = <1>;
+   enable-method = "brcm,bcm63138";
+   };
+   };
+
+   clocks {
+   /* UBUS peripheral clock */
+   periph_clk: periph_clk {
+   #clock-cells = <0>;
+   compatible = "fixed-clock";
+   clock-frequency = <5000>;
+   clock-output-names = "periph";
+   };
+
+   /* peripheral clock for system timer */
+   axi_clk: axi_clk {
+   #clock-cells = <0>;
+   compatible = "fixed-factor-clock";
+   clocks = <>;
+   clock-div = <2>;
+   clock-mult = <1>;
+   };
+
+   /* APB bus clock */
+   apb_clk: apb_clk {
+   #clock-cells = <0>;
+   compatible = "fixed-factor-clock";
+   clocks = <>;
+   clock-div = <4>;
+   clock-mult = <1>;
+   };
+   };
+
+   /* ARM bus */
+   axi@8000 {
+   compatible = "simple-bus";
+   ranges = <0 0x8000 0x784000>;
+   #address-cells = <1>;
+   #size-cells = 

Re: [PATCH v3 5/5] arm: bcmbca: make reset_cpu function weak

2022-08-24 Thread Philippe REYNES

Hi William


Le 22/08/2022 à 20:19, William Zhang a écrit :

BCM63158 carries the CONFIG_SYSRESET from the original configuration. It
provide reset_cpu function already so need to define weak version of the
dummy reset_cpu for other BCMBCA SoCs to avoid linking error.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 




---

Changes in v3:
-Fix reset_cpu function prototype.

  board/broadcom/bcmbca/board.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/broadcom/bcmbca/board.c b/board/broadcom/bcmbca/board.c
index 4aa1d659d5c7..bcecb4d78392 100644
--- a/board/broadcom/bcmbca/board.c
+++ b/board/broadcom/bcmbca/board.c
@@ -30,6 +30,6 @@ int print_cpuinfo(void)
return 0;
  }
  
-void reset_cpu(ulong addr)

+__weak void reset_cpu(void)
  {
  }


Re: [PATCH v3 4/5] MAINTAINERS: Add BCM63158 maintainer to BCMBCA entry

2022-08-24 Thread Philippe REYNES

Hi William,


Le 22/08/2022 à 20:19, William Zhang a écrit :

Since ARCH_BCM63158 SoC support is merged into ARCH_BCMBCA, add BCM63158
maintainer Philippe to bcmbca maintainer list.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 



---

(no changes since v1)

  MAINTAINERS | 1 +
  1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5b219d62f6bf..d0a5b2352cc8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -213,6 +213,7 @@ M:  Anand Gore 
  M:William Zhang 
  M:Kursad Oney 
  M:Joel Peshkin 
+M: Philippe Reynes 
  S:Maintained
  F:arch/arm/mach-bcmbca/
  F:board/broadcom/bcmbca/


Re: [PATCH v3 3/5] arm: bcmbca: replace ARCH_BCM63158 symbols in Kconfig with BCM63158

2022-08-24 Thread Philippe REYNES

Hi William,


Le 22/08/2022 à 20:19, William Zhang a écrit :

As CONFIG_ARCH_BCM63158 is replaced with CONFIG_BCM63158, update the
Kconfig to use the new config symbol.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 




---

Changes in v3:
-Update subject line to be more clear

  drivers/gpio/Kconfig | 2 +-
  drivers/led/Kconfig  | 2 +-
  drivers/mtd/nand/raw/Kconfig | 2 +-
  drivers/spi/Kconfig  | 2 +-
  drivers/watchdog/Kconfig | 2 +-
  5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index aaa152fae73b..83f4f5089992 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -111,7 +111,7 @@ config BCM2835_GPIO
  config BCM6345_GPIO
bool "BCM6345 GPIO driver"
depends on DM_GPIO && (ARCH_BMIPS || ARCH_BCM68360 || \
-  ARCH_BCM6858 || ARCH_BCM63158 || \
+  ARCH_BCM6858 || BCM63158 || \
   ARCH_BCM6753)
help
  This driver supports the GPIO banks on BCM6345 SoCs.
diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig
index ccdd7d7395c8..d777414dda8d 100644
--- a/drivers/led/Kconfig
+++ b/drivers/led/Kconfig
@@ -37,7 +37,7 @@ config LED_BCM6753
  
  config LED_BCM6858

bool "LED Support for BCM6858"
-   depends on LED && (ARCH_BCM68360 || ARCH_BCM6858 || ARCH_BCM63158)
+   depends on LED && (ARCH_BCM68360 || ARCH_BCM6858 || BCM63158)
help
  This option enables support for LEDs connected to the BCM6858
  HW has blinking capabilities and up to 32 LEDs can be controlled.
diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index ce67d1abde25..24c27b6ecf7f 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -121,7 +121,7 @@ config NAND_BRCMNAND_6858
  
  config NAND_BRCMNAND_63158

 bool "Support Broadcom NAND controller on bcm63158"
-   depends on NAND_BRCMNAND && ARCH_BCM63158
+   depends on NAND_BRCMNAND && BCM63158
 help
   Enable support for broadcom nand driver on bcm63158.
  
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig

index 75b794548b22..0a666eee80e7 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -92,7 +92,7 @@ config ATMEL_SPI
  config BCM63XX_HSSPI
bool "BCM63XX HSSPI driver"
depends on (ARCH_BMIPS || ARCH_BCM68360 || \
-   ARCH_BCM6858 || ARCH_BCM63158)
+   ARCH_BCM6858 || BCM63158)
help
  Enable the BCM6328 HSSPI driver. This driver can be used to
  access the SPI NOR flash on platforms embedding this Broadcom
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 50e6a1efba51..ff4d1ee530d2 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -129,7 +129,7 @@ config WDT_AT91
  config WDT_BCM6345
bool "BCM6345 watchdog timer support"
depends on WDT && (ARCH_BMIPS || ARCH_BCM68360 || \
-  ARCH_BCM6858 || ARCH_BCM63158 || \
+  ARCH_BCM6858 || BCM63158 || \
   ARCH_BCM6753)
help
  Select this to enable watchdog timer for BCM6345 SoCs.


Re: [PATCH v3 2/5] arm: bcmbca: remove bcm63158 support under CONFIG_ARCH_BCM63158

2022-08-24 Thread Philippe REYNES

Hi William,


Le 22/08/2022 à 20:19, William Zhang a écrit :

Now that BCM63158 is supported under CONFIG_ARCH_BCMBCA and
CONFIG_BCM63158, remove the original ARCH_BCM63158 support and migrate
configuration settings.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 




---

(no changes since v2)

Changes in v2:
- Remove bcm963158_ram_defconfig per discussion with Philippe as a
basic config version of bcm963158_defconfig is now added.

  arch/arm/Kconfig |  8 +---
  arch/arm/dts/Makefile|  3 --
  board/broadcom/bcm963158/Kconfig | 17 ---
  board/broadcom/bcm963158/MAINTAINERS |  6 ---
  board/broadcom/bcm963158/Makefile|  3 --
  board/broadcom/bcm963158/bcm963158.c | 62 -
  configs/bcm963158_ram_defconfig  | 67 
  include/configs/bcm963158.h  |  4 ++
  include/configs/broadcom_bcm963158.h | 32 -
  9 files changed, 5 insertions(+), 197 deletions(-)
  delete mode 100644 board/broadcom/bcm963158/Kconfig
  delete mode 100644 board/broadcom/bcm963158/MAINTAINERS
  delete mode 100644 board/broadcom/bcm963158/Makefile
  delete mode 100644 board/broadcom/bcm963158/bcm963158.c
  delete mode 100644 configs/bcm963158_ram_defconfig
  delete mode 100644 include/configs/broadcom_bcm963158.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 0d4903a2eb5b..da4defa08466 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -665,12 +665,6 @@ config ARCH_BCM283X
imply CMD_DM
imply FAT_WRITE
  
-config ARCH_BCM63158

-   bool "Broadcom BCM63158 family"
-   select DM
-   select OF_CONTROL
-   imply CMD_DM
-
  config ARCH_BCM6753
bool "Broadcom BCM6753 family"
select CPU_V7A
@@ -706,6 +700,7 @@ config ARCH_BCMBCA
bool "Broadcom broadband chip family"
select DM
select OF_CONTROL
+   imply CMD_DM
  
  config TARGET_VEXPRESS_CA9X4

bool "Support vexpress_ca9x4"
@@ -2284,7 +2279,6 @@ source "board/Marvell/octeontx2/Kconfig"
  source "board/armltd/vexpress/Kconfig"
  source "board/armltd/vexpress64/Kconfig"
  source "board/cortina/presidio-asic/Kconfig"
-source "board/broadcom/bcm963158/Kconfig"
  source "board/broadcom/bcm96753ref/Kconfig"
  source "board/broadcom/bcm968360bg/Kconfig"
  source "board/broadcom/bcm968580xref/Kconfig"
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index a7fc3d7d7021..c55bc3569662 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1147,9 +1147,6 @@ dtb-$(CONFIG_ARCH_BCM283X) += \
bcm2837-rpi-cm3-io3.dtb \
bcm2711-rpi-4-b.dtb
  
-dtb-$(CONFIG_ARCH_BCM63158) += \

-   bcm963158.dtb
-
  dtb-$(CONFIG_ARCH_BCM68360) += \
bcm968360bg.dtb
  
diff --git a/board/broadcom/bcm963158/Kconfig b/board/broadcom/bcm963158/Kconfig

deleted file mode 100644
index 08a8bc1c14d3..
--- a/board/broadcom/bcm963158/Kconfig
+++ /dev/null
@@ -1,17 +0,0 @@
-if TARGET_BCM963158
-
-config SYS_VENDOR
-   default "broadcom"
-
-config SYS_BOARD
-   default "bcm963158"
-
-config SYS_CONFIG_NAME
-   default "broadcom_bcm963158"
-
-endif
-
-config TARGET_BCM963158
-   bool "Support Broadcom bcm963158"
-   depends on ARCH_BCM63158
-   select ARM64
diff --git a/board/broadcom/bcm963158/MAINTAINERS 
b/board/broadcom/bcm963158/MAINTAINERS
deleted file mode 100644
index d28d971f9d36..
--- a/board/broadcom/bcm963158/MAINTAINERS
+++ /dev/null
@@ -1,6 +0,0 @@
-BROADCOM BCM963158
-M: Philippe Reynes 
-S: Maintained
-F: board/broadcom/bcm963158/
-F: include/configs/broadcom_bcm963158.h
-F: configs/bcm963158_ram_defconfig
diff --git a/board/broadcom/bcm963158/Makefile 
b/board/broadcom/bcm963158/Makefile
deleted file mode 100644
index 0a902c9cf618..
--- a/board/broadcom/bcm963158/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-
-obj-y  += bcm963158.o
diff --git a/board/broadcom/bcm963158/bcm963158.c 
b/board/broadcom/bcm963158/bcm963158.c
deleted file mode 100644
index 9feaee3c0fc4..
--- a/board/broadcom/bcm963158/bcm963158.c
+++ /dev/null
@@ -1,62 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2019 Philippe Reynes 
- */
-
-#include 
-#include 
-#include 
-#include 
-
-#ifdef CONFIG_ARM64
-#include 
-
-static struct mm_region broadcom_bcm963158_mem_map[] = {
-   {
-   /* RAM */
-   .virt = 0xUL,
-   .phys = 0xUL,
-   .size = 8UL * SZ_1G,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
-PTE_BLOCK_INNER_SHARE
-   }, {
-   /* SoC */
-   .virt = 0x8000UL,
-   .phys = 0x8000UL,
-   .size = 0xff8000UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-PTE_BLOCK_NON_SHARE |
-PTE_BLOCK_PXN | PTE_BLOCK_UXN
-   

Re: [PATCH v3 1/5] arm: bcmbca: add bcm63158 SoC support under CONFIG_ARCH_BCMBCA

2022-08-24 Thread Philippe REYNES

Hi William,


Le 22/08/2022 à 20:19, William Zhang a écrit :

BCM63158 is a Broadcom B53 based DSL Gateway SoC. It is part of the
BCA (Broadband Carrier Access origin) chipset family. Like other
Broadband SoC, this patch adds it under CONFIG_BCM63158 chip
config and CONFIG_ARCH_BCMBCA platform config.

This initial support includes a bare-bone implementation and dts with
CPU subsystem, memory and ARM PL011 uart. This SoC is supported in the
linux-next git repository so the dts and dtsi files are copied from
linux.

The u-boot image can be loaded from flash or network to the entry
point address in the memory and boot from there to the console.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 




---

(no changes since v2)

Changes in v2:
- Remove extra nodes from bcm963158.dts and keep it as a generic minimun
board support dts following other BCA chip convention.

  MAINTAINERS   |   1 +
  arch/arm/dts/Makefile |   2 +
  arch/arm/dts/bcm63158.dtsi| 207 +-
  arch/arm/dts/bcm963158.dts| 121 +
  arch/arm/mach-bcmbca/Kconfig  |   8 +
  arch/arm/mach-bcmbca/Makefile |   1 +
  arch/arm/mach-bcmbca/bcm63158/Kconfig |  17 ++
  arch/arm/mach-bcmbca/bcm63158/Makefile|   5 +
  arch/arm/mach-bcmbca/bcm63158/mmu_table.c |  32 
  board/broadcom/bcmbca/Kconfig |   7 +
  configs/bcm963158_defconfig   |  23 +++
  include/configs/bcm963158.h   |  11 ++
  12 files changed, 239 insertions(+), 196 deletions(-)
  create mode 100644 arch/arm/mach-bcmbca/bcm63158/Kconfig
  create mode 100644 arch/arm/mach-bcmbca/bcm63158/Makefile
  create mode 100644 arch/arm/mach-bcmbca/bcm63158/mmu_table.c
  create mode 100644 configs/bcm963158_defconfig
  create mode 100644 include/configs/bcm963158.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 3f250942ced1..5b219d62f6bf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -224,6 +224,7 @@ N:  bcm[9]?4912
  N:bcm[9]?63138
  N:bcm[9]?63146
  N:bcm[9]?63148
+N: bcm[9]?63158
  N:bcm[9]?63178
  N:bcm[9]?6756
  N:bcm[9]?6813
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9a6582d9c1c8..a7fc3d7d7021 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1175,6 +1175,8 @@ dtb-$(CONFIG_BCM63146) += \
bcm963146.dtb
  dtb-$(CONFIG_BCM63148) += \
bcm963148.dtb
+dtb-$(CONFIG_BCM63158) += \
+   bcm963158.dtb
  dtb-$(CONFIG_BCM63178) += \
bcm963178.dtb
  dtb-$(CONFIG_BCM6756) += \
diff --git a/arch/arm/dts/bcm63158.dtsi b/arch/arm/dts/bcm63158.dtsi
index 7dd285843849..8b179ba0fca8 100644
--- a/arch/arm/dts/bcm63158.dtsi
+++ b/arch/arm/dts/bcm63158.dtsi
@@ -1,122 +1,167 @@
  // SPDX-License-Identifier: GPL-2.0+
  /*
   * Copyright (C) 2019 Philippe Reynes 
+ * Copyright 2022 Broadcom Ltd.
   */
  
-#include "skeleton64.dtsi"

+#include 
+#include 
  
  / {

-   compatible = "brcm,bcm63158";
+   compatible = "brcm,bcm63158", "brcm,bcmbca";
#address-cells = <2>;
#size-cells = <2>;
  
-	aliases {

-   spi0 = 
-   };
+   interrupt-parent = <>;
  
  	cpus {

#address-cells = <2>;
#size-cells = <0>;
-   u-boot,dm-pre-reloc;
  
-		cpu0: cpu@0 {

-   compatible = "arm,cortex-a53", "arm,armv8";
+   B53_0: cpu@0 {
+   compatible = "brcm,brahma-b53";
device_type = "cpu";
reg = <0x0 0x0>;
-   next-level-cache = <>;
-   u-boot,dm-pre-reloc;
+   next-level-cache = <_0>;
+   enable-method = "psci";
};
  
-		cpu1: cpu@1 {

-   compatible = "arm,cortex-a53", "arm,armv8";
+   B53_1: cpu@1 {
+   compatible = "brcm,brahma-b53";
device_type = "cpu";
reg = <0x0 0x1>;
-   next-level-cache = <>;
-   u-boot,dm-pre-reloc;
+   next-level-cache = <_0>;
+   enable-method = "psci";
};
  
-		cpu2: cpu@2 {

-   compatible = "arm,cortex-a53", "arm,armv8";
+   B53_2: cpu@2 {
+   compatible = "brcm,brahma-b53";
device_type = "cpu";
reg = <0x0 0x2>;
-   next-level-cache = <>;
-   u-boot,dm-pre-reloc;
+   next-level-cache = <_0>;
+   enable-method = "psci";
};
  
-		cpu3: cpu@3 {

-   compatible = "arm,cortex-a53", "arm,armv8";
+   B53_3: cpu@3 {
+   compatible = "brcm,brahma-b53";
device_type = "cpu";
reg = 

Re: [PATCH v2 3/3] arm: bcmbca: replace ARCH_BCM6753 symbols in Kconfig with BCM6855

2022-08-24 Thread Philippe REYNES

Hi William,


Le 22/08/2022 à 20:49, William Zhang a écrit :

As CONFIG_ARCH_BCM6753 is replaced with CONFIG_BCM6855, update the
driver Kconfig to use the new config symbol.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 




---

Changes in v2:
- Update subject line to be more clear for patch 3

  drivers/gpio/Kconfig | 2 +-
  drivers/led/Kconfig  | 2 +-
  drivers/mtd/nand/raw/Kconfig | 2 +-
  drivers/watchdog/Kconfig | 2 +-
  4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 929f3fb9eacb..d8020de969ef 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -111,7 +111,7 @@ config BCM2835_GPIO
  config BCM6345_GPIO
bool "BCM6345 GPIO driver"
depends on DM_GPIO && (ARCH_BMIPS || BCM6856 || \
-  BCM6858 || BCM63158 || ARCH_BCM6753)
+  BCM6858 || BCM63158 || BCM6855)
help
  This driver supports the GPIO banks on BCM6345 SoCs.
  
diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig

index 98f015a07f97..996b757e6d00 100644
--- a/drivers/led/Kconfig
+++ b/drivers/led/Kconfig
@@ -30,7 +30,7 @@ config LED_BCM6358
  
  config LED_BCM6753

bool "LED Support for BCM6753"
-   depends on LED && ARCH_BCM6753
+   depends on LED && BCM6855
help
  This option enables support for LEDs connected to the BCM6753
  HW has blinking and fading capabilities and up to 32 LEDs can be 
controlled.
diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index f8445e09633c..d6e3eeb3c093 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -97,7 +97,7 @@ config NAND_BRCMNAND_6368
  
  config NAND_BRCMNAND_6753

bool "Support Broadcom NAND controller on bcm6753"
-   depends on NAND_BRCMNAND && ARCH_BCM6753
+   depends on NAND_BRCMNAND && BCM6855
help
  Enable support for broadcom nand driver on bcm6753.
  
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig

index 84a4034fe87c..65f2d0821c60 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -129,7 +129,7 @@ config WDT_AT91
  config WDT_BCM6345
bool "BCM6345 watchdog timer support"
depends on WDT && (ARCH_BMIPS || BCM6856 || \
-  BCM6858 || BCM63158 || ARCH_BCM6753)
+  BCM6858 || BCM63158 || BCM6855)
help
  Select this to enable watchdog timer for BCM6345 SoCs.
  The watchdog timer is stopped when initialized.


Re: [PATCH v2 2/3] arm: bcmbca: remove bcm6753 support under CONFIG_ARCH_BCM6753

2022-08-24 Thread Philippe REYNES

Hi William,


Le 22/08/2022 à 20:49, William Zhang a écrit :

BCM6753 is essentially same as the main chip BCM6855 but with different
SKU number. Now that BCM6855 is supported under CONFIG_ARCH_BCMBCA and
CONFIG_BCM6855, remove the original ARCH_BCM6753 support and migrate its
configuration and dts settings. This includes:
- Remove the bcm96753ref board folder. It is replaced by the
generic bcmbca board folder.
- Merge the 6753.dtsi setting to the new 6855.dtsi file. Update
96753ref board dts with the new compatible string.
- Delete broadcom_bcm96763ref.h and merge its setting to the new
bcm96855.h file.
- Delete bcm96753ref_ram_defconfig and use a basic config version of
bcm96855_defconfig

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 



---

(no changes since v1)

  arch/arm/Kconfig |   8 -
  arch/arm/dts/Makefile|   6 +-
  arch/arm/dts/bcm6753.dtsi| 208 ---
  arch/arm/dts/bcm6855.dtsi| 137 +++
  arch/arm/dts/bcm96753ref.dts |   6 +-
  board/broadcom/bcm96753ref/Kconfig   |  16 --
  board/broadcom/bcm96753ref/MAINTAINERS   |   6 -
  board/broadcom/bcm96753ref/Makefile  |   3 -
  board/broadcom/bcm96753ref/bcm96753ref.c |  40 -
  configs/bcm96753ref_ram_defconfig|  87 --
  include/configs/bcm96855.h   |   4 +
  include/configs/broadcom_bcm96753ref.h   |  32 
  12 files changed, 146 insertions(+), 407 deletions(-)
  delete mode 100644 arch/arm/dts/bcm6753.dtsi
  delete mode 100644 board/broadcom/bcm96753ref/Kconfig
  delete mode 100644 board/broadcom/bcm96753ref/MAINTAINERS
  delete mode 100644 board/broadcom/bcm96753ref/Makefile
  delete mode 100644 board/broadcom/bcm96753ref/bcm96753ref.c
  delete mode 100644 configs/bcm96753ref_ram_defconfig
  delete mode 100644 include/configs/broadcom_bcm96753ref.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 063616ff8d0b..c1f195e9d106 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -665,13 +665,6 @@ config ARCH_BCM283X
imply CMD_DM
imply FAT_WRITE
  
-config ARCH_BCM6753

-   bool "Broadcom BCM6753 family"
-   select CPU_V7A
-   select DM
-   select OF_CONTROL
-   imply CMD_DM
-
  config ARCH_BCMSTB
bool "Broadcom BCM7XXX family"
select CPU_V7A
@@ -2267,7 +2260,6 @@ source "board/Marvell/octeontx2/Kconfig"
  source "board/armltd/vexpress/Kconfig"
  source "board/armltd/vexpress64/Kconfig"
  source "board/cortina/presidio-asic/Kconfig"
-source "board/broadcom/bcm96753ref/Kconfig"
  source "board/broadcom/bcmns3/Kconfig"
  source "board/cavium/thunderx/Kconfig"
  source "board/eets/pdu001/Kconfig"
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 5fd38cc63b63..8fba735cc8ab 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1147,9 +1147,6 @@ dtb-$(CONFIG_ARCH_BCM283X) += \
bcm2837-rpi-cm3-io3.dtb \
bcm2711-rpi-4-b.dtb
  
-dtb-$(CONFIG_ARCH_BCM6753) += \

-   bcm96753ref.dtb
-
  dtb-$(CONFIG_TARGET_BCMNS3) += ns3-board.dtb
  
  dtb-$(CONFIG_ARCH_BCMSTB) += bcm7xxx.dtb

@@ -1177,7 +1174,8 @@ dtb-$(CONFIG_BCM6813) += \
  dtb-$(CONFIG_BCM6846) += \
bcm96846.dtb
  dtb-$(CONFIG_BCM6855) += \
-   bcm96855.dtb
+   bcm96855.dtb \
+   bcm96753ref.dtb
  dtb-$(CONFIG_BCM6856) += \
bcm96856.dtb \
bcm968360bg.dtb
diff --git a/arch/arm/dts/bcm6753.dtsi b/arch/arm/dts/bcm6753.dtsi
deleted file mode 100644
index e88ab095c290..
--- a/arch/arm/dts/bcm6753.dtsi
+++ /dev/null
@@ -1,208 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2022 Philippe Reynes 
- */
-
-#include "skeleton.dtsi"
-
-/ {
-   compatible = "brcm,bcm6753";
-   #address-cells = <1>;
-   #size-cells = <1>;
-
-   cpus {
-   #address-cells = <1>;
-   #size-cells = <0>;
-   u-boot,dm-pre-reloc;
-
-   cpu0: cpu@0 {
-   compatible = "arm,cortex-a7";
-   device_type = "cpu";
-   reg = <0x0>;
-   next-level-cache = <>;
-   u-boot,dm-pre-reloc;
-   };
-
-   cpu1: cpu@1 {
-   compatible = "arm,cortex-a7";
-   device_type = "cpu";
-   reg = <0x1>;
-   next-level-cache = <>;
-   u-boot,dm-pre-reloc;
-   };
-
-   cpu2: cpu@2 {
-   compatible = "arm,cortex-a7";
-   device_type = "cpu";
-   reg = <0x2>;
-   next-level-cache = <>;
-   u-boot,dm-pre-reloc;
-   };
-
-   l2: l2-cache0 {
-   compatible = "cache";
-   u-boot,dm-pre-reloc;
-   };
-   };
-
-   clocks {
-   

Re: [PATCH v2 1/3] arm: bcmbca: add bcm6855 SoC support under CONFIG_ARCH_BCMBCA

2022-08-24 Thread Philippe REYNES

Hi William,

Le 22/08/2022 à 20:49, William Zhang a écrit :

BCM6855 is a Broadcom ARM A7 based PON Gateway SoC. It is part of the
BCA (Broadband Carrier Access origin) chipset family. Like other
broadband SoC, this patch adds it under CONFIG_BCM6855 chip config and
CONFIG_ARCH_BCMBCA platform config.

This initial support includes a bare-bone implementation and dts with
CPU subsystem, memory and ARM PL101 uart. This SoC is supported in the
linux-next git repository so the dts and dtsi files are copied from linux.

The u-boot image can be loaded from flash or network to the entry point
address in the memory and boot from there to the console.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 




---

Changes in v2:
- Add help in BCM6855 Kconfig option to include the list of the
supported chips.

  MAINTAINERS   |   1 +
  arch/arm/dts/Makefile |   2 +
  arch/arm/dts/bcm6855.dtsi | 120 ++
  arch/arm/dts/bcm96855.dts |  30 +++
  arch/arm/mach-bcmbca/Kconfig  |  11 +++
  arch/arm/mach-bcmbca/Makefile |   1 +
  arch/arm/mach-bcmbca/bcm6855/Kconfig  |  17 
  arch/arm/mach-bcmbca/bcm6855/Makefile |   5 ++
  board/broadcom/bcmbca/Kconfig |   7 ++
  configs/bcm96855_defconfig|  23 +
  include/configs/bcm96855.h|  11 +++
  11 files changed, 228 insertions(+)
  create mode 100644 arch/arm/dts/bcm6855.dtsi
  create mode 100644 arch/arm/dts/bcm96855.dts
  create mode 100644 arch/arm/mach-bcmbca/bcm6855/Kconfig
  create mode 100644 arch/arm/mach-bcmbca/bcm6855/Makefile
  create mode 100644 configs/bcm96855_defconfig
  create mode 100644 include/configs/bcm96855.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 819fa5b87824..371e84de1bc1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -230,6 +230,7 @@ N:  bcm[9]?63178
  N:bcm[9]?6756
  N:bcm[9]?6813
  N:bcm[9]?6846
+N: bcm[9]?6855
  N:bcm[9]?6856
  N:bcm[9]?6858
  N:bcm[9]?6878
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 07e6130042f5..5fd38cc63b63 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1176,6 +1176,8 @@ dtb-$(CONFIG_BCM6813) += \
bcm96813.dtb
  dtb-$(CONFIG_BCM6846) += \
bcm96846.dtb
+dtb-$(CONFIG_BCM6855) += \
+   bcm96855.dtb
  dtb-$(CONFIG_BCM6856) += \
bcm96856.dtb \
bcm968360bg.dtb
diff --git a/arch/arm/dts/bcm6855.dtsi b/arch/arm/dts/bcm6855.dtsi
new file mode 100644
index ..620f51aee1a2
--- /dev/null
+++ b/arch/arm/dts/bcm6855.dtsi
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright 2022 Broadcom Ltd.
+ */
+
+#include 
+#include 
+
+/ {
+   compatible = "brcm,bcm6855", "brcm,bcmbca";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   interrupt-parent = <>;
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   CA7_0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a7";
+   reg = <0x0>;
+   next-level-cache = <_0>;
+   enable-method = "psci";
+   };
+
+   CA7_1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a7";
+   reg = <0x1>;
+   next-level-cache = <_0>;
+   enable-method = "psci";
+   };
+
+   CA7_2: cpu@2 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a7";
+   reg = <0x2>;
+   next-level-cache = <_0>;
+   enable-method = "psci";
+   };
+
+   L2_0: l2-cache0 {
+   compatible = "cache";
+   };
+   };
+
+   timer {
+   compatible = "arm,armv7-timer";
+   interrupts = ,
+   ,
+   ,
+   ;
+   arm,cpu-registers-not-fw-configured;
+   };
+
+   pmu: pmu {
+   compatible = "arm,cortex-a7-pmu";
+   interrupts = ,
+   ,
+   ;
+   interrupt-affinity = <_0>, <_1>, <_2>;
+   };
+
+   clocks: clocks {
+   periph_clk: periph-clk {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <2>;
+   };
+
+   uart_clk: uart-clk {
+   compatible = "fixed-factor-clock";
+   #clock-cells = <0>;
+   clocks = <_clk>;
+   clock-div = <4>;
+   clock-mult = <1>;
+   };
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   

Re: [PATCH v2 3/3] arm: bcmbca: replace ARCH_BCM6858 symbols in Kconfig with BCM6858

2022-08-24 Thread Philippe REYNES

Hi William,


Le 22/08/2022 à 20:39, William Zhang a écrit :

As CONFIG_ARCH_BCM6858 is replaced with CONFIG_BCM6858, update the
driver Kconfig to use the new config symbol.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 




---

Changes in v2:
-Update subject line to be more clear for patch 3

  drivers/gpio/Kconfig | 3 +--
  drivers/led/Kconfig  | 2 +-
  drivers/mtd/nand/raw/Kconfig | 2 +-
  drivers/spi/Kconfig  | 3 +--
  drivers/watchdog/Kconfig | 3 +--
  5 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 9e00b48234ab..929f3fb9eacb 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -111,8 +111,7 @@ config BCM2835_GPIO
  config BCM6345_GPIO
bool "BCM6345 GPIO driver"
depends on DM_GPIO && (ARCH_BMIPS || BCM6856 || \
-  ARCH_BCM6858 || BCM63158 || \
-  ARCH_BCM6753)
+  BCM6858 || BCM63158 || ARCH_BCM6753)
help
  This driver supports the GPIO banks on BCM6345 SoCs.
  
diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig

index bd8f23fd9631..98f015a07f97 100644
--- a/drivers/led/Kconfig
+++ b/drivers/led/Kconfig
@@ -37,7 +37,7 @@ config LED_BCM6753
  
  config LED_BCM6858

bool "LED Support for BCM6858"
-   depends on LED && (BCM6856 || ARCH_BCM6858 || BCM63158)
+   depends on LED && (BCM6856 || BCM6858 || BCM63158)
help
  This option enables support for LEDs connected to the BCM6858
  HW has blinking capabilities and up to 32 LEDs can be controlled.
diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 5d006ca1ea07..f8445e09633c 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -115,7 +115,7 @@ config NAND_BRCMNAND_6838
  
  config NAND_BRCMNAND_6858

 bool "Support Broadcom NAND controller on bcm6858"
-   depends on NAND_BRCMNAND && ARCH_BCM6858
+   depends on NAND_BRCMNAND && BCM6858
 help
   Enable support for broadcom nand driver on bcm6858.
  
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig

index 978e5c86a420..e815a715f9b2 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -91,8 +91,7 @@ config ATMEL_SPI
  
  config BCM63XX_HSSPI

bool "BCM63XX HSSPI driver"
-   depends on (ARCH_BMIPS || BCM6856 || \
-   ARCH_BCM6858 || BCM63158)
+   depends on (ARCH_BMIPS || BCM6856 || BCM6858 || BCM63158)
help
  Enable the BCM6328 HSSPI driver. This driver can be used to
  access the SPI NOR flash on platforms embedding this Broadcom
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 6d559515b78b..84a4034fe87c 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -129,8 +129,7 @@ config WDT_AT91
  config WDT_BCM6345
bool "BCM6345 watchdog timer support"
depends on WDT && (ARCH_BMIPS || BCM6856 || \
-  ARCH_BCM6858 || BCM63158 || \
-  ARCH_BCM6753)
+  BCM6858 || BCM63158 || ARCH_BCM6753)
help
  Select this to enable watchdog timer for BCM6345 SoCs.
  The watchdog timer is stopped when initialized.


Re: [PATCH v2 2/3] arm: bcmbca: remove bcm6858 support under CONFIG_ARCH_BCM6858

2022-08-24 Thread Philippe REYNES

Hi William,


Le 22/08/2022 à 20:39, William Zhang a écrit :

Now that BCM6858 is supported under CONFIG_ARCH_BCMBCA and
CONFIG_BCM6858, remove the original ARCH_BCM6858 support and migrate its
configuration and dts settings. This includes:
- Remove the bcm968580xref board folder. It is replaced by the generic
bcmbca board folder.
- Update bcm968580xref board dts with the new compatible string.
- Delete broadcom_bcm968580xref.h and merge its setting to the new
bcm96858.h file.
- Remove bcm968580xref_ram_defconfig as a basic config version of
bcm96858_defconfig is now added.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 



---

(no changes since v1)

  arch/arm/Kconfig |  7 ---
  arch/arm/dts/Makefile|  6 +-
  arch/arm/dts/bcm968580xref.dts   |  4 +-
  board/broadcom/bcm968580xref/Kconfig | 17 --
  board/broadcom/bcm968580xref/MAINTAINERS |  6 --
  board/broadcom/bcm968580xref/Makefile|  3 -
  board/broadcom/bcm968580xref/bcm968580xref.c | 62 ---
  configs/bcm968580xref_ram_defconfig  | 64 
  include/configs/bcm96858.h   |  4 ++
  include/configs/broadcom_bcm968580xref.h | 32 --
  10 files changed, 8 insertions(+), 197 deletions(-)
  delete mode 100644 board/broadcom/bcm968580xref/Kconfig
  delete mode 100644 board/broadcom/bcm968580xref/MAINTAINERS
  delete mode 100644 board/broadcom/bcm968580xref/Makefile
  delete mode 100644 board/broadcom/bcm968580xref/bcm968580xref.c
  delete mode 100644 configs/bcm968580xref_ram_defconfig
  delete mode 100644 include/configs/broadcom_bcm968580xref.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3f124ab0ce85..063616ff8d0b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -672,12 +672,6 @@ config ARCH_BCM6753
select OF_CONTROL
imply CMD_DM
  
-config ARCH_BCM6858

-   bool "Broadcom BCM6858 family"
-   select DM
-   select OF_CONTROL
-   imply CMD_DM
-
  config ARCH_BCMSTB
bool "Broadcom BCM7XXX family"
select CPU_V7A
@@ -2274,7 +2268,6 @@ source "board/armltd/vexpress/Kconfig"
  source "board/armltd/vexpress64/Kconfig"
  source "board/cortina/presidio-asic/Kconfig"
  source "board/broadcom/bcm96753ref/Kconfig"
-source "board/broadcom/bcm968580xref/Kconfig"
  source "board/broadcom/bcmns3/Kconfig"
  source "board/cavium/thunderx/Kconfig"
  source "board/eets/pdu001/Kconfig"
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index ee3475b97a40..07e6130042f5 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1150,9 +1150,6 @@ dtb-$(CONFIG_ARCH_BCM283X) += \
  dtb-$(CONFIG_ARCH_BCM6753) += \
bcm96753ref.dtb
  
-dtb-$(CONFIG_ARCH_BCM6858) += \

-   bcm968580xref.dtb
-
  dtb-$(CONFIG_TARGET_BCMNS3) += ns3-board.dtb
  
  dtb-$(CONFIG_ARCH_BCMSTB) += bcm7xxx.dtb

@@ -1183,7 +1180,8 @@ dtb-$(CONFIG_BCM6856) += \
bcm96856.dtb \
bcm968360bg.dtb
  dtb-$(CONFIG_BCM6858) += \
-   bcm96858.dtb
+   bcm96858.dtb \
+   bcm968580xref.dtb
  dtb-$(CONFIG_BCM6878) += \
bcm96878.dtb
  
diff --git a/arch/arm/dts/bcm968580xref.dts b/arch/arm/dts/bcm968580xref.dts

index a034e38318bd..6d787bd011b8 100644
--- a/arch/arm/dts/bcm968580xref.dts
+++ b/arch/arm/dts/bcm968580xref.dts
@@ -8,8 +8,8 @@
  #include "bcm6858.dtsi"
  
  / {

-   model = "Broadcom bcm68580xref";
-   compatible = "broadcom,bcm68580xref", "brcm,bcm6858";
+   model = "Broadcom BCM968580xref Reference Board";
+   compatible = "brcm,bcm968580xref", "brcm,bcm6858", "brcm,bcmbca";
  
  	aliases {

serial0 = 
diff --git a/board/broadcom/bcm968580xref/Kconfig 
b/board/broadcom/bcm968580xref/Kconfig
deleted file mode 100644
index b5730367a2d2..
--- a/board/broadcom/bcm968580xref/Kconfig
+++ /dev/null
@@ -1,17 +0,0 @@
-if ARCH_BCM6858
-
-config SYS_VENDOR
-   default "broadcom"
-
-config SYS_BOARD
-   default "bcm968580xref"
-
-config SYS_CONFIG_NAME
-   default "broadcom_bcm968580xref"
-
-endif
-
-config TARGET_BCM968580XREF
-   bool "Support Broadcom bcm968580xref"
-   depends on ARCH_BCM6858
-   select ARM64
diff --git a/board/broadcom/bcm968580xref/MAINTAINERS 
b/board/broadcom/bcm968580xref/MAINTAINERS
deleted file mode 100644
index 5ee0c4dd4e42..
--- a/board/broadcom/bcm968580xref/MAINTAINERS
+++ /dev/null
@@ -1,6 +0,0 @@
-BCM968580XREF BOARD
-M: Philippe Reynes 
-S: Maintained
-F: board/broadcom/bcm968580xref/
-F: include/configs/broadcom_bcm968580xref.h
-F: configs/bcm968580xref_ram_defconfig
diff --git a/board/broadcom/bcm968580xref/Makefile 
b/board/broadcom/bcm968580xref/Makefile
deleted file mode 100644
index 5cd393b19629..
--- a/board/broadcom/bcm968580xref/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-
-obj-y  += bcm968580xref.o
diff --git 

Re: [PATCH v2 1/3] arm: bcmbca: add bcm6858 SoC support under CONFIG_ARCH_BCMBCA

2022-08-24 Thread Philippe REYNES

Hi William,


Le 22/08/2022 à 20:39, William Zhang a écrit :

BCM6858 is a Broadcom B53 based PON Gateway SoC. It is part of the BCA
(Broadband Carrier Access origin) chipset family. Like other broadband
SoC, this patch adds it under CONFIG_BCM6858 chip config and
CONFIG_ARCH_BCMBCA platform config.

This initial support includes a bare-bone implementation and the
original dts is updated with the one from linux next git repository.

The u-boot image can be loaded from flash or network to the entry point
address in the memory and boot from there to the console.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 




---

Changes in v2:
-Add help in BCM6858 Kconfig option to include the list of the supported
chips.

  MAINTAINERS  |   1 +
  arch/arm/dts/Makefile|   2 +
  arch/arm/dts/bcm6858.dtsi| 197 ++-
  arch/arm/dts/bcm96858.dts|  30 
  arch/arm/mach-bcmbca/Kconfig |  11 ++
  arch/arm/mach-bcmbca/Makefile|   1 +
  arch/arm/mach-bcmbca/bcm6858/Kconfig |  17 ++
  arch/arm/mach-bcmbca/bcm6858/Makefile|   5 +
  arch/arm/mach-bcmbca/bcm6858/mmu_table.c |  32 
  board/broadcom/bcmbca/Kconfig|   7 +
  configs/bcm96858_defconfig   |  23 +++
  include/configs/bcm96858.h   |  11 ++
  12 files changed, 258 insertions(+), 79 deletions(-)
  create mode 100644 arch/arm/dts/bcm96858.dts
  create mode 100644 arch/arm/mach-bcmbca/bcm6858/Kconfig
  create mode 100644 arch/arm/mach-bcmbca/bcm6858/Makefile
  create mode 100644 arch/arm/mach-bcmbca/bcm6858/mmu_table.c
  create mode 100644 configs/bcm96858_defconfig
  create mode 100644 include/configs/bcm96858.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 1f50dad583ce..819fa5b87824 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -231,6 +231,7 @@ N:  bcm[9]?6756
  N:bcm[9]?6813
  N:bcm[9]?6846
  N:bcm[9]?6856
+N: bcm[9]?6858
  N:bcm[9]?6878
  
  ARM BROADCOM BCMSTB

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index a0ea9fa6029d..ee3475b97a40 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1182,6 +1182,8 @@ dtb-$(CONFIG_BCM6846) += \
  dtb-$(CONFIG_BCM6856) += \
bcm96856.dtb \
bcm968360bg.dtb
+dtb-$(CONFIG_BCM6858) += \
+   bcm96858.dtb
  dtb-$(CONFIG_BCM6878) += \
bcm96878.dtb
  
diff --git a/arch/arm/dts/bcm6858.dtsi b/arch/arm/dts/bcm6858.dtsi

index 02225621710b..19c4dd6fa7e4 100644
--- a/arch/arm/dts/bcm6858.dtsi
+++ b/arch/arm/dts/bcm6858.dtsi
@@ -1,122 +1,161 @@
  // SPDX-License-Identifier: GPL-2.0+
  /*
   * Copyright (C) 2018 Philippe Reynes 
+ * Copyright 2022 Broadcom Ltd.
   */
  
-#include "skeleton64.dtsi"

+#include 
+#include 
  
  / {

-   compatible = "brcm,bcm6858";
+   compatible = "brcm,bcm6858", "brcm,bcmbca";
#address-cells = <2>;
#size-cells = <2>;
  
-	aliases {

-   spi0 = 
-   };
+   interrupt-parent = <>;
  
  	cpus {

#address-cells = <2>;
#size-cells = <0>;
-   u-boot,dm-pre-reloc;
  
-		cpu0: cpu@0 {

-   compatible = "arm,cortex-a53", "arm,armv8";
+   B53_0: cpu@0 {
+   compatible = "brcm,brahma-b53";
device_type = "cpu";
reg = <0x0 0x0>;
-   next-level-cache = <>;
-   u-boot,dm-pre-reloc;
+   next-level-cache = <_0>;
+   enable-method = "psci";
};
  
-		cpu1: cpu@1 {

-   compatible = "arm,cortex-a53", "arm,armv8";
+   B53_1: cpu@1 {
+   compatible = "brcm,brahma-b53";
device_type = "cpu";
reg = <0x0 0x1>;
-   next-level-cache = <>;
-   u-boot,dm-pre-reloc;
+   next-level-cache = <_0>;
+   enable-method = "psci";
};
  
-		cpu2: cpu@2 {

-   compatible = "arm,cortex-a53", "arm,armv8";
+   B53_2: cpu@2 {
+   compatible = "brcm,brahma-b53";
device_type = "cpu";
reg = <0x0 0x2>;
-   next-level-cache = <>;
-   u-boot,dm-pre-reloc;
+   next-level-cache = <_0>;
+   enable-method = "psci";
};
  
-		cpu3: cpu@3 {

-   compatible = "arm,cortex-a53", "arm,armv8";
+   B53_3: cpu@3 {
+   compatible = "brcm,brahma-b53";
device_type = "cpu";
reg = <0x0 0x3>;
-   next-level-cache = <>;
-   u-boot,dm-pre-reloc;
+   next-level-cache = <_0>;
+   

Re: [PATCH v4 3/3] arm: bcmbca: replace ARCH_BCM68360 symbols in Kconfig with BCM6856

2022-08-24 Thread Philippe REYNES

Hi William,


Le 22/08/2022 à 20:31, William Zhang a écrit :

As CONFIG_ARCH_BCM68360 is replaced with CONFIG_BCM6856, update the
driver Kconfig to use the new config symbol.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 




---

Changes in v4:
-Update subject line to be more clear for patch 3

  drivers/gpio/Kconfig | 2 +-
  drivers/led/Kconfig  | 2 +-
  drivers/mtd/nand/raw/Kconfig | 2 +-
  drivers/spi/Kconfig  | 2 +-
  drivers/watchdog/Kconfig | 2 +-
  5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 83f4f5089992..9e00b48234ab 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -110,7 +110,7 @@ config BCM2835_GPIO
  
  config BCM6345_GPIO

bool "BCM6345 GPIO driver"
-   depends on DM_GPIO && (ARCH_BMIPS || ARCH_BCM68360 || \
+   depends on DM_GPIO && (ARCH_BMIPS || BCM6856 || \
   ARCH_BCM6858 || BCM63158 || \
   ARCH_BCM6753)
help
diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig
index d777414dda8d..bd8f23fd9631 100644
--- a/drivers/led/Kconfig
+++ b/drivers/led/Kconfig
@@ -37,7 +37,7 @@ config LED_BCM6753
  
  config LED_BCM6858

bool "LED Support for BCM6858"
-   depends on LED && (ARCH_BCM68360 || ARCH_BCM6858 || BCM63158)
+   depends on LED && (BCM6856 || ARCH_BCM6858 || BCM63158)
help
  This option enables support for LEDs connected to the BCM6858
  HW has blinking capabilities and up to 32 LEDs can be controlled.
diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 24c27b6ecf7f..5d006ca1ea07 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -103,7 +103,7 @@ config NAND_BRCMNAND_6753
  
  config NAND_BRCMNAND_68360

 bool "Support Broadcom NAND controller on bcm68360"
-   depends on NAND_BRCMNAND && ARCH_BCM68360
+   depends on NAND_BRCMNAND && BCM6856
 help
   Enable support for broadcom nand driver on bcm68360.
  
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig

index 0a666eee80e7..978e5c86a420 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -91,7 +91,7 @@ config ATMEL_SPI
  
  config BCM63XX_HSSPI

bool "BCM63XX HSSPI driver"
-   depends on (ARCH_BMIPS || ARCH_BCM68360 || \
+   depends on (ARCH_BMIPS || BCM6856 || \
ARCH_BCM6858 || BCM63158)
help
  Enable the BCM6328 HSSPI driver. This driver can be used to
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index ff4d1ee530d2..6d559515b78b 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -128,7 +128,7 @@ config WDT_AT91
  
  config WDT_BCM6345

bool "BCM6345 watchdog timer support"
-   depends on WDT && (ARCH_BMIPS || ARCH_BCM68360 || \
+   depends on WDT && (ARCH_BMIPS || BCM6856 || \
   ARCH_BCM6858 || BCM63158 || \
   ARCH_BCM6753)
help


Re: [PATCH v4 2/3] arm: bcmbca: remove bcm68360 support under CONFIG_ARCH_BCM68360

2022-08-24 Thread Philippe REYNES

Hi William,


Le 22/08/2022 à 20:31, William Zhang a écrit :

BCM68360 is a variant within the BCM6856 chip family. Now that BCM6856
is supported under CONFIG_ARCH_BCMBCA and CONFIG_BCM6856, remove the
original ARCH_BCM68360 support and migrate its configuration and dts
settings. This includes:
   - Remove the bcm968360bg board folder. It is replaced by the generic
 bcmbca board folder.
   - Merge the 68360.dtsi setting to the new 6856.dtsi file. Update board
 dts with the new compatible string.
   - Merge broadcom_bcm968360bg.h setting to the new bcm96856.h file.
   - Remove bcm968360bg_ram_defconfig as a basic config version of
 bcm96856_defconfig is now added.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 



---

(no changes since v3)

Changes in v3:
- Remove bcm968360bg_ram_defconfig per discussion with Philippe as a
basic config version of bcm96856_defconfig is now added.
- Update commit message

Changes in v2:
- Bring Philippe Reynes copyright tag from 68360 dts to 6856 dts

  arch/arm/Kconfig |   7 -
  arch/arm/dts/Makefile|   6 +-
  arch/arm/dts/bcm68360.dtsi   | 217 ---
  arch/arm/dts/bcm6856.dtsi| 150 
  arch/arm/dts/bcm968360bg.dts |   6 +-
  board/broadcom/bcm968360bg/Kconfig   |  17 --
  board/broadcom/bcm968360bg/MAINTAINERS   |   6 -
  board/broadcom/bcm968360bg/Makefile  |   3 -
  board/broadcom/bcm968360bg/bcm968360bg.c |  62 ---
  configs/bcm968360bg_ram_defconfig|  63 ---
  include/configs/bcm96856.h   |   4 +
  include/configs/broadcom_bcm968360bg.h   |  32 
  12 files changed, 159 insertions(+), 414 deletions(-)
  delete mode 100644 arch/arm/dts/bcm68360.dtsi
  delete mode 100644 board/broadcom/bcm968360bg/Kconfig
  delete mode 100644 board/broadcom/bcm968360bg/MAINTAINERS
  delete mode 100644 board/broadcom/bcm968360bg/Makefile
  delete mode 100644 board/broadcom/bcm968360bg/bcm968360bg.c
  delete mode 100644 configs/bcm968360bg_ram_defconfig
  delete mode 100644 include/configs/broadcom_bcm968360bg.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index da4defa08466..3f124ab0ce85 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -672,12 +672,6 @@ config ARCH_BCM6753
select OF_CONTROL
imply CMD_DM
  
-config ARCH_BCM68360

-   bool "Broadcom BCM68360 family"
-   select DM
-   select OF_CONTROL
-   imply CMD_DM
-
  config ARCH_BCM6858
bool "Broadcom BCM6858 family"
select DM
@@ -2280,7 +2274,6 @@ source "board/armltd/vexpress/Kconfig"
  source "board/armltd/vexpress64/Kconfig"
  source "board/cortina/presidio-asic/Kconfig"
  source "board/broadcom/bcm96753ref/Kconfig"
-source "board/broadcom/bcm968360bg/Kconfig"
  source "board/broadcom/bcm968580xref/Kconfig"
  source "board/broadcom/bcmns3/Kconfig"
  source "board/cavium/thunderx/Kconfig"
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index a32bdf8c9f17..a0ea9fa6029d 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1147,9 +1147,6 @@ dtb-$(CONFIG_ARCH_BCM283X) += \
bcm2837-rpi-cm3-io3.dtb \
bcm2711-rpi-4-b.dtb
  
-dtb-$(CONFIG_ARCH_BCM68360) += \

-   bcm968360bg.dtb
-
  dtb-$(CONFIG_ARCH_BCM6753) += \
bcm96753ref.dtb
  
@@ -1183,7 +1180,8 @@ dtb-$(CONFIG_BCM6813) += \

  dtb-$(CONFIG_BCM6846) += \
bcm96846.dtb
  dtb-$(CONFIG_BCM6856) += \
-   bcm96856.dtb
+   bcm96856.dtb \
+   bcm968360bg.dtb
  dtb-$(CONFIG_BCM6878) += \
bcm96878.dtb
  
diff --git a/arch/arm/dts/bcm68360.dtsi b/arch/arm/dts/bcm68360.dtsi

deleted file mode 100644
index 7bbe207794eb..
--- a/arch/arm/dts/bcm68360.dtsi
+++ /dev/null
@@ -1,217 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2020 Philippe Reynes 
- */
-
-#include "skeleton64.dtsi"
-
-/ {
-   compatible = "brcm,bcm68360";
-   #address-cells = <2>;
-   #size-cells = <2>;
-
-   aliases {
-   spi0 = 
-   };
-
-   cpus {
-   #address-cells = <2>;
-   #size-cells = <0>;
-   u-boot,dm-pre-reloc;
-
-   cpu0: cpu@0 {
-   compatible = "arm,cortex-a53", "arm,armv8";
-   device_type = "cpu";
-   reg = <0x0 0x0>;
-   next-level-cache = <>;
-   u-boot,dm-pre-reloc;
-   };
-
-   cpu1: cpu@1 {
-   compatible = "arm,cortex-a53", "arm,armv8";
-   device_type = "cpu";
-   reg = <0x0 0x1>;
-   next-level-cache = <>;
-   u-boot,dm-pre-reloc;
-   };
-
-   l2: l2-cache0 {
-   compatible = "cache";
-   u-boot,dm-pre-reloc;
-   };
-   };
-
-   clocks {
-   compatible = 

Re: [PATCH v4 1/3] arm: bcmbca: add bcm6856 SoC support under CONFIG_ARCH_BCMBCA

2022-08-24 Thread Philippe REYNES

Hi William,


Le 22/08/2022 à 20:31, William Zhang a écrit :

BCM6856 is a Broadcom B53 based PON Gateway SoC. It is part of the BCA
(Broadband Carrier Access origin) chipset family. Like other Broadband
SoC, this patch adds it under CONFIG_BCM6856 chip config and
CONFIG_ARCH_BCMBCA platform config.

This initial support includes a bare-bone implementation and dts with
CPU subsystem, memory and Broadcom uart. This SoC is supported in the
linux-next git repository so the dts and dtsi files are copied from
linux.

The u-boot image can be loaded from flash or network to the entry point
address in the memory and boot from there to the console.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 




---

Changes in v4:
-Add help in BCM6856 Kconfig option to include the list of the supported
chips.

  MAINTAINERS  |   1 +
  arch/arm/dts/Makefile|   2 +
  arch/arm/dts/bcm6856.dtsi| 103 +++
  arch/arm/dts/bcm96856.dts|  30 +++
  arch/arm/mach-bcmbca/Kconfig |  11 +++
  arch/arm/mach-bcmbca/Makefile|   1 +
  arch/arm/mach-bcmbca/bcm6856/Kconfig |  17 
  arch/arm/mach-bcmbca/bcm6856/Makefile|   5 ++
  arch/arm/mach-bcmbca/bcm6856/mmu_table.c |  32 +++
  board/broadcom/bcmbca/Kconfig|   7 ++
  configs/bcm96856_defconfig   |  23 +
  include/configs/bcm96856.h   |  11 +++
  12 files changed, 243 insertions(+)
  create mode 100644 arch/arm/dts/bcm6856.dtsi
  create mode 100644 arch/arm/dts/bcm96856.dts
  create mode 100644 arch/arm/mach-bcmbca/bcm6856/Kconfig
  create mode 100644 arch/arm/mach-bcmbca/bcm6856/Makefile
  create mode 100644 arch/arm/mach-bcmbca/bcm6856/mmu_table.c
  create mode 100644 configs/bcm96856_defconfig
  create mode 100644 include/configs/bcm96856.h

diff --git a/MAINTAINERS b/MAINTAINERS
index d0a5b2352cc8..1f50dad583ce 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -230,6 +230,7 @@ N:  bcm[9]?63178
  N:bcm[9]?6756
  N:bcm[9]?6813
  N:bcm[9]?6846
+N: bcm[9]?6856
  N:bcm[9]?6878
  
  ARM BROADCOM BCMSTB

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index c55bc3569662..a32bdf8c9f17 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1182,6 +1182,8 @@ dtb-$(CONFIG_BCM6813) += \
bcm96813.dtb
  dtb-$(CONFIG_BCM6846) += \
bcm96846.dtb
+dtb-$(CONFIG_BCM6856) += \
+   bcm96856.dtb
  dtb-$(CONFIG_BCM6878) += \
bcm96878.dtb
  
diff --git a/arch/arm/dts/bcm6856.dtsi b/arch/arm/dts/bcm6856.dtsi

new file mode 100644
index ..0bce6497219f
--- /dev/null
+++ b/arch/arm/dts/bcm6856.dtsi
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright 2022 Broadcom Ltd.
+ */
+
+#include 
+#include 
+
+/ {
+   compatible = "brcm,bcm6856", "brcm,bcmbca";
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   interrupt-parent = <>;
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   B53_0: cpu@0 {
+   compatible = "brcm,brahma-b53";
+   device_type = "cpu";
+   reg = <0x0 0x0>;
+   next-level-cache = <_0>;
+   enable-method = "psci";
+   };
+
+   B53_1: cpu@1 {
+   compatible = "brcm,brahma-b53";
+   device_type = "cpu";
+   reg = <0x0 0x1>;
+   next-level-cache = <_0>;
+   enable-method = "psci";
+   };
+
+   L2_0: l2-cache0 {
+   compatible = "cache";
+   };
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+   ,
+   ,
+   ;
+   };
+
+   pmu: pmu {
+   compatible = "arm,cortex-a53-pmu";
+   interrupts = ,
+   ;
+   interrupt-affinity = <_0>, <_1>;
+   };
+
+   clocks: clocks {
+   periph_clk:periph-clk {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <2>;
+   };
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   axi@8100 {
+   compatible = "simple-bus";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges = <0x0 0x0 0x8100 0x8000>;
+
+   gic: interrupt-controller@1000 {
+   compatible = "arm,gic-400";
+   #interrupt-cells = <3>;
+   interrupt-controller;
+   reg = <0x1000 0x1000>, /* GICD */
+   <0x2000 0x2000>, 

Re: [PATCH v2 3/3] arm: bcmbca: make bcm68360 driver depending on CONFIG_BCM6856

2022-08-24 Thread Philippe REYNES

Hi William,


Le 15/08/2022 à 20:55, William Zhang a écrit :

As CONFIG_ARCH_BCM68360 is replaced with CONFIG_BCM6856, update the
driver Kconfig to use the new config symbol

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 




---

(no changes since v1)

  drivers/gpio/Kconfig | 2 +-
  drivers/led/Kconfig  | 2 +-
  drivers/mtd/nand/raw/Kconfig | 2 +-
  drivers/spi/Kconfig  | 2 +-
  drivers/watchdog/Kconfig | 2 +-
  5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 83f4f5089992..9e00b48234ab 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -110,7 +110,7 @@ config BCM2835_GPIO
  
  config BCM6345_GPIO

bool "BCM6345 GPIO driver"
-   depends on DM_GPIO && (ARCH_BMIPS || ARCH_BCM68360 || \
+   depends on DM_GPIO && (ARCH_BMIPS || BCM6856 || \
   ARCH_BCM6858 || BCM63158 || \
   ARCH_BCM6753)
help
diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig
index d777414dda8d..bd8f23fd9631 100644
--- a/drivers/led/Kconfig
+++ b/drivers/led/Kconfig
@@ -37,7 +37,7 @@ config LED_BCM6753
  
  config LED_BCM6858

bool "LED Support for BCM6858"
-   depends on LED && (ARCH_BCM68360 || ARCH_BCM6858 || BCM63158)
+   depends on LED && (BCM6856 || ARCH_BCM6858 || BCM63158)
help
  This option enables support for LEDs connected to the BCM6858
  HW has blinking capabilities and up to 32 LEDs can be controlled.
diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 24c27b6ecf7f..5d006ca1ea07 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -103,7 +103,7 @@ config NAND_BRCMNAND_6753
  
  config NAND_BRCMNAND_68360

 bool "Support Broadcom NAND controller on bcm68360"
-   depends on NAND_BRCMNAND && ARCH_BCM68360
+   depends on NAND_BRCMNAND && BCM6856
 help
   Enable support for broadcom nand driver on bcm68360.
  
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig

index 0a666eee80e7..978e5c86a420 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -91,7 +91,7 @@ config ATMEL_SPI
  
  config BCM63XX_HSSPI

bool "BCM63XX HSSPI driver"
-   depends on (ARCH_BMIPS || ARCH_BCM68360 || \
+   depends on (ARCH_BMIPS || BCM6856 || \
ARCH_BCM6858 || BCM63158)
help
  Enable the BCM6328 HSSPI driver. This driver can be used to
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index ff4d1ee530d2..6d559515b78b 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -128,7 +128,7 @@ config WDT_AT91
  
  config WDT_BCM6345

bool "BCM6345 watchdog timer support"
-   depends on WDT && (ARCH_BMIPS || ARCH_BCM68360 || \
+   depends on WDT && (ARCH_BMIPS || BCM6856 || \
   ARCH_BCM6858 || BCM63158 || \
   ARCH_BCM6753)
help


Re: [PATCH v2 2/3] arm: bcmbca: remove bcm68360 support under CONFIG_ARCH_BCM68360

2022-08-24 Thread Philippe REYNES

Hi William,


Le 15/08/2022 à 20:55, William Zhang a écrit :

BCM68360 is a variant within the BCM6856 chip family. Now that BCM6856
is supported under CONFIG_ARCH_BCMBCA and CONFIG_BCM6856, remove the
original ARCH_BCM68360 support and migrate its configuration and dts
settings. This includes:
   - Remove the bcm968360bg board folder. It is replaced by the generic
 bcmbca board folder.
   - Merge the 68360.dtsi setting to the new 6856.dtsi file. Update board
 dts with the new compatible string.
   - Merge broadcom_bcm968360bg.h setting to the new bcm96856.h file.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 




---

Changes in v2:
- Bring Philippe Reynes copyright tag from 68360 dts to 6856 dts

  arch/arm/Kconfig |   7 -
  arch/arm/dts/Makefile|   6 +-
  arch/arm/dts/bcm68360.dtsi   | 217 ---
  arch/arm/dts/bcm6856.dtsi| 150 
  arch/arm/dts/bcm968360bg.dts |   6 +-
  board/broadcom/bcm968360bg/Kconfig   |  17 --
  board/broadcom/bcm968360bg/MAINTAINERS   |   6 -
  board/broadcom/bcm968360bg/Makefile  |   3 -
  board/broadcom/bcm968360bg/bcm968360bg.c |  62 ---
  configs/bcm968360bg_ram_defconfig|  10 +-
  include/configs/bcm96856.h   |   4 +
  include/configs/broadcom_bcm968360bg.h   |  32 
  12 files changed, 164 insertions(+), 356 deletions(-)
  delete mode 100644 arch/arm/dts/bcm68360.dtsi
  delete mode 100644 board/broadcom/bcm968360bg/Kconfig
  delete mode 100644 board/broadcom/bcm968360bg/MAINTAINERS
  delete mode 100644 board/broadcom/bcm968360bg/Makefile
  delete mode 100644 board/broadcom/bcm968360bg/bcm968360bg.c
  delete mode 100644 include/configs/broadcom_bcm968360bg.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index da4defa08466..3f124ab0ce85 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -672,12 +672,6 @@ config ARCH_BCM6753
select OF_CONTROL
imply CMD_DM
  
-config ARCH_BCM68360

-   bool "Broadcom BCM68360 family"
-   select DM
-   select OF_CONTROL
-   imply CMD_DM
-
  config ARCH_BCM6858
bool "Broadcom BCM6858 family"
select DM
@@ -2280,7 +2274,6 @@ source "board/armltd/vexpress/Kconfig"
  source "board/armltd/vexpress64/Kconfig"
  source "board/cortina/presidio-asic/Kconfig"
  source "board/broadcom/bcm96753ref/Kconfig"
-source "board/broadcom/bcm968360bg/Kconfig"
  source "board/broadcom/bcm968580xref/Kconfig"
  source "board/broadcom/bcmns3/Kconfig"
  source "board/cavium/thunderx/Kconfig"
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index a32bdf8c9f17..a0ea9fa6029d 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1147,9 +1147,6 @@ dtb-$(CONFIG_ARCH_BCM283X) += \
bcm2837-rpi-cm3-io3.dtb \
bcm2711-rpi-4-b.dtb
  
-dtb-$(CONFIG_ARCH_BCM68360) += \

-   bcm968360bg.dtb
-
  dtb-$(CONFIG_ARCH_BCM6753) += \
bcm96753ref.dtb
  
@@ -1183,7 +1180,8 @@ dtb-$(CONFIG_BCM6813) += \

  dtb-$(CONFIG_BCM6846) += \
bcm96846.dtb
  dtb-$(CONFIG_BCM6856) += \
-   bcm96856.dtb
+   bcm96856.dtb \
+   bcm968360bg.dtb
  dtb-$(CONFIG_BCM6878) += \
bcm96878.dtb
  
diff --git a/arch/arm/dts/bcm68360.dtsi b/arch/arm/dts/bcm68360.dtsi

deleted file mode 100644
index 7bbe207794eb..
--- a/arch/arm/dts/bcm68360.dtsi
+++ /dev/null
@@ -1,217 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2020 Philippe Reynes 
- */
-
-#include "skeleton64.dtsi"
-
-/ {
-   compatible = "brcm,bcm68360";
-   #address-cells = <2>;
-   #size-cells = <2>;
-
-   aliases {
-   spi0 = 
-   };
-
-   cpus {
-   #address-cells = <2>;
-   #size-cells = <0>;
-   u-boot,dm-pre-reloc;
-
-   cpu0: cpu@0 {
-   compatible = "arm,cortex-a53", "arm,armv8";
-   device_type = "cpu";
-   reg = <0x0 0x0>;
-   next-level-cache = <>;
-   u-boot,dm-pre-reloc;
-   };
-
-   cpu1: cpu@1 {
-   compatible = "arm,cortex-a53", "arm,armv8";
-   device_type = "cpu";
-   reg = <0x0 0x1>;
-   next-level-cache = <>;
-   u-boot,dm-pre-reloc;
-   };
-
-   l2: l2-cache0 {
-   compatible = "cache";
-   u-boot,dm-pre-reloc;
-   };
-   };
-
-   clocks {
-   compatible = "simple-bus";
-   #address-cells = <2>;
-   #size-cells = <2>;
-   ranges;
-   u-boot,dm-pre-reloc;
-
-   periph_osc: periph-osc {
-   compatible = "fixed-clock";
-   #clock-cells = <0>;
-   clock-frequency = <2>;
-

Re: [PATCH v2 1/3] arm: bcmbca: add bcm6856 SoC support under CONFIG_ARCH_BCMBCA

2022-08-24 Thread Philippe REYNES

Hi William,


Le 15/08/2022 à 20:55, William Zhang a écrit :

BCM6856 is a Broadcom B53 based PON Gateway SoC. It is part of the BCA
(Broadband Carrier Access origin) chipset family. Like other Broadband
SoC, this patch adds it under CONFIG_BCM6856 chip config and
CONFIG_ARCH_BCMBCA platform config.

This initial support includes a bare-bone implementation and dts with
CPU subsystem, memory and Broadcom uart. This SoC is supported in the
linux-next git repository so the dts and dtsi files are copied from
linux.

The u-boot image can be loaded from flash or network to the entry point
address in the memory and boot from there to the console.

Signed-off-by: William Zhang 



Reviewed-by: Philippe Reynes 



---

(no changes since v1)

  MAINTAINERS  |   1 +
  arch/arm/dts/Makefile|   2 +
  arch/arm/dts/bcm6856.dtsi| 103 +++
  arch/arm/dts/bcm96856.dts|  30 +++
  arch/arm/mach-bcmbca/Kconfig |   8 ++
  arch/arm/mach-bcmbca/Makefile|   1 +
  arch/arm/mach-bcmbca/bcm6856/Kconfig |  17 
  arch/arm/mach-bcmbca/bcm6856/Makefile|   5 ++
  arch/arm/mach-bcmbca/bcm6856/mmu_table.c |  32 +++
  board/broadcom/bcmbca/Kconfig|   7 ++
  configs/bcm96856_defconfig   |  23 +
  include/configs/bcm96856.h   |  11 +++
  12 files changed, 240 insertions(+)
  create mode 100644 arch/arm/dts/bcm6856.dtsi
  create mode 100644 arch/arm/dts/bcm96856.dts
  create mode 100644 arch/arm/mach-bcmbca/bcm6856/Kconfig
  create mode 100644 arch/arm/mach-bcmbca/bcm6856/Makefile
  create mode 100644 arch/arm/mach-bcmbca/bcm6856/mmu_table.c
  create mode 100644 configs/bcm96856_defconfig
  create mode 100644 include/configs/bcm96856.h

diff --git a/MAINTAINERS b/MAINTAINERS
index d0a5b2352cc8..1f50dad583ce 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -230,6 +230,7 @@ N:  bcm[9]?63178
  N:bcm[9]?6756
  N:bcm[9]?6813
  N:bcm[9]?6846
+N: bcm[9]?6856
  N:bcm[9]?6878
  
  ARM BROADCOM BCMSTB

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index c55bc3569662..a32bdf8c9f17 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1182,6 +1182,8 @@ dtb-$(CONFIG_BCM6813) += \
bcm96813.dtb
  dtb-$(CONFIG_BCM6846) += \
bcm96846.dtb
+dtb-$(CONFIG_BCM6856) += \
+   bcm96856.dtb
  dtb-$(CONFIG_BCM6878) += \
bcm96878.dtb
  
diff --git a/arch/arm/dts/bcm6856.dtsi b/arch/arm/dts/bcm6856.dtsi

new file mode 100644
index ..0bce6497219f
--- /dev/null
+++ b/arch/arm/dts/bcm6856.dtsi
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright 2022 Broadcom Ltd.
+ */
+
+#include 
+#include 
+
+/ {
+   compatible = "brcm,bcm6856", "brcm,bcmbca";
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   interrupt-parent = <>;
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   B53_0: cpu@0 {
+   compatible = "brcm,brahma-b53";
+   device_type = "cpu";
+   reg = <0x0 0x0>;
+   next-level-cache = <_0>;
+   enable-method = "psci";
+   };
+
+   B53_1: cpu@1 {
+   compatible = "brcm,brahma-b53";
+   device_type = "cpu";
+   reg = <0x0 0x1>;
+   next-level-cache = <_0>;
+   enable-method = "psci";
+   };
+
+   L2_0: l2-cache0 {
+   compatible = "cache";
+   };
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+   ,
+   ,
+   ;
+   };
+
+   pmu: pmu {
+   compatible = "arm,cortex-a53-pmu";
+   interrupts = ,
+   ;
+   interrupt-affinity = <_0>, <_1>;
+   };
+
+   clocks: clocks {
+   periph_clk:periph-clk {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <2>;
+   };
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   axi@8100 {
+   compatible = "simple-bus";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges = <0x0 0x0 0x8100 0x8000>;
+
+   gic: interrupt-controller@1000 {
+   compatible = "arm,gic-400";
+   #interrupt-cells = <3>;
+   interrupt-controller;
+   reg = <0x1000 0x1000>, /* GICD */
+   <0x2000 0x2000>, /* GICC */
+   <0x4000 0x2000>, /* GICH */
+   

Re: [PATCH v2 00/19] imx: kontron-sl-mx8mm: Improvements and OSM board support

2022-08-24 Thread Fabio Estevam
Hi Frieder,

On Mon, Aug 1, 2022 at 7:30 AM Frieder Schrempf  wrote:
>
> From: Frieder Schrempf 
>
> This set contains several improvements for the kontron-sl-mx8mm board
> configuration (patches 1-17, 19) and support for a new SoM (patch 18,
> including baseboard) that complies to the Open Standard Module (OSM) 1.0
> hardware specification, size S (https://sget.org/standards/osm).
>
> Changes in v2:
> * rebase on u-boot-imx/master
> * new patches 2-5, 19
> * fix printf warning in board/kontron/sl-mx8mm/spl.c
> * remove unused pinmux definitions in board/kontron/sl-mx8mm/spl.c
> * describe SPI NOR partitions in devicetree
> * move environment to end of SPI NOR
> * Add tags

For the series:

Reviewed-by: Fabio Estevam 


[PATCH] firmware: zynqmp: Skip loading config object for Versal

2022-08-24 Thread Ashok Reddy Soma
SET_CONFIGURATION is not yet implemented for Versal platforms. Skip
loading config object for Versal until support is added and load it only
for ZYNQMP platforms.

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

 drivers/power/domain/zynqmp-power-domain.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/power/domain/zynqmp-power-domain.c 
b/drivers/power/domain/zynqmp-power-domain.c
index 6943658be4..adbbb5fdd9 100644
--- a/drivers/power/domain/zynqmp-power-domain.c
+++ b/drivers/power/domain/zynqmp-power-domain.c
@@ -25,7 +25,10 @@ static int zynqmp_power_domain_request(struct power_domain 
*power_domain)
 {
dev_dbg(power_domain->dev, "Request for id: %ld\n", power_domain->id);
 
-   return zynqmp_pmufw_node(power_domain->id);
+   if (IS_ENABLED(CONFIG_ARCH_ZYNQMP))
+   return zynqmp_pmufw_node(power_domain->id);
+
+   return 0;
 }
 
 static int zynqmp_power_domain_free(struct power_domain *power_domain)
-- 
2.17.1



Re: [RESEND PATCH 1/2] rpi: Copy properties from firmware dtb to the loaded dtb

2022-08-24 Thread Antoine Mazeas

Hi Simon,

Le 23/08/2022 à 15:38, Simon Glass a écrit :

Hi Antoine,

On Mon, 22 Aug 2022 at 16:00, Antoine Mazeas  wrote:


Thanks Simon,

Can I ask you to clarify what you meant by "drop the private firmware"?


Replace the private binary with a full U-Boot implementation. I hope
that the vendor might do it one day.


I'm not aware whether this has been done, this would make things easier 
and more obvious for sure.



For the record, this patch was tested using the vendored firmware from
Raspberry Pi, v1.20220331, and subsequently v1.20220811 when it came
out.

I'm happy to do the requested change now if you think it is preferable.


No need, it's fine. We'll keep an eye out for it if someone else uses
your function.


Thank you, sounds good!

Regards
Antoine


Regards,
Simon




Regards

Le 22/08/2022 à 18:39, Simon Glass a écrit :

Hi Antoine,

On Fri, 19 Aug 2022 at 08:08, Antoine Mazeas  wrote:


The RPI firmware adjusts several property values in the dtb it passes
to u-boot depending on the board/SoC revision. Inherit some of these
when u-boot loads a dtb itself. Specificaly copy:

* /model: The firmware provides a more specific string
* /memreserve: The firmware defines a reserved range, better keep it
* emmc2bus and pcie0 dma-ranges: The C0T revision of the bcm2711 Soc (as
present on rpi 400 and some rpi 4B boards) has different values for
these then the B0T revision. So these need to be adjusted to boot on
these boards
* blconfig: The firmware defines the memory area where the blconfig
stored. Copy those over so it can be enabled.
* /chosen/kaslr-seed: The firmware generates a kaslr seed, take advantage
of that.

Signed-off-by: Sjoerd Simons 
Signed-off-by: Antoine Mazeas 
---

   board/raspberrypi/rpi/rpi.c | 48 +
   1 file changed, 48 insertions(+)


Reviewed-by: Simon Glass 

I wonder if anyone has tried to drop the private firmware on the boards?

At some point copy_property() should move to fdt_support.c if others use it


[tom.r...@gmail.com: Fwd: New Defects reported by Coverity Scan for Das U-Boot]

2022-08-24 Thread Tom Rini
And here's the most recent one.

- Forwarded message from Tom Rini  -

Date: Wed, 24 Aug 2022 07:38:55 -0400
From: Tom Rini 
To: tr...@konsulko.com
Subject: Fwd: New Defects reported by Coverity Scan for Das U-Boot

-- Forwarded message -
From: 
Date: Mon, Aug 22, 2022 at 7:07 PM
Subject: New Defects reported by Coverity Scan for Das U-Boot
To: 


Hi,

Please find the latest report on new defect(s) introduced to Das
U-Boot found with Coverity Scan.

3 new defect(s) introduced to Das U-Boot found with Coverity Scan.
2 defect(s), reported by Coverity Scan earlier, were marked fixed in
the recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 3 of 3 defect(s)


** CID 356244:  Null pointer dereferences  (FORWARD_NULL)



*** CID 356244:  Null pointer dereferences  (FORWARD_NULL)
/boot/vbe.c: 46 in vbe_find_first_device()
40 int vbe_find_first_device(struct udevice **devp)
41 {
42  uclass_find_first_device(UCLASS_BOOTMETH, devp);
43  if (*devp && is_vbe(*devp))
44  return 0;
45
>>> CID 356244:  Null pointer dereferences  (FORWARD_NULL)
>>> Passing "devp" to "vbe_find_next_device", which dereferences null 
>>> "*devp".
46  return vbe_find_next_device(devp);
47 }
48
49 int vbe_list(void)
50 {
51  struct bootstd_priv *std;

** CID 356243:  Code maintainability issues  (UNUSED_VALUE)
/boot/vbe_simple.c: 237 in bootmeth_vbe_simple_ft_fixup()



*** CID 356243:  Code maintainability issues  (UNUSED_VALUE)
/boot/vbe_simple.c: 237 in bootmeth_vbe_simple_ft_fixup()
231 /*
232  * Ideally we would have driver model support for
fixups, but that does
233  * not exist yet. It is a step too far to try to do
this before VBE is
234  * in place.
235  */
236 for (ret = vbe_find_first_device(); dev;
>>> CID 356243:  Code maintainability issues  (UNUSED_VALUE)
>>> Assigning value from "vbe_find_next_device()" to "ret" here, but 
>>> that stored value is overwritten before it can be used.
237  ret = vbe_find_next_device()) {
238 struct simple_state state;
239
240 if (strcmp("vbe_simple", dev->driver->name))
241 continue;
242

** CID 356242:(TAINTED_SCALAR)



*** CID 356242:(TAINTED_SCALAR)
/test/dm/ofnode.c: 501 in make_ofnode_fdt()
495 ut_assertok(fdt_end_node(fdt));
496
497 ut_assert(fdt_begin_node(fdt, "new-mmc") >= 0);
498 ut_assertok(fdt_end_node(fdt));
499
500 ut_assertok(fdt_end_node(fdt));
>>> CID 356242:(TAINTED_SCALAR)
>>> Passing tainted expression "fdt->size_dt_strings" to "fdt_finish", 
>>> which uses it as an offset.
501 ut_assertok(fdt_finish(fdt));
502
503 return 0;
504 }
505
506 static int dm_test_ofnode_root(struct unit_test_state *uts)
/test/dm/ofnode.c: 501 in make_ofnode_fdt()
495 ut_assertok(fdt_end_node(fdt));
496
497 ut_assert(fdt_begin_node(fdt, "new-mmc") >= 0);
498 ut_assertok(fdt_end_node(fdt));
499
500 ut_assertok(fdt_end_node(fdt));
>>> CID 356242:(TAINTED_SCALAR)
>>> Passing tainted expression "fdt->size_dt_strings" to "fdt_finish", 
>>> which uses it as an offset.
501 ut_assertok(fdt_finish(fdt));
502
503 return 0;
504 }
505
506 static int dm_test_ofnode_root(struct unit_test_state *uts)



To view the defects in Coverity Scan visit,
https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50yoA22WlOQ-2By3ieUvdbKmOyw68TMVT4Kip-2BBzfOGWXJ5yIiYplmPF9KAnKIja4Zd7tU-3Dl_S3_EEm8SbLgSDsaDZif-2Bv7ch8WqhKpLoKErHi4nXpwDNTu-2FviBcJy3TYnkbff9O1lpJB2a065UniCzfVIBu-2Brs6HGPrhp6hp3s-2BQGSVvNSaRsQojbpJAi7kxyFcHZ8aaIeQ0LJlzM2cTXzCCeq8c-2FquCeg4mCmdPzUFdWUhBcgytnExm8LYbWctf-2B-2BcK49gD2uvdO0dVdoZGeFYKdAJZGcKrg-3D-3D

  To manage Coverity Scan email notifications for
"tom.r...@gmail.com", click
https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50yped04pjJnmXOsUBtKYNIXxWeIHzDeopm-2BEWQ6S6K-2FtUHv9ZTk8qZbuzkkz9sa-2BJFzf226DuRd-2B2ygQlLnerl-2BA3jN1AOYejXZ-2FNZ62waJHedPFGpqqjTx8fawy9KPJBno-3D0xWA_EEm8SbLgSDsaDZif-2Bv7ch8WqhKpLoKErHi4nXpwDNTu-2FviBcJy3TYnkbff9O1lpJ8fYfPhPSMWru8G5g0hjYD2lP6GfXdRYLDay-2BEZMB4nffrqxFwC3P84QsfDGYYlZb-2Fv2AYdsgvSvu2gEihe-2BP8O4Khh9gLeVsBYy-2Bps2buInswpEo43c-2B1-2FHNkYpmMXLe6-2FNHIyvt0clj7kDSbeyOqA-3D-3D



-- 
Tom

- End forwarded message -

-- 

[tom.r...@gmail.com: Fwd: New Defects reported by Coverity Scan for Das U-Boot]

2022-08-24 Thread Tom Rini
A bit behind on forwarding these along.

- Forwarded message from Tom Rini  -

Date: Wed, 24 Aug 2022 07:38:46 -0400
From: Tom Rini 
To: tr...@konsulko.com
Subject: Fwd: New Defects reported by Coverity Scan for Das U-Boot

-- Forwarded message -
From: 
Date: Mon, Aug 8, 2022 at 8:51 PM
Subject: New Defects reported by Coverity Scan for Das U-Boot
To: 


Hi,

Please find the latest report on new defect(s) introduced to Das
U-Boot found with Coverity Scan.

6 new defect(s) introduced to Das U-Boot found with Coverity Scan.
2 defect(s), reported by Coverity Scan earlier, were marked fixed in
the recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 6 of 6 defect(s)


** CID 355771:(PRINTF_ARGS)



*** CID 355771:(PRINTF_ARGS)
/test/cmd/fdt.c: 72 in fdt_test_addr()
66  ut_assertok(run_command("fdt addr", 0));
67  ut_assert_nextline("Working fdt: %08lx", (ulong)map_to_sysmem(fdt));
68  ut_assertok(ut_check_console_end(uts));
69
70  /* Set the working FDT */
71  set_working_fdt_addr(0);
>>> CID 355771:(PRINTF_ARGS)
>>> Argument "addr" to format specifier "%08x" was expected to have type 
>>> "unsigned int" but has type "unsigned long".
72  ut_assertok(run_commandf("fdt addr %08x", addr));
73  ut_asserteq(addr, map_to_sysmem(working_fdt));
74  ut_assertok(ut_check_console_end(uts));
75  set_working_fdt_addr(0);
76
77  /* Set the working FDT */
/test/cmd/fdt.c: 89 in fdt_test_addr()
83  ut_assertok(ret);
84  ut_asserteq(addr, map_to_sysmem(new_fdt));
85  ut_assertok(ut_check_console_end(uts));
86
87  /* Test setting an invalid FDT */
88  fdt[0] = 123;
>>> CID 355771:(PRINTF_ARGS)
>>> Argument "addr" to format specifier "%08x" was expected to have type 
>>> "unsigned int" but has type "unsigned long".
89  ut_asserteq(1, run_commandf("fdt addr %08x", addr));
90  ut_assert_nextline("libfdt fdt_check_header(): FDT_ERR_BADMAGIC");
91  ut_assertok(ut_check_console_end(uts));
92
93  /* Test detecting an invalid FDT */
94  fdt[0] = 123;
/test/cmd/fdt.c: 80 in fdt_test_addr()
74  ut_assertok(ut_check_console_end(uts));
75  set_working_fdt_addr(0);
76
77  /* Set the working FDT */
78  fdt_blob = gd->fdt_blob;
79  gd->fdt_blob = NULL;
>>> CID 355771:(PRINTF_ARGS)
>>> Argument "addr" to format specifier "%08x" was expected to have type 
>>> "unsigned int" but has type "unsigned long".
80  ret = run_commandf("fdt addr -c %08x", addr);
81  new_fdt = gd->fdt_blob;
82  gd->fdt_blob = fdt_blob;
83  ut_assertok(ret);
84  ut_asserteq(addr, map_to_sysmem(new_fdt));
85  ut_assertok(ut_check_console_end(uts));

** CID 355770:  Insecure data handling  (TAINTED_SCALAR)



*** CID 355770:  Insecure data handling  (TAINTED_SCALAR)
/test/cmd/fdt.c: 37 in make_test_fdt()
31 static int make_test_fdt(struct unit_test_state *uts, void
*fdt, int size)
32 {
33  ut_assertok(fdt_create(fdt, size));
34  ut_assertok(fdt_finish_reservemap(fdt));
35  ut_assert(fdt_begin_node(fdt, "") >= 0);
36  ut_assertok(fdt_end_node(fdt));
>>> CID 355770:  Insecure data handling  (TAINTED_SCALAR)
>>> Passing tainted expression "fdt->size_dt_strings" to "fdt_finish", 
>>> which uses it as an offset.
37  ut_assertok(fdt_finish(fdt));
38
39  return 0;
40 }
41
42 /* Test 'fdt addr' getting/setting address */

** CID 355769:(PRINTF_ARGS)



*** CID 355769:(PRINTF_ARGS)
/test/cmd/fdt.c: 121 in fdt_test_resize()
115 /* Test setting and resizing the working FDT to a larger size */
116 ut_assertok(console_record_reset_enable());
117 ut_assertok(run_commandf("fdt addr %08x %x", addr, newsize));
118 ut_assertok(ut_check_console_end(uts));
119
120 /* Try shrinking it */
>>> CID 355769:(PRINTF_ARGS)
>>> Argument "addr" to format specifier "%08x" was expected to have type 
>>> "unsigned int" but has type "unsigned long".
121 ut_assertok(run_commandf("fdt addr %08x %x", addr,
sizeof(fdt) / 4));
122 ut_assert_nextline("New length %d < existing length
%d, ignoring",
123(int)sizeof(fdt) / 4, newsize);
124 ut_assertok(ut_check_console_end(uts));
125
126 /* ...quietly */
/test/cmd/fdt.c: 127 in fdt_test_resize()
121 ut_assertok(run_commandf("fdt addr %08x %x", addr,
sizeof(fdt) / 4));
122 ut_assert_nextline("New length %d < existing length
%d, ignoring",
123(int)sizeof(fdt) / 4, newsize);
124

[PATCH 3/3] spi: cadence-qspi: Use priv instead of plat across the driver

2022-08-24 Thread Ashok Reddy Soma
As per driver model we should enumerate plat structure only in
of_to_plat() and should be used only in probe(). Copy required
plat structure info into priv structure in probe() and use priv
structure across the driver. So replace plat with priv structure across
the driver.

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

 drivers/spi/cadence_ospi_versal.c |  52 +++
 drivers/spi/cadence_qspi.c| 101 +++--
 drivers/spi/cadence_qspi.h|  56 +---
 drivers/spi/cadence_qspi_apb.c| 231 +++---
 4 files changed, 236 insertions(+), 204 deletions(-)

diff --git a/drivers/spi/cadence_ospi_versal.c 
b/drivers/spi/cadence_ospi_versal.c
index c756a854bc..a25c50bc50 100644
--- a/drivers/spi/cadence_ospi_versal.c
+++ b/drivers/spi/cadence_ospi_versal.c
@@ -21,7 +21,7 @@
 #define CMD_4BYTE_READ  0x13
 #define CMD_4BYTE_FAST_READ  0x0C
 
-int cadence_qspi_apb_dma_read(struct cadence_spi_plat *plat,
+int cadence_qspi_apb_dma_read(struct cadence_spi_priv *priv,
  const struct spi_mem_op *op)
 {
u32 reg, ret, rx_rem, n_rx, bytes_to_dma, data;
@@ -34,86 +34,86 @@ int cadence_qspi_apb_dma_read(struct cadence_spi_plat *plat,
 
if (bytes_to_dma) {
cadence_qspi_apb_enable_linear_mode(false);
-   reg = readl(plat->regbase + CQSPI_REG_CONFIG);
+   reg = readl(priv->regbase + CQSPI_REG_CONFIG);
reg |= CQSPI_REG_CONFIG_ENBL_DMA;
-   writel(reg, plat->regbase + CQSPI_REG_CONFIG);
+   writel(reg, priv->regbase + CQSPI_REG_CONFIG);
 
-   writel(bytes_to_dma, plat->regbase + CQSPI_REG_INDIRECTRDBYTES);
+   writel(bytes_to_dma, priv->regbase + CQSPI_REG_INDIRECTRDBYTES);
 
writel(CQSPI_DFLT_INDIR_TRIG_ADDR_RANGE,
-  plat->regbase + CQSPI_REG_INDIR_TRIG_ADDR_RANGE);
+  priv->regbase + CQSPI_REG_INDIR_TRIG_ADDR_RANGE);
writel(CQSPI_DFLT_DMA_PERIPH_CFG,
-  plat->regbase + CQSPI_REG_DMA_PERIPH_CFG);
-   writel((unsigned long)rxbuf, plat->regbase +
+  priv->regbase + CQSPI_REG_DMA_PERIPH_CFG);
+   writel((unsigned long)rxbuf, priv->regbase +
   CQSPI_DMA_DST_ADDR_REG);
-   writel(plat->trigger_address, plat->regbase +
+   writel(priv->trigger_address, priv->regbase +
   CQSPI_DMA_SRC_RD_ADDR_REG);
-   writel(bytes_to_dma, plat->regbase +
+   writel(bytes_to_dma, priv->regbase +
   CQSPI_DMA_DST_SIZE_REG);
flush_dcache_range((unsigned long)rxbuf,
   (unsigned long)rxbuf + bytes_to_dma);
writel(CQSPI_DFLT_DST_CTRL_REG_VAL,
-  plat->regbase + CQSPI_DMA_DST_CTRL_REG);
+  priv->regbase + CQSPI_DMA_DST_CTRL_REG);
 
/* Start the indirect read transfer */
-   writel(CQSPI_REG_INDIRECTRD_START, plat->regbase +
+   writel(CQSPI_REG_INDIRECTRD_START, priv->regbase +
   CQSPI_REG_INDIRECTRD);
/* Wait for dma to complete transfer */
-   ret = cadence_qspi_apb_wait_for_dma_cmplt(plat);
+   ret = cadence_qspi_apb_wait_for_dma_cmplt(priv);
if (ret)
return ret;
 
/* Clear indirect completion status */
-   writel(CQSPI_REG_INDIRECTRD_DONE, plat->regbase +
+   writel(CQSPI_REG_INDIRECTRD_DONE, priv->regbase +
   CQSPI_REG_INDIRECTRD);
rxbuf += bytes_to_dma;
}
 
if (rx_rem) {
-   reg = readl(plat->regbase + CQSPI_REG_CONFIG);
+   reg = readl(priv->regbase + CQSPI_REG_CONFIG);
reg &= ~CQSPI_REG_CONFIG_ENBL_DMA;
-   writel(reg, plat->regbase + CQSPI_REG_CONFIG);
+   writel(reg, priv->regbase + CQSPI_REG_CONFIG);
 
-   reg = readl(plat->regbase + CQSPI_REG_INDIRECTRDSTARTADDR);
+   reg = readl(priv->regbase + CQSPI_REG_INDIRECTRDSTARTADDR);
reg += bytes_to_dma;
-   writel(reg, plat->regbase + CQSPI_REG_CMDADDRESS);
+   writel(reg, priv->regbase + CQSPI_REG_CMDADDRESS);
 
-   addr_bytes = readl(plat->regbase + CQSPI_REG_SIZE) &
+   addr_bytes = readl(priv->regbase + CQSPI_REG_SIZE) &
   CQSPI_REG_SIZE_ADDRESS_MASK;
 
opcode = CMD_4BYTE_FAST_READ;
dummy_cycles = 8;
writel((dummy_cycles << CQSPI_REG_RD_INSTR_DUMMY_LSB) | opcode,
-  plat->regbase + CQSPI_REG_RD_INSTR);
+  priv->regbase + CQSPI_REG_RD_INSTR);
 
reg = opcode << CQSPI_REG_CMDCTRL_OPCODE_LSB;
reg |= (0x1 << CQSPI_REG_CMDCTRL_RD_EN_LSB);
  

[PATCH 2/3] spi: cadence_qspi: Call read_setup for STIG_READ

2022-08-24 Thread Ashok Reddy Soma
In cadence_spi_read_id we are using STIG mode to read flash id's.
Call cadence_qspi_apb_command_read_setup() to setup cmd, addr and data
bus width properly before cadence_qspi_apb_command_read().

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

 drivers/spi/cadence_qspi.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c
index 907f5dadc4..6e50b94e14 100644
--- a/drivers/spi/cadence_qspi.c
+++ b/drivers/spi/cadence_qspi.c
@@ -59,12 +59,17 @@ static int cadence_spi_write_speed(struct udevice *bus, 
uint hz)
 static int cadence_spi_read_id(struct cadence_spi_plat *plat, u8 len,
   u8 *idcode)
 {
+   int err;
struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(0x9F, 1),
  SPI_MEM_OP_NO_ADDR,
  SPI_MEM_OP_NO_DUMMY,
  SPI_MEM_OP_DATA_IN(len, idcode, 1));
 
-   return cadence_qspi_apb_command_read(plat, );
+   err = cadence_qspi_apb_command_read_setup(plat, );
+   if (!err)
+   err = cadence_qspi_apb_command_read(plat, );
+
+   return err;
 }
 
 /* Calibration sequence to determine the read data capture delay register */
-- 
2.17.1



[PATCH 1/3] spi: cadence-qspi: Correct flash reset function name

2022-08-24 Thread Ashok Reddy Soma
In cadence_spi_probe, cadence_qspi_versal_flash_reset() is called to reset
the flash device. Looks like there is a mistake in previous series of
patches where it is defined as cadence_spi_versal_flash_reset() but
called as cadence_qspi_versal_flash_reset. Since there is a weak function
defined with the same name this issue was not caught.

Fix the issue by renaming cadence_spi_versal_flash_reset as
cadence_qspi_versal_flash_reset().

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

 drivers/spi/cadence_ospi_versal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/cadence_ospi_versal.c 
b/drivers/spi/cadence_ospi_versal.c
index 52bcad053f..c756a854bc 100644
--- a/drivers/spi/cadence_ospi_versal.c
+++ b/drivers/spi/cadence_ospi_versal.c
@@ -128,7 +128,7 @@ int cadence_qspi_apb_wait_for_dma_cmplt(struct 
cadence_spi_plat *plat)
 }
 
 #if defined(CONFIG_DM_GPIO)
-int cadence_spi_versal_flash_reset(struct udevice *dev)
+int cadence_qspi_versal_flash_reset(struct udevice *dev)
 {
struct gpio_desc gpio;
u32 reset_gpio;
@@ -169,7 +169,7 @@ int cadence_spi_versal_flash_reset(struct udevice *dev)
return 0;
 }
 #else
-int cadence_spi_versal_flash_reset(struct udevice *dev)
+int cadence_qspi_versal_flash_reset(struct udevice *dev)
 {
/* CRP WPROT */
writel(0, WPROT_CRP);
-- 
2.17.1



[PATCH 0/3] cadence_qspi driver updates

2022-08-24 Thread Ashok Reddy Soma
In this patch series
 - Change driver to use plat data structure only in of_to_plat() and
   probe(). In probe, copy plat structure members to priv structure.
   Replace plat with priv across the driver.
 - Fix function name issue in flash reset
 - Add a call to read_setup in cadence_spi_read_id() before STIG read.



Ashok Reddy Soma (3):
  spi: cadence-qspi: Correct flash reset function name
  spi: cadence_qspi: Call read_setup for STIG_READ
  spi: cadence-qspi: Use priv instead of plat across the driver

 drivers/spi/cadence_ospi_versal.c |  56 
 drivers/spi/cadence_qspi.c| 104 --
 drivers/spi/cadence_qspi.h|  56 +---
 drivers/spi/cadence_qspi_apb.c| 231 +++---
 4 files changed, 242 insertions(+), 205 deletions(-)

-- 
2.17.1



RE: [UBOOT PATCH v2] firmware: zynqmp: Skip loading config object for Versal

2022-08-24 Thread Soma, Ashok Reddy
Apologies, send this patch my mistake. Please ignore this patch.

Thanks,
Ashok

-Original Message-
From: Ashok Reddy Soma  
Sent: Wednesday, August 24, 2022 5:05 PM
To: u-boot@lists.denx.de
Cc: ja...@amarulasolutions.com; Simek, Michal ; 
g...@xilinx.com; Ashok Reddy Soma ; Soma, Ashok 
Reddy 
Subject: [UBOOT PATCH v2] firmware: zynqmp: Skip loading config object for 
Versal

SET_CONFIGURATION is not yet implemented for Versal platforms. Skip loading 
config object for Versal until support is added.

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

Changes in v2:
 - Call zynqmp_pmufw_node only for ZynqMP platform.

CR-1136452
branch: master-next-test
Signed-off-by: Ashok Reddy Soma 
---
 drivers/power/domain/zynqmp-power-domain.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/power/domain/zynqmp-power-domain.c 
b/drivers/power/domain/zynqmp-power-domain.c
index 6943658be4..adbbb5fdd9 100644
--- a/drivers/power/domain/zynqmp-power-domain.c
+++ b/drivers/power/domain/zynqmp-power-domain.c
@@ -25,7 +25,10 @@ static int zynqmp_power_domain_request(struct power_domain 
*power_domain)  {
dev_dbg(power_domain->dev, "Request for id: %ld\n", power_domain->id);
 
-   return zynqmp_pmufw_node(power_domain->id);
+   if (IS_ENABLED(CONFIG_ARCH_ZYNQMP))
+   return zynqmp_pmufw_node(power_domain->id);
+
+   return 0;
 }
 
 static int zynqmp_power_domain_free(struct power_domain *power_domain)
--
2.17.1



[UBOOT PATCH v2] firmware: zynqmp: Skip loading config object for Versal

2022-08-24 Thread Ashok Reddy Soma
SET_CONFIGURATION is not yet implemented for Versal platforms. Skip
loading config object for Versal until support is added.

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

Changes in v2:
 - Call zynqmp_pmufw_node only for ZynqMP platform.

CR-1136452
branch: master-next-test
Signed-off-by: Ashok Reddy Soma 
---
 drivers/power/domain/zynqmp-power-domain.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/power/domain/zynqmp-power-domain.c 
b/drivers/power/domain/zynqmp-power-domain.c
index 6943658be4..adbbb5fdd9 100644
--- a/drivers/power/domain/zynqmp-power-domain.c
+++ b/drivers/power/domain/zynqmp-power-domain.c
@@ -25,7 +25,10 @@ static int zynqmp_power_domain_request(struct power_domain 
*power_domain)
 {
dev_dbg(power_domain->dev, "Request for id: %ld\n", power_domain->id);
 
-   return zynqmp_pmufw_node(power_domain->id);
+   if (IS_ENABLED(CONFIG_ARCH_ZYNQMP))
+   return zynqmp_pmufw_node(power_domain->id);
+
+   return 0;
 }
 
 static int zynqmp_power_domain_free(struct power_domain *power_domain)
-- 
2.17.1



[PATCH] xilinx: Enable CMD_GREPENV/SETEXPR by default

2022-08-24 Thread Michal Simek
Enable both of these commands in Xilinx SoCs to be able to use them in boot
scripts.

Signed-off-by: Michal Simek 
---

 configs/microblaze-generic_defconfig | 2 +-
 configs/xilinx_versal_virt_defconfig | 1 +
 configs/xilinx_zynq_virt_defconfig   | 2 +-
 configs/xilinx_zynqmp_virt_defconfig | 1 +
 4 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/configs/microblaze-generic_defconfig 
b/configs/microblaze-generic_defconfig
index b5c5efe59665..01c93d5c4ee9 100644
--- a/configs/microblaze-generic_defconfig
+++ b/configs/microblaze-generic_defconfig
@@ -43,9 +43,9 @@ CONFIG_SYS_BOOTM_LEN=0x400
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_SPL=y
 CONFIG_CMD_ASKENV=y
+CONFIG_CMD_GREPENV=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_SAVES=y
-# CONFIG_CMD_SETEXPR is not set
 CONFIG_BOOTP_BOOTFILESIZE=y
 CONFIG_CMD_TFTPPUT=y
 CONFIG_CMD_CACHE=y
diff --git a/configs/xilinx_versal_virt_defconfig 
b/configs/xilinx_versal_virt_defconfig
index 7b96c4fbd999..c3fa913b20dc 100644
--- a/configs/xilinx_versal_virt_defconfig
+++ b/configs/xilinx_versal_virt_defconfig
@@ -26,6 +26,7 @@ CONFIG_SYS_MAXARGS=64
 CONFIG_SYS_PBSIZE=2073
 CONFIG_SYS_BOOTM_LEN=0x640
 CONFIG_CMD_BOOTMENU=y
+CONFIG_CMD_GREPENV=y
 CONFIG_CMD_NVEDIT_EFI=y
 CONFIG_CMD_MEMTEST=y
 CONFIG_SYS_ALT_MEMTEST=y
diff --git a/configs/xilinx_zynq_virt_defconfig 
b/configs/xilinx_zynq_virt_defconfig
index b8e16cab6e8b..c12a1cbbc8a3 100644
--- a/configs/xilinx_zynq_virt_defconfig
+++ b/configs/xilinx_zynq_virt_defconfig
@@ -51,6 +51,7 @@ CONFIG_SYS_PBSIZE=2071
 CONFIG_SYS_BOOTM_LEN=0x3c0
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_THOR_DOWNLOAD=y
+CONFIG_CMD_GREPENV=y
 CONFIG_CMD_MEMTEST=y
 CONFIG_SYS_ALT_MEMTEST=y
 CONFIG_CMD_DFU=y
@@ -65,7 +66,6 @@ CONFIG_CMD_MTD=y
 CONFIG_CMD_NAND_LOCK_UNLOCK=y
 CONFIG_CMD_SF_TEST=y
 CONFIG_CMD_USB=y
-# CONFIG_CMD_SETEXPR is not set
 CONFIG_BOOTP_MAY_FAIL=y
 CONFIG_CMD_TFTPPUT=y
 CONFIG_CMD_CACHE=y
diff --git a/configs/xilinx_zynqmp_virt_defconfig 
b/configs/xilinx_zynqmp_virt_defconfig
index e242884d3f6f..1591f221b5a5 100644
--- a/configs/xilinx_zynqmp_virt_defconfig
+++ b/configs/xilinx_zynqmp_virt_defconfig
@@ -57,6 +57,7 @@ CONFIG_SYS_PBSIZE=2073
 CONFIG_SYS_BOOTM_LEN=0x640
 CONFIG_CMD_BOOTMENU=y
 CONFIG_CMD_THOR_DOWNLOAD=y
+CONFIG_CMD_GREPENV=y
 CONFIG_CMD_NVEDIT_EFI=y
 CONFIG_CMD_MEMTEST=y
 CONFIG_SYS_ALT_MEMTEST=y
-- 
2.36.1



[PATCH] xilinx: Add env redund offset

2022-08-24 Thread Michal Simek
From: T Karthik Reddy 

ENV_OFFSET_REDUND config is by default set to 0 for flashes. Saving the env
variables is overwriting data at 0 offset, which is wrong. So add default
redund env offset for Zynq, ZynqMP, Versal and microblaze platforms.
Configured ENV_OFFSET_REDUND offsets by ENV_OFFSET + (2 * ENV_SIZE).

In case of versal, we configured ENV_OFFSET_REDUND at 0x7F0 instead
of 0x7F8. As BOOT_SCRIPT_OFFSET is already configured at 0x7F8.

Added ENV_OFFSET_REDUND in Kconfig for microblaze due to dependency of
ENV_IS_IN_SPI_FLASH config.

Below table specifies platform specific env and env redund offsets.

PLATENV_OFFSET  ENV_OFFSET_REDUND
--  -
ZYNQ0xE 0xE4
ZYNQMP  0x1E0   0x1E8
VERSAL  0x7F4   0x7F0
MICROBLAZE  0x108   0x10C

Signed-off-by: T Karthik Reddy 
Signed-off-by: Michal Simek 
---

 configs/xilinx_versal_virt_defconfig | 1 +
 configs/xilinx_zynq_virt_defconfig   | 1 +
 configs/xilinx_zynqmp_virt_defconfig | 1 +
 env/Kconfig  | 1 +
 4 files changed, 4 insertions(+)

diff --git a/configs/xilinx_versal_virt_defconfig 
b/configs/xilinx_versal_virt_defconfig
index ffd8bea81c36..7b96c4fbd999 100644
--- a/configs/xilinx_versal_virt_defconfig
+++ b/configs/xilinx_versal_virt_defconfig
@@ -7,6 +7,7 @@ CONFIG_SYS_TEXT_BASE=0x800
 CONFIG_SYS_MALLOC_F_LEN=0x10
 CONFIG_DEFAULT_DEVICE_TREE="xilinx-versal-virt"
 CONFIG_SYS_PROMPT="Versal> "
+CONFIG_ENV_OFFSET_REDUND=0x7F0
 CONFIG_CMD_FRU=y
 CONFIG_DEFINE_TCM_OCM_MMAP=y
 CONFIG_SYS_LOAD_ADDR=0x800
diff --git a/configs/xilinx_zynq_virt_defconfig 
b/configs/xilinx_zynq_virt_defconfig
index e6f8e221a5d5..b8e16cab6e8b 100644
--- a/configs/xilinx_zynq_virt_defconfig
+++ b/configs/xilinx_zynq_virt_defconfig
@@ -8,6 +8,7 @@ CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc706"
 CONFIG_SPL_STACK_R_ADDR=0x20
 CONFIG_SPL=y
+CONFIG_ENV_OFFSET_REDUND=0xE4
 CONFIG_CMD_FRU=y
 CONFIG_CMD_ZYNQ_AES=y
 CONFIG_SYS_LOAD_ADDR=0x0
diff --git a/configs/xilinx_zynqmp_virt_defconfig 
b/configs/xilinx_zynqmp_virt_defconfig
index e5ac26e0381f..e242884d3f6f 100644
--- a/configs/xilinx_zynqmp_virt_defconfig
+++ b/configs/xilinx_zynqmp_virt_defconfig
@@ -10,6 +10,7 @@ CONFIG_SPL_STACK_R_ADDR=0x1800
 CONFIG_SPL_SIZE_LIMIT=0x2a000
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x0
 CONFIG_SPL=y
+CONFIG_ENV_OFFSET_REDUND=0x1E8
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
 CONFIG_ZYNQ_MAC_IN_EEPROM=y
diff --git a/env/Kconfig b/env/Kconfig
index 238e4c70cf05..5329f7585be5 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -570,6 +570,7 @@ config ENV_OFFSET_REDUND
hex "Redundant environment offset"
depends on (ENV_IS_IN_EEPROM || ENV_IS_IN_MMC || ENV_IS_IN_NAND || \
ENV_IS_IN_SPI_FLASH) && SYS_REDUNDAND_ENVIRONMENT
+   default 0x10C if MICROBLAZE
default 0
help
  Offset from the start of the device (or partition) of the redundant
-- 
2.36.1



[PATCH] cmd: xxd: add new command

2022-08-24 Thread Roger Knecht
Add xxd command to print file content as hexdump to standard out

Signed-off-by: Roger Knecht 
---
The 'xxd' code has a lot in common with my ealier patch for 'cat'.

Example:
```
=> xxd mmc 0:1 hello
: 68 65 6c 6c 6f 20 77 6f 72 6c 64 0a 00 01 02 03  hello world.
0010: 04 05
```

 MAINTAINERS|  7 +++
 cmd/Kconfig|  5 ++
 cmd/Makefile   |  1 +
 cmd/xxd.c  | 85 ++
 configs/sandbox64_defconfig|  1 +
 configs/sandbox_defconfig  |  1 +
 doc/usage/cmd/xxd.rst  | 50 ++
 test/py/tests/test_xxd/conftest.py | 35 
 test/py/tests/test_xxd/test_xxd.py | 23 
 9 files changed, 208 insertions(+)
 create mode 100644 cmd/xxd.c
 create mode 100644 doc/usage/cmd/xxd.rst
 create mode 100644 test/py/tests/test_xxd/conftest.py
 create mode 100644 test/py/tests/test_xxd/test_xxd.py

diff --git a/MAINTAINERS b/MAINTAINERS
index 36a2b69fcb..467c76f854 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1486,6 +1486,13 @@ M:   Max Filippov 
 S: Maintained
 F: arch/xtensa/

+XXD
+M: Roger Knecht 
+S: Maintained
+F: cmd/xxd.c
+F: doc/usage/cmd/xxd.rst
+F: test/py/tests/test_xxd/
+
 THE REST
 M: Tom Rini 
 L: u-boot@lists.denx.de
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 211ebe9c87..f7bbcef9e2 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -469,6 +469,11 @@ config CMD_XIMG
help
  Extract a part of a multi-image.

+config CMD_XXD
+   bool "xxd"
+   help
+ Print file as hexdump to standard output
+
 config CMD_SPL
bool "spl export - Export boot information for Falcon boot"
depends on SPL
diff --git a/cmd/Makefile b/cmd/Makefile
index 6e87522b62..48a2ee2e6e 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -181,6 +181,7 @@ obj-$(CONFIG_CMD_USB_SDP) += usb_gadget_sdp.o
 obj-$(CONFIG_CMD_THOR_DOWNLOAD) += thordown.o
 obj-$(CONFIG_CMD_VBE) += vbe.o
 obj-$(CONFIG_CMD_XIMG) += ximg.o
+obj-$(CONFIG_CMD_XXD) += xxd.o
 obj-$(CONFIG_CMD_YAFFS2) += yaffs2.o
 obj-$(CONFIG_CMD_SPL) += spl.o
 obj-$(CONFIG_CMD_W1) += w1.o
diff --git a/cmd/xxd.c b/cmd/xxd.c
new file mode 100644
index 00..742a85c7a9
--- /dev/null
+++ b/cmd/xxd.c
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2022
+ * Roger Knecht 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int do_xxd(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+   char *ifname;
+   char *dev;
+   char *file;
+   char *buffer;
+   phys_addr_t addr;
+   loff_t file_size;
+
+   if (argc < 4)
+   return CMD_RET_USAGE;
+
+   ifname = argv[1];
+   dev = argv[2];
+   file = argv[3];
+
+   // check file exists
+   if (fs_set_blk_dev(ifname, dev, FS_TYPE_ANY))
+   return CMD_RET_FAILURE;
+
+   if (!fs_exists(file)) {
+   log_err("File does not exist: ifname=%s dev=%s file=%s\n", 
ifname, dev, file);
+   return CMD_RET_FAILURE;
+   }
+
+   // get file size
+   if (fs_set_blk_dev(ifname, dev, FS_TYPE_ANY))
+   return CMD_RET_FAILURE;
+
+   if (fs_size(file, _size)) {
+   log_err("Cannot read file size: ifname=%s dev=%s file=%s\n", 
ifname, dev, file);
+   return CMD_RET_FAILURE;
+   }
+
+   // allocate memory for file content
+   buffer = calloc(sizeof(char), file_size);
+   if (!buffer) {
+   log_err("Out of memory\n");
+   return CMD_RET_FAILURE;
+   }
+
+   // map pointer to system memory
+   addr = map_to_sysmem(buffer);
+
+   // read file to memory
+   if (fs_set_blk_dev(ifname, dev, FS_TYPE_ANY))
+   return CMD_RET_FAILURE;
+
+   if (fs_read(file, addr, 0, 0, _size)) {
+   log_err("Cannot read file: ifname=%s dev=%s file=%s\n", ifname, 
dev, file);
+   return CMD_RET_FAILURE;
+   }
+
+   // print file content
+   print_buffer(0, buffer, sizeof(char), file_size, 0);
+
+   free(buffer);
+
+   return 0;
+}
+
+#ifdef CONFIG_SYS_LONGHELP
+static char xxd_help_text[] =
+   "  \n"
+   "  - Print file from 'dev' on 'interface' as hexdump to standard 
output\n";
+#endif
+
+U_BOOT_CMD(xxd, 4, 1, do_xxd,
+  "Print file as hexdump to standard output",
+  xxd_help_text
+);
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index 290d1506c2..6f8574e0c2 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -54,6 +54,7 @@ CONFIG_CMD_READ=y
 CONFIG_CMD_REMOTEPROC=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
+CONFIG_CMD_XXD=y
 CONFIG_BOOTP_DNS2=y
 CONFIG_CMD_TFTPPUT=y
 CONFIG_CMD_TFTPSRV=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index ab5d3f19bf..2fa6896c4b 100644
--- a/configs/sandbox_defconfig
+++ 

Re: [PATCH v13 1/9] eficonfig: menu-driven addition of UEFI boot option

2022-08-24 Thread Ilias Apalodimas
Hi Kojima-san,

[...]

> + * eficonfig_destroy() - destroy efimenu
> + *
> + * @efi_menu:pointer to the efimenu structure
> + * @flag:flag to free the allocated data
> + */
> +static void eficonfig_destroy(struct efimenu *efi_menu, bool flag)
> +{
> + struct list_head *pos, *n;
> + struct eficonfig_entry *entry;
> +
> + list_for_each_safe(pos, n, _menu->list) {
> + entry = list_entry(pos, struct eficonfig_entry, list);
> + free(entry->title);
> + if (flag)
> + free(entry->data);

I don't we need this flag.  entry->data is either set to a valid pointer or
NULL on append_entry().

> + list_del(>list);
> + free(entry);
> + }
> + free(efi_menu->menu_header);
> + free(efi_menu);

[...]

Regards
/Ilias


Re: [RFC PATCH] imx8mp: fix boot hang when booting NXP kernel 5.15.32

2022-08-24 Thread Peng Fan




On 8/23/2022 9:36 PM, Rasmus Villemoes wrote:

We have observed a somewhat weird bug: When booting the downstream NXP
kernel lf-5.15.32-2.0.0 [fa6c3168595c], sometimes the board would hang
during imx_lcdifv3_probe(). Adding some printk debugging revealed that
the hang always happened at the

   writel(CTRL_SW_RESET, lcdifv3->base + LCDIFV3_CTRL_CLR);


Would you check the mediamix blk ctrl register before access this register?

Regards,
Peng.



However, only some of our imx8mp EVK boards and some of our custom
imx8mp-based boards showed this; others never seemed to show it,
making us initially suspect a hardware/board assembly error, though it
would be weird for that to apply to both our design and the EVKs.

Moreover, for the boards that did have this behaviour, applying a
generous amount of cooling spray to the SOC did make it boot, while
conversely heating it up before booting was a sure way to make it
hang. But even after that discovery, applying heat to the boards that
seemed to be immune from this bug didn't make them hang either.

It is also worth mentioning that whenever the boards did boot,
i.e. get past that critical line in probe(), whether those of the
"immune" kind or those which we cooled sufficiently, graphics appeared
to work just fine.

Eventually, we discovered that when using a downstream NXP U-Boot
[lf_v2022.04, 1c881f4da8], this bug never happened. So I started
bisecting between v2022.04 and lf_v2022.04, leading to

   commit 610e1b1246f7832bd96bfa9615e043565a19ac1b
   Author: Ye Li 
   Date:   Mon Mar 30 01:56:03 2020 -0700

 MLK-23574-22 imx8m: clock: Sync clock settings with imx_v2020.04

Now that commit does a lot of things, but it wasn't hard to figure out
that the part that was relevant to our case was the addition of the
enable_display_clk() function.

Since I only have imx8mp boards (some EVKs and a few custom designs),
this only adds the enable_display_clk() for that SOC. But this really
seems like something that the kernel itself should (be able to) take
care of, without relying on the bootloader having done such random
magic.

Signed-off-by: Rasmus Villemoes 
---

I don't know if upstream U-Boot cares about being able to boot a
downstream NXP linux kernel. Or if this really should be fixed on the
kernel side, making the lcdif driver properly configure the clock(s)
before lifting the reset bit. But if somebody else runs into this
issue, hopefully just this patch submission will at least save them
some time.

Can someone from NXP explain what's going on? In particular, how come
graphics works just fine even when, apparently, clocks have not been
properly configured? And why does this only happen for some boards,
but not others that should be physically identical? What's with the
temperature dependency?

  arch/arm/mach-imx/imx8m/clock_imx8mm.c | 27 +-
  1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/imx8m/clock_imx8mm.c 
b/arch/arm/mach-imx/imx8m/clock_imx8mm.c
index 4db55f8608..96a9eb4dd3 100644
--- a/arch/arm/mach-imx/imx8m/clock_imx8mm.c
+++ b/arch/arm/mach-imx/imx8m/clock_imx8mm.c
@@ -45,7 +45,6 @@ int enable_i2c_clk(unsigned char enable, unsigned i2c_num)
return 0;
  }
  
-#ifdef CONFIG_SPL_BUILD

  static struct imx_int_pll_rate_table imx8mm_fracpll_tbl[] = {
PLL_1443X_RATE(10U, 250, 3, 1, 0),
PLL_1443X_RATE(93300U, 311, 4, 1, 0),
@@ -124,6 +123,8 @@ static int fracpll_configure(enum pll_clocks pll, u32 freq)
return 0;
  }
  
+#ifdef CONFIG_SPL_BUILD

+
  void dram_pll_init(ulong pll_val)
  {
fracpll_configure(ANATOP_DRAM_PLL, pll_val);
@@ -298,6 +299,28 @@ int intpll_configure(enum pll_clocks pll, ulong freq)
return 0;
  }
  
+#define VIDEO_PLL_RATE 59400U

+
+static void enable_display_clk(void)
+{
+   if (IS_ENABLED(CONFIG_IMX8MP)) {
+   clock_enable(CCGR_DISPMIX, false);
+
+   /* Set Video PLL to 594Mhz, p = 1, m = 99, k = 0, s = 2 */
+   fracpll_configure(ANATOP_VIDEO_PLL, VIDEO_PLL_RATE);
+
+   /* 500Mhz */
+   clock_set_target_val(MEDIA_AXI_CLK_ROOT, CLK_ROOT_ON | 
CLK_ROOT_SOURCE_SEL(1) | CLK_ROOT_PRE_DIV(CLK_ROOT_PRE_DIV2));
+
+   /* 200Mhz */
+   clock_set_target_val(MEDIA_APB_CLK_ROOT, CLK_ROOT_ON | 
CLK_ROOT_SOURCE_SEL(2) | CLK_ROOT_PRE_DIV(CLK_ROOT_PRE_DIV4));
+
+   /* 27Mhz MIPI DPHY PLL ref from video PLL */
+   clock_set_target_val(MEDIA_MIPI_PHY1_REF_CLK_ROOT, CLK_ROOT_ON 
| CLK_ROOT_SOURCE_SEL(7) | CLK_ROOT_POST_DIV(CLK_ROOT_POST_DIV22));
+   clock_enable(CCGR_DISPMIX, true);
+   }
+}
+
  void init_uart_clk(u32 index)
  {
/*
@@ -485,6 +508,8 @@ int clock_init(void)
  
  	clock_enable(CCGR_SEC_DEBUG, 1);
  
+	enable_display_clk();

+
return 0;
  };
  


Re: [PATCH] kontron-sl-mx8mm: Let CONFIG_SPL_FIT_IMAGE_TINY be selected

2022-08-24 Thread Frieder Schrempf
Hi Fabio,

Am 24.08.22 um 03:09 schrieb Fabio Estevam:
> When CONFIG_IMX_HAB is selected the 'hab_status' command reports several
> error events, indicating that the BootROM failed to authenticate the SPL.
> 
> After inspecting the content of the memory location that corresponds to
> the DTB load address, the content did not match with the DTB binary,
> showing that some kind of memory corruption/overlap occurred.
> 
> Letting the CONFIG_SPL_FIT_IMAGE_TINY option to be selected causes the
> DTB to be properly placed into RAM and no more overlap occurs.
> 
> With this change, the 'hab_status' command returns no more error events,
> which indicates that the BootROM succeeded to authenticate the SPL.
> 
> Signed-off-by: Fabio Estevam 

Thanks for debugging!

I remember that enabling CONFIG_SPL_FIT_IMAGE_TINY resulted in aliases
from the devicetree not being available anymore. This in turn caused the
indexing of some devices to not be consistent between SPL, U-Boot proper
and kernel. But I don't remember which exact problems were caused by this.

I tried this on top of my patchset [1] and at first glance I don't see
any obvious problems, so I hope whatever I have in the back of my mind
is not an issue anymore.

Reviewed-by: Frieder Schrempf 

[1]
https://patchwork.ozlabs.org/project/uboot/cover/20220801103027.96820-1-frie...@fris.de/

Thanks
Frieder


Re: [PATCH v5 07/12] efi_loader: disk: a helper function to create efi_disk objects from udevice

2022-08-24 Thread Vyacheslav
Config for jethub_j100 did't contain any EFI* options. But build .config 
has these lines:

CONFIG_BOOTMETH_EFILOADER=y
CONFIG_CMD_BOOTEFI=y
CONFIG_CMD_BOOTEFI_HELLO_COMPILE=y
CONFIG_EFI_PARTITION=y
CONFIG_EFI_LOADER=y
CONFIG_CMD_BOOTEFI_BOOTMGR=y
CONFIG_EFI_SETUP_EARLY=y
CONFIG_EFI_VARIABLE_FILE_STORE=y
CONFIG_EFI_GET_TIME=y
CONFIG_EFI_DEVICE_PATH_TO_TEXT=y
CONFIG_EFI_DEVICE_PATH_UTIL=y
CONFIG_EFI_DT_FIXUP=y
CONFIG_EFI_LOADER_HII=y
CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2=y
CONFIG_EFI_UNICODE_CAPITALIZATION=y
CONFIG_EFI_HAVE_RUNTIME_RESET=y
CONFIG_EFI_RNG_PROTOCOL=y
CONFIG_EFI_LOAD_FILE2_INITRD=y

If I set it all to "n" bug dissapears and board boots normally.

24.08.2022 12:00, Vyacheslav wrote:
I has similar problem on axg meson64. Seems problem exists at least on 
1Gb RAM devices, my device with 2 GB RAM did not hit this error.


--
Vyacheslav Bocharov


Re: [RFC PATCH] imx8mp: fix boot hang when booting NXP kernel 5.15.32

2022-08-24 Thread Rasmus Villemoes
On 23/08/2022 16.04, Marek Vasut wrote:

> 
> You might want to check Linux /sys/kernel/debug/clk/clk_summary
> before/after this change and see if there are any differences . If so,
> try using assigned-clock-rates in Linux DT and see if that can achieve
> the same "fix" effect.

Thanks for the hint. Oddly enough, I do see some changes, but only in
the order of the lines - and in particular, even though some lines are
moved around, all clocks are still under the same parent clock as
before. Also all frequencies are the same before/after.

Specifically, I see media_mipi_phy1_ref, media_axi and media_apb (along
with their children) being moved up/down, but they are still children
of, respectively, osc_24m, sys_pll2_1000m and sys_pll1_800m.

So I don't see how that could help me figure out some
assigned-clock-rates or assigned-clock-parents settings that are missing
from DT.

Thanks,
Rasmus


Re: [PATCH v13 8/9] doc:eficonfig: add documentation for eficonfig command

2022-08-24 Thread Ilias Apalodimas
Hi Kojima-san

On Wed, 24 Aug 2022 at 09:37, Masahisa Kojima
 wrote:
>
> Add documentation for eficonfig command.
>
> Signed-off-by: Masahisa Kojima 
> ---
> Changes in v13:
> - describe how to auto boot according to the UEFI Boot option
>
> Changes in v12:
> - CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE condition is added
>   to show newly added boot option
>
> No update since v10
>
> Changes in v10:
> - describe how to boot system after editting by eficonfig
>
> Changes in v8:
> - command name is changed from "efimenu" to "eficonfig"
>
> Newly created in v7
>
>  doc/usage/cmd/eficonfig.rst | 71 +
>  doc/usage/index.rst |  1 +
>  2 files changed, 72 insertions(+)
>  create mode 100644 doc/usage/cmd/eficonfig.rst
>
> diff --git a/doc/usage/cmd/eficonfig.rst b/doc/usage/cmd/eficonfig.rst
> new file mode 100644
> index 00..48932fa16b
> --- /dev/null
> +++ b/doc/usage/cmd/eficonfig.rst
> @@ -0,0 +1,71 @@
> +.. SPDX-License-Identifier: GPL-2.0+
> +.. (C) Copyright 2022, Masahisa Kojima 
> +
> +eficonfig command
> +=
> +
> +Synopsis
> +
> +::
> +
> +eficonfig
> +
> +Description
> +---
> +
> +The "eficonfig" command uses U-Boot menu interface and privides

provides

> +a menu-driven UEFI variable maintenance feature.
> +The "eficonfig" has the following menu entries.
> +
> +Add Boot Option
> +Add new UEFI Boot Option.
> +User can edit description, file path, and optional_data.
> +
> +Edit Boot Option
> +Edit the existing UEFI Boot Option
> +User can edit description, file path, and optional_data.
> +
> +Change Boot Order
> +Change the order of UEFI BootOrder variable.
> +
> +Delete Boot Option
> +Delete the UEFI Boot Option
> +
> +Configuration
> +-
> +
> +The "eficonfig" command is enabled by::
> +
> +CONFIG_CMD_EFICONFIG=y
> +
> +If CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE is enabled, user can not enter
> +U-Boot console. In this case, bootmenu can be used to invoke "eficonfig"::
> +
> +CONFIG_USE_PREBOOT=y
> +CONFIG_PREBOOT="setenv bootmenu_0 UEFI Maintenance Menu=eficonfig"
> +
> +How to boot the system with newly added UEFI Boot Option
> +
> +
> +"eficonfig" command is responsible to configure the UEFI variables,

is responsible for configuring

> +not directly handle the system boot.
> +The new Boot Option added by "eficonfig" is appended at the last entry
> +of UEFI BootOrder variable, user may want to change the boot order
> +through "Change Boot Order".
> +If the bootmenu is enabled, CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE is enabled,
> +and "eficonfig" is configured as preboot command, the newly added Boot 
> Options
> +are enumerated in the bootmenu when user exits from the eficonfig menu.
> +User may select the entry in the bootmenu to boot the system, or follow
> +the U-Boot configuration the system already has.
> +
> +Auto boot with the UEFI Boot Option
> +'''
> +
> +To do auto boot according to the UEFI BootOrder variable,
> +add "bootefi bootmgr" entry as a default or first bootmenu entry::
> +
> +CONFIG_PREBOOT="setenv bootmenu_0 UEFI Boot Manager=bootefi bootmgr; 
> setenv bootmenu_1 UEFI Maintenance Menu=eficonfig"
> +
> +See also
> +
> +* :doc:`bootmenu` provides a simple mechanism for creating menus 
> with different boot items
> diff --git a/doc/usage/index.rst b/doc/usage/index.rst
> index 28f9683a3e..09f2928970 100644
> --- a/doc/usage/index.rst
> +++ b/doc/usage/index.rst
> @@ -35,6 +35,7 @@ Shell commands
> cmd/conitrace
> cmd/dm
> cmd/echo
> +   cmd/eficonfig
> cmd/env
> cmd/event
> cmd/exception
> --
> 2.17.1
>

With these changes

Reviewed-by: Ilias Apalodimas 


Re: [PATCH v13 9/9] test: unit test for eficonfig

2022-08-24 Thread Ilias Apalodimas
On Wed, 24 Aug 2022 at 09:37, Masahisa Kojima
 wrote:
>
> Provide a unit test for the eficonfig command.
>
> Signed-off-by: Masahisa Kojima 
> ---
> No update since v12
>
> Changes in v12:
> - update menu handling
>
> Changes in v11:
> - fix expected result when no BootOrder is defined
>
> Newly added in v10
>
>  configs/sandbox_defconfig |   1 +
>  test/py/tests/test_eficonfig/conftest.py  |  40 +++
>  .../py/tests/test_eficonfig/test_eficonfig.py | 332 ++
>  3 files changed, 373 insertions(+)
>  create mode 100644 test/py/tests/test_eficonfig/conftest.py
>  create mode 100644 test/py/tests/test_eficonfig/test_eficonfig.py
>
> diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
> index eba7bcbb48..48c60c606d 100644
> --- a/configs/sandbox_defconfig
> +++ b/configs/sandbox_defconfig
> @@ -93,6 +93,7 @@ CONFIG_CMD_LINK_LOCAL=y
>  CONFIG_CMD_ETHSW=y
>  CONFIG_CMD_BMP=y
>  CONFIG_CMD_BOOTCOUNT=y
> +CONFIG_CMD_EFICONFIG=y
>  CONFIG_CMD_EFIDEBUG=y
>  CONFIG_CMD_RTC=y
>  CONFIG_CMD_TIME=y
> diff --git a/test/py/tests/test_eficonfig/conftest.py 
> b/test/py/tests/test_eficonfig/conftest.py
> new file mode 100644
> index 00..f289df0362
> --- /dev/null
> +++ b/test/py/tests/test_eficonfig/conftest.py
> @@ -0,0 +1,40 @@
> +# SPDX-License-Identifier:  GPL-2.0+
> +
> +"""Fixture for UEFI eficonfig test
> +"""
> +
> +import os
> +import shutil
> +from subprocess import check_call
> +import pytest
> +
> +@pytest.fixture(scope='session')
> +def efi_eficonfig_data(u_boot_config):
> +"""Set up a file system to be used in UEFI "eficonfig" command
> +   tests
> +
> +Args:
> +u_boot_config -- U-boot configuration.
> +
> +Return:
> +A path to disk image to be used for testing
> +"""
> +mnt_point = u_boot_config.persistent_data_dir + '/test_efi_eficonfig'
> +image_path = u_boot_config.persistent_data_dir + '/efi_eficonfig.img'
> +
> +shutil.rmtree(mnt_point, ignore_errors=True)
> +os.mkdir(mnt_point, mode = 0o755)
> +
> +with open(mnt_point + '/initrd-1.img', 'w', encoding = 'ascii') as file:
> +file.write("initrd 1")
> +
> +with open(mnt_point + '/initrd-2.img', 'w', encoding = 'ascii') as file:
> +file.write("initrd 2")
> +
> +shutil.copyfile(u_boot_config.build_dir + 
> '/lib/efi_loader/initrddump.efi',
> +mnt_point + '/initrddump.efi')
> +
> +check_call(f'virt-make-fs --partition=gpt --size=+1M --type=vfat 
> {mnt_point} {image_path}',
> +   shell=True)
> +
> +return image_path
> diff --git a/test/py/tests/test_eficonfig/test_eficonfig.py 
> b/test/py/tests/test_eficonfig/test_eficonfig.py
> new file mode 100644
> index 00..0edb1ec627
> --- /dev/null
> +++ b/test/py/tests/test_eficonfig/test_eficonfig.py
> @@ -0,0 +1,332 @@
> +# SPDX-License-Identifier:  GPL-2.0+
> +""" Unit test for UEFI menu-driven configuration
> +"""
> +
> +import pytest
> +import time
> +
> +@pytest.mark.boardspec('sandbox')
> +@pytest.mark.buildconfigspec('cmd_eficonfig')
> +@pytest.mark.buildconfigspec('cmd_bootefi_bootmgr')
> +def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
> +
> +def send_user_input_and_wait(user_str, expect_str):
> +time.sleep(0.1) # TODO: does not work correctly without sleep
> +u_boot_console.run_command(cmd=user_str, wait_for_prompt=False,
> +   wait_for_echo=True, send_nl=False)
> +u_boot_console.run_command(cmd='\x0d', wait_for_prompt=False,
> +   wait_for_echo=False, send_nl=False)
> +if expect_str is not None:
> +for i in expect_str:
> +u_boot_console.p.expect([i])
> +
> +def press_up_down_enter_and_wait(up_count, down_count, enter, 
> expect_str):
> +# press UP key
> +for i in range(up_count):
> +u_boot_console.run_command(cmd='\x1b\x5b\x41', 
> wait_for_prompt=False,
> +   wait_for_echo=False, send_nl=False)
> +# press DOWN key
> +for i in range(down_count):
> +u_boot_console.run_command(cmd='\x1b\x5b\x42', 
> wait_for_prompt=False,
> +   wait_for_echo=False, send_nl=False)
> +# press ENTER if requested
> +if enter:
> +u_boot_console.run_command(cmd='\x0d', wait_for_prompt=False,
> +   wait_for_echo=False, send_nl=False)
> +# wait expected output
> +if expect_str is not None:
> +for i in expect_str:
> +u_boot_console.p.expect([i])
> +
> +def press_escape_key(wait_prompt):
> +u_boot_console.run_command(cmd='\x1b', wait_for_prompt=wait_prompt, 
> wait_for_echo=False, send_nl=False)
> +
> +def press_enter_key(wait_prompt):
> +u_boot_console.run_command(cmd='\x0d', wait_for_prompt=wait_prompt,
> +   

Re: [PATCH v5 07/12] efi_loader: disk: a helper function to create efi_disk objects from udevice

2022-08-24 Thread Vyacheslav
I has similar problem on axg meson64. Seems problem exists at least on 
1Gb RAM devices, my device with 2 GB RAM did not hit this error.



19.05.2022 8:04, AKASHI Takahiro wrote:

On Wed, May 18, 2022 at 11:23:32AM +0200, Neil Armstrong wrote:

On 19/04/2022 03:05, AKASHI Takahiro wrote:

Add efi_disk_probe() function.
This function creates an efi_disk object for a raw disk device (UCLASS_BLK)
and additional objects for related partitions (UCLASS_PARTITION).

So this function is expected to be called through driver model's "probe"
interface every time one raw disk device is detected and activated.
We assume that partition devices (UCLASS_PARTITION) have been created
when this function is invoked.

Signed-off-by: AKASHI Takahiro 
---
   include/efi_loader.h  |   4 +-
   lib/efi_driver/efi_block_device.c |  34 ++---
   lib/efi_loader/Kconfig|   3 +
   lib/efi_loader/efi_disk.c | 201 +++---
   lib/efi_loader/efi_setup.c|   4 +-
   5 files changed, 143 insertions(+), 103 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 5bb8fb2acd04..ba79a9afb404 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -525,8 +525,8 @@ void efi_carve_out_dt_rsv(void *fdt);
   void efi_try_purge_kaslr_seed(void *fdt);
   /* Called by bootefi to make console interface available */
   efi_status_t efi_console_register(void);
-/* Called by bootefi to make all disk storage accessible as EFI objects */
-efi_status_t efi_disk_register(void);
+/* Called by efi_init_obj_list() to initialize efi_disks */
+efi_status_t efi_disk_init(void);
   /* Called by efi_init_obj_list() to install EFI_RNG_PROTOCOL */
   efi_status_t efi_rng_register(void);
   /* Called by efi_init_obj_list() to install EFI_TCG2_PROTOCOL */
diff --git a/lib/efi_driver/efi_block_device.c 
b/lib/efi_driver/efi_block_device.c
index 04cb3ef0d4e5..5baa6f87a375 100644
--- a/lib/efi_driver/efi_block_device.c
+++ b/lib/efi_driver/efi_block_device.c
@@ -35,6 +35,7 @@
   #include 
   #include 
   #include 
+#include 
   /*
* EFI attributes of the udevice handled by this driver.
@@ -106,25 +107,6 @@ static ulong efi_bl_write(struct udevice *dev, lbaint_t 
blknr, lbaint_t blkcnt,
return blkcnt;
   }
-/**
- * Create partions for the block device.
- *
- * @handle:EFI handle of the block device
- * @dev:   udevice of the block device
- * Return: number of partitions created
- */
-static int efi_bl_bind_partitions(efi_handle_t handle, struct udevice *dev)
-{
-   struct blk_desc *desc;
-   const char *if_typename;
-
-   desc = dev_get_uclass_plat(dev);
-   if_typename = blk_get_if_type_name(desc->if_type);
-
-   return efi_disk_create_partitions(handle, desc, if_typename,
- desc->devnum, dev->name);
-}
-
   /**
* Create a block device for a handle
*
@@ -139,7 +121,6 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
char *name;
struct efi_object *obj = efi_search_obj(handle);
struct efi_block_io *io = interface;
-   int disks;
struct efi_blk_plat *plat;
EFI_PRINT("%s: handle %p, interface %p\n", __func__, handle, io);
@@ -173,15 +154,20 @@ static int efi_bl_bind(efi_handle_t handle, void 
*interface)
plat->handle = handle;
plat->io = interface;
+   /*
+* FIXME: necessary because we won't do almost nothing in
+* efi_disk_create() when called from device_probe().
+*/
+   ret = dev_tag_set_ptr(bdev, DM_TAG_EFI, handle);
+   if (ret)
+   /* FIXME: cleanup for bdev */
+   return ret;
+
ret = device_probe(bdev);
if (ret)
return ret;
EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name);
-   /* Create handles for the partions of the block device */
-   disks = efi_bl_bind_partitions(handle, bdev);
-   EFI_PRINT("Found %d partitions\n", disks);
-
return 0;
   }
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index bc518d7a413b..6b245f50a726 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -14,6 +14,8 @@ config EFI_LOADER
depends on DM_ETH || !NET
depends on !EFI_APP
default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8
+   select DM_EVENT
+   select EVENT_DYNAMIC
select LIB_UUID
imply PARTITION_UUIDS
select HAVE_BLOCK_DEVICE
@@ -40,6 +42,7 @@ config CMD_BOOTEFI_BOOTMGR
   config EFI_SETUP_EARLY
bool
+   default y
   choice
prompt "Store for non-volatile UEFI variables"
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index c905c12abc2f..d4a0edb458b8 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -10,6 +10,9 @@
   #include 
   #include 
   #include 
+#include 
+#include 
+#include 
   #include 
   #include 
   #include 
@@ -487,103 +490,153 @@ error:

[PATCH] kbuild: add KBUILD_HOSTLDFLAGS to cmd_host-csingle

2022-08-24 Thread Heiko Thiery
When compiling executables from a single.c file, the linker is also
invoked. Pass the flags like the other linker commands.

cherry-pick kbuild change from Linux:

63185b46cdb3 (kbuild: use HOSTLDFLAGS for single .c executables)

Signed-off-by: Heiko Thiery 
---
 scripts/Makefile.host | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 69983a19a4..7624304e3e 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -89,7 +89,7 @@ hostcxx_flags  = -Wp,-MD,$(depfile) $(__hostcxx_flags)
 # Create executable from a single .c file
 # host-csingle -> Executable
 quiet_cmd_host-csingle = HOSTCC  $@
-  cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@ $< \
+  cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(KBUILD_HOSTLDFLAGS) -o $@ 
$< \
$(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F))
 $(host-csingle): $(obj)/%: $(src)/%.c FORCE
$(call if_changed_dep,host-csingle)
-- 
2.20.1



Re: [PATCH v4 6/7] tpm: Implement state command for Cr50

2022-08-24 Thread Ilias Apalodimas
Hi Simon,


[...]

> +
> +static int cr50_i2c_report_state(struct udevice *dev, char *str, int str_max)
> +{
> +   char buf[50];
> +   int buf_size = sizeof(buf);

Shouldn't this be size_t?  I'll go through the rest of the patches, if
that's the only issue I find, I'll fix it while merging

Thanks
/Ilias
> +   int ret;
> +
> +   ret = tpm2_report_state(dev, TPM2_CR50_VENDOR_COMMAND,
> +   TPM2_CR50_SUB_CMD_REPORT_TPM_STATE,
> +   buf, _size);
> +   if (ret)
> +   return ret;
> +
> +   /* TPM responded as expected */
> +   ret = stringify_state(buf, buf_size, str, str_max);
> +   if (ret)
> +   return ret;
> +
> +   return 0;
> +}
> +
>  static int cr50_i2c_open(struct udevice *dev)
>  {
> char buf[80];
> @@ -730,6 +892,7 @@ struct acpi_ops cr50_acpi_ops = {
>  static const struct tpm_ops cr50_i2c_ops = {
> .open   = cr50_i2c_open,
> .get_desc   = cr50_i2c_get_desc,
> +   .report_state   = cr50_i2c_report_state,
> .send   = cr50_i2c_send,
> .recv   = cr50_i2c_recv,
> .cleanup= cr50_i2c_cleanup,
> diff --git a/include/tpm-v2.h b/include/tpm-v2.h
> index e79c90b9395..36c6ac0be6e 100644
> --- a/include/tpm-v2.h
> +++ b/include/tpm-v2.h
> @@ -658,4 +658,17 @@ u32 tpm2_disable_platform_hierarchy(struct udevice *dev);
>  u32 tpm2_submit_command(struct udevice *dev, const u8 *sendbuf,
> u8 *recvbuf, size_t *recv_size);
>
> +/**
> + * tpm_cr50_report_state() - Report the Cr50 internal state
> + *
> + * @dev:   TPM device
> + * @vendor_cmd:Vendor command number to send
> + * @vendor_subcmd: Vendor sub-command number to send
> + * @recvbuf:   Buffer to save the response to
> + * @recv_size: Pointer to the size of the response buffer
> + * Return: result of the operation
> + */
> +u32 tpm2_report_state(struct udevice *dev, uint vendor_cmd, uint 
> vendor_subcmd,
> + u8 *recvbuf, size_t *recv_size);
> +
>  #endif /* __TPM_V2_H */
> diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c
> index 3e240bb4c67..edee9854a7c 100644
> --- a/lib/tpm-v2.c
> +++ b/lib/tpm-v2.c
> @@ -679,3 +679,28 @@ u32 tpm2_submit_command(struct udevice *dev, const u8 
> *sendbuf,
>  {
> return tpm_sendrecv_command(dev, sendbuf, recvbuf, recv_size);
>  }
> +
> +u32 tpm2_report_state(struct udevice *dev, uint vendor_cmd, uint 
> vendor_subcmd,
> + u8 *recvbuf, size_t *recv_size)
> +{
> +   u8 command_v2[COMMAND_BUFFER_SIZE] = {
> +   /* header 10 bytes */
> +   tpm_u16(TPM2_ST_NO_SESSIONS),   /* TAG */
> +   tpm_u32(10 + 2),/* Length */
> +   tpm_u32(vendor_cmd),/* Command code */
> +
> +   tpm_u16(vendor_subcmd),
> +   };
> +   int ret;
> +
> +   ret = tpm_sendrecv_command(dev, command_v2, recvbuf, recv_size);
> +   log_debug("ret=%s, %x\n", dev->name, ret);
> +   if (ret)
> +   return ret;
> +   if (*recv_size < 12)
> +   return -ENODATA;
> +   *recv_size -= 12;
> +   memcpy(recvbuf, recvbuf + 12, *recv_size);
> +
> +   return 0;
> +}
> --
> 2.37.2.609.g9ff673ca1a-goog
>


Re: [PATCH u-boot 0/3] renesas: Fix RPC-IF enablement

2022-08-24 Thread Geert Uytterhoeven
Hi Iwamatsu-san, Marek,

On Wed, Jun 15, 2022 at 4:34 PM Geert Uytterhoeven  wrote:
> On Tue, Mar 29, 2022 at 2:19 PM Geert Uytterhoeven
>  wrote:
> > On Renesas R-Car Gen3 platforms, the SPI Multi I/O Bus Controllers
> > (RPC-IF) provide access to HyperFlash or QSPI storage.  On production
> > systems, they are typically locked by the TF-A firmware, unless TF-A is
> > built with RCAR_RPC_HYPERFLASH_LOCKED=0.  When unlocked, TF-A
> > communicates this to subsequent software by passing a DT fragment that
> > sets the "status" property of the RPC-IF device node to "okay".
> >
> > Unfortunately there are several issues preventing this from working all
> > the way to Linux:
> >   1. TF-A (and U-Boot on the receiving side) uses a device node name
> >  that does not conform to the DT specification nor the DT bindings
> >  for RPC-IF,
> >   2. While U-Boot receives the RPC-IF enablement from TF-A, it does not
> >  propagate it to Linux yet,
> >   3. The DTS files that are part of Linux do not have RPC HyperFlash
> >  support yet.
> >
> > The first issue in TF-A is handled by [1].
> >
> > This patch series takes care of the first and second issue in U-Boot, by
> > renaming the RPC-IF device node, and by propagating the enablement from
> > TF-A, if present, to Linux.  The third patch updates the RPC-IF
> > compatible values to match the actual DT bindings, but this is not
> > critical for operation, and can be postponed (e.g. by syncing DTS with
> > Linux v5.19).
> >
> > Patches to enable RPC-IF support in Linux are available at [2].
>
> The patches to enable RPC HyperFlash support in Linux are now in
> v5.19-rc1.  What needs to be done to accept the U-Boot counterpart?

The Linux counterpart is now in v5.19.
Can you please apply at least the first two patches to U-Boot?
Thanks!

> >
> > Thanks for your comments!
> >
> > [1] "[PATCH TF-A] fix(plat/rcar3): Fix RPC-IF device node name"
> > 
> > https://lore.kernel.org/r/3685623bed84674039adb61e723288d359ab0a50.1648544199.git.geert+rene...@glider.be
> > [2] "[PATCH 0/5] arm64: dts: renesas: rcar-gen3: Enable HyperFlash support"
> > https://lore.kernel.org/r/cover.1648548339.git.geert+rene...@glider.be
> >
> > Geert Uytterhoeven (3):
> >   ARM: dts: rmobile: Fix RPC-IF device node names
> >   ARM: renesas: Propagate RPC-IF enablement to subsequent software
> >   [RFC] renesas: Fix RPC-IF compatible values
> >
> >  arch/arm/dts/r7s72100-gr-peach-u-boot.dts |  4 +-
> >  arch/arm/dts/r8a774c0-u-boot.dtsi |  4 +-
> >  arch/arm/dts/r8a77950-u-boot.dtsi |  4 +-
> >  arch/arm/dts/r8a77960-u-boot.dtsi |  4 +-
> >  arch/arm/dts/r8a77965-u-boot.dtsi |  4 +-
> >  arch/arm/dts/r8a77970-u-boot.dtsi |  4 +-
> >  arch/arm/dts/r8a77980-u-boot.dtsi |  4 +-
> >  arch/arm/dts/r8a77990-u-boot.dtsi |  4 +-
> >  arch/arm/dts/r8a77995-u-boot.dtsi |  4 +-
> >  arch/arm/dts/r8a779a0-u-boot.dtsi |  2 +-
> >  board/renesas/rcar-common/common.c| 46 ++-
> >  drivers/mtd/renesas_rpc_hf.c  |  3 +-
> >  drivers/spi/renesas_rpc_spi.c |  9 +
> >  13 files changed, 67 insertions(+), 29 deletions(-)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


  1   2   >