Re: [PATCH v3 3/8] scripts/Makefile.lib: Statically define *-u-boot.dtsi files location

2024-01-07 Thread Sumit Garg
Hi Bryan,

On Sat, 6 Jan 2024 at 02:12, Bryan Brattlof  wrote:
>
> Hi Sumit!
>
> On December 28, 2023 thus sayeth Sumit Garg:
> > Allow u-boot to build DTB from a different directory tree such that
> > *-u-boot.dtsi files can be included from a common location. Currently
> > that location is arch/$(ARCH)/dts/, so statically define that common
> > location.
> >
> > This is needed for platform owners to start building DTB files from
> > devicetree-rebasing directory but still being able to include
> > *-u-boot.dtsi files.
> >
> > Reviewed-by: Tom Rini 
> > Reviewed-by: Simon Glass 
> > Reviewed-by: Ilias Apalodimas 
> > Signed-off-by: Sumit Garg 
> > ---
> >
>
> ...
>
> >
> > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> > index 27b9437027c..09330421856 100644
> > --- a/scripts/Makefile.lib
> > +++ b/scripts/Makefile.lib
>
> ...
>
> >  # Uncomment for debugging
> > @@ -190,6 +192,7 @@ dtsi_include_list += $(CONFIG_DEVICE_TREE_INCLUDES)
> >  dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc\
> >$(UBOOTINCLUDE) \
> >-I$(dir $<) \
> > +  -I$(u_boot_dtsi_loc) \
> >-I$(srctree)/arch/$(ARCH)/dts/include   \
> >-I$(srctree)/include\
> >-D__ASSEMBLY__  \
> > @@ -328,7 +331,7 @@ cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
> > echo '$(pound)include "$(f)"' >> $(pre-tmp);) \
> >   $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) 
> > $(pre-tmp) ; \
> >   $(DTC) -O dtb -o $@ -b 0 \
> > - -i $(dir $<) $(DTC_FLAGS) \
> > + -i $(dir $<) -i $(u_boot_dtsi_loc) $(DTC_FLAGS) \
> >   -d $(depfile).dtc.tmp $(dtc-tmp) || \
> >   (echo "Check $(shell pwd)/$(pre-tmp) for errors" && false) \
> >   ; \
>
> One of the issues I see with having a separate OF_UPSTREAM and U-Boot dt
> directory is when we have U-Boot board files that use dtsi files in the
> OF_UPSTREAM folder.
>
> For example our reference boards uses the primary bootloader's dtb (eg:
> k3-am62a7-r5-sk.dts) which #includes the k3-am62a7-sk.dts that will be
> found in the OF_UPSTREAM directory and modifies it to give it the
> perspective of the micro-controller it will be running on during boot.

Thanks for bringing this up. I have been playing with the idea to
reuse DT includes from upstream.

>
> What do you think if we have both paths included regardless if
> OF_UPSTREAM is selected or not? IDK if this will break anyone else

Sure, we should be able to do that if we maintain the correct order of
include paths as per following patch [1]. If this works for you let me
know and I will include it for v4.

[1]

commit 7fcebc044c69c57b43ff0e59f2d8c3713bc68b6c
Author: Sumit Garg 
Date:   Tue Jan 2 19:20:01 2024 +0530

Makefile: Allow upstream DT subtree to provide DT includes

Allow platforms to reuse DT headers and dtsi includes directly form
upstream DT subtree which will be frequently synced with Linux kernel.
This will further allow us to drop corresponding DT includes copy from
U-Boot tree.

Also, since the DT includes from upstream DT subtree are done after DT
includes from U-Boot tree, so it shouldn't cause any conflicts.

Signed-off-by: Sumit Garg 

