Re: [PATCH v2 2/3] riscv: timer: add timer_get_boot_us for BOOTSTAGE

2023-09-04 Thread Leo Liang
Hi Chanho,

On Mon, Aug 28, 2023 at 06:49:37PM +0900, Chanho Park wrote:
> timer_get_boot_us function is required to record the boot stages as
> us-based timestamp.
> 
> Signed-off-by: Chanho Park 
> ---
>  drivers/timer/riscv_timer.c | 21 +
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/timer/riscv_timer.c b/drivers/timer/riscv_timer.c
> index 3627ed79b819..6cb589fcdc45 100644
> --- a/drivers/timer/riscv_timer.c
> +++ b/drivers/timer/riscv_timer.c
> @@ -11,6 +11,7 @@
>   */
>  
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -50,6 +51,26 @@ u64 notrace timer_early_get_count(void)
>  }
>  #endif
>  
> +#if CONFIG_IS_ENABLED(RISCV_SMODE) && CONFIG_IS_ENABLED(BOOTSTAGE)
> +ulong timer_get_boot_us(void)
> +{
> + int ret;
> + u64 ticks = 0;
> + u32 rate;
> +
> + ret = dm_timer_init();
> + if (!ret) {
> + rate = timer_get_rate(gd->timer);
> + timer_get_count(gd->timer, &ticks);
> + } else {
> + rate = RISCV_SMODE_TIMER_FREQ;
> + ticks = riscv_timer_get_count(NULL);
> + }
> +
> + return lldiv(ticks * 1000, (rate / 1000));

Could you elaborate a little how this formula is derived?

Best regards,
Leo

> +}
> +#endif
> +
>  static int riscv_timer_probe(struct udevice *dev)
>  {
>   struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
> -- 
> 2.39.2
> 


Re: [PATCH v2 3/3] timer: riscv_aclint_timer: add timer_get_boot_us for BOOTSTAGE

2023-09-04 Thread Leo Liang
Hi Chanho,

On Mon, Aug 28, 2023 at 06:49:38PM +0900, Chanho Park wrote:
> timer_get_boot_us function is required to record the boot stages as
> us-based timestamp.
> 
> Signed-off-by: Chanho Park 
> ---
>  drivers/timer/riscv_aclint_timer.c | 22 ++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/timer/riscv_aclint_timer.c 
> b/drivers/timer/riscv_aclint_timer.c
> index e29d527c8d77..8b67745bb4a2 100644
> --- a/drivers/timer/riscv_aclint_timer.c
> +++ b/drivers/timer/riscv_aclint_timer.c
> @@ -6,6 +6,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -44,6 +45,27 @@ u64 notrace timer_early_get_count(void)
>  }
>  #endif
>  
> +#if CONFIG_IS_ENABLED(RISCV_MMODE) && CONFIG_IS_ENABLED(BOOTSTAGE)
> +ulong timer_get_boot_us(void)
> +{
> + int ret;
> + u64 ticks = 0;
> + u32 rate;
> +
> + ret = dm_timer_init();
> + if (!ret) {
> + rate = timer_get_rate(gd->timer);
> + timer_get_count(gd->timer, &ticks);
> + } else {
> + rate = RISCV_MMODE_TIMER_FREQ;
> + ticks = readq((void __iomem *)MTIME_REG(RISCV_MMODE_TIMERBASE,
> + RISCV_MMODE_TIMEROFF));
> + }
> +
> + return lldiv(ticks * 1001, (rate / 1000));

Why is this dividend 1001 ?

Best regards,
Leo

> +}
> +#endif
> +
>  static const struct timer_ops riscv_aclint_timer_ops = {
>   .get_count = riscv_aclint_timer_get_count,
>  };
> -- 
> 2.39.2
> 


Re: [PATCH] spl: add __noreturn attribute to spl_invoke_opensbi function

2023-09-04 Thread Leo Liang
On Tue, Aug 29, 2023 at 10:20:14AM +0900, Chanho Park wrote:
> spl_invoke_opensbi function is not returned to SPL. Thus, we need to
> set __noreturn function attribute.
> 
> Signed-off-by: Chanho Park 
> ---
>  common/spl/spl_opensbi.c | 7 ---
>  include/spl.h| 2 +-
>  2 files changed, 5 insertions(+), 4 deletions(-)

Reviewed-by: Leo Yu-Chi Liang 


Re: [PATCH v2 05/17] cmd: rockusb: Use plain udevice for UDC controller interaction

2023-09-04 Thread Mattijs Korpershoek
On ven., sept. 01, 2023 at 11:49, Marek Vasut  wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut 

Reviewed-by: Mattijs Korpershoek 

> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
> V2: No change
> ---
>  cmd/rockusb.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/cmd/rockusb.c b/cmd/rockusb.c
> index f181ec61119..07088564a10 100644
> --- a/cmd/rockusb.c
> +++ b/cmd/rockusb.c
> @@ -15,6 +15,7 @@ static int do_rockusb(struct cmd_tbl *cmdtp, int flag, int 
> argc,
>  {
>   int controller_index, dev_index;
>   char *usb_controller;
> + struct udevice *udc;
>   char *devtype;
>   char *devnum;
>   int ret;
> @@ -34,7 +35,7 @@ static int do_rockusb(struct cmd_tbl *cmdtp, int flag, int 
> argc,
>   dev_index = simple_strtoul(devnum, NULL, 0);
>   rockusb_dev_init(devtype, dev_index);
>  
> - ret = usb_gadget_initialize(controller_index);
> + ret = udc_device_get_by_index(controller_index, &udc);
>   if (ret) {
>   printf("USB init failed: %d\n", ret);
>   return CMD_RET_FAILURE;
> @@ -56,14 +57,14 @@ static int do_rockusb(struct cmd_tbl *cmdtp, int flag, 
> int argc,
>   break;
>   if (ctrlc())
>   break;
> - usb_gadget_handle_interrupts(controller_index);
> + dm_usb_gadget_handle_interrupts(udc);
>   }
>   ret = CMD_RET_SUCCESS;
>  
>  exit:
>   g_dnl_unregister();
>   g_dnl_clear_detach();
> - usb_gadget_release(controller_index);
> + udc_device_put(udc);
>  
>   return ret;
>  }
> -- 
> 2.40.1


Re: [PATCH v2 07/17] cmd: thordown: Reorder variable declaration

2023-09-04 Thread Mattijs Korpershoek
On ven., sept. 01, 2023 at 11:49, Marek Vasut  wrote:

> Move the variable declaration around to improve code readability.
> No functional change.
>
> Signed-off-by: Marek Vasut 

Reviewed-by: Mattijs Korpershoek 

> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
> V2: No change
> ---
>  cmd/thordown.c | 15 ---
>  1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/cmd/thordown.c b/cmd/thordown.c
> index 838764ccef7..0d8dcee5314 100644
> --- a/cmd/thordown.c
> +++ b/cmd/thordown.c
> @@ -15,22 +15,23 @@
>  
>  int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
> argv[])
>  {
> + char *interface, *devstring;
> + int controller_index;
> + int ret;
> +
>   if (argc < 4)
>   return CMD_RET_USAGE;
>  
> - char *usb_controller = argv[1];
> - char *interface = argv[2];
> - char *devstring = argv[3];
> -
> - int ret;
> -
>   puts("TIZEN \"THOR\" Downloader\n");
>  
> + interface = argv[2];
> + devstring = argv[3];
> +
>   ret = dfu_init_env_entities(interface, devstring);
>   if (ret)
>   goto done;
>  
> - int controller_index = simple_strtoul(usb_controller, NULL, 0);
> + controller_index = simple_strtoul(argv[1], NULL, 0);
>   ret = usb_gadget_initialize(controller_index);
>   if (ret) {
>   pr_err("USB init failed: %d\n", ret);
> -- 
> 2.40.1


RE: [PATCH v2 2/3] riscv: timer: add timer_get_boot_us for BOOTSTAGE

2023-09-04 Thread Chanho Park
Hi,

> -Original Message-
> From: Leo Liang 
> Sent: Monday, September 4, 2023 4:01 PM
> To: Chanho Park 
> Cc: Rick Chen ; Simon Glass ; u-
> b...@lists.denx.de
> Subject: Re: [PATCH v2 2/3] riscv: timer: add timer_get_boot_us for
> BOOTSTAGE
> 
> Hi Chanho,
> 
> On Mon, Aug 28, 2023 at 06:49:37PM +0900, Chanho Park wrote:
> > timer_get_boot_us function is required to record the boot stages as
> > us-based timestamp.
> >
> > Signed-off-by: Chanho Park 
> > ---
> >  drivers/timer/riscv_timer.c | 21 +
> >  1 file changed, 21 insertions(+)
> >
> > diff --git a/drivers/timer/riscv_timer.c b/drivers/timer/riscv_timer.c
> > index 3627ed79b819..6cb589fcdc45 100644
> > --- a/drivers/timer/riscv_timer.c
> > +++ b/drivers/timer/riscv_timer.c
> > @@ -11,6 +11,7 @@
> >   */
> >
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -50,6 +51,26 @@ u64 notrace timer_early_get_count(void)  }  #endif
> >
> > +#if CONFIG_IS_ENABLED(RISCV_SMODE) && CONFIG_IS_ENABLED(BOOTSTAGE)
> > +ulong timer_get_boot_us(void) {
> > +   int ret;
> > +   u64 ticks = 0;
> > +   u32 rate;
> > +
> > +   ret = dm_timer_init();
> > +   if (!ret) {
> > +   rate = timer_get_rate(gd->timer);
> > +   timer_get_count(gd->timer, &ticks);
> > +   } else {
> > +   rate = RISCV_SMODE_TIMER_FREQ;
> > +   ticks = riscv_timer_get_count(NULL);
> > +   }
> > +
> > +   return lldiv(ticks * 1000, (rate / 1000));
> 
> Could you elaborate a little how this formula is derived?

Sure. Below is the original formula. To avoid zero of (tick/rate), I split
the calculation to ticks and rate, respectively.

Time(us) = (ticks / rate) * 100
  Or (ticks * 100) / rate
  Or tick / (rate / 1000)

Best Regards,
Chanho Park



RE: [PATCH v2 3/3] timer: riscv_aclint_timer: add timer_get_boot_us for BOOTSTAGE

2023-09-04 Thread Chanho Park
Hi,

> -Original Message-
> From: Leo Liang 
> Sent: Monday, September 4, 2023 4:02 PM
> To: Chanho Park 
> Cc: Rick Chen ; Simon Glass ; u-
> b...@lists.denx.de
> Subject: Re: [PATCH v2 3/3] timer: riscv_aclint_timer: add
> timer_get_boot_us for BOOTSTAGE
> 
> Hi Chanho,
> 
> On Mon, Aug 28, 2023 at 06:49:38PM +0900, Chanho Park wrote:
> > timer_get_boot_us function is required to record the boot stages as
> > us-based timestamp.
> >
> > Signed-off-by: Chanho Park 
> > ---
> >  drivers/timer/riscv_aclint_timer.c | 22 ++
> >  1 file changed, 22 insertions(+)
> >
> > diff --git a/drivers/timer/riscv_aclint_timer.c
> > b/drivers/timer/riscv_aclint_timer.c
> > index e29d527c8d77..8b67745bb4a2 100644
> > --- a/drivers/timer/riscv_aclint_timer.c
> > +++ b/drivers/timer/riscv_aclint_timer.c
> > @@ -6,6 +6,7 @@
> >
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -44,6 +45,27 @@ u64 notrace timer_early_get_count(void)  }  #endif
> >
> > +#if CONFIG_IS_ENABLED(RISCV_MMODE) && CONFIG_IS_ENABLED(BOOTSTAGE)
> > +ulong timer_get_boot_us(void) {
> > +   int ret;
> > +   u64 ticks = 0;
> > +   u32 rate;
> > +
> > +   ret = dm_timer_init();
> > +   if (!ret) {
> > +   rate = timer_get_rate(gd->timer);
> > +   timer_get_count(gd->timer, &ticks);
> > +   } else {
> > +   rate = RISCV_MMODE_TIMER_FREQ;
> > +   ticks = readq((void __iomem
> *)MTIME_REG(RISCV_MMODE_TIMERBASE,
> > +
RISCV_MMODE_TIMEROFF));
> > +   }
> > +
> > +   return lldiv(ticks * 1001, (rate / 1000));
> 
> Why is this dividend 1001 ?

It's a typo. I'll correct when I send v2.

Best Regards,
Chanho Park



Re: [PATCH v2 13/17] thordown: Use plain udevice for UDC controller interaction

2023-09-04 Thread Mattijs Korpershoek
On ven., sept. 01, 2023 at 11:49, Marek Vasut  wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm

Reviewed-by: Mattijs Korpershoek 

> ---
> V2: No change
> ---
>  cmd/thordown.c  |  9 +++--
>  drivers/usb/gadget/f_thor.c | 74 +++--
>  include/thor.h  |  4 +-
>  3 files changed, 45 insertions(+), 42 deletions(-)
>
> diff --git a/cmd/thordown.c b/cmd/thordown.c
> index 0d8dcee5314..fcfd38f523c 100644
> --- a/cmd/thordown.c
> +++ b/cmd/thordown.c
> @@ -17,6 +17,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
>  {
>   char *interface, *devstring;
>   int controller_index;
> + struct udevice *udc;
>   int ret;
>  
>   if (argc < 4)
> @@ -32,7 +33,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
>   goto done;
>  
>   controller_index = simple_strtoul(argv[1], NULL, 0);
> - ret = usb_gadget_initialize(controller_index);
> + ret = udc_device_get_by_index(controller_index, &udc);
>   if (ret) {
>   pr_err("USB init failed: %d\n", ret);
>   ret = CMD_RET_FAILURE;
> @@ -46,7 +47,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
>   goto exit;
>   }
>  
> - ret = thor_init();
> + ret = thor_init(udc);
>   if (ret) {
>   pr_err("THOR DOWNLOAD failed: %d\n", ret);
>   ret = CMD_RET_FAILURE;
> @@ -54,7 +55,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
>   }
>  
>   do {
> - ret = thor_handle();
> + ret = thor_handle(udc);
>   if (ret == THOR_DFU_REINIT_NEEDED) {
>   dfu_free_entities();
>   ret = dfu_init_env_entities(interface, devstring);
> @@ -67,7 +68,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
>   } while (ret == 0);
>  exit:
>   g_dnl_unregister();
> - usb_gadget_release(controller_index);
> + udc_device_put(udc);
>  done:
>   dfu_free_entities();
>  
> diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
> index 47ef55b2fd3..3caa4c36387 100644
> --- a/drivers/usb/gadget/f_thor.c
> +++ b/drivers/usb/gadget/f_thor.c
> @@ -15,9 +15,10 @@
>   */
>  
>  #include 
> -#include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -34,9 +35,9 @@
>  
>  #include "f_thor.h"
>  
> -static void thor_tx_data(unsigned char *data, int len);
> +static void thor_tx_data(struct udevice *udc, unsigned char *data, int len);
>  static void thor_set_dma(void *addr, int len);
> -static int thor_rx_data(void);
> +static int thor_rx_data(struct udevice *udc);
>  
>  static struct f_thor *thor_func;
>  static inline struct f_thor *func_to_thor(struct usb_function *f)
> @@ -56,15 +57,15 @@ DEFINE_CACHE_ALIGN_BUFFER(char, f_name, F_NAME_BUF_SIZE + 
> 1);
>  static unsigned long long int thor_file_size;
>  static int alt_setting_num;
>  
> -static void send_rsp(const struct rsp_box *rsp)
> +static void send_rsp(struct udevice *udc, const struct rsp_box *rsp)
>  {
>   memcpy(thor_tx_data_buf, rsp, sizeof(struct rsp_box));
> - thor_tx_data(thor_tx_data_buf, sizeof(struct rsp_box));
> + thor_tx_data(udc, thor_tx_data_buf, sizeof(struct rsp_box));
>  
>   debug("-RSP: %d, %d\n", rsp->rsp, rsp->rsp_data);
>  }
>  
> -static void send_data_rsp(s32 ack, s32 count)
> +static void send_data_rsp(struct udevice *udc, s32 ack, s32 count)
>  {
>   ALLOC_CACHE_ALIGN_BUFFER(struct data_rsp_box, rsp,
>sizeof(struct data_rsp_box));
> @@ -73,12 +74,12 @@ static void send_data_rsp(s32 ack, s32 count)
>   rsp->count = count;
>  
>   memcpy(thor_tx_data_buf, rsp, sizeof(struct data_rsp_box));
> - thor_tx_data(thor_tx_data_buf, sizeof(struct data_rsp_box));
> + thor_tx_data(udc, thor_tx_data_buf, sizeof(struct data_rsp_box));
>  
>   debug("-DATA RSP: %d, %d\n", ack, count);
>  }
>  
> -static int process_rqt_info(const struct rqt_box *rqt)
> +static int process_rqt_info(struct udevice *udc, const struct rqt_box *rqt)
>  {
>   ALLOC_CACHE_ALIGN_BUFFER(struct rsp_box, rsp, sizeof(struct rsp_box));
>   memset(rsp, 0, sizeof(struct rsp_box));
> @@ -111,11 +112,11 @@ static int process_rqt_info(const struct rqt_box *rqt)
>   return -EINVAL;
>   }
>  
> - send_rsp(rsp);
> + send_rsp(udc, rsp);
>   return true;
>  }
>  
> -s

Re: [PATCH v2 14/17] usb: gadget: acm: Use plain udevice for UDC controller interaction

2023-09-04 Thread Mattijs Korpershoek
On ven., sept. 01, 2023 at 11:50, Marek Vasut  wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut 

Reviewed-by: Mattijs Korpershoek 

> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
> V2: No change
> ---
>  drivers/usb/gadget/f_acm.c | 13 -
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
> index b2ddd1ada8b..de42e0189e8 100644
> --- a/drivers/usb/gadget/f_acm.c
> +++ b/drivers/usb/gadget/f_acm.c
> @@ -51,7 +51,7 @@ struct f_acm {
>  #define ACM_CTRL_RTS BIT(1)  /* unused with full duplex */
>  #define ACM_CTRL_DTR BIT(0)  /* host is ready for data r/w */
>  
> - int controller_index;
> + struct udevice *udc;
>  };
>  
>  static struct f_acm *default_acm_function;
> @@ -489,7 +489,7 @@ static void __acm_tx(struct f_acm *f_acm)
>   int len, ret;
>  
>   do {
> - usb_gadget_handle_interrupts(f_acm->controller_index);
> + dm_usb_gadget_handle_interrupts(f_acm->udc);
>  
>   if (!(f_acm->handshake_bits & ACM_CTRL_DTR))
>   break;
> @@ -520,7 +520,7 @@ static bool acm_connected(struct stdio_dev *dev)
>   struct f_acm *f_acm = stdio_to_acm(dev);
>  
>   /* give a chance to process udc irq */
> - usb_gadget_handle_interrupts(f_acm->controller_index);
> + dm_usb_gadget_handle_interrupts(f_acm->udc);
>  
>   return f_acm->connected;
>  }
> @@ -543,7 +543,10 @@ static int acm_add(struct usb_configuration *c)
>   f_acm->usb_function.descriptors = acm_fs_function;
>   f_acm->usb_function.hs_descriptors = acm_hs_function;
>   f_acm->usb_function.setup = acm_setup;
> - f_acm->controller_index = 0;
> +
> + status = udc_device_get_by_index(0, &f_acm->udc);
> + if (status)
> + return status;
>  
>   status = usb_add_function(c, &f_acm->usb_function);
>   if (status) {
> @@ -567,7 +570,7 @@ static int acm_stdio_tstc(struct stdio_dev *dev)
>  {
>   struct f_acm *f_acm = stdio_to_acm(dev);
>  
> - usb_gadget_handle_interrupts(f_acm->controller_index);
> + dm_usb_gadget_handle_interrupts(f_acm->udc);
>  
>   return (f_acm->rx_buf.size > 0);
>  }
> -- 
> 2.40.1


Re: [PATCH v2 15/17] usb: gadget: ether: Use plain udevice for UDC controller interaction

2023-09-04 Thread Mattijs Korpershoek
On ven., sept. 01, 2023 at 11:50, Marek Vasut  wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
> V2: Use udev->parent for UDC access
> ---
>  drivers/usb/gadget/ether.c | 20 +++-
>  1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
> index 5ff06d3814b..11b1a6221b3 100644
> --- a/drivers/usb/gadget/ether.c
> +++ b/drivers/usb/gadget/ether.c
> @@ -1880,8 +1880,10 @@ static void eth_start(struct eth_dev *dev, gfp_t 
> gfp_flags)
>   }
>  }
>  
> -static int eth_stop(struct eth_dev *dev)
> +static int eth_stop(struct udevice *udev)
>  {
> + struct ether_priv *priv = dev_get_priv(udev);
> + struct eth_dev *dev = &priv->ethdev;
>  #ifdef RNDIS_COMPLETE_SIGNAL_DISCONNECT
>   unsigned long ts;
>   unsigned long timeout = CONFIG_SYS_HZ; /* 1 sec to stop RNDIS */
> @@ -1895,7 +1897,7 @@ static int eth_stop(struct eth_dev *dev)
>   /* Wait until host receives OID_GEN_MEDIA_CONNECT_STATUS */
>   ts = get_timer(0);
>   while (get_timer(ts) < timeout)
> - usb_gadget_handle_interrupts(0);
> + dm_usb_gadget_handle_interrupts(udev->parent);
>  #endif
>  
>   rndis_uninit(dev->rndis_config);
> @@ -2300,7 +2302,7 @@ static int usb_eth_start(struct udevice *udev)
>   pr_err("The remote end did not respond in time.");
>   goto fail;
>   }
> - usb_gadget_handle_interrupts(0);
> + dm_usb_gadget_handle_interrupts(udev->parent);
>   }
>  
>   packet_received = 0;
> @@ -2370,7 +2372,7 @@ static int usb_eth_send(struct udevice *udev, void 
> *packet, int length)
>   printf("timeout sending packets to usb ethernet\n");
>   return -1;
>   }
> - usb_gadget_handle_interrupts(0);
> + dm_usb_gadget_handle_interrupts(udev->parent);
>   }
>   free(rndis_pkt);
>  
> @@ -2400,13 +2402,13 @@ static void usb_eth_stop(struct udevice *udev)
>* 2) 'pullup' callback in your UDC driver can be improved to perform
>* this deinitialization.
>*/
> - eth_stop(dev);
> + eth_stop(udev);
>  
>   usb_gadget_disconnect(dev->gadget);
>  
>   /* Clear pending interrupt */
>   if (dev->network_started) {
> - usb_gadget_handle_interrupts(0);
> + dm_usb_gadget_handle_interrupts(udev->parent);
>   dev->network_started = 0;
>   }
>  }
> @@ -2416,7 +2418,7 @@ static int usb_eth_recv(struct udevice *dev, int flags, 
> uchar **packetp)
>   struct ether_priv *priv = dev_get_priv(dev);
>   struct eth_dev *ethdev = &priv->ethdev;
>  
> - usb_gadget_handle_interrupts(0);
> + dm_usb_gadget_handle_interrupts(dev->parent);
>  
>   if (packet_received) {
>   if (ethdev->rx_req) {
> @@ -2467,7 +2469,7 @@ int usb_ether_init(void)
>   return ret;
>   }
>  
> - return usb_gadget_initialize(0);
> + return 0;

No udc_device_get() here?

This looks a little suspicious, because in the unbind() we call
udc_device_put().

>  }
>  
>  static int usb_eth_probe(struct udevice *dev)
> @@ -2528,7 +2530,7 @@ static int usb_eth_remove(struct udevice *dev)
>  
>  static int usb_eth_unbind(struct udevice *dev)
>  {
> - usb_gadget_release(0);
> + udc_device_put(dev->parent);
>  
>   return 0;
>  }
> -- 
> 2.40.1


Re: [PATCH v2 15/17] usb: gadget: ether: Use plain udevice for UDC controller interaction

2023-09-04 Thread Marek Vasut

On 9/4/23 09:56, Mattijs Korpershoek wrote:

On ven., sept. 01, 2023 at 11:50, Marek Vasut  wrote:


Convert to plain udevice interaction with UDC controller
device, avoid the use of UDC uclass dev_array .

Signed-off-by: Marek Vasut 
---
Cc: Angus Ainslie 
Cc: Dmitrii Merkurev 
Cc: Eddie Cai 
Cc: Kever Yang 
Cc: Lukasz Majewski 
Cc: Miquel Raynal 
Cc: Mattijs Korpershoek 
Cc: Nishanth Menon 
Cc: Patrice Chotard 
Cc: Patrick Delaunay 
Cc: Philipp Tomsich 
Cc: Simon Glass 
Cc: Stefan Roese 
Cc: ker...@puri.sm
---
V2: Use udev->parent for UDC access
---
  drivers/usb/gadget/ether.c | 20 +++-
  1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 5ff06d3814b..11b1a6221b3 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -1880,8 +1880,10 @@ static void eth_start(struct eth_dev *dev, gfp_t 
gfp_flags)
}
  }
  
-static int eth_stop(struct eth_dev *dev)

+static int eth_stop(struct udevice *udev)
  {
+   struct ether_priv *priv = dev_get_priv(udev);
+   struct eth_dev *dev = &priv->ethdev;
  #ifdef RNDIS_COMPLETE_SIGNAL_DISCONNECT
unsigned long ts;
unsigned long timeout = CONFIG_SYS_HZ; /* 1 sec to stop RNDIS */
@@ -1895,7 +1897,7 @@ static int eth_stop(struct eth_dev *dev)
/* Wait until host receives OID_GEN_MEDIA_CONNECT_STATUS */
ts = get_timer(0);
while (get_timer(ts) < timeout)
-   usb_gadget_handle_interrupts(0);
+   dm_usb_gadget_handle_interrupts(udev->parent);
  #endif
  
  		rndis_uninit(dev->rndis_config);

@@ -2300,7 +2302,7 @@ static int usb_eth_start(struct udevice *udev)
pr_err("The remote end did not respond in time.");
goto fail;
}
-   usb_gadget_handle_interrupts(0);
+   dm_usb_gadget_handle_interrupts(udev->parent);
}
  
  	packet_received = 0;

@@ -2370,7 +2372,7 @@ static int usb_eth_send(struct udevice *udev, void 
*packet, int length)
printf("timeout sending packets to usb ethernet\n");
return -1;
}
-   usb_gadget_handle_interrupts(0);
+   dm_usb_gadget_handle_interrupts(udev->parent);
}
free(rndis_pkt);
  
@@ -2400,13 +2402,13 @@ static void usb_eth_stop(struct udevice *udev)

 * 2) 'pullup' callback in your UDC driver can be improved to perform
 * this deinitialization.
 */
-   eth_stop(dev);
+   eth_stop(udev);
  
  	usb_gadget_disconnect(dev->gadget);
  
  	/* Clear pending interrupt */

if (dev->network_started) {
-   usb_gadget_handle_interrupts(0);
+   dm_usb_gadget_handle_interrupts(udev->parent);
dev->network_started = 0;
}
  }
@@ -2416,7 +2418,7 @@ static int usb_eth_recv(struct udevice *dev, int flags, 
uchar **packetp)
struct ether_priv *priv = dev_get_priv(dev);
struct eth_dev *ethdev = &priv->ethdev;
  
-	usb_gadget_handle_interrupts(0);

