Re: [PATCH] dts: rockchip: rk3399: enable emmc phy for spl

2021-12-17 Thread Patrick Wildt
Am Mon, Nov 01, 2021 at 12:43:47PM +0800 schrieb Yifeng Zhao:
> adapting commit ac804143cf ("mmc: rockchip_sdhci: add phy and clock
> config for rk3399") to fix the issue "Not found emmc phy device".

Reviewed-by: Patrick Wildt 
Tested-by: Patrick Wildt  - on a Pinebook Pro

Please merge, otherwise the Pinebook Pro doesn't boot up at all.

> Signed-off-by: Yifeng Zhao 
> ---
> 
>  arch/arm/dts/rk3399-u-boot.dtsi | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm/dts/rk3399-u-boot.dtsi b/arch/arm/dts/rk3399-u-boot.dtsi
> index 73922c328a..716b9a433a 100644
> --- a/arch/arm/dts/rk3399-u-boot.dtsi
> +++ b/arch/arm/dts/rk3399-u-boot.dtsi
> @@ -88,6 +88,10 @@
>   u-boot,dm-pre-reloc;
>  };
>  
> +&emmc_phy {
> + u-boot,dm-pre-reloc;
> +};
> +
>  &grf {
>   u-boot,dm-pre-reloc;
>  };
> -- 
> 2.17.1
> 
> 
> 


Re: [PATCH v2 3/4] Revert "mtd: spi-nor-core: Perform a Soft Reset on boot"

2021-12-17 Thread Pratyush Yadav
On 17/12/21 06:27AM, tudor.amba...@microchip.com wrote:
> On 12/16/21 8:45 PM, Pratyush Yadav wrote:
> 
> >
> >> SFDP signature to determine the mode in which the flash is configured:
> >> '''
> >> try to read the SFDP signature (see 6.1) in 4-4-4 mode, if that fails
> >> try 2-2-2 mode, and if that fails try 1-1-1 mode. For Octal devices,
> >> these typically support SFDP read operation in both 1S-1S-1S mode and
> >> 8D-8D-8D mode. If the host controller does not know exactly which
> >> protocol mode is used for SFDP in 8D-8D-8D mode, this information can 
> >> be
> >> found by reading SFDP in 1S-1S-1S mode first. (To read an unknown 
> >> device
> >> directly in 8D-8D-8D mode, the host controller may read from address 0,
> >> and count the number of dummy clocks required before the SFDP signature
> >> is received.)
> >> '''
> 
>  Below is the approach for the flashes that are not SFDP compliant:
> 
> >> If the flash does not support SFDP at all, one should introduce 
> >> dedicated
> >> configs for each reset type and issue just the needed reset command.
> >>>
> >>> There are some problems with this approach. What if we have two flashes
> >>> on the board and both use different reset types? How do we figure out
> >>> which reset to apply? This applies to the current implementation as
> >>> well. If there are two flashes then it will issue the reset to both even
> >>> if one of them does not support/need it.
> >>
> >> One would have to choose the NOR manufacturer with care next time. If we'll
> >> have to statically define the reset type for both the flashes, there's 
> >> nothing
> >> much we can do. Maybe if you have a gpio reset line connected to the flash 
> >> you
> >> can toggle that instead.
> > 
> > Or we can specify the reset type in the device tree? That should neatly
> > solve the problem I believe.
> > 
> 
> It is surely an approach to consider. The downside with it is that people 
> might
> abuse it, and use it regardless if the reset type is defined in SFDP or not.
> Do we care?

I am not sure to be honest. Let's think through that once the problem 
actually comes up I suppose.

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.


Re: [PATCH v2] efi_loader: Get rid of kaslr-seed

2021-12-17 Thread Heinrich Schuchardt

On 12/17/21 08:06, Ilias Apalodimas wrote:

Right now we unconditionally pass a 'kaslr-seed' property to the kernel
if the DTB we ended up in EFI includes the entry.  However the kernel
EFI stub completely ignores it and only relies on EFI_RNG_PROTOCOL for
it's own randomness needs (i.e the randomization of the physical
placement of the kernel).
So let's get rid of it if EFI_RNG_PPROTOCOL is installed.

It's worth noting that TPMs also provide an RNG.  So if we tweak our
EFI_RNG_PROTOCOL slightly and install the protocol when a TPM device
is present the 'kaslr-seed' property will always be removed, allowing
us to reliably measure our DTB as well.

Acked-by: Ard Biesheuvel 
Signed-off-by: Ilias Apalodimas 
---
changes since v1:
- Only removing the property if EFI_RNG_PROTOCOL is installed, since some
   OS'es rely on kaslr-seed


Each TPMv2 provides a hardware RNG. So you can unconditionally remove
the kaslr-seed and create a new one by calling TPM2_GetRandom().

It would further be useful to provide a DM RNG driver using
TPM2_GetRandom().

Best regards

Heinrich


[PATCH v2] ARM: dts: imx6ull: Use the correct name for ESAI_TX0

2021-12-17 Thread Fabio Estevam
According to the i.MX6ULL Reference Manual, pad CSI_DATA07 may
have the ESAI_TX0 functionality, not ESAI_T0.

Also, NXP's i.MX Config Tools 10.0 generates dtsi with the
MX6ULL_PAD_CSI_DATA07__ESAI_TX0 naming, so fix it accordingly.

There are no devicetree users in mainline that use the old name,
so just remove the old entry.

Fixes: f8ca22b8de32 ("arm: dts: imx6ull: add pinctrl defines")
Reported-by: George Makarov 
Signed-off-by: Fabio Estevam 
---
Changes since v2:
- Use the linux-version fix:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/arch/arm/boot/dts/imx6ull-pinfunc.h?h=next-20211216&id=737e65c7956795b3553781fb7bc82fce1c39503f

 arch/arm/dts/imx6ull-pinfunc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/imx6ull-pinfunc.h b/arch/arm/dts/imx6ull-pinfunc.h
index eb025a9d4759..7328d4ef8559 100644
--- a/arch/arm/dts/imx6ull-pinfunc.h
+++ b/arch/arm/dts/imx6ull-pinfunc.h
@@ -82,6 +82,6 @@
 #define MX6ULL_PAD_CSI_DATA04__ESAI_TX_FS 0x01F4 
0x0480 0x 0x9 0x0
 #define MX6ULL_PAD_CSI_DATA05__ESAI_TX_CLK0x01F8 
0x0484 0x 0x9 0x0
 #define MX6ULL_PAD_CSI_DATA06__ESAI_TX5_RX0   0x01FC 
0x0488 0x 0x9 0x0
-#define MX6ULL_PAD_CSI_DATA07__ESAI_T00x0200 
0x048C 0x 0x9 0x0
+#define MX6ULL_PAD_CSI_DATA07__ESAI_TX0   0x0200 
0x048C 0x 0x9 0x0
 
 #endif /* __DTS_IMX6ULL_PINFUNC_H */
-- 
2.25.1



Re: [PATCH v2] efi_loader: Get rid of kaslr-seed

2021-12-17 Thread Mark Kettenis
> From: Ilias Apalodimas 
> Date: Fri, 17 Dec 2021 09:06:44 +0200
> 
> Right now we unconditionally pass a 'kaslr-seed' property to the kernel
> if the DTB we ended up in EFI includes the entry.  However the kernel
> EFI stub completely ignores it and only relies on EFI_RNG_PROTOCOL for
> it's own randomness needs (i.e the randomization of the physical
> placement of the kernel).
> So let's get rid of it if EFI_RNG_PPROTOCOL is installed.
> 
> It's worth noting that TPMs also provide an RNG.  So if we tweak our
> EFI_RNG_PROTOCOL slightly and install the protocol when a TPM device
> is present the 'kaslr-seed' property will always be removed, allowing
> us to reliably measure our DTB as well.

That looks good to me.  But I think you should be honest here.  You're
removing the kaslr-seed property here because it is a part of the DTB
that changes on every boot, which interferes with the measurability.
Not because there is something wrong with passing along the
kaslr-seed.  In the absence of EFI_RNG_PROTOCOL support passing
kaslr-seed still has a benefit as it will still be used for
randomization of the virtual placement of the kernel.  So I think the
comment could use some rewording (but the bit on randomization of the
physical placement is certainly accurate and worth keeping).

Oh, and please say "The Linux kernel's EFI STUB".

Cheers,

Mark

> Acked-by: Ard Biesheuvel 
> Signed-off-by: Ilias Apalodimas 
> ---
> changes since v1:
> - Only removing the property if EFI_RNG_PROTOCOL is installed, since some
>   OS'es rely on kaslr-seed
> - Only display an error message if the kaslr-seed entry was found but not
>   removed
>  cmd/bootefi.c |  2 ++
>  include/efi_loader.h  |  2 ++
>  lib/efi_loader/efi_dt_fixup.c | 33 +
>  3 files changed, 37 insertions(+)
> 
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index d77d3b6e943d..57f13ce701ec 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -310,6 +310,8 @@ efi_status_t efi_install_fdt(void *fdt)
>   /* Create memory reservations as indicated by the device tree */
>   efi_carve_out_dt_rsv(fdt);
>  
> + efi_try_purge_kaslr_seed(fdt);
> +
>   /* Install device tree as UEFI table */
>   ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
>   if (ret != EFI_SUCCESS) {
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 9dd6c2033634..1fe003db69e0 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -519,6 +519,8 @@ efi_status_t EFIAPI efi_convert_pointer(efi_uintn_t 
> debug_disposition,
>   void **address);
>  /* Carve out DT reserved memory ranges */
>  void efi_carve_out_dt_rsv(void *fdt);
> +/* Purge unused kaslr-seed */
> +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 */
> diff --git a/lib/efi_loader/efi_dt_fixup.c b/lib/efi_loader/efi_dt_fixup.c
> index b6fe5d2e5a34..d3923e5dba1b 100644
> --- a/lib/efi_loader/efi_dt_fixup.c
> +++ b/lib/efi_loader/efi_dt_fixup.c
> @@ -8,6 +8,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -40,6 +41,38 @@ static void efi_reserve_memory(u64 addr, u64 size, bool 
> nomap)
>   addr, size);
>  }
>  
> +/**
> + * efi_try_purge_kaslr_seed() - Remove unused kaslr-seed
> + *
> + * Kernel's EFI STUB only relies on EFI_RNG_PROTOCOL for randomization
> + * and completely ignores the kaslr-seed for its own randomness needs
> + * (i.e the randomization of the physical placement of the kernel).
> + * Weed it out from the DTB we hand over, which would mess up our DTB
> + * TPM measurements as well.
> + *
> + * @fdt: Pointer to device tree
> + */
> +void efi_try_purge_kaslr_seed(void *fdt)
> +{
> + const efi_guid_t efi_guid_rng_protocol = EFI_RNG_PROTOCOL_GUID;
> + struct efi_handler *handler;
> + efi_status_t ret;
> + int nodeoff = 0;
> + int err = 0;
> +
> + ret = efi_search_protocol(efi_root, &efi_guid_rng_protocol, &handler);
> + if (ret != EFI_SUCCESS)
> + return;
> +
> + nodeoff = fdt_path_offset(fdt, "/chosen");
> + if (nodeoff < 0)
> + return;
> +
> + err = fdt_delprop(fdt, nodeoff, "kaslr-seed");
> + if (err < 0 && err != -FDT_ERR_NOTFOUND)
> + log_err("Error deleting kaslr-seed\n");
> +}
> +
>  /**
>   * efi_carve_out_dt_rsv() - Carve out DT reserved memory ranges
>   *
> -- 
> 2.30.2
> 
> 


Re: [PATCH v2] efi_loader: Get rid of kaslr-seed

2021-12-17 Thread Ilias Apalodimas
Hi Heinrich,


On Fri, 17 Dec 2021 at 12:59, Heinrich Schuchardt  wrote:
>
> On 12/17/21 08:06, Ilias Apalodimas wrote:
> > Right now we unconditionally pass a 'kaslr-seed' property to the kernel
> > if the DTB we ended up in EFI includes the entry.  However the kernel
> > EFI stub completely ignores it and only relies on EFI_RNG_PROTOCOL for
> > it's own randomness needs (i.e the randomization of the physical
> > placement of the kernel).
> > So let's get rid of it if EFI_RNG_PPROTOCOL is installed.
> >
> > It's worth noting that TPMs also provide an RNG.  So if we tweak our
> > EFI_RNG_PROTOCOL slightly and install the protocol when a TPM device
> > is present the 'kaslr-seed' property will always be removed, allowing
> > us to reliably measure our DTB as well.
> >
> > Acked-by: Ard Biesheuvel 
> > Signed-off-by: Ilias Apalodimas 
> > ---
> > changes since v1:
> > - Only removing the property if EFI_RNG_PROTOCOL is installed, since some
> >OS'es rely on kaslr-seed
>
> Each TPMv2 provides a hardware RNG. So you can unconditionally remove
> the kaslr-seed and create a new one by calling TPM2_GetRandom().
>
> It would further be useful to provide a DM RNG driver using
> TPM2_GetRandom().

Yes it would, but that's orthogonal to this patch. I did look at this
and there's a bit of plumbing still missing, which I'll fix when I
post the series for measuring a DTB.

Cheers
/Ilias
>
> Best regards
>
> Heinrich


Re: [PATCH v2] efi_loader: Get rid of kaslr-seed

2021-12-17 Thread Ilias Apalodimas
Hi Mark, 

On Fri, Dec 17, 2021 at 12:13:20PM +0100, Mark Kettenis wrote:
> > From: Ilias Apalodimas 
> > Date: Fri, 17 Dec 2021 09:06:44 +0200
> > 
> > Right now we unconditionally pass a 'kaslr-seed' property to the kernel
> > if the DTB we ended up in EFI includes the entry.  However the kernel
> > EFI stub completely ignores it and only relies on EFI_RNG_PROTOCOL for
> > it's own randomness needs (i.e the randomization of the physical
> > placement of the kernel).
> > So let's get rid of it if EFI_RNG_PPROTOCOL is installed.
> > 
> > It's worth noting that TPMs also provide an RNG.  So if we tweak our
> > EFI_RNG_PROTOCOL slightly and install the protocol when a TPM device
> > is present the 'kaslr-seed' property will always be removed, allowing
> > us to reliably measure our DTB as well.
> 
> That looks good to me.  But I think you should be honest here.  You're
> removing the kaslr-seed property here because it is a part of the DTB
> that changes on every boot, which interferes with the measurability.
> Not because there is something wrong with passing along the
> kaslr-seed.  

Yep never tried to hide that :)

> In the absence of EFI_RNG_PROTOCOL support passing
> kaslr-seed still has a benefit as it will still be used for
> randomization of the virtual placement of the kernel.  So I think the
> comment could use some rewording (but the bit on randomization of the
> physical placement is certainly accurate and worth keeping).
> 
> Oh, and please say "The Linux kernel's EFI STUB".

Sure something along the lines of:

"Right now we unconditionally keep a 'kaslr-seed' property in the DTB,
if what we ended up in EFI includes the entry.  However the Linux kernel
EFI-stub completely ignores it and only relies on EFI_RNG_PROTOCOL for
it's own randomness needs (i.e the randomization of the physical
placement of the kernel).  In fact it (blindly) overwrites the existing 
seed if the EFI_RNG_PROTOCOL protocol is installed.  However it still uses
it for randomization of the virtual placement of the kernel if the EFI
protocol is not installed. 
So let's get rid of it if EFI_RNG_PPROTOCOL is installed.

It's worth noting that TPMs also provide an RNG.  So if we tweak our
EFI_RNG_PROTOCOL slightly and install the protocol when a TPM device
is present the 'kaslr-seed' property will always be removed, allowing
us to reliably measure our DTB as well."

Cheers
/Ilias
> 
> Cheers,
> 
> Mark
> 
> > Acked-by: Ard Biesheuvel 
> > Signed-off-by: Ilias Apalodimas 
> > ---
> > changes since v1:
> > - Only removing the property if EFI_RNG_PROTOCOL is installed, since some
> >   OS'es rely on kaslr-seed
> > - Only display an error message if the kaslr-seed entry was found but not
> >   removed
> >  cmd/bootefi.c |  2 ++
> >  include/efi_loader.h  |  2 ++
> >  lib/efi_loader/efi_dt_fixup.c | 33 +
> >  3 files changed, 37 insertions(+)
> > 
> > diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> > index d77d3b6e943d..57f13ce701ec 100644
> > --- a/cmd/bootefi.c
> > +++ b/cmd/bootefi.c
> > @@ -310,6 +310,8 @@ efi_status_t efi_install_fdt(void *fdt)
> > /* Create memory reservations as indicated by the device tree */
> > efi_carve_out_dt_rsv(fdt);
> >  
> > +   efi_try_purge_kaslr_seed(fdt);
> > +
> > /* Install device tree as UEFI table */
> > ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
> > if (ret != EFI_SUCCESS) {
> > diff --git a/include/efi_loader.h b/include/efi_loader.h
> > index 9dd6c2033634..1fe003db69e0 100644
> > --- a/include/efi_loader.h
> > +++ b/include/efi_loader.h
> > @@ -519,6 +519,8 @@ efi_status_t EFIAPI efi_convert_pointer(efi_uintn_t 
> > debug_disposition,
> > void **address);
> >  /* Carve out DT reserved memory ranges */
> >  void efi_carve_out_dt_rsv(void *fdt);
> > +/* Purge unused kaslr-seed */
> > +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 */
> > diff --git a/lib/efi_loader/efi_dt_fixup.c b/lib/efi_loader/efi_dt_fixup.c
> > index b6fe5d2e5a34..d3923e5dba1b 100644
> > --- a/lib/efi_loader/efi_dt_fixup.c
> > +++ b/lib/efi_loader/efi_dt_fixup.c
> > @@ -8,6 +8,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  
> > @@ -40,6 +41,38 @@ static void efi_reserve_memory(u64 addr, u64 size, bool 
> > nomap)
> > addr, size);
> >  }
> >  
> > +/**
> > + * efi_try_purge_kaslr_seed() - Remove unused kaslr-seed
> > + *
> > + * Kernel's EFI STUB only relies on EFI_RNG_PROTOCOL for randomization
> > + * and completely ignores the kaslr-seed for its own randomness needs
> > + * (i.e the randomization of the physical placement of the kernel).
> > + * Weed it out from the DTB we hand over, which would mess up our DTB
> > + * TPM measurements as well.
> 

Re: [PATCH v2] efi_loader: Get rid of kaslr-seed

2021-12-17 Thread Mark Kettenis
> Date: Fri, 17 Dec 2021 13:23:59 +0200
> From: Ilias Apalodimas 
> 
> Hi Mark, 
> 
> On Fri, Dec 17, 2021 at 12:13:20PM +0100, Mark Kettenis wrote:
> > > From: Ilias Apalodimas 
> > > Date: Fri, 17 Dec 2021 09:06:44 +0200
> > > 
> > > Right now we unconditionally pass a 'kaslr-seed' property to the kernel
> > > if the DTB we ended up in EFI includes the entry.  However the kernel
> > > EFI stub completely ignores it and only relies on EFI_RNG_PROTOCOL for
> > > it's own randomness needs (i.e the randomization of the physical
> > > placement of the kernel).
> > > So let's get rid of it if EFI_RNG_PPROTOCOL is installed.
> > > 
> > > It's worth noting that TPMs also provide an RNG.  So if we tweak our
> > > EFI_RNG_PROTOCOL slightly and install the protocol when a TPM device
> > > is present the 'kaslr-seed' property will always be removed, allowing
> > > us to reliably measure our DTB as well.
> > 
> > That looks good to me.  But I think you should be honest here.  You're
> > removing the kaslr-seed property here because it is a part of the DTB
> > that changes on every boot, which interferes with the measurability.
> > Not because there is something wrong with passing along the
> > kaslr-seed.  
> 
> Yep never tried to hide that :)
> 
> > In the absence of EFI_RNG_PROTOCOL support passing
> > kaslr-seed still has a benefit as it will still be used for
> > randomization of the virtual placement of the kernel.  So I think the
> > comment could use some rewording (but the bit on randomization of the
> > physical placement is certainly accurate and worth keeping).
> > 
> > Oh, and please say "The Linux kernel's EFI STUB".
> 
> Sure something along the lines of:
> 
> "Right now we unconditionally keep a 'kaslr-seed' property in the DTB,
> if what we ended up in EFI includes the entry.  However the Linux kernel
> EFI-stub completely ignores it and only relies on EFI_RNG_PROTOCOL for
> it's own randomness needs (i.e the randomization of the physical
> placement of the kernel).  In fact it (blindly) overwrites the existing 
> seed if the EFI_RNG_PROTOCOL protocol is installed.  However it still uses
> it for randomization of the virtual placement of the kernel if the EFI
> protocol is not installed. 
> So let's get rid of it if EFI_RNG_PPROTOCOL is installed.
> 
> It's worth noting that TPMs also provide an RNG.  So if we tweak our
> EFI_RNG_PROTOCOL slightly and install the protocol when a TPM device
> is present the 'kaslr-seed' property will always be removed, allowing
> us to reliably measure our DTB as well."

I would go in the other direction.  I'd explain why you want to remove
kaslr-seed first (Property changes every boot; interferes with
measured boot) and then explain why removing it in the presence of
EFI_RNG_PROTOCOL support is fine (Linux kernel EFI STUB doesn't use
for randomizing physical placement; overwrites it if EFI_RNG_PROTOCOL
is implemented).

I think describing it that way will prevent confusion in the future.

Cheers,

Mark

> > Cheers,
> > 
> > Mark
> > 
> > > Acked-by: Ard Biesheuvel 
> > > Signed-off-by: Ilias Apalodimas 
> > > ---
> > > changes since v1:
> > > - Only removing the property if EFI_RNG_PROTOCOL is installed, since some
> > >   OS'es rely on kaslr-seed
> > > - Only display an error message if the kaslr-seed entry was found but not
> > >   removed
> > >  cmd/bootefi.c |  2 ++
> > >  include/efi_loader.h  |  2 ++
> > >  lib/efi_loader/efi_dt_fixup.c | 33 +
> > >  3 files changed, 37 insertions(+)
> > > 
> > > diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> > > index d77d3b6e943d..57f13ce701ec 100644
> > > --- a/cmd/bootefi.c
> > > +++ b/cmd/bootefi.c
> > > @@ -310,6 +310,8 @@ efi_status_t efi_install_fdt(void *fdt)
> > >   /* Create memory reservations as indicated by the device tree */
> > >   efi_carve_out_dt_rsv(fdt);
> > >  
> > > + efi_try_purge_kaslr_seed(fdt);
> > > +
> > >   /* Install device tree as UEFI table */
> > >   ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
> > >   if (ret != EFI_SUCCESS) {
> > > diff --git a/include/efi_loader.h b/include/efi_loader.h
> > > index 9dd6c2033634..1fe003db69e0 100644
> > > --- a/include/efi_loader.h
> > > +++ b/include/efi_loader.h
> > > @@ -519,6 +519,8 @@ efi_status_t EFIAPI efi_convert_pointer(efi_uintn_t 
> > > debug_disposition,
> > >   void **address);
> > >  /* Carve out DT reserved memory ranges */
> > >  void efi_carve_out_dt_rsv(void *fdt);
> > > +/* Purge unused kaslr-seed */
> > > +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 
> > > */
> > > diff --git a/lib/efi_loader/efi_dt_fixup.c b/lib/efi_loader/efi_dt_fixup.c
> > > index b6fe5d2e5a34..d3923e5dba1b 100644
> > > --- a/lib/efi_loader/efi_dt_fixup.c
> > > +++ b/lib/efi_loader/efi

[PATCH 0/3] Conformance Profiles Table support in U-boot

2021-12-17 Thread Jose Marinho
The Conformance Profiles Table (ECPT) table will be included in the UEFI
specification 2.9+.
The ECPT table was introduced in UEFI following the code-first path. The
acceptance ticket can be viewed at:
https://bugzilla.tianocore.org/show_bug.cgi?id=3591

This patch set implements the ECPT table in U-boot.

Jose Marinho (3):
  efi: Create ECPT table
  efi: ECPT add EBBRv2.0 conformance profile
  cmd: efi: efidebug print ECPT table

 cmd/efidebug.c   | 45 +++
 include/efi_api.h| 14 ++
 include/efi_loader.h |  9 
 lib/efi_loader/Kconfig   | 12 +
 lib/efi_loader/Makefile  |  1 +
 lib/efi_loader/efi_conformance.c | 75 
 lib/efi_loader/efi_setup.c   |  6 +++
 7 files changed, 162 insertions(+)
 create mode 100644 lib/efi_loader/efi_conformance.c

-- 
2.25.1



[PATCH 2/3] efi: ECPT add EBBRv2.0 conformance profile

2021-12-17 Thread Jose Marinho
Display the EBBRv2.0 conformance in the ECPT table.

The EBBRv2.0 conformance profile is set in the ECPT if
CONFIG_EFI_EBBR_2_0_CONFORMANCE=y.
The config defaults to 'n'.


Signed-off-by: Jose Marinho 
---
 include/efi_api.h| 4 
 lib/efi_loader/Kconfig   | 6 ++
 lib/efi_loader/efi_conformance.c | 9 +
 3 files changed, 19 insertions(+)

diff --git a/include/efi_api.h b/include/efi_api.h
index 6fd4f04de3..49919caa35 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -230,6 +230,10 @@ enum efi_reset_type {
EFI_GUID(0x36122546, 0xf7ef, 0x4c8f, 0xbd, 0x9b, \
 0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b)
 
+#define EFI_CONFORMANCE_PROFILE_EBBR_2_0_GUID \
+   EFI_GUID(0xcce33c35, 0x74ac, 0x4087, 0xbc, 0xe7, \
+0x8b, 0x29, 0xb0, 0x2e, 0xeb, 0x27)
+
 struct efi_conformance_profiles_table {
u16 version;
u16 number_of_profiles;
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index b2398976f4..ab7476f68b 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -373,4 +373,10 @@ config EFI_ECPT
help
  Enabling this option created the ECPT UEFI table.
 
+config EFI_EBBR_2_0_CONFORMANCE
+   bool "Add the EBBRv2.0 conformance entry to the ECPT table"
+   depends on EFI_ECPT
+   default n
+   help
+ Enabling this option adds the EBBRv2.0 conformance entry to the ECPT 
UEFI table.
 endif
diff --git a/lib/efi_loader/efi_conformance.c b/lib/efi_loader/efi_conformance.c
index 86c26d6b79..b490ff3326 100644
--- a/lib/efi_loader/efi_conformance.c
+++ b/lib/efi_loader/efi_conformance.c
@@ -12,6 +12,7 @@
 #include 
 
 const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID;
+const efi_guid_t efi_ebbr_2_0_guid = EFI_CONFORMANCE_PROFILE_EBBR_2_0_GUID;
 
 #define EFI_CONFORMANCE_PROFILES_TABLE_VERSION 1
 
@@ -29,6 +30,9 @@ efi_status_t efi_ecpt_register(void)
 
EFI_PRINT("ECPT table creation start\n");
 
+   if (IS_ENABLED(CONFIG_EFI_EBBR_2_0_CONFORMANCE))
+   num_entries++;
+
ecpt_size = num_entries * sizeof(efi_guid_t)
+ sizeof(struct efi_conformance_profiles_table);
ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, ecpt_size,
@@ -44,6 +48,11 @@ efi_status_t efi_ecpt_register(void)
ecpt->version = EFI_CONFORMANCE_PROFILES_TABLE_VERSION;
ecpt->number_of_profiles = num_entries;
 
+   if (IS_ENABLED(CONFIG_EFI_EBBR_2_0_CONFORMANCE)) {
+   num_entries--;
+   guidcpy(&ecpt->conformance_profiles[num_entries], 
&efi_ecpt_guid);
+   }
+
if (num_entries)
EFI_PRINT("ECPT check conformance profiles, not all entries 
populated in table\n");
 
-- 
2.25.1



[PATCH 3/3] cmd: efi: efidebug print ECPT table

2021-12-17 Thread Jose Marinho
Signed-off-by: Jose Marinho 
---
 cmd/efidebug.c   | 41 +
 include/efi_loader.h |  2 ++
 2 files changed, 43 insertions(+)

diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index a53a5029fa..c3246e1820 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -889,6 +889,38 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int 
flag,
return CMD_RET_SUCCESS;
 }
 
+#ifdef CONFIG_EFI_ECPT
+static int do_efi_ecpt(struct cmd_tbl *cmdtp, int flag,
+  int argc, char * const argv[])
+{
+   struct efi_conformance_profiles_table *ecpt;
+
+   if (argc != 1)
+   return CMD_RET_USAGE;
+
+   for (int idx = 0; idx < systab.nr_tables; idx++)
+   if (!guidcmp(&efi_ecpt_guid, &systab.tables[idx].guid))
+   ecpt = (struct efi_system_resource_table 
*)systab.tables[idx].table;
+
+   if (!ecpt) {
+   log_info("ECPT: table not present\n");
+   return CMD_RET_SUCCESS;
+   }
+
+   const int num_profiles = ecpt->number_of_profiles;
+
+   printf("\n");
+   printf("ECPT: version:%d\n", ecpt->version);
+   printf("ECPT: num profiles:%d\n", num_profiles);
+
+   for (int i = 0; i < num_profiles; i++)
+   printf("ECPT: profile %d = %pUL\n", i, 
&ecpt->conformance_profiles[i]);
+   printf("\n");
+
+   return CMD_RET_SUCCESS;
+}
+#endif /* CONFIG_EFI_ECPT */
+
 /**
  * create_initrd_dp() - Create a special device for our Boot### option
  *
@@ -1681,6 +1713,11 @@ static struct cmd_tbl cmd_efidebug_sub[] = {
 "", ""),
U_BOOT_CMD_MKENT(query, CONFIG_SYS_MAXARGS, 1, do_efi_query_info,
 "", ""),
+#ifdef CONFIG_EFI_ECPT
+   U_BOOT_CMD_MKENT(ecpt, CONFIG_SYS_MAXARGS, 1, do_efi_ecpt,
+"", ""),
+#endif
+
 };
 
 /**
@@ -1769,6 +1806,10 @@ static char efidebug_help_text[] =
"  - show UEFI memory map\n"
"efidebug tables\n"
"  - show UEFI configuration tables\n"
+#ifdef CONFIG_EFI_ECPT
+   "efidebug ecpt\n"
+   "  - show UEFI conformance profiles table\n"
+#endif
 #ifdef CONFIG_CMD_BOOTEFI_BOOTMGR
"efidebug test bootmgr\n"
"  - run simple bootmgr for test\n"
diff --git a/include/efi_loader.h b/include/efi_loader.h
index d20ff396d0..d60a340136 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -310,6 +310,8 @@ extern const efi_guid_t 
efi_guid_firmware_management_protocol;
 extern const efi_guid_t efi_esrt_guid;
 /* GUID of the SMBIOS table */
 extern const efi_guid_t smbios_guid;
+/* GUID for the ECPT */
+extern const efi_guid_t efi_ecpt_guid;
 
 extern char __efi_runtime_start[], __efi_runtime_stop[];
 extern char __efi_runtime_rel_start[], __efi_runtime_rel_stop[];
-- 
2.25.1



[PATCH 1/3] efi: Create ECPT table

2021-12-17 Thread Jose Marinho
The ECPT table will be included in the UEFI specification 2.9+.
The ECPT table was introduced in UEFI following the code-first path. The
acceptance ticket can be viewed at:
https://bugzilla.tianocore.org/show_bug.cgi?id=3591

The Conformance Profiles table is a UEFI configuration table that contains
GUID of the UEFI profiles that the UEFI implementation conforms with.

The ECPT table is created when CONFIG_EFI_ECPT=y.
The config is set by default.

Signed-off-by: Jose Marinho 
---
 cmd/efidebug.c   |  4 ++
 include/efi_api.h| 10 +
 include/efi_loader.h |  7 
 lib/efi_loader/Kconfig   |  6 +++
 lib/efi_loader/Makefile  |  1 +
 lib/efi_loader/efi_conformance.c | 66 
 lib/efi_loader/efi_setup.c   |  6 +++
 7 files changed, 100 insertions(+)
 create mode 100644 lib/efi_loader/efi_conformance.c

diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index a977ca9c72..a53a5029fa 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -619,6 +619,10 @@ static const struct {
"TCG2 Final Events Table",
EFI_TCG2_FINAL_EVENTS_TABLE_GUID,
},
+   {
+   "EFI Conformance Profiles Table",
+   EFI_CONFORMANCE_PROFILES_TABLE_GUID,
+   },
 };
 
 /**
diff --git a/include/efi_api.h b/include/efi_api.h
index 80109f012b..6fd4f04de3 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -226,6 +226,16 @@ enum efi_reset_type {
EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \
 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
 
+#define EFI_CONFORMANCE_PROFILES_TABLE_GUID \
+   EFI_GUID(0x36122546, 0xf7ef, 0x4c8f, 0xbd, 0x9b, \
+0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b)
+
+struct efi_conformance_profiles_table {
+   u16 version;
+   u16 number_of_profiles;
+   efi_guid_t  conformance_profiles[];
+} __packed;
+
 struct efi_capsule_header {
efi_guid_t capsule_guid;
u32 header_size;
diff --git a/include/efi_loader.h b/include/efi_loader.h
index d52e399841..d20ff396d0 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -976,6 +976,13 @@ efi_status_t efi_capsule_authenticate(const void *capsule,
  */
 efi_status_t efi_esrt_register(void);
 
+/**
+ * efi_ecpt_register() - Install the ECPT system table.
+ *
+ * Return: status code
+ */
+efi_status_t efi_ecpt_register(void);
+
 /**
  * efi_esrt_populate() - Populates the ESRT entries from the FMP instances
  * present in the system.
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 700dc838dd..b2398976f4 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -367,4 +367,10 @@ config EFI_ESRT
help
  Enabling this option creates the ESRT UEFI system table.
 
+config EFI_ECPT
+   bool "Enable the UEFI ECPT generation"
+   default y
+   help
+ Enabling this option created the ECPT UEFI table.
+
 endif
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index fd344cea29..9f5a0cebd1 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -64,6 +64,7 @@ obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
 obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o
 obj-$(CONFIG_EFI_LOAD_FILE2_INITRD) += efi_load_initrd.o
 obj-$(CONFIG_EFI_SIGNATURE_SUPPORT) += efi_signature.o
+obj-$(CONFIG_EFI_ECPT) += efi_conformance.o
 
 EFI_VAR_SEED_FILE := $(subst $\",,$(CONFIG_EFI_VAR_SEED_FILE))
 $(obj)/efi_var_seed.o: $(srctree)/$(EFI_VAR_SEED_FILE)
diff --git a/lib/efi_loader/efi_conformance.c b/lib/efi_loader/efi_conformance.c
new file mode 100644
index 00..86c26d6b79
--- /dev/null
+++ b/lib/efi_loader/efi_conformance.c
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ *  EFI conformance profile table
+ *
+ *  Copyright (C) 2022 Arm Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID;
+
+#define EFI_CONFORMANCE_PROFILES_TABLE_VERSION 1
+
+/**
+ * efi_ecpt_register() - Install the ECPT system table.
+ *
+ * Return: status code
+ */
+efi_status_t efi_ecpt_register(void)
+{
+   int num_entries = 0;
+   struct efi_conformance_profiles_table *ecpt;
+   efi_status_t ret;
+   size_t ecpt_size = 0;
+
+   EFI_PRINT("ECPT table creation start\n");
+
+   ecpt_size = num_entries * sizeof(efi_guid_t)
+   + sizeof(struct efi_conformance_profiles_table);
+   ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, ecpt_size,
+   (void **)&ecpt);
+
+   if (ret != EFI_SUCCESS) {
+   EFI_PRINT("ECPT cannot allocate memory for %u entries (%zu 
bytes)\n",
+ num_entries, ecpt_size);
+
+   return ret;
+   }
+
+   ecpt->version = EFI_CONFORMANCE_PROFILES_TABLE_VERSION;
+   ecpt->number_of_profiles = num_entries;
+
+   if (num_entries)
+   EFI_PRINT("ECPT check conformance prof

Re: [PATCH 3/3] cmd: efi: efidebug print ECPT table

2021-12-17 Thread Heinrich Schuchardt
Am 17. Dezember 2021 13:55:06 MEZ schrieb Jose Marinho :
>Signed-off-by: Jose Marinho 

Please, provide a commit message.

Best regards

Heinrich

>---
> cmd/efidebug.c   | 41 +
> include/efi_loader.h |  2 ++
> 2 files changed, 43 insertions(+)
>
>diff --git a/cmd/efidebug.c b/cmd/efidebug.c
>index a53a5029fa..c3246e1820 100644
>--- a/cmd/efidebug.c
>+++ b/cmd/efidebug.c
>@@ -889,6 +889,38 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int 
>flag,
>   return CMD_RET_SUCCESS;
> }
> 
>+#ifdef CONFIG_EFI_ECPT
>+static int do_efi_ecpt(struct cmd_tbl *cmdtp, int flag,
>+ int argc, char * const argv[])
>+{
>+  struct efi_conformance_profiles_table *ecpt;
>+
>+  if (argc != 1)
>+  return CMD_RET_USAGE;
>+
>+  for (int idx = 0; idx < systab.nr_tables; idx++)
>+  if (!guidcmp(&efi_ecpt_guid, &systab.tables[idx].guid))
>+  ecpt = (struct efi_system_resource_table 
>*)systab.tables[idx].table;
>+
>+  if (!ecpt) {
>+  log_info("ECPT: table not present\n");
>+  return CMD_RET_SUCCESS;
>+  }
>+
>+  const int num_profiles = ecpt->number_of_profiles;
>+
>+  printf("\n");
>+  printf("ECPT: version:%d\n", ecpt->version);
>+  printf("ECPT: num profiles:%d\n", num_profiles);
>+
>+  for (int i = 0; i < num_profiles; i++)
>+  printf("ECPT: profile %d = %pUL\n", i, 
>&ecpt->conformance_profiles[i]);
>+  printf("\n");
>+
>+  return CMD_RET_SUCCESS;
>+}
>+#endif /* CONFIG_EFI_ECPT */
>+
> /**
>  * create_initrd_dp() - Create a special device for our Boot### option
>  *
>@@ -1681,6 +1713,11 @@ static struct cmd_tbl cmd_efidebug_sub[] = {
>"", ""),
>   U_BOOT_CMD_MKENT(query, CONFIG_SYS_MAXARGS, 1, do_efi_query_info,
>"", ""),
>+#ifdef CONFIG_EFI_ECPT
>+  U_BOOT_CMD_MKENT(ecpt, CONFIG_SYS_MAXARGS, 1, do_efi_ecpt,
>+   "", ""),
>+#endif
>+
> };
> 
> /**
>@@ -1769,6 +1806,10 @@ static char efidebug_help_text[] =
>   "  - show UEFI memory map\n"
>   "efidebug tables\n"
>   "  - show UEFI configuration tables\n"
>+#ifdef CONFIG_EFI_ECPT
>+  "efidebug ecpt\n"
>+  "  - show UEFI conformance profiles table\n"
>+#endif
> #ifdef CONFIG_CMD_BOOTEFI_BOOTMGR
>   "efidebug test bootmgr\n"
>   "  - run simple bootmgr for test\n"
>diff --git a/include/efi_loader.h b/include/efi_loader.h
>index d20ff396d0..d60a340136 100644
>--- a/include/efi_loader.h
>+++ b/include/efi_loader.h
>@@ -310,6 +310,8 @@ extern const efi_guid_t 
>efi_guid_firmware_management_protocol;
> extern const efi_guid_t efi_esrt_guid;
> /* GUID of the SMBIOS table */
> extern const efi_guid_t smbios_guid;
>+/* GUID for the ECPT */
>+extern const efi_guid_t efi_ecpt_guid;
> 
> extern char __efi_runtime_start[], __efi_runtime_stop[];
> extern char __efi_runtime_rel_start[], __efi_runtime_rel_stop[];



Re: Pull request: SoCFPGA changes for clk-2022.01-rc3

2021-12-17 Thread Tom Rini
On Fri, Dec 17, 2021 at 05:44:35AM +, Chee, Tien Fong wrote:

> Hi Tom,
> 
> Please pull the SoCFPGA changes for clk-2022.01-rc3.
> Regards
> Tien Fong
> 
> The following changes since commit 5b20efeafec0ebe0ee5742c611e4f2153346797a:
> 
>   Merge tag 'clk-2022.01-rc3' of 
> https://source.denx.de/u-boot/custodians/u-boot-clk (2021-12-15 14:51:44 
> -0500)
> 
> are available in the Git repository at:
> 
>   https://github.com/tienfong/uboot_mainline.git 
> 4720b83d2c711062cfb55f03591b8f12c897d7cb
> 
> for you to fetch changes up to 4720b83d2c711062cfb55f03591b8f12c897d7cb:
> 
>   arm: socfpga: arria10: Enable double peripheral RBF configuration 
> (2021-12-17 12:58:01 +0800)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PULL next] u-boot-at91-2022.04-a

