[PATCH] fastboot: Only call the bootm command if it is enabled

2023-02-19 Thread Samuel Holland
This fixes an error with trying to link against do_bootm() when
CONFIG_CMD_BOOTM is disabled.

Signed-off-by: Samuel Holland 
---

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

diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index 57b6182c46a..20aa80838ae 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -135,7 +135,7 @@ void fastboot_boot(void)
s = env_get("fastboot_bootcmd");
if (s) {
run_command(s, CMD_FLAG_ENV);
-   } else {
+   } else if (IS_ENABLED(CONFIG_CMD_BOOTM)) {
static char boot_addr_start[20];
static char *const bootm_args[] = {
"bootm", boot_addr_start, NULL
-- 
2.39.2



[PATCH 3/3] remoteproc: Remove legacy probing method

2023-02-19 Thread Samuel Holland
This removes code that abused the device's platform data, interpreting
the driver platform data as if it was the uclass platform data.

Signed-off-by: Samuel Holland 
---

 .../driver-model/remoteproc-framework.rst | 29 ---
 drivers/remoteproc/rproc-uclass.c | 18 +---
 drivers/remoteproc/sandbox_testproc.c | 10 ---
 include/remoteproc.h  |  2 --
 4 files changed, 1 insertion(+), 58 deletions(-)

diff --git a/doc/develop/driver-model/remoteproc-framework.rst 
b/doc/develop/driver-model/remoteproc-framework.rst
index bdbbb8ab7be..ce76e5ea495 100644
--- a/doc/develop/driver-model/remoteproc-framework.rst
+++ b/doc/develop/driver-model/remoteproc-framework.rst
@@ -106,35 +106,6 @@ provide a load and start function. We assume here that the 
device
 needs to be loaded and started, else, there is no real purpose of
 using the remoteproc framework.
 
-Describing the device using platform data
--
-
-*IMPORTANT* NOTE: THIS SUPPORT IS NOT MEANT FOR USE WITH NEWER PLATFORM
-SUPPORT. THIS IS ONLY FOR LEGACY DEVICES. THIS MODE OF INITIALIZATION
-*WILL* BE EVENTUALLY REMOVED ONCE ALL NECESSARY PLATFORMS HAVE MOVED
-TO DM/FDT.
-
-Considering that many platforms are yet to move to device-tree model,
-a simplified definition of a device is as follows:
-
-.. code-block:: c
-
-   struct dm_rproc_uclass_pdata proc_3_test = {
-   .name = "proc_3_legacy",
-   .driver_plat_data = _data;
-   };
-
-   U_BOOT_DRVINFO(proc_3_demo) = {
-   .name = "sandbox_test_proc",
-   .plat = _3_test,
-   };
-
-There can be additional data that may be desired depending on the
-remoteproc driver specific needs (for example: SoC integration
-details such as clock handle or something similar). See appropriate
-documentation for specific remoteproc driver for further details.
-These are passed via driver_plat_data.
-
 Describing the device using device tree
 ---
 
diff --git a/drivers/remoteproc/rproc-uclass.c 
b/drivers/remoteproc/rproc-uclass.c
index 3eacd4a8d9b..def43a8cf32 100644
--- a/drivers/remoteproc/rproc-uclass.c
+++ b/drivers/remoteproc/rproc-uclass.c
@@ -131,24 +131,8 @@ static int rproc_pre_probe(struct udevice *dev)
 
/* See if we need to populate via fdt */
 
-   if (!dev_get_plat(dev)) {
-#if CONFIG_IS_ENABLED(OF_CONTROL)
-   bool tmp;
-   debug("'%s': using fdt\n", dev->name);
+   if (dev_has_ofnode(dev))
uc_pdata->name = dev_read_string(dev, "remoteproc-name");
-#else
-   /* Nothing much we can do about this, can we? */
-   return -EINVAL;
-#endif
-
-   } else {
-   struct dm_rproc_uclass_pdata *pdata = dev_get_plat(dev);
-
-   debug("'%s': using legacy data\n", dev->name);
-   if (pdata->name)
-   uc_pdata->name = pdata->name;
-   uc_pdata->driver_plat_data = pdata->driver_plat_data;
-   }
 
/* Else try using device Name */
if (!uc_pdata->name)
diff --git a/drivers/remoteproc/sandbox_testproc.c 
b/drivers/remoteproc/sandbox_testproc.c
index 4cb784ce32e..b19477daa7f 100644
--- a/drivers/remoteproc/sandbox_testproc.c
+++ b/drivers/remoteproc/sandbox_testproc.c
@@ -345,13 +345,3 @@ U_BOOT_DRIVER(sandbox_testproc) = {
.probe = sandbox_testproc_probe,
.priv_auto  = sizeof(struct sandbox_test_devdata),
 };
-
-/* TODO(n...@ti.com): Remove this along with non-DT support */
-static struct dm_rproc_uclass_pdata proc_3_test = {
-   .name = "proc_3_legacy",
-};
-
-U_BOOT_DRVINFO(proc_3_demo) = {
-   .name = "sandbox_test_proc",
-   .plat = _3_test,
-};
diff --git a/include/remoteproc.h b/include/remoteproc.h
index 0c4d64706d9..e0fccb0177f 100644
--- a/include/remoteproc.h
+++ b/include/remoteproc.h
@@ -386,7 +386,6 @@ struct rproc {
 /**
  * struct dm_rproc_uclass_pdata - platform data for a CPU
  * @name: Platform-specific way of naming the Remote proc
- * @driver_plat_data: driver specific platform data that may be needed.
  *
  * This can be accessed with dev_get_uclass_plat() for any UCLASS_REMOTEPROC
  * device.
@@ -394,7 +393,6 @@ struct rproc {
  */
 struct dm_rproc_uclass_pdata {
const char *name;
-   void *driver_plat_data;
 };
 
 /**
-- 
2.39.2



[PATCH 2/3] remoteproc: Remove unused mem_type platform data

2023-02-19 Thread Samuel Holland
There is only one possible value for this field, it is unused except for
debugging, and the devicetree property is not documented.

Signed-off-by: Samuel Holland 
---

 cmd/remoteproc.c  | 12 +---
 doc/develop/driver-model/remoteproc-framework.rst |  1 -
 drivers/remoteproc/rproc-uclass.c |  7 ---
 drivers/remoteproc/sandbox_testproc.c |  1 -
 include/remoteproc.h  | 15 ---
 5 files changed, 1 insertion(+), 35 deletions(-)

diff --git a/cmd/remoteproc.c b/cmd/remoteproc.c
index ca3b436242a..2b2e52e7d3e 100644
--- a/cmd/remoteproc.c
+++ b/cmd/remoteproc.c
@@ -20,7 +20,6 @@ static int print_remoteproc_list(void)
struct udevice *dev;
struct uclass *uc;
int ret;
-   char *type;
 
ret = uclass_get(UCLASS_REMOTEPROC, );
if (ret) {
@@ -38,18 +37,9 @@ static int print_remoteproc_list(void)
if (!(dev_get_flags(dev) & DM_FLAG_ACTIVATED))
continue;
 
-   switch (uc_pdata->mem_type) {
-   case RPROC_INTERNAL_MEMORY_MAPPED:
-   type = "internal memory mapped";
-   break;
-   default:
-   type = "unknown";
-   break;
-   }
-   printf("%d - Name:'%s' type:'%s' supports: %s%s%s%s%s%s\n",
+   printf("%d - Name:'%s' supports: %s%s%s%s%s%s\n",
   dev_seq(dev),
   uc_pdata->name,
-  type,
   ops->load ? "load " : "",
   ops->start ? "start " : "",
   ops->stop ? "stop " : "",
diff --git a/doc/develop/driver-model/remoteproc-framework.rst 
b/doc/develop/driver-model/remoteproc-framework.rst
index 566495a21c4..bdbbb8ab7be 100644
--- a/doc/develop/driver-model/remoteproc-framework.rst
+++ b/doc/develop/driver-model/remoteproc-framework.rst
@@ -121,7 +121,6 @@ a simplified definition of a device is as follows:
 
struct dm_rproc_uclass_pdata proc_3_test = {
.name = "proc_3_legacy",
-   .mem_type = RPROC_INTERNAL_MEMORY_MAPPED,
.driver_plat_data = _data;
};
 
diff --git a/drivers/remoteproc/rproc-uclass.c 
b/drivers/remoteproc/rproc-uclass.c
index 50bcc9030e9..3eacd4a8d9b 100644
--- a/drivers/remoteproc/rproc-uclass.c
+++ b/drivers/remoteproc/rproc-uclass.c
@@ -136,12 +136,6 @@ static int rproc_pre_probe(struct udevice *dev)
bool tmp;
debug("'%s': using fdt\n", dev->name);
uc_pdata->name = dev_read_string(dev, "remoteproc-name");
-
-   /* Default is internal memory mapped */
-   uc_pdata->mem_type = RPROC_INTERNAL_MEMORY_MAPPED;
-   tmp = dev_read_bool(dev, "remoteproc-internal-memory-mapped");
-   if (tmp)
-   uc_pdata->mem_type = RPROC_INTERNAL_MEMORY_MAPPED;
 #else
/* Nothing much we can do about this, can we? */
return -EINVAL;
@@ -153,7 +147,6 @@ static int rproc_pre_probe(struct udevice *dev)
debug("'%s': using legacy data\n", dev->name);
if (pdata->name)
uc_pdata->name = pdata->name;
-   uc_pdata->mem_type = pdata->mem_type;
uc_pdata->driver_plat_data = pdata->driver_plat_data;
}
 
diff --git a/drivers/remoteproc/sandbox_testproc.c 
b/drivers/remoteproc/sandbox_testproc.c
index 78b108184bb..4cb784ce32e 100644
--- a/drivers/remoteproc/sandbox_testproc.c
+++ b/drivers/remoteproc/sandbox_testproc.c
@@ -349,7 +349,6 @@ U_BOOT_DRIVER(sandbox_testproc) = {
 /* TODO(n...@ti.com): Remove this along with non-DT support */
 static struct dm_rproc_uclass_pdata proc_3_test = {
.name = "proc_3_legacy",
-   .mem_type = RPROC_INTERNAL_MEMORY_MAPPED,
 };
 
 U_BOOT_DRVINFO(proc_3_demo) = {
diff --git a/include/remoteproc.h b/include/remoteproc.h
index d8cde73748b..0c4d64706d9 100644
--- a/include/remoteproc.h
+++ b/include/remoteproc.h
@@ -383,23 +383,9 @@ struct rproc {
u32 trace_len;
 };
 
-/**
- * enum rproc_mem_type - What type of memory model does the rproc use
- * @RPROC_INTERNAL_MEMORY_MAPPED: Remote processor uses own memory and is 
memory
- * mapped to the host processor over an address range.
- *
- * Please note that this is an enumeration of memory model of different types
- * of remote processors. Few of the remote processors do have own internal
- * memories, while others use external memory for instruction and data.
- */
-enum rproc_mem_type {
-   RPROC_INTERNAL_MEMORY_MAPPED= 0,
-};
-
 /**
  * struct dm_rproc_uclass_pdata - platform data for a CPU
  * @name: Platform-specific way of naming the Remote proc
- * @mem_type: one of 'enum rproc_mem_type'
  * @driver_plat_data: driver specific platform data that may be needed.
  *
  * This can be 

[PATCH 1/3] remoteproc: Move rproc_cfg_arr out of the uclass header

2023-02-19 Thread Samuel Holland
This array is private to the IPU driver, so it should be declared there.

Signed-off-by: Samuel Holland 
---

 drivers/remoteproc/ipu_rproc.c | 4 +++-
 include/remoteproc.h   | 1 -
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/ipu_rproc.c b/drivers/remoteproc/ipu_rproc.c
index b4a06bc955a..2783628b23a 100644
--- a/drivers/remoteproc/ipu_rproc.c
+++ b/drivers/remoteproc/ipu_rproc.c
@@ -145,6 +145,8 @@ unsigned long mem_count;
 unsigned int pgtable_l2_map[MAX_NUM_L2_PAGE_TABLES];
 unsigned int pgtable_l2_cnt;
 
+static struct rproc *rproc_cfg_arr[2];
+
 void *ipu_alloc_mem(struct udevice *dev, unsigned long len, unsigned long 
align)
 {
unsigned long mask;
@@ -597,7 +599,7 @@ struct rproc ipu2_config = {
.intmem_to_l3_mapping = _intmem_to_l3_mapping
 };
 
-struct rproc *rproc_cfg_arr[2] = {
+static struct rproc *rproc_cfg_arr[2] = {
[IPU2] = _config,
[IPU1] = _config,
 };
diff --git a/include/remoteproc.h b/include/remoteproc.h
index f48054de6ba..d8cde73748b 100644
--- a/include/remoteproc.h
+++ b/include/remoteproc.h
@@ -383,7 +383,6 @@ struct rproc {
u32 trace_len;
 };
 
-extern struct rproc *rproc_cfg_arr[2];
 /**
  * enum rproc_mem_type - What type of memory model does the rproc use
  * @RPROC_INTERNAL_MEMORY_MAPPED: Remote processor uses own memory and is 
memory
-- 
2.39.2



[PATCH 0/3] remoteproc: uclass cleanup

2023-02-19 Thread Samuel Holland
This series cleans up some misplaced and dead code that I ran in to
while writing a new remoteproc driver for the Bouffalo Lab BL808.


Samuel Holland (3):
  remoteproc: Move rproc_cfg_arr out of the uclass header
  remoteproc: Remove unused mem_type platform data
  remoteproc: Remove legacy probing method

 cmd/remoteproc.c  | 12 +---
 .../driver-model/remoteproc-framework.rst | 30 ---
 drivers/remoteproc/ipu_rproc.c|  4 ++-
 drivers/remoteproc/rproc-uclass.c | 25 +---
 drivers/remoteproc/sandbox_testproc.c | 11 ---
 include/remoteproc.h  | 18 ---
 6 files changed, 5 insertions(+), 95 deletions(-)

-- 
2.39.2



[PATCH] riscv: Support CONFIG_REMAKE_ELF

2023-02-19 Thread Samuel Holland
Add flags to tell objcopy what kind of ELF to create.

Signed-off-by: Samuel Holland 
---

 arch/riscv/config.mk | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk
index a8ed3faf28c..e5f4af22bcb 100644
--- a/arch/riscv/config.mk
+++ b/arch/riscv/config.mk
@@ -16,11 +16,13 @@
 ifdef CONFIG_32BIT
 KBUILD_LDFLAGS += -m $(32bit-emul)
 EFI_LDS:= elf_riscv32_efi.lds
+PLATFORM_ELFFLAGS  += -B riscv -O elf32-littleriscv
 endif
 
 ifdef CONFIG_64BIT
 KBUILD_LDFLAGS += -m $(64bit-emul)
 EFI_LDS:= elf_riscv64_efi.lds
+PLATFORM_ELFFLAGS  += -B riscv -O elf64-littleriscv
 endif
 
 PLATFORM_CPPFLAGS  += -ffixed-gp -fpic
-- 
2.39.2



[PATCH 6/6] clk: Add a .get_parent operation

2023-02-19 Thread Samuel Holland
This allows clk_get_parent() to work with non-CCF clock drivers.

Signed-off-by: Samuel Holland 
---

 drivers/clk/clk-uclass.c | 18 --
 include/clk-uclass.h |  2 ++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 53cfd819779..d0f8906cd60 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -485,6 +485,7 @@ ulong clk_get_rate(struct clk *clk)
 
 struct clk *clk_get_parent(struct clk *clk)
 {
+   const struct clk_ops *ops;
struct udevice *pdev;
struct clk *pclk;
 
@@ -492,12 +493,17 @@ struct clk *clk_get_parent(struct clk *clk)
if (!clk_valid(clk))
return ERR_PTR(-ENODEV);
 
-   pdev = dev_get_parent(clk->dev);
-   if (!pdev)
-   return ERR_PTR(-ENODEV);
-   pclk = dev_get_clk_ptr(pdev);
-   if (!pclk)
-   return ERR_PTR(-ENODEV);
+   ops = clk_dev_ops(clk->dev);
+   if (ops->get_parent) {
+   pclk = ops->get_parent(clk);
+   } else {
+   pdev = dev_get_parent(clk->dev);
+   if (!pdev)
+   return ERR_PTR(-ENODEV);
+   pclk = dev_get_clk_ptr(pdev);
+   if (!pclk)
+   return ERR_PTR(-ENODEV);
+   }
 
return pclk;
 }
diff --git a/include/clk-uclass.h b/include/clk-uclass.h
index 65ebff9ed27..4d616720865 100644
--- a/include/clk-uclass.h
+++ b/include/clk-uclass.h
@@ -22,6 +22,7 @@ struct ofnode_phandle_args;
  * @round_rate: Adjust a rate to the exact rate a clock can provide.
  * @get_rate: Get current clock rate.
  * @set_rate: Set current clock rate.
+ * @get_parent: Get current clock parent
  * @set_parent: Set current clock parent
  * @enable: Enable a clock.
  * @disable: Disable a clock.
@@ -36,6 +37,7 @@ struct clk_ops {
ulong (*round_rate)(struct clk *clk, ulong rate);
ulong (*get_rate)(struct clk *clk);
ulong (*set_rate)(struct clk *clk, ulong rate);
+   struct clk *(*get_parent)(struct clk *clk);
int (*set_parent)(struct clk *clk, struct clk *parent);
int (*enable)(struct clk *clk);
int (*disable)(struct clk *clk);
-- 
2.39.2



[PATCH 5/6] clk: Remove an unneeded check from clk_get_parent_rate()

2023-02-19 Thread Samuel Holland
There is no need to check the parent clock's ops. The following call to
clk_get_rate() does that already.

Signed-off-by: Samuel Holland 
---

 drivers/clk/clk-uclass.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 9d052e5a814..53cfd819779 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -504,7 +504,6 @@ struct clk *clk_get_parent(struct clk *clk)
 
 ulong clk_get_parent_rate(struct clk *clk)
 {
-   const struct clk_ops *ops;
struct clk *pclk;
 
debug("%s(clk=%p)\n", __func__, clk);
@@ -515,10 +514,6 @@ ulong clk_get_parent_rate(struct clk *clk)
if (IS_ERR(pclk))
return -ENODEV;
 
-   ops = clk_dev_ops(pclk->dev);
-   if (!ops->get_rate)
-   return -ENOSYS;
-
/* Read the 'rate' if not already set or if proper flag set*/
if (!pclk->rate || IS_ERR_VALUE(pclk->rate) ||
pclk->flags & CLK_GET_RATE_NOCACHE)
-- 
2.39.2



[PATCH 2/6] clk: Fix error handling in clk_get_rate()

2023-02-19 Thread Samuel Holland
log_ret() cannot work with unsigned values, and the assignment to 'ret'
incorrectly truncates the rate from long to int.

Fixes: 5c5992cb90cf ("clk: Add debugging for return values")
Signed-off-by: Samuel Holland 
---

 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 dc3e9d6a261..78299dbceb2 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -471,7 +471,6 @@ void clk_free(struct clk *clk)
 ulong clk_get_rate(struct clk *clk)
 {
const struct clk_ops *ops;
-   int ret;
 
debug("%s(clk=%p)\n", __func__, clk);
if (!clk_valid(clk))
@@ -481,11 +480,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)
-- 
2.39.2



[PATCH 4/6] clk: Fix rate caching in clk_get_parent_rate()

2023-02-19 Thread Samuel Holland
clk_get_rate() can return an error value. Recompute the rate if the
cached value is an error value.

Fixes: 4aa78300a025 ("dm: clk: Define clk_get_parent_rate() for clk operations")
Signed-off-by: Samuel Holland 
---

 drivers/clk/clk-uclass.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 5bce976b060..9d052e5a814 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -520,7 +520,8 @@ ulong clk_get_parent_rate(struct clk *clk)
return -ENOSYS;
 
/* Read the 'rate' if not already set or if proper flag set*/
-   if (!pclk->rate || pclk->flags & CLK_GET_RATE_NOCACHE)
+   if (!pclk->rate || IS_ERR_VALUE(pclk->rate) ||
+   pclk->flags & CLK_GET_RATE_NOCACHE)
pclk->rate = clk_get_rate(pclk);
 
return pclk->rate;
-- 
2.39.2



[PATCH 3/6] clk: Fix error handling in clk_get_parent()

2023-02-19 Thread Samuel Holland
Do not return both NULL and error pointers. The function is only
documented as returning error pointers.

Fixes: 8a1661f20e6c ("drivers: clk: Handle gracefully NULL pointers")
Signed-off-by: Samuel Holland 
---

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

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 78299dbceb2..5bce976b060 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -490,7 +490,7 @@ struct clk *clk_get_parent(struct clk *clk)
 
debug("%s(clk=%p)\n", __func__, clk);
if (!clk_valid(clk))
-   return NULL;
+   return ERR_PTR(-ENODEV);
 
pdev = dev_get_parent(clk->dev);
if (!pdev)
-- 
2.39.2



[PATCH 0/6] clk: uclass fixes and improvements

2023-02-19 Thread Samuel Holland
This series fixes a few issues found while writing a clk driver for a
new SoC (Bouffalo Lab BL808), and adds the new functionality needed to
implement a hierarchy of clocks in a single device (without the CCF).
The .get_parent hook will be useful on other platforms as well; I plan
to use it to implement PLL rate setting on sunxi.


Samuel Holland (6):
  clk: Handle error pointers in clk_valid()
  clk: Fix error handling in clk_get_rate()
  clk: Fix error handling in clk_get_parent()
  clk: Fix rate caching in clk_get_parent_rate()
  clk: Remove an unneeded check from clk_get_parent_rate()
  clk: Add a .get_parent operation

 drivers/clk/clk-uclass.c | 35 ---
 include/clk-uclass.h |  2 ++
 include/clk.h|  2 +-
 3 files changed, 19 insertions(+), 20 deletions(-)

-- 
2.39.2



[PATCH 1/6] clk: Handle error pointers in clk_valid()

2023-02-19 Thread Samuel Holland
Some clk uclass functions, such as devm_clk_get() and clk_get_parent(),
return error pointers. clk_valid() should not consider these pointers
to be valid.

Fixes: 8a1661f20e6c ("drivers: clk: Handle gracefully NULL pointers")
Signed-off-by: Samuel Holland 
---

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

diff --git a/include/clk.h b/include/clk.h
index d91285235f7..4acb878ec6d 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -671,7 +671,7 @@ static inline bool clk_dev_binded(struct clk *clk)
  */
 static inline bool clk_valid(struct clk *clk)
 {
-   return clk && !!clk->dev;
+   return clk && !IS_ERR(clk) && !!clk->dev;
 }
 
 int soc_clk_dump(void);
-- 
2.39.2



[PATCH v4 08/10] phy: socionext: Add UniPhier USB3 PHY driver

2023-02-19 Thread Kunihiko Hayashi
Add USB3 PHY driver support to control clocks and resets needed to enable
PHY. The phy_ops->init() and exit() control PHY clocks and resets only,
and clocks and resets for the controller and the parent logic are enabled
in advance.

Signed-off-by: Kunihiko Hayashi 
---
 drivers/phy/socionext/Kconfig |   8 ++
 drivers/phy/socionext/Makefile|   1 +
 drivers/phy/socionext/phy-uniphier-usb3.c | 168 ++
 3 files changed, 177 insertions(+)
 create mode 100644 drivers/phy/socionext/phy-uniphier-usb3.c

diff --git a/drivers/phy/socionext/Kconfig b/drivers/phy/socionext/Kconfig
index bcd579e98e..de87d5b010 100644
--- a/drivers/phy/socionext/Kconfig
+++ b/drivers/phy/socionext/Kconfig
@@ -10,3 +10,11 @@ config PHY_UNIPHIER_PCIE
help
  Enable this to support PHY implemented in PCIe controller
  on UniPhier SoCs.
+
+config PHY_UNIPHIER_USB3
+   bool "UniPhier USB3 PHY driver"
+   depends on PHY && ARCH_UNIPHIER
+   imply REGMAP
+   help
+ Enable this to support PHY implemented in USB3 controller
+ on UniPhier SoCs.
diff --git a/drivers/phy/socionext/Makefile b/drivers/phy/socionext/Makefile
index 5484360b70..94d3aa68cf 100644
--- a/drivers/phy/socionext/Makefile
+++ b/drivers/phy/socionext/Makefile
@@ -4,3 +4,4 @@
 #
 
 obj-$(CONFIG_PHY_UNIPHIER_PCIE)+= phy-uniphier-pcie.o
+obj-$(CONFIG_PHY_UNIPHIER_USB3)+= phy-uniphier-usb3.o
diff --git a/drivers/phy/socionext/phy-uniphier-usb3.c 
b/drivers/phy/socionext/phy-uniphier-usb3.c
new file mode 100644
index 00..1d65b0b08f
--- /dev/null
+++ b/drivers/phy/socionext/phy-uniphier-usb3.c
@@ -0,0 +1,168 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * phy_uniphier_usb3.c - Socionext UniPhier Usb3 PHY driver
+ * Copyright 2019-2023 Socionext, Inc.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+struct uniphier_usb3phy_priv {
+   struct clk *clk_link, *clk_phy, *clk_parent, *clk_phyext;
+   struct reset_ctl *rst_link, *rst_phy, *rst_parent;
+};
+
+static int uniphier_usb3phy_init(struct phy *phy)
+{
+   struct uniphier_usb3phy_priv *priv = dev_get_priv(phy->dev);
+   int ret;
+
+   ret = clk_enable(priv->clk_phy);
+   if (ret)
+   return ret;
+
+   ret = reset_deassert(priv->rst_phy);
+   if (ret)
+   goto out_clk;
+
+   if (priv->clk_phyext) {
+   ret = clk_enable(priv->clk_phyext);
+   if (ret)
+   goto out_rst;
+   }
+
+   return 0;
+
+out_rst:
+   reset_assert(priv->rst_phy);
+out_clk:
+   clk_disable(priv->clk_phy);
+
+   return ret;
+}
+
+static int uniphier_usb3phy_exit(struct phy *phy)
+{
+   struct uniphier_usb3phy_priv *priv = dev_get_priv(phy->dev);
+
+   if (priv->clk_phyext)
+   clk_disable(priv->clk_phyext);
+
+   reset_assert(priv->rst_phy);
+   clk_disable(priv->clk_phy);
+
+   return 0;
+}
+
+static int uniphier_usb3phy_probe(struct udevice *dev)
+{
+   struct uniphier_usb3phy_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   priv->clk_link = devm_clk_get(dev, "link");
+   if (IS_ERR(priv->clk_link)) {
+   printf("Failed to get link clock\n");
+   return PTR_ERR(priv->clk_link);
+   }
+
+   priv->clk_phy = devm_clk_get(dev, "phy");
+   if (IS_ERR(priv->clk_link)) {
+   printf("Failed to get phy clock\n");
+   return PTR_ERR(priv->clk_link);
+   }
+
+   priv->clk_parent = devm_clk_get_optional(dev, "gio");
+   if (IS_ERR(priv->clk_parent)) {
+   printf("Failed to get parent clock\n");
+   return PTR_ERR(priv->clk_parent);
+   }
+
+   priv->clk_phyext = devm_clk_get_optional(dev, "phy-ext");
+   if (IS_ERR(priv->clk_phyext)) {
+   printf("Failed to get external phy clock\n");
+   return PTR_ERR(priv->clk_phyext);
+   }
+
+   priv->rst_link = devm_reset_control_get(dev, "link");
+   if (IS_ERR(priv->rst_link)) {
+   printf("Failed to get link reset\n");
+   return PTR_ERR(priv->rst_link);
+   }
+
+   priv->rst_phy = devm_reset_control_get(dev, "phy");
+   if (IS_ERR(priv->rst_phy)) {
+   printf("Failed to get phy reset\n");
+   return PTR_ERR(priv->rst_phy);
+   }
+
+   priv->rst_parent = devm_reset_control_get_optional(dev, "gio");
+   if (IS_ERR(priv->rst_parent)) {
+   printf("Failed to get parent reset\n");
+   return PTR_ERR(priv->rst_parent);
+   }
+
+   if (priv->clk_parent) {
+   ret = clk_enable(priv->clk_parent);
+   if (ret)
+   return ret;
+   }
+   if (priv->rst_parent) {
+   ret = reset_deassert(priv->rst_parent);
+   if (ret)
+   goto out_clk_parent;
+   }
+
+   ret = clk_enable(priv->clk_link);
+  

[PATCH v4 09/10] usb: dwc3-uniphier: Use dwc3-generic instead of xhci-dwc3

2023-02-19 Thread Kunihiko Hayashi
dwc3-uniphier depends on xhci-dwc3 framework, however, it is preferable
to use dwc3-generic.

This driver calls the exported dwc3-generic functions and redefine
the SoC-dependent operations to fit dwc3-generic.

Signed-off-by: Kunihiko Hayashi 
Reviewed-by: Marek Vasut 
---
 drivers/usb/dwc3/Kconfig |   4 +-
 drivers/usb/dwc3/dwc3-uniphier.c | 116 ---
 2 files changed, 78 insertions(+), 42 deletions(-)

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index f010291d02..7ddfa94e51 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -55,7 +55,9 @@ config USB_DWC3_MESON_GXL
 
 config USB_DWC3_UNIPHIER
bool "DesignWare USB3 Host Support on UniPhier Platforms"
-   depends on ARCH_UNIPHIER && USB_XHCI_DWC3
+   depends on ARCH_UNIPHIER && USB_DWC3
+   select USB_DWC3_GENERIC
+   select PHY_UNIPHIER_USB3
help
  Support of USB2/3 functionality in Socionext UniPhier platforms.
  Say 'Y' here if you have one such device.
diff --git a/drivers/usb/dwc3/dwc3-uniphier.c b/drivers/usb/dwc3/dwc3-uniphier.c
index 54b52dcd66..ab85428a70 100644
--- a/drivers/usb/dwc3/dwc3-uniphier.c
+++ b/drivers/usb/dwc3/dwc3-uniphier.c
@@ -4,14 +4,17 @@
  *
  * Copyright (C) 2016-2017 Socionext Inc.
  *   Author: Masahiro Yamada 
+ *   Author: Kunihiko Hayashi 
  */
 
 #include 
-#include 
+#include 
 #include 
-#include 
-#include 
-#include 
+#include 
+
+#include "core.h"
+#include "gadget.h"
+#include "dwc3-generic.h"
 
 #define UNIPHIER_PRO4_DWC3_RESET   0x40
 #define   UNIPHIER_PRO4_DWC3_RESET_XIOMMU  BIT(5)
@@ -27,8 +30,11 @@
 #define UNIPHIER_PXS2_DWC3_RESET   0x00
 #define   UNIPHIER_PXS2_DWC3_RESET_XLINK   BIT(15)
 
-static int uniphier_pro4_dwc3_init(void __iomem *regs)
+static void uniphier_pro4_dwc3_init(struct udevice *dev, int index,
+   enum usb_dr_mode mode)
 {
+   struct dwc3_glue_data *glue = dev_get_plat(dev);
+   void *regs = map_physmem(glue->regs, glue->size, MAP_NOCACHE);
u32 tmp;
 
tmp = readl(regs + UNIPHIER_PRO4_DWC3_RESET);
@@ -36,11 +42,14 @@ static int uniphier_pro4_dwc3_init(void __iomem *regs)
tmp |= UNIPHIER_PRO4_DWC3_RESET_XIOMMU | UNIPHIER_PRO4_DWC3_RESET_XLINK;
writel(tmp, regs + UNIPHIER_PRO4_DWC3_RESET);
 
-   return 0;
+   unmap_physmem(regs, MAP_NOCACHE);
 }
 
-static int uniphier_pro5_dwc3_init(void __iomem *regs)
+static void uniphier_pro5_dwc3_init(struct udevice *dev, int index,
+   enum usb_dr_mode mode)
 {
+   struct dwc3_glue_data *glue = dev_get_plat(dev);
+   void *regs = map_physmem(glue->regs, glue->size, MAP_NOCACHE);
u32 tmp;
 
tmp = readl(regs + UNIPHIER_PRO5_DWC3_RESET);
@@ -49,72 +58,97 @@ static int uniphier_pro5_dwc3_init(void __iomem *regs)
tmp |= UNIPHIER_PRO5_DWC3_RESET_XLINK | UNIPHIER_PRO5_DWC3_RESET_XIOMMU;
writel(tmp, regs + UNIPHIER_PRO5_DWC3_RESET);
 
-   return 0;
+   unmap_physmem(regs, MAP_NOCACHE);
 }
 
-static int uniphier_pxs2_dwc3_init(void __iomem *regs)
+static void uniphier_pxs2_dwc3_init(struct udevice *dev, int index,
+   enum usb_dr_mode mode)
 {
+   struct dwc3_glue_data *glue = dev_get_plat(dev);
+   void *regs = map_physmem(glue->regs, glue->size, MAP_NOCACHE);
u32 tmp;
 
tmp = readl(regs + UNIPHIER_PXS2_DWC3_RESET);
tmp |= UNIPHIER_PXS2_DWC3_RESET_XLINK;
writel(tmp, regs + UNIPHIER_PXS2_DWC3_RESET);
 
-   return 0;
+   unmap_physmem(regs, MAP_NOCACHE);
 }
 
-static int uniphier_dwc3_probe(struct udevice *dev)
+static int dwc3_uniphier_glue_get_ctrl_dev(struct udevice *dev, ofnode *node)
 {
-   fdt_addr_t base;
-   void __iomem *regs;
-   int (*init)(void __iomem *regs);
-   int ret;
+   struct udevice *child;
+   const char *name;
+   ofnode subnode;
+
+   /*
+* "controller reset" belongs to glue logic, and it should be
+* accessible in .glue_configure() before access to the controller
+* begins.
+*/
+   ofnode_for_each_subnode(subnode, dev_ofnode(dev)) {
+   name = ofnode_get_name(subnode);
+   if (!strncmp(name, "reset", 5))
+   device_bind_driver_to_node(dev, "uniphier-reset",
+  name, subnode, );
+   }
+
+   /* Get controller node that is placed separately from the glue node */
+   *node = ofnode_by_compatible(dev_ofnode(dev->parent),
+"socionext,uniphier-dwc3");
 
-   base = dev_read_addr(dev);
-   if (base == FDT_ADDR_T_NONE)
-   return -EINVAL;
-
-   regs = ioremap(base, SZ_32K);
-   if (!regs)
-   return -ENOMEM;
+   return 0;
+}
 
-   init = (typeof(init))dev_get_driver_data(dev);
-   ret = init(regs);
-   if (ret)
- 

[PATCH v4 10/10] uniphier_defconfig: Disable USB_XHCI_DWC3

2023-02-19 Thread Kunihiko Hayashi
Replacing with dwc3-generic, no need USB_XHCI_DWC3 anymore.

Signed-off-by: Kunihiko Hayashi 
Reviewed-by: Marek Vasut 
---
 configs/uniphier_v7_defconfig | 1 -
 configs/uniphier_v8_defconfig | 1 -
 2 files changed, 2 deletions(-)

diff --git a/configs/uniphier_v7_defconfig b/configs/uniphier_v7_defconfig
index d626968c76..03feb04b93 100644
--- a/configs/uniphier_v7_defconfig
+++ b/configs/uniphier_v7_defconfig
@@ -82,7 +82,6 @@ CONFIG_DM_SPI=y
 CONFIG_UNIPHIER_SPI=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
-CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
 CONFIG_USB_DWC3=y
diff --git a/configs/uniphier_v8_defconfig b/configs/uniphier_v8_defconfig
index 6a0e2666cf..ed58b5746e 100644
--- a/configs/uniphier_v8_defconfig
+++ b/configs/uniphier_v8_defconfig
@@ -71,7 +71,6 @@ CONFIG_SYSRESET=y
 CONFIG_SYSRESET_PSCI=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
-CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
 CONFIG_USB_DWC3=y
-- 
2.25.1



[PATCH v4 05/10] usb: dwc3-generic: Add the size of regs property to glue structure

2023-02-19 Thread Kunihiko Hayashi
Add the size of regs property to the glue structure to correctly
specify the register region to map.

Signed-off-by: Kunihiko Hayashi 
Reviewed-by: Marek Vasut 
---
 drivers/usb/dwc3/dwc3-generic.c | 2 +-
 drivers/usb/dwc3/dwc3-generic.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 4576390ec7..acbf7acb19 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -542,7 +542,7 @@ int dwc3_glue_probe(struct udevice *dev)
phy.dev = NULL;
}
 
-   glue->regs = dev_read_addr(dev);
+   glue->regs = dev_read_addr_size_index(dev, 0, >size);
 
ret = dwc3_glue_clk_init(dev, glue);
if (ret)
diff --git a/drivers/usb/dwc3/dwc3-generic.h b/drivers/usb/dwc3/dwc3-generic.h
index 824f678841..40902c8923 100644
--- a/drivers/usb/dwc3/dwc3-generic.h
+++ b/drivers/usb/dwc3/dwc3-generic.h
@@ -17,6 +17,7 @@ struct dwc3_glue_data {
struct clk_bulk clks;
struct reset_ctl_bulk   resets;
fdt_addr_t regs;
+   fdt_size_t size;
 };
 
 struct dwc3_glue_ops {
-- 
2.25.1



[PATCH v4 03/10] usb: dwc3-generic: Add clock initialization in child DT node

2023-02-19 Thread Kunihiko Hayashi
Same as the reset cotnrol, should add a clock initialization in child DT
node, if the glue node doesn't have any clocks.

Signed-off-by: Kunihiko Hayashi 
Reviewed-by: Marek Vasut 
---
 drivers/usb/dwc3/dwc3-generic.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index e32003d68e..8fa56e1ac1 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -572,6 +572,12 @@ static int dwc3_glue_probe(struct udevice *dev)
if (ret)
return ret;
 
+   if (glue->clks.count == 0) {
+   ret = dwc3_glue_clk_init(child, glue);
+   if (ret)
+   return ret;
+   }
+
if (glue->resets.count == 0) {
ret = dwc3_glue_reset_init(child, glue);
if (ret)
-- 
2.25.1



[PATCH v4 02/10] usb: dwc3-generic: Allow different controller DT node pattern

2023-02-19 Thread Kunihiko Hayashi
The most of devicetree has the following USB node structure.
The controller node is placed as a child node of the glue node.
Current dwc3-generic driver works on this premise.

glue {
/* glue node */
usb {
/* controller node */
};
};

However, UniPhier original devicetree has the following USB node structure.
The controller node is separately placed from the glue node.

usb {
/* controller node */
};
glue {
/* glue node */
};

In dwc_glue_bind(), this patch provides .glue_get_ctrl_dev() callback to
get such a controller node and binds the driver related to the node.

If this callback isn't defined, dwc_glue_bind() looks for the controller
nodes from the child nodes, as before.

Suggested-by: Marek Vasut 
Signed-off-by: Kunihiko Hayashi 
Reviewed-by: Marek Vasut 
---
 drivers/usb/dwc3/dwc3-generic.c | 93 -
 1 file changed, 57 insertions(+), 36 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 42e92478f2..e32003d68e 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -276,6 +276,7 @@ U_BOOT_DRIVER(dwc3_generic_host) = {
 #endif
 
 struct dwc3_glue_ops {
+   int (*glue_get_ctrl_dev)(struct udevice *parent, ofnode *node);
void (*glue_configure)(struct udevice *dev, int index,
   enum usb_dr_mode mode);
 };
@@ -415,54 +416,74 @@ struct dwc3_glue_ops ti_ops = {
.glue_configure = dwc3_ti_glue_configure,
 };
 
-static int dwc3_glue_bind(struct udevice *parent)
+static int dwc3_glue_bind_common(struct udevice *parent, ofnode node)
 {
-   ofnode node;
-   int ret;
+   const char *name = ofnode_get_name(node);
+   const char *driver = NULL;
enum usb_dr_mode dr_mode;
+   struct udevice *dev;
+   int ret;
 
-   dr_mode = usb_get_dr_mode(dev_ofnode(parent));
-
-   ofnode_for_each_subnode(node, dev_ofnode(parent)) {
-   const char *name = ofnode_get_name(node);
-   struct udevice *dev;
-   const char *driver = NULL;
-
-   debug("%s: subnode name: %s\n", __func__, name);
+   debug("%s: subnode name: %s\n", __func__, name);
 
-   /* if the parent node doesn't have a mode check the leaf */
-   if (!dr_mode)
-   dr_mode = usb_get_dr_mode(node);
+   /* if the parent node doesn't have a mode check the leaf */
+   dr_mode = usb_get_dr_mode(dev_ofnode(parent));
+   if (!dr_mode)
+   dr_mode = usb_get_dr_mode(node);
 
-   switch (dr_mode) {
-   case USB_DR_MODE_PERIPHERAL:
-   case USB_DR_MODE_OTG:
+   switch (dr_mode) {
+   case USB_DR_MODE_PERIPHERAL:
+   case USB_DR_MODE_OTG:
 #if CONFIG_IS_ENABLED(DM_USB_GADGET)
-   debug("%s: dr_mode: OTG or Peripheral\n", __func__);
-   driver = "dwc3-generic-peripheral";
+   debug("%s: dr_mode: OTG or Peripheral\n", __func__);
+   driver = "dwc3-generic-peripheral";
 #endif
-   break;
+   break;
 #if defined(CONFIG_SPL_USB_HOST) || !defined(CONFIG_SPL_BUILD)
-   case USB_DR_MODE_HOST:
-   debug("%s: dr_mode: HOST\n", __func__);
-   driver = "dwc3-generic-host";
-   break;
+   case USB_DR_MODE_HOST:
+   debug("%s: dr_mode: HOST\n", __func__);
+   driver = "dwc3-generic-host";
+   break;
 #endif
-   default:
-   debug("%s: unsupported dr_mode\n", __func__);
-   return -ENODEV;
-   };
+   default:
+   debug("%s: unsupported dr_mode\n", __func__);
+   return -ENODEV;
+   };
 
-   if (!driver)
-   continue;
+   if (!driver)
+   return -ENXIO;
+
+   ret = device_bind_driver_to_node(parent, driver, name,
+node, );
+   if (ret) {
+   debug("%s: not able to bind usb device mode\n",
+ __func__);
+   return ret;
+   }
+
+   return 0;
+}
+
+static int dwc3_glue_bind(struct udevice *parent)
+{
+   struct dwc3_glue_ops *ops = (struct dwc3_glue_ops 
*)dev_get_driver_data(parent);
+   ofnode node;
+   int ret;
 
-   ret = device_bind_driver_to_node(parent, driver, name,
-node, );
-   if (ret) {
-   debug("%s: not able to bind usb device mode\n",
- __func__);
+   if (ops && ops->glue_get_ctrl_dev) {
+   ret = ops->glue_get_ctrl_dev(parent, );
+   if (ret)
+   return ret;
+
+   return dwc3_glue_bind_common(parent, node);
+   }
+
+   

[PATCH v4 07/10] clk: uniphier: Add missing USB SS-PHY clocks

2023-02-19 Thread Kunihiko Hayashi
The USB SS-PHY needs its own clock, however, some clocks don't have
clock gates. Define missing clock entries for the PHY as reference
clock.

Signed-off-by: Kunihiko Hayashi 
---
 drivers/clk/uniphier/clk-uniphier-sys.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/clk/uniphier/clk-uniphier-sys.c 
b/drivers/clk/uniphier/clk-uniphier-sys.c
index ff5d364f59..3b8595fe61 100644
--- a/drivers/clk/uniphier/clk-uniphier-sys.c
+++ b/drivers/clk/uniphier/clk-uniphier-sys.c
@@ -28,7 +28,10 @@ const struct uniphier_clk_data uniphier_pxs2_sys_clk_data[] 
= {
UNIPHIER_CLK_GATE_SIMPLE(14, 0x2104, 16),   /* usb30 (Pro4, Pro5, 
PXs2) */
UNIPHIER_CLK_GATE_SIMPLE(15, 0x2104, 17),   /* usb31 (Pro4, Pro5, 
PXs2) */
UNIPHIER_CLK_GATE_SIMPLE(16, 0x2104, 19),   /* usb30-phy (PXs2) */
+   UNIPHIER_CLK_RATE(17, 2500),/* usb30-phy2 (PXs2) */
+   UNIPHIER_CLK_RATE(18, 2500),/* usb30-phy3 (PXs2) */
UNIPHIER_CLK_GATE_SIMPLE(20, 0x2104, 20),   /* usb31-phy (PXs2) */
+   UNIPHIER_CLK_RATE(21, 2500),/* usb31-phy2 (PXs2) */
UNIPHIER_CLK_GATE_SIMPLE(24, 0x2108, 2),/* pcie (Pro5) */
{ /* sentinel */ }
 #endif
@@ -44,6 +47,8 @@ const struct uniphier_clk_data uniphier_ld20_sys_clk_data[] = 
{
UNIPHIER_CLK_GATE_SIMPLE(14, 0x210c, 14),   /* usb30 (LD20) */
UNIPHIER_CLK_GATE_SIMPLE(16, 0x210c, 12),   /* usb30-phy0 (LD20) */
UNIPHIER_CLK_GATE_SIMPLE(17, 0x210c, 13),   /* usb30-phy1 (LD20) */
+   UNIPHIER_CLK_RATE(18, 2500),/* usb30-phy2 (LD20) */
+   UNIPHIER_CLK_RATE(19, 2500),/* usb30-phy3 (LD20) */
UNIPHIER_CLK_GATE_SIMPLE(24, 0x210c, 4),/* pcie */
{ /* sentinel */ }
 #endif
-- 
2.25.1



[PATCH v4 06/10] reset: uniphier: Add USB glue reset support

2023-02-19 Thread Kunihiko Hayashi
Add reset control support in USB glue logic. This needs to control
the external clocks and resets for the logic before accessing the
glue logic.

The USB dm tree when using dwc3-generic is the following:

   USB glue
 +-- controller   (need controller-reset)
 +-- controller-reset (need syscon-reset)
 +-- phy

The controller needs to deassert "controller-reset" in USB glue before
the controller registers are accessed. The glue needs to deassert
"syscon-reset" before the glue registers are accessed.

The glue itself doesn't have "syscon-reset", so the controller-reset
controls "syscon-reset" instead.

Signed-off-by: Kunihiko Hayashi 
Reviewed-by: Marek Vasut 
---
 drivers/reset/reset-uniphier.c | 78 +-
 1 file changed, 77 insertions(+), 1 deletion(-)

diff --git a/drivers/reset/reset-uniphier.c b/drivers/reset/reset-uniphier.c
index 7adae51873..35e3ccebd7 100644
--- a/drivers/reset/reset-uniphier.c
+++ b/drivers/reset/reset-uniphier.c
@@ -2,6 +2,7 @@
 /*
  * Copyright (C) 2016 Socionext Inc.
  *   Author: Masahiro Yamada 
+ *   Author: Kunihiko Hayashi 
  */
 
 #include 
@@ -9,6 +10,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -178,10 +181,17 @@ static const struct uniphier_reset_data 
uniphier_pro4_peri_reset_data[] = {
UNIPHIER_RESET_END,
 };
 
+/* Glue reset data */
+static const struct uniphier_reset_data uniphier_pro4_usb3_reset_data[] = {
+   UNIPHIER_RESETX(15, 0, 15)
+};
+
 /* core implementaton */
 struct uniphier_reset_priv {
void __iomem *base;
const struct uniphier_reset_data *data;
+   struct clk_bulk clks;
+   struct reset_ctl_bulk   rsts;
 };
 
 static int uniphier_reset_update(struct reset_ctl *reset_ctl, int assert)
@@ -233,10 +243,47 @@ static const struct reset_ops uniphier_reset_ops = {
.rst_deassert = uniphier_reset_deassert,
 };
 
+static int uniphier_reset_rst_init(struct udevice *dev)
+{
+   struct uniphier_reset_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   ret = reset_get_bulk(dev, >rsts);
+   if (ret == -ENOSYS || ret == -ENOENT)
+   return 0;
+   else if (ret)
+   return ret;
+
+   ret = reset_deassert_bulk(>rsts);
+   if (ret)
+   reset_release_bulk(>rsts);
+
+   return ret;
+}
+
+static int uniphier_reset_clk_init(struct udevice *dev)
+{
+   struct uniphier_reset_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   ret = clk_get_bulk(dev, >clks);
+   if (ret == -ENOSYS || ret == -ENOENT)
+   return 0;
+   if (ret)
+   return ret;
+
+   ret = clk_enable_bulk(>clks);
+   if (ret)
+   clk_release_bulk(>clks);
+
+   return ret;
+}
+
 static int uniphier_reset_probe(struct udevice *dev)
 {
struct uniphier_reset_priv *priv = dev_get_priv(dev);
fdt_addr_t addr;
+   int ret;
 
addr = dev_read_addr(dev->parent);
if (addr == FDT_ADDR_T_NONE)
@@ -248,7 +295,11 @@ static int uniphier_reset_probe(struct udevice *dev)
 
priv->data = (void *)dev_get_driver_data(dev);
 
-   return 0;
+   ret = uniphier_reset_clk_init(dev);
+   if (ret)
+   return ret;
+
+   return uniphier_reset_rst_init(dev);
 }
 
 static const struct udevice_id uniphier_reset_match[] = {
@@ -355,6 +406,31 @@ static const struct udevice_id uniphier_reset_match[] = {
.compatible = "socionext,uniphier-pxs3-peri-reset",
.data = (ulong)uniphier_pro4_peri_reset_data,
},
+   /* USB glue reset */
+   {
+   .compatible = "socionext,uniphier-pro4-usb3-reset",
+   .data = (ulong)uniphier_pro4_usb3_reset_data,
+   },
+   {
+   .compatible = "socionext,uniphier-pro5-usb3-reset",
+   .data = (ulong)uniphier_pro4_usb3_reset_data,
+   },
+   {
+   .compatible = "socionext,uniphier-pxs2-usb3-reset",
+   .data = (ulong)uniphier_pro4_usb3_reset_data,
+   },
+   {
+   .compatible = "socionext,uniphier-ld20-usb3-reset",
+   .data = (ulong)uniphier_pro4_usb3_reset_data,
+   },
+   {
+   .compatible = "socionext,uniphier-pxs3-usb3-reset",
+   .data = (ulong)uniphier_pro4_usb3_reset_data,
+   },
+   {
+   .compatible = "socionext,uniphier-nx1-usb3-reset",
+   .data = (ulong)uniphier_pro4_usb3_reset_data,
+   },
{ /* sentinel */ }
 };
 
-- 
2.25.1



[PATCH v4 01/10] usb: dwc3: Look up reference clock DT phandle in both controller DT nodes

2023-02-19 Thread Kunihiko Hayashi
From: Marek Vasut 

There are currently four disparate placement possibilities of DWC3
reference clock phandle in SoC DTs:
- in top level glue node, with generic subnode without clock (ZynqMP)
- in top level generic node, with no subnode (i.MX8MQ)
- in generic subnode, with other clock in top level node (i.MX8MP)
- in both top level node and generic subnode (Rockchip)

Cover all the possibilities here by looking into both nodes, start
with the top level node as that seems to be used in majority of DTs
to reference the clock.

Signed-off-by: Marek Vasut 
Acked-by: Kunihiko Hayashi 
---
 drivers/usb/dwc3/dwc3-generic.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 78966718d0..42e92478f2 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -68,10 +68,27 @@ static int dwc3_generic_probe(struct udevice *dev,
 #if CONFIG_IS_ENABLED(OF_CONTROL)
dwc3_of_parse(dwc3);
 
+   /*
+* There are currently four disparate placement possibilities of DWC3
+* reference clock phandle in SoC DTs:
+* - in top level glue node, with generic subnode without clock (ZynqMP)
+* - in top level generic node, with no subnode (i.MX8MQ)
+* - in generic subnode, with other clock in top level node (i.MX8MP)
+* - in both top level node and generic subnode (Rockchip)
+* Cover all the possibilities here by looking into both nodes, start
+* with the top level node as that seems to be used in majority of DTs
+* to reference the clock.
+*/
node = dev_ofnode(dev->parent);
index = ofnode_stringlist_search(node, "clock-names", "ref");
if (index < 0)
index = ofnode_stringlist_search(node, "clock-names", 
"ref_clk");
+   if (index < 0) {
+   node = dev_ofnode(dev);
+   index = ofnode_stringlist_search(node, "clock-names", "ref");
+   if (index < 0)
+   index = ofnode_stringlist_search(node, "clock-names", 
"ref_clk");
+   }
if (index >= 0)
dwc3->ref_clk = >clks.clks[index];
 #endif
-- 
2.25.1



[PATCH v4 04/10] usb: dwc3-generic: Export glue structures and functions

2023-02-19 Thread Kunihiko Hayashi
In order to allow external SoC-dependent glue drivers to use dwc3-generic
functions, push the glue structures and export the functions to a header
file.

The exported structures and functions are:

- struct dwc3_glue_data
- struct dwc3_glue_ops
- dwc3_glue_bind()
- dwc3_glue_probe()
- dwc3_glue_remove()

The SoC-dependent glue drivers can only define their own wrapper driver
and specify these functions. The drivers can also add their own compatible
strings and configure functions.

Signed-off-by: Kunihiko Hayashi 
Reviewed-by: Marek Vasut 
---
 drivers/usb/dwc3/dwc3-generic.c | 18 --
 drivers/usb/dwc3/dwc3-generic.h | 32 
 2 files changed, 36 insertions(+), 14 deletions(-)
 create mode 100644 drivers/usb/dwc3/dwc3-generic.h

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 8fa56e1ac1..4576390ec7 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -28,11 +28,7 @@
 #include 
 #include 
 
-struct dwc3_glue_data {
-   struct clk_bulk clks;
-   struct reset_ctl_bulk   resets;
-   fdt_addr_t regs;
-};
+#include "dwc3-generic.h"
 
 struct dwc3_generic_plat {
fdt_addr_t base;
@@ -275,12 +271,6 @@ U_BOOT_DRIVER(dwc3_generic_host) = {
 };
 #endif
 
-struct dwc3_glue_ops {
-   int (*glue_get_ctrl_dev)(struct udevice *parent, ofnode *node);
-   void (*glue_configure)(struct udevice *dev, int index,
-  enum usb_dr_mode mode);
-};
-
 void dwc3_imx8mp_glue_configure(struct udevice *dev, int index,
enum usb_dr_mode mode)
 {
@@ -464,7 +454,7 @@ static int dwc3_glue_bind_common(struct udevice *parent, 
ofnode node)
return 0;
 }
 
-static int dwc3_glue_bind(struct udevice *parent)
+int dwc3_glue_bind(struct udevice *parent)
 {
struct dwc3_glue_ops *ops = (struct dwc3_glue_ops 
*)dev_get_driver_data(parent);
ofnode node;
@@ -531,7 +521,7 @@ static int dwc3_glue_clk_init(struct udevice *dev,
return 0;
 }
 
-static int dwc3_glue_probe(struct udevice *dev)
+int dwc3_glue_probe(struct udevice *dev)
 {
struct dwc3_glue_ops *ops = (struct dwc3_glue_ops 
*)dev_get_driver_data(dev);
struct dwc3_glue_data *glue = dev_get_plat(dev);
@@ -597,7 +587,7 @@ static int dwc3_glue_probe(struct udevice *dev)
return 0;
 }
 
-static int dwc3_glue_remove(struct udevice *dev)
+int dwc3_glue_remove(struct udevice *dev)
 {
struct dwc3_glue_data *glue = dev_get_plat(dev);
 
diff --git a/drivers/usb/dwc3/dwc3-generic.h b/drivers/usb/dwc3/dwc3-generic.h
new file mode 100644
index 00..824f678841
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-generic.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * dwc3-generic.h - Generic DWC3 Glue layer header
+ *
+ * Copyright (C) 2016 - 2018 Xilinx, Inc.
+ * Copyright (C) 2023 Socionext Inc.
+ */
+
+#ifndef __DRIVERS_USB_DWC3_GENERIC_H
+#define __DRIVERS_USB_DWC3_GENERIC_H
+
+#include 
+#include 
+#include 
+
+struct dwc3_glue_data {
+   struct clk_bulk clks;
+   struct reset_ctl_bulk   resets;
+   fdt_addr_t regs;
+};
+
+struct dwc3_glue_ops {
+   int (*glue_get_ctrl_dev)(struct udevice *parent, ofnode *node);
+   void (*glue_configure)(struct udevice *dev, int index,
+  enum usb_dr_mode mode);
+};
+
+int dwc3_glue_bind(struct udevice *parent);
+int dwc3_glue_probe(struct udevice *dev);
+int dwc3_glue_remove(struct udevice *dev);
+
+#endif
-- 
2.25.1



[PATCH v4 00/10] usb: dwc3: Refactor dwc3-generic and apply to dwc3-uniphier

2023-02-19 Thread Kunihiko Hayashi
This series achieves refactoring of dwc3-generic.

First, dwc3-generic allows DT controller nodes to be children of glue nodes,
but outside of glue nodes.

To achieve this goal, define a glue-specific function to get controller node,
look up more reference clocks in the controller node, and initialize clocks
in children of glue node before access to the controller,

Next, this series exports the structures and functions from the driver source
to the header, and replaces dwc3-uniphier driver as one implementation using
them. This expects dwc3-generic to prevent more SoC-dependent codes.

The dwc3-uniphier has original USB node, however, tentatively added its own
node dedicated to U-Boot. After this refactoring, the driver needs to add
clock entries and PHY driver to enable them corresponding to the properties
in the original node.

PATCH 1 has been provided below.
  
https://patchwork.ozlabs.org/project/uboot/patch/20221215223822.137739-1-ma...@denx.de/

PATCH 2 is based on the suggested patch from Marek.

PATCH 4-5 and 9-10 have been already reviewed in the previous v1.
  https://lists.denx.de/pipermail/u-boot/2023-January/505689.html

Changes since v3:
- Control the controller clock/reset and phy clock/reset separately

Changes since v2:
- Add Reviewed-by: tags
- Add more details to reset-uniphier patch log
- Add error release for clock/reset initializer in phy-uniphier-usb3 patch
- Fix release year in in phy-uniphier-usb3 patch
- Enable PHY_UNIPHIER_USB3 with DWC3_UNIPHIER
- Separate devicetree patches

Changes since v1:
- Add a patch to refer to the clock in top level generic node
- Add a patch to allow controller DT node outside of glue node
- Add a patch to initialize clocks in children of glue node
- Update dwc3_glue_ops to add the function to get controller device
- Add a patch to support USB glue reset
- Add a patch to add missing PHY clocks
- Add a patch to enable the driver to enable PHY clocks and resets
- Add a patch to fix node names and missing properties
- Add a patch to switch to the original USB node in DT

Kunihiko Hayashi (9):
  usb: dwc3-generic: Allow different controller DT node pattern
  usb: dwc3-generic: Add clock initialization in child DT node
  usb: dwc3-generic: Export glue structures and functions
  usb: dwc3-generic: Add the size of regs property to glue structure
  reset: uniphier: Add USB glue reset support
  clk: uniphier: Add missing USB SS-PHY clocks
  phy: socionext: Add UniPhier USB3 PHY driver
  usb: dwc3-uniphier: Use dwc3-generic instead of xhci-dwc3
  uniphier_defconfig: Disable USB_XHCI_DWC3

Marek Vasut (1):
  usb: dwc3: Look up reference clock DT phandle in both controller DT
nodes

 configs/uniphier_v7_defconfig |   1 -
 configs/uniphier_v8_defconfig |   1 -
 drivers/clk/uniphier/clk-uniphier-sys.c   |   5 +
 drivers/phy/socionext/Kconfig |   8 ++
 drivers/phy/socionext/Makefile|   1 +
 drivers/phy/socionext/phy-uniphier-usb3.c | 168 ++
 drivers/reset/reset-uniphier.c|  78 +-
 drivers/usb/dwc3/Kconfig  |   4 +-
 drivers/usb/dwc3/dwc3-generic.c   | 132 ++---
 drivers/usb/dwc3/dwc3-generic.h   |  33 +
 drivers/usb/dwc3/dwc3-uniphier.c  | 116 +--
 11 files changed, 453 insertions(+), 94 deletions(-)
 create mode 100644 drivers/phy/socionext/phy-uniphier-usb3.c
 create mode 100644 drivers/usb/dwc3/dwc3-generic.h

-- 
2.25.1



[PATCH] spi: spi-mem: s/dummy/data buswidth check in dtr_supports_op()

2023-02-19 Thread Dhruva Gole
This should have been op->data.buswidth instead as we check for octal
bus width for the data related ops
Also add explanation for why there is checks for 8D even data bytes

Cc: Pratyush Yadav 
Signed-off-by: Dhruva Gole 
---

Address Pratyush Yadav's comments from here:
https://lore.kernel.org/u-boot/20221106224617.2ievqx37mcvqn...@yadavpratyush.com/

 drivers/spi/spi-mem.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index 8e8995fc537f..57a36f31a5d3 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -181,8 +181,12 @@ bool spi_mem_dtr_supports_op(struct spi_slave *slave,
if (op->dummy.nbytes && op->dummy.buswidth == 8 && op->dummy.nbytes % 2)
return false;
 
+   /*
+* Transactions of odd length do not make sense for 8D-8D-8D mode
+* because a byte is transferred in just half a cycle.
+*/
if (op->data.dir != SPI_MEM_NO_DATA &&
-   op->dummy.buswidth == 8 && op->data.nbytes % 2)
+   op->data.buswidth == 8 && op->data.nbytes % 2)
return false;
 
return spi_mem_check_buswidth(slave, op);
-- 
2.25.1



Re: [PATCH v3 08/10] phy: socionext: Add UniPhier USB3 PHY driver

2023-02-19 Thread Kunihiko Hayashi

Hi Marek,

On 2023/02/18 4:58, Marek Vasut wrote:

On 2/16/23 17:14, Kunihiko Hayashi wrote:

Hi Marek,


Hello Hayashi-san,


Sorry for late reply.

On 2023/02/14 6:06, Marek Vasut wrote:

On 2/13/23 04:08, Kunihiko Hayashi wrote:

Hi Marek,


Hello Hayashi-san,



[...]


I think so, however, when I added .exit() and executed "usb stop;usb
start",
unfortunately the command got stuck.

Currently uniphier clk doesn't support CLK_CCF and can't be nested.
I think more changes are needed.


Do you know where exactly the system hangs ?


Yes.

The controller-reset driver controls the clock/reset for the glue
in probe(). The phy driver controls the clock/reset for the glue and
the phy in init(). There is an inconsistency.

When submitting "usb stop", the phy driver disables all the clock/reset
in exit().

When submitting "usb start" again, the controller-reset driver accesses
the glue register without enabling the clock/reset, and the system hangs.


Shouldn't the PHY enable its own set of clock, while the controller
should only enable its own (different) set of clock ?


PHY has this own clock/reset, however, PHY is in the glue logic.
So accessing to PHY also needs to enable the glue clock
(same as the controller clock).


If it is the same clock and there is no refcounting, then maybe what you
should do for now is enable/disable all the clock in the controller
driver only, and deal with the PHY once CCF with refcounting is in place ?


PHY needs the glue(controller) clock and the phy clock.
After all, it's wrong to control all the clocks/resets at the same time.

In this time, I don't event think about CCF (sorry to confuse you).


Do you expect to add the CCF support ?


Yes, first I thought the clock needed the CCF support to count the clock
function calls, but there is no support to count the reset function calls.
I need another solution.

Currently the phy driver controls all the clock/reset in init() and
exit(),
however, it should control the phy clock/reset only.


If that's possible on this hardware, that would be good, let controller
control its clock and PHY control its (different) clock.


Yes. I'll separate these controls.


If so, then add at least a FIXME code comment that the exit callback
must be implemented, so that this is not forgotten once CCF is in place.
I don't want this series to grow much further into some "rework
everything at once" thing.


As above, I should put the glue clock/reset into probe(),
and the phy clock/reset into init() without using bulk function.


OK


Thank you,

---
Best Regards
Kunihiko Hayashi


[PATCH 4/4] buildman: Add a flag for reproducible builds

2023-02-19 Thread Simon Glass
This is quite a useful thing to use when building since it avoids small
size changes between commits. Add a -r flag for it.

Signed-off-by: Simon Glass 
---

 doc/build/reproducible.rst  | 2 ++
 tools/buildman/builder.py   | 4 +++-
 tools/buildman/builderthread.py | 2 ++
 tools/buildman/buildman.rst | 7 ---
 tools/buildman/cmdline.py   | 2 ++
 tools/buildman/control.py   | 3 ++-
 tools/buildman/func_test.py | 4 
 7 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/doc/build/reproducible.rst b/doc/build/reproducible.rst
index 5423080633e..8b030f469d7 100644
--- a/doc/build/reproducible.rst
+++ b/doc/build/reproducible.rst
@@ -23,3 +23,5 @@ This date is shown when we launch U-Boot:
 
 ./u-boot -T
 U-Boot 2023.01 (Jan 01 2023 - 00:00:00 +)
+
+The same effect can be obtained with buildman using the `-r` flag.
diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 107086cc0e5..7b9be887e55 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -195,6 +195,7 @@ class Builder:
 don't write to a separate output directory.
 thread_exceptions: List of exceptions raised by thread jobs
 no_lto (bool): True to set the NO_LTO flag when building
+reproducible_builds (bool): True to set SOURCE_DATE_EPOCH=0 for builds
 
 Private members:
 _base_board_dict: Last-summarised Dict of boards
@@ -254,7 +255,7 @@ class Builder:
  config_only=False, squash_config_y=False,
  warnings_as_errors=False, work_in_output=False,
  test_thread_exceptions=False, adjust_cfg=None,
- allow_missing=False, no_lto=False):
+ allow_missing=False, no_lto=False, reproducible_builds=False):
 """Create a new Builder object
 
 Args:
@@ -334,6 +335,7 @@ class Builder:
 self.allow_missing = allow_missing
 self._ide = False
 self.no_lto = no_lto
+self.reproducible_builds = reproducible_builds
 
 if not self.squash_config_y:
 self.config_filenames += EXTRA_CONFIG_FILENAMES
diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index dae3d4ab9ff..8b88c68e5d2 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -257,6 +257,8 @@ class BuilderThread(threading.Thread):
 args.append('BINMAN_ALLOW_MISSING=1')
 if self.builder.no_lto:
 args.append('NO_LTO=1')
+if self.builder.reproducible_builds:
+args.append('SOURCE_DATE_EPOCH=0')
 config_args = ['%s_defconfig' % brd.target]
 config_out = ''
 args.extend(self.builder.toolchains.GetMakeArguments(brd))
diff --git a/tools/buildman/buildman.rst b/tools/buildman/buildman.rst
index 800b83a89de..c8b0db3d8b9 100644
--- a/tools/buildman/buildman.rst
+++ b/tools/buildman/buildman.rst
@@ -1023,14 +1023,15 @@ U-Boot's build system embeds information such as a 
build timestamp into the
 final binary. This information varies each time U-Boot is built. This causes
 various files to be rebuilt even if no source changes are made, which in turn
 requires that the final U-Boot binary be re-linked. This unnecessary work can
-be avoided by turning off the timestamp feature. This can be achieved by
-setting the SOURCE_DATE_EPOCH environment variable to 0.
+be avoided by turning off the timestamp feature. This can be achieved using
+the `-r` flag, which enables reproducible builds by setting
+`SOURCE_DATE_EPOCH=0` when building.
 
 Combining all of these options together yields the command-line shown below.
 This will provide the quickest possible feedback regarding the current content
 of the source tree, thus allowing rapid tested evolution of the code::
 
-SOURCE_DATE_EPOCH=0 ./tools/buildman/buildman -P tegra
+./tools/buildman/buildman -Pr tegra
 
 
 Checking configuration
diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py
index 409013671be..da7f1a99f6b 100644
--- a/tools/buildman/cmdline.py
+++ b/tools/buildman/cmdline.py
@@ -97,6 +97,8 @@ def ParseArgs():
   default=False, help="Use full toolchain path in CROSS_COMPILE")
 parser.add_option('-P', '--per-board-out-dir', action='store_true',
   default=False, help="Use an O= (output) directory per board rather 
than per thread")
+parser.add_option('-r', '--reproducible-builds', action='store_true',
+  help='Set SOURCE_DATE_EPOCH=0 to suuport a reproducible build')
 parser.add_option('-R', '--regen-board-list', action='store_true',
   help='Force regeneration of the list of boards, like the old 
boards.cfg file')
 parser.add_option('-s', '--summary', action='store_true',
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index 13a462ae595..0d7c5f5269f 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py

[PATCH 3/4] buildman: Support disabling LTO

2023-02-19 Thread Simon Glass
This cuts down build performance considerably and is not always needed,
when checking for build errors, etc.

Add a flag to disable it.

Signed-off-by: Simon Glass 
---

 tools/buildman/builder.py   |  5 -
 tools/buildman/builderthread.py |  2 ++
 tools/buildman/buildman.rst | 14 ++
 tools/buildman/cmdline.py   |  2 ++
 tools/buildman/control.py   |  2 +-
 tools/buildman/func_test.py | 25 +
 6 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index c2a69027f88..107086cc0e5 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -194,6 +194,7 @@ class Builder:
 work_in_output: Use the output directory as the work directory and
 don't write to a separate output directory.
 thread_exceptions: List of exceptions raised by thread jobs
+no_lto (bool): True to set the NO_LTO flag when building
 
 Private members:
 _base_board_dict: Last-summarised Dict of boards
@@ -253,7 +254,7 @@ class Builder:
  config_only=False, squash_config_y=False,
  warnings_as_errors=False, work_in_output=False,
  test_thread_exceptions=False, adjust_cfg=None,
- allow_missing=False):
+ allow_missing=False, no_lto=False):
 """Create a new Builder object
 
 Args:
@@ -292,6 +293,7 @@ class Builder:
 C=val to set the value of C (val must have quotes if C is
 a string Kconfig
 allow_missing: Run build with BINMAN_ALLOW_MISSING=1
+no_lto (bool): True to set the NO_LTO flag when building
 
 """
 self.toolchains = toolchains
@@ -331,6 +333,7 @@ class Builder:
 self.adjust_cfg = adjust_cfg
 self.allow_missing = allow_missing
 self._ide = False
+self.no_lto = no_lto
 
 if not self.squash_config_y:
 self.config_filenames += EXTRA_CONFIG_FILENAMES
diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index 7ba9a856dd5..dae3d4ab9ff 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -255,6 +255,8 @@ class BuilderThread(threading.Thread):
 args.append('KCFLAGS=-Werror')
 if self.builder.allow_missing:
 args.append('BINMAN_ALLOW_MISSING=1')
+if self.builder.no_lto:
+args.append('NO_LTO=1')
 config_args = ['%s_defconfig' % brd.target]
 config_out = ''
 args.extend(self.builder.toolchains.GetMakeArguments(brd))
diff --git a/tools/buildman/buildman.rst b/tools/buildman/buildman.rst
index 11c72141791..800b83a89de 100644
--- a/tools/buildman/buildman.rst
+++ b/tools/buildman/buildman.rst
@@ -1123,6 +1123,20 @@ toolchain. For example:
buildman -O clang-7 --board sandbox
 
 
+Building without LTO
+
+
+Link-time optimisation (LTO) is designed to reduce code size by globally
+optimising the U-Boot build. Unfortunately this can dramatically slow down
+builds. This is particularly noticeable when running a lot of builds.
+
+Use the -L (--no-lto) flag to disable LTO.
+
+.. code-block:: bash
+
+   buildman -L --board sandbox
+
+
 Doing a simple build
 
 
diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py
index c485994e9fe..409013671be 100644
--- a/tools/buildman/cmdline.py
+++ b/tools/buildman/cmdline.py
@@ -71,6 +71,8 @@ def ParseArgs():
   default=False, help="Don't convert y to 1 in configs")
 parser.add_option('-l', '--list-error-boards', action='store_true',
   default=False, help='Show a list of boards next to each 
error/warning')
+parser.add_option('-L', '--no-lto', action='store_true',
+  default=False, help='Disable Link-time Optimisation (LTO) for 
builds')
 parser.add_option('--list-tool-chains', action='store_true', default=False,
   help='List available tool chains (use -v to see probing detail)')
 parser.add_option('-m', '--mrproper', action='store_true',
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index 87e7d0e2012..13a462ae595 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -351,7 +351,7 @@ def DoBuildman(options, args, toolchains=None, 
make_func=None, brds=None,
 work_in_output=options.work_in_output,
 test_thread_exceptions=test_thread_exceptions,
 adjust_cfg=adjust_cfg,
-allow_missing=allow_missing)
+allow_missing=allow_missing, no_lto=options.no_lto)
 builder.force_config_on_failure = not options.quick
 if make_func:
 builder.do_make = make_func
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index 799c609446e..6d1557293f0 100644
--- a/tools/buildman/func_test.py
+++ 

[PATCH 2/4] buildman: Write out the build command used

2023-02-19 Thread Simon Glass
It is sometimes useful to see the exact 'make' command used by buildman
for a commit. Add an output file for this.

Signed-off-by: Simon Glass 
---

 tools/buildman/builderthread.py | 13 +
 tools/buildman/buildman.rst |  8 
 tools/buildman/func_test.py | 13 +
 3 files changed, 34 insertions(+)

diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index 680efae02d7..7ba9a856dd5 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -273,14 +273,19 @@ class BuilderThread(threading.Thread):
 
 # If we need to reconfigure, do that now
 cfg_file = os.path.join(out_dir, '.config')
+cmd_list = []
 if do_config or adjust_cfg:
 config_out = ''
 if self.mrproper:
 result = self.Make(commit, brd, 'mrproper', cwd,
 'mrproper', *args, env=env)
 config_out += result.combined
+cmd_list.append([self.builder.gnu_make, 'mrproper',
+ *args])
 result = self.Make(commit, brd, 'config', cwd,
 *(args + config_args), env=env)
+cmd_list.append([self.builder.gnu_make] + args +
+config_args)
 config_out += result.combined
 do_config = False   # No need to configure next time
 if adjust_cfg:
@@ -290,6 +295,7 @@ class BuilderThread(threading.Thread):
 args.append('cfg')
 result = self.Make(commit, brd, 'build', cwd, *args,
 env=env)
+cmd_list.append([self.builder.gnu_make] + args)
 if (result.return_code == 2 and
 ('Some images are invalid' in result.stderr)):
 # This is handled later by the check for output in
@@ -303,6 +309,7 @@ class BuilderThread(threading.Thread):
 result.stderr = result.stderr.replace(src_dir + '/', '')
 if self.builder.verbose_build:
 result.stdout = config_out + result.stdout
+result.cmd_list = cmd_list
 else:
 result.return_code = 1
 result.stderr = 'No tool chain for %s\n' % brd.arch
@@ -378,6 +385,12 @@ class BuilderThread(threading.Thread):
 with open(os.path.join(build_dir, 'out-env'), 'wb') as fd:
 for var in sorted(env.keys()):
 fd.write(b'%s="%s"' % (var, env[var]))
+
+with open(os.path.join(build_dir, 'out-cmd'), 'w',
+  encoding='utf-8') as fd:
+for cmd in result.cmd_list:
+print(' '.join(cmd), file=fd)
+
 lines = []
 for fname in BASE_ELF_FILENAMES:
 cmd = ['%snm' % self.toolchain.cross, '--size-sort', fname]
diff --git a/tools/buildman/buildman.rst b/tools/buildman/buildman.rst
index 9a2d913c785..11c72141791 100644
--- a/tools/buildman/buildman.rst
+++ b/tools/buildman/buildman.rst
@@ -1300,6 +1300,14 @@ You should use 'buildman -nv ' instead of 
greoing the boards.cfg file,
 since it may be dropped altogether in future.
 
 
+Checking the command
+
+
+Buildman writes out the toolchain information to a `toolchain` file within the
+output directory. It also writes the commands used to build U-Boot in an
+`out-cmd` file. You can check these if you suspect something strange is
+happening.
+
 TODO
 
 
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index 559e4edf74b..799c609446e 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -723,3 +723,16 @@ Some images are invalid'''
  control.get_allow_missing(False, False, 2, True))
 self.assertEqual(False,
  control.get_allow_missing(False, True, 2, True))
+
+def testCmdFile(self):
+"""Test that the -cmd-out file is produced"""
+self._RunControl('-o', self._output_dir)
+board0_dir = os.path.join(self._output_dir, 'current', 'board0')
+self.assertTrue(os.path.exists(os.path.join(board0_dir, 'done')))
+cmd_fname = os.path.join(board0_dir, 'out-cmd')
+self.assertTrue(os.path.exists(cmd_fname))
+data = tools.read_file(cmd_fname)
+lines = data.splitlines()
+self.assertEqual(2, len(lines))
+self.assertRegex(lines[0], b'make O=/.*board0_defconfig')
+self.assertRegex(lines[0], b'make O=/.*-s.*')
-- 
2.39.2.637.g21b0678d19-goog



[PATCH 1/4] buildman: Add a note about the out-env file

2023-02-19 Thread Simon Glass
This file holds the environment used when doing a build. Add a note
about it.

Signed-off-by: Simon Glass 
---

 tools/buildman/buildman.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/buildman/buildman.rst b/tools/buildman/buildman.rst
index 2a83cb7e4f8..9a2d913c785 100644
--- a/tools/buildman/buildman.rst
+++ b/tools/buildman/buildman.rst
@@ -1108,6 +1108,8 @@ and 'brppt1_spi', removing a trailing semicolon. 
'brppt1_nand' gained an a
 value for 'altbootcmd', but lost one for ' altbootcmd'.
 
 The -U option uses the u-boot.env files which are produced by a build.
+Internally, buildman writes out an out-env file into the build directory for
+later comparison.
 
 
 Building with clang
-- 
2.39.2.637.g21b0678d19-goog



[PATCH 3/3] arm: rpi: Switch to a text environment

2023-02-19 Thread Simon Glass
Use the new environment format so we can drop most of the config.h file.

Signed-off-by: Simon Glass 
---

 board/raspberrypi/rpi/rpi.env |  77 ++
 include/configs/rpi.h | 100 --
 2 files changed, 77 insertions(+), 100 deletions(-)
 create mode 100644 board/raspberrypi/rpi/rpi.env

diff --git a/board/raspberrypi/rpi/rpi.env b/board/raspberrypi/rpi/rpi.env
new file mode 100644
index 000..30228285edd
--- /dev/null
+++ b/board/raspberrypi/rpi/rpi.env
@@ -0,0 +1,77 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+/* environment for Raspberry Pi boards */
+
+dhcpuboot=usb start; dhcp u-boot.uimg; bootm
+
+/* Environment */
+stdin=serial,usbkbd
+stdout=serial,vidconsole
+stderr=serial,vidconsole
+
+/* DFU over USB/UDC */
+#ifdef CONFIG_CMD_DFU
+dfu_alt_info=u-boot.bin fat 0 1;uboot.env fat 0 1;
+  config.txt fat 0 1;
+#ifdef CONFIG_ARM64
+dfu_alt_info+=Image fat 0 1
+#else
+dfu_alt_info+=zImage fat 0 1
+#endif
+#endif  /* CONFIG_CMD_DFU */
+
+/*
+ * Memory layout for where various images get loaded by boot scripts:
+ *
+ * I suspect address 0 is used as the SMP pen on the RPi2, so avoid this.
+ *
+ * Older versions of the boot firmware place the firmware-loaded DTB at 0x100,
+ * newer versions place it in high memory. So prevent U-Boot from doing its own
+ * DTB + initrd relocation so that we won't accidentally relocate the initrd
+ * over the firmware-loaded DTB and generally try to lay out things starting
+ * from the bottom of RAM.
+ *
+ * kernel_addr_r has different constraints on ARM and Aarch64.  For 32-bit ARM,
+ * it must be within the first 128M of RAM in order for the kernel's
+ * CONFIG_AUTO_ZRELADDR option to work. The kernel itself will be decompressed
+ * to 0x8000 but the decompressor clobbers 0x4000-0x8000 as well. The
+ * decompressor also likes to relocate itself to right past the end of the
+ * decompressed kernel, so in total the sum of the compressed and
+ * decompressed kernel needs to be reserved.
+ *
+ *   For Aarch64, the kernel image is uncompressed and must be loaded at
+ *   text_offset bytes (specified in the header of the Image) into a 2MB
+ *   boundary. The 'booti' command relocates the image if necessary. Linux uses
+ *   a default text_offset of 0x8.  In summary, loading at 0x8
+ *   satisfies all these constraints and reserving memory up to 0x0240
+ *   permits fairly large (roughly 36M) kernels.
+ *
+ * scriptaddr and pxefile_addr_r can be pretty much anywhere that doesn't
+ * conflict with something else. Reserving 1M for each of them at
+ * 0x0240-0x0250 and 0x0250-0x0260 should be plenty.
+ *
+ * On ARM, both the DTB and any possible initrd must be loaded such that they
+ * fit inside the lowmem mapping in Linux. In practice, this usually means not
+ * more than ~700M away from the start of the kernel image but this number can
+ * be larger OR smaller depending on e.g. the 'vmalloc=xxxM' command line
+ * parameter given to the kernel. So reserving memory from low to high
+ * satisfies this constraint again. Reserving 1M at 0x0260-0x0270 for
+ * the DTB leaves rest of the free RAM to the initrd starting at 0x0270.
+ * Even with the smallest possible CPU-GPU memory split of the CPU getting
+ * only 64M, the remaining 25M starting at 0x0270 should allow quite
+ * large initrds before they start colliding with U-Boot.
+ */
+#ifdef CONFIG_ARM64
+fdt_high=
+initrd_high=
+#else
+fdt_high=
+initrd_high=
+#endif
+kernel_addr_r=0x0008
+scriptaddr=0x0240
+pxefile_addr_r=0x0250
+fdt_addr_r=0x0260
+ramdisk_addr_r=0x0270
+
+boot_targets=mmc usb pxe dhcp
diff --git a/include/configs/rpi.h b/include/configs/rpi.h
index 4160db2d8e1..8e56bdc84a8 100644
--- a/include/configs/rpi.h
+++ b/include/configs/rpi.h
@@ -13,8 +13,6 @@
 #include 
 #endif
 
-/* Architecture, CPU, etc.*/
-
 /* Use SoC timer for AArch32, but architected timer for AArch64 */
 #ifndef CONFIG_ARM64
 #define CFG_SYS_TIMER_RATE 100
@@ -33,102 +31,4 @@
  */
 #define CFG_SYS_SDRAM_SIZE SZ_128M
 
-/* Devices */
-/* LCD */
-
-/* DFU over USB/UDC */
-#ifdef CONFIG_CMD_DFU
-#ifdef CONFIG_ARM64
-#define KERNEL_FILENAME"Image"
-#else
-#define KERNEL_FILENAME"zImage"
-#endif
-
-#define ENV_DFU_SETTINGS \
-   "dfu_alt_info=u-boot.bin fat 0 1;uboot.env fat 0 1;" \
- "config.txt fat 0 1;" \
- KERNEL_FILENAME " fat 0 1\0"
-#else
-#define ENV_DFU_SETTINGS ""
-#endif
-
-/* Console configuration */
-
-/* Environment */
-
-/* Shell */
-
-/* Environment */
-#define ENV_DEVICE_SETTINGS \
-   "stdin=serial,usbkbd\0" \
-   "stdout=serial,vidconsole\0" \
-   "stderr=serial,vidconsole\0"
-
-#ifdef CONFIG_ARM64
-#define FDT_HIGH ""
-#define INITRD_HIGH ""
-#else
-#define FDT_HIGH ""
-#define INITRD_HIGH ""

[PATCH 2/3] arm: rpi: Switch to standard boot

2023-02-19 Thread Simon Glass
Drop use of the distro scripts and use standard boot instead.

We don't need to specify the mmc devices individually, since they are
used in order from 0 to 2, and standard boot uses that order anyway.

Signed-off-by: Simon Glass 
---

 configs/rpi_0_w_defconfig  |  6 +++---
 configs/rpi_2_defconfig|  6 +++---
 configs/rpi_3_32b_defconfig|  6 +++---
 configs/rpi_3_b_plus_defconfig |  6 +++---
 configs/rpi_3_defconfig|  6 +++---
 configs/rpi_4_32b_defconfig|  8 +++
 configs/rpi_4_defconfig|  8 +++
 configs/rpi_arm64_defconfig|  8 +++
 configs/rpi_defconfig  |  6 +++---
 include/configs/rpi.h  | 38 ++
 10 files changed, 32 insertions(+), 66 deletions(-)

diff --git a/configs/rpi_0_w_defconfig b/configs/rpi_0_w_defconfig
index baa8c37810c..ded8b774b95 100644
--- a/configs/rpi_0_w_defconfig
+++ b/configs/rpi_0_w_defconfig
@@ -5,13 +5,13 @@ CONFIG_TEXT_BASE=0x8000
 CONFIG_SYS_MALLOC_F_LEN=0x400
 CONFIG_TARGET_RPI_0_W=y
 CONFIG_NR_DRAM_BANKS=1
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x700
 CONFIG_ENV_SIZE=0x4000
 CONFIG_DEFAULT_DEVICE_TREE="bcm2835-rpi-zero-w"
 CONFIG_SYS_PROMPT="U-Boot> "
 CONFIG_SYS_LOAD_ADDR=0x100
-CONFIG_DISTRO_DEFAULTS=y
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x700
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
diff --git a/configs/rpi_2_defconfig b/configs/rpi_2_defconfig
index baae6d48710..4de65f64ff0 100644
--- a/configs/rpi_2_defconfig
+++ b/configs/rpi_2_defconfig
@@ -6,13 +6,13 @@ CONFIG_TEXT_BASE=0x8000
 CONFIG_SYS_MALLOC_F_LEN=0x400
 CONFIG_TARGET_RPI_2=y
 CONFIG_NR_DRAM_BANKS=1
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x700
 CONFIG_ENV_SIZE=0x4000
 CONFIG_DEFAULT_DEVICE_TREE="bcm2836-rpi-2-b"
 CONFIG_SYS_PROMPT="U-Boot> "
 CONFIG_SYS_LOAD_ADDR=0x100
-CONFIG_DISTRO_DEFAULTS=y
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x700
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
diff --git a/configs/rpi_3_32b_defconfig b/configs/rpi_3_32b_defconfig
index f51f3de5964..df2261fc51d 100644
--- a/configs/rpi_3_32b_defconfig
+++ b/configs/rpi_3_32b_defconfig
@@ -5,13 +5,13 @@ CONFIG_ARCH_BCM283X=y
 CONFIG_TEXT_BASE=0x8000
 CONFIG_TARGET_RPI_3_32B=y
 CONFIG_NR_DRAM_BANKS=1
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x700
 CONFIG_ENV_SIZE=0x4000
 CONFIG_DEFAULT_DEVICE_TREE="bcm2837-rpi-3-b"
 CONFIG_SYS_PROMPT="U-Boot> "
 CONFIG_SYS_LOAD_ADDR=0x100
-CONFIG_DISTRO_DEFAULTS=y
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x700
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
diff --git a/configs/rpi_3_b_plus_defconfig b/configs/rpi_3_b_plus_defconfig
index 8fd74fc1f6c..a19fe42d195 100644
--- a/configs/rpi_3_b_plus_defconfig
+++ b/configs/rpi_3_b_plus_defconfig
@@ -4,13 +4,13 @@ CONFIG_ARCH_BCM283X=y
 CONFIG_TEXT_BASE=0x0008
 CONFIG_TARGET_RPI_3=y
 CONFIG_NR_DRAM_BANKS=1
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7fffe40
 CONFIG_ENV_SIZE=0x4000
 CONFIG_DEFAULT_DEVICE_TREE="bcm2837-rpi-3-b-plus"
 CONFIG_SYS_PROMPT="U-Boot> "
 CONFIG_SYS_LOAD_ADDR=0x100
-CONFIG_DISTRO_DEFAULTS=y
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7fffe40
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
diff --git a/configs/rpi_3_defconfig b/configs/rpi_3_defconfig
index bc1a318db41..7f972ce62d4 100644
--- a/configs/rpi_3_defconfig
+++ b/configs/rpi_3_defconfig
@@ -4,13 +4,13 @@ CONFIG_ARCH_BCM283X=y
 CONFIG_TEXT_BASE=0x0008
 CONFIG_TARGET_RPI_3=y
 CONFIG_NR_DRAM_BANKS=1
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7fffe40
 CONFIG_ENV_SIZE=0x4000
 CONFIG_DEFAULT_DEVICE_TREE="bcm2837-rpi-3-b"
 CONFIG_SYS_PROMPT="U-Boot> "
 CONFIG_SYS_LOAD_ADDR=0x100
-CONFIG_DISTRO_DEFAULTS=y
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7fffe40
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
diff --git a/configs/rpi_4_32b_defconfig b/configs/rpi_4_32b_defconfig
index 5207e561ee7..a1c1c227ebd 100644
--- a/configs/rpi_4_32b_defconfig
+++ b/configs/rpi_4_32b_defconfig
@@ -2,13 +2,14 @@ CONFIG_ARM=y
 CONFIG_ARCH_BCM283X=y
 CONFIG_TEXT_BASE=0x8000
 CONFIG_TARGET_RPI_4_32B=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7fffee0
 CONFIG_ENV_SIZE=0x4000
 CONFIG_DEFAULT_DEVICE_TREE="bcm2711-rpi-4-b"
 CONFIG_SYS_PROMPT="U-Boot> "
+CONFIG_DM_RESET=y
 CONFIG_SYS_LOAD_ADDR=0x100
-CONFIG_DISTRO_DEFAULTS=y
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7fffee0

[PATCH 1/3] bootstd: Add support for booti and bootz

2023-02-19 Thread Simon Glass
Enable these options so that we can boot ARM images in these formats.

Signed-off-by: Simon Glass 
---

 boot/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/boot/Kconfig b/boot/Kconfig
index 5f491625c82..da640a37f4f 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -419,6 +419,8 @@ config BOOTSTD_DEFAULTS
imply CMD_FAT
imply CMD_FS_GENERIC
imply CMD_PART
+   imply CMD_BOOTI if ARM64
+   imply CMD_BOOTZ if ARM && !ARM64
imply CMD_DHCP if NET
imply CMD_MII if NET
imply CMD_PING if NET
-- 
2.39.2.637.g21b0678d19-goog



[PATCH 0/3] rpi: Convert to standard boot

2023-02-19 Thread Simon Glass
This series moves Raspberry Pi boards over to use standard boot.

It also adds a few more default boot options to standard boot, which are
commonly used on ARM boards. These are needed for some distros to boot.

It also moves rpi over to use a text-based environment. Unfortunately it
is not possible to empty the header file due to several CFG options.

Fix the repeated "and and" while we are here.

Note that this reduces code size by about 9KB and rodata by about 4.5KB
for a total image-size saving of about 15KB. This is mostly because
HUSH_PARSER is not enabled anymore and the environment shrinks down by
almost 4KB. Hush is not actually needed anymore, since standard boot does
not use it. Also CMD_SYSBOOT is dropped since standard boot calls the
pxe_utils code directly in that case.


Simon Glass (3):
  bootstd: Add support for booti and bootz
  arm: rpi: Switch to standard boot
  arm: rpi: Switch to a text environment

 board/raspberrypi/rpi/rpi.env  |  77 +++
 boot/Kconfig   |   2 +
 configs/rpi_0_w_defconfig  |   6 +-
 configs/rpi_2_defconfig|   6 +-
 configs/rpi_3_32b_defconfig|   6 +-
 configs/rpi_3_b_plus_defconfig |   6 +-
 configs/rpi_3_defconfig|   6 +-
 configs/rpi_4_32b_defconfig|   8 +-
 configs/rpi_4_defconfig|   8 +-
 configs/rpi_arm64_defconfig|   8 +-
 configs/rpi_defconfig  |   6 +-
 include/configs/rpi.h  | 134 -
 12 files changed, 109 insertions(+), 164 deletions(-)
 create mode 100644 board/raspberrypi/rpi/rpi.env

-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 18/46] event: Add Kconfig options for SPL

2023-02-19 Thread Simon Glass
Add options to enable events in SPL. This is mostly so the code can be
excluded from SPL builds.

Signed-off-by: Simon Glass 
---

Changes in v4:
- Modify to get rid of def_bool
- Adjust Kconfig ordering

 common/Kconfig | 20 
 1 file changed, 20 insertions(+)

diff --git a/common/Kconfig b/common/Kconfig
index e3a5e1be1e9..33c3b1dbf0f 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -631,6 +631,26 @@ config EVENT_DEBUG
  events, such as event-type names. This adds to the code size of
  U-Boot so can be turned off for production builds.
 
+config SPL_EVENT
+   bool  # General-purpose event-handling mechanism in SPL
+   depends on SPL
+   help
+ This adds a framework for general purpose sending and processing of
+ events, to allow interested parties to be alerted when something
+ happens. This is an attempt to stem the flow of weak functions,
+ hooks, functions in board_f.c and board_r.c and the Kconfig options
+ below.
+
+ See doc/develop/event.rst for more information.
+
+config SPL_EVENT_DYNAMIC
+   bool
+   depends on SPL_EVENT && EVENT_DYNAMIC
+   help
+ Enable this to support adding an event spy at runtime, without adding
+ it to the EVENT_SPY() linker list. This increases code size slightly
+ but provides more flexibility for boards and subsystems that need it.
+
 endif # EVENT
 
 config ARCH_EARLY_INIT_R
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 19/46] bootstd: Correct 'VPL' typo

2023-02-19 Thread Simon Glass
Correct a 'VPL' typo in the Kconfig.

Signed-off-by: Simon Glass 
---

Changes in v4:
- Just fix the typo

Changes in v3:
- Correct 'VPL' typo
- Use a consistent format for the comment

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

diff --git a/boot/Kconfig b/boot/Kconfig
index b89916c109c..d646369f55c 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -385,7 +385,7 @@ config BOOTSTD_FULL
as well as the "boot_targets" environment variable
 
 config SPL_BOOTSTD
-   bool "Standard boot support in VPL"
+   bool "Standard boot support in SPL"
depends on SPL && SPL_DM && SPL_OF_CONTROL && SPL_BLK
default y if VPL
help
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 44/46] power: wandboard: Add a missing CONFIG

2023-02-19 Thread Simon Glass
We should enable pmic in SPL since it is used.

Signed-off-by: Simon Glass 
---

Changes in v4:
- Fix 'wanderboard' typo
- Reduce and rename commit

 configs/wandboard_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/wandboard_defconfig b/configs/wandboard_defconfig
index a6baff1e24c..05383f6e47b 100644
--- a/configs/wandboard_defconfig
+++ b/configs/wandboard_defconfig
@@ -71,6 +71,7 @@ CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
 CONFIG_DM_PMIC=y
+CONFIG_SPL_DM_PMIC=y
 CONFIG_DM_PMIC_PFUZE100=y
 CONFIG_DM_SCSI=y
 CONFIG_DM_SERIAL=y
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 22/46] lib: Add VPL options for SHA1 and SHA256

2023-02-19 Thread Simon Glass
Add these options so these algorithms can be used in VPL.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 lib/Kconfig | 20 
 1 file changed, 20 insertions(+)

diff --git a/lib/Kconfig b/lib/Kconfig
index 1c93f523b3a..08318843231 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -579,6 +579,26 @@ config SPL_SHA_PROG_HW_ACCEL
 
 endif
 
+config VPL_SHA1
+   bool "Enable SHA1 support in VPL"
+   depends on VPL
+   default y if SHA1
+   help
+ This option enables support of hashing using SHA1 algorithm.
+ The hash is calculated in software.
+ The SHA1 algorithm produces a 160-bit (20-byte) hash value
+ (digest).
+
+config VPL_SHA256
+   bool "Enable SHA256 support in VPL"
+   depends on VPL
+   default y if SHA256
+   help
+ This option enables support of hashing using SHA256 algorithm.
+ The hash is calculated in software.
+ The SHA256 algorithm produces a 256-bit (32-byte) hash value
+ (digest).
+
 if SHA_HW_ACCEL
 
 config SHA512_HW_ACCEL
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 21/46] env: Allow VPL environment to be nowhere

2023-02-19 Thread Simon Glass
Add an option to put the VPL environment nowhere (not in storage).

Signed-off-by: Simon Glass 
---

(no changes since v1)

 env/Kconfig | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/env/Kconfig b/env/Kconfig
index 6e24eee55f2..2bbe4c466a6 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -860,6 +860,16 @@ config TPL_ENV_IS_IN_FLASH
 
 endif
 
+if VPL_ENV_SUPPORT
+
+config VPL_ENV_IS_NOWHERE
+   bool "VPL Environment is not stored"
+   default y if ENV_IS_NOWHERE
+   help
+ Similar to ENV_IS_NOWHERE, used for VPL environment.
+
+endif  # VPL_ENV_SUPPORT
+
 config USE_BOOTFILE
bool "Add a 'bootfile' environment variable"
help
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 08/46] Correct SPL uses of FSL_ISBC_KEY_EXT

2023-02-19 Thread Simon Glass
This converts 9 usages of this option to the non-SPL form, since there is
no SPL_FSL_ISBC_KEY_EXT defined in Kconfig

Signed-off-by: Simon Glass 
---

(no changes since v1)

 board/freescale/common/fsl_validate.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/board/freescale/common/fsl_validate.c 
b/board/freescale/common/fsl_validate.c
index bfe6357b0d6..78bed122466 100644
--- a/board/freescale/common/fsl_validate.c
+++ b/board/freescale/common/fsl_validate.c
@@ -29,7 +29,7 @@
 #define CHECK_KEY_LEN(key_len) (((key_len) == 2 * KEY_SIZE_BYTES / 4) || \
 ((key_len) == 2 * KEY_SIZE_BYTES / 2) || \
 ((key_len) == 2 * KEY_SIZE_BYTES))
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
 /* Global data structure */
 static struct fsl_secboot_glb glb;
 #endif
@@ -63,7 +63,7 @@ self:
goto self;
 }
 
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
 static u32 check_ie(struct fsl_secboot_img_priv *img)
 {
if (img->hdr.ie_flag & IE_FLAG_MASK)
@@ -188,7 +188,7 @@ static u32 check_srk(struct fsl_secboot_img_priv *img)
 {
 #ifdef CONFIG_ESBC_HDR_LS
/* In LS, No SRK Flag as SRK is always present if IE not present*/
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
return !check_ie(img);
 #endif
return 1;
@@ -278,7 +278,7 @@ static u32 read_validate_single_key(struct 
fsl_secboot_img_priv *img)
 }
 #endif /* CONFIG_ESBC_HDR_LS */
 
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
 
 static void install_ie_tbl(uintptr_t ie_tbl_addr,
struct fsl_secboot_img_priv *img)
@@ -434,7 +434,7 @@ void fsl_secboot_handle_error(int error)
case ERROR_ESBC_CLIENT_HEADER_INVALID_KEY_NUM:
case ERROR_ESBC_CLIENT_HEADER_INV_SRK_ENTRY_KEYLEN:
 #endif
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
/*@fallthrough@*/
case ERROR_ESBC_CLIENT_HEADER_IE_KEY_REVOKED:
case ERROR_ESBC_CLIENT_HEADER_INVALID_IE_NUM_ENTRY:
@@ -571,7 +571,7 @@ static int calc_esbchdr_esbc_hash(struct 
fsl_secboot_img_priv *img)
key_hash = 1;
}
 #endif
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
if (!key_hash && check_ie(img))
key_hash = 1;
 #endif
@@ -705,7 +705,7 @@ static int read_validate_esbc_client_header(struct 
fsl_secboot_img_priv *img)
}
 #endif
 
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
if (!key_found && check_ie(img)) {
ret = read_validate_ie_tbl(img);
if (ret != 0)
@@ -851,7 +851,7 @@ static int secboot_init(struct fsl_secboot_img_priv 
**img_ptr)
return -ENOMEM;
memset(img, 0, sizeof(struct fsl_secboot_img_priv));
 
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
if (glb.ie_addr)
img->ie_addr = glb.ie_addr;
 #endif
@@ -952,7 +952,7 @@ int fsl_secboot_validate(uintptr_t haddr, char 
*arg_hash_str,
else
ret = memcmp(srk_hash, img->img_key_hash, SHA256_BYTES);
 
-#if CONFIG_IS_ENABLED(FSL_ISBC_KEY_EXT)
+#if IS_ENABLED(CONFIG_FSL_ISBC_KEY_EXT)
if (!hash_cmd && check_ie(img))
ret = 0;
 #endif
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 20/46] env: Avoid checking ENV_IS_IN when env disabled

2023-02-19 Thread Simon Glass
This check is not needed when the environment is not enabled, e.g. in
SPL. Add a condition to handle this.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 cmd/nvedit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 7cbc3fd573a..277293679df 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -59,11 +59,13 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #endif
 
+#if CONFIG_IS_ENABLED(ENV_SUPPORT)
 #if!defined(ENV_IS_IN_DEVICE)  && \
!defined(CONFIG_ENV_IS_NOWHERE)
 # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|\
 NAND|NVRAM|ONENAND|SATA|SPI_FLASH|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE
 #endif
+#endif /* ENV_SUPPORT */
 
 /*
  * Maximum expected input data size for import command
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 14/46] Correct SPL use of DM_RNG

2023-02-19 Thread Simon Glass
This converts 1 usage of this option to the non-SPL form, since there is
no SPL_DM_RNG defined in Kconfig

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/vbe_request.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/boot/vbe_request.c b/boot/vbe_request.c
index 45f1d2b7e17..312edfa2bdb 100644
--- a/boot/vbe_request.c
+++ b/boot/vbe_request.c
@@ -36,7 +36,7 @@ static int handle_random_req(ofnode node, int default_size,
u32 size;
int ret;
 
-   if (!CONFIG_IS_ENABLED(DM_RNG))
+   if (!IS_ENABLED(CONFIG_DM_RNG))
return -ENOTSUPP;
 
if (ofnode_read_u32(node, "vbe,size", )) {
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 27/46] sandbox: Tidy up I2C options

2023-02-19 Thread Simon Glass
At present we enable the sandbox I2C driver for all builds. Add a separate
Kconfig option to control this, so that it can be disabled in TPL, where
it is not needed.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/i2c/Kconfig | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 3279fef1eb0..1077c331c30 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -47,6 +47,16 @@ config SPL_DM_I2C
  device (bus child) info is kept as parent platdata. The interface
  is defined in include/i2c.h.
 
+config TPL_DM_I2C
+   bool "Enable Driver Model for I2C drivers in TPL"
+   depends on TPL_DM && DM_I2C
+   help
+ Enable driver model for I2C. The I2C uclass interface: probe, read,
+ write and speed, is implemented with the bus drivers operations,
+ which provide methods for bus setting and data transfer. Each chip
+ device (bus child) info is kept as parent platdata. The interface
+ is defined in include/i2c.h.
+
 config VPL_DM_I2C
bool "Enable Driver Model for I2C drivers in VPL"
depends on VPL_DM && DM_I2C
@@ -508,6 +518,16 @@ config SYS_I2C_ROCKCHIP
 config SYS_I2C_SANDBOX
bool "Sandbox I2C driver"
depends on SANDBOX && DM_I2C
+   default y
+   help
+ Enable I2C support for sandbox. This is an emulation of a real I2C
+ bus. Devices can be attached to the bus using the device tree
+ which specifies the driver to use.  See sandbox.dts as an example.
+
+config SPL_SYS_I2C_SANDBOX
+   bool "Sandbox I2C driver (SPL)"
+   depends on SPL && SANDBOX && DM_I2C
+   default y
help
  Enable I2C support for sandbox. This is an emulation of a real I2C
  bus. Devices can be attached to the bus using the device tree
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 41/46] serial: Support ns16550 driver in TPL

2023-02-19 Thread Simon Glass
Add options for this since they are needed by P1020RDB-PC_NAND.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/serial/Kconfig | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index bb5083201b3..6f40c051604 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -731,6 +731,12 @@ config SPL_SYS_NS16550_SERIAL
default y if SYS_NS16550_SERIAL || ARCH_SUNXI || ARCH_OMAP2PLUS
select SYS_NS16550
 
+config TPL_SYS_NS16550_SERIAL
+   bool "NS16550 UART or compatible legacy driver in TPL"
+   depends on TPL && !TPL_DM_SERIAL
+   default y if SYS_NS16550_SERIAL || ARCH_SUNXI || ARCH_OMAP2PLUS
+   select SYS_NS16550
+
 config SYS_NS16550
bool "NS16550 UART or compatible"
help
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 4/4] patman: Check patches in parallel

2023-02-19 Thread Simon Glass
For large series this can take a while. Run checkpatch in parallel to
try to reduce the time. The checkpatch information is still reported in
sequential order, so a very slow patch at the start can still slow
things down. But overall this gives good results.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/patmanu/checkpatch.py | 46 +
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/tools/patmanu/checkpatch.py b/tools/patmanu/checkpatch.py
index 55d962f536f..1317f50b464 100644
--- a/tools/patmanu/checkpatch.py
+++ b/tools/patmanu/checkpatch.py
@@ -3,6 +3,7 @@
 #
 
 import collections
+import concurrent.futures
 import os
 import re
 import sys
@@ -244,26 +245,31 @@ def check_patches(verbose, args, use_tree):
 error_count, warning_count, check_count = 0, 0, 0
 col = terminal.Color()
 
-for fname in args:
-result = check_patch(fname, verbose, use_tree=use_tree)
-if not result.ok:
-error_count += result.errors
-warning_count += result.warnings
-check_count += result.checks
-print('%d errors, %d warnings, %d checks for %s:' % (result.errors,
-result.warnings, result.checks, col.build(col.BLUE, 
fname)))
-if (len(result.problems) != result.errors + result.warnings +
-result.checks):
-print("Internal error: some problems lost")
-# Python seems to get confused by this
-# pylint: disable=E1133
-for item in result.problems:
-sys.stderr.write(
-get_warning_msg(col, item.get('type', ''),
-item.get('file', ''),
-item.get('line', 0), item.get('msg', 'message')))
-print
-#print(stdout)
+with concurrent.futures.ThreadPoolExecutor(max_workers=16) as executor:
+futures = []
+for fname in args:
+f = executor.submit(check_patch, fname, verbose, use_tree=use_tree)
+futures.append(f)
+
+for fname, f in zip(args, futures):
+result = f.result()
+if not result.ok:
+error_count += result.errors
+warning_count += result.warnings
+check_count += result.checks
+print('%d errors, %d warnings, %d checks for %s:' % 
(result.errors,
+result.warnings, result.checks, col.build(col.BLUE, 
fname)))
+if (len(result.problems) != result.errors + result.warnings +
+result.checks):
+print("Internal error: some problems lost")
+# Python seems to get confused by this
+# pylint: disable=E1133
+for item in result.problems:
+sys.stderr.write(
+get_warning_msg(col, item.get('type', ''),
+item.get('file', ''),
+item.get('line', 0), item.get('msg', 'message')))
+print
 if error_count or warning_count or check_count:
 str = 'checkpatch.pl found %d error(s), %d warning(s), %d checks(s)'
 color = col.GREEN
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 3/4] patman: Run get_maintainer.pl in parallel

2023-02-19 Thread Simon Glass
This script can take ages on some series. Try to limit the time by
using threads. If a few stubborn patches remain, show progress so the
user has some idea what is going on.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/patmanu/func_test.py |  2 ++
 tools/patmanu/series.py| 33 ++---
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/tools/patmanu/func_test.py b/tools/patmanu/func_test.py
index 238fd5b6100..48109ae5725 100644
--- a/tools/patmanu/func_test.py
+++ b/tools/patmanu/func_test.py
@@ -240,6 +240,8 @@ class TestFunctional(unittest.TestCase):
 self.assertEqual('Change log missing for v3', next(lines))
 self.assertEqual('Change log for unknown version v4', next(lines))
 self.assertEqual("Alias 'pci' not found", next(lines))
+while next(lines) != 'Cc processing complete':
+pass
 self.assertIn('Dry run', next(lines))
 self.assertEqual('', next(lines))
 self.assertIn('Send a total of %d patches' % count, next(lines))
diff --git a/tools/patmanu/series.py b/tools/patmanu/series.py
index 8ead87ef53e..e7a5f91da87 100644
--- a/tools/patmanu/series.py
+++ b/tools/patmanu/series.py
@@ -5,8 +5,11 @@
 from __future__ import print_function
 
 import collections
+import concurrent.futures
 import itertools
 import os
+import sys
+import time
 
 from patmanu import get_maintainer
 from patmanu import gitutil
@@ -302,10 +305,34 @@ class Series(dict):
 fd = open(fname, 'w', encoding='utf-8')
 all_ccs = []
 all_skips = set()
+with concurrent.futures.ThreadPoolExecutor(max_workers=16) as executor:
+for i, commit in enumerate(self.commits):
+commit.seq = i
+commit.future = executor.submit(
+self.GetCcForCommit, commit, process_tags, warn_on_error,
+add_maintainers, limit, get_maintainer_script, all_skips)
+
+# Show progress any commits that are taking forever
+lastlen = 0
+while True:
+left = [commit for commit in self.commits
+if not commit.future.done()]
+if not left:
+break
+names = ', '.join(f'{c.seq + 1}:{c.subject}'
+  for c in left[:2])
+out = f'\r{len(left)} remaining: {names}'[:79]
+spaces = ' ' * (lastlen - len(out))
+if lastlen:  # Don't print anything the first time
+print(out, spaces, end='')
+sys.stdout.flush()
+lastlen = len(out)
+time.sleep(.25)
+print(f'\rdone{" " * lastlen}\r', end='')
+print('Cc processing complete')
+
 for commit in self.commits:
-cc = self.GetCcForCommit(commit, process_tags, warn_on_error,
- add_maintainers, limit,
- get_maintainer_script, all_skips)
+cc = commit.future.result()
 all_ccs += cc
 print(commit.patch, '\0'.join(sorted(set(cc))), file=fd)
 self._generated_cc[commit.patch] = cc
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 2/4] patman: Refactor MakeCcFile() into two functions

2023-02-19 Thread Simon Glass
This function is quite long. Moving the handling of a commit into a
separate function. This will make it easier to do the work in parallel.

Update function comments while we are here.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Fix missing 'f' on format string

 tools/patmanu/series.py | 80 -
 1 file changed, 56 insertions(+), 24 deletions(-)

diff --git a/tools/patmanu/series.py b/tools/patmanu/series.py
index f2d415609d2..8ead87ef53e 100644
--- a/tools/patmanu/series.py
+++ b/tools/patmanu/series.py
@@ -234,6 +234,48 @@ class Series(dict):
 str = 'Change log exists, but no version is set'
 print(col.build(col.RED, str))
 
+def GetCcForCommit(self, commit, process_tags, warn_on_error,
+   add_maintainers, limit, get_maintainer_script,
+   all_skips):
+"""Get the email CCs to use with a particular commit
+
+Uses subject tags and get_maintainers.pl script to find people to cc
+on a patch
+
+Args:
+commit (Commit): Commit to process
+process_tags (bool): Process tags as if they were aliases
+warn_on_error (bool): True to print a warning when an alias fails 
to
+match, False to ignore it.
+add_maintainers (bool or list of str): Either:
+True/False to call the get_maintainers to CC maintainers
+List of maintainers to include (for testing)
+limit (int): Limit the length of the Cc list (None if no limit)
+get_maintainer_script (str): The file name of the get_maintainer.pl
+script (or compatible).
+all_skips (set of str): Set of bouncing email address that were
+dropped from the output
+
+Returns:
+list of str: List of email addresses to cc
+"""
+cc = []
+if process_tags:
+cc += gitutil.build_email_list(commit.tags,
+   warn_on_error=warn_on_error)
+cc += gitutil.build_email_list(commit.cc_list,
+   warn_on_error=warn_on_error)
+if type(add_maintainers) == type(cc):
+cc += add_maintainers
+elif add_maintainers:
+cc += get_maintainer.get_maintainer(get_maintainer_script,
+commit.patch)
+all_skips |= set(cc) & set(settings.bounces)
+cc = list(set(cc) - set(settings.bounces))
+if limit is not None:
+cc = cc[:limit]
+return cc
+
 def MakeCcFile(self, process_tags, cover_fname, warn_on_error,
add_maintainers, limit, get_maintainer_script):
 """Make a cc file for us to use for per-commit Cc automation
@@ -241,15 +283,15 @@ class Series(dict):
 Also stores in self._generated_cc to make ShowActions() faster.
 
 Args:
-process_tags: Process tags as if they were aliases
-cover_fname: If non-None the name of the cover letter.
-warn_on_error: True to print a warning when an alias fails to 
match,
-False to ignore it.
-add_maintainers: Either:
+process_tags (bool): Process tags as if they were aliases
+cover_fname (str): If non-None the name of the cover letter.
+warn_on_error (bool): True to print a warning when an alias fails 
to
+match, False to ignore it.
+add_maintainers (bool or list of str): Either:
 True/False to call the get_maintainers to CC maintainers
 List of maintainers to include (for testing)
-limit: Limit the length of the Cc list (None if no limit)
-get_maintainer_script: The file name of the get_maintainer.pl
+limit (int): Limit the length of the Cc list (None if no limit)
+get_maintainer_script (str): The file name of the get_maintainer.pl
 script (or compatible).
 Return:
 Filename of temp file created
@@ -259,28 +301,18 @@ class Series(dict):
 fname = '/tmp/patman.%d' % os.getpid()
 fd = open(fname, 'w', encoding='utf-8')
 all_ccs = []
+all_skips = set()
 for commit in self.commits:
-cc = []
-if process_tags:
-cc += gitutil.build_email_list(commit.tags,
-   warn_on_error=warn_on_error)
-cc += gitutil.build_email_list(commit.cc_list,
-   warn_on_error=warn_on_error)
-if type(add_maintainers) == type(cc):
-cc += add_maintainers
-elif add_maintainers:
-
-cc += get_maintainer.get_maintainer(get_maintainer_script,
-commit.patch)
-for x in set(cc) & 

[PATCH v4 45/46] venice: Simplify conditions for network init

2023-02-19 Thread Simon Glass
The conditions in this code do not align when doing an SPL build with
split config. Use __maybe_unused to avoid needing to be so explicit.

Of course a better solution would be to refactor all of this to avoid
using #ifdef.

Signed-off-by: Simon Glass 
---

(no changes since v1)

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

diff --git a/board/gateworks/venice/venice.c b/board/gateworks/venice/venice.c
index c4d86c26a9b..e6fa7eb3d73 100644
--- a/board/gateworks/venice/venice.c
+++ b/board/gateworks/venice/venice.c
@@ -41,8 +41,7 @@ int board_fit_config_name_match(const char *name)
return -1;
 }
 
-#if (IS_ENABLED(CONFIG_NET))
-static int setup_fec(void)
+static int __maybe_unused setup_fec(void)
 {
struct iomuxc_gpr_base_regs *gpr =
(struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
@@ -58,7 +57,7 @@ static int setup_fec(void)
return 0;
 }
 
-static int setup_eqos(void)
+static int __maybe_unused setup_eqos(void)
 {
struct iomuxc_gpr_base_regs *gpr =
(struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
@@ -71,6 +70,7 @@ static int setup_eqos(void)
return set_clk_eqos(ENET_125MHZ);
 }
 
+#if (IS_ENABLED(CONFIG_NET))
 int board_phy_config(struct phy_device *phydev)
 {
unsigned short val;
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 39/46] net: Add an SPL config for atheros

2023-02-19 Thread Simon Glass
Add a new SPL_PHY_ATHEROS to avoid a build error on am335x_evm with split
config.

Signed-off-by: Simon Glass 
Reviewed-by: Ramon Fried 
---

(no changes since v1)

 drivers/net/phy/Kconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 5eaff053a09..6806e3c0903 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -106,6 +106,9 @@ config PHY_AQUANTIA_FW_NAME
 config PHY_ATHEROS
bool "Atheros Ethernet PHYs support"
 
+config SPL_PHY_ATHEROS
+   bool "Atheros Ethernet PHYs support (SPL)"
+
 config PHY_BROADCOM
bool "Broadcom Ethernet PHYs support"
 
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 37/46] freescale: Drop old pre-DM_ETH code

2023-02-19 Thread Simon Glass
This is used by ls1021atwr_sdcard_ifc_SECURE_BOOT with split config, but
is not needed anymore, since Ethernet migration is complete. Drop it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/arm/cpu/armv7/ls102xa/fdt.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/arch/arm/cpu/armv7/ls102xa/fdt.c b/arch/arm/cpu/armv7/ls102xa/fdt.c
index 599b7e18ef3..a5c5c780ae8 100644
--- a/arch/arm/cpu/armv7/ls102xa/fdt.c
+++ b/arch/arm/cpu/armv7/ls102xa/fdt.c
@@ -25,11 +25,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 void ft_fixup_enet_phy_connect_type(void *fdt)
 {
-#ifdef CONFIG_DM_ETH
struct udevice *dev;
-#else
-   struct eth_device *dev;
-#endif
struct tsec_private *priv;
const char *enet_path, *phy_path;
char enet[16];
@@ -37,12 +33,8 @@ void ft_fixup_enet_phy_connect_type(void *fdt)
int phy_node;
int i = 0;
uint32_t ph;
-#ifdef CONFIG_DM_ETH
char *name[3] = { "ethernet@2d1", "ethernet@2d5",
  "ethernet@2d9" };
-#else
-   char *name[3] = { "eTSEC1", "eTSEC2", "eTSEC3" };
-#endif
 
for (; i < ARRAY_SIZE(name); i++) {
dev = eth_get_dev_by_name(name[i]);
@@ -53,11 +45,7 @@ void ft_fixup_enet_phy_connect_type(void *fdt)
continue;
}
 
-#ifdef CONFIG_DM_ETH
priv = dev_get_priv(dev);
-#else
-   priv = dev->priv;
-#endif
if (priv->flags & TSEC_SGMII)
continue;
 
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 1/4] patman: Drop an incorrect comment about git am

2023-02-19 Thread Simon Glass
Patman does not do this anymore, so drop the comment.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Fix 'uncorrect' typo in subject

 tools/patmanu/control.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/patmanu/control.py b/tools/patmanu/control.py
index b1e23870d9d..6ff94776da9 100644
--- a/tools/patmanu/control.py
+++ b/tools/patmanu/control.py
@@ -85,7 +85,7 @@ def check_patches(series, patch_files, run_checkpatch, 
verbose, use_tree):
 # Do a few checks on the series
 series.DoChecks()
 
-# Check the patches, and run them through 'git am' just to be sure
+# Check the patches
 if run_checkpatch:
 ok = checkpatch.check_patches(verbose, patch_files, use_tree)
 else:
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 0/4] patman: Speed up some operations

2023-02-19 Thread Simon Glass
This little series updates patman to run the get_maintainer.py script in
parallel for each commit. It also does the same with checkpatch.

In some cases this can make a dramatic different to the speed.

Changes in v2:
- Fix 'uncorrect' typo in subject
- Fix missing 'f' on format string

Simon Glass (4):
  patman: Drop an incorrect comment about git am
  patman: Refactor MakeCcFile() into two functions
  patman: Run get_maintainer.pl in parallel
  patman: Check patches in parallel

 tools/patmanu/checkpatch.py |  46 +---
 tools/patmanu/control.py|   2 +-
 tools/patmanu/func_test.py  |   2 +
 tools/patmanu/series.py | 107 
 4 files changed, 112 insertions(+), 45 deletions(-)

-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 46/46] command: Don't allow commands in SPL

2023-02-19 Thread Simon Glass
At present we compile commands into U-Boot SPL even though they cannot
be used. This wastes space. Adjust the condition to avoid this.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Add a new patch to disallow commands in SPL

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

diff --git a/include/command.h b/include/command.h
index 0db48980624..1b018cb98e7 100644
--- a/include/command.h
+++ b/include/command.h
@@ -376,7 +376,7 @@ int cmd_source_script(ulong addr, const char *fit_uname, 
const char *confname);
U_BOOT_SUBCMDS_DO_CMD(_cmdname) \
U_BOOT_SUBCMDS_COMPLETE(_cmdname)
 
-#ifdef CONFIG_CMDLINE
+#if CONFIG_IS_ENABLED(CMDLINE)
 #define U_BOOT_CMDREP_MKENT_COMPLETE(_name, _maxargs, _cmd_rep,
\
 _usage, _help, _comp)  \
{ #_name, _maxargs, _cmd_rep, cmd_discard_repeatable,   \
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 23/46] x86: Use string functions for all 32-bit builds

2023-02-19 Thread Simon Glass
At present these are not included in SPL. They do add to code size but
are a bit faster, so adjust the setting to add them.

Signed-off-by: Simon Glass 
---

(no changes since v1)

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

diff --git a/arch/x86/include/asm/string.h b/arch/x86/include/asm/string.h
index c15b264a5c0..0254a022160 100644
--- a/arch/x86/include/asm/string.h
+++ b/arch/x86/include/asm/string.h
@@ -14,7 +14,7 @@ extern char *strrchr(const char *s, int c);
 #undef __HAVE_ARCH_STRCHR
 extern char *strchr(const char *s, int c);
 
-#ifdef CONFIG_X86_64
+#if CONFIG_IS_ENABLED(X86_64)
 
 #undef __HAVE_ARCH_MEMCPY
 extern void *memcpy(void *, const void *, __kernel_size_t);
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index a6f22441474..ea7ff2bcf38 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -4,7 +4,7 @@
 # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 
 obj-y  += bdinfo.o
-ifndef CONFIG_X86_64
+ifndef CONFIG_$(SPL_TPL_)X86_64
 ifndef CONFIG_TPL_BUILD
 obj-y += bios.o
 obj-y += bios_asm.o
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 28/46] fixdep: Add support for VPL

2023-02-19 Thread Simon Glass
Add VPL files into the mix so that we can fix up the dependencies there.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 scripts/basic/fixdep.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 5ced0f6b069..3d40bd7ee25 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -421,6 +421,8 @@ int main(int argc, char *argv[])
strcpy(tmp_buf, "SPL_");
else if (!strncmp(target, "tpl/", 4))
strcpy(tmp_buf, "TPL_");
+   else if (!strncmp(target, "vpl/", 4))
+   strcpy(tmp_buf, "VPL_");
/* end U-Boot hack */
 
xprintf("cmd_%s := %s\n\n", target, cmdline);
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 34/46] x86: Fix up use of X86_32BIT_INIT and X86_64 options

2023-02-19 Thread Simon Glass
Drop the invalid SPL_ in a CONFIG_IS_ENABLED() usage. Use the correct
X86_64 option in msr.h since SPL may be 32-bit when U-Bout proper is
not.

Signed-off-by: Simon Glass 
---

Changes in v4:
- Reduce and rename commit

 arch/x86/cpu/qemu/qemu.c   | 2 +-
 arch/x86/include/asm/msr.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/cpu/qemu/qemu.c b/arch/x86/cpu/qemu/qemu.c
index e54082df7f9..274978c023b 100644
--- a/arch/x86/cpu/qemu/qemu.c
+++ b/arch/x86/cpu/qemu/qemu.c
@@ -97,7 +97,7 @@ static void qemu_chipset_init(void)
}
 }
 
-#if !CONFIG_IS_ENABLED(SPL_X86_32BIT_INIT)
+#if CONFIG_IS_ENABLED(X86_32BIT_INIT)
 int arch_cpu_init(void)
 {
post_code(POST_CPU_INIT);
diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index 27764fc56cb..eb3ddde8c07 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -59,7 +59,7 @@ static inline unsigned long long native_read_tscp(unsigned 
int *aux)
  * edx:eax, while for x86_64 it doesn't mean rdx:rax or edx:eax. Instead,
  * it means rax *or* rdx.
  */
-#ifdef CONFIG_X86_64
+#if CONFIG_IS_ENABLED(X86_64)
 #define DECLARE_ARGS(val, low, high)   unsigned low, high
 #define EAX_EDX_VAL(val, low, high)((low) | ((u64)(high) << 32))
 #define EAX_EDX_ARGS(val, low, high)   "a" (low), "d" (high)
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 16/46] moveconfig: Various minor improvements

2023-02-19 Thread Simon Glass
It turns out that the conf_noproper file is not neeed, since if an option
does not appear in U-Boot proper we can just omit it from the autoconf for
that build. Drop it.

Also add more control over what is output from the tool.

Add this in here. It should be added to the previous series (splb).

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/moveconfig.py | 91 +
 1 file changed, 43 insertions(+), 48 deletions(-)

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index b3ac2672737..ec2afa92e46 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -1833,13 +1833,20 @@ def scan_src_files(fname_dict, all_uses, fname_uses):
 
 MODE_NORMAL, MODE_SPL, MODE_PROPER = range(3)
 
-def do_scan_source(path, do_update, show_conflicts, do_commit):
+def do_scan_source(path, do_update, do_update_source, show_conflicts,
+   do_commit):
 """Scan the source tree for Kconfig inconsistencies
 
 Args:
 path (str): Path to source tree
-do_update (bool): True to write to scripts/kconf_... files
-show_conflicts (bool): True to show conflicts
+do_update (bool): True to write to scripts/conf_nospl file
+do_update_source (bool): True to update source to remove invalid use of
+   CONFIG_IS_ENABLED()
+show_conflicts (bool): True to show conflicts between the source code
+   and the Kconfig (such as missing options, or options which imply an
+   SPL option that does not exist)
+do_commit (bool): Create commits to remove use of SPL_TPL_ and
+   CONFIG_IS_ENABLED macros when there is no SPL symbol.
 """
 def is_not_proper(name):
 for prefix in SPL_PREFIXES:
@@ -1977,9 +1984,7 @@ def do_scan_source(path, do_update, show_conflicts, 
do_commit):
 
 dirname, leaf = os.path.split(fname)
 root, ext = os.path.splitext(leaf)
-#if dirname != '' or root != 'Makefile':
-#continue
-if (dirname.startswith('test') or
+if (dirname.startswith('test/') or
 dirname.startswith('lib/efi_selftest')):
 # Ignore test code since it is mostly only for sandbox
 pass
@@ -2011,38 +2016,25 @@ def do_scan_source(path, do_update, show_conflicts, 
do_commit):
 finish_file(last_fname, rest_list)
 return mk_dict, src_dict
 
-def check_mk_missing(all_uses, spl_not_found, proper_not_found):
+def check_missing(all_uses, spl_not_found, proper_not_found,
+  show_conflicts):
 # Make sure we know about all the options in Makefiles
-print('\nCONFIG options present in Makefiles but not Kconfig:')
 not_found = check_not_found(all_uses, MODE_NORMAL)
-show_uses(not_found)
+if show_conflicts:
+print('\nCONFIG options present in source but not Kconfig:')
+show_uses(not_found)
 
-print('\nCONFIG options present in Makefiles but not Kconfig (SPL):')
 not_found = check_not_found(all_uses, MODE_SPL)
-show_uses(not_found)
 spl_not_found |= set(is_not_proper(key) or key for key in 
not_found.keys())
+if show_conflicts:
+print('\nCONFIG options present in source but not Kconfig (SPL):')
+show_uses(not_found)
 
-print('\nCONFIG options used as Proper in Makefiles but without a 
non-SPL_ variant:')
 not_found = check_not_found(all_uses, MODE_PROPER)
-show_uses(not_found)
-proper_not_found |= set(key for key in not_found.keys())
-
-def check_src_missing(all_uses, spl_not_found, proper_not_found):
-# Make sure we know about all the options in source files
-print('\nCONFIG options present in source but not Kconfig:')
-not_found = check_not_found(all_uses, MODE_NORMAL)
-show_uses(not_found)
-
-print('\nCONFIG options present in source but not Kconfig (SPL):')
-not_found = check_not_found(all_uses, MODE_SPL)
-show_uses(not_found)
-spl_not_found |= set(is_not_proper(key) or key
- for key in not_found.keys())
-
-print('\nCONFIG options used as Proper in source but without a 
non-SPL_ variant:')
-not_found = check_not_found(all_uses, MODE_PROPER)
-show_uses(not_found)
 proper_not_found |= set(key for key in not_found.keys())
+if show_conflicts:
+print('\nCONFIG options used as Proper in source but without a 
non-SPL_ variant:')
+show_uses(not_found)
 
 def show_summary(spl_not_found, proper_not_found):
 print('\nCONFIG options used as SPL but without an SPL_ variant:')
@@ -2053,19 +2045,24 @@ def do_scan_source(path, do_update, show_conflicts, 
do_commit):
 for item in sorted(proper_not_found):
 print(f'   {item}')
 
-def write_update(spl_not_found, proper_not_found):
-with 

[PATCH v4 26/46] sandbox: Use the generic VPL option to enable VPL

2023-02-19 Thread Simon Glass
Avoid using CONFIG_SANDBOX_VPL since we have a generic option which works
just as well.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/sandbox/dts/sandbox.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index e9b6745d2db..12d3eff5fa7 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -103,6 +103,6 @@
 #include "cros-ec-keyboard.dtsi"
 #include "sandbox_pmic.dtsi"
 
-#ifdef CONFIG_SANDBOX_VPL
+#if IS_ENABLED(CONFIG_SUPPORT_VPL)
 #include "sandbox_vpl.dtsi"
 #endif
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 31/46] test: Add SPL versions of the TEST_KCONFIG options

2023-02-19 Thread Simon Glass
These are needed since we need a separate value in SPL and Proper.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 test/lib/Kconfig | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/test/lib/Kconfig b/test/lib/Kconfig
index dbb03e4a36f..134cbb85b83 100644
--- a/test/lib/Kconfig
+++ b/test/lib/Kconfig
@@ -18,6 +18,24 @@ config TEST_KCONFIG_VALUE
int "Value associated with the option"
depends on TEST_KCONFIG_ENABLE
help
- This is the value whgch is present if TEST_KCONFIG_ENABLE is enabled.
+ This is the value which is present if TEST_KCONFIG_ENABLE is enabled.
+
+config SPL_TEST_KCONFIG
+   bool "Enable detection of Kconfig macro errors (SPL)"
+   help
+ This is used to test that the IF_ENABLED_INT() macro causes a build 
error
+ if the value is used when the CONFIG Is not enabled.
+
+config SPL_TEST_KCONFIG_ENABLE
+   bool "Option to enable (SPL)"
+   help
+ This is the option that controls whether the value is present.
+
+config SPL_TEST_KCONFIG_VALUE
+   int "Value associated with the option (SPL"
+   depends on SPL_TEST_KCONFIG_ENABLE
+   help
+ This is the value which is present if SPL_TEST_KCONFIG_ENABLE is
+ enabled.
 
 endif # SANDBOX
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 25/46] sandbox: Tidy up RTC options

2023-02-19 Thread Simon Glass
At present we enable the sandbox RTC driver for all builds. Add a separate
Kconfig option to control this, so that it can be disabled in TPL, where
it is not needed.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Fix a transitory build error with sandbox_spl

 arch/sandbox/dts/sandbox.dts   |  2 +-
 arch/sandbox/dts/sandbox.dtsi  |  6 +++---
 arch/sandbox/include/asm/rtc.h |  2 +-
 drivers/rtc/Kconfig| 18 ++
 drivers/rtc/Makefile   |  4 ++--
 5 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index a4c1b8f6cb7..e9b6745d2db 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -76,7 +76,7 @@
clock-frequency = <40>;
pinctrl-names = "default";
pinctrl-0 = <_i2c0>;
-   bootph-all;
+   bootph-pre-ram;
};
 
pcic: pci@0 {
diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index 1f446e62e16..30a305c4d20 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -115,7 +115,7 @@
reg = <0x43>;
compatible = "sandbox-rtc";
sandbox,emul = <>;
-   bootph-all;
+   bootph-pre-ram;
};
sandbox_pmic: sandbox_pmic {
reg = <0x40>;
@@ -126,7 +126,7 @@
};
 
i2c_emul: emul {
-   bootph-all;
+   bootph-pre-ram;
reg = <0xff>;
compatible = "sandbox,i2c-emul-parent";
emul_eeprom: emul-eeprom {
@@ -136,7 +136,7 @@
#emul-cells = <0>;
};
emul0: emul0 {
-   bootph-all;
+   bootph-pre-ram;
compatible = "sandbox,i2c-rtc-emul";
#emul-cells = <0>;
};
diff --git a/arch/sandbox/include/asm/rtc.h b/arch/sandbox/include/asm/rtc.h
index 025cd6c67cf..bf3ac5ea1ec 100644
--- a/arch/sandbox/include/asm/rtc.h
+++ b/arch/sandbox/include/asm/rtc.h
@@ -40,7 +40,7 @@ enum {
  * @reg:   Register values
  */
 struct sandbox_i2c_rtc_plat_data {
-#if CONFIG_IS_ENABLED(OF_PLATDATA)
+#if CONFIG_IS_ENABLED(OF_PLATDATA) && IS_ENABLED(CONFIG_RTC_SANDBOX)
struct dtd_sandbox_i2c_rtc_emul dtplat;
 #endif
long base_time;
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 35b6ed4d7c7..fcfda2847c8 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -231,6 +231,24 @@ config RTC_M41T62
  Enable driver for ST's M41T62 compatible RTC devices (like RV-4162).
  It is a serial (I2C) real-time clock (RTC) with alarm.
 
+config RTC_SANDBOX
+   bool "Enable sandbox RTC driver"
+   depends on SANDBOX && DM_RTC
+   default y
+   help
+ Enable the sandbox RTC driver. This driver connects to the RTC
+ emulator and is used to test the RTC uclasses and associated code,
+ as well as the I2C subsystem.
+
+config SPL_RTC_SANDBOX
+   bool "Enable sandbox RTC driver (SPL)"
+   depends on SANDBOX && SPL_DM_RTC
+   default y
+   help
+ Enable the sandbox RTC driver. This driver connects to the RTC
+ emulator and is used to test the RTC uclasses and associated code,
+ as well as the I2C subsystem.
+
 config RTC_STM32
bool "Enable STM32 RTC driver"
depends on DM_RTC
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 447551e15aa..b6c9029c8f0 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -16,7 +16,7 @@ obj-$(CONFIG_RTC_DS3231) += ds3231.o
 obj-$(CONFIG_RTC_DS3232) += ds3232.o
 obj-$(CONFIG_RTC_EMULATION) += emul_rtc.o
 obj-$(CONFIG_RTC_HT1380) += ht1380.o
-obj-$(CONFIG_SANDBOX) += i2c_rtc_emul.o
+obj-$(CONFIG_$(SPL_TPL_)RTC_SANDBOX) += i2c_rtc_emul.o
 obj-$(CONFIG_RTC_ISL1208) += isl1208.o
 obj-$(CONFIG_RTC_M41T62) += m41t62.o
 obj-$(CONFIG_RTC_MC13XXX) += mc13xxx-rtc.o
@@ -35,6 +35,6 @@ obj-$(CONFIG_RTC_RX8025) += rx8025.o
 obj-$(CONFIG_RTC_RX8010SJ) += rx8010sj.o
 obj-$(CONFIG_RTC_S35392A) += s35392a.o
 obj-$(CONFIG_RTC_STM32) += stm32_rtc.o
-obj-$(CONFIG_SANDBOX) += sandbox_rtc.o
+obj-$(CONFIG_$(SPL_TPL_)RTC_SANDBOX) += sandbox_rtc.o
 obj-$(CONFIG_RTC_ABX80X) += abx80x.o
 obj-$(CONFIG_RTC_ZYNQMP) += zynqmp_rtc.o
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 24/46] lib: Fix build condition for tiny-printf

2023-02-19 Thread Simon Glass
This should be checking for any SPL build. Drop the use of SPL_TPL_ since
it is not necessary and will not work with split config.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 lib/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Makefile b/lib/Makefile
index a282e40258c..10aa7ac0298 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -127,7 +127,7 @@ obj-$(CONFIG_LIB_UUID) += uuid.o
 obj-$(CONFIG_LIB_RAND) += rand.o
 obj-y += panic.o
 
-ifeq ($(CONFIG_$(SPL_TPL_)BUILD),y)
+ifeq ($(CONFIG_SPL_BUILD),y)
 # SPL U-Boot may use full-printf, tiny-printf or none at all
 ifdef CONFIG_$(SPL_TPL_)USE_TINY_PRINTF
 obj-$(CONFIG_$(SPL_TPL_)SPRINTF) += tiny-printf.o
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 35/46] Add VPL options for BLOBLIST

2023-02-19 Thread Simon Glass
We can use this feature in VPL, so add some options for it. Also fix a
typo in the SPL help while we are here.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/Kconfig | 31 ++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/common/Kconfig b/common/Kconfig
index 33c3b1dbf0f..a6b10a251a0 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1063,7 +1063,7 @@ choice
prompt "Bloblist location in TPL"
help
  Select the location of the bloblist, via various means. Typically
- you should use the same value for SPL as for U-Boot, since they need
+ you should use the same value for TPL as for U-Boot, since they need
  to look in the same place. But if BLOBLIST_ALLOC is used, then a
  fresh bloblist will be created each time, since there is no shared
  address (between phases) for the bloblist.
@@ -1086,6 +1086,35 @@ endchoice
 
 endif # TPL_BLOBLIST
 
+if VPL_BLOBLIST
+
+choice
+   prompt "Bloblist location in VPL"
+   help
+ Select the location of the bloblist, via various means. Typically
+ you should use the same value for VPL as for U-Boot, since they need
+ to look in the same place. But if BLOBLIST_ALLOC is used, then a
+ fresh bloblist will be created each time, since there is no shared
+ address (between phases) for the bloblist.
+
+config VPL_BLOBLIST_FIXED
+   bool "Place bloblist at a fixed address in memory"
+   help
+ Select this to used a fixed memory address for the bloblist. If the
+ bloblist exists at this address from a previous phase, it used as is.
+ If not it is created at this address in VPL.
+
+config VPL_BLOBLIST_ALLOC
+   bool "Allocate bloblist"
+   help
+ Allocate the bloblist using malloc(). This avoids the need to
+ specify a fixed address on systems where this is unknown or can
+ change at runtime.
+
+endchoice
+
+endif # VPL_BLOBLIST
+
 endmenu
 
 source "common/spl/Kconfig"
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 42/46] dm: Add a TPL symbol for simple-bus

2023-02-19 Thread Simon Glass
This is used in some x86 code, so add a symbol for it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/core/Kconfig | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig
index 6fc8854b574..0f755aa702e 100644
--- a/drivers/core/Kconfig
+++ b/drivers/core/Kconfig
@@ -301,6 +301,13 @@ config SPL_SIMPLE_BUS
  Supports the 'simple-bus' driver, which is used on some systems
  in SPL.
 
+config TPL_SIMPLE_BUS
+   bool "Support simple-bus driver in TPL"
+   depends on TPL_DM && TPL_OF_CONTROL
+   help
+ Supports the 'simple-bus' driver, which is used on some systems
+ in TPL.
+
 config SIMPLE_BUS_CORRECT_RANGE
bool "Decode the 'simple-bus'  by honoring the #address-cells 
and #size-cells"
depends on SIMPLE_BUS
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 36/46] rockchip: Avoid checking environment without ENV_SUPPORT

2023-02-19 Thread Simon Glass
With split config, this causes a build error in SPL where the environment
may not be enabled. It affects two rk3399 boards. Add a condition.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 board/theobroma-systems/puma_rk3399/puma-rk3399.c | 2 +-
 board/theobroma-systems/ringneck_px30/ringneck-px30.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c 
b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
index 97f398bd754..34839dcb9f1 100644
--- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c
+++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
@@ -136,7 +136,7 @@ int mmc_get_env_dev(void)
return CONFIG_SYS_MMC_ENV_DEV;
 }
 
-#if !IS_ENABLED(CONFIG_ENV_IS_NOWHERE)
+#if IS_ENABLED(CONFIG_ENV_SUPPORT) && !IS_ENABLED(CONFIG_ENV_IS_NOWHERE)
 #error Please enable CONFIG_ENV_IS_NOWHERE
 #endif
 
diff --git a/board/theobroma-systems/ringneck_px30/ringneck-px30.c 
b/board/theobroma-systems/ringneck_px30/ringneck-px30.c
index 47d1a40ef7c..9eb2fcfc48f 100644
--- a/board/theobroma-systems/ringneck_px30/ringneck-px30.c
+++ b/board/theobroma-systems/ringneck_px30/ringneck-px30.c
@@ -118,7 +118,7 @@ int mmc_get_env_dev(void)
return CONFIG_SYS_MMC_ENV_DEV;
 }
 
-#if !IS_ENABLED(CONFIG_ENV_IS_NOWHERE)
+#if IS_ENABLED(CONFIG_ENV_SUPPORT) && !IS_ENABLED(CONFIG_ENV_IS_NOWHERE)
 #error Please enable CONFIG_ENV_IS_NOWHERE
 #endif
 
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 40/46] freescale: Fix odd use of ESDHCI_QUIRK_BROKEN_TIMEOUT_VALUE

2023-02-19 Thread Simon Glass
This is not a CONFIG option so we should not be using IS_ENABLED() on it,
particularly not when it is not defined to anything, so shows up as
calling IS_ENABLED() with no arguments.

Just check it normally.

This fixes a build error with split config on T2080QDS.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/mmc/fsl_esdhc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index d506698..7215f61f468 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -325,8 +325,9 @@ static int esdhc_setup_data(struct fsl_esdhc_priv *priv, 
struct mmc *mmc,
(timeout == 4 || timeout == 8 || timeout == 12))
timeout++;
 
-   if (IS_ENABLED(ESDHCI_QUIRK_BROKEN_TIMEOUT_VALUE))
-   timeout = 0xE;
+#ifdef ESDHCI_QUIRK_BROKEN_TIMEOUT_VALUE
+   timeout = 0xE;
+#endif
 
esdhc_clrsetbits32(>sysctl, SYSCTL_TIMEOUT_MASK, timeout << 16);
 
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 38/46] imx: Use SATA instead of CMD_SATA

2023-02-19 Thread Simon Glass
This causes a build failure on mx6cuboxi with split config, since CMD_SATA
shows up as enabled in SPl (because there is no SPL_CMD_SATA).

The condition is wrong anyway, so change it to use SATA instead.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 board/solidrun/mx6cuboxi/mx6cuboxi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c 
b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 7c44379ec4a..cb14c2f30c9 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -275,7 +275,7 @@ int board_early_init_f(void)
 {
setup_iomux_uart();
 
-#ifdef CONFIG_CMD_SATA
+#ifdef CONFIG_SATA
setup_sata();
 #endif
setup_fec();
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 29/46] fixdep: Refactor to make testing easier

2023-02-19 Thread Simon Glass
Move the config parsing into a separate function so that it is possible
to write tests for the function.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 scripts/basic/fixdep.c | 87 ++
 1 file changed, 54 insertions(+), 33 deletions(-)

diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 3d40bd7ee25..a49d35ba5f6 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -236,47 +236,68 @@ static int str_ends_with(const char *s, int slen, const 
char *sub)
return !memcmp(s + slen - sublen, sub, sublen);
 }
 
-static void parse_config_file(const char *p)
+static const char *parse_config_line(const char *p, const char **endp)
 {
const char *q, *r;
-   const char *start = p;
 
-   while ((p = strstr(p, "CONFIG_"))) {
-   if (p > start && (isalnum(p[-1]) || p[-1] == '_')) {
-   p += 7;
-   continue;
-   }
-   p += 7;
+   p = strstr(p, "CONFIG_");
+   if (!p) {
+   *endp = NULL;
+   return NULL;
+   }
+   if ((isalnum(p[-1]) || p[-1] == '_')) {
+   *endp = p + 7;
+   return NULL;
+   }
+   p += 7;
+   q = p;
+   while (isalnum(*q) || *q == '_')
+   q++;
+   if (str_ends_with(p, q - p, "_MODULE"))
+   r = q - 7;
+   else
+   r = q;
+   /*
+* U-Boot also handles
+*   CONFIG_IS_ENABLED(...)
+*   CONFIG_VAL(...)
+*/
+   if ((q - p == 10 && !memcmp(p, "IS_ENABLED(", 11)) ||
+   (q - p == 3 && !memcmp(p, "VAL(", 4))) {
+   p = q + 1;
q = p;
while (isalnum(*q) || *q == '_')
q++;
-   if (str_ends_with(p, q - p, "_MODULE"))
-   r = q - 7;
-   else
-   r = q;
-   /*
-* U-Boot also handles
-*   CONFIG_IS_ENABLED(...)
-*   CONFIG_VAL(...)
-*/
-   if ((q - p == 10 && !memcmp(p, "IS_ENABLED(", 11)) ||
-   (q - p == 3 && !memcmp(p, "VAL(", 4))) {
-   p = q + 1;
-   q = p;
-   while (isalnum(*q) || *q == '_')
-   q++;
-   r = q;
-   if (r > p && tmp_buf[0]) {
-   memcpy(tmp_buf + 4, p, r - p);
-   r = tmp_buf + 4 + (r - p);
-   p = tmp_buf;
-   }
+   r = q;
+   if (r > p && tmp_buf[0]) {
+   memcpy(tmp_buf + 4, p, r - p);
+   r = tmp_buf + 4 + (r - p);
+   p = tmp_buf;
}
-   /* end U-Boot hack */
+   }
+   /* end U-Boot hack */
+   *endp = r;
+
+   if (r > p)
+   return p;
 
-   if (r > p)
-   use_config(p, r - p);
-   p = q;
+   return NULL;
+}
+
+static void parse_config_file(const char *base)
+{
+   const char *p;
+
+   if (!*base)
+   return;
+   p = base + 1;
+   while (p) {
+   const char *out, *end;
+
+   out = parse_config_line(p, );
+   if (out)
+   use_config(out, end - out);
+   p = end;
}
 }
 
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 32/46] lib: Add an SPL config for LIB_UUID

2023-02-19 Thread Simon Glass
This is selected by PARTITION_UUIDS which has a separate option for SPL.
Add an SPL option for LIB_UUID also, so that we can keep them consistent.

Also add one for PARTITION_TYPE_GUID to avoid a build error in part_efi.c
which wants to call a uuid function in SPL.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 disk/Kconfig | 8 
 lib/Kconfig  | 4 
 2 files changed, 12 insertions(+)

diff --git a/disk/Kconfig b/disk/Kconfig
index c9b9dbaf1a6..817b7c8c76d 100644
--- a/disk/Kconfig
+++ b/disk/Kconfig
@@ -149,6 +149,7 @@ config SPL_PARTITION_UUIDS
bool "Enable support of UUID for partition in SPL"
depends on SPL_PARTITIONS
default y if SPL_EFI_PARTITION
+   select SPL_LIB_UUID
 
 config PARTITION_TYPE_GUID
bool "Enable support of GUID for partition type"
@@ -157,4 +158,11 @@ config PARTITION_TYPE_GUID
  Activate the configuration of GUID type
  for EFI partition
 
+config SPL_PARTITION_TYPE_GUID
+   bool "Enable support of GUID for partition type (SPL)"
+   depends on SPL_EFI_PARTITION
+   help
+ Activate the configuration of GUID type
+ for EFI partition
+
 endmenu
diff --git a/lib/Kconfig b/lib/Kconfig
index 08318843231..4278b240554 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -74,6 +74,10 @@ config HAVE_PRIVATE_LIBGCC
 config LIB_UUID
bool
 
+config SPL_LIB_UUID
+   depends on SPL
+   bool
+
 config SEMIHOSTING
bool "Support semihosting"
depends on ARM || RISCV
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 33/46] test: Tidy up sandbox handling in test-main

2023-02-19 Thread Simon Glass
This is pretty messy at present since it relies on a SPL_SANDBOX option
that does not exist. Use the normal options instead, so that it will work
with split config.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 test/test-main.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/test/test-main.c b/test/test-main.c
index ea959f4e859..b3c30d92937 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -46,14 +46,14 @@ enum fdtchk_t {
  */
 static enum fdtchk_t fdt_action(void)
 {
-   /* Do a copy for sandbox (but only the U-Boot build, not SPL) */
-   if (CONFIG_IS_ENABLED(SANDBOX))
-   return FDTCHK_COPY;
-
/* For sandbox SPL builds, do nothing */
-   if (IS_ENABLED(CONFIG_SANDBOX))
+   if (IS_ENABLED(CONFIG_SANDBOX) && IS_ENABLED(CONFIG_SPL_BUILD))
return FDTCHK_NONE;
 
+   /* Do a copy for sandbox (but only the U-Boot build, not SPL) */
+   if (IS_ENABLED(CONFIG_SANDBOX))
+   return FDTCHK_COPY;
+
/* For all other boards, do a checksum */
return FDTCHK_CHECKSUM;
 }
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 43/46] x86: coral: Add missing TPL options

2023-02-19 Thread Simon Glass
Some options should be enabled which are missing. Fix this.

Signed-off-by: Simon Glass 
---

Changes in v4:
- Reduce and rename commit

 configs/chromebook_coral_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/chromebook_coral_defconfig 
b/configs/chromebook_coral_defconfig
index 401506e2193..f5995f22004 100644
--- a/configs/chromebook_coral_defconfig
+++ b/configs/chromebook_coral_defconfig
@@ -87,6 +87,7 @@ CONFIG_TFTP_TSIZE=y
 CONFIG_USE_ROOTPATH=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
+CONFIG_TPL_SIMPLE_BUS=y
 CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
@@ -96,6 +97,8 @@ CONFIG_SYS_I2C_DW=y
 CONFIG_MISC=y
 CONFIG_CROS_EC=y
 CONFIG_CROS_EC_LPC=y
+CONFIG_SPL_P2SB=y
+CONFIG_TPL_P2SB=y
 CONFIG_SPI_FLASH_WINBOND=y
 # CONFIG_X86_PCH7 is not set
 # CONFIG_X86_PCH9 is not set
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 30/46] fixdep: Add some tests for parse_config_line()

2023-02-19 Thread Simon Glass
Add tests for this code to cover the basic cases.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 scripts/basic/fixdep.c | 73 ++
 1 file changed, 73 insertions(+)

diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index a49d35ba5f6..fe8180ab4e7 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -425,11 +425,84 @@ static void parse_dep_file(char *m, const char *target)
xprintf("$(deps_%s):\n", target);
 }
 
+#define CHECKP(expect, got)\
+   if (expect != got) { \
+   fprintf(stderr, "Test failed at line %d: expect %ld, got 
%ld\n", \
+   __LINE__, expect - buf, got - buf); \
+   return 1; \
+   }
+
+#define CHECK(expect, got) \
+   if (expect != got) { \
+   fprintf(stderr, "Test failed at line %d: expect %p, got %p\n", \
+   __LINE__, expect, got); \
+   return 1; \
+   }
+
+static int run_tests(void)
+{
+   const char *out, *end;
+   char buf_s[40], *buf = buf_s + 1;
+
+   /* make sure the previous char doesn't look like part of the CONFIG */
+   buf_s[0] = ' ';
+
+   strcpy(buf, "");
+   out = parse_config_line(buf, );
+   CHECK(NULL, out);
+   CHECK(NULL, end);
+
+   strcpy(buf, "nothing");
+   out = parse_config_line(buf, );
+   CHECK(NULL, out);
+   CHECK(NULL, end);
+
+   strcpy(buf, "CONFIG_OPTION_MORE");
+   out = parse_config_line(buf, );
+   CHECKP(buf + 7, out);
+   CHECKP(buf + 18, end);
+
+   strcpy(buf, "some CONFIG_OPTION_MORE");
+   out = parse_config_line(buf, );
+   CHECKP(buf + 12, out);
+   CHECKP(buf + 23, end);
+
+   strcpy(buf, "some CONFIG_OPTION_MORE here");
+   out = parse_config_line(buf, );
+   CHECKP(buf + 12, out);
+   CHECKP(buf + 23, end);
+
+   strcpy(buf, "CONFIG_OPTION_MODULE");
+   out = parse_config_line(buf, );
+   CHECKP(buf + 7, out);
+   CHECKP(buf + 13, end);
+
+   strcpy(buf, "CONFIG_IS_ENABLED(FRED)");
+   out = parse_config_line(buf, );
+   CHECKP(buf + 18, out);
+   CHECKP(buf + 22, end);
+
+   strcpy(buf, "CONFIG_VAL(MARY)");
+   out = parse_config_line(buf, );
+   CHECKP(buf + 11, out);
+   CHECKP(buf + 15, end);
+
+   return 0;
+}
+
 int main(int argc, char *argv[])
 {
const char *depfile, *target, *cmdline;
void *buf;
 
+   if (argc == 2 && !strcmp("-t", argv[1])) {
+   if (run_tests()) {
+   fprintf(stderr, "Tests failed\n");
+   return 1;
+   }
+   printf("Tests passed\n");
+   return 0;
+   }
if (argc != 4)
usage();
 
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 15/46] lib: Add a Kconfig for SPL_BZIP2

2023-02-19 Thread Simon Glass
This is implicitly used in the source and seems useful, so add it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 lib/Kconfig | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/lib/Kconfig b/lib/Kconfig
index 83e5edd73b0..1c93f523b3a 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -727,6 +727,12 @@ config ZSTD_LIB_MINIFY
 
 endif
 
+config SPL_BZIP2
+   bool "Enable bzip2 decompression support for SPL build"
+   depends on SPL
+   help
+ This enables support for bzip2 compression algorithm for SPL boot.
+
 config SPL_LZ4
bool "Enable LZ4 decompression support in SPL"
depends on SPL
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 13/46] boot: Add Kconfigs for BOOTMETH_VBE_REQUEST

2023-02-19 Thread Simon Glass
Allow this to be enabled separately in U-Boot proper and in SPL, since
it is not needed in SPL.

Signed-off-by: Simon Glass 
---

Changes in v4:
- Avoid use of def_bool

 boot/Kconfig  | 20 
 boot/Makefile |  3 ++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/boot/Kconfig b/boot/Kconfig
index 5f491625c82..b89916c109c 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -528,6 +528,26 @@ config VPL_BOOTMETH_VBE
 
 if BOOTMETH_VBE
 
+config BOOTMETH_VBE_REQUEST
+   bool "Support for serving VBE OS requests"
+   default y
+   help
+ Enables support for looking that the requests made by the
+ Operating System being booted. These requests result in additions to
+ the device tree /chosen node, added during the device tree fixup
+ phase.
+
+config SPL_BOOTMETH_VBE_REQUEST
+   bool "Support for serving VBE OS requests (SPL)"
+   depends on SPL
+   help
+ Enables support for looking that the requests made by the
+ Operating System being booted. These requests result in additions to
+ the device tree /chosen node, added during the device tree fixup
+ phase.
+
+ This is only useful if you are booting an OS direct from SPL.
+
 config BOOTMETH_VBE_SIMPLE
bool "Bootdev support for VBE 'simple' method"
default y
diff --git a/boot/Makefile b/boot/Makefile
index b9a12236798..88193a1b60e 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -52,7 +52,8 @@ endif
 
 obj-$(CONFIG_$(SPL_TPL_)EXPO) += expo.o scene.o scene_menu.o
 
-obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE) += vbe.o vbe_request.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE) += vbe.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE_REQUEST) += vbe_request.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE_SIMPLE) += vbe_simple.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE_SIMPLE_FW) += vbe_simple_fw.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE_SIMPLE_OS) += vbe_simple_os.o
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 12/46] Correct SPL uses of PHY_FIXED

