Re: [PATCH v4 08/15] cmd: bmp: Split bmp commands and functions

2023-03-30 Thread Nikhil M Jain

Hi Simon,

On 31/03/23 01:44, Simon Glass wrote:

Hi Nikhil,

On Thu, 30 Mar 2023 at 01:02, Nikhil M Jain  wrote:


To enable splash screen at spl, need to compile cmd/bmp.c which also
includes bmp commands, since SPL can't have commands split bmp.c into
common/bmp.c which includes all bmp functions and cmd/bmp_cmd contains
bmp commands.

Add delclaration for bmp_info in video.h.

Signed-off-by: Nikhil M Jain 
---
V4:
- No change

V3 (patch introduced):
- Split bmp functions and commands

  cmd/bmp_cmd.c |  98 +++


Please can you keep this as cmd/bmp.c ?


I will keep cmd/bmp.c



  {cmd => common}/bmp.c | 104 +-
  include/video.h   |   7 +++
  3 files changed, 106 insertions(+), 103 deletions(-)
  create mode 100644 cmd/bmp_cmd.c
  rename {cmd => common}/bmp.c (62%)



Otherwise looks good

[..]

Regards,
SImon


Thanks,
Nikhil


Re: [PATCH v4 04/15] drivers: video: Makefile: Rule to compile necessary video driver files.

2023-03-30 Thread Nikhil M Jain

Hi Simon

On 31/03/23 01:44, Simon Glass wrote:

Hi Nikhil,

On Thu, 30 Mar 2023 at 01:01, Nikhil M Jain  wrote:


To enable video driver at SPL, need to compile video-uclass,
vidconsole-uclass, backlight-uclass, panel-uclass, simple-panel, add
rules to compile them at SPL only. To support splash_display at SPL,
need to compile video-bmp, add rule to compile at SPL stage only.

Signed-off-by: Nikhil M Jain 
---
V4:
- No change

V3:
- Rule to compile backlight, console and panel files
- Not added Reiewed-by tag due to changes

V2:
- No change

  drivers/video/Makefile | 9 +
  1 file changed, 9 insertions(+)

diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index cdb7d9a54d..2374b240c2 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -68,3 +68,12 @@ obj-$(CONFIG_VIDEO_ZYNQMP_DPSUB) += zynqmp_dpsub.o

  obj-y += bridge/
  obj-y += sunxi/
+
+ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_SPL_BACKLIGHT) += backlight-uclass.o
+obj-$(CONFIG_SPL_PANEL) += panel-uclass.o
+obj-$(CONFIG_SPL_SIMPLE_PANEL) += simple_panel.o
+obj-$(CONFIG_SPL_CONSOLE_NORMAL) += console_normal.o
+obj-$(CONFIG_SPL_VIDEO) += video-uclass.o vidconsole-uclass.o
+obj-$(CONFIG_SPL_VIDEO) += video_bmp.o


Can you use

obj-$(CONFIG_$(SPL_TPL_)VIDEO) += video_bmp.o

instead?

If I ever get back to the split config thing we'll need that.


I can use obj-$(CONFIG_$(SPL_TPL_)VIDEO) += video_bmp.o.


+endif
--
2.34.1



Regards,
Simon


Thanks,
Nikhil


Re: [PATCH v4 00/15] Add splash screen support at u-boot SPL

2023-03-30 Thread Nikhil M Jain

Hi Simon

On 31/03/23 01:44, Simon Glass wrote:

Hi Nikhil,

On Thu, 30 Mar 2023 at 01:01, Nikhil M Jain  wrote:


To enable splash screen at SPL stage move video driver and splash screen
framework at SPL, which will bring up image on display very quickly and
thus have early display support in SPL.

Change in V4
- Add Reviewed-by tag in apprpriate patch

Change in V3
- Add separate video configs for SPL splash screen
- Add rule to compile video driver in drivers/Makefile at SPL
- Add rule to compile splash.c and splash_source.c
- Squash drivers: video: video-uclass: Disable u-boot logo at SPL into
   drivers: video: Use CONFIG_IS_ENABLED and CONFIG_VAL
- Split cmd/bmp.c to separate bmp functions and commands.
- Add CONFIG_BMP and CONFIG_SPL_BMP.
- Add rule to compile necessary files required for video driver.
- Add rule to compile common/bmp.c

Change in V2
- Removed artifacts from bad patch apply.

Nikhil M Jain (15):
   drivers: video: Kconfig: Add configs for enabling video at SPL
   drivers: video: tidss: Kconfig: Configs to enable TIDSS at SPL
   drivers: Makefile: Add rule to compile video driver
   drivers: video: Makefile: Rule to compile necessary video driver
 files.
   drivers: video: tidss: Makefile: Add condition to compile TIDSS at SPL
   common: Makefile: Add rule to compile splash and splash_source at SPL
   common: Kconfig: Add BMP configs
   cmd: bmp: Split bmp commands and functions
   cmd: Makefile: Rule to compile bmp_cmd
   common: Makefile: Rule to compile bmp.c
   drivers: video: Enable necessary video functions at SPL
   common: Enable splash functions at SPL
   include: Enable video related global data variable and splash at SPL
   common: splash: Replace CONFIG_CMD_BMP
   board: ti: am62x: evm: OSPI support for splash screen

  board/ti/am62x/evm.c  |   8 +-
  cmd/Makefile  |   3 +-
  cmd/bmp_cmd.c |  98 +
  common/Kconfig|  12 ++
  common/Makefile   |   3 +
  {cmd => common}/bmp.c | 114 +--
  common/splash.c   |  10 +-
  drivers/Makefile  |   2 +-
  drivers/video/Kconfig | 221 ++
  drivers/video/Makefile|  10 ++
  drivers/video/console_normal.c|   6 +-
  drivers/video/tidss/Kconfig   |   6 +
  drivers/video/tidss/Makefile  |   2 +-
  drivers/video/vidconsole-uclass.c |   2 +-
  drivers/video/video-uclass.c  |  14 +-
  drivers/video/video_bmp.c |   8 +-
  include/asm-generic/global_data.h |   4 +-
  include/splash.h  |   6 +-
  include/video.h   |   7 +
  19 files changed, 399 insertions(+), 137 deletions(-)
  create mode 100644 cmd/bmp_cmd.c
  rename {cmd => common}/bmp.c (58%)

--
2.34.1



I wasn't able to apply this to -next due to conflicts. Could you
please check that?


I will check and fix the issue.


Regards,
Simon


Thanks,
Nikhil


Re: [PATCH 2/6] serial: msm-geni: remove redundant includes

2023-03-30 Thread Konrad Dybcio



On 30.03.2023 21:47, Vladimir Zapolskiy wrote:
> For whatever reason, likely a driver stub was copied from another
> driver, the driver contains a bunch of unnecessary and confusing
> includes like watchdog.h etc., the change reduces the list.
> 
> Signed-off-by: Vladimir Zapolskiy 
> ---
Reviewed-by: Konrad Dybcio 

Konrad
>  drivers/serial/serial_msm_geni.c | 6 --
>  1 file changed, 6 deletions(-)
> 
> diff --git a/drivers/serial/serial_msm_geni.c 
> b/drivers/serial/serial_msm_geni.c
> index 3943ca43e49e..df61ae04df0a 100644
> --- a/drivers/serial/serial_msm_geni.c
> +++ b/drivers/serial/serial_msm_geni.c
> @@ -11,15 +11,9 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
> -#include 
> -#include 
>  #include 
> -#include 
>  #include 
> -#include 
> -#include 
>  
>  #define UART_OVERSAMPLING32
>  #define STALE_TIMEOUT160


Re: [PATCH 6/6] serial: msm-geni: correct oversampling value based on QUP hardware revision

2023-03-30 Thread Konrad Dybcio



On 30.03.2023 21:47, Vladimir Zapolskiy wrote:
> Starting from QUP v2.5 the value of oversampling is changed from 32
> to 16, keeping the old value on newer platforms results on wrong set
> UART IP clock divider, thus the asked baudrate does not correspond to
> the actually set with all the consequencies for a user.
> 
> The change links the driver to a new Qualcomm GENI SE QUP driver
> to get its hardware version and update the oversampling value.
> 
> Deliberately the code under CONFIG_DEBUG_UART_MSM_GENI is not touched,
> since a wanted baudrate can be controlled by setting a modified
> CONFIG_DEBUG_UART_CLOCK build time variable.
> 
> Signed-off-by: Vladimir Zapolskiy 
> ---
>  drivers/serial/serial_msm_geni.c | 32 +++-
>  1 file changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/serial/serial_msm_geni.c 
> b/drivers/serial/serial_msm_geni.c
> index 03fc704182d3..cdca7e83daa6 100644
> --- a/drivers/serial/serial_msm_geni.c
> +++ b/drivers/serial/serial_msm_geni.c
> @@ -13,6 +13,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #define UART_OVERSAMPLING32
> @@ -110,6 +111,10 @@
>  #define TX_FIFO_DEPTH_MSK(GENMASK(21, 16))
>  #define TX_FIFO_DEPTH_SHFT   16
>  
> +/* GENI SE QUP Registers */
> +#define QUP_HW_VER_REG   0x4
> +#define  QUP_SE_VERSION_2_5  0x2005
Should we perhaps store this in the parent's dev / priv data?
If we had to take care of it for other GENI peripherals, we
would have to redo it over and over again.

> +
>  /*
>   * Predefined packing configuration of the serial engine (CFG0, CFG1 regs)
>   * for uart mode.
> @@ -127,6 +132,7 @@ DECLARE_GLOBAL_DATA_PTR;
>  struct msm_serial_data {
>   phys_addr_t base;
>   u32 baud;
> + u32 oversampling;
>  };
>  
>  unsigned long root_freq[] = {7372800,  14745600, 1920, 29491200,
> @@ -246,7 +252,7 @@ static int msm_serial_setbrg(struct udevice *dev, int 
> baud)
>  
>   priv->baud = baud;
>  
> - clk_rate = get_clk_div_rate(baud, UART_OVERSAMPLING, _div);
> + clk_rate = get_clk_div_rate(baud, priv->oversampling, _div);
>   geni_serial_set_clock_rate(dev, clk_rate);
>   geni_serial_baud(priv->base, clk_div, baud);
>  
> @@ -480,6 +486,27 @@ static const struct dm_serial_ops msm_serial_ops = {
>   .setbrg = msm_serial_setbrg,
>  };
>  
> +static inline void geni_get_oversampling(struct udevice *dev)
Nit: functions with _get_ in their names are generally expected to
return the value they're getting, perhaps _adjust_ or _set_ would
be more fitting.

> +{
> + struct msm_serial_data *priv = dev_get_priv(dev);
> + struct udevice *parent_dev = dev_get_parent(dev);
> + u32 geni_se_version;
> + int ret;
> +
> + priv->oversampling = UART_OVERSAMPLING;
> +
> + /*
> +  * It could happen that GENI SE QUP driver is disabled or GENI UART
> +  * device tree node is a direct child of SoC device tree node.
> +  */
> + if (device_get_uclass_id(parent_dev) != UCLASS_MISC)
> + return;
> +
> + ret = misc_read(parent_dev, QUP_HW_VER_REG, _se_version, 4);
sizeof(int) or sizeof(geni_se_version)?