diff --git a/Makefile b/Makefile
index d8d168cd4c3..0160e827a29 100644
--- a/Makefile
+++ b/Makefile
@@ -834,7 +834,8 @@ UBOOTINCLUDE:= \
-I$(srctree)/arch/arm/thumb1/include), \
-I$(srctree)/arch/arm/thumb1/include)) \
-I$(srctree)/arch/$(ARCH)/include \
-   -include $(srctree)/include/linux/kconfig.h
+   -include $(srctree)/include/linux/kconfig.h \
+   -I$(srctree)/devicetree-rebasing/include

 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 09330421856..30033092597 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -189,12 +189,17 @@ dtsi_include_list = $(strip $(u_boot_dtsi_options_debug) \
 dtsi_include_list += $(CONFIG_DEVICE_TREE_INCLUDES)

 # Modified for U-Boot
+upstream_dtsi_include = $(addprefix -I, $(srctree)/devicetree-rebasing/src/ \
+   $(sort $(dir $(wildcard
$(srctree)/devicetree-rebasing/src/$(ARCH)/*/*))) \
+   $(if (CONFIG_ARM64), \
+$(sort $(dir $(wildcard
$(srctree)/devicetree-rebasing/src/arm64/*/*)
 dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc\
 $(UBOOTINCLUDE) \
 -I$(dir $<) \
 -I$(u_boot_dtsi_loc) \
 -I$(srctree)/arch/$(ARCH)

Re: [PATCH v2] rockchip: rk3328: Set efuse auto mode and timing control

2024-01-07 Thread Kever Yang



On 2024/1/8 02:18, Jonas Karlman wrote:

Reading from efuse return zero when mainline TF-A is used.

   => dump_efuse
   : 00 00 00 00  
   0004: 00 00 00 00  
   0008: 00 00 00 00  
   000c: 00 00 00 00  
   0010: 00 00 00 00  
   0014: 00 00 00 00  
   0018: 00 00 00 00  
   001c: 00 00 00 00  

However, when vendor TF-A blobs is used reading from efuse works.

Change to use auto mode, enable finish and auto access err interrupts
and set timing control using same values that vendor TF-A blob use to
fix this.

With this efuse can be read when either of mainline TF-A or vendor blob
is used.

   => dump_efuse
   : 52 4b 33 82  RK3.
   0004: 00 fe 21 55  ..!U
   0008: 52 4b 57 34  RKW4
   000c: 35 30 32 39  5029
   0010: 00 00 00 00  
   0014: 08 25 0c 0f  .%..
   0018: 02 0d 08 00  
   001c: 00 00 f0 00  

Signed-off-by: Jonas Karlman 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
Changes in v2:
- Read and mask user mode flag instead of force 0x46 value

  arch/arm/mach-rockchip/rk3328/rk3328.c | 38 ++
  1 file changed, 38 insertions(+)

diff --git a/arch/arm/mach-rockchip/rk3328/rk3328.c 
b/arch/arm/mach-rockchip/rk3328/rk3328.c
index de17b8868273..ca623c0d3d03 100644
--- a/arch/arm/mach-rockchip/rk3328/rk3328.c
+++ b/arch/arm/mach-rockchip/rk3328/rk3328.c
@@ -19,6 +19,23 @@ DECLARE_GLOBAL_DATA_PTR;
  #define GRF_BASE  0xFF10
  #define UART2_BASE0xFF13
  #define FW_DDR_CON_REG0xFF7C0040
+#define EFUSE_NS_BASE  0xFF26
+
+#define EFUSE_MOD  0x
+#define EFUSE_INT_CON  0x0014
+#define EFUSE_T_CSB_P  0x0028
+#define EFUSE_T_PGENB_P0x002C
+#define EFUSE_T_LOAD_P 0x0030
+#define EFUSE_T_ADDR_P 0x0034
+#define EFUSE_T_STROBE_P   0x0038
+#define EFUSE_T_CSB_R  0x003C
+#define EFUSE_T_PGENB_R0x0040
+#define EFUSE_T_LOAD_R 0x0044
+#define EFUSE_T_ADDR_R 0x0048
+#define EFUSE_T_STROBE_R   0x004C
+
+#define EFUSE_USER_MODE0x1
+#define EFUSE_TIMING(s, l) (((s) << 16) | (l))
  
  const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {

[BROM_BOOTSOURCE_EMMC] = "/mmc@ff52",
@@ -50,10 +67,31 @@ struct mm_region *mem_map = rk3328_mem_map;
  int arch_cpu_init(void)
  {
  #ifdef CONFIG_SPL_BUILD
+   u32 reg;
+
/* We do some SoC one time setting here. */
  
  	/* Disable the ddr secure region setting to make it non-secure */

rk_setreg(FW_DDR_CON_REG, 0x200);
+
+   /* Use efuse auto mode */
+   reg = readl(EFUSE_NS_BASE + EFUSE_MOD);
+   writel(reg & ~EFUSE_USER_MODE, EFUSE_NS_BASE + EFUSE_MOD);
+
+   /* Enable efuse finish and auto access err interrupt */
+   writel(0x07, EFUSE_NS_BASE + EFUSE_INT_CON);
+
+   /* Set efuse timing control */
+   writel(EFUSE_TIMING(1, 241), EFUSE_NS_BASE + EFUSE_T_CSB_P);
+   writel(EFUSE_TIMING(1, 241), EFUSE_NS_BASE + EFUSE_T_PGENB_P);
+   writel(EFUSE_TIMING(1, 241), EFUSE_NS_BASE + EFUSE_T_LOAD_P);
+   writel(EFUSE_TIMING(1, 241), EFUSE_NS_BASE + EFUSE_T_ADDR_P);
+   writel(EFUSE_TIMING(2, 240), EFUSE_NS_BASE + EFUSE_T_STROBE_P);
+   writel(EFUSE_TIMING(1, 4), EFUSE_NS_BASE + EFUSE_T_CSB_R);
+   writel(EFUSE_TIMING(1, 4), EFUSE_NS_BASE + EFUSE_T_PGENB_R);
+   writel(EFUSE_TIMING(1, 4), EFUSE_NS_BASE + EFUSE_T_LOAD_R);
+   writel(EFUSE_TIMING(1, 4), EFUSE_NS_BASE + EFUSE_T_ADDR_R);
+   writel(EFUSE_TIMING(2, 3), EFUSE_NS_BASE + EFUSE_T_STROBE_R);
  #endif
return 0;
  }


Please pull u-boot-dm/next

2024-01-07 Thread Simon Glass
Hi Tom,

This is for -next


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

https://dev.azure.com/simon0972/u-boot/_build/results?buildId=58&view=results


The following changes since commit c2c598e87cfe56f5991730762c00733c5aa9a994:

  Merge branch 'staging' of
https://source.denx.de/u-boot/custodians/u-boot-tegra into next
(2024-01-06 09:57:56 -0500)

are available in the Git repository at:

  git://git.denx.de/u-boot-dm.git tags/dm-next-7jan23

for you to fetch changes up to 8c4b37ce97c27ad4e7f83b028d4cd1396a51a36f:

  arm: enable support for QEMU firmware tables (2024-01-07 13:49:15 -0700)


switch to SMBIOS3 tables
allow devicetree from bloblist
ACPI support for ARM and RISC-V


Heinrich Schuchardt (14):
  smbios: SMBIOS 3.0 (64-bit) Entry Point structure
  acpi: use 64-bit addresses in FADT table
  cmd: acpi: fix listing DSDT and FACS
  cmd: acpi: check HW reduced flag in acpi list
  acpi: support 64bit in acpi_find_table for DSDT and FACS
  acpi: Kconfig symbol CONFIG_QFW_ACPI
  acpi: carve out qfw_acpi.c
  arm: add ACPI fields to global data
  riscv: add ACPI fields to global data
  acpi: enable writing ACPI tables on QEMU
  riscv: add support for QEMU firmware tables
  riscv: allow usage of ACPI
  configs: qemu: add config fragment for ACPI
  arm: enable support for QEMU firmware tables

Simon Glass (12):
  smbios: Refactor 32-bit code into an else statement
  smbios: Move the rest of the SMBIOS2 code
  smbios: Use SMBIOS 3.0 to support an address above 4GB
  smbios: Correct gd_smbios_start()
  efi: Use the correct GUID for the SMBIOS table
  smbios: Require the caller to align the SMBIOS table
  smbios: Drop support for SMBIOS2 tables
  efi: smbios: Drop support for SMBIOS2 tables
  acpi: Rename test dm_test_setup_ctx_and_base_tables()
  acpi: Write pointers to tables instead of addresses
  efi: Correct smbios-table installation
  fdt: Allow the devicetree to come from a bloblist

 MAINTAINERS  |   1 +
 arch/Kconfig |   1 +
 arch/arm/include/asm/global_data.h   |   7 ++-
 arch/riscv/include/asm/global_data.h |   6 ++
 arch/sandbox/include/asm/io.h|  16 ++
 arch/x86/cpu/baytrail/acpi.c |   9 +--
 arch/x86/cpu/quark/acpi.c|   9 +--
 arch/x86/cpu/tangier/acpi.c  |   9 +--
 arch/x86/lib/acpi_table.c|  15 ++---
 board/emulation/configs/acpi.config  |   3 +
 board/emulation/qemu-arm/Kconfig |   1 +
 board/emulation/qemu-riscv/Kconfig   |   2 +
 cmd/acpi.c   |  24 +---
 doc/board/emulation/acpi.rst |  23 
 doc/board/emulation/index.rst|   1 +
 doc/develop/devicetree/control.rst   |   3 +
 drivers/misc/Kconfig |   7 +++
 drivers/misc/Makefile|   1 +
 drivers/misc/qfw.c   | 240
--
 drivers/misc/qfw_acpi.c  | 281

 include/acpi/acpi_table.h|   6 +-
 include/asm-generic/global_data.h|   2 +-
 include/efi_api.h|   4 ++
 include/fdtdec.h |   6 +-
 include/mapmem.h |  18 ++
 include/smbios.h |  41 --
 lib/acpi/Makefile|   2 +-
 lib/acpi/acpi.c  |  37 +---
 lib/acpi/acpi_table.c|   4 +-
 lib/acpi/acpi_writer.c   |   4 +-
 lib/acpi/base.c  |   4 +-
 lib/efi_loader/efi_smbios.c  |  28 ++
 lib/fdtdec.c |  44 +++
 lib/smbios.c |  55 ++
 test/dm/acpi.c   |  14 ++---
 35 files changed, 556 insertions(+), 372 deletions(-)
 create mode 100644 board/emulation/configs/acpi.config
 create mode 100644 doc/board/emulation/acpi.rst
 create mode 100644 drivers/misc/qfw_acpi.c

Regards,
Simon


Re: [PATCH v3 1/4] acpi: use 64-bit addresses in FADT table

2024-01-07 Thread Simon Glass
On Sat, 16 Dec 2023 at 01:12, Heinrich Schuchardt
 wrote:
>
> Fields X_FIRMWAE_CTRL and X_DSDT must be 64bit wide. Convert pointers to
> to uintptr_t to fill these.
>
> If field X_FIRMWARE_CTRL is filled, field FIRMWARE must be ignored. If
> field X_DSDT is filled, field DSDT must be ignored. We should not fill
> unused fields.
>
> See the field definitions in chapter "5.2.9 Fixed ACPI Description Table
> (FADT)" of the ACPI Specification 6.5.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  arch/x86/cpu/baytrail/acpi.c | 9 +++--
>  arch/x86/cpu/quark/acpi.c| 9 +++--
>  arch/x86/cpu/tangier/acpi.c  | 9 +++--
>  arch/x86/lib/acpi_table.c| 9 ++---
>  include/acpi/acpi_table.h| 6 ++
>  5 files changed, 13 insertions(+), 29 deletions(-)

Reviewed-by: Simon Glass 

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


Re: [PATCH v3 2/4] cmd: acpi: fix listing DSDT and FACS

2024-01-07 Thread Simon Glass
On Sat, 16 Dec 2023 at 01:12, Heinrich Schuchardt
 wrote:
>
> If field X_FIRMWARE_CTRL is filled, field FIRMWARE must be ignored. If
> field X_DSDT is filled, field DSDT must be ignored.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  cmd/acpi.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass 

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


Re: [PATCH v3 3/4] cmd: acpi: check HW reduced flag in acpi list

2024-01-07 Thread Simon Glass
On Sat, 16 Dec 2023 at 01:12, Heinrich Schuchardt
 wrote:
>
> On non x86 platforms the hardware reduce flag must be set in the FADT
> table. Write an error message if the flag is missing.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  cmd/acpi.c | 4 
>  1 file changed, 4 insertions(+)

Reviewed-by: Simon Glass 

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


Re: [PATCH v4 2/9] acpi: carve out qfw_acpi.c

2024-01-07 Thread Simon Glass
On Tue, Dec 19, 2023 at 04:04:01PM +0100, Heinrich Schuchardt wrote:
> Move the code related to copying tables from QEMU to a separate code
> module.
>
> Signed-off-by: Heinrich Schuchardt 
> Reviewed-by: Tom Rini 
> Reviewed-by: Simon Glass 
> ---
> v4:
>   no change
> v3:
>   no change
> v2:
>   add missing blank line
> ---
>  drivers/misc/Makefile   |   1 +
>  drivers/misc/qfw.c  | 240 -
>  drivers/misc/qfw_acpi.c | 256 
>  3 files changed, 257 insertions(+), 240 deletions(-)
>  create mode 100644 drivers/misc/qfw_acpi.c

Reviewed-by: Ilias Apalodimas 

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


Re: [PATCH v3 4/4] acpi: support 64bit in acpi_find_table for DSDT and FACS

2024-01-07 Thread Simon Glass
Hi Heinrich,

On Sat, 16 Dec 2023 at 12:21, Heinrich Schuchardt
 wrote:
>
> On 12/16/23 19:45, Simon Glass wrote:
> > On Sat, 16 Dec 2023 at 01:12, Heinrich Schuchardt
> >  wrote:
> >>
> >> Use X_DSDT and X_FIRMWARE_CTRL if available.
> >>
> >> Signed-off-by: Heinrich Schuchardt 
> >> ---
> >>   lib/acpi/acpi.c | 29 -
> >>   1 file changed, 24 insertions(+), 5 deletions(-)
> >
> > Reviewed-by: Simon Glass 
> >
> > This could really use a test
>
> I guess we want a test on library level separate from test/dm/acpi.c as
> this test will not be driver model related?

Yes, but it isn't that important. I have been moving DM tests to only
differ in their flags, so I'm not sure there is much difference
anymore.

Regards,
Simon

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


Re: [PATCH v4 1/9] acpi: Kconfig symbol CONFIG_QFW_ACPI

2024-01-07 Thread Simon Glass
We have two implementations of write_acpi_tables(). One for writing ACPI
tables based on ACPI_WRITER() entries another based on copying tables from
QEMU.

Create a symbol CONFIG_QFW_ACPI that signifies copying ACPI tables from
QEMU and use it consistently.

Signed-off-by: Heinrich Schuchardt 
Reviewed-by: Simon Glass 
---
v4:
no change
v3:
no change
v2:
no change
---
 drivers/misc/Kconfig   | 7 +++
 drivers/misc/qfw.c | 4 ++--
 lib/acpi/Makefile  | 2 +-
 lib/acpi/acpi_writer.c | 4 ++--
 4 files changed, 12 insertions(+), 5 deletions(-)

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


Re: [PATCH v4 6/9] riscv: add support for QEMU firmware tables

2024-01-07 Thread Simon Glass
Enable the QEMU firmware interface if ACPI tables are to be supported on
the QEMU platform.

Enable the QFW MMIO interface if the QEMU firmware interface is enabled.

Signed-off-by: Heinrich Schuchardt 
Reviewed-by: Simon Glass 
Reviewed-by: Ilias Apalodimas 
---
v4:
no change
v3:
no change
v2:
no change
---
 board/emulation/qemu-riscv/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

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


Re: [PATCH v4 3/9] arm: add ACPI fields to global data

2024-01-07 Thread Simon Glass
On Tue, 19 Dec 2023 at 08:04, Heinrich Schuchardt
 wrote:
>
> Add fields for the location of ACPI tables to the global data.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
> v4:
> no change
> v3:
> let tables in global data depend on CONFIG_(SPL_)ACPI
> v2:
> new patch
> ---
>  arch/arm/include/asm/global_data.h | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass 

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


Re: [PATCH v4 4/9] riscv: add ACPI fields to global data

2024-01-07 Thread Simon Glass
Add fields for the location of ACPI tables to the global data.

Signed-off-by: Heinrich Schuchardt 
Reviewed-by: Simon Glass 
Reviewed-by: Bin Meng 
---
v4:
no change
v3:
let tables in global data depend on CONFIG_(SPL_)ACPI
v2:
no change
---
 arch/riscv/include/asm/global_data.h | 6 ++
 1 file changed, 6 insertions(+)

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


Re: [PATCH v4 5/9] acpi: enable writing ACPI tables on QEMU

2024-01-07 Thread Simon Glass
On Tue, Dec 19, 2023 at 04:04:04PM +0100, Heinrich Schuchardt wrote:
> Invoke write_acpi_tables() via EVT_LAST_STAGE_INIT on QEMU except on X86.
> X86 calls write_acpi_tables() in write_tables().
>
> Signed-off-by: Heinrich Schuchardt 
> Reviewed-by: Simon Glass 
> ---
> v4:
>   no change
> v3:
>   no change
> v2:
>   new patch
> ---
>  drivers/misc/qfw_acpi.c | 25 +
>  1 file changed, 25 insertions(+)
>
Applied to u-boot-dm/next, thanks!


Re: [PATCH v4 8/9] configs: qemu: add config fragment for ACPI

2024-01-07 Thread Simon Glass
Provide a configuration fragment to enable ACPI on QEMU.

Signed-off-by: Heinrich Schuchardt 
Acked-by: Ilias Apalodimas 
Reviewed-by: Simon Glass 
---
v4:
mention that QEMU v8.0.0 introduced RISC-V ACPI support
v3:
no change
v2:
no change
---
 MAINTAINERS |  1 +
 board/emulation/configs/acpi.config |  3 +++
 doc/board/emulation/acpi.rst| 23 +++
 doc/board/emulation/index.rst   |  1 +
 4 files changed, 28 insertions(+)
 create mode 100644 board/emulation/configs/acpi.config
 create mode 100644 doc/board/emulation/acpi.rst

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


Re: [PATCH v4 7/9] riscv: allow usage of ACPI

2024-01-07 Thread Simon Glass
Select CONFIG_SUPPORT_ACPI to allow usage of ACPI tables with RISC-V.

Signed-off-by: Heinrich Schuchardt 
Reviewed-by: Simon Glass 
---
v4:
no change
v3:
no change
v2:
no change
---
 arch/Kconfig | 1 +
 1 file changed, 1 insertion(+)

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


Re: [PATCH v4 9/9] arm: enable support for QEMU firmware tables

2024-01-07 Thread Simon Glass
On Tue, 19 Dec 2023 at 17:04, Heinrich Schuchardt
 wrote:
>
> Enable the QEMU firmware interface if ACPI tables are to be supported on
> the QEMU platform.
>
> Signed-off-by: Heinrich Schuchardt 
> Reviewed-by: Simon Glass 
> ---
> v4:
> no change
> v3:
> no change
> v2:
> new patch
> ---
>  board/emulation/qemu-arm/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
Applied to u-boot-dm/next, thanks!


Re: [PATCH v5 01/12] smbios: Refactor 32-bit code into an else statement

2024-01-07 Thread Simon Glass
In preparation for adding support for SMBIOS3 move this code into an
else statement. There is no functional change.

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

(no changes since v1)

 lib/smbios.c | 38 +-
 1 file changed, 21 insertions(+), 17 deletions(-)

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


Re: [PATCH v5 02/12] smbios: Move the rest of the SMBIOS2 code

2024-01-07 Thread Simon Glass
Move all of this logic into the else clause, since it will not be used
for SMBIOS3

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

(no changes since v1)

 lib/smbios.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

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


Re: [PATCH v5 04/12] smbios: Use SMBIOS 3.0 to support an address above 4GB

2024-01-07 Thread Simon Glass
Hi Heinrich,

On Mon, Jan 1, 2024 at 10:34 AM Heinrich Schuchardt  wrote:
>
> On 12/31/23 16:25, Simon Glass wrote:
> > When the SMBIOS table is written to an address above 4GB a 32-bit table
> > address is not large enough.
> >
> > Use an SMBIOS3 table in that case.
> >
> > Note that we cannot use efi_allocate_pages() since this function has
> > nothing to do with EFI. There is no equivalent function to allocate
> > memory below 4GB in U-Boot. One solution would be to create a separate
> > malloc() pool, or just always put the malloc() pool below 4GB.
> >
> > - Use log_debug() for warning
> > - Rebase on Heinrich's smbios.h patch
> > - Set the checksum for SMBIOS3
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v4)
> >
> > Changes in v4:
> > - Check the start of the table rather than the end
> >
> > Changes in v2:
> > - Check the end of the table rather than the start.
> >
> >   include/smbios.h |  6 +-
> >   lib/smbios.c | 30 +-
> >   2 files changed, 30 insertions(+), 6 deletions(-)
> >
Applied to u-boot-dm/next, thanks!


Re: [PATCH v5 03/12] smbios: SMBIOS 3.0 (64-bit) Entry Point structure

2024-01-07 Thread Simon Glass
From: Heinrich Schuchardt 

Add definition of the SMBIOS 3.0 (64-bit) Entry Point structure.

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

Signed-off-by: Simon Glass 
---

(no changes since v4)

Changes in v4:
- Bring in this patch from Heinrich's series

 include/smbios.h | 26 ++
 1 file changed, 26 insertions(+)

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


Re: [PATCH v5 05/12] smbios: Correct gd_smbios_start()

2024-01-07 Thread Simon Glass
This should access arch-specific properties. Fix it and update the
existing usage.

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

(no changes since v2)

Changes in v2:
- Add a new patch to correct gd_smbios_start()

 include/asm-generic/global_data.h | 2 +-
 lib/efi_loader/efi_smbios.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

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


Re: [PATCH v5 06/12] efi: Use the correct GUID for the SMBIOS table

2024-01-07 Thread Simon Glass
EFI does not use the 'anchor string' to determine the SMBIOS table
version, instead preferring to have two separate GUIDs. Use the correct
one, depending on the table version.

Call unmap_system() to balance to the use of map_sysmem()

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

(no changes since v2)

Changes in v2:
- Add a note about why unmap_system() is called

 include/efi_api.h   |  4 
 lib/efi_loader/efi_smbios.c | 12 ++--
 2 files changed, 14 insertions(+), 2 deletions(-)

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


Re: [PATCH v5 08/12] smbios: Drop support for SMBIOS2 tables

2024-01-07 Thread Simon Glass
On Sun, Dec 31, 2023 at 3:26 PM Simon Glass  wrote:
>
> These tables are a pain since there is no way to handle memory above
> 4GB. Use SMBIOS3 always.
>
> This should hopefully not create problems on x86 devices, since SMBIOS3
> was released seven years ago (2015).
>
> Signed-off-by: Simon Glass 
Reviewed-by: Peter Robinson 

It's also worth noting here the aarch64 Server Base Boot Requirements
(SBBR) has required SMBIOS v3 since version 1.0 of the spec [1].

[1] https://documentation-service.arm.com/static/5fb7e5adca04df4095c1d64d

> ---
>
> Changes in v5:
> - Add new patch to drop support for SMBIOS2 tables
>
>  lib/smbios.c | 76 
>  1 file changed, 17 insertions(+), 59 deletions(-)
>
Applied to u-boot-dm/next, thanks!


Re: [PATCH v5 07/12] smbios: Require the caller to align the SMBIOS table

2024-01-07 Thread Simon Glass
All callers handle this alignment, so drop the unnecessary code. This
simplifies things a little.

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

Changes in v5:
- Update comment to mention x86 alignment

 include/smbios.h | 9 +
 lib/smbios.c | 2 --
 2 files changed, 5 insertions(+), 6 deletions(-)

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


Re: [PATCH v5 09/12] efi: smbios: Drop support for SMBIOS2 tables

2024-01-07 Thread Simon Glass
On 12/31/23 16:25, Simon Glass wrote:
> Only the v3 table is supported now, so always use this when installing
> the EFI table.
>
> Signed-off-by: Simon Glass 

Reviewed-by: Heinrich Schuchardt 

> ---
>
> Changes in v5:
> - Add new patch to drop support for SMBIOS2 tables with EFI
>
>   lib/efi_loader/efi_smbios.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
>
Applied to u-boot-dm/next, thanks!


Re: [PATCH v7] fdt: Allow the devicetree to come from a bloblist

2024-01-07 Thread Simon Glass
On Thu, 4 Jan 2024 at 03:49, Simon Glass  wrote:
>
> Standard passage provides for a bloblist to be passed from one firmware
> phase to the next. That can be used to pass the devicetree along as well.
> Add an option to support this.
>
> Tests for this will be added as part of the Universal Payload work.
>
> Signed-off-by: Simon Glass 
> ---
> The discussion on this was not resolved and is now important due to the
> bloblist series from Raymond. So I am sending it again since I believe
> this is a better starting point than building on OF_BOARD
>
> Changes in v7:
> - Drop use of OF_BLOBLIST
>
> Changes in v6:
> - Don't allow bloblist with OF_EMBED
>
> Changes in v5:
> - Make OF_BLOBLIST default y
> - Make OF_BLOBLIST optional at runtime
>
> Changes in v4:
> - Rebase to -next
>
>  doc/develop/devicetree/control.rst |  3 ++
>  include/fdtdec.h   |  6 ++--
>  lib/fdtdec.c   | 44 +++---
>  3 files changed, 41 insertions(+), 12 deletions(-)
>
Applied to u-boot-dm/next, thanks!


Re: [PATCH v5 11/12] acpi: Write pointers to tables instead of addresses

2024-01-07 Thread Simon Glass
On 12/31/23 16:25, Simon Glass wrote:
> Sandbox uses an API to map between addresses and pointers. This allows
> it to have (emulated) memory at zero and avoid arch-specific addressing
> details. It also allows memory-mapped peripherals to work.
>
> As an example, on many machines sandbox maps address 100 to pointer
> value 1000.
>
> However this is not correct for ACPI, if sandbox starts another program
> (e.g EFI app) and passes it the tables. That app has no knowledge of
> sandbox's address mapping. So to make this work we want to store
> 1000 as the value in the table.
>
> Add two new 'nomap' functions which clearly make this exeption to how
> sandbox works.
>
> This should allow EFI apps to access ACPI tables with sandbox, e.g. for
> testing purposes.
>
> Signed-off-by: Simon Glass
> Suggested-by: Heinrich Schuchardt

Thanks a lot for making this change.

Best regards

Heinrich

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


Re: [PATCH v5 10/12] acpi: Rename test dm_test_setup_ctx_and_base_tables()

2024-01-07 Thread Simon Glass
Am 31. Dezember 2023 16:25:53 MEZ schrieb Simon Glass :
>Use the word 'acpi' in this test so that it runs along with all the
>other ACPI tests.
>
>Signed-off-by: Simon Glass 


Reviewed-by: Heinrich Schuchardt 

>---
>
>Changes in v5:
>- Add new patch to rename test dm_test_setup_ctx_and_base_tables()
>
> test/dm/acpi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
Applied to u-boot-dm/next, thanks!


Re: [PATCH v5 12/12] efi: Correct smbios-table installation

2024-01-07 Thread Simon Glass
On 1/1/24 01:37, Simon Glass wrote:
> Hi Heinrich,
>
> On Sun, Dec 31, 2023 at 9:27 AM Heinrich Schuchardt  
> wrote:
>>
>> On 12/31/23 16:25, Simon Glass wrote:
>>> At present this code allocates memory when writing the tables and
>>> then unnecessarily adds another memory map when installing it.
>>>
>>> Adjust the code to allocate the tables using the normal U-Boot
>>> mechanism. This avoids doing an EFI memory allocation early in
>>> U-Boot, which may use memory that would be overwritten by a
>>> 'load' command, for example.
>>>
>>> Signed-off-by: Simon Glass 
>>
>> In patch 11/12 you changed the address fields in ACPI tables from
>> sandbox virtual addresses to pointers. Do you plan to do the same for
>> SMBIOS?
>
> I haven't looked at it, but could if it would help. Are you planning
> to add an EFI test app for sandbox?

Yes, we need a test checking that the SMBIOS protocol is correctly
installed. A tool like dtbdump.efi (lib/efi_loader/dtbdump.efi) would
allow to dump the SMBIOS table to file and then use dmidecode to check
the tables for consistency.

Best regards

Heinrich

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


[PATCH 2/2] coreboot: Switch to a monospaced font

2024-01-07 Thread Simon Glass
The default font is proportional, with different character widths.
Select a monospace font for coreboot so that the 'dm tree' output lines
up correctly.

Update the coreboot tests to match.

Signed-off-by: Simon Glass 
---

 configs/coreboot64_defconfig |  3 +++
 configs/coreboot_defconfig   |  3 +++
 test/cmd/font.c  | 12 +---
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/configs/coreboot64_defconfig b/configs/coreboot64_defconfig
index 49c982ef756..c4571090859 100644
--- a/configs/coreboot64_defconfig
+++ b/configs/coreboot64_defconfig
@@ -64,6 +64,9 @@ CONFIG_SOUND=y
 CONFIG_SOUND_I8254=y
 CONFIG_VIDEO_COPY=y
 CONFIG_CONSOLE_TRUETYPE=y
+CONFIG_CONSOLE_TRUETYPE_SIZE=20
+# CONFIG_CONSOLE_TRUETYPE_NIMBUS is not set
+CONFIG_CONSOLE_TRUETYPE_ANKACODER=y
 CONFIG_CONSOLE_SCROLL_LINES=5
 CONFIG_SPL_ACPI=y
 CONFIG_CMD_DHRYSTONE=y
diff --git a/configs/coreboot_defconfig b/configs/coreboot_defconfig
index d4e44e00dca..7aa841bb54b 100644
--- a/configs/coreboot_defconfig
+++ b/configs/coreboot_defconfig
@@ -61,6 +61,9 @@ CONFIG_SOUND=y
 CONFIG_SOUND_I8254=y
 CONFIG_VIDEO_COPY=y
 CONFIG_CONSOLE_TRUETYPE=y
+CONFIG_CONSOLE_TRUETYPE_SIZE=20
+# CONFIG_CONSOLE_TRUETYPE_NIMBUS is not set
+CONFIG_CONSOLE_TRUETYPE_ANKACODER=y
 CONFIG_CONSOLE_SCROLL_LINES=5
 CONFIG_CMD_DHRYSTONE=y
 # CONFIG_GZIP is not set
diff --git a/test/cmd/font.c b/test/cmd/font.c
index 9c1eebf799e..ee1c610106d 100644
--- a/test/cmd/font.c
+++ b/test/cmd/font.c
@@ -29,14 +29,20 @@ static int font_test_base(struct unit_test_state *uts)
 
ut_assertok(console_record_reset_enable());
ut_assertok(run_command("font list", 0));
-   ut_assert_nextline("nimbus_sans_l_regular");
+   if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_NIMBUS))
+   ut_assert_nextline("nimbus_sans_l_regular");
+   if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_ANKACODER))
+   ut_assert_nextline("ankacoder_c75_r");
if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_CANTORAONE))
ut_assert_nextline("cantoraone_regular");
ut_assertok(ut_check_console_end(uts));
 