+   dm_usb_gadget_handle_interrupts(dev->parent);
  
  	if (packet_received) {

if (ethdev->rx_req) {
@@ -2467,7 +2469,7 @@ int usb_ether_init(void)
return ret;
}
  
-	return usb_gadget_initialize(0);

+   return 0;


No udc_device_get() here?

This looks a little suspicious, because in the unbind() we call
udc_device_put().


Look at how udc_device_get_by_index() is implemented and what it does, 
compared to what usb_ether_init() does (hint: they are basically doing 
the same thing). This udc_device_put() here is only a workaround for 
platforms which are not using the bind command to bind USB ethernet yet.


Re: [PATCH 7/8] spl: x86: Avoid starting up PCI automatically in SPL

2023-09-04 Thread Bin Meng
Hi Simon,

On Thu, Aug 24, 2023 at 10:11 AM Heinrich Schuchardt  wrote:
>
>
>
> Am 24. August 2023 01:57:55 MESZ schrieb Simon Glass :
> >Hi Heinrich,
> >
> >On Wed, 23 Aug 2023 at 14:19, Heinrich Schuchardt  wrote:
> >>
> >> On 8/23/23 20:47, Simon Glass wrote:
> >> > For x86 platforms, PCI is core to their operation and is managed in
> >> > arch-specific code. Each platform has its own way of doing this. For TPL
> >> > and some SPL implementations, the full driver model PCI is not used.
> >> >
> >> > A recent change enabled full PCI in TPL/SPL for all boards. This breaks
> >> > some x86 boards, so adjust it to skip that for x86.
> >>
> >> Could you, please, give some more detail?
> >>
> >> * Which boards are broken?
> >
> >For example, chromebook_samus and chromebook_samus_tpl
> >
> >> * Don't these boards have a pci_init() function?
> >
> >Yes, the same one you are calling.
> >
> >> * In what way does calling pci_init() lead to a failure?
> >
> >It probes and sets up PCI devices and uses a lot of pre-alloc RAM.
> >
> >>
> >> It would be preferable to have all architectures and boards use the same
> >> high level API. Excluding x86 here looks more like a (necessary) hack
> >> than like a target state.
> >
> >Fair enough, but on x86 we access PCI long before driver model is up.
> >Generally we don't fully enumerate it in SPL as it is expensive. It is
> >also pointless, since U-Boot proper does it again later.
> >
> >Regards,
> >Simon
> >
>
> Acked-by: Heinrich Schuchardt 
>

To address Heinrich's concern, how about you turn off CONFIG_SPL_PCI
in chromebook_samus and chromebook_samus_tpl?

Regards,
Bin


Re: [PATCH 1/8] x86: broadwell: Show the memory delay

2023-09-04 Thread Bin Meng
On Thu, Aug 24, 2023 at 2:47 AM Simon Glass  wrote:
>
> Samus only takes 7 seconds but it is long enough to think it has hung. Add
> a message about what it is doing, similar to the approach on coral.
>
> Signed-off-by: Simon Glass 
> ---
>
>  arch/x86/cpu/intel_common/mrc.c   | 18 +-
>  arch/x86/dts/chromebook_samus.dts |  1 +
>  2 files changed, 18 insertions(+), 1 deletion(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH 2/8] x86: Add some log categories

2023-09-04 Thread Bin Meng
On Thu, Aug 24, 2023 at 2:47 AM Simon Glass  wrote:
>
> Add some missing log categories to a few files.
>
> Signed-off-by: Simon Glass 
> ---
>
>  arch/x86/cpu/broadwell/sdram.c | 2 ++
>  arch/x86/lib/tpl.c | 2 ++
>  2 files changed, 4 insertions(+)
>

Reviewed-by: Bin Meng 


Re: [PATCH 3/8] x86: samus_tpl: Correct text base and alloc sizes

2023-09-04 Thread Bin Meng
Hi Simon,

On Thu, Aug 24, 2023 at 2:48 AM Simon Glass  wrote:
>
> Make sure that CONFIG_TEXT_BASE is the same as CONFIG_X86_OFFSET_U_BOOT

The commit message should say:

Make sure that CONFIG_X86_OFFSET_U_BOOT is the same as
CONFIG_TEXT_BASE as it is changing CONFIG_X86_OFFSET_U_BOOT.

> since this boards boots into U-Boot proper in flash, not RAM. Also exapnd

s/boards/board

typo: expand

> the SPL malloc() size a little, to avoid an error.
>
> Signed-off-by: Simon Glass 
> ---
>
>  configs/chromebook_samus_tpl_defconfig | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/configs/chromebook_samus_tpl_defconfig 
> b/configs/chromebook_samus_tpl_defconfig
> index 4cfaf4bc5c7..6fefe2ddc25 100644
> --- a/configs/chromebook_samus_tpl_defconfig
> +++ b/configs/chromebook_samus_tpl_defconfig
> @@ -1,6 +1,8 @@
>  CONFIG_X86=y
>  CONFIG_TEXT_BASE=0xffed
>  CONFIG_SYS_MALLOC_F_LEN=0x2000
> +CONFIG_TPL_SYS_MALLOC_F_LEN=0x2000
> +CONFIG_SPL_SYS_MALLOC_F_LEN=0x3000
>  CONFIG_NR_DRAM_BANKS=8
>  CONFIG_ENV_SIZE=0x1000
>  CONFIG_ENV_OFFSET=0x3F8000
> @@ -19,7 +21,7 @@ CONFIG_HAVE_MRC=y
>  CONFIG_HAVE_REFCODE=y
>  CONFIG_SMP=y
>  CONFIG_HAVE_VGA_BIOS=y
> -CONFIG_X86_OFFSET_U_BOOT=0xffee
> +CONFIG_X86_OFFSET_U_BOOT=0xffed
>  CONFIG_SYS_MONITOR_BASE=0xFFED
>  CONFIG_BOOTSTAGE=y
>  CONFIG_BOOTSTAGE_REPORT=y
> --

Otherwise,
Reviewed-by: Bin Meng 

Regards,
Bin


Re: [PATCH 4/8] x86: spl: Change the condition for copying U-Boot to RAM

2023-09-04 Thread Bin Meng
On Thu, Aug 24, 2023 at 2:48 AM Simon Glass  wrote:
>
> Make this depend on whether the address matches the offset, rather than
> a particular board build. For samus_tpl we don't need to copy, for
> example.
>
> Signed-off-by: Simon Glass 
> ---
>
>  arch/x86/lib/spl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH 5/8] x86: broadwell: Avoid initing the CPU twice

2023-09-04 Thread Bin Meng
On Thu, Aug 24, 2023 at 2:48 AM Simon Glass  wrote:
>
> When TPL has already set up the CPU, don't do it again. This existing
> code actually has this backwards, so fix it.
>
> Signed-off-by: Simon Glass 
> ---
>
>  arch/x86/cpu/broadwell/cpu.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH 6/8] x86: broadwell: Set up MTRRs

2023-09-04 Thread Bin Meng
Hi Simon,

