[PATCH 2/2] ARM: imx: Update DRAM timings with inline ECC on DH i.MX8MP DHCOM SoM

2023-12-15 Thread Marek Vasut
Import DRAM timings generated by the DDR tool 3.31 which introduce assorted
tweaks to the DRAM controller settings. Furthermore, enable DBI to improve
noise resilience of the DRAM bus by reducing the number of bit changes on
the bus.

Reduce the DRAM rate to 3600 MTps to remove all remaining correctable errors
reported by EDAC . It is not entirely clear why the slightly faster setting
does produce sporadic correctable errors, while this one does not, but this
could be related to simpler PLL setting at 3600 MTps.

Enable inline ECC which is necessary to detect ECC errors and collect
statistics by the EDAC driver in Linux. This reduces the DRAM size by
64 MiB for each 512 MiB of DRAM, so for a 4 GiB device the available
DRAM size becomes 3.5 GiB and for 2 GiB device the available DRAM size
becomes 1.8 GiB.

Signed-off-by: Marek Vasut 
---
Cc: "NXP i.MX U-Boot Team" 
Cc: Fabio Estevam 
Cc: Stefano Babic 
Cc: u-b...@dh-electronics.com
---
 .../dh_imx8mp/imx8mp_dhcom_pdk2.c |   5 +-
 board/dhelectronics/dh_imx8mp/lpddr4_timing.h |   6 +
 .../dh_imx8mp/lpddr4_timing_2G_32.c   | 130 ---
 .../dh_imx8mp/lpddr4_timing_4G_32.c   | 149 +++---
 board/dhelectronics/dh_imx8mp/spl.c   |  28 
 configs/imx8mp_dhcom_pdk2_defconfig   |   3 +-
 configs/imx8mp_dhcom_pdk3_defconfig   |   3 +-
 7 files changed, 208 insertions(+), 116 deletions(-)

diff --git a/board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c 
b/board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c
index 570d2f59ab8..5e21dfb6751 100644
--- a/board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c
+++ b/board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -30,9 +31,11 @@ int mach_cpu_init(void)
 int board_phys_sdram_size(phys_size_t *size)
 {
const u16 memsz[] = { 512, 1024, 1536, 2048, 3072, 4096, 6144, 8192 };
+   const u8 ecc = readl(DDRC_ECCCFG0(0)) & DDRC_ECCCFG0_ECC_MODE_MASK;
u8 memcfg = dh_get_memcfg();
 
-   *size = (u64)memsz[memcfg] << 20ULL;
+   /* 896 kiB, i.e. 1 MiB without 12.5% reserved for in-band ECC */
+   *size = (u64)memsz[memcfg] * (SZ_1M - (ecc ? (SZ_1M / 8) : 0));
 
return 0;
 }
diff --git a/board/dhelectronics/dh_imx8mp/lpddr4_timing.h 
b/board/dhelectronics/dh_imx8mp/lpddr4_timing.h
index 7894da3b918..c4d51174a33 100644
--- a/board/dhelectronics/dh_imx8mp/lpddr4_timing.h
+++ b/board/dhelectronics/dh_imx8mp/lpddr4_timing.h
@@ -9,6 +9,12 @@
 extern struct dram_timing_info dh_imx8mp_dhcom_dram_timing_16g_x32;
 extern struct dram_timing_info dh_imx8mp_dhcom_dram_timing_32g_x32;
 
+typedef void (*scrub_func_t)(void);
+extern void dh_imx8mp_dhcom_dram_scrub_16g_x32(void);
+extern void dh_imx8mp_dhcom_dram_scrub_32g_x32(void);
+
 u8 dh_get_memcfg(void);
 
+#define DDRC_ECCCFG0_ECC_MODE_MASK 0x7
+
 #endif /* __LPDDR4_TIMING_H__ */
diff --git a/board/dhelectronics/dh_imx8mp/lpddr4_timing_2G_32.c 
b/board/dhelectronics/dh_imx8mp/lpddr4_timing_2G_32.c
index 51b8c4cf7ba..add7a0bf23b 100644
--- a/board/dhelectronics/dh_imx8mp/lpddr4_timing_2G_32.c
+++ b/board/dhelectronics/dh_imx8mp/lpddr4_timing_2G_32.c
@@ -14,48 +14,62 @@ static struct dram_cfg_param ddr_ddrc_cfg[] = {
{ 0x3d400030, 0x1 },
{ 0x3d40, 0xa1080020 },
{ 0x3d400020, 0x1323 },
-   { 0x3d400024, 0x1c79100 },
-   { 0x3d400064, 0x710106 },
+   { 0x3d400024, 0x1b77400 },
+   { 0x3d400064, 0x6d00fc },
+#if IS_ENABLED(CONFIG_IMX8M_DRAM_INLINE_ECC)
+   { 0x3d400070, 0x7027fd4 },
+#else
{ 0x3d400070, 0x7027f90 },
+#endif
{ 0x3d400074, 0x790 },
-   { 0x3d4000d0, 0xc0030720 },
-   { 0x3d4000d4, 0xb8 },
+   { 0x3d4000d0, 0xc00306df },
+   { 0x3d4000d4, 0xb1 },
{ 0x3d4000dc, 0xe40036 },
-   { 0x3d4000e0, 0x33 },
+   { 0x3d4000e0, 0xf3 },
{ 0x3d4000e8, 0x660048 },
{ 0x3d4000ec, 0x160048 },
-   { 0x3d400100, 0x1e262028 },
-   { 0x3d400104, 0x7073b },
-   { 0x3d40010c, 0xe0e000 },
-   { 0x3d400110, 0x11040a11 },
+   { 0x3d400100, 0x1d241e26 },
+   { 0x3d400104, 0x70739 },
+   { 0x3d40010c, 0xd0d000 },
+   { 0x3d400110, 0x11040911 },
{ 0x3d400114, 0x2050e0e },
{ 0x3d400118, 0x1010008 },
{ 0x3d40011c, 0x502 },
{ 0x3d400130, 0x20700 },
{ 0x3d400134, 0xd12 },
-   { 0x3d400138, 0x10d },
-   { 0x3d400144, 0xbb005e },
-   { 0x3d400180, 0x3a5001c },
-   { 0x3d400184, 0x2f071e5 },
+   { 0x3d400138, 0x103 },
+   { 0x3d400144, 0xb4005a },
+   { 0x3d400180, 0x384001b },
+   { 0x3d400184, 0x2d06ddd },
{ 0x3d400188, 0x0 },
-   { 0x3d400190, 0x49b820c },
+   { 0x3d400190, 0x49f820c },
{ 0x3d400194, 0x80303 },
-   { 0x3d4001b4, 0x1b0c },
+   { 0x3d4001b4, 0x1f0c },
{ 0x3d4001a0, 0xe0400018 },
{ 0x3d4001a4, 0xdf00e4 },
{ 0x3d4001a8, 0x8

[PATCH 1/2] ARM: imx: Force DRAM regulators into FPWM mode on DH i.MX8MP DHCOM SoM

2023-12-15 Thread Marek Vasut
In case the Buck5 and Buck6 regulators which supply DRAM Vdd1 and Vdd2/Vddq
respectively operate in automatic PWM/PFM mode, the DRAM EDAC detects more
correctable errors than if the regulators operate in forced PWM only mode.
Force DRAM regulators to forced PWM mode only to stop tempting the DRAM.

Signed-off-by: Marek Vasut 
---
Cc: "NXP i.MX U-Boot Team" 
Cc: Fabio Estevam 
Cc: Stefano Babic 
Cc: u-b...@dh-electronics.com
---
 board/dhelectronics/dh_imx8mp/spl.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/board/dhelectronics/dh_imx8mp/spl.c 
b/board/dhelectronics/dh_imx8mp/spl.c
index 1b05da53c35..21b12a70c8e 100644
--- a/board/dhelectronics/dh_imx8mp/spl.c
+++ b/board/dhelectronics/dh_imx8mp/spl.c
@@ -94,6 +94,11 @@ static int dh_imx8mp_board_power_init(void)
/* To avoid timing risk from SoC to ARM, increase VDD_ARM to OD voltage 
0.95V */
pmic_reg_write(dev, PCA9450_BUCK2OUT_DVS0, 0x1c);
 
+   /* DRAM Vdd1 always FPWM */
+   pmic_reg_write(dev, PCA9450_BUCK5CTRL, 0x0d);
+   /* DRAM Vdd2/Vddq always FPWM */
+   pmic_reg_write(dev, PCA9450_BUCK6CTRL, 0x0d);
+
/* Set LDO4 and CONFIG2 to enable the I2C level translator. */
pmic_reg_write(dev, PCA9450_LDO4CTRL, 0x59);
pmic_reg_write(dev, PCA9450_CONFIG2, 0x1);
-- 
2.43.0



[PATCH] ARM: dts: imx7d-pico: Fix alias node indent

2023-12-15 Thread Marek Vasut
Switch from indent with spaces to indent with tabs. No functional change.

Fixes: f8548ce0e093 ("imx7d-pico: Fix the name of the u-boot.dtsi file")
Signed-off-by: Marek Vasut 
---
Cc: "NXP i.MX U-Boot Team" 
Cc: Fabio Estevam 
Cc: Stefano Babic 
Cc: u-boot@lists.denx.de
---
 arch/arm/dts/imx7d-pico-pi-u-boot.dtsi | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/dts/imx7d-pico-pi-u-boot.dtsi 
b/arch/arm/dts/imx7d-pico-pi-u-boot.dtsi
index c6856823c64..220748723b0 100644
--- a/arch/arm/dts/imx7d-pico-pi-u-boot.dtsi
+++ b/arch/arm/dts/imx7d-pico-pi-u-boot.dtsi
@@ -1,11 +1,11 @@
 #include "imx7s-u-boot.dtsi"
 
 /{
-aliases {
-mmc0 = &usdhc3;
-usb0 = &usbotg1;
-display0 = &lcdif;
-};
+   aliases {
+   mmc0 = &usdhc3;
+   usb0 = &usbotg1;
+   display0 = &lcdif;
+   };
 
wdt-reboot {
compatible = "wdt-reboot";
-- 
2.43.0



[PATCH v3 00/22] Complete decoupling of bootm logic from commands

2023-12-15 Thread Simon Glass
This series continues refactoring the bootm code to allow it to be used
with CONFIG_COMMAND disabled. The OS-handling code is refactored and
a new bootm_run() function is created to run through the bootm stages.
This completes the work.

A booti_go() function is created also, in case it proves useful, but at
last for now standard boot does not use this.

This is cmdd (part d of CMDLINE refactoring)
It depends on dm/bootstda-working
which depends on dm/cmdc-working

Changes in v3:
- Rename addr_fit to addr_img in struct bootm_info
- Rename addr_fit to addr_img in struct bootm_info
- Enable CONFIG_MEASURED_BOOT always and rely on CONFIG_MEASURED_BOOT
- Rename addr_fit to addr_img in struct bootm_info
- Add new boot_run() function

Changes in v2:
- Add new patch to enable more bootm OS methods in sandbox
- Split addition of struct bootm_info to its own patch
- Split changing of boot_os_fn parameters to a separate patch
- Split out adding the rest of struct bootm_info fields to separate patch
- Split out patch to move do_bootm_states() comment to header
- Split out booti removal of #ifdef
- Split out bootz removal of #ifdef
- Adjust patch to focus just on dropping the do_bootm_states() arguments
- Split do_bootm_states() rename to a separate patch
- Rework series to allow OS access to cmdline arguments for bootm

Simon Glass (22):
  mips: Add a reset_cpu() function
  m68k: Add a reset_cpu() function
  ppc: Add a reset_cpu() function
  nios2: Add a reset_cpu() function
  riscv: Add a reset_cpu() function
  bootm: Adjust how the board is reset
  sandbox: bootm: Enable more bootm OS methods
  bootm: Create a struct for argument information
  bootm: Adjust arguments of boot_os_fn
  bootm: Add more fields to bootm_info
  bootm: Move do_bootm_states() comment to header file
  booti: Avoid use of #ifdef
  bootz: Avoid use of #ifdef
  bootm: Drop arguments from do_bootm_states()
  bootm: Rename do_bootm_states() to bootm_run_states()
  bootm: Tidy up boot_selected_os()
  bootm: Create a function to run through the bootm states
  stm32: Use local vars in stm32prog for initrd and fdt
  bootm: Create a function to run through the bootz states
  stm32: Use bootm_run() and bootz_run()
  bootm: Create a function to run through the booti states
  bootm: Create a new boot_run() function to handle booting

 arch/arc/lib/bootm.c  |   5 +-
 arch/arm/lib/bootm.c  |   6 +-
 .../cmd_stm32prog/cmd_stm32prog.c |  33 ++--
 arch/m68k/lib/bootm.c |   5 +-
 arch/m68k/lib/traps.c |   7 +
 arch/microblaze/lib/bootm.c   |   6 +-
 arch/mips/cpu/cpu.c   |   8 +-
 arch/mips/lib/bootm.c |   8 +-
 arch/nios2/cpu/cpu.c  |   8 +-
 arch/nios2/lib/bootm.c|  10 +-
 arch/powerpc/lib/bootm.c  |   5 +-
 arch/powerpc/lib/traps.c  |  10 ++
 arch/riscv/cpu/cpu.c  |  13 ++
 arch/riscv/lib/bootm.c|  11 +-
 arch/riscv/lib/reset.c|   7 +-
 arch/sandbox/cpu/cpu.c|   8 +
 arch/sandbox/lib/bootm.c  |   5 +-
 arch/sh/lib/bootm.c   |   6 +-
 arch/x86/lib/bootm.c  |   6 +-
 arch/xtensa/lib/bootm.c   |   4 +-
 boot/bootm.c  | 119 ---
 boot/bootm_os.c   |  78 +-
 cmd/booti.c   |  55 ---
 cmd/bootm.c   |  43 --
 cmd/bootz.c   |  35 +++--
 configs/sandbox_defconfig |   3 +-
 include/bootm.h   | 142 --
 27 files changed, 444 insertions(+), 202 deletions(-)

-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 10/22] bootm: Add more fields to bootm_info

2023-12-15 Thread Simon Glass
Add fields for the three bootm parameters and other things needed for
booting. Also add a helper to set up the struct correctly.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Rename addr_fit to addr_img in struct bootm_info

Changes in v2:
- Split out adding the rest of struct bootm_info fields to separate patch

 boot/bootm.c|  8 
 include/bootm.h | 35 +++
 2 files changed, 43 insertions(+)

diff --git a/boot/bootm.c b/boot/bootm.c
index f1c45c380659..9e42fa5117d0 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -1192,6 +1192,14 @@ int bootm_boot_start(ulong addr, const char *cmdline)
return ret;
 }
 
+void bootm_init(struct bootm_info *bmi)
+{
+   memset(bmi, '\0', sizeof(struct bootm_info));
+   bmi->boot_progress = true;
+   if (IS_ENABLED(CONFIG_CMD_BOOTM))
+   bmi->images = &images;
+}
+
 /**
  * switch_to_non_secure_mode() - switch to non-secure mode
  *
diff --git a/include/bootm.h b/include/bootm.h
index 85c560d5a0ae..7cfaa0a7d053 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -19,17 +19,52 @@ struct cmd_tbl;
 /**
  * struct bootm_info() - information used when processing images to boot
  *
+ * These mirror the first three arguments of the bootm command. They are
+ * designed to handle any type of image, but typically it is a FIT.
+ *
+ * @addr_img: Address of image to bootm, as passed to
+ * genimg_get_kernel_addr_fit() for processing:
+ *
+ *NULL: Usees default load address, i.e. image_load_addr
+ *: Uses hex address
+ *
+ * For FIT:
+ *"[]#": Uses address (or image_load_addr) and also specifies
+ * the FIT configuration to use
+ *"[]:": Uses address (or image_load_addr) and also
+ * specifies the subimage name containing the OS
+ *
+ * @conf_ramdisk: Address (or with FIT, the name) of the ramdisk image, as
+ * passed to boot_get_ramdisk() for processing, or NULL for none
+ * @conf_fdt: Address (or with FIT, the name) of the FDT image, as passed to
+ * boot_get_fdt() for processing, or NULL for none
+ * @boot_progress: true to show boot progress
  * @images: images information
+ * @cmd_name: command which invoked this operation, e.g. "bootm"
  * @argc: Number of arguments to the command (excluding the actual command).
  * This is 0 if there are no arguments
  * @argv: NULL-terminated list of arguments, or NULL if there are no arguments
  */
 struct bootm_info {
+   const char *addr_img;
+   const char *conf_ramdisk;
+   const char *conf_fdt;
+   bool boot_progress;
struct bootm_headers *images;
+   const char *cmd_name;
int argc;
char *const *argv;
 };
 
+/**
+ * bootm_init() - Set up a bootm_info struct with useful defaults
+ *
+ * Set up the struct with default values for all members:
+ * @boot_progress is set to true and @images is set to the global images
+ * variable. Everything else is set to NULL except @argc which is 0
+ */
+void bootm_init(struct bootm_info *bmi);
+
 /*
  *  Continue booting an OS image; caller already has:
  *  - copied image header to global variable `header'
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 22/22] bootm: Create a new boot_run() function to handle booting

2023-12-15 Thread Simon Glass
Create a common function used by the three existing bootz/i/m_run()
functions, to reduce duplicated code.

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

Changes in v3:
- Add new boot_run() function

 boot/bootm.c| 40 ++--
 include/bootm.h | 18 ++
 2 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/boot/bootm.c b/boot/bootm.c
index 53236136f489..6a4cebcf7a08 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -1123,47 +1123,35 @@ err:
return ret;
 }
 
-int bootm_run(struct bootm_info *bmi)
+int boot_run(struct bootm_info *bmi, const char *cmd, int extra_states)
 {
int states;
 
-   bmi->cmd_name = "bootm";
-   states = BOOTM_STATE_START | BOOTM_STATE_FINDOS | BOOTM_STATE_PRE_LOAD |
-   BOOTM_STATE_FINDOTHER | BOOTM_STATE_LOADOS |
-   BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
-   BOOTM_STATE_OS_GO | BOOTM_STATE_MEASURE;
+   bmi->cmd_name = cmd;
+   states = BOOTM_STATE_MEASURE | BOOTM_STATE_OS_PREP |
+   BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO;
if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
states |= BOOTM_STATE_RAMDISK;
-   if (IS_ENABLED(CONFIG_PPC) || IS_ENABLED(CONFIG_MIPS))
-   states |= BOOTM_STATE_OS_CMDLINE;
+   states |= extra_states;
 
return bootm_run_states(bmi, states);
 }
 
-int bootz_run(struct bootm_info *bmi)
+int bootm_run(struct bootm_info *bmi)
 {
-   int states;
-
-   bmi->cmd_name = "bootz";
-   states = BOOTM_STATE_MEASURE | BOOTM_STATE_OS_PREP |
-   BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO;
-   if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
-   states |= BOOTM_STATE_RAMDISK;
+   return boot_run(bmi, "bootm", BOOTM_STATE_START | BOOTM_STATE_FINDOS |
+   BOOTM_STATE_PRE_LOAD | BOOTM_STATE_FINDOTHER |
+   BOOTM_STATE_LOADOS);
+}
 
-   return bootm_run_states(bmi, states);
+int bootz_run(struct bootm_info *bmi)
+{
+   return boot_run(bmi, "bootz", 0);
 }
 
 int booti_run(struct bootm_info *bmi)
 {
-   int states;
-
-   bmi->cmd_name = "booti";
-   states = BOOTM_STATE_MEASURE | BOOTM_STATE_OS_PREP |
-   BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO;
-   if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
-   states |= BOOTM_STATE_RAMDISK;
-
-   return bootm_run_states(bmi, states);
+   return boot_run(bmi, "booti", 0);
 }
 
 int bootm_boot_start(ulong addr, const char *cmdline)
diff --git a/include/bootm.h b/include/bootm.h
index eba35b33b4e5..9e0f8d60de0a 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -150,6 +150,24 @@ int bootm_measure(struct bootm_headers *images);
  */
 int bootm_run_states(struct bootm_info *bmi, int states);
 
+/**
+ * boot_run() - Run the entire bootm/booti/bootz process
+ *
+ * This runs through the boot process from start to finish, with a base set of
+ * states, along with the extra ones supplied.
+ *
+ * This uses bootm_run_states().
+ *
+ * Note that it is normally easier to use bootm_run(), etc. since they handle
+ * the extra states correctly.
+ *
+ * @bmi: bootm information
+ * @cmd: command being run, NULL if none
+ * @extra_states: Mask of extra states to use for the boot
+ * Return: 0 if ok, something else on error
+ */
+int boot_run(struct bootm_info *bmi, const char *cmd, int extra_states);
+
 /**
  * bootm_run() - Run the entire bootm process
  *
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 21/22] bootm: Create a function to run through the booti states

2023-12-15 Thread Simon Glass
In a few places, the booti command is used to handle a boot. We want
these to be done without needing CONFIG_CMDLINE, so add a new
booti_run() function to handle this.

So far this is not used.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Rework series to allow OS access to cmdline arguments for bootm

 boot/bootm.c| 13 +
 include/bootm.h | 13 +
 2 files changed, 26 insertions(+)

diff --git a/boot/bootm.c b/boot/bootm.c
index 40751a4c6e6f..53236136f489 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -1153,6 +1153,19 @@ int bootz_run(struct bootm_info *bmi)
return bootm_run_states(bmi, states);
 }
 
+int booti_run(struct bootm_info *bmi)
+{
+   int states;
+
+   bmi->cmd_name = "booti";
+   states = BOOTM_STATE_MEASURE | BOOTM_STATE_OS_PREP |
+   BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO;
+   if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
+   states |= BOOTM_STATE_RAMDISK;
+
+   return bootm_run_states(bmi, states);
+}
+
 int bootm_boot_start(ulong addr, const char *cmdline)
 {
char addr_str[30];
diff --git a/include/bootm.h b/include/bootm.h
index f7d6d27ecb0a..eba35b33b4e5 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -176,6 +176,19 @@ int bootm_run(struct bootm_info *bmi);
  */
 int bootz_run(struct bootm_info *bmi);
 
+/**
+ * booti_run() - Run the entire booti process
+ *
+ * This runs through the booti process from start to finish, using the default
+ * set of states.
+ *
+ * This uses bootm_run_states().
+ *
+ * @bmi: bootm information
+ * Return: 0 if ok, something else on error
+ */
+int booti_run(struct bootm_info *bmi);
+
 void arch_preboot_os(void);
 
 /*
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 20/22] stm32: Use bootm_run() and bootz_run()

2023-12-15 Thread Simon Glass
Use the new bootm/z_run() functions to avoid having to create an
argument list for the stm32prog code.

Signed-off-by: Simon Glass 
Reviewed-by: Patrick Delaunay 
---

Changes in v3:
- Rename addr_fit to addr_img in struct bootm_info

 .../cmd_stm32prog/cmd_stm32prog.c | 20 ++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c 
b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
index 8670535844d3..adee6e05b636 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -125,12 +126,10 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, 
int argc,
char dtb_addr[20];
char initrd_addr[40];
char *fdt_arg, *initrd_arg;
-   char *bootm_argv[5] = {
-   "bootm", boot_addr_start,
-   };
const void *uimage = (void *)data->uimage;
const void *dtb = (void *)data->dtb;
const void *initrd = (void *)data->initrd;
+   struct bootm_info bmi;
 
fdt_arg = dtb_addr;
if (!dtb)
@@ -141,7 +140,7 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, 
int argc,
snprintf(boot_addr_start, sizeof(boot_addr_start) - 1,
 "0x%p", uimage);
 
-   initrd_arg = "-";
+   initrd_arg = NULL;
if (initrd) {
snprintf(initrd_addr, sizeof(initrd_addr) - 1,
 "0x%p:0x%zx", initrd, data->initrd_size);
@@ -149,15 +148,18 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, 
int argc,
}
 
printf("Booting kernel at %s %s %s...\n\n\n", boot_addr_start,
-  initrd_arg, fdt_arg);
-   bootm_argv[2] = initrd_arg;
-   bootm_argv[3] = fdt_arg;
+  initrd_arg ?: "-", fdt_arg);
+
+   bootm_init(&bmi);
+   bmi.addr_img = boot_addr_start;
+   bmi.conf_ramdisk = initrd_arg;
+   bmi.conf_fdt = fdt_arg;
 
/* Try bootm for legacy and FIT format image */
if (genimg_get_format(uimage) != IMAGE_FORMAT_INVALID)
-   do_bootm(cmdtp, 0, 4, bootm_argv);
+   bootm_run(&bmi);
else if (IS_ENABLED(CONFIG_CMD_BOOTZ))
-   do_bootz(cmdtp, 0, 4, bootm_argv);
+   bootz_run(&bmi);
}
if (data->script)
cmd_source_script(data->script, NULL, NULL);
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 19/22] bootm: Create a function to run through the bootz states

2023-12-15 Thread Simon Glass
In a few places, the bootz command is used to handle a boot. We want
these to be done without needing CONFIG_CMDLINE, so add a new
bootz_run() function to handle this.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/bootm.c| 13 +
 cmd/bootz.c |  9 ++---
 include/bootm.h | 13 +
 3 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/boot/bootm.c b/boot/bootm.c
index cce8485f2d47..40751a4c6e6f 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -1140,6 +1140,19 @@ int bootm_run(struct bootm_info *bmi)
return bootm_run_states(bmi, states);
 }
 
+int bootz_run(struct bootm_info *bmi)
+{
+   int states;
+
+   bmi->cmd_name = "bootz";
+   states = BOOTM_STATE_MEASURE | BOOTM_STATE_OS_PREP |
+   BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO;
+   if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
+   states |= BOOTM_STATE_RAMDISK;
+
+   return bootm_run_states(bmi, states);
+}
+
 int bootm_boot_start(ulong addr, const char *cmdline)
 {
char addr_str[30];
diff --git a/cmd/bootz.c b/cmd/bootz.c
index 05b15eb4d761..b6bb4aae72d4 100644
--- a/cmd/bootz.c
+++ b/cmd/bootz.c
@@ -74,7 +74,7 @@ static int bootz_start(struct cmd_tbl *cmdtp, int flag, int 
argc,
 int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct bootm_info bmi;
-   int states, ret;
+   int ret;
 
/* Consume 'bootz' */
argc--; argv++;
@@ -99,12 +99,7 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char 
*const argv[])
bmi.conf_fdt = argv[2];
bmi.cmd_name = "bootz";
 
-   states = BOOTM_STATE_MEASURE | BOOTM_STATE_OS_PREP |
-   BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO;
-   if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
-   states |= BOOTM_STATE_RAMDISK;
-
-   ret = bootm_run_states(&bmi, states);
+   ret = bootz_run(&bmi);
 
return ret;
 }
diff --git a/include/bootm.h b/include/bootm.h
index 6e6b2ad8f7ef..f7d6d27ecb0a 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -163,6 +163,19 @@ int bootm_run_states(struct bootm_info *bmi, int states);
  */
 int bootm_run(struct bootm_info *bmi);
 