2023-02-19 Thread Simon Glass
This converts 3 usages of this option to the non-SPL form, since there is
no SPL_PHY_FIXED defined in Kconfig

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/net/mvneta.c | 4 ++--
 net/mdio-uclass.c| 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 0fbfad11d45..24933473fa0 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -815,7 +815,7 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
 
/* Enable PHY polling in hardware if not in fixed-link mode */
-   if (!CONFIG_IS_ENABLED(PHY_FIXED) ||
+   if (!IS_ENABLED(CONFIG_PHY_FIXED) ||
pp->phydev->phy_id != PHY_FIXED_ID) {
mvreg_write(pp, MVNETA_PHY_ADDR, pp->phydev->addr);
 
@@ -1176,7 +1176,7 @@ static void mvneta_adjust_link(struct udevice *dev)
 * be added). Also, why is ADVERT_FC enabled if we don't enable
 * inband AN at all?
 */
-   if (CONFIG_IS_ENABLED(PHY_FIXED) &&
+   if (IS_ENABLED(CONFIG_PHY_FIXED) &&
pp->phydev->phy_id == PHY_FIXED_ID)
val = MVNETA_GMAC_IB_BYPASS_AN_EN |
  MVNETA_GMAC_SET_FC_EN |
diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
index d80037d0ac7..e758cc66d7e 100644
--- a/net/mdio-uclass.c
+++ b/net/mdio-uclass.c
@@ -175,7 +175,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct 
udevice *ethdev,
struct phy_device *phy;
ofnode phynode;
 
-   if (CONFIG_IS_ENABLED(PHY_FIXED) &&
+   if (IS_ENABLED(CONFIG_PHY_FIXED) &&
ofnode_phy_is_fixed_link(dev_ofnode(ethdev), )) {
phy = phy_connect(NULL, 0, ethdev, interface);
goto out;
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 10/46] Correct SPL use of PG_WCOM_UBOOT_UPDATE_SUPPORTED

2023-02-19 Thread Simon Glass
This converts 1 usage of this option to the non-SPL form, since there is
no SPL_PG_WCOM_UBOOT_UPDATE_SUPPORTED defined in Kconfig

Signed-off-by: Simon Glass 
Aleksandar Gerasimovski 
---

(no changes since v1)

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

diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index 8c282f9952a..991022ac833 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -78,7 +78,7 @@ int set_km_env(void)
return 0;
 }
 
-#if CONFIG_IS_ENABLED(PG_WCOM_UBOOT_UPDATE_SUPPORTED)
+#if IS_ENABLED(CONFIG_PG_WCOM_UBOOT_UPDATE_SUPPORTED)
 #if   ((!IS_ENABLED(CONFIG_PG_WCOM_UBOOT_BOOTPACKAGE) && \
!IS_ENABLED(CONFIG_PG_WCOM_UBOOT_UPDATE)) || \
(IS_ENABLED(CONFIG_PG_WCOM_UBOOT_BOOTPACKAGE) && \
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 11/46] Correct SPL use of PHY_CADENCE_SIERRA

2023-02-19 Thread Simon Glass
This converts 1 usage of this option to the non-SPL form, since there is
no SPL_PHY_CADENCE_SIERRA defined in Kconfig

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/phy/cadence/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/phy/cadence/Makefile b/drivers/phy/cadence/Makefile
index af63b32d9f5..c247feb8262 100644
--- a/drivers/phy/cadence/Makefile
+++ b/drivers/phy/cadence/Makefile
@@ -1,2 +1,2 @@
-obj-$(CONFIG_$(SPL_)PHY_CADENCE_SIERRA)+= phy-cadence-sierra.o
+obj-$(CONFIG_PHY_CADENCE_SIERRA)   += phy-cadence-sierra.o
 obj-$(CONFIG_$(SPL_)PHY_CADENCE_TORRENT) += phy-cadence-torrent.o
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 03/46] sh4: Drop unused twl6030 driver