On Thu, Aug 24, 2023 at 2:48 AM Simon Glass  wrote:
>
> The current condition does not handle the samus_tpl case where it sets
> up the RAM in SPL but needs to commit the MTRRs in U-Boot proper.
>
> Add another case to handle this and update the comment.
>
> Signed-off-by: Simon Glass 
> ---
>
>  arch/x86/lib/init_helpers.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/lib/init_helpers.c b/arch/x86/lib/init_helpers.c
> index 60a2707dcf1..bf0c921577d 100644
> --- a/arch/x86/lib/init_helpers.c
> +++ b/arch/x86/lib/init_helpers.c
> @@ -15,7 +15,8 @@ DECLARE_GLOBAL_DATA_PTR;
>  int init_cache_f_r(void)
>  {
> bool do_mtrr = CONFIG_IS_ENABLED(X86_32BIT_INIT) ||
> -IS_ENABLED(CONFIG_FSP_VERSION2);
> +IS_ENABLED(CONFIG_FSP_VERSION2) ||
> +(IS_ENABLED(CONFIG_TPL) && IS_ENABLED(CONFIG_HAVE_MRC));

So this combination is only for Samus TPL case, not a generic one, right?

I hate this as it's easy to break. Maybe we should be calling an API
from the board specific codes to determine whether we should do the
MTRR programming. Thoughts?

> int ret;
>
> /*
> @@ -23,11 +24,9 @@ int init_cache_f_r(void)
>  *
>  * booting from slimbootloader - MTRRs are already set up
>  * booting with FSPv1 - MTRRs are already set up
> -* booting with FSPv2 - MTRRs must be set here
> +* booting with FSPv2 or MRC - MTRRs must be set here
>  * booting from coreboot - in this case there is no SPL, so we set up
>  *  the MTRRs here
> -* Note: if there is an SPL, then it has already set up MTRRs so we
> -*  don't need to do that here
>  */
> do_mtrr &= !IS_ENABLED(CONFIG_FSP_VERSION1) &&
> !IS_ENABLED(CONFIG_SYS_SLIMBOOTLOADER);
> --

Regards,
Bin


Re: [PATCH 8/8] x86: doc: Update the list of supported Chromebooks

2023-09-04 Thread Bin Meng
On Thu, Aug 24, 2023 at 2:48 AM Simon Glass  wrote:
>
> One is missing, so add it. Also mention the SoC used in each.
>
> Signed-off-by: Simon Glass 
> ---
>
>  doc/arch/x86.rst | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>

Reviewed-by: Bin Meng 


Re: [PATCH] usb: host: ohci-generic: Make usage of clock/reset bulk() API

2023-09-04 Thread Fabrice Gasnier
On 9/2/23 11:06, Xavier Drudis Ferran wrote:
> Is the change of behaviour intended when a clock or reset is not found ?
> (see below)

Hi Xavier,

I'd say yes, although I haven't seen that... please find my answers below.

> 
> El Wed, Aug 30, 2023 at 10:01:49AM +0200, Fabrice Gasnier deia:
>> Make usage of clock and reset bulk API in order to simplify the code
>>
>> Signed-off-by: Fabrice Gasnier 
>> ---
>>
>>  drivers/usb/host/ohci-generic.c | 92 +++--
>>  1 file changed, 29 insertions(+), 63 deletions(-)
>>
>> diff --git a/drivers/usb/host/ohci-generic.c 
>> b/drivers/usb/host/ohci-generic.c
>> index 2d8d38ce9a40..95aa608d8c19 100644
>> --- a/drivers/usb/host/ohci-generic.c
>> +++ b/drivers/usb/host/ohci-generic.c
>> @@ -16,75 +16,41 @@
>>  
>>  struct generic_ohci {
>>  ohci_t ohci;
>> -struct clk *clocks; /* clock list */
>> -struct reset_ctl *resets; /* reset list */
>> +struct clk_bulk clocks; /* clock list */
>> +struct reset_ctl_bulk resets; /* reset list */
>>  struct phy phy;
>> -int clock_count;/* number of clock in clock list */
>> -int reset_count;/* number of reset in reset list */
>>  };
>>  
>>  static int ohci_usb_probe(struct udevice *dev)
>>  {
>>  struct ohci_regs *regs = dev_read_addr_ptr(dev);
>>  struct generic_ohci *priv = dev_get_priv(dev);
>> -int i, err, ret, clock_nb, reset_nb;
>> -
>> -err = 0;
>> -priv->clock_count = 0;
>> -clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells",
>> -   0);
>> -if (clock_nb > 0) {
>> -priv->clocks = devm_kcalloc(dev, clock_nb, sizeof(struct clk),
>> -GFP_KERNEL);
>> -if (!priv->clocks)
>> -return -ENOMEM;
>> -
>> -for (i = 0; i < clock_nb; i++) {
>> -err = clk_get_by_index(dev, i, &priv->clocks[i]);
>> -if (err < 0)
>> -break;
>> -
> 
> Please note the old code was tolerant of not finding some clocks. It
> ignored any clock not found and any other listed after it in the
> "clocks" property and enabled the clocks before it.
> 
> The clk_get_bulk() function instead returns an error when any clock in
> "clocks" is not found and releases (disables again and frees) those
> before it.
> 
> I'm not aware of any case that breaks because of this, but I once saw
> a case of ehci not working and ohci working because one of the listed
> clocks not being found (ehci called clk_get_bulk(),
> clk_enable_blk()).

IMHO, the OHCI should have failed too in this example, instead of
silently ignoring the error. Hopefully it has probed.

The clk_get_bulk() code does a similar job compared to ohci current
code. It counts all clock entries. So, when trying to get them, these
should be found.

Having a clock listed, but it can't be found or taken rather looks like
a real error, that needs to be fixed.
(e.g. missing config for a clk/reset controller ? Or could it be a bug
in such a driver ? Or a miss-configured device-tree ? something else?)
Ignoring such error may be miss-leading (as you pointed out, one was
working).

I hope I don't miss your point. If this is the case, could you point
more precise example, or how it used to fail ?

> In that case, a fix by ignoring the missing clock
> in ehci was rejected, so maybe that criteria applies here as well and
> your patch is deemed correct. I don't know. That case won't break now,
> I think, either with or without your patch, because after another fix,
> that clock will be found.

If I understand correctly, this used to fixed elsewhere (e.g. there used
to be a real bug fixed) ?

> But I don't know if there might be similar
> cases.
> 
> I just wanted to point out the change in behaviour. If the change is
> intended, then all is fine.

IMHO, this should be fine. I hope you agree with this change and the
rationale.

Best Regards,
Fabrice

> 
>> -err = clk_enable(&priv->clocks[i]);
>> -if (err && err != -ENOSYS) {
>> -dev_err(dev, "failed to enable clock %d\n", i);
>> -clk_free(&priv->clocks[i]);
>> -goto clk_err;
>> -}
>> -priv->clock_count++;
>> -}
>> -} else if (clock_nb != -ENOENT) {
>> -dev_err(dev, "failed to get clock phandle(%d)\n", clock_nb);
>> -return clock_nb;
>> +int err, ret;
>> +
>> +ret = clk_get_bulk(dev, &priv->clocks);
>> +if (ret && ret != -ENOENT) {
>> +dev_err(dev, "Failed to get clocks (ret=%d)\n", ret);
>> +return ret;
>> +}
>> +
>> +err = clk_enable_bulk(&priv->clocks);
>> +if (err) {
>> +dev_err(dev, "Failed to enable clocks (err=%d)\n", err);
>> +goto clk_err;
>>  }
>>  
>> -priv->reset_count = 0;
>>

RE: [PATCH 2/2] risc-v: implement DBCN based debug console

2023-09-04 Thread Chanho Park
Hi,

> -Original Message-
> From: U-Boot  On Behalf Of Heinrich
> Schuchardt
> Sent: Saturday, August 19, 2023 10:13 PM
> To: Rick Chen ; Leo 
> Cc: Bin Meng ; Anup Patel ;
> u-boot@lists.denx.de; Heinrich Schuchardt
> 
> Subject: [PATCH 2/2] risc-v: implement DBCN based debug console
> 
> Use the DBCN SBI extension to implement a debug console.
> Make it the default for S-mode RISC-V.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  drivers/serial/Kconfig  |  3 ++-
>  drivers/serial/serial_sbi.c | 19 +++
>  2 files changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index
> a1e089962a..8421c5c047 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -218,6 +218,7 @@ config DEBUG_UART
>  choice
>   prompt "Select which UART will provide the debug UART"
>   depends on DEBUG_UART
> + default DEBUG_SBI_CONSOLE if RISCV_SMODE
>   default DEBUG_UART_NS16550
> 
>  config DEBUG_UART_ALTERA_JTAGUART
> @@ -289,7 +290,7 @@ config DEBUG_EFI_CONSOLE
> 
>  config DEBUG_SBI_CONSOLE
>   bool "SBI"
> - depends on SBI_V01
> + depends on RISCV_SMODE
>   help
> Select this to enable a debug console which calls back to SBI to
> output to the console. This can be useful for early debugging of
> diff --git a/drivers/serial/serial_sbi.c b/drivers/serial/serial_sbi.c
> index b9f35ed36e..093c7309d3 100644
> --- a/drivers/serial/serial_sbi.c
> +++ b/drivers/serial/serial_sbi.c
> @@ -3,6 +3,8 @@
>  #include 
>  #include 
> 
> +#ifdef CONFIG_SBI_V01
> +
>  static inline void _debug_uart_init(void)  {  } @@ -13,4 +15,21 @@ static
> inline void _debug_uart_putc(int c)
>   sbi_console_putchar(c);
>  }
> 
> +#else
> +
> +static int sbi_dbcn_available;
> +
> +static inline void _debug_uart_init(void) {
> + sbi_dbcn_available = sbi_probe_extension(SBI_EXT_DBCN);
> +}
> +
> +static inline void _debug_uart_putc(int ch) {
> + if (sbi_dbcn_available)
> + sbi_dbcn_write_byte(ch);
> +}
> +
> +#endif
> +
>  DEBUG_UART_FUNCS
> --
> 2.40.1

I've got below error when I tried to build it with VisionFive2 board
configuration(starfive_visionfive2_defconfig).
To test this patch, I enabled CONFIG_DEBUG_SBI_CONSOLE. Seems like spl also
includes the driver when DEBUG_SBI_CONSOLE is enabled.
Do I need to do any more configurations to test this?

LD  spl/u-boot-spl
riscv64-unknown-linux-gnu-ld.bfd: drivers/serial/serial_sbi.o: in function
`_debug_uart_putc':
/data/risc-v/vf2/mainline/u-boot/drivers/serial/serial_sbi.c:30: undefined
reference to `sbi_dbcn_write_byte'
riscv64-unknown-linux-gnu-ld.bfd:
/data/risc-v/vf2/mainline/u-boot/drivers/serial/serial_sbi.c:30: undefined
reference to `sbi_dbcn_write_byte'
riscv64-unknown-linux-gnu-ld.bfd: drivers/serial/serial_sbi.o: in function
`_debug_uart_init':
/data/risc-v/vf2/mainline/u-boot/drivers/serial/serial_sbi.c:24: undefined
reference to `sbi_probe_extension'
make[2]: *** [/data/risc-v/vf2/mainline/u-boot/scripts/Makefile.spl:527:
spl/u-boot-spl] Error 1

Best Regards,
Chanho Park



Re: [PATCH 30/32] fdt: Allow the devicetree to come from a bloblist

2023-09-04 Thread Ilias Apalodimas
Hi Simon,

On Fri, 1 Sept 2023 at 18:51, Simon Glass  wrote:
>
> Hi Ilias,
>
> On Fri, 1 Sept 2023 at 01:50, Ilias Apalodimas  
> wrote:
> >
> > [...]
> >
> > > >
> > > > > +config OF_BLOBLIST
> > > > > + bool "DTB is provided by a bloblist"
> > > > > + help
> > > > > +   Select this to read the devicetree from the bloblist. This 
> > > > > allows
> > > > > +   using a bloblist to transfer the devicetree between  U-Boot 
> > > > > phases.
> > > > > +   The devicetree is stored in the bloblist by an early phase so 
> > > > > that
> > > > > +   U-Boot can read it.
> > > > > +
> > > >
> > > > I dont think this is a good idea.  We used to have 4-5 different options
> > > > here, which we tried to clean up and ended up with two very discrete
> > > > options.  Why do we have to reintroduce a new one?  Doesn't that 
> > > > bloblist
> > > > have a header of some sort?  The bloblist literally comes from a 
> > > > previous
> > > > stage bootloader which is what OF_BOARD is here for. So why can't we 
> > > > just
> > > > read the header and figure out if the magic of the bloblist matches?
> > >
> > > No, OF_BOARD is a hack to allow boards to do what they like with the FDT.
> > >
> > > This patch is a standard mechanism to pass the DT from one firmware
> > > phase to the next. We have spent quite a bit of time creating a spec
> > > for it, and we should use it.
> >
> > Where exactly am I objecting using the spec?   Can you please re-read my 
> > email?
> > I am actually pointing out we should use the spec *properly*.  So
> > instead of having a Kconfig option for the DT, which is pretty
> > pointless,  we should parse the bloblist.  If the header defined by
> > the *spec* is found, we should just search for the DT in there.
> > What you are doing here, is take the spec, pick a very specific item
> > that the list contains, and create a Kconfig option out of it.  Which
> > basically ignores the discoverable options of the bloblist.  For
> > example, that bloblist can also contain an entry to a TPM eventlog.
> > Should we start creating Kconfig options for all the firmware handoff
> > entries that are defined on that spec?
>
> OK so that is a different thing. What should it do if it expects to find a 
> bloblist but cannot? I want it to throw an error, because I am trying to make 
> the boot deterministic. What do you think?

That's fine by me.  You can even put that under IS_ENABLED for the
bloblist inside the existing OF_BOARD check.  So I was thinking
- If no bloblist is required in Kconfig options we do the hacks we used to
- if bloblist is selected and the config option is OF_BOARD, throw an
error and mention that the previous stage loader should hand over a DT

Is that what you had in mind?

Thanks
/Ilias
>
> >
> > Thanks
> > /Ilias
> >
> > >
> > > The patches to align bloblist with the spec have been sent, but there
> > > is a late-breaking change that we are trying to resolve. Once that is
> > > sorted out, I will send v2 of those patches.
> > >
> > > >
> > > > >  config OF_BOARD
> > > > >   bool "Provided by the board (e.g a previous loader) at runtime"
> > > > >   default y if SANDBOX || OF_HAS_PRIOR_STAGE
> > > > > diff --git a/include/bloblist.h b/include/bloblist.h
> > > > > index 080cc46a126..e16d122f4fb 100644
> > > > > --- a/include/bloblist.h
> > > > > +++ b/include/bloblist.h
> > > > > @@ -103,6 +103,11 @@ enum bloblist_tag_t {
> > > > >   BLOBLISTT_ACPI_TABLES = 0x104,  /* ACPI tables for x86 */
> > > > >   BLOBLISTT_SMBIOS_TABLES = 0x105, /* SMBIOS tables for x86 */
> > > > >   BLOBLISTT_VBOOT_CTX = 0x106,/* Chromium OS verified boot 
> > > > > context */
> > > > > + /*
> > > >
> > > > [...]
> > > >
> > > > >
> > > > [0] https://github.com/FirmwareHandoff/firmware_handoff
> > >
>
> Regards,
> Simon


Re: [PATCH 4/5] xilinx: zynqmp: add Beckhoff CX8200

2023-09-04 Thread Michal Simek




On 9/1/23 17:03, Steffen Dirkwinkel wrote:



Am 01.09.23 um 13:16 schrieb Michal Simek:



On 9/1/23 11:00, Steffen Dirkwinkel wrote:



Am 01.09.23 um 09:36 schrieb Michal Simek:



On 8/30/23 16:03, Steffen Dirkwinkel wrote:

From: Steffen Dirkwinkel 

This adds support for the Beckhoff CX8200 series of industrial embedded PCs.
There is some information about the device and features here:
https://www.beckhoff.com/en-en/products/ipc/embedded-pcs/cx8200-arm-cortex-a53/

Currently supported/tested:
- Boot from microSD
- Ethernet
- USB
- rtc / rtc eeprom
- tpm access
- uart

Open points:
- adding the psgtr usb phy doesn't work in linux (failed to get pll
   lock)
- fpga loading currently only as u-boot script or pre launch cmd (type
   may be stored in eeprom of rtc so this could be made generic)

Signed-off-by: Steffen Dirkwinkel 
---

  arch/arm/dts/Makefile |    1 +
  arch/arm/dts/zynqmp-beckhoff-cx8200.dts   |  247 +++
  .../zynqmp-beckhoff-cx8200/psu_init_gpl.c | 1960 +
  configs/xilinx_zynqmp_virt_defconfig  |    2 +-
  4 files changed, 2209 insertions(+), 1 deletion(-)
  create mode 100644 arch/arm/dts/zynqmp-beckhoff-cx8200.dts
  create mode 100644 board/xilinx/zynqmp/zynqmp-beckhoff-cx8200/psu_init_gpl.c


First of all xilinx folder is not the right location because Xilinx/AMD is 
not manufacturer of this board.


Yeah, sorry. I saw the avnet board and copied that.



Second I am normally pushing back on adding these custom boards because it 
just increase time for maintaining.
Your last commit was in 2019 but at least you have some commits that I can 
trust that you would maintain your board for some time.


Our last board [1] only had linux/u-boot support as an afterthought. 
Customers had to buy a special option to set the right boot fuses, so most 
devices don’t boot u-boot.
With this board and a second similar zynqmp board (CX9240 [2]) we’ll have 
u-boot as default (and probably only) bootloader, so we’ll be
more active. We can also set two of us as maintainers and it would be fine to 
drop the boards if nobody responds.
We generally support these industrial boards for long time frames and would 
like to stay close to mainline instead of maintaining forks.


The alternative would be to have a downstream u-boot repository on github or 
somewhere. We’ll still likely have something there for build scripts / 
firmware builds / integration, but don’t plan to really diverge from upstream 
u-boot.


The main advantage of being in upstream u-boot would be that we can trigger 
internal CI on upstream changes. We can still do that and apply patches, but 
even simple patches like adding files to a makefile may fail to apply and 
will need fixing.





My biggest question is in what category is your board unique that it should 
be added it to the tree?


Currently the board isn’t really unique. I guess we’d be the only users of 
the rtc with eeprom and there might be something needed for loading the 
correct fpga file based on eeprom (this might be done in linux / userspace or 
even u-boot script though)


[1] 
https://www.beckhoff.com/en-en/products/ipc/embedded-pcs/cx9020-arm-cortex-a8/cx9020.html#tab_productdetails_1
[2] 
https://www.beckhoff.com/en-en/products/ipc/embedded-pcs/cx9240-arm-cortex-a53/cx9240.html


Regarding board itself.
It is DTB - we use OF_SEPARATE/OF_BOARD it means building is easy. I expect 
you have pretty much something in PL that's why your DT is bigger if you don't 
use DT overlays but for fixed design there is actually no reason to use it.


psu_init_gpl. You are adding it to specific folder which match DEVICE_TREE 
variable when you use it. You can actually just copy it to 
board/xilinx/zynqmp/ folder and it will be pick up for your build.


xilinx_zynqmp_virt_defconfig - you likely don't want to use this in your 
product because there are things enabled which you don't use on your board. 
That's why you should tune it for your usage.


regs.init - that's for boot.bin generation with SPL - BOOT_INIT_FILE should be 
used and it can't be wired via generic defconfig anyway.


That pretty much leads to the state that make no sense for you to use 
xilinx_zynqmp_virt_defconfig.


There are things in the defconfig we don't need, but size hasn't really been an 
issue, since we boot from relatively large sdcards. We might still do separate 
config for all our boards though.


We currently build virt_defconfig and set BOOT_INIT_FILE, PMUFW_INIT_FILE and 
ZYNQMP_SPL_PM_CFG_OBJ_FILE. If we ship this firmware somewhere (similar to 
linux-firmware?) we could set fixed paths for that and make rebuilding u-boot 
simpler. I've found reproducing images for zynqmp devboards with and without 
using petalinux and the xilinx fsbl to be quite annoying on the first try and 
this could be simpler if one just wants to support generic arm64 distros.




I think we are still supporting defconfig fragments which is the way how to 
maintain your 

Re: [PATCH 2/2] risc-v: implement DBCN based debug console

2023-09-04 Thread Heinrich Schuchardt

On 9/4/23 11:30, Chanho Park wrote:

Hi,


-Original Message-
From: U-Boot  On Behalf Of Heinrich
Schuchardt
Sent: Saturday, August 19, 2023 10:13 PM
To: Rick Chen ; Leo 
Cc: Bin Meng ; Anup Patel ;
u-boot@lists.denx.de; Heinrich Schuchardt

Subject: [PATCH 2/2] risc-v: implement DBCN based debug console

Use the DBCN SBI extension to implement a debug console.
Make it the default for S-mode RISC-V.

Signed-off-by: Heinrich Schuchardt 
---
  drivers/serial/Kconfig  |  3 ++-
  drivers/serial/serial_sbi.c | 19 +++
  2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index
a1e089962a..8421c5c047 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -218,6 +218,7 @@ config DEBUG_UART
  choice
prompt "Select which UART will provide the debug UART"
depends on DEBUG_UART
+   default DEBUG_SBI_CONSOLE if RISCV_SMODE
default DEBUG_UART_NS16550

  config DEBUG_UART_ALTERA_JTAGUART
@@ -289,7 +290,7 @@ config DEBUG_EFI_CONSOLE

  config DEBUG_SBI_CONSOLE
bool "SBI"
-   depends on SBI_V01
+   depends on RISCV_SMODE
help
  Select this to enable a debug console which calls back to SBI to
  output to the console. This can be useful for early debugging of
diff --git a/drivers/serial/serial_sbi.c b/drivers/serial/serial_sbi.c
index b9f35ed36e..093c7309d3 100644
--- a/drivers/serial/serial_sbi.c
+++ b/drivers/serial/serial_sbi.c
@@ -3,6 +3,8 @@
  #include 
  #include 

+#ifdef CONFIG_SBI_V01
+
  static inline void _debug_uart_init(void)  {  } @@ -13,4 +15,21 @@ static
inline void _debug_uart_putc(int c)
sbi_console_putchar(c);
  }

+#else
+
+static int sbi_dbcn_available;
+
+static inline void _debug_uart_init(void) {
+   sbi_dbcn_available = sbi_probe_extension(SBI_EXT_DBCN);
+}
+
+static inline void _debug_uart_putc(int ch) {
+   if (sbi_dbcn_available)
+   sbi_dbcn_write_byte(ch);
+}
+
+#endif
+
  DEBUG_UART_FUNCS
--
2.40.1


I've got below error when I tried to build it with VisionFive2 board
configuration(starfive_visionfive2_defconfig).
To test this patch, I enabled CONFIG_DEBUG_SBI_CONSOLE. Seems like spl also
includes the driver when DEBUG_SBI_CONSOLE is enabled.
Do I need to do any more configurations to test this?

LD  spl/u-boot-spl
riscv64-unknown-linux-gnu-ld.bfd: drivers/serial/serial_sbi.o: in function
`_debug_uart_putc':
/data/risc-v/vf2/mainline/u-boot/drivers/serial/serial_sbi.c:30: undefined
reference to `sbi_dbcn_write_byte'
riscv64-unknown-linux-gnu-ld.bfd:
/data/risc-v/vf2/mainline/u-boot/drivers/serial/serial_sbi.c:30: undefined
reference to `sbi_dbcn_write_byte'
riscv64-unknown-linux-gnu-ld.bfd: drivers/serial/serial_sbi.o: in function
`_debug_uart_init':
/data/risc-v/vf2/mainline/u-boot/drivers/serial/serial_sbi.c:24: undefined
reference to `sbi_probe_extension'
make[2]: *** [/data/risc-v/vf2/mainline/u-boot/scripts/Makefile.spl:527:
spl/u-boot-spl] Error 1

Best Regards,
Chanho Park



Hello Chanho,

thanks for reporting the issue. SBI is not available in M-mode. We need 
a check in the driver like


if (!CONFIG_IS_ENABLED(RISCV_MMODE))

I will send a new version of the series.

Best regards

Heinrich


[PATCH v4 0/6] DTS Sync from v6.5-rc1 to u-boot

2023-09-04 Thread Manorit Chawdhry
The sync tries to ensure that U-boot remains functional with the updated
Linux DTS and all the fixes from Linux move to U-boot during the sync.

The series tries to sync from Linux v6.5-rc1 along with addition of
the documentation for J721S2 that had been previously missing.

MCU Ringacc [0] and DMA fixes [1] are currently being upstreamed to Linux. 
They'll be fixed in U-boot post their merge in Linux hopefully during
v6.6-rc1 timeframe.

Test Logs are included in [2]

[0]: https://lore.kernel.org/all/20230809175932.2553156-1-vigne...@ti.com/
[1]: https://lore.kernel.org/all/20230810174356.3322583-1-vigne...@ti.com/
[2]: https://gist.github.com/manorit2001/dbad09fd00e8b7c3872e85874c8e648c

Signed-off-by: Manorit Chawdhry 
---
Changes in v4:
- Change the documentation commit description. (Nishanth)
- Remove extra spaces (Nishanth)
- Update J721S2 as J721S2-EVM and similar for AM68 (Nishanth)
- Add documentation for AM68 openocd (Nishanth)
- Add k3-j721s2-thermal.dtsi and arch/arm/mach-k3/j721s2 folder 
  in MAINTAINERS file
- Link to v3: 
https://lore.kernel.org/r/20230816-b4-upstream-j721s2-r5-pinmux-v3-0-fd6602912...@ti.com

---
Manorit Chawdhry (5):
  arm: mach-k3: j721s2: Add mcu_timer0 id to the dev list
  k3-j721s2: Sync from Linux tag v6.5-rc1
  k3-am68: Sync from Linux tag v6.5-rc1
  docs: board: ti: Add j721s2_evm documentation
  board: ti: j721s2: MAINTAINERS: Update the MAINTAINERS File.

Udit Kumar (1):
  configs: j721s2_evm_r5_defconfig: Increase malloc pool size in DRAM

 arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi |  69 +--
 arch/arm/dts/k3-am68-sk-base-board.dts | 389 --
 arch/arm/dts/k3-am68-sk-r5-base-board.dts  | 151 +-
 arch/arm/dts/k3-am68-sk-som.dtsi   | 112 +---
 .../dts/k3-j721s2-common-proc-board-u-boot.dtsi|  60 +--
 arch/arm/dts/k3-j721s2-common-proc-board.dts   | 330 ++--
 arch/arm/dts/k3-j721s2-main.dtsi   | 585 -
 arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi | 365 -
 arch/arm/dts/k3-j721s2-r5-common-proc-board.dts| 158 +-
 arch/arm/dts/k3-j721s2-som-p0.dtsi | 165 +++---
 arch/arm/dts/k3-j721s2-thermal.dtsi| 101 
 arch/arm/dts/k3-j721s2.dtsi|  12 +-
 arch/arm/mach-k3/j721s2/dev-data.c |   1 +
 board/ti/j721s2/MAINTAINERS|  11 +-
 configs/j721s2_evm_r5_defconfig|   1 +
 doc/board/ti/j721s2_evm.rst| 341 
 doc/board/ti/k3.rst|   1 +
 17 files changed, 1998 insertions(+), 854 deletions(-)
---
base-commit: f2bb6d9ffd9ba0d0d89c00445a70cf81327a7af2
change-id: 20230816-b4-upstream-j721s2-r5-pinmux-25c4cd61b258

Best regards,
-- 
Manorit Chawdhry 



[PATCH v4 1/6] configs: j721s2_evm_r5_defconfig: Increase malloc pool size in DRAM

2023-09-04 Thread Manorit Chawdhry
From: Udit Kumar 

The malloc capacity in DRAM at R5 SPL is set to 1MB which isn't
sufficient to load the new tispl.bin to
enable loading of tispl.bin the size is increased by 256KB to 1.25MB.

Cc: Nikhil M Jain 
Signed-off-by: Udit Kumar 
Reviewed-by: Nishanth Menon 
Signed-off-by: Manorit Chawdhry 
---
 configs/j721s2_evm_r5_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/j721s2_evm_r5_defconfig b/configs/j721s2_evm_r5_defconfig
index 1e66ac23d05b..e2b83b337809 100644
--- a/configs/j721s2_evm_r5_defconfig
+++ b/configs/j721s2_evm_r5_defconfig
@@ -42,6 +42,7 @@ CONFIG_SPL_SYS_REPORT_STACK_F_USAGE=y
 CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_STACK_R=y
+CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x14
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SYS_SPL_MALLOC=y
 CONFIG_HAS_CUSTOM_SPL_MALLOC_START=y

-- 
2.41.0



[PATCH v4 2/6] arm: mach-k3: j721s2: Add mcu_timer0 id to the dev list

2023-09-04 Thread Manorit Chawdhry
mcu_timer0 is used by u-boot as the tick-timer. Add it to the soc
devices lsit so it an be enabled via the k3 power controller.

Reviewed-by: Neha Malcom Francis 
Reviewed-by: Nishanth Menon 
Signed-off-by: Manorit Chawdhry 
---
 arch/arm/mach-k3/j721s2/dev-data.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-k3/j721s2/dev-data.c 
b/arch/arm/mach-k3/j721s2/dev-data.c
index 8c999a3c5a8b..df70c5e5d7c0 100644
--- a/arch/arm/mach-k3/j721s2/dev-data.c
+++ b/arch/arm/mach-k3/j721s2/dev-data.c
@@ -47,6 +47,7 @@ static struct ti_lpsc soc_lpsc_list[] = {
 };
 
 static struct ti_dev soc_dev_list[] = {
+   PSC_DEV(35, &soc_lpsc_list[0]),
PSC_DEV(108, &soc_lpsc_list[0]),
PSC_DEV(109, &soc_lpsc_list[0]),
PSC_DEV(110, &soc_lpsc_list[0]),

-- 
2.41.0



[PATCH v4 3/6] k3-j721s2: Sync from Linux tag v6.5-rc1

2023-09-04 Thread Manorit Chawdhry
The following commit syncs the device tree from Linux tag
v6.5-rc1 to U-boot and fixes the following to be compatible with
the future syncs -

- Include k3-j721s2-common-proc-board.dts file

Remove the duplicated pinmuxes from r5 and -u-boot.dtsi files and
include k3-j721s2-common-proc-board.dts for Linux fixes to propagate
to U-boot.

- Fixing the mcu_timer0

Remove timer0 and use the mcu_timer0 defined in mcu-wakeup.dtsi

The device manager is not functional at this point so we can't
configure the clocks for the mcu_timer0, delete the properties
that enable the clocks and power domains for it.

- Fixing secure proxy nodes

Linux DT now have these nodes defined so remove them and rename to
use the Linux DT ones.

- Remove cpsw node

The compatible is now fixed and the node is not required in
-u-boot specifically

- Remove aliases and chosen node

Use these from Linux and don't override when not required.

- Remove /delete-property/ from sdhci nodes

We have the necessary clock and dev data so remove these.

- Remove dummy_clocks and fs_loader0

These weren't being used anywhere so remove it.

All these have been put in a single commit to not break the
bisectability.

Reviewed-by: Neha Malcom Francis 
Reviewed-by: Nishanth Menon 
Signed-off-by: Manorit Chawdhry 
---
 .../dts/k3-j721s2-common-proc-board-u-boot.dtsi|  60 +--
 arch/arm/dts/k3-j721s2-common-proc-board.dts   | 330 ++--
 arch/arm/dts/k3-j721s2-main.dtsi   | 585 -
 arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi | 365 -
 arch/arm/dts/k3-j721s2-r5-common-proc-board.dts| 158 +-
 arch/arm/dts/k3-j721s2-som-p0.dtsi | 165 +++---
 arch/arm/dts/k3-j721s2-thermal.dtsi| 101 
 arch/arm/dts/k3-j721s2.dtsi|  12 +-
 8 files changed, 1342 insertions(+), 434 deletions(-)

diff --git a/arch/arm/dts/k3-j721s2-common-proc-board-u-boot.dtsi 
b/arch/arm/dts/k3-j721s2-common-proc-board-u-boot.dtsi
index f940ffee8787..faa01169ebd8 100644
--- a/arch/arm/dts/k3-j721s2-common-proc-board-u-boot.dtsi
+++ b/arch/arm/dts/k3-j721s2-common-proc-board-u-boot.dtsi
@@ -1,28 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com/
+ * Copyright (C) 2021-2023 Texas Instruments Incorporated - https://www.ti.com/
  */
 
 #include "k3-j721s2-binman.dtsi"
 
-/ {
-   chosen {
-   stdout-path = "serial2:115200n8";
-   tick-timer = &timer1;
-   };
-
-   aliases {
-   serial0 = &wkup_uart0;
-   serial1 = &mcu_uart0;
-   serial2 = &main_uart8;
-   i2c0 = &wkup_i2c0;
-   i2c1 = &mcu_i2c0;
-   i2c2 = &mcu_i2c1;
-   i2c3 = &main_i2c0;
-   ethernet0 = &cpsw_port1;
-   };
-};
-
 &wkup_i2c0 {
bootph-pre-ram;
 };
@@ -38,14 +20,6 @@
 &cbass_mcu_wakeup {
bootph-pre-ram;
 
-   timer1: timer@4040 {
-   compatible = "ti,omap5430-timer";
-   reg = <0x0 0x4040 0x0 0x80>;
-   ti,timer-alwon;
-   clock-frequency = <25000>;
-   bootph-pre-ram;
-   };
-
chipid@4314 {
bootph-pre-ram;
};
@@ -101,6 +75,10 @@
bootph-pre-ram;
 };
 
+&main_usbss0_pins_default {
+   bootph-pre-ram;
+};
+
 &wkup_pmx0 {
bootph-pre-ram;
 };
@@ -129,23 +107,27 @@
bootph-pre-ram;
 };
 
-&mcu_cpsw {
-   reg = <0x0 0x4600 0x0 0x20>,
- <0x0 0x40f00200 0x0 0x8>;
-   reg-names = "cpsw_nuss", "mac_efuse";
-   /delete-property/ ranges;
+&main_sdhci0 {
+   bootph-pre-ram;
+};
 
-   cpsw-phy-sel@40f04040 {
-   compatible = "ti,am654-cpsw-phy-sel";
-   reg= <0x0 0x40f04040 0x0 0x4>;
-   reg-names = "gmii-sel";
-   };
+&main_sdhci1 {
+   bootph-pre-ram;
 };
 
-&main_sdhci0 {
+&ospi0 {
+   status = "disabled";
+};
+
+&ospi1 {
+   status = "disabled";
+};
+
+&usbss0 {
bootph-pre-ram;
 };
 
-&main_sdhci1 {
+&usb0 {
+   dr_mode = "peripheral";
bootph-pre-ram;
 };
diff --git a/arch/arm/dts/k3-j721s2-common-proc-board.dts 
b/arch/arm/dts/k3-j721s2-common-proc-board.dts
index 3bba6473a3b6..04d4739d7245 100644
--- a/arch/arm/dts/k3-j721s2-common-proc-board.dts
+++ b/arch/arm/dts/k3-j721s2-common-proc-board.dts
@@ -2,13 +2,16 @@
 /*
  * Copyright (C) 2021 Texas Instruments Incorporated - https://www.ti.com/
  *
- * Link to Common Processor Board: https://www.ti.com/lit/zip/sprr439
+ * Common Processor Board: https://www.ti.com/tool/J721EXCPXEVM
  */
 
 /dts-v1/;
 
 #include "k3-j721s2-som-p0.dtsi"
 #include 
+#include 
+#include 
+#include 
 
 / {
compatible = "ti,j721s2-evm", "ti,j721s2";
@@ -16,10 +19,10 @@
 
chosen {
stdout-path = "serial2:115200n8";
-   

[PATCH v4 4/6] k3-am68: Sync from Linux tag v6.5-rc1

2023-09-04 Thread Manorit Chawdhry
The following commit syncs the device tree from Linux tag
v6.5-rc1 to U-boot and fixes the following to be compatible with
the future syncs -

- Include k3-am68-sk-base-board.dts file

Remove the duplicated pinmuxes from r5 and -u-boot.dtsi files and
include k3-am68-sk-base-board.dts for Linux fixes to propagate
to U-boot.

- Fixing the mcu_timer0

Remove timer0 and use the mcu_timer0 defined in mcu-wakeup.dtsi

The device manager is not functional at this point so we can't
configure the clocks for the mcu_timer0, delete the properties
that enable the clocks and power domains for it.

- Fixing secure proxy nodes

Linux DT now have these nodes defined so remove them and rename to
use the Linux DT ones.

- Remove cpsw node

The compatible is now fixed and the node is not required in
-u-boot specifically

- Remove aliases and chosen node

Use these from Linux and don't override when not required.

- Remove /delete-property/ from sdhci nodes

We have the necessary clock and dev data so remove these.

- Remove dummy_clocks and fs_loader0

These weren't being used anywhere so remove it.

All these have been put in a single commit to not break the
bisectability.

Reviewed-by: Neha Malcom Francis 
Reviewed-by: Nishanth Menon 
Signed-off-by: Manorit Chawdhry 
---
 arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi |  69 ++---
 arch/arm/dts/k3-am68-sk-base-board.dts | 389 +++--
 arch/arm/dts/k3-am68-sk-r5-base-board.dts  | 151 ++
 arch/arm/dts/k3-am68-sk-som.dtsi   | 112 ++-
 4 files changed, 303 insertions(+), 418 deletions(-)

diff --git a/arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi 
b/arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi
index 79faa1b5737d..b05a2245b6da 100644
--- a/arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi
+++ b/arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi
@@ -1,29 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ * Copyright (C) 2022-2023 Texas Instruments Incorporated - https://www.ti.com/
  */
 
 #include "k3-j721s2-binman.dtsi"
 
-/ {
-   chosen {
-   stdout-path = "serial2:115200n8";
-   tick-timer = &timer1;
-   };
-
-   aliases {
-   serial0 = &wkup_uart0;
-   serial1 = &mcu_uart0;
-   serial2 = &main_uart8;
-   i2c0 = &wkup_i2c0;
-   i2c1 = &mcu_i2c0;
-   i2c2 = &mcu_i2c1;
-   i2c3 = &main_i2c0;
-   ethernet0 = &cpsw_port1;
-   mmc1 = &main_sdhci1;
-   };
-};
-
 &wkup_i2c0 {
bootph-pre-ram;
 };
@@ -39,14 +20,6 @@
 &cbass_mcu_wakeup {
bootph-pre-ram;
 
-   timer1: timer@4040 {
-   compatible = "ti,omap5430-timer";
-   reg = <0x0 0x4040 0x0 0x80>;
-   ti,timer-alwon;
-   clock-frequency = <25000>;
-   bootph-pre-ram;
-   };
-
chipid@4314 {
bootph-pre-ram;
};
@@ -102,10 +75,26 @@
bootph-pre-ram;
 };
 
+&main_usbss0_pins_default {
+   bootph-pre-ram;
+};
+
 &wkup_pmx0 {
bootph-pre-ram;
 };
 
+&wkup_pmx1 {
+   bootph-pre-ram;
+};
+
+&wkup_pmx2 {
+   bootph-pre-ram;
+};
+
+&wkup_pmx3 {
+   bootph-pre-ram;
+};
+
 &k3_pds {
bootph-pre-ram;
 };
@@ -130,23 +119,23 @@
bootph-pre-ram;
 };
 
-&mcu_cpsw {
-   reg = <0x0 0x4600 0x0 0x20>,
- <0x0 0x40f00200 0x0 0x8>;
-   reg-names = "cpsw_nuss", "mac_efuse";
-   /delete-property/ ranges;
+&main_sdhci1 {
+   bootph-pre-ram;
+};
 
-   cpsw-phy-sel@40f04040 {
-   compatible = "ti,am654-cpsw-phy-sel";
-   reg= <0x0 0x40f04040 0x0 0x4>;
-   reg-names = "gmii-sel";
-   };
+&ospi0 {
+   status = "disabled";
 };
 
-&main_sdhci0 {
+&ospi1 {
status = "disabled";
 };
 
-&main_sdhci1 {
+&usbss0 {
+   bootph-pre-ram;
+};
+
+&usb0 {
+   dr_mode = "peripheral";
bootph-pre-ram;
 };
diff --git a/arch/arm/dts/k3-am68-sk-base-board.dts 
b/arch/arm/dts/k3-am68-sk-base-board.dts
index 8fc03324ab8a..d5889ba3fa46 100644
--- a/arch/arm/dts/k3-am68-sk-base-board.dts
+++ b/arch/arm/dts/k3-am68-sk-base-board.dts
@@ -1,8 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
+ * Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/
  *
- * Base Board: **Yet to Add**
+ * Base Board: https://www.ti.com/lit/zip/SPRR463
  */
 
 /dts-v1/;
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 / {
compatible = "ti,am68-sk", "ti,j721s2";
@@ -18,15 +19,20 @@
 
chosen {
stdout-path = "serial2:115200n8";
-   bootargs = "console=ttyS2,115200n8 
earlycon=ns16550a,mmio32,0x288";
};
 
aliases {
+   serial0 = &w

[PATCH v4 5/6] docs: board: ti: Add j721s2_evm documentation

2023-09-04 Thread Manorit Chawdhry
Add the documentation for J721S2-EVM and SK-AM68

TRM for J721S2/AM68: https://www.ti.com/lit/pdf/spruj28
Product Page for J721S2: https://www.ti.com/tool/J721S2XSOMXEVM
Product Page for AM68: https://www.ti.com/tool/SK-AM68

Reviewed-by: Neha Malcom Francis 
Signed-off-by: Manorit Chawdhry 
---
 doc/board/ti/j721s2_evm.rst | 341 
 doc/board/ti/k3.rst |   1 +
 2 files changed, 342 insertions(+)

diff --git a/doc/board/ti/j721s2_evm.rst b/doc/board/ti/j721s2_evm.rst
new file mode 100644
index ..a72a47ee8603
--- /dev/null
+++ b/doc/board/ti/j721s2_evm.rst
@@ -0,0 +1,341 @@
+.. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+.. sectionauthor:: Manorit Chawdhry 
+
+J721S2 and AM68 Platforms
+=
+
+Introduction:
+-
+The J721S2 family of SoCs are part of K3 Multicore SoC architecture platform
+targeting automotive applications. They are designed as a low power, high
+performance and highly integrated device architecture, adding significant
+enhancement on processing power, graphics capability, video and imaging
+processing, virtualization and coherent memory support.
+
+The AM68 Starter Kit/Evaluation Module (EVM) is based on the J721S2 family
+of SoCs. They are designed for machine vision, traffic monitoring, retail
+automation, and factory automation.
+
+The device is partitioned into three functional domains, each containing
+specific processing cores and peripherals:
+
+1. Wake-up (WKUP) domain:
+* ARM Cortex-M4F processor, runs TI Foundational Security (TIFS)
+
+2. Microcontroller (MCU) domain:
+* Dual core ARM Cortex-R5F processor, runs device management
+  and SoC early boot
+
+3. MAIN domain:
+* Dual core 64-bit ARM Cortex-A72, runs HLOS
+
+More info can be found in TRM: https://www.ti.com/lit/pdf/spruj28
+
+Platform information:
+
+* https://www.ti.com/tool/J721S2XSOMXEVM
+* https://www.ti.com/tool/SK-AM68
+
+Boot Flow:
+--
+Below is the pictorial representation of boot flow:
+
+.. image:: img/boot_diagram_k3_current.svg
+
+- On this platform, "TI Foundational Security" (TIFS) functions as the
+  security enclave master while "Device Manager" (DM), also known as the
+  "TISCI server" in TI terminology, offers all the essential services.
+
+- As illustrated in the diagram above, R5 SPL manages power and clock
+  services independently before handing over control to "DM". The A72 or
+  the C7x (Aux core) software components request TIFS/DM to handle
+  security or device management services.
+
+Sources:
+
+
+.. include::  k3.rst
+:start-after: .. k3_rst_include_start_boot_sources
+:end-before: .. k3_rst_include_end_boot_sources
+
+Build procedure:
+
+0. Setup the environment variables:
+
+.. include::  k3.rst
+:start-after: .. k3_rst_include_start_common_env_vars_desc
+:end-before: .. k3_rst_include_end_common_env_vars_desc
+
+.. include::  k3.rst
+:start-after: .. k3_rst_include_start_board_env_vars_desc
+:end-before: .. k3_rst_include_end_board_env_vars_desc
+
+Set the variables corresponding to this platform:
+
+.. include::  k3.rst
+:start-after: .. k3_rst_include_start_common_env_vars_defn
+:end-before: .. k3_rst_include_end_common_env_vars_defn
+.. code-block:: bash
+
+ $ export UBOOT_CFG_CORTEXR=j721s2_evm_r5_defconfig
+ $ export UBOOT_CFG_CORTEXA=j721s2_evm_a72_defconfig
+ $ export TFA_BOARD=generic
+ $ export TFA_EXTRA_ARGS="K3_USART=0x8"
+ $ # The following is not a typo, j784s4 is the OP-TEE platform for j721s2
+ $ export OPTEE_PLATFORM=k3-j784s4
+ $ export OPTEE_EXTRA_ARGS="CFG_CONSOLE_UART=0x8"
+
+.. j721s2_evm_rst_include_start_build_steps
+
+1. Trusted Firmware-A:
+
+.. include::  k3.rst
+:start-after: .. k3_rst_include_start_build_steps_tfa
+:end-before: .. k3_rst_include_end_build_steps_tfa
+
+
+2. OP-TEE:
+
+.. include::  k3.rst
+:start-after: .. k3_rst_include_start_build_steps_optee
+:end-before: .. k3_rst_include_end_build_steps_optee
+
+3. U-Boot:
+
+.. _j721s2_evm_rst_u_boot_r5:
+
+* 3.1 R5:
+
+.. include::  k3.rst
+:start-after: .. k3_rst_include_start_build_steps_spl_r5
+:end-before: .. k3_rst_include_end_build_steps_spl_r5
+
+.. _j721s2_evm_rst_u_boot_a72:
+
+* 3.2 A72:
+
+.. include::  k3.rst
+:start-after: .. k3_rst_include_start_build_steps_uboot
+:end-before: .. k3_rst_include_end_build_steps_uboot
+.. j721s2_evm_rst_include_end_build_steps
+
+Target Images
+--
+In order to boot we need tiboot3.bin, tispl.bin and u-boot.img. Each SoC
+variant (GP, HS-FS, HS-SE) requires a different source for these files.
+
+ - GP
+
+* tiboot3-j721s2-gp-evm.bin from :ref:`step 3.1 `
+* tispl.bin_unsigned, u-boot.img_unsigned from :ref:`step 3.2 
`
+
+ - HS-FS
+
+* tiboot3-j721s2-hs-fs-evm.bin from :ref:`step 3.1 
`
+* tispl.bin, u-boot.img from :ref:`step 3.2 `
+
+ - HS-SE
+
+* tiboot3-j721s2-hs-evm.bin from :ref:`step 3.1 `
+* tispl.bin, u-boot.i

[PATCH v4 6/6] board: ti: j721s2: MAINTAINERS: Update the MAINTAINERS File.

2023-09-04 Thread Manorit Chawdhry
Update the MAINTAINERS file and propose a new MAINTAINER for j721s2 due
to the previous MAINTAINER not being associated with TI.

Signed-off-by: Manorit Chawdhry 
---
 board/ti/j721s2/MAINTAINERS | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/board/ti/j721s2/MAINTAINERS b/board/ti/j721s2/MAINTAINERS
index 323bd2353a7e..08c8d110ac0a 100644
--- a/board/ti/j721s2/MAINTAINERS
+++ b/board/ti/j721s2/MAINTAINERS
@@ -1,16 +1,23 @@
 J721S2 BOARD
-M: Aswath Govindraju 
+M: Manorit Chawdhry 
 S: Maintained
 F: board/ti/j721s2
+F: arch/arm/mach-k3/j721s2
+F: doc/board/ti/j721s2_evm.rst
 F: include/configs/j721s2_evm.h
 F: configs/j721s2_evm_r5_defconfig
 F: configs/j721s2_evm_a72_defconfig
 F: arch/arm/dts/k3-j721s2.dtsi
 F: arch/arm/dts/k3-j721s2-main.dtsi
 F: arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi
+F: arch/arm/dts/k3-j721s2-thermal.dtsi
 F: arch/arm/dts/k3-j721s2-som-p0.dtsi
 F: arch/arm/dts/k3-j721s2-common-proc-board.dts
 F: arch/arm/dts/k3-j721s2-common-proc-board-u-boot.dtsi
-F: arch/arm/dts//k3-j721s2-r5-common-proc-board.dts
+F: arch/arm/dts/k3-j721s2-r5-common-proc-board.dts
 F: arch/arm/dts/k3-j721s2-ddr.dtsi
 F: arch/arm/dts/k3-j721s2-ddr-evm-lp4-4266.dtsi
+F: arch/arm/dts/k3-am68-sk-som.dtsi
+F: arch/arm/dts/k3-am68-sk-base-board.dts
+F: arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi
+F: arch/arm/dts/k3-am68-sk-r5-base-board.dts

-- 
2.41.0



[PATCH v2 0/2] risc-v: implement DBCN based debug console

2023-09-04 Thread Heinrich Schuchardt
Currently we only offer an SBI based debug UART for SBI v0.1.
With OpenSBI 1.3 the Debug Console Extension (DBCN) has become available.
This allows us to implement a debug UART in a device independent manor.

v2:
In the driver check that we are in S-mode.

Heinrich Schuchardt (2):
  risc-v: implement DBCN write byte
  risc-v: implement DBCN based debug console

 arch/riscv/include/asm/sbi.h |  1 +
 arch/riscv/lib/sbi.c | 16 
 drivers/serial/Kconfig   |  5 -
 drivers/serial/serial_sbi.c  | 20 
 4 files changed, 41 insertions(+), 1 deletion(-)

-- 
2.40.1



[PATCH v2 1/2] risc-v: implement DBCN write byte

2023-09-04 Thread Heinrich Schuchardt
The DBCN extension provides a Console Write Byte call.
Implement function sbi_dbcn_write_byte to invoke it.

Signed-off-by: Heinrich Schuchardt 
Reviewed-by: Leo Yu-Chi Liang 
---
v2:
no change
---
 arch/riscv/include/asm/sbi.h |  1 +
 arch/riscv/lib/sbi.c | 16 
 2 files changed, 17 insertions(+)

diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
index 009a26885c..bf4c9af622 100644
--- a/arch/riscv/include/asm/sbi.h
+++ b/arch/riscv/include/asm/sbi.h
@@ -170,5 +170,6 @@ int sbi_get_mvendorid(long *mvendorid);
 int sbi_get_marchid(long *marchid);
 int sbi_get_mimpid(long *mimpid);
 void sbi_srst_reset(unsigned long type, unsigned long reason);
+int sbi_dbcn_write_byte(unsigned char ch);
 
 #endif
diff --git a/arch/riscv/lib/sbi.c b/arch/riscv/lib/sbi.c
index 8724e3a460..55a3bc3b5c 100644
--- a/arch/riscv/lib/sbi.c
+++ b/arch/riscv/lib/sbi.c
@@ -204,6 +204,22 @@ void sbi_srst_reset(unsigned long type, unsigned long 
reason)
  0, 0, 0, 0);
 }
 
+/**
+ * sbi_dbcn_write_byte() - write byte to debug console
+ *
+ * @ch:byte to be written
+ * Return: SBI error code (SBI_SUCCESS = 0 on success)
+ */
+int sbi_dbcn_write_byte(unsigned char ch)
+{
+   struct sbiret ret;
+
+   ret = sbi_ecall(SBI_EXT_DBCN,
+   SBI_EXT_DBCN_CONSOLE_WRITE_BYTE,
+   ch, 0, 0, 0, 0, 0);
+   return ret.error;
+}
+
 #ifdef CONFIG_SBI_V01
 
 /**
-- 
2.40.1



[PATCH v2 2/2] risc-v: implement DBCN based debug console

2023-09-04 Thread Heinrich Schuchardt
Use the DBCN SBI extension to implement a debug console.
Make it the default for S-mode RISC-V.

Signed-off-by: Heinrich Schuchardt 
---
v2:
check that we are in S-mode
---
 drivers/serial/Kconfig  |  5 -
 drivers/serial/serial_sbi.c | 20 
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 7ca42df6a7..fb108f0189 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -218,6 +218,7 @@ config DEBUG_UART
 choice
prompt "Select which UART will provide the debug UART"
depends on DEBUG_UART
+   default DEBUG_SBI_CONSOLE if RISCV_SMODE
default DEBUG_UART_NS16550
 
 config DEBUG_UART_ALTERA_JTAGUART
@@ -289,11 +290,13 @@ config DEBUG_EFI_CONSOLE
 
 config DEBUG_SBI_CONSOLE
bool "SBI"
-   depends on SBI_V01
+   depends on RISCV_SMODE
help
  Select this to enable a debug console which calls back to SBI to
  output to the console. This can be useful for early debugging of
  U-Boot when running on top of SBI (Supervisor Binary Interface).
+ This implementation of the debug UART is not available while in
+ M-mode (e.g. during SPL).
 
 config DEBUG_UART_S5P
bool "Samsung S5P"
diff --git a/drivers/serial/serial_sbi.c b/drivers/serial/serial_sbi.c
index b9f35ed36e..a51a96c1ef 100644
--- a/drivers/serial/serial_sbi.c
+++ b/drivers/serial/serial_sbi.c
@@ -3,6 +3,8 @@
 #include 
 #include 
 
+#ifdef CONFIG_SBI_V01
+
 static inline void _debug_uart_init(void)
 {
 }
@@ -13,4 +15,22 @@ static inline void _debug_uart_putc(int c)
sbi_console_putchar(c);
 }
 
+#else
+
+static int sbi_dbcn_available;
+
+static inline void _debug_uart_init(void)
+{
+   if (CONFIG_IS_ENABLED(RISCV_SMODE))
+   sbi_dbcn_available = sbi_probe_extension(SBI_EXT_DBCN);
+}
+
+static inline void _debug_uart_putc(int ch)
+{
+   if (CONFIG_IS_ENABLED(RISCV_SMODE) && sbi_dbcn_available)
+   sbi_dbcn_write_byte(ch);
+}
+
+#endif
+
 DEBUG_UART_FUNCS
-- 
2.40.1



Updates for RPi for 2023.10:

2023-09-04 Thread Peter Robinson
The following changes since commit 8999257f219d1e371c2fd66f255b8782897944d9:

  Merge tag 'doc-2023-10-rc4-2' of
https://source.denx.de/u-boot/custodians/u-boot-efi (2023-09-02
09:08:54 -0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-raspberrypi/ tags/rpi-2023.10

for you to fetch changes up to fc2af2d978b525e188b15d909e321caf9445bdb0:

  arm: rpi: Switch to a text environment (2023-09-03 23:33:04 +0100)


Updates for RPi for 2023.10:

- rpi: Disable DISTRO_DEFAULTS
- arm: rpi: Switch to standard boot
- arm: rpi: Switch to a text environment


Simon Glass (3):
  arm: rpi: Switch to standard boot
  rpi: Disable DISTRO_DEFAULTS
  arm: rpi: Switch to a text environment

 board/raspberrypi/rpi/rpi.env  |  77
+
 configs/rpi_0_w_defconfig  |   2 +-
 configs/rpi_2_defconfig|   2 +-
 configs/rpi_3_32b_defconfig|   2 +-
 configs/rpi_3_b_plus_defconfig |   2 +-
 configs/rpi_3_defconfig|   2 +-
 configs/rpi_4_32b_defconfig|   2 +-
 configs/rpi_4_defconfig|   2 +-
 configs/rpi_arm64_defconfig|   2 +-
 configs/rpi_defconfig  |   2 +-
 include/configs/rpi.h  | 134
--
 11 files changed, 86 insertions(+), 143 deletions(-)
 create mode 100644 board/raspberrypi/rpi/rpi.env


[PATCH v2] usb: host: ohci-generic: Make usage of clock/reset bulk() API

2023-09-04 Thread Fabrice Gasnier
Make usage of clock and reset bulk API in order to simplify the code

Reviewed-by: Marek Vasut 
Signed-off-by: Fabrice Gasnier 
---

Changes in v2:
- fix copy/paste on dev_err message since Marek's review comment
- add Marek's review tag

---
 drivers/usb/host/ohci-generic.c | 92 +++--
 1 file changed, 29 insertions(+), 63 deletions(-)

diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
index 2d8d38ce9a40..ceed1911a95a 100644
--- a/drivers/usb/host/ohci-generic.c
+++ b/drivers/usb/host/ohci-generic.c
@@ -16,75 +16,41 @@
 
 struct generic_ohci {
ohci_t ohci;
-   struct clk *clocks; /* clock list */
-   struct reset_ctl *resets; /* reset list */
+   struct clk_bulk clocks; /* clock list */
+   struct reset_ctl_bulk resets; /* reset list */
struct phy phy;
-   int clock_count;/* number of clock in clock list */
-   int reset_count;/* number of reset in reset list */
 };
 
 static int ohci_usb_probe(struct udevice *dev)
 {
struct ohci_regs *regs = dev_read_addr_ptr(dev);
struct generic_ohci *priv = dev_get_priv(dev);
-   int i, err, ret, clock_nb, reset_nb;
-
-   err = 0;
-   priv->clock_count = 0;
-   clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells",
-  0);
-   if (clock_nb > 0) {
-   priv->clocks = devm_kcalloc(dev, clock_nb, sizeof(struct clk),
-   GFP_KERNEL);
-   if (!priv->clocks)
-   return -ENOMEM;
-
-   for (i = 0; i < clock_nb; i++) {
-   err = clk_get_by_index(dev, i, &priv->clocks[i]);
-   if (err < 0)
-   break;
-
-   err = clk_enable(&priv->clocks[i]);
-   if (err && err != -ENOSYS) {
-   dev_err(dev, "failed to enable clock %d\n", i);
-   clk_free(&priv->clocks[i]);
-   goto clk_err;
-   }
-   priv->clock_count++;
-   }
-   } else if (clock_nb != -ENOENT) {
-   dev_err(dev, "failed to get clock phandle(%d)\n", clock_nb);
-   return clock_nb;
+   int err, ret;
+
+   ret = clk_get_bulk(dev, &priv->clocks);
+   if (ret && ret != -ENOENT) {
+   dev_err(dev, "Failed to get clocks (ret=%d)\n", ret);
+   return ret;
+   }
+
+   err = clk_enable_bulk(&priv->clocks);
+   if (err) {
+   dev_err(dev, "Failed to enable clocks (err=%d)\n", err);
+   goto clk_err;
}
 
-   priv->reset_count = 0;
-   reset_nb = dev_count_phandle_with_args(dev, "resets", "#reset-cells",
-  0);
-   if (reset_nb > 0) {
-   priv->resets = devm_kcalloc(dev, reset_nb,
-   sizeof(struct reset_ctl),
-   GFP_KERNEL);
-   if (!priv->resets)
-   return -ENOMEM;
-
-   for (i = 0; i < reset_nb; i++) {
-   err = reset_get_by_index(dev, i, &priv->resets[i]);
-   if (err < 0)
-   break;
-
-   err = reset_deassert(&priv->resets[i]);
-   if (err) {
-   dev_err(dev, "failed to deassert reset %d\n", 
i);
-   reset_free(&priv->resets[i]);
-   goto reset_err;
-   }
-   priv->reset_count++;
-   }
-   } else if (reset_nb != -ENOENT) {
-   dev_err(dev, "failed to get reset phandle(%d)\n", reset_nb);
+   err = reset_get_bulk(dev, &priv->resets);
+   if (err && err != -ENOENT) {
+   dev_err(dev, "failed to get resets (err=%d)\n", err);
goto clk_err;
}
 
+   err = reset_deassert_bulk(&priv->resets);
+   if (err) {
+   dev_err(dev, "failed to deassert resets (err=%d)\n", err);
+   goto reset_err;
+   }
+
err = generic_setup_phy(dev, &priv->phy, 0);
if (err)
goto reset_err;
@@ -101,13 +67,13 @@ phy_err:
dev_err(dev, "failed to shutdown usb phy\n");
 
 reset_err:
-   ret = reset_release_all(priv->resets, priv->reset_count);
+   ret = reset_release_bulk(&priv->resets);
if (ret)
-   dev_err(dev, "failed to assert all resets\n");
+   dev_err(dev, "failed to release resets (ret=%d)\n", ret);
 clk_err:
-   ret = clk_release_all(priv->clocks, priv->clock_count);
+   ret = clk_release_bulk(&priv->clocks);
if (ret)
-   dev_err(dev, "failed to disable all clocks\n");
+

Re: [PATCH v2] usb: check for companion controller in uclass

2023-09-04 Thread Fabrice Gasnier
On 9/1/23 18:00, Marek Vasut wrote:
> On 9/1/23 14:12, Fabrice Gasnier wrote:
>> On 9/1/23 12:48, Marek Vasut wrote:
>>> On 9/1/23 11:52, Fabrice Gasnier wrote:
 EHCI is usually used with companion controller (like OHCI) as companion
 controller. This information on the companion is missing currently in
 companion drivers.
 So, if the usb-uclass isn't aware, it may scan busses in any order:
 OHCI
 first, then EHCI.
 This is seen on STM32MP1 where DT probing makes the probe order to
 occur
 by increasing address (OHCI address < EHCI address).

 When a low speed or full-speed device is plugged in, it's not
 detected as
 EHCI should first detect it, and give ownership (handover) to OHCI.

 Current situation on STM32MP1 (with a low speed device plugged-in)
 STM32MP> usb start
 starting USB...
 Bus usb@5800c000: USB OHCI 1.0
 Bus usb@5800d000: USB EHCI 1.00
 scanning bus usb@5800c000 for devices... 1 USB Device(s) found
 scanning bus usb@5800d000 for devices... 1 USB Device(s) found
  scanning usb for storage devices... 0 Storage Device(s) found

 The "companion" property in the device tree allow to retrieve companion
 controller information, from the EHCI node. This allow marking the
 companion driver as such.

 With this patch (same low speed device plugged in):
 STM32MP> usb start
 starting USB...
 Bus usb@5800c000: USB OHCI 1.0
 Bus usb@5800d000: USB EHCI 1.00
 scanning bus usb@5800d000 for devices... 1 USB Device(s) found
 scanning bus usb@5800c000 for devices... 2 USB Device(s) found
  scanning usb for storage devices... 0 Storage Device(s) found
 STM32MP> usb tree
 USB device tree:
 1  Hub (12 Mb/s, 0mA)
 |   U-Boot Root Hub
 |
 +-2  Human Interface (1.5 Mb/s, 100mA)
  HP HP USB 1000dpi Laser Mouse

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

 This also optimize bus scan when a High speed device is plugged in, as
 the usb-uclass skips OHCI in this case:

 STM32MP> usb reset
 resetting USB...
 Bus usb@5800c000: USB OHCI 1.0
 Bus usb@5800d000: USB EHCI 1.00
 scanning bus usb@5800d000 for devices... 2 USB Device(s) found
  scanning usb for storage devices... 1 Storage Device(s) found
 STM32MP> usb tree
 USB device tree:
 1  Hub (480 Mb/s, 0mA)
 |  u-boot EHCI Host Controller
 |
 +-2  Mass Storage (480 Mb/s, 200mA)
  SanDisk Cruzer Blade 03003432021922011407

 Signed-off-by: Fabrice Gasnier 
 ---

 Changes in v2:
 - move companion probing from generic ehci driver to usb-uclass, after
     Marek's questions on design choice.
 - rename commit title to follow this change

 ---
    drivers/usb/host/usb-uclass.c | 36
 +++
    1 file changed, 36 insertions(+)

 diff --git a/drivers/usb/host/usb-uclass.c
 b/drivers/usb/host/usb-uclass.c
 index 02c0138a2065..e238eee8c84d 100644
 --- a/drivers/usb/host/usb-uclass.c
 +++ b/drivers/usb/host/usb-uclass.c
 @@ -249,6 +249,37 @@ static void remove_inactive_children(struct
 uclass *uc, struct udevice *bus)
    }
    }
    +static int usb_probe_companion(struct udevice *bus)
 +{
 +    struct udevice *companion_dev;
 +    int ret;
 +
 +    /*
 + * Enforce optional companion controller is marked as such in
 order to
 + * 1st scan the primary controller, before the companion
 controller
 + * (ownership is given to companion when low or full speed devices
 + * have been detected).
 + */
 +    ret = uclass_get_device_by_phandle(UCLASS_USB, bus, "companion",
 &companion_dev);
 +    if (!ret) {
 +    struct usb_bus_priv *companion_bus_priv;
 +
 +    debug("%s is the companion of %s\n", companion_dev->name,
 bus->name);
 +    companion_bus_priv = dev_get_uclass_priv(companion_dev);
 +    companion_bus_priv->companion = true;
 +    } else if (ret && ret != -ENOENT && ret != -ENODEV) {
 +    /*
 + * Treat everything else than no companion or disabled
 + * companion as an error. (It may not be enabled on boards
 + * that have a High-Speed HUB to handle FS and LS traffic).
 + */
 +    printf("Failed to get companion (ret=%d)\n", ret);
 +    return ret;
 +    }
 +
 +    return 0;
 +}
 +
    int usb_init(void)
    {
    int controllers_initialized = 0;
 @@ -299,6 +330,11 @@ int usb_init(void)
    printf("probe failed, error %d\n", ret);
    continue;
    }
 +
 +    ret = usb_probe_companion(bus);
>>>
>>> Shouldn't this ^ be in separate uclass_foreach_dev(bus, uc) {} loop
>>> before this device_pro

Re: [PATCH] usb: host: ohci-generic: Make usage of clock/reset bulk() API

2023-09-04 Thread Xavier Drudis Ferran
El Mon, Sep 04, 2023 at 11:25:06AM +0200, Fabrice Gasnier deia:
> 
> IMHO, the OHCI should have failed too in this example, instead of
> silently ignoring the error. Hopefully it has probed.
>
> The clk_get_bulk() code does a similar job compared to ohci current
> code. It counts all clock entries. So, when trying to get them, these
> should be found.
> 
> Having a clock listed, but it can't be found or taken rather looks like
> a real error, that needs to be fixed.
> (e.g. missing config for a clk/reset controller ? Or could it be a bug
> in such a driver ? Or a miss-configured device-tree ? something else?)
> Ignoring such error may be miss-leading (as you pointed out, one was
> working).
> 
> I hope I don't miss your point. If this is the case, could you point
> more precise example, or how it used to fail ?
>

No, you don't miss my point. I'll give you pointers to the case I
meant, but I'm afraid it might mislead, because it's already solved,
and for current U-Boot it should pose no problem with or without your
patch.

The general problem might be that dts come from linux, and the drivers
come from U-Boot, so U-Boot might ignore some hardware described in
the linux dts that it doesn't need. Now this is more typical for, say,
a VPU than a clock or reset. But it once was a missing clock driver in
U-Boot that linux used for suspend/resume and happened to be at the
end of the clock list. So it worked when ohci probe ignored the missing
clock, because U-Boot doesn't need suspend, but it didn't work for ehci
that called clk_get_bulk().

There might be other cases like that example somewhere, but I'm not
saying it's likely. I guess we'll know if some board breaks.


If you really want the gory details...

https://patchwork.ozlabs.org/project/uboot/patch/20220701185959.GC1700@begut/
https://patchwork.ozlabs.org/project/uboot/patch/Y44+ayJfUlI08ptM@localhost/
https://patchwork.ozlabs.org/project/uboot/patch/Y5IWpjYLB4aXMy9o@localhost/
https://lists.denx.de/pipermail/u-boot/2022-December/501811.html
https://lists.denx.de/pipermail/u-boot/2023-February/510676.html
https://lists.denx.de/pipermail/u-boot/2023-February/510678.html
https://patchwork.ozlabs.org/project/uboot/patch/202013db5a47ecbac4a53c360ed1ca91ca663996.1685974993.git.xdru...@tinet.cat/
https://patchwork.ozlabs.org/project/uboot/patch/464111fca83008503022e8ada5305e69ffd1afbd.1685974993.git.xdru...@tinet.cat/


> > In that case, a fix by ignoring the missing clock
> > in ehci was rejected, so maybe that criteria applies here as well and
> > your patch is deemed correct. I don't know. That case won't break now,
> > I think, either with or without your patch, because after another fix,
> > that clock will be found.
> 
> If I understand correctly, this used to fixed elsewhere (e.g. there used
> to be a real bug fixed) ?
>

Yes. See above. Or don't, it's not that important.
A clock driver was missing, only needed for suspend/resume.
ohci ignored it and worked (U-Boot doesn't suspend)
ehci failed probing and dind't work.
Current situation is this particular clock driver is no longer missing.

> > But I don't know if there might be similar
> > cases.
> > 
> > I just wanted to point out the change in behaviour. If the change is
> > intended, then all is fine.
> 
> IMHO, this should be fine. I hope you agree with this change and the
> rationale.
>

I do.

I just wanted to point it out in case anyone knew why ohci wasn't
calling clk_get_bulk(). It might have been on purpose.

In fact Kever Yang once proposed to change ehci to be tolerant to a
missing clock like ohci was (but with an explicit warning). But Marek
Vasut proposed adding a clock driver and Kever didn't complain, so I
don't think this is his very strong opinion, he may just be happy when
things work and others are happy, I can't read minds.

https://lists.denx.de/pipermail/u-boot/2022-December/501811.html

FWIW

ohci_probe introduced:
fee331f66c9 (Alexey Brodkin   2015-12-14 17:18:50 +0300 

loop for clocks introduced in ohci_probe:
155d9f65d3b (Patrice Chotard  2017-07-18 11:57:12 +0200 

clk_get_bulk introduced:
a855be87da4 (Neil Armstrong  2018-04-03 11:44:18 +0200 156)

So ochi_probe() didn't call clk_get_bulk() most likely because it
din't exist back then.

So, unless someone else has a failing case, I agree to your change.

I'd welcome if the commit message would say that the new policy is any
missing clocks or resets cause the probe to fail. But since you
already sent v2, it doesn't matter.



Re: [PATCH v5 05/11] spl: Convert mmc to spl_load

2023-09-04 Thread Xavier Drudis Ferran
El Sun, Sep 03, 2023 at 08:17:26AM +, Jonas Karlman deia:

> > Fundamentally, we can't really deal with unaligned images without a
> > bounce-buffer. The method used by SPL_LOAD_FIT_IMAGE_BUFFER_SIZE will
> > continue working, since we call into the FIT routines to load the image.

Yes

> > I would like to defer bounce buffering for other images until someone
> > actually needs it.
> >

Fine.

> > Note that in the FIT case, you can also do `mkimage -EB`, at least if
> > you aren't using FIT_LOAD_FULL.
> 
> With the following two commits introduced in v2023.04-rc1, the alignment
> issue for Rockchip has been fixed and all external data is now accessed
> block aligned.
> 
> 9b2fd2d22852 ("binman: Add support for align argument to mkimage tool")
> 5ad03fc77dfa ("rockchip: Align FIT image data to SD/MMC block length")
> 
> Regards,
> Jonas
>

Well, yes, thanks.

I was carrying Jerome's patch still thinking it was needed for me, but
I just tried without and it works too, in mmc. In spi I didn't try but
it should be even easier (bl_len=1).

For me it's still odd to write outside intended memory. Would a warning
in case legacy image loading writes before load_addr be acceptable ?
Just in case someone was using the memory there for something else.







Re: [PATCH] verdin-imx8mp: drop unused tdx easy installer ifdef

2023-09-04 Thread Marcel Ziswiler
Hi Hiago

Thanks!

On Mon, 2023-09-04 at 10:24 -0300, Hiago De Franco wrote:
> From: Hiago De Franco 
> 
> Drop unused code related to CONFIG_TDX_EASY_INSTALLER, that existed only on
> toradex downstream branch.
> 
> Signed-off-by: Hiago De Franco 

Acked-by: Marcel Ziswiler 

> ---
>  include/configs/verdin-imx8mp.h | 10 ++
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/include/configs/verdin-imx8mp.h b/include/configs/verdin-imx8mp.h
> index 942081ab84..d980bd66ae 100644
> --- a/include/configs/verdin-imx8mp.h
> +++ b/include/configs/verdin-imx8mp.h
> @@ -36,20 +36,14 @@
> func(DHCP, dhcp, na)
>  #include 
>  
> -#if defined(CONFIG_TDX_EASY_INSTALLER)
> -#  define BOOT_SCRIPT  "boot-tezi.scr"
> -#else
> -#  define BOOT_SCRIPT  "boot.scr"
> -#endif
> -
>  /* Initial environment variables */
>  #define CFG_EXTRA_ENV_SETTINGS \
> BOOTENV \
> MEM_LAYOUT_ENV_SETTINGS \
> "bootcmd_mfg=fastboot 0\0" \
> "boot_file=Image\0" \
> -   "boot_scripts=" BOOT_SCRIPT "\0" \
> -   "boot_script_dhcp=" BOOT_SCRIPT "\0" \
> +   "boot_scripts=boot.scr\0" \
> +   "boot_script_dhcp=boot.scr\0" \
> "console=ttymxc2\0" \
> "fdt_board=dev\0" \
> "initrd_addr=0x4380\0" \

Cheers

Marcel


Re: [PATCH v2] usb: check for companion controller in uclass

2023-09-04 Thread Marek Vasut

On 9/4/23 14:34, Fabrice Gasnier wrote:

On 9/1/23 18:00, Marek Vasut wrote:

On 9/1/23 14:12, Fabrice Gasnier wrote:

On 9/1/23 12:48, Marek Vasut wrote:

On 9/1/23 11:52, Fabrice Gasnier wrote:

EHCI is usually used with companion controller (like OHCI) as companion
controller. This information on the companion is missing currently in
companion drivers.
So, if the usb-uclass isn't aware, it may scan busses in any order:
OHCI
first, then EHCI.
This is seen on STM32MP1 where DT probing makes the probe order to
occur
by increasing address (OHCI address < EHCI address).

When a low speed or full-speed device is plugged in, it's not
detected as
EHCI should first detect it, and give ownership (handover) to OHCI.

Current situation on STM32MP1 (with a low speed device plugged-in)
STM32MP> usb start
starting USB...
Bus usb@5800c000: USB OHCI 1.0
Bus usb@5800d000: USB EHCI 1.00
scanning bus usb@5800c000 for devices... 1 USB Device(s) found
scanning bus usb@5800d000 for devices... 1 USB Device(s) found
  scanning usb for storage devices... 0 Storage Device(s) found

The "companion" property in the device tree allow to retrieve companion
controller information, from the EHCI node. This allow marking the
companion driver as such.

With this patch (same low speed device plugged in):
STM32MP> usb start
starting USB...
Bus usb@5800c000: USB OHCI 1.0
Bus usb@5800d000: USB EHCI 1.00
scanning bus usb@5800d000 for devices... 1 USB Device(s) found
scanning bus usb@5800c000 for devices... 2 USB Device(s) found
  scanning usb for storage devices... 0 Storage Device(s) found
STM32MP> usb tree
USB device tree:
1  Hub (12 Mb/s, 0mA)
|   U-Boot Root Hub
|
+-2  Human Interface (1.5 Mb/s, 100mA)
  HP HP USB 1000dpi Laser Mouse

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

This also optimize bus scan when a High speed device is plugged in, as
the usb-uclass skips OHCI in this case:

STM32MP> usb reset
resetting USB...
Bus usb@5800c000: USB OHCI 1.0
Bus usb@5800d000: USB EHCI 1.00
scanning bus usb@5800d000 for devices... 2 USB Device(s) found
  scanning usb for storage devices... 1 Storage Device(s) found
STM32MP> usb tree
USB device tree:
1  Hub (480 Mb/s, 0mA)
|  u-boot EHCI Host Controller
|
+-2  Mass Storage (480 Mb/s, 200mA)
  SanDisk Cruzer Blade 03003432021922011407

Signed-off-by: Fabrice Gasnier 
---

Changes in v2:
- move companion probing from generic ehci driver to usb-uclass, after
     Marek's questions on design choice.
- rename commit title to follow this change

---
    drivers/usb/host/usb-uclass.c | 36
+++
    1 file changed, 36 insertions(+)

diff --git a/drivers/usb/host/usb-uclass.c
b/drivers/usb/host/usb-uclass.c
index 02c0138a2065..e238eee8c84d 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -249,6 +249,37 @@ static void remove_inactive_children(struct
uclass *uc, struct udevice *bus)
    }
    }
    +static int usb_probe_companion(struct udevice *bus)
+{
+    struct udevice *companion_dev;
+    int ret;
+
+    /*
+ * Enforce optional companion controller is marked as such in
order to
+ * 1st scan the primary controller, before the companion
controller
+ * (ownership is given to companion when low or full speed devices
+ * have been detected).
+ */
+    ret = uclass_get_device_by_phandle(UCLASS_USB, bus, "companion",
&companion_dev);
+    if (!ret) {
+    struct usb_bus_priv *companion_bus_priv;
+
+    debug("%s is the companion of %s\n", companion_dev->name,
bus->name);
+    companion_bus_priv = dev_get_uclass_priv(companion_dev);
+    companion_bus_priv->companion = true;
+    } else if (ret && ret != -ENOENT && ret != -ENODEV) {
+    /*
+ * Treat everything else than no companion or disabled
+ * companion as an error. (It may not be enabled on boards
+ * that have a High-Speed HUB to handle FS and LS traffic).
+ */
+    printf("Failed to get companion (ret=%d)\n", ret);
+    return ret;
+    }
+
+    return 0;
+}
+
    int usb_init(void)
    {
    int controllers_initialized = 0;
@@ -299,6 +330,11 @@ int usb_init(void)
    printf("probe failed, error %d\n", ret);
    continue;
    }
+
+    ret = usb_probe_companion(bus);


One more thing, shouldn't this do

if (ret)
  continue;

for maximum compatibility ?


I'd be glad to have it in this release.


OK


Re: [PATCH v2] usb: host: ohci-generic: Make usage of clock/reset bulk() API

2023-09-04 Thread Marek Vasut

On 9/4/23 14:20, Fabrice Gasnier wrote:

Make usage of clock and reset bulk API in order to simplify the code

Reviewed-by: Marek Vasut 
Signed-off-by: Fabrice Gasnier 
---

Changes in v2:
- fix copy/paste on dev_err message since Marek's review comment
- add Marek's review tag


Likely still needs RB from Xavier ?


[PATCH v2 0/2] Fix dependencies of USB Kconfig options

2023-09-04 Thread Venkatesh Yadav Abbarapu
When USB device driver CONFIG_USB and CONFIG_CMD_USB are disabled,
some compilation issues are seen. Also CMD_THOR_DOWNLOAD should
depend on USB_GADGET_DOWNLOAD. Add dependencies to resolve those
issues and compile properly. Also remove unused config CONFIG_ZYNQMP_USB.

Changes in v2:
- Added the dependency on USB_GADGET_DOWNLOAD for CMD_THOR_DOWNLOAD.

Venkatesh Yadav Abbarapu (2):
  cmd: thordown: Add proper dependency for CMD_THOR_DOWNLOAD
  zynqmp: config: Add proper dependencies for USB

 arch/arm/mach-zynqmp/Kconfig | 3 ---
 cmd/Kconfig  | 2 ++
 configs/xilinx_zynqmp_virt_defconfig | 1 -
 include/configs/xilinx_zynqmp.h  | 4 ++--
 4 files changed, 4 insertions(+), 6 deletions(-)

-- 
2.17.1



[PATCH v2 1/2] cmd: thordown: Add proper dependency for CMD_THOR_DOWNLOAD

2023-09-04 Thread Venkatesh Yadav Abbarapu
When CONFIG_CMD_USB and CONFIG_USB are disabled some compilation errors are 
seen as below.

cmd/thordown.o: in function `usb_gadget_initialize':
include/linux/usb/gadget.h:981: undefined reference to `board_usb_init'
cmd/thordown.o: in function `do_thor_down':
cmd/thordown.c:68: undefined reference to `g_dnl_unregister'
cmd/thordown.o: in function `usb_gadget_release':
include/linux/usb/gadget.h:986: undefined reference to `board_usb_cleanup'
cmd/thordown.o: in function `do_thor_down':
cmd/thordown.c:41: undefined reference to `g_dnl_register'
cmd/thordown.c:48: undefined reference to `thor_init'
cmd/thordown.c:56: undefined reference to `thor_handle'
gnu/aarch64/lin/aarch64-linux/bin/aarch64-linux-gnu-ld.bfd: line 4:  8485
Segmentation fault  (core dumped) $CC --sysroot=$LIBC
--no-warn-rwx-segment "$@"
Makefile:1779: recipe for target 'u-boot' failed
make: *** [u-boot] Error 139
make: *** Deleting file 'u-boot'

Add dependency of USB_GADGET_DOWNLOAD for CONFIG_CMD_THOR_DOWNLOAD to fix the 
errors.

Signed-off-by: Ashok Reddy Soma 
Signed-off-by: Venkatesh Yadav Abbarapu 
---
 cmd/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 43ca10f69c..ac58000eb3 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -544,6 +544,8 @@ config CMD_SPL_WRITE_SIZE
 config CMD_THOR_DOWNLOAD
bool "thor - TIZEN 'thor' download"
select DFU
+   select USB_FUNCTION_THOR
+   depends on USB_GADGET_DOWNLOAD
help
  Implements the 'thor' download protocol. This is a way of
  downloading a software update over USB from an attached host.
-- 
2.17.1



[PATCH v2 2/2] zynqmp: config: Add proper dependencies for USB

2023-09-04 Thread Venkatesh Yadav Abbarapu
When CONFIG_CMD_USB and CONFIG_USB are disabled, still some compilation
errors are seen as below.

In file included from include/configs/xilinx_zynqmp.h:173,
 from include/config.h:3,
 from include/common.h:16,
 from env/common.c:10:
include/config_distro_bootcmd.h:302:9: error: expected '}' before 
'BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB'
  302 | BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB
  | ^
include/config_distro_bootcmd.h:302:9: note: in definition of macro
'BOOTENV_DEV_NAME_USB'
  302 | BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB
  | ^
include/configs/xilinx_zynqmp.h:77:41: note: in expansion of macro
'BOOTENV_DEV_NAME'
   77 | # define BOOT_TARGET_DEVICES_USB(func)  func(USB, usb, 0)
   func(USB, usb, 1)
  | ^~~~
include/configs/xilinx_zynqmp.h:168:9: note: in expansion of macro
'BOOT_TARGET_DEVICES_USB'
  168 | BOOT_TARGET_DEVICES_USB(func) \
  | ^~~
include/config_distro_bootcmd.h:454:25: note: in expansion of macro
'BOOT_TARGET_DEVICES'
  454 | "boot_targets=" BOOT_TARGET_DEVICES(BOOTENV_DEV_NAME) "\0"
  | ^~~
include/config_distro_bootcmd.h:474:9: note: in expansion of macro
'BOOTENV_BOOT_TARGETS'
  474 | BOOTENV_BOOT_TARGETS \
  | ^~~~
include/configs/xilinx_zynqmp.h:179:9: note: in expansion of macro
'BOOTENV'
  179 | BOOTENV
  | ^~~
include/env_default.h:120:9: note: in expansion of macro
'CFG_EXTRA_ENV_SETTINGS'
  120 | CFG_EXTRA_ENV_SETTINGS
  | ^~
In file included from env/common.c:32:
include/env_default.h:27:36: note: to match this '{'
   27 | const char default_environment[] = {
  |^
scripts/Makefile.build:256: recipe for target 'env/common.o' failed
make[1]: *** [env/common.o] Error 1
Makefile:1853: recipe for target 'env' failed
make: *** [env] Error 2
make: *** Waiting for unfinished jobs

Add CONFIG_USB_STORAGE as dependency for USB related macro's such as
BOOT_TARGET_DEVICES_USB() and DFU_DEFAULT_POLL_TIMEOUT and
CONFIG_THOR_RESET_OFF.

Remove CONFIG_ZYNQMP_USB from Kconfig and also from defconfig since it
is not used anywhere else.

Signed-off-by: Ashok Reddy Soma 
Signed-off-by: Venkatesh Yadav Abbarapu 
---
 arch/arm/mach-zynqmp/Kconfig | 3 ---
 configs/xilinx_zynqmp_virt_defconfig | 1 -
 include/configs/xilinx_zynqmp.h  | 4 ++--
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-zynqmp/Kconfig b/arch/arm/mach-zynqmp/Kconfig
index fd6f07715a..26b80b7882 100644
--- a/arch/arm/mach-zynqmp/Kconfig
+++ b/arch/arm/mach-zynqmp/Kconfig
@@ -84,9 +84,6 @@ config ZYNQMP_SPL_PM_CFG_OBJ_FILE
  Leave this option empty if your PMU firmware has a hard-coded
  configuration object or you are loading it by any other means.
 
-config ZYNQMP_USB
-   bool "Configure ZynqMP USB"
-
 config ZYNQMP_NO_DDR
bool "Disable DDR MMU mapping"
help
diff --git a/configs/xilinx_zynqmp_virt_defconfig 
b/configs/xilinx_zynqmp_virt_defconfig
index acab38fefe..c0e7061524 100644
--- a/configs/xilinx_zynqmp_virt_defconfig
+++ b/configs/xilinx_zynqmp_virt_defconfig
@@ -17,7 +17,6 @@ CONFIG_ENV_OFFSET_REDUND=0x1E8
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
 CONFIG_CMD_FRU=y
-CONFIG_ZYNQMP_USB=y
 CONFIG_SYS_LOAD_ADDR=0x800
 CONFIG_AHCI=y
 CONFIG_SYS_MEMTEST_START=0x
diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h
index 74264b7bee..a8edf13e34 100644
--- a/include/configs/xilinx_zynqmp.h
+++ b/include/configs/xilinx_zynqmp.h
@@ -29,7 +29,7 @@
 
 /* Miscellaneous configurable options */
 
-#if defined(CONFIG_ZYNQMP_USB)
+#if defined(CONFIG_USB_STORAGE)
 #define DFU_DEFAULT_POLL_TIMEOUT   300
 
 # define PARTS_DEFAULT \
@@ -76,7 +76,7 @@
 # define BOOT_TARGET_DEVICES_SCSI(func)
 #endif
 
-#if defined(CONFIG_ZYNQMP_USB)
+#if defined(CONFIG_USB_STORAGE)
 # define BOOT_TARGET_DEVICES_USB(func) func(USB, usb, 0) func(USB, usb, 1)
 #else
 # define BOOT_TARGET_DEVICES_USB(func)
-- 
2.17.1



[PATCH 0/3] Do not setup boot_targets if driver is not enabled

2023-09-04 Thread Venkatesh Yadav Abbarapu
Fixing the boot_targets for versal-net, versal and zynqmp platforms.

Venkatesh Yadav Abbarapu (3):
  xilinx: versal-net: Do not setup boot_targets if driver is not enabled
  xilinx: versal: Do not setup boot_targets if driver is not enabled
  xilinx: zynqmp: Do not setup boot_targets if driver is not enabled

 board/xilinx/versal-net/board.c | 76 -
 board/xilinx/versal/board.c | 67 +++--
 board/xilinx/zynqmp/zynqmp.c| 71 +++---
 3 files changed, 108 insertions(+), 106 deletions(-)

-- 
2.17.1



[PATCH 1/3] xilinx: versal-net: Do not setup boot_targets if driver is not enabled

2023-09-04 Thread Venkatesh Yadav Abbarapu
SOC can boot in the device which is not accessible from APU and running
this is detected as error which ends up in stopping boot process.
Boot mode detection and logic around is present to setup priority
on boot devices that SOC boot device is likely also used for booting OS.
Change logic to detect this case with showing message about it but don't
fail in boot process and don't prioritize boot device in this case.

Signed-off-by: Michal Simek 
Signed-off-by: Venkatesh Yadav Abbarapu 
---
 board/xilinx/versal-net/board.c | 76 -
 1 file changed, 38 insertions(+), 38 deletions(-)

diff --git a/board/xilinx/versal-net/board.c b/board/xilinx/versal-net/board.c
index f0d2224b33..7ad299f3a2 100644
--- a/board/xilinx/versal-net/board.c
+++ b/board/xilinx/versal-net/board.c
@@ -201,7 +201,7 @@ int board_late_init(void)
int bootseq = -1;
int bootseq_len = 0;
int env_targets_len = 0;
-   const char *mode;
+   const char *mode = NULL;
char *new_targets;
char *env_targets;
 
@@ -229,8 +229,8 @@ int board_late_init(void)
puts("QSPI_MODE_24\n");
if (uclass_get_device_by_name(UCLASS_SPI,
  "spi@f103", &dev)) {
-   puts("Boot from QSPI but without QSPI enabled!\n");
-   return -1;
+   debug("QSPI driver for QSPI device is not present\n");
+   break;
}
mode = "xspi";
bootseq = dev_seq(dev);
@@ -239,8 +239,8 @@ int board_late_init(void)
puts("QSPI_MODE_32\n");
if (uclass_get_device_by_name(UCLASS_SPI,
  "spi@f103", &dev)) {
-   puts("Boot from QSPI but without QSPI enabled!\n");
-   return -1;
+   debug("QSPI driver for QSPI device is not present\n");
+   break;
}
mode = "xspi";
bootseq = dev_seq(dev);
@@ -249,8 +249,8 @@ int board_late_init(void)
puts("OSPI_MODE\n");
if (uclass_get_device_by_name(UCLASS_SPI,
  "spi@f101", &dev)) {
-   puts("Boot from OSPI but without OSPI enabled!\n");
-   return -1;
+   debug("OSPI driver for OSPI device is not present\n");
+   break;
}
mode = "xspi";
bootseq = dev_seq(dev);
@@ -264,8 +264,8 @@ int board_late_init(void)
puts("SD_MODE\n");
if (uclass_get_device_by_name(UCLASS_MMC,
  "mmc@f104", &dev)) {
-   puts("Boot from SD0 but without SD0 enabled!\n");
-   return -1;
+   debug("SD0 driver for SD0 device is not present\n");
+   break;
}
debug("mmc0 device found at %p, seq %d\n", dev, dev_seq(dev));
 
@@ -279,8 +279,8 @@ int board_late_init(void)
puts("SD_MODE1\n");
if (uclass_get_device_by_name(UCLASS_MMC,
  "mmc@f105", &dev)) {
-   puts("Boot from SD1 but without SD1 enabled!\n");
-   return -1;
+   debug("SD1 driver for SD1 device is not present\n");
+   break;
}
debug("mmc1 device found at %p, seq %d\n", dev, dev_seq(dev));
 
@@ -288,38 +288,38 @@ int board_late_init(void)
bootseq = dev_seq(dev);
break;
default:
-   mode = "";
printf("Invalid Boot Mode:0x%x\n", bootmode);
break;
}
 
-   if (bootseq >= 0) {
-   bootseq_len = snprintf(NULL, 0, "%i", bootseq);
-   debug("Bootseq len: %x\n", bootseq_len);
-   }
-
-   /*
-* One terminating char + one byte for space between mode
-* and default boot_targets
-*/
-   env_targets = env_get("boot_targets");
-   if (env_targets)
-   env_targets_len = strlen(env_targets);
-
-   new_targets = calloc(1, strlen(mode) + env_targets_len + 2 +
-bootseq_len);
-   if (!new_targets)
-   return -ENOMEM;
-
-   if (bootseq >= 0)
-   sprintf(new_targets, "%s%x %s", mode, bootseq,
-   env_targets ? env_targets : "");
-   else
-   sprintf(new_targets, "%s %s", mode,
-   env_targets ? env_targets : "");
-
-   env_set("boot_targets", new_targets);
+   if (mode) {
+   if (bootseq >= 0) {
+   bootseq_len = snprintf(NULL, 0, "%i", bootseq);
+   debug("Boo

[PATCH 3/3] xilinx: zynqmp: Do not setup boot_targets if driver is not enabled

2023-09-04 Thread Venkatesh Yadav Abbarapu
SOC can boot in the device which is not accessible from APU and running
this is detected as error which ends up in stopping boot process.
Boot mode detection and logic around is present to setup priority on boot
devices that SOC boot device is likely also used for booting OS.
Change logic to detect this case with showing message about it but don't fail
in boot process and don't prioritize boot device in this case.

Signed-off-by: Venkatesh Yadav Abbarapu 
---
 board/xilinx/zynqmp/zynqmp.c | 71 ++--
 1 file changed, 36 insertions(+), 35 deletions(-)

diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index 309f24a5f4..0b6d4e5707 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -391,7 +391,7 @@ int board_late_init(void)
int bootseq = -1;
int bootseq_len = 0;
int env_targets_len = 0;
-   const char *mode;
+   const char *mode = NULL;
char *new_targets;
char *env_targets;
int ret, multiboot;
@@ -442,8 +442,8 @@ int board_late_init(void)
  "mmc@ff16", &dev) &&
uclass_get_device_by_name(UCLASS_MMC,
  "sdhci@ff16", &dev)) {
-   puts("Boot from EMMC but without SD0 enabled!\n");
-   return -1;
+   debug("SD0 driver for SD0 device is not present\n");
+   break;
}
debug("mmc0 device found at %p, seq %d\n", dev, dev_seq(dev));
 
@@ -457,8 +457,8 @@ int board_late_init(void)
  "mmc@ff16", &dev) &&
uclass_get_device_by_name(UCLASS_MMC,
  "sdhci@ff16", &dev)) {
-   puts("Boot from SD0 but without SD0 enabled!\n");
-   return -1;
+   debug("SD0 driver for SD0 device is not present\n");
+   break;
}
debug("mmc0 device found at %p, seq %d\n", dev, dev_seq(dev));
 
@@ -475,8 +475,8 @@ int board_late_init(void)
  "mmc@ff17", &dev) &&
uclass_get_device_by_name(UCLASS_MMC,
  "sdhci@ff17", &dev)) {
-   puts("Boot from SD1 but without SD1 enabled!\n");
-   return -1;
+   debug("SD1 driver for SD1 device is not present\n");
+   break;
}
debug("mmc1 device found at %p, seq %d\n", dev, dev_seq(dev));
 
@@ -490,39 +490,40 @@ int board_late_init(void)
env_set("modeboot", "nandboot");
break;
default:
-   mode = "";
printf("Invalid Boot Mode:0x%x\n", bootmode);
break;
}
 
-   if (bootseq >= 0) {
-   bootseq_len = snprintf(NULL, 0, "%i", bootseq);
-   debug("Bootseq len: %x\n", bootseq_len);
-   env_set_hex("bootseq", bootseq);
-   }
+   if (mode) {
+   if (bootseq >= 0) {
+   bootseq_len = snprintf(NULL, 0, "%i", bootseq);
+   debug("Bootseq len: %x\n", bootseq_len);
+   env_set_hex("bootseq", bootseq);
+   }
 
-   /*
-* One terminating char + one byte for space between mode
-* and default boot_targets
-*/
-   env_targets = env_get("boot_targets");
-   if (env_targets)
-   env_targets_len = strlen(env_targets);
-
-   new_targets = calloc(1, strlen(mode) + env_targets_len + 2 +
-bootseq_len);
-   if (!new_targets)
-   return -ENOMEM;
-
-   if (bootseq >= 0)
-   sprintf(new_targets, "%s%x %s", mode, bootseq,
-   env_targets ? env_targets : "");
-   else
-   sprintf(new_targets, "%s %s", mode,
-   env_targets ? env_targets : "");
-
-   env_set("boot_targets", new_targets);
-   free(new_targets);
+   /*
+* One terminating char + one byte for space between mode
+* and default boot_targets
+*/
+   env_targets = env_get("boot_targets");
+   if (env_targets)
+   env_targets_len = strlen(env_targets);
+
+   new_targets = calloc(1, strlen(mode) + env_targets_len + 2 +
+bootseq_len);
+   if (!new_targets)
+   return -ENOMEM;
+
+   if (bootseq >= 0)
+   sprintf(new_targets, "%s%x %s", mode, bootseq,
+   env_targets ? env_targets : "");
+   else
+   sprintf(new_targets, "%s %s

[PATCH 2/3] xilinx: versal: Do not setup boot_targets if driver is not enabled

2023-09-04 Thread Venkatesh Yadav Abbarapu
SOC can boot in the device which is not accessible from APU and running
this is detected as error which ends up in stopping boot process.
Boot mode detection and logic around is present to setup priority on boot
devices that SOC boot device is likely also used for booting OS.
Change logic to detect this case with showing message about it but don't fail
in boot process and don't prioritize boot device in this case.

Signed-off-by: Venkatesh Yadav Abbarapu 
---
 board/xilinx/versal/board.c | 67 +++--
 1 file changed, 34 insertions(+), 33 deletions(-)

diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c
index 60bf37d3c9..982a8b3779 100644
--- a/board/xilinx/versal/board.c
+++ b/board/xilinx/versal/board.c
@@ -133,7 +133,7 @@ int board_late_init(void)
int bootseq = -1;
int bootseq_len = 0;
int env_targets_len = 0;
-   const char *mode;
+   const char *mode = NULL;
char *new_targets;
char *env_targets;
 
@@ -175,8 +175,8 @@ int board_late_init(void)
  "mmc@f105", &dev) &&
uclass_get_device_by_name(UCLASS_MMC,
  "sdhci@f105", &dev)) {
-   puts("Boot from EMMC but without SD1 enabled!\n");
-   return -1;
+   debug("SD1 driver for SD1 device is not present\n");
+   break;
}
debug("mmc1 device found at %p, seq %d\n", dev, dev_seq(dev));
mode = "mmc";
@@ -188,8 +188,8 @@ int board_late_init(void)
  "mmc@f104", &dev) &&
uclass_get_device_by_name(UCLASS_MMC,
  "sdhci@f104", &dev)) {
-   puts("Boot from SD0 but without SD0 enabled!\n");
-   return -1;
+   debug("SD0 driver for SD0 device is not present\n");
+   break;
}
debug("mmc0 device found at %p, seq %d\n", dev, dev_seq(dev));
 
@@ -205,8 +205,8 @@ int board_late_init(void)
  "mmc@f105", &dev) &&
uclass_get_device_by_name(UCLASS_MMC,
  "sdhci@f105", &dev)) {
-   puts("Boot from SD1 but without SD1 enabled!\n");
-   return -1;
+   debug("SD1 driver for SD1 device is not present\n");
+   break;
}
debug("mmc1 device found at %p, seq %d\n", dev, dev_seq(dev));
 