+/**
+ * bootz_run() - Run the entire bootz process
+ *
+ * This runs through the bootz process from start to finish, using the default
+ * set of states.
+ *
+ * This uses bootm_run_states().
+ *
+ * @bmi: bootm information
+ * Return: 0 if ok, something else on error
+ */
+int bootz_run(struct bootm_info *bmi);
+
 void arch_preboot_os(void);
 
 /*
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 18/22] stm32: Use local vars in stm32prog for initrd and fdt

2023-12-15 Thread Simon Glass
Rather than assigning to the bootm_argv[] array multiple times, use
local variables for the two things that can change and assign them at
the end.

This makes it easier to drop the array eventually.

Tidu up an overly short line while we are here.

Signed-off-by: Simon Glass 
Reviewed-by: Patrick Delaunay 
---

(no changes since v1)

 .../cmd_stm32prog/cmd_stm32prog.c | 23 +++
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c 
b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
index 2411bcf06d8f..8670535844d3 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
@@ -124,30 +124,35 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, 
int argc,
char boot_addr_start[20];
char dtb_addr[20];
char initrd_addr[40];
+   char *fdt_arg, *initrd_arg;
char *bootm_argv[5] = {
-   "bootm", boot_addr_start, "-", dtb_addr, NULL
+   "bootm", boot_addr_start,
};
const void *uimage = (void *)data->uimage;
const void *dtb = (void *)data->dtb;
const void *initrd = (void *)data->initrd;
 
+   fdt_arg = dtb_addr;
if (!dtb)
-   bootm_argv[3] = env_get("fdtcontroladdr");
+   fdt_arg = env_get("fdtcontroladdr");
else
-   snprintf(dtb_addr, sizeof(dtb_addr) - 1,
-"0x%p", dtb);
+   snprintf(dtb_addr, sizeof(dtb_addr) - 1, "0x%p", dtb);
 
snprintf(boot_addr_start, sizeof(boot_addr_start) - 1,
 "0x%p", uimage);
 
+   initrd_arg = "-";
if (initrd) {
-   snprintf(initrd_addr, sizeof(initrd_addr) - 1, 
"0x%p:0x%zx",
-initrd, data->initrd_size);
-   bootm_argv[2] = initrd_addr;
+   snprintf(initrd_addr, sizeof(initrd_addr) - 1,
+"0x%p:0x%zx", initrd, data->initrd_size);
+   initrd_arg = initrd_addr;
}
 
-   printf("Booting kernel at %s %s %s...\n\n\n",
-  boot_addr_start, bootm_argv[2], bootm_argv[3]);
+   printf("Booting kernel at %s %s %s...\n\n\n", boot_addr_start,
+  initrd_arg, fdt_arg);
+   bootm_argv[2] = initrd_arg;
+   bootm_argv[3] = fdt_arg;
+
/* Try bootm for legacy and FIT format image */
if (genimg_get_format(uimage) != IMAGE_FORMAT_INVALID)
do_bootm(cmdtp, 0, 4, bootm_argv);
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 17/22] bootm: Create a function to run through the bootm states

2023-12-15 Thread Simon Glass
In quite a few places, the bootm command is used to handle a boot. We
want these to be done without needing CONFIG_CMDLINE, so add a new
bootm_run() function to handle this.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Enable CONFIG_MEASURED_BOOT always and rely on CONFIG_MEASURED_BOOT

 boot/bootm.c| 17 +
 cmd/bootm.c | 14 +-
 include/bootm.h | 13 +
 3 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/boot/bootm.c b/boot/bootm.c
index 66b7e350aa86..cce8485f2d47 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -1123,6 +1123,23 @@ err:
return ret;
 }
 
+int bootm_run(struct bootm_info *bmi)
+{
+   int states;
+
+   bmi->cmd_name = "bootm";
+   states = BOOTM_STATE_START | BOOTM_STATE_FINDOS | BOOTM_STATE_PRE_LOAD |
+   BOOTM_STATE_FINDOTHER | BOOTM_STATE_LOADOS |
+   BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
+   BOOTM_STATE_OS_GO | BOOTM_STATE_MEASURE;
+   if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
+   states |= BOOTM_STATE_RAMDISK;
+   if (IS_ENABLED(CONFIG_PPC) || IS_ENABLED(CONFIG_MIPS))
+   states |= BOOTM_STATE_OS_CMDLINE;
+
+   return bootm_run_states(bmi, states);
+}
+
 int bootm_boot_start(ulong addr, const char *cmdline)
 {
char addr_str[30];
diff --git a/cmd/bootm.c b/cmd/bootm.c
index 26d20b9118d2..9737a2d28c03 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -136,7 +136,6 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int 
flag, int argc,
 int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct bootm_info bmi;
-   int states;
int ret;
 
/* determine if we have a sub command */
@@ -157,17 +156,6 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
return do_bootm_subcommand(cmdtp, flag, argc, argv);
}
 
-   states = BOOTM_STATE_START | BOOTM_STATE_FINDOS | BOOTM_STATE_PRE_LOAD |
-   BOOTM_STATE_FINDOTHER | BOOTM_STATE_LOADOS |
-   BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
-   BOOTM_STATE_OS_GO;
-   if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
-   states |= BOOTM_STATE_RAMDISK;
-   if (IS_ENABLED(CONFIG_MEASURED_BOOT))
-   states |= BOOTM_STATE_MEASURE;
-   if (IS_ENABLED(CONFIG_PPC) || IS_ENABLED(CONFIG_MIPS))
-   states |= BOOTM_STATE_OS_CMDLINE;
-
bootm_init(&bmi);
if (argc)
bmi.addr_img = argv[0];
@@ -180,7 +168,7 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
bmi.argc = argc;
bmi.argv = argv;
 
-   ret = bootm_run_states(&bmi, states);
+   ret = bootm_run(&bmi);
 
return ret ? CMD_RET_FAILURE : 0;
 }
diff --git a/include/bootm.h b/include/bootm.h
index 628d3d3e83ff..6e6b2ad8f7ef 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -150,6 +150,19 @@ int bootm_measure(struct bootm_headers *images);
  */
 int bootm_run_states(struct bootm_info *bmi, int states);
 
+/**
+ * bootm_run() - Run the entire bootm process
+ *
+ * This runs through the bootm process from start to finish, using the default
+ * set of states.
+ *
+ * This uses bootm_run_states().
+ *
+ * @bmi: bootm information
+ * Return: 0 if ok, something else on error
+ */
+int bootm_run(struct bootm_info *bmi);
+
 void arch_preboot_os(void);
 
 /*
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 15/22] bootm: Rename do_bootm_states() to bootm_run_states()

2023-12-15 Thread Simon Glass
Rename the function to bootm_run_states() to better indicate ts
purpose. The 'do_' prefix is used to indicate a command processor,
which this is now not.

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

(no changes since v2)

Changes in v2:
- Split do_bootm_states() rename to a separate patch

 arch/mips/lib/bootm.c | 2 +-
 boot/bootm.c  | 4 ++--
 cmd/booti.c   | 4 ++--
 cmd/bootm.c   | 4 ++--
 cmd/bootz.c   | 4 ++--
 include/bootm.h   | 4 ++--
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 286dbd5c4581..adb6b6cc229e 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -217,7 +217,7 @@ static int boot_reloc_fdt(struct bootm_headers *images)
 {
/*
 * In case of legacy uImage's, relocation of FDT is already done
-* by do_bootm_states() and should not repeated in 'bootm prep'.
+* by bootm_run_states() and should not repeated in 'bootm prep'.
 */
if (images->state & BOOTM_STATE_FDT) {
debug("## FDT already relocated\n");
diff --git a/boot/bootm.c b/boot/bootm.c
index be1124f75b54..f009e9ace652 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -990,7 +990,7 @@ unmap_image:
return ret;
 }
 
-int do_bootm_states(struct bootm_info *bmi, int states)
+int bootm_run_states(struct bootm_info *bmi, int states)
 {
struct bootm_headers *images = bmi->images;
boot_os_fn *boot_fn;
@@ -1152,7 +1152,7 @@ int bootm_boot_start(ulong addr, const char *cmdline)
bootm_init(&bmi);
bmi.addr_img = addr_str;
bmi.cmd_name = "bootm";
-   ret = do_bootm_states(&bmi, states);
+   ret = bootm_run_states(&bmi, states);
 
return ret;
 }
diff --git a/cmd/booti.c b/cmd/booti.c
index 0ab293bb880a..898df0f8896b 100644
--- a/cmd/booti.c
+++ b/cmd/booti.c
@@ -34,7 +34,7 @@ static int booti_start(struct bootm_info *bmi)
unsigned long decomp_len;
int ctype;
 
-   ret = do_bootm_states(bmi, BOOTM_STATE_START);
+   ret = bootm_run_states(bmi, BOOTM_STATE_START);
 
/* Setup Linux kernel Image entry point */
if (!bmi->addr_img) {
@@ -141,7 +141,7 @@ int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
states |= BOOTM_STATE_RAMDISK;
 
-   ret = do_bootm_states(&bmi, states);
+   ret = bootm_run_states(&bmi, states);
 
return ret;
 }
diff --git a/cmd/bootm.c b/cmd/bootm.c
index 76986c61e7b6..26d20b9118d2 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -118,7 +118,7 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int 
flag, int argc,
bmi.argc = argc;
bmi.argv = argv;
 
-   ret = do_bootm_states(&bmi, state);
+   ret = bootm_run_states(&bmi, state);
 
 #if defined(CONFIG_CMD_BOOTM_PRE_LOAD)
if (!ret && (state & BOOTM_STATE_PRE_LOAD))
@@ -180,7 +180,7 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
bmi.argc = argc;
bmi.argv = argv;
 
-   ret = do_bootm_states(&bmi, states);
+   ret = bootm_run_states(&bmi, states);
 
return ret ? CMD_RET_FAILURE : 0;
 }
diff --git a/cmd/bootz.c b/cmd/bootz.c
index 12da9422741d..05b15eb4d761 100644
--- a/cmd/bootz.c
+++ b/cmd/bootz.c
@@ -40,7 +40,7 @@ static int bootz_start(struct cmd_tbl *cmdtp, int flag, int 
argc,
bmi.conf_fdt = argv[2];
/* do not set up argc and argv[] since nothing uses them */
 
-   ret = do_bootm_states(&bmi, BOOTM_STATE_START);
+   ret = bootm_run_states(&bmi, BOOTM_STATE_START);
 
/* Setup Linux kernel zImage entry point */
if (!argc) {
@@ -104,7 +104,7 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
states |= BOOTM_STATE_RAMDISK;
 
-   ret = do_bootm_states(&bmi, states);
+   ret = bootm_run_states(&bmi, states);
 
return ret;
 }
diff --git a/include/bootm.h b/include/bootm.h
index 8010d2f98113..dbf883bb08ad 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -132,7 +132,7 @@ int bootm_find_images(ulong img_addr, const char 
*conf_ramdisk,
 int bootm_measure(struct bootm_headers *images);
 
 /**
- * do_bootm_states() - Execute selected states of the bootm command.
+ * bootm_run_states() - Execute selected states of the bootm command.
  *
  * Note that if states contains more than one flag it MUST contain
  * BOOTM_STATE_START, since this handles the addr_fit, conf_ramdisk and 
conf_fit
@@ -149,7 +149,7 @@ int bootm_measure(struct bootm_headers *images);
  * then the intent is to boot an OS, so this function will not return
  * unless the image type is standalone.
  */
-int do_bootm_states(struct bootm_info *bmi, int states);
+int bootm_run_states(struct bootm_info *bmi, int states);
 
 void arch_preboot_os(void);
 
-- 
2.43.0.47

[PATCH v3 16/22] bootm: Tidy up boot_selected_os()

2023-12-15 Thread Simon Glass
Use struct bootm_info with this function, to avoiding needing to
create a new one.

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

(no changes since v1)

 boot/bootm.c|  6 ++
 boot/bootm_os.c | 11 +++
 include/bootm.h |  3 +--
 3 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/boot/bootm.c b/boot/bootm.c
index f009e9ace652..66b7e350aa86 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -1092,8 +1092,7 @@ int bootm_run_states(struct bootm_info *bmi, int states)
if (!ret && (states & BOOTM_STATE_OS_FAKE_GO)) {
char *cmd_list = env_get("fakegocmd");
 
-   ret = boot_selected_os(bmi->argc, bmi->argv,
-  BOOTM_STATE_OS_FAKE_GO, images, boot_fn);
+   ret = boot_selected_os(BOOTM_STATE_OS_FAKE_GO, bmi, boot_fn);
if (!ret && cmd_list)
ret = run_command_list(cmd_list, -1, 0);
}
@@ -1107,8 +1106,7 @@ int bootm_run_states(struct bootm_info *bmi, int states)
 
/* Now run the OS! We hope this doesn't return */
if (!ret && (states & BOOTM_STATE_OS_GO))
-   ret = boot_selected_os(bmi->argc, bmi->argv, BOOTM_STATE_OS_GO,
-  images, boot_fn);
+   ret = boot_selected_os(BOOTM_STATE_OS_GO, bmi, boot_fn);
 
/* Deal with any fallout */
 err:
diff --git a/boot/bootm_os.c b/boot/bootm_os.c
index 4f547b1b1148..47a5fd78fb6a 100644
--- a/boot/bootm_os.c
+++ b/boot/bootm_os.c
@@ -566,20 +566,15 @@ __weak void board_preboot_os(void)
/* please define board specific board_preboot_os() */
 }
 
-int boot_selected_os(int argc, char *const argv[], int state,
-struct bootm_headers *images, boot_os_fn *boot_fn)
+int boot_selected_os(int state, struct bootm_info *bmi, boot_os_fn *boot_fn)
 {
-   struct bootm_info bmi;
arch_preboot_os();
board_preboot_os();
 
-   bmi.argc = argc;
-   bmi.argv = argv;
-   bmi.images = images;
-   boot_fn(state, &bmi);
+   boot_fn(state, bmi);
 
/* Stand-alone may return when 'autostart' is 'no' */
-   if (images->os.type == IH_TYPE_STANDALONE ||
+   if (bmi->images->os.type == IH_TYPE_STANDALONE ||
IS_ENABLED(CONFIG_SANDBOX) ||
state == BOOTM_STATE_OS_FAKE_GO) /* We expect to return */
return 0;
diff --git a/include/bootm.h b/include/bootm.h
index dbf883bb08ad..628d3d3e83ff 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -91,8 +91,7 @@ boot_os_fn *bootm_os_get_boot_func(int os);
 int bootm_host_load_images(const void *fit, int cfg_noffset);
 #endif
 
-int boot_selected_os(int argc, char *const argv[], int state,
-struct bootm_headers *images, boot_os_fn *boot_fn);
+int boot_selected_os(int state, struct bootm_info *bmi, boot_os_fn *boot_fn);
 
 ulong bootm_disable_interrupts(void);
 
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 14/22] bootm: Drop arguments from do_bootm_states()

2023-12-15 Thread Simon Glass
Use the bootm_info struct to hold the information required by bootm.

Now that none of the functions called from do_bootm_states() needs an
argv[] list, change the arguments of do_bootm_states() as well. Take
care to use the same value for boot_progress even though it is a little
inconsistent.

For booti make sure it only uses argv[] and argc at the top of the
function, so we can eventually refactor to remove these parameters.

With bootm, some OSes need access to the arguments provided to the
command, so set these up in the bootm_info struct, for bootm only.

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

Changes in v3:
- Rename addr_fit to addr_img in struct bootm_info

Changes in v2:
- Adjust patch to focus just on dropping the do_bootm_states() arguments

 boot/bootm.c| 52 -
 cmd/booti.c | 33 ---
 cmd/bootm.c | 33 +--
 cmd/bootz.c | 27 +
 include/bootm.h | 25 
 5 files changed, 105 insertions(+), 65 deletions(-)

diff --git a/boot/bootm.c b/boot/bootm.c
index 875f8a1c2a56..be1124f75b54 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -990,11 +990,9 @@ unmap_image:
return ret;
 }
 
-int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,
-   char *const argv[], int states, struct bootm_headers 
*images,
-   int boot_progress)
+int do_bootm_states(struct bootm_info *bmi, int states)
 {
-   struct bootm_info bmi;
+   struct bootm_headers *images = bmi->images;
boot_os_fn *boot_fn;
ulong iflag = 0;
int ret = 0, need_boot_fn;
@@ -1009,17 +1007,18 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, 
int argc,
ret = bootm_start();
 
if (!ret && (states & BOOTM_STATE_PRE_LOAD))
-   ret = bootm_pre_load(argv[0]);
+   ret = bootm_pre_load(bmi->addr_img);
 
if (!ret && (states & BOOTM_STATE_FINDOS))
-   ret = bootm_find_os(cmdtp->name, argv[0]);
+   ret = bootm_find_os(bmi->cmd_name, bmi->addr_img);
 
if (!ret && (states & BOOTM_STATE_FINDOTHER)) {
ulong img_addr;
 
-   img_addr = argc ? hextoul(argv[0], NULL) : image_load_addr;
-   ret = bootm_find_other(img_addr, cmd_arg1(argc, argv),
-  cmd_arg2(argc, argv));
+   img_addr = bmi->addr_img ? hextoul(bmi->addr_img, NULL)
+   : image_load_addr;
+   ret = bootm_find_other(img_addr, bmi->conf_ramdisk,
+  bmi->conf_fdt);
}
 
if (IS_ENABLED(CONFIG_MEASURED_BOOT) && !ret &&
@@ -1073,15 +1072,11 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, 
int argc,
return 1;
}
 
-   bmi.images = images;
-   bmi.argc = argc;
-   bmi.argv = argv;
-
/* Call various other states that are not generally used */
if (!ret && (states & BOOTM_STATE_OS_CMDLINE))
-   ret = boot_fn(BOOTM_STATE_OS_CMDLINE, &bmi);
+   ret = boot_fn(BOOTM_STATE_OS_CMDLINE, bmi);
if (!ret && (states & BOOTM_STATE_OS_BD_T))
-   ret = boot_fn(BOOTM_STATE_OS_BD_T, &bmi);
+   ret = boot_fn(BOOTM_STATE_OS_BD_T, bmi);
if (!ret && (states & BOOTM_STATE_OS_PREP)) {
ret = bootm_process_cmdline_env(images->os.os == IH_OS_LINUX);
if (ret) {
@@ -1089,7 +1084,7 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int 
argc,
ret = CMD_RET_FAILURE;
goto err;
}
-   ret = boot_fn(BOOTM_STATE_OS_PREP, &bmi);
+   ret = boot_fn(BOOTM_STATE_OS_PREP, bmi);
}
 
 #ifdef CONFIG_TRACE
@@ -1097,10 +1092,10 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, 
int argc,
if (!ret && (states & BOOTM_STATE_OS_FAKE_GO)) {
char *cmd_list = env_get("fakegocmd");
 
-   ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_FAKE_GO,
-   images, boot_fn);
+   ret = boot_selected_os(bmi->argc, bmi->argv,
+  BOOTM_STATE_OS_FAKE_GO, images, boot_fn);
if (!ret && cmd_list)
-   ret = run_command_list(cmd_list, -1, flag);
+   ret = run_command_list(cmd_list, -1, 0);
}
 #endif
 
@@ -1112,8 +1107,8 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int 
argc,
 
/* Now run the OS! We hope this doesn't return */
if (!ret && (states & BOOTM_STATE_OS_GO))
-   ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_GO,
-   images, boot_fn);
+   ret = boot_selected_os(bmi->argc, bmi->argv, BOOTM_STATE_OS_GO,
+  images, boot_fn);
 
   

[PATCH v3 12/22] booti: Avoid use of #ifdef

2023-12-15 Thread Simon Glass
Use the compiler to get the set of states, instead of the preprocessor.

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

(no changes since v2)

Changes in v2:
- Split out booti removal of #ifdef

 cmd/booti.c | 24 +++-
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/cmd/booti.c b/cmd/booti.c
index 41d40c962ec2..d3cceb7e0a39 100644
--- a/cmd/booti.c
+++ b/cmd/booti.c
@@ -105,6 +105,7 @@ static int booti_start(struct cmd_tbl *cmdtp, int flag, int 
argc,
 
 int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
+   int states;
int ret;
 
/* Consume 'booti' */
@@ -120,19 +121,16 @@ int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
bootm_disable_interrupts();
 
images.os.os = IH_OS_LINUX;
-#ifdef CONFIG_RISCV_SMODE
-   images.os.arch = IH_ARCH_RISCV;
-#elif CONFIG_ARM64
-   images.os.arch = IH_ARCH_ARM64;
-#endif
-   ret = do_bootm_states(cmdtp, flag, argc, argv,
-#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
- BOOTM_STATE_RAMDISK |
-#endif
- BOOTM_STATE_MEASURE |
- BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
- BOOTM_STATE_OS_GO,
- &images, 1);
+   if (IS_ENABLED(CONFIG_RISCV_SMODE))
+   images.os.arch = IH_ARCH_RISCV;
+   else if (IS_ENABLED(CONFIG_ARM64))
+   images.os.arch = IH_ARCH_ARM64;
+
+   states = BOOTM_STATE_MEASURE | BOOTM_STATE_OS_PREP |
+   BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO;
+   if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
+   states |= BOOTM_STATE_RAMDISK;
+   ret = do_bootm_states(cmdtp, flag, argc, argv, states, &images, 1);
 
return ret;
 }
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 13/22] bootz: Avoid use of #ifdef

2023-12-15 Thread Simon Glass
Use the compiler to get the set of states, instead of the preprocessor.

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

(no changes since v2)

Changes in v2:
- Split out bootz removal of #ifdef

 cmd/bootz.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/cmd/bootz.c b/cmd/bootz.c
index a652879ea5ec..8c25905598a8 100644
--- a/cmd/bootz.c
+++ b/cmd/bootz.c
@@ -64,7 +64,7 @@ static int bootz_start(struct cmd_tbl *cmdtp, int flag, int 
argc,
 
 int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
-   int ret;
+   int states, ret;
 
/* Consume 'bootz' */
argc--; argv++;
@@ -79,14 +79,13 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
bootm_disable_interrupts();
 
images.os.os = IH_OS_LINUX;
-   ret = do_bootm_states(cmdtp, flag, argc, argv,
-#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
- BOOTM_STATE_RAMDISK |
-#endif
- BOOTM_STATE_MEASURE |
- BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
- BOOTM_STATE_OS_GO,
- &images, 1);
+
+   states = BOOTM_STATE_MEASURE | BOOTM_STATE_OS_PREP |
+   BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO;
+   if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
+   states |= BOOTM_STATE_RAMDISK;
+
+   ret = do_bootm_states(cmdtp, flag, argc, argv, states, &images, 1);
 
return ret;
 }
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 11/22] bootm: Move do_bootm_states() comment to header file

2023-12-15 Thread Simon Glass
This is an exported function, so move the function comment to the
bootm.h header file.

Signed-off-by: Simon Glass 
Reviewed-by: Mattijs Korpershoek 
Reviewed-by: Tom Rini 
---

(no changes since v2)

Changes in v2:
- Split out patch to move do_bootm_states() comment to header

 boot/bootm.c| 25 -
 include/bootm.h | 25 +
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/boot/bootm.c b/boot/bootm.c
index 9e42fa5117d0..875f8a1c2a56 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -990,31 +990,6 @@ unmap_image:
return ret;
 }
 
-/**
- * Execute selected states of the bootm command.
- *
- * Note the arguments to this state must be the first argument, Any 'bootm'
- * or sub-command arguments must have already been taken.
- *
- * Note that if states contains more than one flag it MUST contain
- * BOOTM_STATE_START, since this handles and consumes the command line args.
- *
- * Also note that aside from boot_os_fn functions and bootm_load_os no other
- * functions we store the return value of in 'ret' may use a negative return
- * value, without special handling.
- *
- * @param cmdtpPointer to bootm command table entry
- * @param flag Command flags (CMD_FLAG_...)
- * @param argc Number of subcommand arguments (0 = no arguments)
- * @param argv Arguments
- * @param states   Mask containing states to run (BOOTM_STATE_...)
- * @param images   Image header information
- * @param boot_progress 1 to show boot progress, 0 to not do this
- * Return: 0 if ok, something else on error. Some errors will cause this
- * function to perform a reboot! If states contains BOOTM_STATE_OS_GO
- * then the intent is to boot an OS, so this function will not return
- * unless the image type is standalone.
- */
 int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[], int states, struct bootm_headers 
*images,
int boot_progress)
diff --git a/include/bootm.h b/include/bootm.h
index 7cfaa0a7d053..81f2514f1b7b 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -131,6 +131,31 @@ int bootm_find_images(ulong img_addr, const char 
*conf_ramdisk,
  */
 int bootm_measure(struct bootm_headers *images);
 
+/**
+ * Execute selected states of the bootm command.
+ *
+ * Note the arguments to this state must be the first argument, Any 'bootm'
+ * or sub-command arguments must have already been taken.
+ *
+ * Note that if states contains more than one flag it MUST contain
+ * BOOTM_STATE_START, since this handles and consumes the command line args.
+ *
+ * Also note that aside from boot_os_fn functions and bootm_load_os no other
+ * functions we store the return value of in 'ret' may use a negative return
+ * value, without special handling.
+ *
+ * @param cmdtpPointer to bootm command table entry
+ * @param flag Command flags (CMD_FLAG_...)
+ * @param argc Number of subcommand arguments (0 = no arguments)
+ * @param argv Arguments
+ * @param states   Mask containing states to run (BOOTM_STATE_...)
+ * @param images   Image header information
+ * @param boot_progress 1 to show boot progress, 0 to not do this
+ * Return: 0 if ok, something else on error. Some errors will cause this
+ * function to perform a reboot! If states contains BOOTM_STATE_OS_GO
+ * then the intent is to boot an OS, so this function will not return
+ * unless the image type is standalone.
+ */
 int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[], int states, struct bootm_headers 
*images,
int boot_progress);
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 09/22] bootm: Adjust arguments of boot_os_fn

2023-12-15 Thread Simon Glass
Adjust boot_os_fn to use struct bootm_info instead of the separate
argc, argv and image parameters. Update the handlers accordingly. Few
of the functions make use of the arguments, so this improves code size
slightly.

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

(no changes since v2)

Changes in v2:
- Split changing of boot_os_fn parameters to a separate patch

 arch/arc/lib/bootm.c|  5 ++-
 arch/arm/lib/bootm.c|  6 ++-
 arch/m68k/lib/bootm.c   |  5 ++-
 arch/microblaze/lib/bootm.c |  6 ++-
 arch/mips/lib/bootm.c   |  6 ++-
 arch/nios2/lib/bootm.c  | 10 +++--
 arch/powerpc/lib/bootm.c|  5 ++-
 arch/riscv/lib/bootm.c  | 11 +++---
 arch/sandbox/lib/bootm.c|  5 ++-
 arch/sh/lib/bootm.c |  6 ++-
 arch/x86/lib/bootm.c|  6 ++-
 arch/xtensa/lib/bootm.c |  4 +-
 boot/bootm.c| 11 --
 boot/bootm_os.c | 77 -
 include/bootm.h |  9 +
 15 files changed, 100 insertions(+), 72 deletions(-)

diff --git a/arch/arc/lib/bootm.c b/arch/arc/lib/bootm.c
index 44ec5864a1c6..b143392ee6c2 100644
--- a/arch/arc/lib/bootm.c
+++ b/arch/arc/lib/bootm.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -78,8 +79,10 @@ static void boot_jump_linux(struct bootm_headers *images, 
int flag)
board_jump_and_run(kernel_entry, r0, 0, r2);
 }
 
-int do_bootm_linux(int flag, int argc, char *argv[], struct bootm_headers 
*images)
+int do_bootm_linux(int flag, struct bootm_info *bmi)
 {
+   struct bootm_headers *images = bmi->images;
+
/* No need for those on ARC */
if ((flag & BOOTM_STATE_OS_BD_T) || (flag & BOOTM_STATE_OS_CMDLINE))
return -1;
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index c56285738a26..f30a483ed8b4 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -12,6 +12,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -378,9 +379,10 @@ static void boot_jump_linux(struct bootm_headers *images, 
int flag)
  * DIFFERENCE: Instead of calling prep and go at the end
  * they are called if subcommand is equal 0.
  */
-int do_bootm_linux(int flag, int argc, char *const argv[],
-  struct bootm_headers *images)
+int do_bootm_linux(int flag, struct bootm_info *bmi)
 {
+   struct bootm_headers *images = bmi->images;
+
/* No need for those on ARM */
if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE)
return -1;
diff --git a/arch/m68k/lib/bootm.c b/arch/m68k/lib/bootm.c
index 79d8b34c0d56..f2d02e437658 100644
--- a/arch/m68k/lib/bootm.c
+++ b/arch/m68k/lib/bootm.c
@@ -4,6 +4,7 @@
  * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -34,9 +35,9 @@ void arch_lmb_reserve(struct lmb *lmb)
arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 1024);
 }
 