2021-12-17 Thread Tom Rini
On Fri, Dec 17, 2021 at 08:43:59AM +, eugen.hris...@microchip.com wrote:

> Hello Tom,
> 
> Please pull tag u-boot-at91-2022.04-a , the first set of at91 features 
> for the next cycle 2022.04 .
> 
> This feature set includes : support for the new QSPI hardware on 
> sama7g5, small fixes on sam9x60 and sama7g5, some additions of commands 
> and PIO controller on sam9x60/sam9x60ek.
> 
> Happy holidays !
> 
> Thanks,
> Eugen
> 
> 
> The following changes since commit 9272805139a104c83dff8230e03e9626dd9bc195:
> 
>Prepare v2022.01-rc2 (2021-11-15 11:58:37 -0500)
> 
> are available in the Git repository at:
> 
>https://source.denx.de/u-boot/custodians/u-boot-at91.git 
> tags/u-boot-at91-2022.04-a
> 
> for you to fetch changes up to 9bf459c23dc03f3c4405650e3c8578265fd9d62c:
> 
>ARM: mach-at91: Add compile time option to choose proper timer 
> (2021-12-16 11:41:45 +0200)
> 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] drivers: spi-nor: Add JEDEC id for W25Q16JV

2021-12-17 Thread Angus Ainslie

Hi,

Are there any problems with this patch ?

Thanks
Angus

On 2021-11-28 07:09, Angus Ainslie wrote:
Add a JEDEC id for the Winbond W25Q16JV 16M-BIT serial flash memory 
with

DUAL/QUAD SPI

Signed-off-by: Angus Ainslie 
---
 drivers/mtd/spi/spi-nor-ids.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-ids.c 
b/drivers/mtd/spi/spi-nor-ids.c