@@ -214,37 +214,38 @@ int board_late_init(void)
bootseq = dev_seq(dev);
break;
default:
-   mode = "";
printf("Invalid Boot Mode:0x%x\n", bootmode);
break;
}
 
-   if (bootseq >= 0) {
-   bootseq_len = snprintf(NULL, 0, "%i", bootseq);
-   debug("Bootseq len: %x\n", bootseq_len);
-   }
+   if (mode) {
+   if (bootseq >= 0) {
+   bootseq_len = snprintf(NULL, 0, "%i", bootseq);
+   debug("Bootseq len: %x\n", bootseq_len);
+   }
 
-   /*
-* One terminating char + one byte for space between mode
-* and default boot_targets
-*/
-   env_targets = env_get("boot_targets");
-   if (env_targets)
-   env_targets_len = strlen(env_targets);
-
-   new_targets = calloc(1, strlen(mode) + env_targets_len + 2 +
-bootseq_len);
-   if (!new_targets)
-   return -ENOMEM;
-
-   if (bootseq >= 0)
-   sprintf(new_targets, "%s%x %s", mode, bootseq,
-   env_targets ? env_targets : "");
-   else
-   sprintf(new_targets, "%s %s", mode,
-   env_targets ? env_targets : "");
-
-   env_set("boot_targets", new_targets);
+   /*
+* One terminating char + one byte for space between mode
+* and default boot_targets
+*/
+   env_targets = env_get("boot_targets");
+   if (env_targets)
+   env_targets_len = strlen(env_targets);
+
+   new_targets = calloc(1, strlen(mode) + env_targets_len + 2 +
+bootseq_len);
+   if (!new_targets)
+   return -ENOMEM;
+
+   if (bootseq >= 0)
+   sprintf(new_targets, "%s%x %s", mode, bootseq,
+   env_targets ? env_targets : "");
+   else
+   sprintf(new_targets, "%s %s", mode,
+   env_targets ? env_targets : "");
+
+   env_set("boot_targets", new_targets);
+   }
 
  