ut_assertok(vidconsole_get_font_size(dev, &name, &size));
-   ut_asserteq_str("nimbus_sans_l_regular", name);
-   ut_asserteq(18, size);
+   if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_ANKACODER))
+   ut_asserteq_str("ankacoder_c75_r", name);
+   else
+   ut_asserteq_str("nimbus_sans_l_regular", name);
+   ut_asserteq(CONFIG_CONSOLE_TRUETYPE_SIZE, size);
 
if (!IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_CANTORAONE))
return 0;
-- 
2.34.1



[PATCH 1/2] video: Allow querying the font size

2024-01-07 Thread Simon Glass
All the font size to be queried using the 'font size' command.

Signed-off-by: Simon Glass 
---

 cmd/font.c | 17 +
 doc/usage/cmd/font.rst |  6 --
 test/cmd/font.c|  9 +
 3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/cmd/font.c b/cmd/font.c
index cb39c88063f..c7fe2a70a49 100644
--- a/cmd/font.c
+++ b/cmd/font.c
@@ -56,9 +56,6 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, int 
argc,
uint size;
int ret;
 
-   if (argc != 2)
-   return CMD_RET_USAGE;
-
if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
return CMD_RET_FAILURE;
ret = vidconsole_get_font_size(dev, &font_name, &size);
@@ -67,12 +64,16 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, 
int argc,
return CMD_RET_FAILURE;
}
 