index 3ae7bb1ed7e..f20b21e0d06 100644
--- a/drivers/mtd/spi/spi-nor-ids.c
+++ b/drivers/mtd/spi/spi-nor-ids.c
@@ -314,6 +314,11 @@ const struct flash_info spi_nor_ids[] = {
SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
},
+   {
+   INFO("w25q16jv", 0xef7015, 0, 64 * 1024,  32,
+   SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
+   SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
+   },
{
INFO("w25q32jv", 0xef7016, 0, 64 * 1024,  64,
SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |


[PATCH 1/3] imx8m: clock_imx8mq: Add the ecspi clocks

2021-12-17 Thread Angus Ainslie
Enable the clocks for spi buses 1 through 3

Signed-off-by: Angus Ainslie 
---
 arch/arm/include/asm/arch-imx8m/imx-regs.h |  9 +
 arch/arm/mach-imx/imx8m/clock_imx8mq.c | 38 ++
 2 files changed, 47 insertions(+)

diff --git a/arch/arm/include/asm/arch-imx8m/imx-regs.h 
b/arch/arm/include/asm/arch-imx8m/imx-regs.h
index b800da13a1..8cb499d3a3 100644
--- a/arch/arm/include/asm/arch-imx8m/imx-regs.h
+++ b/arch/arm/include/asm/arch-imx8m/imx-regs.h
@@ -94,6 +94,15 @@
 #define SRC_DDR1_RCR_CORE_RESET_N_MASK BIT(1)
 #define SRC_DDR1_RCR_PRESET_N_MASK BIT(0)
 
+#define IMX_CSPI1_BASE 0x3082
+#define IMX_CSPI2_BASE 0x3083
+#define IMX_CSPI3_BASE 0x3084
+
+#define MXC_SPI_BASE_ADDRESSES \
+   IMX_CSPI1_BASE, \
+   IMX_CSPI2_BASE, \
+   IMX_CSPI3_BASE
+
 struct iomuxc_gpr_base_regs {
u32 gpr[47];
 };
diff --git a/arch/arm/mach-imx/imx8m/clock_imx8mq.c 
b/arch/arm/mach-imx/imx8m/clock_imx8mq.c
index 60e2218a3c..834a7bfa01 100644
--- a/arch/arm/mach-imx/imx8m/clock_imx8mq.c
+++ b/arch/arm/mach-imx/imx8m/clock_imx8mq.c
@@ -505,6 +505,31 @@ int set_clk_qspi(void)
return 0;
 }
 
+int set_clk_ecspi(int sel)
+{
+   int clk = ECSPI1_CLK_ROOT;
+
+   switch (sel) {
+   case 1:
+   clk = ECSPI1_CLK_ROOT;
+   break;
+   case 2:
+   clk = ECSPI2_CLK_ROOT;
+   break;
+   case 3:
+   clk = ECSPI3_CLK_ROOT;
+   break;
+   }
+
+   clock_enable(clk, 0);
+   /*
+* TODO: configure clock
+*/
+   clock_enable(clk, 1);
+
+   return 0;
+}
+
 #ifdef CONFIG_FEC_MXC
 int set_clk_enet(enum enet_freq type)
 {
@@ -772,6 +797,19 @@ int clock_init(void)
clock_enable(CCGR_TSENSOR, 1);
clock_enable(CCGR_OCOTP, 1);
 
+   /*
+* set ecspi roots
+*/
+   clock_enable(CCGR_ECSPI1, 0);
+   clock_enable(CCGR_ECSPI2, 0);
+   clock_enable(CCGR_ECSPI3, 0);
+   clock_set_target_val(ECSPI1_CLK_ROOT, CLK_ROOT_ON | 
CLK_ROOT_SOURCE_SEL(0));
+   clock_set_target_val(ECSPI2_CLK_ROOT, CLK_ROOT_ON | 
CLK_ROOT_SOURCE_SEL(0));
+   clock_set_target_val(ECSPI3_CLK_ROOT, CLK_ROOT_ON | 
CLK_ROOT_SOURCE_SEL(0));
+   clock_enable(CCGR_ECSPI1, 1);
+   clock_enable(CCGR_ECSPI2, 1);
+   clock_enable(CCGR_ECSPI3, 1);
+
/* config GIC ROOT to sys_pll2_200m */
clock_enable(CCGR_GIC, 0);
clock_set_target_val(GIC_CLK_ROOT,
-- 
2.25.1



[PATCH 0/3] add some imx8m power and clock control

2021-12-17 Thread Angus Ainslie
Enable some imx8m subsystems used when booting the librem5 phone

Angus Ainslie (3):
  imx8m: clock_imx8mq: Add the ecspi clocks
  arch: imx8m: imx-regs.h add the USB regs
  arch: imx8m: Add USB power control

 arch/arm/include/asm/arch-imx8m/imx-regs.h  | 14 +
 arch/arm/include/asm/arch-imx8m/sys_proto.h |  1 +
 arch/arm/mach-imx/imx8m/clock_imx8mq.c  | 38 ++
 arch/arm/mach-imx/imx8m/soc.c   | 57 +
 4 files changed, 110 insertions(+)

-- 
2.25.1



[PATCH 2/3] arch: imx8m: imx-regs.h add the USB regs

2021-12-17 Thread Angus Ainslie
Add the USB regs for SDP mode

Signed-off-by: Angus Ainslie 
---
 arch/arm/include/asm/arch-imx8m/imx-regs.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/include/asm/arch-imx8m/imx-regs.h 
b/arch/arm/include/asm/arch-imx8m/imx-regs.h
index 8cb499d3a3..bd474f88a6 100644
--- a/arch/arm/include/asm/arch-imx8m/imx-regs.h
+++ b/arch/arm/include/asm/arch-imx8m/imx-regs.h
@@ -103,6 +103,11 @@
IMX_CSPI2_BASE, \
IMX_CSPI3_BASE
 
+#define USB1_BASE_ADDR 0x3810
+#define USB2_BASE_ADDR 0x3820
+#define USB1_PHY_BASE_ADDR 0x381F
+#define USB2_PHY_BASE_ADDR 0x382F
+
 struct iomuxc_gpr_base_regs {
u32 gpr[47];
 };
-- 
2.25.1



[PATCH 3/3] arch: imx8m: Add USB power control

2021-12-17 Thread Angus Ainslie
Enable turning on USB power for SDP mode

Signed-off-by: Angus Ainslie 
---
 arch/arm/include/asm/arch-imx8m/sys_proto.h |  1 +
 arch/arm/mach-imx/imx8m/soc.c   | 57 +
 2 files changed, 58 insertions(+)

diff --git a/arch/arm/include/asm/arch-imx8m/sys_proto.h 
b/arch/arm/include/asm/arch-imx8m/sys_proto.h
index d328542ece..98a958166a 100644
--- a/arch/arm/include/asm/arch-imx8m/sys_proto.h
+++ b/arch/arm/include/asm/arch-imx8m/sys_proto.h
@@ -14,4 +14,5 @@ void restore_boot_params(void);
 extern unsigned long rom_pointer[];
 enum boot_device get_boot_device(void);
 bool is_usb_boot(void);
+int imx8m_usb_power(int usb_id, bool on);
 #endif
diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index 863508776d..a43075e1c6 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -1203,6 +1203,63 @@ int arch_misc_init(void)
 }
 #endif
 
+#ifdef CONFIG_SPL_BUILD
+static u32 gpc_pu_m_core_offset[11] = {
+   0xc00, 0xc40, 0xc80, 0xcc0,
+   0xdc0, 0xe00, 0xe40, 0xe80,
+   0xec0, 0xf00, 0xf40,
+};
+
+#define PGC_PCR0
+
+void imx_gpc_set_m_core_pgc(unsigned int offset, bool pdn)
+{
+   u32 val;
+   uintptr_t reg = GPC_BASE_ADDR + offset;
+
+   val = readl(reg);
+   val &= ~(0x1 << PGC_PCR);
+
+   if (pdn)
+   val |= 0x1 << PGC_PCR;
+   writel(val, reg);
+}
+
+void imx8m_usb_power_domain(u32 domain_id, bool on)
+{
+   u32 val;
+   uintptr_t reg;
+
+   imx_gpc_set_m_core_pgc(gpc_pu_m_core_offset[domain_id], true);
+
+   reg = GPC_BASE_ADDR + (on ? 0xf8 : 0x104);
+   val = 1 << (domain_id > 3 ? (domain_id + 3) : domain_id);
+   writel(val, reg);
+   while (readl(reg) & val)
+   ;
+   imx_gpc_set_m_core_pgc(gpc_pu_m_core_offset[domain_id], false);
+}
+#endif
+
+int imx8m_usb_power(int usb_id, bool on)
+{
+   struct arm_smccc_res res;
+
+   if (usb_id > 1)
+   return -EINVAL;
+
+#ifdef CONFIG_SPL_BUILD
+   imx8m_usb_power_domain(2 + usb_id, on);
+#else
+   arm_smccc_smc(IMX_SIP_GPC, IMX_SIP_GPC_PM_DOMAIN,
+ 2 + usb_id, on, 0, 0, 0, 0, &res);
+   if (res.a0)
+   return -EPERM;
+#endif
+
+   return 0;
+}
+
 void imx_tmu_arch_init(void *reg_base)
 {
if (is_imx8mm() || is_imx8mn()) {
-- 
2.25.1



[PATCH] arm: dts: stm32mp15: alignment with v5.16

2021-12-17 Thread Patrick Delaunay
Device tree alignment with Linux kernel v5.16-rc5
- ARM: dts: stm32: set otg-rev on stm32mp151
- ARM: dts: stm32: use usbphyc ck_usbo_48m as USBH OHCI clock on stm32mp151
- ARM: dts: stm32: fix AV96 board SAI2 pin muxing on stm32mp15
- ARM: dts: stm32: fix SAI sub nodes register range
- ARM: dts: stm32: fix STUSB1600 Type-C irq level on stm32mp15xx-dkx

Signed-off-by: Patrick Delaunay 
---

 arch/arm/dts/stm32mp15-pinctrl.dtsi |  8 
 arch/arm/dts/stm32mp151.dtsi| 19 ++-
 arch/arm/dts/stm32mp15xx-dkx.dtsi   |  2 +-
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/arch/arm/dts/stm32mp15-pinctrl.dtsi 
b/arch/arm/dts/stm32mp15-pinctrl.dtsi
index 5b60ecbd71..d3553e0f01 100644
--- a/arch/arm/dts/stm32mp15-pinctrl.dtsi
+++ b/arch/arm/dts/stm32mp15-pinctrl.dtsi
@@ -1179,7 +1179,7 @@
};
};
 
-   sai2a_pins_c: sai2a-4 {
+   sai2a_pins_c: sai2a-2 {
pins {
pinmux = , /* SAI2_SCK_A */
 , /* SAI2_SD_A */
@@ -1190,7 +1190,7 @@
};
};
 
-   sai2a_sleep_pins_c: sai2a-5 {
+   sai2a_sleep_pins_c: sai2a-sleep-2 {
pins {
pinmux = , /* SAI2_SCK_A 
*/
 , /* SAI2_SD_A 
*/
@@ -1235,14 +1235,14 @@
};
};
 
-   sai2b_pins_c: sai2a-4 {
+   sai2b_pins_c: sai2b-2 {
pins1 {
pinmux = ; /* SAI2_SD_B */
bias-disable;
};
};
 
-   sai2b_sleep_pins_c: sai2a-sleep-5 {
+   sai2b_sleep_pins_c: sai2b-sleep-2 {
pins {
pinmux = ; /* SAI2_SD_B 
*/
};
diff --git a/arch/arm/dts/stm32mp151.dtsi b/arch/arm/dts/stm32mp151.dtsi
index 8e0a0bc1dd..5a2be00758 100644
--- a/arch/arm/dts/stm32mp151.dtsi
+++ b/arch/arm/dts/stm32mp151.dtsi
@@ -842,7 +842,7 @@
#sound-dai-cells = <0>;
 
compatible = "st,stm32-sai-sub-a";
-   reg = <0x4 0x1c>;
+   reg = <0x4 0x20>;
clocks = <&rcc SAI1_K>;
clock-names = "sai_ck";
dmas = <&dmamux1 87 0x400 0x01>;
@@ -852,7 +852,7 @@
sai1b: audio-controller@4400a024 {
#sound-dai-cells = <0>;
compatible = "st,stm32-sai-sub-b";
-   reg = <0x24 0x1c>;
+   reg = <0x24 0x20>;
clocks = <&rcc SAI1_K>;
clock-names = "sai_ck";
dmas = <&dmamux1 88 0x400 0x01>;
@@ -873,7 +873,7 @@
sai2a: audio-controller@4400b004 {
#sound-dai-cells = <0>;
compatible = "st,stm32-sai-sub-a";
-   reg = <0x4 0x1c>;
+   reg = <0x4 0x20>;
clocks = <&rcc SAI2_K>;
clock-names = "sai_ck";
dmas = <&dmamux1 89 0x400 0x01>;
@@ -883,7 +883,7 @@
sai2b: audio-controller@4400b024 {
#sound-dai-cells = <0>;
compatible = "st,stm32-sai-sub-b";
-   reg = <0x24 0x1c>;
+   reg = <0x24 0x20>;
clocks = <&rcc SAI2_K>;
clock-names = "sai_ck";
dmas = <&dmamux1 90 0x400 0x01>;
@@ -904,7 +904,7 @@
sai3a: audio-controller@4400c004 {
#sound-dai-cells = <0>;
compatible = "st,stm32-sai-sub-a";
-   reg = <0x04 0x1c>;
+   reg = <0x04 0x20>;
clocks = <&rcc SAI3_K>;
clock-names = "sai_ck";
dmas = <&dmamux1 113 0x400 0x01>;
@@ -914,7 +914,7 @@
sai3b: audio-controller@4400c024 {
#sound-dai-cells = <0>;
compatible = "st,stm32-sai-sub-b";
-   reg = <0x24 0x1c>;
+   reg = <0x24 0x20>;
clocks = <&rcc SAI3_K>;
clock-names = "sai_ck";
dmas = <&dmamux1 114 0x400 0x01>;
@@ -1103,6 +1103,7 @@
g-np-tx-fifo-size = <32>;
g-tx-fifo-size = <256 16 16 16 16 16 16 16>;
dr_mode = "otg";
+   otg-rev = <0x200>;

[PATCH] spl: Provide more space to be used for storing SPL on imx28 OCRAM

2021-12-17 Thread Lukasz Majewski
With the current configuration provided in mxsimage{-spl}.mx28.cfg the
size of SPL binary has been constrained to 32 KiB, due to "LOAD IVT"
command with 0x8000 offset.

The problem was that, the imx28 ROM takes the u-boot.sb and then
extracts from it the IVT header and places it on the 0x8000 OCRAM offset
overwriting any valid (i.e. loaded from eMMC or SPI-NOR) SPL code. This
bug was unnoticed as the overwrite size was just 32 bytes, so the
probability that some important code is altered was low.

However, in the XEA board (where the SPL size is ~39KiB), the overwritten
data was `(struct dm_spi_ops *) 0x800c `, which is used
during the boot process.

As a result the SPL execution code hanged with "undefined instruction"
abort as callbacks (with wrong addresses) from it were called.

The fix is to change the OCRAM's offset where IVT is loaded to 0xE000,
so the SPL can grow up to ~57KiB (the maximal size of OCRAM memory
available is 0xE3FC).

Signed-off-by: Lukasz Majewski 
---
 arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg | 4 ++--
 arch/arm/cpu/arm926ejs/mxs/mxsimage.mx28.cfg | 8 
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg 
b/arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg
index 0d95064ff7f..fd09780303e 100644
--- a/arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg
+++ b/arch/arm/cpu/arm926ejs/mxs/mxsimage-spl.mx28.cfg
@@ -2,5 +2,5 @@ DISPLAYPROGRESS
 SECTION 0x0 BOOTABLE
  TAG LAST
  LOAD 0x1000 spl/u-boot-spl.bin
- LOAD IVT 0x8000 0x1000
- CALL HAB 0x8000 0x0
+ LOAD IVT 0xE000 0x1000
+ CALL HAB 0xE000 0x0
diff --git a/arch/arm/cpu/arm926ejs/mxs/mxsimage.mx28.cfg 
b/arch/arm/cpu/arm926ejs/mxs/mxsimage.mx28.cfg
index 3f7bf599248..f0f3dd7d6b1 100644
--- a/arch/arm/cpu/arm926ejs/mxs/mxsimage.mx28.cfg
+++ b/arch/arm/cpu/arm926ejs/mxs/mxsimage.mx28.cfg
@@ -2,8 +2,8 @@ DISPLAYPROGRESS
 SECTION 0x0 BOOTABLE
  TAG LAST
  LOAD 0x1000 spl/u-boot-spl.bin
- LOAD IVT 0x8000 0x1000
- CALL HAB 0x8000 0x0
+ LOAD IVT 0xE000 0x1000
+ CALL HAB 0xE000 0x0
  LOAD 0x40002000 u-boot.bin
- LOAD IVT 0x8000 0x40002000
- CALL HAB 0x8000 0x0
+ LOAD IVT 0xE000 0x40002000
+ CALL HAB 0xE000 0x0
-- 
2.20.1



[PATCH 1/2] fastboot: fb_getvar: Add getvar_logical_blocksize for MXP mfgtool

2021-12-17 Thread Angus Ainslie
uuu uses the blocksize to determine the upload size

Signed-off-by: Angus Ainslie 
---
 drivers/fastboot/fb_getvar.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c
index d43f2cfee6..ff5f0d3d40 100644
--- a/drivers/fastboot/fb_getvar.c
+++ b/drivers/fastboot/fb_getvar.c
@@ -31,6 +31,7 @@ static void getvar_partition_type(char *part_name, char 
*response);
 static void getvar_partition_size(char *part_name, char *response);
 #endif
 static void getvar_is_userspace(char *var_parameter, char *response);
+static void getvar_logical_blocksize(char *var_parameter, char *response);
 
 static const struct {
const char *variable;
@@ -81,6 +82,9 @@ static const struct {
}, {
.variable = "is-userspace",
.dispatch = getvar_is_userspace
+   }, {
+   .variable = "logical-block-size",
+   .dispatch = getvar_logical_blocksize
}
 };
 
@@ -140,6 +144,29 @@ static void getvar_downloadsize(char *var_parameter, char 
*response)
fastboot_response("OKAY", response, "0x%08x", fastboot_buf_size);
 }
 
+static int fb_get_block_size(void)
+{
+   int dev_no = 0;
+   struct blk_desc *dev_desc;
+
+   dev_desc = blk_get_dev("mmc", 0);
+
+   if (!dev_desc) {
+   printf("** Block device %s %d not supported\n",
+  "mmc", 0);
+   return 0;
+   }
+   return dev_desc->blksz;
+}
+
+static void getvar_logical_blocksize(char *var_parameter, char *response)
+{
+   u32 blksz;
+
+   blksz = fb_get_block_size();
+   fastboot_response("OKAY", response, "0x%08x", blksz);
+}
+
 static void getvar_serialno(char *var_parameter, char *response)
 {
const char *tmp = env_get("serial#");
-- 
2.25.1



[PATCH 0/2] Add more support for NXP's mfgtool

2021-12-17 Thread Angus Ainslie
NXP's mfgtool needs some additional switches to deal with the whole
mmc device.

Angus Ainslie (2):
  fastboot: fb_getvar: Add getvar_logical_blocksize for MXP mfgtool
  fastboot: fb_mmc: Add mfgtool all partition size

 drivers/fastboot/fb_getvar.c | 27 +++
 drivers/fastboot/fb_mmc.c|  7 +++
 2 files changed, 34 insertions(+)

-- 
2.25.1



[PATCH 2/2] fastboot: fb_mmc: Add mfgtool all partition size

2021-12-17 Thread Angus Ainslie
NXP mfgtool uses all to specify the entire partition

Signed-off-by: Angus Ainslie 
---
 drivers/fastboot/fb_mmc.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 2738dc836e..9ebf392252 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -84,6 +84,13 @@ static int do_get_part_info(struct blk_desc **dev_desc, 
const char *name,
/* First try partition names on the default device */
*dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
if (*dev_desc) {
+   if (!strncmp(name, "all", strlen("all"))) {
+   info->blksz = (*dev_desc)->blksz;
+   info->size = (*dev_desc)->lba;
+   info->start = 0;
+   return 0;
+   }
+
ret = part_get_info_by_name(*dev_desc, name, info);
if (ret >= 0)
return ret;
-- 
2.25.1



Re: [PATCH 2/3] arch: imx8m: imx-regs.h add the USB regs

2021-12-17 Thread Fabio Estevam
Hi Angus,

On Fri, Dec 17, 2021 at 12:21 PM Angus Ainslie  wrote:
>
> Add the USB regs for SDP mode
>
> Signed-off-by: Angus Ainslie 
> ---
>  arch/arm/include/asm/arch-imx8m/imx-regs.h | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/arch/arm/include/asm/arch-imx8m/imx-regs.h 
> b/arch/arm/include/asm/arch-imx8m/imx-regs.h
> index 8cb499d3a3..bd474f88a6 100644
> --- a/arch/arm/include/asm/arch-imx8m/imx-regs.h
> +++ b/arch/arm/include/asm/arch-imx8m/imx-regs.h
> @@ -103,6 +103,11 @@
> IMX_CSPI2_BASE, \
> IMX_CSPI3_BASE
>
> +#define USB1_BASE_ADDR 0x3810
> +#define USB2_BASE_ADDR 0x3820
> +#define USB1_PHY_BASE_ADDR 0x381F
> +#define USB2_PHY_BASE_ADDR 0x382F

Some time ago I sent a similar patch and the feedback from Marek was that these
base addresses should be retrieved from the devicetree instead.


Re: [PATCH 2/3] arch: imx8m: imx-regs.h add the USB regs

2021-12-17 Thread Angus Ainslie

Hi Fabio,

On 2021-12-17 08:28, Fabio Estevam wrote:

Hi Angus,

On Fri, Dec 17, 2021 at 12:21 PM Angus Ainslie  wrote:


Add the USB regs for SDP mode

Signed-off-by: Angus Ainslie 
---
 arch/arm/include/asm/arch-imx8m/imx-regs.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/include/asm/arch-imx8m/imx-regs.h 
b/arch/arm/include/asm/arch-imx8m/imx-regs.h

index 8cb499d3a3..bd474f88a6 100644
--- a/arch/arm/include/asm/arch-imx8m/imx-regs.h
+++ b/arch/arm/include/asm/arch-imx8m/imx-regs.h
@@ -103,6 +103,11 @@
IMX_CSPI2_BASE, \
IMX_CSPI3_BASE

+#define USB1_BASE_ADDR 0x3810
+#define USB2_BASE_ADDR 0x3820
+#define USB1_PHY_BASE_ADDR 0x381F
+#define USB2_PHY_BASE_ADDR 0x382F


Some time ago I sent a similar patch and the feedback from Marek was 
that these

base addresses should be retrieved from the devicetree instead.


I had problems getting the dwc3 to initialize properly when using the 
device model in the SPL. I'm currently just using this in the SPL and 
the device model in u-boot.


I'll take another shot at initializing the dwc3 in the SPL with the DM.

Thanks
Angus


Re: Are dt-bindings headers part of the device tree spec?

2021-12-17 Thread Simon Glass
Hi Sean,

On Wed, 15 Dec 2021 at 08:53, Sean Anderson  wrote:
>
>
> Hi all,
>
> I'm reviewing a clock driver [1], and the submitter has deviated from
> the defines used by Linux. For example, where Linux might have
>
> #define CLOCK_FOOBAR 5
>
> his driver might have
>
> #define CLK_FUBAR 6
>
> Which means that both the device tree source and the resulting device
> tree binary will be different.
>
> As I understand it, we try to be compatible with Linux on these things.
> However, it is unclear to me if include/dt-bindings is also part of
> this, or just the things in Documentation/devicetree/bindings. And if it
> is, do we need to have compatible sources, compatible binaries, or both?
> In general, I think we should try to have the same headers as well, but
> is it permitted to allow deviations with reasonable justification?

I think they should be the same, including the name and value. It gets
too confusing otherwise.

If there are conversions needed for U-Boot, perhaps they could be
handled by some #defines in the driver or another file in U-Boot.

Regards,
Simon

>
> --Sean
>
> [1] 
> https://lore.kernel.org/u-boot/de6e75a083647dfeec3058dd4dcc0419b08e155c.1637285375.git.weijie@mediatek.com/


Re: [PATCH v2] phy: zynqmp: Add serdes/psgtr driver

2021-12-17 Thread Simon Glass
Hi Michal,

On Wed, 15 Dec 2021 at 02:58, Michal Simek  wrote:
>
> Add PSGTR driver for Xilinx ZynqMP.
> The most of configurations are taken from Linux kernel psgtr driver.
>
> USB3.0 and SGMII configurations are tested on SOM. In SGMII case also
> IOU_SLCR reg is updated to get proper clock setup and signal detection
> configuration.
>
> Signed-off-by: Michal Simek 
> ---
>
> Changes in v2:
> - Add phy power on sequence
> - Use NUM_LANES in for loop
> - Use dev_remap_addr_name
> - Fix clk handling
>
>  MAINTAINERS  |   1 +
>  drivers/phy/Kconfig  |   7 +
>  drivers/phy/Makefile |   1 +
>  drivers/phy/phy-zynqmp.c | 760 +++
>  4 files changed, 769 insertions(+)
>  create mode 100644 drivers/phy/phy-zynqmp.c

Reviewed-by: Simon Glass 

Various nits below.

>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index de42663ac1ea..b36a4c44716b 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -611,6 +611,7 @@ F:  drivers/mmc/zynq_sdhci.c
>  F: drivers/mtd/nand/raw/zynq_nand.c
>  F: drivers/net/phy/xilinx_phy.c
>  F: drivers/net/zynq_gem.c
> +F: drivers/phy/phy-zynqmp.c
>  F: drivers/serial/serial_zynq.c
>  F: drivers/reset/reset-zynqmp.c
>  F: drivers/rtc/zynqmp_rtc.c
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index 4767d215f337..d79798429b18 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -281,6 +281,13 @@ config PHY_IMX8MQ_USB
> help
>   Support the USB3.0 PHY in NXP i.MX8MQ SoC
>
> +config PHY_XILINX_ZYNQMP
> +   tristate "Xilinx ZynqMP PHY driver"
> +   depends on PHY && ARCH_ZYNQMP
> +   help
> + Enable this to support ZynqMP High Speed Gigabit Transceiver
> + that is part of ZynqMP SoC.
> +
>  source "drivers/phy/rockchip/Kconfig"
>  source "drivers/phy/cadence/Kconfig"
>  source "drivers/phy/ti/Kconfig"
> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> index 13a8ade8919f..bf9b40932fe3 100644
> --- a/drivers/phy/Makefile
> +++ b/drivers/phy/Makefile
> @@ -38,5 +38,6 @@ obj-$(CONFIG_MT76X8_USB_PHY) += mt76x8-usb-phy.o
>  obj-$(CONFIG_PHY_DA8XX_USB) += phy-da8xx-usb.o
>  obj-$(CONFIG_PHY_MTK_TPHY) += phy-mtk-tphy.o
>  obj-$(CONFIG_PHY_IMX8MQ_USB) += phy-imx8mq-usb.o
> +obj-$(CONFIG_PHY_XILINX_ZYNQMP) += phy-zynqmp.o
>  obj-y += cadence/
>  obj-y += ti/
> diff --git a/drivers/phy/phy-zynqmp.c b/drivers/phy/phy-zynqmp.c
> new file mode 100644
> index ..1f43e6441af6
> --- /dev/null
> +++ b/drivers/phy/phy-zynqmp.c
> @@ -0,0 +1,760 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * phy-zynqmp.c - PHY driver for Xilinx ZynqMP GT.
> + *
> + * Copyright (C) 2018-2021 Xilinx Inc.
> + *
> + * Author: Anurag Kumar Vulisha 
> + * Author: Subbaraya Sundeep 
> + * Author: Laurent Pinchart 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

Please check ordering

https://www.denx.de/wiki/U-Boot/CodingStyle

[..]

> +/* Protocol Type parameters */
> +#define XPSGTR_TYPE_USB0   0  /* USB controller 0 */
> +#define XPSGTR_TYPE_USB1   1  /* USB controller 1 */
> +#define XPSGTR_TYPE_SATA_0 2  /* SATA controller lane 0 */
> +#define XPSGTR_TYPE_SATA_1 3  /* SATA controller lane 1 */
> +#define XPSGTR_TYPE_PCIE_0 4  /* PCIe controller lane 0 */
> +#define XPSGTR_TYPE_PCIE_1 5  /* PCIe controller lane 1 */
> +#define XPSGTR_TYPE_PCIE_2 6  /* PCIe controller lane 2 */
> +#define XPSGTR_TYPE_PCIE_3 7  /* PCIe controller lane 3 */
> +#define XPSGTR_TYPE_DP_0   8  /* Display Port controller lane 0 
> */
> +#define XPSGTR_TYPE_DP_1   9  /* Display Port controller lane 1 
> */
> +#define XPSGTR_TYPE_SGMII0 10 /* Ethernet SGMII controller 0 */
> +#define XPSGTR_TYPE_SGMII1 11 /* Ethernet SGMII controller 1 */
> +#define XPSGTR_TYPE_SGMII2 12 /* Ethernet SGMII controller 2 */
> +#define XPSGTR_TYPE_SGMII3 13 /* Ethernet SGMII controller 3 */

Could use an enum...

> +
> +/* Timeout values */
> +#define TIMEOUT_US 1000
> +
> +#define IOU_SLCR_GEM_CLK_CTRL  0x308
> +#define GEM_CTRL_GEM_SGMII_MODEBIT(2)
> +#define GEM_CTRL_GEM_REF_SRC_SEL   BIT(1)
> +
> +#define IOU_SLCR_GEM_CTRL  0x360
> +#define GEM_CTRL_GEM_SGMII_SD  BIT(0)
> +
> +/**
> + * struct xpsgtr_ssc - structure to hold SSC settings for a lane
> + * @refclk_rate: PLL reference clock frequency
> + * @pll_ref_clk: value to be written to register for corresponding ref clk 
> rate
> + * @steps: number of steps of SSC (Spread Spectrum Clock)
> + * @step_size: step size of each step
> + */
> +struct xpsgtr_ssc {
> +   u32 refclk_rate;
> +   u8  pll_ref_clk;
> +   u32 steps;
> + 

Re: [PATCH] sunxi: add board documentation

2021-12-17 Thread Simon Glass
Hi Andre,

On Sun, 12 Dec 2021 at 18:03, Andre Przywara  wrote:
>
> Add some long overdue instructions for building and installing U-Boot on
> Allwinner SoC based boards.
> This describes the building process, including TF-A and crust, plus
> installation to SD card, eMMC and SPI flash, both from Linux and U-Boot
> itself. Also describe FEL booting.
>
> Signed-off-by: Andre Przywara 
> ---
> Hi,
>
> please have a look whether this makes sense. Feel free to just try something,
> and point out ambiguities or missing bits. For missing topics, please
> send a follow-up patch ;-)
>
> Also this is quite long, shall this be split up in two (or more) files?
>
> This is what rst.ninjs.org made of it, if you prefer to read it formatted:
> https://paste.c-net.org/PleasantNeedy
>
> Cheers,
> Andre
>
>  doc/board/allwinner/index.rst |   9 +
>  doc/board/allwinner/sunxi.rst | 304 ++
>  2 files changed, 313 insertions(+)
>  create mode 100644 doc/board/allwinner/index.rst
>  create mode 100644 doc/board/allwinner/sunxi.rst

Reviewed-by: Simon Glass 

I agree that a follow-on patch to remove the duplicated files would be
helpful, but this patch is a big step forward on its own.

It would be interesting to convert sunxi to use binman.

Regards,
Simon


Re: [PATCH] doc: board: Add Calxeda Highbank/Midway documentation

2021-12-17 Thread Simon Glass
Hi Andre,

On Tue, 14 Dec 2021 at 10:47, Andre Przywara  wrote:
>
> The Calxeda servers are using U-Boot as the primary bootloader, which
> was shipped as part of a firmware upgrade package.
> Even though the machines are considered legacy at this point, the port
> still works, so deserves some documentation.
>
> Signed-off-by: Andre Przywara 
> ---
>  doc/board/highbank/highbank.rst | 78 +
>  doc/board/highbank/index.rst|  9 
>  doc/board/index.rst |  1 +
>  3 files changed, 88 insertions(+)
>  create mode 100644 doc/board/highbank/highbank.rst
>  create mode 100644 doc/board/highbank/index.rst

Reviewed-by: Simon Glass 

nits below

>
> diff --git a/doc/board/highbank/highbank.rst b/doc/board/highbank/highbank.rst
> new file mode 100644
> index 00..654ef8a026
> --- /dev/null
> +++ b/doc/board/highbank/highbank.rst
> @@ -0,0 +1,78 @@
> +Calxeda Highbank/Midway board support
> +=
> +
> +The Calxeda ECX-1000 ("Highbank") and ECX-2000 ("Midway") were ARM based

s/were/are/

Present tense is much easier to understand.

> +servers, providing high-density cluster systems. A single motherboard could
> +host between 12 and 48 nodes, each with their own quad-core ARMv7
> +processor, private DRAM and peripherals, connected through a high-bandwith
> +and low-latency "fabric" network. Multiple motherboards could be connected
> +together, to extend this fabric.
> +
> +For the purpose of U-Boot we just care about a single node, this can be
> +used as a single system, just using the fabric to connect to some Ethernet
> +network. Each node boots on its own, either from a local hard disk, or
> +via the network.
> +
> +The earlier ECX-1000 nodes ("Highbank") contain four ARM Cortex-A9 cores,
> +a Cortex-M3 system controller, three 10GBit/s MACs and five SATA
> +controllers. The DRAM is limited to 4GB.
> +
> +The later ECX-2000 nodes ("Midway") use four Cortex-A15 cores, alongside
> +two Cortex-A7 management cores, and support up to 32GB of DRAM, while
> +keeping the other peripherals.
> +
> +For the purpose of U-Boot those two SoCs are very similar, so we offer
> +one build target. The subtle differences are handled at runtime.
> +Calxeda as a company is long defunct, and the remaining systems are
> +considered legacy at this point.
> +
> +Bgilding U-Boot

Building

> +---
> +There is only one defconfig to cover both systems::
> +
> +$ make highbank_defconfig
> +$ make
> +
> +This will create ``u-boot.bin``, which could become part of the firmware 
> update
> +package, or could be chainloaded by the existing U-Boot, see below for more
> +details.
> +
> +Boot process
> +
> +Upon powering up a node (which would be controlled by some BMC style

s/would be/is/

We don't really care about tense, IMO. I suggest dropping 'would' and
'was', etc.

> +management controller on the motherboard), the system controller ("ECME")
> +would start and do some system initialisation (fabric registration,
> +DRAM init, clock setup). It would load the device tree binary, some secure
> +monitor code (``a9boot``/``a15boot``) and a U-Boot binary from SPI flash
> +into DRAM, then power up the actual application cores (ARM Cortex-A9/A15).
> +They would start executing ``a9boot``/``a15boot``, registering the PSCI SMC
> +handlers, then dropping into U-Boot, but in non-secure state (HYP mode on
> +the A15s).
> +
> +U-Boot would act as a mere loader, trying to find some ``boot.scr`` file on
> +the local hard disks, or reverting to PXE boot.
> +
> +Updating U-Boot
> +---
> +The U-Boot binary is loaded from SPI flash, which is controlled exclusively
> +by the ECME. This can be reached via IPMI using the LANplus transport 
> protocol.
> +Updating the SPI flash content requires vendor specific additions to the
> +IPMI protocol, support for which was never upstreamed to ipmitool or
> +FreeIPMI. Some older repositories for `ipmitool`_, the `pyipmi`_ library and
> +a Python `management script`_ to update the SPI flash can be found on Github.
> +
> +A simpler and safer way to get an up-to-date U-Boot running, is chainloading
> +it via the legacy U-Boot::
> +
> +$ mkimage -A arm -O u-boot -T standalone -C none -a 0x8000 -e 0x8000 \
> +  -n U-Boot -d u-boot.bin u-boot-highbank.img
> +
> +Then load this image file, either from hard disk, or via TFTP, from the
> +existing U-Boot, and execute it with bootm::
> +
> +=> tftpboot 0x8000 u-boot-highbank.img
> +=> bootm
> +
> +.. _`ipmitool`: https://github.com/Cynerva/ipmitool
> +.. _`pyipmi`: https://pypi.org/project/pyipmi/
> +.. _`management script`: https://github.com/Cynerva/cxmanage
> diff --git a/doc/board/highbank/index.rst b/doc/board/highbank/index.rst
> new file mode 100644
> index 00..b6975ca496
> --- /dev/null
> +++ b/doc/board/highbank/index.rst
> @@ -0,0 +1,9 @@
> +.. SPDX-License-Identifier: GPL-2.0+
> +
> +Highbank
> +
> +
> +.. toctre

Re: [PATCH 1/2] doc: Add documentation for the Arm VExpress64 board configs

2021-12-17 Thread Simon Glass
Hi Andre,

On Tue, 14 Dec 2021 at 10:55, Andre Przywara  wrote:
>
> From: Peter Hoyes 
>
> Create a new documentation section for Arm Ltd boards with a sub-page
> for the FVP VExpress64 system.
>
> Signed-off-by: Peter Hoyes 
> [Andre: remove Juno stub]
> Signed-off-by: Andre Przywara 
> ---
>  doc/board/armltd/fvp64.rst | 30 ++
>  doc/board/armltd/index.rst | 10 ++
>  doc/board/index.rst|  1 +
>  3 files changed, 41 insertions(+)
>  create mode 100644 doc/board/armltd/fvp64.rst
>  create mode 100644 doc/board/armltd/index.rst
>
> diff --git a/doc/board/armltd/fvp64.rst b/doc/board/armltd/fvp64.rst
> new file mode 100644
> index 00..9817b0aa3f
> --- /dev/null
> +++ b/doc/board/armltd/fvp64.rst
> @@ -0,0 +1,30 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +Fixed Virtual Platforms
> +===
> +
> +The Fixed Virtual Platforms (FVP) are complete software simulations of an Arm
> +system, including processor, memory and peripherals. They are set out in a
> +"programmer's view", which gives a comprehensive model on which to build and
> +test software.
> +
> +The supported FVPs are available free of charge and can be downloaded from 
> the
> +Arm developer site [1]_ (user registration might be required).
> +
> +Supported features:
> +
> + * GICv3
> + * Generic timer
> + * PL011 UART
> +
> +The default configuration assumes that U-Boot is bootstrapped using a 
> suitable
> +bootloader, such as Trusted Firmware-A [4]_. The u-boot binary can be passed

TF-A has become a bootloader?!

> +into the TF-A build: ``make PLAT= all fip BL33=u-boot.bin``

What is  in this case?

> +
> +The FVPs can be debugged using Arm Development Studio [2]_.
> +
> +References
> +--
> +
> +.. [1] 
> https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms
> +.. [2] 
> https://developer.arm.com/tools-and-software/embedded/arm-development-studio
> diff --git a/doc/board/armltd/index.rst b/doc/board/armltd/index.rst
> new file mode 100644
> index 00..caa6fd2bb0
> --- /dev/null
> +++ b/doc/board/armltd/index.rst
> @@ -0,0 +1,10 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +.. Copyright (C) 2021 Arm Ltd.
> +
> +ARM Ltd. boards and emulated systems
> +
> +
> +.. toctree::
> +   :maxdepth: 2
> +
> +   fvp64
> diff --git a/doc/board/index.rst b/doc/board/index.rst
> index 74ea33e081..78b486538b 100644
> --- a/doc/board/index.rst
> +++ b/doc/board/index.rst
> @@ -11,6 +11,7 @@ Board-specific doc
> AndesTech/index
> amlogic/index
> apple/index
> +   armltd/index
> atmel/index
> congatec/index
> coreboot/index
> --
> 2.25.1
>

Regards,
Simon


Re: [PATCH 2/2] doc: add Arm Juno board documentation

2021-12-17 Thread Simon Glass
On Tue, 14 Dec 2021 at 10:55, Andre Przywara  wrote:
>
> The Juno Arm development board is an open, vendor-neutral, Armv8-A
> development platform.
> Add documentation that briefly outlines the hardware, and describes
> building and installation of U-Boot.
>
> Signed-off-by: Andre Przywara 
> ---
>  doc/board/armltd/index.rst |   1 +
>  doc/board/armltd/juno.rst  | 117 +
>  2 files changed, 118 insertions(+)
>  create mode 100644 doc/board/armltd/juno.rst
>

Reviewed-by: Simon Glass 


Re: [PATCH v5 04/28] efi: Locate all block devices in the app

2021-12-17 Thread Simon Glass
Hi Heinrich,

On Thu, 9 Dec 2021 at 12:23, Heinrich Schuchardt  wrote:
>
> On 12/4/21 10:43, Heinrich Schuchardt wrote:
> > On 12/4/21 16:56, Simon Glass wrote:
> >> When starting the app, locate all block devices and make them available
> >> to U-Boot. This allows listing partitions and accessing files in
> >> filesystems.
> >>
> >> EFI also has the concept of 'disks', meaning boot media. For now, this
> >> is not obviously useful in U-Boot, but add code to at least locate these.
> >> This can be expanded later as needed.
> >>
> >> Series-changes; 2
> >> - Store device path in struct efi_media_plat
> >> - Don't export efi_bind_block()
> >> - Only bind devices for media devices, not for partitions
> >> - Show devices that are processed
> >> - Update documentation
> >>
> >> Signed-off-by: Simon Glass 
> >> ---
> >>
> >> (no changes since v1)
> >>
> >>   doc/develop/uefi/u-boot_on_efi.rst |   4 +-
> >>   include/efi.h  |   6 +-
> >>   include/efi_api.h  |  15 ++
> >>   lib/efi/efi_app.c  | 223 +
> >>   4 files changed, 243 insertions(+), 5 deletions(-)
[..]

> >> +static int setup_disks(void)
> >> +{
> >> +/* This is not fully implemented yet */
>
> see hint below.
>
> >> +return 0;
> >> +
> >> +efi_guid_t efi_disk_guid = EFI_DISK_IO_PROTOCOL_GUID;
>
> U-Boot does not implement the EFI_DISK_IO_PROTOCOL. So you will not be
> able to run U-Boot as an EFI app loaded by U-Boot which might be nice
> for testing.
>
> The more basic protocol is the EFI_BLOCK_IO_PROTOCOL. The difference is
> that the EFI_BLOCK_IO_PROTOCOL requires using a properly aligned buffer.
>
> >> +struct efi_boot_services *boot = efi_get_boot();
> >> +struct efi_disk *disk;
> >> +int ret;
> >> +
> >> +if (!boot)
> >> +return log_msg_ret("sys", -ENOSYS);
> >> +ret = boot->locate_protocol(&efi_disk_guid, NULL, (void **)&disk);
>
> If you want to find all handles implementing a protocol, you can use
> EFI_BOOT_SERVICES.LocateHandleBuffer() with SearchType ByProtocol.
>
> I guess we should add this patch to U-Boot once it is completed.

OK, let's drop this code then.

[..]
Regards,
Simon


Re: [PATCH v5 05/28] efi: serial: Support arrow keys

2021-12-17 Thread Simon Glass
Hi Heinrich,

On Thu, 9 Dec 2021 at 12:44, Heinrich Schuchardt  wrote:
>
> On 12/4/21 07:56, Simon Glass wrote:
> > At present only the backspace key is supported in U-Boot, when running as
> > an EFI app. Add support for arrows, home and end as well, to make the CLI
> > more friendly.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
> >   drivers/serial/serial_efi.c | 11 +--
> >   1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c
> > index 33ddbd6080c..0067576389d 100644
> > --- a/drivers/serial/serial_efi.c
> > +++ b/drivers/serial/serial_efi.c
> > @@ -24,6 +24,9 @@ struct serial_efi_priv {
> >   bool have_key;
> >   };
> >
> > +/* Convert a lower-case character to its ctrl-char equivalent */
> > +#define CTL_CH(c)((c) - 'a' + 1)
> > +
> >   int serial_efi_setbrg(struct udevice *dev, int baudrate)
> >   {
> >   return 0;
> > @@ -49,6 +52,7 @@ static int serial_efi_get_key(struct serial_efi_priv 
> > *priv)
> >   static int serial_efi_getc(struct udevice *dev)
> >   {
> >   struct serial_efi_priv *priv = dev_get_priv(dev);
> > + char conv_scan[10] = {0, 'p', 'n', 'f', 'b', 'a', 'e', 0, 8};
> >   int ret, ch;
> >
> >   ret = serial_efi_get_key(priv);
> > @@ -63,8 +67,11 @@ static int serial_efi_getc(struct udevice *dev)
> >* key scan code of 8. Handle this so that backspace works correctly
> >* in the U-Boot command line.
> >*/
> > - if (!ch && priv->key.scan_code == 8)
> > - ch = 8;
> > + if (!ch && priv->key.scan_code < sizeof(conv_scan)) {
> > + ch = conv_scan[priv->key.scan_code];
> > + if (ch >= 'a')
> > + ch -= 'a' - 1;
>
> This is not what a serial console would use in Linux. Just try U-Boot's
> conitrace command. If you use the following, we get compatibility with
> the rest of U-Boot:
>
> 1b 5b 32 7e - insert
> 1b 5b 33 7e - delete
> 1b 5b 35 7e - page up
> 1b 5b 36 7e - page down
> 1b 5b 41 - up
> 1b 5b 42 - down
> 1b 5b 43 - right
> 1b 5b 44 - left
> 1b 5b 46 - end
> 1b 5b 48 - home

That's more complicated since it requires the serial driver to convert
one character into multiple. We can always add it later if needed. But
this does command-line history, etc. working in the app.

Regards,
Simon


Re: [PATCH v5 18/28] efi: Show when allocated pages are used

2021-12-17 Thread Simon Glass
Hi Heinrich,

On Thu, 9 Dec 2021 at 12:55, Heinrich Schuchardt  wrote:
>
> On 12/4/21 07:56, Simon Glass wrote:
> > Add a message here so that both paths of memory allocation are reported.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v2)
> >
> > Changes in v2:
> > - Use log_info() instead of printf()
> >
> >   lib/efi/efi_app.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
> > index e454f1a1564..36e3f1de427 100644
> > --- a/lib/efi/efi_app.c
> > +++ b/lib/efi/efi_app.c
> > @@ -121,13 +121,14 @@ static efi_status_t setup_memory(struct efi_priv 
> > *priv)
> >   ret = boot->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
> >  priv->image_data_type, pages, &addr);
> >   if (ret) {
>
> If AllocatePages() fails the system is out of memory. Just return to the
> calling firmware with EFI_OUT_OF_RESOURCES.

I have left this as it is as sometimes it is possible to allocate from
the pool even if allocate_pages() fails. I hit this on an Intel
platform some years ago.

In any case your comment does not relate to this patch.

Regards,
Simon


Re: [PATCH v5 15/28] efi: Move exit_boot_services into a function

2021-12-17 Thread Simon Glass
Hi Heinrich,

On Sat, 4 Dec 2021 at 12:13, Heinrich Schuchardt  wrote:
>
> On 12/4/21 16:56, Simon Glass wrote:
> > At present this code is inline in the app and stub. But they do the same
> > thing. The difference is that the stub does it immediately and the app
> > doesn't want to do it until the end (when it boots a kernel) or not at
> > all, if returning to UEFI.
> >
> > Move it into a function so it can be called as needed.
> >
> > Also store the memory map so that it can be accessed within the app if
> > needed.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v2)
> >
> > Changes in v2:
> > - Add a sentence about what the patch does
> >
> >   include/efi.h  | 32 ++
> >   lib/efi/efi.c  | 68 ++
> >   lib/efi/efi_app.c  |  3 ++
> >   lib/efi/efi_stub.c | 66 
> >   4 files changed, 114 insertions(+), 55 deletions(-)
> >
[..]

> > +/**
> > + * efi_store_memory_map() - Collect the memory-map info from EFI
> > + *
> > + * Collect the memory info and store it for later use, e.g. in calling
> > + * exit_boot_services()
> > + *
> > + * @priv:Pointer to private EFI structure
> > + * @return 0 if OK, non-zero on error
>
> %s/@return/Return:/

I will have to try to remember that. We are on our 3rd comment style now.

>
> Cf.
> https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
>

[..]

>
> Missing function description
>
> > +int efi_call_exit_boot_services(void)

Putting your comment above the code you refer to defeats 'patman
status -C', so could you please put it below?

The comment is in the header file as this is an exported function.

Regards,
Simon


Re: [PATCH v5 21/28] efi: Support the efi command in the app

2021-12-17 Thread Simon Glass
Hi Heinrich,

On Thu, 9 Dec 2021 at 13:27, Heinrich Schuchardt  wrote:
>
> On 12/4/21 07:56, Simon Glass wrote:
> > At present the 'efi' command only works in the EFI payload. Update it to
> > work in the app too, so the memory map can be examined.
>
> cmd/efi.c seems to be duplicating function do_efi_show_memmap(). In a
> future patch we should try to move to using common code for commands efi
> and efidebug.

Yes and that depends on EFI_LOADER. Perhaps one day we can have a
common helper for this, e.g. in lib/efi ?

Regards,
Simon


Re: [PATCH v5 22/28] x86: efi: Show the system-table revision

2021-12-17 Thread Simon Glass
Hi Heinrich,

On Thu, 9 Dec 2021 at 13:34, Heinrich Schuchardt  wrote:
>
> On 12/4/21 07:56, Simon Glass wrote:
> > Show the revision of this table as it can be important.
> >
> > Alo update the 'efi table' entry to show the actual address of the EFI
>
> %s/Alo/Also/
>
> > table rather than our table that points to it. This saves a step and the
> > intermediate table has nothing else in it.
>
> Should this information been shown by the 'efi' command instead of 'bdinfo'?

Perhaps we should add an 'efi info' command for this and various other
things. We could show a lot more info.

But as you know, I like to have EFI more integrated into U-Boot and
the bdinfo command is used for all sorts of subsystems. It is a
natural place for people to look for the basics.

Regards,
Simon


Re: [PATCH 1/2] fdtgrep: Correct alignment of struct section

2021-12-17 Thread Simon Glass
When outputting a devicetree we should not align the struct section to a
16-byte boundary. The normal position is fine, which is 8-byte aligned.

This avoids leaving adding 8 extra zero bytes in the output tree in the
case where the reserved section is empty (i.e has 16 zero bytes).

Signed-off-by: Simon Glass 
---

 tools/fdtgrep.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Applied to u-boot-dm/next, thanks!


Re: [PATCH 2/2] fdtgrep: Handle an empty output tree

2021-12-17 Thread Simon Glass
In strange cases it is possible for fdtgrep to find nothing to output.
Typically this means that the resulting SPL device tree is not going to
allow anything to boot, but at present the tree is actually invalid,
since it only has an END tag in the struct region.

The FDT spec requires at least a root node. So add a special case to
include at least this, if the FDT_REG_SUPERNODES flag is set.

This ensures that grepping an empty tree still produces a valid tree.

Also add comments to the enum since it is not completely obvious from
the names now.

The typical symptom of this problem is a message from binman:

   pylibfdt error -11: FDT_ERR_BADSTRUCTURE

Signed-off-by: Simon Glass 
---

 boot/fdt_region.c| 43 +--
 include/fdt_region.h |  1 +
 2 files changed, 38 insertions(+), 6 deletions(-)

Applied to u-boot-dm/next, thanks!


Re: [PATCH 2/3] arch: imx8m: imx-regs.h add the USB regs

2021-12-17 Thread Adam Ford
On Fri, Dec 17, 2021 at 10:35 AM Angus Ainslie  wrote:
>
> Hi Fabio,
>
> On 2021-12-17 08:28, Fabio Estevam wrote:
> > Hi Angus,
> >
> > On Fri, Dec 17, 2021 at 12:21 PM Angus Ainslie  wrote:
> >>
> >> Add the USB regs for SDP mode
> >>
> >> Signed-off-by: Angus Ainslie 
> >> ---
> >>  arch/arm/include/asm/arch-imx8m/imx-regs.h | 5 +
> >>  1 file changed, 5 insertions(+)
> >>
> >> diff --git a/arch/arm/include/asm/arch-imx8m/imx-regs.h
> >> b/arch/arm/include/asm/arch-imx8m/imx-regs.h
> >> index 8cb499d3a3..bd474f88a6 100644
> >> --- a/arch/arm/include/asm/arch-imx8m/imx-regs.h
> >> +++ b/arch/arm/include/asm/arch-imx8m/imx-regs.h
> >> @@ -103,6 +103,11 @@
> >> IMX_CSPI2_BASE, \
> >> IMX_CSPI3_BASE
> >>
> >> +#define USB1_BASE_ADDR 0x3810
> >> +#define USB2_BASE_ADDR 0x3820
> >> +#define USB1_PHY_BASE_ADDR 0x381F
> >> +#define USB2_PHY_BASE_ADDR 0x382F
> >
> > Some time ago I sent a similar patch and the feedback from Marek was
> > that these
> > base addresses should be retrieved from the devicetree instead.

I didn't think Driver model was a requirement for SPL.

>
> I had problems getting the dwc3 to initialize properly when using the
> device model in the SPL. I'm currently just using this in the SPL and
> the device model in u-boot.
>
> I'll take another shot at initializing the dwc3 in the SPL with the DM.

Could we compromise by putting the #define statements in an ifdef to
only enable them when SPL is being built?


>
> Thanks
> Angus


Re: [PATCH v5 05/28] efi: serial: Support arrow keys

2021-12-17 Thread Heinrich Schuchardt

On 12/17/21 17:37, Simon Glass wrote:

Hi Heinrich,

On Thu, 9 Dec 2021 at 12:44, Heinrich Schuchardt  wrote:


On 12/4/21 07:56, Simon Glass wrote:

At present only the backspace key is supported in U-Boot, when running as
an EFI app. Add support for arrows, home and end as well, to make the CLI
more friendly.

Signed-off-by: Simon Glass 
---

(no changes since v1)

   drivers/serial/serial_efi.c | 11 +--
   1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c
index 33ddbd6080c..0067576389d 100644
--- a/drivers/serial/serial_efi.c
+++ b/drivers/serial/serial_efi.c
@@ -24,6 +24,9 @@ struct serial_efi_priv {
   bool have_key;
   };

+/* Convert a lower-case character to its ctrl-char equivalent */
+#define CTL_CH(c)((c) - 'a' + 1)
+
   int serial_efi_setbrg(struct udevice *dev, int baudrate)
   {
   return 0;
@@ -49,6 +52,7 @@ static int serial_efi_get_key(struct serial_efi_priv *priv)
   static int serial_efi_getc(struct udevice *dev)
   {
   struct serial_efi_priv *priv = dev_get_priv(dev);
+ char conv_scan[10] = {0, 'p', 'n', 'f', 'b', 'a', 'e', 0, 8};
   int ret, ch;

   ret = serial_efi_get_key(priv);
@@ -63,8 +67,11 @@ static int serial_efi_getc(struct udevice *dev)
* key scan code of 8. Handle this so that backspace works correctly
* in the U-Boot command line.
*/
- if (!ch && priv->key.scan_code == 8)
- ch = 8;
+ if (!ch && priv->key.scan_code < sizeof(conv_scan)) {
+ ch = conv_scan[priv->key.scan_code];
+ if (ch >= 'a')
+ ch -= 'a' - 1;


This is not what a serial console would use in Linux. Just try U-Boot's
conitrace command. If you use the following, we get compatibility with
the rest of U-Boot:

1b 5b 32 7e - insert
1b 5b 33 7e - delete
1b 5b 35 7e - page up
1b 5b 36 7e - page down
1b 5b 41 - up
1b 5b 42 - down
1b 5b 43 - right
1b 5b 44 - left
1b 5b 46 - end
1b 5b 48 - home


That's more complicated since it requires the serial driver to convert
one character into multiple. We can always add it later if needed. But
this does command-line history, etc. working in the app.


Yes you will need a ring buffer as in the USB keyboard driver.

lib/efi_loader/efi_console.c only understands the multi-byte sequences.
I do not know if there are other places which have the same limitation.

Best regards

Heinrich



Regards,
Simon




Re: [PATCH 1/3] efi: Create ECPT table

2021-12-17 Thread Heinrich Schuchardt

On 12/17/21 13:55, Jose Marinho wrote:

The ECPT table will be included in the UEFI specification 2.9+.
The ECPT table was introduced in UEFI following the code-first path. The
acceptance ticket can be viewed at:
https://bugzilla.tianocore.org/show_bug.cgi?id=3591

The Conformance Profiles table is a UEFI configuration table that contains
GUID of the UEFI profiles that the UEFI implementation conforms with.

The ECPT table is created when CONFIG_EFI_ECPT=y.
The config is set by default.

Signed-off-by: Jose Marinho 
---
  cmd/efidebug.c   |  4 ++
  include/efi_api.h| 10 +
  include/efi_loader.h |  7 
  lib/efi_loader/Kconfig   |  6 +++
  lib/efi_loader/Makefile  |  1 +
  lib/efi_loader/efi_conformance.c | 66 
  lib/efi_loader/efi_setup.c   |  6 +++
  7 files changed, 100 insertions(+)
  create mode 100644 lib/efi_loader/efi_conformance.c

diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index a977ca9c72..a53a5029fa 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -619,6 +619,10 @@ static const struct {
"TCG2 Final Events Table",
EFI_TCG2_FINAL_EVENTS_TABLE_GUID,
},
+   {
+   "EFI Conformance Profiles Table",
+   EFI_CONFORMANCE_PROFILES_TABLE_GUID,


Just as side note. Consider sending a patch for GRUB to amend:

grub-core/commands/efi/lsefisystab.c
include/grub/efi/api.h


+   },
  };

  /**
diff --git a/include/efi_api.h b/include/efi_api.h
index 80109f012b..6fd4f04de3 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -226,6 +226,16 @@ enum efi_reset_type {
EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \
 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)

+#define EFI_CONFORMANCE_PROFILES_TABLE_GUID \
+   EFI_GUID(0x36122546, 0xf7ef, 0x4c8f, 0xbd, 0x9b, \
+0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b)
+
+struct efi_conformance_profiles_table {
+   u16 version;
+   u16 number_of_profiles;
+   efi_guid_t  conformance_profiles[];
+} __packed;
+
  struct efi_capsule_header {
efi_guid_t capsule_guid;
u32 header_size;
diff --git a/include/efi_loader.h b/include/efi_loader.h
index d52e399841..d20ff396d0 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -976,6 +976,13 @@ efi_status_t efi_capsule_authenticate(const void *capsule,
   */
  efi_status_t efi_esrt_register(void);

+/**
+ * efi_ecpt_register() - Install the ECPT system table.
+ *
+ * Return: status code
+ */
+efi_status_t efi_ecpt_register(void);
+
  /**
   * efi_esrt_populate() - Populates the ESRT entries from the FMP instances
   * present in the system.
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 700dc838dd..b2398976f4 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -367,4 +367,10 @@ config EFI_ESRT
help
  Enabling this option creates the ESRT UEFI system table.

+config EFI_ECPT
+   bool "Enable the UEFI ECPT generation"
+   default y
+   help
+ Enabling this option created the ECPT UEFI table.
+
  endif
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index fd344cea29..9f5a0cebd1 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -64,6 +64,7 @@ obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
  obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o
  obj-$(CONFIG_EFI_LOAD_FILE2_INITRD) += efi_load_initrd.o
  obj-$(CONFIG_EFI_SIGNATURE_SUPPORT) += efi_signature.o
+obj-$(CONFIG_EFI_ECPT) += efi_conformance.o

  EFI_VAR_SEED_FILE := $(subst $\",,$(CONFIG_EFI_VAR_SEED_FILE))
  $(obj)/efi_var_seed.o: $(srctree)/$(EFI_VAR_SEED_FILE)
diff --git a/lib/efi_loader/efi_conformance.c b/lib/efi_loader/efi_conformance.c
new file mode 100644
index 00..86c26d6b79
--- /dev/null
+++ b/lib/efi_loader/efi_conformance.c
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ *  EFI conformance profile table
+ *
+ *  Copyright (C) 2022 Arm Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID;
+
+#define EFI_CONFORMANCE_PROFILES_TABLE_VERSION 1
+
+/**
+ * efi_ecpt_register() - Install the ECPT system table.
+ *
+ * Return: status code
+ */
+efi_status_t efi_ecpt_register(void)
+{
+   int num_entries = 0;


Shouldn't we add EFI_CONFORMANCE_PROFILES_EBBR_2_0_GUID as entry?
What would be the point of adding an empty ECPT table?


+   struct efi_conformance_profiles_table *ecpt;
+   efi_status_t ret;
+   size_t ecpt_size = 0;
+
+   EFI_PRINT("ECPT table creation start\n");


This function is not called via the EFI API. Please, use log_debug().

Best regards

Heinrich


+
+   ecpt_size = num_entries * sizeof(efi_guid_t)
+   + sizeof(struct efi_conformance_profiles_table);
+   ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, ecpt_size,
+   (void **)&ecpt);

Re: [PATCH 2/3] efi: ECPT add EBBRv2.0 conformance profile

2021-12-17 Thread Heinrich Schuchardt

On 12/17/21 13:55, Jose Marinho wrote:

Display the EBBRv2.0 conformance in the ECPT table.

The EBBRv2.0 conformance profile is set in the ECPT if
CONFIG_EFI_EBBR_2_0_CONFORMANCE=y.
The config defaults to 'n'.


Signed-off-by: Jose Marinho 
---
  include/efi_api.h| 4 
  lib/efi_loader/Kconfig   | 6 ++
  lib/efi_loader/efi_conformance.c | 9 +
  3 files changed, 19 insertions(+)

diff --git a/include/efi_api.h b/include/efi_api.h
index 6fd4f04de3..49919caa35 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -230,6 +230,10 @@ enum efi_reset_type {
EFI_GUID(0x36122546, 0xf7ef, 0x4c8f, 0xbd, 0x9b, \
 0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b)

+#define EFI_CONFORMANCE_PROFILE_EBBR_2_0_GUID \
+   EFI_GUID(0xcce33c35, 0x74ac, 0x4087, 0xbc, 0xe7, \
+0x8b, 0x29, 0xb0, 0x2e, 0xeb, 0x27)
+
  struct efi_conformance_profiles_table {
u16 version;
u16 number_of_profiles;
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index b2398976f4..ab7476f68b 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -373,4 +373,10 @@ config EFI_ECPT
help
  Enabling this option created the ECPT UEFI table.

+config EFI_EBBR_2_0_CONFORMANCE
+   bool "Add the EBBRv2.0 conformance entry to the ECPT table"
+   depends on EFI_ECPT


With this dependency the symbol EFI_EBBR_2_0_CONFORMANCE is superfluous.

Can we add EFI_EBBR_2_0_CONFORMANCE unconditionally or are there
relevant configuration flags in U-Boot that must be enabled to claim
EBBR 2.0 compliance? E.g.

* CONFIG_CMD_BOOTEFI_BOOTMGR
* CONFIG_EFI_GET_TIME
* CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT

Best regards

Heinrich


+   default n
+   help
+ Enabling this option adds the EBBRv2.0 conformance entry to the ECPT 
UEFI table.
  endif
diff --git a/lib/efi_loader/efi_conformance.c b/lib/efi_loader/efi_conformance.c
index 86c26d6b79..b490ff3326 100644
--- a/lib/efi_loader/efi_conformance.c
+++ b/lib/efi_loader/efi_conformance.c
@@ -12,6 +12,7 @@
  #include 

  const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID;
+const efi_guid_t efi_ebbr_2_0_guid = EFI_CONFORMANCE_PROFILE_EBBR_2_0_GUID;

  #define EFI_CONFORMANCE_PROFILES_TABLE_VERSION 1

@@ -29,6 +30,9 @@ efi_status_t efi_ecpt_register(void)

EFI_PRINT("ECPT table creation start\n");

+   if (IS_ENABLED(CONFIG_EFI_EBBR_2_0_CONFORMANCE))
+   num_entries++;
+
ecpt_size = num_entries * sizeof(efi_guid_t)
+ sizeof(struct efi_conformance_profiles_table);
ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, ecpt_size,
@@ -44,6 +48,11 @@ efi_status_t efi_ecpt_register(void)
ecpt->version = EFI_CONFORMANCE_PROFILES_TABLE_VERSION;
ecpt->number_of_profiles = num_entries;

+   if (IS_ENABLED(CONFIG_EFI_EBBR_2_0_CONFORMANCE)) {
+   num_entries--;
+   guidcpy(&ecpt->conformance_profiles[num_entries], 
&efi_ecpt_guid);
+   }
+
if (num_entries)
EFI_PRINT("ECPT check conformance profiles, not all entries 
populated in table\n");





[PATCH] arm: mvebu: Remove commented example code

2021-12-17 Thread Pali Rohár
Include file debug_uart.h already contains documentation how to use it.

Signed-off-by: Pali Rohár 
---
 arch/arm/mach-mvebu/spl.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index 6a9e1d860cf7..29a8adc9d79c 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -5,7 +5,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -303,18 +302,6 @@ void board_init_f(ulong dummy)
 */
board_early_init_f();
 
-   /* Example code showing how to enable the debug UART on MVEBU */
-#ifdef EARLY_UART
-   /*
-* Debug UART can be used from here if required:
-*
-* debug_uart_init();
-* printch('a');
-* printhex8(0x1234);
-* printascii("string");
-*/
-#endif
-
/*
 * Use special translation offset for SPL. This needs to be
 * configured *before* spl_init() is called as this function
-- 
2.20.1



[PATCH v10] driver: spi: add bcm iproc qspi support

2021-12-17 Thread Roman Bacik
IPROC qspi driver supports both BSPI and MSPI modes.

Signed-off-by: Rayagonda Kokatanur 
Signed-off-by: Bharat Gooty 
Acked-by: Rayagonda Kokatanur 
Signed-off-by: Roman Bacik 
---

Changes in v10:
- remove binding document
- use defined values for delays and timeouts
- replace timer-based logic with readl_poll_timeout
- format selected commands to single line
- remove unnecessary entries from struct bcmspi_priv
- simplify and move bspi strap override to bspi_set_flex_mode

Changes in v9:
- merge bspi_set_4byte_mode to bspi_set_flex_mode
- simplify bspi_set_flex_mode using data from spi_mem_op
- rename mode_4byte to bspi_4byte
- use BIT(x) istead of 1cmd.opcode for BSPI_CMD_AND_MODE_BYTE_REG
- move iproc_qspi.c to spi

Changes in v4:
- move iproc_qspi.c from spi to mtd/spi
- remove iproc_qspi.h
- rename IPROC_QSPI to SPI_FLASH_IPROC

Changes in v3:
- fix warning by including linux/delay.h
- change ofdata_to_platdata to of_to_plat
- change priv_auto_alloc_size to priv_auto

Changes in v2:
- remove include spi-nor.h
- define and use named BITs for writing register values
- remove bspi_set_4byte_mode() method

 drivers/spi/Kconfig  |   6 +
 drivers/spi/Makefile |   1 +
 drivers/spi/iproc_qspi.c | 578 +++
 3 files changed, 585 insertions(+)
 create mode 100644 drivers/spi/iproc_qspi.c

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index d07e9a28af82..faebc212753e 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -178,6 +178,12 @@ config ICH_SPI
  access the SPI NOR flash on platforms embedding this Intel
  ICH IP core.
 
+config IPROC_QSPI
+   bool "Broadcom iProc QSPI Flash Controller driver"
+   help
+ Enable Broadcom iProc QSPI Flash Controller driver.
+ This driver can be used to access the SPI NOR flash.
+
 config KIRKWOOD_SPI
bool "Marvell Kirkwood SPI Driver"
help
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index d2f24bccefd3..869763187062 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
 obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
 obj-$(CONFIG_SYNQUACER_SPI) += spi-synquacer.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
+obj-$(CONFIG_IPROC_QSPI) += iproc_qspi.o
 obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_MESON_SPIFC) += meson_spifc.o
 obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
diff --git a/drivers/spi/iproc_qspi.c b/drivers/spi/iproc_qspi.c
new file mode 100644
index ..2eb09058c286
--- /dev/null
+++ b/drivers/spi/iproc_qspi.c
@@ -0,0 +1,578 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2020-2021 Broadcom
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Delay required to change the mode of operation */
+#define BUSY_DELAY_US  1
+#define BUSY_TIMEOUT_US20
+#define DWORD_ALIGNED(a)   (!(((ulong)(a)) & 3))
+
+/* Chip attributes */
+#define QSPI_AXI_CLK   17500
+#define SPBR_MIN   8U
+#define SPBR_MAX   255U
+#define NUM_CDRAM  16U
+
+#define CDRAM_PCS0 2
+#define CDRAM_CONT BIT(7)
+#define CDRAM_BITS_EN  BIT(6)
+#define CDRAM_QUAD_MODEBIT(8)
+#define CDRAM_RBIT_INPUT   BIT(10)
+#define MSPI_SPE   BIT(6)
+#define MSPI_CONT_AFTER_CMDBIT(7)
+
+/* Register fields */
+#define MSPI_SPCR0_MSB_BITS_8  0x0020
+#define BSPI_RAF_CONTROL_START_MASK0x0001
+#define BSPI_RAF_STATUS_SESSION_BUSY_MASK  0x0001
+#define BSPI_RAF_STATUS_FIFO_EMPTY_MASK0x0002
+#define BSPI_STRAP_OVERRIDE_DATA_QUAD_SHIFT3
+#define BSPI_STRAP_OVERRIDE_4BYTE_SHIFT2
+#define BSPI_STRAP_OVERRIDE_DATA_DUAL_SHIFT1
+#define BSPI_STRAP_OVERRIDE_SHIFT  0
+#define BSPI_BPC_DATA_SHIFT0
+#define BSPI_BPC_MODE_SHIFT8
+#define BSPI_BPC_ADDR_SHIFT16
+#define BSPI_BPC_CMD_SHIFT 24
+#define BSPI_BPP_ADDR_SHIFT16
+
+/* MSPI registers */
+#define MSPI_SPCR0_LSB_REG 0x000
+#define MSPI_SPCR0_MSB_REG 0x004
+#define MSPI_SPCR1_LSB_REG 0x008
+#define MSPI_SPCR1_MSB_REG 0x00c
+#define MSPI_NEWQP_REG 0x010
+#define MSPI_ENDQP_REG 0x014
+#define MSPI_SPCR2_REG 0x018
+#define MSPI_STATUS_REG0x020
+#define MSPI_CPTQP_RE

[PATCH] arm: mvebu: Use printf for printing fatal errors

2021-12-17 Thread Pali Rohár
There is no point to hide/disable fatal errors via debug() macro.
Print fatal errors loudly.

Signed-off-by: Pali Rohár 
---
 arch/arm/mach-mvebu/spl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index 29a8adc9d79c..609495097585 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -313,7 +313,7 @@ void board_init_f(ulong dummy)
 
ret = spl_init();
if (ret) {
-   debug("spl_init() failed: %d\n", ret);
+   printf("spl_init() failed: %d\n", ret);
hang();
}
 
@@ -329,7 +329,7 @@ void board_init_f(ulong dummy)
/* Setup DDR */
ret = ddr3_init();
if (ret) {
-   debug("ddr3_init() failed: %d\n", ret);
+   printf("ddr3_init() failed: %d\n", ret);
hang();
}
 #endif
-- 
2.20.1



Re: [PATCH u-boot-next 00/12] Common U-Boot macros for PCI Configuration Mechanism #1

2021-12-17 Thread Pali Rohár
Hello! Could you look and review at this patch series?

On Friday 26 November 2021 11:42:40 Pali Rohár wrote:
> This patch series add new U-Boot macros for composing Config Address for
> PCI Configuration Mechanism #1 as defined in PCI Local Bus Specification,
> including extended variant (which do not have any formal specification)
> and then use these new macros (PCI_CONF1_ADDRESS and PCI_CONF1_EXT_ADDRESS)
> in all PCI drivers that use Config Address according to PCI Configuration
> Mechanism #1.
> 
> PCI Configuration Mechanism #1 was originally specified for x86 platforms
> and it is still supported on x86 together with PCIe ECAM. Nowadays lot of
> non-ECAM-compliant ARM PCIe controllers use only extended variant of this
> address construction and some of them requires cleared Enable bit. Extended
> variant is also supported by x86 AMD Barcelona (and new) CPUs, but U-Boot
> code does not provide this support yet.
> 
> Note that it exists also PCI Configuration Mechanism #2, but this one was
> removed from PCI Local Bus Specification revision 3.0 and seems that it is
> not used by any PCI driver in U-Boot. So I have not added macros for this
> mechanism in this patch series.
> 
> Because lot of hardware still use this (rather old) mechanism, relevant
> U-Boot PCI and PCIe drivers have own ad-hoc code address construction,
> which is repeated and written in different ways.
> 
> This patch series is code cleanup of these PCIe drivers to use common
> U-Boot macros for PCI Configuration Mechanism #1.
> 
> The last change is fixing construction of Config Address in PCI driver
> sh7751. Construction with this change matches Linux kernel code and also
> U-Boot code prior commit mentioned in commit message.
> 
> I have tested this patch series only for PCI mvebu driver on A385 board and
> it is working fine. So Please properly review all other changes. Ideally
> test them.
> 
> I have run CI tests with these changes on github and everything passed:
> https://github.com/u-boot/u-boot/pull/101
> 
> Please let me know what do you think about this change.
> 
> Pali Rohár (12):
>   pci: Add standard PCI Config Address macros
>   pci: gt64120: Use PCI_CONF1_ADDRESS() macro
>   pci: mpc85xx: Use PCI_CONF1_EXT_ADDRESS() macro
>   pci: msc01: Use PCI_CONF1_ADDRESS() macro
>   pci: mvebu: Use PCI_CONF1_EXT_ADDRESS() macro
>   pci: tegra: Use PCI_CONF1_EXT_ADDRESS() macro
>   pci: fsl: Use PCI_CONF1_EXT_ADDRESS() macro
>   pci: mediatek: Use PCI_CONF1_EXT_ADDRESS() macro
>   pci: sh7780: Use PCI_CONF1_ADDRESS() macro
>   x86: pci: Use PCI_CONF1_ADDRESS() macro
>   m68k: mcf5445x: pci: Use PCI_CONF1_ADDRESS() macro
>   pci: sh7751: Fix access to config space via PCI_CONF1_ADDRESS() macro
> 
>  arch/m68k/cpu/mcf5445x/pci.c |  7 +++---
>  arch/x86/cpu/pci.c   |  4 ++--
>  drivers/pci/pci_gt64120.c|  7 ++
>  drivers/pci/pci_mpc85xx.c|  4 ++--
>  drivers/pci/pci_msc01.c  |  7 ++
>  drivers/pci/pci_mvebu.c  | 17 --
>  drivers/pci/pci_sh7751.c | 29 ++-
>  drivers/pci/pci_sh7780.c |  8 +++
>  drivers/pci/pci_tegra.c  | 11 +++--
>  drivers/pci/pcie_fsl.c   | 10 
>  drivers/pci/pcie_mediatek.c  | 17 +++---
>  include/gt64120.h| 12 --
>  include/msc01.h  |  9 
>  include/pci.h| 45 
>  14 files changed, 83 insertions(+), 104 deletions(-)
> 
> -- 
> 2.20.1
> 


Re: [PATCH v5 25/29] image: Remove #ifdefs from select_ramdisk()

2021-12-17 Thread Neil Armstrong
Hi,

On 09/10/2021 03:41, Tom Rini wrote:
> On Sat, Sep 25, 2021 at 07:43:38PM -0600, Simon Glass wrote:
> 
>> Use boolean variables to deal with the strange #ifdef logic of this
>> function, so we can remove the #ifdefs.
>>
>> Signed-off-by: Simon Glass 
> 
> Applied to u-boot/master, thanks!
> 

This commit causes an abort on Libretech-CC when trying to load an initrd 
(using libretech-cc_defconfig & gcc-arm-9.2-2019.12):

U-Boot 2021.10-00076-gf33a2c1bd0 (Dec 17 2021 - 18:21:08 +0100) libretech-cc

Model: Libre Computer AML-S905X-CC
SoC:   Amlogic Meson GXL (S905X) Revision 21:d (84:2)
DRAM:  2 GiB
MMC:   mmc@72000: 0, mmc@74000: 1
Loading Environment from nowhere... OK
In:serial
Out:   serial
Err:   serial
[BL31]: tee size: 0
[BL31]: tee size: 0
Net:   eth0: ethernet@c941
Hit any key to stop autoboot:  0
(ROM USB boot)
## Executing script at 0800

Moving Image from 0x808 to 0x820, end=a6c
"Synchronous Abort" handler, esr 0x96000210
elr: 0101bd44 lr : 0101bf3c (reloc)
elr: 7df70d44 lr : 7df70f3c
x0 :  x1 : 7dfcd6fc
x2 : 0003 x3 : 
x4 : 7bf74b20 x5 : 0030
x6 :  x7 : 0002
x8 : 7bf441c0 x9 : 
x10: 7fff x11: 
x12: 0a6c x13: 0a6b
x14: 7bf49210 x15: 0020
x16: 7df853bc x17: 
x18: 7bf52dd0 x19: 7dff4e98
x20: 7dff4f88 x21: 7dff4f90
x22: 0016 x23: 7bf74b20
x24:  x25: 7bf74b48
x26:  x27: 
x28: 7bf74b70 x29: 7bf481f0

Code: a9017fff 97f5 a8c27bfd d65f03c0 (b942)
Resetting CPU ...

Abort is probably in genimg_get_format()

Reverting on master fixes the issue.

Neil


Re: [PATCH v5 05/28] efi: serial: Support arrow keys

2021-12-17 Thread Simon Glass
Hi Heinrich,

On Fri, 17 Dec 2021 at 10:14, Heinrich Schuchardt  wrote:
>
> On 12/17/21 17:37, Simon Glass wrote:
> > Hi Heinrich,
> >
> > On Thu, 9 Dec 2021 at 12:44, Heinrich Schuchardt  wrote:
> >>
> >> On 12/4/21 07:56, Simon Glass wrote:
> >>> At present only the backspace key is supported in U-Boot, when running as
> >>> an EFI app. Add support for arrows, home and end as well, to make the CLI
> >>> more friendly.
> >>>
> >>> Signed-off-by: Simon Glass 
> >>> ---
> >>>
> >>> (no changes since v1)
> >>>
> >>>drivers/serial/serial_efi.c | 11 +--
> >>>1 file changed, 9 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c
> >>> index 33ddbd6080c..0067576389d 100644
> >>> --- a/drivers/serial/serial_efi.c
> >>> +++ b/drivers/serial/serial_efi.c
> >>> @@ -24,6 +24,9 @@ struct serial_efi_priv {
> >>>bool have_key;
> >>>};
> >>>
> >>> +/* Convert a lower-case character to its ctrl-char equivalent */
> >>> +#define CTL_CH(c)((c) - 'a' + 1)
> >>> +
> >>>int serial_efi_setbrg(struct udevice *dev, int baudrate)
> >>>{
> >>>return 0;
> >>> @@ -49,6 +52,7 @@ static int serial_efi_get_key(struct serial_efi_priv 
> >>> *priv)
> >>>static int serial_efi_getc(struct udevice *dev)
> >>>{
> >>>struct serial_efi_priv *priv = dev_get_priv(dev);
> >>> + char conv_scan[10] = {0, 'p', 'n', 'f', 'b', 'a', 'e', 0, 8};
> >>>int ret, ch;
> >>>
> >>>ret = serial_efi_get_key(priv);
> >>> @@ -63,8 +67,11 @@ static int serial_efi_getc(struct udevice *dev)
> >>> * key scan code of 8. Handle this so that backspace works 
> >>> correctly
> >>> * in the U-Boot command line.
> >>> */
> >>> - if (!ch && priv->key.scan_code == 8)
> >>> - ch = 8;
> >>> + if (!ch && priv->key.scan_code < sizeof(conv_scan)) {
> >>> + ch = conv_scan[priv->key.scan_code];
> >>> + if (ch >= 'a')
> >>> + ch -= 'a' - 1;
> >>
> >> This is not what a serial console would use in Linux. Just try U-Boot's
> >> conitrace command. If you use the following, we get compatibility with
> >> the rest of U-Boot:
> >>
> >> 1b 5b 32 7e - insert
> >> 1b 5b 33 7e - delete
> >> 1b 5b 35 7e - page up
> >> 1b 5b 36 7e - page down
> >> 1b 5b 41 - up
> >> 1b 5b 42 - down
> >> 1b 5b 43 - right
> >> 1b 5b 44 - left
> >> 1b 5b 46 - end
> >> 1b 5b 48 - home
> >
> > That's more complicated since it requires the serial driver to convert
> > one character into multiple. We can always add it later if needed. But
> > this does command-line history, etc. working in the app.
>
> Yes you will need a ring buffer as in the USB keyboard driver.
>
> lib/efi_loader/efi_console.c only understands the multi-byte sequences.
> I do not know if there are other places which have the same limitation.

The ones I am using here are the official U-Boot codes. Perhaps
EFI_LOADER should be fixed, but this doesn't matter for the EFI app.

In any case, this work can be done later if needed.

Regards,
Simon


Re: [PATCH 2/3] arch: imx8m: imx-regs.h add the USB regs

2021-12-17 Thread Fabio Estevam
On Fri, Dec 17, 2021 at 2:03 PM Adam Ford  wrote:

> I didn't think Driver model was a requirement for SPL.

That's my understanding as well.

> > I had problems getting the dwc3 to initialize properly when using the
> > device model in the SPL. I'm currently just using this in the SPL and
> > the device model in u-boot.
> >
> > I'll take another shot at initializing the dwc3 in the SPL with the DM.
>
> Could we compromise by putting the #define statements in an ifdef to
> only enable them when SPL is being built?

This looks like a a good idea.


Re: [PATCH 0/3] Conformance Profiles Table support in U-boot

2021-12-17 Thread Heinrich Schuchardt

On 12/17/21 13:55, Jose Marinho wrote:

The Conformance Profiles Table (ECPT) table will be included in the UEFI
specification 2.9+.


The change suggested in
https://bugzilla.tianocore.org/show_bug.cgi?id=3591
is a not well designed: How could the missing of a table ever be taken
as a sign of compliance?

How would an application make use of the table?
What information does it provide that is not better obtained from API calls?

As the table is not defined in UEFI 2.9 and no software uses it, why
should we implement it?

Best regards

Heinrich


The ECPT table was introduced in UEFI following the code-first path. The
acceptance ticket can be viewed at:
https://bugzilla.tianocore.org/show_bug.cgi?id=3591

This patch set implements the ECPT table in U-boot.

Jose Marinho (3):
   efi: Create ECPT table
   efi: ECPT add EBBRv2.0 conformance profile
   cmd: efi: efidebug print ECPT table

  cmd/efidebug.c   | 45 +++
  include/efi_api.h| 14 ++
  include/efi_loader.h |  9 
  lib/efi_loader/Kconfig   | 12 +
  lib/efi_loader/Makefile  |  1 +
  lib/efi_loader/efi_conformance.c | 75 
  lib/efi_loader/efi_setup.c   |  6 +++
  7 files changed, 162 insertions(+)
  create mode 100644 lib/efi_loader/efi_conformance.c





Re: [PATCH 3/3] cmd: efi: efidebug print ECPT table

2021-12-17 Thread Heinrich Schuchardt

On 12/17/21 13:55, Jose Marinho wrote:

Signed-off-by: Jose Marinho 
---
  cmd/efidebug.c   | 41 +
  include/efi_loader.h |  2 ++
  2 files changed, 43 insertions(+)

diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index a53a5029fa..c3246e1820 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -889,6 +889,38 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int 
flag,
return CMD_RET_SUCCESS;
  }

+#ifdef CONFIG_EFI_ECPT
+static int do_efi_ecpt(struct cmd_tbl *cmdtp, int flag,
+  int argc, char * const argv[])
+{
+   struct efi_conformance_profiles_table *ecpt;
+
+   if (argc != 1)
+   return CMD_RET_USAGE;
+
+   for (int idx = 0; idx < systab.nr_tables; idx++)
+   if (!guidcmp(&efi_ecpt_guid, &systab.tables[idx].guid))
+   ecpt = (struct efi_system_resource_table 
*)systab.tables[idx].table;
+
+   if (!ecpt) {
+   log_info("ECPT: table not present\n");
+   return CMD_RET_SUCCESS;
+   }
+
+   const int num_profiles = ecpt->number_of_profiles;
+
+   printf("\n");
+   printf("ECPT: version:%d\n", ecpt->version);
+   printf("ECPT: num profiles:%d\n", num_profiles);
+
+   for (int i = 0; i < num_profiles; i++)
+   printf("ECPT: profile %d = %pUL\n", i, 
&ecpt->conformance_profiles[i]);
+   printf("\n");
+
+   return CMD_RET_SUCCESS;
+}
+#endif /* CONFIG_EFI_ECPT */
+
  /**
   * create_initrd_dp() - Create a special device for our Boot### option
   *
@@ -1681,6 +1713,11 @@ static struct cmd_tbl cmd_efidebug_sub[] = {
 "", ""),
U_BOOT_CMD_MKENT(query, CONFIG_SYS_MAXARGS, 1, do_efi_query_info,
 "", ""),
+#ifdef CONFIG_EFI_ECPT
+   U_BOOT_CMD_MKENT(ecpt, CONFIG_SYS_MAXARGS, 1, do_efi_ecpt,
+"", ""),
+#endif
+
  };

  /**
@@ -1769,6 +1806,10 @@ static char efidebug_help_text[] =
"  - show UEFI memory map\n"
"efidebug tables\n"
"  - show UEFI configuration tables\n"
+#ifdef CONFIG_EFI_ECPT
+   "efidebug ecpt\n"
+   "  - show UEFI conformance profiles table\n"
+#endif
  #ifdef CONFIG_CMD_BOOTEFI_BOOTMGR
"efidebug test bootmgr\n"
"  - run simple bootmgr for test\n"
diff --git a/include/efi_loader.h b/include/efi_loader.h
index d20ff396d0..d60a340136 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -310,6 +310,8 @@ extern const efi_guid_t 
efi_guid_firmware_management_protocol;
  extern const efi_guid_t efi_esrt_guid;
  /* GUID of the SMBIOS table */
  extern const efi_guid_t smbios_guid;
+/* GUID for the ECPT */
+extern const efi_guid_t efi_ecpt_guid;

  extern char __efi_runtime_start[], __efi_runtime_stop[];
  extern char __efi_runtime_rel_start[], __efi_runtime_rel_stop[];


Our interest is to keep the U-Boot binary size small. I see no need to
print the ECPT table.

What make more sense is a unit test that checks the consistency of the
table.

Best regards

Heinrich


USB 2.0 Test Errors when XHCI driver is loaded on RZ/G2

2021-12-17 Thread Adam Ford
I have an RZ/G2 family of boards which has a USB 2.0 controller
connected to a hub with 4 ports on it.

I'm trying to run some hardware tests on the USB and when I issue the command:
usb test 0 1 P

I get a strange error and subsequently a message that looks like it's
executing successfully, however the usb test signal is not present on
the USB port.

=> usb test 0 1 P
Setting Test_Packet mode on downstream facing port 1...
The request port(1024) exceeds maximum port number
^--The error message
Test mode successfully set. Use 'usb start' to return to normal operation.
^--The appearance of a successful command.

The error message that reads "The request port(1024) exceeds..." is
coming from the rcar XHCI driver, but that is not the driver hosting
the USB hub or USB device attached.

=> usb tree
USB device tree:
  1  Hub (5 Gb/s, 0mA)
 U-Boot XHCI Host Controller

  1  Hub (480 Mb/s, 0mA)
 u-boot EHCI Host Controller

  1  Hub (480 Mb/s, 0mA)
  |  u-boot EHCI Host Controller
  |
  +-2  Hub (480 Mb/s, 2mA)
|
+-3  Mass Storage (480 Mb/s, 224mA)
 SanDisk Cruzer 4C530001210813101175

=>

If I disable the XHCI driver, and run the same commands, the error
message goes away, and the USB test signal is present on the USB
correct port, but the test signal is missing with the XHCI driver is
loaded, so it leads me to believe that the message is being propagated
to the wrong controller.  Somehow, by the time the message reaches the
XHCI controller, it also changes the port number to 1024 which is
clearly also incorrect.

USB dev 0 appears as my thumb drive

=> usb dev 0

Device 0: Vendor: SanDisk Rev: 1.00 Prod: Cruzer
Type: Removable Hard Disk
Capacity: 120864.0 MB = 118.0 GB (247529472 x 512)
... is now current device
=>


Does anyone have any suggestions on how to troubleshoot this?   I was
wondering if the hub numbers should be unique instead of all being the
number 1.

thanks for any advice.


[PATCH v6 00/27] efi: Improvements to U-Boot running on top of UEFI

2021-12-17 Thread Simon Glass
At present U-Boot can be built as an EFI app, but it is really just for
testing, with very few features. Instead, the payload build is used for
booting on top of UEFI, where U-Boot takes over the machine immediately
and supplies its own drivers.

But the app could be made more useful.

This series provides access to EFI block devices and the video console
within U-Boot. It also restructures the app to make it possible to boot
a kernel, although further work is needed to implement this.

This can be thought of as making U-Boot perform a little like 'grub', in
that it runs purely based on UEFI-provided services.

Of course a lot more work is required, but this is a start.

Note: It would be very useful to include qemu tests of the app and stub
in CI.

This is available at u-boot-dm/efi-working

Changes in v6:
- Add comment for dm_scan_other()
- Add comment for free_memory()
- Drop setup_disks() as U-Boot does not support it
- Fix 'have have' typo
- Fix 'stuff' typo in comment
- Fix Alo typo in commit message
- Fix comment style in setup_info_table()
- Fix typo in function comment
- Reword commit message
- Update comment for UCLASS_EFI_MEDIA (within space constraints)
- Update comment format for devpath_is_partition()
- Update comment to UCLASS_EFI_LOADER
- Update to 'This function' in comment
- Use 'U-Boot' instead of 'ARP' typo

Changes in v5:
- Add new patch to avoid setting up global_data again with EFI
- Add new patch to avoid using the 64-bit link script for the EFI app
- Add new patch to build the 64-bit app properly
- Add new patch to resolve EFI/EFI_LOADER conflict
- Add new patch to round out the link script for 64-bit EFI
- Add new patch to set the correct link flags for the 64-bit EFI app
- Add new patch to tweak the code used for the 64-bit EFI app
- Add various patches to fix up the 64-bit app so that it boots
- Fix grammar in commit message

Changes in v3:
- Add new patch to show the system-table revision
- Drop comments that confuse sphinx
- Move device_path path change to its own patch

Changes in v2:
- Add MAINTAINERS entry
- Add a better boot command too
- Add a sentence about what the patch does
- Add new patch to support the efi command in the app
- Don't export efi_bind_block()
- Drop mention of partitions from the commit message
- Fix 'as' typo
- Only bind devices for media devices, not for partitions
- Show devices that are processed
- Show the correct interface type with 'part list'
- Store device path in struct efi_media_plat
- Update documentation
- Update the commit message to explain things better
- Use log_info() instead of printf()

Simon Glass (27):
  efi: Rename UCLASS_EFI and IF_TYPE_EFI
  efi: Add EFI uclass for media
  efi: Add a media/block driver for EFI block devices
  efi: Locate all block devices in the app
  efi: serial: Support arrow keys
  x86: Allow booting a kernel from the EFI app
  x86: Don't process the kernel command line unless enabled
  x86: efi: Add room for the binman definition in the dtb
  efi: Drop device_path from struct efi_priv
  efi: Add comments to struct efi_priv
  efi: Fix ll_boot_init() operation with the app
  efi: Add a few comments to the stub
  efi: Share struct efi_priv between the app and stub code
  efi: Move exit_boot_services into a function
  efi: Check for failure when initing the app
  efi: Mention that efi_info_get() is only used in the stub
  efi: Show when allocated pages are used
  efi: Allow easy selection of serial-only operation
  x86: efi: Update efi_get_next_mem_desc() to avoid needing a map
  efi: Support the efi command in the app
  x86: efi: Show the system-table revision
  x86: efi: Don't set up global_data again with EFI
  x86: efi: Tweak the code used for the 64-bit EFI app
  x86: efi: Round out the link script for 64-bit EFI
  x86: efi: Don't use the 64-bit link script for the EFI app
  x86: efi: Set the correct link flags for the 64-bit EFI app
  efi: Build the 64-bit app properly

 MAINTAINERS|   3 +
 Makefile   |   4 +-
 arch/sandbox/dts/test.dts  |   4 +
 arch/x86/config.mk |  15 +-
 arch/x86/cpu/config.mk |   2 +-
 arch/x86/cpu/efi/payload.c |  17 +-
 arch/x86/cpu/x86_64/cpu.c  |   5 +
 arch/x86/dts/Makefile  |   2 +-
 arch/x86/lib/Makefile  |   5 +-
 arch/x86/lib/bootm.c   |  11 +-
 arch/x86/lib/elf_x86_64_efi.lds|   5 +-
 arch/x86/lib/relocate.c|   2 +
 arch/x86/lib/zimage.c  |  13 +-
 cmd/Makefile   |   2 +-
 cmd/efi.c  |  78 +
 common/board_r.c   |   5 +-
 disk/part.c|   5 +-
 doc/develop/uefi/u-boot_on_efi.rst |   6 +-
 doc/develop/uefi/uefi.rst  |   8 +-
 drivers/block/Kconfig  |  33 
 drivers/block/Makefile |   4 +
 drivers/block/blk-uclass.c |   6 +-
 drivers/block/efi-media-uclass.c   |  15 ++
 drivers/block/e

[PATCH v6 01/27] efi: Rename UCLASS_EFI and IF_TYPE_EFI

2021-12-17 Thread Simon Glass
These names are better used for access to devices provided by an EFI
layer. Use EFI_LOADER instead here, since these are only available in
U-Boot's EFI_LOADER layer.

Signed-off-by: Simon Glass 
Reviewed-by: Heinrich Schuchardt 
---

Changes in v6:
- Update comment to UCLASS_EFI_LOADER

Changes in v5:
- Add new patch to resolve EFI/EFI_LOADER conflict

 doc/develop/uefi/uefi.rst | 8 
 drivers/block/blk-uclass.c| 4 ++--
 include/blk.h | 2 +-
 include/dm/uclass-id.h| 2 +-
 lib/efi_driver/efi_block_device.c | 8 
 lib/efi_driver/efi_uclass.c   | 8 
 6 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst
index f17138f5c76..a3e2656ab81 100644
--- a/doc/develop/uefi/uefi.rst
+++ b/doc/develop/uefi/uefi.rst
@@ -620,12 +620,12 @@ EFI_DRIVER_BINDING_PROTOCOL implementation for the UEFI 
drivers.
 
 A linker created list is used to keep track of the UEFI drivers. To create an
 entry in the list the UEFI driver uses the U_BOOT_DRIVER macro specifying
-UCLASS_EFI as the ID of its uclass, e.g::
+UCLASS_EFI_LOADER as the ID of its uclass, e.g::
 
 /* Identify as UEFI driver */
 U_BOOT_DRIVER(efi_block) = {
 .name  = "EFI block driver",
-.id= UCLASS_EFI,
+.id= UCLASS_EFI_LOADER,
 .ops   = &driver_ops,
 };
 
@@ -651,8 +651,8 @@ UEFI block IO driver
 The UEFI block IO driver supports devices exposing the EFI_BLOCK_IO_PROTOCOL.
 
 When connected it creates a new U-Boot block IO device with interface type
-IF_TYPE_EFI, adds child controllers mapping the partitions, and installs the
-EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on these. This can be used together with the
+IF_TYPE_EFI_LOADER, adds child controllers mapping the partitions, and installs
+the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on these. This can be used together with 
the
 software iPXE to boot from iSCSI network drives [4].
 
 This driver is only available if U-Boot is configured with::
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 83682dcc181..a7470ae28d5 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -28,7 +28,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
[IF_TYPE_SATA]  = "sata",
[IF_TYPE_HOST]  = "host",
[IF_TYPE_NVME]  = "nvme",
-   [IF_TYPE_EFI]   = "efi",
+   [IF_TYPE_EFI_LOADER]= "efiloader",
[IF_TYPE_VIRTIO]= "virtio",
[IF_TYPE_PVBLOCK]   = "pvblock",
 };
@@ -44,7 +44,7 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
[IF_TYPE_SATA]  = UCLASS_AHCI,
[IF_TYPE_HOST]  = UCLASS_ROOT,
[IF_TYPE_NVME]  = UCLASS_NVME,
-   [IF_TYPE_EFI]   = UCLASS_EFI,
+   [IF_TYPE_EFI_LOADER]= UCLASS_EFI_LOADER,
[IF_TYPE_VIRTIO]= UCLASS_VIRTIO,
[IF_TYPE_PVBLOCK]   = UCLASS_PVBLOCK,
 };
diff --git a/include/blk.h b/include/blk.h
index f0cc7ca1a28..f0835c3fed5 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -34,7 +34,7 @@ enum if_type {
IF_TYPE_SATA,
IF_TYPE_HOST,
IF_TYPE_NVME,
-   IF_TYPE_EFI,
+   IF_TYPE_EFI_LOADER,
IF_TYPE_PVBLOCK,
IF_TYPE_VIRTIO,
 
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index fd139b9b2a0..2d05694982b 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -48,7 +48,7 @@ enum uclass_id {
UCLASS_DMA, /* Direct Memory Access */
UCLASS_DSA, /* Distributed (Ethernet) Switch Architecture */
UCLASS_ECDSA,   /* Elliptic curve cryptographic device */
-   UCLASS_EFI, /* EFI managed devices */
+   UCLASS_EFI_LOADER,  /* Devices created by UEFI apps and drivers */
UCLASS_ETH, /* Ethernet device */
UCLASS_ETH_PHY, /* Ethernet PHY device */
UCLASS_FIRMWARE,/* Firmware */
diff --git a/lib/efi_driver/efi_block_device.c 
b/lib/efi_driver/efi_block_device.c
index 0937e3595a4..04cb3ef0d4e 100644
--- a/lib/efi_driver/efi_block_device.c
+++ b/lib/efi_driver/efi_block_device.c
@@ -147,7 +147,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
if (!obj)
return -ENOENT;
 
-   devnum = blk_find_max_devnum(IF_TYPE_EFI);
+   devnum = blk_find_max_devnum(IF_TYPE_EFI_LOADER);
if (devnum == -ENODEV)
devnum = 0;
else if (devnum < 0)
@@ -159,8 +159,8 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
sprintf(name, "efiblk#%d", devnum);
 
/* Create driver model udevice for the EFI block io device */
-   ret = blk_create_device(parent, "efi_blk", name, IF_TYPE_EFI, devnum,
-   io->media->block_size,
+   ret = blk_create_device(parent, "efi_blk", name, IF_TYPE_EFI_LOADER,
+  

[PATCH v6 02/27] efi: Add EFI uclass for media

2021-12-17 Thread Simon Glass
At present UCLASS_EFI_LOADER is used to represent an EFI filesystem among
other things. The only driver that uses this uclass is in fact not a real
U-Boot driver, since its operations do not include a struct udevice.

Rather than mess with this, create a new UCLASS_EFI_MEDIA uclass to handle
EFI media such as disks. Make this the uclass to use for devices provided
by a UEFI implementation loading U-Boot as an EFI application, so that it
can be used with 'part list', for example.

The existing implementation using UCLASS_EFI remains as is, for
discussion.

Signed-off-by: Simon Glass 
Reviewed-by: Heinrich Schuchardt 
---

Changes in v6:
- Reword commit message
- Update comment for UCLASS_EFI_MEDIA (within space constraints)

Changes in v2:
- Add MAINTAINERS entry
- Show the correct interface type with 'part list'
- Update the commit message to explain things better

 MAINTAINERS  |  3 +++
 arch/sandbox/dts/test.dts|  4 
 disk/part.c  |  5 -
 drivers/block/Kconfig| 23 +++
 drivers/block/Makefile   |  3 +++
 drivers/block/blk-uclass.c   |  2 ++
 drivers/block/efi-media-uclass.c | 15 +++
 drivers/block/sb_efi_media.c | 20 
 include/blk.h|  1 +
 include/dm/uclass-id.h   |  1 +
 test/dm/Makefile |  1 +
 test/dm/efi_media.c  | 24 
 12 files changed, 101 insertions(+), 1 deletion(-)
 create mode 100644 drivers/block/efi-media-uclass.c
 create mode 100644 drivers/block/sb_efi_media.c
 create mode 100644 test/dm/efi_media.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 9045e509d73..5b162ad2978 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -714,8 +714,11 @@ W: 
https://u-boot.readthedocs.io/en/latest/develop/uefi/u-boot_on_efi.html
 F: board/efi/efi-x86_app
 F: configs/efi-x86_app*
 F: doc/develop/uefi/u-boot_on_efi.rst
+F: drivers/block/efi-media-uclass.c
+F: drivers/block/sb_efi_media.c
 F: lib/efi/efi_app.c
 F: scripts/build-efi.sh
+F: test/dm/efi_media.c
 
 EFI PAYLOAD
 M: Heinrich Schuchardt 
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index e5261bb9fa2..48ca3e1e472 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -499,6 +499,10 @@
compatible = "sandbox,clk-ccf";
};
 
+   efi-media {
+   compatible = "sandbox,efi-media";
+   };
+
eth@10002000 {
compatible = "sandbox,eth";
reg = <0x10002000 0x1000>;
diff --git a/disk/part.c b/disk/part.c
index fe1ebd4adf7..e857a9f9585 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -296,8 +296,11 @@ static void print_part_header(const char *type, struct 
blk_desc *dev_desc)
case IF_TYPE_VIRTIO:
puts("VirtIO");
break;
+   case IF_TYPE_EFI_MEDIA:
+   puts("EFI");
+   break;
default:
-   puts ("UNKNOWN");
+   puts("UNKNOWN");
break;
}
printf (" device %d  --   Partition Type: %s\n\n",
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 56a4eec05ac..755fdccb574 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -61,6 +61,29 @@ config TPL_BLOCK_CACHE
help
  This option enables the disk-block cache in TPL
 
+config EFI_MEDIA
+   bool "Support EFI media drivers"
+   default y if EFI || SANDBOX
+   help
+ Enable this to support media devices on top of UEFI. This enables
+ just the uclass so you also need a specific driver to make this do
+ anything.
+
+ For sandbox there is a test driver.
+
+if EFI_MEDIA
+
+config EFI_MEDIA_SANDBOX
+   bool "Sandbox EFI media driver"
+   depends on SANDBOX
+   default y
+   help
+ Enables a simple sandbox media driver, used for testing just the
+ EFI_MEDIA uclass. It does not do anything useful, since sandbox does
+ not actually support running on top of UEFI.
+
+endif  # EFI_MEDIA
+
 config IDE
bool "Support IDE controllers"
select HAVE_BLOCK_DEVICE
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 94ab5c6f906..3778633da1d 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -14,3 +14,6 @@ obj-$(CONFIG_IDE) += ide.o
 endif
 obj-$(CONFIG_SANDBOX) += sandbox.o
 obj-$(CONFIG_$(SPL_TPL_)BLOCK_CACHE) += blkcache.o
+
+obj-$(CONFIG_EFI_MEDIA) += efi-media-uclass.o
+obj-$(CONFIG_EFI_MEDIA_SANDBOX) += sb_efi_media.o
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index a7470ae28d5..4ae8af6d609 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -28,6 +28,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
[IF_TYPE_SATA]  = "sata",
[IF_TYPE_HOST]  = "host",
[IF_TYPE_NVME]  = "nvme",
+

[PATCH v6 03/27] efi: Add a media/block driver for EFI block devices

2021-12-17 Thread Simon Glass
Add a block driver which handles read/write for EFI block devices. This
driver actually already exists ('efi_block') but is not really suitable
for use as a real U-Boot driver:

- The operations do not provide a udevice
- The code is designed for running as part of EFI loader, so uses
EFI_PRINT() and EFI_CALL().
- The bind method probes the device, which is not permitted
- It uses 'EFI' as its parent device

The new driver is more 'normal', just requiring its platform data be set
up in advance.

Signed-off-by: Simon Glass 
Reviewed-by: Heinrich Schuchardt 
---

(no changes since v2)

Changes in v2:
- Drop mention of partitions from the commit message

 drivers/block/Kconfig   |  10 
 drivers/block/Makefile  |   1 +
 drivers/block/efi_blk.c | 115 
 include/efi.h   |  11 
 4 files changed, 137 insertions(+)
 create mode 100644 drivers/block/efi_blk.c

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 755fdccb574..8235430497d 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -82,6 +82,16 @@ config EFI_MEDIA_SANDBOX
  EFI_MEDIA uclass. It does not do anything useful, since sandbox does
  not actually support running on top of UEFI.
 
+config EFI_MEDIA_BLK
+   bool "EFI media block driver"
+   depends on EFI_APP
+   default y
+   help
+ Enables a block driver for providing access to UEFI devices. This
+ allows use of block devices detected by the underlying UEFI
+ implementation. With this it is possible to use filesystems on these
+ devices, for example.
+
 endif  # EFI_MEDIA
 
 config IDE
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 3778633da1d..b221a7c6eea 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_$(SPL_TPL_)BLOCK_CACHE) += blkcache.o
 
 obj-$(CONFIG_EFI_MEDIA) += efi-media-uclass.o
 obj-$(CONFIG_EFI_MEDIA_SANDBOX) += sb_efi_media.o
+obj-$(CONFIG_EFI_MEDIA_BLK) += efi_blk.o
diff --git a/drivers/block/efi_blk.c b/drivers/block/efi_blk.c
new file mode 100644
index 000..9d25ecbf37f
--- /dev/null
+++ b/drivers/block/efi_blk.c
@@ -0,0 +1,115 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Block driver for EFI devices
+ * This supports a media driver of UCLASS_EFI with a child UCLASS_BLK
+ * It allows block-level access to EFI devices made available via EFI boot
+ * services
+ *
+ * Copyright 2021 Google LLC
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct efi_block_plat {
+   struct efi_block_io *blkio;
+};
+
+/**
+ * Read from block device
+ *
+ * @dev:   device
+ * @blknr: first block to be read
+ * @blkcnt:number of blocks to read
+ * @buffer:output buffer
+ * Return: number of blocks transferred
+ */
+static ulong efi_bl_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
+void *buffer)
+{
+   struct efi_block_plat *plat = dev_get_plat(dev);
+   struct efi_block_io *io = plat->blkio;
+   efi_status_t ret;
+
+   log_debug("read buf=%p, block=%lx, count=%lx: ", buffer, (ulong)blknr,
+ (ulong)blkcnt);
+   ret = io->read_blocks(io, io->media->media_id, blknr,
+ blkcnt * io->media->block_size, buffer);
+   log_debug("ret=%lx (dec %ld)\n", ret & ~EFI_ERROR_MASK,
+ ret & ~EFI_ERROR_MASK);
+   if (ret)
+   return 0;
+
+   return blkcnt;
+}
+
+/**
+ * Write to block device
+ *
+ * @dev:   device
+ * @blknr: first block to be write
+ * @blkcnt:number of blocks to write
+ * @buffer:input buffer
+ * Return: number of blocks transferred
+ */
+static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
+ const void *buffer)
+{
+   struct efi_block_plat *plat = dev_get_plat(dev);
+   struct efi_block_io *io = plat->blkio;
+   efi_status_t ret;
+
+   log_debug("write buf=%p, block=%lx, count=%lx: ", buffer, (ulong)blknr,
+ (ulong)blkcnt);
+   ret = io->write_blocks(io, io->media->media_id, blknr,
+  blkcnt * io->media->block_size, (void *)buffer);
+   log_debug("ret=%lx (dec %ld)\n", ret & ~EFI_ERROR_MASK,
+ ret & ~EFI_ERROR_MASK);
+   if (ret)
+   return 0;
+
+   return blkcnt;
+}
+
+/* Block device driver operators */
+static const struct blk_ops efi_blk_ops = {
+   .read   = efi_bl_read,
+   .write  = efi_bl_write,
+};
+
+U_BOOT_DRIVER(efi_block) = {
+   .name   = "efi_block",
+   .id = UCLASS_BLK,
+   .ops= &efi_blk_ops,
+   .plat_auto  = sizeof(struct efi_block_plat),
+};
+
+static int efi_media_bind(struct udevice *dev)
+{
+   struct efi_media_plat *plat = dev_get_plat(dev);
+   struct efi_block_plat *blk_plat;
+   struct udevice *blk;
+   int ret;
+
+   ret = b

[PATCH v6 07/27] x86: Don't process the kernel command line unless enabled

2021-12-17 Thread Simon Glass
If the 'bootm' command is not enabled then this code is not available and
this causes a link error. Fix it.

Note that for the EFI app, there is no indication of missing code. It just
hangs!

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/x86/lib/zimage.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index 7ce02226ef9..9cc04490307 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -365,11 +365,14 @@ int setup_zimage(struct boot_params *setup_base, char 
*cmd_line, int auto_boot,
strcpy(cmd_line, (char *)cmdline_force);
else
build_command_line(cmd_line, auto_boot);
-   ret = bootm_process_cmdline(cmd_line, max_size, BOOTM_CL_ALL);
-   if (ret) {
-   printf("Cmdline setup failed (max_size=%x, 
bootproto=%x, err=%d)\n",
-  max_size, bootproto, ret);
-   return ret;
+   if (IS_ENABLED(CONFIG_CMD_BOOTM)) {
+   ret = bootm_process_cmdline(cmd_line, max_size,
+   BOOTM_CL_ALL);
+   if (ret) {
+   printf("Cmdline setup failed (max_size=%x, 
bootproto=%x, err=%d)\n",
+  max_size, bootproto, ret);
+   return ret;
+   }
}
printf("Kernel command line: \"");
puts(cmd_line);
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 05/27] efi: serial: Support arrow keys

2021-12-17 Thread Simon Glass
At present only the backspace key is supported in U-Boot, when running as
an EFI app. Add support for arrows, home and end as well, to make the CLI
more friendly.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/serial/serial_efi.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c
index 33ddbd6080c..0067576389d 100644
--- a/drivers/serial/serial_efi.c
+++ b/drivers/serial/serial_efi.c
@@ -24,6 +24,9 @@ struct serial_efi_priv {
bool have_key;
 };
 
+/* Convert a lower-case character to its ctrl-char equivalent */
+#define CTL_CH(c)  ((c) - 'a' + 1)
+
 int serial_efi_setbrg(struct udevice *dev, int baudrate)
 {
return 0;
@@ -49,6 +52,7 @@ static int serial_efi_get_key(struct serial_efi_priv *priv)
 static int serial_efi_getc(struct udevice *dev)
 {
struct serial_efi_priv *priv = dev_get_priv(dev);
+   char conv_scan[10] = {0, 'p', 'n', 'f', 'b', 'a', 'e', 0, 8};
int ret, ch;
 
ret = serial_efi_get_key(priv);
@@ -63,8 +67,11 @@ static int serial_efi_getc(struct udevice *dev)
 * key scan code of 8. Handle this so that backspace works correctly
 * in the U-Boot command line.
 */
-   if (!ch && priv->key.scan_code == 8)
-   ch = 8;
+   if (!ch && priv->key.scan_code < sizeof(conv_scan)) {
+   ch = conv_scan[priv->key.scan_code];
+   if (ch >= 'a')
+   ch -= 'a' - 1;
+   }
debug(" [%x %x %x] ", ch, priv->key.unicode_char, priv->key.scan_code);
 
return ch;
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 06/27] x86: Allow booting a kernel from the EFI app

2021-12-17 Thread Simon Glass
At present this is disabled, but it should work so long as the kernel does
not need EFI services. Enable it and add a note about remaining work.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Update documentation

 arch/x86/lib/bootm.c   | 11 +++
 doc/develop/uefi/u-boot_on_efi.rst |  2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c
index 667e5e689e3..57cba5c65d3 100644
--- a/arch/x86/lib/bootm.c
+++ b/arch/x86/lib/bootm.c
@@ -179,10 +179,14 @@ int boot_linux_kernel(ulong setup_base, ulong 
load_address, bool image_64bit)
* U-Boot is setting them up that way for itself in
* arch/i386/cpu/cpu.c.
*
-   * Note that we cannot currently boot a kernel while running as
-   * an EFI application. Please use the payload option for that.
+   * Note: this is incomplete for EFI kernels!
+   *
+   * This can boot a kernel while running as an EFI application,
+   * but if the kernel requires EFI support then that support needs
+   * to be enabled first (see EFI_LOADER). Also the EFI information
+   * must enabled with setup_efi_info(). See setup_zimage() for
+   * how this is done with the stub.
*/
-#ifndef CONFIG_EFI_APP
__asm__ __volatile__ (
"movl $0, %%ebp\n"
"cli\n"
@@ -191,7 +195,6 @@ int boot_linux_kernel(ulong setup_base, ulong load_address, 
bool image_64bit)
[boot_params] "S"(setup_base),
"b"(0), "D"(0)
);
-#endif
}
 
/* We can't get to here */
diff --git a/doc/develop/uefi/u-boot_on_efi.rst 
b/doc/develop/uefi/u-boot_on_efi.rst
index 8f81b799072..acad6397e81 100644
--- a/doc/develop/uefi/u-boot_on_efi.rst
+++ b/doc/develop/uefi/u-boot_on_efi.rst
@@ -269,7 +269,7 @@ This work could be extended in a number of ways:
 
 - Avoid turning off boot services in the stub. Instead allow U-Boot to make
   use of boot services in case it wants to. It is unclear what it might want
-  though.
+  though. It is better to use the app.
 
 Where is the code?
 --
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 08/27] x86: efi: Add room for the binman definition in the dtb

2021-12-17 Thread Simon Glass
At present only 4KB of spare space is left in the DTB when building the
EFI app. Increase this to 32KB so there is plenty of space to insert the
binman definition. This cannot be expanded later (as with OF_SEPARATE)
because the ELF image has already been built.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/x86/dts/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/dts/Makefile b/arch/x86/dts/Makefile
index be209aaaf8f..5c8c05ec499 100644
--- a/arch/x86/dts/Makefile
+++ b/arch/x86/dts/Makefile
@@ -24,7 +24,7 @@ dtb-y += bayleybay.dtb \
 
 targets += $(dtb-y)
 
-DTC_FLAGS += -R 4 -p 0x1000
+DTC_FLAGS += -R 4 -p $(if $(CONFIG_EFI_APP),0x8000,0x1000)
 
 PHONY += dtbs
 dtbs: $(addprefix $(obj)/, $(dtb-y))
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 04/27] efi: Locate all block devices in the app

2021-12-17 Thread Simon Glass
When starting the app, locate all block devices and make them available
to U-Boot. This allows listing partitions and accessing files in
filesystems.

EFI also has the concept of 'disks', meaning boot media. For now, this
is not obviously useful in U-Boot, but add code to at least locate these.
This can be expanded later as needed.

Signed-off-by: Simon Glass 
---

Changes in v6:
- Add comment for dm_scan_other()
- Add comment for free_memory()
- Drop setup_disks() as U-Boot does not support it
- Fix 'have have' typo
- Update comment format for devpath_is_partition()

Changes in v2:
- Don't export efi_bind_block()
- Only bind devices for media devices, not for partitions
- Show devices that are processed
- Store device path in struct efi_media_plat
- Update documentation

 doc/develop/uefi/u-boot_on_efi.rst |   4 +-
 include/efi.h  |   6 +-
 include/efi_api.h  |  15 ++
 lib/efi/efi_app.c  | 216 +
 4 files changed, 236 insertions(+), 5 deletions(-)

diff --git a/doc/develop/uefi/u-boot_on_efi.rst 
b/doc/develop/uefi/u-boot_on_efi.rst
index 5f2f850f071..8f81b799072 100644
--- a/doc/develop/uefi/u-boot_on_efi.rst
+++ b/doc/develop/uefi/u-boot_on_efi.rst
@@ -265,9 +265,7 @@ This work could be extended in a number of ways:
 
 - Figure out how to solve the interrupt problem
 
-- Add more drivers to the application side (e.g. block devices, USB,
-  environment access). This would mostly be an academic exercise as a strong
-  use case is not readily apparent, but it might be fun.
+- Add more drivers to the application side (e.g.USB, environment access).
 
 - Avoid turning off boot services in the stub. Instead allow U-Boot to make
   use of boot services in case it wants to. It is unclear what it might want
diff --git a/include/efi.h b/include/efi.h
index 0ec5913ddd1..908c5dc6ebd 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -419,10 +419,12 @@ struct efi_priv {
  *
  * @handle: handle of the controller on which this driver is installed
  * @blkio: block io protocol proxied by this driver
+ * @device_path: EFI path to the device
  */
 struct efi_media_plat {
-   efi_handle_thandle;
-   struct efi_block_io *blkio;
+   efi_handle_t handle;
+   struct efi_block_io *blkio;
+   struct efi_device_path *device_path;
 };
 
 /* Base address of the EFI image */
diff --git a/include/efi_api.h b/include/efi_api.h
index 80109f012bc..ec9fa89a935 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -2035,4 +2035,19 @@ struct efi_firmware_management_protocol {
const u16 *package_version_name);
 };
 
+#define EFI_DISK_IO_PROTOCOL_GUID  \
+   EFI_GUID(0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, \
+0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+
+struct efi_disk {
+   u64 revision;
+   efi_status_t (EFIAPI *read_disk)(struct efi_disk *this, u32 media_id,
+u64 offset, efi_uintn_t buffer_size,
+void *buffer);
+
+   efi_status_t (EFIAPI *write_disk)(struct efi_disk *this, u32 media_id,
+ u64 offset, efi_uintn_t buffer_size,
+ void *buffer);
+};
+
 #endif
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index f61665686c5..6a71cef7acb 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -21,6 +21,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -46,6 +49,64 @@ int efi_info_get(enum efi_entry_t type, void **datap, int 
*sizep)
return -ENOSYS;
 }
 
+/**
+ * efi_print_str() - Print a UFT-16 string to the U-Boot console
+ *
+ * @str: String to print
+ */
+static void efi_print_str(const u16 *str)
+{
+   while (*str) {
+   int ch = *str++;
+
+   if (ch > ' ' && ch < 127)
+   putc(ch);
+   }
+}
+
+/**
+ * efi_bind_block() - bind a new block device to an EFI device
+ *
+ * Binds a new top-level EFI_MEDIA device as well as a child block device so
+ * that the block device can be accessed in U-Boot.
+ *
+ * The device can then be accessed using 'part list efi 0', 'fat ls efi 0:1',
+ * for example, just like any other interface type.
+ *
+ * @handle: handle of the controller on which this driver is installed
+ * @blkio: block io protocol proxied by this driver
+ * @device_path: EFI device path structure for this
+ * @len: Length of @device_path in bytes
+ * @devp: Returns the bound device
+ * @return 0 if OK, -ve on error
+ */
+int efi_bind_block(efi_handle_t handle, struct efi_block_io *blkio,
+  struct efi_device_path *device_path, int len,
+  struct udevice **devp)
+{
+   struct efi_media_plat plat;
+   struct udevice *dev;
+   char name[18];
+   int ret;
+
+   plat.handle = handle;
+   plat.blkio = blkio;
+   plat.device_path = malloc(device

[PATCH v6 10/27] efi: Add comments to struct efi_priv

2021-12-17 Thread Simon Glass
This structure is uncommented. Fix it.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Drop comments that confuse sphinx
- Move device_path path change to its own patch

 include/efi.h | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/include/efi.h b/include/efi.h
index 77e599c256e..6622a733e6e 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -400,14 +400,37 @@ static inline struct efi_mem_desc *efi_get_next_mem_desc(
return (struct efi_mem_desc *)((ulong)desc + map->desc_size);
 }
 
+/**
+ * struct efi_priv - Information about the environment provided by EFI
+ *
+ * @parent_image: image passed into the EFI app or stub
+ * @sys_table: Pointer to system table
+ * @boot: Pointer to boot-services table
+ * @run: Pointer to runtime-services table
+ *
+ * @use_pool_for_malloc: true if all allocation should go through the EFI 
'pool'
+ * methods allocate_pool() and free_pool(); false to use 'pages' methods
+ * allocate_pages() and free_pages()
+ * @ram_base: Base address of RAM (size CONFIG_EFI_RAM_SIZE)
+ * @image_data_type: Type of the loaded image (e.g. EFI_LOADER_CODE)
+ *
+ * @info: Header of the info list, holding info collected by the stub and 
passed
+ * to U-Boot
+ * @info_size: Size of the info list, in bytes from @info
+ * @next_hdr: Pointer to where to put the next header when adding to the list
+ */
 struct efi_priv {
efi_handle_t parent_image;
struct efi_system_table *sys_table;
struct efi_boot_services *boot;
struct efi_runtime_services *run;
+
+   /* app: */
bool use_pool_for_malloc;
unsigned long ram_base;
unsigned int image_data_type;
+
+   /* stub: */
struct efi_info_hdr *info;
unsigned int info_size;
void *next_hdr;
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 11/27] efi: Fix ll_boot_init() operation with the app

2021-12-17 Thread Simon Glass
This should return false when the EFI app is running, since UEFI has done
the required low-level init. Fix it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

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

diff --git a/include/init.h b/include/init.h
index f2cd46dead0..3ce7b8b95bd 100644
--- a/include/init.h
+++ b/include/init.h
@@ -15,7 +15,7 @@
 #include 
 
 /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */
-#ifdef CONFIG_EFI_STUB
+#ifdef CONFIG_EFI
 #define ll_boot_init() false
 #else
 #include 
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 09/27] efi: Drop device_path from struct efi_priv

2021-12-17 Thread Simon Glass
This is not used anywhere drop it.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Move device_path path change to its own patch

 include/efi.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/efi.h b/include/efi.h
index 908c5dc6ebd..77e599c256e 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -402,7 +402,6 @@ static inline struct efi_mem_desc *efi_get_next_mem_desc(
 
 struct efi_priv {
efi_handle_t parent_image;
-   struct efi_device_path *device_path;
struct efi_system_table *sys_table;
struct efi_boot_services *boot;
struct efi_runtime_services *run;
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 12/27] efi: Add a few comments to the stub

2021-12-17 Thread Simon Glass
Comment some functions that need more information.

Signed-off-by: Simon Glass 
---

Changes in v6:
- Fix comment style in setup_info_table()

 lib/efi/efi_stub.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c
index b3393e47fae..e8a594cb2aa 100644
--- a/lib/efi/efi_stub.c
+++ b/lib/efi/efi_stub.c
@@ -225,6 +225,22 @@ static int get_codeseg32(void)
return cs32;
 }
 
+/**
+ * setup_info_table() - sets up a table containing information from EFI
+ *
+ * We must call exit_boot_services() before jumping out of the stub into U-Boot
+ * proper, so that U-Boot has full control of peripherals, memory, etc.
+ *
+ * Once we do this, we cannot call any boot-services functions so we must find
+ * out everything we need to before doing that.
+ *
+ * Set up a struct efi_info_hdr table which can hold various records (e.g.
+ * struct efi_entry_memmap) with information obtained from EFI.
+ *
+ * @priv: Pointer to our private information which contains the list
+ * @size: Size of the table to allocate
+ * Return: 0 if OK, non-zero on error
+ */
 static int setup_info_table(struct efi_priv *priv, int size)
 {
struct efi_info_hdr *info;
@@ -248,6 +264,12 @@ static int setup_info_table(struct efi_priv *priv, int 
size)
return 0;
 }
 
+/**
+ * add_entry_addr() - Add a new entry to the efi_info list
+ *
+ * @priv: Pointer to our private information which contains the list
+ *
+ */
 static void add_entry_addr(struct efi_priv *priv, enum efi_entry_t type,
   void *ptr1, int size1, void *ptr2, int size2)
 {
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 16/27] efi: Mention that efi_info_get() is only used in the stub

2021-12-17 Thread Simon Glass
This provides access to EFI tables after U-Boot has exited boot services.
It is not needed in the app since boot services remain alive and we can
just call them whenever needed.

Add a comment to explain this.

Signed-off-by: Simon Glass 
---

Changes in v6:
- Fix 'stuff' typo in comment
- Update to 'This function' in comment

Changes in v2:
- Fix 'as' typo

 include/efi.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/efi.h b/include/efi.h
index ca4afaf524b..0aa07193640 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -578,6 +578,10 @@ void efi_putc(struct efi_priv *priv, const char ch);
 /**
  * efi_info_get() - get an entry from an EFI table
  *
+ * This function is called from U-Boot proper to read information set up by the
+ * EFI stub. It can only be used when running from the EFI stub, not when 
U-Boot
+ * is running as an app.
+ *
  * @type:  Entry type to search for
  * @datap: Returns pointer to entry data
  * @sizep: Returns pointer to entry size
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 15/27] efi: Check for failure when initing the app

2021-12-17 Thread Simon Glass
The stub checks for failure with efi_init(). Add this for the app as well.
It is unlikely that anything can be done, but we may as well stop.

Signed-off-by: Simon Glass 
---

Changes in v6:
- Use 'U-Boot' instead of 'ARP' typo

 lib/efi/efi_app.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index 2024ecc37b6..2a6740b836a 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -318,8 +318,11 @@ efi_status_t EFIAPI efi_main(efi_handle_t image,
efi_status_t ret;
 
/* Set up access to EFI data structures */
-   efi_init(priv, "App", image, sys_table);
-
+   ret = efi_init(priv, "App", image, sys_table);
+   if (ret) {
+   printf("Failed to set up U-Boot: err=%lx\n", ret);
+   return ret;
+   }
efi_set_priv(priv);
 
/*
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 13/27] efi: Share struct efi_priv between the app and stub code

2021-12-17 Thread Simon Glass
At present each of these has its own static variable and helper functions.
Move them into a shared file.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/efi.h  | 21 +
 lib/efi/efi.c  | 29 +
 lib/efi/efi_app.c  | 21 ++---
 lib/efi/efi_stub.c |  7 ---
 4 files changed, 56 insertions(+), 22 deletions(-)

diff --git a/include/efi.h b/include/efi.h
index 6622a733e6e..ca301db7cb5 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -474,6 +474,27 @@ extern char _binary_u_boot_bin_start[], 
_binary_u_boot_bin_end[];

EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \
EFI_VARIABLE_APPEND_WRITE)
 
+/**
+ * efi_get_priv() - Get access to the EFI-private information
+ *
+ * This struct it used by both the stub and the app to record things about the
+ * EFI environment. It is not available in U-Boot proper after the stub has
+ * jumped there. Use efi_info_get() to obtain info in that case.
+ *
+ * @return pointer to private info
+ */
+struct efi_priv *efi_get_priv(void);
+
+/**
+ * efi_set_priv() - Set up a pointer to the EFI-private information
+ *
+ * This is called in the stub and app to record the location of this
+ * information.
+ *
+ * @priv: New location of private data
+ */
+void efi_set_priv(struct efi_priv *priv);
+
 /**
  * efi_get_sys_table() - Get access to the main EFI system table
  *
diff --git a/lib/efi/efi.c b/lib/efi/efi.c
index 69e52e45748..cd6bf47b180 100644
--- a/lib/efi/efi.c
+++ b/lib/efi/efi.c
@@ -1,5 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
+ * Functions shared by the app and stub
+ *
  * Copyright (c) 2015 Google, Inc
  *
  * EFI information obtained here:
@@ -17,6 +19,33 @@
 #include 
 #include 
 
+static struct efi_priv *global_priv;
+
+struct efi_priv *efi_get_priv(void)
+{
+   return global_priv;
+}
+
+void efi_set_priv(struct efi_priv *priv)
+{
+   global_priv = priv;
+}
+
+struct efi_system_table *efi_get_sys_table(void)
+{
+   return global_priv->sys_table;
+}
+
+struct efi_boot_services *efi_get_boot(void)
+{
+   return global_priv->boot;
+}
+
+unsigned long efi_get_ram_base(void)
+{
+   return global_priv->ram_base;
+}
+
 /*
  * Global declaration of gd.
  *
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index 6a71cef7acb..122945e1ddd 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -27,23 +27,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static struct efi_priv *global_priv;
-
-struct efi_system_table *efi_get_sys_table(void)
-{
-   return global_priv->sys_table;
-}
-
-struct efi_boot_services *efi_get_boot(void)
-{
-   return global_priv->boot;
-}
-
-unsigned long efi_get_ram_base(void)
-{
-   return global_priv->ram_base;
-}
-
 int efi_info_get(enum efi_entry_t type, void **datap, int *sizep)
 {
return -ENOSYS;
@@ -337,7 +320,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image,
/* Set up access to EFI data structures */
efi_init(priv, "App", image, sys_table);
 
-   global_priv = priv;
+   efi_set_priv(priv);
 
/*
 * Set up the EFI debug UART so that printf() works. This is
@@ -363,7 +346,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image,
 
 static void efi_exit(void)
 {
-   struct efi_priv *priv = global_priv;
+   struct efi_priv *priv = efi_get_priv();
 
free_memory(priv);
printf("U-Boot EFI exiting\n");
diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c
index e8a594cb2aa..b4e9f49a6df 100644
--- a/lib/efi/efi_stub.c
+++ b/lib/efi/efi_stub.c
@@ -31,7 +31,6 @@
 #error "This file needs to be ported for use on architectures"
 #endif
 
-static struct efi_priv *global_priv;
 static bool use_uart;
 
 struct __packed desctab_info {
@@ -63,6 +62,8 @@ void _debug_uart_init(void)
 
 void putc(const char ch)
 {
+   struct efi_priv *priv = efi_get_priv();
+
if (ch == '\n')
putc('\r');
 
@@ -73,7 +74,7 @@ void putc(const char ch)
;
outb(ch, (ulong)&com_port->thr);
} else {
-   efi_putc(global_priv, ch);
+   efi_putc(priv, ch);
}
 }
 
@@ -313,7 +314,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image,
puts(" efi_init() failed\n");
return ret;
}
-   global_priv = priv;
+   efi_set_priv(priv);
 
cs32 = get_codeseg32();
if (cs32 < 0)
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 14/27] efi: Move exit_boot_services into a function

2021-12-17 Thread Simon Glass
At present this code is inline in the app and stub. But they do the same
thing. The difference is that the stub does it immediately and the app
doesn't want to do it until the end (when it boots a kernel) or not at
all, if returning to UEFI.

Move it into a function so it can be called as needed.

Also store the memory map so that it can be accessed within the app if
needed.

Signed-off-by: Simon Glass 
---

Changes in v6:
- Fix typo in function comment

Changes in v2:
- Add a sentence about what the patch does

 include/efi.h  | 32 ++
 lib/efi/efi.c  | 68 ++
 lib/efi/efi_app.c  |  3 ++
 lib/efi/efi_stub.c | 66 
 4 files changed, 114 insertions(+), 55 deletions(-)

diff --git a/include/efi.h b/include/efi.h
index ca301db7cb5..ca4afaf524b 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -407,6 +407,12 @@ static inline struct efi_mem_desc *efi_get_next_mem_desc(
  * @sys_table: Pointer to system table
  * @boot: Pointer to boot-services table
  * @run: Pointer to runtime-services table
+ * @memmap_key: Key returned from get_memory_map()
+ * @memmap_desc: List of memory-map records
+ * @memmap_alloc: Amount of memory allocated for memory map list
+ * @memmap_size Size of memory-map list in bytes
+ * @memmap_desc_size: Size of an individual memory-map record, in bytes
+ * @memmap_version: Memory-map version
  *
  * @use_pool_for_malloc: true if all allocation should go through the EFI 
'pool'
  * methods allocate_pool() and free_pool(); false to use 'pages' methods
@@ -424,6 +430,12 @@ struct efi_priv {
struct efi_system_table *sys_table;
struct efi_boot_services *boot;
struct efi_runtime_services *run;
+   efi_uintn_t memmap_key;
+   struct efi_mem_desc *memmap_desc;
+   efi_uintn_t memmap_alloc;
+   efi_uintn_t memmap_size;
+   efi_uintn_t memmap_desc_size;
+   u32 memmap_version;
 
/* app: */
bool use_pool_for_malloc;
@@ -574,4 +586,24 @@ void efi_putc(struct efi_priv *priv, const char ch);
  */
 int efi_info_get(enum efi_entry_t type, void **datap, int *sizep);
 
+/**
+ * efi_store_memory_map() - Collect the memory-map info from EFI
+ *
+ * Collect the memory info and store it for later use, e.g. in calling
+ * exit_boot_services()
+ *
+ * @priv:  Pointer to private EFI structure
+ * @return 0 if OK, non-zero on error
+ */
+int efi_store_memory_map(struct efi_priv *priv);
+
+/**
+ * efi_call_exit_boot_services() - Handle the exit-boot-service procedure
+ *
+ * Tell EFI we don't want their boot services anymore
+ *
+ * Return: 0 if OK, non-zero on error
+ */
+int efi_call_exit_boot_services(void);
+
 #endif /* _LINUX_EFI_H */
diff --git a/lib/efi/efi.c b/lib/efi/efi.c
index cd6bf47b180..20da88c9151 100644
--- a/lib/efi/efi.c
+++ b/lib/efi/efi.c
@@ -135,3 +135,71 @@ void efi_free(struct efi_priv *priv, void *ptr)
 
boot->free_pool(ptr);
 }
+
+int efi_store_memory_map(struct efi_priv *priv)
+{
+   struct efi_boot_services *boot = priv->sys_table->boottime;
+   efi_uintn_t size, desc_size;
+   efi_status_t ret;
+
+   /* Get the memory map so we can switch off EFI */
+   size = 0;
+   ret = boot->get_memory_map(&size, NULL, &priv->memmap_key,
+  &priv->memmap_desc_size,
+  &priv->memmap_version);
+   if (ret != EFI_BUFFER_TOO_SMALL) {
+   printhex2(EFI_BITS_PER_LONG);
+   putc(' ');
+   printhex2(ret);
+   puts(" No memory map\n");
+   return ret;
+   }
+   /*
+* Since doing a malloc() may change the memory map and also we want to
+* be able to read the memory map in efi_call_exit_boot_services()
+* below, after more changes have happened
+*/
+   priv->memmap_alloc = size + 1024;
+   priv->memmap_size = priv->memmap_alloc;
+   priv->memmap_desc = efi_malloc(priv, size, &ret);
+   if (!priv->memmap_desc) {
+   printhex2(ret);
+   puts(" No memory for memory descriptor\n");
+   return ret;
+   }
+
+   ret = boot->get_memory_map(&priv->memmap_size, priv->memmap_desc,
+  &priv->memmap_key, &desc_size,
+  &priv->memmap_version);
+   if (ret) {
+   printhex2(ret);
+   puts(" Can't get memory map\n");
+   return ret;
+   }
+
+   return 0;
+}
+
+int efi_call_exit_boot_services(void)
+{
+   struct efi_priv *priv = efi_get_priv();
+   const struct efi_boot_services *boot = priv->boot;
+   efi_uintn_t size;
+   u32 version;
+   efi_status_t ret;
+
+   size = priv->memmap_alloc;
+   ret = boot->get_memory_map(&size, priv->memmap_desc,
+  &priv->memmap_key,
+  &priv->memmap_desc_size

[PATCH v6 18/27] efi: Allow easy selection of serial-only operation

2021-12-17 Thread Simon Glass
Add info about how to select vidconsole or serial.

Also set up a demo boot command.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Add a better boot command too

 include/configs/efi-x86_app.h | 25 +
 1 file changed, 25 insertions(+)

diff --git a/include/configs/efi-x86_app.h b/include/configs/efi-x86_app.h
index 6061a6db0a4..33afb7ca0f9 100644
--- a/include/configs/efi-x86_app.h
+++ b/include/configs/efi-x86_app.h
@@ -10,8 +10,33 @@
 
 #undef CONFIG_TPM_TIS_BASE_ADDRESS
 
+/*
+ * Select the output device: Put an 'x' prefix before one of these to disable 
it
+ */
+
+/*
+ * Video output - can normally continue after exit_boot_services has been
+ * called, since output to the display does not require EFI services at that
+ * point. U-Boot sets up the console memory and does its own drawing.
+ */
 #define CONFIG_STD_DEVICES_SETTINGS"stdin=serial\0" \
"stdout=vidconsole\0" \
"stderr=vidconsole\0"
 
+/*
+ * Serial output with no console. Run qemu with:
+ *
+ *-display none -serial mon:stdio
+ *
+ * This will hang or fail to output on the console after exit_boot_services is
+ * called.
+ */
+#define xCONFIG_STD_DEVICES_SETTINGS   "stdin=serial\0" \
+   "stdout=serial\0" \
+   "stderr=serial\0"
+
+#undef CONFIG_BOOTCOMMAND
+
+#define CONFIG_BOOTCOMMAND "part list efi 0; fatls efi 0:1"
+
 #endif
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 17/27] efi: Show when allocated pages are used

2021-12-17 Thread Simon Glass
Add a message here so that both paths of memory allocation are reported.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Use log_info() instead of printf()

 lib/efi/efi_app.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index 2a6740b836a..b2d2de1dc3a 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -121,13 +121,14 @@ static efi_status_t setup_memory(struct efi_priv *priv)
ret = boot->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
   priv->image_data_type, pages, &addr);
if (ret) {
-   printf("(using pool %lx) ", ret);
+   log_info("(using pool %lx) ", ret);
priv->ram_base = (ulong)efi_malloc(priv, CONFIG_EFI_RAM_SIZE,
   &ret);
if (!priv->ram_base)
return ret;
priv->use_pool_for_malloc = true;
} else {
+   log_info("(using allocated RAM address %lx) ", (ulong)addr);
priv->ram_base = addr;
}
gd->ram_size = pages << 12;
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 19/27] x86: efi: Update efi_get_next_mem_desc() to avoid needing a map

2021-12-17 Thread Simon Glass
At present this function requires a pointer to struct efi_entry_memmap
but the only field used in there is the desc_size. We want to be able
to use it from the app, so update it to use desc_size directly.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/x86/cpu/efi/payload.c |  8 
 cmd/efi.c  | 34 ++
 include/efi.h  |  4 ++--
 3 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/arch/x86/cpu/efi/payload.c b/arch/x86/cpu/efi/payload.c
index 3a9f7d72868..d2aa889a2b9 100644
--- a/arch/x86/cpu/efi/payload.c
+++ b/arch/x86/cpu/efi/payload.c
@@ -50,7 +50,7 @@ ulong board_get_usable_ram_top(ulong total_size)
 
end = (struct efi_mem_desc *)((ulong)map + size);
desc = map->desc;
-   for (; desc < end; desc = efi_get_next_mem_desc(map, desc)) {
+   for (; desc < end; desc = efi_get_next_mem_desc(desc, map->desc_size)) {
if (desc->type != EFI_CONVENTIONAL_MEMORY ||
desc->physical_start >= 1ULL << 32)
continue;
@@ -88,7 +88,7 @@ int dram_init(void)
end = (struct efi_mem_desc *)((ulong)map + size);
gd->ram_size = 0;
desc = map->desc;
-   for (; desc < end; desc = efi_get_next_mem_desc(map, desc)) {
+   for (; desc < end; desc = efi_get_next_mem_desc(desc, map->desc_size)) {
if (desc->type < EFI_MMAP_IO)
gd->ram_size += desc->num_pages << EFI_PAGE_SHIFT;
}
@@ -113,7 +113,7 @@ int dram_init_banksize(void)
desc = map->desc;
for (num_banks = 0;
 desc < end && num_banks < CONFIG_NR_DRAM_BANKS;
-desc = efi_get_next_mem_desc(map, desc)) {
+desc = efi_get_next_mem_desc(desc, map->desc_size)) {
/*
 * We only use conventional memory and ignore
 * anything less than 1MB.
@@ -196,7 +196,7 @@ unsigned int install_e820_map(unsigned int max_entries,
 
end = (struct efi_mem_desc *)((ulong)map + size);
for (desc = map->desc; desc < end;
-desc = efi_get_next_mem_desc(map, desc)) {
+desc = efi_get_next_mem_desc(desc, map->desc_size)) {
if (desc->num_pages == 0)
continue;
 
diff --git a/cmd/efi.c b/cmd/efi.c
index f2ed26bd4b2..d2400acbbba 100644
--- a/cmd/efi.c
+++ b/cmd/efi.c
@@ -75,16 +75,17 @@ static int h_cmp_entry(const void *v1, const void *v2)
 /**
  * efi_build_mem_table() - make a sorted copy of the memory table
  *
- * @map:   Pointer to EFI memory map table
+ * @desc_base: Pointer to EFI memory map table
  * @size:  Size of table in bytes
+ * @desc_size: Size of each @desc_base record
  * @skip_bs:   True to skip boot-time memory and merge it with conventional
  * memory. This will significantly reduce the number of table
  * entries.
  * Return: pointer to the new table. It should be freed with free() by the
  * caller.
  */
-static void *efi_build_mem_table(struct efi_entry_memmap *map, int size,
-bool skip_bs)
+static void *efi_build_mem_table(struct efi_mem_desc *desc_base, int size,
+int desc_size, bool skip_bs)
 {
struct efi_mem_desc *desc, *end, *base, *dest, *prev;
int count;
@@ -95,15 +96,16 @@ static void *efi_build_mem_table(struct efi_entry_memmap 
*map, int size,
debug("%s: Cannot allocate %#x bytes\n", __func__, size);
return NULL;
}
-   end = (struct efi_mem_desc *)((ulong)map + size);
-   count = ((ulong)end - (ulong)map->desc) / map->desc_size;
-   memcpy(base, map->desc, (ulong)end - (ulong)map->desc);
-   qsort(base, count, map->desc_size, h_cmp_entry);
+   end = (void *)desc_base + size;
+   count = ((ulong)end - (ulong)desc_base) / desc_size;
+   memcpy(base, desc_base, (ulong)end - (ulong)desc_base);
+   qsort(base, count, desc_size, h_cmp_entry);
prev = NULL;
addr = 0;
dest = base;
-   end = (struct efi_mem_desc *)((ulong)base + count * map->desc_size);
-   for (desc = base; desc < end; desc = efi_get_next_mem_desc(map, desc)) {
+   end = (struct efi_mem_desc *)((ulong)base + count * desc_size);
+   for (desc = base; desc < end;
+desc = efi_get_next_mem_desc(desc, desc_size)) {
bool merge = true;
u32 type = desc->type;
 
@@ -116,7 +118,7 @@ static void *efi_build_mem_table(struct efi_entry_memmap 
*map, int size,
if (skip_bs && is_boot_services(desc->type))
type = EFI_CONVENTIONAL_MEMORY;
 
-   memcpy(dest, desc, map->desc_size);
+   memcpy(dest, desc, desc_size);
dest->type = type;
if (!skip_bs || !prev)
merge = false;
@@ -131,7 +133,7 @@ static void *efi_build_mem_table(struct 

[PATCH v6 22/27] x86: efi: Don't set up global_data again with EFI

2021-12-17 Thread Simon Glass
Since EFI does not relocate and uses the same global_data pointer
throughout the board-init process, drop this unnecessary setup, to avoid
a hang.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to avoid setting up global_data again with EFI

 common/board_r.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index 31a59c585a8..8b5948100b1 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -817,9 +817,8 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
 * TODO(s...@chromium.org): Consider doing this for all archs, or
 * dropping the new_gd parameter.
 */
-#if CONFIG_IS_ENABLED(X86_64)
-   arch_setup_gd(new_gd);
-#endif
+   if (CONFIG_IS_ENABLED(X86_64) && !IS_ENABLED(CONFIG_EFI_APP))
+   arch_setup_gd(new_gd);
 
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
int i;
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 20/27] efi: Support the efi command in the app

2021-12-17 Thread Simon Glass
At present the 'efi' command only works in the EFI payload. Update it to
work in the app too, so the memory map can be examined.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 cmd/Makefile  |  2 +-
 cmd/efi.c | 48 ---
 include/efi.h | 15 +++
 lib/efi/efi_app.c | 33 
 4 files changed, 82 insertions(+), 16 deletions(-)

diff --git a/cmd/Makefile b/cmd/Makefile
index 891819ae0f6..df50625bde7 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -58,7 +58,7 @@ obj-$(CONFIG_CMD_EXTENSION) += extension_board.o
 obj-$(CONFIG_CMD_ECHO) += echo.o
 obj-$(CONFIG_ENV_IS_IN_EEPROM) += eeprom.o
 obj-$(CONFIG_CMD_EEPROM) += eeprom.o
-obj-$(CONFIG_EFI_STUB) += efi.o
+obj-$(CONFIG_EFI) += efi.o
 obj-$(CONFIG_CMD_EFIDEBUG) += efidebug.o
 obj-$(CONFIG_CMD_ELF) += elf.o
 obj-$(CONFIG_HUSH_PARSER) += exit.o
diff --git a/cmd/efi.c b/cmd/efi.c
index d2400acbbba..c0384e0db28 100644
--- a/cmd/efi.c
+++ b/cmd/efi.c
@@ -13,6 +13,8 @@
 #include 
 #include 
 
+DECLARE_GLOBAL_DATA_PTR;
+
 static const char *const type_name[] = {
"reserved",
"loader_code",
@@ -217,37 +219,53 @@ static void efi_print_mem_table(struct efi_mem_desc 
*desc, int desc_size,
 static int do_efi_mem(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[])
 {
-   struct efi_mem_desc *desc;
-   struct efi_entry_memmap *map;
+   struct efi_mem_desc *orig, *desc;
+   uint version, key;
+   int desc_size;
int size, ret;
bool skip_bs;
 
skip_bs = !argc || *argv[0] != 'a';
-   ret = efi_info_get(EFIET_MEMORY_MAP, (void **)&map, &size);
-   switch (ret) {
-   case -ENOENT:
-   printf("No EFI table available\n");
-   goto done;
-   case -EPROTONOSUPPORT:
-   printf("Incorrect EFI table version\n");
-   goto done;
+   if (IS_ENABLED(CONFIG_EFI_APP)) {
+   ret = efi_get_mmap(&orig, &size, &key, &desc_size, &version);
+   if (ret) {
+   printf("Cannot read memory map (err=%d)\n", ret);
+   return CMD_RET_FAILURE;
+   }
+   } else {
+   struct efi_entry_memmap *map;
+
+   ret = efi_info_get(EFIET_MEMORY_MAP, (void **)&map, &size);
+   switch (ret) {
+   case -ENOENT:
+   printf("No EFI table available\n");
+   goto done;
+   case -EPROTONOSUPPORT:
+   printf("Incorrect EFI table version\n");
+   goto done;
+   }
+   orig = map->desc;
+   desc_size = map->desc_size;
+   version = map->version;
}
-   printf("EFI table at %lx, memory map %p, size %x, version %x, descr. 
size %#x\n",
-  gd->arch.table, map, size, map->version, map->desc_size);
-   if (map->version != EFI_MEM_DESC_VERSION) {
+   printf("EFI table at %lx, memory map %p, size %x, key %x, version %x, 
descr. size %#x\n",
+  gd->arch.table, orig, size, key, version, desc_size);
+   if (version != EFI_MEM_DESC_VERSION) {
printf("Incorrect memory map version\n");
ret = -EPROTONOSUPPORT;
goto done;
}
 
-   desc = efi_build_mem_table(map->desc, size, map->desc_size, skip_bs);
+   desc = efi_build_mem_table(orig, size, desc_size, skip_bs);
if (!desc) {
ret = -ENOMEM;
goto done;
}
 
-   efi_print_mem_table(desc, map->desc_size, skip_bs);
+   efi_print_mem_table(desc, desc_size, skip_bs);
free(desc);
+   if (IS_ENABLED(CONFIG_EFI_APP))
+   free(orig);
 done:
if (ret)
printf("Error: %d\n", ret);
diff --git a/include/efi.h b/include/efi.h
index d6d73c5fab4..bd23a867136 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -610,4 +610,19 @@ int efi_store_memory_map(struct efi_priv *priv);
  */
 int efi_call_exit_boot_services(void);
 
+/**
+ * efi_get_mmap() - Get the memory map from EFI
+ *
+ * This is used in the app. The caller must free *@descp when done
+ *
+ * @descp: Returns allocated pointer to EFI memory map table
+ * @sizep: Returns size of table in bytes
+ * @keyp:  Returns memory-map key
+ * @desc_sizep:Returns size of each @desc_base record
+ * @versionp:  Returns version number of memory map
+ * @return 0 on success, -ve on error
+ */
+int efi_get_mmap(struct efi_mem_desc **descp, int *sizep, uint *keyp,
+int *desc_sizep, uint *versionp);
+
 #endif /* _LINUX_EFI_H */
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index b2d2de1dc3a..d798bf98ca6 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -32,6 +32,39 @@ int efi_info_get(enum efi_entry_t type, void **datap, int 
*sizep)
return -ENOSYS;
 }
 
+int efi_get_mmap(struct efi_mem_

[PATCH v6 25/27] x86: efi: Don't use the 64-bit link script for the EFI app

2021-12-17 Thread Simon Glass
That script is not intended for use with EFI, so update the logic to avoid
using it.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to avoid using the 64-bit link script for the EFI app

 arch/x86/cpu/config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/cpu/config.mk b/arch/x86/cpu/config.mk
index d3033b41603..87e242a2065 100644
--- a/arch/x86/cpu/config.mk
+++ b/arch/x86/cpu/config.mk
@@ -9,7 +9,7 @@ LDPPFLAGS += -DRESET_VEC_LOC=$(CONFIG_RESET_VEC_LOC)
 LDPPFLAGS += -DSTART_16=$(CONFIG_SYS_X86_START16)
 
 ifdef CONFIG_X86_64
-ifndef CONFIG_SPL_BUILD
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_EFI_APP),)
 LDSCRIPT = $(srctree)/arch/x86/cpu/u-boot-64.lds
 endif
 endif
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 27/27] efi: Build the 64-bit app properly

2021-12-17 Thread Simon Glass
Now that the linker crash is resolved, build the 64-bit EFI app, including
all the required code.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to build the 64-bit app properly
- Add various patches to fix up the 64-bit app so that it boots

Changes in v2:
- Add new patch to support the efi command in the app

 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 18fe6fdb440..83f2e04c225 100644
--- a/Makefile
+++ b/Makefile
@@ -1772,9 +1772,9 @@ else
 quiet_cmd_u-boot__ ?= LD  $@
   cmd_u-boot__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@  
\
-T u-boot.lds $(u-boot-init)
\
-   $(if $(CONFIG_EFI_APP_64BIT),,--whole-archive)  
\
+   --whole-archive 
\
$(u-boot-main)  
\
-   $(if $(CONFIG_EFI_APP_64BIT),,--no-whole-archive)   
\
+   --no-whole-archive  
\
$(PLATFORM_LIBS) -Map u-boot.map;   
\
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
 endif
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 26/27] x86: efi: Set the correct link flags for the 64-bit EFI app

2021-12-17 Thread Simon Glass
At present some 32-bit settings are used with the 64-bit app. Fix this by
separating out the two cases.

Be careful not to break the 64-bit payload, which needs to build a 64-bit
EFI stub with a 32-bit U-Boot.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to set the correct link flags for the 64-bit EFI app

 arch/x86/config.mk | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index 589f2aed2bc..889497b6bd7 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -20,6 +20,11 @@ IS_32BIT := y
 endif
 endif
 
+EFI_IS_32BIT := $(IS_32BIT)
+ifdef CONFIG_EFI_STUB_64BIT
+EFI_IS_32BIT :=
+endif
+
 ifeq ($(IS_32BIT),y)
 PLATFORM_CPPFLAGS += -march=i386 -m32
 else
@@ -44,8 +49,14 @@ CFLAGS_EFI := -fpic -fshort-wchar
 # Compiler flags to be removed when building UEFI applications
 CFLAGS_NON_EFI := -mregparm=3 -fstack-protector-strong
 
-ifeq ($(CONFIG_EFI_STUB_64BIT),)
+ifeq ($(IS_32BIT),y)
+EFIPAYLOAD_BFDARCH = i386
+else
 CFLAGS_EFI += $(call cc-option, -mno-red-zone)
+EFIPAYLOAD_BFDARCH = x86_64
+endif
+
+ifeq ($(EFI_IS_32BIT),y)
 EFIARCH = ia32
 EFIPAYLOAD_BFDTARGET = elf32-i386
 else
@@ -53,8 +64,6 @@ EFIARCH = x86_64
 EFIPAYLOAD_BFDTARGET = elf64-x86-64
 endif
 
-EFIPAYLOAD_BFDARCH = i386
-
 LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds
 EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o
 OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 23/27] x86: efi: Tweak the code used for the 64-bit EFI app

2021-12-17 Thread Simon Glass
Add an empty CPU init function to avoid fiddling with low-level CPU
features in the app. Set up the C runtime correctly for 64-bit use
and avoid clearing BSS, since this is done by EFI when U-Boot is loaded.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to tweak the code used for the 64-bit EFI app

 arch/x86/cpu/x86_64/cpu.c | 5 +
 arch/x86/lib/Makefile | 5 ++---
 arch/x86/lib/relocate.c   | 2 ++
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c
index a3674e8e29a..6a387612916 100644
--- a/arch/x86/cpu/x86_64/cpu.c
+++ b/arch/x86/cpu/x86_64/cpu.c
@@ -45,3 +45,8 @@ int cpu_phys_address_size(void)
 {
return CONFIG_CPU_ADDR_BITS;
 }
+
+int x86_cpu_init_f(void)
+{
+   return 0;
+}
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 18757b29aa9..e5235b7c4f4 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -65,9 +65,8 @@ endif
 
 lib-$(CONFIG_USE_PRIVATE_LIBGCC) += div64.o
 
-ifeq ($(CONFIG_$(SPL_)X86_64),)
-obj-$(CONFIG_EFI_APP) += crt0_ia32_efi.o reloc_ia32_efi.o
-endif
+obj-$(CONFIG_EFI_APP_32BIT) += crt0_ia32_efi.o reloc_ia32_efi.o
+obj-$(CONFIG_EFI_APP_64BIT) += crt0_x86_64_efi.o reloc_x86_64_efi.o
 
 ifneq ($(CONFIG_EFI_STUB),)
 
diff --git a/arch/x86/lib/relocate.c b/arch/x86/lib/relocate.c
index 6fe51516477..9060d19d46a 100644
--- a/arch/x86/lib/relocate.c
+++ b/arch/x86/lib/relocate.c
@@ -35,6 +35,7 @@ int copy_uboot_to_ram(void)
return 0;
 }
 
+#ifndef CONFIG_EFI_APP
 int clear_bss(void)
 {
ulong dst_addr = (ulong)&__bss_start + gd->reloc_off;
@@ -46,6 +47,7 @@ int clear_bss(void)
 
return 0;
 }
+#endif
 
 #if CONFIG_IS_ENABLED(X86_64)
 static void do_elf_reloc_fixups64(unsigned int text_base, uintptr_t size,
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 24/27] x86: efi: Round out the link script for 64-bit EFI

2021-12-17 Thread Simon Glass
Make sure the linker lists are in the right place and drop the eh_frame
section, which is not needed.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to round out the link script for 64-bit EFI

 arch/x86/lib/elf_x86_64_efi.lds | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/lib/elf_x86_64_efi.lds b/arch/x86/lib/elf_x86_64_efi.lds
index b436429b33e..75727400aa4 100644
--- a/arch/x86/lib/elf_x86_64_efi.lds
+++ b/arch/x86/lib/elf_x86_64_efi.lds
@@ -63,6 +63,7 @@ SECTIONS
*(.rela.data*)
*(.rela.got)
*(.rela.stab)
+*(.rela.u_boot_list*)
}
 
. = ALIGN(4096);
@@ -70,9 +71,11 @@ SECTIONS
. = ALIGN(4096);
.dynstr : { *(.dynstr) }
. = ALIGN(4096);
+
+/DISCARD/ : { *(.eh_frame) }
+
.ignored.reloc : {
*(.rela.reloc)
-   *(.eh_frame)
*(.note.GNU-stack)
}
 
-- 
2.34.1.173.g76aa8bc2d0-goog



Please pull u-boot-dm/next

2021-12-17 Thread Simon Glass
Hi Tom,

This is for the -next branch.

https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/10299

The following changes since commit b9c9ce8a4064c8d88f714604db856cf1cd2b40b5:

  Merge tag 'u-boot-at91-2022.04-a' of
https://source.denx.de/u-boot/custodians/u-boot-at91 into next (2021-12-17
07:25:34 -0500)

are available in the Git repository at:

  git://git.denx.de/u-boot-dm.git tags/dm-pull-17dec21

for you to fetch changes up to 121cfe5a84d463893bd01da16417ab138f98666a:

  fdtgrep: Handle an empty output tree (2021-12-17 09:44:59 -0700)


binman support for ATF FIP
fdtgrep fixes for empty devicetree


Andy Shevchenko (2):
  binman: Do not pollute source tree when build with `make O=...`
  binman: Use less hard coded magic when inserting new PATH

Ivan Mikhaylov (1):
  iot2050: binman: add missing-msg for blobs

Simon Glass (5):
  binman: Add a utility module for ATF FIP
  binman: Add support for ATF FIP
  Convert CONFIG_PHYSMEM to Kconfig
  fdtgrep: Correct alignment of struct section
  fdtgrep: Handle an empty output tree

 README   |   8 -
 arch/Kconfig |   2 +
 arch/arm/dts/k3-am65-iot2050-boot-image.dtsi |   5 +
 boot/fdt_region.c|  43 ++-
 include/configs/edison.h |   3 -
 include/configs/sandbox.h|   2 -
 include/configs/x86-common.h |   2 -
 include/fdt_region.h |   1 +
 lib/Kconfig  |  10 +
 scripts/config_whitelist.txt |   1 -
 tools/binman/entries.rst | 154 +++
 tools/binman/etype/atf_fip.py| 273 +++
 tools/binman/fip_util.py | 653
++
 tools/binman/fip_util_test.py| 405

 tools/binman/ftest.py| 217 +++
 tools/binman/main.py |  27 +-
 tools/binman/missing-blob-help   |  11 +
 tools/binman/test/203_fip.dts|  21 ++
 tools/binman/test/204_fip_other.dts  |  22 ++
 tools/binman/test/205_fip_no_type.dts|  15 ++
 tools/binman/test/206_fip_uuid.dts   |  22 ++
 tools/binman/test/207_fip_ls.dts |  25 ++
 tools/binman/test/208_fip_replace.dts|  33 +++
 tools/binman/test/209_fip_missing.dts|  19 ++
 tools/binman/test/210_fip_size.dts   |  19 ++
 tools/binman/test/211_fip_bad_align.dts  |  18 ++
 tools/binman/test/212_fip_collection.dts |  24 ++
 tools/fdtgrep.c  |   3 +-
 28 files changed, 2008 insertions(+), 30 deletions(-)
 create mode 100644 tools/binman/etype/atf_fip.py
 create mode 100755 tools/binman/fip_util.py
 create mode 100755 tools/binman/fip_util_test.py
 create mode 100644 tools/binman/test/203_fip.dts
 create mode 100644 tools/binman/test/204_fip_other.dts
 create mode 100644 tools/binman/test/205_fip_no_type.dts
 create mode 100644 tools/binman/test/206_fip_uuid.dts
 create mode 100644 tools/binman/test/207_fip_ls.dts
 create mode 100644 tools/binman/test/208_fip_replace.dts
 create mode 100644 tools/binman/test/209_fip_missing.dts
 create mode 100644 tools/binman/test/210_fip_size.dts
 create mode 100644 tools/binman/test/211_fip_bad_align.dts
 create mode 100644 tools/binman/test/212_fip_collection.dts

Regards,
Simon


[PATCH] arm: rmobile: rzg2_beacon: Migrate reset to SYSRESET_PSCI

2021-12-17 Thread Adam Ford
Instead of a custom cpu_reset function, use the sysreset_psci
instead to reduce redundant code clutter.

Signed-off-by: Adam Ford 

diff --git a/board/beacon/beacon-rzg2m/beacon-rzg2m.c 
b/board/beacon/beacon-rzg2m/beacon-rzg2m.c
index df6044a429..4b41c6fdaa 100644
--- a/board/beacon/beacon-rzg2m/beacon-rzg2m.c
+++ b/board/beacon/beacon-rzg2m/beacon-rzg2m.c
@@ -6,7 +6,6 @@
 #include 
 #include 
 #include 
-#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -18,15 +17,6 @@ int board_init(void)
return 0;
 }
 
-#define RST_BASE   0xE616
-#define RST_CA57RESCNT (RST_BASE + 0x40)
-#define RST_CODE   0xA5A5000F
-
-void reset_cpu(void)
-{
-   writel(RST_CODE, RST_CA57RESCNT);
-}
-
 #if IS_ENABLED(CONFIG_MULTI_DTB_FIT)
 int board_fit_config_name_match(const char *name)
 {
diff --git a/configs/rzg2_beacon_defconfig b/configs/rzg2_beacon_defconfig
index 6c48c3b8c9..55d4982721 100644
--- a/configs/rzg2_beacon_defconfig
+++ b/configs/rzg2_beacon_defconfig
@@ -70,6 +70,8 @@ CONFIG_SCIF_CONSOLE=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_RENESAS_RPC_SPI=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_PSCI=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
-- 
2.32.0



[PATCH v6 21/27] x86: efi: Show the system-table revision

2021-12-17 Thread Simon Glass
Show the revision of this table as it can be important.

Also update the 'efi table' entry to show the actual address of the EFI
table rather than our table that points to it. This saves a step and the
intermediate table has nothing else in it.

Signed-off-by: Simon Glass 
---

Changes in v6:
- Fix Alo typo in commit message

Changes in v5:
- Fix grammar in commit message

Changes in v3:
- Add new patch to show the system-table revision

 arch/x86/cpu/efi/payload.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/x86/cpu/efi/payload.c b/arch/x86/cpu/efi/payload.c
index d2aa889a2b9..b7778565b19 100644
--- a/arch/x86/cpu/efi/payload.c
+++ b/arch/x86/cpu/efi/payload.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -296,8 +297,14 @@ void setup_efi_info(struct efi_info *efi_info)
 void efi_show_bdinfo(void)
 {
struct efi_entry_systable *table = NULL;
+   struct efi_system_table *sys_table;
int size, ret;
 
ret = efi_info_get(EFIET_SYS_TABLE, (void **)&table, &size);
-   bdinfo_print_num_l("efi_table", (ulong)table);
+   if (!ret) {
+   bdinfo_print_num_l("efi_table", table->sys_table);
+   sys_table = (struct efi_system_table *)(uintptr_t)
+   table->sys_table;
+   bdinfo_print_num_l(" revision", sys_table->fw_revision);
+   }
 }
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v11] driver: spi: add bcm iproc qspi support

2021-12-17 Thread Roman Bacik
From: Rayagonda Kokatanur 

IPROC qspi driver supports both BSPI and MSPI modes.

Signed-off-by: Rayagonda Kokatanur 
Signed-off-by: Bharat Gooty 
Acked-by: Rayagonda Kokatanur 

Signed-off-by: Roman Bacik 
---

Changes in v11:
- fix condition for readl_poll_timeout in bspi_read_via_raf

Changes in v10:
- remove binding document
- use defined values for delays and timeouts
- replace timer-based logic with readl_poll_timeout
- format selected commands to single line
- remove unnecessary entries from struct bcmspi_priv
- simplify and move bspi strap override to bspi_set_flex_mode

Changes in v9:
- merge bspi_set_4byte_mode to bspi_set_flex_mode
- simplify bspi_set_flex_mode using data from spi_mem_op
- rename mode_4byte to bspi_4byte
- use BIT(x) istead of 1cmd.opcode for BSPI_CMD_AND_MODE_BYTE_REG
- move iproc_qspi.c to spi

Changes in v4:
- move iproc_qspi.c from spi to mtd/spi
- remove iproc_qspi.h
- rename IPROC_QSPI to SPI_FLASH_IPROC

Changes in v3:
- fix warning by including linux/delay.h
- change ofdata_to_platdata to of_to_plat
- change priv_auto_alloc_size to priv_auto

Changes in v2:
- remove include spi-nor.h
- define and use named BITs for writing register values
- remove bspi_set_4byte_mode() method

 drivers/spi/Kconfig  |   6 +
 drivers/spi/Makefile |   1 +
 drivers/spi/iproc_qspi.c | 573 +++
 3 files changed, 580 insertions(+)
 create mode 100644 drivers/spi/iproc_qspi.c

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index d07e9a28af82..faebc212753e 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -178,6 +178,12 @@ config ICH_SPI
  access the SPI NOR flash on platforms embedding this Intel
  ICH IP core.
 
+config IPROC_QSPI
+   bool "Broadcom iProc QSPI Flash Controller driver"
+   help
+ Enable Broadcom iProc QSPI Flash Controller driver.
+ This driver can be used to access the SPI NOR flash.
+
 config KIRKWOOD_SPI
bool "Marvell Kirkwood SPI Driver"
help
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index d2f24bccefd3..869763187062 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
 obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
 obj-$(CONFIG_SYNQUACER_SPI) += spi-synquacer.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
+obj-$(CONFIG_IPROC_QSPI) += iproc_qspi.o
 obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_MESON_SPIFC) += meson_spifc.o
 obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
diff --git a/drivers/spi/iproc_qspi.c b/drivers/spi/iproc_qspi.c
new file mode 100644
index ..0f9c2f9729c4
--- /dev/null
+++ b/drivers/spi/iproc_qspi.c
@@ -0,0 +1,573 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2020-2021 Broadcom
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Delay required to change the mode of operation */
+#define BUSY_DELAY_US  1
+#define BUSY_TIMEOUT_US20
+#define DWORD_ALIGNED(a)   (!(((ulong)(a)) & 3))
+
+/* Chip attributes */
+#define QSPI_AXI_CLK   17500
+#define SPBR_MIN   8U
+#define SPBR_MAX   255U
+#define NUM_CDRAM  16U
+
+#define CDRAM_PCS0 2
+#define CDRAM_CONT BIT(7)
+#define CDRAM_BITS_EN  BIT(6)
+#define CDRAM_QUAD_MODEBIT(8)
+#define CDRAM_RBIT_INPUT   BIT(10)
+#define MSPI_SPE   BIT(6)
+#define MSPI_CONT_AFTER_CMDBIT(7)
+
+/* Register fields */
+#define MSPI_SPCR0_MSB_BITS_8  0x0020
+#define BSPI_RAF_CONTROL_START_MASK0x0001
+#define BSPI_RAF_STATUS_SESSION_BUSY_MASK  0x0001
+#define BSPI_RAF_STATUS_FIFO_EMPTY_MASK0x0002
+#define BSPI_STRAP_OVERRIDE_DATA_QUAD_SHIFT3
+#define BSPI_STRAP_OVERRIDE_4BYTE_SHIFT2
+#define BSPI_STRAP_OVERRIDE_DATA_DUAL_SHIFT1
+#define BSPI_STRAP_OVERRIDE_SHIFT  0
+#define BSPI_BPC_DATA_SHIFT0
+#define BSPI_BPC_MODE_SHIFT8
+#define BSPI_BPC_ADDR_SHIFT16
+#define BSPI_BPC_CMD_SHIFT 24
+#define BSPI_BPP_ADDR_SHIFT16
+
+/* MSPI registers */
+#define MSPI_SPCR0_LSB_REG 0x000
+#define MSPI_SPCR0_MSB_REG 0x004
+#define MSPI_SPCR1_LSB_REG 0x008
+#define MSPI_SPCR1_MSB_REG 0x00c
+#define MSPI_NEWQP_REG 0x010
+#define MSPI_ENDQP_REG 0x014
+#define MSPI_SPCR2_REG 

Timer migration to driver model

2021-12-17 Thread Simon Glass
Hi,

I've sent a patch to set a deadline for migration to CONFIG_TIMER,
i.e. using driver model for timers. This catches quite a lot of
boards, so please take a look.

Regards,
Simon


[PATCH v1 0/5] Move board specific files to board directory

2021-12-17 Thread Troy Kisky
This series intends to let board specific files live in the boards
directory. The last patch moves files for nitrogen6x.
I have tested it with buildman

./tools/buildman/buildman boundary -b denx_master

But it is likely the more scripts then just tools/genboardscfg.py would
need to be updated.

Troy Kisky (5):
  kconfig: allow defconfigs to live in board directory
  dts: allow dts files in board directory
  scripts: Makefile.autoconf: allow CONFIG_SYS_CONFIG_NAME file to live
in board directory
  genboardcfg: allow defconfigs in board directory
  nitrogen6x: move board specific files to nitrogen6x directory

 arch/arm/dts/Makefile |  3 --
 board/boundary/nitrogen6x/MAINTAINERS | 13 ---
 board/boundary/nitrogen6x/Makefile| 13 +++
 .../nitrogen6x}/imx6dl-nitrogen6x.dts |  0
 .../boundary/nitrogen6x}/imx6q-nitrogen6x.dts |  0
 .../boundary/nitrogen6x}/imx6q-sabrelite.dts  |  0
 .../nitrogen6x}/imx6qdl-nitrogen6x.dtsi   |  0
 .../nitrogen6x}/imx6qdl-sabrelite.dtsi|  0
 .../nitrogen6x}/mx6qsabrelite_defconfig   |  0
 .../nitrogen6x}/nitrogen6dl2g_defconfig   |  0
 .../nitrogen6x}/nitrogen6dl_defconfig |  0
 .../nitrogen6x}/nitrogen6q2g_defconfig|  0
 .../boundary/nitrogen6x}/nitrogen6q_defconfig |  0
 .../nitrogen6x}/nitrogen6s1g_defconfig|  0
 .../boundary/nitrogen6x}/nitrogen6s_defconfig |  0
 .../boundary/nitrogen6x}/nitrogen6x.h |  2 +-
 dts/Makefile  | 11 +-
 scripts/Makefile.autoconf |  9 -
 scripts/Makefile.lib  |  1 +
 scripts/kconfig/Makefile  |  9 -
 tools/genboardscfg.py | 37 ++-
 21 files changed, 75 insertions(+), 23 deletions(-)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6dl-nitrogen6x.dts (100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6q-nitrogen6x.dts (100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6q-sabrelite.dts (100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6qdl-nitrogen6x.dtsi 
(100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6qdl-sabrelite.dtsi 
(100%)
 rename {configs => board/boundary/nitrogen6x}/mx6qsabrelite_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6dl2g_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6dl_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6q2g_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6q_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6s1g_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6s_defconfig (100%)
 rename {include/configs => board/boundary/nitrogen6x}/nitrogen6x.h (98%)

-- 
2.32.0



[PATCH v1 1/5] kconfig: allow defconfigs to live in board directory

2021-12-17 Thread Troy Kisky
This will reduce the size of the configs directory, and
make it more clear which board directory uses the defconfig
file.

Signed-off-by: Troy Kisky 
---
 scripts/kconfig/Makefile | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 12e525ee31f..307262e00de 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -92,8 +92,15 @@ else
 endif
 endif
 
+%_defconfig: SHELL:=/bin/bash
 %_defconfig: $(obj)/conf
-   $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
+   $(Q)readarray -d '' names < <(find $(srctree)/configs $(srctree)/board 
-type f -name $@ -print0); \
+   if (test $${#names[*]} -eq 1); then \
+   $< $(silent) --defconfig="$${names[0]}" $(Kconfig); \
+   else \
+   echo "$@" not found or ambiguous error; \
+   echo "$${names[@]}"; exit 1; \
+   fi
 
 # Added for U-Boot (backward compatibility)
 %_config: %_defconfig
-- 
2.32.0



[PATCH v1 3/5] scripts: Makefile.autoconf: allow CONFIG_SYS_CONFIG_NAME file to live in board directory

2021-12-17 Thread Troy Kisky
Let the board specific include file live in the board directory.

Signed-off-by: Troy Kisky 
---
 scripts/Makefile.autoconf | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf
index 8a3efdb2db0..6a725a3e2ff 100644
--- a/scripts/Makefile.autoconf
+++ b/scripts/Makefile.autoconf
@@ -103,9 +103,14 @@ define filechk_config_h
echo \#define CONFIG_$$i\
| sed '/=/ {s/=//;q; } ; { s/$$/1/; }'; \
done;   \
-   echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\
+   config_boarddir=board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);   \
+   echo \#define CONFIG_BOARDDIR $$config_boarddir;\
echo \#include \;  \
-   echo \#include \; \
+   if [ -f $(srctree)/$$config_boarddir/$(CONFIG_SYS_CONFIG_NAME).h ] ; 
then   \
+   echo \#include 
\"../$$config_boarddir/$(CONFIG_SYS_CONFIG_NAME).h\"; \
+   else\
+   echo \#include \; \
+   fi; \
echo \#include \;\
echo \#include \; \
echo \#include \;)
-- 
2.32.0



[PATCH v1 5/5] nitrogen6x: move board specific files to nitrogen6x directory

2021-12-17 Thread Troy Kisky
This makes it clearer which board uses a file.

Signed-off-by: Troy Kisky 
---
 arch/arm/dts/Makefile   |  3 ---
 board/boundary/nitrogen6x/MAINTAINERS   | 13 -
 board/boundary/nitrogen6x/Makefile  | 13 +
 .../boundary/nitrogen6x}/imx6dl-nitrogen6x.dts  |  0
 .../boundary/nitrogen6x}/imx6q-nitrogen6x.dts   |  0
 .../boundary/nitrogen6x}/imx6q-sabrelite.dts|  0
 .../boundary/nitrogen6x}/imx6qdl-nitrogen6x.dtsi|  0
 .../boundary/nitrogen6x}/imx6qdl-sabrelite.dtsi |  0
 .../boundary/nitrogen6x}/mx6qsabrelite_defconfig|  0
 .../boundary/nitrogen6x}/nitrogen6dl2g_defconfig|  0
 .../boundary/nitrogen6x}/nitrogen6dl_defconfig  |  0
 .../boundary/nitrogen6x}/nitrogen6q2g_defconfig |  0
 .../boundary/nitrogen6x}/nitrogen6q_defconfig   |  0
 .../boundary/nitrogen6x}/nitrogen6s1g_defconfig |  0
 .../boundary/nitrogen6x}/nitrogen6s_defconfig   |  0
 .../boundary/nitrogen6x}/nitrogen6x.h   |  2 +-
 16 files changed, 14 insertions(+), 17 deletions(-)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6dl-nitrogen6x.dts (100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6q-nitrogen6x.dts (100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6q-sabrelite.dts (100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6qdl-nitrogen6x.dtsi 
(100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6qdl-sabrelite.dtsi 
(100%)
 rename {configs => board/boundary/nitrogen6x}/mx6qsabrelite_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6dl2g_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6dl_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6q2g_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6q_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6s1g_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6s_defconfig (100%)
 rename {include/configs => board/boundary/nitrogen6x}/nitrogen6x.h (98%)

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 7f622fedbda..a864a6dd4b8 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -744,7 +744,6 @@ dtb-y += \
imx6dl-mba6a.dtb \
imx6dl-mba6b.dtb \
imx6dl-mamoj.dtb \
-   imx6dl-nitrogen6x.dtb \
imx6dl-pico.dtb \
imx6dl-udoo.dtb \
imx6dl-riotboard.dtb \
@@ -792,13 +791,11 @@ dtb-y += \
imx6q-mba6a.dtb \
imx6q-mba6b.dtb \
imx6q-mccmon6.dtb\
-   imx6q-nitrogen6x.dtb \
imx6q-novena.dtb \
imx6q-pico.dtb \
imx6q-phytec-mira-rdk-nand.dtb \
imx6q-udoo.dtb \
imx6q-sabreauto.dtb \
-   imx6q-sabrelite.dtb \
imx6q-sabresd.dtb \
imx6q-tbs2910.dtb \
imx6q-wandboard-revd1.dtb \
diff --git a/board/boundary/nitrogen6x/MAINTAINERS 
b/board/boundary/nitrogen6x/MAINTAINERS
index 17018d69f64..b11bc1f20d1 100644
--- a/board/boundary/nitrogen6x/MAINTAINERS
+++ b/board/boundary/nitrogen6x/MAINTAINERS
@@ -1,17 +1,4 @@
 NITROGEN6X BOARD
 M: Troy Kisky 
 S: Maintained
-F: arch/arm/dts/imx6dl-nitrogen6x.dts
-F: arch/arm/dts/imx6q-nitrogen6x.dts
-F: arch/arm/dts/imx6q-sabrelite.dts
-F: arch/arm/dts/imx6qdl-nitrogen6x.dtsi
-F: arch/arm/dts/imx6qdl-sabrelite.dtsi
 F: board/boundary/nitrogen6x/
-F: include/configs/nitrogen6x.h
-F: configs/mx6qsabrelite_defconfig
-F: configs/nitrogen6dl_defconfig
-F: configs/nitrogen6dl2g_defconfig
-F: configs/nitrogen6q_defconfig
-F: configs/nitrogen6q2g_defconfig
-F: configs/nitrogen6s_defconfig
-F: configs/nitrogen6s1g_defconfig
diff --git a/board/boundary/nitrogen6x/Makefile 
b/board/boundary/nitrogen6x/Makefile
index c8433bd7488..dd627411fa9 100644
--- a/board/boundary/nitrogen6x/Makefile
+++ b/board/boundary/nitrogen6x/Makefile
@@ -5,3 +5,16 @@
 # Copyright (C) 2013, Boundary Devices 
 
 obj-y  := nitrogen6x.o
+
+dtb-y += imx6dl-nitrogen6x.dtb \
+   imx6q-nitrogen6x.dtb \
+   imx6q-sabrelite.dtb \
+
+# Add any required device tree compiler flags here
+DTC_FLAGS += -a 0x8
+
+PHONY += dtbs
+dtbs: $(addprefix $(obj)/, $(dtb-y))
+   @:
+
+clean-files := $(dtb-y)
diff --git a/arch/arm/dts/imx6dl-nitrogen6x.dts 
b/board/boundary/nitrogen6x/imx6dl-nitrogen6x.dts
similarity index 100%
rename from arch/arm/dts/imx6dl-nitrogen6x.dts
rename to board/boundary/nitrogen6x/imx6dl-nitrogen6x.dts
diff --git a/arch/arm/dts/imx6q-nitrogen6x.dts 
b/board/boundary/nitrogen6x/imx6q-nitrogen6x.dts
similarity index 100%
rename from arch/arm/dts/imx6q-nitrogen6x.dts
rename to board/boundary/nitrogen6x/imx6q-nitrogen6x.dts
diff --git a/arch/arm/dts/imx6q-sabrelite.dts 
b/board/boundary/nitrogen6x/imx6q-sabrelite.dts
similarity index 100%
rename from arch/arm/dts/imx6q-sabrelite.dts
rename to board/boundary/nitrogen6x/imx6q-sabrelite.dts
diff --git a/arch/arm/d

[PATCH v1 4/5] genboardcfg: allow defconfigs in board directory

2021-12-17 Thread Troy Kisky
The adds boards whose defconfigs are in the board's directory.

Signed-off-by: Troy Kisky 
---
 tools/genboardscfg.py | 37 -
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/tools/genboardscfg.py b/tools/genboardscfg.py
index 4ee7aa1f891..60e2fe5cf3e 100755
--- a/tools/genboardscfg.py
+++ b/tools/genboardscfg.py
@@ -37,6 +37,13 @@ COMMENT_BLOCK = '''#
 ''' % __file__
 
 ### helper functions ###
+def find_defconfig_in_board_subdir(f):
+for (dirpath, dirnames, filenames) in os.walk('board'):
+for filename in filenames:
+if filename == f:
+return True
+return False
+
 def try_remove(f):
 """Remove a file ignoring 'No such file or directory' error."""
 try:
@@ -76,6 +83,14 @@ def output_is_new(output):
 if ctime < os.path.getctime(filepath):
 return False
 
+for (dirpath, dirnames, filenames) in os.walk('board'):
+for filename in fnmatch.filter(filenames, '*'):
+if fnmatch.fnmatch(filename, '.*'):
+continue
+filepath = os.path.join(dirpath, filename)
+if ctime < os.path.getctime(filepath):
+return False
+
 for (dirpath, dirnames, filenames) in os.walk('.'):
 for filename in filenames:
 if (fnmatch.fnmatch(filename, '*~') or
@@ -94,7 +109,8 @@ def output_is_new(output):
 continue
 defconfig = line.split()[6] + '_defconfig'
 if not os.path.exists(os.path.join(CONFIG_DIR, defconfig)):
-return False
+if not find_defconfig_in_board_subdir(defconfig):
+return False
 
 return True
 
@@ -231,6 +247,12 @@ def scan_defconfigs(jobs=1):
 continue
 all_defconfigs.append(os.path.join(dirpath, filename))
 
+for (dirpath, dirnames, filenames) in os.walk('board'):
+for filename in fnmatch.filter(filenames, '*_defconfig'):
+if fnmatch.fnmatch(filename, '.*'):
+continue
+all_defconfigs.append(os.path.join(dirpath, filename))
+
 total_boards = len(all_defconfigs)
 processes = []
 queues = []
@@ -346,6 +368,19 @@ class MaintainersDatabase:
 targets = []
 maintainers = []
 status = '-'
+
+front, match, rear = file.partition('board/')
+if match:
+front, match, rear = file.partition('/MAINTAINERS')
+if front:
+for (dirpath, dirnames, filenames) in os.walk(front):
+for filename in fnmatch.filter(filenames, '*_defconfig'):
+if fnmatch.fnmatch(filename, '.*'):
+continue
+front, match, rear = filename.rpartition('_defconfig')
+if match and not rear:
+targets.append(front)
+
 if targets:
 for target in targets:
 self.database[target] = (status, maintainers)
-- 
2.32.0



[PATCH v1 2/5] dts: allow dts files in board directory

2021-12-17 Thread Troy Kisky
Let the board specific dts files live in the board directory.

Signed-off-by: Troy Kisky 
---
 dts/Makefile | 11 +--
 scripts/Makefile.lib |  1 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/dts/Makefile b/dts/Makefile
index cb311138295..09b46f9fcfd 100644
--- a/dts/Makefile
+++ b/dts/Makefile
@@ -13,7 +13,9 @@ endif
 ifneq ($(EXT_DTB),)
 DTB := $(EXT_DTB)
 else
-DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb
+ifneq "$(ARCH)" "arm64"
+DTB := $(patsubst $(srctree)/%.dts,%.dtb,$(shell find 
"$(srctree)/board/$(BOARDDIR)" $(srctree)/arch/$(ARCH)/dts/ -type f -name 
$(DEVICE_TREE).dts))
+endif
 endif
 
 $(obj)/dt-$(SPL_NAME).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE
@@ -40,8 +42,13 @@ $(DTB): arch-dtbs
/bin/false)
 
 PHONY += arch-dtbs
+ifneq "$(patsubst board/$(BOARDDIR)/%,,$(DTB))" ""
 arch-dtbs:
$(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbs
+else
+arch-dtbs:
+   $(Q)$(MAKE) $(build)="board/$(BOARDDIR)" dtbs
+endif
 
 ifeq ($(CONFIG_SPL_BUILD),y)
 obj-$(CONFIG_OF_EMBED) := dt-spl.dtb.o
@@ -63,4 +70,4 @@ spl_dtbs: $(obj)/dt-$(SPL_NAME).dtb
 clean-files := dt.dtb.S
 
 # Let clean descend into dts directories
-subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts 
../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts
+subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts 
../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts 
../$(patsubst $(srctree)/%/,%,$(dir $(shell find $(srctree)/board -type f -name 
"*.dtb")))
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 39f03398ed8..18fe42f378f 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -183,6 +183,7 @@ u_boot_dtsi = $(strip $(u_boot_dtsi_options_debug) \
 
 # Modified for U-Boot
 dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc\
+-I$(srctree)/board/$(BOARDDIR)  \
 -I$(srctree)/arch/$(ARCH)/dts   \
 -I$(srctree)/arch/$(ARCH)/dts/include   \
 -Iinclude   \
-- 
2.32.0



Re: [PATCH 2/2] fastboot: fb_mmc: Add mfgtool all partition size

2021-12-17 Thread Sean Anderson




On 12/17/21 10:42 AM, Angus Ainslie wrote:

NXP mfgtool uses all to specify the entire partition

Signed-off-by: Angus Ainslie 
---
  drivers/fastboot/fb_mmc.c | 7 +++
  1 file changed, 7 insertions(+)

diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 2738dc836e..9ebf392252 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -84,6 +84,13 @@ static int do_get_part_info(struct blk_desc **dev_desc, 
const char *name,
/* First try partition names on the default device */
*dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
if (*dev_desc) {
+   if (!strncmp(name, "all", strlen("all"))) {
+   info->blksz = (*dev_desc)->blksz;
+   info->size = (*dev_desc)->lba;
+   info->start = 0;
+   return 0;
+   }
+
ret = part_get_info_by_name(*dev_desc, name, info);
if (ret >= 0)
return ret;



This can be done with "partition" 0. If you need compatibility, use an alias.

--Sean


[PATCH 02/12] ppc: mpc83xx: Remove unused CONFIG symbols

2021-12-17 Thread Tom Rini
Neither of these symbols are referenced anywhere else, so remove them.

Signed-off-by: Tom Rini 
---
 arch/powerpc/cpu/mpc83xx/start.S | 2 --
 include/configs/km/km-mpc832x.h  | 5 -
 2 files changed, 7 deletions(-)

diff --git a/arch/powerpc/cpu/mpc83xx/start.S b/arch/powerpc/cpu/mpc83xx/start.S
index 91c8778e5033..0944d1910573 100644
--- a/arch/powerpc/cpu/mpc83xx/start.S
+++ b/arch/powerpc/cpu/mpc83xx/start.S
@@ -14,8 +14,6 @@
 #include 
 #include 
 
-#define CONFIG_83XX1   /* needed for Linux kernel header 
files*/
-
 #include 
 #include 
 
diff --git a/include/configs/km/km-mpc832x.h b/include/configs/km/km-mpc832x.h
index 54018daa68e6..aac1e999e40a 100644
--- a/include/configs/km/km-mpc832x.h
+++ b/include/configs/km/km-mpc832x.h
@@ -1,8 +1,3 @@
-/*
- * High Level Configuration Options
- */
-#define CONFIG_KM8321  /* Keymile PBEC8321 board specific */
-
 /*
  * System IO Config
  */
-- 
2.25.1



[PATCH 01/12] Convert CONFIG_83XX_PCICLK to Kconfig

2021-12-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_83XX_PCICLK

Signed-off-by: Tom Rini 
---
 arch/powerpc/cpu/mpc83xx/Kconfig | 7 +++
 configs/kmcoge5ne_defconfig  | 1 +
 configs/kmopti2_defconfig| 1 +
 configs/kmsupx5_defconfig| 1 +
 configs/kmtegr1_defconfig| 1 +
 configs/kmtepr2_defconfig| 1 +
 configs/tuge1_defconfig  | 1 +
 configs/tuxx1_defconfig  | 1 +
 include/configs/km/km-mpc8309.h  | 5 -
 include/configs/km/km-mpc832x.h  | 5 -
 include/configs/kmcoge5ne.h  | 5 -
 scripts/config_whitelist.txt | 1 -
 12 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/cpu/mpc83xx/Kconfig b/arch/powerpc/cpu/mpc83xx/Kconfig
index d58d278c6da8..bcd837508789 100644
--- a/arch/powerpc/cpu/mpc83xx/Kconfig
+++ b/arch/powerpc/cpu/mpc83xx/Kconfig
@@ -188,6 +188,13 @@ source "arch/powerpc/cpu/mpc83xx/sysio/Kconfig"
 source "arch/powerpc/cpu/mpc83xx/arbiter/Kconfig"
 source "arch/powerpc/cpu/mpc83xx/initreg/Kconfig"
 
+config 83XX_PCICLK
+   hex "PCI clock frequency"
+   default 0xDEADBEEF
+   help
+ If required, the PCI clock frequency to use when configuring
+ the host bridge.
+
 config FSL_ELBC
bool
 
diff --git a/configs/kmcoge5ne_defconfig b/configs/kmcoge5ne_defconfig
index 461f2e381224..53f7abc3fd09 100644
--- a/configs/kmcoge5ne_defconfig
+++ b/configs/kmcoge5ne_defconfig
@@ -156,6 +156,7 @@ CONFIG_ACR_PARKM_USB_I2C1_BOOT=y
 CONFIG_LCRR_DBYP_PLL_BYPASSED=y
 CONFIG_LCRR_EADC_2=y
 CONFIG_LCRR_CLKDIV_4=y
+CONFIG_83XX_PCICLK=0x3ef1480
 CONFIG_SYS_LOAD_ADDR=0x10
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
diff --git a/configs/kmopti2_defconfig b/configs/kmopti2_defconfig
index 01709052c1a2..d230638548b8 100644
--- a/configs/kmopti2_defconfig
+++ b/configs/kmopti2_defconfig
@@ -139,6 +139,7 @@ CONFIG_ACR_APARK_MASTER=y
 CONFIG_ACR_PARKM_USB_I2C1_BOOT=y
 CONFIG_LCRR_EADC_1=y
 CONFIG_LCRR_CLKDIV_2=y
+CONFIG_83XX_PCICLK=0x3ef1480
 CONFIG_SYS_LOAD_ADDR=0x10
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
diff --git a/configs/kmsupx5_defconfig b/configs/kmsupx5_defconfig
index 7802be8af4c8..b0b59262dec3 100644
--- a/configs/kmsupx5_defconfig
+++ b/configs/kmsupx5_defconfig
@@ -119,6 +119,7 @@ CONFIG_ACR_APARK_MASTER=y
 CONFIG_ACR_PARKM_USB_I2C1_BOOT=y
 CONFIG_LCRR_EADC_1=y
 CONFIG_LCRR_CLKDIV_2=y
+CONFIG_83XX_PCICLK=0x3ef1480
 CONFIG_SYS_LOAD_ADDR=0x10
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
diff --git a/configs/kmtegr1_defconfig b/configs/kmtegr1_defconfig
index e2bf945bc3dc..53aaf6caa25c 100644
--- a/configs/kmtegr1_defconfig
+++ b/configs/kmtegr1_defconfig
@@ -118,6 +118,7 @@ CONFIG_ACR_APARK_MASTER=y
 CONFIG_ACR_PARKM_USB_I2C1_BOOT=y
 CONFIG_LCRR_EADC_1=y
 CONFIG_LCRR_CLKDIV_2=y
+CONFIG_83XX_PCICLK=0x3ef1480
 CONFIG_SYS_LOAD_ADDR=0x10
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
diff --git a/configs/kmtepr2_defconfig b/configs/kmtepr2_defconfig
index 98f613ce16e3..b333769dc4f5 100644
--- a/configs/kmtepr2_defconfig
+++ b/configs/kmtepr2_defconfig
@@ -139,6 +139,7 @@ CONFIG_ACR_APARK_MASTER=y
 CONFIG_ACR_PARKM_USB_I2C1_BOOT=y
 CONFIG_LCRR_EADC_1=y
 CONFIG_LCRR_CLKDIV_2=y
+CONFIG_83XX_PCICLK=0x3ef1480
 CONFIG_SYS_LOAD_ADDR=0x10
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
diff --git a/configs/tuge1_defconfig b/configs/tuge1_defconfig
index 9272a0cb4214..6078b46410af 100644
--- a/configs/tuge1_defconfig
+++ b/configs/tuge1_defconfig
@@ -119,6 +119,7 @@ CONFIG_ACR_APARK_MASTER=y
 CONFIG_ACR_PARKM_USB_I2C1_BOOT=y
 CONFIG_LCRR_EADC_1=y
 CONFIG_LCRR_CLKDIV_2=y
+CONFIG_83XX_PCICLK=0x3ef1480
 CONFIG_SYS_LOAD_ADDR=0x10
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
diff --git a/configs/tuxx1_defconfig b/configs/tuxx1_defconfig
index 38875b39c12f..cc9bbab8c6bb 100644
--- a/configs/tuxx1_defconfig
+++ b/configs/tuxx1_defconfig
@@ -141,6 +141,7 @@ CONFIG_ACR_APARK_MASTER=y
 CONFIG_ACR_PARKM_USB_I2C1_BOOT=y
 CONFIG_LCRR_EADC_1=y
 CONFIG_LCRR_CLKDIV_2=y
+CONFIG_83XX_PCICLK=0x3ef1480
 CONFIG_SYS_LOAD_ADDR=0x10
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
diff --git a/include/configs/km/km-mpc8309.h b/include/configs/km/km-mpc8309.h
index 47a335bcf8ff..98204bd3c692 100644
--- a/include/configs/km/km-mpc8309.h
+++ b/include/configs/km/km-mpc8309.h
@@ -5,11 +5,6 @@
 
 #define CONFIG_KM_DEF_ARCH "arch=ppc_82xx\0"
 
-/*
- * System Clock Setup
- */
-#define CONFIG_83XX_PCICLK 6600
-
 /* QE microcode/firmware address */
 /* between the u-boot partition and env */
 
diff --git a/include/configs/km/km-mpc832x.h b/include/configs/km/km-mpc832x.h
index d985ab7a65a9..54018daa68e6 100644
--- a/include/configs/km/km-mpc832x.h
+++ b/include/configs/km/km-mpc832x.h
@@ -3,11 +3,6 @@
  */
 #define CONFIG_KM8321  /* Keymile PBEC8321 board specific */
 
-/*
- * System Clock Setup
- */
-#define CONFIG_83XX_PCICLK 6600
-
 /*
  * System IO Config
  */
diff --git a/include/configs/kmcoge5ne.h b

[PATCH 06/12] Convert CONFIG_CPU_SH7751 to Kconfig

2021-12-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_CPU_SH7751

Signed-off-by: Tom Rini 
---
 arch/sh/Kconfig  | 6 +-
 include/configs/r2dplus.h| 1 -
 scripts/config_whitelist.txt | 1 -
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 7836869c55dc..7e6cb7015896 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -4,13 +4,17 @@ menu "SuperH architecture"
 config CPU_SH4
bool
 
+config CPU_SH7751
+   bool
+   select CPU_SH4
+
 choice
prompt "Target select"
optional
 
 config TARGET_R2DPLUS
bool "Renesas R2D-PLUS"
-   select CPU_SH4
+   select CPU_SH7751
 
 endchoice
 
diff --git a/include/configs/r2dplus.h b/include/configs/r2dplus.h
index 680d16d547c4..8e86830e61be 100644
--- a/include/configs/r2dplus.h
+++ b/include/configs/r2dplus.h
@@ -1,7 +1,6 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
-#define CONFIG_CPU_SH7751  1
 #define __LITTLE_ENDIAN__  1
 
 /* SCIF */
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 2bc2d5b146bd..655eaab81812 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -163,7 +163,6 @@ CONFIG_CPU_MONAHANS
 CONFIG_CPU_PXA25X
 CONFIG_CPU_PXA26X
 CONFIG_CPU_PXA300
-CONFIG_CPU_SH7751
 CONFIG_CPU_TYPE_R
 CONFIG_CPU_VR41XX
 CONFIG_CQSPI_REF_CLK
-- 
2.25.1



[PATCH 03/12] Convert CONFIG_SYS_I2C_EEPROM_ADDR_LEN to Kconfig

2021-12-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_I2C_EEPROM_ADDR_LEN

Signed-off-by: Tom Rini 
---
 include/configs/km/km-mpc832x.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/configs/km/km-mpc832x.h b/include/configs/km/km-mpc832x.h
index aac1e999e40a..888bb2981f7b 100644
--- a/include/configs/km/km-mpc832x.h
+++ b/include/configs/km/km-mpc832x.h
@@ -58,6 +58,3 @@
 
 #define CONFIG_SYS_KMBEC_FPGA_BASE 0xE800
 #define CONFIG_SYS_KMBEC_FPGA_SIZE 128
-
-/* EEprom support */
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
-- 
2.25.1



[PATCH 05/12] Convert CONFIG_CPU_PXA27X to Kconfig

2021-12-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_CPU_PXA27X

Signed-off-by: Tom Rini 
---
 arch/arm/Kconfig | 6 +-
 include/configs/colibri_pxa270.h | 1 -
 scripts/config_whitelist.txt | 1 -
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 594aec2b92d7..4bfca750c27b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -311,6 +311,10 @@ config CPU_PXA
select SYS_CACHE_SHIFT_5
imply SYS_ARM_MMU
 
+config CPU_PXA27X
+   bool
+   select CPU_PXA
+
 config CPU_SA1100
bool
select SYS_CACHE_SHIFT_5
@@ -1765,7 +1769,7 @@ config TARGET_SL28
 
 config TARGET_COLIBRI_PXA270
bool "Support colibri_pxa270"
-   select CPU_PXA
+   select CPU_PXA27X
select GPIO_EXTRA_HEADER
 
 config ARCH_UNIPHIER
diff --git a/include/configs/colibri_pxa270.h b/include/configs/colibri_pxa270.h
index 22eab7779b01..0be7f5a416d0 100644
--- a/include/configs/colibri_pxa270.h
+++ b/include/configs/colibri_pxa270.h
@@ -12,7 +12,6 @@
 /*
  * High Level Board Configuration Options
  */
-#defineCONFIG_CPU_PXA27X   1   /* Marvell PXA270 CPU */
 /* Avoid overwriting factory configuration block */
 #define CONFIG_BOARD_SIZE_LIMIT0x4
 
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index a9bbd5078a87..2bc2d5b146bd 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -162,7 +162,6 @@ CONFIG_CPU_MIPSR2
 CONFIG_CPU_MONAHANS
 CONFIG_CPU_PXA25X
 CONFIG_CPU_PXA26X
-CONFIG_CPU_PXA27X
 CONFIG_CPU_PXA300
 CONFIG_CPU_SH7751
 CONFIG_CPU_TYPE_R
-- 
2.25.1



[PATCH 07/12] Convert CONFIG_CPU_FREQ_HZ to Kconfig

2021-12-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_CPU_FREQ_HZ

Cc: Michal Simek 
Signed-off-by: Tom Rini 
---
 arch/arm/mach-zynqmp-r5/Kconfig| 6 ++
 configs/xilinx_zynqmp_r5_defconfig | 1 +
 include/configs/xilinx_zynqmp_r5.h | 3 ---
 include/configs/zynq-common.h  | 5 -
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-zynqmp-r5/Kconfig b/arch/arm/mach-zynqmp-r5/Kconfig
index 5e0175413395..f14514b3c7c1 100644
--- a/arch/arm/mach-zynqmp-r5/Kconfig
+++ b/arch/arm/mach-zynqmp-r5/Kconfig
@@ -21,6 +21,12 @@ config SYS_CONFIG_NAME
  Based on this option include/configs/.h header
  will be used for board configuration.
 
+config CPU_FREQ_HZ
+   int "CPU frequency"
+   default 8
+   help
+ The value, in Hz, that the CPU clock is running at.
+
 config SYS_MALLOC_F_LEN
default 0x600
 
diff --git a/configs/xilinx_zynqmp_r5_defconfig 
b/configs/xilinx_zynqmp_r5_defconfig
index a9c3c4a03e81..98f46cf0205a 100644
--- a/configs/xilinx_zynqmp_r5_defconfig
+++ b/configs/xilinx_zynqmp_r5_defconfig
@@ -9,6 +9,7 @@ CONFIG_ENV_SIZE=0x2
 CONFIG_DEFAULT_DEVICE_TREE="zynqmp-r5"
 CONFIG_DEBUG_UART_BASE=0xff01
 CONFIG_DEBUG_UART_CLOCK=1
+CONFIG_CPU_FREQ_HZ=5
 CONFIG_DEBUG_UART=y
 CONFIG_SYS_LOAD_ADDR=0x0
 CONFIG_BOOTSTAGE=y
diff --git a/include/configs/xilinx_zynqmp_r5.h 
b/include/configs/xilinx_zynqmp_r5.h
index 6d5b81e05e16..3ec99e062df5 100644
--- a/include/configs/xilinx_zynqmp_r5.h
+++ b/include/configs/xilinx_zynqmp_r5.h
@@ -8,9 +8,6 @@
 
 #define CONFIG_EXTRA_ENV_SETTINGS
 
-/* CPU clock */
-#define CONFIG_CPU_FREQ_HZ 5
-
 /* Serial drivers */
 /* The following table includes the supported baudrates */
 #define CONFIG_SYS_BAUDRATE_TABLE  \
diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h
index 8f8a9c7479c3..88c6490d81cd 100644
--- a/include/configs/zynq-common.h
+++ b/include/configs/zynq-common.h
@@ -9,11 +9,6 @@
 #ifndef __CONFIG_ZYNQ_COMMON_H
 #define __CONFIG_ZYNQ_COMMON_H
 
-/* CPU clock */
-#ifndef CONFIG_CPU_FREQ_HZ
-# define CONFIG_CPU_FREQ_HZ8
-#endif
-
 #define CONFIG_REMAKE_ELF
 
 /* Cache options */
-- 
2.25.1



  1   2   >