2023-02-19 Thread Simon Glass
This is not used. Drop the driver and Kconfig option.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/input/Makefile  |  1 -
 drivers/input/twl6030.c | 47 -
 2 files changed, 48 deletions(-)
 delete mode 100644 drivers/input/twl6030.c

diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 14c0ea73254..71f315adf6f 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -14,5 +14,4 @@ obj-$(CONFIG_APPLE_SPI_KEYB) += apple_spi_kbd.o
 obj-$(CONFIG_I8042_KEYB) += i8042.o
 obj-$(CONFIG_TEGRA_KEYBOARD) += input.o tegra-kbc.o
 obj-$(CONFIG_TWL4030_INPUT) += twl4030.o
-obj-$(CONFIG_TWL6030_INPUT) += twl6030.o
 endif
diff --git a/drivers/input/twl6030.c b/drivers/input/twl6030.c
deleted file mode 100644
index 76bd3488fc6..000
--- a/drivers/input/twl6030.c
+++ /dev/null
@@ -1,47 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * TWL6030 input
- *
- * Copyright (C) 2016 Paul Kocialkowski 
- */
-
-#include 
-
-int twl6030_input_power_button(void)
-{
-   u8 value;
-
-   twl6030_i2c_read_u8(TWL6030_CHIP_PM, TWL6030_STS_HW_CONDITIONS, );
-
-   /* Power button is active low. */
-   if (value & TWL6030_STS_HW_CONDITIONS_PWRON)
-   return 0;
-
-   return 1;
-}
-
-int twl6030_input_charger(void)
-{
-   u8 value;
-
-   twl6030_i2c_read_u8(TWL6030_CHIP_CHARGER, TWL6030_CONTROLLER_STAT1,
-   );
-
-   if (value & TWL6030_CONTROLLER_STAT1_VAC_DET)
-   return 1;
-
-   return 0;
-}
-
-int twl6030_input_usb(void)
-{
-   u8 value;
-
-   twl6030_i2c_read_u8(TWL6030_CHIP_CHARGER, TWL6030_CONTROLLER_STAT1,
-   );
-
-   if (value & TWL6030_CONTROLLER_STAT1_VBUS_DET)
-   return 1;
-
-   return 0;
-}
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 04/46] moveconfig: Update to detect / correct missing SPL Kconfigs