-   size = dectoul(argv[1], NULL);
+   if (argc < 2) {
+   printf("%d\n", size);
+   } else {
+   size = dectoul(argv[1], NULL);
 
-   ret = vidconsole_select_font(dev, font_name, size);
-   if (ret) {
-   printf("Failed (error %d)\n", ret);
-   return CMD_RET_FAILURE;
+   ret = vidconsole_select_font(dev, font_name, size);
+   if (ret) {
+   printf("Failed (error %d)\n", ret);
+   return CMD_RET_FAILURE;
+   }
}
 
return 0;
diff --git a/doc/usage/cmd/font.rst b/doc/usage/cmd/font.rst
index 8ba149d7599..fea0df3f745 100644
--- a/doc/usage/cmd/font.rst
+++ b/doc/usage/cmd/font.rst
@@ -10,7 +10,7 @@ Synopis
 
 font list
 font select  []
-font size 
+font size []
 
 Description
 ---
@@ -31,7 +31,7 @@ This selects a new font and optionally changes the size.
 font size
 ~
 
-This changes the font size only.
+This changes the font size only. With no argument it shows the current size.
 
 Examples
 
@@ -41,6 +41,8 @@ Examples
 => font list
 nimbus_sans_l_regular
 cantoraone_regular
+=> font size
+30
 => font size 40
 => font select cantoraone_regular 20
 =>
diff --git a/test/cmd/font.c b/test/cmd/font.c
index 1fe05c1ead5..9c1eebf799e 100644
--- a/test/cmd/font.c
+++ b/test/cmd/font.c
@@ -60,10 +60,19 @@ static int font_test_base(struct unit_test_state *uts)
ut_assertok(vidconsole_get_font_size(dev, &name, &size));
ut_asserteq_str("cantoraone_regular", name);
ut_asserteq(40, size);
+   ut_assertok(ut_check_console_end(uts));
+
+   ut_assertok(run_command("font size", 0));
+   ut_assert_nextline("40");
+   ut_assertok(ut_check_console_end(uts));
 
ut_assertok(run_command("font size 30", 0));
ut_assertok(ut_check_console_end(uts));
 
+   ut_assertok(run_command("font size", 0));
+   ut_assert_nextline("30");
+   ut_assertok(ut_check_console_end(uts));
+
ut_assertok(vidconsole_get_font_size(dev, &name, &size));
ut_asserteq_str("cantoraone_regular", name);
ut_asserteq(30, size);
-- 
2.34.1



Re: [RFC PATCH V2] net: wget: Take in account tcp sequence number wrap around

2024-01-07 Thread Fabio Estevam
On Sun, Jan 7, 2024 at 5:01 PM Michael Trimarchi
 wrote:
>
> Coming from some discussion on mailing about wget unconsistent. It's
> just and idea to play around
>
> Signed-off-by: Michael Trimarchi 
> ---
> RFC V1 -> RFC V2:
> - drop random train change in unsigned difference

Same behavior: I always get Bytes transferred = 1448 (5a8 hex), no
matter the file size.

Please try to reproduce the original error when you get a chance.


[RFC PATCH V2] net: wget: Take in account tcp sequence number wrap around

2024-01-07 Thread Michael Trimarchi
Coming from some discussion on mailing about wget unconsistent. It's
just and idea to play around

Signed-off-by: Michael Trimarchi 
---
RFC V1 -> RFC V2:
- drop random train change in unsigned difference

---
 include/net/tcp.h | 10 ++
 net/wget.c|  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index c29d4ce24a..584813b637 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -88,6 +88,16 @@ struct ip_tcp_hdr {
 #define TCP_MSS1460/* Max segment size 
*/
 #define TCP_SCALE  0x01/* Scale*/
 
+/*
+ * The next routines deal with comparing 32 bit unsigned ints
+ * and worry about wraparound (automatic with unsigned arithmetic).
+ */
+static inline bool before(__u32 seq1, __u32 seq2)
+{
+   return (__s32)(seq1-seq2) < 0;
+}
+#define after(seq2, seq1)  before(seq1, seq2)
+
 /**
  * struct tcp_mss - TCP option structure for MSS (Max segment size)
  * @kind: Field ID
diff --git a/net/wget.c b/net/wget.c
index 8bb4d72db1..020503b763 100644
--- a/net/wget.c
+++ b/net/wget.c
@@ -333,7 +333,7 @@ static void wget_handler(uchar *pkt, u16 dport,
   "wget: Transferring, seq=%x, ack=%x,len=%x\n",
   tcp_seq_num, tcp_ack_num, len);
 
-   if (tcp_seq_num >= initial_data_seq_num &&
+   if (!before(initial_data_seq_num, tcp_seq_num) &&
store_block(pkt, tcp_seq_num - initial_data_seq_num,
len) != 0) {
wget_fail("wget: store error\n",
-- 
2.40.1



Re: [PATCH] boot: add support for button commands

2024-01-07 Thread Svyatoslav Ryhel
пт, 5 січ. 2024 р. о 18:03 Caleb Connolly  пише:
>
> With the relatively new button API in U-Boot, it's now much easier to
> model the common usecase of mapping arbitrary actions to different
> buttons during boot - for example entering fastboot mode, setting some
> additional kernel cmdline arguments, or booting with a custom recovery
> ramdisk, to name a few.
>
> Historically, this functionality has been implemented in board code,
> making it fixed for a given U-Boot binary and requiring the code be
> duplicated and modified for every board.
>
> Implement a generic abstraction to run an arbitrary command during boot
> when a specific button is pressed. The button -> command mapping is
> configured via environment variables with the following format:
>
>   button_cmd_N_name=
>   button_cmd_N=
>
> Where N is the mapping number starting from 0. For example:
>
>   button_cmd_0_name=vol_down
>   button_cmd_0=fastboot usb 0
>
> This will cause the device to enter fastboot mode if volume down is held
> during boot.
>
> After we enter the cli loop the button commands are no longer valid,
> this allows the buttons to additionally be used for navigating a boot
> menu.
>
> Signed-off-by: Caleb Connolly 
> ---
>  boot/Kconfig  | 14 +++
>  common/Makefile   |  1 +
>  common/button_cmd.c   | 83 +++
>  common/main.c |  3 ++
>  doc/usage/environment.rst |  4 ++
>  include/button.h  |  9 +
>  6 files changed, 114 insertions(+)
>  create mode 100644 common/button_cmd.c
>
I wonder how I lived without this patch! I hope to see it in the mainline ASAP.

Tested-by: Svyatoslav Ryhel  # Tegra30


[PATCH v2] rockchip: rk3328: Set efuse auto mode and timing control

2024-01-07 Thread Jonas Karlman
Reading from efuse return zero when mainline TF-A is used.

  => dump_efuse
  : 00 00 00 00  
  0004: 00 00 00 00  
  0008: 00 00 00 00  
  000c: 00 00 00 00  
  0010: 00 00 00 00  
  0014: 00 00 00 00  
  0018: 00 00 00 00  
  001c: 00 00 00 00  

However, when vendor TF-A blobs is used reading from efuse works.

Change to use auto mode, enable finish and auto access err interrupts
and set timing control using same values that vendor TF-A blob use to
fix this.

With this efuse can be read when either of mainline TF-A or vendor blob
is used.

  => dump_efuse
  : 52 4b 33 82  RK3.
  0004: 00 fe 21 55  ..!U
  0008: 52 4b 57 34  RKW4
  000c: 35 30 32 39  5029
  0010: 00 00 00 00  
  0014: 08 25 0c 0f  .%..
  0018: 02 0d 08 00  
  001c: 00 00 f0 00  

Signed-off-by: Jonas Karlman 
---
Changes in v2:
- Read and mask user mode flag instead of force 0x46 value

 arch/arm/mach-rockchip/rk3328/rk3328.c | 38 ++
 1 file changed, 38 insertions(+)

diff --git a/arch/arm/mach-rockchip/rk3328/rk3328.c 
b/arch/arm/mach-rockchip/rk3328/rk3328.c
index de17b8868273..ca623c0d3d03 100644
--- a/arch/arm/mach-rockchip/rk3328/rk3328.c
+++ b/arch/arm/mach-rockchip/rk3328/rk3328.c
@@ -19,6 +19,23 @@ DECLARE_GLOBAL_DATA_PTR;
 #define GRF_BASE   0xFF10
 #define UART2_BASE 0xFF13
 #define FW_DDR_CON_REG 0xFF7C0040
+#define EFUSE_NS_BASE  0xFF26
+
+#define EFUSE_MOD  0x
+#define EFUSE_INT_CON  0x0014
+#define EFUSE_T_CSB_P  0x0028
+#define EFUSE_T_PGENB_P0x002C
+#define EFUSE_T_LOAD_P 0x0030
+#define EFUSE_T_ADDR_P 0x0034
+#define EFUSE_T_STROBE_P   0x0038
+#define EFUSE_T_CSB_R  0x003C
+#define EFUSE_T_PGENB_R0x0040
+#define EFUSE_T_LOAD_R 0x0044
+#define EFUSE_T_ADDR_R 0x0048
+#define EFUSE_T_STROBE_R   0x004C
+
+#define EFUSE_USER_MODE0x1
+#define EFUSE_TIMING(s, l) (((s) << 16) | (l))
 
 const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
[BROM_BOOTSOURCE_EMMC] = "/mmc@ff52",
@@ -50,10 +67,31 @@ struct mm_region *mem_map = rk3328_mem_map;
 int arch_cpu_init(void)
 {
 #ifdef CONFIG_SPL_BUILD
+   u32 reg;
+
/* We do some SoC one time setting here. */
 
/* Disable the ddr secure region setting to make it non-secure */
rk_setreg(FW_DDR_CON_REG, 0x200);
+
+   /* Use efuse auto mode */
+   reg = readl(EFUSE_NS_BASE + EFUSE_MOD);
+   writel(reg & ~EFUSE_USER_MODE, EFUSE_NS_BASE + EFUSE_MOD);
+
+   /* Enable efuse finish and auto access err interrupt */
+   writel(0x07, EFUSE_NS_BASE + EFUSE_INT_CON);
+
+   /* Set efuse timing control */
+   writel(EFUSE_TIMING(1, 241), EFUSE_NS_BASE + EFUSE_T_CSB_P);
+   writel(EFUSE_TIMING(1, 241), EFUSE_NS_BASE + EFUSE_T_PGENB_P);
+   writel(EFUSE_TIMING(1, 241), EFUSE_NS_BASE + EFUSE_T_LOAD_P);
+   writel(EFUSE_TIMING(1, 241), EFUSE_NS_BASE + EFUSE_T_ADDR_P);
+   writel(EFUSE_TIMING(2, 240), EFUSE_NS_BASE + EFUSE_T_STROBE_P);
+   writel(EFUSE_TIMING(1, 4), EFUSE_NS_BASE + EFUSE_T_CSB_R);
+   writel(EFUSE_TIMING(1, 4), EFUSE_NS_BASE + EFUSE_T_PGENB_R);
+   writel(EFUSE_TIMING(1, 4), EFUSE_NS_BASE + EFUSE_T_LOAD_R);
+   writel(EFUSE_TIMING(1, 4), EFUSE_NS_BASE + EFUSE_T_ADDR_R);
+   writel(EFUSE_TIMING(2, 3), EFUSE_NS_BASE + EFUSE_T_STROBE_R);
 #endif
return 0;
 }
-- 
2.43.0



Re: inconsistent wget behavior

2024-01-07 Thread Fabio Estevam
Hi Michael,

On Sun, Jan 7, 2024 at 1:36 PM Michael Nazzareno Trimarchi
 wrote:

> I have sent but not sure about it, just compile for now ;)