-int do_bootm_linux(int flag, int argc, char *const argv[],
-  struct bootm_headers *images)
+int do_bootm_linux(int flag, struct bootm_info *bmi)
 {
+   struct bootm_headers *images = bmi->images;
int ret;
struct bd_info  *kbd;
void  (*kernel) (struct bd_info *, ulong, ulong, ulong, ulong);
diff --git a/arch/microblaze/lib/bootm.c b/arch/microblaze/lib/bootm.c
index f3ec4b741b88..cbe9d85aa911 100644
--- a/arch/microblaze/lib/bootm.c
+++ b/arch/microblaze/lib/bootm.c
@@ -7,6 +7,7 @@
  * Yasushi SHOJI 
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -81,9 +82,10 @@ static void boot_prep_linux(struct bootm_headers *images)
}
 }
 
-int do_bootm_linux(int flag, int argc, char *const argv[],
-  struct bootm_headers *images)
+int do_bootm_linux(int flag, struct bootm_info *bmi)
 {
+   struct bootm_headers *images = bmi->images;
+
images->cmdline_start = (ulong)env_get("bootargs");
 
/* cmdline init is the part of 'prep' and nothing to do for 'bdt' */
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index f1cff691f4fe..286dbd5c4581 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -4,6 +4,7 @@
  * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -300,9 +301,10 @@ static void boot_jump_linux(struct bootm_headers *images)
linux_extra);
 }
 
-int do_bootm_linux(int flag, int argc, char *const argv[],
-  struct bootm_headers *images)
+int do_bootm_linux(int flag, struct bootm_info *bmi)
 {
+   struct bootm_headers *images = bmi->images;
+
/* No need for those on MIPS */
if (flag & BOOTM_STATE_OS_BD_T)
return -1;
diff --git a/arch/nios2/lib/bootm.c b/arch/nios2/lib/bootm.c
index 06c094d0f1c7..657a17c7204f 100644
--- a/arch/nios2/lib/bootm.c
+++ b/arch/nios2/lib/bootm.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#

[PATCH v3 08/22] bootm: Create a struct for argument information

2023-12-15 Thread Simon Glass
Some OS functions require the arguments to the 'bootm' command. This is
inconvenient for two reasons.

Firstly, there may not be any actual command, if CMDLINE is not enabled
and programmatic boot is being used.

Secondly, most functions don't require the arguments, so it is
inefficient to pass them when not needed. For example it increases code
size.

Create a new struct which holds the arguments, which can be used if
needed.

Add the images pointer as well, since this is commonly needed.

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

(no changes since v2)

Changes in v2:
- Split addition of struct bootm_info to its own patch

 include/bootm.h | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/bootm.h b/include/bootm.h
index f5229ea90b33..a6d5d5ceee8f 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -16,6 +16,20 @@ struct cmd_tbl;
 #define BOOTM_ERR_OVERLAP  (-2)
 #define BOOTM_ERR_UNIMPLEMENTED(-3)
 
+/**
+ * struct bootm_info() - information used when processing images to boot
+ *
+ * @images: images information
+ * @argc: Number of arguments to the command (excluding the actual command).
+ * This is 0 if there are no arguments
+ * @argv: NULL-terminated list of arguments, or NULL if there are no arguments
+ */
+struct bootm_info {
+   struct bootm_headers *images;
+   int argc;
+   char *const *argv;
+};
+
 /*
  *  Continue booting an OS image; caller already has:
  *  - copied image header to global variable `header'
@@ -39,7 +53,7 @@ typedef int boot_os_fn(int flag, int argc, char *const argv[],
 extern boot_os_fn do_bootm_linux;
 extern boot_os_fn do_bootm_vxworks;
 
-int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
+int do_bootelf(struct cmd_tbl *cmdtp, int fglag, int argc, char *const argv[]);
 
 boot_os_fn *bootm_os_get_boot_func(int os);
 
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 07/22] sandbox: bootm: Enable more bootm OS methods

2023-12-15 Thread Simon Glass
It is useful for sandbox to build as much code as possible. Enable
support for booting various other operating systems. Add the missing
cache functions.

These operating systems do not actually boot on sandbox, of course.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Add new patch to enable more bootm OS methods in sandbox

 arch/sandbox/cpu/cpu.c| 8 
 configs/sandbox_defconfig | 3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index a1c5c7c4311a..d134905e3f5f 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -286,6 +286,14 @@ void sandbox_set_enable_pci_map(int enable)
enable_pci_map = enable;
 }
 
+void dcache_enable(void)
+{
+}
+
+void dcache_disable(void)
+{
+}
+
 int dcache_status(void)
 {
return 1;
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index af3e7d85be39..fd9ca24f8dbe 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -44,10 +44,11 @@ CONFIG_CMD_CPU=y
 CONFIG_CMD_LICENSE=y
 CONFIG_CMD_BOOTM_PRE_LOAD=y
 CONFIG_CMD_BOOTZ=y
+CONFIG_BOOTM_OPENRTOS=y
+CONFIG_BOOTM_OSE=y
 CONFIG_CMD_BOOTEFI_HELLO=y
 CONFIG_CMD_BOOTMENU=y
 CONFIG_CMD_ABOOTIMG=y
-# CONFIG_CMD_ELF is not set
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 CONFIG_CMD_ERASEENV=y
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 05/22] riscv: Add a reset_cpu() function

2023-12-15 Thread Simon Glass
The current do_reset() is called from a command context. Add a function
which can be used from anywhere, as is done on ARM. Adjust do_reset()
to call it.

Note that reset_cpu() is normally provided by SYSRESET so make this
declaration conditional on that being disabled.

Signed-off-by: Simon Glass 
Reviewed-by: Chanho Park 
Tested-by: Chanho Park 
---

(no changes since v1)

 arch/riscv/cpu/cpu.c   | 13 +
 arch/riscv/lib/reset.c |  7 ++-
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
index ebd39cb41a60..8445c5823e17 100644
--- a/arch/riscv/cpu/cpu.c
+++ b/arch/riscv/cpu/cpu.c
@@ -3,10 +3,13 @@
  * Copyright (C) 2018, Bin Meng 
  */
 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -162,3 +165,13 @@ int arch_early_init_r(void)
 __weak void harts_early_init(void)
 {
 }
+
+#if !CONFIG_IS_ENABLED(SYSRESET)
+void reset_cpu(void)
+{
+   printf("resetting ...\n");
+
+   printf("reset not supported yet\n");
+   hang();
+}
+#endif
diff --git a/arch/riscv/lib/reset.c b/arch/riscv/lib/reset.c
index 712e1bdb8e1d..c4153c9e6e02 100644
--- a/arch/riscv/lib/reset.c
+++ b/arch/riscv/lib/reset.c
@@ -4,14 +4,11 @@
  */
 
 #include 
-#include 
+#include 
 
 int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
-   printf("resetting ...\n");
-
-   printf("reset not supported yet\n");
-   hang();
+   reset_cpu();
 
return 0;
 }
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 06/22] bootm: Adjust how the board is reset

2023-12-15 Thread Simon Glass
Use reset_cpu() to reset the board, copying the logic from the 'reset'
command. This makes more sense than directly calling the do_reset()
function with the arguments passsed to the bootm command.

Signed-off-by: Simon Glass 
Reviewed-by: Tom Rini 
Reviewed-by: Mattijs Korpershoek 
---

(no changes since v1)

 boot/bootm.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/boot/bootm.c b/boot/bootm.c
index 301cfded05cb..8a0dba5074e8 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -1140,10 +1140,12 @@ err:
if (iflag)
enable_interrupts();
 
-   if (ret == BOOTM_ERR_UNIMPLEMENTED)
+   if (ret == BOOTM_ERR_UNIMPLEMENTED) {
bootstage_error(BOOTSTAGE_ID_DECOMP_UNIMPL);
-   else if (ret == BOOTM_ERR_RESET)
-   do_reset(cmdtp, flag, argc, argv);
+   } else if (ret == BOOTM_ERR_RESET) {
+   printf("Resetting the board...\n");
+   reset_cpu();
+   }
 
return ret;
 }
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 04/22] nios2: Add a reset_cpu() function

2023-12-15 Thread Simon Glass
The current do_reset() is called from a command context. Add a function
which can be used from anywhere, as is done on ARM.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/nios2/cpu/cpu.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c
index 79a54d1bc259..de7bfa947f11 100644
--- a/arch/nios2/cpu/cpu.c
+++ b/arch/nios2/cpu/cpu.c
@@ -35,11 +35,17 @@ int checkboard(void)
 }
 #endif
 
-int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+void reset_cpu(void)
 {
disable_interrupts();
/* indirect call to go beyond 256MB limitation of toolchain */
nios2_callr(gd->arch.reset_addr);
+}
+
+int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+   reset_cpu();
+
return 0;
 }
 
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 02/22] m68k: Add a reset_cpu() function

2023-12-15 Thread Simon Glass
The current do_reset() is called from a command context. Add a function
which can be used from anywhere, as is done on ARM.

Since there are lots of reset functions, this one actually just calls
do_reset(). Future refactoring could correct this.

Signed-off-by: Simon Glass 
Acked-by: Angelo Dureghello 
---

(no changes since v1)

 arch/m68k/lib/traps.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/m68k/lib/traps.c b/arch/m68k/lib/traps.c
index c283351181d8..ae8ae6ccf592 100644
--- a/arch/m68k/lib/traps.c
+++ b/arch/m68k/lib/traps.c
@@ -7,6 +7,7 @@
  * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -65,3 +66,9 @@ int arch_initr_trap(void)
 
return 0;
 }
+
+void reset_cpu(void)
+{
+   /* TODO: Refactor all the do_reset calls to be reset_cpu() instead */
+   do_reset(NULL, 0, 0, NULL);
+}
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 03/22] ppc: Add a reset_cpu() function

2023-12-15 Thread Simon Glass
The current do_reset() is called from a command context. Add a function
which can be used from anywhere, as is done on ARM.

This is only needed if CONFIG_SYSRESET is disabled.

Since there are lots of reset functions, this one actually just calls
do_reset(). Future refactoring could correct this.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/powerpc/lib/traps.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/powerpc/lib/traps.c b/arch/powerpc/lib/traps.c
index c7bce82a44b3..cf8da2e5df0d 100644
--- a/arch/powerpc/lib/traps.c
+++ b/arch/powerpc/lib/traps.c
@@ -4,6 +4,8 @@
  * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
  */
 
+#include 
+#include 
 #include 
 #include 
 
@@ -17,3 +19,11 @@ int arch_initr_trap(void)
 
return 0;
 }
+
+#ifndef CONFIG_SYSRESET
+void reset_cpu(void)
+{
+   /* TODO: Refactor all the do_reset calls to be reset_cpu() instead */
+   do_reset(NULL, 0, 0, NULL);
+}
+#endif
-- 
2.43.0.472.g3155946c3a-goog



[PATCH v3 01/22] mips: Add a reset_cpu() function

2023-12-15 Thread Simon Glass
The current do_reset() is called from a command context. Add a function
which can be used from anywhere, as is done on ARM.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/mips/cpu/cpu.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/mips/cpu/cpu.c b/arch/mips/cpu/cpu.c
index acfc9dc43f17..443465047715 100644
--- a/arch/mips/cpu/cpu.c
+++ b/arch/mips/cpu/cpu.c
@@ -4,6 +4,7 @@
  * Wolfgang Denk, DENX Software Engineering, 
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -20,9 +21,14 @@ void __weak _machine_restart(void)
/* NOP */;
 }
 
-int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+void reset_cpu(void)
 {
_machine_restart();
+}
+
+int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+   reset_cpu();
 
return 0;
 }
-- 
2.43.0.472.g3155946c3a-goog



[PATCH] boot: Support decompressing non-kernel OS images

2023-12-15 Thread Simon Glass
Sometimes the kernel is built as an EFI application rather than a
binary. We still want to support compression for this case.

For arm64 the entry point is set later in the bootm_load_os() function,
since these images are typically relocated due to the 2MB-alignment
requirement of arm64 images. But since the EFI image is not in the same
format, we need to update the entry point earlier.

Set the entry point always, for kernel_noload to resolve this problem.
It should be harmless to do this always.

Signed-off-by: Simon Glass 
---

 boot/bootm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/boot/bootm.c b/boot/bootm.c
index 301cfded05c..75a94d97643 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -643,6 +643,7 @@ static int bootm_load_os(struct bootm_headers *images, int 
boot_progress)
if (!load)
return 1;
os.load = load;
+   images->ep = load;
debug("Allocated %lx bytes at %lx for kernel (size %lx) 
decompression\n",
  req_size, load, image_len);
}
-- 
2.43.0.472.g3155946c3a-goog



[PATCH 1/1] binman: used-before-assignment in ftest.py

2023-12-15 Thread Heinrich Schuchardt
Pytest 7.4.3 complains if a variable is used in a finally clause without
having been initialized before the try clause.

Signed-off-by: Heinrich Schuchardt 
---
 tools/binman/ftest.py | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index a273120d9f..a4ac520cbb 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -2842,12 +2842,14 @@ class TestFunctional(unittest.TestCase):
 fdt_size = entries['section'].GetEntries()['u-boot-dtb'].size
 fdtmap_offset = entries['fdtmap'].offset
 
+tmpdir = None
 try:
 tmpdir, updated_fname = self._SetupImageInTmpdir()
 with test_util.capture_sys_output() as (stdout, stderr):
 self._DoBinman('ls', '-i', updated_fname)
 finally:
-shutil.rmtree(tmpdir)
+if tmpdir:
+shutil.rmtree(tmpdir)
 lines = stdout.getvalue().splitlines()
 expected = [
 'Name  Image-pos  Size  Entry-typeOffset  Uncomp-size',
@@ -2868,12 +2870,14 @@ class TestFunctional(unittest.TestCase):
 def testListCmdFail(self):
 """Test failing to list an image"""
 self._DoReadFile('005_simple.dts')
+tmpdir = None
 try:
 tmpdir, updated_fname = self._SetupImageInTmpdir()
 with self.assertRaises(ValueError) as e:
 self._DoBinman('ls', '-i', updated_fname)
 finally:
-shutil.rmtree(tmpdir)
+if tmpdir:
+shutil.rmtree(tmpdir)
 self.assertIn("Cannot find FDT map in image", str(e.exception))
 
 def _RunListCmd(self, paths, expected):
@@ -3002,13 +3006,15 @@ class TestFunctional(unittest.TestCase):
 self._CheckLz4()
 self._DoReadFileRealDtb('130_list_fdtmap.dts')
 fname = os.path.join(self._indir, 'output.extact')
+tmpdir = None
 try:
 tmpdir, updated_fname = self._SetupImageInTmpdir()
 with test_util.capture_sys_output() as (stdout, stderr):
 self._DoBinman('extract', '-i', updated_fname, 'u-boot',
'-f', fname)
 finally:
-shutil.rmtree(tmpdir)
+if tmpdir:
+shutil.rmtree(tmpdir)
 data = tools.read_file(fname)
 self.assertEqual(U_BOOT_DATA, data)
 
@@ -5185,12 +5191,14 @@ fdt fdtmapExtract the 
devicetree blob from the fdtmap
 data = self._DoReadFileRealDtb('207_fip_ls.dts')
 hdr, fents = fip_util.decode_fip(data)
 
+tmpdir = None
 try:
 tmpdir, updated_fname = self._SetupImageInTmpdir()
 with test_util.capture_sys_output() as (stdout, stderr):
 self._DoBinman('ls', '-i', updated_fname)
 finally:
-shutil.rmtree(tmpdir)
+if tmpdir:
+shutil.rmtree(tmpdir)
 lines = stdout.getvalue().splitlines()
 expected = [
 'NameImage-pos  Size  Entry-type  Offset  Uncomp-size',
@@ -5395,12 +5403,14 @@ fdt fdtmapExtract the 
devicetree blob from the fdtmap
 use_real_dtb=True,
 extra_indirs=[os.path.join(self._indir, TEST_FDT_SUBDIR)])
 
+tmpdir = None
 try:
 tmpdir, updated_fname = self._SetupImageInTmpdir()
 with test_util.capture_sys_output() as (stdout, stderr):
 self._RunBinman('ls', '-i', updated_fname)
 finally:
-shutil.rmtree(tmpdir)
+if tmpdir:
+shutil.rmtree(tmpdir)
 
 def testFitSubentryUsesBintool(self):
 """Test that binman FIT subentries can use bintools"""
-- 
2.40.1



Re: [PATCH v2] imx: imx8mp: Add support for Polyhex Debix Model A SBC

2023-12-15 Thread Gilles Talis
Hi Milan,
Thanks for testing the patch! Glad that you could get it to work!

Hi Fabio,
Le mer. 13 déc. 2023 à 12:22, Fabio Estevam  a écrit :

> On Thu, Dec 7, 2023 at 2:15 PM Milan Zamazal  wrote:
> >
> > Peng Fan  writes:
> >
> > > On 5/24/2023 3:21 AM, Gilles Talis wrote:
> > >> Add support for the Polyhex Debix Model A SBC board.
> > >> It is an industrial grade single board computer based on
> > >> NXP's i.MX 8M Plus.
> > >> Currently supported interfaces are:
> > >> - Serial console
> > >> - Micro SD
> > >> - eQOS and FEC Ethernet
> > >> imx8mp-debix-model-a.dts is taken from Linux 6.3.
> > >> Signed-off-by: Gilles Talis
> > >
> > > Reviewed-by: Peng Fan 
> >
> > Do you know why the patch has been left (as far as I can see) without
> > further action?
>
> Applied to u-boot-imx next, thanks.
>
Thanks for applying it !
Gilles.


Re: [PATCH] board: ti: k3: Remove need for CFG_SYS_SDRAM_BASE

2023-12-15 Thread Tom Rini
On Thu, Nov 30, 2023 at 08:49:11AM -0600, Andrew Davis wrote:

> The base address of extended DDR does not change across the K3 family.
> Setting this per SoC is not needed. Remove this definition to help
> remove the last bits from K3 include/configs/*.h files.
> 
> Signed-off-by: Andrew Davis 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 4/4] board: ti: am62x/am62ax: Update virtual interrupt allocations in board config

2023-12-15 Thread Tom Rini
On Tue, Nov 28, 2023 at 01:40:24PM -0600, Vishal Mahaveer wrote:

> Updates as a result of TIFS core now reserving a virtual interrupt
> for enabling interrupts between DM to TIFS core. Because of this
> change other virtual interrupt counts decrease by one.
> 
> Signed-off-by: Vishal Mahaveer 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 3/4] board: ti: am62x/am62ax: Update MCU GPIO interrupt allocation in board config

2023-12-15 Thread Tom Rini
On Tue, Nov 28, 2023 at 01:40:23PM -0600, Vishal Mahaveer wrote:

> Share the MCU GPIO interrupts between A53 core and DM R5 core. Allocating
> 2 instances each to A53 and DM R5.
> 
> Signed-off-by: Vishal Mahaveer 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 2/4] board: ti: am62ax: Add C7x resource allocation entries to board config

2023-12-15 Thread Tom Rini
On Tue, Nov 28, 2023 at 01:40:22PM -0600, Vishal Mahaveer wrote:

> Update am62ax rm-cfg with allocation entries for C7x core. Following
> updates are added for C7x:
> - Share split BCDMA tx and rx channels between DM R5 and C7x
> - Share rings for split BCDMA tx and rx channels between DM R5 and C7x
> - Add Global events and Virtual interrupts for C7x
> 
> Signed-off-by: Vishal Mahaveer 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/4] board: ti: am62x/am62ax: Formatting updates to board config files

2023-12-15 Thread Tom Rini
On Tue, Nov 28, 2023 at 01:40:21PM -0600, Vishal Mahaveer wrote:

> Minor formatting updates to the rm board configuration file for
> am62x and am62ax boards.
> 
> Signed-off-by: Vishal Mahaveer 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 4/4] arm: mach-k3: Merge initial memory maps

2023-12-15 Thread Tom Rini
On Tue, Nov 28, 2023 at 11:05:28AM -0600, Andrew Davis wrote:

> The Device vs Normal memory map is the same for all K3 SoCs. Merge
> the SoC specific maps into one.
> 
> Signed-off-by: Andrew Davis 
> Reviewed-by: Nishanth Menon 
> Tested-by: Nishanth Menon 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 3/4] arm: mach-k3: Remove non-cached memory map areas

2023-12-15 Thread Tom Rini
On Tue, Nov 28, 2023 at 11:05:27AM -0600, Andrew Davis wrote:

> All normal memory areas should be mapped as such.
> 
> We added these un-cached holes in our memory map to hack around the
> remoteproc driver missing the proper cache maintenance operations.
> 
> The problem is having these non-cached memory map areas causes stability
> issues later in system operation due to the nature of the K3 coherency
> architecture. Plus these are board specific carveouts and instead
> should have been added at the board level, not here in the SoC common
> code area.
> 
> Remove these non-cached memory map areas.
> 
> Signed-off-by: Andrew Davis 
> Reviewed-by: Nishanth Menon 
> Tested-by: Nishanth Menon 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 2/4] arm: mach-k3: Do not map ATF and OPTEE regions in MMU

2023-12-15 Thread Tom Rini
On Tue, Nov 28, 2023 at 11:05:26AM -0600, Andrew Davis wrote:

> ATF and OPTEE regions may be firewalled from non-secure entities. To
> prevent access to this area we leave a hole there in the MMU map. This
> is the same idea as [0] but we complete that patch by adding the same
> for AM65, J721e, J7200, and J721s2 here.
> 
> [0] commit 0688ff3ae23c ("arm: mach-k3: arm64-mmu: do not map ATF and OPTEE 
> regions in A53 MMU")
> 
> Signed-off-by: Andrew Davis 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2 1/4] arm: mach-k3: Let the compiler size the mem_map lists

2023-12-15 Thread Tom Rini
On Tue, Nov 28, 2023 at 11:05:25AM -0600, Andrew Davis wrote:

> NR_MMU_REGIONS is a copy/paste from another platform that extends
> this list later. We do not do that, so let the list be the size
> of the initializer list.
> 
> Signed-off-by: Andrew Davis 
> Reviewed-by: Nishanth Menon 
> Tested-by: Nishanth Menon 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2] arm: mach-k3: Move K3 common schema.yaml out of board directory

2023-12-15 Thread Tom Rini
On Wed, Nov 22, 2023 at 03:30:05PM -0600, Andrew Davis wrote:

> This file is common for all K3, move it out of board/ directory and
> into mach-k3. As we need to change the path in k3-binman.dtsi let's
> take this opportunity to switch to absolute paths which makes adding
> non-TI boards (like Toradex Verdin) not need to override these paths.
> 
> Signed-off-by: Andrew Davis 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[GIT PULL] clock changes for u-boot/master

2023-12-15 Thread Sean Anderson

The following changes since commit 3ac22891cfc0dc6d8eec25d2b0fbdd2eb8f3d3ed:

  Merge tag 'u-boot-imx-20231214' of 
https://gitlab.denx.de/u-boot/custodians/u-boot-imx (2023-12-15 08:22:31 -0500)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-clk.git tags/clk-2024.01-rc5

for you to fetch changes up to 97d65b32d76cb3b8297cd8aa2c1f0caab5ab6c57:

  test: dm: clk_ccf: fix building error (2023-12-15 15:30:12 -0500)


clock changes for u-boot/master

This has some clock fixes which should go in before the release. It's a bit
late in the cycle, but most of these have tests to go along with them.

Signed-off-by: Sean Anderson 


Igor Prusov (2):
  clk: Check that composite clock's div has set_rate()
  dm: test: clk: Add test for ccf clk_set_rate()

Yang Xiwen (4):
  clk: check parent_name in clk_register to avoid confusing log_error() 
output
  clk: get correct ops for clk_enable() and clk_disable()
  test: dm: clk_ccf: test ccf_clk_ops
  test: dm: clk_ccf: fix building error

 arch/sandbox/dts/test.dts  |  4 +++-
 arch/sandbox/include/asm/clk.h |  1 +
 drivers/clk/clk-composite.c|  2 +-
 drivers/clk/clk-uclass.c   |  2 ++
 drivers/clk/clk.c  | 18 ++
 drivers/clk/clk_sandbox_ccf.c  |  1 +
 drivers/clk/clk_sandbox_test.c |  1 +
 test/dm/clk_ccf.c  | 22 --
 8 files changed, 39 insertions(+), 12 deletions(-)


Re: (subset) [PATCH v3 2/2] test: dm: clk_ccf: test ccf_clk_ops

2023-12-15 Thread Sean Anderson
On Sat, 16 Dec 2023 02:28:52 +0800, Yang Xiwen wrote:
> Assign ccf_clk_ops to .ops of clk_ccf driver so that it can act as an
> clk provider. Also add "#clock-cells=<1>" to its device tree node.
> 
> Add "i2c_root" to clk_test in the device tree and driver for testing.
> 
> Get "i2c_root" clock in CCF unit tests and add tests for it.
> 
> [...]

Applied, thanks!

[2/2] test: dm: clk_ccf: test ccf_clk_ops
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/d30618243990

Best regards,
-- 
Sean Anderson 


Re: [PATCH] test: dm: clk_ccf: fix building error

2023-12-15 Thread Sean Anderson
On Sat, 16 Dec 2023 04:21:11 +0800, Yang Xiwen wrote:
> Fix unused variable error produced by building tests
> 
> 

Applied, thanks!

[1/1] test: dm: clk_ccf: fix building error
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/97d65b32d76c

Best regards,
-- 
Sean Anderson 


[GIT PULL] clock changes for u-boot/next

2023-12-15 Thread Sean Anderson

The following changes since commit fa3f19aa56c519d6345cc774187b7a8fdc053d71:

  Merge tag 'xilinx-for-v2024.04-rc1' of 
https://source.denx.de/u-boot/custodians/u-boot-microblaze into next 
(2023-12-14 13:27:11 -0500)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-clk.git tags/clk-2024.01-next

for you to fetch changes up to 652d8d4561a34fc71d9bcb6ad2b0035d2c4189c1:

  clk: nuvoton: add read only feature for clk driver (2023-12-15 13:05:55 -0500)


clock patches for u-boot/next

The main thing in here is Igor's conversion of soc_clk_dump to a clk_ops
member. There's also a write-protect feature for nuvoton clocks.

Signed-off-by: Sean Anderson 


Igor Prusov (8):
  clk: zynq: Move soc_clk_dump to Zynq clock driver
  clk: ast2600: Move soc_clk_dump function
  clk: k210: Move soc_clk_dump function
  clk: amlogic: Move driver and ops structs
  clk: Add dump operation to clk_ops
  cmd: clk: Use dump function from clk_ops
  clk: treewide: switch to clock dump from clk_ops
  cmd: clk: Make soc_clk_dump static

Jim Liu (1):
  clk: nuvoton: add read only feature for clk driver

 arch/arm/mach-zynq/clk.c   |  57 
---
 arch/mips/mach-pic32/cpu.c |  23 -
 cmd/clk.c  |  13 ++--
 drivers/clk/aspeed/clk_ast2600.c   |  83 
+-
 drivers/clk/clk_k210.c | 104 
+
 drivers/clk/clk_pic32.c|  37 +
 drivers/clk/clk_versal.c   |   9 +---
 drivers/clk/clk_zynq.c |  52 
+++
 drivers/clk/clk_zynqmp.c   |  22 ++--
 drivers/clk/imx/clk-imx8.c |  13 
 drivers/clk/meson/a1.c |  58 
+---
 drivers/clk/mvebu/armada-37xx-periph.c |  20 +++---
 drivers/clk/nuvoton/clk_npcm.c |  15 +++---
 drivers/clk/nuvoton/clk_npcm.h |   1 +
 drivers/clk/nuvoton/clk_npcm8xx.c  |  12 +--
 drivers/clk/stm32/clk-stm32mp1.c   |  31 
 include/clk-uclass.h   |  13 
 include/clk.h  |   2 --
 18 files changed, 288 insertions(+), 277 deletions(-)


Re: [PATCH v7 5/8] clk: Add dump operation to clk_ops

2023-12-15 Thread Sean Anderson

On 11/9/23 05:55, Igor Prusov wrote:

This adds dump function to struct clk_ops which should replace
soc_clk_dump. It allows clock drivers to provide custom dump
implementation without overriding generic CCF dump function.

Reviewed-by: Patrice Chotard 
Tested-by: Patrice Chotard 
Reviewed-by: Sean Anderson 
Signed-off-by: Igor Prusov 
---
  include/clk-uclass.h | 13 +
  1 file changed, 13 insertions(+)

diff --git a/include/clk-uclass.h b/include/clk-uclass.h
index a22f1a5d84..f10dd213ff 100644
--- a/include/clk-uclass.h
+++ b/include/clk-uclass.h
@@ -25,6 +25,7 @@ struct ofnode_phandle_args;
   * @set_parent: Set current clock parent
   * @enable: Enable a clock.
   * @disable: Disable a clock.
+ * @dump: Print clock information.
   *
   * The individual methods are described more fully below.
   */
@@ -39,6 +40,9 @@ struct clk_ops {
int (*set_parent)(struct clk *clk, struct clk *parent);
int (*enable)(struct clk *clk);
int (*disable)(struct clk *clk);
+#if IS_ENABLED(CONFIG_CMD_CLK)
+   void (*dump)(struct udevice *dev);
+#endif
  };
  
  #if 0 /* For documentation only */

@@ -135,6 +139,15 @@ int enable(struct clk *clk);
   * Return: zero on success, or -ve error code.
   */
  int disable(struct clk *clk);
+
+/**
+ * dump() - Print clock information.
+ * @clk:   The clock device to dump.


The correct member here is @dev. I fixed this when applying.

--Sean


+ * If present, this function is called by "clk dump" command for each
+ * bound device.
+ */
+void dump(struct udevice *dev);
  #endif
  
  #endif




Re: [PATCH v3] clk: nuvoton: add read only feature for clk driver

2023-12-15 Thread Sean Anderson
On Tue, 14 Nov 2023 17:00:04 +0800, Jim Liu wrote:
> Add a flag to set ahb/apb/fiu/spi clock divider as read-only
> The spi clock setting is related to booting flash, it is setup by early
> bootloader.
> It just protects the clock source and can't modify it in uboot.
> 
> 

Applied, thanks!

[1/1] clk: nuvoton: add read only feature for clk driver
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/652d8d4561a3

Best regards,
-- 
Sean Anderson 


Re: [PATCH v7 0/8] clk: Switch from soc_clk_dump to clk_ops function

2023-12-15 Thread Sean Anderson
On Thu, 9 Nov 2023 13:55:08 +0300, Igor Prusov wrote:
> Currently clock providers may override default implementation of
> soc_clk_dump function to replace clk dump command output. This causes
> confusing behaviour when u-boot is built with one of such drivers
> enabled but still has clocks defined using CCF. For example, enabling
> CMD_CLK and using clk dump on sandbox target will not show CCF clocks
> because k210 driver overrides common soc_clk_dump.
> 
> [...]

Applied, thanks!

[1/8] clk: zynq: Move soc_clk_dump to Zynq clock driver
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/bdac75511411
[2/8] clk: ast2600: Move soc_clk_dump function
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/3f192541df79
[3/8] clk: k210: Move soc_clk_dump function
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/77beaad3d1d2
[4/8] clk: amlogic: Move driver and ops structs
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/4f48202ba82e
[5/8] clk: Add dump operation to clk_ops
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/505ef5f627d8
[6/8] cmd: clk: Use dump function from clk_ops
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/258c1002383e
[7/8] clk: treewide: switch to clock dump from clk_ops
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/bc3e313ff6af
[8/8] cmd: clk: Make soc_clk_dump static
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/5666558a6cb0

Best regards,
-- 
Sean Anderson 


Re: [PATCH v2] board: rockchip: Add the Turing RK1 SoM

2023-12-15 Thread Sam Edwards

Hi Joshua,

I just updated my own modules to this version of the patch and all 
continues to be well.


On 12/14/23 16:46, Joshua Riek wrote:

Signed-off-by: Joshua Riek 
Cc: Sam Edwards 

Tested-by: Sam Edwards 

Thanks for the continued efforts, my friend!

Happy Friday,
Sam


Re: [PATCH v2 0/6] board: siemens: clean up subfolders

2023-12-15 Thread Tom Rini
On Thu, Nov 30, 2023 at 01:23:18PM +0100, Enrico Leto wrote:

> This serie depends on the serie:
> [PATCH 0/6] siemens,am335x: clean up the draco board family
> 
> The common folder was initialially created for the common parts of
> the products based on draco-am355x board family. We have the
> product lines 'pxm2', 'rut' and the base line unfortunately named
> 'draco'! Adding the new capricorn-imx8 board family, the files
> were enhanced without cleanup.
> 
> Simplify first EEPROM probe and access that implements both i2c
> with & without driver model. Use abstraction functions for this.
> 
> Move all am355x specifics to a new file 'board_am335x'.
> 
> Clean-up includes, config checks, maintainer.
> 
> Signed-off-by: Enrico Leto 

Can you please rebase this on top of the current -next branch and ensure
there's no warnings on the platforms when done? Thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] test: dm: clk_ccf: fix building error

2023-12-15 Thread Sean Anderson

On 12/15/23 15:21, Yang Xiwen via B4 Relay wrote:

From: Yang Xiwen 

Fix unused variable error produced by building tests

Fixes: d3061824 (test: dm: clk_ccf: test ccf_clk_ops)
Signed-off-by: Yang Xiwen 
---
it's detected by u-boot gitlab CI.
---
  test/dm/clk_ccf.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test/dm/clk_ccf.c b/test/dm/clk_ccf.c
index b8be6d6572..5a3c58c6b5 100644
--- a/test/dm/clk_ccf.c
+++ b/test/dm/clk_ccf.c
@@ -18,11 +18,12 @@
  /* Tests for Common Clock Framework driver */
  static int dm_test_clk_ccf(struct unit_test_state *uts)
  {
-   struct clk *clk, *pclk, clk_ccf;
+   struct clk *clk, *pclk;
struct udevice *dev, *test_dev;
long long rate;
int ret;
  #if CONFIG_IS_ENABLED(CLK_CCF)
+   struct clk clk_ccf;
const char *clkname;
int clkid, i;
  #endif

---
base-commit: c9945276f77921feb8df7be75cced3338d08e8d4
change-id: 20231216-b4-fix_build-d05f2b26c8a7

Best regards,


Reviewed-by: Sean Anderson 


[PATCH] test: dm: clk_ccf: fix building error

2023-12-15 Thread Yang Xiwen via B4 Relay
From: Yang Xiwen 

Fix unused variable error produced by building tests

Fixes: d3061824 (test: dm: clk_ccf: test ccf_clk_ops)
Signed-off-by: Yang Xiwen 
---
it's detected by u-boot gitlab CI.
---
 test/dm/clk_ccf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test/dm/clk_ccf.c b/test/dm/clk_ccf.c
index b8be6d6572..5a3c58c6b5 100644
--- a/test/dm/clk_ccf.c
+++ b/test/dm/clk_ccf.c
@@ -18,11 +18,12 @@
 /* Tests for Common Clock Framework driver */
 static int dm_test_clk_ccf(struct unit_test_state *uts)
 {
-   struct clk *clk, *pclk, clk_ccf;
+   struct clk *clk, *pclk;
struct udevice *dev, *test_dev;
long long rate;
int ret;
 #if CONFIG_IS_ENABLED(CLK_CCF)
+   struct clk clk_ccf;
const char *clkname;
int clkid, i;
 #endif

---
base-commit: c9945276f77921feb8df7be75cced3338d08e8d4
change-id: 20231216-b4-fix_build-d05f2b26c8a7

Best regards,
-- 
Yang Xiwen 



Re: [PATCH v1 1/1] clk: clk-gpio: add actual gated clock

2023-12-15 Thread Sean Anderson

On 12/15/23 15:00, Svyatoslav Ryhel wrote:

пт, 15 груд. 2023 р. о 20:45 Sean Anderson  пише:


On 12/15/23 13:26, Svyatoslav Ryhel wrote:

пт, 15 груд. 2023 р. о 19:25 Sean Anderson  пише:


On 11/17/23 02:52, Svyatoslav Ryhel wrote:

Existing gpio-gate-clock driver acts like a simple GPIO switch without any
effect on gated clock. Add actual clock actions into enable/disable ops and
implement get_rate op by passing gated clock if it is enabled.

Signed-off-by: Svyatoslav Ryhel 
---
drivers/clk/clk-gpio.c | 47 +++---
1 file changed, 40 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c
index 26d795b978..a55470cfbf 100644
--- a/drivers/clk/clk-gpio.c
+++ b/drivers/clk/clk-gpio.c
@@ -3,19 +3,23 @@
 * Copyright (C) 2023 Marek Vasut 
 */

-#include 
-#include 
-#include 
+#include 
#include 
+#include 
+#include 
+
+#include 

struct clk_gpio_priv {
struct gpio_descenable;
+ struct clk  *clk;


Please name this "parent".


I see no need in this since clk is generic name and this driver can
accept only one clock with any name.


It's good documentation. It makes it clear what the purpose of the member is.


This driver uses a single (1) clock with a single purpose.

Why do you think you need a clock in a clock-gpio driver? Hm, I don't
know. This will remain a mystery for future archeo-coders yeah.


If you don't want to change the name, then add a doc comment.


};

static int clk_gpio_enable(struct clk *clk)
{
struct clk_gpio_priv *priv = dev_get_priv(clk->dev);

+ clk_prepare_enable(priv->clk);


Just clk_enable is fine. We don't have a separate prepare stage line Linux.


U-Boot supports clk_prepare_enable and since this support is present I
see no contradiction in using it.


These functions are only there for to make it easier to port code from Linux.
Since this code was written for U-Boot, just use the actual function.


Then document that its use is discouraged. Until then it is not restricted.


There are many functions like this in U-Boot (e.g. kmalloc which takes an unused
flags argument, or all the pr_* functions which are almost-but-not-quite the
same as log_*). Not all of them are explicitly document as such, but generally
you should use the native functions where it is not inconvenient.

--Sean


Re: [PULL] Pull request for u-boot next / v2024.04 = u-boot-stm32-20231215

2023-12-15 Thread Tom Rini
On Fri, Dec 15, 2023 at 05:30:42PM +0100, Patrice CHOTARD wrote:

> Hi Tom
> 
> Please pull the STM32 related patches for u-boot/next, v2024.04: 
> u-boot-stm32-20231215
> 
> CI status: 
> https://source.denx.de/u-boot/custodians/u-boot-stm/-/pipelines/18947
> 
> The following changes since commit fa3f19aa56c519d6345cc774187b7a8fdc053d71:
> 
>   Merge tag 'xilinx-for-v2024.04-rc1' of 
> https://source.denx.de/u-boot/custodians/u-boot-microblaze into next 
> (2023-12-14 13:27:11 -0500)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-stm.git 
> tags/u-boot-stm32-20231215
> 
> for you to fetch changes up to 395507e50d7137e0bcfce74e1b4122e49d9984cb:
> 
>   configs: stm32: Apply savedefconfig (2023-12-15 15:41:23 +0100)
> 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v1 1/1] clk: clk-gpio: add actual gated clock

2023-12-15 Thread Svyatoslav Ryhel
пт, 15 груд. 2023 р. о 20:45 Sean Anderson  пише:
>
> On 12/15/23 13:26, Svyatoslav Ryhel wrote:
> > пт, 15 груд. 2023 р. о 19:25 Sean Anderson  пише:
> >>
> >> On 11/17/23 02:52, Svyatoslav Ryhel wrote:
> >>> Existing gpio-gate-clock driver acts like a simple GPIO switch without any
> >>> effect on gated clock. Add actual clock actions into enable/disable ops 
> >>> and
> >>> implement get_rate op by passing gated clock if it is enabled.
> >>>
> >>> Signed-off-by: Svyatoslav Ryhel 
> >>> ---
> >>>drivers/clk/clk-gpio.c | 47 +++---
> >>>1 file changed, 40 insertions(+), 7 deletions(-)
> >>>
> >>> diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c
> >>> index 26d795b978..a55470cfbf 100644
> >>> --- a/drivers/clk/clk-gpio.c
> >>> +++ b/drivers/clk/clk-gpio.c
> >>> @@ -3,19 +3,23 @@
> >>> * Copyright (C) 2023 Marek Vasut 
> >>> */
> >>>
> >>> -#include 
> >>> -#include 
> >>> -#include 
> >>> +#include 
> >>>#include 
> >>> +#include 
> >>> +#include 
> >>> +
> >>> +#include 
> >>>
> >>>struct clk_gpio_priv {
> >>>struct gpio_descenable;
> >>> + struct clk  *clk;
> >>
> >> Please name this "parent".
> >>
> > I see no need in this since clk is generic name and this driver can
> > accept only one clock with any name.
>
> It's good documentation. It makes it clear what the purpose of the member is.
>
This driver uses a single (1) clock with a single purpose.

Why do you think you need a clock in a clock-gpio driver? Hm, I don't
know. This will remain a mystery for future archeo-coders yeah.

> >>>};
> >>>
> >>>static int clk_gpio_enable(struct clk *clk)
> >>>{
> >>>struct clk_gpio_priv *priv = dev_get_priv(clk->dev);
> >>>
> >>> + clk_prepare_enable(priv->clk);
> >>
> >> Just clk_enable is fine. We don't have a separate prepare stage line Linux.
> >>
> > U-Boot supports clk_prepare_enable and since this support is present I
> > see no contradiction in using it.
>
> These functions are only there for to make it easier to port code from Linux.
> Since this code was written for U-Boot, just use the actual function.
>
Then document that its use is discouraged. Until then it is not restricted.

> >>>dm_gpio_set_value(&priv->enable, 1);
> >>>
> >>>return 0;
> >>> @@ -26,21 +30,50 @@ static int clk_gpio_disable(struct clk *clk)
> >>>struct clk_gpio_priv *priv = dev_get_priv(clk->dev);
> >>>
> >>>dm_gpio_set_value(&priv->enable, 0);
> >>> + clk_disable_unprepare(priv->clk);
> >>>
> >>>return 0;
> >>>}
> >>>
> >>> +static ulong clk_gpio_get_rate(struct clk *clk)
> >>> +{
> >>> + struct clk_gpio_priv *priv = dev_get_priv(clk->dev);
> >>> + int ret;
> >>> +
> >>> + ret = dm_gpio_get_value(&priv->enable);
> >>> + if (ret)
> >>> + return clk_get_rate(priv->clk);
> >>> + else
> >>> + return -EINVAL;
> >>
> >> This should always return the parent rate.
> >>
> > How can you return clock rate if the gate is disabled?
>
> This allows consumers to know what the rate will be before they
> enable the clock.
>
I don't quite understand the logic behind this but ok.

> >>> +}
> >>> +
> >>>const struct clk_ops clk_gpio_ops = {
> >>>.enable = clk_gpio_enable,
> >>>.disable= clk_gpio_disable,
> >>> + .get_rate   = clk_gpio_get_rate,
> >>>};
> >>>
> >>> -static int clk_gpio_probe(struct udevice *dev)
> >>> +static int clk_gpio_of_to_plat(struct udevice *dev)
> >>
> >> This change should be a separate commit.
> >>
> > This actually should not be accepted first place
> >
> > .of_to_plat - convert device tree data to plat
> > .probe - make a device ready for use
> >
> > https://github.com/u-boot/u-boot/blob/master/doc/develop/driver-model/design.rst
>
> Yes, this is why I was a bit confused :)
>
> >>>{
> >>>struct clk_gpio_priv *priv = dev_get_priv(dev);
> >>> + int ret;
> >>>
> >>> - return gpio_request_by_name(dev, "enable-gpios", 0,
> >>> - &priv->enable, GPIOD_IS_OUT);
> >>> + priv->clk = devm_clk_get(dev, NULL);
> >>> + if (IS_ERR(priv->clk)) {
> >>> + log_err("%s: Could not get gated clock: %ld\n",
> >>> + __func__, PTR_ERR(priv->clk));
> >>> + return PTR_ERR(priv->clk);
> >>> + }
> >>> +
> >>> + ret = gpio_request_by_name(dev, "enable-gpios", 0,
> >>> +&priv->enable, GPIOD_IS_OUT);
> >>> + if (ret) {
> >>> + log_err("%s: Could not decode enable-gpios (%d)\n",
> >>> + __func__, ret);
> >>
> >> Use dev_dbg for probe errors to reduce binary size.
> >>
> > These errors provide intel about probing 2 key parts of the driver.
> > How would you know it fails in case you have no devices which face
> > this error? Iis there any convention or restriction which prohibits
> > this? If yes, then provide a docume

Re: [RFC PATCH] mxs: Don't enable 4P2 reg if mx28 is powered only from DCDC_BATT without 5V

2023-12-15 Thread Fabio Estevam
On Fri, Dec 15, 2023 at 1:20 PM Fabio Estevam  wrote:

> Ok, what about the patch below?
>
> https://patchwork.ozlabs.org/project/uboot/patch/20230703205700.9120-1-c...@londelec.com/
>
> Is this still needed?

I looked in the i.MX28 Reference Manual, and the one above looks a
correct fix. I will queue it.


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

2023-12-15 Thread Heinrich Schuchardt

On 12/15/23 18:46, Andy Shevchenko wrote:

On Fri, Dec 15, 2023 at 05:40:16PM +0100, 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.


...


+   if (!IS_ENABLED(CONFIG_X86) &&
+   !(fadt->flags & ACPI_FADT_HW_REDUCED_ACPI))
+   log_err("FADT not ACPI hardware reduced compliant\n");


I guess it's half baked solution as this, HW reduced, flag adds more
limitations even on x86. If you want a good validation it should be done
in a separate function taking others aspects into account.

But since it doesn't affect my area of interest in U-Boot, I won't prevent
you from doing this way, it's up to the U-Boot maintainers how to proceed
with it.



This flag is checked by Linux. It won't boot at all if the flag is not 
set on arm64 or riscv64. See arch/arm64/kernel/acpi.c and 
arch/riscv/kernel/acpi.c, function acpi_fadt_sanity_check().


Once you have booted you can use the Firmware Test Suite (FWTS) to check 
the rest. I don't plan rewriting such a validation in U-Boot.


Best regards

Heinrich


Re: [PATCH 0/8] An effort to bring DT bindings compliance within U-boot

2023-12-15 Thread Tom Rini
On Fri, Dec 15, 2023 at 02:45:11PM +, Conor Dooley wrote:
> On Fri, Dec 15, 2023 at 08:37:43AM -0500, Tom Rini wrote:
> > On Fri, Dec 15, 2023 at 08:50:51AM +0100, Krzysztof Kozlowski wrote:
> > > On 14/12/2023 20:48, Rob Herring wrote:
> > > >>
> > > >> I think some of the important questions to ask are, how often / likely
> > > >> are the breakages to occur? It seems like these days it's either:
> > > >> - U-Boot had an early version of the binding and we already state we
> > > >>   don't support backwards compatibility here. It should be on the
> > > >>   maintainer to be proactive in this case.
> > > >> - It's a "the DT was wrong about the hardware, sorry not sorry it's an
> > > >>   incompatible DTS change now". This too is hopefully the kind of thing
> > > >>   that at least board maintainers will be more actively aware of 
> > > >> needing
> > > >>   to deal with in U-Boot, if it's really a problem.
> > > > 
> > > > A common issue in the kernel is with forward compatibility when
> > > > platforms add new resources from a new provider. Then the kernel
> > > > expects a driver for the provider and waits for the dependency. Of
> > > > course, older kernels don't have that provider driver and so the
> > > > dependency is never met. Not sure if u-boot will have similar issues?
> > > > At least you should/could know if the provider driver exists or not.
> > > > (The kernel doesn't because modules.)
> > > 
> > > If some U-Boot platform decides to aggressively sync with kernel DTS,
> > > then probably the kernel subarch maintainer should be aware of it.
> > > Mentioned forward compatibility issue is a result of assumption that
> > > there are no out-of-tree upstream consumers of our DTS. I am certainly
> > > not aware of any such consumer for Samsung. If someone told me (me
> > > wearing Samsung hat), hey U-Boot now cares, I would start caring as well.
> > > 
> > > The usual argument of contributors wanting to break the backward and
> > > forward compatibility, is "there is no other OS depending on this"
> > > (recent discussion with Johan about order of interrupts:
> > > https://lore.kernel.org/all/zwcpzpx-et-xh...@hovoldconsulting.com/ ).
> > > You need to tell the maintainers of that platform, that now they have
> > > other OS/firmware/bootloader depending on DTS compatibility.
> > 
> > I think this hints at one of the bigger impacts this might have.
> > Reminding everyone that other projects do use the device trees and have
> > for years.
> 
> TBF, we do try to ask these questions as much as possible, usually (for
> me at least) citing U-Boot or the BSDs as users. It largely seems to me
> like we are all bark and no bite though, so a project like U-Boot having
> a defined "schedule" as you suggest below would add more meaning to our
> questioning.
> 
> > Without rehashing history, BSD does use the trees as-is and
> > for platforms U-Boot supports they are supposed to be re-synced
> > periodically.
> 
> I know this is the theory, but I also know that how well this is
> implemented varies wildly per-platform. I generally don't pay all
> that much attention to the various arm platforms, but I do pay
> attention to what's going on for RISC-V and there appear to be no
> active maintainers of individual platforms and the architecture
> maintainers are not aware of the status of the equivalent patches
> for Linux when they apply patches.
> 
> In recent memory, this has lead to the clock indices in the DT
> differing between U-Boot and Linux for one such platform, which, IMO,
> is an insidious difference that is hard to spot during review and highly
> unlikely to crop up while comparing dts files, since the defines were named
> identically. To be clear, I am not expecting the architecture code
> maintainers to be aware of the minutiae of the various RISC-V platforms,
> but rather suggesting they might have an easier time reviewing if both
> projects' dts files and binding headers were tied together.
> 
> That said, automatically synced devicetrees will, as has been pointed out,
> require the platform maintainers in Linux to be more aware of the affect of
> what they accept on other users, but it will also require the equivalent
> maintainers on the U-Boot side to engage too, so that the "upstream" dts
> files do not change in a way that screws the usecase in U-Boot.

Yeah, it will hopefully lead to better coordination between maintainers
in some places. There are SoCs where the kernel DTS people are the
U-Boot DTS people too. All in all, I should probably CC more people than
I usually do on these resync patches just to try and head off any
tricky changes like you've mentioned above.

> Also, if people send fixes to the U-Boot copies of these devicetrees,
> would the plan be to request that these are sent to Linux and the fixes
> pulled in via a resync after each -rc release of Linux (or similar, just
> throwing some example schedule out there)?

The way we've always tried to operate is that changes should b

Re: [PATCH] arm: dts: imx8mm_evk: Fix PMIC definition

2023-12-15 Thread Fabio Estevam
Hi Alexander,

On Tue, Sep 26, 2023 at 3:55 AM Alexander Koch  wrote:
>
> Newer revisions of the i.MX8MM EVK are equipped with a different PMIC than
> the initial ones (PCA9540 instead of BD71847), which has already been
> reflected in 4c07a21e5.

This commit hash does not exist:

$ git show 4c07a21e5
fatal: ambiguous argument '4c07a21e5': unknown revision or path not in
the working tree.

> These changes have been reverted implicitly as part of the device tree
> re-sync with the Linux kernel done in 24a7a3c1c.
>
> This lead to an inconsistent state: while the device tree describes the old
> PMIC again the code in board/freescale/imx8mm_evk/spl.c tries to initialize
> the new PMIC:
>
> ret = pmic_get("pca9450@25", &dev);
> if (ret == -ENODEV) {
> puts("No pmic\n");
> return 0;
> }

Yes, I agree this is inconsistent and we need to fix it.

>
> This leads to the expected error message from SPL:

> -   pmic@4b {
> -   compatible = "rohm,bd71847";
> -   reg = <0x4b>;
> -   pinctrl-names = "default";
> +   pmic: pca9450@25 {
> +   reg = <0x25>;
> +   compatible = "nxp,pca9450a";

If we change like this, we will lose the change after a sync with the Linux dts.

In Linux we have arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi that contains:

pmic@4b {
compatible = "rohm,bd71847";

and arch/arm64/boot/dts/freescale/imx8mm-evkb.dts that contains:

&i2c1 {
/delete-node/ pmic@4b;

pmic@25 {
compatible = "nxp,pca9450a";

We need to have a new imx8mm-evkb_defconfig in U-Boot to deal with the
PCA9450 PMIC.


Re: [PATCH 2/2] ARM: dts: imx8mm-venice: prepare for dek blob encapsulation

2023-12-15 Thread Adam Ford
On Fri, Dec 15, 2023 at 12:41 PM Fabio Estevam  wrote:
>
> Hi Tim,
>
> On Fri, Dec 15, 2023 at 3:34 PM Tim Harvey  wrote:
>
> > Fabio,
> >
> > The commit log details are not valid for upstream. I was basing this
> > off of 8d060e4a66d6884341fbb3d8ab1d837a3f173d47 which made it upstream
> > with the same message.
> >
> > I can submit a v2 if necessary.
>
> Yes, please submit a v2 and I will queue this series and the TPM one
> to u-boot-imx next.

This node appears to already be in the imx8mm-u-boot.dtsi encapsulated
by an #ifdef looking for optee.  Can this ifdef be expanded to include
CONFIG_SECURE_BOOT?

adam

> Regards,
>
> Fabio Estevam


Re: [PATCH 1/3] acpi: fix FADT table

2023-12-15 Thread Heinrich Schuchardt

On 12/15/23 18:48, Simon Glass wrote:

Hi Heinrich,

On Fri, 15 Dec 2023 at 09:40, 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.

Signed-off-by: Heinrich Schuchardt 
---
  arch/x86/cpu/baytrail/acpi.c | 8 ++--
  arch/x86/cpu/quark/acpi.c| 8 ++--
  arch/x86/cpu/tangier/acpi.c  | 8 ++--
  arch/x86/lib/acpi_table.c| 9 ++---
  include/acpi/acpi_table.h| 6 ++
  5 files changed, 10 insertions(+), 29 deletions(-)



Just as a general comment, the word 'fix' does not really describe
things very well. There may be many fixes to a piece of code or
feature. I would suggest something a bit more specific.  Perhaps
something like ':'

Also please use the U-Boot standard of ulong for addresses, not uintptr_t


You can have pointers that are shorter or longer than long depending on 
compiler invocation parametes. uintptr_t is the only type guaranteed to 
take a pointer. Using unsigned long here would be a non-portable 
programming style and we should avoid such sin.




For casts, it is better to use map_sysmem() and map_to_sysmem() so
that we can use the code in unit tests (although of course we
currently have no way of running x86-specific code in sandbox).


Please, keep the sandbox buildable on other architectues.

Using map_to_sysmem() makes sense here as we use the same fields as 
virtual sandbox addresses.


Best regards

Heinrich




diff --git a/arch/x86/cpu/baytrail/acpi.c b/arch/x86/cpu/baytrail/acpi.c
index 4378846f8b..5c28c4d260 100644
--- a/arch/x86/cpu/baytrail/acpi.c
+++ b/arch/x86/cpu/baytrail/acpi.c
@@ -31,8 +31,6 @@ static int baytrail_write_fadt(struct acpi_ctx *ctx,
 header->length = sizeof(struct acpi_fadt);
 header->revision = 4;

-   fadt->firmware_ctrl = (u32)ctx->facs;
-   fadt->dsdt = (u32)ctx->dsdt;
 fadt->preferred_pm_profile = ACPI_PM_MOBILE;
 fadt->sci_int = 9;
 fadt->smi_cmd = 0;
@@ -79,10 +77,8 @@ static int baytrail_write_fadt(struct acpi_ctx *ctx,
 fadt->reset_reg.addrh = 0;
 fadt->reset_value = SYS_RST | RST_CPU | FULL_RST;

-   fadt->x_firmware_ctl_l = (u32)ctx->facs;
-   fadt->x_firmware_ctl_h = 0;
-   fadt->x_dsdt_l = (u32)ctx->dsdt;
-   fadt->x_dsdt_h = 0;
+   fadt->x_firmware_ctrl = (uintptr_t)ctx->facs;
+   fadt->x_dsdt = (uintptr_t)ctx->dsdt;

 fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
 fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
diff --git a/arch/x86/cpu/quark/acpi.c b/arch/x86/cpu/quark/acpi.c
index 9a2d682451..583d4583c0 100644
--- a/arch/x86/cpu/quark/acpi.c
+++ b/arch/x86/cpu/quark/acpi.c
@@ -26,8 +26,6 @@ static int quark_write_fadt(struct acpi_ctx *ctx,
 header->length = sizeof(struct acpi_fadt);
 header->revision = 4;

-   fadt->firmware_ctrl = (u32)ctx->facs;
-   fadt->dsdt = (u32)ctx->dsdt;
 fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED;
 fadt->sci_int = 9;
 fadt->smi_cmd = 0;
@@ -74,10 +72,8 @@ static int quark_write_fadt(struct acpi_ctx *ctx,
 fadt->reset_reg.addrh = 0;
 fadt->reset_value = SYS_RST | RST_CPU | FULL_RST;

-   fadt->x_firmware_ctl_l = (u32)ctx->facs;
-   fadt->x_firmware_ctl_h = 0;
-   fadt->x_dsdt_l = (u32)ctx->dsdt;
-   fadt->x_dsdt_h = 0;
+   fadt->x_firmware_ctrl = (uintptr_t)ctx->facs;
+   fadt->x_dsdt = (uintptr_t)ctx->dsdt;

 fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
 fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
diff --git a/arch/x86/cpu/tangier/acpi.c b/arch/x86/cpu/tangier/acpi.c
index 1c667c7d56..19ec6e3390 100644
--- a/arch/x86/cpu/tangier/acpi.c
+++ b/arch/x86/cpu/tangier/acpi.c
@@ -31,8 +31,6 @@ static int tangier_write_fadt(struct acpi_ctx *ctx,
 header->length = sizeof(struct acpi_fadt);
 header->revision = 6;

-   fadt->firmware_ctrl = (u32)ctx->facs;
-   fadt->dsdt = (u32)ctx->dsdt;
 fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED;

 fadt->iapc_boot_arch = ACPI_FADT_VGA_NOT_PRESENT |
@@ -45,10 +43,8 @@ static int tangier_write_fadt(struct acpi_ctx *ctx,

 fadt->minor_revision = 2;

-   fadt->x_firmware_ctl_l = (u32)ctx->facs;
-   fadt->x_firmware_ctl_h = 0;
-   fadt->x_dsdt_l = (u32)ctx->dsdt;
-   fadt->x_dsdt_h = 0;
+   fadt->x_firmware_ctrl = (uintptr_t)ctx->facs;
+   fadt->x_dsdt = (uintptr_t)ctx->dsdt;

 header->checksum = table_compute_checksum(fadt, header->length);

diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index c5b33dc65d..f49b6933ab 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -572,13 +572,8 @@ void acpi_fadt_common(struct acpi_fadt *fadt, struct 
acpi_facs *facs,

Re: [PATCH v3 2/2] test: dm: clk_ccf: test ccf_clk_ops

2023-12-15 Thread Sean Anderson

On 12/15/23 13:28, Yang Xiwen via B4 Relay wrote:

From: Yang Xiwen 

Assign ccf_clk_ops to .ops of clk_ccf driver so that it can act as an
clk provider. Also add "#clock-cells=<1>" to its device tree node.

Add "i2c_root" to clk_test in the device tree and driver for testing.

Get "i2c_root" clock in CCF unit tests and add tests for it.

Signed-off-by: Yang Xiwen 
---
  arch/sandbox/dts/test.dts  |  4 +++-
  arch/sandbox/include/asm/clk.h |  1 +
  drivers/clk/clk_sandbox_ccf.c  |  1 +
  drivers/clk/clk_sandbox_test.c |  1 +
  test/dm/clk_ccf.c  | 14 +++---
  5 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index c7197795ef..a3a865d65c 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -631,9 +631,10 @@
clocks = <&clk_fixed>,
 <&clk_sandbox 1>,
 <&clk_sandbox 0>,
+<&ccf 11>,
 <&clk_sandbox 3>,
 <&clk_sandbox 2>;
-   clock-names = "fixed", "i2c", "spi", "uart2", "uart1";
+   clock-names = "fixed", "i2c", "spi", "i2c_root", "uart2", 
"uart1";
};
  
  	clk-test2 {

@@ -654,6 +655,7 @@
  
  	ccf: clk-ccf {

compatible = "sandbox,clk-ccf";
+   #clock-cells = <1>;
};
  
  	efi-media {

diff --git a/arch/sandbox/include/asm/clk.h b/arch/sandbox/include/asm/clk.h
index df7156fe31..1daf2e7ac7 100644
--- a/arch/sandbox/include/asm/clk.h
+++ b/arch/sandbox/include/asm/clk.h
@@ -39,6 +39,7 @@ enum sandbox_clk_test_id {
SANDBOX_CLK_TEST_ID_FIXED,
SANDBOX_CLK_TEST_ID_SPI,
SANDBOX_CLK_TEST_ID_I2C,
+   SANDBOX_CLK_TEST_ID_I2C_ROOT,
SANDBOX_CLK_TEST_ID_DEVM1,
SANDBOX_CLK_TEST_ID_DEVM2,
SANDBOX_CLK_TEST_ID_DEVM_NULL,
diff --git a/drivers/clk/clk_sandbox_ccf.c b/drivers/clk/clk_sandbox_ccf.c
index fedcdd4044..38184e27aa 100644
--- a/drivers/clk/clk_sandbox_ccf.c
+++ b/drivers/clk/clk_sandbox_ccf.c
@@ -284,6 +284,7 @@ static int sandbox_clk_ccf_probe(struct udevice *dev)
  U_BOOT_DRIVER(sandbox_clk_ccf) = {
.name = "sandbox_clk_ccf",
.id = UCLASS_CLK,
+   .ops = &ccf_clk_ops,
.probe = sandbox_clk_ccf_probe,
.of_match = sandbox_clk_ccf_test_ids,
  };
diff --git a/drivers/clk/clk_sandbox_test.c b/drivers/clk/clk_sandbox_test.c
index 5807a454f3..c695b69321 100644
--- a/drivers/clk/clk_sandbox_test.c
+++ b/drivers/clk/clk_sandbox_test.c
@@ -15,6 +15,7 @@ static const char * const sandbox_clk_test_names[] = {
[SANDBOX_CLK_TEST_ID_FIXED] = "fixed",
[SANDBOX_CLK_TEST_ID_SPI] = "spi",
[SANDBOX_CLK_TEST_ID_I2C] = "i2c",
+   [SANDBOX_CLK_TEST_ID_I2C_ROOT] = "i2c_root",
  };
  
  int sandbox_clk_test_get(struct udevice *dev)

diff --git a/test/dm/clk_ccf.c b/test/dm/clk_ccf.c
index e4ebb93cda..b8be6d6572 100644
--- a/test/dm/clk_ccf.c
+++ b/test/dm/clk_ccf.c
@@ -18,8 +18,8 @@
  /* Tests for Common Clock Framework driver */
  static int dm_test_clk_ccf(struct unit_test_state *uts)
  {
-   struct clk *clk, *pclk;
-   struct udevice *dev;
+   struct clk *clk, *pclk, clk_ccf;
+   struct udevice *dev, *test_dev;
long long rate;
int ret;
  #if CONFIG_IS_ENABLED(CLK_CCF)
@@ -29,6 +29,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
  
  	/* Get the device using the clk device */

ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-ccf", &dev));
+   ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test", 
&test_dev));
  
  	/* Test for clk_get_by_id() */

ret = clk_get_by_id(SANDBOX_CLK_ECSPI_ROOT, &clk);
@@ -110,11 +111,18 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
  
  #if CONFIG_IS_ENABLED(CLK_CCF)

/* Test clk tree enable/disable */
+
+   ret = clk_get_by_index(test_dev, SANDBOX_CLK_TEST_ID_I2C_ROOT, 
&clk_ccf);
+   ut_assertok(ret);
+   ut_asserteq_str("clk-ccf", clk_ccf.dev->name);
+   ut_asserteq(clk_ccf.id, SANDBOX_CLK_I2C_ROOT);
+
ret = clk_get_by_id(SANDBOX_CLK_I2C_ROOT, &clk);
ut_assertok(ret);
ut_asserteq_str("i2c_root", clk->dev->name);
+   ut_asserteq(clk->id, SANDBOX_CLK_I2C_ROOT);
  
-	ret = clk_enable(clk);

+   ret = clk_enable(&clk_ccf);
ut_assertok(ret);
  
  	ret = sandbox_clk_enable_count(clk);




Reviewed-by: Sean Anderson 


Re: [PATCH v1 1/1] clk: clk-gpio: add actual gated clock

2023-12-15 Thread Sean Anderson

On 12/15/23 13:26, Svyatoslav Ryhel wrote:

пт, 15 груд. 2023 р. о 19:25 Sean Anderson  пише:


On 11/17/23 02:52, Svyatoslav Ryhel wrote:

Existing gpio-gate-clock driver acts like a simple GPIO switch without any
effect on gated clock. Add actual clock actions into enable/disable ops and
implement get_rate op by passing gated clock if it is enabled.

Signed-off-by: Svyatoslav Ryhel 
---
   drivers/clk/clk-gpio.c | 47 +++---
   1 file changed, 40 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c
index 26d795b978..a55470cfbf 100644
--- a/drivers/clk/clk-gpio.c
+++ b/drivers/clk/clk-gpio.c
@@ -3,19 +3,23 @@
* Copyright (C) 2023 Marek Vasut 
*/

-#include 
-#include 
-#include 
+#include 
   #include 
+#include 
+#include 
+
+#include 

   struct clk_gpio_priv {
   struct gpio_descenable;
+ struct clk  *clk;


Please name this "parent".


I see no need in this since clk is generic name and this driver can
accept only one clock with any name.


It's good documentation. It makes it clear what the purpose of the member is.


   };

   static int clk_gpio_enable(struct clk *clk)
   {
   struct clk_gpio_priv *priv = dev_get_priv(clk->dev);

+ clk_prepare_enable(priv->clk);


Just clk_enable is fine. We don't have a separate prepare stage line Linux.


U-Boot supports clk_prepare_enable and since this support is present I
see no contradiction in using it.


These functions are only there for to make it easier to port code from Linux.
Since this code was written for U-Boot, just use the actual function.


   dm_gpio_set_value(&priv->enable, 1);

   return 0;
@@ -26,21 +30,50 @@ static int clk_gpio_disable(struct clk *clk)
   struct clk_gpio_priv *priv = dev_get_priv(clk->dev);

   dm_gpio_set_value(&priv->enable, 0);
+ clk_disable_unprepare(priv->clk);

   return 0;
   }

+static ulong clk_gpio_get_rate(struct clk *clk)
+{
+ struct clk_gpio_priv *priv = dev_get_priv(clk->dev);
+ int ret;
+
+ ret = dm_gpio_get_value(&priv->enable);
+ if (ret)
+ return clk_get_rate(priv->clk);
+ else
+ return -EINVAL;


This should always return the parent rate.


How can you return clock rate if the gate is disabled?


This allows consumers to know what the rate will be before they
enable the clock.


+}
+
   const struct clk_ops clk_gpio_ops = {
   .enable = clk_gpio_enable,
   .disable= clk_gpio_disable,
+ .get_rate   = clk_gpio_get_rate,
   };

-static int clk_gpio_probe(struct udevice *dev)
+static int clk_gpio_of_to_plat(struct udevice *dev)


This change should be a separate commit.


This actually should not be accepted first place

.of_to_plat - convert device tree data to plat
.probe - make a device ready for use

https://github.com/u-boot/u-boot/blob/master/doc/develop/driver-model/design.rst


Yes, this is why I was a bit confused :)


   {
   struct clk_gpio_priv *priv = dev_get_priv(dev);
+ int ret;

- return gpio_request_by_name(dev, "enable-gpios", 0,
- &priv->enable, GPIOD_IS_OUT);
+ priv->clk = devm_clk_get(dev, NULL);
+ if (IS_ERR(priv->clk)) {
+ log_err("%s: Could not get gated clock: %ld\n",
+ __func__, PTR_ERR(priv->clk));
+ return PTR_ERR(priv->clk);
+ }
+
+ ret = gpio_request_by_name(dev, "enable-gpios", 0,
+&priv->enable, GPIOD_IS_OUT);
+ if (ret) {
+ log_err("%s: Could not decode enable-gpios (%d)\n",
+ __func__, ret);


Use dev_dbg for probe errors to reduce binary size.


These errors provide intel about probing 2 key parts of the driver.
How would you know it fails in case you have no devices which face
this error? Iis there any convention or restriction which prohibits
this? If yes, then provide a document please.


https://docs.u-boot.org/en/latest/develop/driver-model/design.html#error-codes

| Ideally, messages in drivers should only be displayed when debugging,
| e.g. by using log_debug() although in extreme cases log_warning() or
| log_error() may be used.


All other general clock drivers use log_err/dev_err versions btw.


Yeah, it's something we have not been so consistent with enforcing.


+ return ret;
+ }
+
+ return 0;
   }

   /*
@@ -59,7 +92,7 @@ U_BOOT_DRIVER(gpio_gate_clock) = {
   .name   = "gpio_clock",
   .id = UCLASS_CLK,
   .of_match   = clk_gpio_match,
- .probe  = clk_gpio_probe,
+ .of_to_plat = clk_gpio_of_to_plat,
   .priv_auto  = sizeof(struct clk_gpio_priv),
   .ops= &clk_gpio_ops,
   .flags  = DM_FLAG_PRE_RELOC,


--Sean




Re: [PATCH v2 1/4] acpi: fix FADT table

2023-12-15 Thread Andy Shevchenko
On Fri, Dec 15, 2023 at 07:26:55PM +0100, 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.

...

> v2:
>   no change

Have you seen my email?

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH 2/2] ARM: dts: imx8mm-venice: prepare for dek blob encapsulation

2023-12-15 Thread Fabio Estevam
Hi Tim,

On Fri, Dec 15, 2023 at 3:34 PM Tim Harvey  wrote:

> Fabio,
>
> The commit log details are not valid for upstream. I was basing this
> off of 8d060e4a66d6884341fbb3d8ab1d837a3f173d47 which made it upstream
> with the same message.
>
> I can submit a v2 if necessary.

Yes, please submit a v2 and I will queue this series and the TPM one
to u-boot-imx next.

Regards,

Fabio Estevam


Re: [PATCH v6 06/17] arm: mach-k3: j784s4: Add clk and power support

2023-12-15 Thread Bryan Brattlof
On December  6, 2023 thus sayeth Apurva Nandan:
> Add clk and device data which can be used by respective drivers
> to configure clocks and PSC.
> 
> Signed-off-by: Hari Nagalla 
> Signed-off-by: Apurva Nandan 
> ---
>  arch/arm/mach-k3/r5/j784s4/Makefile|   7 +
>  arch/arm/mach-k3/r5/j784s4/clk-data.c  | 428 +
>  arch/arm/mach-k3/r5/j784s4/dev-data.c  |  98 ++
>  drivers/clk/ti/clk-k3.c|   6 +
>  drivers/power/domain/ti-power-domain.c |   6 +
>  include/k3-clk.h   |   1 +
>  include/k3-dev.h   |   1 +
>  7 files changed, 547 insertions(+)
>  create mode 100644 arch/arm/mach-k3/r5/j784s4/Makefile
>  create mode 100644 arch/arm/mach-k3/r5/j784s4/clk-data.c
>  create mode 100644 arch/arm/mach-k3/r5/j784s4/dev-data.c

...


> diff --git a/arch/arm/mach-k3/r5/j784s4/clk-data.c 
> b/arch/arm/mach-k3/r5/j784s4/clk-data.c
> new file mode 100644
> index 00..d3fac38dd6
> --- /dev/null
> +++ b/arch/arm/mach-k3/r5/j784s4/clk-data.c
> @@ -0,0 +1,428 @@

...

> +const struct ti_k3_clk_platdata j784s4_clk_platdata = {
> + .clk_list = clk_list,
> + .clk_list_cnt = 106,
> + .soc_dev_clk_data = soc_dev_clk_data,
> + .soc_dev_clk_data_cnt = 128,

These should probably be updated to use the ARRAY_SIZE() macros instead 
of their hard coded values.

> diff --git a/arch/arm/mach-k3/r5/j784s4/dev-data.c 
> b/arch/arm/mach-k3/r5/j784s4/dev-data.c
> new file mode 100644
> index 00..a9b77d0f49
> --- /dev/null
> +++ b/arch/arm/mach-k3/r5/j784s4/dev-data.c
> @@ -0,0 +1,98 @@

...

> +const struct ti_k3_pd_platdata j784s4_pd_platdata = {
> + .psc = soc_psc_list,
> + .pd = soc_pd_list,
> + .lpsc = soc_lpsc_list,
> + .devs = soc_dev_list,
> + .num_psc = 3,
> + .num_pd = 8,
> + .num_lpsc = 23,
> + .num_devs = 30,
> +};

Here too, just to make future updates a little easier.

~Bryan


Re: [PATCH 0/2] Fix NULL dereference in clk_composite_set_rate()

2023-12-15 Thread Sean Anderson
On Wed, 6 Dec 2023 02:23:32 +0300, Igor Prusov wrote:
> On sandbox it's possible to trigger NULL dereference when setting rate
> of a composite clock. It happens because sandbox composite divider does
> not implement set_rate() operation. This series adds NULL check and a
> test cases for clk_set_rate().
> 
> 
> Igor Prusov (2):
>   clk: Check that composite clock's div has set_rate()
>   dm: test: clk: Add test for ccf clk_set_rate()
> 
> [...]

Applied, thanks!

[1/2] clk: Check that composite clock's div has set_rate()
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/54d7da773062
[2/2] dm: test: clk: Add test for ccf clk_set_rate()
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/9e0250321a0d

Best regards,
-- 
Sean Anderson 


Re: [PATCH v2] clk: check parent_name in clk_register to avoid confusing log_error() output

2023-12-15 Thread Sean Anderson
On Sat, 11 Nov 2023 03:19:52 +0800, Yang Xiwen wrote:
> For some gate clocks and fixed clocks without a parent, calling
> clk_register will print an useless error message indicating that parent
> is missing. Fix that by gaurding log_xxx() with an if-statement.
> 
> 

Applied, thanks!

[1/1] clk: check parent_name in clk_register to avoid confusing log_error() 
output
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/09844d0de555

Best regards,
-- 
Sean Anderson 


Re: (subset) [PATCH v2 2/4] clk: get correct ops for clk_enable() and clk_disable()

2023-12-15 Thread Sean Anderson
On Sun, 19 Nov 2023 06:10:06 +0800, Yang Xiwen wrote:
> assign clk_dev_ops(clkp->dev) to ops to ensure correct clk operations
> are called on clocks.
> 
> This fixes the incorrect enable_count issue as described in [1].
> 
> [1]: 
> https://lore.kernel.org/all/sezpr06mb695927a6deeef8489a06897396...@sezpr06mb6959.apcprd06.prod.outlook.com/
> 
> [...]

Applied, thanks!

[2/4] clk: get correct ops for clk_enable() and clk_disable()
  https://source.denx.de/u-boot/custodians/u-boot-clk/-/commit/3fb2d3d6acba

Best regards,
-- 
Sean Anderson 


Re: [PATCH 2/2] ARM: dts: imx8mm-venice: prepare for dek blob encapsulation

2023-12-15 Thread Tim Harvey
On Thu, Dec 14, 2023 at 8:30 AM Fabio Estevam  wrote:
>
> Hi Tim,
>
> On Thu, Dec 14, 2023 at 1:25 PM Tim Harvey  wrote:
> >
> > Prepare for DEK blob encapsulation support through "dek_blob" command.
> > On ARMv8, u-boot runs in non-secure, thus cannot encapsulate a DEK blob
> > for encrypted boot.
> >
> > The DEK blob is encapsulated by OP-TEE through a trusted application
> > call. U-boot sends and receives the DEK and the DEK blob binaries
> > through OP-TEE dynamic shared memory.
> >
> > To enable the DEK blob encapsulation, add to the defconfig:
> > CONFIG_SECURE_BOOT=y
>
> This option does not exist.
>
> Do you mean CONFIG_IMX_HAB=y?

Fabio,

The commit log details are not valid for upstream. I was basing this
off of 8d060e4a66d6884341fbb3d8ab1d837a3f173d47 which made it upstream
with the same message.

I can submit a v2 if necessary.

Best Regards,

Tim


Re: [PATCH v3 0/4] bootm: Handle compressed arm64 images with bootm

2023-12-15 Thread Tom Rini
On Sun, 19 Nov 2023 07:43:30 -0700, Simon Glass wrote:

> This little series corrects a problem I noticed with arm64 images,
> where the kernel is not recognised if compression is used:
> 
>U-Boot> tftp image.fit
>Using ethernet@7d58 device
>TFTP from server 192.168.4.7; our IP address is 192.168.4.147
>Filename 'image.fit'.
>Load address: 0x100
>Loading: ##  23 MiB
>20.5 MiB/s
>done
>Bytes transferred = 24118272 (1700400 hex)
>U-Boot> bootm
>## Loading kernel from FIT Image at 0100 ...
>   Using 'conf-768' configuration
>   Trying 'kernel' kernel subimage
> Description:  Linux
> Type: Kernel Image (no loading done)
> Compression:  gzip compressed
> Data Start:   0x01000120
> Data Size:13662338 Bytes = 13 MiB
>   Verifying Hash Integrity ... OK
>Bad Linux ARM64 Image magic!
> 
> [...]

Applied to u-boot/next, thanks!

-- 
Tom




[PATCH v3 0/2] clk: ccf: fix enable_count mismatch

2023-12-15 Thread Yang Xiwen via B4 Relay
As described in [1], enable_count is incremented by 2 when
ccf_clk_enable() is called. This series of patch fixed this issue and
added a testcase for that.

[1]: 
https://lore.kernel.org/all/sezpr06mb695927a6deeef8489a06897396...@sezpr06mb6959.apcprd06.prod.outlook.com/

Signed-off-by: Yang Xiwen 
---
Changes in v3:
- move i2v_root in front of devm clocks. So that clk_test driver needs a
  minimum modification
- squash patch 1, 3 and 4. -- Suggested by Sean
- rewrite commit log for clarity.
- Link to v2: 
https://lore.kernel.org/r/2023-enable_count-v2-0-20e372860...@outlook.com

Changes in v2:
- add missing SoB in patch 1/4, no functional change
- Link to v1: 
https://lore.kernel.org/r/2023-enable_count-v1-0-509f400a9...@outlook.com

---
Yang Xiwen (2):
  clk: get correct ops for clk_enable() and clk_disable()
  test: dm: clk_ccf: test ccf_clk_ops

 arch/sandbox/dts/test.dts  |  4 +++-
 arch/sandbox/include/asm/clk.h |  1 +
 drivers/clk/clk-uclass.c   |  2 ++
 drivers/clk/clk_sandbox_ccf.c  |  1 +
 drivers/clk/clk_sandbox_test.c |  1 +
 test/dm/clk_ccf.c  | 14 +++---
 6 files changed, 19 insertions(+), 4 deletions(-)
---
base-commit: 3b913c148249a2b9d12ff25517ec311646e83bee
change-id: 2023-enable_count-ad5001326815

Best regards,
-- 
Yang Xiwen 



[PATCH v3 1/2] clk: get correct ops for clk_enable() and clk_disable()

2023-12-15 Thread Yang Xiwen via B4 Relay
From: Yang Xiwen 

assign clk_dev_ops(clkp->dev) to ops to ensure correct clk operations
are called on clocks.

This fixes the incorrect enable_count issue as described in [1].

[1]: 
https://lore.kernel.org/all/sezpr06mb695927a6deeef8489a06897396...@sezpr06mb6959.apcprd06.prod.outlook.com/

Reviewed-by: Sean Anderson 
Signed-off-by: Yang Xiwen 
---
 drivers/clk/clk-uclass.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 3b5e3f9c86..3e9d68feb3 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -640,6 +640,7 @@ int clk_enable(struct clk *clk)
if (CONFIG_IS_ENABLED(CLK_CCF)) {
/* Take id 0 as a non-valid clk, such as dummy */
if (clk->id && !clk_get_by_id(clk->id, &clkp)) {
+   ops = clk_dev_ops(clkp->dev);
if (clkp->enable_count) {
clkp->enable_count++;
return 0;
@@ -699,6 +700,7 @@ int clk_disable(struct clk *clk)
 
if (CONFIG_IS_ENABLED(CLK_CCF)) {
if (clk->id && !clk_get_by_id(clk->id, &clkp)) {
+   ops = clk_dev_ops(clkp->dev);
if (clkp->flags & CLK_IS_CRITICAL)
return 0;
 

-- 
2.39.2



[PATCH v3 2/2] test: dm: clk_ccf: test ccf_clk_ops

2023-12-15 Thread Yang Xiwen via B4 Relay
From: Yang Xiwen 

Assign ccf_clk_ops to .ops of clk_ccf driver so that it can act as an
clk provider. Also add "#clock-cells=<1>" to its device tree node.

Add "i2c_root" to clk_test in the device tree and driver for testing.

Get "i2c_root" clock in CCF unit tests and add tests for it.

Signed-off-by: Yang Xiwen 
---
 arch/sandbox/dts/test.dts  |  4 +++-
 arch/sandbox/include/asm/clk.h |  1 +
 drivers/clk/clk_sandbox_ccf.c  |  1 +
 drivers/clk/clk_sandbox_test.c |  1 +
 test/dm/clk_ccf.c  | 14 +++---
 5 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index c7197795ef..a3a865d65c 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -631,9 +631,10 @@
clocks = <&clk_fixed>,
 <&clk_sandbox 1>,
 <&clk_sandbox 0>,
+<&ccf 11>,
 <&clk_sandbox 3>,
 <&clk_sandbox 2>;
-   clock-names = "fixed", "i2c", "spi", "uart2", "uart1";
+   clock-names = "fixed", "i2c", "spi", "i2c_root", "uart2", 
"uart1";
};
 
clk-test2 {
@@ -654,6 +655,7 @@
 
ccf: clk-ccf {
compatible = "sandbox,clk-ccf";
+   #clock-cells = <1>;
};
 
efi-media {
diff --git a/arch/sandbox/include/asm/clk.h b/arch/sandbox/include/asm/clk.h
index df7156fe31..1daf2e7ac7 100644
--- a/arch/sandbox/include/asm/clk.h
+++ b/arch/sandbox/include/asm/clk.h
@@ -39,6 +39,7 @@ enum sandbox_clk_test_id {
SANDBOX_CLK_TEST_ID_FIXED,
SANDBOX_CLK_TEST_ID_SPI,
SANDBOX_CLK_TEST_ID_I2C,
+   SANDBOX_CLK_TEST_ID_I2C_ROOT,
SANDBOX_CLK_TEST_ID_DEVM1,
SANDBOX_CLK_TEST_ID_DEVM2,
SANDBOX_CLK_TEST_ID_DEVM_NULL,
diff --git a/drivers/clk/clk_sandbox_ccf.c b/drivers/clk/clk_sandbox_ccf.c
index fedcdd4044..38184e27aa 100644
--- a/drivers/clk/clk_sandbox_ccf.c
+++ b/drivers/clk/clk_sandbox_ccf.c
@@ -284,6 +284,7 @@ static int sandbox_clk_ccf_probe(struct udevice *dev)
 U_BOOT_DRIVER(sandbox_clk_ccf) = {
.name = "sandbox_clk_ccf",
.id = UCLASS_CLK,
+   .ops = &ccf_clk_ops,
.probe = sandbox_clk_ccf_probe,
.of_match = sandbox_clk_ccf_test_ids,
 };
diff --git a/drivers/clk/clk_sandbox_test.c b/drivers/clk/clk_sandbox_test.c
index 5807a454f3..c695b69321 100644
--- a/drivers/clk/clk_sandbox_test.c
+++ b/drivers/clk/clk_sandbox_test.c
@@ -15,6 +15,7 @@ static const char * const sandbox_clk_test_names[] = {
[SANDBOX_CLK_TEST_ID_FIXED] = "fixed",
[SANDBOX_CLK_TEST_ID_SPI] = "spi",
[SANDBOX_CLK_TEST_ID_I2C] = "i2c",
+   [SANDBOX_CLK_TEST_ID_I2C_ROOT] = "i2c_root",
 };
 
 int sandbox_clk_test_get(struct udevice *dev)
diff --git a/test/dm/clk_ccf.c b/test/dm/clk_ccf.c
index e4ebb93cda..b8be6d6572 100644
--- a/test/dm/clk_ccf.c
+++ b/test/dm/clk_ccf.c
@@ -18,8 +18,8 @@
 /* Tests for Common Clock Framework driver */
 static int dm_test_clk_ccf(struct unit_test_state *uts)
 {
-   struct clk *clk, *pclk;
-   struct udevice *dev;
+   struct clk *clk, *pclk, clk_ccf;
+   struct udevice *dev, *test_dev;
long long rate;
int ret;
 #if CONFIG_IS_ENABLED(CLK_CCF)
@@ -29,6 +29,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
 
/* Get the device using the clk device */
ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-ccf", &dev));
+   ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test", 
&test_dev));
 
/* Test for clk_get_by_id() */
ret = clk_get_by_id(SANDBOX_CLK_ECSPI_ROOT, &clk);
@@ -110,11 +111,18 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
 
 #if CONFIG_IS_ENABLED(CLK_CCF)
/* Test clk tree enable/disable */
+
+   ret = clk_get_by_index(test_dev, SANDBOX_CLK_TEST_ID_I2C_ROOT, 
&clk_ccf);
+   ut_assertok(ret);
+   ut_asserteq_str("clk-ccf", clk_ccf.dev->name);
+   ut_asserteq(clk_ccf.id, SANDBOX_CLK_I2C_ROOT);
+
ret = clk_get_by_id(SANDBOX_CLK_I2C_ROOT, &clk);
ut_assertok(ret);
ut_asserteq_str("i2c_root", clk->dev->name);
+   ut_asserteq(clk->id, SANDBOX_CLK_I2C_ROOT);
 
-   ret = clk_enable(clk);
+   ret = clk_enable(&clk_ccf);
ut_assertok(ret);
 
ret = sandbox_clk_enable_count(clk);

-- 
2.39.2



[PATCH v2 4/4] aci: fix acpi_find_table() for DSDT and FACS

2023-12-15 Thread Heinrich Schuchardt
Use X_DSDT and X_FIRMWARE_CTRL if available.

Signed-off-by: Heinrich Schuchardt 
---
v2:
new patch
---
 lib/acpi/acpi.c | 29 -
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/lib/acpi/acpi.c b/lib/acpi/acpi.c
index f21e509461..f80b2176e1 100644
--- a/lib/acpi/acpi.c
+++ b/lib/acpi/acpi.c
@@ -45,11 +45,30 @@ struct acpi_table_header *acpi_find_table(const char *sig)
if (!memcmp(hdr->signature, "FACP", ACPI_NAME_LEN)) {
struct acpi_fadt *fadt = (struct acpi_fadt *)hdr;
 
-   if (!memcmp(sig, "DSDT", ACPI_NAME_LEN) && fadt->dsdt)
-   return map_sysmem(fadt->dsdt, 0);
-   if (!memcmp(sig, "FACS", ACPI_NAME_LEN) &&
-   fadt->firmware_ctrl)
-   return map_sysmem(fadt->firmware_ctrl, 0);
+   if (!memcmp(sig, "DSDT", ACPI_NAME_LEN)) {
+   void *dsdt;
+
+   if (fadt->header.revision >= 3 && fadt->x_dsdt)
+   dsdt = map_sysmem(fadt->x_dsdt, 0);
+   else if (fadt->dsdt)
+   dsdt = map_sysmem(fadt->dsdt, 0);
+   else
+   dsdt = NULL;
+   return dsdt;
+   }
+
+   if (!memcmp(sig, "FACS", ACPI_NAME_LEN)) {
+   void *facs;
+
+   if (fadt->header.revision >= 3 &&
+   fadt->x_firmware_ctrl)
+   facs = 
map_sysmem(fadt->x_firmware_ctrl, 0);
+   else if (fadt->firmware_ctrl)
+   facs = map_sysmem(fadt->firmware_ctrl, 
0);
+   else
+   facs = NULL;
+   return facs;
+   }
}
}
 
-- 
2.40.1



Re: [PATCH v1 1/1] clk: clk-gpio: add actual gated clock

2023-12-15 Thread Svyatoslav Ryhel
пт, 15 груд. 2023 р. о 19:25 Sean Anderson  пише:
>
> On 11/17/23 02:52, Svyatoslav Ryhel wrote:
> > Existing gpio-gate-clock driver acts like a simple GPIO switch without any
> > effect on gated clock. Add actual clock actions into enable/disable ops and
> > implement get_rate op by passing gated clock if it is enabled.
> >
> > Signed-off-by: Svyatoslav Ryhel 
> > ---
> >   drivers/clk/clk-gpio.c | 47 +++---
> >   1 file changed, 40 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c
> > index 26d795b978..a55470cfbf 100644
> > --- a/drivers/clk/clk-gpio.c
> > +++ b/drivers/clk/clk-gpio.c
> > @@ -3,19 +3,23 @@
> >* Copyright (C) 2023 Marek Vasut 
> >*/
> >
> > -#include 
> > -#include 
> > -#include 
> > +#include 
> >   #include 
> > +#include 
> > +#include 
> > +
> > +#include 
> >
> >   struct clk_gpio_priv {
> >   struct gpio_descenable;
> > + struct clk  *clk;
>
> Please name this "parent".
>
I see no need in this since clk is generic name and this driver can
accept only one clock with any name.

> >   };
> >
> >   static int clk_gpio_enable(struct clk *clk)
> >   {
> >   struct clk_gpio_priv *priv = dev_get_priv(clk->dev);
> >
> > + clk_prepare_enable(priv->clk);
>
> Just clk_enable is fine. We don't have a separate prepare stage line Linux.
>
U-Boot supports clk_prepare_enable and since this support is present I
see no contradiction in using it.

> >   dm_gpio_set_value(&priv->enable, 1);
> >
> >   return 0;
> > @@ -26,21 +30,50 @@ static int clk_gpio_disable(struct clk *clk)
> >   struct clk_gpio_priv *priv = dev_get_priv(clk->dev);
> >
> >   dm_gpio_set_value(&priv->enable, 0);
> > + clk_disable_unprepare(priv->clk);
> >
> >   return 0;
> >   }
> >
> > +static ulong clk_gpio_get_rate(struct clk *clk)
> > +{
> > + struct clk_gpio_priv *priv = dev_get_priv(clk->dev);
> > + int ret;
> > +
> > + ret = dm_gpio_get_value(&priv->enable);
> > + if (ret)
> > + return clk_get_rate(priv->clk);
> > + else
> > + return -EINVAL;
>
> This should always return the parent rate.
>
How can you return clock rate if the gate is disabled?

> > +}
> > +
> >   const struct clk_ops clk_gpio_ops = {
> >   .enable = clk_gpio_enable,
> >   .disable= clk_gpio_disable,
> > + .get_rate   = clk_gpio_get_rate,
> >   };
> >
> > -static int clk_gpio_probe(struct udevice *dev)
> > +static int clk_gpio_of_to_plat(struct udevice *dev)
>
> This change should be a separate commit.
>
This actually should not be accepted first place

.of_to_plat - convert device tree data to plat
.probe - make a device ready for use

https://github.com/u-boot/u-boot/blob/master/doc/develop/driver-model/design.rst

> >   {
> >   struct clk_gpio_priv *priv = dev_get_priv(dev);
> > + int ret;
> >
> > - return gpio_request_by_name(dev, "enable-gpios", 0,
> > - &priv->enable, GPIOD_IS_OUT);
> > + priv->clk = devm_clk_get(dev, NULL);
> > + if (IS_ERR(priv->clk)) {
> > + log_err("%s: Could not get gated clock: %ld\n",
> > + __func__, PTR_ERR(priv->clk));
> > + return PTR_ERR(priv->clk);
> > + }
> > +
> > + ret = gpio_request_by_name(dev, "enable-gpios", 0,
> > +&priv->enable, GPIOD_IS_OUT);
> > + if (ret) {
> > + log_err("%s: Could not decode enable-gpios (%d)\n",
> > + __func__, ret);
>
> Use dev_dbg for probe errors to reduce binary size.
>
These errors provide intel about probing 2 key parts of the driver.
How would you know it fails in case you have no devices which face
this error? Iis there any convention or restriction which prohibits
this? If yes, then provide a document please.

All other general clock drivers use log_err/dev_err versions btw.

> > + return ret;
> > + }
> > +
> > + return 0;
> >   }
> >
> >   /*
> > @@ -59,7 +92,7 @@ U_BOOT_DRIVER(gpio_gate_clock) = {
> >   .name   = "gpio_clock",
> >   .id = UCLASS_CLK,
> >   .of_match   = clk_gpio_match,
> > - .probe  = clk_gpio_probe,
> > + .of_to_plat = clk_gpio_of_to_plat,
> >   .priv_auto  = sizeof(struct clk_gpio_priv),
> >   .ops= &clk_gpio_ops,
> >   .flags  = DM_FLAG_PRE_RELOC,
>
> --Sean


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

2023-12-15 Thread Heinrich Schuchardt
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 
---
v2:
no change
---
 cmd/acpi.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/cmd/acpi.c b/cmd/acpi.c
index 8d9eaf36c9..f6e02ea7a5 100644
--- a/cmd/acpi.c
+++ b/cmd/acpi.c
@@ -6,6 +6,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -57,6 +58,9 @@ static void list_fadt(struct acpi_fadt *fadt)
dump_hdr(map_sysmem(fadt->x_dsdt, 0));
else if (fadt->dsdt)
dump_hdr(map_sysmem(fadt->dsdt, 0));
+   if (!IS_ENABLED(CONFIG_X86) &&
+   !(fadt->flags & ACPI_FADT_HW_REDUCED_ACPI))
+   log_err("FADT not ACPI hardware reduced compliant\n");
if (fadt->header.revision >= 3 && fadt->x_firmware_ctrl)
dump_hdr(map_sysmem(fadt->x_firmware_ctrl, 0));
else if (fadt->firmware_ctrl)
-- 
2.40.1



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

2023-12-15 Thread Heinrich Schuchardt
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 
---
v2:
check FADT table revision
---
 cmd/acpi.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/cmd/acpi.c b/cmd/acpi.c
index 0c14409242..8d9eaf36c9 100644
--- a/cmd/acpi.c
+++ b/cmd/acpi.c
@@ -53,9 +53,13 @@ static int dump_table_name(const char *sig)
 
 static void list_fadt(struct acpi_fadt *fadt)
 {
-   if (fadt->dsdt)
+   if (fadt->header.revision >= 3 && fadt->x_dsdt)
+   dump_hdr(map_sysmem(fadt->x_dsdt, 0));
+   else if (fadt->dsdt)
dump_hdr(map_sysmem(fadt->dsdt, 0));
-   if (fadt->firmware_ctrl)
+   if (fadt->header.revision >= 3 && fadt->x_firmware_ctrl)
+   dump_hdr(map_sysmem(fadt->x_firmware_ctrl, 0));
+   else if (fadt->firmware_ctrl)
dump_hdr(map_sysmem(fadt->firmware_ctrl, 0));
 }
 
-- 
2.40.1



[PATCH v2 1/4] acpi: fix FADT table

2023-12-15 Thread Heinrich Schuchardt
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.

Signed-off-by: Heinrich Schuchardt 
---
v2:
no change
---
 arch/x86/cpu/baytrail/acpi.c | 8 ++--
 arch/x86/cpu/quark/acpi.c| 8 ++--
 arch/x86/cpu/tangier/acpi.c  | 8 ++--
 arch/x86/lib/acpi_table.c| 9 ++---
 include/acpi/acpi_table.h| 6 ++
 5 files changed, 10 insertions(+), 29 deletions(-)

diff --git a/arch/x86/cpu/baytrail/acpi.c b/arch/x86/cpu/baytrail/acpi.c
index 4378846f8b..5c28c4d260 100644
--- a/arch/x86/cpu/baytrail/acpi.c
+++ b/arch/x86/cpu/baytrail/acpi.c
@@ -31,8 +31,6 @@ static int baytrail_write_fadt(struct acpi_ctx *ctx,
header->length = sizeof(struct acpi_fadt);
header->revision = 4;
 
-   fadt->firmware_ctrl = (u32)ctx->facs;
-   fadt->dsdt = (u32)ctx->dsdt;
fadt->preferred_pm_profile = ACPI_PM_MOBILE;
fadt->sci_int = 9;
fadt->smi_cmd = 0;
@@ -79,10 +77,8 @@ static int baytrail_write_fadt(struct acpi_ctx *ctx,
fadt->reset_reg.addrh = 0;
fadt->reset_value = SYS_RST | RST_CPU | FULL_RST;
 
-   fadt->x_firmware_ctl_l = (u32)ctx->facs;
-   fadt->x_firmware_ctl_h = 0;
-   fadt->x_dsdt_l = (u32)ctx->dsdt;
-   fadt->x_dsdt_h = 0;
+   fadt->x_firmware_ctrl = (uintptr_t)ctx->facs;
+   fadt->x_dsdt = (uintptr_t)ctx->dsdt;
 
fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
diff --git a/arch/x86/cpu/quark/acpi.c b/arch/x86/cpu/quark/acpi.c
index 9a2d682451..583d4583c0 100644
--- a/arch/x86/cpu/quark/acpi.c
+++ b/arch/x86/cpu/quark/acpi.c
@@ -26,8 +26,6 @@ static int quark_write_fadt(struct acpi_ctx *ctx,
header->length = sizeof(struct acpi_fadt);
header->revision = 4;
 
-   fadt->firmware_ctrl = (u32)ctx->facs;
-   fadt->dsdt = (u32)ctx->dsdt;
fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED;
fadt->sci_int = 9;
fadt->smi_cmd = 0;
@@ -74,10 +72,8 @@ static int quark_write_fadt(struct acpi_ctx *ctx,
fadt->reset_reg.addrh = 0;
fadt->reset_value = SYS_RST | RST_CPU | FULL_RST;
 
-   fadt->x_firmware_ctl_l = (u32)ctx->facs;
-   fadt->x_firmware_ctl_h = 0;
-   fadt->x_dsdt_l = (u32)ctx->dsdt;
-   fadt->x_dsdt_h = 0;
+   fadt->x_firmware_ctrl = (uintptr_t)ctx->facs;
+   fadt->x_dsdt = (uintptr_t)ctx->dsdt;
 
fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
diff --git a/arch/x86/cpu/tangier/acpi.c b/arch/x86/cpu/tangier/acpi.c
index 1c667c7d56..19ec6e3390 100644
--- a/arch/x86/cpu/tangier/acpi.c
+++ b/arch/x86/cpu/tangier/acpi.c
@@ -31,8 +31,6 @@ static int tangier_write_fadt(struct acpi_ctx *ctx,
header->length = sizeof(struct acpi_fadt);
header->revision = 6;
 
-   fadt->firmware_ctrl = (u32)ctx->facs;
-   fadt->dsdt = (u32)ctx->dsdt;
fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED;
 
fadt->iapc_boot_arch = ACPI_FADT_VGA_NOT_PRESENT |
@@ -45,10 +43,8 @@ static int tangier_write_fadt(struct acpi_ctx *ctx,
 
fadt->minor_revision = 2;
 
-   fadt->x_firmware_ctl_l = (u32)ctx->facs;
-   fadt->x_firmware_ctl_h = 0;
-   fadt->x_dsdt_l = (u32)ctx->dsdt;
-   fadt->x_dsdt_h = 0;
+   fadt->x_firmware_ctrl = (uintptr_t)ctx->facs;
+   fadt->x_dsdt = (uintptr_t)ctx->dsdt;
 
header->checksum = table_compute_checksum(fadt, header->length);
 
diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index c5b33dc65d..f49b6933ab 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -572,13 +572,8 @@ void acpi_fadt_common(struct acpi_fadt *fadt, struct 
acpi_facs *facs,
memcpy(header->aslc_id, ASLC_ID, 4);
header->aslc_revision = 1;
 
-   fadt->firmware_ctrl = (unsigned long)facs;
-   fadt->dsdt = (unsigned long)dsdt;
-
-   fadt->x_firmware_ctl_l = (unsigned long)facs;
-   fadt->x_firmware_ctl_h = 0;
-   fadt->x_dsdt_l = (unsigned long)dsdt;
-   fadt->x_dsdt_h = 0;
+   fadt->x_firmware_ctrl = (uintptr_t)facs;
+   fadt->x_dsdt = (uintptr_t)dsdt;
 
fadt->preferred_pm_profile = ACPI_PM_MOBILE;
 
diff --git a/include/acpi/acpi_table.h b/include/acpi/acpi_table.h
index 20ac3b51ba..e67562ef65 100644
--- a/include/acpi/acpi_table.h
+++ b/include/acpi/acpi_table.h
@@ -228,10 +228,8 @@ struct __packed acpi_fadt {
u8 reset_value;
u16 arm_boot_arch;
u8 minor_revision;
-   u32 x_firmware_ctl_l;
-   u32 x_firmware_ctl_h;
-   u32 x_dsdt_l;
-   u32 x_dsdt_h;
+   u64 x_firmware_ctrl;
+   u64 x_dsdt;
struct acpi_gen_regaddr x_pm1a_evt_blk;
struct acpi_gen_regaddr x_pm1b_evt_blk;
struct ac

[PATCH v2 0/4] cmd: acpi: correct handling of DSDT and FACS

2023-12-15 Thread Heinrich Schuchardt
Fields X_FIRMWARE and X_DSDT in the FADT table must be 64bit.
Fix the definition in our include.

The 64bit fields X_FIRMWARE and X_DSDT take precedence over the respective
32bit fields. Consider this in the 'acpi list' and 'acpi dump' commands.
The fields only exist for FADT table revision 3 and above.

Don't fill unused fields FIRMWAE and DSDT.

Write an error if the hardware reduce flag is not set for non-x86 systems.

v2:
check FADT table revision
correct dumping DSDT and FACS

Heinrich Schuchardt (4):
  acpi: fix FADT table
  cmd: acpi: fix listing DSDT and FACS
  cmd: acpi: check HW reduced flag in acpi list
  aci: fix acpi_find_table() for DSDT and FACS

 arch/x86/cpu/baytrail/acpi.c |  8 ++--
 arch/x86/cpu/quark/acpi.c|  8 ++--
 arch/x86/cpu/tangier/acpi.c  |  8 ++--
 arch/x86/lib/acpi_table.c|  9 ++---
 cmd/acpi.c   | 12 ++--
 include/acpi/acpi_table.h|  6 ++
 lib/acpi/acpi.c  | 29 -
 7 files changed, 44 insertions(+), 36 deletions(-)

-- 
2.40.1



Re: [PATCH] rock-pi-4: Enable SPI flash

2023-12-15 Thread Dragan Simic

On 2023-12-15 15:00, Stefan Nagy wrote:

The ROCK Pi 4A/B/C boards come with a 32 Mbit SPI NOR flash chip
(XTX Technology Limited XT25F32).

Sync the devicetrees from Linux to enable spi1 and add a device
node for the NOR flash chip. In the board's defconfig files enable
the Rockchip SPI driver, add XTX SPI flash support and set the
SPI flash default bus identifier.

This patch has been tested on ROCK Pi 4A.

Signed-off-by: Stefan Nagy 
---
 arch/arm/dts/rk3399-rock-pi-4a.dts  | 10 ++
 arch/arm/dts/rk3399-rock-pi-4c.dts  | 10 ++
 configs/rock-pi-4-rk3399_defconfig  |  3 +++
 configs/rock-pi-4c-rk3399_defconfig |  3 +++
 4 files changed, 26 insertions(+)

diff --git a/arch/arm/dts/rk3399-rock-pi-4a.dts
b/arch/arm/dts/rk3399-rock-pi-4a.dts
index 931334aa..d5df8939 100644
--- a/arch/arm/dts/rk3399-rock-pi-4a.dts
+++ b/arch/arm/dts/rk3399-rock-pi-4a.dts
@@ -12,3 +12,13 @@
model = "Radxa ROCK Pi 4A";
compatible = "radxa,rockpi4a", "radxa,rockpi4", "rockchip,rk3399";
 };
+
+&spi1 {
+   status = "okay";
+
+   flash@0 {
+   compatible = "jedec,spi-nor";
+   reg = <0>;
+   spi-max-frequency = <1000>;
+   };
+};
diff --git a/arch/arm/dts/rk3399-rock-pi-4c.dts
b/arch/arm/dts/rk3399-rock-pi-4c.dts
index d32efab7..de2ebe4c 100644
--- a/arch/arm/dts/rk3399-rock-pi-4c.dts
+++ b/arch/arm/dts/rk3399-rock-pi-4c.dts
@@ -43,6 +43,16 @@
hp-det-gpio = <&gpio1 RK_PA0 GPIO_ACTIVE_HIGH>;
 };

+&spi1 {
+   status = "okay";
+
+   flash@0 {
+   compatible = "jedec,spi-nor";
+   reg = <0>;
+   spi-max-frequency = <1000>;
+   };
+};
+
 &uart0 {
status = "okay";

diff --git a/configs/rock-pi-4-rk3399_defconfig
b/configs/rock-pi-4-rk3399_defconfig
index 84e0dcf0..c45a8c04 100644
--- a/configs/rock-pi-4-rk3399_defconfig
+++ b/configs/rock-pi-4-rk3399_defconfig
@@ -61,6 +61,8 @@ CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_ROCKCHIP=y
+CONFIG_SF_DEFAULT_BUS=1
+CONFIG_SPI_FLASH_XTX=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_GMAC_ROCKCHIP=y
 CONFIG_NVME_PCI=y
@@ -74,6 +76,7 @@ CONFIG_RAM_ROCKCHIP_LPDDR4=y
 CONFIG_BAUDRATE=150
 CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_SYS_NS16550_MEM32=y
+CONFIG_ROCKCHIP_SPI=y
 CONFIG_SYSRESET=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
diff --git a/configs/rock-pi-4c-rk3399_defconfig
b/configs/rock-pi-4c-rk3399_defconfig
index 5c9fb147..1ca19b4e 100644
--- a/configs/rock-pi-4c-rk3399_defconfig
+++ b/configs/rock-pi-4c-rk3399_defconfig
@@ -58,6 +58,8 @@ CONFIG_MMC_DW=y
 CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_ROCKCHIP=y
+CONFIG_SF_DEFAULT_BUS=1
+CONFIG_SPI_FLASH_XTX=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_GMAC_ROCKCHIP=y
 CONFIG_NVME_PCI=y
@@ -71,6 +73,7 @@ CONFIG_RAM_ROCKCHIP_LPDDR4=y
 CONFIG_BAUDRATE=150
 CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_SYS_NS16550_MEM32=y
+CONFIG_ROCKCHIP_SPI=y
 CONFIG_SYSRESET=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y


Perhaps it would be better to wait a bit until your patch for the Linux 
kernel [1] is accepted, and then have the updated spi-max-frequency 
values synced back to U-Boot in the v2 of this patch.


[1] 
https://lore.kernel.org/linux-rockchip/4fce0de996d6cc3056d972cd3fc3f...@manjaro.org/T/#m0621f671c597a4c0138b27bfc6fa3a16f82b721f


Re: whitelist commands

2023-12-15 Thread Simon Glass
Hi Thomas,

On Fri, 15 Dec 2023 at 02:12, Thomas McCann  wrote:
>
> Hello Simon,
>
> Firstly my apologies I very new to U-Boot and just trying to make sense of it 
> all. My chip currently does not boot because the commands "bootelf" commend 
> is not whitelisted.
> My question was two-fold really, it the whitelisting done by u-boot or is 
> specified in the device tree?
> How does one modify the u-boot boot.scr so that I can boot my device to not 
> use bootelf?

Please can you keep the ML copied with replies? (and BTW we try to add
posts to the bottom)

To find this:
- look up do_bootelf()   (~all commands start with do_ and end with
the command name)
- this is in cmd/elf.c
- then look up cmd/Makefile to see where elf.o is enabled:
obj-$(CONFIG_CMD_ELF) += elf.o
- then look up cmd/Kconfig to see 'config CMD_ELF'

So probably your board has CMD_ELF disabled. It is enabled by default,
so perhaps you have '# CONFIG_CMD_ELF is not set' in the
config_xxx_defconfig for your board? If you remove that, then the
command should be enabled. You can check using 'make menuconfig' or by
using grep on the .config file produced.

Regards,
Simon


>
>
> Yours sincerely,
>
> Thomas McCann | Software Engineer
>
> -Original Message-
> From: Simon Glass 
> Sent: Wednesday, December 13, 2023 7:50 PM
> To: Thomas McCann 
> Cc: u-boot@lists.denx.de
> Subject: Re: whitelist commands
>
> CAUTION: This email originated from outside the organisation, do not click 
> links or open attachments unless you recognise the sender and know the 
> content is safe. Forward this email to 
> i...@drumgrange.com if you believe it is 
> suspicious.
>
> Hi Thomas,
>
> On Wed, 13 Dec 2023 at 07:29, Thomas McCann  wrote:
> >
> > How do I add commands to the whitelist.
>
> Which whitelist are you referring to? I am not aware of one for commands.
>
> Regards,
> Simon
>
>
> >
> >
> > Yours sincerely,
> >
> > [cid:image001.png@01DA2DCD.383194D0]
> >
> > Thomas McCann
> > Software Engineer
> > 📧 tmcc...@drumgrange.com
> >
> > [cid:image002.png@01DA2DCD.383194D0] > grange-ltd>[cid:image003.png@01DA2DCD.383194D0] > rg.uk/about/>. [cid:image004.png@01DA2DCD.383194D0]
> >  . [cid:image005.png@01DA2DCD.383194D0]
> > 
> > ..[cid:image006.jpg@01DA2DCD.383194D0] > t-us/armed-forces-corporate-covenant/>
> >
> > .
> > Drumgrange is recruiting! For more information, click
> > here.
> > .
> >
> > 🌲  Please consider the environment before printing this e-mail This
> > communication may contain information which is subject to UK Export Control 
> > Law, commercial-in-confidence and/or legally privileged and is intended 
> > only for the addressee named above. If you are not the named addressee, the 
> > communication has been sent to you in error. Any copying, distribution or 
> > other use of the information is strictly prohibited. Please note we do not 
> > accept liability for any viruses which may be transmitted in or with this 
> > message.
> >
> > Drumgrange Ltd. is a company registered in England and Wales with company 
> > registration number 1460044 Registered office address. Drumgrange Ltd. Unit 
> > A, The Forum, Hanworth Lane, Chertsey, Surrey, KT16 9JX.
> >


Re: [PATCH v2] clk: meson: add Hardware Clock measure driver

2023-12-15 Thread Sean Anderson

On 12/12/23 09:12, Neil Armstrong wrote:

Amlogic SoCs embeds an hardware clock measure block, port it
from Linux and implement it as a UCLK_CLK with only the dump
op and fail-only xlate.


Please include a short blurb describing the hardware like you did for Linux
commit 2b45ebef39a2 ("soc: amlogic: Add Meson Clock Measure driver").


Signed-off-by: Neil Armstrong 
---
Changes in v2:
- remove common.h and include time.h instead
- Link to v1: 
https://lore.kernel.org/r/20231113-uboot-meson-clk-msr-v1-1-73204d09f...@linaro.org
---
  drivers/clk/meson/Kconfig   |   9 +
  drivers/clk/meson/Makefile  |   1 +
  drivers/clk/meson/clk-measure.c | 634 
  3 files changed, 644 insertions(+)

diff --git a/drivers/clk/meson/Kconfig b/drivers/clk/meson/Kconfig
index cdc9d6f76c..da097ae7b8 100644
--- a/drivers/clk/meson/Kconfig
+++ b/drivers/clk/meson/Kconfig
@@ -29,3 +29,12 @@ config CLK_MESON_A1
help
  Enable clock support for the Amlogic A1 SoC family, such as
  the A113L
+
+config CLK_MESON_MSR
+   bool "Enable clock measure driver for Amlogic SoCs"
+   depends on CLK && ARCH_MESON
+   depends on CMD_CLK
+   default ARCH_MESON
+   help
+ Enable clock support for the Hardware Clock Measure for various
+ Amlogic SoCs.


And something closer to the Linux Kconfig would be nice too. E.g.

Enable measuring a set of internal SoC clock frequencies with the clk dump
command.



diff --git a/drivers/clk/meson/Makefile b/drivers/clk/meson/Makefile
index d975f07aab..c7a446e86c 100644
--- a/drivers/clk/meson/Makefile
+++ b/drivers/clk/meson/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_CLK_MESON_AXG) += axg-ao.o
  obj-$(CONFIG_CLK_MESON_G12A) += g12a.o
  obj-$(CONFIG_CLK_MESON_G12A) += g12a-ao.o
  obj-$(CONFIG_CLK_MESON_A1) += a1.o
+obj-$(CONFIG_CLK_MESON_MSR) += clk-measure.o
diff --git a/drivers/clk/meson/clk-measure.c b/drivers/clk/meson/clk-measure.c
new file mode 100644
index 00..f653fc6355
--- /dev/null
+++ b/drivers/clk/meson/clk-measure.c
@@ -0,0 +1,634 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Based on Linux driver from:
+ * (C) Copyright 2018 - BayLibre, SAS
+ * Author: Neil Armstrong 
+ * (C) Copyright 2023 - Neil Armstrong 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MSR_CLK_DUTY   0x0
+#define MSR_CLK_REG0   0x4
+#define MSR_CLK_REG1   0x8
+#define MSR_CLK_REG2   0xc
+
+#define MSR_DURATION   GENMASK(15, 0)
+#define MSR_ENABLE BIT(16)
+#define MSR_CONT   BIT(17) /* continuous measurement */
+#define MSR_INTR   BIT(18) /* interrupts */
+#define MSR_RUNBIT(19)
+#define MSR_CLK_SRCGENMASK(26, 20)
+#define MSR_BUSY   BIT(31)
+
+#define MSR_VAL_MASK   GENMASK(15, 0)
+
+#define DIV_MIN32
+#define DIV_STEP   32
+#define DIV_MAX640
+
+#define CLK_MSR_MAX128
+
+struct meson_msr_id {
+   unsigned int id;
+   const char *name;
+};
+
+struct meson_msr {
+   struct regmap *regmap;
+   struct meson_msr_id *msr_table;
+};
+
+#define CLK_MSR_ID(__id, __name) \
+   [__id] = {.id = __id, .name = __name,}


To reduce binary size you may want to ifdef these arrays out depending on the
platform. Up to you.


+static struct meson_msr_id clk_msr_m8[CLK_MSR_MAX] = {
+   CLK_MSR_ID(0, "ring_osc_out_ee0"),
+   CLK_MSR_ID(1, "ring_osc_out_ee1"),
+   CLK_MSR_ID(2, "ring_osc_out_ee2"),
+   CLK_MSR_ID(3, "a9_ring_osck"),
+   CLK_MSR_ID(6, "vid_pll"),
+   CLK_MSR_ID(7, "clk81"),
+   CLK_MSR_ID(8, "encp"),
+   CLK_MSR_ID(9, "encl"),
+   CLK_MSR_ID(11, "eth_rmii"),
+   CLK_MSR_ID(13, "amclk"),
+   CLK_MSR_ID(14, "fec_clk_0"),
+   CLK_MSR_ID(15, "fec_clk_1"),
+   CLK_MSR_ID(16, "fec_clk_2"),
+   CLK_MSR_ID(18, "a9_clk_div16"),
+   CLK_MSR_ID(19, "hdmi_sys"),
+   CLK_MSR_ID(20, "rtc_osc_clk_out"),
+   CLK_MSR_ID(21, "i2s_clk_in_src0"),
+   CLK_MSR_ID(22, "clk_rmii_from_pad"),
+   CLK_MSR_ID(23, "hdmi_ch0_tmds"),
+   CLK_MSR_ID(24, "lvds_fifo"),
+   CLK_MSR_ID(26, "sc_clk_int"),
+   CLK_MSR_ID(28, "sar_adc"),
+   CLK_MSR_ID(30, "mpll_clk_test_out"),
+   CLK_MSR_ID(31, "audac_clkpi"),
+   CLK_MSR_ID(32, "vdac"),
+   CLK_MSR_ID(33, "sdhc_rx"),
+   CLK_MSR_ID(34, "sdhc_sd"),
+   CLK_MSR_ID(35, "mali"),
+   CLK_MSR_ID(36, "hdmi_tx_pixel"),
+   CLK_MSR_ID(38, "vdin_meas"),
+   CLK_MSR_ID(39, "pcm_sclk"),
+   CLK_MSR_ID(40, "pcm_mclk"),
+   CLK_MSR_ID(41, "eth_rx_tx"),
+   CLK_MSR_ID(42, "pwm_d"),
+   CLK_MSR_ID(43, "pwm_c"),
+   CLK_MSR_ID(44, "pwm_b"),
+   CLK_MSR_ID(45, "pwm_a"),
+   CLK_MSR_ID(46, "pcm2_sclk"),
+   CLK_MSR_ID(47, "ddr_dpll_pt"),
+   CLK_MSR_I

Re: [PATCH v4 1/8] binman: ti-secure: Add support for firewalling entities

2023-12-15 Thread Simon Glass
Hi Jon,

On Thu, 14 Dec 2023 at 14:49, Jon Cormier  wrote:
>
> Hi Manorit,
>
> This commit added a possibly unintentional dependency on python 3.9+.
>
> I ran into this while trying to build the soon-to-be-released 09.01.00.008.
>
> Build failure on ubuntu 20.04 which uses python 3.8:
> "binman: 'type' object is not subscriptable"

Thank you for reporting this. Yes, we should not require python 3.9,
even though I feel it is reasonable to give up on 3.6 at this stage.

>
> This can be fixed by:
>
> diff --git a/tools/binman/etype/ti_secure.py b/tools/binman/etype/ti_secure.py
> index f80eb542c956..872c6d38ff46 100644
> --- a/tools/binman/etype/ti_secure.py
> +++ b/tools/binman/etype/ti_secure.py
> @@ -16,7 +16,7 @@ class Firewall():
>  id: int
>  region: int
>  control : int
> -permissions: list[hex]
> +permissions: list
>  start_address: str
>  end_address: str
>
> > Hi Manorit,
> >
> > On Wed, 11 Oct 2023 at 23:02, Manorit Chawdhry  wrote:
> > >
> > > Hi Simon,
> > >
> > > On 11:54-20231011, Manorit Chawdhry wrote:
> > > > We can now firewall entities while loading them through our secure
> > > > entity TIFS, the required information should be present in the
> > > > certificate that is being parsed by TIFS.
> > > >
> > > > The following commit adds the support to enable the certificates to be
> > > > generated if the firewall configurations are present in the binman dtsi
> > > > nodes.
> > > >
> > > > Signed-off-by: Manorit Chawdhry 
> > > > ---
> > > [..]
> > > >  tools/binman/btool/openssl.py   | 16 +++-
> > > >  tools/binman/etype/ti_secure.py | 90
> > > > +
> > > >  tools/binman/etype/x509_cert.py |  3 +-
> > > >  3 files changed, 106 insertions(+), 3 deletions(-)
> > > >
> > > >  from binman.entry import EntryArg
> > > >  from binman.etype.x509_cert import Entry_x509_cert
> > > > +from dataclasses import dataclass
> > >
> > > What all python versions do we support in u-boot? I see that dataclasses
> > > are in-built from python3.7 but for older versions we would need to
> > > install them separately, do I need to add this in buildman requirements
> > > for those versions?
> >
> > I would prefer not to worry about Python 3.6 if possible. There are a
> > few workarounds in buildman for it, though.
Regards,
Simon


Re: [PATCH 1/1] buildman: type cotaining

2023-12-15 Thread Simon Glass
On Fri, 15 Dec 2023 at 02:42, Heinrich Schuchardt
 wrote:
>
> %s/cotaining/containing/
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  tools/buildman/boards.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/buildman/boards.py b/tools/buildman/boards.py
> index 341a5056df..3c2822715f 100644
> --- a/tools/buildman/boards.py
> +++ b/tools/buildman/boards.py
> @@ -119,7 +119,7 @@ class Expr:
>  """Set up a new Expr object.
>
>  Args:
> -expr (str): String cotaining regular expression to store
> +expr (str): String containing regular expression to store
>  """
>  self._expr = expr
>  self._re = re.compile(expr)
> --
> 2.40.1
>

Reviewed-by: Simon Glass 


Re: [PATCH 1/3] acpi: fix FADT table

2023-12-15 Thread Simon Glass
Hi Heinrich,

On Fri, 15 Dec 2023 at 09:40, 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.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  arch/x86/cpu/baytrail/acpi.c | 8 ++--
>  arch/x86/cpu/quark/acpi.c| 8 ++--
>  arch/x86/cpu/tangier/acpi.c  | 8 ++--
>  arch/x86/lib/acpi_table.c| 9 ++---
>  include/acpi/acpi_table.h| 6 ++
>  5 files changed, 10 insertions(+), 29 deletions(-)
>

Just as a general comment, the word 'fix' does not really describe
things very well. There may be many fixes to a piece of code or
feature. I would suggest something a bit more specific.  Perhaps
something like 'Support 64-bit addresses in FADT table'

Also please use the U-Boot standard of ulong for addresses, not uintptr_t

For casts, it is better to use map_sysmem() and map_to_sysmem() so
that we can use the code in unit tests (although of course we
currently have no way of running x86-specific code in sandbox).

> diff --git a/arch/x86/cpu/baytrail/acpi.c b/arch/x86/cpu/baytrail/acpi.c
> index 4378846f8b..5c28c4d260 100644
> --- a/arch/x86/cpu/baytrail/acpi.c
> +++ b/arch/x86/cpu/baytrail/acpi.c
> @@ -31,8 +31,6 @@ static int baytrail_write_fadt(struct acpi_ctx *ctx,
> header->length = sizeof(struct acpi_fadt);
> header->revision = 4;
>
> -   fadt->firmware_ctrl = (u32)ctx->facs;
> -   fadt->dsdt = (u32)ctx->dsdt;
> fadt->preferred_pm_profile = ACPI_PM_MOBILE;
> fadt->sci_int = 9;
> fadt->smi_cmd = 0;
> @@ -79,10 +77,8 @@ static int baytrail_write_fadt(struct acpi_ctx *ctx,
> fadt->reset_reg.addrh = 0;
> fadt->reset_value = SYS_RST | RST_CPU | FULL_RST;
>
> -   fadt->x_firmware_ctl_l = (u32)ctx->facs;
> -   fadt->x_firmware_ctl_h = 0;
> -   fadt->x_dsdt_l = (u32)ctx->dsdt;
> -   fadt->x_dsdt_h = 0;
> +   fadt->x_firmware_ctrl = (uintptr_t)ctx->facs;
> +   fadt->x_dsdt = (uintptr_t)ctx->dsdt;
>
> fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
> fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
> diff --git a/arch/x86/cpu/quark/acpi.c b/arch/x86/cpu/quark/acpi.c
> index 9a2d682451..583d4583c0 100644
> --- a/arch/x86/cpu/quark/acpi.c
> +++ b/arch/x86/cpu/quark/acpi.c
> @@ -26,8 +26,6 @@ static int quark_write_fadt(struct acpi_ctx *ctx,
> header->length = sizeof(struct acpi_fadt);
> header->revision = 4;
>
> -   fadt->firmware_ctrl = (u32)ctx->facs;
> -   fadt->dsdt = (u32)ctx->dsdt;
> fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED;
> fadt->sci_int = 9;
> fadt->smi_cmd = 0;
> @@ -74,10 +72,8 @@ static int quark_write_fadt(struct acpi_ctx *ctx,
> fadt->reset_reg.addrh = 0;
> fadt->reset_value = SYS_RST | RST_CPU | FULL_RST;
>
> -   fadt->x_firmware_ctl_l = (u32)ctx->facs;
> -   fadt->x_firmware_ctl_h = 0;
> -   fadt->x_dsdt_l = (u32)ctx->dsdt;
> -   fadt->x_dsdt_h = 0;
> +   fadt->x_firmware_ctrl = (uintptr_t)ctx->facs;
> +   fadt->x_dsdt = (uintptr_t)ctx->dsdt;
>
> fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
> fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
> diff --git a/arch/x86/cpu/tangier/acpi.c b/arch/x86/cpu/tangier/acpi.c
> index 1c667c7d56..19ec6e3390 100644
> --- a/arch/x86/cpu/tangier/acpi.c
> +++ b/arch/x86/cpu/tangier/acpi.c
> @@ -31,8 +31,6 @@ static int tangier_write_fadt(struct acpi_ctx *ctx,
> header->length = sizeof(struct acpi_fadt);
> header->revision = 6;
>
> -   fadt->firmware_ctrl = (u32)ctx->facs;
> -   fadt->dsdt = (u32)ctx->dsdt;
> fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED;
>
> fadt->iapc_boot_arch = ACPI_FADT_VGA_NOT_PRESENT |
> @@ -45,10 +43,8 @@ static int tangier_write_fadt(struct acpi_ctx *ctx,
>
> fadt->minor_revision = 2;
>
> -   fadt->x_firmware_ctl_l = (u32)ctx->facs;
> -   fadt->x_firmware_ctl_h = 0;
> -   fadt->x_dsdt_l = (u32)ctx->dsdt;
> -   fadt->x_dsdt_h = 0;
> +   fadt->x_firmware_ctrl = (uintptr_t)ctx->facs;
> +   fadt->x_dsdt = (uintptr_t)ctx->dsdt;
>
> header->checksum = table_compute_checksum(fadt, header->length);
>
> diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
> index c5b33dc65d..f49b6933ab 100644
> --- a/arch/x86/lib/acpi_table.c
> +++ b/arch/x86/lib/acpi_table.c
> @@ -572,13 +572,8 @@ void acpi_fadt_common(struct acpi_fadt *fadt, struct 
> acpi_facs *facs,
> memcpy(header->aslc_id, ASLC_ID, 4);
> header->aslc_revision = 1;
>
> -   fadt->firmware_ctrl = (unsigned long)facs;
> -   fadt->dsdt = (unsigned long)dsdt;
> -
> -   fadt->x_firmware_ctl_l = (unsigned long)facs;
> -   fadt->x_firmware_ctl_h = 0;
> -   fadt->x_dsdt

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

2023-12-15 Thread Andy Shevchenko
On Fri, Dec 15, 2023 at 05:40:16PM +0100, 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.

...

> + if (!IS_ENABLED(CONFIG_X86) &&
> + !(fadt->flags & ACPI_FADT_HW_REDUCED_ACPI))
> + log_err("FADT not ACPI hardware reduced compliant\n");

I guess it's half baked solution as this, HW reduced, flag adds more
limitations even on x86. If you want a good validation it should be done
in a separate function taking others aspects into account.

But since it doesn't affect my area of interest in U-Boot, I won't prevent
you from doing this way, it's up to the U-Boot maintainers how to proceed
with it.

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH 1/3] acpi: fix FADT table

2023-12-15 Thread Andy Shevchenko
On Fri, Dec 15, 2023 at 05:40:14PM +0100, 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.

Is it dictated by the specifications?
Please, put the reference here in the commit message (section X.Y.Z "Goo bar").

...


>From code perspective LGTM.

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH v6 06/17] arm: mach-k3: j784s4: Add clk and power support

2023-12-15 Thread Sean Anderson

On 12/6/23 07:37, Apurva Nandan wrote:

Add clk and device data which can be used by respective drivers
to configure clocks and PSC.

Signed-off-by: Hari Nagalla 
Signed-off-by: Apurva Nandan 
---
  arch/arm/mach-k3/r5/j784s4/Makefile|   7 +
  arch/arm/mach-k3/r5/j784s4/clk-data.c  | 428 +
  arch/arm/mach-k3/r5/j784s4/dev-data.c  |  98 ++
  drivers/clk/ti/clk-k3.c|   6 +
  drivers/power/domain/ti-power-domain.c |   6 +
  include/k3-clk.h   |   1 +
  include/k3-dev.h   |   1 +
  7 files changed, 547 insertions(+)
  create mode 100644 arch/arm/mach-k3/r5/j784s4/Makefile
  create mode 100644 arch/arm/mach-k3/r5/j784s4/clk-data.c
  create mode 100644 arch/arm/mach-k3/r5/j784s4/dev-data.c

diff --git a/arch/arm/mach-k3/r5/j784s4/Makefile 
b/arch/arm/mach-k3/r5/j784s4/Makefile
new file mode 100644
index 00..23e1ce51ac
--- /dev/null
+++ b/arch/arm/mach-k3/r5/j784s4/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/
+#
+
+obj-y += clk-data.o
+obj-y += dev-data.o
diff --git a/arch/arm/mach-k3/r5/j784s4/clk-data.c 
b/arch/arm/mach-k3/r5/j784s4/clk-data.c
new file mode 100644
index 00..d3fac38dd6
--- /dev/null
+++ b/arch/arm/mach-k3/r5/j784s4/clk-data.c
@@ -0,0 +1,428 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * J784S4 specific clock platform data
+ *
+ * This file is auto generated. Please do not hand edit and report any issues
+ * to Bryan Brattlof .
+ *
+ * Copyright (C) 2020-2023 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#include 
+#include "k3-clk.h"
+
+static const char * const gluelogic_hfosc0_clkout_parents[] = {
+   "osc_19_2_mhz",
+   "osc_20_mhz",
+   "osc_24_mhz",
+   "osc_25_mhz",
+   "osc_26_mhz",
+   "osc_27_mhz",
+};
+
+static const char * const mcu_ospi0_iclk_sel_out0_parents[] = {
+   "board_0_mcu_ospi0_dqs_out",
+   "fss_mcu_0_ospi_0_ospi_oclk_clk",
+};
+
+static const char * const mcu_ospi1_iclk_sel_out0_parents[] = {
+   "board_0_mcu_ospi1_dqs_out",
+   "fss_mcu_0_ospi_1_ospi_oclk_clk",
+};
+
+static const char * const wkup_fref_clksel_out0_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "j7am_wakeup_16ff_wkup_0_wkup_rcosc_12p5m_clk",
+};
+
+static const char * const k3_pll_ctrl_wrap_wkup_0_sysclkout_clk_parents[] = {
+   "wkup_fref_clksel_out0",
+   "hsdiv1_16fft_mcu_0_hsdivout0_clk",
+};
+
+static const char * const mcu_ospi_ref_clk_sel_out0_parents[] = {
+   "hsdiv4_16fft_mcu_1_hsdivout4_clk",
+   "hsdiv4_16fft_mcu_2_hsdivout4_clk",
+};
+
+static const char * const mcu_ospi_ref_clk_sel_out1_parents[] = {
+   "hsdiv4_16fft_mcu_1_hsdivout4_clk",
+   "hsdiv4_16fft_mcu_2_hsdivout4_clk",
+};
+
+static const char * const wkup_gpio0_clksel_out0_parents[] = {
+   "k3_pll_ctrl_wrap_wkup_0_chip_div1_clk_clk",
+   "k3_pll_ctrl_wrap_wkup_0_chip_div1_clk_clk",
+   "j7am_wakeup_16ff_wkup_0_wkup_rcosc_32k_clk",
+   "j7am_wakeup_16ff_wkup_0_wkup_rcosc_12p5m_clk",
+};
+
+static const char * const mcu_usart_clksel_out0_parents[] = {
+   "hsdiv4_16fft_mcu_1_hsdivout3_clk",
+   "postdiv3_16fft_main_1_hsdivout5_clk",
+};
+
+static const char * const wkup_i2c_mcupll_bypass_out0_parents[] = {
+   "hsdiv4_16fft_mcu_1_hsdivout3_clk",
+   "gluelogic_hfosc0_clkout",
+};
+
+static const char * const main_pll_hfosc_sel_out0_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "board_0_hfosc1_clk_out",
+};
+
+static const char * const main_pll_hfosc_sel_out1_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "board_0_hfosc1_clk_out",
+};
+
+static const char * const main_pll_hfosc_sel_out12_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "board_0_hfosc1_clk_out",
+};
+
+static const char * const main_pll_hfosc_sel_out19_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "board_0_hfosc1_clk_out",
+};
+
+static const char * const main_pll_hfosc_sel_out2_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "board_0_hfosc1_clk_out",
+};
+
+static const char * const main_pll_hfosc_sel_out26_0_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "board_0_hfosc1_clk_out",
+};
+
+static const char * const main_pll_hfosc_sel_out27_0_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "board_0_hfosc1_clk_out",
+};
+
+static const char * const main_pll_hfosc_sel_out28_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "board_0_hfosc1_clk_out",
+};
+
+static const char * const main_pll_hfosc_sel_out3_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "board_0_hfosc1_clk_out",
+};
+
+static const char * const main_pll_hfosc_sel_out7_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "board_0_hfosc1_clk_out",
+};
+
+static const char * const main_pll_hfosc_sel_out8_parents[] = {
+   "gluelogic_hfosc0_clkout",
+   "board_0_hfosc1_clk_out",
+};

Re: [PATCH v1 1/1] clk: clk-gpio: add actual gated clock

2023-12-15 Thread Sean Anderson

On 11/17/23 02:52, Svyatoslav Ryhel wrote:

Existing gpio-gate-clock driver acts like a simple GPIO switch without any
effect on gated clock. Add actual clock actions into enable/disable ops and
implement get_rate op by passing gated clock if it is enabled.

Signed-off-by: Svyatoslav Ryhel 
---
  drivers/clk/clk-gpio.c | 47 +++---
  1 file changed, 40 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c
index 26d795b978..a55470cfbf 100644
--- a/drivers/clk/clk-gpio.c
+++ b/drivers/clk/clk-gpio.c
@@ -3,19 +3,23 @@
   * Copyright (C) 2023 Marek Vasut 
   */
  
-#include 

-#include 
-#include 
+#include 
  #include 
+#include 
+#include 
+
+#include 
  
  struct clk_gpio_priv {

struct gpio_descenable;
+   struct clk  *clk;


Please name this "parent".


  };
  
  static int clk_gpio_enable(struct clk *clk)

  {
struct clk_gpio_priv *priv = dev_get_priv(clk->dev);
  
+	clk_prepare_enable(priv->clk);


Just clk_enable is fine. We don't have a separate prepare stage line Linux.


dm_gpio_set_value(&priv->enable, 1);
  
  	return 0;

@@ -26,21 +30,50 @@ static int clk_gpio_disable(struct clk *clk)
struct clk_gpio_priv *priv = dev_get_priv(clk->dev);
  
  	dm_gpio_set_value(&priv->enable, 0);

+   clk_disable_unprepare(priv->clk);
  
  	return 0;

  }
  
+static ulong clk_gpio_get_rate(struct clk *clk)

+{
+   struct clk_gpio_priv *priv = dev_get_priv(clk->dev);
+   int ret;
+
+   ret = dm_gpio_get_value(&priv->enable);
+   if (ret)
+   return clk_get_rate(priv->clk);
+   else
+   return -EINVAL;


This should always return the parent rate.


+}
+
  const struct clk_ops clk_gpio_ops = {
.enable = clk_gpio_enable,
.disable= clk_gpio_disable,
+   .get_rate   = clk_gpio_get_rate,
  };
  
-static int clk_gpio_probe(struct udevice *dev)

+static int clk_gpio_of_to_plat(struct udevice *dev)


This change should be a separate commit.


  {
struct clk_gpio_priv *priv = dev_get_priv(dev);
+   int ret;
  
-	return gpio_request_by_name(dev, "enable-gpios", 0,

-   &priv->enable, GPIOD_IS_OUT);
+   priv->clk = devm_clk_get(dev, NULL);
+   if (IS_ERR(priv->clk)) {
+   log_err("%s: Could not get gated clock: %ld\n",
+   __func__, PTR_ERR(priv->clk));
+   return PTR_ERR(priv->clk);
+   }
+
+   ret = gpio_request_by_name(dev, "enable-gpios", 0,
+  &priv->enable, GPIOD_IS_OUT);
+   if (ret) {
+   log_err("%s: Could not decode enable-gpios (%d)\n",
+   __func__, ret);


Use dev_dbg for probe errors to reduce binary size.


+   return ret;
+   }
+
+   return 0;
  }
  
  /*

@@ -59,7 +92,7 @@ U_BOOT_DRIVER(gpio_gate_clock) = {
.name   = "gpio_clock",
.id = UCLASS_CLK,
.of_match   = clk_gpio_match,
-   .probe  = clk_gpio_probe,
+   .of_to_plat = clk_gpio_of_to_plat,
.priv_auto  = sizeof(struct clk_gpio_priv),
.ops= &clk_gpio_ops,
.flags  = DM_FLAG_PRE_RELOC,


--Sean


u-boot@lists.denx.de

2023-12-15 Thread Sean Anderson

On 11/18/23 17:10, Yang Xiwen via B4 Relay wrote:

From: Yang Xiwen 

get i2c_root clock from device tree. In this way we get an CCF clock and
also test ccf_clk_ops.

Signed-off-by: Yang Xiwen 
---
  test/dm/clk_ccf.c | 14 +++---
  1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/test/dm/clk_ccf.c b/test/dm/clk_ccf.c
index e4ebb93cda..b8be6d6572 100644
--- a/test/dm/clk_ccf.c
+++ b/test/dm/clk_ccf.c
@@ -18,8 +18,8 @@
  /* Tests for Common Clock Framework driver */
  static int dm_test_clk_ccf(struct unit_test_state *uts)
  {
-   struct clk *clk, *pclk;
-   struct udevice *dev;
+   struct clk *clk, *pclk, clk_ccf;
+   struct udevice *dev, *test_dev;
long long rate;
int ret;
  #if CONFIG_IS_ENABLED(CLK_CCF)
@@ -29,6 +29,7 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
  
  	/* Get the device using the clk device */

ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-ccf", &dev));
+   ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test", 
&test_dev));
  
  	/* Test for clk_get_by_id() */

ret = clk_get_by_id(SANDBOX_CLK_ECSPI_ROOT, &clk);
@@ -110,11 +111,18 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
  
  #if CONFIG_IS_ENABLED(CLK_CCF)

/* Test clk tree enable/disable */
+
+   ret = clk_get_by_index(test_dev, SANDBOX_CLK_TEST_ID_I2C_ROOT, 
&clk_ccf);
+   ut_assertok(ret);
+   ut_asserteq_str("clk-ccf", clk_ccf.dev->name);
+   ut_asserteq(clk_ccf.id, SANDBOX_CLK_I2C_ROOT);
+
ret = clk_get_by_id(SANDBOX_CLK_I2C_ROOT, &clk);
ut_assertok(ret);
ut_asserteq_str("i2c_root", clk->dev->name);
+   ut_asserteq(clk->id, SANDBOX_CLK_I2C_ROOT);
  
-	ret = clk_enable(clk);

+   ret = clk_enable(&clk_ccf);
ut_assertok(ret);
  
  	ret = sandbox_clk_enable_count(clk);




This patch should be combined with patches 1 and 3. With the changes spread out
over 3 patches it is hard to see what is going on.

--Sean


Re: [PATCH v2 2/4] clk: get correct ops for clk_enable() and clk_disable()

2023-12-15 Thread Sean Anderson

On 11/18/23 17:10, Yang Xiwen via B4 Relay wrote:

From: Yang Xiwen 

assign clk_dev_ops(clkp->dev) to ops to ensure correct clk operations
are called on clocks.

This fixes the incorrect enable_count issue as described in [1].

[1]: 
https://lore.kernel.org/all/sezpr06mb695927a6deeef8489a06897396...@sezpr06mb6959.apcprd06.prod.outlook.com/

Signed-off-by: Yang Xiwen 
---
  drivers/clk/clk-uclass.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 3b5e3f9c86..3e9d68feb3 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -640,6 +640,7 @@ int clk_enable(struct clk *clk)
if (CONFIG_IS_ENABLED(CLK_CCF)) {
/* Take id 0 as a non-valid clk, such as dummy */
if (clk->id && !clk_get_by_id(clk->id, &clkp)) {
+   ops = clk_dev_ops(clkp->dev);
if (clkp->enable_count) {
clkp->enable_count++;
return 0;
@@ -699,6 +700,7 @@ int clk_disable(struct clk *clk)
  
  	if (CONFIG_IS_ENABLED(CLK_CCF)) {

if (clk->id && !clk_get_by_id(clk->id, &clkp)) {
+   ops = clk_dev_ops(clkp->dev);
if (clkp->flags & CLK_IS_CRITICAL)
return 0;
  



Reviewed-by: Sean Anderson 


Re: [PATCH 2/2] dm: test: clk: Add test for ccf clk_set_rate()

2023-12-15 Thread Sean Anderson

On 12/5/23 18:23, Igor Prusov wrote:

Add a simple test case which sets clock rate to its current value.

Signed-off-by: Igor Prusov 
---

  test/dm/clk_ccf.c | 9 +
  1 file changed, 9 insertions(+)

diff --git a/test/dm/clk_ccf.c b/test/dm/clk_ccf.c
index e4ebb93cda..3b23982541 100644
--- a/test/dm/clk_ccf.c
+++ b/test/dm/clk_ccf.c
@@ -63,6 +63,9 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
rate = clk_get_parent_rate(clk);
ut_asserteq(rate, 6000);
  
+	rate = clk_set_rate(clk, 6000);

+   ut_asserteq(rate, -ENOSYS);
+
rate = clk_get_rate(clk);
ut_asserteq(rate, 6000);
  
@@ -87,6 +90,9 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)

ut_asserteq_str("pll3_80m", pclk->dev->name);
ut_asserteq(CLK_SET_RATE_PARENT, pclk->flags);
  
+	rate = clk_set_rate(clk, 8000);

+   ut_asserteq(rate, -ENOSYS);
+
rate = clk_get_rate(clk);
ut_asserteq(rate, 8000);
  
@@ -108,6 +114,9 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)

rate = clk_get_rate(clk);
ut_asserteq(rate, 6000);
  
+	rate = clk_set_rate(clk, 6000);

+   ut_asserteq(rate, 6000);
+
  #if CONFIG_IS_ENABLED(CLK_CCF)
/* Test clk tree enable/disable */
ret = clk_get_by_id(SANDBOX_CLK_I2C_ROOT, &clk);


Reviewed-by: Sean Anderson 


Re: [PATCH 1/2] clk: Check that composite clock's div has set_rate()

2023-12-15 Thread Sean Anderson

On 12/5/23 18:23, Igor Prusov wrote:

It's possible for composite clocks to have a divider that does not
implement set_rate() operation. For example, sandbox_clk_composite()
registers composite clock with a divider that only has get_rate().
Currently clk_composite_set_rate() only checks thate rate_ops are
present, so for sandbox it will cause NULL dereference during
clk_set_rate().

This patch adds rate_ops->set_rate check tp clk_composite_set_rate().

Signed-off-by: Igor Prusov 
---

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

diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
index 6eb2b8133a..d2e5a1ae40 100644
--- a/drivers/clk/clk-composite.c
+++ b/drivers/clk/clk-composite.c
@@ -66,7 +66,7 @@ static ulong clk_composite_set_rate(struct clk *clk, unsigned 
long rate)
const struct clk_ops *rate_ops = composite->rate_ops;
struct clk *clk_rate = composite->rate;
  
-	if (rate && rate_ops)

+   if (rate && rate_ops && rate_ops->set_rate)
return rate_ops->set_rate(clk_rate, rate);
else
return clk_get_rate(clk);


Reviewed-by: Sean Anderson 


[PATCH v2] doc: Replace examples of MD5 and SHA1 with SHA256

2023-12-15 Thread Sean Anderson
Both SHA1 and (especially) MD5 are no longer as safe as they once were for
cryptographic use. Replace examples that use them with examples using
SHA256 instead. This will provide more-secure defaults for users who use
documentation examples as a base for their own use. This is not too
necessary for non-verified-boot scenarios (since someone could just replace
the checksum), but I wanted to be complete.

All the new hashes were generated like

echo fake kernel hash | sha256sum

which should be fine, since the actual values are just for example anyway.

Signed-off-by: Sean Anderson 
Reviewed-by: Simon Glass 
Reviewed-by: Peter Robinson 
Reviewed-by: Tom Rini 
---

Changes in v2:
- Mention CONFIG_SHA256/512 in doc/usage/fit/signature.rst
- Describe how the hashes were generated in the commit message

 doc/chromium/files/chromebook_jerry.its  |  4 +-
 doc/chromium/files/nyan-big.its  |  4 +-
 doc/usage/cmd/imxtract.rst   |  6 +-
 doc/usage/fit/beaglebone_vboot.rst   | 74 
 doc/usage/fit/howto.rst  | 40 ++---
 doc/usage/fit/kernel.rst |  6 +-
 doc/usage/fit/kernel_fdt.rst |  4 +-
 doc/usage/fit/kernel_fdts_compressed.rst |  6 +-
 doc/usage/fit/multi-with-fpga.rst|  6 +-
 doc/usage/fit/multi-with-loadables.rst   |  8 +--
 doc/usage/fit/multi.rst  | 12 ++--
 doc/usage/fit/sign-configs.rst   |  6 +-
 doc/usage/fit/sign-images.rst|  4 +-
 doc/usage/fit/signature.rst  | 28 +
 doc/usage/fit/update3.rst|  6 +-
 doc/usage/fit/update_uboot.rst   |  2 +-
 doc/usage/fit/x86-fit-boot.rst   |  8 +--
 17 files changed, 115 insertions(+), 109 deletions(-)

diff --git a/doc/chromium/files/chromebook_jerry.its 
b/doc/chromium/files/chromebook_jerry.its
index 7505a20535b..02e5e1340f3 100644
--- a/doc/chromium/files/chromebook_jerry.its
+++ b/doc/chromium/files/chromebook_jerry.its
@@ -15,7 +15,7 @@
load = <0>;
entry = <0>;
hash-2 {
-   algo = "sha1";
+   algo = "sha256";
};
};
 
@@ -26,7 +26,7 @@
arch = "arm";
compression = "none";
hash-1{
-   algo = "sha1";
+   algo = "sha256";
};
};
};
diff --git a/doc/chromium/files/nyan-big.its b/doc/chromium/files/nyan-big.its
index bd412915e95..60bdffbb829 100644
--- a/doc/chromium/files/nyan-big.its
+++ b/doc/chromium/files/nyan-big.its
@@ -15,7 +15,7 @@
load = <0>;
entry = <0>;
hash-2 {
-   algo = "sha1";
+   algo = "sha256";
};
};
 
@@ -26,7 +26,7 @@
arch = "arm";
compression = "none";
hash-1{
-   algo = "sha1";
+   algo = "sha256";
};
};
};
diff --git a/doc/usage/cmd/imxtract.rst b/doc/usage/cmd/imxtract.rst
index eb64b1cefab..16be60b4aab 100644
--- a/doc/usage/cmd/imxtract.rst
+++ b/doc/usage/cmd/imxtract.rst
@@ -45,14 +45,14 @@ Examples
 
 With verify=no incorrect hashes, signatures, or check sums don't stop the
 extraction. But correct hashes are still indicated in the output
-(here: md5, sha1).
+(here: sha256, sha512).
 
 .. code-block:: console
 
 => setenv verify no
 => imxtract $loadaddr kernel-1 $kernel_addr_r
 ## Copying 'kernel-1' subimage from FIT image at 4020 ...
-md5+ sha1+Loading part 0 ... OK
+sha256+ sha512+Loading part 0 ... OK
 =>
 
 With verify=yes incorrect hashes, signatures, or check sums stop the 
extraction.
@@ -62,7 +62,7 @@ With verify=yes incorrect hashes, signatures, or check sums 
stop the extraction.
 => setenv verify yes
 => imxtract $loadaddr kernel-1 $kernel_addr_r
 ## Copying 'kernel-1' subimage from FIT image at 4020 ...
-md5 error!
+sha256 error!
 Bad hash value for 'hash-1' hash node in 'kernel-1' image node
 Bad Data Hash
 =>
diff --git a/doc/usage/fit/beaglebone_vboot.rst 
b/doc/usage/fit/beaglebone_vboot.rst
index a102be187bd..cd6bb141910 100644
--- a/doc/usage/fit/beaglebone_vboot.rst
+++ b/doc/usage/fit/beaglebone_vboot.rst
@@ -145,7 +145,7 @@ Put this into a file in that directory called sign.its::
 load = <0x80008000>;
 entry = <0x80008000>;
 hash-1 {
-algo = "sha1";
+algo = "sha256";
 };
 };
 fdt-1 {
@@ -155,7 +155,7 @@ Put this into a file in that directory called sign

Re: [PATCH] doc: Replace examples of MD5 and SHA1 with SHA256

2023-12-15 Thread Sean Anderson

On 12/3/23 11:45, Peter Robinson wrote:

On Sat, Dec 2, 2023 at 7:33 PM Sean Anderson  wrote:


Both SHA1 and (especially) MD5 are no longer as safe as they once were for
cryptographic use. Replaces examples which use them with examples using
SHA256 instead. This will provide more-secure defaults for users who use
documentation examples as a base for their own use. This is not too
necessary for non-verified-boot scenarios (since someone could just replace
the checksum), but I wanted to be complete.

Signed-off-by: Sean Anderson 
---

  doc/chromium/files/chromebook_jerry.its  |  4 +-
  doc/chromium/files/nyan-big.its  |  4 +-
  doc/usage/cmd/imxtract.rst   |  6 +-
  doc/usage/fit/beaglebone_vboot.rst   | 74 
  doc/usage/fit/howto.rst  | 40 ++---
  doc/usage/fit/kernel.rst |  6 +-
  doc/usage/fit/kernel_fdt.rst |  4 +-
  doc/usage/fit/kernel_fdts_compressed.rst |  6 +-
  doc/usage/fit/multi-with-fpga.rst|  6 +-
  doc/usage/fit/multi-with-loadables.rst   |  8 +--
  doc/usage/fit/multi.rst  | 12 ++--
  doc/usage/fit/sign-configs.rst   |  6 +-
  doc/usage/fit/sign-images.rst|  4 +-
  doc/usage/fit/signature.rst  | 22 +++
  doc/usage/fit/update3.rst|  6 +-
  doc/usage/fit/update_uboot.rst   |  2 +-
  doc/usage/fit/x86-fit-boot.rst   |  8 +--
  17 files changed, 109 insertions(+), 109 deletions(-)

diff --git a/doc/chromium/files/chromebook_jerry.its 
b/doc/chromium/files/chromebook_jerry.its
index 7505a20535b..02e5e1340f3 100644
--- a/doc/chromium/files/chromebook_jerry.its
+++ b/doc/chromium/files/chromebook_jerry.its
@@ -15,7 +15,7 @@
 load = <0>;
 entry = <0>;
 hash-2 {
-   algo = "sha1";
+   algo = "sha256";
 };
 };

@@ -26,7 +26,7 @@
 arch = "arm";
 compression = "none";
 hash-1{
-   algo = "sha1";
+   algo = "sha256";
 };
 };
 };
diff --git a/doc/chromium/files/nyan-big.its b/doc/chromium/files/nyan-big.its
index bd412915e95..60bdffbb829 100644
--- a/doc/chromium/files/nyan-big.its
+++ b/doc/chromium/files/nyan-big.its
@@ -15,7 +15,7 @@
 load = <0>;
 entry = <0>;
 hash-2 {
-   algo = "sha1";
+   algo = "sha256";
 };
 };

@@ -26,7 +26,7 @@
 arch = "arm";
 compression = "none";
 hash-1{
-   algo = "sha1";
+   algo = "sha256";
 };
 };
 };
diff --git a/doc/usage/cmd/imxtract.rst b/doc/usage/cmd/imxtract.rst
index eb64b1cefab..16be60b4aab 100644
--- a/doc/usage/cmd/imxtract.rst
+++ b/doc/usage/cmd/imxtract.rst
@@ -45,14 +45,14 @@ Examples

  With verify=no incorrect hashes, signatures, or check sums don't stop the
  extraction. But correct hashes are still indicated in the output
-(here: md5, sha1).
+(here: sha256, sha512).

  .. code-block:: console

  => setenv verify no
  => imxtract $loadaddr kernel-1 $kernel_addr_r
  ## Copying 'kernel-1' subimage from FIT image at 4020 ...
-md5+ sha1+Loading part 0 ... OK
+sha256+ sha512+Loading part 0 ... OK
  =>

  With verify=yes incorrect hashes, signatures, or check sums stop the 
extraction.
@@ -62,7 +62,7 @@ With verify=yes incorrect hashes, signatures, or check sums 
stop the extraction.
  => setenv verify yes
  => imxtract $loadaddr kernel-1 $kernel_addr_r
  ## Copying 'kernel-1' subimage from FIT image at 4020 ...
-md5 error!
+sha256 error!
  Bad hash value for 'hash-1' hash node in 'kernel-1' image node
  Bad Data Hash
  =>
diff --git a/doc/usage/fit/beaglebone_vboot.rst 
b/doc/usage/fit/beaglebone_vboot.rst
index a102be187bd..cd6bb141910 100644
--- a/doc/usage/fit/beaglebone_vboot.rst
+++ b/doc/usage/fit/beaglebone_vboot.rst
@@ -145,7 +145,7 @@ Put this into a file in that directory called sign.its::
  load = <0x80008000>;
  entry = <0x80008000>;
  hash-1 {
-algo = "sha1";
+algo = "sha256";
  };
  };
  fdt-1 {
@@ -155,7 +155,7 @@ Put this into a file in that directory called sign.its::
  arch = "arm";
  compression = "none";
  hash-1 {
-algo = "sha1";
+algo = "sha256";
  };
  };
  

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

2023-12-15 Thread Heinrich Schuchardt
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(+)

diff --git a/cmd/acpi.c b/cmd/acpi.c
index 24910c150b..2e9a333ffa 100644
--- a/cmd/acpi.c
+++ b/cmd/acpi.c
@@ -6,6 +6,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -57,6 +58,9 @@ static void list_fadt(struct acpi_fadt *fadt)
dump_hdr(map_sysmem(fadt->x_dsdt, 0));
else if (fadt->dsdt)
dump_hdr(map_sysmem(fadt->dsdt, 0));
+   if (!IS_ENABLED(CONFIG_X86) &&
+   !(fadt->flags & ACPI_FADT_HW_REDUCED_ACPI))
+   log_err("FADT not ACPI hardware reduced compliant\n");
if (fadt->x_firmware_ctrl)
dump_hdr(map_sysmem(fadt->x_firmware_ctrl, 0));
else if (fadt->firmware_ctrl)
-- 
2.40.1



[PATCH 2/3] cmd: acpi: fix listing DSDT and FACS

2023-12-15 Thread Heinrich Schuchardt
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(-)

diff --git a/cmd/acpi.c b/cmd/acpi.c
index 0c14409242..24910c150b 100644
--- a/cmd/acpi.c
+++ b/cmd/acpi.c
@@ -53,9 +53,13 @@ static int dump_table_name(const char *sig)
 
 static void list_fadt(struct acpi_fadt *fadt)
 {
-   if (fadt->dsdt)
+   if (fadt->x_dsdt)
+   dump_hdr(map_sysmem(fadt->x_dsdt, 0));
+   else if (fadt->dsdt)
dump_hdr(map_sysmem(fadt->dsdt, 0));
-   if (fadt->firmware_ctrl)
+   if (fadt->x_firmware_ctrl)
+   dump_hdr(map_sysmem(fadt->x_firmware_ctrl, 0));
+   else if (fadt->firmware_ctrl)
dump_hdr(map_sysmem(fadt->firmware_ctrl, 0));
 }
 
-- 
2.40.1



[PATCH 1/3] acpi: fix FADT table

2023-12-15 Thread Heinrich Schuchardt
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.

Signed-off-by: Heinrich Schuchardt 
---
 arch/x86/cpu/baytrail/acpi.c | 8 ++--
 arch/x86/cpu/quark/acpi.c| 8 ++--
 arch/x86/cpu/tangier/acpi.c  | 8 ++--
 arch/x86/lib/acpi_table.c| 9 ++---
 include/acpi/acpi_table.h| 6 ++
 5 files changed, 10 insertions(+), 29 deletions(-)

diff --git a/arch/x86/cpu/baytrail/acpi.c b/arch/x86/cpu/baytrail/acpi.c
index 4378846f8b..5c28c4d260 100644
--- a/arch/x86/cpu/baytrail/acpi.c
+++ b/arch/x86/cpu/baytrail/acpi.c
@@ -31,8 +31,6 @@ static int baytrail_write_fadt(struct acpi_ctx *ctx,
header->length = sizeof(struct acpi_fadt);
header->revision = 4;
 
-   fadt->firmware_ctrl = (u32)ctx->facs;
-   fadt->dsdt = (u32)ctx->dsdt;
fadt->preferred_pm_profile = ACPI_PM_MOBILE;
fadt->sci_int = 9;
fadt->smi_cmd = 0;
@@ -79,10 +77,8 @@ static int baytrail_write_fadt(struct acpi_ctx *ctx,
fadt->reset_reg.addrh = 0;
fadt->reset_value = SYS_RST | RST_CPU | FULL_RST;
 
-   fadt->x_firmware_ctl_l = (u32)ctx->facs;
-   fadt->x_firmware_ctl_h = 0;
-   fadt->x_dsdt_l = (u32)ctx->dsdt;
-   fadt->x_dsdt_h = 0;
+   fadt->x_firmware_ctrl = (uintptr_t)ctx->facs;
+   fadt->x_dsdt = (uintptr_t)ctx->dsdt;
 
fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
diff --git a/arch/x86/cpu/quark/acpi.c b/arch/x86/cpu/quark/acpi.c
index 9a2d682451..583d4583c0 100644
--- a/arch/x86/cpu/quark/acpi.c
+++ b/arch/x86/cpu/quark/acpi.c
@@ -26,8 +26,6 @@ static int quark_write_fadt(struct acpi_ctx *ctx,
header->length = sizeof(struct acpi_fadt);
header->revision = 4;
 
-   fadt->firmware_ctrl = (u32)ctx->facs;
-   fadt->dsdt = (u32)ctx->dsdt;
fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED;
fadt->sci_int = 9;
fadt->smi_cmd = 0;
@@ -74,10 +72,8 @@ static int quark_write_fadt(struct acpi_ctx *ctx,
fadt->reset_reg.addrh = 0;
fadt->reset_value = SYS_RST | RST_CPU | FULL_RST;
 
-   fadt->x_firmware_ctl_l = (u32)ctx->facs;
-   fadt->x_firmware_ctl_h = 0;
-   fadt->x_dsdt_l = (u32)ctx->dsdt;
-   fadt->x_dsdt_h = 0;
+   fadt->x_firmware_ctrl = (uintptr_t)ctx->facs;
+   fadt->x_dsdt = (uintptr_t)ctx->dsdt;
 
fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
diff --git a/arch/x86/cpu/tangier/acpi.c b/arch/x86/cpu/tangier/acpi.c
index 1c667c7d56..19ec6e3390 100644
--- a/arch/x86/cpu/tangier/acpi.c
+++ b/arch/x86/cpu/tangier/acpi.c
@@ -31,8 +31,6 @@ static int tangier_write_fadt(struct acpi_ctx *ctx,
header->length = sizeof(struct acpi_fadt);
header->revision = 6;
 
-   fadt->firmware_ctrl = (u32)ctx->facs;
-   fadt->dsdt = (u32)ctx->dsdt;
fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED;
 
fadt->iapc_boot_arch = ACPI_FADT_VGA_NOT_PRESENT |
@@ -45,10 +43,8 @@ static int tangier_write_fadt(struct acpi_ctx *ctx,
 
fadt->minor_revision = 2;
 
-   fadt->x_firmware_ctl_l = (u32)ctx->facs;
-   fadt->x_firmware_ctl_h = 0;
-   fadt->x_dsdt_l = (u32)ctx->dsdt;
-   fadt->x_dsdt_h = 0;
+   fadt->x_firmware_ctrl = (uintptr_t)ctx->facs;
+   fadt->x_dsdt = (uintptr_t)ctx->dsdt;
 
header->checksum = table_compute_checksum(fadt, header->length);
 
diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index c5b33dc65d..f49b6933ab 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -572,13 +572,8 @@ void acpi_fadt_common(struct acpi_fadt *fadt, struct 
acpi_facs *facs,
memcpy(header->aslc_id, ASLC_ID, 4);
header->aslc_revision = 1;
 
-   fadt->firmware_ctrl = (unsigned long)facs;
-   fadt->dsdt = (unsigned long)dsdt;
-
-   fadt->x_firmware_ctl_l = (unsigned long)facs;
-   fadt->x_firmware_ctl_h = 0;
-   fadt->x_dsdt_l = (unsigned long)dsdt;
-   fadt->x_dsdt_h = 0;
+   fadt->x_firmware_ctrl = (uintptr_t)facs;
+   fadt->x_dsdt = (uintptr_t)dsdt;
 
fadt->preferred_pm_profile = ACPI_PM_MOBILE;
 
diff --git a/include/acpi/acpi_table.h b/include/acpi/acpi_table.h
index 20ac3b51ba..e67562ef65 100644
--- a/include/acpi/acpi_table.h
+++ b/include/acpi/acpi_table.h
@@ -228,10 +228,8 @@ struct __packed acpi_fadt {
u8 reset_value;
u16 arm_boot_arch;
u8 minor_revision;
-   u32 x_firmware_ctl_l;
-   u32 x_firmware_ctl_h;
-   u32 x_dsdt_l;
-   u32 x_dsdt_h;
+   u64 x_firmware_ctrl;
+   u64 x_dsdt;
struct acpi_gen_regaddr x_pm1a_evt_blk;
struct acpi_gen_regaddr x_pm1b_evt_blk;
struct acpi_gen_regaddr x_pm1a_cnt_

[PATCH 0/3] cmd: acpi: fix list_fadt()

2023-12-15 Thread Heinrich Schuchardt
Fields X_FIRMWARE and X_DSDT in the FADT table must be 64bit.
Fix the definition in our include.

The 64bit fields X_FIRMWARE and X_DSDT take precedence over the respective
32bit fields.

Don't fill unused fields FIRMWAE and DSDT.

Write an error if the hardware reduce flag is not set for non-x86 systems.

Heinrich Schuchardt (3):
  acpi: fix FADT table
  cmd: acpi: fix listing DSDT and FACS
  cmd: acpi: check HW reduced flag in acpi list

 arch/x86/cpu/baytrail/acpi.c |  8 ++--
 arch/x86/cpu/quark/acpi.c|  8 ++--
 arch/x86/cpu/tangier/acpi.c  |  8 ++--
 arch/x86/lib/acpi_table.c|  9 ++---
 cmd/acpi.c   | 12 ++--
 include/acpi/acpi_table.h|  6 ++
 6 files changed, 20 insertions(+), 31 deletions(-)

-- 
2.40.1



[PULL] Pull request for u-boot next / v2024.04 = u-boot-stm32-20231215

2023-12-15 Thread Patrice CHOTARD
Hi Tom

Please pull the STM32 related patches for u-boot/next, v2024.04: 
u-boot-stm32-20231215

CI status: https://source.denx.de/u-boot/custodians/u-boot-stm/-/pipelines/18947

The following changes since commit fa3f19aa56c519d6345cc774187b7a8fdc053d71:

  Merge tag 'xilinx-for-v2024.04-rc1' of 
https://source.denx.de/u-boot/custodians/u-boot-microblaze into next 
(2023-12-14 13:27:11 -0500)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-stm.git 
tags/u-boot-stm32-20231215

for you to fetch changes up to 395507e50d7137e0bcfce74e1b4122e49d9984cb:

  configs: stm32: Apply savedefconfig (2023-12-15 15:41:23 +0100)


_ run savedefconfig on all STM32 defconfig

STM32 MCU:
_ Sync stm32f469-disco DT with Linux 6.5
_ rework ltdc node for stm32f769-disco
_ clk: stm32f: Fix settings for LCD_CLK
_ Support display on stm32f469-disco board

STM32 MPU:
_ stm32mp_dfu : Fix board_get_alt_info_mtd()
_ stm32mp_dfu : Simplify MTD device parsing


Dario Binacchi (9):
  ARM: dts: stm32f769-disco: rework ltdc node
  clk: stm32f: fix setting of division factor for LCD_CLK
  clk: stm32f: fix setting of LCD clock
  ARM: dts: stm32f469-disco: sync with Linux 6.5
  ARM: dts: stm32: make the LTDC clock usable by the clock driver
  ARM: dts: stm32: make the DSI clock usable by the clock driver
  ARM: dts: stm32: support MIPI DSI on stm32f469-disco board
  board: stm32f469-disco: add support to display
  board: stm32f469-disco: add splash screen with stmicroelectronics logo

Patrice Chotard (3):
  board: st: common: Fix board_get_alt_info_mtd()
  board: st: common: simplify MTD device parsing
  configs: stm32: Apply savedefconfig

 arch/arm/dts/stm32f469-disco-u-boot.dtsi |  13 +
 arch/arm/dts/stm32f469-disco.dts |   4 ++--
 arch/arm/dts/stm32f769-disco-u-boot.dtsi |  23 +--
 arch/arm/dts/stm32f769-disco.dts |   4 
 board/st/common/stm32mp_dfu.c|  28 
 configs/stm32746g-eval_defconfig |   4 ++--
 configs/stm32f429-discovery_defconfig|   2 +-
 configs/stm32f429-evaluation_defconfig   |   4 ++--
 configs/stm32f469-discovery_defconfig|  19 +--
 configs/stm32f746-disco_defconfig|   4 ++--
 configs/stm32f769-disco_defconfig|   4 ++--
 configs/stm32h743-disco_defconfig|   4 ++--
 configs/stm32mp13_defconfig  |   2 +-
 drivers/clk/stm32/clk-stm32f.c   |  25 ++---
 drivers/video/stm32/stm32_ltdc.c |  31 +++
 include/configs/stm32f469-discovery.h|   2 ++
 tools/logos/stm32f469-discovery.bmp  | Bin 0 -> 18532 bytes
 17 files changed, 108 insertions(+), 65 deletions(-)
 create mode 100644 tools/logos/stm32f469-discovery.bmp


Re: [PATCH v2] clk: fix clk_get_rate() always return ulong

2023-12-15 Thread Sean Anderson



On 12/15/23 09:09, Julien Masson wrote:

When we call clk_get_rate(), we expect to get clock rate value as
ulong.
In that case we should not use log_ret() macro since it use internally
an int.
Otherwise we may return an invalid/truncated clock rate value.


Fixes: 5c5992cb90c ("clk: Add debugging for return values")

+CC Simon


Signed-off-by: Julien Masson 
---
Changes in v2:
- remove local var ret (fix warning)
- Link to v1: https://lore.kernel.org/all/871qcj5frz@baylibre.com
---
  drivers/clk/clk-uclass.c | 7 +--
  1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 3b5e3f9c86..3cbcb2d033 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -478,7 +478,6 @@ void clk_free(struct clk *clk)
  ulong clk_get_rate(struct clk *clk)
  {
const struct clk_ops *ops;
-   ulong ret;
  
  	debug("%s(clk=%p)\n", __func__, clk);

if (!clk_valid(clk))
@@ -488,11 +487,7 @@ ulong clk_get_rate(struct clk *clk)
if (!ops->get_rate)
return -ENOSYS;
  
-	ret = ops->get_rate(clk);

-   if (ret)
-   return log_ret(ret);
-
-   return 0;
+   return ops->get_rate(clk);
  }
  
  struct clk *clk_get_parent(struct clk *clk)


Anyway, I don't particularly care about logging the error here.

Reviewed-by: Sean Anderson 


  1   2   >