[PATCH] verdin-imx8mp: drop unused tdx easy installer ifdef

2023-09-04 Thread Hiago De Franco
From: Hiago De Franco 

Drop unused code related to CONFIG_TDX_EASY_INSTALLER, that existed only on
toradex downstream branch.

Signed-off-by: Hiago De Franco 
---
 include/configs/verdin-imx8mp.h | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/include/configs/verdin-imx8mp.h b/include/configs/verdin-imx8mp.h
index 942081ab84..d980bd66ae 100644
--- a/include/configs/verdin-imx8mp.h
+++ b/include/configs/verdin-imx8mp.h
@@ -36,20 +36,14 @@
func(DHCP, dhcp, na)
 #include 
 
-#if defined(CONFIG_TDX_EASY_INSTALLER)
-#  define BOOT_SCRIPT  "boot-tezi.scr"
-#else
-#  define BOOT_SCRIPT  "boot.scr"
-#endif
-
 /* Initial environment variables */
 #define CFG_EXTRA_ENV_SETTINGS \
BOOTENV \
MEM_LAYOUT_ENV_SETTINGS \
"bootcmd_mfg=fastboot 0\0" \
"boot_file=Image\0" \
-   "boot_scripts=" BOOT_SCRIPT "\0" \
-   "boot_script_dhcp=" BOOT_SCRIPT "\0" \
+   "boot_scripts=boot.scr\0" \
+   "boot_script_dhcp=boot.scr\0" \
"console=ttymxc2\0" \
"fdt_board=dev\0" \
"initrd_addr=0x4380\0" \
-- 
2.40.1



[PATCH] Adjust gitignore for /build

2023-09-04 Thread Rong Tao
From: Rong Tao 

/build-* can't ignore /build.

Signed-off-by: Rong Tao 
---
 .gitignore | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 002f95de4feb..9697f0088f80 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,7 +35,7 @@
 *.tab.[ch]
 
 # Build tree
-/build-*
+/build*
 
 #
 # Top-level generic files
-- 
2.41.0



[PATCH] binman: Fix SyntaxWarning: invalid escape sequence '\('

2023-09-04 Thread Rong Tao
From: Rong Tao 

Reproduct warning:

$ sudo git clean -dfx
$ make CROSS_COMPILE="" qemu-x86_64_defconfig
$ sudo make -j8
...
u-boot/tools/binman/etype/section.py:25:
SyntaxWarning: invalid escape sequence '\('
"""Entry that contains other entries

Signed-off-by: Rong Tao 
---
 tools/binman/etype/section.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index fb49e85a7634..30c1041c7e8d 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -40,7 +40,7 @@ class Entry_section(Entry):
 For example code, see etypes which subclass `Entry_section`, or `cbfs.py`
 for a more involved example::
 
-   $ grep -l \(Entry_section tools/binman/etype/*.py
+   $ grep -l \\(Entry_section tools/binman/etype/*.py
 
 ReadNode()
 Call `super().ReadNode()`, then read any special properties for the
-- 
2.41.0



Re: Updates for RPi for 2023.10:

2023-09-04 Thread Tom Rini
On Mon, Sep 04, 2023 at 01:10:09PM +0100, Peter Robinson wrote:

> The following changes since commit 8999257f219d1e371c2fd66f255b8782897944d9:
> 
>   Merge tag 'doc-2023-10-rc4-2' of
> https://source.denx.de/u-boot/custodians/u-boot-efi (2023-09-02
> 09:08:54 -0400)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-raspberrypi/ 
> tags/rpi-2023.10
> 
> for you to fetch changes up to fc2af2d978b525e188b15d909e321caf9445bdb0:
> 
>   arm: rpi: Switch to a text environment (2023-09-03 23:33:04 +0100)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[ANN] U-Boot v2023.10-rc4 released

2023-09-04 Thread Tom Rini
Hey all,

Once again it's release day and I've tagged and pushed -rc4, and will
merge that to next as well shortly. We are firmly in the stabilization
period at this point and I really want to see PRs for -next for things
that aren't fixes.  Adding Fixes tags would be great and helpful, but
not required.

In terms of a changelog, 
git log --merges v2023.10-rc3..v2023.10-rc4
contains what I've pulled but as always, better PR messages and tags
will provide better results here.

I'm going to try and stay on schedule now and that means the rest of the
rcs every other Monday, and with final release on October 2nd, 2023.
Thanks all!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v3 01/20] lib: rational: Move the Kconfigs into the correct place

2023-09-04 Thread Simon Glass
These should not be part of the 'system tables' menu. Move them outside
on their own.

Signed-off-by: Simon Glass 
Fixes: 7d0f3fbb93c ("lib: rational: copy the rational fraction lib...")
---

(no changes since v1)

 lib/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index 42e559ad0b51..9addcfab3734 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -989,6 +989,8 @@ config GENERATE_SMBIOS_TABLE
  See also SMBIOS_SYSINFO which allows SMBIOS values to be provided in
  the devicetree.
 
+endmenu
+
 config LIB_RATIONAL
bool "enable continued fraction calculation routines"
 
@@ -996,8 +998,6 @@ config SPL_LIB_RATIONAL
bool "enable continued fraction calculation routines for SPL"
depends on SPL
 
-endmenu
-
 config ASN1_COMPILER
bool
help
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 00/20] Kconfig: Tidy up some options

2023-09-04 Thread Simon Glass
The view from 'make menuconfig' is confusing in places. This series aims
to improve the top-level menu and also the boot menu.

It also groups FDT-fixup options tegether, at least the ones I could fine.

Finally this series marks the distro scripts as deprecated, so people have
a pointer to standard boot.

Changes in v3:
- Drop comment about an update/ directory
- Drop extra newline and quote
- Add new patch to drop CMD_MTDPARTS condition for FDT_FIXUP_PARTITIONS
- Drop patch 'Move SYS_RX_ETH_BUFFER into the network menu'

Changes in v2:
- Add new patch to move bmp code to drivers/video
- Just move these options to driver/video for later consideration
- Fix FMU typo in the subject
- Drop now-unnecessary depends on FWU_MULTI_BANK_UPDATE
- Mention in the DISTRO_DEFAULTS option that it is script-based
- Expand and rewrite the commit message
- Use the word 'Mark' instead of 'Make' to improve the English

Simon Glass (20):
  lib: rational: Move the Kconfigs into the correct place
  Kconfig: Move API into general setup
  video: Move bmp code to drivers/video
  video: Move the BMP options
  video: Move BMP options and code to video directory
  FWU: Avoid showing an unselectable menu option
  test: Move POST under a renamed Testing section
  boot: Move fdt_support to boot/
  Move fdt_simplefb to boot/
  boot: Move some other fdt-fixup options to the same menu
  boot: Rename Android-boot text
  Kconfig: Create a menu for FIT
  Kconfig: Move SPL_FIT under FIT
  spl: Tidy up load address in spl_ram
  boot: Make standard boot a menu
  Kconfig: Move TEXT_BASE et al under general setup
  Mark DISTRO_DEFAULTS as deprecated
  boot: Join FDT_FIXUP_PARTITIONS with related options
  boot: Drop CMD_MTDPARTS condition for FDT_FIXUP_PARTITIONS
  boot: Join ARCH_FIXUP_FDT_MEMORY with related options

 Kconfig |  67 ++-
 boot/Kconfig| 200 +---
 boot/Makefile   |   4 +
 {common => boot}/fdt_simplefb.c |   0
 {common => boot}/fdt_support.c  |   0
 common/Kconfig  |  20 
 common/Makefile |   4 -
 common/spl/spl_ram.c|  19 ++-
 doc/develop/bootstd.rst |  23 
 drivers/video/Kconfig   |  27 +
 drivers/video/Makefile  |   3 +
 {common => drivers/video}/bmp.c |   0
 lib/Kconfig |  17 +--
 lib/fwu_updates/Kconfig |   9 +-
 test/Kconfig|  12 +-
 15 files changed, 227 insertions(+), 178 deletions(-)
 rename {common => boot}/fdt_simplefb.c (100%)
 rename {common => boot}/fdt_support.c (100%)
 rename {common => drivers/video}/bmp.c (100%)

-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 02/20] Kconfig: Move API into general setup

2023-09-04 Thread Simon Glass
This is perhaps not a commonly used feature so should not have its own
option in the main menu. Move it under general setup.

Signed-off-by: Simon Glass 
---

(no changes since v1)

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

diff --git a/Kconfig b/Kconfig
index 91170bf8d223..0a2e97578dfc 100644
--- a/Kconfig
+++ b/Kconfig
@@ -585,10 +585,10 @@ config MP
  This provides an option to bringup different processors
  in multiprocessor cases.
 
-endmenu# General setup
-
 source "api/Kconfig"
 
+endmenu# General setup
+
 source "boot/Kconfig"
 
 source "common/Kconfig"
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 03/20] video: Move bmp code to drivers/video

2023-09-04 Thread Simon Glass
This relates to graphics which is only active when CONFIG_VIDEO is
enabled. Move it into that directory.

There is no harm in compiling it always, since it if not used it will
be dropped by the linker. So drop use of the BMP Kconfig.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Add new patch to move bmp code to drivers/video

 common/Makefile | 1 -
 drivers/video/Makefile  | 1 +
 {common => drivers/video}/bmp.c | 0
 3 files changed, 1 insertion(+), 1 deletion(-)
 rename {common => drivers/video}/bmp.c (100%)

diff --git a/common/Makefile b/common/Makefile
index f5c3d90f0675..0a3f75f2f1c8 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -45,7 +45,6 @@ endif # !CONFIG_SPL_BUILD
 
 obj-$(CONFIG_$(SPL_TPL_)BOOTSTAGE) += bootstage.o
 obj-$(CONFIG_$(SPL_TPL_)BLOBLIST) += bloblist.o
-obj-$(CONFIG_$(SPL_)BMP) += bmp.o
 
 ifdef CONFIG_SPL_BUILD
 ifdef CONFIG_SPL_DFU
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index d13af9f3b19b..6841d8965842 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_PANEL_HX8238D) += hx8238d.o
 obj-$(CONFIG_$(SPL_TPL_)SIMPLE_PANEL) += simple_panel.o
 
 obj-$(CONFIG_VIDEO_LOGO) += u_boot_logo.o
+obj-y += bmp.o
 
 endif
 
diff --git a/common/bmp.c b/drivers/video/bmp.c
similarity index 100%
rename from common/bmp.c
rename to drivers/video/bmp.c
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 04/20] video: Move the BMP options

2023-09-04 Thread Simon Glass
These appear prominently in the main menu at present. Move them to the
video Kconfig where they belong.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Just move these options to driver/video for later consideration

 common/Kconfig| 11 ---
 drivers/video/Kconfig | 16 
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index d916194b9423..d11292f52c2b 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1168,14 +1168,3 @@ config FDT_SIMPLEFB
 
 config IO_TRACE
bool
-
-config BMP
-   bool "Enable bmp image display"
-   help
- Enable bmp functions to display bmp image and get bmp info.
-
-config SPL_BMP
-   bool "Enable bmp image display at SPL"
-   depends on SPL_VIDEO
-   help
- Enable bmp functions to display bmp image and get bmp info at SPL.
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 09f2cb1a7321..4eeb8ce022a6 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -959,6 +959,14 @@ config SPLASH_SOURCE
 
 endif # SPLASH_SCREEN
 
+config BMP
+   bool
+   help
+ Enable bmp functions to display bmp image and get bmp info.
+
+ BMP is a simple graphics-image file format designed to store bitmap
+ images. It is primarily used on Windows devices.
+
 config VIDEO_BMP_GZIP
bool "Gzip compressed BMP image support"
depends on BMP || SPLASH_SCREEN
@@ -1162,6 +1170,14 @@ config SPL_SPLASH_SOURCE
 
 endif # SPL_SPLASH_SCREEN
 
+config SPL_BMP
+   bool
+   help
+ Enable bmp functions to display bmp image and get bmp info in SPL.
+
+ BMP is a simple graphics-image file format designed to store bitmap
+ images. It is primarily used on Windows devices.
+
 config SPL_VIDEO_BMP_GZIP
bool "Gzip compressed BMP image support at SPL"
depends on SPL_SPLASH_SCREEN || SPL_BMP
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 05/20] video: Move BMP options and code to video directory

2023-09-04 Thread Simon Glass
Put the options and the common BMP code with the other related Kconfig
options in the drivers/video directory.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/video/Kconfig  | 11 +++
 drivers/video/Makefile |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 4eeb8ce022a6..336508af6a57 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -682,6 +682,11 @@ config BACKLIGHT_LM3533
  LM3533 Lighting Power chip. Only Bank A is supported as for now.
  Supported backlight level range is from 2 to 255 with step of 1.
 
+config BMP
+   bool # Enable bmp image display
+   help
+ Enable bmp functions to display bmp image and get bmp info.
+
 source "drivers/video/ti/Kconfig"
 
 source "drivers/video/exynos/Kconfig"
@@ -1125,6 +1130,12 @@ config SPL_VIDEO_REMOVE
  if this  option is enabled video driver will be removed at the end of
  SPL stage, before loading the next stage.
 
+config SPL_BMP
+   bool # Enable bmp image display at SPL
+   depends on SPL_VIDEO
+   help
+ Enable bmp functions to display bmp image and get bmp info at SPL.
+
 if SPL_SPLASH_SCREEN
 
 config SPL_SPLASH_SCREEN_ALIGN
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 6841d8965842..88b37b1855c6 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -3,6 +3,8 @@
 # (C) Copyright 2000-2007
 # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 
+obj-$(CONFIG_$(SPL_)BMP) += bmp.o
+
 ifdef CONFIG_DM
 obj-$(CONFIG_$(SPL_TPL_)BACKLIGHT) += backlight-uclass.o
 obj-$(CONFIG_BACKLIGHT_GPIO) += backlight_gpio.o
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 06/20] FWU: Avoid showing an unselectable menu option

2023-09-04 Thread Simon Glass
Use a menuconfig to avoid showing a menu which cannot be selected in many
cases.

Signed-off-by: Simon Glass 
Acked-by: Sughosh Ganu 
Reviewed-by: Tom Rini 
---

Changes in v3:
- Drop comment about an update/ directory

Changes in v2:
- Fix FMU typo in the subject
- Drop now-unnecessary depends on FWU_MULTI_BANK_UPDATE

 lib/Kconfig | 4 
 lib/fwu_updates/Kconfig | 9 +
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index 9addcfab3734..bfab2f3165a7 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -1118,8 +1118,4 @@ config PHANDLE_CHECK_SEQ
 
 endmenu
 
-menu "FWU Multi Bank Updates"
-
 source lib/fwu_updates/Kconfig
-
-endmenu
diff --git a/lib/fwu_updates/Kconfig b/lib/fwu_updates/Kconfig
index 71f34793d926..d35247d0e5d4 100644
--- a/lib/fwu_updates/Kconfig
+++ b/lib/fwu_updates/Kconfig
@@ -1,4 +1,4 @@
-config FWU_MULTI_BANK_UPDATE
+menuconfig FWU_MULTI_BANK_UPDATE
bool "Enable FWU Multi Bank Update Feature"
depends on EFI_CAPSULE_ON_DISK
select PARTITION_TYPE_GUID
@@ -10,24 +10,25 @@ config FWU_MULTI_BANK_UPDATE
  multiple banks(copies) of the firmware images. One of the
  bank is selected for updating all the firmware components
 
+if FWU_MULTI_BANK_UPDATE
+
 config FWU_NUM_BANKS
int "Number of Banks defined by the platform"
-   depends on FWU_MULTI_BANK_UPDATE
help
  Define the number of banks of firmware images on a platform
 
 config FWU_NUM_IMAGES_PER_BANK
int "Number of firmware images per bank"
-   depends on FWU_MULTI_BANK_UPDATE
help
  Define the number of firmware images per bank. This value
  should be the same for all the banks.
 
 config FWU_TRIAL_STATE_CNT
int "Number of times system boots in Trial State"
-   depends on FWU_MULTI_BANK_UPDATE
default 3
help
  With FWU Multi Bank Update feature enabled, number of times
  the platform is allowed to boot in Trial State after an
  update.
+
+endif
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 07/20] test: Move POST under a renamed Testing section

2023-09-04 Thread Simon Glass
Rename Unit tests to Testing, since it is a stretch to describe some of
the tests as unit tests. Move POST there as well, so it doesn't show up
by itself in the top-level menu.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 test/Kconfig | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/test/Kconfig b/test/Kconfig
index 6e859fb7d0db..830245b6f9a9 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -1,9 +1,4 @@
-config POST
-   bool "Power On Self Test support"
-   help
- See doc/README.POST for more details
-
-menu "Unit tests"
+menu "Testing"
 
 config UNIT_TEST
bool "Unit tests"
@@ -110,4 +105,9 @@ source "test/lib/Kconfig"
 source "test/optee/Kconfig"
 source "test/overlay/Kconfig"
 
+config POST
+   bool "Power On Self Test support"
+   help
+ See doc/README.POST for more details
+
 endmenu
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 08/20] boot: Move fdt_support to boot/

2023-09-04 Thread Simon Glass
This relates to booting since it fixes up the devicetree for the OS. Move
it into the boot/ directory.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/Makefile  | 3 +++
 {common => boot}/fdt_support.c | 0
 common/Makefile| 2 --
 3 files changed, 3 insertions(+), 2 deletions(-)
 rename {common => boot}/fdt_support.c (100%)

diff --git a/boot/Makefile b/boot/Makefile
index 10f015722378..f15a161614ff 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_QFW) += bootmeth_qfw.o
 endif
 
 obj-y += image.o image-board.o
+
 obj-$(CONFIG_ANDROID_AB) += android_ab.o
 obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o image-android-dt.o
 
@@ -37,6 +38,8 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow_menu.o
 obj-$(CONFIG_$(SPL_TPL_)CEDIT) += cedit.o
 endif
 
+obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
+
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
 obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o
 obj-$(CONFIG_$(SPL_TPL_)FIT) += image-fit.o
diff --git a/common/fdt_support.c b/boot/fdt_support.c
similarity index 100%
rename from common/fdt_support.c
rename to boot/fdt_support.c
diff --git a/common/Makefile b/common/Makefile
index 0a3f75f2f1c8..0948721d0b47 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -18,7 +18,6 @@ obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
 obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o
 
 obj-$(CONFIG_FDT_SIMPLEFB) += fdt_simplefb.o
-obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
 obj-$(CONFIG_MII) += miiphyutil.o
 obj-$(CONFIG_CMD_MII) += miiphyutil.o
 obj-$(CONFIG_PHYLIB) += miiphyutil.o
@@ -51,7 +50,6 @@ ifdef CONFIG_SPL_DFU
 obj-$(CONFIG_DFU_OVER_USB) += dfu.o
 endif
 obj-$(CONFIG_SPL_NET) += miiphyutil.o
-obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
 
 obj-$(CONFIG_SPL_USB_HOST) += usb.o usb_hub.o
 obj-$(CONFIG_SPL_USB_STORAGE) += usb_storage.o
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 09/20] Move fdt_simplefb to boot/

2023-09-04 Thread Simon Glass
This relates to booting, so move it there. Create a new Kconfig menu for
things related to devicetree fixup.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/Kconfig| 16 
 boot/Makefile   |  1 +
 {common => boot}/fdt_simplefb.c |  0
 common/Kconfig  |  9 -
 common/Makefile |  1 -
 5 files changed, 17 insertions(+), 10 deletions(-)
 rename {common => boot}/fdt_simplefb.c (100%)

diff --git a/boot/Kconfig b/boot/Kconfig
index 86ccfd780312..025fa01d782c 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -1538,6 +1538,22 @@ config SPL_IMAGE_PRE_LOAD_SIG
 
 endmenu
 
+if OF_LIBFDT
+
+menu "Devicetree fixup"
+
+config FDT_SIMPLEFB
+   bool "FDT tools for simplefb support"
+   help
+ Enable the fdt tools to manage the simple fb nodes in device tree.
+ These functions can be used by board to indicate to the OS
+ the presence of the simple frame buffer with associated reserved
+ memory
+
+endmenu
+
+endif # OF_LIBFDT
+
 config USE_BOOTARGS
bool "Enable boot arguments"
help
diff --git a/boot/Makefile b/boot/Makefile
index f15a161614ff..6ce983b83fa4 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_$(SPL_TPL_)CEDIT) += cedit.o
 endif
 
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
+obj-$(CONFIG_$(SPL_TPL_)FDT_SIMPLEFB) += fdt_simplefb.o
 
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
 obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o
diff --git a/common/fdt_simplefb.c b/boot/fdt_simplefb.c
similarity index 100%
rename from common/fdt_simplefb.c
rename to boot/fdt_simplefb.c
diff --git a/common/Kconfig b/common/Kconfig
index d11292f52c2b..21eaa5e815f9 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1157,14 +1157,5 @@ config VPL_IMAGE_SIGN_INFO
 
 endif
 
-config FDT_SIMPLEFB
-   bool "FDT tools for simplefb support"
-   depends on OF_LIBFDT
-   help
- Enable the fdt tools to manage the simple fb nodes in device tree.
- These functions can be used by board to indicate to the OS
- the presence of the simple frame buffer with associated reserved
- memory
-
 config IO_TRACE
bool
diff --git a/common/Makefile b/common/Makefile
index 0948721d0b47..5c1617206f07 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -17,7 +17,6 @@ obj-y += board_r.o
 obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
 obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o
 
-obj-$(CONFIG_FDT_SIMPLEFB) += fdt_simplefb.o
 obj-$(CONFIG_MII) += miiphyutil.o
 obj-$(CONFIG_CMD_MII) += miiphyutil.o
 obj-$(CONFIG_PHYLIB) += miiphyutil.o
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 10/20] boot: Move some other fdt-fixup options to the same menu

2023-09-04 Thread Simon Glass
Move more options relating to fixing up a device tree into the new
devicetree-fixup menu.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/Kconfig | 55 +---
 1 file changed, 26 insertions(+), 29 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 025fa01d782c..70cbcc38fdd4 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -696,35 +696,6 @@ config SUPPORT_RAW_INITRD
  address of the initrd must be augmented by it's size, in the following
  format: ":".
 
-config OF_BOARD_SETUP
-   bool "Set up board-specific details in device tree before boot"
-   depends on OF_LIBFDT
-   help
- This causes U-Boot to call ft_board_setup() before booting into
- the Operating System. This function can set up various
- board-specific information in the device tree for use by the OS.
- The device tree is then passed to the OS.
-
-config OF_SYSTEM_SETUP
-   bool "Set up system-specific details in device tree before boot"
-   depends on OF_LIBFDT
-   help
- This causes U-Boot to call ft_system_setup() before booting into
- the Operating System. This function can set up various
- system-specific information in the device tree for use by the OS.
- The device tree is then passed to the OS.
-
-config OF_STDOUT_VIA_ALIAS
-   bool "Update the device-tree stdout alias from U-Boot"
-   depends on OF_LIBFDT
-   help
- This uses U-Boot's serial alias from the aliases node to update
- the device tree passed to the OS. The "linux,stdout-path" property
- in the chosen node is set to point to the correct serial node.
- This option currently references CONFIG_CONS_INDEX, which is
- incorrect when used with device tree as this option does not
- exist / should not be used.
-
 config HAVE_TEXT_BASE
bool
depends on !NIOS2 && !XTENSA
@@ -1542,6 +1513,32 @@ if OF_LIBFDT
 
 menu "Devicetree fixup"
 
+config OF_BOARD_SETUP
+   bool "Set up board-specific details in device tree before boot"
+   help
+ This causes U-Boot to call ft_board_setup() before booting into
+ the Operating System. This function can set up various
+ board-specific information in the device tree for use by the OS.
+ The device tree is then passed to the OS.
+
+config OF_SYSTEM_SETUP
+   bool "Set up system-specific details in device tree before boot"
+   help
+ This causes U-Boot to call ft_system_setup() before booting into
+ the Operating System. This function can set up various
+ system-specific information in the device tree for use by the OS.
+ The device tree is then passed to the OS.
+
+config OF_STDOUT_VIA_ALIAS
+   bool "Update the device-tree stdout alias from U-Boot"
+   help
+ This uses U-Boot's serial alias from the aliases node to update
+ the device tree passed to the OS. The "linux,stdout-path" property
+ in the chosen node is set to point to the correct serial node.
+ This option currently references CONFIG_CONS_INDEX, which is
+ incorrect when used with device tree as this option does not
+ exist / should not be used.
+
 config FDT_SIMPLEFB
bool "FDT tools for simplefb support"
help
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 11/20] boot: Rename Android-boot text

2023-09-04 Thread Simon Glass
Phrases like 'Enable support for' are pointless since this is an option
which enables things. Drop that part so it is easier to follow.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 70cbcc38fdd4..f603a64a23de 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -3,7 +3,7 @@ menu "Boot options"
 menu "Boot images"
 
 config ANDROID_BOOT_IMAGE
-   bool "Enable support for Android Boot Images"
+   bool "Android Boot Images"
default y if FASTBOOT
help
  This enables support for booting images which use the Android
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 12/20] Kconfig: Create a menu for FIT

2023-09-04 Thread Simon Glass
This is a major feature with a lot of options. Give it its own menu to
tidy up the 'make menuconfig' display. Drop the 'depends on FIT' pieces
which are now unnecessary, since they are now bracketed by an 'if FIT'.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/Kconfig | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index f603a64a23de..467bca706782 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -9,8 +9,8 @@ config ANDROID_BOOT_IMAGE
  This enables support for booting images which use the Android
  image format header.
 
-config FIT
-   bool "Support Flattened Image Tree"
+menuconfig FIT
+   bool "Flattened Image Tree (FIT)"
select HASH
select MD5
select SHA1
@@ -25,6 +25,8 @@ config FIT
  multiple configurations, verification through hashing and also
  verified boot (secure boot using RSA).
 
+if FIT
+
 config TIMESTAMP
bool "Show image date and time when displaying image information"
default y if CMD_DATE
@@ -38,7 +40,6 @@ config TIMESTAMP
 
 config FIT_EXTERNAL_OFFSET
hex "FIT external data offset"
-   depends on FIT
default 0x0
help
  This specifies a data offset in fit image.
@@ -49,7 +50,6 @@ config FIT_EXTERNAL_OFFSET
 
 config FIT_FULL_CHECK
bool "Do a full check of the FIT before using it"
-   depends on FIT
default y
help
  Enable this do a full check of the FIT to make sure it is valid. This
@@ -59,7 +59,7 @@ config FIT_FULL_CHECK
 
 config FIT_SIGNATURE
bool "Enable signature verification of FIT uImages"
-   depends on DM && FIT
+   depends on DM
select HASH
imply RSA
imply RSA_VERIFY
@@ -97,7 +97,7 @@ config FIT_RSASSA_PSS
 
 config FIT_CIPHER
bool "Enable ciphering data in a FIT uImages"
-   depends on DM && FIT
+   depends on DM
select AES
help
  Enable the feature of data ciphering/unciphering in the tool mkimage
@@ -105,7 +105,6 @@ config FIT_CIPHER
 
 config FIT_VERBOSE
bool "Show verbose messages when FIT images fail"
-   depends on FIT
help
  Generally a system will have valid FIT images so debug messages
  are a waste of code space. If you are debugging your images then
@@ -114,7 +113,6 @@ config FIT_VERBOSE
 
 config FIT_BEST_MATCH
bool "Select the best match for the kernel device tree"
-   depends on FIT
help
  When no configuration is explicitly selected, default to the
  one whose fdt's compatibility field best matches that of
@@ -124,7 +122,6 @@ config FIT_BEST_MATCH
 
 config FIT_IMAGE_POST_PROCESS
bool "Enable post-processing of FIT artifacts after loading by U-Boot"
-   depends on FIT
depends on SOCFPGA_SECURE_VAB_AUTH
help
  Allows doing any sort of manipulation to blobs after they got 
extracted
@@ -139,11 +136,12 @@ config FIT_IMAGE_POST_PROCESS
 
 config FIT_PRINT
 bool "Support FIT printing"
-   depends on FIT
 default y
 help
   Support printing the content of the fitImage in a verbose manner.
 
+endif # FIT
+
 config SPL_FIT
bool "Support Flattened Image Tree within SPL"
depends on SPL && FIT
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 13/20] Kconfig: Move SPL_FIT under FIT

2023-09-04 Thread Simon Glass
This option already depends on FIT, so put it under the same umbrella, so
that it appears in the FIT menu.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/Kconfig | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 467bca706782..c9b7d3f710b6 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -140,11 +140,9 @@ config FIT_PRINT
 help
   Support printing the content of the fitImage in a verbose manner.
 
-endif # FIT
-
 config SPL_FIT
bool "Support Flattened Image Tree within SPL"
-   depends on SPL && FIT
+   depends on SPL
select SPL_HASH
select SPL_OF_LIBFDT
 
@@ -195,7 +193,7 @@ config SPL_FIT_RSASSA_PSS
 
 config SPL_LOAD_FIT
bool "Enable SPL loading U-Boot as a FIT (basic fitImage features)"
-   depends on SPL && FIT
+   depends on SPL
select SPL_FIT
help
  Normally with the SPL framework a legacy image is generated as part
@@ -243,7 +241,6 @@ config SPL_LOAD_FIT_APPLY_OVERLAY_BUF_SZ
 
 config SPL_LOAD_FIT_FULL
bool "Enable SPL loading U-Boot as a FIT (full fitImage features)"
-   depends on FIT
select SPL_FIT
help
  Normally with the SPL framework a legacy image is generated as part
@@ -341,6 +338,8 @@ config VPL_FIT_SIGNATURE_MAX_SIZE
 
 endif # VPL
 
+endif # FIT
+
 config PXE_UTILS
bool
select MENU
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 14/20] spl: Tidy up load address in spl_ram

2023-09-04 Thread Simon Glass
This CONFIG is used but is not given a value by some boards. Use
a default value of 0 explicitly, rather than relying on the 0 value
provided by CONFIG_SPL_LOAD_FIT_ADDRESS

This will allow us to make SPL_LOAD_FIT_ADDRESS depend on SPL_LOAD_FIT
as it should.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/spl/spl_ram.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/common/spl/spl_ram.c b/common/spl/spl_ram.c
index 93cf420d810a..4158ed1c32d7 100644
--- a/common/spl/spl_ram.c
+++ b/common/spl/spl_ram.c
@@ -20,12 +20,16 @@
 static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
   ulong count, void *buf)
 {
-   ulong addr;
+   ulong addr = 0;
 
debug("%s: sector %lx, count %lx, buf %lx\n",
  __func__, sector, count, (ulong)buf);
 
-   addr = (ulong)CONFIG_SPL_LOAD_FIT_ADDRESS + sector;
+   if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
+   addr = IF_ENABLED_INT(CONFIG_SPL_LOAD_FIT,
+ CONFIG_SPL_LOAD_FIT_ADDRESS);
+   }
+   addr += sector;
if (CONFIG_IS_ENABLED(IMAGE_PRE_LOAD))
addr += image_load_offset;
 
@@ -38,20 +42,23 @@ static int spl_ram_load_image(struct spl_image_info 
*spl_image,
  struct spl_boot_device *bootdev)
 {
struct legacy_img_hdr *header;
+   ulong addr = 0;
int ret;
 
-   header = (struct legacy_img_hdr *)CONFIG_SPL_LOAD_FIT_ADDRESS;
+   if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
+   addr = IF_ENABLED_INT(CONFIG_SPL_LOAD_FIT,
+ CONFIG_SPL_LOAD_FIT_ADDRESS);
+   }
 
if (CONFIG_IS_ENABLED(IMAGE_PRE_LOAD)) {
-   unsigned long addr = (unsigned long)header;
ret = image_pre_load(addr);
 
if (ret)
return ret;
 
addr += image_load_offset;
-   header = (struct legacy_img_hdr *)addr;
}
+   header = map_sysmem(addr, 0);
 
 #if CONFIG_IS_ENABLED(DFU)
if (bootdev->boot_device == BOOT_DEVICE_DFU)
@@ -84,7 +91,7 @@ static int spl_ram_load_image(struct spl_image_info 
*spl_image,
u_boot_pos = 
(ulong)spl_get_load_buffer(-sizeof(*header),

sizeof(*header));
}
-   header = (struct legacy_img_hdr *)map_sysmem(u_boot_pos, 0);
+   header = map_sysmem(u_boot_pos, 0);
 
ret = spl_parse_image_header(spl_image, bootdev, header);
}
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 15/20] boot: Make standard boot a menu

2023-09-04 Thread Simon Glass
Collect these options into a menu for easier viewing.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/Kconfig | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index c9b7d3f710b6..17f54b926f05 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -372,8 +372,8 @@ config BOOT_DEFAULTS
  of U-Boot to boot various images. Currently much functionality is
  tied to enabling the command that exercises it.
 
-config BOOTSTD
-   bool "Standard boot support"
+menuconfig BOOTSTD
+   bool "Standard boot"
default y
depends on DM && OF_CONTROL && BLK
help
@@ -393,6 +393,8 @@ config BOOTSTD
U-Boot)
- bootflow - a description of how to boot (owned by the distro)
 
+if BOOTSTD
+
 config SPL_BOOTSTD
bool "Standard boot support in SPL"
depends on SPL && SPL_DM && SPL_OF_CONTROL && SPL_BLK
@@ -413,8 +415,6 @@ config VPL_BOOTSTD
  boot. It is enabled by default since the main purpose of VPL is to
  handle the firmware part of VBE.
 
-if BOOTSTD
-
 config BOOTSTD_FULL
bool "Enhanced features for standard boot"
default y if SANDBOX
@@ -673,7 +673,7 @@ config BOOTMETH_SCRIPT
  This provides a way to try out standard boot on an existing boot flow.
  It is not enabled by default to save space.
 
-endif
+endif # BOOTSTD
 
 config LEGACY_IMAGE_FORMAT
bool "Enable support for the legacy image format"
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 16/20] Kconfig: Move TEXT_BASE et al under general setup

2023-09-04 Thread Simon Glass
These don't relate to booting. Move them out of there and into the same
place as the other related settings.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 Kconfig  | 65 
 boot/Kconfig | 65 
 2 files changed, 65 insertions(+), 65 deletions(-)

diff --git a/Kconfig b/Kconfig
index 0a2e97578dfc..2d4b82149860 100644
--- a/Kconfig
+++ b/Kconfig
@@ -585,6 +585,71 @@ config MP
  This provides an option to bringup different processors
  in multiprocessor cases.
 
+config HAVE_TEXT_BASE
+   bool
+   depends on !NIOS2 && !XTENSA
+   depends on !EFI_APP
+   default y
+
+config TEXT_BASE
+   depends on HAVE_TEXT_BASE
+   default 0x0 if POSITION_INDEPENDENT
+   default 0x8080 if ARCH_OMAP2PLUS || ARCH_K3
+   default 0x8170 if MACH_SUNIV
+   default 0x2a00 if MACH_SUN9I
+   default 0x4a00 if SUNXI_MINIMUM_DRAM_MB >= 256
+   default 0x42e0 if SUNXI_MINIMUM_DRAM_MB >= 64
+   hex "Text Base"
+   help
+ The address in memory that U-Boot will be running from, initially.
+
+config HAVE_SYS_MONITOR_BASE
+   bool
+   depends on ARC || MIPS || M68K || NIOS2 || PPC || XTENSA || X86 \
+   || ENV_IS_IN_FLASH || MTD_NOR_FLASH
+   depends on !EFI_APP
+   default y
+
+config SYS_MONITOR_BASE
+   depends on HAVE_SYS_MONITOR_BASE
+   hex "Physical start address of boot monitor code"
+   default TEXT_BASE
+   help
+ The physical start address of boot monitor code (which is the same as
+ CONFIG_TEXT_BASE when linking) and the same as CFG_SYS_FLASH_BASE
+ when booting from flash.
+
+config SPL_SYS_MONITOR_BASE
+   depends on MPC85xx && SPL && HAVE_SYS_MONITOR_BASE
+   hex "Physical start address of SPL monitor code"
+   default SPL_TEXT_BASE
+
+config TPL_SYS_MONITOR_BASE
+   depends on MPC85xx && TPL && HAVE_SYS_MONITOR_BASE
+   hex "Physical start address of TPL monitor code"
+
+config DYNAMIC_SYS_CLK_FREQ
+   bool "Determine CPU clock frequency at run-time"
+   help
+ Implement a get_board_sys_clk function that will determine the CPU
+ clock frequency at run time, rather than define it statically.
+
+config SYS_CLK_FREQ
+   depends on !DYNAMIC_SYS_CLK_FREQ
+   int "CPU clock frequency"
+   default 12500 if ARCH_LS1012A
+   default 1 if ARCH_P2020 || ARCH_T1024 || ARCH_T1042 || \
+ARCH_LS1021A || FSL_LSCH2 || FSL_LSCH3
+   default  if ARCH_P1010 || ARCH_P1020 || ARCH_T4240
+   default  if ARCH_T2080
+   default  if RCAR_GEN3
+   default 2400 if ARCH_EXYNOS
+   default 2000 if RCAR_GEN2
+   default 0
+   help
+ A static value for the CPU frequency.  Note that if not required
+ for a given SoC, this can be left at 0.
+
 source "api/Kconfig"
 
 endmenu# General setup
diff --git a/boot/Kconfig b/boot/Kconfig
index 17f54b926f05..458512a4ade2 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -693,71 +693,6 @@ config SUPPORT_RAW_INITRD
  address of the initrd must be augmented by it's size, in the following
  format: ":".
 
-config HAVE_TEXT_BASE
-   bool
-   depends on !NIOS2 && !XTENSA
-   depends on !EFI_APP
-   default y
-
-config TEXT_BASE
-   depends on HAVE_TEXT_BASE
-   default 0x0 if POSITION_INDEPENDENT
-   default 0x8080 if ARCH_OMAP2PLUS || ARCH_K3
-   default 0x8170 if MACH_SUNIV
-   default 0x2a00 if MACH_SUN9I
-   default 0x4a00 if SUNXI_MINIMUM_DRAM_MB >= 256
-   default 0x42e0 if SUNXI_MINIMUM_DRAM_MB >= 64
-   hex "Text Base"
-   help
- The address in memory that U-Boot will be running from, initially.
-
-config HAVE_SYS_MONITOR_BASE
-   bool
-   depends on ARC || MIPS || M68K || NIOS2 || PPC || XTENSA || X86 \
-   || ENV_IS_IN_FLASH || MTD_NOR_FLASH
-   depends on !EFI_APP
-   default y
-
-config SYS_MONITOR_BASE
-   depends on HAVE_SYS_MONITOR_BASE
-   hex "Physical start address of boot monitor code"
-   default TEXT_BASE
-   help
- The physical start address of boot monitor code (which is the same as
- CONFIG_TEXT_BASE when linking) and the same as CFG_SYS_FLASH_BASE
- when booting from flash.
-
-config SPL_SYS_MONITOR_BASE
-   depends on MPC85xx && SPL && HAVE_SYS_MONITOR_BASE
-   hex "Physical start address of SPL monitor code"
-   default SPL_TEXT_BASE
-
-config TPL_SYS_MONITOR_BASE
-   depends on MPC85xx && TPL && HAVE_SYS_MONITOR_BASE
-   hex "Physical start address of TPL monitor code"
-
-config DYNAMIC_SYS_CLK_FREQ
-   bool "Determine CPU clock frequency at run-time"
-   help
- Implement a get_board_sys_clk function that will determine the CPU
- c

[PATCH v3 17/20] Mark DISTRO_DEFAULTS as deprecated

2023-09-04 Thread Simon Glass
Standard boot has been in place for a while now. Quite a few problems
have been found and fixed. It seems like a good time to mark the
script-based approach as deprecated and encourage people to use standard
boot.

Update the DISTRO_DEFAULTS Kconfig to encourage people to move to
standard boot, which is able to boot Linux distributions automatically.

Add a short migration guide to make this easier.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Drop extra newline and quote

Changes in v2:
- Mention in the DISTRO_DEFAULTS option that it is script-based
- Expand and rewrite the commit message
- Use the word 'Mark' instead of 'Make' to improve the English

 boot/Kconfig|  6 +-
 doc/develop/bootstd.rst | 23 +++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 458512a4ade2..08efecb13ef6 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -784,7 +784,7 @@ config SYS_BOOT_RAMDISK_HIGH
 endmenu# Boot images
 
 config DISTRO_DEFAULTS
-   bool "Select defaults suitable for booting general purpose Linux 
distributions"
+   bool "(deprecated) Script-based booting of Linux distributions"
select BOOT_DEFAULTS
select AUTO_COMPLETE
select CMDLINE_EDITING
@@ -792,6 +792,10 @@ config DISTRO_DEFAULTS
select HUSH_PARSER
select SYS_LONGHELP
help
+ Note: These scripts have been replaced by Standard Boot. Do not use
+ them on new boards. See 'Migrating from distro_boot' at
+ doc/develop/bootstd.rst
+
  Select this to enable various options and commands which are suitable
  for building u-boot for booting general purpose Linux distributions.
 
diff --git a/doc/develop/bootstd.rst b/doc/develop/bootstd.rst
index c01e0971dc84..ddcd05f931ad 100644
--- a/doc/develop/bootstd.rst
+++ b/doc/develop/bootstd.rst
@@ -458,6 +458,28 @@ readyFile was loaded and is ready for use. In this 
state the bootflow is
 ===  
===
 
 
+Migrating from distro_boot
+--
+
+To migrate from distro_boot:
+
+#. Update your board header files to remove the BOOTENV and BOOT_TARGET_xxx
+   defines. Standard boot finds available boot devices automatically.
+
+#. Remove the "boot_targets" variable unless you need it. Standard boot uses a
+   default order from fastest to slowest, which generally matches the order 
used
+   by boards.
+
+#. Make sure that CONFIG_BOOTSTD_DEFAULTS is enabled by your board, so it can
+   boot common Linux distributions.
+
+An example patch is at migrate_patch_.
+
+If you are using custom boot scripts for your board, consider creating your
+own bootmeth to hold the logic. There are various examples at
+`boot/bootmeth_...`.
+
+
 Theory of operation
 ---
 
@@ -769,3 +791,4 @@ Other ideas:
 .. _BootLoaderSpec: 
http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/
 .. _distro_boot: https://github.com/u-boot/u-boot/blob/master/boot/distro.c
 .. _bootflow_h: https://github.com/u-boot/u-boot/blob/master/include/bootflow.h
+.. _migrate_patch: 
https://patchwork.ozlabs.org/project/uboot/patch/20230727215433.578830-2-...@chromium.org/
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 18/20] boot: Join FDT_FIXUP_PARTITIONS with related options

2023-09-04 Thread Simon Glass
Move this to be with the other devicetree-fixup options.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/Kconfig | 8 
 lib/Kconfig  | 9 -
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 08efecb13ef6..a7dcd6b0ae07 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -1475,6 +1475,14 @@ config OF_STDOUT_VIA_ALIAS
  incorrect when used with device tree as this option does not
  exist / should not be used.
 
+config FDT_FIXUP_PARTITIONS
+   bool "overwrite MTD partitions in DTS through defined in 'mtdparts'"
+   depends on CMD_MTDPARTS
+   help
+ Allow overwriting defined partitions in the device tree blob
+ using partition info defined in the 'mtdparts' environment
+ variable.
+
 config FDT_SIMPLEFB
bool "FDT tools for simplefb support"
help
diff --git a/lib/Kconfig b/lib/Kconfig
index bfab2f3165a7..eb2b10161824 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -953,15 +953,6 @@ config VPL_OF_LIBFDT_ASSUME_MASK
  0xff means all assumptions are made and any invalid data may cause
  unsafe execution. See FDT_ASSUME_PERFECT, etc. in libfdt_internal.h
 
-config FDT_FIXUP_PARTITIONS
-   bool "overwrite MTD partitions in DTS through defined in 'mtdparts'"
-   depends on OF_LIBFDT
-   depends on CMD_MTDPARTS
-   help
- Allow overwriting defined partitions in the device tree blob
- using partition info defined in the 'mtdparts' environment
- variable.
-
 menu "System tables"
depends on (!EFI && !SYS_COREBOOT) || (ARM && EFI_LOADER)
 
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 19/20] boot: Drop CMD_MTDPARTS condition for FDT_FIXUP_PARTITIONS

2023-09-04 Thread Simon Glass
This is not needed, so drop it. Also use a capital 'O' for the option,
while we are here.

Signed-off-by: Simon Glass 
Suggested-by: Tom Rini 
---

Changes in v3:
- Add new patch to drop CMD_MTDPARTS condition for FDT_FIXUP_PARTITIONS

 boot/Kconfig | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index a7dcd6b0ae07..e8bc7dfddc77 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -1476,8 +1476,7 @@ config OF_STDOUT_VIA_ALIAS
  exist / should not be used.
 
 config FDT_FIXUP_PARTITIONS
-   bool "overwrite MTD partitions in DTS through defined in 'mtdparts'"
-   depends on CMD_MTDPARTS
+   bool "Overwrite MTD partitions in DTS through defined in 'mtdparts'"
help
  Allow overwriting defined partitions in the device tree blob
  using partition info defined in the 'mtdparts' environment
-- 
2.42.0.283.g2d96d420d3-goog



[PATCH v3 20/20] boot: Join ARCH_FIXUP_FDT_MEMORY with related options

2023-09-04 Thread Simon Glass
Move this to be with the other devicetree-fixup options.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Drop patch 'Move SYS_RX_ETH_BUFFER into the network menu'

 boot/Kconfig | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index e8bc7dfddc77..bd2e4aed3dd8 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -693,14 +693,6 @@ config SUPPORT_RAW_INITRD
  address of the initrd must be augmented by it's size, in the following
  format: ":".
 
-config ARCH_FIXUP_FDT_MEMORY
-   bool "Enable arch_fixup_memory_banks() call"
-   default y
-   help
- Enable FDT memory map syncup before OS boot. This feature can be
- used for booting OS with different memory setup where the part of
- the memory location should be used for different purpose.
-
 config CHROMEOS
bool "Support booting Chrome OS"
help
@@ -1490,6 +1482,14 @@ config FDT_SIMPLEFB
  the presence of the simple frame buffer with associated reserved
  memory
 
+config ARCH_FIXUP_FDT_MEMORY
+   bool "Enable arch_fixup_memory_banks() call"
+   default y
+   help
+ Enable FDT memory map syncup before OS boot. This feature can be
+ used for booting OS with different memory setup where the part of
+ the memory location should be used for different purpose.
+
 endmenu
 
 endif # OF_LIBFDT
-- 
2.42.0.283.g2d96d420d3-goog



Re: [PATCH v2] usb: host: ohci-generic: Make usage of clock/reset bulk() API

2023-09-04 Thread Xavier Drudis Ferran
El Mon, Sep 04, 2023 at 02:20:21PM +0200, Fabrice Gasnier deia:
> Make usage of clock and reset bulk API in order to simplify the code
> 
> Reviewed-by: Marek Vasut 

Reviewed-by: Xavier Drudis Ferran 

Sorry. I don't know why I used the wrong address before.

> Signed-off-by: Fabrice Gasnier 
> ---
> 
> Changes in v2:
> - fix copy/paste on dev_err message since Marek's review comment
> - add Marek's review tag
> 
> ---
>  drivers/usb/host/ohci-generic.c | 92 +++--
>  1 file changed, 29 insertions(+), 63 deletions(-)
> 
> diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
> index 2d8d38ce9a40..ceed1911a95a 100644
> --- a/drivers/usb/host/ohci-generic.c
> +++ b/drivers/usb/host/ohci-generic.c
> @@ -16,75 +16,41 @@
>  
>  struct generic_ohci {
>   ohci_t ohci;
> - struct clk *clocks; /* clock list */
> - struct reset_ctl *resets; /* reset list */
> + struct clk_bulk clocks; /* clock list */
> + struct reset_ctl_bulk resets; /* reset list */
>   struct phy phy;
> - int clock_count;/* number of clock in clock list */
> - int reset_count;/* number of reset in reset list */
>  };
>  
>  static int ohci_usb_probe(struct udevice *dev)
>  {
>   struct ohci_regs *regs = dev_read_addr_ptr(dev);
>   struct generic_ohci *priv = dev_get_priv(dev);
> - int i, err, ret, clock_nb, reset_nb;
> -
> - err = 0;
> - priv->clock_count = 0;
> - clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells",
> -0);
> - if (clock_nb > 0) {
> - priv->clocks = devm_kcalloc(dev, clock_nb, sizeof(struct clk),
> - GFP_KERNEL);
> - if (!priv->clocks)
> - return -ENOMEM;
> -
> - for (i = 0; i < clock_nb; i++) {
> - err = clk_get_by_index(dev, i, &priv->clocks[i]);
> - if (err < 0)
> - break;
> -
> - err = clk_enable(&priv->clocks[i]);
> - if (err && err != -ENOSYS) {
> - dev_err(dev, "failed to enable clock %d\n", i);
> - clk_free(&priv->clocks[i]);
> - goto clk_err;
> - }
> - priv->clock_count++;
> - }
> - } else if (clock_nb != -ENOENT) {
> - dev_err(dev, "failed to get clock phandle(%d)\n", clock_nb);
> - return clock_nb;
> + int err, ret;
> +
> + ret = clk_get_bulk(dev, &priv->clocks);
> + if (ret && ret != -ENOENT) {
> + dev_err(dev, "Failed to get clocks (ret=%d)\n", ret);
> + return ret;
> + }
> +
> + err = clk_enable_bulk(&priv->clocks);
> + if (err) {
> + dev_err(dev, "Failed to enable clocks (err=%d)\n", err);
> + goto clk_err;
>   }
>  
> - priv->reset_count = 0;
> - reset_nb = dev_count_phandle_with_args(dev, "resets", "#reset-cells",
> -0);
> - if (reset_nb > 0) {
> - priv->resets = devm_kcalloc(dev, reset_nb,
> - sizeof(struct reset_ctl),
> - GFP_KERNEL);
> - if (!priv->resets)
> - return -ENOMEM;
> -
> - for (i = 0; i < reset_nb; i++) {
> - err = reset_get_by_index(dev, i, &priv->resets[i]);
> - if (err < 0)
> - break;
> -
> - err = reset_deassert(&priv->resets[i]);
> - if (err) {
> - dev_err(dev, "failed to deassert reset %d\n", 
> i);
> - reset_free(&priv->resets[i]);
> - goto reset_err;
> - }
> - priv->reset_count++;
> - }
> - } else if (reset_nb != -ENOENT) {
> - dev_err(dev, "failed to get reset phandle(%d)\n", reset_nb);
> + err = reset_get_bulk(dev, &priv->resets);
> + if (err && err != -ENOENT) {
> + dev_err(dev, "failed to get resets (err=%d)\n", err);
>   goto clk_err;
>   }
>  
> + err = reset_deassert_bulk(&priv->resets);
> + if (err) {
> + dev_err(dev, "failed to deassert resets (err=%d)\n", err);
> + goto reset_err;
> + }
> +
>   err = generic_setup_phy(dev, &priv->phy, 0);
>   if (err)
>   goto reset_err;
> @@ -101,13 +67,13 @@ phy_err:
>   dev_err(dev, "failed to shutdown usb phy\n");
>  
>  reset_err:
> - ret = reset_release_all(priv->resets, priv->reset_count);
> + ret = reset_release_bulk(&priv->resets);
>   if (ret)
> - dev_err(dev, "failed to assert all resets\n");
> + dev_err(dev, "failed to release rese

Re: [PATCH v2 19/19] boot: Join ARCH_FIXUP_FDT_MEMORY with related options

2023-09-04 Thread Simon Glass
Hi Tom,

On Thu, 31 Aug 2023 at 08:01, Tom Rini  wrote:
>
> On Wed, Aug 30, 2023 at 09:53:13PM -0600, Simon Glass wrote:
> > Move this to be with the other devicetree-fixup options.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
> >  boot/Kconfig | 16 
> >  1 file changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/boot/Kconfig b/boot/Kconfig
> > index 023446130282..257f4cc085e1 100644
> > --- a/boot/Kconfig
> > +++ b/boot/Kconfig
> > @@ -693,14 +693,6 @@ config SUPPORT_RAW_INITRD
> > address of the initrd must be augmented by it's size, in the 
> > following
> > format: ":".
> >
> > -config ARCH_FIXUP_FDT_MEMORY
> > - bool "Enable arch_fixup_memory_banks() call"
> > - default y
> > - help
> > -   Enable FDT memory map syncup before OS boot. This feature can be
> > -   used for booting OS with different memory setup where the part of
> > -   the memory location should be used for different purpose.
> > -
> >  config CHROMEOS
> >   bool "Support booting Chrome OS"
> >   help
> > @@ -1492,6 +1484,14 @@ config FDT_SIMPLEFB
> > the presence of the simple frame buffer with associated reserved
> > memory
> >
> > +config ARCH_FIXUP_FDT_MEMORY
> > + bool "Enable arch_fixup_memory_banks() call"
> > + default y
> > + help
> > +   Enable FDT memory map syncup before OS boot. This feature can be
> > +   used for booting OS with different memory setup where the part of
> > +   the memory location should be used for different purpose.
> > +
> >  endmenu
> >
> >  endif # OF_LIBFDT
>
> It seems like fixups are mixed in with other changes in this menu when
> we should probably keep the fixups lumped together at least.

>From what I can tell all of the things I am putting in this menu
relate to DT fixups. The naming is a bit odd though, on some of them.

Regards,
Simon


Re: [PATCH 1/3] xilinx: versal-net: Do not setup boot_targets if driver is not enabled

2023-09-04 Thread Simon Glass
Hi Venkatesh,

On Mon, 4 Sept 2023 at 07:58, Venkatesh Yadav Abbarapu
 wrote:
>
> SOC can boot in the device which is not accessible from APU and running
> this is detected as error which ends up in stopping boot process.
> Boot mode detection and logic around is present to setup priority
> on boot devices that SOC boot device is likely also used for booting OS.
> Change logic to detect this case with showing message about it but don't
> fail in boot process and don't prioritize boot device in this case.
>
> Signed-off-by: Michal Simek 
> Signed-off-by: Venkatesh Yadav Abbarapu 
> ---
>  board/xilinx/versal-net/board.c | 76 -
>  1 file changed, 38 insertions(+), 38 deletions(-)
>

If you switch to standard boot it won't try to boot on devices which
don't exist.

Regards,
Simon


Re: [PATCH v2 19/19] boot: Join ARCH_FIXUP_FDT_MEMORY with related options

2023-09-04 Thread Tom Rini
On Mon, Sep 04, 2023 at 08:43:12AM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On Thu, 31 Aug 2023 at 08:01, Tom Rini  wrote:
> >
> > On Wed, Aug 30, 2023 at 09:53:13PM -0600, Simon Glass wrote:
> > > Move this to be with the other devicetree-fixup options.
> > >
> > > Signed-off-by: Simon Glass 
> > > ---
> > >
> > > (no changes since v1)
> > >
> > >  boot/Kconfig | 16 
> > >  1 file changed, 8 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/boot/Kconfig b/boot/Kconfig
> > > index 023446130282..257f4cc085e1 100644
> > > --- a/boot/Kconfig
> > > +++ b/boot/Kconfig
> > > @@ -693,14 +693,6 @@ config SUPPORT_RAW_INITRD
> > > address of the initrd must be augmented by it's size, in the 
> > > following
> > > format: ":".
> > >
> > > -config ARCH_FIXUP_FDT_MEMORY
> > > - bool "Enable arch_fixup_memory_banks() call"
> > > - default y
> > > - help
> > > -   Enable FDT memory map syncup before OS boot. This feature can be
> > > -   used for booting OS with different memory setup where the part of
> > > -   the memory location should be used for different purpose.
> > > -
> > >  config CHROMEOS
> > >   bool "Support booting Chrome OS"
> > >   help
> > > @@ -1492,6 +1484,14 @@ config FDT_SIMPLEFB
> > > the presence of the simple frame buffer with associated reserved
> > > memory
> > >
> > > +config ARCH_FIXUP_FDT_MEMORY
> > > + bool "Enable arch_fixup_memory_banks() call"
> > > + default y
> > > + help
> > > +   Enable FDT memory map syncup before OS boot. This feature can be
> > > +   used for booting OS with different memory setup where the part of
> > > +   the memory location should be used for different purpose.
> > > +
> > >  endmenu
> > >
> > >  endif # OF_LIBFDT
> >
> > It seems like fixups are mixed in with other changes in this menu when
> > we should probably keep the fixups lumped together at least.
> 
> From what I can tell all of the things I am putting in this menu
> relate to DT fixups. The naming is a bit odd though, on some of them.

OK, thanks.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 02/14] lmb: Rename interior piece to area

2023-09-04 Thread Simon Glass
Hi Heinrich,

On Fri, 1 Sept 2023 at 08:29, Simon Glass  wrote:
>
> Hi Heinrich,
>
> On Fri, 1 Sept 2023 at 00:16, Heinrich Schuchardt  wrote:
> >
> > On 9/1/23 03:13, Simon Glass wrote:
> > > The lmb data structures use the word 'region' to describe the region in
> > > which the allocations happen, as well as the individual allocations in
> > > that region. The interior structure is called lmb_property but is
> > > described as a region.
> > >
> > > This is quite confusing. One of the reviewers in v1 asked why we are using
> > > a property to describe a region!
> >
> > We currently have:
> >
> > struct lmb_region - Description of a set of region.
> > struct lmb_property - Description of one region.
> >
> > The word 'region' implies that it is contiguous, while 'region set'
> > implies that its members might not be contiguous.
>
> From what I can tell, the areas inside a region are contiguous. The
> code is so badly commented that it is hard to know what the intent
> was.
>
> Actually I just looked it up and found it came from Linux, so I
> suppose that explains the lack of comments. There it has been renamed
> memblock.
>
> Could you take a look and see if we could adopt the same naming?

I am waiting for your thoughts on this one.

>
> >
> > Calling a set region is what starts the confusion.
> >
> > Your patch is creating new confusion by calling a member of "a set of
> > regions" "area".
> >
> > Please, rename as follows:
> >
> > lmb_region -> lmb_region_set
>
> That sounds like it sets a region
>
> > lmb_property -> lmb_region
> >
> > The comments below are only valid if you stick with area which I
> > strongly discourage.
>
> Fair enough, I don't like it much either.
>
[..]

Regards,
Simon


Binman how to build using Rockchip BL32 binary as OP-TEE

2023-09-04 Thread Massimo Pegorer
Hi,

Is there any way for binman to package FIT with U-Boot TF-A and
OP-TEE, using bl32 binary provided by Rockchip as TEE?

I've tried with TEE=/path/to/rkbin/bin/rk33/xxx_bl32_vX.YZ.bin, but
binman failed.

In my poor understanding of Python code, it seems binman accepts only
ELF format or a binary format starting with optee_v1_header, but
binaries provided by Rockchip in rkbin repository do not have this
header.

Thanks in advance for any hints!

Massimo


[PATCH 1/6] board: gateworks: venice: fix gw7904

2023-09-04 Thread sbabic
> Add missing imx8mm-venice-gw7904 to CONFIG_OF_LIST
> Fixes commit 61e7f9732565 ("board: gateworks: venice: add imx8mm-gw7904 
> support")
> Signed-off-by: Tim Harvey 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] ARM: imx: Select 2 DRAM banks on Data Modul i.MX8M Mini eDM SBC

2023-09-04 Thread sbabic
> U-Boot splits DRAM bank spanning addresses below and above the 32bit
> boundary into two DRAM banks. Since this platform may come with 4GiB
> of DRAM, increase the DRAM bank count to 2.
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] ARM: imx: Use default SAVED_DRAM_TIMING_BASE on DH i.MX8M Plus DHCOM

2023-09-04 Thread sbabic
> Use default SAVED_DRAM_TIMING_BASE as that is what upstream TFA expects.
> Without this change, the board will fail to suspend/resume e.g. in Linux.
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH 1/2] ARM: imx: Use default SAVED_DRAM_TIMING_BASE on Data Modul i.MX8M Mini eDM SBC

2023-09-04 Thread sbabic
> Use default SAVED_DRAM_TIMING_BASE as that is what upstream TFA expects.
> Without this change, the board will fail to suspend/resume e.g. in Linux.
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH 2/2] ARM: imx: Use default SAVED_DRAM_TIMING_BASE on Data Modul i.MX8M Plus eDM SBC

2023-09-04 Thread sbabic
> Use default SAVED_DRAM_TIMING_BASE as that is what upstream TFA expects.
> Without this change, the board will fail to suspend/resume e.g. in Linux.
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] ARM: imx: Drop CONFIG_USE_BOOTCOMMAND=n on i.MX6 DHSOM

2023-09-04 Thread sbabic
> This board certainly does use default 'run distro_bootcmd' boot command,
> make sure this is set in 'bootcmd' variable.
> Fixes: 970bf8603b8 ("Convert CONFIG_USE_BOOTCOMMAND et al to Kconfig")
> Signed-off-by: Marek Vasut 
> Reviewed-by: Tom Rini 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH v2] arm: imx: imx8m: imx9: Fix DRAM size calculation due to rom_pointer

2023-09-04 Thread sbabic
> If dram_init_banksize() is called from SPL, the rom_pointer, at that
> point, is not correctly initialized. This causes wrong calculation of
> DRAM start and size in dram_init_banksize(). The issue became apparent
> only in Falcon Mode. Added an extra condition to prevent using
> rom_pointer in SPL.
> Signed-off-by: Elena Popa 
> Reviewed-by: Marek Vasut 
> Reviewed-by: Fabio Estevam 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] event.h: Documented some newly added portions better

2023-09-04 Thread Tom Rini
After the merge of v2023.10-rc4 to next include/event.h needs to be
fully documented in order for documentation builds to complete.  Rewords
two of the event_t descriptions to be docbook style and better match the
rest of this enum.  Fix two typos (flag->flags) in other comments.

Signed-off-by: Tom Rini 
---
 include/event.h | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/event.h b/include/event.h
index c37deae94527..311df878c4a5 100644
--- a/include/event.h
+++ b/include/event.h
@@ -94,18 +94,19 @@ enum event_t {
 */
EVT_MISC_INIT_F,
 
-   /*
-* Emitted before relocation to set up Firmware Support Package
-*
+   /**
+* @EVT_FSP_INIT_F:
+* This event is triggered before relocation to set up Firmware Support
+* Package.
 * Where U-Boot relies on binary blobs to handle part of the system
 * init, this event can be used to set up the blobs. This is used on
 * some Intel platforms
 */
EVT_FSP_INIT_F,
 
-   /*
-* Emitted just before jumping to the main loop
-*
+   /**
+* @EVT_LAST_STAGE_INIT:
+* This event is triggered just before jumping to the main loop.
 * Some boards need to perform initialisation immediately before control
 * is passed to the command-line interpreter (e.g. for init that depend
 * on later phases in the init sequence).
@@ -222,7 +223,7 @@ typedef int (*event_handler_simple_t)(void);
  *
  * @func: Function to call when the event is activated (must be first)
  * @type: Event type
- * @flag: Flags for this spy
+ * @flags: Flags for this spy
  * @id: Event id string
  */
 struct evspy_info {
@@ -241,7 +242,7 @@ struct evspy_info {
  *
  * @func: Function to call when the event is activated (must be first)
  * @type: Event type
- * @flag: Flags for this spy
+ * @flags: Flags for this spy
  * @id: Event id string
  */
 struct evspy_info_simple {
-- 
2.34.1



Re: [PATCH] event.h: Documented some newly added portions better

2023-09-04 Thread Tom Rini
On Mon, Sep 04, 2023 at 11:21:20AM -0400, Tom Rini wrote:

> After the merge of v2023.10-rc4 to next include/event.h needs to be
> fully documented in order for documentation builds to complete.  Rewords
> two of the event_t descriptions to be docbook style and better match the
> rest of this enum.  Fix two typos (flag->flags) in other comments.
> 
> Signed-off-by: Tom Rini 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCHv7 04/15] net/lwip: implement dhcp cmd

2023-09-04 Thread Maxim Uvarov
On Wed, 23 Aug 2023 at 00:58, Simon Glass  wrote:

> Hi Maxim,
>
> On Tue, 22 Aug 2023 at 03:39, Maxim Uvarov 
> wrote:
> >
> > U-Boot recently got support for an alternative network stack using LWIP.
> > Replace dhcp command with the LWIP variant while keeping the output and
> > error messages identical.
> >
> > Signed-off-by: Maxim Uvarov 
> > ---
> >  include/net/lwip.h | 12 +++
> >  net/lwip/Makefile  |  1 +
> >  net/lwip/apps/dhcp/lwip-dhcp.c | 62 ++
> >  3 files changed, 75 insertions(+)
> >  create mode 100644 net/lwip/apps/dhcp/lwip-dhcp.c
> >
> > diff --git a/include/net/lwip.h b/include/net/lwip.h
> > index cda896d062..240ebba354 100644
> > --- a/include/net/lwip.h
> > +++ b/include/net/lwip.h
> > @@ -17,3 +17,15 @@ int do_lwip_dns(struct cmd_tbl *cmdtp, int flag, int
> argc,
> >   * Other value < 0, if error
> >   */
> >  int ulwip_dns(char *name, char *varname);
> > +
> > +/**
> > + * ulwip_dhcp() -  create the DHCP request to obtain IP address.
> > + *
> > + * This function creates the DHCP request to obtain IP address. If DHCP
> server
> > + * returns file name, this file will be downloaded with tftp.  After
> this
> > + * function you need to invoke the polling loop to process network
> communication.
> > + *
> > + * Returns: 0 if success
> > + * Other value < 0, if error
>
> So this is an errno value from errno.h ?
>
>
No.  In this version it's what lwip returned. I can replace it with:
return dhcp_start(netif) ? 0 : -EPERM;
to not provide on upper layer lwip internal things.



> > +*/
> > +int ulwip_dhcp(void);
> > diff --git a/net/lwip/Makefile b/net/lwip/Makefile
> > index 6d2c00605b..59323fb325 100644
> > --- a/net/lwip/Makefile
> > +++ b/net/lwip/Makefile
> > @@ -65,4 +65,5 @@ obj-$(CONFIG_NET) += $(LWIPDIR)/netif/ethernet.o
> >  obj-$(CONFIG_NET) += port/if.o
> >  obj-$(CONFIG_NET) += port/sys-arch.o
> >
> > +obj-$(CONFIG_CMD_DHCP) += apps/dhcp/lwip-dhcp.o
> >  obj-$(CONFIG_CMD_DNS) += apps/dns/lwip-dns.o
> > diff --git a/net/lwip/apps/dhcp/lwip-dhcp.c
> b/net/lwip/apps/dhcp/lwip-dhcp.c
> > new file mode 100644
> > index 00..cce1e367f9
> > --- /dev/null
> > +++ b/net/lwip/apps/dhcp/lwip-dhcp.c
> > @@ -0,0 +1,62 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +
> > +/*
> > + * (C) Copyright 2023 Linaro Ltd. 
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +
> > +static struct dhcp dhcp;
>
> Can we keep the state in the uclass?
>
>
I found a good way to avoid this static. If dhcp_set_struct() is not called
this struct is malloced, later it can be accessed as code bellow.


> > +
> > +static int ulwip_dhcp_tmo(void)
> > +{
> > +   switch (dhcp.state) {
> > +   case DHCP_STATE_BOUND:
> > +   env_set("bootfile", dhcp.boot_file_name);
> > +   env_set("ipaddr", ip4addr_ntoa(&dhcp.offered_ip_addr));
> > +   env_set("netmask", ip4addr_ntoa(&dhcp.offered_sn_mask));
> > +   env_set("serverip", ip4addr_ntoa(&dhcp.server_ip_addr));
>
> Please check errors throughout your patches. Use the
> netif_get_client_data() as in code bellow and do not pass
>
>
yep.


> > +   printf("DHCP client bound to address %s\n",
> ip4addr_ntoa(&dhcp.offered_ip_addr));
> > +   break;
> > +   default:
> > +   return -1;
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> > +int ulwip_dhcp(void)
> > +{
> > +   int err;
> > +   struct netif *netif;
> > +   int eth_idx;
> > +
> > +   eth_idx = eth_get_dev_index();
> > +   if (eth_idx < 0) {
> > +   log_err("no eth idx\n");
> > +   return -1;
>
> That is -EPERM...please use a suitable error, perhaps -ENOENT?
>
> > +   }
> > +
> > +   netif = netif_get_by_index(eth_idx + 1);
> > +   if (!netif)
> > +   return -1;
> > +
> > +   ulwip_set_tmo(ulwip_dhcp_tmo);
> > +
> > +   if (!netif_get_client_data(netif,
> LWIP_NETIF_CLIENT_DATA_INDEX_DHCP))
> > +   dhcp_set_struct(netif, &dhcp);
> > +
> > +   err = dhcp_start(netif);
> > +   if (err)
> > +   log_err("dhcp_start error %d\n", err);
>
> Ideally the caller would print the errors. We try to have commands do
> that, since then it allows silent running for things which want it. It
> also helps with code size.
>
>
ok.

> > +
> > +   return err;
> > +}
> > --
> > 2.30.2
> >
>
> Regards,
> Simon
>


Re: [PATCH v2 15/17] usb: gadget: ether: Use plain udevice for UDC controller interaction

2023-09-04 Thread Mattijs Korpershoek
On lun., sept. 04, 2023 at 11:10, Marek Vasut  wrote:

> On 9/4/23 09:56, Mattijs Korpershoek wrote:
>> On ven., sept. 01, 2023 at 11:50, Marek Vasut  wrote:
>> 
>>> Convert to plain udevice interaction with UDC controller
>>> device, avoid the use of UDC uclass dev_array .
>>>
>>> Signed-off-by: Marek Vasut 
>>> ---
>>> Cc: Angus Ainslie 
>>> Cc: Dmitrii Merkurev 
>>> Cc: Eddie Cai 
>>> Cc: Kever Yang 
>>> Cc: Lukasz Majewski 
>>> Cc: Miquel Raynal 
>>> Cc: Mattijs Korpershoek 
>>> Cc: Nishanth Menon 
>>> Cc: Patrice Chotard 
>>> Cc: Patrick Delaunay 
>>> Cc: Philipp Tomsich 
>>> Cc: Simon Glass 
>>> Cc: Stefan Roese 
>>> Cc: ker...@puri.sm
>>> ---
>>> V2: Use udev->parent for UDC access
>>> ---
>>>   drivers/usb/gadget/ether.c | 20 +++-
>>>   1 file changed, 11 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
>>> index 5ff06d3814b..11b1a6221b3 100644
>>> --- a/drivers/usb/gadget/ether.c
>>> +++ b/drivers/usb/gadget/ether.c
>>> @@ -1880,8 +1880,10 @@ static void eth_start(struct eth_dev *dev, gfp_t 
>>> gfp_flags)
>>> }
>>>   }
>>>   
>>> -static int eth_stop(struct eth_dev *dev)
>>> +static int eth_stop(struct udevice *udev)
>>>   {
>>> +   struct ether_priv *priv = dev_get_priv(udev);
>>> +   struct eth_dev *dev = &priv->ethdev;
>>>   #ifdef RNDIS_COMPLETE_SIGNAL_DISCONNECT
>>> unsigned long ts;
>>> unsigned long timeout = CONFIG_SYS_HZ; /* 1 sec to stop RNDIS */
>>> @@ -1895,7 +1897,7 @@ static int eth_stop(struct eth_dev *dev)
>>> /* Wait until host receives OID_GEN_MEDIA_CONNECT_STATUS */
>>> ts = get_timer(0);
>>> while (get_timer(ts) < timeout)
>>> -   usb_gadget_handle_interrupts(0);
>>> +   dm_usb_gadget_handle_interrupts(udev->parent);
>>>   #endif
>>>   
>>> rndis_uninit(dev->rndis_config);
>>> @@ -2300,7 +2302,7 @@ static int usb_eth_start(struct udevice *udev)
>>> pr_err("The remote end did not respond in time.");
>>> goto fail;
>>> }
>>> -   usb_gadget_handle_interrupts(0);
>>> +   dm_usb_gadget_handle_interrupts(udev->parent);
>>> }
>>>   
>>> packet_received = 0;
>>> @@ -2370,7 +2372,7 @@ static int usb_eth_send(struct udevice *udev, void 
>>> *packet, int length)
>>> printf("timeout sending packets to usb ethernet\n");
>>> return -1;
>>> }
>>> -   usb_gadget_handle_interrupts(0);
>>> +   dm_usb_gadget_handle_interrupts(udev->parent);
>>> }
>>> free(rndis_pkt);
>>>   
>>> @@ -2400,13 +2402,13 @@ static void usb_eth_stop(struct udevice *udev)
>>>  * 2) 'pullup' callback in your UDC driver can be improved to perform
>>>  * this deinitialization.
>>>  */
>>> -   eth_stop(dev);
>>> +   eth_stop(udev);
>>>   
>>> usb_gadget_disconnect(dev->gadget);
>>>   
>>> /* Clear pending interrupt */
>>> if (dev->network_started) {
>>> -   usb_gadget_handle_interrupts(0);
>>> +   dm_usb_gadget_handle_interrupts(udev->parent);
>>> dev->network_started = 0;
>>> }
>>>   }
>>> @@ -2416,7 +2418,7 @@ static int usb_eth_recv(struct udevice *dev, int 
>>> flags, uchar **packetp)
>>> struct ether_priv *priv = dev_get_priv(dev);
>>> struct eth_dev *ethdev = &priv->ethdev;
>>>   
>>> -   usb_gadget_handle_interrupts(0);
>>> +   dm_usb_gadget_handle_interrupts(dev->parent);
>>>   
>>> if (packet_received) {
>>> if (ethdev->rx_req) {
>>> @@ -2467,7 +2469,7 @@ int usb_ether_init(void)
>>> return ret;
>>> }
>>>   
>>> -   return usb_gadget_initialize(0);
>>> +   return 0;
>> 
>> No udc_device_get() here?
>> 
>> This looks a little suspicious, because in the unbind() we call
>> udc_device_put().
>
> Look at how udc_device_get_by_index() is implemented and what it does, 
> compared to what usb_ether_init() does (hint: they are basically doing 
> the same thing). This udc_device_put() here is only a workaround for 
> platforms which are not using the bind command to bind USB ethernet yet.

Oh right. Thank you for explaining.

Reviewed-by: Mattijs Korpershoek 


[PATCH] buildman: Fix full help for Python 3.8

2023-09-04 Thread Simon Glass
With Python versions older than 3.9 Buildman produces an error on
start-up. Fix this with a workaround for importlib.

There is already a workaround for v3.6 but I am not sure if that is still
functioning.

Signed-off-by: Simon Glass 
---

 tools/buildman/main.py | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/buildman/main.py b/tools/buildman/main.py
index 5f42a58ddbb3..3cf877e5e688 100755
--- a/tools/buildman/main.py
+++ b/tools/buildman/main.py
@@ -7,7 +7,7 @@
 """See README for more information"""
 
 try:
-from importlib.resources import files
+import importlib.resources
 except ImportError:
 # for Python 3.6
 import importlib_resources
@@ -83,7 +83,13 @@ def run_buildman():
 run_test_coverage()
 
 elif args.full_help:
-tools.print_full_help(str(files('buildman').joinpath('README.rst')))
+if hasattr(importlib.resources, 'files'):
+dirpath = importlib.resources.files('buildman')
+tools.print_full_help(str(dirpath.joinpath('README.rst')))
+else:
+with importlib.resources.path('buildman', 'README.rst') as readme:
+tools.print_full_help(str(readme))
+
 
 # Build selected commits for selected boards
 else:
-- 
2.42.0.283.g2d96d420d3-goog



Re: [PATCH] arm: dts: k3-j7*: ddr: Update to 0.10 version of DDR config tool

2023-09-04 Thread Bryan Brattlof
Hi Neha!

On August 28, 2023 thus sayeth Neha Malcom Francis:
> Update the DDR settings to those generated using 0.10 version of Jacinto
> 7 DDRSS Register Configuration tool.
> 
> Signed-off-by: Neha Malcom Francis 
> ---
>  arch/arm/dts/k3-j721e-ddr-evm-lp4-4266.dtsi  |  98 ++--
>  arch/arm/dts/k3-j721s2-ddr-evm-lp4-4266.dtsi | 464 +--
>  2 files changed, 281 insertions(+), 281 deletions(-)

Reviewed-by: Bryan Brattlof 

This works for me :)

~Bryan


Re: [PATCH v2] usb: check for companion controller in uclass

2023-09-04 Thread Fabrice Gasnier
On 9/4/23 15:54, Marek Vasut wrote:
> On 9/4/23 14:34, Fabrice Gasnier wrote:
>> On 9/1/23 18:00, Marek Vasut wrote:
>>> On 9/1/23 14:12, Fabrice Gasnier wrote:
 On 9/1/23 12:48, Marek Vasut wrote:
> On 9/1/23 11:52, Fabrice Gasnier wrote:
>> EHCI is usually used with companion controller (like OHCI) as
>> companion
>> controller. This information on the companion is missing currently in
>> companion drivers.
>> So, if the usb-uclass isn't aware, it may scan busses in any order:
>> OHCI
>> first, then EHCI.
>> This is seen on STM32MP1 where DT probing makes the probe order to
>> occur
>> by increasing address (OHCI address < EHCI address).
>>
>> When a low speed or full-speed device is plugged in, it's not
>> detected as
>> EHCI should first detect it, and give ownership (handover) to OHCI.
>>
>> Current situation on STM32MP1 (with a low speed device plugged-in)
>> STM32MP> usb start
>> starting USB...
>> Bus usb@5800c000: USB OHCI 1.0
>> Bus usb@5800d000: USB EHCI 1.00
>> scanning bus usb@5800c000 for devices... 1 USB Device(s) found
>> scanning bus usb@5800d000 for devices... 1 USB Device(s) found
>>   scanning usb for storage devices... 0 Storage Device(s) found
>>
>> The "companion" property in the device tree allow to retrieve
>> companion
>> controller information, from the EHCI node. This allow marking the
>> companion driver as such.
>>
>> With this patch (same low speed device plugged in):
>> STM32MP> usb start
>> starting USB...
>> Bus usb@5800c000: USB OHCI 1.0
>> Bus usb@5800d000: USB EHCI 1.00
>> scanning bus usb@5800d000 for devices... 1 USB Device(s) found
>> scanning bus usb@5800c000 for devices... 2 USB Device(s) found
>>   scanning usb for storage devices... 0 Storage Device(s) found
>> STM32MP> usb tree
>> USB device tree:
>> 1  Hub (12 Mb/s, 0mA)
>> |   U-Boot Root Hub
>> |
>> +-2  Human Interface (1.5 Mb/s, 100mA)
>>   HP HP USB 1000dpi Laser Mouse
>>
>> 1  Hub (480 Mb/s, 0mA)
>>     u-boot EHCI Host Controller
>>
>> This also optimize bus scan when a High speed device is plugged
>> in, as
>> the usb-uclass skips OHCI in this case:
>>
>> STM32MP> usb reset
>> resetting USB...
>> Bus usb@5800c000: USB OHCI 1.0
>> Bus usb@5800d000: USB EHCI 1.00
>> scanning bus usb@5800d000 for devices... 2 USB Device(s) found
>>   scanning usb for storage devices... 1 Storage Device(s) found
>> STM32MP> usb tree
>> USB device tree:
>> 1  Hub (480 Mb/s, 0mA)
>> |  u-boot EHCI Host Controller
>> |
>> +-2  Mass Storage (480 Mb/s, 200mA)
>>   SanDisk Cruzer Blade 03003432021922011407
>>
>> Signed-off-by: Fabrice Gasnier 
>> ---
>>
>> Changes in v2:
>> - move companion probing from generic ehci driver to usb-uclass,
>> after
>>  Marek's questions on design choice.
>> - rename commit title to follow this change
>>
>> ---
>>     drivers/usb/host/usb-uclass.c | 36
>> +++
>>     1 file changed, 36 insertions(+)
>>
>> diff --git a/drivers/usb/host/usb-uclass.c
>> b/drivers/usb/host/usb-uclass.c
>> index 02c0138a2065..e238eee8c84d 100644
>> --- a/drivers/usb/host/usb-uclass.c
>> +++ b/drivers/usb/host/usb-uclass.c
>> @@ -249,6 +249,37 @@ static void remove_inactive_children(struct
>> uclass *uc, struct udevice *bus)
>>     }
>>     }
>>     +static int usb_probe_companion(struct udevice *bus)
>> +{
>> +    struct udevice *companion_dev;
>> +    int ret;
>> +
>> +    /*
>> + * Enforce optional companion controller is marked as such in
>> order to
>> + * 1st scan the primary controller, before the companion
>> controller
>> + * (ownership is given to companion when low or full speed
>> devices
>> + * have been detected).
>> + */
>> +    ret = uclass_get_device_by_phandle(UCLASS_USB, bus, "companion",
>> &companion_dev);
>> +    if (!ret) {
>> +    struct usb_bus_priv *companion_bus_priv;
>> +
>> +    debug("%s is the companion of %s\n", companion_dev->name,
>> bus->name);
>> +    companion_bus_priv = dev_get_uclass_priv(companion_dev);
>> +    companion_bus_priv->companion = true;
>> +    } else if (ret && ret != -ENOENT && ret != -ENODEV) {
>> +    /*
>> + * Treat everything else than no companion or disabled
>> + * companion as an error. (It may not be enabled on boards
>> + * that have a High-Speed HUB to handle FS and LS traffic).
>> + */
>> +    printf("Failed to get companion (ret=%d)\n", ret);
>> +    return ret;
>> +    }
>> +
>> +    return 0;
>> +}
>> +
>>     int us

Re: [PATCH v2] usb: check for companion controller in uclass

2023-09-04 Thread Marek Vasut

On 9/4/23 18:21, Fabrice Gasnier wrote:

On 9/4/23 15:54, Marek Vasut wrote:

On 9/4/23 14:34, Fabrice Gasnier wrote:

On 9/1/23 18:00, Marek Vasut wrote:

On 9/1/23 14:12, Fabrice Gasnier wrote:

On 9/1/23 12:48, Marek Vasut wrote:

On 9/1/23 11:52, Fabrice Gasnier wrote:

EHCI is usually used with companion controller (like OHCI) as
companion
controller. This information on the companion is missing currently in
companion drivers.
So, if the usb-uclass isn't aware, it may scan busses in any order:
OHCI
first, then EHCI.
This is seen on STM32MP1 where DT probing makes the probe order to
occur
by increasing address (OHCI address < EHCI address).

When a low speed or full-speed device is plugged in, it's not
detected as
EHCI should first detect it, and give ownership (handover) to OHCI.

Current situation on STM32MP1 (with a low speed device plugged-in)
STM32MP> usb start
starting USB...
Bus usb@5800c000: USB OHCI 1.0
Bus usb@5800d000: USB EHCI 1.00
scanning bus usb@5800c000 for devices... 1 USB Device(s) found
scanning bus usb@5800d000 for devices... 1 USB Device(s) found
   scanning usb for storage devices... 0 Storage Device(s) found

The "companion" property in the device tree allow to retrieve
companion
controller information, from the EHCI node. This allow marking the
companion driver as such.

With this patch (same low speed device plugged in):
STM32MP> usb start
starting USB...
Bus usb@5800c000: USB OHCI 1.0
Bus usb@5800d000: USB EHCI 1.00
scanning bus usb@5800d000 for devices... 1 USB Device(s) found
scanning bus usb@5800c000 for devices... 2 USB Device(s) found
   scanning usb for storage devices... 0 Storage Device(s) found
STM32MP> usb tree
USB device tree:
1  Hub (12 Mb/s, 0mA)
|   U-Boot Root Hub
|
+-2  Human Interface (1.5 Mb/s, 100mA)
   HP HP USB 1000dpi Laser Mouse

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

This also optimize bus scan when a High speed device is plugged
in, as
the usb-uclass skips OHCI in this case:

STM32MP> usb reset
resetting USB...
Bus usb@5800c000: USB OHCI 1.0
Bus usb@5800d000: USB EHCI 1.00
scanning bus usb@5800d000 for devices... 2 USB Device(s) found
   scanning usb for storage devices... 1 Storage Device(s) found
STM32MP> usb tree
USB device tree:
1  Hub (480 Mb/s, 0mA)
|  u-boot EHCI Host Controller
|
+-2  Mass Storage (480 Mb/s, 200mA)
   SanDisk Cruzer Blade 03003432021922011407

Signed-off-by: Fabrice Gasnier 
---

Changes in v2:
- move companion probing from generic ehci driver to usb-uclass,
after
  Marek's questions on design choice.
- rename commit title to follow this change

---
     drivers/usb/host/usb-uclass.c | 36
+++
     1 file changed, 36 insertions(+)

diff --git a/drivers/usb/host/usb-uclass.c
b/drivers/usb/host/usb-uclass.c
index 02c0138a2065..e238eee8c84d 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -249,6 +249,37 @@ static void remove_inactive_children(struct
uclass *uc, struct udevice *bus)
     }
     }
     +static int usb_probe_companion(struct udevice *bus)
+{
+    struct udevice *companion_dev;
+    int ret;
+
+    /*
+ * Enforce optional companion controller is marked as such in
order to
+ * 1st scan the primary controller, before the companion
controller
+ * (ownership is given to companion when low or full speed
devices
+ * have been detected).
+ */
+    ret = uclass_get_device_by_phandle(UCLASS_USB, bus, "companion",
&companion_dev);
+    if (!ret) {
+    struct usb_bus_priv *companion_bus_priv;
+
+    debug("%s is the companion of %s\n", companion_dev->name,
bus->name);
+    companion_bus_priv = dev_get_uclass_priv(companion_dev);
+    companion_bus_priv->companion = true;
+    } else if (ret && ret != -ENOENT && ret != -ENODEV) {
+    /*
+ * Treat everything else than no companion or disabled
+ * companion as an error. (It may not be enabled on boards
+ * that have a High-Speed HUB to handle FS and LS traffic).
+ */
+    printf("Failed to get companion (ret=%d)\n", ret);
+    return ret;
+    }
+
+    return 0;
+}
+
     int usb_init(void)
     {
     int controllers_initialized = 0;
@@ -299,6 +330,11 @@ int usb_init(void)
     printf("probe failed, error %d\n", ret);
     continue;
     }
+
+    ret = usb_probe_companion(bus);


One more thing, shouldn't this do

if (ret)
   continue;

for maximum compatibility ?


I think it does :-) Or I miss your question here, could you clarify ?

In the original PATCH there is:
+
+   ret = usb_probe_companion(bus);
+   if (ret)
+   continue;
+


Then all is OK, thanks. The missing context confused me.

But since rc4 was just tagged, I'll be putting this into next, we're too 
close to the release.


Re: [PATCH 3/3] Azure: Add sandbox64 to CI

2023-09-04 Thread Simon Glass
On Fri, 1 Sept 2023 at 14:42, Tom Rini  wrote:
>
> Now that sandbox64 can run and pass the regular test.py suite, add it
> here as well.
>
> Signed-off-by: Tom Rini 
> ---
>  .azure-pipelines.yml | 5 +
>  1 file changed, 5 insertions(+)
>

Reviewed-by: Simon Glass 


Re: [PATCH v2 2/4] cmd: gpt: use UUID accessor more consistently

2023-09-04 Thread Simon Glass
On Sat, 2 Sept 2023 at 01:34, Heinrich Schuchardt
 wrote:
>
> disk_partition_uuid() and disk_partition_set_uuid() were introduced to let
> us avoid the usage of #ifdef when dealing with the field uuid of
> struct disk_partition.
>
> In allocate_disk_part() commit c5f1d005f517 ("part: Add accessors for
> struct disk_partition uuid") missed to use the setter.
>
> print_gpt_info() and create_gpt_partitions_list() are further functions
> where we should use the getter.
>
> Fixes: c5f1d005f517 ("part: Add accessors for struct disk_partition uuid")
> Signed-off-by: Heinrich Schuchardt 
> ---
> v2:
> new patch
> ---
>  cmd/gpt.c | 23 ---
>  1 file changed, 12 insertions(+), 11 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH v2 3/4] cmd: gpt: fix calc_parts_list_len()

2023-09-04 Thread Simon Glass
Hi Heinrich,
On Sat, 2 Sept 2023 at 01:34, Heinrich Schuchardt
 wrote:
>
> * Avoid incrementing by moving comma into strlen("uuid_disk=,") and
>   considering NUL byte.
> * Appending a UUID only adds UUID_STR_LEN bytes.
>   Don't count the terminating NUL.
> * The length of the hexadecimal representation of lba_int is
>   2 * sizeof(lba_int).
> * We don't use a 'MiB' postfix but a '0x' prefix.

Why do we want the 0x prefix?

> * The uuid field is only needed if configured.
>
> Fixes: 2fcaa413b3f6 ("gpt: harden set_gpt_info() against non NULL-terminated 
> strings")
> Signed-off-by: Heinrich Schuchardt 
> ---
> v2:
> new patch
> ---
>  cmd/gpt.c | 33 -
>  1 file changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/cmd/gpt.c b/cmd/gpt.c
> index 092f7defff..e7a53747fc 100644
> --- a/cmd/gpt.c
> +++ b/cmd/gpt.c
> @@ -162,22 +162,29 @@ static bool found_key(const char *str, const char *key)
> return result;
>  }
>
> +/**
> + * calc_parts_list_len() - get size of partition table description
> + *
> + * @numparts:  number of partitions
> + * Return: string size including terminating NUL
> + */
>  static int calc_parts_list_len(int numparts)
>  {
> -   int partlistlen = UUID_STR_LEN + 1 + strlen("uuid_disk=");
> -   /* for the comma */
> -   partlistlen++;
> -
> -   /* per-partition additions; numparts starts at 1, so this should be 
> correct */
> -   partlistlen += numparts * (strlen("name=,") + PART_NAME_LEN + 1);
> +   /* number of hexadecimal digits of the lbaint_t representation */
> +   const int lbaint_size = 2 * sizeof(lbaint_t);
> +   int partlistlen;
> +
> +   /* media description including terminating NUL */
> +   partlistlen = strlen("uuid_disk=;") + UUID_STR_LEN + 1;
> +   /* per-partition descriptions; numparts */
> +   partlistlen += numparts * (strlen("name=,") + PART_NAME_LEN);
> /* see part.h for definition of struct disk_partition */
> -   partlistlen += numparts * (strlen("start=MiB,") + sizeof(lbaint_t) + 
> 1);
> -   partlistlen += numparts * (strlen("size=MiB,") + sizeof(lbaint_t) + 
> 1);
> -   partlistlen += numparts * (strlen("uuid=;") + UUID_STR_LEN + 1);
> -   /* for the terminating null */
> -   partlistlen++;
> -   debug("Length of partitions_list is %d for %d partitions\n", 
> partlistlen,
> - numparts);
> +   partlistlen += numparts * (strlen("start=0x,") + lbaint_size);
> +   partlistlen += numparts * (strlen("size=0x,") + lbaint_size);
> +   if (IS_ENABLED(CONFIG_PARTITION_UUIDS))
> +   partlistlen += numparts * (strlen("uuid=;") + UUID_STR_LEN);
> +   debug("Length of partitions_list is %d for %d partitions\n",
> + partlistlen, numparts);
> return partlistlen;
>  }
>
> --
> 2.40.1
>

Regards,
Simon


Re: [PATCH 08/19] boot: Move fdt_support to boot/

2023-09-04 Thread Simon Glass
Hi Devarsh,

On Thu, 31 Aug 2023 at 00:02, Devarsh Thakkar  wrote:
>
> Hi Simon,
>
> On 25/08/23 01:28, Simon Glass wrote:
> > This relates to booting since it fixes up the devicetree for the OS. Move
> > it into the boot/ directory.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >  boot/Makefile  | 3 +++
> >  {common => boot}/fdt_support.c | 0
> >  common/Makefile| 2 --
> >  3 files changed, 3 insertions(+), 2 deletions(-)
> >  rename {common => boot}/fdt_support.c (100%)
> >
> > diff --git a/boot/Makefile b/boot/Makefile
> > index 10f015722378..f15a161614ff 100644
> > --- a/boot/Makefile
> > +++ b/boot/Makefile
> > @@ -16,6 +16,7 @@ obj-$(CONFIG_QFW) += bootmeth_qfw.o
> >  endif
> >
> >  obj-y += image.o image-board.o
> > +
> >  obj-$(CONFIG_ANDROID_AB) += android_ab.o
> >  obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o image-android-dt.o
> >
> > @@ -37,6 +38,8 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow_menu.o
> >  obj-$(CONFIG_$(SPL_TPL_)CEDIT) += cedit.o
> >  endif
> >
> > +obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
> > +
> >  obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
>
> Can this be,
> obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o image-fdt.o ?

Yes...unfortunately I missed this when sending v3

Regards,
Simon


  1   2   >