It didn't work:

u-boot=> wget 192.168.0.16:/test
HTTP/1.0 200 OK| | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | |
Packets received 298384, Transfer Successful
Bytes transferred = 1448 (5a8 hex)
u-boot=> wget 192.168.0.16:/Image
HTTP/1.0 200 OK

Re: [PATCH v2] rockchip: rk35xx: expand space for decompressed kernel

2024-01-07 Thread Jonas Karlman
Hi Hugh,

On 2023-12-26 17:43, Hugh Cole-Baker wrote:
> An uncompressed 6.7.0-rc1 Linux kernel Image built with the arm64
> defconfig is about 40MB. This does not fit in to the space between
> kernel_comp_addr_r and fdt_addr_r, so when uncompressing an Image.gz
> to this size, the FDT will be overwritten. Rearrange addresses to have
> 128MiB for the kernel and its decompression buffer, then devicetree,
> overlay and ramdisk at the end.
> 
> Signed-off-by: Hugh Cole-Baker 
> ---
> Changes from v1:
> Reorder things to have to have 128MiB for kernel and decompression space,
> then devicetree, overlays and ramdisk.
> Update kernel_comp_size to 128MiB.
> 
>  include/configs/rk3568_common.h | 12 ++--
>  include/configs/rk3588_common.h | 12 ++--
>  2 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/include/configs/rk3568_common.h b/include/configs/rk3568_common.h
> index 1b7d3437b1..48f93083de 100644
> --- a/include/configs/rk3568_common.h
> +++ b/include/configs/rk3568_common.h
> @@ -20,12 +20,12 @@
>   "script_offset_f=0xffe000\0"\
>   "script_size_f=0x2000\0"\
>   "pxefile_addr_r=0x00e0\0"   \
> - "fdt_addr_r=0x0a10\0"   \
> - "fdtoverlay_addr_r=0x0200\0"\
> - "kernel_addr_r=0x0208\0"\
> - "ramdisk_addr_r=0x0a20\0"   \
> - "kernel_comp_addr_r=0x0800\0"   \
> - "kernel_comp_size=0x200\0"
> + "kernel_addr_r=0x0200\0"\
> + "kernel_comp_addr_r=0x0a00\0"   \
> + "fdt_addr_r=0x1200\0"   \
> + "fdtoverlay_addr_r=0x1210\0"\
> + "ramdisk_addr_r=0x1218\0"   \
> + "kernel_comp_size=0x800\0"

This (and the prior) memory layout extend over the possible memory
region that OPTEE may use, 32 MiB at 132 MiB offset.

The following regions is typically reserved for TF-A and OPTEE:

0x - 0x0020 - reserved for TF-A, pstore, shmem, etc (0-2 MiB)
0x0840 - 0x0a40 - reserved for OPTEE (132-164 MiB)

Following offsets are used by U-Boot on rockchip rk35xx:

@0   - U-Boot SPL
@4   - TF-A (@256 KiB)
@a0  - U-Boot proper (@10 MiB)
@c0  - scriptaddr (@12 MiB)
@c00800  - loadaddr (@12 MiB + 2 KiB)
@e0  - pxefile_addr_r (@14 MiB)
@840 - optional OPTEE (@132 MiB)

May I suggest a memory layout similar to the following be used:

@180  - fdtoverlay_addr_r (@24 MiB)
@1c0  - fdt_addr_r (@28 MiB)
@200  - kernel_addr_r (@32 MiB)
@a80  - kernel_comp_addr_r (@168 MiB) // could also be a40 (@164 MiB)
@12c0 - ramdisk_addr_r (@300 MiB) // kernel_comp_addr_r + kernel_comp_size
and kernel_comp_size = 0x800 (128 MiB)

With that it should allow for a 100-136 MiB kernel starting at @32 MiB,
depending on if memory is reserved for OPTEE or not. It also leave 4 MiB
for FDT and FDT overlay in memory just before the kernel. And finally do
not overlap kernel_comp_addr_r with possible OPTEE memory.

If we need more space then 2 MiB for U-Boot proper we should also
revise the offsets used for loadaddr, scriptaddr and pxefile_addr_r.

Regards,
Jonas