> + if (!ret && geni_se_version >= QUP_SE_VERSION_2_5)
> + priv->oversampling /= 2;
> +}
> +
>  static inline void geni_serial_init(struct udevice *dev)
>  {
>   struct msm_serial_data *priv = dev_get_priv(dev);
> @@ -523,6 +550,8 @@ static int msm_serial_probe(struct udevice *dev)
>  {
>   struct msm_serial_data *priv = dev_get_priv(dev);
>  
> + geni_get_oversampling(dev);
> +
>   /* No need to reinitialize the UART after relocation */
>   if (gd->flags & GD_FLG_RELOC)
>   return 0;
> @@ -557,6 +586,7 @@ U_BOOT_DRIVER(serial_msm_geni) = {
>   .priv_auto = sizeof(struct msm_serial_data),
>   .probe = msm_serial_probe,
>   .ops = _serial_ops,
> + .flags = DM_FLAG_PRE_RELOC,
This change was not mentioned in the commit message. You can
pick up

https://lore.kernel.org/u-boot/20230327-qc_cleanups-v2-4-9a80cc563...@linaro.org/

which also cleans up the remnants of this in the DTs.
It will however need to be rebased against the `next` branch and

8c103c33fb14 ("dm: dts: Convert driver model tags to use new schema")

Konrad
>  };
>  
>  #ifdef CONFIG_DEBUG_UART_MSM_GENI


Re: [PATCH 5/6] serial: msm-geni: fix a compile time warning from msm_serial_setbrg()

2023-03-30 Thread Konrad Dybcio



On 30.03.2023 21:47, Vladimir Zapolskiy wrote:
> A compiler warns about a missing function prototype, which is valid
> and fixed by converting the function into static one, also fix
> interleaved local variable declarations and assignments.
> 
> Signed-off-by: Vladimir Zapolskiy 
> ---

Fixes: 324df15a292e ("serial: qcom: add support for GENI serial driver")
Reviewed-by: Konrad Dybcio 

Konrad
>  drivers/serial/serial_msm_geni.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/serial/serial_msm_geni.c 
> b/drivers/serial/serial_msm_geni.c
> index c9813f06ace7..03fc704182d3 100644
> --- a/drivers/serial/serial_msm_geni.c
> +++ b/drivers/serial/serial_msm_geni.c
> @@ -238,13 +238,13 @@ static inline void geni_serial_baud(phys_addr_t 
> base_address, u32 clk_div,
>   writel(s_clk_cfg, base_address + GENI_SER_S_CLK_CFG);
>  }
>  
> -int msm_serial_setbrg(struct udevice *dev, int baud)
> +static int msm_serial_setbrg(struct udevice *dev, int baud)
>  {
>   struct msm_serial_data *priv = dev_get_priv(dev);
> + u64 clk_rate;
> + u32 clk_div;
>  
>   priv->baud = baud;
> - u32 clk_div;
> - u64 clk_rate;
>  
>   clk_rate = get_clk_div_rate(baud, UART_OVERSAMPLING, _div);
>   geni_serial_set_clock_rate(dev, clk_rate);


Re: [PATCH 4/6] serial: msm-geni: fix code indentation

2023-03-30 Thread Konrad Dybcio



On 30.03.2023 21:47, Vladimir Zapolskiy wrote:
> This a cosmetic change, which corrects code indentation in a few places.
> 
> Signed-off-by: Vladimir Zapolskiy 
> ---
Reviewed-by: Konrad Dybcio 

Konrad
>  drivers/serial/serial_msm_geni.c | 11 +--
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/serial/serial_msm_geni.c 
> b/drivers/serial/serial_msm_geni.c
> index 1b12fdfbdafc..c9813f06ace7 100644
> --- a/drivers/serial/serial_msm_geni.c
> +++ b/drivers/serial/serial_msm_geni.c
> @@ -130,8 +130,8 @@ struct msm_serial_data {
>  };
>  
>  unsigned long root_freq[] = {7372800,  14745600, 1920, 29491200,
> -  3200, 4800, 6400, 8000,
> -  9600, 1};
> +  3200, 4800, 6400, 8000,
> +  9600, 1};
>  
>  /**
>   * get_clk_cfg() - Get clock rate to apply on clock supplier.
> @@ -160,8 +160,7 @@ static int get_clk_cfg(unsigned long clk_freq)
>   *
>   * Return: frequency, supported by clock supplier, multiple of clk_freq.
>   */
> -static int get_clk_div_rate(u32 baud,
> - u64 sampling_rate, u32 
> *clk_div)
> +static int get_clk_div_rate(u32 baud, u64 sampling_rate, u32 *clk_div)
>  {
>   unsigned long ser_clk;
>   unsigned long desired_clk;
> @@ -228,7 +227,7 @@ static inline u32 geni_se_get_tx_fifo_width(long base)
>  }
>  
>  static inline void geni_serial_baud(phys_addr_t base_address, u32 clk_div,
> - int 
> baud)
> + int baud)
>  {
>   u32 s_clk_cfg = 0;
>  
> @@ -268,7 +267,7 @@ int msm_serial_setbrg(struct udevice *dev, int baud)
>   * reached.
>   */
>  static bool qcom_geni_serial_poll_bit(const struct udevice *dev, int offset,
> -   int field, bool set)
> +   int field, bool set)
>  {
>   u32 reg;
>   struct msm_serial_data *priv = dev_get_priv(dev);


Re: [PATCH 3/6] serial: msm-geni: remove invalid se-clk clock name

2023-03-30 Thread Konrad Dybcio



On 30.03.2023 21:47, Vladimir Zapolskiy wrote:
> There is only one clock supplier to the serial IP, thus getting it by
> name is not needed, also note that "clock-names" property is not listed
> under doc/device-tree-bindings/serial/msm-geni-serial.txt, and finally
> "se-clk" clock name is invalid, if added, it shall get "se" value like
> it's already described in Linux device tree documentation.
> 
> Signed-off-by: Vladimir Zapolskiy 
> ---
OK this is even better than my approach of using "se", didn't know
we could just "get whatever's present".

Reviewed-by: Konrad Dybcio 

Konrad
>  drivers/serial/serial_msm_geni.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/serial/serial_msm_geni.c 
> b/drivers/serial/serial_msm_geni.c
> index df61ae04df0a..1b12fdfbdafc 100644
> --- a/drivers/serial/serial_msm_geni.c
> +++ b/drivers/serial/serial_msm_geni.c
> @@ -183,7 +183,7 @@ static int geni_serial_set_clock_rate(struct udevice 
> *dev, u64 rate)
>   struct clk *clk;
>   int ret;
>  
> - clk = devm_clk_get(dev, "se-clk");
> + clk = devm_clk_get(dev, NULL);
>   if (!clk)
>   return -EINVAL;
>  


Re: [PATCH 1/6] misc: add Qualcomm GENI SE QUP device driver

2023-03-30 Thread Konrad Dybcio



On 30.03.2023 21:47, Vladimir Zapolskiy wrote:
> This change adds a Qualcomm GENI SE QUP device driver as a wrapper for
> actually enabled and used serial devices found on a board.
> 
> At the moment the driver is pretty simple, its intention is to populate
> childred devices and provide I/O mem read interface to them as clients,
> this is needed for GENI UART driver to set up a proper clock divider
> and provide the actually asked baud rate.
> 
> Signed-off-by: Vladimir Zapolskiy 
> ---
>  drivers/misc/Kconfig|  6 ++
>  drivers/misc/Makefile   |  1 +
>  drivers/misc/qcom-geni-se.c | 42 +
>  3 files changed, 49 insertions(+)
>  create mode 100644 drivers/misc/qcom-geni-se.c
> 
> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> index b5707a15c504..348e1ab407ad 100644
> --- a/drivers/misc/Kconfig
> +++ b/drivers/misc/Kconfig
> @@ -511,6 +511,12 @@ config WINBOND_W83627
> legacy UART or other devices in the Winbond Super IO chips
> on X86 platforms.
>  
> +config QCOM_GENI_SE
> + bool "Qualcomm GENI Serial Engine Driver"
> + help
> +   The driver manages Generic Interface (GENI) firmware based
> +   Qualcomm Technologies, Inc. Universal Peripheral (QUP) Wrapper.
> +
>  config QFW
>   bool
>   help
> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> index 3b792f2a14ce..52aed096021f 100644
> --- a/drivers/misc/Makefile
> +++ b/drivers/misc/Makefile
> @@ -60,6 +60,7 @@ obj-$(CONFIG_NUVOTON_NCT6102D) += nuvoton_nct6102d.o
>  obj-$(CONFIG_P2SB) += p2sb-uclass.o
>  obj-$(CONFIG_PCA9551_LED) += pca9551_led.o
>  obj-$(CONFIG_$(SPL_)PWRSEQ) += pwrseq-uclass.o
> +obj-$(CONFIG_QCOM_GENI_SE) += qcom-geni-se.o
>  ifdef CONFIG_QFW
>  obj-y += qfw.o
>  obj-$(CONFIG_QFW_PIO) += qfw_pio.o
> diff --git a/drivers/misc/qcom-geni-se.c b/drivers/misc/qcom-geni-se.c
> new file mode 100644
> index ..4f1775b11f62
> --- /dev/null
> +++ b/drivers/misc/qcom-geni-se.c
> @@ -0,0 +1,42 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Qualcomm Generic Interface (GENI) Serial Engine (SE) Wrapper
> + *
> + * (C) Copyright 2023 Vladimir Zapolskiy 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static int geni_se_qup_read(struct udevice *dev, int offset,
> + void *buf, int size)
> +{
> + fdt_addr_t base = dev_read_addr(dev);
> +
> + if (size != sizeof(u32))
> + return -EINVAL;
> +
> + *(u32 *)buf = readl(base + offset);
Maybe 

u32 *buffer = buf;

[...]

*buf = readl..

would be more stylish, but that's a nit and I don't have
any other complaints! :D

Reviewed-by: Konrad Dybcio 

Konrad
> +
> + return 0;
> +}
> +
> +static struct misc_ops geni_se_qup_ops = {
> + .read = geni_se_qup_read,
> +};
> +
> +static const struct udevice_id geni_se_qup_ids[] = {
> + { .compatible = "qcom,geni-se-qup" },
> + {}
> +};
> +
> +U_BOOT_DRIVER(geni_se_qup) = {
> + .name = "geni_se_qup",
> + .id = UCLASS_MISC,
> + .of_match = geni_se_qup_ids,
> + .bind = dm_scan_fdt_dev,
> + .ops = _se_qup_ops,
> + .flags  = DM_FLAG_PRE_RELOC,
> +};


Re: [PATCH 32/38] fs: fat: Shrink the size of a few strings

2023-03-30 Thread Simon Glass
Hi Heinrich,

On Fri, 31 Mar 2023 at 13:05, Heinrich Schuchardt  wrote:
>
>
>
> Am 31. März 2023 01:49:35 MESZ schrieb Simon Glass :
> >Hi Heinrich,
> >
> >On Fri, 31 Mar 2023 at 11:48, Heinrich Schuchardt  wrote:
> >>
> >>
> >>
> >> Am 30. März 2023 23:32:21 MESZ schrieb Simon Glass :
> >> >To save a few bytes, replace Error with ** and try to use the same string
> >> >for multiple messages where possible.
> >> >
> >> >Signed-off-by: Simon Glass 
> >> >---
> >> >
> >> > fs/fat/fat.c   | 12 ++--
> >> > fs/fat/fat_write.c | 14 --
> >> > 2 files changed, 10 insertions(+), 16 deletions(-)
> >> >
> >> >diff --git a/fs/fat/fat.c b/fs/fat/fat.c
> >> >index 2da93dae3cf3..f0df7988e172 100644
> >> >--- a/fs/fat/fat.c
> >> >+++ b/fs/fat/fat.c
> >> >@@ -97,8 +97,8 @@ int fat_register_device(struct blk_desc *dev_desc, int 
> >> >part_no)
> >> >   /* Read the partition table, if present */
> >> >   if (part_get_info(dev_desc, part_no, )) {
> >> >   if (part_no != 0) {
> >> >-  printf("** Partition %d not valid on device %d 
> >> >**\n",
> >> >-  part_no, dev_desc->devnum);
> >> >+  printf("** Partition %d invalid on device %d **\n",
> >> >+ part_no, dev_desc->devnum);
> >> >   return -1;
> >> >   }
> >> >
> >> >@@ -168,7 +168,7 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry)
> >> >   __u32 ret = 0x00;
> >> >
> >> >   if (CHECK_CLUST(entry, mydata->fatsize)) {
> >> >-  printf("Error: Invalid FAT entry: 0x%08x\n", entry);
> >> >+  printf("** Invalid FAT entry: %#08x\n", entry);
> >>
> >> The ** is superfluous. The text makes it clear that an error occured
> >
> >So should I drop the other ** strings in these files too? Please take
> >a look and see what you think.
>
> I suggest to avoid prefixes like 'Error:' and '**' in all our code if the 
> message text already indicates an error.

That makes sense to me. It is sometimes hard to know whether something
indicates an error, though. If you look through fat.c you'll see what
I mean.

Regards,
Simon


Re: [PATCH 13/38] part: Allow setting the partition-table type

2023-03-30 Thread Simon Glass
Hi Heinrich,

On Fri, 31 Mar 2023 at 13:17, Heinrich Schuchardt  wrote:
>
>
>
> Am 31. März 2023 01:49:05 MESZ schrieb Simon Glass :
> >Hi Heinrich,
> >
> >On Fri, 31 Mar 2023 at 11:33, Heinrich Schuchardt  wrote:
> >>
> >>
> >>
> >> Am 30. März 2023 23:32:02 MESZ schrieb Simon Glass :
> >> >Some devices have multiple partition types available on the same media.
> >> >It is sometimes useful to see these to check that everything is working
> >> >correctly.
> >> >
> >> >Provide a way to manually set the partition-table type, avoiding the
> >> >auto-detection process.
> >>
> >> Do you have an example image where we get it wrong?
> >>
> >> Linux does not need that. What is different in our  table type  priorities 
> >> to Linux?
> >>
> >> I am not yet convinced we need to set this manually.
> >
> >There is an example in the documentation I added. That is using the
> >Ubuntu 22.04 ISO. Can you give it a try?
>
> Linux would mount this as iso9660.
>
> U-Boot lacks a driver for this file system.
>
> There is no need to mount the file as CD-ROM drive. You could mount it as 
> virtio drive instead or as USB. Then U-Boot can read the EFI partition with 
> sector size 512.
>
> Computers nowadays are installed from USB. Most workstation cases don't 
> foresee optical drives anymore.

Yes, the example I have shown is for virtio and you can see the
different filesystems present there.

Regards,
Simon


>
> Best regards
>
> Heinrich
>
> >
> >You can also try it with a CDROM drive, something like:
> >
> >qemu-system-x86_64  -drive format=raw,file=root.img -bios
> >/tmp/b/qemu-x86_64/u-boot.rom -cdrom ubuntu-22.04.2-desktop-amd64.iso
> >-hdb fat:rw:/home/sglass/cosarm/win/seabios -nographic -m 4096
> >
> >Regards,
> >Simon
> >
> >> >
> >> >Signed-off-by: Simon Glass 
> >> >---
> >> >
> >> > cmd/part.c | 34 +++
> >> > disk/part.c| 16 +
> >> > doc/usage/cmd/part.rst | 74 ++
> >> > include/part.h |  9 +
> >> > 4 files changed, 133 insertions(+)
> >
> >[..]


Re: [PATCH 18/38] efi: Show all known UUIDs with CONFIG_CMD_EFIDEBUG

2023-03-30 Thread Simon Glass
Hi Heinrich,

On Fri, 31 Mar 2023 at 13:27, Heinrich Schuchardt  wrote:
>
>
>
> Am 31. März 2023 01:48:57 MESZ schrieb Simon Glass :
> >Hi Heinrich,
> >
> >On Fri, 31 Mar 2023 at 11:38, Heinrich Schuchardt  wrote:
> >>
> >>
> >>
> >> Am 30. März 2023 23:32:07 MESZ schrieb Simon Glass :
> >> >The CMD_EFIDEBUG option enables debugging so it is reasonable to assume
> >> >that all effects should be made to decode the dreaded UUIDs favoured by
> >> >UEFI.
> >> >
> >> >Update the table to show them all when CONFIG_CMD_EFIDEBUG is enabled.
> >> >
> >> >Signed-off-by: Simon Glass 
> >> >---
> >> >
> >> > lib/uuid.c | 2 +-
> >> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> >diff --git a/lib/uuid.c b/lib/uuid.c
> >> >index 96e1af3c8b00..ab30fbf9152f 100644
> >> >--- a/lib/uuid.c
> >> >+++ b/lib/uuid.c
> >> >@@ -255,7 +255,7 @@ static const struct {
> >> >   EFI_CERT_TYPE_PKCS7_GUID,
> >> >   },
> >> > #endif
> >> >-#ifdef CONFIG_EFI
> >> >+#if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI)
> >> >   { "EFI_LZMA_COMPRESSED", EFI_LZMA_COMPRESSED },
> >> >   { "EFI_DXE_SERVICES", EFI_DXE_SERVICES },
> >> >   { "EFI_HOB_LIST", EFI_HOB_LIST },
> >>
> >> None of these are used when not building the EFI app.
> >
> >So you think we should disable them? As I said above, enabling
> >debugging seems like a good reason to allow decoding of all of them.
> >
> >Regards,
> >SImon
>
> U-Boot, Shim, GRUB will not use any of these. The EFI app sees them if shared 
> by the preceding UEFI firmware.
>
> There are zillions other GUIDs that a vendor UEFI might use. But why should 
> we care?
>
> I would rather drop these strings from the code base.

I would far rather drop the UUIDs from the code base. Is that
possible? We should use a simple numeric tag, like 0, 1, 2, 3, 4 with
an associated descriptive string. Even using a 16-byte string would be
better than a UUID.

While we have to put up with UUIDs, we need a way to make them
intelligible for us poor sods who need to decode boot-time traces[1]
and the like.

Regards,
Simon

[1]
EFI: Exit: efi_open_protocol: 0
EFI: Entry efi_open_protocol(7ed33da0,
5b1b31a1-9562-11d2-8e3f-00a0c969723b, 7ecf4978,
7ed33da0, 000
0, 0x2)
EFI: Exit: efi_open_protocol: 0
EFI: Entry efi_open_protocol(7ed238b0,
09576e91-6d3f-11d2-8e39-00a0c969723b, 7ecf4978,
7ed33da0, 000
0, 0x2)
EFI: Exit: efi_open_protocol: 0
EFI: Entry efi_locate_handle_ext(2,
a19832b9-ac25-11d3-9a2d-0090273fc14d, ,
7ecf4948, 7d6f3ba0)
EFI: Exit: efi_locate_handle_ext: 0
EFI: Entry efi_open_protocol(7ed25040,
09576e91-6d3f-11d2-8e39-00a0c969723b, 7ecf4978,
7ed33da0, 000
0, 0x2)
EFI: Exit: efi_open_protocol: 0
EFI: Entry efi_open_protocol(7ed25040,
a19832b9-ac25-11d3-9a2d-0090273fc14d, 7ecf4978,
7ed33da0, 000
0, 0x2)
EFI: Exit: efi_open_protocol: 0
EFI: Entry efi_open_protocol(7ed33da0,
5b1b31a1-9562-11d2-8e3f-00a0c969723b, 7ecf49b8, 0
0007ed33da0, , 0x2)
EFI: Exit: efi_open_protocol: 0
EFI: Entry efi_open_protocol(7ed238b0,
09576e91-6d3f-11d2-8e39-00a0c969723b, 7ecf4958,
7ed33da0, 000
0, 0x2)
EFI: Exit: efi_open_protocol: 0
EFI: Entry efi_locate_protocol(96751a3d-72f4-41a6-a794-ed5d0e67ae6b,
, 7ecf4668)
EFI: Exit: efi_locate_protocol: 14
EFI: Entry efi_locate_handle_ext(2,
f541796d-a62e-4954-a775-9584f61b9cdd, ,
7ecf4638, 7d40be00)
EFI: Exit: efi_locate_handle_ext: 14
EFI: Entry efi_locate_handle_ext(2,
607f766c-7455-42be-930b-e4d76db2720f, ,
7ecf4638, 7d40be00)
EFI: Exit: efi_locate_handle_ext: 14
EFI: Entry efi_locate_protocol(f42f7782-012e-4c12-9956-49f94304f721,
, 7ecf43e8)
EFI: Exit: efi_locate_protocol: 14


Re: [PATCH 18/38] efi: Show all known UUIDs with CONFIG_CMD_EFIDEBUG

2023-03-30 Thread Heinrich Schuchardt



Am 31. März 2023 01:48:57 MESZ schrieb Simon Glass :
>Hi Heinrich,
>
>On Fri, 31 Mar 2023 at 11:38, Heinrich Schuchardt  wrote:
>>
>>
>>
>> Am 30. März 2023 23:32:07 MESZ schrieb Simon Glass :
>> >The CMD_EFIDEBUG option enables debugging so it is reasonable to assume
>> >that all effects should be made to decode the dreaded UUIDs favoured by
>> >UEFI.
>> >
>> >Update the table to show them all when CONFIG_CMD_EFIDEBUG is enabled.
>> >
>> >Signed-off-by: Simon Glass 
>> >---
>> >
>> > lib/uuid.c | 2 +-
>> > 1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> >diff --git a/lib/uuid.c b/lib/uuid.c
>> >index 96e1af3c8b00..ab30fbf9152f 100644
>> >--- a/lib/uuid.c
>> >+++ b/lib/uuid.c
>> >@@ -255,7 +255,7 @@ static const struct {
>> >   EFI_CERT_TYPE_PKCS7_GUID,
>> >   },
>> > #endif
>> >-#ifdef CONFIG_EFI
>> >+#if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI)
>> >   { "EFI_LZMA_COMPRESSED", EFI_LZMA_COMPRESSED },
>> >   { "EFI_DXE_SERVICES", EFI_DXE_SERVICES },
>> >   { "EFI_HOB_LIST", EFI_HOB_LIST },
>>
>> None of these are used when not building the EFI app.
>
>So you think we should disable them? As I said above, enabling
>debugging seems like a good reason to allow decoding of all of them.
>
>Regards,
>SImon

U-Boot, Shim, GRUB will not use any of these. The EFI app sees them if shared 
by the preceding UEFI firmware.

There are zillions other GUIDs that a vendor UEFI might use. But why should we 
care?

I would rather drop these strings from the code base.

Best regards

Heinrich



Re: [PATCH 13/38] part: Allow setting the partition-table type

2023-03-30 Thread Heinrich Schuchardt



Am 31. März 2023 01:49:05 MESZ schrieb Simon Glass :
>Hi Heinrich,
>
>On Fri, 31 Mar 2023 at 11:33, Heinrich Schuchardt  wrote:
>>
>>
>>
>> Am 30. März 2023 23:32:02 MESZ schrieb Simon Glass :
>> >Some devices have multiple partition types available on the same media.
>> >It is sometimes useful to see these to check that everything is working
>> >correctly.
>> >
>> >Provide a way to manually set the partition-table type, avoiding the
>> >auto-detection process.
>>
>> Do you have an example image where we get it wrong?
>>
>> Linux does not need that. What is different in our  table type  priorities 
>> to Linux?
>>
>> I am not yet convinced we need to set this manually.
>
>There is an example in the documentation I added. That is using the
>Ubuntu 22.04 ISO. Can you give it a try?

Linux would mount this as iso9660.

U-Boot lacks a driver for this file system.

There is no need to mount the file as CD-ROM drive. You could mount it as 
virtio drive instead or as USB. Then U-Boot can read the EFI partition with 
sector size 512.

Computers nowadays are installed from USB. Most workstation cases don't foresee 
optical drives anymore.

Best regards

Heinrich

>
>You can also try it with a CDROM drive, something like:
>
>qemu-system-x86_64  -drive format=raw,file=root.img -bios
>/tmp/b/qemu-x86_64/u-boot.rom -cdrom ubuntu-22.04.2-desktop-amd64.iso
>-hdb fat:rw:/home/sglass/cosarm/win/seabios -nographic -m 4096
>
>Regards,
>Simon
>
>> >
>> >Signed-off-by: Simon Glass 
>> >---
>> >
>> > cmd/part.c | 34 +++
>> > disk/part.c| 16 +
>> > doc/usage/cmd/part.rst | 74 ++
>> > include/part.h |  9 +
>> > 4 files changed, 133 insertions(+)
>
>[..]


Re: [PATCH 32/38] fs: fat: Shrink the size of a few strings

2023-03-30 Thread Heinrich Schuchardt



Am 31. März 2023 01:49:35 MESZ schrieb Simon Glass :
>Hi Heinrich,
>
>On Fri, 31 Mar 2023 at 11:48, Heinrich Schuchardt  wrote:
>>
>>
>>
>> Am 30. März 2023 23:32:21 MESZ schrieb Simon Glass :
>> >To save a few bytes, replace Error with ** and try to use the same string
>> >for multiple messages where possible.
>> >
>> >Signed-off-by: Simon Glass 
>> >---
>> >
>> > fs/fat/fat.c   | 12 ++--
>> > fs/fat/fat_write.c | 14 --
>> > 2 files changed, 10 insertions(+), 16 deletions(-)
>> >
>> >diff --git a/fs/fat/fat.c b/fs/fat/fat.c
>> >index 2da93dae3cf3..f0df7988e172 100644
>> >--- a/fs/fat/fat.c
>> >+++ b/fs/fat/fat.c
>> >@@ -97,8 +97,8 @@ int fat_register_device(struct blk_desc *dev_desc, int 
>> >part_no)
>> >   /* Read the partition table, if present */
>> >   if (part_get_info(dev_desc, part_no, )) {
>> >   if (part_no != 0) {
>> >-  printf("** Partition %d not valid on device %d **\n",
>> >-  part_no, dev_desc->devnum);
>> >+  printf("** Partition %d invalid on device %d **\n",
>> >+ part_no, dev_desc->devnum);
>> >   return -1;
>> >   }
>> >
>> >@@ -168,7 +168,7 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry)
>> >   __u32 ret = 0x00;
>> >
>> >   if (CHECK_CLUST(entry, mydata->fatsize)) {
>> >-  printf("Error: Invalid FAT entry: 0x%08x\n", entry);
>> >+  printf("** Invalid FAT entry: %#08x\n", entry);
>>
>> The ** is superfluous. The text makes it clear that an error occured
>
>So should I drop the other ** strings in these files too? Please take
>a look and see what you think.

I suggest to avoid prefixes like 'Error:' and '**' in all our code if the 
message text already indicates an error.

Best regards

Heinrich 

>
>[..]
>
>Regards,
>Simon


Re: [PATCH 32/38] fs: fat: Shrink the size of a few strings

2023-03-30 Thread Simon Glass
Hi Heinrich,

On Fri, 31 Mar 2023 at 11:48, Heinrich Schuchardt  wrote:
>
>
>
> Am 30. März 2023 23:32:21 MESZ schrieb Simon Glass :
> >To save a few bytes, replace Error with ** and try to use the same string
> >for multiple messages where possible.
> >
> >Signed-off-by: Simon Glass 
> >---
> >
> > fs/fat/fat.c   | 12 ++--
> > fs/fat/fat_write.c | 14 --
> > 2 files changed, 10 insertions(+), 16 deletions(-)
> >
> >diff --git a/fs/fat/fat.c b/fs/fat/fat.c
> >index 2da93dae3cf3..f0df7988e172 100644
> >--- a/fs/fat/fat.c
> >+++ b/fs/fat/fat.c
> >@@ -97,8 +97,8 @@ int fat_register_device(struct blk_desc *dev_desc, int 
> >part_no)
> >   /* Read the partition table, if present */
> >   if (part_get_info(dev_desc, part_no, )) {
> >   if (part_no != 0) {
> >-  printf("** Partition %d not valid on device %d **\n",
> >-  part_no, dev_desc->devnum);
> >+  printf("** Partition %d invalid on device %d **\n",
> >+ part_no, dev_desc->devnum);
> >   return -1;
> >   }
> >
> >@@ -168,7 +168,7 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry)
> >   __u32 ret = 0x00;
> >
> >   if (CHECK_CLUST(entry, mydata->fatsize)) {
> >-  printf("Error: Invalid FAT entry: 0x%08x\n", entry);
> >+  printf("** Invalid FAT entry: %#08x\n", entry);
>
> The ** is superfluous. The text makes it clear that an error occured

So should I drop the other ** strings in these files too? Please take
a look and see what you think.

[..]

Regards,
Simon


Re: [PATCH 13/38] part: Allow setting the partition-table type

2023-03-30 Thread Simon Glass
Hi Heinrich,

On Fri, 31 Mar 2023 at 11:33, Heinrich Schuchardt  wrote:
>
>
>
> Am 30. März 2023 23:32:02 MESZ schrieb Simon Glass :
> >Some devices have multiple partition types available on the same media.
> >It is sometimes useful to see these to check that everything is working
> >correctly.
> >
> >Provide a way to manually set the partition-table type, avoiding the
> >auto-detection process.
>
> Do you have an example image where we get it wrong?
>
> Linux does not need that. What is different in our  table type  priorities to 
> Linux?
>
> I am not yet convinced we need to set this manually.

There is an example in the documentation I added. That is using the
Ubuntu 22.04 ISO. Can you give it a try?

You can also try it with a CDROM drive, something like:

qemu-system-x86_64  -drive format=raw,file=root.img -bios
/tmp/b/qemu-x86_64/u-boot.rom -cdrom ubuntu-22.04.2-desktop-amd64.iso
-hdb fat:rw:/home/sglass/cosarm/win/seabios -nographic -m 4096

Regards,
Simon

> >
> >Signed-off-by: Simon Glass 
> >---
> >
> > cmd/part.c | 34 +++
> > disk/part.c| 16 +
> > doc/usage/cmd/part.rst | 74 ++
> > include/part.h |  9 +
> > 4 files changed, 133 insertions(+)

[..]


Re: [PATCH 18/38] efi: Show all known UUIDs with CONFIG_CMD_EFIDEBUG

2023-03-30 Thread Simon Glass
Hi Heinrich,

On Fri, 31 Mar 2023 at 11:38, Heinrich Schuchardt  wrote:
>
>
>
> Am 30. März 2023 23:32:07 MESZ schrieb Simon Glass :
> >The CMD_EFIDEBUG option enables debugging so it is reasonable to assume
> >that all effects should be made to decode the dreaded UUIDs favoured by
> >UEFI.
> >
> >Update the table to show them all when CONFIG_CMD_EFIDEBUG is enabled.
> >
> >Signed-off-by: Simon Glass 
> >---
> >
> > lib/uuid.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >diff --git a/lib/uuid.c b/lib/uuid.c
> >index 96e1af3c8b00..ab30fbf9152f 100644
> >--- a/lib/uuid.c
> >+++ b/lib/uuid.c
> >@@ -255,7 +255,7 @@ static const struct {
> >   EFI_CERT_TYPE_PKCS7_GUID,
> >   },
> > #endif
> >-#ifdef CONFIG_EFI
> >+#if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI)
> >   { "EFI_LZMA_COMPRESSED", EFI_LZMA_COMPRESSED },
> >   { "EFI_DXE_SERVICES", EFI_DXE_SERVICES },
> >   { "EFI_HOB_LIST", EFI_HOB_LIST },
>
> None of these are used when not building the EFI app.

So you think we should disable them? As I said above, enabling
debugging seems like a good reason to allow decoding of all of them.

Regards,
SImon


Re: [PATCH 38/38] efi: Use the installed ACPI tables

2023-03-30 Thread Simon Glass
Hi Heinrich,

On Fri, 31 Mar 2023 at 10:53, Heinrich Schuchardt  wrote:
>
>
>
> Am 30. März 2023 23:32:27 MESZ schrieb Simon Glass :
> >U-Boot sets up the ACPI tables during startup. Rather than creating a
> >new set, install the existing ones. Create a memory-map record to cover
> >the tables.
>
> I understand that this works on QEMU which provides ACPI tables. But on all 
> other systems that use ACPI you will still have to generate ACPI tables.
>
> So you cannot simply drop the table generation.
>
> If you have moved the generation step somewhere else, this patch should 
> mention the new location.

This only applies to x86 as we don't have ACPI tables for other archs.
The generation step has not moved, it's just that they have always
been generated before start-up. I think this might have been
overlooked when writing the UEFI code? I'm actually not sure how this
worked before on any x86 board.

See last_stage_init() which calls write_tables().

Regards,
Simon


>
> >
> >Signed-off-by: Simon Glass 
> >---
> >
> > lib/efi_loader/efi_acpi.c | 33 +++--
> > 1 file changed, 19 insertions(+), 14 deletions(-)
> >
[..]


Re: [PATCH 14/38] qfw: Show the file address if available

2023-03-30 Thread Simon Glass
Hi Heinrich,

On Fri, 31 Mar 2023 at 11:31, Heinrich Schuchardt  wrote:
>
>
>
> Am 30. März 2023 23:32:03 MESZ schrieb Simon Glass :
> >Some files have an associated address. Show this with the 'qfw list'
> >command so that it is possible to dump the data.
> >
> >Signed-off-by: Simon Glass 
> >---
> >
> > cmd/qfw.c |  2 +-
> > doc/usage/cmd/qfw.rst | 28 
> > 2 files changed, 17 insertions(+), 13 deletions(-)
> >
> >diff --git a/cmd/qfw.c b/cmd/qfw.c
> >index ae3c6a7a84e9..d6ecfa60d5a7 100644
> >--- a/cmd/qfw.c
> >+++ b/cmd/qfw.c
> >@@ -26,7 +26,7 @@ static int qemu_fwcfg_cmd_list_firmware(void)
> >   for (file = qfw_file_iter_init(qfw_dev, );
> >!qfw_file_iter_end();
> >file = qfw_file_iter_next()) {
> >-  printf("%-56s\n", file->cfg.name);
> >+  printf("%08lx %-56s\n", file->addr, file->cfg.name);
>
> Are the tables always in the lower 4GiB on all architectures (riscv64, arm64, 
> x86)?

Yes, so far as I have seen on x86. We don't generate them for ARM or
RISC-V. I do want to make sure the addresses are readable.

[..]

Regards,
Simon


Re: [PATCH 1/1] rockchip: Fix incorrect constant name in RAM init code

2023-03-30 Thread Simon Glass
On Fri, 31 Mar 2023 at 10:53, David Sebek  wrote:
>
> A condition in the rk3399 RAM initialization code used the old
> CONFIG_RAM_RK3399_LPDDR4 constant name. This commit changes the
> condition to use the correct CONFIG_RAM_ROCKCHIP_LPDDR4 constant.
> ---
>  drivers/ram/rockchip/sdram_rk3399.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCH 33/38] fs: fat: Support reading from a larger block size

2023-03-30 Thread Heinrich Schuchardt



Am 30. März 2023 23:32:22 MESZ schrieb Simon Glass :
>At present it is not possible to read from some CDROM drives since the
>FAT sector size does not match the media's block size. Add a conversion
>option for this, so that reading is possible.
>
>This does increase SPL size for read-only FAT support by 25 bytes but
>all but 6 are covered by the previous patch. We could reduce the
>overhead of this feature to 0 bytes by making the code uglier (using
>a static variable).

512 and 2048 are not the only physical sector sizes. Some hard drives use 4096.

This change deserves a test case.

Best regards

Heinrich

>
>Signed-off-by: Simon Glass 
>---
>
> fs/fat/Kconfig |  13 ++
> fs/fat/fat.c   | 107 -
> fs/fat/fat_write.c |   8 ++--
> 3 files changed, 114 insertions(+), 14 deletions(-)
>
>diff --git a/fs/fat/Kconfig b/fs/fat/Kconfig
>index 9bb11eac9f7a..b0aa888c6cc4 100644
>--- a/fs/fat/Kconfig
>+++ b/fs/fat/Kconfig
>@@ -22,3 +22,16 @@ config FS_FAT_MAX_CLUSTSIZE
> is the smallest amount of disk space that can be used to hold a
> file. Unless you have an extremely tight memory memory constraints,
> leave the default.
>+
>+config FAT_BLK_XLATE
>+  bool "Enable FAT filesystem on a device with a larger block size"
>+  depends on FS_FAT
>+  help
>+This provides a simple translation mechanism for reading FAT
>+filesystems which don't use the same sector size as the underlying
>+media. For example, the FAT filesystem may use 512 bytes but the
>+media uses 2048, e.g. on a CDROM drive.
>+
>+This only supports the case where the FAT filesystem's sector size is
>+smaller than the media's block size. It does not support creating or
>+writing files.
>diff --git a/fs/fat/fat.c b/fs/fat/fat.c
>index f0df7988e172..02c6d55a99b3 100644
>--- a/fs/fat/fat.c
>+++ b/fs/fat/fat.c
>@@ -43,13 +43,93 @@ static struct disk_partition cur_part_info;
> #define DOS_FS_TYPE_OFFSET0x36
> #define DOS_FS32_TYPE_OFFSET  0x52
> 
>-static int disk_read(__u32 block, __u32 nr_blocks, void *buf)
>+/**
>+ * disk_read_conv() - Read blocks and break them into smaller ones
>+ *
>+ * This is used when the FAT filesystem is hosted on a block device with a
>+ * block size greated than 512 bytes, e.g. the 2048 bytes of a CDROM drive. It
>+ * reads the blocks into a buffer and pulls out what is requested by the 
>calling
>+ * function.
>+ *
>+ * It uses an internal 2KB buffer on the stack.
>+ *
>+ * @mydata: Filesystem information
>+ * @block: Block number to read, in terms of mydata->sect_size
>+ * @nr_blocks: Number of blocks to read, in terms of mydata->sect_size
>+ * @buf: Buffer for data
>+ */
>+static int disk_read_conv(fsdata *mydata, __u32 block, __u32 nr_blocks,
>+void *buf)
>+{
>+  uint factor, whole, remain, upto;
>+  ulong base, index;
>+  uint to_copy;
>+  u8 tbuf[2048];
>+  int ret;
>+
>+  log_debug("mydata %x, cur_dev %lx, block %x, nr_block %x\n",
>+mydata->sect_size, cur_dev->blksz, block, nr_blocks);
>+  if (mydata->sect_size > cur_dev->blksz ||
>+  cur_dev->blksz > sizeof(tbuf)) {
>+  log_err("Block size %lx not supported\n", cur_dev->blksz);
>+  return -EIO;
>+  }
>+  factor = cur_dev->blksz / mydata->sect_size;
>+
>+  /* get the first partial block */
>+  base = cur_part_info.start + block / factor;
>+  index = block % factor;
>+  log_debug("cur_part_info.start %llx, block %x, base %lx, index %lx\n",
>+(unsigned long long)cur_part_info.start, block, base, index);
>+  ret = blk_dread(cur_dev, base, 1, tbuf);
>+  if (ret != 1)
>+  return -EIO;
>+
>+  to_copy = min((ulong)nr_blocks, factor - index);
>+  log_debug("to_copy %x\n", to_copy);
>+  memcpy(buf, tbuf + index * mydata->sect_size,
>+ to_copy * mydata->sect_size);
>+  upto = to_copy;
>+
>+  /* load any whole blocks */
>+  remain = nr_blocks - upto;
>+  whole = remain / factor;
>+  log_debug("factor %x, whole %x, remain %x\n", factor, whole, remain);
>+  if (whole) {
>+  ret = blk_dread(cur_dev, base + 1, whole,
>+  buf + upto * mydata->sect_size);
>+  if (ret != whole)
>+  return -EIO;
>+  upto += whole * factor;
>+  remain = nr_blocks - upto;
>+  }
>+
>+  /* load any blocks at the end */
>+  log_debug("end: remain %x\n", remain);
>+  if (remain) {
>+  ret = blk_dread(cur_dev, base + 1 + whole, 1, tbuf);
>+  if (ret != 1)
>+  return -EIO;
>+  memcpy(buf + upto * mydata->sect_size, tbuf,
>+ remain * mydata->sect_size);
>+  upto += remain;
>+  }
>+
>+  return upto;
>+}
>+
>+static int disk_read(fsdata *mydata, __u32 block, 

Re: [PATCH 32/38] fs: fat: Shrink the size of a few strings

2023-03-30 Thread Heinrich Schuchardt



Am 30. März 2023 23:32:21 MESZ schrieb Simon Glass :
>To save a few bytes, replace Error with ** and try to use the same string
>for multiple messages where possible.
>
>Signed-off-by: Simon Glass 
>---
>
> fs/fat/fat.c   | 12 ++--
> fs/fat/fat_write.c | 14 --
> 2 files changed, 10 insertions(+), 16 deletions(-)
>
>diff --git a/fs/fat/fat.c b/fs/fat/fat.c
>index 2da93dae3cf3..f0df7988e172 100644
>--- a/fs/fat/fat.c
>+++ b/fs/fat/fat.c
>@@ -97,8 +97,8 @@ int fat_register_device(struct blk_desc *dev_desc, int 
>part_no)
>   /* Read the partition table, if present */
>   if (part_get_info(dev_desc, part_no, )) {
>   if (part_no != 0) {
>-  printf("** Partition %d not valid on device %d **\n",
>-  part_no, dev_desc->devnum);
>+  printf("** Partition %d invalid on device %d **\n",
>+ part_no, dev_desc->devnum);
>   return -1;
>   }
> 
>@@ -168,7 +168,7 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry)
>   __u32 ret = 0x00;
> 
>   if (CHECK_CLUST(entry, mydata->fatsize)) {
>-  printf("Error: Invalid FAT entry: 0x%08x\n", entry);
>+  printf("** Invalid FAT entry: %#08x\n", entry);

The ** is superfluous. The text makes it clear that an error occured


>   return ret;
>   }
> 
>@@ -586,17 +586,17 @@ static int get_fs_info(fsdata *mydata)
>   mydata->sect_size = (bs.sector_size[1] << 8) + bs.sector_size[0];
>   mydata->clust_size = bs.cluster_size;
>   if (mydata->sect_size != cur_part_info.blksz) {
>-  printf("Error: FAT sector size mismatch (fs=%hu, dev=%lu)\n",
>+  printf("** FAT sector size mismatch (fs=%hu, dev=%lu)\n",

ditto

>   mydata->sect_size, cur_part_info.blksz);
>   return -1;
>   }
>   if (mydata->clust_size == 0) {
>-  printf("Error: FAT cluster size not set\n");
>+  printf("** FAT cluster size not set\n");

ditto

>   return -1;
>   }
>   if ((unsigned int)mydata->clust_size * mydata->sect_size >
>   MAX_CLUSTSIZE) {
>-  printf("Error: FAT cluster size too big (cs=%u, max=%u)\n",
>+  printf("** FAT cluster size too big

ditto

 (cs=%u, max=%u)\n",
>  (unsigned int)mydata->clust_size * mydata->sect_size,
>  MAX_CLUSTSIZE);
>   return -1;
>diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
>index 00541ebc3a4a..4d2d4db07fa6 100644
>--- a/fs/fat/fat_write.c
>+++ b/fs/fat/fat_write.c
>@@ -1568,8 +1568,9 @@ int fat_unlink(const char *filename)
>   char *filename_copy, *dirname, *basename;
> 
>   filename_copy = strdup(filename);
>-  if (!filename_copy) {
>-  printf("Error: allocating memory\n");
>+  itr = malloc_cache_aligned(sizeof(fat_itr));
>+  if (!itr || !filename_copy) {
>+  printf("Error: out of memory\n");

remove 'Error: '

Best regards

Heinrich 

>   ret = -ENOMEM;
>   goto exit;
>   }
>@@ -1581,13 +1582,6 @@ int fat_unlink(const char *filename)
>   goto exit;
>   }
> 
>-  itr = malloc_cache_aligned(sizeof(fat_itr));
>-  if (!itr) {
>-  printf("Error: allocating memory\n");
>-  ret = -ENOMEM;
>-  goto exit;
>-  }
>-
>   ret = fat_itr_root(itr, );
>   if (ret)
>   goto exit;
>@@ -1602,7 +1596,7 @@ int fat_unlink(const char *filename)
>   }
> 
>   if (!find_directory_entry(itr, basename)) {
>-  printf("%s: doesn't exist\n", basename);
>+  printf("%s: doesn't exist (%d)\n", basename, -ENOENT);
>   ret = -ENOENT;
>   goto exit;
>   }


Re: [PATCH 18/38] efi: Show all known UUIDs with CONFIG_CMD_EFIDEBUG

2023-03-30 Thread Heinrich Schuchardt



Am 30. März 2023 23:32:07 MESZ schrieb Simon Glass :
>The CMD_EFIDEBUG option enables debugging so it is reasonable to assume
>that all effects should be made to decode the dreaded UUIDs favoured by
>UEFI.
>
>Update the table to show them all when CONFIG_CMD_EFIDEBUG is enabled.
>
>Signed-off-by: Simon Glass 
>---
>
> lib/uuid.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/lib/uuid.c b/lib/uuid.c
>index 96e1af3c8b00..ab30fbf9152f 100644
>--- a/lib/uuid.c
>+++ b/lib/uuid.c
>@@ -255,7 +255,7 @@ static const struct {
>   EFI_CERT_TYPE_PKCS7_GUID,
>   },
> #endif
>-#ifdef CONFIG_EFI
>+#if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI)
>   { "EFI_LZMA_COMPRESSED", EFI_LZMA_COMPRESSED },
>   { "EFI_DXE_SERVICES", EFI_DXE_SERVICES },
>   { "EFI_HOB_LIST", EFI_HOB_LIST },

None of these are used when not building the EFI app.

Best regards

Heinrich 


Re: [PATCH 14/38] qfw: Show the file address if available

2023-03-30 Thread Heinrich Schuchardt



Am 30. März 2023 23:32:03 MESZ schrieb Simon Glass :
>Some files have an associated address. Show this with the 'qfw list'
>command so that it is possible to dump the data.
>
>Signed-off-by: Simon Glass 
>---
>
> cmd/qfw.c |  2 +-
> doc/usage/cmd/qfw.rst | 28 
> 2 files changed, 17 insertions(+), 13 deletions(-)
>
>diff --git a/cmd/qfw.c b/cmd/qfw.c
>index ae3c6a7a84e9..d6ecfa60d5a7 100644
>--- a/cmd/qfw.c
>+++ b/cmd/qfw.c
>@@ -26,7 +26,7 @@ static int qemu_fwcfg_cmd_list_firmware(void)
>   for (file = qfw_file_iter_init(qfw_dev, );
>!qfw_file_iter_end();
>file = qfw_file_iter_next()) {
>-  printf("%-56s\n", file->cfg.name);
>+  printf("%08lx %-56s\n", file->addr, file->cfg.name);

Are the tables always in the lower 4GiB on all architectures (riscv64, arm64, 
x86)?

>   }
> 
>   return 0;
>diff --git a/doc/usage/cmd/qfw.rst b/doc/usage/cmd/qfw.rst
>index cc0e27c27790..76d74278a213 100644
>--- a/doc/usage/cmd/qfw.rst
>+++ b/doc/usage/cmd/qfw.rst
>@@ -11,6 +11,7 @@ Synopsis
> qfw list
> qfw cpus
> qfw load [kernel_addr [initrd_addr]]
>+qfw list
> 
> Description
> ---
>@@ -41,18 +42,21 @@ QEMU firmware files are listed via the *qfw list* command:
> ::
> 
> => qfw list
>-etc/boot-fail-wait
>-etc/smbios/smbios-tables
>-etc/smbios/smbios-anchor
>-etc/e820
>-genroms/kvmvapic.bin
>-genroms/linuxboot.bin
>-etc/system-states
>-etc/acpi/tables
>-etc/table-loader
>-etc/tpm/log
>-etc/acpi/rsdp
>-bootorder
>+ bios-geometry
>+ bootorder
>+000f0060 etc/acpi/rsdp
>+bed14040 etc/acpi/tables
>+ etc/boot-fail-wait
>+ etc/e820
>+ etc/smbios/smbios-anchor
>+ etc/smbios/smbios-tables
>+ etc/system-states
>+ etc/table-loader
>+ etc/tpm/log
>+ genroms/kvmvapic.bin
>+
>+Where an address is shown, it indicates where the data is available for
>+inspection, e.g. using the :doc:`md`.
> 
> The available CPUs can be shown via the *qfw cpus* command:
> 


Re: [PATCH 13/38] part: Allow setting the partition-table type

2023-03-30 Thread Heinrich Schuchardt



Am 30. März 2023 23:32:02 MESZ schrieb Simon Glass :
>Some devices have multiple partition types available on the same media.
>It is sometimes useful to see these to check that everything is working
>correctly.
>
>Provide a way to manually set the partition-table type, avoiding the
>auto-detection process.

Do you have an example image where we get it wrong?

Linux does not need that. What is different in our  table type  priorities to 
Linux?

I am not yet convinced we need to set this manually.

Best regards

Heinrich 


>
>Signed-off-by: Simon Glass 
>---
>
> cmd/part.c | 34 +++
> disk/part.c| 16 +
> doc/usage/cmd/part.rst | 74 ++
> include/part.h |  9 +
> 4 files changed, 133 insertions(+)
>
>diff --git a/cmd/part.c b/cmd/part.c
>index 28f2b7ff9bbe..0ce190005d32 100644
>--- a/cmd/part.c
>+++ b/cmd/part.c
>@@ -182,6 +182,36 @@ static int do_part_number(int argc, char *const argv[])
>   return do_part_info(argc, argv, CMD_PART_INFO_NUMBER);
> }
> 
>+static int do_part_set(int argc, char *const argv[])
>+{
>+  const char *devname, *partstr, *typestr;
>+  struct blk_desc *desc;
>+  int dev;
>+
>+  if (argc < 3)
>+  return CMD_RET_USAGE;
>+
>+  /* Look up the device */
>+  devname = argv[0];
>+  partstr = argv[1];
>+  typestr = argv[2];
>+  dev = blk_get_device_by_str(devname, partstr, );
>+  if (dev < 0) {
>+  printf("** Bad device specification %s %s **\n", devname,
>+ partstr);
>+  return CMD_RET_FAILURE;
>+  }
>+
>+  desc->part_type = part_get_type_by_name(typestr);
>+  if (!desc->part_type) {
>+  printf("Unknown partition type '%s'\n", typestr);
>+  return CMD_RET_FAILURE;
>+  }
>+  part_print(desc);
>+
>+  return 0;
>+}
>+
> #ifdef CONFIG_PARTITION_TYPE_GUID
> static int do_part_type(int argc, char *const argv[])
> {
>@@ -245,6 +275,8 @@ static int do_part(struct cmd_tbl *cmdtp, int flag, int 
>argc,
>   return do_part_number(argc - 2, argv + 2);
>   else if (!strcmp(argv[1], "types"))
>   return do_part_types(argc - 2, argv + 2);
>+  else if (!strcmp(argv[1], "set"))
>+  return do_part_set(argc - 2, argv + 2);
> #ifdef CONFIG_PARTITION_TYPE_GUID
>   else if (!strcmp(argv[1], "type"))
>   return do_part_type(argc - 2, argv + 2);
>@@ -279,6 +311,8 @@ U_BOOT_CMD(
> #endif
>   "part type  : \n"
>   "- set environment variable to partition type\n"
>+  "part set   type\n"
>+  "- set partition type for a device\n"
>   "part types\n"
>   "- list supported partition table types"
> );
>diff --git a/disk/part.c b/disk/part.c
>index d449635254e1..5274baaac208 100644
>--- a/disk/part.c
>+++ b/disk/part.c
>@@ -54,6 +54,22 @@ static struct part_driver *part_driver_lookup_type(struct 
>blk_desc *dev_desc)
>   return NULL;
> }
> 
>+int part_get_type_by_name(const char *name)
>+{
>+  struct part_driver *drv =
>+  ll_entry_start(struct part_driver, part_driver);
>+  const int n_ents = ll_entry_count(struct part_driver, part_driver);
>+  struct part_driver *entry;
>+
>+  for (entry = drv; entry != drv + n_ents; entry++) {
>+  if (!strcasecmp(name, entry->name))
>+  return entry->part_type;
>+  }
>+
>+  /* Not found */
>+  return PART_TYPE_UNKNOWN;
>+}
>+
> static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int 
> hwpart)
> {
>   struct blk_desc *dev_desc;
>diff --git a/doc/usage/cmd/part.rst b/doc/usage/cmd/part.rst
>index 8d2a2803912d..8a594aaff27e 100644
>--- a/doc/usage/cmd/part.rst
>+++ b/doc/usage/cmd/part.rst
>@@ -13,6 +13,7 @@ Synopis
> part start
> part size
> part number
>+part set
> part type  : [varname]
> part types
> 
>@@ -82,6 +83,18 @@ part must be specified as partition name.
> varname
> a variable to store the current partition number value into
> 
>+The 'part set' command sets the type of a partition. This is useful when
>+autodetection fails or does not do the correct thing:
>+
>+interface
>+interface for accessing the block device (mmc, sata, scsi, usb, )
>+dev
>+device number
>+part
>+partition number
>+type
>+partition type to use (see 'part types') to check available types
>+
> The 'part type' command prints or sets an environment variable to the 
> partition type UUID.
> 
> interface
>@@ -147,6 +160,67 @@ Examples
> => part types
> Supported partition tables: EFI, AMIGA, DOS, ISO, MAC
> 
>+This shows looking at a device with multiple partition tables::
>+
>+=> virtio scan
>+=> part list virtio 0
>+
>+Partition Map for VirtIO device 0  --   Partition Type: EFI
>+
>+Part  Start LBA   End LBA Name
>+

Re: [PATCH 10/38] x86: Show an error when a BINS exception occurs

2023-03-30 Thread Heinrich Schuchardt



Am 30. März 2023 23:31:59 MESZ schrieb Simon Glass :
>Rather than silently hanging, show an error first. This can happen when
>there is something wrong with the video BIOS.
>
>Signed-off-by: Simon Glass 
>---
>
> arch/x86/lib/bios.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>diff --git a/arch/x86/lib/bios.c b/arch/x86/lib/bios.c
>index 94349ba8073d..b28db31308f0 100644
>--- a/arch/x86/lib/bios.c
>+++ b/arch/x86/lib/bios.c
>@@ -78,7 +78,8 @@ static int int_exception_handler(void)
>   };
>   struct eregs *regs = _info;
> 
>-  debug("Oops, exception %d while executing option rom\n", regs->vector);
>+  log_err("Oops, exception %d while executing option rom\n",

Please, drop "Oops, " which does not add information. Do we have a function to 
convert the exception number to a string?

%s/rom/ROM/

Regards

Heinrich 

>+  regs->vector);
>   cpu_hlt();
> 
>   return 0;


Re: [PATCH 07/38] x86: Add a comment for board_init_f_r_trampoline()

2023-03-30 Thread Heinrich Schuchardt



Am 30. März 2023 23:31:56 MESZ schrieb Simon Glass :
>Add a comment for this function in the header.
>
>Change the function (and the one after) to use __noreturn to keep
>checkpatch happy.
>
>Signed-off-by: Simon Glass 
>---
>
> arch/x86/include/asm/u-boot-x86.h | 10 --
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
>diff --git a/arch/x86/include/asm/u-boot-x86.h 
>b/arch/x86/include/asm/u-boot-x86.h
>index 8f38c2d1c601..1610d7237bcd 100644
>--- a/arch/x86/include/asm/u-boot-x86.h
>+++ b/arch/x86/include/asm/u-boot-x86.h
>@@ -102,8 +102,14 @@ int video_bios_init(void);
>  */
> int fsp_save_s3_stack(void);
> 
>-void  board_init_f_r_trampoline(ulong) __attribute__ ((noreturn));
>-void  board_init_f_r(void) __attribute__ ((noreturn));
>+/**
>+ * board_init_f_r_trampoline() - jump to relocated address with new stack
>+ *
>+ * @sp: New stack pointer to use
>+ */
>+void __noreturn board_init_f_r_trampoline(ulong sp);
>+

missing function description

>+void __noreturn board_init_f_r(void);
> 

ditto

> int arch_misc_init(void);
> 


Re: [RFC PATCH v7 23/23] DO NOT MERGE: only to make CI happy

2023-03-30 Thread Francis Laniel
Hi.

Le jeudi 30 mars 2023, 21:17:33 WEST Tony Dinh a écrit :
> Hi Francis,
> 
> On Thu, Mar 30, 2023 at 12:50 PM Francis Laniel
> 
>  wrote:
> > This commit set CONFIG_HUSH_PARSER_2021 as the default to trigger the CI
> > with this parser.
> > 
> > Nonetheless, the keymile (i.e. VENDOR_KM) board family is not compatible
> > with new 2021 hush parser.
> > Indeed, This boards used set_local_var() to store some variables as local
> > shell. They then used get_local_var() to retrieve the variables values.
> > Sadly, this two functions do not exist with CONFIG_HUSH_PARSER_2021.
> > A patch was proposed to use environment variables rather than local
> > variables but it does not tackle the problem, so complementary work is
> > needed to make this boards use CONFIG_HUSH_PARSER_2021 [1].
> > 
> > We also remove a #undef of CONFIG_FEATURE_SH_STANDALONE as it does not
> > exist in U-Boot and causes troubles in the CI.
> > 
> > We also set CONFIG_LTO for kirkwoord sheevaplug and phytec bk4r1,
> > otherwise it hits its board size limit.
> > By enabling this option, we also had to add assembly for
> > __gnu_thumb1_case_si. It was taken from upstream gcc and adapted as width
> > suffix was removed for the add [2].
> 
> Thanks for adding __gnu_thumb1_case_si ! It will help not just the
> Sheevaplug board, but also a few other boards too. I'll give this a
> try.

You are welcome!
I nonetheless cannot ensure the modifications I brought to the code are correct 
as I do not have the board to test them.
So, if you can test it on a board it will be really welcomed and in case you 
find any problem I will add your suggested changes to the commit!

> 
> All the best,
> Tony
> 
> > Signed-off-by: Francis Laniel 
> > [1] https://marc.info/?l=u-boot=165541917618725=2
> > [2]
> > https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be901
> > 8f1611/libgcc/config/arm/lib1funcs.S#L2156 ---
> > 
> >  arch/arm/lib/lib1funcs.S | 17 +
> >  cmd/Kconfig  |  3 ++-
> >  common/cli_hush_upstream.c   |  1 -
> >  configs/bk4r1_defconfig  |  1 +
> >  configs/sheevaplug_defconfig |  1 +
> >  5 files changed, 21 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/lib/lib1funcs.S b/arch/arm/lib/lib1funcs.S
> > index de15d09e36..a1f44d9454 100644
> > --- a/arch/arm/lib/lib1funcs.S
> > +++ b/arch/arm/lib/lib1funcs.S
> > @@ -419,4 +419,21 @@ ENTRY(__gnu_thumb1_case_uhi)
> > 
> > ret lr
> >  
> >  ENDPROC(__gnu_thumb1_case_uhi)
> >  .popsection
> > 
> > +
> > +/* Taken and adapted from:
> > https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be901
> > 8f1611/libgcc/config/arm/lib1funcs.S#L2156 */ +.pushsection
> > .text.__gnu_thumb1_case_si, "ax"
> > +ENTRY(__gnu_thumb1_case_si)
> > +   push{r0, r1}
> > +   mov r1, lr
> > +   addsr1, r1, #2  /* Align to word.  */
> > +   lsrsr1, r1, #2
> > +   lslsr0, r0, #2
> > +   lslsr1, r1, #2
> > +   ldr r0, [r1, r0]
> > +   addsr0, r0, r1
> > +   mov lr, r0
> > +   pop {r0, r1}
> > +   mov pc, lr  /* We know we were called from thumb code.
> >  */ +ENDPROC(__gnu_thumb1_case_si)
> > +.popsection
> > 
> >  #endif
> > 
> > diff --git a/cmd/Kconfig b/cmd/Kconfig
> > index 1b9d04680d..d4809fcfa4 100644
> > --- a/cmd/Kconfig
> > +++ b/cmd/Kconfig
> > @@ -28,7 +28,7 @@ menu "Hush flavor to use"
> > 
> > config HUSH_OLD_PARSER
> > 
> > bool "Use hush old parser"
> > 
> > -   default y
> > +   default y if VENDOR_KM
> > 
> > help
> > 
> >   This option enables the old flavor of hush based on hush
> >   Busybox from
> >   2005.
> > 
> > @@ -37,6 +37,7 @@ menu "Hush flavor to use"
> > 
> > config HUSH_2021_PARSER
> > 
> > bool "Use hush 2021 parser"
> > 
> > +   default y if !VENDOR_KM
> > 
> > help
> > 
> >   This option enables the new flavor of hush based on hush
> >   Busybox from
> >   2021.
> > 
> > diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
> > index 93796e87c5..78a13eeb62 100644
> > --- a/common/cli_hush_upstream.c
> > +++ b/common/cli_hush_upstream.c
> > @@ -427,7 +427,6 @@
> > 
> >  #include "NUM_APPLETS.h"
> >  #if NUM_APPLETS == 1
> >  /* STANDALONE does not make sense, and won't compile */
> > 
> > -# undef CONFIG_FEATURE_SH_STANDALONE
> > 
> >  # undef ENABLE_FEATURE_SH_STANDALONE
> >  # undef IF_FEATURE_SH_STANDALONE
> >  # undef IF_NOT_FEATURE_SH_STANDALONE
> > 
> > diff --git a/configs/bk4r1_defconfig b/configs/bk4r1_defconfig
> > index 66adeac725..95f0c30cde 100644
> > --- a/configs/bk4r1_defconfig
> > +++ b/configs/bk4r1_defconfig
> > @@ -18,6 +18,7 @@ CONFIG_TARGET_BK4R1=y
> > 
> >  CONFIG_SYS_LOAD_ADDR=0x8200
> >  

Re: [PATCH 02/38] x86: Allow listing MTRRs in SPL

2023-03-30 Thread Heinrich Schuchardt



Am 30. März 2023 23:31:51 MESZ schrieb Simon Glass :
>When using video in SPL it is useful to see the values of the MTRR
>registers. Move this code into a shared file, so it can be called from
>SPL easily.
>
>Signed-off-by: Simon Glass 
>---
>
> arch/x86/cpu/mtrr.c | 61 +
> arch/x86/include/asm/mtrr.h | 20 
> cmd/x86/mtrr.c  | 60 +++-
> 3 files changed, 85 insertions(+), 56 deletions(-)
>
>diff --git a/arch/x86/cpu/mtrr.c b/arch/x86/cpu/mtrr.c
>index e69dfb552b16..1b5f24aab317 100644
>--- a/arch/x86/cpu/mtrr.c
>+++ b/arch/x86/cpu/mtrr.c
>@@ -30,6 +30,16 @@
> 
> DECLARE_GLOBAL_DATA_PTR;
> 
>+const char *const mtrr_type_name[MTRR_TYPE_COUNT] = {
>+  "Uncacheable",
>+  "Combine",
>+  "2",
>+  "3",
>+  "Through",
>+  "Protect",
>+  "Back",
>+};
>+
> /* Prepare to adjust MTRRs */
> void mtrr_open(struct mtrr_state *state, bool do_caches)
> {
>@@ -320,3 +330,54 @@ int mtrr_set(int cpu_select, int reg, u64 base, u64 mask)
> 
>   return mtrr_start_op(cpu_select, );
> }
>+
>+static void read_mtrrs_(void *arg)
>+{
>+  struct mtrr_info *info = arg;
>+
>+  mtrr_read_all(info);
>+}
>+
>+int mtrr_list(int reg_count, int cpu_select)
>+{
>+  struct mtrr_info info;
>+  int ret;
>+  int i;
>+
>+  printf("Reg Valid Write-type   %-16s %-16s %-16s\n", "Base   ||",
>+ "Mask   ||", "Size   ||");
>+  memset(, '\0', sizeof(info));
>+  ret = mp_run_on_cpus(cpu_select, read_mtrrs_, );
>+  if (ret)
>+  return log_msg_ret("run", ret);
>+  for (i = 0; i < reg_count; i++) {
>+  const char *type = "Invalid";
>+  u64 base, mask, size;
>+  bool valid;
>+
>+  base = info.mtrr[i].base;
>+  mask = info.mtrr[i].mask;
>+  size = ~mask & ((1ULL << CONFIG_CPU_ADDR_BITS) - 1);
>+  size |= (1 << 12) - 1;
>+  size += 1;
>+  valid = mask & MTRR_PHYS_MASK_VALID;
>+  type = mtrr_type_name[base & MTRR_BASE_TYPE_MASK];
>+  printf("%d   %-5s %-12s %016llx %016llx %016llx\n", i,
>+ valid ? "Y" : "N", type, base & ~MTRR_BASE_TYPE_MASK,
>+ mask & ~MTRR_PHYS_MASK_VALID, size);
>+  }
>+
>+  return 0;
>+}
>+
>+int mtrr_get_type_by_name(const char *typename)
>+{
>+  int i;
>+
>+  for (i = 0; i < MTRR_TYPE_COUNT; i++) {
>+  if (*typename == *mtrr_type_name[i])
>+  return i;
>+  }
>+
>+  return -EINVAL;
>+};
>diff --git a/arch/x86/include/asm/mtrr.h b/arch/x86/include/asm/mtrr.h
>index ca2edc7878f7..2e995f540616 100644
>--- a/arch/x86/include/asm/mtrr.h
>+++ b/arch/x86/include/asm/mtrr.h
>@@ -190,6 +190,26 @@ int mtrr_set(int cpu_select, int reg, u64 base, u64 mask);
>  */
> int mtrr_get_var_count(void);
> 
>+/**
>+ * mtrr_list() - List the MTRRs
>+ *
>+ * Shows a list of all the MTRRs including their values
>+ *
>+ * @reg_count: Number of registers to show. You can use mtrr_get_var_count() 
>for
>+ * this
>+ * @cpu_select: CPU to use. Use MP_SELECT_BSP for the boot CPU
>+ * Returns: 0 if OK, -ve if the CPU was not found
>+ */
>+int mtrr_list(int reg_count, int cpu_select);
>+
>+/**
>+ * mtrr_get_type_by_name() - Get the type of an MTRR given its type name
>+ *
>+ * @typename: Name to check
>+ * Returns: MTRR type (MTRR_TYPE_...) or -EINVAL if invalid
>+ */
>+int mtrr_get_type_by_name(const char *typename);
>+
> #endif
> 
> #if ((CONFIG_XIP_ROM_SIZE & (CONFIG_XIP_ROM_SIZE - 1)) != 0)
>diff --git a/cmd/x86/mtrr.c b/cmd/x86/mtrr.c
>index ff4be6b7bf5b..fd0e67e46eb3 100644
>--- a/cmd/x86/mtrr.c
>+++ b/cmd/x86/mtrr.c
>@@ -10,71 +10,19 @@
> #include 
> #include 
> 
>-static const char *const mtrr_type_name[MTRR_TYPE_COUNT] = {
>-  "Uncacheable",
>-  "Combine",
>-  "2",
>-  "3",
>-  "Through",
>-  "Protect",
>-  "Back",
>-};


Adding a "write-" prefix would make the meaning clearer

{
"uncachable", /* 0 */ 
"write-combining", /* 1 */ 
"2", /* 2 */
"3", /* 3 */ 
"write-through", /* 4 */
"write-protect", /* 5 */
"write-back", /* 6 */ 
};

Please, provide /doc/usage/cmd/mtrr.rst.

Best regards

Heinrich 

>-
>-static void read_mtrrs(void *arg)
>-{
>-  struct mtrr_info *info = arg;
>-
>-  mtrr_read_all(info);
>-}
>-
>-static int do_mtrr_list(int reg_count, int cpu_select)
>-{
>-  struct mtrr_info info;
>-  int ret;
>-  int i;
>-
>-  printf("Reg Valid Write-type   %-16s %-16s %-16s\n", "Base   ||",
>- "Mask   ||", "Size   ||");
>-  memset(, '\0', sizeof(info));
>-  ret = mp_run_on_cpus(cpu_select, read_mtrrs, );
>-  if (ret)
>-  return log_msg_ret("run", ret);
>-  for (i = 0; i < reg_count; i++) {
>-  const char *type = "Invalid";
>-  uint64_t base, mask, size;
>-  bool valid;
>-
>-  base = info.mtrr[i].base;
>-

Re: [PATCH 38/38] efi: Use the installed ACPI tables

2023-03-30 Thread Heinrich Schuchardt



Am 30. März 2023 23:32:27 MESZ schrieb Simon Glass :
>U-Boot sets up the ACPI tables during startup. Rather than creating a
>new set, install the existing ones. Create a memory-map record to cover
>the tables.

I understand that this works on QEMU which provides ACPI tables. But on all 
other systems that use ACPI you will still have to generate ACPI tables.

So you cannot simply drop the table generation.

If you have moved the generation step somewhere else, this patch should mention 
the new location.

Best regards

Heinrich


>
>Signed-off-by: Simon Glass 
>---
>
> lib/efi_loader/efi_acpi.c | 33 +++--
> 1 file changed, 19 insertions(+), 14 deletions(-)
>
>diff --git a/lib/efi_loader/efi_acpi.c b/lib/efi_loader/efi_acpi.c
>index 2ddc3502b5df..f755af76f866 100644
>--- a/lib/efi_loader/efi_acpi.c
>+++ b/lib/efi_loader/efi_acpi.c
>@@ -10,6 +10,9 @@
> #include 
> #include 
> #include 
>+#include 
>+
>+DECLARE_GLOBAL_DATA_PTR;
> 
> static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
> 
>@@ -20,26 +23,28 @@ static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
>  */
> efi_status_t efi_acpi_register(void)
> {
>-  /* Map within the low 32 bits, to allow for 32bit ACPI tables */
>-  u64 acpi = U32_MAX;
>+  ulong addr, start, end;
>   efi_status_t ret;
>-  ulong addr;
> 
>-  /* Reserve 64kiB page for ACPI */
>-  ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
>-   EFI_ACPI_RECLAIM_MEMORY, 16, );
>+  /* Mark space used for tables */
>+  start = ALIGN_DOWN(gd->arch.table_start, EFI_PAGE_MASK);
>+  end = ALIGN(gd->arch.table_end, EFI_PAGE_MASK);
>+  ret = efi_add_memory_map(start, end - start, EFI_ACPI_RECLAIM_MEMORY);
>   if (ret != EFI_SUCCESS)
>   return ret;
>+  if (gd->arch.table_start_high) {
>+  start = ALIGN_DOWN(gd->arch.table_start_high, EFI_PAGE_MASK);
>+  end = ALIGN(gd->arch.table_end_high, EFI_PAGE_MASK);
>+  ret = efi_add_memory_map(start, end - start,
>+   EFI_ACPI_RECLAIM_MEMORY);
>+  if (ret != EFI_SUCCESS)
>+  return ret;
>+  }
> 
>-  /*
>-   * Generate ACPI tables - we know that efi_allocate_pages() returns
>-   * a 4k-aligned address, so it is safe to assume that
>-   * write_acpi_tables() will write the table at that address.
>-   */
>-  addr = map_to_sysmem((void *)(ulong)acpi);
>-  write_acpi_tables(addr);
>+  addr = gd_acpi_start();
>+  printf("EFI using ACPI tables at %lx\n", addr);
> 
>   /* And expose them to our EFI payload */
>   return efi_install_configuration_table(_guid,
>- (void *)(uintptr_t)acpi);
>+ (void *)(ulong)addr);
> }


[PATCH 1/1] rockchip: Fix incorrect constant name in RAM init code

2023-03-30 Thread David Sebek
A condition in the rk3399 RAM initialization code used the old
CONFIG_RAM_RK3399_LPDDR4 constant name. This commit changes the
condition to use the correct CONFIG_RAM_ROCKCHIP_LPDDR4 constant.
---
 drivers/ram/rockchip/sdram_rk3399.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ram/rockchip/sdram_rk3399.c 
b/drivers/ram/rockchip/sdram_rk3399.c
index b1fea04e84..963a05c244 100644
--- a/drivers/ram/rockchip/sdram_rk3399.c
+++ b/drivers/ram/rockchip/sdram_rk3399.c
@@ -2954,7 +2954,7 @@ static int sdram_init(struct dram_info *dram,
params->ch[ch].cap_info.rank = rank;
}
 
-#if defined(CONFIG_RAM_RK3399_LPDDR4)
+#if defined(CONFIG_RAM_ROCKCHIP_LPDDR4)
/* LPDDR4 needs to be trained at 400MHz */
lpddr4_set_rate(dram, params, 0);
params->base.ddr_freq = dfs_cfgs_lpddr4[0].base.ddr_freq / MHz;
-- 
2.40.0



[PATCH 00/38] x86: Use qemu-x86_64 to boot EFI installers

2023-03-30 Thread Simon Glass
This series adds various minor features so that qemu-x86_64 can boot the
Ubuntu 2022.04 installer using a virtio device:

qemu-system-x86_64 -M pc -drive format=raw,file=root.img
-bios /tmp/b/qemu-x86_64/u-boot.rom
-drive if=virtio,file=ubuntu-22.04.2-desktop-amd64.iso
-smp 4 -m 4G -serial mon:stdio

The main changes include:
- Enable video in SPL while running in 32-bit mode
- Drop the duplicate ACPI tables with EFI
- Support PCI autoconfig in SPL
- Support FAT on a CDROM filesystem
- Improved bootstd rules around device tree and efi_set_bootdev()

There are also quite a number of minor tweaks and fixes to make things
easier to use.

This series is based on an older version of the SPL-video series from
Nikhil M Jain. It is available at u-boot-dm/bryc-working


Simon Glass (38):
  x86: Tidy up availability of string functions
  x86: Allow listing MTRRs in SPL
  bios_emulator: Add Kconfig and adjust Makefile for SPL
  bios_emulator: Drop VIDEO_IO_OFFSET
  x86: Tidy up EFI code in interrupt_init()
  x86: Set high bits of the mtrr base registrer
  x86: Add a comment for board_init_f_r_trampoline()
  x86: Show the CPU physical address size with bdinfo
  x86: Correct get_sp() implementation for 64-bit
  x86: Show an error when a BINS exception occurs
  acpi: Add a comment to set the acpi tables
  bdinfo: Show the RAM top and approximate stack pointer
  part: Allow setting the partition-table type
  qfw: Show the file address if available
  log: Tidy up an ambiguous comment.
  video: Allow building video drivers for SPL
  qfw: Set the address of the ACPI tables
  efi: Show all known UUIDs with CONFIG_CMD_EFIDEBUG
  x86: Improve the trampoline in 64-bit mode
  Show the malloc base with the bdinfo command
  nvme: Provide more useful debugging messages
  pci: Support autoconfig in SPL
  pci: Allow the video BIOS to work in SPL with QEMU
  pci: Tidy up logging and reporting for video BIOS
  x86: Allow video-BIOS code to be built for SPL
  x86: Pass video settings from SPL to U-Boot proper
  x86: Init video in SPL if enabled
  pci: Adjust video BIOS debugging to be SPL-friendly
  pci: Mask the ROM address in case it is already enabled
  x86: Enable display for QEMU 64-bit
  x86: Allow logging to be used in SPL reliably
  fs: fat: Shrink the size of a few strings
  fs: fat: Support reading from a larger block size
  x86: Enable useful options for qemu-86_64
  x86: Record the start and end of the tables
  sandbox: Correct header order in board file
  sandbox: Install ACPI tables on startup
  efi: Use the installed ACPI tables

 arch/sandbox/include/asm/global_data.h|   4 +
 arch/x86/cpu/i386/interrupt.c |  17 +--
 arch/x86/cpu/mtrr.c   |  62 +++-
 arch/x86/cpu/start64.S|  19 +++
 arch/x86/include/asm/global_data.h|   4 +
 arch/x86/include/asm/mtrr.h   |  20 +++
 arch/x86/include/asm/string.h |   6 +-
 arch/x86/include/asm/u-boot-x86.h |  21 ++-
 arch/x86/lib/Makefile |   9 +-
 arch/x86/lib/bdinfo.c |   5 +
 arch/x86/lib/bios.c   |   5 +-
 arch/x86/lib/bootm.c  |   2 +-
 arch/x86/lib/spl.c|  26 +++-
 arch/x86/lib/tables.c |   4 +-
 board/google/Kconfig  |   7 -
 board/sandbox/sandbox.c   |  22 ++-
 cmd/Kconfig   |   8 ++
 cmd/acpi.c|  24 +++-
 cmd/bdinfo.c  |   6 +
 cmd/part.c|  34 +
 cmd/qfw.c |   2 +-
 cmd/x86/mtrr.c|  60 +---
 common/board_f.c  |  12 +-
 common/board_r.c  |   7 +-
 common/log.c  |   2 +-
 configs/qemu-x86_64_defconfig |  14 ++
 disk/part.c   |  16 +++
 doc/usage/cmd/acpi.rst|  29 +++-
 doc/usage/cmd/part.rst|  74 ++
 doc/usage/cmd/qfw.rst |  28 ++--
 drivers/Kconfig   |   2 +
 drivers/Makefile  |   5 +-
 drivers/bios_emulator/Kconfig |  10 ++
 drivers/bios_emulator/biosemui.h  |  18 +--
 drivers/bios_emulator/x86emu/sys.c|   1 +
 drivers/misc/qfw.c|  12 ++
 drivers/nvme/nvme.c   |  36 +++--
 drivers/pci/Kconfig   |   8 ++
 drivers/pci/pci-uclass.c  |  10 +-
 drivers/pci/pci_rom.c | 165 +-
 fs/fat/Kconfig|  13 ++
 fs/fat/fat.c  | 117 ---
 fs/fat/fat_write.c|  22 ++-
 include/asm-generic/global_data.h |  11 ++
 include/bloblist.h|   1 +
 

[PATCH] include: configs: Change dtb names in fitImage to match oe-core

2023-03-30 Thread Ryan Eatmon
The oe-core class for assembling the fitImage includes the vendor
sub-directory (with the / changed to _) in the config sections of
the fitImage.  Our env var settings for chosing which section to
boot from needs to be updated to agree with the fitImage.

Signed-off-by: Ryan Eatmon 
---
 include/configs/am64x_evm.h  | 4 ++--
 include/configs/am65x_evm.h  | 2 +-
 include/configs/j721e_evm.h  | 6 +++---
 include/configs/j721s2_evm.h | 6 +++---
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/configs/am64x_evm.h b/include/configs/am64x_evm.h
index 26a7f2521e..456a44730c 100644
--- a/include/configs/am64x_evm.h
+++ b/include/configs/am64x_evm.h
@@ -26,9 +26,9 @@
 #define EXTRA_ENV_AM642_BOARD_SETTINGS \
"findfdt="  \
"if test $board_name = am64x_gpevm; then " \
-   "setenv fdtfile k3-am642-evm.dtb; fi; " \
+   "setenv fdtfile ti_k3-am642-evm.dtb; fi; " \
"if test $board_name = am64x_skevm; then " \
-   "setenv fdtfile k3-am642-sk.dtb; fi;" \
+   "setenv fdtfile ti_k3-am642-sk.dtb; fi;" \
"if test $fdtfile = undefined; then " \
"echo WARNING: Could not determine device tree to use; 
fi; \0" \
"name_kern=Image\0" \
diff --git a/include/configs/am65x_evm.h b/include/configs/am65x_evm.h
index 33dd6cfdfa..60a7eb1453 100644
--- a/include/configs/am65x_evm.h
+++ b/include/configs/am65x_evm.h
@@ -24,7 +24,7 @@
 /* U-Boot general configuration */
 #define EXTRA_ENV_AM65X_BOARD_SETTINGS \
"findfdt="  \
-   "setenv name_fdt k3-am654-base-board.dtb;"  \
+   "setenv name_fdt ti_k3-am654-base-board.dtb;"   \
"setenv fdtfile ${name_fdt}\0"  \
"name_kern=Image\0" \
"console=ttyS2,115200n8\0"  \
diff --git a/include/configs/j721e_evm.h b/include/configs/j721e_evm.h
index 48b1cea6e3..eac5cd5b76 100644
--- a/include/configs/j721e_evm.h
+++ b/include/configs/j721e_evm.h
@@ -34,11 +34,11 @@
 #define EXTRA_ENV_J721E_BOARD_SETTINGS \
"default_device_tree=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0"  \
"findfdt="  \
-   "setenv name_fdt ${default_device_tree};"   \
+   "setenv name_fdt ti_${default_device_tree};"\
"if test $board_name = j721e; then "\
-   "setenv name_fdt k3-j721e-common-proc-board.dtb; fi;" \
+   "setenv name_fdt ti_k3-j721e-common-proc-board.dtb; 
fi;" \
"if test $board_name = j721e-eaik || test $board_name = 
j721e-sk; then "\
-   "setenv name_fdt k3-j721e-sk.dtb; fi;"  \
+   "setenv name_fdt ti_k3-j721e-sk.dtb; fi;"   \
"setenv fdtfile ${name_fdt}\0"  \
"name_kern=Image\0" \
"console=ttyS2,115200n8\0"  \
diff --git a/include/configs/j721s2_evm.h b/include/configs/j721s2_evm.h
index bfada9eebc..b30a4a8da4 100644
--- a/include/configs/j721s2_evm.h
+++ b/include/configs/j721s2_evm.h
@@ -31,11 +31,11 @@
 #define EXTRA_ENV_J721S2_BOARD_SETTINGS
\
"default_device_tree=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0"  \
"findfdt="  \
-   "setenv name_fdt ${default_device_tree};"   \
+   "setenv name_fdt ti_${default_device_tree};"\
"if test $board_name = j721s2; then "   \
-   "setenv name_fdt k3-j721s2-common-proc-board.dtb; fi;" \
+   "setenv name_fdt ti_k3-j721s2-common-proc-board.dtb; 
fi;" \
"if test $board_name = am68-sk; then "  \
-   "setenv name_fdt k3-am68-sk-base-board.dtb; fi;"\
+   "setenv name_fdt ti_k3-am68-sk-base-board.dtb; fi;"\
"setenv fdtfile ${name_fdt}\0"  \
"name_kern=Image\0" \
"console=ttyS2,115200n8\0"  \
-- 
2.17.1



[PATCH] include: configs: Change dtb names in fitImage to match oe-core

2023-03-30 Thread Ryan Eatmon
The oe-core class for assembling the fitImage includes the vendor
sub-directory (with the / changed to _) in the config sections of
the fitImage.  Our env var settings for chosing which section to
boot from needs to be updated to agree with the fitImage.

Signed-off-by: Ryan Eatmon 
---
 include/configs/am64x_evm.h  | 4 ++--
 include/configs/am65x_evm.h  | 2 +-
 include/configs/j721e_evm.h  | 6 +++---
 include/configs/j721s2_evm.h | 6 +++---
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/configs/am64x_evm.h b/include/configs/am64x_evm.h
index 26a7f2521e..456a44730c 100644
--- a/include/configs/am64x_evm.h
+++ b/include/configs/am64x_evm.h
@@ -26,9 +26,9 @@
 #define EXTRA_ENV_AM642_BOARD_SETTINGS \
"findfdt="  \
"if test $board_name = am64x_gpevm; then " \
-   "setenv fdtfile k3-am642-evm.dtb; fi; " \
+   "setenv fdtfile ti_k3-am642-evm.dtb; fi; " \
"if test $board_name = am64x_skevm; then " \
-   "setenv fdtfile k3-am642-sk.dtb; fi;" \
+   "setenv fdtfile ti_k3-am642-sk.dtb; fi;" \
"if test $fdtfile = undefined; then " \
"echo WARNING: Could not determine device tree to use; 
fi; \0" \
"name_kern=Image\0" \
diff --git a/include/configs/am65x_evm.h b/include/configs/am65x_evm.h
index 33dd6cfdfa..60a7eb1453 100644
--- a/include/configs/am65x_evm.h
+++ b/include/configs/am65x_evm.h
@@ -24,7 +24,7 @@
 /* U-Boot general configuration */
 #define EXTRA_ENV_AM65X_BOARD_SETTINGS \
"findfdt="  \
-   "setenv name_fdt k3-am654-base-board.dtb;"  \
+   "setenv name_fdt ti_k3-am654-base-board.dtb;"   \
"setenv fdtfile ${name_fdt}\0"  \
"name_kern=Image\0" \
"console=ttyS2,115200n8\0"  \
diff --git a/include/configs/j721e_evm.h b/include/configs/j721e_evm.h
index 48b1cea6e3..eac5cd5b76 100644
--- a/include/configs/j721e_evm.h
+++ b/include/configs/j721e_evm.h
@@ -34,11 +34,11 @@
 #define EXTRA_ENV_J721E_BOARD_SETTINGS \
"default_device_tree=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0"  \
"findfdt="  \
-   "setenv name_fdt ${default_device_tree};"   \
+   "setenv name_fdt ti_${default_device_tree};"\
"if test $board_name = j721e; then "\
-   "setenv name_fdt k3-j721e-common-proc-board.dtb; fi;" \
+   "setenv name_fdt ti_k3-j721e-common-proc-board.dtb; 
fi;" \
"if test $board_name = j721e-eaik || test $board_name = 
j721e-sk; then "\
-   "setenv name_fdt k3-j721e-sk.dtb; fi;"  \
+   "setenv name_fdt ti_k3-j721e-sk.dtb; fi;"   \
"setenv fdtfile ${name_fdt}\0"  \
"name_kern=Image\0" \
"console=ttyS2,115200n8\0"  \
diff --git a/include/configs/j721s2_evm.h b/include/configs/j721s2_evm.h
index bfada9eebc..b30a4a8da4 100644
--- a/include/configs/j721s2_evm.h
+++ b/include/configs/j721s2_evm.h
@@ -31,11 +31,11 @@
 #define EXTRA_ENV_J721S2_BOARD_SETTINGS
\
"default_device_tree=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0"  \
"findfdt="  \
-   "setenv name_fdt ${default_device_tree};"   \
+   "setenv name_fdt ti_${default_device_tree};"\
"if test $board_name = j721s2; then "   \
-   "setenv name_fdt k3-j721s2-common-proc-board.dtb; fi;" \
+   "setenv name_fdt ti_k3-j721s2-common-proc-board.dtb; 
fi;" \
"if test $board_name = am68-sk; then "  \
-   "setenv name_fdt k3-am68-sk-base-board.dtb; fi;"\
+   "setenv name_fdt ti_k3-am68-sk-base-board.dtb; fi;"\
"setenv fdtfile ${name_fdt}\0"  \
"name_kern=Image\0" \
"console=ttyS2,115200n8\0"  \
-- 
2.17.1



Re: Missed rename of CONFIG_RAM_RK3399_LPDDR4

2023-03-30 Thread David Sebek
Correction: The correct condition should be:
#if defined(CONFIG_RAM_ROCKCHIP_LPDDR4)

The constant was renamed from CONFIG_RAM_RK3399_LPDDR4 to
CONFIG_RAM_ROCKCHIP_LPDDR4 in commit 26f92be0. I accidentally copy-pasted
the wrong value in my previous email.

On Thu, Mar 30, 2023 at 4:14 PM Simon Glass  wrote:

> +Jagan Teki
> +Kever Yang
>
> On Thu, 30 Mar 2023 at 15:26, David Sebek  wrote:
> >
> > Hi,
> >
> > I think this line:
> >
> https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/ram/rockchip/sdram_rk3399.c#L2957
> > should be
> >
> > #if defined(CONFIG_RAM_ROCKCHIP_DEBUG)
> > instead of
> > #if defined(CONFIG_RAM_RK3399_LPDDR4)
> >
> > The condition now evaluates to false on the RockPro64 board in the latest
> > U-Boot version, which I believe is incorrect.
> >
> > Thanks,
> > David Sebek
>


[PATCH 22/38] pci: Support autoconfig in SPL

2023-03-30 Thread Simon Glass
Allow PCI autoconfig to be handled in SPL, so that we can set it up
correctly for boards which need to do this before U-Boot proper. This
includes qemu-x64_64 which needs to set up the video device while in
32-bit mode.

Signed-off-by: Simon Glass 
---

 drivers/pci/Kconfig  |  8 
 drivers/pci/pci-uclass.c | 10 +-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index ef328d26525b..165f111a4f5b 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -40,6 +40,14 @@ config PCI_PNP
help
  Enable PCI memory and I/O space resource allocation and assignment.
 
+config SPL_PCI_PNP
+   bool "Enable Plug & Play support for PCI"
+   help
+ Enable PCI memory and I/O space resource allocation and assignment.
+ This is normally not done in SPL, but can be enabled if devices must
+ be set up in the SPL phase. Often it is enough to manually configure
+ one device, so this option can be disabled.
+
 config PCI_REGION_MULTI_ENTRY
bool "Enable Multiple entries of region type MEMORY in ranges for PCI"
help
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 8d27e40338cf..632c1a63cfce 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -722,6 +723,9 @@ static bool pci_need_device_pre_reloc(struct udevice *bus, 
uint vendor,
u32 vendev;
int index;
 
+   if (spl_phase() == PHASE_SPL && CONFIG_IS_ENABLED(PCI_PNP))
+   return true;
+
for (index = 0;
 !dev_read_u32_index(bus, "u-boot,pci-pre-reloc", index,
 );
@@ -793,7 +797,9 @@ static int pci_find_and_bind_driver(struct udevice *parent,
 * space is pretty limited (ie: using Cache As RAM).
 */
if (!(gd->flags & GD_FLG_RELOC) &&
-   !(drv->flags & DM_FLAG_PRE_RELOC))
+   !(drv->flags & DM_FLAG_PRE_RELOC) &&
+   (!CONFIG_IS_ENABLED(PCI_PNP) ||
+spl_phase() != PHASE_SPL))
return log_msg_ret("pre", -EPERM);
 
/*
@@ -918,6 +924,8 @@ int pci_bind_bus_devices(struct udevice *bus)
}
ret = pci_find_and_bind_driver(bus, _id, bdf,
   );
+   } else {
+   debug("device: %s\n", dev->name);
}
if (ret == -EPERM)
continue;
-- 
2.40.0.348.gf938b09366-goog



[PATCH 12/38] bdinfo: Show the RAM top and approximate stack pointer

2023-03-30 Thread Simon Glass
These are useful pieces of information when debugging. The RAM top shows
where U-Boot started allocating memory from, before it relocated. The
stack pointer can be checked to ensure it is in the correct region.

Signed-off-by: Simon Glass 
---

 cmd/Kconfig  | 8 
 cmd/bdinfo.c | 5 +
 2 files changed, 13 insertions(+)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 6ab05ea52aa2..cd47d7b9ef45 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -135,6 +135,14 @@ config CMD_BDI
help
  Print board info
 
+config CMD_BDINFO_EXTRA
+   bool "bdinfo extra features"
+   default y if SANDBOX || X86
+   help
+ Show additional information about the board. This uses a little more
+ code space but provides more options, particularly those useful for
+ bringup, development and debugging.
+
 config CMD_CONFIG
bool "config"
default SANDBOX
diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index f709904c5167..4e0c763a7096 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -145,6 +145,11 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
printf("devicetree  = %s\n", fdtdec_get_srcname());
}
 
+   if (IS_ENABLED(CONFIG_CMD_BDINFO_EXTRA)) {
+   bdinfo_print_num_ll("stack ptr", (ulong));
+   bdinfo_print_num_ll("ram_top ptr", (ulong)gd->ram_top);
+   }
+
arch_print_bdinfo();
 
return 0;
-- 
2.40.0.348.gf938b09366-goog



[PATCH 29/38] pci: Mask the ROM address in case it is already enabled

2023-03-30 Thread Simon Glass
In some cases the video ROM may have been enabled previously, such as by
a previous firmware stage. Use the correct address in that case.

Signed-off-by: Simon Glass 
---

 drivers/pci/pci_rom.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index 62cfe60c0fb2..ba2cf18d53eb 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -93,6 +93,7 @@ static int pci_rom_probe(struct udevice *dev, struct 
pci_rom_header **hdrp)
debug("%s: rom_address=%x\n", __func__, rom_address);
return -ENOENT;
}
+   rom_address &= PCI_ROM_ADDRESS_MASK;
 
/* Enable expansion ROM address decoding. */
dm_pci_write_config32(dev, PCI_ROM_ADDRESS,
-- 
2.40.0.348.gf938b09366-goog



[PATCH 27/38] x86: Init video in SPL if enabled

2023-03-30 Thread Simon Glass
When video is required in SPL, set this up ready for use. Ignore any
problems since it may be that video is not actually available and we
still want to continue on to U-Boot proper in that case.

Make sure that the SPL banner is only shown once.

Signed-off-by: Simon Glass 
---

 arch/x86/lib/spl.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/x86/lib/spl.c b/arch/x86/lib/spl.c
index bdf57ef7b5bd..0e1a18b251d7 100644
--- a/arch/x86/lib/spl.c
+++ b/arch/x86/lib/spl.c
@@ -15,10 +15,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -96,7 +98,8 @@ static int x86_spl_init(void)
return ret;
}
 #endif
-   preloader_console_init();
+   if (!IS_ENABLED(CONFIG_SPL_BOARD_INIT))
+   preloader_console_init();
 #if !defined(CONFIG_TPL) && !CONFIG_IS_ENABLED(CPU)
ret = print_cpuinfo();
if (ret) {
@@ -255,4 +258,12 @@ void spl_board_init(void)
 #ifndef CONFIG_TPL
preloader_console_init();
 #endif
+
+   if (CONFIG_IS_ENABLED(VIDEO)) {
+   struct udevice *dev;
+
+   /* Set up PCI video in SPL if required */
+   uclass_first_device_err(UCLASS_PCI, );
+   uclass_first_device_err(UCLASS_VIDEO, );
+   }
 }
-- 
2.40.0.348.gf938b09366-goog



[PATCH 37/38] sandbox: Install ACPI tables on startup

2023-03-30 Thread Simon Glass
With x86 we set up the ACPI tables on startup so they can be examined. Do
the same with sandbox, so it is consistent.

Signed-off-by: Simon Glass 
---

 board/sandbox/sandbox.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index e72d8164ebf6..2083eaa2dc55 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -15,7 +15,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -154,6 +156,8 @@ int extension_board_scan(struct list_head *extension_list)
 int board_late_init(void)
 {
struct udevice *dev;
+   ulong addr, end;
+   void *ptr;
int ret;
 
ret = uclass_first_device_err(UCLASS_CROS_EC, );
@@ -166,6 +170,18 @@ int board_late_init(void)
panic("Cannot init cros-ec device");
return -1;
}
+
+   if (IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) {
+   /* Reserve 64K for ACPI tables, aligned to a 4K boundary */
+   ptr = memalign(SZ_4K, SZ_64K);
+   addr = map_to_sysmem(ptr);
+
+   /* Generate ACPI tables */
+   end = write_acpi_tables(addr);
+   gd->arch.table_start = addr;
+   gd->arch.table_end = addr;
+   }
+
return 0;
 }
 #endif
-- 
2.40.0.348.gf938b09366-goog



[PATCH 38/38] efi: Use the installed ACPI tables

2023-03-30 Thread Simon Glass
U-Boot sets up the ACPI tables during startup. Rather than creating a
new set, install the existing ones. Create a memory-map record to cover
the tables.

Signed-off-by: Simon Glass 
---

 lib/efi_loader/efi_acpi.c | 33 +++--
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/lib/efi_loader/efi_acpi.c b/lib/efi_loader/efi_acpi.c
index 2ddc3502b5df..f755af76f866 100644
--- a/lib/efi_loader/efi_acpi.c
+++ b/lib/efi_loader/efi_acpi.c
@@ -10,6 +10,9 @@
 #include 
 #include 
 #include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
 
 static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
 
@@ -20,26 +23,28 @@ static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
  */
 efi_status_t efi_acpi_register(void)
 {
-   /* Map within the low 32 bits, to allow for 32bit ACPI tables */
-   u64 acpi = U32_MAX;
+   ulong addr, start, end;
efi_status_t ret;
-   ulong addr;
 
-   /* Reserve 64kiB page for ACPI */
-   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
-EFI_ACPI_RECLAIM_MEMORY, 16, );
+   /* Mark space used for tables */
+   start = ALIGN_DOWN(gd->arch.table_start, EFI_PAGE_MASK);
+   end = ALIGN(gd->arch.table_end, EFI_PAGE_MASK);
+   ret = efi_add_memory_map(start, end - start, EFI_ACPI_RECLAIM_MEMORY);
if (ret != EFI_SUCCESS)
return ret;
+   if (gd->arch.table_start_high) {
+   start = ALIGN_DOWN(gd->arch.table_start_high, EFI_PAGE_MASK);
+   end = ALIGN(gd->arch.table_end_high, EFI_PAGE_MASK);
+   ret = efi_add_memory_map(start, end - start,
+EFI_ACPI_RECLAIM_MEMORY);
+   if (ret != EFI_SUCCESS)
+   return ret;
+   }
 
-   /*
-* Generate ACPI tables - we know that efi_allocate_pages() returns
-* a 4k-aligned address, so it is safe to assume that
-* write_acpi_tables() will write the table at that address.
-*/
-   addr = map_to_sysmem((void *)(ulong)acpi);
-   write_acpi_tables(addr);
+   addr = gd_acpi_start();
+   printf("EFI using ACPI tables at %lx\n", addr);
 
/* And expose them to our EFI payload */
return efi_install_configuration_table(_guid,
-  (void *)(uintptr_t)acpi);
+  (void *)(ulong)addr);
 }
-- 
2.40.0.348.gf938b09366-goog



[PATCH 36/38] sandbox: Correct header order in board file

2023-03-30 Thread Simon Glass
Fix the header order in this file.

Signed-off-by: Simon Glass 
---

 board/sandbox/sandbox.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index 2e44bdf0df3e..e72d8164ebf6 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -11,16 +11,16 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
-
-#include 
+#include 
 
 /*
  * Pointer to initial global data area
-- 
2.40.0.348.gf938b09366-goog



[PATCH 35/38] x86: Record the start and end of the tables

2023-03-30 Thread Simon Glass
The ACPI tables are special in that they are passed to EFI as a separate
piece, independent of other tables.

Also they can be spread over two areas of memory, e.g. with QEMU we end
up with tables kept in high memory as well.

Add new global_data fields to hold this information and update the bdinfo
command to show the table areas.

Move the rom_table_end variable into the loop that uses it.

Signed-off-by: Simon Glass 
---

 arch/sandbox/include/asm/global_data.h | 4 
 arch/x86/include/asm/global_data.h | 4 
 arch/x86/lib/bdinfo.c  | 4 
 arch/x86/lib/tables.c  | 4 +++-
 drivers/misc/qfw.c | 8 
 5 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/include/asm/global_data.h 
b/arch/sandbox/include/asm/global_data.h
index f4ce72d56602..f0ab3ba5c146 100644
--- a/arch/sandbox/include/asm/global_data.h
+++ b/arch/sandbox/include/asm/global_data.h
@@ -13,6 +13,10 @@
 struct arch_global_data {
uint8_t *ram_buf;   /* emulated RAM buffer */
void*text_base; /* pointer to base of text region */
+   ulong table_start;  /* Start address of x86 tables */
+   ulong table_end;/* End address of x86 tables */
+   ulong table_start_high; /* Start address of high x86 tables */
+   ulong table_end_high;   /* End address of high x86 tables */
 };
 
 #include 
diff --git a/arch/x86/include/asm/global_data.h 
b/arch/x86/include/asm/global_data.h
index 22d103df4ee8..ea58259ad774 100644
--- a/arch/x86/include/asm/global_data.h
+++ b/arch/x86/include/asm/global_data.h
@@ -123,6 +123,10 @@ struct arch_global_data {
 #endif
void *itss_priv;/* Private ITSS data pointer */
ulong coreboot_table;   /* Address of coreboot table */
+   ulong table_start;  /* Start address of x86 tables */
+   ulong table_end;/* End address of x86 tables */
+   ulong table_start_high; /* Start address of high x86 tables */
+   ulong table_end_high;   /* End address of high x86 tables */
 };
 
 #endif
diff --git a/arch/x86/lib/bdinfo.c b/arch/x86/lib/bdinfo.c
index 0970efa4726f..9504e7fc293e 100644
--- a/arch/x86/lib/bdinfo.c
+++ b/arch/x86/lib/bdinfo.c
@@ -23,6 +23,10 @@ void arch_print_bdinfo(void)
bdinfo_print_str(" name", cpu_vendor_name(gd->arch.x86_vendor));
bdinfo_print_num_l("model", gd->arch.x86_model);
bdinfo_print_num_l("phys_addr", cpu_phys_address_size());
+   bdinfo_print_num_l("table start", gd->arch.table_start);
+   bdinfo_print_num_l("table end", gd->arch.table_end);
+   bdinfo_print_num_l(" high start", gd->arch.table_start_high);
+   bdinfo_print_num_l(" high end", gd->arch.table_end_high);
 
if (IS_ENABLED(CONFIG_EFI_STUB))
efi_show_bdinfo();
diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c
index ea834a5035f5..66b1700adc62 100644
--- a/arch/x86/lib/tables.c
+++ b/arch/x86/lib/tables.c
@@ -79,17 +79,18 @@ void table_fill_string(char *dest, const char *src, size_t 
n, char pad)
 int write_tables(void)
 {
u32 rom_table_start;
-   u32 rom_table_end;
u32 high_table, table_size;
struct memory_area cfg_tables[ARRAY_SIZE(table_list) + 1];
int i;
 
rom_table_start = ROM_TABLE_ADDR;
+   gd->arch.table_start = rom_table_start;
 
debug("Writing tables to %x:\n", rom_table_start);
for (i = 0; i < ARRAY_SIZE(table_list); i++) {
const struct table_info *table = _list[i];
int size = table->size ? : CONFIG_ROM_TABLE_SIZE;
+   u32 rom_table_end;
 
if (IS_ENABLED(CONFIG_BLOBLIST_TABLES) && table->tag) {
rom_table_start = (ulong)bloblist_add(table->tag, size,
@@ -131,6 +132,7 @@ int write_tables(void)
}
rom_table_start = rom_table_end;
}
+   gd->arch.table_end = rom_table_start;
 
if (IS_ENABLED(CONFIG_SEABIOS)) {
/* make sure the last item is zero */
diff --git a/drivers/misc/qfw.c b/drivers/misc/qfw.c
index 0a93feeb4b2e..c0da4bd7359e 100644
--- a/drivers/misc/qfw.c
+++ b/drivers/misc/qfw.c
@@ -65,6 +65,11 @@ static int bios_linker_allocate(struct udevice *dev,
printf("error: allocating resource\n");
return -ENOMEM;
}
+   if (aligned_addr < gd->arch.table_start_high)
+   gd->arch.table_start_high = aligned_addr;
+   if (aligned_addr + size > gd->arch.table_end_high)
+   gd->arch.table_end_high = aligned_addr + size;
+
} else if (entry->alloc.zone == BIOS_LINKER_LOADER_ALLOC_ZONE_FSEG) {
aligned_addr = ALIGN(*addr, align);
} else {
@@ -189,6 +194,9 @@ ulong write_acpi_tables(ulong addr)
return addr;

[PATCH 13/38] part: Allow setting the partition-table type

2023-03-30 Thread Simon Glass
Some devices have multiple partition types available on the same media.
It is sometimes useful to see these to check that everything is working
correctly.

Provide a way to manually set the partition-table type, avoiding the
auto-detection process.

Signed-off-by: Simon Glass 
---

 cmd/part.c | 34 +++
 disk/part.c| 16 +
 doc/usage/cmd/part.rst | 74 ++
 include/part.h |  9 +
 4 files changed, 133 insertions(+)

diff --git a/cmd/part.c b/cmd/part.c
index 28f2b7ff9bbe..0ce190005d32 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -182,6 +182,36 @@ static int do_part_number(int argc, char *const argv[])
return do_part_info(argc, argv, CMD_PART_INFO_NUMBER);
 }
 
+static int do_part_set(int argc, char *const argv[])
+{
+   const char *devname, *partstr, *typestr;
+   struct blk_desc *desc;
+   int dev;
+
+   if (argc < 3)
+   return CMD_RET_USAGE;
+
+   /* Look up the device */
+   devname = argv[0];
+   partstr = argv[1];
+   typestr = argv[2];
+   dev = blk_get_device_by_str(devname, partstr, );
+   if (dev < 0) {
+   printf("** Bad device specification %s %s **\n", devname,
+  partstr);
+   return CMD_RET_FAILURE;
+   }
+
+   desc->part_type = part_get_type_by_name(typestr);
+   if (!desc->part_type) {
+   printf("Unknown partition type '%s'\n", typestr);
+   return CMD_RET_FAILURE;
+   }
+   part_print(desc);
+
+   return 0;
+}
+
 #ifdef CONFIG_PARTITION_TYPE_GUID
 static int do_part_type(int argc, char *const argv[])
 {
@@ -245,6 +275,8 @@ static int do_part(struct cmd_tbl *cmdtp, int flag, int 
argc,
return do_part_number(argc - 2, argv + 2);
else if (!strcmp(argv[1], "types"))
return do_part_types(argc - 2, argv + 2);
+   else if (!strcmp(argv[1], "set"))
+   return do_part_set(argc - 2, argv + 2);
 #ifdef CONFIG_PARTITION_TYPE_GUID
else if (!strcmp(argv[1], "type"))
return do_part_type(argc - 2, argv + 2);
@@ -279,6 +311,8 @@ U_BOOT_CMD(
 #endif
"part type  : \n"
"- set environment variable to partition type\n"
+   "part set   type\n"
+   "- set partition type for a device\n"
"part types\n"
"- list supported partition table types"
 );
diff --git a/disk/part.c b/disk/part.c
index d449635254e1..5274baaac208 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -54,6 +54,22 @@ static struct part_driver *part_driver_lookup_type(struct 
blk_desc *dev_desc)
return NULL;
 }
 
+int part_get_type_by_name(const char *name)
+{
+   struct part_driver *drv =
+   ll_entry_start(struct part_driver, part_driver);
+   const int n_ents = ll_entry_count(struct part_driver, part_driver);
+   struct part_driver *entry;
+
+   for (entry = drv; entry != drv + n_ents; entry++) {
+   if (!strcasecmp(name, entry->name))
+   return entry->part_type;
+   }
+
+   /* Not found */
+   return PART_TYPE_UNKNOWN;
+}
+
 static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
 {
struct blk_desc *dev_desc;
diff --git a/doc/usage/cmd/part.rst b/doc/usage/cmd/part.rst
index 8d2a2803912d..8a594aaff27e 100644
--- a/doc/usage/cmd/part.rst
+++ b/doc/usage/cmd/part.rst
@@ -13,6 +13,7 @@ Synopis
 part start
 part size
 part number
+part set
 part type  : [varname]
 part types
 
@@ -82,6 +83,18 @@ part must be specified as partition name.
 varname
 a variable to store the current partition number value into
 
+The 'part set' command sets the type of a partition. This is useful when
+autodetection fails or does not do the correct thing:
+
+interface
+interface for accessing the block device (mmc, sata, scsi, usb, )
+dev
+device number
+part
+partition number
+type
+partition type to use (see 'part types') to check available types
+
 The 'part type' command prints or sets an environment variable to the 
partition type UUID.
 
 interface
@@ -147,6 +160,67 @@ Examples
 => part types
 Supported partition tables: EFI, AMIGA, DOS, ISO, MAC
 
+This shows looking at a device with multiple partition tables::
+
+=> virtio scan
+=> part list virtio 0
+
+Partition Map for VirtIO device 0  --   Partition Type: EFI
+
+Part   Start LBA   End LBA Name
+Attributes
+Type GUID
+Partition GUID
+1  0x0040  0x0092b093  "ISO9660"
+attrs: 0x1001
+type:  ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
+guid:  a0891d7e-b930-4513-94d8-f629dbd637b2
+2  0x0092b094  0x0092d7e7  "Appended2"
+attrs: 0x
+

[PATCH 05/38] x86: Tidy up EFI code in interrupt_init()

2023-03-30 Thread Simon Glass
The ll_boot_init() check handles the EFI case so we don't need the rest
of the code. Drop it.

Signed-off-by: Simon Glass 
---

 arch/x86/cpu/i386/interrupt.c | 17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/arch/x86/cpu/i386/interrupt.c b/arch/x86/cpu/i386/interrupt.c
index fae2544c456f..f3f3527237f2 100644
--- a/arch/x86/cpu/i386/interrupt.c
+++ b/arch/x86/cpu/i386/interrupt.c
@@ -266,6 +266,10 @@ int interrupt_init(void)
struct udevice *dev;
int ret;
 
+   /*
+* When running as an EFI application we are not in control of
+* interrupts and should leave them alone.
+*/
if (!ll_boot_init())
return 0;
 
@@ -274,11 +278,6 @@ int interrupt_init(void)
if (ret && ret != -ENODEV)
return ret;
 
-   /*
-* When running as an EFI application we are not in control of
-* interrupts and should leave them alone.
-*/
-#ifndef CONFIG_EFI_APP
/* Just in case... */
disable_interrupts();
 
@@ -294,14 +293,8 @@ int interrupt_init(void)
/* Initialize core interrupt and exception functionality of CPU */
cpu_init_interrupts();
 
-   /*
-* It is now safe to enable interrupts.
-*
-* TODO(s...@chromium.org): But we don't handle these correctly when
-* booted from EFI.
-*/
+   /* It is now safe to enable interrupts */
enable_interrupts();
-#endif
 
return 0;
 }
-- 
2.40.0.348.gf938b09366-goog



RISC-V FIT image type

2023-03-30 Thread Simon Glass
Hi,

I notice that in image.h we have IH_ARCH_RISCV but no mention of
IH_ARCH_RISCV64. Should we not have two separate image types, as we do
with ARM and x86? Otherwise, how would a loader know the word size of
the target machine?

Regards,
Simon


[PATCH 34/38] x86: Enable useful options for qemu-86_64

2023-03-30 Thread Simon Glass
This build can be used to boot standard distro builds, since these are
mostly 64-bit these days. Enable some more options, so that all possible
EFI UUIDs are decoded, we get a proper printf() in SPL, can search
memory for tables, support the full set of standard-boot features, have
full logging and can boot from CDROM media.

Signed-off-by: Simon Glass 
---

 configs/qemu-x86_64_defconfig | 8 
 1 file changed, 8 insertions(+)

diff --git a/configs/qemu-x86_64_defconfig b/configs/qemu-x86_64_defconfig
index 371ca9de8429..79ea35918575 100644
--- a/configs/qemu-x86_64_defconfig
+++ b/configs/qemu-x86_64_defconfig
@@ -19,6 +19,7 @@ CONFIG_GENERATE_MP_TABLE=y
 CONFIG_X86_OFFSET_U_BOOT=0xfff0
 CONFIG_FIT=y
 CONFIG_SPL_LOAD_FIT=y
+CONFIG_BOOTSTD_FULL=y
 CONFIG_SYS_MONITOR_BASE=0x0111
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTSTAGE=y
@@ -27,6 +28,9 @@ CONFIG_SHOW_BOOT_PROGRESS=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro"
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
+CONFIG_LOG=y
+CONFIG_LOGF_FUNC=y
+CONFIG_SPL_LOG=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_PCI_INIT_R=y
@@ -46,12 +50,14 @@ CONFIG_SYS_PBSIZE=532
 CONFIG_CMD_CPU=y
 CONFIG_CMD_BOOTEFI_SELFTEST=y
 CONFIG_CMD_NVEDIT_EFI=y
+CONFIG_CMD_MEM_SEARCH=y
 CONFIG_CMD_IDE=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_BOOTP_BOOTFILESIZE=y
 # CONFIG_CMD_NFS is not set
+CONFIG_CMD_EFIDEBUG=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_QFW=y
 CONFIG_CMD_BOOTSTAGE=y
@@ -83,5 +89,7 @@ CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
 CONFIG_FRAMEBUFFER_VESA_MODE_USER=y
 CONFIG_FRAMEBUFFER_VESA_MODE=0x144
 CONFIG_CONSOLE_SCROLL_LINES=5
+CONFIG_FAT_BLK_XLATE=y
+# CONFIG_SPL_USE_TINY_PRINTF is not set
 CONFIG_GENERATE_ACPI_TABLE=y
 # CONFIG_GZIP is not set
-- 
2.40.0.348.gf938b09366-goog



[PATCH 33/38] fs: fat: Support reading from a larger block size

2023-03-30 Thread Simon Glass
At present it is not possible to read from some CDROM drives since the
FAT sector size does not match the media's block size. Add a conversion
option for this, so that reading is possible.

This does increase SPL size for read-only FAT support by 25 bytes but
all but 6 are covered by the previous patch. We could reduce the
overhead of this feature to 0 bytes by making the code uglier (using
a static variable).

Signed-off-by: Simon Glass 
---

 fs/fat/Kconfig |  13 ++
 fs/fat/fat.c   | 107 -
 fs/fat/fat_write.c |   8 ++--
 3 files changed, 114 insertions(+), 14 deletions(-)

diff --git a/fs/fat/Kconfig b/fs/fat/Kconfig
index 9bb11eac9f7a..b0aa888c6cc4 100644
--- a/fs/fat/Kconfig
+++ b/fs/fat/Kconfig
@@ -22,3 +22,16 @@ config FS_FAT_MAX_CLUSTSIZE
  is the smallest amount of disk space that can be used to hold a
  file. Unless you have an extremely tight memory memory constraints,
  leave the default.
+
+config FAT_BLK_XLATE
+   bool "Enable FAT filesystem on a device with a larger block size"
+   depends on FS_FAT
+   help
+ This provides a simple translation mechanism for reading FAT
+ filesystems which don't use the same sector size as the underlying
+ media. For example, the FAT filesystem may use 512 bytes but the
+ media uses 2048, e.g. on a CDROM drive.
+
+ This only supports the case where the FAT filesystem's sector size is
+ smaller than the media's block size. It does not support creating or
+ writing files.
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index f0df7988e172..02c6d55a99b3 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -43,13 +43,93 @@ static struct disk_partition cur_part_info;
 #define DOS_FS_TYPE_OFFSET 0x36
 #define DOS_FS32_TYPE_OFFSET   0x52
 
-static int disk_read(__u32 block, __u32 nr_blocks, void *buf)
+/**
+ * disk_read_conv() - Read blocks and break them into smaller ones
+ *
+ * This is used when the FAT filesystem is hosted on a block device with a
+ * block size greated than 512 bytes, e.g. the 2048 bytes of a CDROM drive. It
+ * reads the blocks into a buffer and pulls out what is requested by the 
calling
+ * function.
+ *
+ * It uses an internal 2KB buffer on the stack.
+ *
+ * @mydata: Filesystem information
+ * @block: Block number to read, in terms of mydata->sect_size
+ * @nr_blocks: Number of blocks to read, in terms of mydata->sect_size
+ * @buf: Buffer for data
+ */
+static int disk_read_conv(fsdata *mydata, __u32 block, __u32 nr_blocks,
+ void *buf)
+{
+   uint factor, whole, remain, upto;
+   ulong base, index;
+   uint to_copy;
+   u8 tbuf[2048];
+   int ret;
+
+   log_debug("mydata %x, cur_dev %lx, block %x, nr_block %x\n",
+ mydata->sect_size, cur_dev->blksz, block, nr_blocks);
+   if (mydata->sect_size > cur_dev->blksz ||
+   cur_dev->blksz > sizeof(tbuf)) {
+   log_err("Block size %lx not supported\n", cur_dev->blksz);
+   return -EIO;
+   }
+   factor = cur_dev->blksz / mydata->sect_size;
+
+   /* get the first partial block */
+   base = cur_part_info.start + block / factor;
+   index = block % factor;
+   log_debug("cur_part_info.start %llx, block %x, base %lx, index %lx\n",
+ (unsigned long long)cur_part_info.start, block, base, index);
+   ret = blk_dread(cur_dev, base, 1, tbuf);
+   if (ret != 1)
+   return -EIO;
+
+   to_copy = min((ulong)nr_blocks, factor - index);
+   log_debug("to_copy %x\n", to_copy);
+   memcpy(buf, tbuf + index * mydata->sect_size,
+  to_copy * mydata->sect_size);
+   upto = to_copy;
+
+   /* load any whole blocks */
+   remain = nr_blocks - upto;
+   whole = remain / factor;
+   log_debug("factor %x, whole %x, remain %x\n", factor, whole, remain);
+   if (whole) {
+   ret = blk_dread(cur_dev, base + 1, whole,
+   buf + upto * mydata->sect_size);
+   if (ret != whole)
+   return -EIO;
+   upto += whole * factor;
+   remain = nr_blocks - upto;
+   }
+
+   /* load any blocks at the end */
+   log_debug("end: remain %x\n", remain);
+   if (remain) {
+   ret = blk_dread(cur_dev, base + 1 + whole, 1, tbuf);
+   if (ret != 1)
+   return -EIO;
+   memcpy(buf + upto * mydata->sect_size, tbuf,
+  remain * mydata->sect_size);
+   upto += remain;
+   }
+
+   return upto;
+}
+
+static int disk_read(fsdata *mydata, __u32 block, __u32 nr_blocks, void *buf)
 {
ulong ret;
 
if (!cur_dev)
return -1;
 
+   /* support converting from a larger block size */
+   if (IS_ENABLED(CONFIG_FAT_BLK_XLATE) && mydata &&
+   mydata->sect_size != 

[PATCH 32/38] fs: fat: Shrink the size of a few strings

2023-03-30 Thread Simon Glass
To save a few bytes, replace Error with ** and try to use the same string
for multiple messages where possible.

Signed-off-by: Simon Glass 
---

 fs/fat/fat.c   | 12 ++--
 fs/fat/fat_write.c | 14 --
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 2da93dae3cf3..f0df7988e172 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -97,8 +97,8 @@ int fat_register_device(struct blk_desc *dev_desc, int 
part_no)
/* Read the partition table, if present */
if (part_get_info(dev_desc, part_no, )) {
if (part_no != 0) {
-   printf("** Partition %d not valid on device %d **\n",
-   part_no, dev_desc->devnum);
+   printf("** Partition %d invalid on device %d **\n",
+  part_no, dev_desc->devnum);
return -1;
}
 
@@ -168,7 +168,7 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry)
__u32 ret = 0x00;
 
if (CHECK_CLUST(entry, mydata->fatsize)) {
-   printf("Error: Invalid FAT entry: 0x%08x\n", entry);
+   printf("** Invalid FAT entry: %#08x\n", entry);
return ret;
}
 
@@ -586,17 +586,17 @@ static int get_fs_info(fsdata *mydata)
mydata->sect_size = (bs.sector_size[1] << 8) + bs.sector_size[0];
mydata->clust_size = bs.cluster_size;
if (mydata->sect_size != cur_part_info.blksz) {
-   printf("Error: FAT sector size mismatch (fs=%hu, dev=%lu)\n",
+   printf("** FAT sector size mismatch (fs=%hu, dev=%lu)\n",
mydata->sect_size, cur_part_info.blksz);
return -1;
}
if (mydata->clust_size == 0) {
-   printf("Error: FAT cluster size not set\n");
+   printf("** FAT cluster size not set\n");
return -1;
}
if ((unsigned int)mydata->clust_size * mydata->sect_size >
MAX_CLUSTSIZE) {
-   printf("Error: FAT cluster size too big (cs=%u, max=%u)\n",
+   printf("** FAT cluster size too big (cs=%u, max=%u)\n",
   (unsigned int)mydata->clust_size * mydata->sect_size,
   MAX_CLUSTSIZE);
return -1;
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index 00541ebc3a4a..4d2d4db07fa6 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -1568,8 +1568,9 @@ int fat_unlink(const char *filename)
char *filename_copy, *dirname, *basename;
 
filename_copy = strdup(filename);
-   if (!filename_copy) {
-   printf("Error: allocating memory\n");
+   itr = malloc_cache_aligned(sizeof(fat_itr));
+   if (!itr || !filename_copy) {
+   printf("Error: out of memory\n");
ret = -ENOMEM;
goto exit;
}
@@ -1581,13 +1582,6 @@ int fat_unlink(const char *filename)
goto exit;
}
 
-   itr = malloc_cache_aligned(sizeof(fat_itr));
-   if (!itr) {
-   printf("Error: allocating memory\n");
-   ret = -ENOMEM;
-   goto exit;
-   }
-
ret = fat_itr_root(itr, );
if (ret)
goto exit;
@@ -1602,7 +1596,7 @@ int fat_unlink(const char *filename)
}
 
if (!find_directory_entry(itr, basename)) {
-   printf("%s: doesn't exist\n", basename);
+   printf("%s: doesn't exist (%d)\n", basename, -ENOENT);
ret = -ENOENT;
goto exit;
}
-- 
2.40.0.348.gf938b09366-goog



[PATCH 30/38] x86: Enable display for QEMU 64-bit

2023-03-30 Thread Simon Glass
Enable the various options needed for display to work on the qemu-x86_64
board. This includes expanding the available malloc() memory in SPL,
since the PCI bus must be enumerated in order to find the video device.

It also includes enabling a bloblist, so that the video parameters can be
passed. This is placed at address 1 but is not needed after U-Boot
proper reads the information there.

Signed-off-by: Simon Glass 
---

 configs/qemu-x86_64_defconfig | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/configs/qemu-x86_64_defconfig b/configs/qemu-x86_64_defconfig
index f29a5aa0f813..371ca9de8429 100644
--- a/configs/qemu-x86_64_defconfig
+++ b/configs/qemu-x86_64_defconfig
@@ -7,6 +7,7 @@ CONFIG_MAX_CPUS=2
 CONFIG_SPL_DM_SPI=y
 CONFIG_DEFAULT_DEVICE_TREE="qemu-x86_i440fx"
 CONFIG_SPL_TEXT_BASE=0xfffd
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x2000
 CONFIG_DEBUG_UART_BASE=0x3f8
 CONFIG_DEBUG_UART_CLOCK=1843200
 CONFIG_X86_RUN_64BIT=y
@@ -29,7 +30,10 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_PCI_INIT_R=y
+CONFIG_BLOBLIST=y
+CONFIG_BLOBLIST_ADDR=0x1
 CONFIG_SPL_NO_BSS_LIMIT=y
+CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_CPU=y
 CONFIG_SPL_ENV_SUPPORT=y
@@ -69,10 +73,12 @@ CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_CPU=y
 CONFIG_NVME_PCI=y
+CONFIG_SPL_PCI_PNP=y
 CONFIG_SPL_DM_RTC=y
 CONFIG_SYS_NS16550_PORT_MAPPED=y
 CONFIG_SPI=y
 CONFIG_USB_KEYBOARD=y
+CONFIG_SPL_VIDEO=y
 CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
 CONFIG_FRAMEBUFFER_VESA_MODE_USER=y
 CONFIG_FRAMEBUFFER_VESA_MODE=0x144
-- 
2.40.0.348.gf938b09366-goog



[PATCH 31/38] x86: Allow logging to be used in SPL reliably

2023-03-30 Thread Simon Glass
When global_data is relocated, log_head moves in memory, meaning that
the items in that list point to the wrong place.

Disable logging when making the change, then reenable it afterwards, so
that logging works normally.

Signed-off-by: Simon Glass 
---

 arch/x86/lib/spl.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/arch/x86/lib/spl.c b/arch/x86/lib/spl.c
index 0e1a18b251d7..3253b0a26062 100644
--- a/arch/x86/lib/spl.c
+++ b/arch/x86/lib/spl.c
@@ -137,9 +137,22 @@ static int x86_spl_init(void)
 */
gd->new_gd = (struct global_data *)ptr;
memcpy(gd->new_gd, gd, sizeof(*gd));
+
+   /*
+* Make sure logging is disabled when we switch, since the log system
+* list head will move
+*/
+   gd->new_gd->flags &= ~GD_FLG_LOG_READY;
arch_setup_gd(gd->new_gd);
gd->start_addr_sp = (ulong)ptr;
 
+   /* start up logging again, with the new list-head location */
+   ret = log_init();
+   if (ret) {
+   log_debug("Log setup failed (err=%d)\n", ret);
+   return ret;
+   }
+
/* Cache the SPI flash. Otherwise copying the code to RAM takes ages */
ret = mtrr_add_request(MTRR_TYPE_WRBACK,
   (1ULL << 32) - CONFIG_XIP_ROM_SIZE,
-- 
2.40.0.348.gf938b09366-goog



[PATCH 28/38] pci: Adjust video BIOS debugging to be SPL-friendly

2023-03-30 Thread Simon Glass
A hex value is expected for the VGA mode. Drop the 0x prefix, which is
not supported in SPL.

Signed-off-by: Simon Glass 
---

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

diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index ecb6da64c5c9..62cfe60c0fb2 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -319,7 +319,7 @@ int dm_pci_run_vga_bios(struct udevice *dev, int 
(*int15_handler)(void),
defined(CONFIG_FRAMEBUFFER_VESA_MODE)
vesa_mode = CONFIG_FRAMEBUFFER_VESA_MODE;
 #endif
-   debug("Selected vesa mode %#x\n", vesa_mode);
+   debug("Selected vesa mode %x\n", vesa_mode);
 
if (exec_method & PCI_ROM_USE_NATIVE) {
 #ifdef CONFIG_X86
@@ -370,7 +370,7 @@ int dm_pci_run_vga_bios(struct udevice *dev, int 
(*int15_handler)(void),
log_debug("done\n");
 #endif
}
-   debug("Final vesa mode %#x\n", mode_info.video_mode);
+   debug("Final vesa mode %x\n", mode_info.video_mode);
ret = 0;
 
 err:
-- 
2.40.0.348.gf938b09366-goog



[PATCH 26/38] x86: Pass video settings from SPL to U-Boot proper

2023-03-30 Thread Simon Glass
When video is set up in SPL, U-Boot proper needs to use the correct
parameters so it can write to the display.

Put these in a bloblist so they are available to U-Boot proper.

Signed-off-by: Simon Glass 
---

 drivers/pci/pci_rom.c | 78 +++
 include/bloblist.h|  1 +
 include/video.h   | 24 +
 3 files changed, 82 insertions(+), 21 deletions(-)

diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index 2d9a2a899ef7..ecb6da64c5c9 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -26,6 +26,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -34,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -420,34 +422,68 @@ int vesa_setup_video(struct udevice *dev, int 
(*int15_handler)(void))
printf("Not available (previous bootloader prevents it)\n");
return -EPERM;
}
-   bootstage_start(BOOTSTAGE_ID_ACCUM_LCD, "vesa display");
-   ret = dm_pci_run_vga_bios(dev, int15_handler, PCI_ROM_USE_NATIVE |
-   PCI_ROM_ALLOW_FALLBACK);
-   bootstage_accum(BOOTSTAGE_ID_ACCUM_LCD);
-   if (ret) {
-   debug("failed to run video BIOS: %d\n", ret);
-   return ret;
-   }
 
-   ret = vesa_setup_video_priv(_info.vesa,
-   mode_info.vesa.phys_base_ptr, uc_priv,
-   plat);
-   if (ret) {
-   if (ret == -ENFILE) {
-   /*
-* See video-uclass.c for how to set up reserved memory
-* in your video driver
-*/
-   log_err("CONFIG_VIDEO_COPY enabled but driver '%s' set 
up no reserved memory\n",
-   dev->driver->name);
+   /* In U-Boot proper, collect the information added by SPL (see below) */
+   if (IS_ENABLED(CONFIG_SPL_VIDEO) && spl_phase() > PHASE_SPL &&
+   CONFIG_IS_ENABLED(BLOBLIST)) {
+   struct video_handoff *ho;
+
+   ho = bloblist_find(BLOBLISTT_U_BOOT_VIDEO, sizeof(*ho));
+   if (!ho)
+   return log_msg_ret("blf", -ENOENT);
+   plat->base = ho->fb;
+   plat->size = ho->size;
+   uc_priv->xsize = ho->xsize;
+   uc_priv->ysize = ho->ysize;
+   uc_priv->line_length = ho->line_length;
+   uc_priv->bpix = ho->bpix;
+   } else {
+   bootstage_start(BOOTSTAGE_ID_ACCUM_LCD, "vesa display");
+   ret = dm_pci_run_vga_bios(dev, int15_handler,
+ PCI_ROM_USE_NATIVE |
+ PCI_ROM_ALLOW_FALLBACK);
+   bootstage_accum(BOOTSTAGE_ID_ACCUM_LCD);
+   if (ret) {
+   debug("failed to run video BIOS: %d\n", ret);
+   return ret;
}
 
-   debug("No video mode configured\n");
-   return ret;
+   ret = vesa_setup_video_priv(_info.vesa,
+   mode_info.vesa.phys_base_ptr,
+   uc_priv, plat);
+   if (ret) {
+   if (ret == -ENFILE) {
+   /*
+* See video-uclass.c for how to set up reserved
+* memory in your video driver
+*/
+   log_err("CONFIG_VIDEO_COPY enabled but driver 
'%s' set up no reserved memory\n",
+   dev->driver->name);
+   }
+
+   debug("No video mode configured\n");
+   return ret;
+   }
}
 
printf("Video: %dx%dx%d\n", uc_priv->xsize, uc_priv->ysize,
   mode_info.vesa.bits_per_pixel);
 
+   /* In SPL, store the information for use by U-Boot proper */
+   if (spl_phase() == PHASE_SPL && CONFIG_IS_ENABLED(BLOBLIST)) {
+   struct video_handoff *ho;
+
+   ho = bloblist_add(BLOBLISTT_U_BOOT_VIDEO, sizeof(*ho), 0);
+   if (!ho)
+   return log_msg_ret("blc", -ENOMEM);
+
+   ho->fb = plat->base;
+   ho->size = plat->size;
+   ho->xsize = uc_priv->xsize;
+   ho->ysize = uc_priv->ysize;
+   ho->line_length = uc_priv->line_length;
+   ho->bpix = uc_priv->bpix;
+   }
+
return 0;
 }
diff --git a/include/bloblist.h b/include/bloblist.h
index 2a2f1700eb09..7ea72c6bd46d 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -113,6 +113,7 @@ enum bloblist_tag_t {
BLOBLISTT_PROJECT_AREA = 0x8000,
BLOBLISTT_U_BOOT_SPL_HANDOFF = 0x8000, /* Hand-off info from SPL */
   

[PATCH 25/38] x86: Allow video-BIOS code to be built for SPL

2023-03-30 Thread Simon Glass
With qemu-x86_64 we need to run the video BIOS while in 32-bit mode, i.e.
SPL. Add a Kconfig option for this, adjust the Makefile rules and use
CONFIG_IS_ENABLED() where needed.

Signed-off-by: Simon Glass 
---

 arch/x86/lib/Makefile |  7 ---
 arch/x86/lib/bios.c   |  2 +-
 drivers/pci/pci_rom.c | 28 ++--
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index b0612ae6dd5f..90a7618ecfde 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -4,16 +4,17 @@
 # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 
 obj-y  += bdinfo.o
-ifndef CONFIG_X86_64
-ifndef CONFIG_TPL_BUILD
+
+ifndef CONFIG_$(SPL_TPL_)X86_64
 obj-y += bios.o
 obj-y += bios_asm.o
 obj-y += bios_interrupts.o
 endif
-endif
+
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_X86_32BIT_INIT) += string.o
 endif
+
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 endif
diff --git a/arch/x86/lib/bios.c b/arch/x86/lib/bios.c
index b28db31308f0..e2b422bec1ed 100644
--- a/arch/x86/lib/bios.c
+++ b/arch/x86/lib/bios.c
@@ -23,7 +23,7 @@
 static int (*int_handler[256])(void);
 
 /* to have a common register file for interrupt handlers */
-#ifndef CONFIG_BIOSEMU
+#if !CONFIG_IS_ENABLED(BIOSEMU)
 X86EMU_sysEnv _X86EMU_env;
 #endif
 
diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index dab0f1979068..2d9a2a899ef7 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -344,20 +344,20 @@ int dm_pci_run_vga_bios(struct udevice *dev, int 
(*int15_handler)(void),
}
 
if (emulate) {
-#ifdef CONFIG_BIOSEMU
-   BE_VGAInfo *info;
-
-   log_debug("Running video BIOS with emulator...");
-   ret = biosemu_setup(dev, );
-   if (ret)
-   goto err;
-   biosemu_set_interrupt_handler(0x15, int15_handler);
-   ret = biosemu_run(dev, (uchar *)ram, 1 << 16, info,
- true, vesa_mode, _info);
-   log_debug("done\n");
-   if (ret)
-   goto err;
-#endif
+   if (CONFIG_IS_ENABLED(BIOSEMU)) {
+   BE_VGAInfo *info;
+
+   log_debug("Running video BIOS with emulator...");
+   ret = biosemu_setup(dev, );
+   if (ret)
+   goto err;
+   biosemu_set_interrupt_handler(0x15, int15_handler);
+   ret = biosemu_run(dev, (uchar *)ram, 1 << 16, info,
+ true, vesa_mode, _info);
+   log_debug("done\n");
+   if (ret)
+   goto err;
+   }
} else {
 #if defined(CONFIG_X86) && (CONFIG_IS_ENABLED(X86_32BIT_INIT) || CONFIG_TPL)
log_debug("Running video BIOS...");
-- 
2.40.0.348.gf938b09366-goog



[PATCH 23/38] pci: Allow the video BIOS to work in SPL with QEMU

2023-03-30 Thread Simon Glass
QEMU emulates two common machines (Q35 and i440fx) which use mapping to
determine whether RAM is present below 1MB. In order to copy the video
BIOS to c we need to flip this mapping over to RAM. This does not
happen automatically until SPL has finished running.

Switch in RAM at these address so that the video BIOS can be loaded and
run. This fix was found in the seabios code base.

Signed-off-by: Simon Glass 
---

 drivers/pci/pci_rom.c | 46 +++
 include/pci_ids.h |  1 +
 2 files changed, 47 insertions(+)

diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index f0dfe6314907..0f44238bbbc8 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -141,6 +141,49 @@ static int pci_rom_probe(struct udevice *dev, struct 
pci_rom_header **hdrp)
return 0;
 }
 
+#define Q35_HOST_BRIDGE_PAM0   0x90
+#define I440FX_PAM00x59
+
+/**
+ * intel_set_writable_ram() - Set RAM to be writable
+ *
+ * This is needed for QEMU when using Q35 or I440FX emulation, since otherwise
+ * there is no RAM available at c
+ *
+ * See Intel 82945G/82945G/82945GC GMCH and 82945P/82945PL MCH Datasheet for
+ * information about the PAM0-PAM6 registers
+ */
+static void intel_set_writable_ram(void)
+{
+   struct udevice *dev;
+   int pam0 = -1;
+   int i;
+
+   for (pci_find_first_device(); dev; pci_find_next_device()) {
+   const struct pci_child_plat *pdata = dev_get_parent_plat(dev);
+
+   if (pdata->vendor == PCI_VENDOR_ID_INTEL) {
+   if (pdata->device == PCI_DEVICE_ID_INTEL_Q35_MCH) {
+   pam0 = Q35_HOST_BRIDGE_PAM0;
+   break;
+   } else if (pdata->device == PCI_DEVICE_ID_INTEL_82441) {
+   pam0 = I440FX_PAM0;
+   break;
+   }
+   }
+   }
+
+   if (!dev)
+   return;
+
+   // Adjust RAM to be writable from c to f
+   for (i = 1; i <= 6; i++)
+   dm_pci_write_config8(dev, pam0 + i, 0x33);
+
+   // Also f-10
+   dm_pci_write_config8(dev, pam0, 0x30);
+}
+
 /**
  * pci_rom_load() - Load a ROM image and return a pointer to it
  *
@@ -185,6 +228,9 @@ static int pci_rom_load(struct pci_rom_header *rom_header,
return -ENOMEM;
*allocedp = true;
 #endif
+   /* QEMU hacks */
+   intel_set_writable_ram();
+
if (target != rom_header) {
ulong start = get_timer(0);
 
diff --git a/include/pci_ids.h b/include/pci_ids.h
index 5ae1b9b7fb6e..33e90c8d2769 100644
--- a/include/pci_ids.h
+++ b/include/pci_ids.h
@@ -2870,6 +2870,7 @@
 #define PCI_DEVICE_ID_INTEL_ICH9_7 0x2916
 #define PCI_DEVICE_ID_INTEL_ICH9_8 0x2918
 #define PCI_DEVICE_ID_INTEL_ICH9_AHCI  0x2922
+#define PCI_DEVICE_ID_INTEL_Q35_MCH0x29c0
 #define PCI_DEVICE_ID_INTEL_I7_MCR 0x2c18
 #define PCI_DEVICE_ID_INTEL_I7_MC_TAD  0x2c19
 #define PCI_DEVICE_ID_INTEL_I7_MC_RAS  0x2c1a
-- 
2.40.0.348.gf938b09366-goog



[PATCH 24/38] pci: Tidy up logging and reporting for video BIOS

2023-03-30 Thread Simon Glass
When running the ROM the code is not very helpful when something goes
wrong. Add a little more debugging and some logging of return values to
improve this.

Signed-off-by: Simon Glass 
---

 drivers/pci/pci_rom.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index 0f44238bbbc8..dab0f1979068 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -300,14 +300,16 @@ int dm_pci_run_vga_bios(struct udevice *dev, int 
(*int15_handler)(void),
 
ret = pci_rom_probe(dev, );
if (ret)
-   return ret;
+   return log_msg_ret("pro", ret);
 
ret = pci_rom_load(rom, , );
-   if (ret)
+   if (ret) {
+   ret = log_msg_ret("ld", ret);
goto err;
+   }
 
if (!board_should_run_oprom(dev)) {
-   ret = -ENXIO;
+   ret = log_msg_ret("run", -ENXIO);
goto err;
}
 
@@ -345,21 +347,25 @@ int dm_pci_run_vga_bios(struct udevice *dev, int 
(*int15_handler)(void),
 #ifdef CONFIG_BIOSEMU
BE_VGAInfo *info;
 
+   log_debug("Running video BIOS with emulator...");
ret = biosemu_setup(dev, );
if (ret)
goto err;
biosemu_set_interrupt_handler(0x15, int15_handler);
ret = biosemu_run(dev, (uchar *)ram, 1 << 16, info,
  true, vesa_mode, _info);
+   log_debug("done\n");
if (ret)
goto err;
 #endif
} else {
 #if defined(CONFIG_X86) && (CONFIG_IS_ENABLED(X86_32BIT_INIT) || CONFIG_TPL)
+   log_debug("Running video BIOS...");
bios_set_interrupt_handler(0x15, int15_handler);
 
bios_run_on_x86(dev, (unsigned long)ram, vesa_mode,
_info);
+   log_debug("done\n");
 #endif
}
debug("Final vesa mode %#x\n", mode_info.video_mode);
-- 
2.40.0.348.gf938b09366-goog



[PATCH 21/38] nvme: Provide more useful debugging messages

2023-03-30 Thread Simon Glass
When scanning fails it is useful to be able to decode what went wrong. Add
some debugging for this.

Signed-off-by: Simon Glass 
---

 drivers/nvme/nvme.c | 36 ++--
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index 74e7a5b01109..a7add66ab4d1 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -578,17 +578,22 @@ static int nvme_set_queue_count(struct nvme_dev *dev, int 
count)
return min(result & 0x, result >> 16) + 1;
 }
 
-static void nvme_create_io_queues(struct nvme_dev *dev)
+static int nvme_create_io_queues(struct nvme_dev *dev)
 {
unsigned int i;
+   int ret;
 
for (i = dev->queue_count; i <= dev->max_qid; i++)
if (!nvme_alloc_queue(dev, i, dev->q_depth))
-   break;
+   return log_msg_ret("all", -ENOMEM);
 
-   for (i = dev->online_queues; i <= dev->queue_count - 1; i++)
-   if (nvme_create_queue(dev->queues[i], i))
-   break;
+   for (i = dev->online_queues; i <= dev->queue_count - 1; i++) {
+   ret = nvme_create_queue(dev->queues[i], i);
+   if (ret)
+   return log_msg_ret("cre", ret);
+   }
+
+   return 0;
 }
 
 static int nvme_setup_io_queues(struct nvme_dev *dev)
@@ -598,14 +603,18 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
 
nr_io_queues = 1;
result = nvme_set_queue_count(dev, nr_io_queues);
-   if (result <= 0)
+   if (result <= 0) {
+   log_debug("Cannot set queue count (err=%dE)\n", result);
return result;
+   }
 
dev->max_qid = nr_io_queues;
 
/* Free previously allocated queues */
nvme_free_queues(dev, nr_io_queues + 1);
-   nvme_create_io_queues(dev);
+   result = nvme_create_io_queues(dev);
+   if (result)
+   return result;
 
return 0;
 }
@@ -683,8 +692,11 @@ int nvme_scan_namespace(void)
 
uclass_foreach_dev(dev, uc) {
ret = device_probe(dev);
-   if (ret)
+   if (ret) {
+   log_err("Failed to probe '%s': err=%dE\n", dev->name,
+   ret);
return ret;
+   }
}
 
return 0;
@@ -842,8 +854,10 @@ int nvme_init(struct udevice *udev)
ndev->dbs = ((void __iomem *)ndev->bar) + 4096;
 
ret = nvme_configure_admin_queue(ndev);
-   if (ret)
+   if (ret) {
+   log_debug("Unable to configure admin queue (err=%dE)\n", ret);
goto free_queue;
+   }
 
/* Allocate after the page size is known */
ndev->prp_pool = memalign(ndev->page_size, MAX_PRP_POOL);
@@ -855,8 +869,10 @@ int nvme_init(struct udevice *udev)
ndev->prp_entry_num = MAX_PRP_POOL >> 3;
 
ret = nvme_setup_io_queues(ndev);
-   if (ret)
+   if (ret) {
+   log_debug("Unable to setup I/O queues(err=%dE)\n", ret);
goto free_queue;
+   }
 
nvme_get_info_from_identify(ndev);
 
-- 
2.40.0.348.gf938b09366-goog



[PATCH 19/38] x86: Improve the trampoline in 64-bit mode

2023-03-30 Thread Simon Glass
At present this leaves the stack at the pre-relocation value. This is not
ideal since we want to have U-Boot running entirely from the top of
memory.

In addition, the new global_data pointer is not actually used, since
the global_data pointer itself is relocated, then the pre-relocation value
is changed, so the effective value (after relocation) does not update.

Adjust the implementation to follow the 32-bit code more closely, with a
trampoline function which is passed the new stack and global_data pointer.
This ensures that the correct values come through even when relocating.

Signed-off-by: Simon Glass 
---

 arch/x86/cpu/start64.S| 19 +++
 arch/x86/include/asm/u-boot-x86.h | 11 +++
 common/board_f.c  | 12 +++-
 3 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/arch/x86/cpu/start64.S b/arch/x86/cpu/start64.S
index 7be834788b9f..78e894d2a21a 100644
--- a/arch/x86/cpu/start64.S
+++ b/arch/x86/cpu/start64.S
@@ -26,3 +26,22 @@ _start:
 
/* Should not return here */
jmp .
+
+.globl board_init_f_r_trampoline64
+.type board_init_f_r_trampoline64, @function
+board_init_f_r_trampoline64:
+   /*
+* SDRAM has been initialised, U-Boot code has been copied into
+* RAM, BSS has been cleared and relocation adjustments have been
+* made. It is now time to jump into the in-RAM copy of U-Boot
+*
+* %eax = Address of top of new stack
+*/
+
+   /* Stack grows down from top of SDRAM */
+   movq%rsi, %rsp
+
+   /* New gd is in rdi */
+
+   /* Re-enter U-Boot by calling board_init_f_r() */
+   callboard_init_f_r
diff --git a/arch/x86/include/asm/u-boot-x86.h 
b/arch/x86/include/asm/u-boot-x86.h
index 1610d7237bcd..3703094027d5 100644
--- a/arch/x86/include/asm/u-boot-x86.h
+++ b/arch/x86/include/asm/u-boot-x86.h
@@ -109,6 +109,17 @@ int fsp_save_s3_stack(void);
  */
 void __noreturn board_init_f_r_trampoline(ulong sp);
 
+/**
+ * board_init_f_r_trampoline64() - jump to relocated address with new stack
+ *
+ * This is the 64-bit version
+ *
+ * @new_gd: New global_data pointer to use
+ * @sp: New stack pointer to pass on to board_init_r()
+ */
+void __noreturn board_init_f_r_trampoline64(struct global_data *new_gd,
+   ulong sp);
+
 void __noreturn board_init_f_r(void);
 
 int arch_misc_init(void);
diff --git a/common/board_f.c b/common/board_f.c
index f3c1ab53b1c6..f252a8eed5fd 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -731,8 +731,7 @@ static int fix_fdt(void)
 #endif
 
 /* ARM calls relocate_code from its crt0.S */
-#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
-   !CONFIG_IS_ENABLED(X86_64)
+#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
 
 static int jump_to_copy(void)
 {
@@ -754,7 +753,11 @@ static int jump_to_copy(void)
 * (CPU cache)
 */
arch_setup_gd(gd->new_gd);
-   board_init_f_r_trampoline(gd->start_addr_sp);
+# if CONFIG_IS_ENABLED(X86_64)
+   board_init_f_r_trampoline64(gd->new_gd, gd->start_addr_sp);
+# else
+   board_init_f_r_trampoline(gd->start_addr_sp);
+# endif
 #else
relocate_code(gd->start_addr_sp, gd->new_gd, gd->relocaddr);
 #endif
@@ -969,8 +972,7 @@ static const init_fnc_t init_sequence_f[] = {
 * watchdog device is not serviced is as small as possible.
 */
cyclic_unregister_all,
-#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
-   !CONFIG_IS_ENABLED(X86_64)
+#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
jump_to_copy,
 #endif
NULL,
-- 
2.40.0.348.gf938b09366-goog



[PATCH 20/38] Show the malloc base with the bdinfo command

2023-03-30 Thread Simon Glass
It is useful to see the base of the malloc region. This is visible when
debugging but not in normal usage.

Add it to the global data so that it can be shown.

Signed-off-by: Simon Glass 
---

 cmd/bdinfo.c  |  1 +
 common/board_r.c  |  7 ---
 include/asm-generic/global_data.h | 11 +++
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index 4e0c763a7096..f1f8d59673fb 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -148,6 +148,7 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
if (IS_ENABLED(CONFIG_CMD_BDINFO_EXTRA)) {
bdinfo_print_num_ll("stack ptr", (ulong));
bdinfo_print_num_ll("ram_top ptr", (ulong)gd->ram_top);
+   bdinfo_print_num_l("malloc base", gd_malloc_start());
}
 
arch_print_bdinfo();
diff --git a/common/board_r.c b/common/board_r.c
index d798c00a80a5..4aaa89403117 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -196,7 +196,7 @@ static int initr_barrier(void)
 
 static int initr_malloc(void)
 {
-   ulong malloc_start;
+   ulong start;
 
 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
debug("Pre-reloc malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
@@ -207,8 +207,9 @@ static int initr_malloc(void)
 * This value MUST match the value of gd->start_addr_sp in board_f.c:
 * reserve_noncached().
 */
-   malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
-   mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
+   start = gd->relocaddr - TOTAL_MALLOC_LEN;
+   gd_set_malloc_start(start);
+   mem_malloc_init((ulong)map_sysmem(start, TOTAL_MALLOC_LEN),
TOTAL_MALLOC_LEN);
return 0;
 }
diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index 422e0cf4720f..3ccd66fdeb7a 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -301,6 +301,10 @@ struct global_data {
 * @timebase_l: low 32 bits of timer
 */
unsigned int timebase_l;
+   /**
+* @malloc_start: start of malloc() region
+*/
+   CONFIG_IS_ENABLED(CMD_BDINFO_EXTRA, (ulong malloc_start;))
 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
/**
 * @malloc_base: base address of early malloc()
@@ -560,6 +564,13 @@ static_assert(sizeof(struct global_data) == GD_SIZE);
 #define gd_event_state()   NULL
 #endif
 
+#if CONFIG_IS_ENABLED(CMD_BDINFO_EXTRA)
+#define gd_malloc_start()  gd->malloc_start
+#define gd_set_malloc_start(_val)  gd->malloc_start = (_val)
+#else
+#define gd_malloc_start()  0
+#define gd_set_malloc_start(val)
+#endif
 /**
  * enum gd_flags - global data flags
  *
-- 
2.40.0.348.gf938b09366-goog



[PATCH 18/38] efi: Show all known UUIDs with CONFIG_CMD_EFIDEBUG

2023-03-30 Thread Simon Glass
The CMD_EFIDEBUG option enables debugging so it is reasonable to assume
that all effects should be made to decode the dreaded UUIDs favoured by
UEFI.

Update the table to show them all when CONFIG_CMD_EFIDEBUG is enabled.

Signed-off-by: Simon Glass 
---

 lib/uuid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/uuid.c b/lib/uuid.c
index 96e1af3c8b00..ab30fbf9152f 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -255,7 +255,7 @@ static const struct {
EFI_CERT_TYPE_PKCS7_GUID,
},
 #endif
-#ifdef CONFIG_EFI
+#if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI)
{ "EFI_LZMA_COMPRESSED", EFI_LZMA_COMPRESSED },
{ "EFI_DXE_SERVICES", EFI_DXE_SERVICES },
{ "EFI_HOB_LIST", EFI_HOB_LIST },
-- 
2.40.0.348.gf938b09366-goog



[PATCH 17/38] qfw: Set the address of the ACPI tables

2023-03-30 Thread Simon Glass
Once the ACPI tables have been set up, record their address so that it is
possible to list them with 'acpi list'.

Signed-off-by: Simon Glass 
---

 drivers/misc/qfw.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/misc/qfw.c b/drivers/misc/qfw.c
index 9ef95caa8956..0a93feeb4b2e 100644
--- a/drivers/misc/qfw.c
+++ b/drivers/misc/qfw.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if defined(CONFIG_GENERATE_ACPI_TABLE) && !defined(CONFIG_SANDBOX)
 /*
@@ -227,6 +228,9 @@ out:
}
 
free(table_loader);
+
+   gd_set_acpi_start(acpi_get_rsdp_addr());
+
return addr;
 }
 
-- 
2.40.0.348.gf938b09366-goog



[PATCH 16/38] video: Allow building video drivers for SPL

2023-03-30 Thread Simon Glass
Update the Makefile rules to allow video drivers in SPL. This is useful
for 64-bit QEMU on x86, since the video BIOS can only be run from 32-bit
mode (i.e. in SPL).

Signed-off-by: Simon Glass 
---

 drivers/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/Makefile b/drivers/Makefile
index f9822bea266e..eb8e2b5ee805 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -37,6 +37,8 @@ obj-$(CONFIG_$(SPL_)SYSINFO) += sysinfo/
 obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/
 obj-$(CONFIG_XEN) += xen/
 obj-$(CONFIG_$(SPL_)FPGA) += fpga/
+obj-$(CONFIG_$(SPL_TPL_)VIDEO) += video/
+
 obj-y += bus/
 
 ifndef CONFIG_TPL_BUILD
@@ -96,7 +98,6 @@ obj-y += rtc/
 obj-y += scsi/
 obj-y += sound/
 obj-y += spmi/
-obj-y += video/
 obj-y += watchdog/
 obj-$(CONFIG_QE) += qe/
 obj-$(CONFIG_U_QE) += qe/
-- 
2.40.0.348.gf938b09366-goog



[PATCH 14/38] qfw: Show the file address if available

2023-03-30 Thread Simon Glass
Some files have an associated address. Show this with the 'qfw list'
command so that it is possible to dump the data.

Signed-off-by: Simon Glass 
---

 cmd/qfw.c |  2 +-
 doc/usage/cmd/qfw.rst | 28 
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/cmd/qfw.c b/cmd/qfw.c
index ae3c6a7a84e9..d6ecfa60d5a7 100644
--- a/cmd/qfw.c
+++ b/cmd/qfw.c
@@ -26,7 +26,7 @@ static int qemu_fwcfg_cmd_list_firmware(void)
for (file = qfw_file_iter_init(qfw_dev, );
 !qfw_file_iter_end();
 file = qfw_file_iter_next()) {
-   printf("%-56s\n", file->cfg.name);
+   printf("%08lx %-56s\n", file->addr, file->cfg.name);
}
 
return 0;
diff --git a/doc/usage/cmd/qfw.rst b/doc/usage/cmd/qfw.rst
index cc0e27c27790..76d74278a213 100644
--- a/doc/usage/cmd/qfw.rst
+++ b/doc/usage/cmd/qfw.rst
@@ -11,6 +11,7 @@ Synopsis
 qfw list
 qfw cpus
 qfw load [kernel_addr [initrd_addr]]
+qfw list
 
 Description
 ---
@@ -41,18 +42,21 @@ QEMU firmware files are listed via the *qfw list* command:
 ::
 
 => qfw list
-etc/boot-fail-wait
-etc/smbios/smbios-tables
-etc/smbios/smbios-anchor
-etc/e820
-genroms/kvmvapic.bin
-genroms/linuxboot.bin
-etc/system-states
-etc/acpi/tables
-etc/table-loader
-etc/tpm/log
-etc/acpi/rsdp
-bootorder
+ bios-geometry
+ bootorder
+000f0060 etc/acpi/rsdp
+bed14040 etc/acpi/tables
+ etc/boot-fail-wait
+ etc/e820
+ etc/smbios/smbios-anchor
+ etc/smbios/smbios-tables
+ etc/system-states
+ etc/table-loader
+ etc/tpm/log
+ genroms/kvmvapic.bin
+
+Where an address is shown, it indicates where the data is available for
+inspection, e.g. using the :doc:`md`.
 
 The available CPUs can be shown via the *qfw cpus* command:
 
-- 
2.40.0.348.gf938b09366-goog



[PATCH 15/38] log: Tidy up an ambiguous comment.

2023-03-30 Thread Simon Glass
Add a a bit more detail so it is clear that multiple devices are
supported, but only one per driver.

Signed-off-by: Simon Glass 
---

 common/log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/log.c b/common/log.c
index 7cfc49bc28a5..ec33b62e8a6f 100644
--- a/common/log.c
+++ b/common/log.c
@@ -436,7 +436,7 @@ int log_init(void)
/*
 * We cannot add runtime data to the driver since it is likely stored
 * in rodata. Instead, set up a 'device' corresponding to each driver.
-* We only support having a single device.
+* We only support having a single device for each driver.
 */
INIT_LIST_HEAD((struct list_head *)>log_head);
while (drv < end) {
-- 
2.40.0.348.gf938b09366-goog



[PATCH 11/38] acpi: Add a comment to set the acpi tables

2023-03-30 Thread Simon Glass
Sometimes a previous bootloader has written ACPI tables. It is useful to
be able to find and list these. Add an 'acpi set' command to set the
address for these tables.

Signed-off-by: Simon Glass 
---

 cmd/acpi.c | 24 +---
 doc/usage/cmd/acpi.rst | 29 +++--
 test/dm/acpi.c | 38 ++
 3 files changed, 86 insertions(+), 5 deletions(-)

diff --git a/cmd/acpi.c b/cmd/acpi.c
index e70913e40bfe..ede9c8c7dcb4 100644
--- a/cmd/acpi.c
+++ b/cmd/acpi.c
@@ -118,6 +118,22 @@ static int do_acpi_list(struct cmd_tbl *cmdtp, int flag, 
int argc,
return 0;
 }
 
+static int do_acpi_set(struct cmd_tbl *cmdtp, int flag, int argc,
+  char *const argv[])
+{
+   ulong val;
+
+   if (argc < 2) {
+   printf("ACPI pointer: %lx\n", gd_acpi_start());
+   } else {
+   val = hextoul(argv[1], NULL);
+   printf("Setting ACPI pointer to %lx\n", val);
+   gd_set_acpi_start(val);
+   }
+
+   return 0;
+}
+
 static int do_acpi_items(struct cmd_tbl *cmdtp, int flag, int argc,
 char *const argv[])
 {
@@ -157,12 +173,14 @@ static int do_acpi_dump(struct cmd_tbl *cmdtp, int flag, 
int argc,
 
 #ifdef CONFIG_SYS_LONGHELP
 static char acpi_help_text[] =
-   "list - list ACPI tables\n"
-   "acpi items [-d]  - List/dump each piece of ACPI data from devices\n"
-   "acpi dump  - Dump ACPI table";
+   "list  - list ACPI tables\n"
+   "acpi items [-d]   - List/dump each piece of ACPI data from devices\n"
+   "acpi set [] - Set or show address of ACPI tables\n"
+   "acpi dump   - Dump ACPI table";
 #endif
 
 U_BOOT_CMD_WITH_SUBCMDS(acpi, "ACPI tables", acpi_help_text,
U_BOOT_SUBCMD_MKENT(list, 1, 1, do_acpi_list),
U_BOOT_SUBCMD_MKENT(items, 2, 1, do_acpi_items),
+   U_BOOT_SUBCMD_MKENT(set, 2, 1, do_acpi_set),
U_BOOT_SUBCMD_MKENT(dump, 2, 1, do_acpi_dump));
diff --git a/doc/usage/cmd/acpi.rst b/doc/usage/cmd/acpi.rst
index 14bafc8e3524..5aeb4f4b77bf 100644
--- a/doc/usage/cmd/acpi.rst
+++ b/doc/usage/cmd/acpi.rst
@@ -11,12 +11,14 @@ Synopis
 acpi list
 acpi items [-d]
 acpi dump 
+acpi set 
 
 Description
 ---
 
-The *acpi* command is used to dump the ACPI tables generated by U-Boot for 
passing
-to the operating systems.
+The *acpi* command is used to dump the ACPI tables generated by U-Boot for
+passing to the operating systems. It allow allows manually setting the address
+to take a look at existing ACPI tables.
 
 ACPI tables can be generated by various output functions and even devices can
 output material to include in the Differentiated System Description Table 
(DSDT)
@@ -231,5 +233,28 @@ Example
 : 44 53 44 54 ea 32 00 00 02 eb 55 2d 42 4f 4f 54  DSDT.2U-BOOT
 0010: 55 2d 42 4f 4f 54 42 4c 25 07 11 20 49 4e 54 4c  U-BOOTBL%.. INTL
 
+This shows searching for tables in a known area of memory, then setting the
+pointer::
+
+=> acpi list
+No ACPI tables present
+=> ms.s bff0 8 "RSD PTR"
+bff75000: 52 53 44 20 50 54 52 20 cf 42 4f 43 48 53 20 00  RSD PTR .BOCHS .
+1 match
+=> acpi set bff75000
+Setting ACPI pointer to bff75000
+=> acpi list
+Name  Base   Size  Detail
+    -  --
+RSDP  bff75000  0  v00 BOCHS
+RSDT  bff76a63 38  v01 BOCHS  BXPC 1 BXPC 1
+FACP  bff768ff 74  v01 BOCHS  BXPC 1 BXPC 1
+DSDT  bff75080   187f  v01 BOCHS  BXPC 1 BXPC 1
+FACS  bff75040 40
+APIC  bff76973 90  v01 BOCHS  BXPC 1 BXPC 1
+HPET  bff76a03 38  v01 BOCHS  BXPC 1 BXPC 1
+WAET  bff76a3b 28  v01 BOCHS  BXPC 1 BXPC 1
+SSDT  bff95040 c5  v02 COREv4 COREBOOT 2a CORE 20221020
+
 
 .. _`ACPI specification`: 
https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf
diff --git a/test/dm/acpi.c b/test/dm/acpi.c
index 9634fc2e9002..1511336a5ebc 100644
--- a/test/dm/acpi.c
+++ b/test/dm/acpi.c
@@ -611,3 +611,41 @@ static int dm_test_acpi_cmd_items(struct unit_test_state 
*uts)
return 0;
 }
 DM_TEST(dm_test_acpi_cmd_items, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
+/* Test 'acpi set' command */
+static int dm_test_acpi_cmd_set(struct unit_test_state *uts)
+{
+   struct acpi_ctx ctx;
+   ulong addr;
+   void *buf;
+
+   gd_set_acpi_start(0);
+
+   console_record_reset();
+   ut_asserteq(0, gd_acpi_start());
+   ut_assertok(run_command("acpi set", 0));
+   ut_assert_nextline("ACPI pointer: 0");
+
+   buf = memalign(16, BUF_SIZE);
+   ut_assertnonnull(buf);
+   addr = map_to_sysmem(buf);
+   ut_assertok(setup_ctx_and_base_tables(uts, , addr));
+
+   ut_assertok(acpi_write_dev_tables());
+
+   ut_assertok(run_command("acpi set", 0));
+   ut_assert_nextline("ACPI pointer: %lx", addr);
+
+   ut_assertok(run_command("acpi 

[PATCH 07/38] x86: Add a comment for board_init_f_r_trampoline()

2023-03-30 Thread Simon Glass
Add a comment for this function in the header.

Change the function (and the one after) to use __noreturn to keep
checkpatch happy.

Signed-off-by: Simon Glass 
---

 arch/x86/include/asm/u-boot-x86.h | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/u-boot-x86.h 
b/arch/x86/include/asm/u-boot-x86.h
index 8f38c2d1c601..1610d7237bcd 100644
--- a/arch/x86/include/asm/u-boot-x86.h
+++ b/arch/x86/include/asm/u-boot-x86.h
@@ -102,8 +102,14 @@ int video_bios_init(void);
  */
 int fsp_save_s3_stack(void);
 
-void   board_init_f_r_trampoline(ulong) __attribute__ ((noreturn));
-void   board_init_f_r(void) __attribute__ ((noreturn));
+/**
+ * board_init_f_r_trampoline() - jump to relocated address with new stack
+ *
+ * @sp: New stack pointer to use
+ */
+void __noreturn board_init_f_r_trampoline(ulong sp);
+
+void __noreturn board_init_f_r(void);
 
 int arch_misc_init(void);
 
-- 
2.40.0.348.gf938b09366-goog



[PATCH 10/38] x86: Show an error when a BINS exception occurs

2023-03-30 Thread Simon Glass
Rather than silently hanging, show an error first. This can happen when
there is something wrong with the video BIOS.

Signed-off-by: Simon Glass 
---

 arch/x86/lib/bios.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/lib/bios.c b/arch/x86/lib/bios.c
index 94349ba8073d..b28db31308f0 100644
--- a/arch/x86/lib/bios.c
+++ b/arch/x86/lib/bios.c
@@ -78,7 +78,8 @@ static int int_exception_handler(void)
};
struct eregs *regs = _info;
 
-   debug("Oops, exception %d while executing option rom\n", regs->vector);
+   log_err("Oops, exception %d while executing option rom\n",
+   regs->vector);
cpu_hlt();
 
return 0;
-- 
2.40.0.348.gf938b09366-goog



[PATCH 09/38] x86: Correct get_sp() implementation for 64-bit

2023-03-30 Thread Simon Glass
Use an assembler implementation as is done for i386, so that the results
are equivalent.

Signed-off-by: Simon Glass 
---

 arch/x86/lib/bootm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c
index 61cb7bc61168..3196f9ddc2c8 100644
--- a/arch/x86/lib/bootm.c
+++ b/arch/x86/lib/bootm.c
@@ -258,7 +258,7 @@ static ulong get_sp(void)
ulong ret;
 
 #if CONFIG_IS_ENABLED(X86_64)
-   ret = gd->start_addr_sp;
+   asm("mov %%rsp, %0" : "=r"(ret) : );
 #else
asm("mov %%esp, %0" : "=r"(ret) : );
 #endif
-- 
2.40.0.348.gf938b09366-goog



[PATCH 06/38] x86: Set high bits of the mtrr base registrer

2023-03-30 Thread Simon Glass
Linux expects all the high bits to be set, not just those needed for the
CPU. Ignore the number of CPU bits and set them all.

Signed-off-by: Simon Glass 
---

 arch/x86/cpu/mtrr.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/x86/cpu/mtrr.c b/arch/x86/cpu/mtrr.c
index 1b5f24aab317..bde8481a41c8 100644
--- a/arch/x86/cpu/mtrr.c
+++ b/arch/x86/cpu/mtrr.c
@@ -73,7 +73,6 @@ static void set_var_mtrr(uint reg, uint type, uint64_t start, 
uint64_t size)
 
wrmsrl(MTRR_PHYS_BASE_MSR(reg), start | type);
mask = ~(size - 1);
-   mask &= (1ULL << CONFIG_CPU_ADDR_BITS) - 1;
wrmsrl(MTRR_PHYS_MASK_MSR(reg), mask | MTRR_PHYS_MASK_VALID);
 }
 
-- 
2.40.0.348.gf938b09366-goog



[PATCH 08/38] x86: Show the CPU physical address size with bdinfo

2023-03-30 Thread Simon Glass
This is useful information so show it with the bdinfo command.

Signed-off-by: Simon Glass 
---

 arch/x86/lib/bdinfo.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/lib/bdinfo.c b/arch/x86/lib/bdinfo.c
index 15390070fe85..0970efa4726f 100644
--- a/arch/x86/lib/bdinfo.c
+++ b/arch/x86/lib/bdinfo.c
@@ -22,6 +22,7 @@ void arch_print_bdinfo(void)
bdinfo_print_num_l("vendor", gd->arch.x86_vendor);
bdinfo_print_str(" name", cpu_vendor_name(gd->arch.x86_vendor));
bdinfo_print_num_l("model", gd->arch.x86_model);
+   bdinfo_print_num_l("phys_addr", cpu_phys_address_size());
 
if (IS_ENABLED(CONFIG_EFI_STUB))
efi_show_bdinfo();
-- 
2.40.0.348.gf938b09366-goog



[PATCH 04/38] bios_emulator: Drop VIDEO_IO_OFFSET

2023-03-30 Thread Simon Glass
This is always zero in the source tree, so drop it.

While we are here, add a comment to _X86EMU_env since it the symbol is
actually defined twice, which can cause confusion when building.

Signed-off-by: Simon Glass 
---

 drivers/bios_emulator/biosemui.h  | 18 +-
 drivers/bios_emulator/x86emu/sys.c|  1 +
 include/configs/conga-qeval20-qa3-e3845.h |  2 --
 include/configs/dfi-bt700.h   |  2 --
 include/configs/minnowmax.h   |  2 --
 include/configs/som-db5800-som-6867.h |  2 --
 include/configs/theadorable-x86-common.h  |  2 --
 include/configs/x86-chromebook.h  |  2 --
 8 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/drivers/bios_emulator/biosemui.h b/drivers/bios_emulator/biosemui.h
index 7853015c1e2e..954cd883158c 100644
--- a/drivers/bios_emulator/biosemui.h
+++ b/drivers/bios_emulator/biosemui.h
@@ -128,19 +128,19 @@ typedef struct {
u32 finalVal;
 } BE_portInfo;
 
-#define PM_inpb(port)  inb(port+VIDEO_IO_OFFSET)
-#define PM_inpw(port)  inw(port+VIDEO_IO_OFFSET)
-#define PM_inpd(port)  inl(port+VIDEO_IO_OFFSET)
-#define PM_outpb(port,val) outb(val,port+VIDEO_IO_OFFSET)
-#define PM_outpw(port,val) outw(val,port+VIDEO_IO_OFFSET)
-#define PM_outpd(port,val) outl(val,port+VIDEO_IO_OFFSET)
+#define PM_inpb(port)  inb(port)
+#define PM_inpw(port)  inw(port)
+#define PM_inpd(port)  inl(port)
+#define PM_outpb(port, val)outb(val, port)
+#define PM_outpw(port, val)outw(val, port)
+#define PM_outpd(port, val)outl(val, port)
 
 #define LOG_inpb(port) PM_inpb(port)
 #define LOG_inpw(port) PM_inpw(port)
 #define LOG_inpd(port) PM_inpd(port)
-#define LOG_outpb(port,val)PM_outpb(port,val)
-#define LOG_outpw(port,val)PM_outpw(port,val)
-#define LOG_outpd(port,val)PM_outpd(port,val)
+#define LOG_outpb(port, val)   PM_outpb(port, val)
+#define LOG_outpw(port, val)   PM_outpw(port, val)
+#define LOG_outpd(port, val)   PM_outpd(port, val)
 
 /*-- Function Prototypes --*/
 
diff --git a/drivers/bios_emulator/x86emu/sys.c 
b/drivers/bios_emulator/x86emu/sys.c
index c2db1213fe66..882a8a34cc3e 100644
--- a/drivers/bios_emulator/x86emu/sys.c
+++ b/drivers/bios_emulator/x86emu/sys.c
@@ -44,6 +44,7 @@
 
 /*- Global Variables --*/
 
+/* Note: bios.c defines this if the emulator is not enabled */
 X86EMU_sysEnv _X86EMU_env; /* Global emulator machine state */
 X86EMU_intrFuncs _X86EMU_intrTab[256];
 
diff --git a/include/configs/conga-qeval20-qa3-e3845.h 
b/include/configs/conga-qeval20-qa3-e3845.h
index 60617e6fec25..03c364f29fb3 100644
--- a/include/configs/conga-qeval20-qa3-e3845.h
+++ b/include/configs/conga-qeval20-qa3-e3845.h
@@ -16,8 +16,6 @@
"stdout=serial\0" \
"stderr=serial\0"
 
-#define VIDEO_IO_OFFSET0
-
 #undef CFG_EXTRA_ENV_SETTINGS
 #define CFG_EXTRA_ENV_SETTINGS \
"kernel-ver=4.4.0-22\0" \
diff --git a/include/configs/dfi-bt700.h b/include/configs/dfi-bt700.h
index 05389a435bee..be095e28a1b4 100644
--- a/include/configs/dfi-bt700.h
+++ b/include/configs/dfi-bt700.h
@@ -20,8 +20,6 @@
"stdout=serial\0" \
"stderr=serial\0"
 
-#define VIDEO_IO_OFFSET0
-
 #undef CFG_EXTRA_ENV_SETTINGS
 #define CFG_EXTRA_ENV_SETTINGS \
"kernel-ver=4.4.0-24\0" \
diff --git a/include/configs/minnowmax.h b/include/configs/minnowmax.h
index 4a12c2f72c62..842672d55751 100644
--- a/include/configs/minnowmax.h
+++ b/include/configs/minnowmax.h
@@ -17,6 +17,4 @@
"stderr=vidconsole,serial\0" \
"usb_pgood_delay=40\0"
 
-#define VIDEO_IO_OFFSET0
-
 #endif /* __CONFIG_H */
diff --git a/include/configs/som-db5800-som-6867.h 
b/include/configs/som-db5800-som-6867.h
index b2e7aa1514c0..5f7eabd3fc64 100644
--- a/include/configs/som-db5800-som-6867.h
+++ b/include/configs/som-db5800-som-6867.h
@@ -16,6 +16,4 @@
"stdout=serial,vidconsole\0" \
"stderr=serial,vidconsole\0"
 
-#define VIDEO_IO_OFFSET0
-
 #endif /* __CONFIG_H */
diff --git a/include/configs/theadorable-x86-common.h 
b/include/configs/theadorable-x86-common.h
index b23b8783076b..46aef238213a 100644
--- a/include/configs/theadorable-x86-common.h
+++ b/include/configs/theadorable-x86-common.h
@@ -15,8 +15,6 @@
"stdout=serial\0" \
"stderr=serial\0"
 
-#define VIDEO_IO_OFFSET0
-
 /* 

[PATCH 03/38] bios_emulator: Add Kconfig and adjust Makefile for SPL

2023-03-30 Thread Simon Glass
The Kconfig for this is currently inside a particular board. Move it into
the correct place and allow use in SPL, so that video can be used there
if needed.

Signed-off-by: Simon Glass 
---

 board/google/Kconfig  |  7 ---
 drivers/Kconfig   |  2 ++
 drivers/Makefile  |  2 +-
 drivers/bios_emulator/Kconfig | 10 ++
 4 files changed, 13 insertions(+), 8 deletions(-)
 create mode 100644 drivers/bios_emulator/Kconfig

diff --git a/board/google/Kconfig b/board/google/Kconfig
index a0f1a6097641..e4f9b5b68aab 100644
--- a/board/google/Kconfig
+++ b/board/google/Kconfig
@@ -4,13 +4,6 @@
 
 if VENDOR_GOOGLE
 
-config BIOSEMU
-   bool
-   select X86EMU_RAW_IO
-
-config X86EMU_RAW_IO
-   bool
-
 choice
prompt "Mainboard model"
optional
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 9101e538b097..b5d21e8e6c90 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -10,6 +10,8 @@ source "drivers/ata/Kconfig"
 
 source "drivers/axi/Kconfig"
 
+source "drivers/bios_emulator/Kconfig"
+
 source "drivers/bus/Kconfig"
 
 source "drivers/block/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index 58be410135dd..f9822bea266e 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 
+obj-$(CONFIG_$(SPL_TPL_)BIOSEMU) += bios_emulator/
 obj-$(CONFIG_$(SPL_TPL_)BLK) += block/
 obj-$(CONFIG_$(SPL_TPL_)BOOTCOUNT_LIMIT) += bootcount/
 obj-$(CONFIG_$(SPL_TPL_)BUTTON) += button/
@@ -77,7 +78,6 @@ ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
 obj-y += adc/
 obj-y += ata/
 obj-$(CONFIG_DM_DEMO) += demo/
-obj-$(CONFIG_BIOSEMU) += bios_emulator/
 obj-y += block/
 obj-y += cache/
 obj-$(CONFIG_CPU) += cpu/
diff --git a/drivers/bios_emulator/Kconfig b/drivers/bios_emulator/Kconfig
new file mode 100644
index ..3660576772d1
--- /dev/null
+++ b/drivers/bios_emulator/Kconfig
@@ -0,0 +1,10 @@
+config BIOSEMU
+   bool
+   select X86EMU_RAW_IO
+
+config SPL_BIOSEMU
+   bool
+   select X86EMU_RAW_IO
+
+config X86EMU_RAW_IO
+   bool
-- 
2.40.0.348.gf938b09366-goog



[PATCH 02/38] x86: Allow listing MTRRs in SPL

2023-03-30 Thread Simon Glass
When using video in SPL it is useful to see the values of the MTRR
registers. Move this code into a shared file, so it can be called from
SPL easily.

Signed-off-by: Simon Glass 
---

 arch/x86/cpu/mtrr.c | 61 +
 arch/x86/include/asm/mtrr.h | 20 
 cmd/x86/mtrr.c  | 60 +++-
 3 files changed, 85 insertions(+), 56 deletions(-)

diff --git a/arch/x86/cpu/mtrr.c b/arch/x86/cpu/mtrr.c
index e69dfb552b16..1b5f24aab317 100644
--- a/arch/x86/cpu/mtrr.c
+++ b/arch/x86/cpu/mtrr.c
@@ -30,6 +30,16 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+const char *const mtrr_type_name[MTRR_TYPE_COUNT] = {
+   "Uncacheable",
+   "Combine",
+   "2",
+   "3",
+   "Through",
+   "Protect",
+   "Back",
+};
+
 /* Prepare to adjust MTRRs */
 void mtrr_open(struct mtrr_state *state, bool do_caches)
 {
@@ -320,3 +330,54 @@ int mtrr_set(int cpu_select, int reg, u64 base, u64 mask)
 
return mtrr_start_op(cpu_select, );
 }
+
+static void read_mtrrs_(void *arg)
+{
+   struct mtrr_info *info = arg;
+
+   mtrr_read_all(info);
+}
+
+int mtrr_list(int reg_count, int cpu_select)
+{
+   struct mtrr_info info;
+   int ret;
+   int i;
+
+   printf("Reg Valid Write-type   %-16s %-16s %-16s\n", "Base   ||",
+  "Mask   ||", "Size   ||");
+   memset(, '\0', sizeof(info));
+   ret = mp_run_on_cpus(cpu_select, read_mtrrs_, );
+   if (ret)
+   return log_msg_ret("run", ret);
+   for (i = 0; i < reg_count; i++) {
+   const char *type = "Invalid";
+   u64 base, mask, size;
+   bool valid;
+
+   base = info.mtrr[i].base;
+   mask = info.mtrr[i].mask;
+   size = ~mask & ((1ULL << CONFIG_CPU_ADDR_BITS) - 1);
+   size |= (1 << 12) - 1;
+   size += 1;
+   valid = mask & MTRR_PHYS_MASK_VALID;
+   type = mtrr_type_name[base & MTRR_BASE_TYPE_MASK];
+   printf("%d   %-5s %-12s %016llx %016llx %016llx\n", i,
+  valid ? "Y" : "N", type, base & ~MTRR_BASE_TYPE_MASK,
+  mask & ~MTRR_PHYS_MASK_VALID, size);
+   }
+
+   return 0;
+}
+
+int mtrr_get_type_by_name(const char *typename)
+{
+   int i;
+
+   for (i = 0; i < MTRR_TYPE_COUNT; i++) {
+   if (*typename == *mtrr_type_name[i])
+   return i;
+   }
+
+   return -EINVAL;
+};
diff --git a/arch/x86/include/asm/mtrr.h b/arch/x86/include/asm/mtrr.h
index ca2edc7878f7..2e995f540616 100644
--- a/arch/x86/include/asm/mtrr.h
+++ b/arch/x86/include/asm/mtrr.h
@@ -190,6 +190,26 @@ int mtrr_set(int cpu_select, int reg, u64 base, u64 mask);
  */
 int mtrr_get_var_count(void);
 
+/**
+ * mtrr_list() - List the MTRRs
+ *
+ * Shows a list of all the MTRRs including their values
+ *
+ * @reg_count: Number of registers to show. You can use mtrr_get_var_count() 
for
+ * this
+ * @cpu_select: CPU to use. Use MP_SELECT_BSP for the boot CPU
+ * Returns: 0 if OK, -ve if the CPU was not found
+ */
+int mtrr_list(int reg_count, int cpu_select);
+
+/**
+ * mtrr_get_type_by_name() - Get the type of an MTRR given its type name
+ *
+ * @typename: Name to check
+ * Returns: MTRR type (MTRR_TYPE_...) or -EINVAL if invalid
+ */
+int mtrr_get_type_by_name(const char *typename);
+
 #endif
 
 #if ((CONFIG_XIP_ROM_SIZE & (CONFIG_XIP_ROM_SIZE - 1)) != 0)
diff --git a/cmd/x86/mtrr.c b/cmd/x86/mtrr.c
index ff4be6b7bf5b..fd0e67e46eb3 100644
--- a/cmd/x86/mtrr.c
+++ b/cmd/x86/mtrr.c
@@ -10,71 +10,19 @@
 #include 
 #include 
 
-static const char *const mtrr_type_name[MTRR_TYPE_COUNT] = {
-   "Uncacheable",
-   "Combine",
-   "2",
-   "3",
-   "Through",
-   "Protect",
-   "Back",
-};
-
-static void read_mtrrs(void *arg)
-{
-   struct mtrr_info *info = arg;
-
-   mtrr_read_all(info);
-}
-
-static int do_mtrr_list(int reg_count, int cpu_select)
-{
-   struct mtrr_info info;
-   int ret;
-   int i;
-
-   printf("Reg Valid Write-type   %-16s %-16s %-16s\n", "Base   ||",
-  "Mask   ||", "Size   ||");
-   memset(, '\0', sizeof(info));
-   ret = mp_run_on_cpus(cpu_select, read_mtrrs, );
-   if (ret)
-   return log_msg_ret("run", ret);
-   for (i = 0; i < reg_count; i++) {
-   const char *type = "Invalid";
-   uint64_t base, mask, size;
-   bool valid;
-
-   base = info.mtrr[i].base;
-   mask = info.mtrr[i].mask;
-   size = ~mask & ((1ULL << CONFIG_CPU_ADDR_BITS) - 1);
-   size |= (1 << 12) - 1;
-   size += 1;
-   valid = mask & MTRR_PHYS_MASK_VALID;
-   type = mtrr_type_name[base & MTRR_BASE_TYPE_MASK];
-   printf("%d   %-5s %-12s %016llx %016llx %016llx\n", i,
-  valid ? "Y" : "N", type, base & ~MTRR_BASE_TYPE_MASK,
-  

[PATCH 01/38] x86: Tidy up availability of string functions

2023-03-30 Thread Simon Glass
For now, just enable the fast-but-large string functions in 32-boot
U-Boot proper only. Avoid using them in SPL. We cannot use then in 64-bit
builds since we only have 32-bit assembly.

Signed-off-by: Simon Glass 
---

 arch/x86/include/asm/string.h | 6 +-
 arch/x86/lib/Makefile | 4 +++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/string.h b/arch/x86/include/asm/string.h
index c15b264a5c08..5c49b0f009b7 100644
--- a/arch/x86/include/asm/string.h
+++ b/arch/x86/include/asm/string.h
@@ -14,7 +14,11 @@ extern char *strrchr(const char *s, int c);
 #undef __HAVE_ARCH_STRCHR
 extern char *strchr(const char *s, int c);
 
-#ifdef CONFIG_X86_64
+/*
+ * Our assembly routines do not work on in 64-bit mode and we don't do a lot of
+ * copying in SPL, so code size is more important there.
+ */
+#if defined(CONFIG_SPL_BUILD) || !IS_ENABLED(CONFIG_X86_32BIT_INIT)
 
 #undef __HAVE_ARCH_MEMCPY
 extern void *memcpy(void *, const void *, __kernel_size_t);
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index a6f22441474b..b0612ae6dd5f 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -10,7 +10,9 @@ obj-y += bios.o
 obj-y += bios_asm.o
 obj-y += bios_interrupts.o
 endif
-obj-y += string.o
+endif
+ifndef CONFIG_SPL_BUILD
+obj-$(CONFIG_X86_32BIT_INIT) += string.o
 endif
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
-- 
2.40.0.348.gf938b09366-goog



Please pull u-boot-dm

2023-03-30 Thread Simon Glass
Hi Tom,

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


The following changes since commit 565681e596381b5b6db59cf06931e698f2d829e5:

  imx6sx-udoo-neo-basic: Introduce the u-boot.dtsi (2023-03-28 10:58:16 -0400)

are available in the Git repository at:

  git://git.denx.de/u-boot-dm.git tags/dm-pull-31mar23

for you to fetch changes up to a47164dfc1ef899ef9ddc6d8f2a17f0e9e90ef34:

  sysreset: gpio: fix gpio_reboot_request return value (2023-03-31
08:32:52 +1300)


Fixes for buildman and sysreset


Jonathan Liu (1):
  sysreset: gpio: fix gpio_reboot_request return value

Simon Glass (1):
  buildman: Correct overwriting of settings file

 drivers/sysreset/sysreset_gpio.c | 7 ++-
 tools/buildman/toolchain.py  | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

Regards,
Simon


[PATCH v5 7/8] bootstd: Report missing labels only when asked

2023-03-30 Thread Simon Glass
Use the -l flag to indicate whether to report missing uclasses.

Also try to be more helpful when no devices are found. For example, when
we see something 'scsi0' requested and nothing was found, this indicates
that there are no SCSI devices, so show a suitable message.

Move messages out of the low-level functions so that silent operation
is possible.

This means they are never reported unless BOOTSTD_FULL is enabled, since
that flag cannot otherwise be set.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/bootdev-uclass.c | 32 +---
 include/bootdev.h |  2 +-
 test/boot/bootdev.c   | 12 +---
 3 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index d34b7e37cf79..91087981d213 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -364,7 +364,8 @@ int bootdev_unbind_dev(struct udevice *parent)
  * @seqp: Returns the sequence number, or -1 if none
  * @method_flagsp: If non-NULL, returns any flags implied by the label
  * (enum bootflow_meth_flags_t), 0 if none
- * Returns: sequence number on success, else -ve error code
+ * Returns: sequence number on success, -EPFNOSUPPORT is the uclass is not
+ * known, other -ve error code on other error
  */
 static int label_to_uclass(const char *label, int *seqp, int *method_flagsp)
 {
@@ -394,8 +395,7 @@ static int label_to_uclass(const char *label, int *seqp, 
int *method_flagsp)
id = UCLASS_ETH;
method_flags |= BOOTFLOW_METHF_DHCP_ONLY;
} else {
-   log_warning("Unknown uclass '%s' in label\n", label);
-   return -EINVAL;
+   return -EPFNOSUPPORT;
}
}
if (id == UCLASS_USB)
@@ -458,7 +458,6 @@ int bootdev_find_by_label(const char *label, struct udevice 
**devp,
}
log_debug("- no device in %s\n", media->name);
}
-   log_warning("Unknown seq %d for label '%s'\n", seq, label);
 
return -ENOENT;
 }
@@ -577,9 +576,28 @@ int bootdev_next_label(struct bootflow_iter *iter, struct 
udevice **devp,
 
log_debug("next\n");
for (dev = NULL; !dev && iter->labels[++iter->cur_label];) {
-   log_debug("Scanning: %s\n", iter->labels[iter->cur_label]);
-   bootdev_hunt_and_find_by_label(iter->labels[iter->cur_label],
-  , method_flagsp);
+   const char *label = iter->labels[iter->cur_label];
+   int ret;
+
+   log_debug("Scanning: %s\n", label);
+   ret = bootdev_hunt_and_find_by_label(label, ,
+method_flagsp);
+   if (iter->flags & BOOTFLOWIF_SHOW) {
+   if (ret == -EPFNOSUPPORT) {
+   log_warning("Unknown uclass '%s' in label\n",
+   label);
+   } else if (ret == -ENOENT) {
+   /*
+* looking for, e.g. 'scsi0' should find
+* something if SCSI is present
+*/
+   if (!trailing_strtol(label)) {
+   log_warning("No bootdevs for '%s'\n",
+   label);
+   }
+   }
+   }
+
}
 
if (!dev)
diff --git a/include/bootdev.h b/include/bootdev.h
index b92ff4d4f154..e72ef3650f7c 100644
--- a/include/bootdev.h
+++ b/include/bootdev.h
@@ -258,7 +258,7 @@ int bootdev_find_by_label(const char *label, struct udevice 
**devp,
  * @devp: returns the device found, on success
  * @method_flagsp: If non-NULL, returns any flags implied by the label
  * (enum bootflow_meth_flags_t), 0 if none. Unset if function fails
- * Return: 0 if OK, -EINVAL if the uclass is not supported by this board,
+ * Return: 0 if OK, -EPFNOSUPPORT if the uclass is not supported by this board,
  * -ENOENT if there is no device with that number
  */
 int bootdev_find_by_any(const char *name, struct udevice **devp,
diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c
index 4fe9fd722084..0899c78c2c4a 100644
--- a/test/boot/bootdev.c
+++ b/test/boot/bootdev.c
@@ -124,7 +124,8 @@ static int bootdev_test_labels(struct unit_test_state *uts)
mflags);
 
/* Check invalid uclass */
-   ut_asserteq(-EINVAL, bootdev_find_by_label("fred0", , ));
+   ut_asserteq(-EPFNOSUPPORT,
+   bootdev_find_by_label("fred0", , ));
 
/* Check unknown sequence number */
ut_asserteq(-ENOENT, bootdev_find_by_label("mmc6", , ));
@@ -179,9 +180,8 @@ static int bootdev_test_any(struct unit_test_state *uts)
 
/* Check invalid uclass */
mflags = 123;
-   

[PATCH v5 6/8] bootstd: Show a message sometimes if no bootflows are found

2023-03-30 Thread Simon Glass
Enable some messages that might provide hints, but only for
CMD_BOOTFLOW_FULL since otherwise the -l flag is not available.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 cmd/bootflow.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 42f6e14a4370..aa06999e3db3 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -181,6 +181,9 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int 
flag, int argc,
if (list)
show_footer(i, num_valid);
 
+   if (IS_ENABLED(CONFIG_CMD_BOOTFLOW_FULL) && !num_valid && !list)
+   printf("No bootflows found; try again with -l\n");
+
return 0;
 }
 
-- 
2.40.0.348.gf938b09366-goog



[PATCH v5 4/8] rockchip: Move to standard boot

2023-03-30 Thread Simon Glass
Drop the distro-boot scripts and use standard boot instead.

Signed-off-by: Simon Glass 
---

(no changes since v4)

Changes in v4:
- Add back BOOT_TARGETS

Changes in v3:
- Update rk3588 boards too

Changes in v2:
- Add new patch to move rockchip to standard boot

 include/configs/px30_common.h |  3 +-
 include/configs/rk3036_common.h   |  4 +--
 include/configs/rk3066_common.h   |  4 +--
 include/configs/rk3128_common.h   |  3 +-
 include/configs/rk3188_common.h   |  4 +--
 include/configs/rk322x_common.h   |  4 +--
 include/configs/rk3288_common.h   |  4 +--
 include/configs/rk3308_common.h   |  3 +-
 include/configs/rk3328_common.h   |  3 +-
 include/configs/rk3368_common.h   |  6 ++--
 include/configs/rk3568_common.h   |  5 ++-
 include/configs/rk3588_common.h   |  5 ++-
 include/configs/rockchip-common.h | 58 ---
 include/configs/rv1108_common.h   |  2 +-
 14 files changed, 16 insertions(+), 92 deletions(-)

diff --git a/include/configs/px30_common.h b/include/configs/px30_common.h
index 8df481b09788..6fbd2679f099 100644
--- a/include/configs/px30_common.h
+++ b/include/configs/px30_common.h
@@ -24,12 +24,11 @@
"kernel_addr_c=0x03e8\0" \
"ramdisk_addr_r=0x0a20\0"
 
-#include 
 #define CFG_EXTRA_ENV_SETTINGS \
ENV_MEM_LAYOUT_SETTINGS \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
"partitions=" PARTS_DEFAULT \
ROCKCHIP_DEVICE_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3036_common.h b/include/configs/rk3036_common.h
index ea6073f29446..c2abd14e114b 100644
--- a/include/configs/rk3036_common.h
+++ b/include/configs/rk3036_common.h
@@ -21,8 +21,6 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
-
 /* Linux fails to load the fdt if it's loaded above 512M on a evb-rk3036 board,
  * so limit the fdt reallocation to that */
 #define CFG_EXTRA_ENV_SETTINGS \
@@ -30,6 +28,6 @@
"fdt_high=0x7fff\0" \
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3066_common.h b/include/configs/rk3066_common.h
index 1a6d3678df3e..d70c8f77d487 100644
--- a/include/configs/rk3066_common.h
+++ b/include/configs/rk3066_common.h
@@ -22,14 +22,12 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
-
 #define CFG_EXTRA_ENV_SETTINGS \
"fdt_high=0x6fff\0" \
"initrd_high=0x6fff\0" \
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
ROCKCHIP_DEVICE_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3128_common.h b/include/configs/rk3128_common.h
index 8736b14d1015..d8269b0ec96f 100644
--- a/include/configs/rk3128_common.h
+++ b/include/configs/rk3128_common.h
@@ -22,11 +22,10 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
 #define CFG_EXTRA_ENV_SETTINGS \
ENV_MEM_LAYOUT_SETTINGS \
"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
"partitions=" PARTS_DEFAULT \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3188_common.h b/include/configs/rk3188_common.h
index fcb274565e9e..a8cee1e44d4d 100644
--- a/include/configs/rk3188_common.h
+++ b/include/configs/rk3188_common.h
@@ -21,8 +21,6 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
-
 /* Linux fails to load the fdt if it's loaded above 256M on a Rock board,
  * so limit the fdt reallocation to that */
 #define CFG_EXTRA_ENV_SETTINGS \
@@ -32,6 +30,6 @@
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
ROCKCHIP_DEVICE_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk322x_common.h b/include/configs/rk322x_common.h
index 39a40f4e2d10..15f77df3e17e 100644
--- a/include/configs/rk322x_common.h
+++ b/include/configs/rk322x_common.h
@@ -22,8 +22,6 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
-
 /* Linux fails to load the fdt if it's loaded above 512M on a evb-rk3036 board,
  * so limit the fdt reallocation to that */
 #define CFG_EXTRA_ENV_SETTINGS \
@@ -31,6 +29,6 @@
"fdt_high=0x7fff\0" \
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h
index 71d2426d72a4..3063076a97af 100644
--- a/include/configs/rk3288_common.h
+++ b/include/configs/rk3288_common.h
@@ -23,8 +23,6 @@
"kernel_addr_r=0x0200\0" \
"ramdisk_addr_r=0x0400\0"
 
-#include 
-
 /* Linux fails to load the fdt if it's loaded above 256M on a Rock 2 board, so
  * limit the 

[PATCH v5 5/8] rockchip: Use the same boot_targets for all boards

2023-03-30 Thread Simon Glass
It doesn't really matter if we mention things which are not present. For
example, if 'nvme' is included but the board does not support it, we get
a message like:

   Unknown uclass 'nvme' in label

This seems tolerable. If it creates confusion we could perhaps find a way
to avoid the message, e.g. by maintaining a list of uclasses which may
be missing from the build and supressing warnings about them.

It is simpler to use the same target list for all boards, so drop the
different one for rk3399.

Signed-off-by: Simon Glass 
---

Changes in v5:
- Drop patch to relax the argument requirements for bootflow scan

Changes in v4:
- Rebase to -next
- Add new patch to use the same boot_targets for all boards

 include/configs/rockchip-common.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/include/configs/rockchip-common.h 
b/include/configs/rockchip-common.h
index e9f4072b7e78..9121bba37384 100644
--- a/include/configs/rockchip-common.h
+++ b/include/configs/rockchip-common.h
@@ -13,11 +13,7 @@
 
 #ifndef CONFIG_SPL_BUILD
 
-#ifdef CONFIG_ROCKCHIP_RK3399
 #define BOOT_TARGETS   "mmc1 mmc0 nvme scsi usb pxe dhcp spi"
-#else
-#define BOOT_TARGETS   "mmc1 mmc0 usb pxe dhcp"
-#endif
 
 #ifdef CONFIG_ARM64
 #define ROOT_UUID "B921B045-1DF0-41C3-AF44-4C6F280D3FAE;\0"
-- 
2.40.0.348.gf938b09366-goog



[PATCH v5 3/8] bootstd: Support booting EFI where multiple options exist

2023-03-30 Thread Simon Glass
The current EFI implementation has a strange quirk where it watches
loaded files and uses the last-loaded file to determine the device that
is being booted from.

This is confusing with bootstd, where multiple options may exist. Even
loading a device tree will cause it to go wrong. There is no API for
passing this information, since the only entry into booting an EFI image
is the 'bootefi' command.

To work around this, call efi_set_bootdev() for EFI images, if possible,
just before booting.

Signed-off-by: Simon Glass 
---

Changes in v5:
- Add new patch to support booting EFI where multiple options exist

 boot/bootmeth_efi.c | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index d7e042cf01ee..d8bc7fafd127 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -94,7 +94,7 @@ static int get_efi_pxe_vci(char *str, int max_len)
return 0;
 }
 
-static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
+static void set_efi_bootdev(struct blk_desc *desc, struct bootflow *bflow)
 {
const struct udevice *media_dev;
int size = bflow->size;
@@ -102,11 +102,6 @@ static int efiload_read_file(struct blk_desc *desc, struct 
bootflow *bflow)
char devnum_str[9];
char dirname[200];
char *last_slash;
-   int ret;
-
-   ret = bootmeth_alloc_file(bflow, 0x200, 0x1);
-   if (ret)
-   return log_msg_ret("read", ret);
 
/*
 * This is a horrible hack to tell EFI about this boot device. Once we
@@ -117,7 +112,8 @@ static int efiload_read_file(struct blk_desc *desc, struct 
bootflow *bflow)
 * this can go away.
 */
media_dev = dev_get_parent(bflow->dev);
-   snprintf(devnum_str, sizeof(devnum_str), "%x", dev_seq(media_dev));
+   snprintf(devnum_str, sizeof(devnum_str), "%x:%x", dev_seq(media_dev),
+bflow->part);
 
strlcpy(dirname, bflow->fname, sizeof(dirname));
last_slash = strrchr(dirname, '/');
@@ -130,6 +126,15 @@ static int efiload_read_file(struct blk_desc *desc, struct 
bootflow *bflow)
dev_name = device_get_uclass_id(media_dev) == UCLASS_MASS_STORAGE ?
 "usb" : dev_get_uclass_name(media_dev);
efi_set_bootdev(dev_name, devnum_str, bflow->fname, bflow->buf, size);
+}
+
+static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
+{
+   int ret;
+
+   ret = bootmeth_alloc_file(bflow, 0x200, 0x1);
+   if (ret)
+   return log_msg_ret("read", ret);
 
return 0;
 }
@@ -373,6 +378,13 @@ int distro_efi_boot(struct udevice *dev, struct bootflow 
*bflow)
 
/* A non-zero buffer indicates the kernel is there */
if (bflow->buf) {
+   /* Set the EFI bootdev again, since reading an FDT loses it! */
+   if (bflow->blk) {
+   struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
+
+   set_efi_bootdev(desc, bflow);
+   }
+
kernel = (ulong)map_to_sysmem(bflow->buf);
 
/*
-- 
2.40.0.348.gf938b09366-goog



[PATCH v5 2/8] virtio: Ensure PCI is set up first

2023-03-30 Thread Simon Glass
Sometimes virtio may rely on PCI, or at least that is what the
distro_bootcmd script suggests. Add this in.

Signed-off-by: Simon Glass 
---

Changes in v5:
Add new patch to ensure PCI is set up first

 drivers/virtio/virtio-uclass.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c
index de9bc90359ca..918cc15b019f 100644
--- a/drivers/virtio/virtio-uclass.c
+++ b/drivers/virtio/virtio-uclass.c
@@ -373,6 +373,12 @@ static int virtio_bootdev_hunt(struct bootdev_hunter 
*info, bool show)
 {
int ret;
 
+   if (IS_ENABLED(CONFIG_PCI)) {
+   ret = uclass_probe_all(UCLASS_PCI);
+   if (ret && ret != -ENOENT)
+   return log_msg_ret("pci", ret);
+   }
+
ret = uclass_probe_all(UCLASS_VIRTIO);
if (ret && ret != -ENOENT)
return log_msg_ret("vir", ret);
-- 
2.40.0.348.gf938b09366-goog



[PATCH v5 1/8] bootstd: Tweak bootflow logic for device tree

2023-03-30 Thread Simon Glass
We should only store the FDT filename if we were unable to determine one.
Adjust the logic for this.

This corrects the case where no FDT is needed to boot, such as with EFI
using ACPI.

Signed-off-by: Simon Glass 
---

Changes in v5:
- Add new patch to tweak bootflow logic for device tree

 boot/bootmeth_efi.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index 6a97ac02ff5c..d7e042cf01ee 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -235,21 +235,21 @@ static int distro_efi_read_bootflow_file(struct udevice 
*dev,
 
/* try the various available names */
ret = -ENOENT;
-   for (seq = 0; ret; seq++) {
+   *fname = '\0';
+   for (seq = 0; ret == -ENOENT; seq++) {
ret = distro_efi_get_fdt_name(fname, sizeof(fname), seq);
-   if (ret == -EALREADY) {
+   if (ret == -EALREADY)
bflow->flags = BOOTFLOWF_USE_PRIOR_FDT;
-   break;
-   }
-   if (ret)
-   return log_msg_ret("nam", ret);
-   ret = bootmeth_common_read_file(dev, bflow, fname, fdt_addr,
-   );
+   if (!ret)
+   ret = bootmeth_common_read_file(dev, bflow, fname,
+   fdt_addr, );
}
 
-   bflow->fdt_fname = strdup(fname);
-   if (!bflow->fdt_fname)
-   return log_msg_ret("fil", -ENOMEM);
+   if (*fname) {
+   bflow->fdt_fname = strdup(fname);
+   if (!bflow->fdt_fname)
+   return log_msg_ret("fil", -ENOMEM);
+   }
 
if (!ret) {
bflow->fdt_size = size;
-- 
2.40.0.348.gf938b09366-goog



Re: Missed rename of CONFIG_RAM_RK3399_LPDDR4

2023-03-30 Thread Jagan Teki
On Fri, Mar 31, 2023 at 2:13 AM David Sebek  wrote:
>
> Correction: The correct condition should be:
> #if defined(CONFIG_RAM_ROCKCHIP_LPDDR4)
>
> The constant was renamed from CONFIG_RAM_RK3399_LPDDR4 to 
> CONFIG_RAM_ROCKCHIP_LPDDR4 in commit 26f92be0. I accidentally copy-pasted the 
> wrong value in my previous email.

Please send a patch to mailinglist, if there is any issue.

Thanks,
Jagan.


[RFC PATCH v7 17/23] test: hush: Fix variable expansion tests for hush 2021

2023-03-30 Thread Francis Laniel
Modifies the expected result for hush 2021.
Indeed, there were bugs in actual U-Boot hush which were fixed in upstream
Busybox.
As hush 2021 is based on upstream Busybox, these bugs no longer exist.

Signed-off-by: Francis Laniel 
---
 test/hush/dollar.c | 79 --
 1 file changed, 69 insertions(+), 10 deletions(-)

diff --git a/test/hush/dollar.c b/test/hush/dollar.c
index 27feda2970..0ca799b6b1 100644
--- a/test/hush/dollar.c
+++ b/test/hush/dollar.c
@@ -9,6 +9,9 @@
 #include 
 #include 
 #include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
 
 static int hush_test_simple_dollar(struct unit_test_state *uts)
 {
@@ -51,13 +54,29 @@ static int hush_test_simple_dollar(struct unit_test_state 
*uts)
ut_asserteq(1, run_command("dollar_foo='bar quux", 0));
/* Next line contains error message */
ut_assert_skipline();
-   ut_assert_console_end();
+
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* For some strange reasons, the console is not empty after
+* running above command.
+* So, we reset it to not have side effects for other tests.
+*/
+   console_record_reset_enable();
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_assert_console_end();
+   }
 
ut_asserteq(1, run_command("dollar_foo=bar quux\"", 0));
/* Two next lines contain error message */
ut_assert_skipline();
ut_assert_skipline();
-   ut_assert_console_end();
+
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /* See above comments. */
+   console_record_reset_enable();
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_assert_console_end();
+   }
 
ut_assertok(run_command("dollar_foo='bar \"quux'", 0));
 
@@ -71,17 +90,35 @@ static int hush_test_simple_dollar(struct unit_test_state 
*uts)
 */
console_record_reset_enable();
 
-   ut_asserteq(1, run_command("dollar_foo=\"bar 'quux\"", 0));
-   /* Next line contains error message */
-   ut_assert_skipline();
-   ut_assert_console_end();
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* Old parser returns an error because it waits for closing
+* '\'', but this behavior is wrong as the '\'' is surrounded by
+* '"', so no need to wait for a closing one.
+*/
+   ut_assertok(run_command("dollar_foo=\"bar 'quux\"", 0));
+
+   ut_assertok(run_command("echo $dollar_foo", 0));
+   ut_assert_nextline("bar 'quux");
+   ut_assert_console_end();
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_asserteq(1, run_command("dollar_foo=\"bar 'quux\"", 0));
+   /* Next line contains error message */
+   ut_assert_skipline();
+   ut_assert_console_end();
+   }
 
ut_assertok(run_command("dollar_foo='bar quux'", 0));
ut_assertok(run_command("echo $dollar_foo", 0));
ut_assert_nextline("bar quux");
ut_assert_console_end();
 
-   puts("Beware: this test set local variable dollar_foo and it cannot be 
unset!");
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /* Reset local variable. */
+   ut_assertok(run_command("dollar_foo=", 0));
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   puts("Beware: this test set local variable dollar_foo and it 
cannot be unset!");
+   }
 
return 0;
 }
@@ -109,7 +146,12 @@ static int hush_test_env_dollar(struct unit_test_state 
*uts)
/* Clean up setting the variable */
env_set("env_foo", NULL);
 
-   puts("Beware: this test set local variable env_foo and it cannot be 
unset!");
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /* Reset local variable. */
+   ut_assertok(run_command("env_foo=", 0));
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   puts("Beware: this test set local variable env_foo and it 
cannot be unset!");
+   }
 
return 0;
 }
@@ -144,7 +186,18 @@ static int hush_test_command_dollar(struct unit_test_state 
*uts)
ut_assertok(run_command("dollar_bar='echo bar\\n'", 0));
 
ut_assertok(run_command("$dollar_bar", 0));
-   ut_assert_nextline("barn");
+
+   if (gd->flags & GD_FLG_HUSH_2021_PARSER) {
+   /*
+* This difference seems to come from a bug solved in Busybox
+* hush.
+* Behavior of hush 2021 is coherent with bash and other shells.
+*/
+   ut_assert_nextline("bar\\n");
+   } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+   ut_assert_nextline("barn");
+   }
+
ut_assert_console_end();
 
ut_assertok(run_command("dollar_bar='echo 

Re: WIP: Signing TI x509 certificates using binman

2023-03-30 Thread Simon Glass
Hi Neha,

On Fri, 24 Mar 2023 at 22:28, Neha Malcom Francis  wrote:
>
> Hi Simon,
>
> Before I roll out the entire series that works for packaging K3
> bootloader images, wanted to get some reviews and comments regarding the
> implementation of the signing etype [1] . I believe I've taken into
> consideration what we've discussed earlier [2].
>
> Let me know your thoughts. The tree is also WIP, and was mainly designed
> for testing the signing etype on two of the devices. I will add the
> remaining and refine the series based on the next comments.

Yes this looks reasonable to me. For the openssl method, can you
create a new 'real' method and put the cert stuff in there instead of
using a 'custom' one? It seems to have a lot in common with what is
there. We should really have an internal cert-generator method in that
class, with other functions in that class doing appropriate things. I
am looking for code reuse here, as well as clear indication of what
the cert is for or does. If most of the cert is the same, you could
pass a dict for the CN stuff, perhaps?

What is the taml for? It is hard to tell, from the example provided.

Do you have a .dts which shows the full image for a board? I think the
cert stuff looks right, but it's a bit hard to tell.

When sending the patches please do do follow the function-commenting
style and make sure that it is clear what each arg means. E.g. I saw a
hash integer which I assume is used to pass 256 or 384 or 512 for sha
hashing. It should indicate the possible values / meaning in the arg.
In fact, in that case, it might be better to pass a string like
'sha256'.

Anyway, apart from my questions it seems good.

Regards,
Simon

>
> [1]
> https://github.com/nehamalcom/u-boot/commit/ea7413ed5864340bd6f01e704e8bdcc073a7896b#diff-efb03d61a324724c4f86bf42b45c4e4e614cab18e1b3184f63721d62280a11b5
>
> [2]
> https://patchwork.ozlabs.org/project/uboot/patch/20230224120340.587786-1-n-fran...@ti.com/
>
> --
> Thanking You
> Neha Malcom Francis


[PATCH 06/12] arm: mach-k3: Make release_resources_for_core_shutdown() common

2023-03-30 Thread Andrew Davis
This function is the same for each device when it needs to shutdown
the R5 core. Move this to the common section and move the remaining
device specific ID list to the device hardware include.

Signed-off-by: Andrew Davis 
---
 arch/arm/mach-k3/am642_init.c | 51 -
 arch/arm/mach-k3/am654_init.c | 51 -
 arch/arm/mach-k3/common.c | 32 ++-
 arch/arm/mach-k3/include/mach/am62_hardware.h |  8 +++
 .../arm/mach-k3/include/mach/am62a_hardware.h |  8 +++
 arch/arm/mach-k3/include/mach/am64_hardware.h | 24 
 arch/arm/mach-k3/include/mach/am6_hardware.h  | 19 +++
 .../arm/mach-k3/include/mach/j721e_hardware.h | 19 +++
 .../mach-k3/include/mach/j721s2_hardware.h| 19 +++
 arch/arm/mach-k3/include/mach/sys_proto.h |  1 -
 arch/arm/mach-k3/j721e_init.c | 55 ---
 arch/arm/mach-k3/j721s2_init.c| 54 --
 12 files changed, 127 insertions(+), 214 deletions(-)

diff --git a/arch/arm/mach-k3/am642_init.c b/arch/arm/mach-k3/am642_init.c
index 96f292ea75c..74297be0f20 100644
--- a/arch/arm/mach-k3/am642_init.c
+++ b/arch/arm/mach-k3/am642_init.c
@@ -346,54 +346,3 @@ u32 spl_boot_device(void)
else
return __get_backup_bootmedia(devstat);
 }
-
-#if defined(CONFIG_SYS_K3_SPL_ATF)
-
-#define AM64X_DEV_RTI8 127
-#define AM64X_DEV_RTI9 128
-#define AM64X_DEV_R5FSS0_CORE0 121
-#define AM64X_DEV_R5FSS0_CORE1 122
-
-void release_resources_for_core_shutdown(void)
-{
-   struct ti_sci_handle *ti_sci = get_ti_sci_handle();
-   struct ti_sci_dev_ops *dev_ops = _sci->ops.dev_ops;
-   struct ti_sci_proc_ops *proc_ops = _sci->ops.proc_ops;
-   int ret;
-   u32 i;
-
-   const u32 put_device_ids[] = {
-   AM64X_DEV_RTI9,
-   AM64X_DEV_RTI8,
-   };
-
-   /* Iterate through list of devices to put (shutdown) */
-   for (i = 0; i < ARRAY_SIZE(put_device_ids); i++) {
-   u32 id = put_device_ids[i];
-
-   ret = dev_ops->put_device(ti_sci, id);
-   if (ret)
-   panic("Failed to put device %u (%d)\n", id, ret);
-   }
-
-   const u32 put_core_ids[] = {
-   AM64X_DEV_R5FSS0_CORE1,
-   AM64X_DEV_R5FSS0_CORE0, /* Handle CPU0 after CPU1 */
-   };
-
-   /* Iterate through list of cores to put (shutdown) */
-   for (i = 0; i < ARRAY_SIZE(put_core_ids); i++) {
-   u32 id = put_core_ids[i];
-
-   /*
-* Queue up the core shutdown request. Note that this call
-* needs to be followed up by an actual invocation of an WFE
-* or WFI CPU instruction.
-*/
-   ret = proc_ops->proc_shutdown_no_wait(ti_sci, id);
-   if (ret)
-   panic("Failed sending core %u shutdown message (%d)\n",
- id, ret);
-   }
-}
-#endif
diff --git a/arch/arm/mach-k3/am654_init.c b/arch/arm/mach-k3/am654_init.c
index 768fdd69602..8ee1e9be643 100644
--- a/arch/arm/mach-k3/am654_init.c
+++ b/arch/arm/mach-k3/am654_init.c
@@ -354,54 +354,3 @@ u32 spl_boot_device(void)
else
return __get_backup_bootmedia(devstat);
 }
-
-#ifdef CONFIG_SYS_K3_SPL_ATF
-
-#define AM6_DEV_MCU_RTI0   134
-#define AM6_DEV_MCU_RTI1   135
-#define AM6_DEV_MCU_ARMSS0_CPU0159
-#define AM6_DEV_MCU_ARMSS0_CPU1245
-
-void release_resources_for_core_shutdown(void)
-{
-   struct ti_sci_handle *ti_sci = get_ti_sci_handle();
-   struct ti_sci_dev_ops *dev_ops = _sci->ops.dev_ops;
-   struct ti_sci_proc_ops *proc_ops = _sci->ops.proc_ops;
-   int ret;
-   u32 i;
-
-   const u32 put_device_ids[] = {
-   AM6_DEV_MCU_RTI0,
-   AM6_DEV_MCU_RTI1,
-   };
-
-   /* Iterate through list of devices to put (shutdown) */
-   for (i = 0; i < ARRAY_SIZE(put_device_ids); i++) {
-   u32 id = put_device_ids[i];
-
-   ret = dev_ops->put_device(ti_sci, id);
-   if (ret)
-   panic("Failed to put device %u (%d)\n", id, ret);
-   }
-
-   const u32 put_core_ids[] = {
-   AM6_DEV_MCU_ARMSS0_CPU1,
-   AM6_DEV_MCU_ARMSS0_CPU0,/* Handle CPU0 after CPU1 */
-   };
-
-   /* Iterate through list of cores to put (shutdown) */
-   for (i = 0; i < ARRAY_SIZE(put_core_ids); i++) {
-   u32 id = put_core_ids[i];
-
-   /*
-* Queue up the core shutdown request. Note that this call
-* needs to be followed up by an actual invocation of an WFE
-* or WFI CPU instruction.
-*/
-   ret = proc_ops->proc_shutdown_no_wait(ti_sci, id);
- 

[PATCH 12/12] arm: mach-k3: Remove empty sys_proto.h include

2023-03-30 Thread Andrew Davis
This header file is now empty, remove it.

Signed-off-by: Andrew Davis 
---
 arch/arm/mach-k3/am642_init.c |  2 --
 arch/arm/mach-k3/am654_init.c |  1 -
 arch/arm/mach-k3/common.c |  1 -
 arch/arm/mach-k3/include/mach/sys_proto.h | 10 --
 arch/arm/mach-k3/j721e_init.c |  1 -
 arch/arm/mach-k3/j721s2_init.c|  1 -
 arch/arm/mach-k3/security.c   |  1 -
 arch/arm/mach-k3/sysfw-loader.c   |  1 -
 board/siemens/iot2050/board.c |  1 -
 board/ti/am62ax/evm.c |  1 -
 board/ti/am62x/evm.c  |  1 -
 board/ti/am64x/evm.c  |  1 -
 board/ti/am65x/evm.c  |  2 --
 board/ti/j721e/evm.c  |  2 --
 board/ti/j721s2/evm.c |  2 --
 drivers/phy/phy-ti-am654.c|  1 -
 drivers/ram/k3-am654-ddrss.c  |  1 -
 17 files changed, 30 deletions(-)
 delete mode 100644 arch/arm/mach-k3/include/mach/sys_proto.h

diff --git a/arch/arm/mach-k3/am642_init.c b/arch/arm/mach-k3/am642_init.c
index 192c8f785de..078755178ea 100644
--- a/arch/arm/mach-k3/am642_init.c
+++ b/arch/arm/mach-k3/am642_init.c
@@ -13,9 +13,7 @@
 #include 
 #include 
 #include "sysfw-loader.h"
-#include 
 #include "common.h"
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-k3/am654_init.c b/arch/arm/mach-k3/am654_init.c
index 5a9a780f521..b5021069d62 100644
--- a/arch/arm/mach-k3/am654_init.c
+++ b/arch/arm/mach-k3/am654_init.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include "sysfw-loader.h"
-#include 
 #include "common.h"
 #include 
 #include 
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 9f2f5a98771..e29e51b7042 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-k3/include/mach/sys_proto.h 
b/arch/arm/mach-k3/include/mach/sys_proto.h
deleted file mode 100644
index 5638c6f8c8a..000
--- a/arch/arm/mach-k3/include/mach/sys_proto.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
- * Andreas Dannenberg 
- */
-
-#ifndef _SYS_PROTO_H_
-#define _SYS_PROTO_H_
-
-#endif
diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
index 92f11133c85..7666ac9b91a 100644
--- a/arch/arm/mach-k3/j721e_init.c
+++ b/arch/arm/mach-k3/j721e_init.c
@@ -14,7 +14,6 @@
 #include 
 #include "sysfw-loader.h"
 #include "common.h"
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-k3/j721s2_init.c b/arch/arm/mach-k3/j721s2_init.c
index 175ac4028a0..001d9466c20 100644
--- a/arch/arm/mach-k3/j721s2_init.c
+++ b/arch/arm/mach-k3/j721s2_init.c
@@ -14,7 +14,6 @@
 #include 
 #include "sysfw-loader.h"
 #include "common.h"
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/arm/mach-k3/security.c b/arch/arm/mach-k3/security.c
index 092588f4b5e..6179f7373aa 100644
--- a/arch/arm/mach-k3/security.c
+++ b/arch/arm/mach-k3/security.c
@@ -17,7 +17,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "common.h"
diff --git a/arch/arm/mach-k3/sysfw-loader.c b/arch/arm/mach-k3/sysfw-loader.c
index c4c5c371100..9be2d9eaea2 100644
--- a/arch/arm/mach-k3/sysfw-loader.c
+++ b/arch/arm/mach-k3/sysfw-loader.c
@@ -23,7 +23,6 @@
 #include 
 
 #include 
-#include 
 #include "common.h"
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c
index 8b0506e4cb9..e0614ff853d 100644
--- a/board/siemens/iot2050/board.c
+++ b/board/siemens/iot2050/board.c
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/board/ti/am62ax/evm.c b/board/ti/am62ax/evm.c
index beef3f2f3da..f2dd3b4192e 100644
--- a/board/ti/am62ax/evm.c
+++ b/board/ti/am62ax/evm.c
@@ -7,7 +7,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/board/ti/am62x/evm.c b/board/ti/am62x/evm.c
index 20b2a701223..034fbed3aa4 100644
--- a/board/ti/am62x/evm.c
+++ b/board/ti/am62x/evm.c
@@ -15,7 +15,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/board/ti/am64x/evm.c b/board/ti/am64x/evm.c
index c88139ac7ac..b63792e 100644
--- a/board/ti/am64x/evm.c
+++ b/board/ti/am64x/evm.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "../common/board_detect.h"
diff --git a/board/ti/am65x/evm.c b/board/ti/am65x/evm.c
index 4053b8333cf..706b2198183 100644
--- a/board/ti/am65x/evm.c
+++ b/board/ti/am65x/evm.c
@@ -13,7 +13,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -21,7 +20,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "../common/board_detect.h"
 
diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c
index 

[PATCH 11/12] arm: mach-k3: Move J721s2 SPL init functions to mach-k3

2023-03-30 Thread Andrew Davis
This matches AM64 and J721e and removes the need to forward
declare k3_spl_init(), k3_mem_init(), and check_rom_loaded_sysfw()
in sys_proto.h.

Signed-off-by: Andrew Davis 
---
 arch/arm/mach-k3/include/mach/sys_proto.h |  3 --
 arch/arm/mach-k3/j721s2_init.c| 64 +++
 board/ti/j721s2/evm.c | 63 --
 3 files changed, 64 insertions(+), 66 deletions(-)

diff --git a/arch/arm/mach-k3/include/mach/sys_proto.h 
b/arch/arm/mach-k3/include/mach/sys_proto.h
index 4b4e2a5be39..5638c6f8c8a 100644
--- a/arch/arm/mach-k3/include/mach/sys_proto.h
+++ b/arch/arm/mach-k3/include/mach/sys_proto.h
@@ -7,7 +7,4 @@
 #ifndef _SYS_PROTO_H_
 #define _SYS_PROTO_H_
 
-void k3_spl_init(void);
-void k3_mem_init(void);
-bool check_rom_loaded_sysfw(void);
 #endif
diff --git a/arch/arm/mach-k3/j721s2_init.c b/arch/arm/mach-k3/j721s2_init.c
index 4785a747bf3..175ac4028a0 100644
--- a/arch/arm/mach-k3/j721s2_init.c
+++ b/arch/arm/mach-k3/j721s2_init.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -182,6 +183,69 @@ void k3_mem_init(void)
spl_enable_dcache();
 }
 
+/* Support for the various EVM / SK families */
+#if defined(CONFIG_SPL_OF_LIST) && defined(CONFIG_TI_I2C_BOARD_DETECT)
+void do_dt_magic(void)
+{
+   int ret, rescan, mmc_dev = -1;
+   static struct mmc *mmc;
+
+   do_board_detect();
+
+   /*
+* Board detection has been done.
+* Let us see if another dtb wouldn't be a better match
+* for our board
+*/
+   if (IS_ENABLED(CONFIG_CPU_V7R)) {
+   ret = fdtdec_resetup();
+   if (!ret && rescan) {
+   dm_uninit();
+   dm_init_and_scan(true);
+   }
+   }
+
+   /*
+* Because of multi DTB configuration, the MMC device has
+* to be re-initialized after reconfiguring FDT inorder to
+* boot from MMC. Do this when boot mode is MMC and ROM has
+* not loaded SYSFW.
+*/
+   switch (spl_boot_device()) {
+   case BOOT_DEVICE_MMC1:
+   mmc_dev = 0;
+   break;
+   case BOOT_DEVICE_MMC2:
+   case BOOT_DEVICE_MMC2_2:
+   mmc_dev = 1;
+   break;
+   }
+
+   if (mmc_dev > 0 && !check_rom_loaded_sysfw()) {
+   ret = mmc_init_device(mmc_dev);
+   if (!ret) {
+   mmc = find_mmc_device(mmc_dev);
+   if (mmc) {
+   ret = mmc_init(mmc);
+   if (ret)
+   printf("mmc init failed with error: 
%d\n", ret);
+   }
+   }
+   }
+}
+#endif
+
+#ifdef CONFIG_SPL_BUILD
+void board_init_f(ulong dummy)
+{
+   k3_spl_init();
+#if defined(CONFIG_SPL_OF_LIST) && defined(CONFIG_TI_I2C_BOARD_DETECT)
+   do_dt_magic();
+#endif
+   k3_mem_init();
+}
+#endif
+
 u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
switch (boot_device) {
diff --git a/board/ti/j721s2/evm.c b/board/ti/j721s2/evm.c
index 9b130c141ac..d3f9a655899 100644
--- a/board/ti/j721s2/evm.c
+++ b/board/ti/j721s2/evm.c
@@ -192,66 +192,3 @@ int board_late_init(void)
 void spl_board_init(void)
 {
 }
-
-/* Support for the various EVM / SK families */
-#if defined(CONFIG_SPL_OF_LIST) && defined(CONFIG_TI_I2C_BOARD_DETECT)
-void do_dt_magic(void)
-{
-   int ret, rescan, mmc_dev = -1;
-   static struct mmc *mmc;
-
-   do_board_detect();
-
-   /*
-* Board detection has been done.
-* Let us see if another dtb wouldn't be a better match
-* for our board
-*/
-   if (IS_ENABLED(CONFIG_CPU_V7R)) {
-   ret = fdtdec_resetup();
-   if (!ret && rescan) {
-   dm_uninit();
-   dm_init_and_scan(true);
-   }
-   }
-
-   /*
-* Because of multi DTB configuration, the MMC device has
-* to be re-initialized after reconfiguring FDT inorder to
-* boot from MMC. Do this when boot mode is MMC and ROM has
-* not loaded SYSFW.
-*/
-   switch (spl_boot_device()) {
-   case BOOT_DEVICE_MMC1:
-   mmc_dev = 0;
-   break;
-   case BOOT_DEVICE_MMC2:
-   case BOOT_DEVICE_MMC2_2:
-   mmc_dev = 1;
-   break;
-   }
-
-   if (mmc_dev > 0 && !check_rom_loaded_sysfw()) {
-   ret = mmc_init_device(mmc_dev);
-   if (!ret) {
-   mmc = find_mmc_device(mmc_dev);
-   if (mmc) {
-   ret = mmc_init(mmc);
-   if (ret)
-   printf("mmc init failed with error: 
%d\n", ret);
-   }
-   }
-   }
-}
-#endif
-
-#ifdef CONFIG_SPL_BUILD
-void 

[PATCH 01/12] arm: mach-k3: Move MSMC fixup to SoC level

2023-03-30 Thread Andrew Davis
The MSMC fixup is something we do based on SoC, not based on the board.
So this fixup does not belong in the board files. Move this to the
mach-k3 common file so that it does not have to be done in each board
that uses these SoCs.

We use ft_system_setup() here instead of ft_board_setup() since it is no
longer board level. Enable OF_SYSTEM_SETUP in the configurations that use
this to keep functionality the same.

Signed-off-by: Andrew Davis 
---
 arch/arm/mach-k3/common.c | 16 
 arch/arm/mach-k3/include/mach/sys_proto.h |  1 -
 board/siemens/iot2050/board.c | 16 
 board/ti/am65x/evm.c  | 18 --
 board/ti/j721e/evm.c  | 11 +--
 board/ti/j721s2/evm.c | 16 
 configs/am65x_evm_a53_defconfig   |  2 +-
 configs/am65x_hs_evm_a53_defconfig|  2 +-
 configs/iot2050_defconfig |  2 +-
 configs/j7200_evm_a72_defconfig   |  1 +
 configs/j7200_hs_evm_a72_defconfig|  1 +
 configs/j721e_evm_a72_defconfig   |  1 +
 configs/j721e_hs_evm_a72_defconfig|  1 +
 configs/j721s2_evm_a72_defconfig  |  2 +-
 configs/j721s2_hs_evm_a72_defconfig   |  2 +-
 15 files changed, 26 insertions(+), 66 deletions(-)

diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index a2adb791f6c..6870f13c520 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -386,6 +386,22 @@ int fdt_disable_node(void *blob, char *node_path)
return 0;
 }
 
+#if defined(CONFIG_OF_SYSTEM_SETUP)
+int ft_system_setup(void *blob, struct bd_info *bd)
+{
+   int ret;
+
+   ret = fdt_fixup_msmc_ram(blob, "/bus@10", "sram@7000");
+   if (ret < 0)
+   ret = fdt_fixup_msmc_ram(blob, "/interconnect@10",
+"sram@7000");
+   if (ret)
+   printf("%s: fixing up msmc ram failed %d\n", __func__, ret);
+
+   return ret;
+}
+#endif
+
 #endif
 
 #ifndef CONFIG_SYSRESET
diff --git a/arch/arm/mach-k3/include/mach/sys_proto.h 
b/arch/arm/mach-k3/include/mach/sys_proto.h
index 3d3d90d02d6..0b5d606eaa2 100644
--- a/arch/arm/mach-k3/include/mach/sys_proto.h
+++ b/arch/arm/mach-k3/include/mach/sys_proto.h
@@ -11,7 +11,6 @@ void sdelay(unsigned long loops);
 u32 wait_on_value(u32 read_bit_mask, u32 match_value, void *read_addr,
  u32 bound);
 struct ti_sci_handle *get_ti_sci_handle(void);
-int fdt_fixup_msmc_ram(void *blob, char *parent_path, char *node_name);
 int do_board_detect(void);
 void release_resources_for_core_shutdown(void);
 int fdt_disable_node(void *blob, char *node_path);
diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c
index 8f4b0eae495..8b0506e4cb9 100644
--- a/board/siemens/iot2050/board.c
+++ b/board/siemens/iot2050/board.c
@@ -230,22 +230,6 @@ int board_late_init(void)
return 0;
 }
 
-#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
-int ft_board_setup(void *blob, struct bd_info *bd)
-{
-   int ret;
-
-   ret = fdt_fixup_msmc_ram(blob, "/bus@10", "sram@7000");
-   if (ret < 0)
-   ret = fdt_fixup_msmc_ram(blob, "/interconnect@10",
-"sram@7000");
-   if (ret)
-   pr_err("%s: fixing up msmc ram failed %d\n", __func__, ret);
-
-   return ret;
-}
-#endif
-
 void spl_board_init(void)
 {
 }
diff --git a/board/ti/am65x/evm.c b/board/ti/am65x/evm.c
index b266ccb4b82..4053b8333cf 100644
--- a/board/ti/am65x/evm.c
+++ b/board/ti/am65x/evm.c
@@ -101,24 +101,6 @@ int board_fit_config_name_match(const char *name)
 }
 #endif
 
-#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
-int ft_board_setup(void *blob, struct bd_info *bd)
-{
-   int ret;
-
-   ret = fdt_fixup_msmc_ram(blob, "/bus@10", "sram@7000");
-   if (ret < 0)
-   ret = fdt_fixup_msmc_ram(blob, "/interconnect@10",
-"sram@7000");
-   if (ret) {
-   printf("%s: fixing up msmc ram failed %d\n", __func__, ret);
-   return ret;
-   }
-
-   return 0;
-}
-#endif
-
 #ifdef CONFIG_TI_I2C_BOARD_DETECT
 int do_board_detect(void)
 {
diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c
index d4e672a7acd..00ce009d3e8 100644
--- a/board/ti/j721e/evm.c
+++ b/board/ti/j721e/evm.c
@@ -144,18 +144,9 @@ void spl_perform_fixups(struct spl_image_info *spl_image)
 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
-   int ret;
-
-   ret = fdt_fixup_msmc_ram(blob, "/bus@10", "sram@7000");
-   if (ret < 0)
-   ret = fdt_fixup_msmc_ram(blob, "/interconnect@10",
-"sram@7000");
-   if (ret)
-   printf("%s: fixing up msmc ram failed 

[PATCH 10/12] arm: mach-k3: Move sdelay() and wait_on_value() declaration

2023-03-30 Thread Andrew Davis
These probably should be in some system wide header given their use.
Until then move them out of K3 sys_proto.h so we can finish cleaning
that header out.

Signed-off-by: Andrew Davis 
---
 arch/arm/mach-k3/include/mach/sys_proto.h | 4 
 drivers/ram/k3-am654-ddrss.c  | 4 
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-k3/include/mach/sys_proto.h 
b/arch/arm/mach-k3/include/mach/sys_proto.h
index bbe57718e1a..4b4e2a5be39 100644
--- a/arch/arm/mach-k3/include/mach/sys_proto.h
+++ b/arch/arm/mach-k3/include/mach/sys_proto.h
@@ -7,10 +7,6 @@
 #ifndef _SYS_PROTO_H_
 #define _SYS_PROTO_H_
 
-void sdelay(unsigned long loops);
-u32 wait_on_value(u32 read_bit_mask, u32 match_value, void *read_addr,
- u32 bound);
-
 void k3_spl_init(void);
 void k3_mem_init(void);
 bool check_rom_loaded_sysfw(void);
diff --git a/drivers/ram/k3-am654-ddrss.c b/drivers/ram/k3-am654-ddrss.c
index 4453c247b29..adac14f9464 100644
--- a/drivers/ram/k3-am654-ddrss.c
+++ b/drivers/ram/k3-am654-ddrss.c
@@ -18,6 +18,10 @@
 #include 
 #include "k3-am654-ddrss.h"
 
+void sdelay(unsigned long loops);
+u32 wait_on_value(u32 read_bit_mask, u32 match_value, void *read_addr,
+ u32 bound);
+
 #define LDELAY 1
 
 /* DDRSS PHY configuration register fixed values */
-- 
2.39.2



[PATCH 03/12] soc: soc_ti_k3: Use hardware.h to remove definition duplication

2023-03-30 Thread Andrew Davis
The K3 JTAG and SoC ID information is already stored in the K3 arch
hardware file, include that and use its definitions here.

Signed-off-by: Andrew Davis 
---
 drivers/soc/Kconfig |  2 +-
 drivers/soc/soc_ti_k3.c | 30 +-
 2 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index acf555baaec..85dac9de78a 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -10,7 +10,7 @@ config SOC_DEVICE
  specific device variant in use.
 
 config SOC_DEVICE_TI_K3
-   depends on SOC_DEVICE
+   depends on SOC_DEVICE && ARCH_K3
bool "Enable SoC Device ID driver for TI K3 SoCs"
help
  This allows Texas Instruments Keystone 3 SoCs to identify
diff --git a/drivers/soc/soc_ti_k3.c b/drivers/soc/soc_ti_k3.c
index 8af0ac70519..42430d79a7a 100644
--- a/drivers/soc/soc_ti_k3.c
+++ b/drivers/soc/soc_ti_k3.c
@@ -8,21 +8,9 @@
 #include 
 #include 
 
+#include 
 #include 
 
-#define AM65X  0xbb5a
-#define J721E  0xbb64
-#define J7200  0xbb6d
-#define AM64X  0xbb38
-#define J721S2 0xbb75
-#define AM62X  0xbb7e
-#define AM62AX 0xbb8d
-
-#define JTAG_ID_VARIANT_SHIFT  28
-#define JTAG_ID_VARIANT_MASK   (0xf << 28)
-#define JTAG_ID_PARTNO_SHIFT   12
-#define JTAG_ID_PARTNO_MASK(0x << 12)
-
 struct soc_ti_k3_plat {
const char *family;
const char *revision;
@@ -36,25 +24,25 @@ static const char *get_family_string(u32 idreg)
soc = (idreg & JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT;
 
switch (soc) {
-   case AM65X:
+   case JTAG_ID_PARTNO_AM65X:
family = "AM65X";
break;
-   case J721E:
+   case JTAG_ID_PARTNO_J721E:
family = "J721E";
break;
-   case J7200:
+   case JTAG_ID_PARTNO_J7200:
family = "J7200";
break;
-   case AM64X:
+   case JTAG_ID_PARTNO_AM64X:
family = "AM64X";
break;
-   case J721S2:
+   case JTAG_ID_PARTNO_J721S2:
family = "J721S2";
break;
-   case AM62X:
+   case JTAG_ID_PARTNO_AM62X:
family = "AM62X";
break;
-   case AM62AX:
+   case JTAG_ID_PARTNO_AM62AX:
family = "AM62AX";
break;
default:
@@ -81,7 +69,7 @@ static const char *get_rev_string(u32 idreg)
soc = (idreg & JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT;
 
switch (soc) {
-   case J721E:
+   case JTAG_ID_PARTNO_J721E:
if (rev > ARRAY_SIZE(j721e_rev_string_map))
goto bail;
return j721e_rev_string_map[rev];
-- 
2.39.2



[PATCH 08/12] arm: mach-k3: Add weak do_board_detect() to common file

2023-03-30 Thread Andrew Davis
This matches how it was done for pre-K3 TI platforms and it allows
us to move the forward declaration out of sys_proto.h.

It also removes the need to check for TI_I2C_BOARD_DETECT before
calling this function, which might not be the right guard ifdef
should a board use a different method for board detection.

Signed-off-by: Andrew Davis 
---
 arch/arm/mach-k3/am642_init.c |  3 +--
 arch/arm/mach-k3/am654_init.c |  3 +--
 arch/arm/mach-k3/common.c | 10 ++
 arch/arm/mach-k3/common.h |  2 ++
 arch/arm/mach-k3/include/mach/sys_proto.h |  2 --
 arch/arm/mach-k3/j721e_init.c |  6 ++
 6 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-k3/am642_init.c b/arch/arm/mach-k3/am642_init.c
index b29b7376ffd..192c8f785de 100644
--- a/arch/arm/mach-k3/am642_init.c
+++ b/arch/arm/mach-k3/am642_init.c
@@ -100,8 +100,7 @@ void do_dt_magic(void)
 {
int ret, rescan;
 
-   if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT))
-   do_board_detect();
+   do_board_detect();
 
/*
 * Board detection has been done.
diff --git a/arch/arm/mach-k3/am654_init.c b/arch/arm/mach-k3/am654_init.c
index 5b8e506c793..5a9a780f521 100644
--- a/arch/arm/mach-k3/am654_init.c
+++ b/arch/arm/mach-k3/am654_init.c
@@ -246,8 +246,7 @@ void board_init_f(ulong dummy)
k3_sysfw_print_ver();
 
/* Perform EEPROM-based board detection */
-   if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT))
-   do_board_detect();
+   do_board_detect();
 
 #if defined(CONFIG_CPU_V7R) && defined(CONFIG_K3_AVS0)
ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(k3_avs),
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 4f2e14c3105..115f5959734 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -636,3 +636,13 @@ int misc_init_r(void)
 
return 0;
 }
+
+/**
+ * do_board_detect() - Detect board description
+ *
+ * Function to detect board description. This is expected to be
+ * overridden in the SoC family board file where desired.
+ */
+void __weak do_board_detect(void)
+{
+}
diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h
index 531be0be54c..130f5021123 100644
--- a/arch/arm/mach-k3/common.h
+++ b/arch/arm/mach-k3/common.h
@@ -35,3 +35,5 @@ void mmr_unlock(phys_addr_t base, u32 partition);
 bool is_rom_loaded_sysfw(struct rom_extended_boot_data *data);
 enum k3_device_type get_device_type(void);
 void ti_secure_image_post_process(void **p_image, size_t *p_size);
+struct ti_sci_handle *get_ti_sci_handle(void);
+void do_board_detect(void);
diff --git a/arch/arm/mach-k3/include/mach/sys_proto.h 
b/arch/arm/mach-k3/include/mach/sys_proto.h
index 8cc75b636b5..939de0f79b4 100644
--- a/arch/arm/mach-k3/include/mach/sys_proto.h
+++ b/arch/arm/mach-k3/include/mach/sys_proto.h
@@ -10,8 +10,6 @@
 void sdelay(unsigned long loops);
 u32 wait_on_value(u32 read_bit_mask, u32 match_value, void *read_addr,
  u32 bound);
-struct ti_sci_handle *get_ti_sci_handle(void);
-int do_board_detect(void);
 int fdt_disable_node(void *blob, char *node_path);
 
 void k3_spl_init(void);
diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
index 6c18778c73e..92f11133c85 100644
--- a/arch/arm/mach-k3/j721e_init.c
+++ b/arch/arm/mach-k3/j721e_init.c
@@ -160,8 +160,7 @@ void do_dt_magic(void)
int ret, rescan, mmc_dev = -1;
static struct mmc *mmc;
 
-   if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT))
-   do_board_detect();
+   do_board_detect();
 
/*
 * Board detection has been done.
@@ -288,8 +287,7 @@ void board_init_f(ulong dummy)
k3_sysfw_print_ver();
 
/* Perform EEPROM-based board detection */
-   if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT))
-   do_board_detect();
+   do_board_detect();
 
 #if defined(CONFIG_CPU_V7R) && defined(CONFIG_K3_AVS0)
ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(k3_avs),
-- 
2.39.2



[PATCH 04/12] configs: j721x_evm.h: Remove unneeded check for SYS_K3_SPL_ATF

2023-03-30 Thread Andrew Davis
The TARGET_x_R5_EVM check is already enough to limit these defines to
only the correct builds. Remove the extra outer check.

Signed-off-by: Andrew Davis 
---
 include/configs/j721e_evm.h  | 4 +---
 include/configs/j721s2_evm.h | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/configs/j721e_evm.h b/include/configs/j721e_evm.h
index 48b1cea6e39..b2138c33b57 100644
--- a/include/configs/j721e_evm.h
+++ b/include/configs/j721e_evm.h
@@ -51,7 +51,6 @@
"uuid_disk=${uuid_gpt_disk};" \
"name=rootfs,start=0,size=-,uuid=${uuid_gpt_rootfs}\0"
 
-#ifdef CONFIG_SYS_K3_SPL_ATF
 #if defined(CONFIG_TARGET_J721E_R5_EVM)
 #define EXTRA_ENV_R5_SPL_RPROC_FW_ARGS_MMC \
"addr_mcur5f0_0load=0x8900\0"   \
@@ -60,10 +59,9 @@
 #define EXTRA_ENV_R5_SPL_RPROC_FW_ARGS_MMC \
"addr_mcur5f0_0load=0x8900\0"   \
"name_mcur5f0_0fw=/lib/firmware/j7200-mcu-r5f0_0-fw\0"
-#endif /* CONFIG_TARGET_J721E_R5_EVM */
 #else
 #define EXTRA_ENV_R5_SPL_RPROC_FW_ARGS_MMC ""
-#endif /* CONFIG_SYS_K3_SPL_ATF */
+#endif
 
 /* U-Boot MMC-specific configuration */
 #define EXTRA_ENV_J721E_BOARD_SETTINGS_MMC \
diff --git a/include/configs/j721s2_evm.h b/include/configs/j721s2_evm.h
index bfada9eebc2..d401f28ff21 100644
--- a/include/configs/j721s2_evm.h
+++ b/include/configs/j721s2_evm.h
@@ -48,7 +48,6 @@
"uuid_disk=${uuid_gpt_disk};" \
"name=rootfs,start=0,size=-,uuid=${uuid_gpt_rootfs}\0"
 
-#ifdef CONFIG_SYS_K3_SPL_ATF
 #if defined(CONFIG_TARGET_J721S2_R5_EVM)
 #define EXTRA_ENV_R5_SPL_RPROC_FW_ARGS_MMC \
"addr_mcur5f0_0load=0x8900\0"   \
@@ -57,10 +56,9 @@
 #define EXTRA_ENV_R5_SPL_RPROC_FW_ARGS_MMC \
"addr_mcur5f0_0load=0x8900\0"   \
"name_mcur5f0_0fw=/lib/firmware/j7200-mcu-r5f0_0-fw\0"
-#endif /* CONFIG_TARGET_J721S2_R5_EVM */
 #else
 #define EXTRA_ENV_R5_SPL_RPROC_FW_ARGS_MMC ""
-#endif /* CONFIG_SYS_K3_SPL_ATF */
+#endif
 
 /* U-Boot MMC-specific configuration */
 #define EXTRA_ENV_J721S2_BOARD_SETTINGS_MMC\
-- 
2.39.2



[PATCH 09/12] arm: mach-k3: Remove unused fdt_disable_node()

2023-03-30 Thread Andrew Davis
This function is not used currently; remove it.

Signed-off-by: Andrew Davis 
---
 arch/arm/mach-k3/common.c | 19 ---
 arch/arm/mach-k3/include/mach/sys_proto.h |  1 -
 2 files changed, 20 deletions(-)

diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 115f5959734..9f2f5a98771 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -395,25 +395,6 @@ int fdt_fixup_msmc_ram(void *blob, char *parent_path, char 
*node_name)
return 0;
 }
 
-int fdt_disable_node(void *blob, char *node_path)
-{
-   int offs;
-   int ret;
-
-   offs = fdt_path_offset(blob, node_path);
-   if (offs < 0) {
-   printf("Node %s not found.\n", node_path);
-   return offs;
-   }
-   ret = fdt_setprop_string(blob, offs, "status", "disabled");
-   if (ret < 0) {
-   printf("Could not add status property to node %s: %s\n",
-  node_path, fdt_strerror(ret));
-   return ret;
-   }
-   return 0;
-}
-
 #if defined(CONFIG_OF_SYSTEM_SETUP)
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
diff --git a/arch/arm/mach-k3/include/mach/sys_proto.h 
b/arch/arm/mach-k3/include/mach/sys_proto.h
index 939de0f79b4..bbe57718e1a 100644
--- a/arch/arm/mach-k3/include/mach/sys_proto.h
+++ b/arch/arm/mach-k3/include/mach/sys_proto.h
@@ -10,7 +10,6 @@
 void sdelay(unsigned long loops);
 u32 wait_on_value(u32 read_bit_mask, u32 match_value, void *read_addr,
  u32 bound);
-int fdt_disable_node(void *blob, char *node_path);
 
 void k3_spl_init(void);
 void k3_mem_init(void);
-- 
2.39.2



[PATCH 07/12] arm: mach-k3: Move sysfw-loader.h out of mach includes

2023-03-30 Thread Andrew Davis
This header is only used locally by K3 init files, no need to have it
up with the global mach includes. Move into local includes.

Signed-off-by: Andrew Davis 
---
 arch/arm/mach-k3/am625_init.c  | 2 +-
 arch/arm/mach-k3/am62a7_init.c | 2 +-
 arch/arm/mach-k3/am642_init.c  | 2 +-
 arch/arm/mach-k3/am654_init.c  | 2 +-
 arch/arm/mach-k3/j721e_init.c  | 2 +-
 arch/arm/mach-k3/j721s2_init.c | 2 +-
 arch/arm/mach-k3/{include/mach => }/sysfw-loader.h | 0
 7 files changed, 6 insertions(+), 6 deletions(-)
 rename arch/arm/mach-k3/{include/mach => }/sysfw-loader.h (100%)

diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c
index a91c15ca4e1..026c4f9c02d 100644
--- a/arch/arm/mach-k3/am625_init.c
+++ b/arch/arm/mach-k3/am625_init.c
@@ -9,7 +9,7 @@
 #include 
 #include 
 #include 
-#include 
+#include "sysfw-loader.h"
 #include "common.h"
 #include 
 #include 
diff --git a/arch/arm/mach-k3/am62a7_init.c b/arch/arm/mach-k3/am62a7_init.c
index 02da24a3d6f..a89a9b4ae3a 100644
--- a/arch/arm/mach-k3/am62a7_init.c
+++ b/arch/arm/mach-k3/am62a7_init.c
@@ -8,7 +8,7 @@
 #include 
 #include 
 #include 
-#include 
+#include "sysfw-loader.h"
 #include "common.h"
 #include 
 #include 
diff --git a/arch/arm/mach-k3/am642_init.c b/arch/arm/mach-k3/am642_init.c
index 74297be0f20..b29b7376ffd 100644
--- a/arch/arm/mach-k3/am642_init.c
+++ b/arch/arm/mach-k3/am642_init.c
@@ -12,7 +12,7 @@
 #include 
 #include 
 #include 
-#include 
+#include "sysfw-loader.h"
 #include 
 #include "common.h"
 #include 
diff --git a/arch/arm/mach-k3/am654_init.c b/arch/arm/mach-k3/am654_init.c
index 8ee1e9be643..5b8e506c793 100644
--- a/arch/arm/mach-k3/am654_init.c
+++ b/arch/arm/mach-k3/am654_init.c
@@ -13,7 +13,7 @@
 #include 
 #include 
 #include 
-#include 
+#include "sysfw-loader.h"
 #include 
 #include "common.h"
 #include 
diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
index afd46647405..6c18778c73e 100644
--- a/arch/arm/mach-k3/j721e_init.c
+++ b/arch/arm/mach-k3/j721e_init.c
@@ -12,7 +12,7 @@
 #include 
 #include 
 #include 
-#include 
+#include "sysfw-loader.h"
 #include "common.h"
 #include 
 #include 
diff --git a/arch/arm/mach-k3/j721s2_init.c b/arch/arm/mach-k3/j721s2_init.c
index fb95984c1ab..4785a747bf3 100644
--- a/arch/arm/mach-k3/j721s2_init.c
+++ b/arch/arm/mach-k3/j721s2_init.c
@@ -12,7 +12,7 @@
 #include 
 #include 
 #include 
-#include 
+#include "sysfw-loader.h"
 #include "common.h"
 #include 
 #include 
diff --git a/arch/arm/mach-k3/include/mach/sysfw-loader.h 
b/arch/arm/mach-k3/sysfw-loader.h
similarity index 100%
rename from arch/arm/mach-k3/include/mach/sysfw-loader.h
rename to arch/arm/mach-k3/sysfw-loader.h
-- 
2.39.2



[PATCH 02/12] arm: mach-k3: Move J721e SoC detection out of common section

2023-03-30 Thread Andrew Davis
This belongs in the J721e specific file as it is the only place
this is used. Any board level users should use the SOC driver.

While here, move the J721e and J7200 SoC IDs out of sys_proto.h
and into hardware.h. Add the rest of the SoC IDs for completeness
and later use.

Signed-off-by: Andrew Davis 
---
 arch/arm/mach-k3/common.c | 20 
 arch/arm/mach-k3/common.h |  3 ---
 arch/arm/mach-k3/include/mach/hardware.h  |  8 
 arch/arm/mach-k3/include/mach/sys_proto.h |  3 ---
 arch/arm/mach-k3/j721e_init.c | 20 
 5 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 6870f13c520..6e084de692c 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -488,26 +488,6 @@ int print_cpuinfo(void)
 }
 #endif
 
-bool soc_is_j721e(void)
-{
-   u32 soc;
-
-   soc = (readl(CTRLMMR_WKUP_JTAG_ID) &
-   JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT;
-
-   return soc == J721E;
-}
-
-bool soc_is_j7200(void)
-{
-   u32 soc;
-
-   soc = (readl(CTRLMMR_WKUP_JTAG_ID) &
-   JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT;
-
-   return soc == J7200;
-}
-
 #ifdef CONFIG_ARM64
 void board_prep_linux(struct bootm_headers *images)
 {
diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h
index 8f38fcef7f0..531be0be54c 100644
--- a/arch/arm/mach-k3/common.h
+++ b/arch/arm/mach-k3/common.h
@@ -9,9 +9,6 @@
 #include 
 #include 
 
-#define J721E  0xbb64
-#define J7200  0xbb6d
-
 struct fwl_data {
const char *name;
u16 fwl_id;
diff --git a/arch/arm/mach-k3/include/mach/hardware.h 
b/arch/arm/mach-k3/include/mach/hardware.h
index 2c60ef85432..f87b4c6e5a7 100644
--- a/arch/arm/mach-k3/include/mach/hardware.h
+++ b/arch/arm/mach-k3/include/mach/hardware.h
@@ -36,6 +36,14 @@
 #define JTAG_ID_VARIANT_MASK   (0xf << 28)
 #define JTAG_ID_PARTNO_SHIFT   12
 #define JTAG_ID_PARTNO_MASK(0x << 12)
+#define JTAG_ID_PARTNO_AM65X   0xbb5a
+#define JTAG_ID_PARTNO_J721E   0xbb64
+#define JTAG_ID_PARTNO_J7200   0xbb6d
+#define JTAG_ID_PARTNO_AM64X   0xbb38
+#define JTAG_ID_PARTNO_J721S2  0xbb75
+#define JTAG_ID_PARTNO_AM62X   0xbb7e
+#define JTAG_ID_PARTNO_AM62AX   0xbb8d
+
 #define K3_SEC_MGR_SYS_STATUS  0x44234100
 #define SYS_STATUS_DEV_TYPE_SHIFT  0
 #define SYS_STATUS_DEV_TYPE_MASK   (0xf)
diff --git a/arch/arm/mach-k3/include/mach/sys_proto.h 
b/arch/arm/mach-k3/include/mach/sys_proto.h
index 0b5d606eaa2..d5d4b787b7d 100644
--- a/arch/arm/mach-k3/include/mach/sys_proto.h
+++ b/arch/arm/mach-k3/include/mach/sys_proto.h
@@ -15,9 +15,6 @@ int do_board_detect(void);
 void release_resources_for_core_shutdown(void);
 int fdt_disable_node(void *blob, char *node_path);
 
-bool soc_is_j721e(void);
-bool soc_is_j7200(void);
-
 void k3_spl_init(void);
 void k3_mem_init(void);
 bool check_rom_loaded_sysfw(void);
diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
index 276cbb5dae2..233b867e90c 100644
--- a/arch/arm/mach-k3/j721e_init.c
+++ b/arch/arm/mach-k3/j721e_init.c
@@ -63,6 +63,26 @@ struct fwl_data cbass_hc_cfg0_fwls[] = {
 };
 #endif
 
+bool soc_is_j721e(void)
+{
+   u32 soc;
+
+   soc = (readl(CTRLMMR_WKUP_JTAG_ID) &
+   JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT;
+
+   return soc == JTAG_ID_PARTNO_J721E;
+}
+
+bool soc_is_j7200(void)
+{
+   u32 soc;
+
+   soc = (readl(CTRLMMR_WKUP_JTAG_ID) &
+   JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT;
+
+   return soc == JTAG_ID_PARTNO_J7200;
+}
+
 static void ctrl_mmr_unlock(void)
 {
/* Unlock all WKUP_CTRL_MMR0 module registers */
-- 
2.39.2



[PATCH 05/12] configs: j721s2_evm.h: Remove refrences to J7200 EVM

2023-03-30 Thread Andrew Davis
The J7200 EVM will not include this file, all these J7200 checks look
to be copy/paste errors from j721e_evm.h, which J7200 *can* include.

Signed-off-by: Andrew Davis 
---
 include/configs/j721s2_evm.h | 23 ++-
 1 file changed, 2 insertions(+), 21 deletions(-)

diff --git a/include/configs/j721s2_evm.h b/include/configs/j721s2_evm.h
index d401f28ff21..45d080023f6 100644
--- a/include/configs/j721s2_evm.h
+++ b/include/configs/j721s2_evm.h
@@ -20,7 +20,7 @@
 #define CFG_SYS_SDRAM_BASE10x88000
 
 /* SPL Loader Configuration */
-#if defined(CONFIG_TARGET_J721S2_A72_EVM) || 
defined(CONFIG_TARGET_J7200_A72_EVM)
+#if defined(CONFIG_TARGET_J721S2_A72_EVM)
 #define CFG_SYS_UBOOT_BASE 0x5028
 /* Image load address in RAM for DFU boot*/
 #else
@@ -52,10 +52,6 @@
 #define EXTRA_ENV_R5_SPL_RPROC_FW_ARGS_MMC \
"addr_mcur5f0_0load=0x8900\0"   \
"name_mcur5f0_0fw=/lib/firmware/j7-mcu-r5f0_0-fw\0"
-#elif defined(CONFIG_TARGET_J7200_R5_EVM)
-#define EXTRA_ENV_R5_SPL_RPROC_FW_ARGS_MMC \
-   "addr_mcur5f0_0load=0x8900\0"   \
-   "name_mcur5f0_0fw=/lib/firmware/j7200-mcu-r5f0_0-fw\0"
 #else
 #define EXTRA_ENV_R5_SPL_RPROC_FW_ARGS_MMC ""
 #endif
@@ -86,7 +82,7 @@
"partitions=" PARTS_DEFAULT
 
 /* Set the default list of remote processors to boot */
-#if defined(CONFIG_TARGET_J721S2_A72_EVM) || 
defined(CONFIG_TARGET_J7200_A72_EVM)
+#if defined(CONFIG_TARGET_J721S2_A72_EVM)
 #ifdef DEFAULT_RPROCS
 #undef DEFAULT_RPROCS
 #endif
@@ -102,21 +98,6 @@
"7 /lib/firmware/j721s2-c71_1-fw "
 #endif /* CONFIG_TARGET_J721S2_A72_EVM */
 
-#ifdef CONFIG_TARGET_J7200_A72_EVM
-#define EXTRA_ENV_CONFIG_MAIN_CPSW0_QSGMII_PHY \
-   "do_main_cpsw0_qsgmii_phyinit=1\0"  \
-   "init_main_cpsw0_qsgmii_phy=gpio set gpio@22_17;"   \
-"gpio clear gpio@22_16\0"  \
-   "main_cpsw0_qsgmii_phyinit="\
-   "if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1 && test ${dorprocboot} 
-eq 1 && " \
-   "test ${boot} = mmc; then " \
-   "run init_main_cpsw0_qsgmii_phy;"   \
-   "fi;\0"
-#define DEFAULT_RPROCS ""  \
-   "2 /lib/firmware/j7200-main-r5f0_0-fw " \
-   "3 /lib/firmware/j7200-main-r5f0_1-fw "
-#endif /* CONFIG_TARGET_J7200_A72_EVM */
-
 #ifndef EXTRA_ENV_CONFIG_MAIN_CPSW0_QSGMII_PHY
 #define EXTRA_ENV_CONFIG_MAIN_CPSW0_QSGMII_PHY
 #endif
-- 
2.39.2



Re: [PATCH u-boot-mvebu 0/7] arm: mvebu: Boot support for 4K Native disks

2023-03-30 Thread Tony Dinh
Hi Pali,

On Wed, Mar 29, 2023 at 12:28 PM Pali Rohár  wrote:
>
> This patch series allows to build SATA kwbimage for disks which do not
> have sector size 512 bytes long. For example 4K Native disks.
>
> SATA kwbimage differs from other kwbimage types in that way, that offset
> in its header is stored in SATA sectors units instead of byte units.
> Therefore image generator needs to know sector size of the target SATA
> disk. Currently both kwbimage and mkimage has hardcoded SATA sector size
> to 512 bytes.
>
> This patch series allows to specify custom SATA sector size via a new
> config option CONFIG_MVEBU_SPL_SATA_BLKSZ. And add autodetection of the
> sector size into kwboot to allow parsing such images.
>
> Maximal theoretical sector size is 32 kB because ATA IDENTIFY command
> returns sector size as 16-bit number and sector size should be power
> of two.

I don't have any board that can boot from SATA. But I ran regression
tests on the Pogo V4 (Kirkwood 6192).  kwboot and boot from NAND works
fine.

Tested-by: Tony Dinh 

Thanks,
Tony

> Pali Rohár (7):
>   arm: mvebu: spl: Do not hardcode SATA block size to 512
>   cmd: mvebu/bubt: a38x: Do not hardcode SATA block size to 512
>   tools: imagetool: Extend print_header() by params argument
>   tools: kwbimage: Simplify align code
>   tools: kwbimage: Add support for SATA images with non-512 byte block
> size
>   tools: kwboot: Add support for parsing SATA images with non-512 block
> size
>   arm: mvebu: spl: Allow to build SATA kwbimage for 4K Native disks
>
>  arch/arm/mach-mvebu/Kconfig |  10 ++
>  arch/arm/mach-mvebu/Makefile|   5 +
>  arch/arm/mach-mvebu/kwbimage.cfg.in |   3 +
>  arch/arm/mach-mvebu/spl.c   |  11 ++-
>  cmd/mvebu/bubt.c|   7 +-
>  tools/aisimage.c|   2 +-
>  tools/atmelimage.c  |   2 +-
>  tools/default_image.c   |   7 +-
>  tools/fit_common.c  |   5 +
>  tools/fit_common.h  |   2 +
>  tools/fit_image.c   |   2 +-
>  tools/gpimage.c |   2 +-
>  tools/imagetool.c   |   4 +-
>  tools/imagetool.h   |   2 +-
>  tools/imx8image.c   |   2 +-
>  tools/imx8mimage.c  |   2 +-
>  tools/imximage.c|   2 +-
>  tools/kwbimage.c| 144 ++--
>  tools/kwboot.c  |  35 ++-
>  tools/lpc32xximage.c|   2 +-
>  tools/mkimage.c |   2 +-
>  tools/mtk_image.c   |   2 +-
>  tools/mxsimage.c|   2 +-
>  tools/omapimage.c   |   2 +-
>  tools/pblimage.c|   2 +-
>  tools/rkcommon.c|   2 +-
>  tools/rkcommon.h|   2 +-
>  tools/socfpgaimage.c|   2 +-
>  tools/stm32image.c  |   2 +-
>  tools/sunxi_egon.c  |   2 +-
>  tools/sunxi_toc0.c  |   2 +-
>  tools/ublimage.c|   2 +-
>  tools/vybridimage.c |   2 +-
>  tools/zynqimage.c   |   2 +-
>  tools/zynqmpimage.c |   2 +-
>  tools/zynqmpimage.h |   2 +-
>  36 files changed, 199 insertions(+), 84 deletions(-)
>
> --
> 2.20.1
>


Re: [RFC PATCH v7 23/23] DO NOT MERGE: only to make CI happy

2023-03-30 Thread Tony Dinh
Hi Francis,

On Thu, Mar 30, 2023 at 12:50 PM Francis Laniel
 wrote:
>
> This commit set CONFIG_HUSH_PARSER_2021 as the default to trigger the CI with
> this parser.
>
> Nonetheless, the keymile (i.e. VENDOR_KM) board family is not compatible with
> new 2021 hush parser.
> Indeed, This boards used set_local_var() to store some variables as local 
> shell.
> They then used get_local_var() to retrieve the variables values.
> Sadly, this two functions do not exist with CONFIG_HUSH_PARSER_2021.
> A patch was proposed to use environment variables rather than local variables
> but it does not tackle the problem, so complementary work is needed to make
> this boards use CONFIG_HUSH_PARSER_2021 [1].
>
> We also remove a #undef of CONFIG_FEATURE_SH_STANDALONE as it does not exist 
> in
> U-Boot and causes troubles in the CI.
>
> We also set CONFIG_LTO for kirkwoord sheevaplug and phytec bk4r1, otherwise it
> hits its board size limit.
> By enabling this option, we also had to add assembly for __gnu_thumb1_case_si.
> It was taken from upstream gcc and adapted as width suffix was removed for the
> add [2].

Thanks for adding __gnu_thumb1_case_si ! It will help not just the
Sheevaplug board, but also a few other boards too. I'll give this a
try.

All the best,
Tony

>
> Signed-off-by: Francis Laniel 
> [1] https://marc.info/?l=u-boot=165541917618725=2
> [2] 
> https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156
> ---
>  arch/arm/lib/lib1funcs.S | 17 +
>  cmd/Kconfig  |  3 ++-
>  common/cli_hush_upstream.c   |  1 -
>  configs/bk4r1_defconfig  |  1 +
>  configs/sheevaplug_defconfig |  1 +
>  5 files changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/lib/lib1funcs.S b/arch/arm/lib/lib1funcs.S
> index de15d09e36..a1f44d9454 100644
> --- a/arch/arm/lib/lib1funcs.S
> +++ b/arch/arm/lib/lib1funcs.S
> @@ -419,4 +419,21 @@ ENTRY(__gnu_thumb1_case_uhi)
> ret lr
>  ENDPROC(__gnu_thumb1_case_uhi)
>  .popsection
> +
> +/* Taken and adapted from: 
> https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156
>  */
> +.pushsection .text.__gnu_thumb1_case_si, "ax"
> +ENTRY(__gnu_thumb1_case_si)
> +   push{r0, r1}
> +   mov r1, lr
> +   addsr1, r1, #2  /* Align to word.  */
> +   lsrsr1, r1, #2
> +   lslsr0, r0, #2
> +   lslsr1, r1, #2
> +   ldr r0, [r1, r0]
> +   addsr0, r0, r1
> +   mov lr, r0
> +   pop {r0, r1}
> +   mov pc, lr  /* We know we were called from thumb code.  */
> +ENDPROC(__gnu_thumb1_case_si)
> +.popsection
>  #endif
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 1b9d04680d..d4809fcfa4 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -28,7 +28,7 @@ menu "Hush flavor to use"
>
> config HUSH_OLD_PARSER
> bool "Use hush old parser"
> -   default y
> +   default y if VENDOR_KM
> help
>   This option enables the old flavor of hush based on hush 
> Busybox from
>   2005.
> @@ -37,6 +37,7 @@ menu "Hush flavor to use"
>
> config HUSH_2021_PARSER
> bool "Use hush 2021 parser"
> +   default y if !VENDOR_KM
> help
>   This option enables the new flavor of hush based on hush 
> Busybox from
>   2021.
> diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
> index 93796e87c5..78a13eeb62 100644
> --- a/common/cli_hush_upstream.c
> +++ b/common/cli_hush_upstream.c
> @@ -427,7 +427,6 @@
>  #include "NUM_APPLETS.h"
>  #if NUM_APPLETS == 1
>  /* STANDALONE does not make sense, and won't compile */
> -# undef CONFIG_FEATURE_SH_STANDALONE
>  # undef ENABLE_FEATURE_SH_STANDALONE
>  # undef IF_FEATURE_SH_STANDALONE
>  # undef IF_NOT_FEATURE_SH_STANDALONE
> diff --git a/configs/bk4r1_defconfig b/configs/bk4r1_defconfig
> index 66adeac725..95f0c30cde 100644
> --- a/configs/bk4r1_defconfig
> +++ b/configs/bk4r1_defconfig
> @@ -18,6 +18,7 @@ CONFIG_TARGET_BK4R1=y
>  CONFIG_SYS_LOAD_ADDR=0x8200
>  CONFIG_SYS_MEMTEST_START=0x8001
>  CONFIG_SYS_MEMTEST_END=0x87c0
> +CONFIG_LTO=y
>  CONFIG_HAS_BOARD_SIZE_LIMIT=y
>  CONFIG_BOARD_SIZE_LIMIT=520192
>  CONFIG_FIT=y
> diff --git a/configs/sheevaplug_defconfig b/configs/sheevaplug_defconfig
> index 2e4901b840..365f779cc8 100644
> --- a/configs/sheevaplug_defconfig
> +++ b/configs/sheevaplug_defconfig
> @@ -16,6 +16,7 @@ CONFIG_ENV_OFFSET=0x8
>  CONFIG_DEFAULT_DEVICE_TREE="kirkwood-sheevaplug"
>  CONFIG_IDENT_STRING="\nMarvell-Sheevaplug"
>  CONFIG_SYS_LOAD_ADDR=0x80
> +CONFIG_LTO=y
>  CONFIG_HAS_BOARD_SIZE_LIMIT=y
>  CONFIG_BOARD_SIZE_LIMIT=524288
>  CONFIG_BOOTDELAY=3
> --
> 2.34.1
>


  1   2   3   >