2023-02-19 Thread Simon Glass
This adds quite a few more features, all designed to detect problems with
Kconfig options and their use. It can find options mentioned in the source
code which are not in the Kconfig and vice versa. It can convert SPL
usages of non-SPL Kconfig options (i.e. changing CONFIG_IS_ENABLED() to
IS_ENABLED() and CONFIG_$(SPL)_FOO to CONFIG_FOO, creating commits
automatically if requested.

These features are only useful for code clean-up, not for normal
development.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Rebase to previous series

 tools/moveconfig.py | 599 +---
 1 file changed, 456 insertions(+), 143 deletions(-)

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index c4d72ede368..b3ac2672737 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -20,6 +20,7 @@ import doctest
 import filecmp
 import fnmatch
 import glob
+import io
 import multiprocessing
 import os
 import queue
@@ -118,6 +119,16 @@ def check_clean_directory():
 if os.path.exists(fname):
 sys.exit("source tree is not clean, please run 'make mrproper'")
 
+def write_commit(msg):
+"""Create a new commit with all modified files
+
+Args:
+msg (str): Commit message
+"""
+subprocess.call(['git', 'add', '-u'])
+rc = subprocess.call(['git', 'commit', '-s', '-m', msg])
+return rc == 0
+
 def get_make_cmd():
 """Get the command name of GNU Make.
 
@@ -1606,30 +1617,59 @@ def prefix_config(cfg):
 return op + cfg
 
 
-RE_MK_CONFIGS = re.compile('CONFIG_(\$\(SPL_(?:TPL_)?\))?([A-Za-z0-9_]*)')
-RE_IFDEF = re.compile('(ifdef|ifndef)')
-RE_C_CONFIGS = re.compile('CONFIG_([A-Za-z0-9_]*)')
-RE_CONFIG_IS = re.compile('CONFIG_IS_ENABLED\(([A-Za-z0-9_]*)\)')
+RE_MK_CONFIGS = re.compile(r'CONFIG_(\$\(SPL_(?:TPL_)?\))?([A-Za-z0-9_]*)')
+
+# Makefile ifdefs: this only handles 'else' on its own line, so not
+# 'else ifeq ...', for example
+RE_IF = 
re.compile(r'^(ifdef|ifndef|endif|ifeq|ifneq|else)([^,]*,([^,]*)\))?.*$')
+
+# Normal CONFIG options in C
+RE_C_CONFIGS = re.compile(r'CONFIG_([A-Za-z0-9_]*)')
+
+# CONFIG_IS_ENABLED() construct
+RE_CONFIG_IS = re.compile(r'CONFIG_IS_ENABLED\(([A-Za-z0-9_]*)\)')
+
+# Preprocessor #if/#ifdef directives, etc.
+RE_IFDEF = 
re.compile(r'^\s*#\s*(ifdef|ifndef|endif|if|elif|else)\s*(?:#.*)?(.*)$')
 
 class ConfigUse:
-def __init__(self, cfg, is_spl, fname, rest):
+"""Holds information about a use of a CONFIG option"""
+def __init__(self, cfg, is_spl, conds, fname, rest, is_mk):
+"""Set up a new use of a CONFIG option
+
+Args:
+cfg (str): Config option, without the CONFIG_
+is_spl (bool): True if it indicates an SPL option, i.e. has a
+$(SPL_) or similar, False if not
+conds (list of str): List of conditions for this use, e.g.
+['SPL_BUILD']
+fname (str): Filename contining the use
+rest (str): Entire line from the file
+is_mk (bool): True if this is in a Makefile, False if not
+"""
 self.cfg = cfg
 self.is_spl = is_spl
+self.conds = list(c for c in conds if '(NONE)' not in c)
 self.fname = fname
 self.rest = rest
+self.is_mk = is_mk
 
 def __hash__(self):
 return hash((self.cfg, self.is_spl))
 
-def scan_makefiles(fnames):
+def __str__(self):
+return (f'ConfigUse({self.cfg}, is_spl={self.is_spl}, '
+f'is_mk={self.is_mk}, fname={self.fname}, rest={self.rest}')
+
+def scan_makefiles(fname_dict):
 """Scan Makefiles looking for Kconfig options
 
 Looks for uses of CONFIG options in Makefiles
 
 Args:
-fnames (list of tuple):
-str: Makefile filename where the option was found
-str: Line of the Makefile
+fname_dict (dict lines):
+key: Makefile filename where the option was found
+value: List of str lines of the Makefile
 
 Returns:
 tuple:
@@ -1646,46 +1686,81 @@ def scan_makefiles(fnames):
 ('$(SPL_)', 'MARY')
 >>> RE_MK_CONFIGS.search('CONFIG_$(SPL_TPL_)MARY').groups()
 ('$(SPL_TPL_)', 'MARY')
+>>> RE_IF.match('ifdef CONFIG_SPL_BUILD').groups()
+('ifdef', None, None)
+>>> RE_IF.match('endif # CONFIG_SPL_BUILD').groups()
+('endif', None, None)
+>>> RE_IF.match('endif').groups()
+('endif', None, None)
+>>> RE_IF.match('else').groups()
+('else', None, None)
 """
 all_uses = collections.defaultdict(list)
 fname_uses = {}
-for fname, rest in fnames:
-m_iter = RE_MK_CONFIGS.finditer(rest)
-found = False
-for m in m_iter:
-found = True
-real_opt = m.group(2)
-if real_opt == '':
-continue
-is_spl = False
-if m.group(1):
-is_spl = True
-use = ConfigUse(real_opt, is_spl, fname, rest)
-if fname 

[PATCH v4 09/46] Correct SPL uses of MULTIPLEXER

2023-02-19 Thread Simon Glass
This converts 3 usages of this option to the non-SPL form, since there is
no SPL_MULTIPLEXER defined in Kconfig

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

(no changes since v3)

Changes in v3:
- Move the option down to the non-SPL part of drivers/Makefile

 drivers/Makefile | 2 +-
 drivers/mux/Makefile | 2 +-
 include/mux.h| 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/Makefile b/drivers/Makefile
index 15d19d0c8a3..58be410135d 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -18,7 +18,6 @@ obj-$(CONFIG_$(SPL_TPL_)INPUT) += input/
 obj-$(CONFIG_$(SPL_TPL_)LED) += led/
 obj-$(CONFIG_$(SPL_TPL_)MMC) += mmc/
 obj-y += mtd/
-obj-$(CONFIG_$(SPL_)MULTIPLEXER) += mux/
 obj-$(CONFIG_$(SPL_TPL_)ETH) += net/
 obj-$(CONFIG_$(SPL_TPL_)PCH) += pch/
 obj-$(CONFIG_$(SPL_TPL_)PCI) += pci/
@@ -87,6 +86,7 @@ obj-$(CONFIG_FASTBOOT) += fastboot/
 obj-$(CONFIG_FWU_MDATA) += fwu-mdata/
 obj-y += misc/
 obj-$(CONFIG_MMC) += mmc/
+obj-$(CONFIG_MULTIPLEXER) += mux/
 obj-$(CONFIG_NVME) += nvme/
 obj-$(CONFIG_PCI_ENDPOINT) += pci_endpoint/
 obj-y += dfu/
diff --git a/drivers/mux/Makefile b/drivers/mux/Makefile
index 78ebf04c7a9..d4e24789d33 100644
--- a/drivers/mux/Makefile
+++ b/drivers/mux/Makefile
@@ -3,5 +3,5 @@
 # (C) Copyright 2019
 # Jean-Jacques Hiblot 
 
-obj-$(CONFIG_$(SPL_)MULTIPLEXER) += mux-uclass.o
+obj-$(CONFIG_MULTIPLEXER) += mux-uclass.o
 obj-$(CONFIG_$(SPL_)MUX_MMIO) += mmio.o
diff --git a/include/mux.h b/include/mux.h
index 9f809912742..c92d887591e 100644
--- a/include/mux.h
+++ b/include/mux.h
@@ -23,7 +23,7 @@
 struct udevice;
 struct mux_control;
 
-#if CONFIG_IS_ENABLED(MULTIPLEXER)
+#if IS_ENABLED(CONFIG_MULTIPLEXER)
 /**
  * mux_control_states() - Query the number of multiplexer states.
  * @mux: The mux-control to query.
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 07/46] Correct SPL uses of DISPLAY_AER_FULL

2023-02-19 Thread Simon Glass
This converts 2 usages of this option to the non-SPL form, since there is
no SPL_DISPLAY_AER_FULL defined in Kconfig

Signed-off-by: Simon Glass 
---

(no changes since v1)

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

diff --git a/drivers/sysreset/sysreset_mpc83xx.c 
b/drivers/sysreset/sysreset_mpc83xx.c
index c9a03266595..ca48328f7b5 100644
--- a/drivers/sysreset/sysreset_mpc83xx.c
+++ b/drivers/sysreset/sysreset_mpc83xx.c
@@ -107,7 +107,7 @@ static int print_83xx_arb_event(bool force, char *buf, int 
size)
if (!force && !gd->arch.arbiter_event_address)
return 0;
 
-   if (CONFIG_IS_ENABLED(DISPLAY_AER_FULL)) {
+   if (IS_ENABLED(CONFIG_DISPLAY_AER_FULL)) {
res = snprintf(buf, size,
   "Arbiter Event Status:\n"
   "%s: 0x%08lX\n"
@@ -184,7 +184,7 @@ static int mpc83xx_sysreset_get_status(struct udevice *dev, 
char *buf, int size)
 * TODO(mario@gdsys.cc): Move this into a dedicated
 *   arbiter driver
 */
-   if (CONFIG_IS_ENABLED(DISPLAY_AER_FULL) ||
+   if (IS_ENABLED(CONFIG_DISPLAY_AER_FULL) ||
IS_ENABLED(CONFIG_DISPLAY_AER_BRIEF)) {
/*
 * If there was a bus monitor reset event, we force the arbiter
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 05/46] bootstd: Disable QFW bootmeth in SPL

2023-02-19 Thread Simon Glass
Move this Makefile line into the non-SPL area so we don't have to reply
on the SPL_TPL_ macro.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Add new patch to disable QFW bootmeth in SPL

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

diff --git a/boot/Makefile b/boot/Makefile
index 5424b6fafcc..b9a12236798 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_CMD_BOOTZ) += bootm.o bootm_os.o
 obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
 
 obj-$(CONFIG_PXE_UTILS) += pxe_utils.o
+obj-$(CONFIG_QFW) += bootmeth_qfw.o
 
 endif
 
@@ -26,7 +27,6 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO) += bootmeth_distro.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO_PXE) += bootmeth_pxe.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) += bootmeth_efi.o
-obj-$(CONFIG_$(SPL_TPL_)QFW) += bootmeth_qfw.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SANDBOX) += bootmeth_sandbox.o
 obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SCRIPT) += bootmeth_script.o
 ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 06/46] Correct SPL uses of ARCH_MVEBU

2023-02-19 Thread Simon Glass
This converts 2 usages of this option to the non-SPL form, since there is
no SPL_ARCH_MVEBU defined in Kconfig

Signed-off-by: Simon Glass 
---

(no changes since v1)

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

diff --git a/drivers/mmc/mv_sdhci.c b/drivers/mmc/mv_sdhci.c
index 336ebf14102..20049981473 100644
--- a/drivers/mmc/mv_sdhci.c
+++ b/drivers/mmc/mv_sdhci.c
@@ -64,7 +64,7 @@ int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 
min_clk, u32 quirks)
host->ops = _ops;
 #endif
 
-   if (CONFIG_IS_ENABLED(ARCH_MVEBU)) {
+   if (IS_ENABLED(CONFIG_ARCH_MVEBU)) {
/* Configure SDHCI MBUS mbus bridge windows */
sdhci_mvebu_mbus_config((void __iomem *)regbase);
}
@@ -103,7 +103,7 @@ static int mv_sdhci_probe(struct udevice *dev)
if (ret)
return ret;
 
-   if (CONFIG_IS_ENABLED(ARCH_MVEBU)) {
+   if (IS_ENABLED(CONFIG_ARCH_MVEBU)) {
/* Configure SDHCI MBUS mbus bridge windows */
sdhci_mvebu_mbus_config(host->ioaddr);
}
-- 
2.39.2.637.g21b0678d19-goog



Re: [PATCH v4 00/50] More tidy-ups of Kconfig options

2023-02-19 Thread Simon Glass
Hi,

On Sun, 19 Feb 2023 at 16:45, Simon Glass  wrote:
>
> This series was split out of the old 'split config' splc series. It
> contains clean-up patches which do not depend on split config.
>
> This is available at u-boot-dm/spld-working
>
> The remaining patches will move into a new 'splg' series (G for Good).
>
> [1] https://patchwork.ozlabs.org/project/uboot/list/?series=341504=*
>
> Changes in v4:
> - Avoid use of def_bool
> - Modify to get rid of def_bool
> - Adjust Kconfig ordering
> - Just fix the typo
> - Reduce and rename commit
> - Reduce and rename commit
> - Fix 'wanderboard' typo
> - Reduce and rename commit

Please ignore this one.

Regards,
Simon


[PATCH v4 02/46] mtd: Drop unused CONFIG_ONENAND_U_BOOT

2023-02-19 Thread Simon Glass
This option does not exist, so the Makefile rule does nothing. Drop it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Makefile b/Makefile
index 54f894dab84..20608b6a800 100644
--- a/Makefile
+++ b/Makefile
@@ -956,7 +956,6 @@ endif
 # Always append INPUTS so that arch config.mk's can add custom ones
 INPUTS-y += u-boot.srec u-boot.bin u-boot.sym System.map binary_size_check
 
-INPUTS-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin
 ifeq ($(CONFIG_SPL_FSL_PBL),y)
 INPUTS-$(CONFIG_RAMBOOT_PBL) += u-boot-with-spl-pbl.bin
 else
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v4 01/46] mtd: Drop unused kb9202_nand driver

2023-02-19 Thread Simon Glass
This is not used since time out of mind.

Drop the driver and Kconfig option.

Signed-off-by: Simon Glass 
Acked-by: Michael Trimarchi 
---

(no changes since v1)

 drivers/mtd/nand/raw/Makefile  |   1 -
 drivers/mtd/nand/raw/kb9202_nand.c | 134 -
 2 files changed, 135 deletions(-)
 delete mode 100644 drivers/mtd/nand/raw/kb9202_nand.c

diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile
index 666323e2219..add2b4cf655 100644
--- a/drivers/mtd/nand/raw/Makefile
+++ b/drivers/mtd/nand/raw/Makefile
@@ -56,7 +56,6 @@ obj-$(CONFIG_NAND_DENALI) += denali.o
 obj-$(CONFIG_NAND_DENALI_DT) += denali_dt.o
 obj-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_nand.o
 obj-$(CONFIG_NAND_FSL_IFC) += fsl_ifc_nand.o
-obj-$(CONFIG_NAND_KB9202) += kb9202_nand.o
 obj-$(CONFIG_NAND_KIRKWOOD) += kirkwood_nand.o
 obj-$(CONFIG_NAND_KMETER1) += kmeter1_nand.o
 obj-$(CONFIG_NAND_LPC32XX_MLC) += lpc32xx_nand_mlc.o
diff --git a/drivers/mtd/nand/raw/kb9202_nand.c 
b/drivers/mtd/nand/raw/kb9202_nand.c
deleted file mode 100644
index 9d26532c780..000
--- a/drivers/mtd/nand/raw/kb9202_nand.c
+++ /dev/null
@@ -1,134 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2006
- * KwikByte 
- *
- * (C) Copyright 2009
- * Matthias Kaehlcke 
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-/*
- *  hardware specific access to control-lines
- */
-
-#define MASK_ALE(1 << 22)   /* our ALE is A22 */
-#define MASK_CLE(1 << 21)   /* our CLE is A21 */
-
-#define KB9202_NAND_NCE (1 << 28) /* EN* on D28 */
-#define KB9202_NAND_BUSY (1 << 29) /* RB* on D29 */
-
-#define KB9202_SMC2_NWS (1 << 2)
-#define KB9202_SMC2_TDF (1 << 8)
-#define KB9202_SMC2_RWSETUP (1 << 24)
-#define KB9202_SMC2_RWHOLD (1 << 29)
-
-/*
- * Board-specific function to access device control signals
- */
-static void kb9202_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int 
ctrl)
-{
-   struct nand_chip *this = mtd_to_nand(mtd);
-
-   if (ctrl & NAND_CTRL_CHANGE) {
-   ulong IO_ADDR_W = (ulong) this->IO_ADDR_W;
-
-   /* clear ALE and CLE bits */
-   IO_ADDR_W &= ~(MASK_ALE | MASK_CLE);
-
-   if (ctrl & NAND_CLE)
-   IO_ADDR_W |= MASK_CLE;
-
-   if (ctrl & NAND_ALE)
-   IO_ADDR_W |= MASK_ALE;
-
-   this->IO_ADDR_W = (void *) IO_ADDR_W;
-
-   if (ctrl & NAND_NCE)
-   writel(KB9202_NAND_NCE, AT91C_PIOC_CODR);
-   else
-   writel(KB9202_NAND_NCE, AT91C_PIOC_SODR);
-   }
-
-   if (cmd != NAND_CMD_NONE)
-   writeb(cmd, this->IO_ADDR_W);
-}
-
-
-/*
- * Board-specific function to access the device ready signal.
- */
-static int kb9202_nand_ready(struct mtd_info *mtd)
-{
-   return readl(AT91C_PIOC_PDSR) & KB9202_NAND_BUSY;
-}
-
-
-/*
- * Board-specific NAND init.  Copied from include/linux/mtd/nand.h for 
reference.
- *
- * struct nand_chip - NAND Private Flash Chip Data
- * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the 
flash device
- * @IO_ADDR_W: [BOARDSPECIFIC] address to write the 8 I/O lines of the 
flash device
- * @hwcontrol: [BOARDSPECIFIC] hardwarespecific function for accesing 
control-lines
- * @dev_ready: [BOARDSPECIFIC] hardwarespecific function for accesing 
device ready/busy line
- * If set to NULL no access to ready/busy is available and 
the ready/busy information
- * is read from the chip status register
- * @enable_hwecc:  [BOARDSPECIFIC] function to enable (reset) hardware ecc 
generator. Must only
- * be provided if a hardware ECC is available
- * @eccmode:   [BOARDSPECIFIC] mode of ecc, see defines
- * @chip_delay:[BOARDSPECIFIC] chip dependent delay for 
transfering data from array to read regs (tR)
- * @options:   [BOARDSPECIFIC] various chip options. They can partly 
be set to inform nand_scan about
- * special functionality. See the defines for further 
explanation
-*/
-/*
- * This routine initializes controller and GPIOs.
- */
-int board_nand_init(struct nand_chip *nand)
-{
-   unsigned int value;
-
-   nand->ecc.mode = NAND_ECC_SOFT;
-   nand->cmd_ctrl = kb9202_nand_hwcontrol;
-   nand->dev_ready = kb9202_nand_ready;
-
-   /* in case running outside of bootloader */
-   writel(1 << AT91C_ID_PIOC, AT91C_PMC_PCER);
-
-   /* setup nand flash access (allow ample margin) */
-   /* 4 wait states, 1 setup, 1 hold, 1 float for 8-bit device */
-   writel(AT91C_SMC2_WSEN | KB9202_SMC2_NWS | KB9202_SMC2_TDF |
-   AT91C_SMC2_DBW_8 | KB9202_SMC2_RWSETUP | KB9202_SMC2_RWHOLD,
-   AT91C_SMC_CSR3);
-
-   /* enable internal NAND controller */
-   value = readl(AT91C_EBI_CSA);
-   value |= 

[PATCH v4 00/46] More tidy-ups of Kconfig options

2023-02-19 Thread Simon Glass
This series was split out of the old 'split config' splc series. It
contains clean-up patches which do not depend on split config.

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

The remaining patches will move into a new 'splg' series (G for Good).

[1] https://patchwork.ozlabs.org/project/uboot/list/?series=341504=*

Changes in v4:
- Avoid use of def_bool
- Modify to get rid of def_bool
- Adjust Kconfig ordering
- Just fix the typo
- Reduce and rename commit
- Reduce and rename commit
- Fix 'wanderboard' typo
- Reduce and rename commit

Changes in v3:
- Add new patch to disable QFW bootmeth in SPL
- Move the option down to the non-SPL part of drivers/Makefile
- Correct 'VPL' typo
- Use a consistent format for the comment
- Fix a transitory build error with sandbox_spl
- Add a new patch to disallow commands in SPL

Changes in v2:
- Rebase to previous series

Simon Glass (46):
  mtd: Drop unused kb9202_nand driver
  mtd: Drop unused CONFIG_ONENAND_U_BOOT
  sh4: Drop unused twl6030 driver
  moveconfig: Update to detect / correct missing SPL Kconfigs
  bootstd: Disable QFW bootmeth in SPL
  Correct SPL uses of ARCH_MVEBU
  Correct SPL uses of DISPLAY_AER_FULL
  Correct SPL uses of FSL_ISBC_KEY_EXT
  Correct SPL uses of MULTIPLEXER
  Correct SPL use of PG_WCOM_UBOOT_UPDATE_SUPPORTED
  Correct SPL use of PHY_CADENCE_SIERRA
  Correct SPL uses of PHY_FIXED
  boot: Add Kconfigs for BOOTMETH_VBE_REQUEST
  Correct SPL use of DM_RNG
  lib: Add a Kconfig for SPL_BZIP2
  moveconfig: Various minor improvements
  sandbox: Expand size for VPL image
  event: Add Kconfig options for SPL
  bootstd: Correct 'VPL' typo
  env: Avoid checking ENV_IS_IN when env disabled
  env: Allow VPL environment to be nowhere
  lib: Add VPL options for SHA1 and SHA256
  x86: Use string functions for all 32-bit builds
  lib: Fix build condition for tiny-printf
  sandbox: Tidy up RTC options
  sandbox: Use the generic VPL option to enable VPL
  sandbox: Tidy up I2C options
  fixdep: Add support for VPL
  fixdep: Refactor to make testing easier
  fixdep: Add some tests for parse_config_line()
  test: Add SPL versions of the TEST_KCONFIG options
  lib: Add an SPL config for LIB_UUID
  test: Tidy up sandbox handling in test-main
  x86: Fix up use of X86_32BIT_INIT and X86_64 options
  Add VPL options for BLOBLIST
  rockchip: Avoid checking environment without ENV_SUPPORT
  freescale: Drop old pre-DM_ETH code
  imx: Use SATA instead of CMD_SATA
  net: Add an SPL config for atheros
  freescale: Fix odd use of ESDHCI_QUIRK_BROKEN_TIMEOUT_VALUE
  serial: Support ns16550 driver in TPL
  dm: Add a TPL symbol for simple-bus
  x86: coral: Add missing TPL options
  power: wandboard: Add a missing CONFIG
  venice: Simplify conditions for network init
  command: Don't allow commands in SPL

 Makefile  |   1 -
 arch/arm/cpu/armv7/ls102xa/fdt.c  |  12 -
 arch/sandbox/dts/sandbox.dts  |   4 +-
 arch/sandbox/dts/sandbox.dtsi |   6 +-
 arch/sandbox/dts/sandbox_vpl.dtsi |   4 +-
 arch/sandbox/include/asm/rtc.h|   2 +-
 arch/x86/cpu/qemu/qemu.c  |   2 +-
 arch/x86/include/asm/msr.h|   2 +-
 arch/x86/include/asm/string.h |   2 +-
 arch/x86/lib/Makefile |   2 +-
 board/freescale/common/fsl_validate.c |  18 +-
 board/gateworks/venice/venice.c   |   6 +-
 board/keymile/common/common.c |   2 +-
 board/solidrun/mx6cuboxi/mx6cuboxi.c  |   2 +-
 .../puma_rk3399/puma-rk3399.c |   2 +-
 .../ringneck_px30/ringneck-px30.c |   2 +-
 boot/Kconfig  |  22 +-
 boot/Makefile |   5 +-
 boot/vbe_request.c|   2 +-
 cmd/nvedit.c  |   2 +
 common/Kconfig|  51 +-
 configs/chromebook_coral_defconfig|   3 +
 configs/wandboard_defconfig   |   1 +
 disk/Kconfig  |   8 +
 drivers/Makefile  |   2 +-
 drivers/core/Kconfig  |   7 +
 drivers/i2c/Kconfig   |  20 +
 drivers/input/Makefile|   1 -
 drivers/input/twl6030.c   |  47 --
 drivers/mmc/fsl_esdhc.c   |   5 +-
 drivers/mmc/mv_sdhci.c|   4 +-
 drivers/mtd/nand/raw/Makefile |   1 -
 drivers/mtd/nand/raw/kb9202_nand.c| 134 
 drivers/mux/Makefile  |   2 +-
 drivers/net/mvneta.c  |   4 +-
 drivers/net/phy/Kconfig   |   3 +
 drivers/phy/cadence/Makefile  |   2 +-
 drivers/rtc/Kconfig   |  18 +
 drivers/rtc/Makefile  |   4 +-
 drivers/serial/Kconfig  

[PATCH v4 00/50] More tidy-ups of Kconfig options

2023-02-19 Thread Simon Glass
This series was split out of the old 'split config' splc series. It
contains clean-up patches which do not depend on split config.

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

The remaining patches will move into a new 'splg' series (G for Good).

[1] https://patchwork.ozlabs.org/project/uboot/list/?series=341504=*

Changes in v4:
- Avoid use of def_bool
- Modify to get rid of def_bool
- Adjust Kconfig ordering
- Just fix the typo
- Reduce and rename commit
- Reduce and rename commit
- Fix 'wanderboard' typo
- Reduce and rename commit

Changes in v3:
- Add new patch to disable QFW bootmeth in SPL
- Move the option down to the non-SPL part of drivers/Makefile
- Correct 'VPL' typo
- Use a consistent format for the comment
- Fix a transitory build error with sandbox_spl
- Add a new patch to disallow commands in SPL

Changes in v2:
- Rebase to previous series

Simon Glass (50):
  patman: Drop an uncorrect comment about git am
  patman: Refactor MakeCcFile() into two functions
  patman: Run get_maintainer.pl in parallel
  patman: Check patches in parallel
  mtd: Drop unused kb9202_nand driver
  mtd: Drop unused CONFIG_ONENAND_U_BOOT
  sh4: Drop unused twl6030 driver
  moveconfig: Update to detect / correct missing SPL Kconfigs
  bootstd: Disable QFW bootmeth in SPL
  Correct SPL uses of ARCH_MVEBU
  Correct SPL uses of DISPLAY_AER_FULL
  Correct SPL uses of FSL_ISBC_KEY_EXT
  Correct SPL uses of MULTIPLEXER
  Correct SPL use of PG_WCOM_UBOOT_UPDATE_SUPPORTED
  Correct SPL use of PHY_CADENCE_SIERRA
  Correct SPL uses of PHY_FIXED
  boot: Add Kconfigs for BOOTMETH_VBE_REQUEST
  Correct SPL use of DM_RNG
  lib: Add a Kconfig for SPL_BZIP2
  moveconfig: Various minor improvements
  sandbox: Expand size for VPL image
  event: Add Kconfig options for SPL
  bootstd: Correct 'VPL' typo
  env: Avoid checking ENV_IS_IN when env disabled
  env: Allow VPL environment to be nowhere
  lib: Add VPL options for SHA1 and SHA256
  x86: Use string functions for all 32-bit builds
  lib: Fix build condition for tiny-printf
  sandbox: Tidy up RTC options
  sandbox: Use the generic VPL option to enable VPL
  sandbox: Tidy up I2C options
  fixdep: Add support for VPL
  fixdep: Refactor to make testing easier
  fixdep: Add some tests for parse_config_line()
  test: Add SPL versions of the TEST_KCONFIG options
  lib: Add an SPL config for LIB_UUID
  test: Tidy up sandbox handling in test-main
  x86: Fix up use of X86_32BIT_INIT and X86_64 options
  Add VPL options for BLOBLIST
  rockchip: Avoid checking environment without ENV_SUPPORT
  freescale: Drop old pre-DM_ETH code
  imx: Use SATA instead of CMD_SATA
  net: Add an SPL config for atheros
  freescale: Fix odd use of ESDHCI_QUIRK_BROKEN_TIMEOUT_VALUE
  serial: Support ns16550 driver in TPL
  dm: Add a TPL symbol for simple-bus
  x86: coral: Add missing TPL options
  power: wandboard: Add a missing CONFIG
  venice: Simplify conditions for network init
  command: Don't allow commands in SPL

 Makefile  |   1 -
 arch/arm/cpu/armv7/ls102xa/fdt.c  |  12 -
 arch/sandbox/dts/sandbox.dts  |   4 +-
 arch/sandbox/dts/sandbox.dtsi |   6 +-
 arch/sandbox/dts/sandbox_vpl.dtsi |   4 +-
 arch/sandbox/include/asm/rtc.h|   2 +-
 arch/x86/cpu/qemu/qemu.c  |   2 +-
 arch/x86/include/asm/msr.h|   2 +-
 arch/x86/include/asm/string.h |   2 +-
 arch/x86/lib/Makefile |   2 +-
 board/freescale/common/fsl_validate.c |  18 +-
 board/gateworks/venice/venice.c   |   6 +-
 board/keymile/common/common.c |   2 +-
 board/solidrun/mx6cuboxi/mx6cuboxi.c  |   2 +-
 .../puma_rk3399/puma-rk3399.c |   2 +-
 .../ringneck_px30/ringneck-px30.c |   2 +-
 boot/Kconfig  |  22 +-
 boot/Makefile |   5 +-
 boot/vbe_request.c|   2 +-
 cmd/nvedit.c  |   2 +
 common/Kconfig|  51 +-
 configs/chromebook_coral_defconfig|   3 +
 configs/wandboard_defconfig   |   1 +
 disk/Kconfig  |   8 +
 drivers/Makefile  |   2 +-
 drivers/core/Kconfig  |   7 +
 drivers/i2c/Kconfig   |  20 +
 drivers/input/Makefile|   1 -
 drivers/input/twl6030.c   |  47 --
 drivers/mmc/fsl_esdhc.c   |   5 +-
 drivers/mmc/mv_sdhci.c|   4 +-
 drivers/mtd/nand/raw/Makefile |   1 -
 drivers/mtd/nand/raw/kb9202_nand.c| 134 
 drivers/mux/Makefile  |   2 +-
 drivers/net/mvneta.c  |   4 +-
 drivers/net/phy/Kconfig   |   3 +
 

Re: [PATCH 07/15] patman: Rename directory to patmanu

2023-02-19 Thread Simon Glass
Hi Sean,

On Sun, 19 Feb 2023 at 12:51, Sean Anderson  wrote:
>
> On 2/19/23 13:50, Simon Glass wrote:
> > Hi Sean,
> >
> > On Sun, 19 Feb 2023 at 09:49, Sean Anderson  wrote:
> >>
> >> On 2/19/23 09:51, Simon Glass wrote:
> >>> The name 'patman' is already taken in PyPi so use 'patmanu' as the name
> >>> of the package. Rename the source directory accordingly.
> >>
> >> Can't we just have a pypi package named e.g. patch-manager while the actual
> >> package name stays the same?
> >
> > That's exactly what I tried at first. When I use 'from patman import
> > xxx' I seem to need patman to be the actual package name. So I ended
> > up making it the same in the source tree as in the package.
> >
> > Do you know of a way around that? I would much prefer something like that.
> >
>
> I thought it was as simple as something like
>
> from setuptools import setup
> setup(name='patch-manager',
>version='1.0',
>license='GPL-2.0+',
>scripts=['patman'],
>packages=['patman'],
>package_dir={'patman': ''},
>package_data={'patman': ['README.rst']},
>classifiers=['Environment :: Console',
> 'Topic :: Software Development'])

But that is the setup file..I am trying to create something for use
with pip. I am using a .toml file.

But I am pretty new to this so may be missing something.

I made some changes along the lines of what you said and pushed the tree here:

https://github.com/sjg20/u-boot/tree/pata2-try

Could you please take a look and advise how to do this? You can run with:

$ scripts/make_pip.sh patman -n

Regards,
Simon


[PATCH 9/9] Makefile: Show binman missing blob message

2023-02-19 Thread Jonas Karlman
When binman is invoked during a build of U-Boot and an external blob is
missing, the user is usually presented with a generic file not found in
input path message.

Invoke binman with --allow-missing so that binman can show relevant
missing blob help messages. Build continue to fail with missing blobs
unless BINMAN_ALLOW_MISSING=1 is used.

This changes the following error message:

  binman: Filename 'atf-bl31' not found in input path (...)

to the following:

  Image 'itb' is missing external blobs and is non-functional: atf-blob

  /binman/itb/fit/images/atf/atf-blob (bl31.bin):
 See the documentation for your board. You may need to build ARM Trusted
 Firmware and build with BL31=/path/to/bl31.bin

Signed-off-by: Jonas Karlman 
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 58f8c7a35335..c2860824f6f2 100644
--- a/Makefile
+++ b/Makefile
@@ -1326,7 +1326,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if 
$(BINMAN_DEBUG),-D) \
 --toolpath $(objtree)/tools \
$(if $(BINMAN_VERBOSE),-v$(BINMAN_VERBOSE)) \
build -u -d u-boot.dtb -O . -m \
-   $(if $(BINMAN_ALLOW_MISSING),--allow-missing --ignore-missing) \
+   --allow-missing $(if $(BINMAN_ALLOW_MISSING),--ignore-missing) \
-I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \
-I arch/$(ARCH)/dts -a of-list=$(CONFIG_OF_LIST) \
$(foreach f,$(BINMAN_INDIRS),-I $(f)) \
-- 
2.39.2



[PATCH 5/9] binman: Implement missing check functions in mkimage entry

2023-02-19 Thread Jonas Karlman
The mkimage entry is working like a section entry but inherits from
Entry not Entry_section. Copy implementations of missing Check-functions
from Entry_section and adopt to Entry_mkimage.

Signed-off-by: Jonas Karlman 
---
 tools/binman/etype/mkimage.py | 44 ++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
index cb264c3cad0b..49d3462a154c 100644
--- a/tools/binman/etype/mkimage.py
+++ b/tools/binman/etype/mkimage.py
@@ -206,16 +206,31 @@ class Entry_mkimage(Entry):
 self._imagename.SetAllowMissing(allow_missing)
 
 def SetAllowFakeBlob(self, allow_fake):
-"""Set whether the sub nodes allows to create a fake blob
+"""Set whether a section allows to create a fake blob
 
 Args:
 allow_fake: True if allowed, False if not allowed
 """
+super().SetAllowFakeBlob(allow_fake)
 for entry in self._mkimage_entries.values():
 entry.SetAllowFakeBlob(allow_fake)
 if self._imagename:
 self._imagename.SetAllowFakeBlob(allow_fake)
 
+def CheckMissing(self, missing_list):
+"""Check if any entries in this section have missing external blobs
+
+If there are missing (non-optional) blobs, the entries are added to the
+list
+
+Args:
+missing_list: List of Entry objects to be added to
+"""
+for entry in self._mkimage_entries.values():
+entry.CheckMissing(missing_list)
+if self._imagename:
+self._imagename.CheckMissing(missing_list)
+
 def CheckFakedBlobs(self, faked_blobs_list):
 """Check if any entries in this section have faked external blobs
 
@@ -229,6 +244,33 @@ class Entry_mkimage(Entry):
 if self._imagename:
 self._imagename.CheckFakedBlobs(faked_blobs_list)
 
+def CheckOptional(self, optional_list):
+"""Check the section for missing but optional external blobs
+
+If there are missing (optional) blobs, the entries are added to the 
list
+
+Args:
+optional_list (list): List of Entry objects to be added to
+"""
+for entry in self._mkimage_entries.values():
+entry.CheckOptional(optional_list)
+if self._imagename:
+self._imagename.CheckOptional(optional_list)
+
+def check_missing_bintools(self, missing_list):
+"""Check if any entries in this section have missing bintools
+
+If there are missing bintools, these are added to the list
+
+Args:
+missing_list: List of Bintool objects to be added to
+"""
+super().check_missing_bintools(missing_list)
+for entry in self._mkimage_entries.values():
+entry.check_missing_bintools(missing_list)
+if self._imagename:
+self._imagename.check_missing_bintools(missing_list)
+
 def AddBintools(self, btools):
 super().AddBintools(btools)
 self.mkimage = self.AddBintool(btools, 'mkimage')
-- 
2.39.2



[PATCH 7/9] binman: Fix blank line usage for invalid images warning text

2023-02-19 Thread Jonas Karlman
There is no blank line between last missing blob help message and the
header line for optional blob help messages.

  Image 'simple-bin' is missing external blobs and is non-functional: atf-bl31

  /binman/simple-bin/fit/images/@atf-SEQ/atf-bl31:
 See the documentation for your board. You may need to build ARM Trusted
 Firmware and build with BL31=/path/to/bl31.bin
  Image 'simple-bin' is missing external blobs but is still functional: tee-os

  /binman/simple-bin/fit/images/@tee-SEQ/tee-os:
 See the documentation for your board. You may need to build Open Portable
 Trusted Execution Environment (OP-TEE) with TEE=/path/to/tee.bin

  Some images are invalid

With this a blank line is inserted to make the text more readable.

Signed-off-by: Jonas Karlman 
---
 tools/binman/control.py | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/tools/binman/control.py b/tools/binman/control.py
index e64740094f60..b5ede60c1cde 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -106,9 +106,10 @@ def _ReadMissingBlobHelp():
 return result
 
 def _ShowBlobHelp(path, text):
-tout.warning('\n%s:' % path)
+tout.warning('%s:' % path)
 for line in text.splitlines():
 tout.warning('   %s' % line)
+tout.warning('')
 
 def _ShowHelpForMissingBlobs(missing_list):
 """Show help for each missing blob to help the user take action
@@ -598,7 +599,7 @@ def ProcessImage(image, update_fdt, write_map, 
get_contents=True,
 missing_list = []
 image.CheckMissing(missing_list)
 if missing_list:
-tout.warning("Image '%s' is missing external blobs and is 
non-functional: %s" %
+tout.warning("Image '%s' is missing external blobs and is 
non-functional: %s\n" %
  (image.name, ' '.join([e.name for e in missing_list])))
 _ShowHelpForMissingBlobs(missing_list)
 
@@ -606,7 +607,7 @@ def ProcessImage(image, update_fdt, write_map, 
get_contents=True,
 image.CheckFakedBlobs(faked_list)
 if faked_list:
 tout.warning(
-"Image '%s' has faked external blobs and is non-functional: %s" %
+"Image '%s' has faked external blobs and is non-functional: %s\n" %
 (image.name, ' '.join([os.path.basename(e.GetDefaultFilename())
for e in faked_list])))
 
@@ -614,7 +615,7 @@ def ProcessImage(image, update_fdt, write_map, 
get_contents=True,
 image.CheckOptional(optional_list)
 if optional_list:
 tout.warning(
-"Image '%s' is missing external blobs but is still functional: %s" 
%
+"Image '%s' is missing external blobs but is still functional: 
%s\n" %
 (image.name, ' '.join([e.name for e in optional_list])))
 _ShowHelpForMissingBlobs(optional_list)
 
@@ -622,7 +623,7 @@ def ProcessImage(image, update_fdt, write_map, 
get_contents=True,
 image.check_missing_bintools(missing_bintool_list)
 if missing_bintool_list:
 tout.warning(
-"Image '%s' has missing bintools and is non-functional: %s" %
+"Image '%s' has missing bintools and is non-functional: %s\n" %
 (image.name, ' '.join([os.path.basename(bintool.name)
for bintool in missing_bintool_list])))
 return any([missing_list, faked_list, missing_bintool_list])
@@ -756,7 +757,7 @@ def Binman(args):
 # This can only be True if -M is provided, since otherwise binman
 # would have raised an error already
 if invalid:
-msg = '\nSome images are invalid'
+msg = 'Some images are invalid'
 if args.ignore_missing:
 tout.warning(msg)
 else:
-- 
2.39.2



[PATCH 2/9] binman: Fix spelling of nodes in code comments

2023-02-19 Thread Jonas Karlman
Replace notes with nodes in code comments and docstrings.

Signed-off-by: Jonas Karlman 
---
 tools/binman/etype/fit.py | 2 +-
 tools/binman/etype/section.py | 2 +-
 tools/binman/state.py | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index cd2943533ce2..822de7982768 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -823,7 +823,7 @@ class Entry_fit(Entry_section):
 self.mkimage = self.AddBintool(btools, 'mkimage')
 
 def CheckMissing(self, missing_list):
-# We must use our private entry list for this since generator notes
+# We must use our private entry list for this since generator nodes
 # which are removed from self._entries will otherwise not show up as
 # missing
 for entry in self._priv_entries.values():
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 57b91ff726c0..8bf5aa437d1a 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -172,7 +172,7 @@ class Entry_section(Entry):
 def IsSpecialSubnode(self, node):
 """Check if a node is a special one used by the section itself
 
-Some notes are used for hashing / signatures and do not add entries to
+Some nodes are used for hashing / signatures and do not add entries to
 the actual section.
 
 Returns:
diff --git a/tools/binman/state.py b/tools/binman/state.py
index 56e5bf8bc10f..33563199840e 100644
--- a/tools/binman/state.py
+++ b/tools/binman/state.py
@@ -306,7 +306,7 @@ def GetUpdateNodes(node, for_repack=False):
 """Yield all the nodes that need to be updated in all device trees
 
 The property referenced by this node is added to any device trees which
-have the given node. Due to removable of unwanted notes, SPL and TPL may
+have the given node. Due to removable of unwanted nodes, SPL and TPL may
 not have this node.
 
 Args:
-- 
2.39.2



[PATCH 8/9] binman: Show filename in missing blob help message

2023-02-19 Thread Jonas Karlman
Show the filename next to the node path in missing blob help messages,
also show a generic missing blob message when there was no help message
for the help tag.

Signed-off-by: Jonas Karlman 
---
 tools/binman/control.py | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/tools/binman/control.py b/tools/binman/control.py
index b5ede60c1cde..a5ff1cb56245 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -105,8 +105,8 @@ def _ReadMissingBlobHelp():
 _FinishTag(tag, msg, result)
 return result
 
-def _ShowBlobHelp(path, text):
-tout.warning('%s:' % path)
+def _ShowBlobHelp(path, text, fname):
+tout.warning('%s (%s):' % (path, fname))
 for line in text.splitlines():
 tout.warning('   %s' % line)
 tout.warning('')
@@ -126,10 +126,17 @@ def _ShowHelpForMissingBlobs(missing_list):
 tags = entry.GetHelpTags()
 
 # Show the first match help message
+shown_help = False
 for tag in tags:
 if tag in missing_blob_help:
-_ShowBlobHelp(entry._node.path, missing_blob_help[tag])
+_ShowBlobHelp(entry._node.path, missing_blob_help[tag],
+  entry.GetDefaultFilename())
+shown_help = True
 break
+# Or a generic help message
+if not shown_help:
+_ShowBlobHelp(entry._node.path, "Missing blob",
+  entry.GetDefaultFilename())
 
 def GetEntryModules(include_testing=True):
 """Get a set of entry class implementations
-- 
2.39.2



[PATCH 3/9] binman: Use correct argument name in docstrings

2023-02-19 Thread Jonas Karlman
Use correct argument name in docstrings.

Signed-off-by: Jonas Karlman 
---
 tools/binman/entry.py | 2 +-
 tools/binman/etype/blob.py| 2 +-
 tools/binman/etype/section.py | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 5eacc5fa6c42..52b5d335f8ba 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -1104,7 +1104,7 @@ features to produce new behaviours.
 If there are faked blobs, the entries are added to the list
 
 Args:
-fake_blobs_list: List of Entry objects to be added to
+faked_blobs_list: List of Entry objects to be added to
 """
 # This is meaningless for anything other than blobs
 pass
diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py
index c7ddcedffb82..a80741e36338 100644
--- a/tools/binman/etype/blob.py
+++ b/tools/binman/etype/blob.py
@@ -102,7 +102,7 @@ class Entry_blob(Entry):
 If there are faked blobs, the entries are added to the list
 
 Args:
-fake_blobs_list: List of Entry objects to be added to
+faked_blobs_list: List of Entry objects to be added to
 """
 if self.faked:
 faked_blobs_list.append(self)
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 8bf5aa437d1a..d3926f791c72 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -885,7 +885,7 @@ class Entry_section(Entry):
 """Set whether a section allows to create a fake blob
 
 Args:
-allow_fake_blob: True if allowed, False if not allowed
+allow_fake: True if allowed, False if not allowed
 """
 super().SetAllowFakeBlob(allow_fake)
 for entry in self._entries.values():
@@ -909,7 +909,7 @@ class Entry_section(Entry):
 If there are faked blobs, the entries are added to the list
 
 Args:
-fake_blobs_list: List of Entry objects to be added to
+faked_blobs_list: List of Entry objects to be added to
 """
 for entry in self._entries.values():
 entry.CheckFakedBlobs(faked_blobs_list)
-- 
2.39.2



[PATCH 6/9] binman: Mark mkimage entry missing when its subnodes is missing

2023-02-19 Thread Jonas Karlman
Using the mkimage entry with the multiple-data-files prop and having a
missing external blob result in an unexpected ValueError exception using
the --allow-missing flag.

  ValueError: Filename 'missing.bin' not found in input path (...)

Fix this by using _pathname that is resolved by ObtainContents for blob
entries, ObtainContents also handles allow missing for external blobs.

Mark mkimage entry as missing and return without running mkimage when
missing entries is reported by CheckMissing.

Signed-off-by: Jonas Karlman 
---
 tools/binman/etype/mkimage.py | 10 +-
 tools/binman/ftest.py |  9 +
 .../test/278_mkimage_missing_multiple.dts | 19 +++
 3 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/test/278_mkimage_missing_multiple.dts

diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
index 49d3462a154c..2673a8607f37 100644
--- a/tools/binman/etype/mkimage.py
+++ b/tools/binman/etype/mkimage.py
@@ -156,7 +156,8 @@ class Entry_mkimage(Entry):
 for entry in self._mkimage_entries.values():
 if not entry.ObtainContents(fake_size=fake_size):
 return False
-
fnames.append(tools.get_input_filename(entry.GetDefaultFilename()))
+if entry._pathname:
+fnames.append(entry._pathname)
 input_fname = ":".join(fnames)
 else:
 data, input_fname, uniq = self.collect_contents_to_file(
@@ -171,6 +172,13 @@ class Entry_mkimage(Entry):
 outfile = self._filename if self._filename else 'mkimage-out.%s' % uniq
 output_fname = tools.get_output_filename(outfile)
 
+missing_list = []
+self.CheckMissing(missing_list)
+self.missing = bool(missing_list)
+if self.missing:
+self.SetContents(b'')
+return self.allow_missing
+
 args = ['-d', input_fname]
 if self._data_to_imagename:
 args += ['-n', input_fname]
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 48ac1540bfd8..803b8c5accf4 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -6393,6 +6393,15 @@ fdt fdtmapExtract the devicetree 
blob from the fdtmap
 data = self._DoReadFile('277_rockchip_tpl.dts')
 self.assertEqual(ROCKCHIP_TPL_DATA, data[:len(ROCKCHIP_TPL_DATA)])
 
+def testMkimageMissingBlobMultiple(self):
+"""Test using mkimage to build an image"""
+with test_util.capture_sys_output() as (stdout, stderr):
+self._DoTestFile('278_mkimage_missing_multiple.dts', 
allow_missing=True)
+err = stderr.getvalue()
+self.assertRegex(
+err,
+"Image '.*' is missing external blobs and is non-functional: .*")
+
 
 if __name__ == "__main__":
 unittest.main()
diff --git a/tools/binman/test/278_mkimage_missing_multiple.dts 
b/tools/binman/test/278_mkimage_missing_multiple.dts
new file mode 100644
index ..f84aea49ead9
--- /dev/null
+++ b/tools/binman/test/278_mkimage_missing_multiple.dts
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   binman {
+   mkimage {
+   args = "-n test -T script";
+   multiple-data-files;
+
+   blob-ext {
+   filename = "missing.bin";
+   };
+   };
+   };
+};
-- 
2.39.2



[PATCH 4/9] binman: Override CheckOptional in fit entry

2023-02-19 Thread Jonas Karlman
Missing optional blobs was not reported for generated entries, e.g.
tee-os on rockchip targets. Implement a CheckOptional to fix this.

After this the following can be shown:

  Image 'simple-bin' is missing external blobs but is still functional: tee-os

  /binman/simple-bin/fit/images/@tee-SEQ/tee-os (tee-os):
 See the documentation for your board. You may need to build Open Portable
 Trusted Execution Environment (OP-TEE) with TEE=/path/to/tee.bin

Signed-off-by: Jonas Karlman 
---
 tools/binman/etype/fit.py | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index 822de7982768..314e03b4a964 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -828,3 +828,10 @@ class Entry_fit(Entry_section):
 # missing
 for entry in self._priv_entries.values():
 entry.CheckMissing(missing_list)
+
+def CheckOptional(self, optional_list):
+# We must use our private entry list for this since generator nodes
+# which are removed from self._entries will otherwise not show up as
+# optional
+for entry in self._priv_entries.values():
+entry.CheckOptional(optional_list)
-- 
2.39.2



[PATCH 0/9] binman: Show missing blob message when building U-Boot

2023-02-19 Thread Jonas Karlman
binman currently support showing a helpful missing blob message, but
only when the --allow-missing flag is used.

This changes so that binman is invoked with the --allow-missing flag
and the helpful message can be shown by default when building U-Boot.

Using the following:

  make rockpro64-rk3399_defconfig
  make CROSS_COMPILE="aarch64-linux-gnu-"

Before this series a build fails with:

  binman: Filename 'atf-bl31' not found in input path (...)

After this series a build fails with:

  Image 'simple-bin' is missing external blobs and is non-functional: atf-bl31

  /binman/simple-bin/fit/images/@atf-SEQ/atf-bl31 (atf-bl31):
 See the documentation for your board. You may need to build ARM Trusted
 Firmware and build with BL31=/path/to/bl31.bin

  Image 'simple-bin' is missing external blobs but is still functional: tee-os

  /binman/simple-bin/fit/images/@tee-SEQ/tee-os (tee-os):
 See the documentation for your board. You may need to build Open Portable
 Trusted Execution Environment (OP-TEE) with TEE=/path/to/tee.bin

  Some images are invalid

Builds will continue to fail when there is missing blobs, and the use of
BINMAN_ALLOW_MISSING=1 now only enables the --ignore-missing flag.

This series also fixes a few minor issues that prevented some missing
and optional blobs to be detected for fit and mkimage entries.

Patch 1-3 contains spelling fixes and code cleanup for related parts.
Patch 4-6 improve missing/optional detection for fit and mkimage entries.
Patch 7-8 improve the missing blob warning message output.
Patch 9 finally update Makefile to always pass the --allow-missing flag.

The series is based on top of [1], and is the follow-up series meant to
address the issue with missing blob message for mkimage entries.

[1] 
https://patchwork.ozlabs.org/project/uboot/cover/20230219150629.4012377-1-jo...@kwiboo.se/

Jonas Karlman (9):
  binman: Remove redundant SetAllowFakeBlob from blob-ext entry
  binman: Fix spelling of nodes in code comments
  binman: Use correct argument name in docstrings
  binman: Override CheckOptional in fit entry
  binman: Implement missing check functions in mkimage entry
  binman: Mark mkimage entry missing when its subnodes is missing
  binman: Fix blank line usage for invalid images warning text
  binman: Show filename in missing blob help message
  Makefile: Show binman missing blob message

 Makefile  |  2 +-
 tools/binman/control.py   | 24 ++---
 tools/binman/entry.py |  2 +-
 tools/binman/etype/blob.py|  2 +-
 tools/binman/etype/blob_ext.py|  8 ---
 tools/binman/etype/fit.py |  9 +++-
 tools/binman/etype/mkimage.py | 54 ++-
 tools/binman/etype/section.py |  6 +--
 tools/binman/ftest.py |  9 
 tools/binman/state.py |  2 +-
 .../test/278_mkimage_missing_multiple.dts | 19 +++
 11 files changed, 111 insertions(+), 26 deletions(-)
 create mode 100644 tools/binman/test/278_mkimage_missing_multiple.dts

-- 
2.39.2



[PATCH 1/9] binman: Remove redundant SetAllowFakeBlob from blob-ext entry

2023-02-19 Thread Jonas Karlman
Entry_blob_ext contains an implementation of SetAllowFakeBlob that is
identical to the one in the base Entry class, remove it.

Signed-off-by: Jonas Karlman 
---
 tools/binman/etype/blob_ext.py | 8 
 1 file changed, 8 deletions(-)

diff --git a/tools/binman/etype/blob_ext.py b/tools/binman/etype/blob_ext.py
index fba6271de2bb..d6b0ca17c3f3 100644
--- a/tools/binman/etype/blob_ext.py
+++ b/tools/binman/etype/blob_ext.py
@@ -26,11 +26,3 @@ class Entry_blob_ext(Entry_blob):
 def __init__(self, section, etype, node):
 Entry_blob.__init__(self, section, etype, node)
 self.external = True
-
-def SetAllowFakeBlob(self, allow_fake):
-"""Set whether the entry allows to create a fake blob
-
-Args:
-allow_fake_blob: True if allowed, False if not allowed
-"""
-self.allow_fake = allow_fake
-- 
2.39.2



Pull request for efi-2023-04-rc3

2023-02-19 Thread Heinrich Schuchardt

Dear Tom,

The following changes since commit 1198b38ba980efed050c878c083607d997010e03:

  Merge branch '2023-02-17-assorted-fixes' (2023-02-17 14:18:46 -0500)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-efi.git 
tags/efi-2023-04-rc3


for you to fetch changes up to 5e957ae3504290a0c62188331a429ec9b908aa1b:

  doc: remove superfluous warning (2023-02-19 21:34:38 +0100)

Gitlab CI showed no issues:
https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/15256


Pull request for efi-2023-04-rc3

Documentation

* Add a document for the RISC-V architecture
* Move gateworks and bcm7xxx documentation to HTML

UEFI

* measure the loaded device-tree
* make CapsuleMax configurable and provide sensible default


Etienne Carriere (2):
  efi_loader: Measure the loaded DTB
  efi_loader: set CapsuleMax from CONFIG_EFI_CAPSULE_MAX

Heinrich Schuchardt (2):
  efi_loader: avoid buffer overrun in efi_var_mem_compare
  doc: remove superfluous warning

Masahisa Kojima (1):
  efi_loader: fix wrong attribute check for QueryVariableInfo

Thomas Fitzsimmons (1):
  doc: board: bcm7xxx: Convert to reStructuredText format

Tim Harvey (1):
  board: gateworks: venice: move README to RST

Yu Chien Peter Lin (2):
  doc: devicetree: dt_qemu.rst: Fix the typo and space
  doc: arch: Add document for RISC-V architecture

 MAINTAINERS   |   1 +
 board/gateworks/venice/MAINTAINERS|   1 +
 board/gateworks/venice/README |  35 ---
 cmd/bootefi.c |   8 ++
 doc/README.bcm7xxx| 156 -
 doc/arch/index.rst|   1 +
 doc/arch/riscv.rst|  81 +++
 doc/board/broadcom/bcm7xxx.rst| 183 
++

 doc/board/broadcom/index.rst  |   1 +
 doc/board/gateworks/imx8mm_venice.rst |  50 ++
 doc/board/gateworks/imx8mn_venice.rst |  50 ++
 doc/board/gateworks/imx8mp_venice.rst |  50 ++
 doc/board/gateworks/index.rst |  11 ++
 doc/board/index.rst   |   1 +
 doc/conf.py   |   4 -
 doc/develop/devicetree/dt_qemu.rst|   4 +-
 include/efi_loader.h  |   2 +
 include/efi_tcg2.h|  10 ++
 include/tpm-v2.h  |   2 +
 lib/efi_loader/Kconfig|  19 
 lib/efi_loader/efi_capsule.c  |  48 ++---
 lib/efi_loader/efi_setup.c|   7 +-
 lib/efi_loader/efi_tcg2.c |  73 ++
 lib/efi_loader/efi_var_mem.c  |   4 +-
 lib/efi_loader/efi_variable.c |   3 -
 25 files changed, 589 insertions(+), 216 deletions(-)
 delete mode 100644 board/gateworks/venice/README
 delete mode 100644 doc/README.bcm7xxx
 create mode 100644 doc/arch/riscv.rst
 create mode 100644 doc/board/broadcom/bcm7xxx.rst
 create mode 100644 doc/board/gateworks/imx8mm_venice.rst
 create mode 100644 doc/board/gateworks/imx8mn_venice.rst
 create mode 100644 doc/board/gateworks/imx8mp_venice.rst
 create mode 100644 doc/board/gateworks/index.rst


[PATCH] kconfig: Proposed language extension for multiple builds

2023-02-19 Thread Simon Glass
In the case of Linux, only one build is produced so there is only a
single configuration. For other projects, such as U-Boot and Zephyr, the
same code is used to produce multiple builds, each with related (but
different) options enabled.

This can be handled with the existing kconfig language, but it is quite
verbose, somewhat tedious and very error-prone, since there is a lot of
duplication. The result is hard to maintain.

Describe an extension to the Kconfig language to support easier handling
of this use case.

Signed-off-by: Simon Glass 
---

 Documentation/kbuild/kconfig-language.rst | 134 ++
 1 file changed, 134 insertions(+)

diff --git a/Documentation/kbuild/kconfig-language.rst 
b/Documentation/kbuild/kconfig-language.rst
index 858ed5d80defe..73fb016a5533f 100644
--- a/Documentation/kbuild/kconfig-language.rst
+++ b/Documentation/kbuild/kconfig-language.rst
@@ -228,6 +228,24 @@ applicable everywhere (see syntax).
   enables the third modular state for all config symbols.
   At most one symbol may have the "modules" option set.
 
+- phase declaration: "defphase"
+  This defines a new build phase. See `Build Phases`_.
+
+- default phase: "phasedefault"
+  This indicates the default build phase. See `Build Phases`_.
+
+- add entries for phases: "addphases"
+  This creates new phase-specific entries based on a template entry and adds
+  the same attributes to it. See `Build Phases`_.
+
+- set entries for phases: "setphases"
+  This sets the phases which need an entry. This allows creating an entry that
+  only has a primary phase. See `Build Phases`_.
+
+- indicate a phase-specific attribute: "forphases"
+  This marks an attribute as being applicable only to a particular phase or
+  group of phases.  See `Build Phases`_.
+
 Menu dependencies
 -
 
@@ -319,6 +337,119 @@ MODVERSIONS directly depends on MODULES, this means it's 
only visible if
 MODULES is different from 'n'. The comment on the other hand is only
 visible when MODULES is set to 'n'.
 
+Build Phases
+
+
+Some projects use Kconfig to control multiple build phases, each phase
+resulting in a separate set of object files and executable. This is the
+case in U-Boot [12]_. Zephyr OS seems to be heading this way too [13]_.
+
+Generally the phases are related, so that enabling an entry in the primary
+phase also enables it by default in the others. But in some cases it may
+be desirable to use separate conditions for each phase.
+
+All phases have a phase name, for example `SPL`. This name is used as a
+prefix to each entry used in that phase, with an underscore in between.
+So if FOO is the primary entry, the equivalent entry for the SPL phase
+is SPL_FOO. The primary phase is marked with a "phasedefault" entry.
+
+Phases are declared like any other menu entry except that also have a
+"defphase" keyword. Phase entries are normally hidden so do not have a
+prompt::
+
+config PPL
+bool
+defphase "Primary Program Loader"
+phasedefault
+help
+  This is the primary bootloader.
+
+config SPL
+bool
+defphase "Secondary Program Loader"
+help
+  This is used to set up memory and load the primary bootloader.
+
+The default phase (here PPL) is assumed for all entries, in the sense that
+all entries are present in PPL by default and no prefix is needed on these
+entries. So FOO means that it applies to PPL. There must be exactly one
+default phase.
+
+The resulting menu entries can be used normally throughout the Kconfig. With
+this technique, the different build phases can be fully and individually
+controlled from Kconfig.
+
+However it is not ideal. Often the secondary phases have far fewer entries than
+the primary phase, since they offer fewer features. Even so, each FOO that is
+needed in a phase must have an SPL_FOO, etc. To avoid an explosion of entries,
+it is possible to indicate which are enabled, as a shortcut for creating new
+entries::
+
+config FOO
+bool "Enable foo feature"
+addphases SPL
+depends on %BAR
+depends on QUX
+forphases SPL depends on FIZZ
+
+Note that "%" expands to the phase, so this is equivalent to (ignoring BAR)::
+
+config FOO
+bool "Enable foo feature"
+depends on BAR
+depends on QUX
+
+config SPL_FOO# Phase is prepended
+bool "Enable foo feature (SPL)"# Suffix is added
+depends on SPL_BAR # "%" dependency is expanded
+depends on QUX
+depends on FIZZ# Added only for SPL
+depends on SPL # Added automatically
+
+Attributes declared in the primary symbol FOO (such as "depends on BAR") also
+apply to the secondary ones.
+
+An entry without any 'addphases' attribute applies to all phases. Individual
+phase entries are not available in that case. If the entry is enabled, then
+it is enabled for all 

  1   2   >