>  
>  #define CFG_EXTRA_ENV_SETTINGS   \
>   ENV_MEM_LAYOUT_SETTINGS \
> diff --git a/include/configs/rk3588_common.h b/include/configs/rk3588_common.h
> index 46389d087d..70430612ef 100644
> --- a/include/configs/rk3588_common.h
> +++ b/include/configs/rk3588_common.h
> @@ -19,12 +19,12 @@
>   "script_offset_f=0xffe000\0"\
>   "script_size_f=0x2000\0"\
>   "pxefile_addr_r=0x00e0\0"   \
> - "fdt_addr_r=0x0a10\0"   \
> - "fdtoverlay_addr_r=0x0200\0"\
> - "kernel_addr_r=0x0208\0"\
> - "ramdisk_addr_r=0x0a20\0"   \
> - "kernel_comp_addr_r=0x0800\0"   \
> - "kernel_comp_size=0x200\0"
> + "kernel_addr_r=0x0200\0"\
> + "kernel_comp_addr_r=0x0a00\0"   \
> + "fdt_addr_r=0x1200\0"   \
> + "fdtoverlay_addr_r=0x1210\0"\
> + "ramdisk_addr_r=0x1218\0"   \
> + "kernel_comp_size=0x800\0"
>  
>  #define CFG_EXTRA_ENV_SETTINGS \
>   "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \




Re: inconsistent wget behavior

2024-01-07 Thread Michael Nazzareno Trimarchi
Hi Fabio

On Sun, Jan 7, 2024 at 5:19 PM Michael Nazzareno Trimarchi
 wrote:
>
> Hi
>
> Il dom 7 gen 2024, 17:08 Fabio Estevam  ha scritto:
>>
>> Hi Michael,
>>
>> On Sat, Jan 6, 2024 at 5:49 AM Michael Nazzareno Trimarchi
>>  wrote:
>> >
>> > Hi
>> >
>> > Is this code correct?
>> >
>> > if (tcp_seq_num >= initial_data_seq_num &&
>> > store_block(pkt, tcp_seq_num - initial_data_seq_num,
>> > len) != 0) {
>> > wget_fail("wget: store error\n",
>> >   tcp_seq_num, tcp_ack_num, action);
>> > return;
>> > }
>> >
>> > Can not be seq_num wrap around? Another point seems that is not
>> > guarantee packet reassembly
>>
>> If you submit a patch, I will be glad to test it.
>>
>> Cheers
>
>
> I have already wrote something but I can not test. Will send tonight. My 
> feeling is that sometime the initial sequence number of TCP ip is next to 
> wrap around but not sure.
>

I have sent but not sure about it, just compile for now ;)

> Michael



-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
mich...@amarulasolutions.com
__

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
i...@amarulasolutions.com
www.amarulasolutions.com


[RFC PATCH] net: wget: Take in account tcp sequence number wrap around

2024-01-07 Thread Michael Trimarchi
Coming from some discussion on mailing about wget unconsistent. It's
just and idea to play around

Signed-off-by: Michael Trimarchi 
---

I'm on a train ;). No board to test

---
 include/net/tcp.h | 10 ++
 net/wget.c|  8 
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index c29d4ce24a..584813b637 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -88,6 +88,16 @@ struct ip_tcp_hdr {
 #define TCP_MSS1460/* Max segment size 
*/
 #define TCP_SCALE  0x01/* Scale*/
 
+/*
+ * The next routines deal with comparing 32 bit unsigned ints
+ * and worry about wraparound (automatic with unsigned arithmetic).
+ */
+static inline bool before(__u32 seq1, __u32 seq2)
+{
+   return (__s32)(seq1-seq2) < 0;
+}
+#define after(seq2, seq1)  before(seq1, seq2)
+
 /**
  * struct tcp_mss - TCP option structure for MSS (Max segment size)
  * @kind: Field ID
diff --git a/net/wget.c b/net/wget.c
index 8bb4d72db1..99a688846f 100644
--- a/net/wget.c
+++ b/net/wget.c
@@ -260,8 +260,8 @@ static void wget_connected(uchar *pkt, unsigned int 
tcp_seq_num,
(phys_addr_t)(pkt_q[i].pkt),
pkt_q[i].len);
store_block(ptr1,
-   pkt_q[i].tcp_seq_num -
-   initial_data_seq_num,
+   (unsigned 
int)((s32)pkt_q[i].tcp_seq_num -
+   (s32)initial_data_seq_num),
pkt_q[i].len);
unmap_sysmem(ptr1);
debug_cond(DEBUG_WGET,
@@ -333,8 +333,8 @@ static void wget_handler(uchar *pkt, u16 dport,
   "wget: Transferring, seq=%x, ack=%x,len=%x\n",
   tcp_seq_num, tcp_ack_num, len);
 
-   if (tcp_seq_num >= initial_data_seq_num &&
-   store_block(pkt, tcp_seq_num - initial_data_seq_num,
+   if (!before(initial_data_seq_num, tcp_seq_num) &&
+   store_block(pkt, (unsigned int)((s32)tcp_seq_num - 
(s32)initial_data_seq_num),
len) != 0) {
wget_fail("wget: store error\n",
  tcp_seq_num, tcp_ack_num, action);
-- 
2.40.1



Re: inconsistent wget behavior

2024-01-07 Thread Michael Nazzareno Trimarchi
Hi

Il dom 7 gen 2024, 17:08 Fabio Estevam  ha scritto:

> Hi Michael,
>
> On Sat, Jan 6, 2024 at 5:49 AM Michael Nazzareno Trimarchi
>  wrote:
> >
> > Hi
> >
> > Is this code correct?
> >
> > if (tcp_seq_num >= initial_data_seq_num &&
> > store_block(pkt, tcp_seq_num - initial_data_seq_num,
> > len) != 0) {
> > wget_fail("wget: store error\n",
> >   tcp_seq_num, tcp_ack_num, action);
> > return;
> > }
> >
> > Can not be seq_num wrap around? Another point seems that is not
> > guarantee packet reassembly
>
> If you submit a patch, I will be glad to test it.
>
> Cheers
>

I have already wrote something but I can not test. Will send tonight. My
feeling is that sometime the initial sequence number of TCP ip is next to
wrap around but not sure.

Michael

>


Re: inconsistent wget behavior

2024-01-07 Thread Fabio Estevam
Hi Michael,

On Sat, Jan 6, 2024 at 5:49 AM Michael Nazzareno Trimarchi
 wrote:
>
> Hi
>
> Is this code correct?
>
> if (tcp_seq_num >= initial_data_seq_num &&
> store_block(pkt, tcp_seq_num - initial_data_seq_num,
> len) != 0) {
> wget_fail("wget: store error\n",
>   tcp_seq_num, tcp_ack_num, action);
> return;
> }
>
> Can not be seq_num wrap around? Another point seems that is not
> guarantee packet reassembly

If you submit a patch, I will be glad to test it.

Cheers


[PATCH 4/4] doc: sophgo: milkv_duo: document Milk-V Duo board

2024-01-07 Thread Kongyang Liu
Add document for Milk-V Duo board which based on Sophgo's CV1800B SoC.

Signed-off-by: Kongyang Liu 
---

 doc/board/index.rst|  1 +
 doc/board/sophgo/index.rst |  8 ++
 doc/board/sophgo/milkv_duo.rst | 50 ++
 3 files changed, 59 insertions(+)
 create mode 100644 doc/board/sophgo/index.rst
 create mode 100644 doc/board/sophgo/milkv_duo.rst

diff --git a/doc/board/index.rst b/doc/board/index.rst
index 531e547e7e..a0bd534742 100644
--- a/doc/board/index.rst
+++ b/doc/board/index.rst
@@ -45,6 +45,7 @@ Board-specific doc
sifive/index
sipeed/index
socionext/index
+   sophgo/index
st/index
starfive/index
ste/index
diff --git a/doc/board/sophgo/index.rst b/doc/board/sophgo/index.rst
new file mode 100644
index 00..e097afdac6
--- /dev/null
+++ b/doc/board/sophgo/index.rst
@@ -0,0 +1,8 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Sophgo
+==
+.. toctree::
+   :maxdepth: 1
+
+   milkv_duo
diff --git a/doc/board/sophgo/milkv_duo.rst b/doc/board/sophgo/milkv_duo.rst
new file mode 100644
index 00..b63304b510
--- /dev/null
+++ b/doc/board/sophgo/milkv_duo.rst
@@ -0,0 +1,50 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Milk-V Duo
+==
+
+CV1800B RISC-V SoC
+--
+The CV1800B is a high-performance, low-power 1+1 64-bit RISC-V SoC from Sophgo.
+
+Mainline support
+
+The support for following drivers are already enabled:
+1. ns16550 UART Driver.
+
+Building
+
+1. Add the RISC-V toolchain to your PATH.
+2. Setup ARCH & cross compilation environment variable:
+
+.. code-block:: console
+
+   export CROSS_COMPILE=
+   cd 
+   make milkv_duo_defconfig
+   make
+
+This will generate u-boot-dtb.bin
+
+Booting
+~~~
+Currently, we rely on vendor FSBL(First Stage Boot Loader) to initialize the
+clock and load the u-boot image, then bootup from it.
+
+Sample boot log from Milk-V Duo board
+~
+.. code-block:: none
+
+   U-Boot 2024.01-rc5-00010-g51965baa36 (Dec 28 2023 - 13:15:53 +0800)milkv_duo
+
+   DRAM:  63.3 MiB
+   Core:  10 devices, 8 uclasses, devicetree: separate
+   Loading Environment from nowhere... OK
+   In:serial@414
+   Out:   serial@414
+   Err:   serial@414
+   Net:   No ethernet found.
+   milkv_duo# cpu detail
+ 0: cpu@0  rv64imafdc
+  ID = 0, freq = 0 Hz: L1 cache, MMU
+   milkv_duo#
-- 
2.41.0



[PATCH 3/4] configs: milkv_duo_defconfig: Add initial config

2024-01-07 Thread Kongyang Liu
Add basic config for Milk-V Duo board which make it capable of booting into
serial console.

Signed-off-by: Kongyang Liu 
---

 configs/milkv_duo_defconfig | 24 
 1 file changed, 24 insertions(+)
 create mode 100644 configs/milkv_duo_defconfig

diff --git a/configs/milkv_duo_defconfig b/configs/milkv_duo_defconfig
new file mode 100644
index 00..c4782639ef
--- /dev/null
+++ b/configs/milkv_duo_defconfig
@@ -0,0 +1,24 @@
+CONFIG_RISCV=y
+CONFIG_SYS_MALLOC_LEN=0x82
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8230
+CONFIG_DEFAULT_DEVICE_TREE="cv1800b-milkv-duo"
+CONFIG_IDENT_STRING="milkv_duo"
+CONFIG_SYS_LOAD_ADDR=0x8008
+CONFIG_TARGET_MILKV_DUO=y
+CONFIG_ARCH_RV64I=y
+CONFIG_RISCV_SMODE=y
+CONFIG_FIT=y
+CONFIG_SUPPORT_RAW_INITRD=y
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="milkv_duo# "
+CONFIG_SYS_MAXARGS=64
+CONFIG_SYS_CBSIZE=512
+CONFIG_SYS_PBSIZE=544
+CONFIG_SYS_BOOTM_LEN=0x400
+CONFIG_ENV_OVERWRITE=y
+CONFIG_SYS_NS16550=y
+CONFIG_SYS_NS16550_MEM32=y
+# CONFIG_EFI_LOADER is not set
-- 
2.41.0



[PATCH 2/4] riscv: dts: sophgo: Add basic device tree for Milk-V Duo board

2024-01-07 Thread Kongyang Liu
Import device tree from Linux kernel to add basic support for CPU, PLIC,
UART and Timer. The name cv1800b in the filename represent the chip used
on Milk-V Duo board.

Signed-off-by: Kongyang Liu 
---

 arch/riscv/dts/Makefile  |   1 +
 arch/riscv/dts/cv1800b-milkv-duo.dts |  38 +
 arch/riscv/dts/cv1800b.dtsi  | 123 +++
 3 files changed, 162 insertions(+)
 create mode 100644 arch/riscv/dts/cv1800b-milkv-duo.dts
 create mode 100644 arch/riscv/dts/cv1800b.dtsi

diff --git a/arch/riscv/dts/Makefile b/arch/riscv/dts/Makefile
index be6c8a4227..b9e1678676 100644
--- a/arch/riscv/dts/Makefile
+++ b/arch/riscv/dts/Makefile
@@ -2,6 +2,7 @@
 
 dtb-$(CONFIG_TARGET_ANDES_AE350) += ae350_32.dtb ae350_64.dtb
 dtb-$(CONFIG_TARGET_MICROCHIP_ICICLE) += mpfs-icicle-kit.dtb
+dtb-$(CONFIG_TARGET_MILKV_DUO) += cv1800b-milkv-duo.dtb
 dtb-$(CONFIG_TARGET_QEMU_VIRT) += qemu-virt32.dtb qemu-virt64.dtb
 dtb-$(CONFIG_TARGET_OPENPITON_RISCV64) += openpiton-riscv64.dtb
 dtb-$(CONFIG_TARGET_SIFIVE_UNLEASHED) += hifive-unleashed-a00.dtb
diff --git a/arch/riscv/dts/cv1800b-milkv-duo.dts 
b/arch/riscv/dts/cv1800b-milkv-duo.dts
new file mode 100644
index 00..3af9e34b3b
--- /dev/null
+++ b/arch/riscv/dts/cv1800b-milkv-duo.dts
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2023 Jisheng Zhang 
+ */
+
+/dts-v1/;
+
+#include "cv1800b.dtsi"
+
+/ {
+   model = "Milk-V Duo";
+   compatible = "milkv,duo", "sophgo,cv1800b";
+
+   aliases {
+   serial0 = &uart0;
+   serial1 = &uart1;
+   serial2 = &uart2;
+   serial3 = &uart3;
+   serial4 = &uart4;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory@8000 {
+   device_type = "memory";
+   reg = <0x8000 0x3f4>;
+   };
+};
+
+&osc {
+   clock-frequency = <2500>;
+};
+
+&uart0 {
+   status = "okay";
+};
diff --git a/arch/riscv/dts/cv1800b.dtsi b/arch/riscv/dts/cv1800b.dtsi
new file mode 100644
index 00..df40e87ee0
--- /dev/null
+++ b/arch/riscv/dts/cv1800b.dtsi
@@ -0,0 +1,123 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2023 Jisheng Zhang 
+ */
+
+#include 
+
+/ {
+   compatible = "sophgo,cv1800b";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   cpus: cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   timebase-frequency = <2500>;
+
+   cpu0: cpu@0 {
+   compatible = "thead,c906", "riscv";
+   device_type = "cpu";
+   reg = <0>;
+   d-cache-block-size = <64>;
+   d-cache-sets = <512>;
+   d-cache-size = <65536>;
+   i-cache-block-size = <64>;
+   i-cache-sets = <128>;
+   i-cache-size = <32768>;
+   mmu-type = "riscv,sv39";
+   riscv,isa = "rv64imafdc";
+   riscv,isa-base = "rv64i";
+   riscv,isa-extensions = "i", "m", "a", "f", "d", "c", 
"zicntr", "zicsr",
+  "zifencei", "zihpm";
+
+   cpu0_intc: interrupt-controller {
+   compatible = "riscv,cpu-intc";
+   interrupt-controller;
+   #address-cells = <0>;
+   #interrupt-cells = <1>;
+   };
+   };
+   };
+
+   osc: oscillator {
+   compatible = "fixed-clock";
+   clock-output-names = "osc_25m";
+   #clock-cells = <0>;
+   };
+
+   soc {
+   compatible = "simple-bus";
+   interrupt-parent = <&plic>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   dma-noncoherent;
+   ranges;
+
+   uart0: serial@414 {
+   compatible = "snps,dw-apb-uart";
+   reg = <0x0414 0x100>;
+   interrupts = <44 IRQ_TYPE_LEVEL_HIGH>;
+   clocks = <&osc>;
+   reg-shift = <2>;
+   reg-io-width = <4>;
+   status = "disabled";
+   };
+
+   uart1: serial@415 {
+   compatible = "snps,dw-apb-uart";
+   reg = <0x0415 0x100>;
+   interrupts = <45 IRQ_TYPE_LEVEL_HIGH>;
+   clocks = <&osc>;
+   reg-shift = <2>;
+   reg-io-width = <4>;
+   status = "disabled";
+   };
+
+   uart2: serial@416 {
+   compatible = "snps,dw-apb-uart";
+ 

[PATCH 1/4] riscv: sophgo: milkv_duo: initial support added

2024-01-07 Thread Kongyang Liu
Add support for Sophgo's Milk-V Duo board, only minimal device tree and
serial console are enabled, and it can boot via vendor first stage
bootloader.

Signed-off-by: Kongyang Liu 

---

 arch/riscv/Kconfig |  4 
 board/sophgo/milkv_duo/Kconfig | 28 
 board/sophgo/milkv_duo/MAINTAINERS |  6 ++
 board/sophgo/milkv_duo/Makefile|  5 +
 board/sophgo/milkv_duo/board.c |  9 +
 include/configs/milkv_duo.h| 16 
 6 files changed, 68 insertions(+)
 create mode 100644 board/sophgo/milkv_duo/Kconfig
 create mode 100644 board/sophgo/milkv_duo/MAINTAINERS
 create mode 100644 board/sophgo/milkv_duo/Makefile
 create mode 100644 board/sophgo/milkv_duo/board.c
 create mode 100644 include/configs/milkv_duo.h

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 6d0d812ddb..de99ce3a28 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -14,6 +14,9 @@ config TARGET_ANDES_AE350
 config TARGET_MICROCHIP_ICICLE
bool "Support Microchip PolarFire-SoC Icicle Board"
 
+config TARGET_MILKV_DUO
+   bool "Support Milk-v Duo Board"
+
 config TARGET_OPENPITON_RISCV64
bool "Support RISC-V cores on OpenPiton SoC"
 
@@ -80,6 +83,7 @@ source "board/openpiton/riscv64/Kconfig"
 source "board/sifive/unleashed/Kconfig"
 source "board/sifive/unmatched/Kconfig"
 source "board/sipeed/maix/Kconfig"
+source "board/sophgo/milkv_duo/Kconfig"
 source "board/starfive/visionfive2/Kconfig"
 source "board/thead/th1520_lpi4a/Kconfig"
 
diff --git a/board/sophgo/milkv_duo/Kconfig b/board/sophgo/milkv_duo/Kconfig
new file mode 100644
index 00..2a458f291c
--- /dev/null
+++ b/board/sophgo/milkv_duo/Kconfig
@@ -0,0 +1,28 @@
+if TARGET_MILKV_DUO
+
+config SYS_BOARD
+   default "milkv_duo"
+
+config SYS_VENDOR
+   default "sophgo"
+
+config SYS_CPU
+   default "generic"
+
+config SYS_CONFIG_NAME
+   default "milkv_duo"
+
+config TEXT_BASE
+   default 0x8020
+
+config ENV_SIZE
+   default 0x2
+
+config ENV_SECT_SIZE
+   default 0x4
+
+config BOARD_SPECIFIC_OPTIONS
+   def_bool y
+   select GENERIC_RISCV
+
+endif
diff --git a/board/sophgo/milkv_duo/MAINTAINERS 
b/board/sophgo/milkv_duo/MAINTAINERS
new file mode 100644
index 00..651a0592f7
--- /dev/null
+++ b/board/sophgo/milkv_duo/MAINTAINERS
@@ -0,0 +1,6 @@
+Milk-V Duo
+M: Kongyang Liu 
+S: Maintained
+F: board/sophgo/milkv_duo/
+F: configs/milkv_duo_defconfig
+F: doc/board/sophgo/milkv_duo.rst
diff --git a/board/sophgo/milkv_duo/Makefile b/board/sophgo/milkv_duo/Makefile
new file mode 100644
index 00..a087013f5c
--- /dev/null
+++ b/board/sophgo/milkv_duo/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2024, Kongyang Liu 
+
+obj-y := board.o
diff --git a/board/sophgo/milkv_duo/board.c b/board/sophgo/milkv_duo/board.c
new file mode 100644
index 00..eaa47be173
--- /dev/null
+++ b/board/sophgo/milkv_duo/board.c
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2024, Kongyang Liu 
+ */
+
+int board_init(void)
+{
+   return 0;
+}
diff --git a/include/configs/milkv_duo.h b/include/configs/milkv_duo.h
new file mode 100644
index 00..dd1d146c50
--- /dev/null
+++ b/include/configs/milkv_duo.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2024, Kongyang Liu 
+ *
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define CFG_SYS_SDRAM_BASE 0x8000
+
+#define CFG_EXTRA_ENV_SETTINGS \
+   "consoledev=ttyS0" \
+   "baudrate=115200\0"\
+
+#endif /* __CONFIG_H */
-- 
2.41.0



[PATCH 0/4] riscv: sophgo: milkv_duo: add support for Milk-V Duo board

2024-01-07 Thread Kongyang Liu
The Milk-V Duo board is built upon Sophgo's CV1800B SoC, featuring two
XuanTie C906 CPUs running at 1.0GHz and 700MHz, respectively.

This series introduces fundamental support for the Milk-V Duo board,
encompassing UART, CPU, and PLIC support. This ensures that U-Boot can
operate in serial console mode.


Kongyang Liu (4):
  riscv: sophgo: milkv_duo: initial support added
  riscv: dts: sophgo: Add basic device tree for Milk-V Duo board
  configs: milkv_duo_defconfig: Add initial config
  doc: sophgo: milkv_duo: document Milk-V Duo board

 arch/riscv/Kconfig   |   4 +
 arch/riscv/dts/Makefile  |   1 +
 arch/riscv/dts/cv1800b-milkv-duo.dts |  38 +
 arch/riscv/dts/cv1800b.dtsi  | 123 +++
 board/sophgo/milkv_duo/Kconfig   |  28 ++
 board/sophgo/milkv_duo/MAINTAINERS   |   6 ++
 board/sophgo/milkv_duo/Makefile  |   5 ++
 board/sophgo/milkv_duo/board.c   |   9 ++
 configs/milkv_duo_defconfig  |  24 ++
 doc/board/index.rst  |   1 +
 doc/board/sophgo/index.rst   |   8 ++
 doc/board/sophgo/milkv_duo.rst   |  50 +++
 include/configs/milkv_duo.h  |  16 
 13 files changed, 313 insertions(+)
 create mode 100644 arch/riscv/dts/cv1800b-milkv-duo.dts
 create mode 100644 arch/riscv/dts/cv1800b.dtsi
 create mode 100644 board/sophgo/milkv_duo/Kconfig
 create mode 100644 board/sophgo/milkv_duo/MAINTAINERS
 create mode 100644 board/sophgo/milkv_duo/Makefile
 create mode 100644 board/sophgo/milkv_duo/board.c
 create mode 100644 configs/milkv_duo_defconfig
 create mode 100644 doc/board/sophgo/index.rst
 create mode 100644 doc/board/sophgo/milkv_duo.rst
 create mode 100644 include/configs/milkv_duo.h

-- 
2.41.0



Re: [PATCH 3/6] board: ti: am62x: Add basic initialization for usb voltage, 32k crystal, debounce

2024-01-07 Thread Jan Kiszka
On 26.07.23 13:10, Nishanth Menon wrote:
> On 00:35-20230726, Francesco Dolcini wrote:
> [...]

 At least the ones we have currently (I am not sure about toradex,
 phytech etc), seem to operate the vdd_core at 0.85V .. (which is what
 USB is dependent upon).
>>>
>>> For Toradex, we do have the equivalent code in our board file, see
>>> https://git.toradex.com/cgit/u-boot-toradex.git/tree/board/toradex/verdin-am62/verdin-am62.c?h=toradex_ti-u-boot-2023.04#n92
>>>
>>> The 32kHz configuration is just different for us, we do not re-use the
>>> same you have here.
>
> True, you are hitting the bypass control and not powering on the
> oscillator control since the 32k is incoming from RTC, in my case, since
> I have an actual 32k crystal, I am clearing the powerdown.
>
>
>>>
>>> The debounce conf registers I have no idea what they are about,
>>> something we should have also on our board? Any additional details?
>>
>> So, I got curious and checked on the datasheet/TRM on this debounce. If
>> I understood correctly this is to have debounce on GPIO and/or EQEP.
>
> Typically, yes - input signals more useful for eQEP or GPIO. but the
> implementation is at pin level which, technically could be used for
> other purposes (but I have'nt seen any).
>
>>
>> However to my understanding this would need to have the corresponding
>> DEBOUNCE_SEL register written on the pad configuration, and by default it's 
>> 0.
>>
>> What's the use case for this debounce configuration you have here?
>
> TRM was a bit of a crap (internal ticket was filed to improve), but long
> story short:
> * bootloader configures delays per index
> * in the pinmux configuration, we pick which index to use for the pin
>
> On Beagleplay, for example, the HDMI hot plug detect GPIO benefited from
> this[1]. Corresponding pinctrl.h macros were posted in [2].
>
> Why do it in the bootloader? since gpio inputs could also used in u-boot
> (e.g. MMC/CD)
>
>
> All said, Tom's question is very valid - we'd rather not modify evm.c
> for these specific configurations (popcorn as they might be), and we
> need to figure out a better option to introduce this kind of variation
> cleanly. For now, I will try dropping this patch.
>
>
> [1] 
> https://git.beagleboard.org/beagleboard/linux/-/blob/v6.1.33-ti-rt-arm64-r6/arch/arm64/boot/dts/ti/k3-am625-beagleplay.dts#L311
> [2] https://lore.kernel.org/all/20230619131620.3286650-1...@ti.com/
>

What happened to this? I still need something like this patch (a version
that has the CFG register writes correctly ordered) on top of current
master in order to get WIFI on the Beagleplay.

Jan



[PATCH 1/1] boot: superfluous assignment in bootflow_menu_new()

2024-01-07 Thread Heinrich Schuchardt
ret is assigned a value 0 which is never used but
is immediately overwritten in the next statement.

Addresses-Coverity-ID: 453304 ("Unused value")
Signed-off-by: Heinrich Schuchardt 
---
 boot/bootflow_menu.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/boot/bootflow_menu.c b/boot/bootflow_menu.c
index 7c1abe5772..16f9cd8f8c 100644
--- a/boot/bootflow_menu.c
+++ b/boot/bootflow_menu.c
@@ -120,7 +120,6 @@ int bootflow_menu_new(struct expo **expp)
 
if (ret < 0)
return log_msg_ret("itm", -EINVAL);
-   ret = 0;
priv->num_bootflows++;
}
 
-- 
2.43.0



[PATCH 1/1] boot: boot_flow_iter_set() called with uninitialized methods_flag

2024-01-07 Thread Heinrich Schuchardt
Some code paths do not initialize methods_flag before using it.
Initialize it to 0 in the definition line.

Addresses-Coverity-ID: ("467057 Uninitialized scalar variable")
Signed-off-by: Heinrich Schuchardt 
---
 boot/bootflow.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/boot/bootflow.c b/boot/bootflow.c
index 05484fd5b1..4b32d74fe1 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -241,7 +241,7 @@ static int iter_incr(struct bootflow_iter *iter)
if (iter->flags & BOOTFLOWIF_SINGLE_DEV) {
ret = -ENOENT;
} else {
-   int method_flags;
+   int method_flags = 0;
 
ret = 0;
dev = iter->dev;
@@ -260,7 +260,6 @@ static int iter_incr(struct bootflow_iter *iter)
} else if (IS_ENABLED(CONFIG_BOOTSTD_FULL) &&
   iter->flags & BOOTFLOWIF_SINGLE_MEDIA) {
log_debug("next in single\n");
-   method_flags = 0;
do {
/*
 * Move to the next bootdev child of this media
@@ -302,7 +301,6 @@ static int iter_incr(struct bootflow_iter *iter)
}
} else {
ret = bootdev_next_prio(iter, &dev);
-   method_flags = 0;
}
}
log_debug("ret=%d, dev=%p %s\n", ret, dev,
-- 
2.43.0



[PATCH 1/1] boot: remove dead code in bootflow_check()

2024-01-07 Thread Heinrich Schuchardt
The 'return 0;' statement is not reachable. Remove it.
'else' is superfluous after an if statement with return.

Addresses-Coverity-ID: 352451 ("Logically dead code")
Signed-off-by: Heinrich Schuchardt 
---
Simon, please, recheck the logic of the function.

The comment 'For 'all' we return all bootflows' implies that in this case
0 should be returned.

Best regards

Heinrich
---
 boot/bootflow.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/boot/bootflow.c b/boot/bootflow.c
index 1ea2966ae9..05484fd5b1 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -361,7 +361,7 @@ static int bootflow_check(struct bootflow_iter *iter, 
struct bootflow *bflow)
}
 
/* Unless there is nothing more to try, move to the next device */
-   else if (ret != BF_NO_MORE_PARTS && ret != -ENOSYS) {
+   if (ret != BF_NO_MORE_PARTS && ret != -ENOSYS) {
log_debug("Bootdev '%s' part %d method '%s': Error %d\n",
  dev->name, iter->part, iter->method->name, ret);
/*
@@ -371,10 +371,8 @@ static int bootflow_check(struct bootflow_iter *iter, 
struct bootflow *bflow)
if (iter->flags & BOOTFLOWIF_ALL)
return log_msg_ret("all", ret);
}
-   if (ret)
-   return log_msg_ret("check", ret);
 
-   return 0;
+   return log_msg_ret("check", ret);
 }
 
 int bootflow_scan_first(struct udevice *dev, const char *label,
-- 
2.43.0



[PATCH 1/1] sandbox: missing return value checks in eth-raw-os

2024-01-07 Thread Heinrich Schuchardt
We should check the return value of fcntl().

Addresses-Coverity-ID: 131108 ("Unchecked return value from library")
Addresses-Coverity-ID: 131109 ("Unchecked return value from library")
Signed-off-by: Heinrich Schuchardt 
---
 arch/sandbox/cpu/eth-raw-os.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c
index e59b96be5f..4ef2af0c36 100644
--- a/arch/sandbox/cpu/eth-raw-os.c
+++ b/arch/sandbox/cpu/eth-raw-os.c
@@ -105,7 +105,12 @@ static int _raw_packet_start(struct eth_sandbox_raw_priv 
*priv,
 
/* Make the socket non-blocking */
flags = fcntl(priv->sd, F_GETFL, 0);
-   fcntl(priv->sd, F_SETFL, flags | O_NONBLOCK);
+   ret = fcntl(priv->sd, F_SETFL, flags | O_NONBLOCK);
+   if (ret == -1) {
+   printf("Failed to make socket non-blocking: %d %s\n", errno,
+  strerror(errno));
+   return -errno;
+   }
 
/* Enable promiscuous mode to receive responses meant for us */
mr.mr_ifindex = device->sll_ifindex;
@@ -172,7 +177,12 @@ static int _local_inet_start(struct eth_sandbox_raw_priv 
*priv)
 
/* Make the socket non-blocking */
flags = fcntl(priv->sd, F_GETFL, 0);
-   fcntl(priv->sd, F_SETFL, flags | O_NONBLOCK);
+   ret = fcntl(priv->sd, F_SETFL, flags | O_NONBLOCK);
+   if (ret == -1) {
+   printf("Failed to make socket non-blocking: %d %s\n", errno,
+  strerror(errno));
+   return -errno;
+   }
 
/* Include the UDP/IP headers on send and receive */
ret = setsockopt(priv->sd, IPPROTO_IP, IP_HDRINCL, &one,
-- 
2.43.0