[PATCH 18/21] Convert CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST to Kconfig

2022-10-28 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST

Signed-off-by: Tom Rini 
---
 configs/da850evm_nand_defconfig  | 1 +
 configs/k2e_evm_defconfig| 1 +
 configs/k2e_hs_evm_defconfig | 1 +
 configs/k2hk_evm_defconfig   | 1 +
 configs/k2hk_hs_evm_defconfig| 1 +
 configs/k2l_evm_defconfig| 1 +
 configs/k2l_hs_evm_defconfig | 1 +
 configs/omapl138_lcdk_defconfig  | 1 +
 drivers/mtd/nand/raw/Kconfig | 4 
 include/configs/da850evm.h   | 1 -
 include/configs/omapl138_lcdk.h  | 1 -
 include/configs/ti_armv7_keystone2.h | 1 -
 12 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/configs/da850evm_nand_defconfig b/configs/da850evm_nand_defconfig
index f3ae5a77ccc5..dfa0399f3cf1 100644
--- a/configs/da850evm_nand_defconfig
+++ b/configs/da850evm_nand_defconfig
@@ -86,6 +86,7 @@ CONFIG_DM_MTD=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_SYS_NAND_USE_FLASH_BBT=y
 CONFIG_NAND_DAVINCI=y
+CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST=y
 CONFIG_SYS_NAND_BLOCK_SIZE=0x2
 CONFIG_SYS_NAND_PAGE_COUNT=0x40
 CONFIG_SYS_NAND_PAGE_SIZE=0x800
diff --git a/configs/k2e_evm_defconfig b/configs/k2e_evm_defconfig
index ed2affd8f7f0..4184d280b30e 100644
--- a/configs/k2e_evm_defconfig
+++ b/configs/k2e_evm_defconfig
@@ -79,6 +79,7 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_SYS_NAND_USE_FLASH_BBT=y
 CONFIG_NAND_DAVINCI=y
+CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=3000
 CONFIG_SPI_FLASH_STMICRO=y
diff --git a/configs/k2e_hs_evm_defconfig b/configs/k2e_hs_evm_defconfig
index c19c69903b1b..9958cf7a265f 100644
--- a/configs/k2e_hs_evm_defconfig
+++ b/configs/k2e_hs_evm_defconfig
@@ -54,6 +54,7 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_SYS_NAND_USE_FLASH_BBT=y
 CONFIG_NAND_DAVINCI=y
+CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=3000
 CONFIG_SPI_FLASH_STMICRO=y
diff --git a/configs/k2hk_evm_defconfig b/configs/k2hk_evm_defconfig
index 973d812385b5..9c3e92c11c8a 100644
--- a/configs/k2hk_evm_defconfig
+++ b/configs/k2hk_evm_defconfig
@@ -79,6 +79,7 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_SYS_NAND_USE_FLASH_BBT=y
 CONFIG_NAND_DAVINCI=y
+CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=3000
 CONFIG_SPI_FLASH_STMICRO=y
diff --git a/configs/k2hk_hs_evm_defconfig b/configs/k2hk_hs_evm_defconfig
index fe25c090bbf7..b37e5c829375 100644
--- a/configs/k2hk_hs_evm_defconfig
+++ b/configs/k2hk_hs_evm_defconfig
@@ -54,6 +54,7 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_SYS_NAND_USE_FLASH_BBT=y
 CONFIG_NAND_DAVINCI=y
+CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=3000
 CONFIG_SPI_FLASH_STMICRO=y
diff --git a/configs/k2l_evm_defconfig b/configs/k2l_evm_defconfig
index 437cf4b06d94..e0976312c129 100644
--- a/configs/k2l_evm_defconfig
+++ b/configs/k2l_evm_defconfig
@@ -79,6 +79,7 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_SYS_NAND_USE_FLASH_BBT=y
 CONFIG_NAND_DAVINCI=y
+CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=3000
 CONFIG_SPI_FLASH_STMICRO=y
diff --git a/configs/k2l_hs_evm_defconfig b/configs/k2l_hs_evm_defconfig
index 9b98bc9f2abe..090e16be3128 100644
--- a/configs/k2l_hs_evm_defconfig
+++ b/configs/k2l_hs_evm_defconfig
@@ -57,6 +57,7 @@ CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_SYS_NAND_USE_FLASH_BBT=y
 CONFIG_NAND_DAVINCI=y
+CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=3000
 CONFIG_SPI_FLASH_STMICRO=y
diff --git a/configs/omapl138_lcdk_defconfig b/configs/omapl138_lcdk_defconfig
index a7918aaa0b0a..bc3af8a851c6 100644
--- a/configs/omapl138_lcdk_defconfig
+++ b/configs/omapl138_lcdk_defconfig
@@ -83,6 +83,7 @@ CONFIG_DM_MTD=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_SYS_NAND_USE_FLASH_BBT=y
 CONFIG_NAND_DAVINCI=y
+CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST=y
 CONFIG_SYS_NAND_BLOCK_SIZE=0x2
 CONFIG_SYS_NAND_PAGE_COUNT=0x40
 CONFIG_SYS_NAND_PAGE_SIZE=0x800
diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 2c03676bf78b..1686f8b94d66 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -136,6 +136,10 @@ config NAND_DAVINCI
  Enable this driver for NAND flash controllers available in TI Davinci
  and Keystone2 platforms
 
+config SYS_NAND_4BIT_HW_ECC_OOBFIRST
+   bool "Use 4-bit HW ECC with OOB at the front"
+   depends on NAND_DAVINCI
+
 config KEYSTONE_RBL_NAND
depends on ARCH_KEYSTONE
def_bool y
diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h
index 3625f923a5c1..281cbe37f9d9 100644
--- a/include/configs/da850evm.h
+++ b/include/configs/da850evm.h
@@ -107,7 +107,6 @@
  * Flash & Environment
  */
 #ifdef CONFIG_MTD_RAW_NAND
-#define CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST
 #defineCONFIG_SYS_NAND_PAGE_2K
 #define CONFIG_SYS_NAND_CS 3
 

[PATCH 19/21] global: Migrate CONFIG_SYS_MPC8* symbols to the CFG_SYS namespace

2022-10-28 Thread Tom Rini
Migrate all of COFIG_SYS_MPC* to the CFG_SYS namespace.

Signed-off-by: Tom Rini 
---
 arch/powerpc/cpu/mpc85xx/bsc9132_serdes.c |   2 +-
 arch/powerpc/cpu/mpc85xx/c29x_serdes.c|   2 +-
 arch/powerpc/cpu/mpc85xx/cpu.c|   8 +-
 arch/powerpc/cpu/mpc85xx/cpu_init.c   |  22 +-
 arch/powerpc/cpu/mpc85xx/cpu_init_early.c |   4 +-
 arch/powerpc/cpu/mpc85xx/fdt.c|   6 +-
 .../powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c |   4 +-
 arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c |  10 +-
 arch/powerpc/cpu/mpc85xx/interrupts.c |   2 +-
 arch/powerpc/cpu/mpc85xx/mp.c |  20 +-
 arch/powerpc/cpu/mpc85xx/mpc8536_serdes.c |   4 +-
 arch/powerpc/cpu/mpc85xx/mpc8544_serdes.c |   2 +-
 arch/powerpc/cpu/mpc85xx/mpc8548_serdes.c |   2 +-
 arch/powerpc/cpu/mpc85xx/p1010_serdes.c   |   2 +-
 arch/powerpc/cpu/mpc85xx/p1021_serdes.c   |   4 +-
 arch/powerpc/cpu/mpc85xx/p1023_serdes.c   |   2 +-
 arch/powerpc/cpu/mpc85xx/p2020_serdes.c   |   2 +-
 arch/powerpc/cpu/mpc85xx/qe_io.c  |   2 +-
 arch/powerpc/cpu/mpc85xx/speed.c  |   4 +-
 arch/powerpc/cpu/mpc85xx/spl_minimal.c|   2 +-
 arch/powerpc/cpu/mpc85xx/start.S  |   8 +-
 arch/powerpc/cpu/mpc85xx/traps.c  |   2 +-
 arch/powerpc/cpu/mpc8xxx/cpu.c|  14 +-
 arch/powerpc/cpu/mpc8xxx/law.c|   2 +-
 arch/powerpc/cpu/mpc8xxx/srio.c   |   4 +-
 arch/powerpc/include/asm/fsl_liodn.h  |  26 +--
 arch/powerpc/include/asm/immap_83xx.h |  16 +-
 arch/powerpc/include/asm/immap_85xx.h | 212 +-
 arch/powerpc/include/asm/mpc85xx_gpio.h   |   4 +-
 board/freescale/common/fsl_chain_of_trust.c   |   2 +-
 board/freescale/common/fsl_validate.c |   2 +-
 board/freescale/common/mpc85xx_sleep.c|   6 +-
 board/freescale/common/vid.c  |   2 +-
 board/freescale/mpc8548cds/mpc8548cds.c   |   6 +-
 board/freescale/p1010rdb/p1010rdb.c   |   6 +-
 board/freescale/p1010rdb/spl.c|   2 +-
 board/freescale/p1010rdb/spl_minimal.c|   2 +-
 board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c   |  12 +-
 board/freescale/p1_p2_rdb_pc/spl.c|   2 +-
 board/freescale/p1_p2_rdb_pc/spl_minimal.c|   2 +-
 board/freescale/p2041rdb/p2041rdb.c   |   4 +-
 board/freescale/t102xrdb/eth_t102xrdb.c   |   2 +-
 board/freescale/t102xrdb/spl.c|   6 +-
 board/freescale/t102xrdb/t102xrdb.c   |  16 +-
 board/freescale/t104xrdb/eth.c|   2 +-
 board/freescale/t104xrdb/spl.c|   2 +-
 board/freescale/t104xrdb/t104xrdb.c   |   2 +-
 board/freescale/t208xqds/eth_t208xqds.c   |   6 +-
 board/freescale/t208xqds/spl.c|   2 +-
 board/freescale/t208xqds/t208xqds.c   |   2 +-
 board/freescale/t208xrdb/spl.c|   2 +-
 board/freescale/t4rdb/eth.c   |   2 +-
 board/freescale/t4rdb/spl.c   |   2 +-
 board/keymile/kmcent2/kmcent2.c   |   6 +-
 board/socrates/socrates.c |   6 +-
 board/xes/common/fsl_8xxx_clk.c   |   4 +-
 board/xes/common/fsl_8xxx_misc.c  |   2 +-
 drivers/ddr/fsl/mpc85xx_ddr_gen2.c|   2 +-
 drivers/ddr/fsl/mpc85xx_ddr_gen3.c|   2 +-
 drivers/dma/fsl_dma.c |   4 +-
 drivers/net/fm/b4860.c|   8 +-
 drivers/net/fm/p1023.c|   8 +-
 drivers/net/fm/p4080.c|   8 +-
 drivers/net/fm/p5020.c|   8 +-
 drivers/net/fm/p5040.c|   8 +-
 drivers/net/fm/t1024.c|   6 +-
 drivers/net/fm/t1040.c|   2 +-
 drivers/net/fm/t2080.c|   6 +-
 drivers/net/fm/t4240.c|   8 +-
 drivers/qe/qe.c   |   6 +-
 drivers/qe/uec.c  |   4 +-
 drivers/spi/fsl_espi.c|   2 +-
 include/configs/MPC837XERDB.h |   2 +-
 include/configs/P1010RDB.h|   2 +-
 include/configs/P2041RDB.h|   2 +-
 include/configs/T102xRDB.h|   2 +-
 include/configs/T104xRDB.h|   2 +-
 include/configs/T208xQDS.h|   2 +-
 include/configs/T208xRDB.h|   2 +-
 include/configs/T4240RDB.h|   2 +-
 include/configs/p1_p2_rdb_pc.h|   2 +-
 include/post.h|   2 +-
 82 files changed, 304 insertions(+), 304 deletions(-)

diff --git a/arch/powerpc/cpu/mpc85xx/bsc9132_serdes.c 
b/arch/powerpc/cpu/mpc85xx/bsc9132_serdes.c
index b972cf3b5e45..792133482740 100644
--- a/arch/powerpc/cpu/mpc85xx/bsc9132_serdes.c
+++ b/arch/powerpc/cpu/mpc85xx/bsc9132_serdes.c
@@ -76,7 +76

[PATCH 17/21] Convert CONFIG_SYS_NONCACHED_MEMORY to Kconfig

2022-10-28 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_NONCACHED_MEMORY

To do this we introduce CONFIG_SYS_HAS_NONCACHED_MEMORY as a bool to
gate if we are going to have noncached_... functions available and then
continue to use CONFIG_SYS_NONCACHED_MEMORY to store the size of said
cache. We make this new option depend on both the architectures which
implement support and the drivers which make use of it.

Cc: Tom Warren 
Cc: Mingming lee 
Cc: "Ying-Chun Liu (PaulLiu)" 
Cc: Alban Bedel 
Cc: Stephen Warren 
Cc: Marcel Ziswiler 
Cc: Allen Martin 
Signed-off-by: Tom Rini 
---
I'm cc'ing a bunch of board maintainers here because restricting the
noncached support to these drivers results in the noncached framework
not being used, but also doesn't change anything else about the binary.
Is there some other use case here I'm missing?
---
 README | 19 -
 arch/Kconfig   | 24 ++
 configs/apalis-tk1_defconfig   |  1 +
 configs/apalis_t30_defconfig   |  1 +
 configs/beaver_defconfig   |  1 +
 configs/cardhu_defconfig   |  1 +
 configs/cei-tk1-som_defconfig  |  1 +
 configs/colibri_t20_defconfig  |  1 +
 configs/colibri_t30_defconfig  |  1 +
 configs/dalmore_defconfig  |  1 +
 configs/harmony_defconfig  |  1 +
 configs/imx8mp_rsb3720a1_4G_defconfig  |  1 +
 configs/imx8mp_rsb3720a1_6G_defconfig  |  1 +
 configs/jetson-tk1_defconfig   |  1 +
 configs/medcom-wide_defconfig  |  1 +
 configs/mt7621_nand_rfb_defconfig  |  1 +
 configs/mt7621_rfb_defconfig   |  1 +
 configs/mt7622_rfb_defconfig   |  1 +
 configs/mt7623a_unielec_u7623_02_defconfig |  1 +
 configs/mt7623n_bpir2_defconfig|  1 +
 configs/mt7629_rfb_defconfig   |  1 +
 configs/mt7981_emmc_rfb_defconfig  |  1 +
 configs/mt7981_rfb_defconfig   |  1 +
 configs/mt7981_sd_rfb_defconfig|  1 +
 configs/mt7986_rfb_defconfig   |  1 +
 configs/mt7986a_bpir3_emmc_defconfig   |  1 +
 configs/mt7986a_bpir3_sd_defconfig |  1 +
 configs/mt8512_bm1_emmc_defconfig  |  1 +
 configs/mt8518_ap1_emmc_defconfig  |  1 +
 configs/nyan-big_defconfig |  1 +
 configs/p2371-_defconfig   |  1 +
 configs/p2371-2180_defconfig   |  1 +
 configs/p2571_defconfig|  1 +
 configs/p2771--000_defconfig   |  1 +
 configs/p2771--500_defconfig   |  1 +
 configs/p3450-_defconfig   |  1 +
 configs/paz00_defconfig|  1 +
 configs/plutux_defconfig   |  1 +
 configs/seaboard_defconfig |  1 +
 configs/tec-ng_defconfig   |  1 +
 configs/tec_defconfig  |  1 +
 configs/trimslice_defconfig|  1 +
 configs/venice2_defconfig  |  1 +
 configs/ventana_defconfig  |  1 +
 include/configs/imx8mp_rsb3720.h   |  4 
 include/configs/mt7621.h   |  2 --
 include/configs/mt7622.h   |  4 
 include/configs/mt7623.h   |  2 --
 include/configs/mt7629.h   |  2 --
 include/configs/mt7981.h   |  4 
 include/configs/mt7986.h   |  4 
 include/configs/mt8512.h   |  4 
 include/configs/mt8518.h   |  5 -
 include/configs/tegra-common-post.h|  2 --
 54 files changed, 66 insertions(+), 52 deletions(-)

diff --git a/README b/README
index ee63a115fa91..edbcc02444a9 100644
--- a/README
+++ b/README
@@ -1547,25 +1547,6 @@ Configuration Settings:
boards which do not use the full malloc in SPL (which is
enabled with CONFIG_SYS_SPL_MALLOC).
 
-- CONFIG_SYS_NONCACHED_MEMORY:
-   Size of non-cached memory area. This area of memory will be
-   typically located right below the malloc() area and mapped
-   uncached in the MMU. This is useful for drivers that would
-   otherwise require a lot of explicit cache maintenance. For
-   some drivers it's also impossible to properly maintain the
-   cache. For example if the regions that need to be flushed
-   are not a multiple of the cache-line size, *and* padding
-   cannot be allocated between the regions to align them (i.e.
-   if the HW requires a contiguous array of regions, and the
-   size of each region is not cache-aligned), then a flush of
-   one region may result in overwriting data that hardware has
-   written to another region in the same cache-line. This can
-   happen for example in network drivers where descriptors for
-   

[PATCH 16/21] SYS_NONCACHED_MEMORY: Correct comment in common/board_f.c

2022-10-28 Thread Tom Rini
The comment block in reserve_noncached has a typo in one filename and
an incorrect filename in another function reference. Correct both of
these.

Signed-off-by: Tom Rini 
---
 common/board_f.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index 4355d1c82d4b..3cbf675e63c8 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -480,8 +480,8 @@ static int reserve_noncached(void)
 {
/*
 * The value of gd->start_addr_sp must match the value of malloc_start
-* calculated in boatrd_f.c:initr_malloc(), which is passed to
-* board_r.c:mem_malloc_init() and then used by
+* calculated in board_r.c:initr_malloc(), which is passed to
+* dlmalloc.c:mem_malloc_init() and then used by
 * cache.c:noncached_init()
 *
 * These calculations must match the code in cache.c:noncached_init()
-- 
2.25.1



[PATCH 10/21] rtc: Remove unused drivers

2022-10-28 Thread Tom Rini
These drivers are not enabled anywhere, remove them.

Signed-off-by: Tom Rini 
---
 drivers/rtc/Makefile   |   4 -
 drivers/rtc/m41t11.c   | 168 --
 drivers/rtc/m41t60.c   | 239 -
 drivers/rtc/m41t94.c   | 123 ---
 drivers/rtc/m48t35ax.c | 135 -
 include/configs/m53menlo.h |   1 -
 6 files changed, 670 deletions(-)
 delete mode 100644 drivers/rtc/m41t11.c
 delete mode 100644 drivers/rtc/m41t60.c
 delete mode 100644 drivers/rtc/m41t94.c
 delete mode 100644 drivers/rtc/m48t35ax.c

diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index d621be622848..009dd9d28c95 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -27,11 +27,7 @@ obj-$(CONFIG_RTC_FTRTC010) += ftrtc010.o
 obj-$(CONFIG_SANDBOX) += i2c_rtc_emul.o
 obj-$(CONFIG_RTC_IMXDI) += imxdi.o
 obj-$(CONFIG_RTC_ISL1208) += isl1208.o
-obj-$(CONFIG_RTC_M41T11) += m41t11.o
-obj-$(CONFIG_RTC_M41T60) += m41t60.o
 obj-$(CONFIG_RTC_M41T62) += m41t62.o
-obj-$(CONFIG_RTC_M41T94) += m41t94.o
-obj-$(CONFIG_RTC_M48T35A) += m48t35ax.o
 obj-$(CONFIG_RTC_MAX6900) += max6900.o
 obj-$(CONFIG_RTC_MC13XXX) += mc13xxx-rtc.o
 obj-$(CONFIG_RTC_MC146818) += mc146818.o
diff --git a/drivers/rtc/m41t11.c b/drivers/rtc/m41t11.c
deleted file mode 100644
index 706b7188cf83..
--- a/drivers/rtc/m41t11.c
+++ /dev/null
@@ -1,168 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2002
- * Andrew May, Viasat Inc, a...@viasat.com
- */
-
-/*
- * M41T11 Serial Access Timekeeper(R) SRAM
- * can you believe a trademark on that?
- */
-
-/* #define DEBUG 1 */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/*
-   I Don't have an example config file but this
-   is what should be done.
-
-#define CONFIG_RTC_M41T11 1
-#define CONFIG_SYS_I2C_RTC_ADDR 0x68
-#if 0
-#define CONFIG_SYS_M41T11_EXT_CENTURY_DATA
-#else
-#define CONFIG_SYS_M41T11_BASE_YEAR 2000
-#endif
-*/
-
-/* - */
-/*
-  these are simple defines for the chip local to here so they aren't too
-  verbose
-  DAY/DATE aren't nice but that is how they are on the data sheet
-*/
-#define RTC_SEC_ADDR   0x0
-#define RTC_MIN_ADDR   0x1
-#define RTC_HOUR_ADDR  0x2
-#define RTC_DAY_ADDR   0x3
-#define RTC_DATE_ADDR  0x4
-#define RTC_MONTH_ADDR 0x5
-#define RTC_YEARS_ADDR 0x6
-
-#define RTC_REG_CNT7
-
-#define RTC_CONTROL_ADDR   0x7
-
-
-#ifndef CONFIG_SYS_M41T11_EXT_CENTURY_DATA
-
-#define REG_CNT(RTC_REG_CNT+1)
-
-/*
-  you only get 00-99 for the year we will asume you
-  want from the year 2000 if you don't set the config
-*/
-#ifndef CONFIG_SYS_M41T11_BASE_YEAR
-#define CONFIG_SYS_M41T11_BASE_YEAR 2000
-#endif
-
-#else
-/* we will store extra year info in byte 9*/
-#define M41T11_YEAR_DATA   0x8
-#define M41T11_YEAR_SIZE   1
-#define REG_CNT(RTC_REG_CNT+1+M41T11_YEAR_SIZE)
-#endif
-
-#define M41T11_STORAGE_SZ  (64-REG_CNT)
-
-int rtc_get (struct rtc_time *tmp)
-{
-   int rel = 0;
-   uchar data[RTC_REG_CNT];
-
-   i2c_read(CONFIG_SYS_I2C_RTC_ADDR, RTC_SEC_ADDR, 1, data, RTC_REG_CNT);
-
-   if( data[RTC_SEC_ADDR] & 0x80 ){
-   printf( "m41t11 RTC Clock stopped!!!\n" );
-   rel = -1;
-   }
-   tmp->tm_sec  = bcd2bin (data[RTC_SEC_ADDR]  & 0x7F);
-   tmp->tm_min  = bcd2bin (data[RTC_MIN_ADDR]  & 0x7F);
-   tmp->tm_hour = bcd2bin (data[RTC_HOUR_ADDR] & 0x3F);
-   tmp->tm_mday = bcd2bin (data[RTC_DATE_ADDR] & 0x3F);
-   tmp->tm_mon  = bcd2bin (data[RTC_MONTH_ADDR]& 0x1F);
-#ifndef CONFIG_SYS_M41T11_EXT_CENTURY_DATA
-   tmp->tm_year = CONFIG_SYS_M41T11_BASE_YEAR
-   + bcd2bin(data[RTC_YEARS_ADDR])
-   + ((data[RTC_HOUR_ADDR]&0x40) ? 100 : 0);
-#else
-   {
-   unsigned char cent;
-   i2c_read(CONFIG_SYS_I2C_RTC_ADDR, M41T11_YEAR_DATA, 1, ¢, 
M41T11_YEAR_SIZE);
-   if( !(data[RTC_HOUR_ADDR] & 0x80) ){
-   printf( "m41t11 RTC: cann't keep track of years without 
CEB set\n" );
-   rel = -1;
-   }
-   if( (cent & 0x1) != ((data[RTC_HOUR_ADDR]&0x40)>>7) ){
-   /*century flip store off new year*/
-   cent += 1;
-   i2c_write(CONFIG_SYS_I2C_RTC_ADDR, M41T11_YEAR_DATA, 1, 
¢, M41T11_YEAR_SIZE);
-   }
-   tmp->tm_year =((int)cent*100)+bcd2bin(data[RTC_YEARS_ADDR]);
-   }
-#endif
-   tmp->tm_wday = bcd2bin (data[RTC_DAY_ADDR]  & 0x07);
-   tmp->tm_yday = 0;
-   tmp->tm_isdst= 0;
-
-   debug("Get DATE: %4d-%02d-%02d (wday=%d)  TIME: %2d:%02d:%02d\n",
- tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
- tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
-
-   return rel;
-}
-
-int rtc_set (struct rtc_time *tmp)
-{
-   uchar data[RTC_RE

[PATCH 15/21] mediatek: Include where needed

2022-10-28 Thread Tom Rini
These files reference SZ_ macros without including ,
correct this.

Signed-off-by: Tom Rini 
---
 arch/arm/mach-mediatek/mt7981/init.c | 1 +
 arch/arm/mach-mediatek/mt7986/init.c | 1 +
 arch/arm/mach-mediatek/mt8512/init.c | 1 +
 drivers/spi/mtk_spim.c   | 1 +
 4 files changed, 4 insertions(+)

diff --git a/arch/arm/mach-mediatek/mt7981/init.c 
b/arch/arm/mach-mediatek/mt7981/init.c
index 4f77a3defb02..a8955064e031 100644
--- a/arch/arm/mach-mediatek/mt7981/init.c
+++ b/arch/arm/mach-mediatek/mt7981/init.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/arch/arm/mach-mediatek/mt7986/init.c 
b/arch/arm/mach-mediatek/mt7986/init.c
index 0fd459657d99..cf89e63e80ad 100644
--- a/arch/arm/mach-mediatek/mt7986/init.c
+++ b/arch/arm/mach-mediatek/mt7986/init.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/arch/arm/mach-mediatek/mt8512/init.c 
b/arch/arm/mach-mediatek/mt8512/init.c
index b7050dfc3922..5a21e9a4485c 100644
--- a/arch/arm/mach-mediatek/mt8512/init.c
+++ b/arch/arm/mach-mediatek/mt8512/init.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/drivers/spi/mtk_spim.c b/drivers/spi/mtk_spim.c
index b45ef529a505..a7c0fc593fb1 100644
--- a/drivers/spi/mtk_spim.c
+++ b/drivers/spi/mtk_spim.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define SPI_CFG0_REG   0x
 #define SPI_CFG1_REG   0x0004
-- 
2.25.1



[PATCH 13/21] Convert CONFIG_SYS_MMC_MAX_DEVICE to Kconfig

2022-10-28 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_MMC_MAX_DEVICE

Signed-off-by: Tom Rini 
---
 api/Kconfig|  5 +
 api/api_storage.c  |  4 
 include/configs/am335x_evm.h   | 18 --
 include/configs/stm32mp13_common.h |  3 ---
 include/configs/stm32mp15_common.h |  3 ---
 include/configs/sunxi-common.h |  2 --
 include/configs/tegra-common.h |  7 ---
 include/configs/zynq-common.h  |  3 ---
 8 files changed, 5 insertions(+), 40 deletions(-)

diff --git a/api/Kconfig b/api/Kconfig
index 382aa4ad3f02..eb8d5d0596a7 100644
--- a/api/Kconfig
+++ b/api/Kconfig
@@ -5,4 +5,9 @@ config API
help
  This option enables the U-Boot API. See api/README for more 
information.
 
+config SYS_MMC_MAX_DEVICE
+   int  "Maximum number of MMC devices exposed via the API"
+   depends on API
+   default 1
+
 endmenu
diff --git a/api/api_storage.c b/api/api_storage.c
index adca44b4fd22..997e8727a965 100644
--- a/api/api_storage.c
+++ b/api/api_storage.c
@@ -44,10 +44,6 @@ struct stor_spec {
 
 static struct stor_spec specs[ENUM_MAX] = { { 0, 0, 0, 0, NULL }, };
 
-#ifndef CONFIG_SYS_MMC_MAX_DEVICE
-#define CONFIG_SYS_MMC_MAX_DEVICE  1
-#endif
-
 void dev_stor_init(void)
 {
 #if defined(CONFIG_IDE)
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index bd7e2f1bf503..8eefaf24b28d 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -192,24 +192,6 @@
DFU_ALT_INFO_NAND
 #endif
 
-/*
- * Default to using SPI for environment, etc.
- * 0x00 - 0x02 : SPL (128KiB)
- * 0x02 - 0x0A : U-Boot (512KiB)
- * 0x0A - 0x0B : First copy of U-Boot Environment (128KiB)
- * 0x0C - 0x0D : Second copy of U-Boot Environment (128KiB)
- * 0x0E - 0x442000 : Linux Kernel
- * 0x442000 - 0x80 : Userland
- */
-#if defined(CONFIG_SPI_BOOT)
-/* SPL related */
-#elif defined(CONFIG_EMMC_BOOT)
-#define CONFIG_SYS_MMC_MAX_DEVICE  2
-#endif
-
-/* Network. */
-/* Enable Atheros phy driver */
-
 /*
  * NOR Size = 16 MiB
  * Number of Sectors/Blocks = 128
diff --git a/include/configs/stm32mp13_common.h 
b/include/configs/stm32mp13_common.h
index 222e69c20c01..07a5bfc8a86e 100644
--- a/include/configs/stm32mp13_common.h
+++ b/include/configs/stm32mp13_common.h
@@ -21,9 +21,6 @@
  */
 #define CONFIG_SYS_BOOTMAPSZ   SZ_256M
 
-/*MMC SD*/
-#define CONFIG_SYS_MMC_MAX_DEVICE  2
-
 /* NAND support */
 
 /*/
diff --git a/include/configs/stm32mp15_common.h 
b/include/configs/stm32mp15_common.h
index 9dad2a8ebdca..66b4638b312f 100644
--- a/include/configs/stm32mp15_common.h
+++ b/include/configs/stm32mp15_common.h
@@ -21,9 +21,6 @@
  */
 #define CONFIG_SYS_BOOTMAPSZ   SZ_256M
 
-/*MMC SD*/
-#define CONFIG_SYS_MMC_MAX_DEVICE  3
-
 /* NAND support */
 
 /* Ethernet need */
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 93a56b5c575b..183af45f556f 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -78,8 +78,6 @@
 /* mmc config */
 #define CONFIG_MMC_SUNXI_SLOT  0
 
-#define CONFIG_SYS_MMC_MAX_DEVICE  4
-
 /*
  * Miscellaneous configurable options
  */
diff --git a/include/configs/tegra-common.h b/include/configs/tegra-common.h
index 159ba093f299..2915db7f8bf7 100644
--- a/include/configs/tegra-common.h
+++ b/include/configs/tegra-common.h
@@ -28,13 +28,6 @@
  */
 #define CONFIG_SYS_NS16550_CLK V_NS16550_CLK
 
-/*
- * Common HW configuration.
- * If this varies between SoCs later, move to tegraNN-common.h
- * Note: This is number of devices, not max device ID.
- */
-#define CONFIG_SYS_MMC_MAX_DEVICE 4
-
 #ifdef CONFIG_ARM64
 #define FDTFILE "nvidia/" CONFIG_DEFAULT_DEVICE_TREE ".dtb"
 #else
diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h
index e194e77e5b77..6574cf92e26e 100644
--- a/include/configs/zynq-common.h
+++ b/include/configs/zynq-common.h
@@ -195,9 +195,6 @@
 
 /* Extend size of kernel image for uncompression */
 
-/* Boot FreeBSD/vxWorks from an ELF image */
-#define CONFIG_SYS_MMC_MAX_DEVICE  1
-
 /* Address in RAM where the parameters must be copied by SPL. */
 
 /* Not using MMC raw mode - just for compilation purpose */
-- 
2.25.1



[PATCH 09/21] Convert CONFIG_SYS_LOADS_BAUD_CHANGE et al to Kconfig

2022-10-28 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_LOADS_BAUD_CHANGE
   CONFIG_LOADS_ECHO

As part of this, we move CMD_SAVES to be after CMD_LOADS as they are
logically related (load or save an s-record format file) and this makes
grouping of CONFIG_SYS_LOADS_BAUD_CHANGE easier.

Signed-off-by: Tom Rini 
---
 README   | 12 -
 cmd/Kconfig  | 28 +++-
 configs/MPC837XERDB_defconfig|  2 ++
 configs/MPC8548CDS_36BIT_defconfig   |  2 ++
 configs/MPC8548CDS_defconfig |  2 ++
 configs/MPC8548CDS_legacy_defconfig  |  2 ++
 configs/P1010RDB-PA_36BIT_NAND_defconfig |  2 ++
 configs/P1010RDB-PA_36BIT_NOR_defconfig  |  2 ++
 configs/P1010RDB-PA_36BIT_SDCARD_defconfig   |  2 ++
 configs/P1010RDB-PA_36BIT_SPIFLASH_defconfig |  2 ++
 configs/P1010RDB-PA_NAND_defconfig   |  2 ++
 configs/P1010RDB-PA_NOR_defconfig|  2 ++
 configs/P1010RDB-PA_SDCARD_defconfig |  2 ++
 configs/P1010RDB-PA_SPIFLASH_defconfig   |  2 ++
 configs/P1010RDB-PB_36BIT_NAND_defconfig |  2 ++
 configs/P1010RDB-PB_36BIT_NOR_defconfig  |  2 ++
 configs/P1010RDB-PB_36BIT_SDCARD_defconfig   |  2 ++
 configs/P1010RDB-PB_36BIT_SPIFLASH_defconfig |  2 ++
 configs/P1010RDB-PB_NAND_defconfig   |  2 ++
 configs/P1010RDB-PB_NOR_defconfig|  2 ++
 configs/P1010RDB-PB_SDCARD_defconfig |  2 ++
 configs/P1010RDB-PB_SPIFLASH_defconfig   |  2 ++
 configs/P1020RDB-PC_36BIT_NAND_defconfig |  2 ++
 configs/P1020RDB-PC_36BIT_SDCARD_defconfig   |  2 ++
 configs/P1020RDB-PC_36BIT_SPIFLASH_defconfig |  2 ++
 configs/P1020RDB-PC_36BIT_defconfig  |  2 ++
 configs/P1020RDB-PC_NAND_defconfig   |  2 ++
 configs/P1020RDB-PC_SDCARD_defconfig |  2 ++
 configs/P1020RDB-PC_SPIFLASH_defconfig   |  2 ++
 configs/P1020RDB-PC_defconfig|  2 ++
 configs/P1020RDB-PD_NAND_defconfig   |  2 ++
 configs/P1020RDB-PD_SDCARD_defconfig |  2 ++
 configs/P1020RDB-PD_SPIFLASH_defconfig   |  2 ++
 configs/P1020RDB-PD_defconfig|  2 ++
 configs/P2020RDB-PC_36BIT_NAND_defconfig |  2 ++
 configs/P2020RDB-PC_36BIT_SDCARD_defconfig   |  2 ++
 configs/P2020RDB-PC_36BIT_SPIFLASH_defconfig |  2 ++
 configs/P2020RDB-PC_36BIT_defconfig  |  2 ++
 configs/P2020RDB-PC_NAND_defconfig   |  2 ++
 configs/P2020RDB-PC_SDCARD_defconfig |  2 ++
 configs/P2020RDB-PC_SPIFLASH_defconfig   |  2 ++
 configs/P2020RDB-PC_defconfig|  2 ++
 configs/P2041RDB_NAND_defconfig  |  2 ++
 configs/P2041RDB_SDCARD_defconfig|  2 ++
 configs/P2041RDB_SPIFLASH_defconfig  |  2 ++
 configs/P2041RDB_defconfig   |  2 ++
 configs/T1024RDB_NAND_defconfig  |  2 ++
 configs/T1024RDB_SDCARD_defconfig|  2 ++
 configs/T1024RDB_SPIFLASH_defconfig  |  2 ++
 configs/T1024RDB_defconfig   |  2 ++
 configs/T1042D4RDB_NAND_defconfig|  2 ++
 configs/T1042D4RDB_SDCARD_defconfig  |  2 ++
 configs/T1042D4RDB_SPIFLASH_defconfig|  2 ++
 configs/T1042D4RDB_defconfig |  2 ++
 configs/T2080QDS_NAND_defconfig  |  2 ++
 configs/T2080QDS_SDCARD_defconfig|  2 ++
 configs/T2080QDS_SECURE_BOOT_defconfig   |  2 ++
 configs/T2080QDS_SPIFLASH_defconfig  |  2 ++
 configs/T2080QDS_SRIO_PCIE_BOOT_defconfig|  2 ++
 configs/T2080QDS_defconfig   |  2 ++
 configs/T4240RDB_SDCARD_defconfig|  2 ++
 configs/T4240RDB_defconfig   |  2 ++
 configs/gazerbeam_defconfig  |  2 ++
 configs/kmcent2_defconfig|  2 ++
 configs/kmcoge5ne_defconfig  |  2 ++
 configs/kmeter1_defconfig|  2 ++
 configs/kmopti2_defconfig|  2 ++
 configs/kmsupx5_defconfig|  2 ++
 configs/kmtepr2_defconfig|  2 ++
 configs/pg_wcom_expu1_defconfig  |  2 ++
 configs/pg_wcom_expu1_update_defconfig   |  2 ++
 configs/pg_wcom_seli8_defconfig  |  2 ++
 configs/pg_wcom_seli8_update_defconfig   |  2 ++
 configs/qemu-ppce500_defconfig   |  1 +
 configs/socrates_defconfig   |  2 ++
 configs/tuge1_defconfig  |  2 ++
 configs/tuxx1_defconfig  |  2 ++
 include/configs/MCR3000.h|  2 --
 include/configs/MPC837XERDB.h|  7 -
 include/configs/MPC8548CDS.h |  7 -
 include/configs/P1010RDB.h   |  3 ---
 include/configs/P2041RDB.h   |  6 -
 include/configs/T102xRDB.h   |  6 -
 include/configs/T104xRDB.h   |  6 -
 include/configs/T208xQDS.h   |  6 -
 include/configs/T4240RDB.h   |  6 -

[PATCH 11/21] Convert CONFIG_SYS_MAX_NAND_DEVICE to Kconfig

2022-10-28 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_MAX_NAND_DEVICE

Signed-off-by: Tom Rini 
---
 configs/CHIP_pro_defconfig  | 1 +
 configs/Nintendo_NES_Classic_Edition_defconfig  | 1 +
 configs/etamin_defconfig| 1 +
 doc/README.nand | 3 ---
 drivers/mtd/nand/raw/Kconfig| 4 
 include/configs/M5329EVB.h  | 1 -
 include/configs/M5373EVB.h  | 1 -
 include/configs/MCR3000.h   | 1 -
 include/configs/P1010RDB.h  | 1 -
 include/configs/P2041RDB.h  | 1 -
 include/configs/T102xRDB.h  | 1 -
 include/configs/T104xRDB.h  | 1 -
 include/configs/T208xQDS.h  | 1 -
 include/configs/T208xRDB.h  | 1 -
 include/configs/T4240RDB.h  | 1 -
 include/configs/at91sam9260ek.h | 1 -
 include/configs/at91sam9261ek.h | 1 -
 include/configs/at91sam9263ek.h | 1 -
 include/configs/at91sam9m10g45ek.h  | 1 -
 include/configs/at91sam9n12ek.h | 1 -
 include/configs/at91sam9rlek.h  | 1 -
 include/configs/at91sam9x5ek.h  | 1 -
 include/configs/bk4r1.h | 1 -
 include/configs/broadcom_bcm963158.h| 4 
 include/configs/broadcom_bcm96753ref.h  | 4 
 include/configs/broadcom_bcm968360bg.h  | 4 
 include/configs/broadcom_bcm968380gerg.h| 3 ---
 include/configs/broadcom_bcm968580xref.h| 4 
 include/configs/cm_fx6.h| 1 -
 include/configs/colibri-imx6ull.h   | 1 -
 include/configs/colibri_imx7.h  | 1 -
 include/configs/colibri_t20.h   | 1 -
 include/configs/colibri_vf.h| 1 -
 include/configs/comtrend_vr3032u.h  | 3 ---
 include/configs/corvus.h| 1 -
 include/configs/da850evm.h  | 1 -
 include/configs/devkit3250.h| 1 -
 include/configs/etamin.h| 2 --
 include/configs/ethernut5.h | 1 -
 include/configs/gardena-smart-gateway-at91sam.h | 1 -
 include/configs/gw_ventana.h| 1 -
 include/configs/harmony.h   | 1 -
 include/configs/imx27lite-common.h  | 1 -
 include/configs/imx6-engicam.h  | 1 -
 include/configs/imx6_logic.h| 1 -
 include/configs/imx6ulz_smm_m2.h| 1 -
 include/configs/imx8mn_bsh_smm_s2.h | 1 -
 include/configs/imx8mp_rsb3720.h| 1 -
 include/configs/km/km-mpc83xx.h | 1 -
 include/configs/km/pg-wcom-ls102xa.h| 1 -
 include/configs/kmcent2.h   | 1 -
 include/configs/kmcoge5ne.h | 1 -
 include/configs/ls1021aqds.h| 1 -
 include/configs/ls1043aqds.h| 1 -
 include/configs/ls1043ardb.h| 1 -
 include/configs/ls1046afrwy.h   | 1 -
 include/configs/ls1046aqds.h| 1 -
 include/configs/ls1046ardb.h| 1 -
 include/configs/ls1088aqds.h| 1 -
 include/configs/ls1088ardb.h| 1 -
 include/configs/ls2080aqds.h| 1 -
 include/configs/ls2080ardb.h| 1 -
 include/configs/m53menlo.h  | 1 -
 include/configs/medcom-wide.h   | 1 -
 include/configs/meesc.h | 1 -
 include/configs/mt7621.h| 1 -
 include/configs/mv-common.h | 3 ---
 include/configs/mvebu_armada-8k.h   | 2 --
 include/configs/mx6sabreauto.h  | 1 -
 include/configs/mx6sxsabreauto.h| 1 -
 include/configs/mx7dsabresd.h   | 1 -
 include/configs/mxs.h   | 1 -
 include/configs/mys_6ulx.h  | 1 -
 include/configs/npi_imx6ull.h   | 1 -
 include/configs/octeontx_common.h   | 4 
 include/configs/omap3_beagle.h  | 1 -
 include/configs/omap3_evm.h | 1 -
 include/configs/omap3_logic.h   | 1 -
 include/configs/omapl138_lcdk.h | 1 -
 include/configs/p1_p2_rdb_pc.h  | 1 -
 include/configs/pcl063.h| 1 -
 include/configs/pcl063_ull.h| 1 -
 include/configs/pcm052.h| 2 --
 include/configs/pcm058.h| 1 -
 include/configs/plutux.h| 1 -
 include/configs/pm9261.h| 1 -
 include/configs/pm9263.h| 1 -
 include/configs/pm9g45.h| 1 -
 include/configs/presidio_asic

[PATCH 12/21] Convert CONFIG_SYS_MMC_MAX_BLK_COUNT to Kconfig

2022-10-28 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_MMC_MAX_BLK_COUNT

Signed-off-by: Tom Rini 
---
 configs/hikey960_defconfig  | 1 +
 configs/octeontx2_95xx_defconfig| 1 +
 configs/octeontx2_96xx_defconfig| 1 +
 configs/octeontx_81xx_defconfig | 1 +
 configs/octeontx_83xx_defconfig | 1 +
 configs/socfpga_agilex_atf_defconfig| 1 +
 configs/socfpga_agilex_defconfig| 1 +
 configs/socfpga_agilex_vab_defconfig| 1 +
 configs/socfpga_arria10_defconfig   | 1 +
 configs/socfpga_arria5_defconfig| 1 +
 configs/socfpga_cyclone5_defconfig  | 1 +
 configs/socfpga_dbm_soc1_defconfig  | 1 +
 configs/socfpga_de0_nano_soc_defconfig  | 1 +
 configs/socfpga_de10_nano_defconfig | 1 +
 configs/socfpga_de10_standard_defconfig | 1 +
 configs/socfpga_de1_soc_defconfig   | 1 +
 configs/socfpga_mcvevk_defconfig| 1 +
 configs/socfpga_n5x_atf_defconfig   | 1 +
 configs/socfpga_n5x_defconfig   | 1 +
 configs/socfpga_n5x_vab_defconfig   | 1 +
 configs/socfpga_secu1_defconfig | 1 +
 configs/socfpga_sockit_defconfig| 1 +
 configs/socfpga_socrates_defconfig  | 1 +
 configs/socfpga_sr1500_defconfig| 1 +
 configs/socfpga_stratix10_atf_defconfig | 1 +
 configs/socfpga_stratix10_defconfig | 1 +
 configs/socfpga_vining_fpga_defconfig   | 1 +
 configs/total_compute_defconfig | 1 +
 configs/vexpress_ca9x4_defconfig| 1 +
 drivers/mmc/Kconfig | 7 +++
 include/configs/hikey960.h  | 1 -
 include/configs/octeontx2_common.h  | 2 --
 include/configs/octeontx_common.h   | 2 --
 include/configs/socfpga_common.h| 9 -
 include/configs/socfpga_soc64_common.h  | 3 ---
 include/configs/total_compute.h | 2 --
 include/configs/vexpress_common.h   | 2 --
 include/mmc.h   | 5 -
 38 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/configs/hikey960_defconfig b/configs/hikey960_defconfig
index f212f3b91642..153260d93cc6 100644
--- a/configs/hikey960_defconfig
+++ b/configs/hikey960_defconfig
@@ -29,6 +29,7 @@ CONFIG_ENV_IS_IN_EXT4=y
 CONFIG_ENV_EXT4_INTERFACE="mmc"
 CONFIG_ENV_EXT4_DEVICE_AND_PART="0:2"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_MAX_BLK_COUNT=1024
 CONFIG_MMC_DW=y
 CONFIG_MMC_DW_K3=y
 CONFIG_PINCTRL=y
diff --git a/configs/octeontx2_95xx_defconfig b/configs/octeontx2_95xx_defconfig
index 700d49ebeda3..de860235152f 100644
--- a/configs/octeontx2_95xx_defconfig
+++ b/configs/octeontx2_95xx_defconfig
@@ -83,6 +83,7 @@ CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_TFTP_TSIZE=y
 CONFIG_DM_I2C=y
 CONFIG_MISC=y
+CONFIG_SYS_MMC_MAX_BLK_COUNT=8192
 CONFIG_SUPPORT_EMMC_RPMB=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_HS400_SUPPORT=y
diff --git a/configs/octeontx2_96xx_defconfig b/configs/octeontx2_96xx_defconfig
index fe67c4860a11..3945b8b1e78e 100644
--- a/configs/octeontx2_96xx_defconfig
+++ b/configs/octeontx2_96xx_defconfig
@@ -89,6 +89,7 @@ CONFIG_I2C_SET_DEFAULT_BUS_NUM=y
 CONFIG_I2C_MUX=y
 CONFIG_I2C_MUX_PCA954x=y
 CONFIG_MISC=y
+CONFIG_SYS_MMC_MAX_BLK_COUNT=8192
 CONFIG_SUPPORT_EMMC_RPMB=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_HS400_SUPPORT=y
diff --git a/configs/octeontx_81xx_defconfig b/configs/octeontx_81xx_defconfig
index c4a22cfd7f22..2be23524bc4b 100644
--- a/configs/octeontx_81xx_defconfig
+++ b/configs/octeontx_81xx_defconfig
@@ -87,6 +87,7 @@ CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_DM_I2C=y
 CONFIG_MISC=y
+CONFIG_SYS_MMC_MAX_BLK_COUNT=8192
 CONFIG_SUPPORT_EMMC_RPMB=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_OCTEONTX=y
diff --git a/configs/octeontx_83xx_defconfig b/configs/octeontx_83xx_defconfig
index 4bd662a3180d..9417ab723839 100644
--- a/configs/octeontx_83xx_defconfig
+++ b/configs/octeontx_83xx_defconfig
@@ -84,6 +84,7 @@ CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_DM_I2C=y
 CONFIG_MISC=y
+CONFIG_SYS_MMC_MAX_BLK_COUNT=8192
 CONFIG_SUPPORT_EMMC_RPMB=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_OCTEONTX=y
diff --git a/configs/socfpga_agilex_atf_defconfig 
b/configs/socfpga_agilex_atf_defconfig
index 4356171c143e..43b9f5c18460 100644
--- a/configs/socfpga_agilex_atf_defconfig
+++ b/configs/socfpga_agilex_atf_defconfig
@@ -71,6 +71,7 @@ CONFIG_SPL_ALTERA_SDRAM=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_DW=y
+CONFIG_SYS_MMC_MAX_BLK_COUNT=256
 CONFIG_MMC_DW=y
 CONFIG_MTD=y
 CONFIG_SF_DEFAULT_MODE=0x2003
diff --git a/configs/socfpga_agilex_defconfig b/configs/socfpga_agilex_defconfig
index 0603dd15ecbe..fabb2d25f47a 100644
--- a/configs/socfpga_agilex_defconfig
+++ b/configs/socfpga_agilex_defconfig
@@ -65,6 +65,7 @@ CONFIG_SPL_ALTERA_SDRAM=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_DW=y
+CONFIG_SYS_MMC_MAX_BLK_COUNT=256
 CONFIG_MMC_DW=y
 CONFIG_SF_DEFAULT_MODE=0x2003
 CONFIG_SPI_FLASH_SPANSION=y
diff --git a/configs/socfpga_agilex_vab_defconfig 
b/configs/socfpga_agilex_vab_defconfig
index f568f5525ea6..911562710cd4 100644
--- a/configs/socfpga_a

[PATCH 02/21] Convert CONFIG_SYS_INIT_RAM_LOCK to Kconfig

2022-10-28 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_INIT_RAM_LOCK

Signed-off-by: Tom Rini 
---
 arch/powerpc/Kconfig | 4 
 arch/powerpc/include/asm/cache.h | 2 --
 configs/MPC837XERDB_defconfig| 1 +
 configs/MPC8548CDS_36BIT_defconfig   | 1 +
 configs/MPC8548CDS_defconfig | 1 +
 configs/MPC8548CDS_legacy_defconfig  | 1 +
 configs/P1010RDB-PA_36BIT_NAND_defconfig | 1 +
 configs/P1010RDB-PA_36BIT_NOR_defconfig  | 1 +
 configs/P1010RDB-PA_36BIT_SDCARD_defconfig   | 1 +
 configs/P1010RDB-PA_36BIT_SPIFLASH_defconfig | 1 +
 configs/P1010RDB-PA_NAND_defconfig   | 1 +
 configs/P1010RDB-PA_NOR_defconfig| 1 +
 configs/P1010RDB-PA_SDCARD_defconfig | 1 +
 configs/P1010RDB-PA_SPIFLASH_defconfig   | 1 +
 configs/P1010RDB-PB_36BIT_NAND_defconfig | 1 +
 configs/P1010RDB-PB_36BIT_NOR_defconfig  | 1 +
 configs/P1010RDB-PB_36BIT_SDCARD_defconfig   | 1 +
 configs/P1010RDB-PB_36BIT_SPIFLASH_defconfig | 1 +
 configs/P1010RDB-PB_NAND_defconfig   | 1 +
 configs/P1010RDB-PB_NOR_defconfig| 1 +
 configs/P1010RDB-PB_SDCARD_defconfig | 1 +
 configs/P1010RDB-PB_SPIFLASH_defconfig   | 1 +
 configs/P1020RDB-PC_36BIT_NAND_defconfig | 1 +
 configs/P1020RDB-PC_36BIT_SDCARD_defconfig   | 1 +
 configs/P1020RDB-PC_36BIT_SPIFLASH_defconfig | 1 +
 configs/P1020RDB-PC_36BIT_defconfig  | 1 +
 configs/P1020RDB-PC_NAND_defconfig   | 1 +
 configs/P1020RDB-PC_SDCARD_defconfig | 1 +
 configs/P1020RDB-PC_SPIFLASH_defconfig   | 1 +
 configs/P1020RDB-PC_defconfig| 1 +
 configs/P1020RDB-PD_NAND_defconfig   | 1 +
 configs/P1020RDB-PD_SDCARD_defconfig | 1 +
 configs/P1020RDB-PD_SPIFLASH_defconfig   | 1 +
 configs/P1020RDB-PD_defconfig| 1 +
 configs/P2020RDB-PC_36BIT_NAND_defconfig | 1 +
 configs/P2020RDB-PC_36BIT_SDCARD_defconfig   | 1 +
 configs/P2020RDB-PC_36BIT_SPIFLASH_defconfig | 1 +
 configs/P2020RDB-PC_36BIT_defconfig  | 1 +
 configs/P2020RDB-PC_NAND_defconfig   | 1 +
 configs/P2020RDB-PC_SDCARD_defconfig | 1 +
 configs/P2020RDB-PC_SPIFLASH_defconfig   | 1 +
 configs/P2020RDB-PC_defconfig| 1 +
 configs/P2041RDB_NAND_defconfig  | 1 +
 configs/P2041RDB_SDCARD_defconfig| 1 +
 configs/P2041RDB_SPIFLASH_defconfig  | 1 +
 configs/P2041RDB_defconfig   | 1 +
 configs/T1024RDB_NAND_defconfig  | 1 +
 configs/T1024RDB_SDCARD_defconfig| 1 +
 configs/T1024RDB_SPIFLASH_defconfig  | 1 +
 configs/T1024RDB_defconfig   | 1 +
 configs/T1042D4RDB_NAND_defconfig| 1 +
 configs/T1042D4RDB_SDCARD_defconfig  | 1 +
 configs/T1042D4RDB_SPIFLASH_defconfig| 1 +
 configs/T1042D4RDB_defconfig | 1 +
 configs/T2080QDS_NAND_defconfig  | 1 +
 configs/T2080QDS_SDCARD_defconfig| 1 +
 configs/T2080QDS_SECURE_BOOT_defconfig   | 1 +
 configs/T2080QDS_SPIFLASH_defconfig  | 1 +
 configs/T2080QDS_SRIO_PCIE_BOOT_defconfig| 1 +
 configs/T2080QDS_defconfig   | 1 +
 configs/T2080RDB_NAND_defconfig  | 1 +
 configs/T2080RDB_SDCARD_defconfig| 1 +
 configs/T2080RDB_SPIFLASH_defconfig  | 1 +
 configs/T2080RDB_defconfig   | 1 +
 configs/T2080RDB_revD_NAND_defconfig | 1 +
 configs/T2080RDB_revD_SDCARD_defconfig   | 1 +
 configs/T2080RDB_revD_SPIFLASH_defconfig | 1 +
 configs/T2080RDB_revD_defconfig  | 1 +
 configs/T4240RDB_SDCARD_defconfig| 1 +
 configs/T4240RDB_defconfig   | 1 +
 configs/gazerbeam_defconfig  | 1 +
 configs/kmcent2_defconfig| 1 +
 configs/kmcoge5ne_defconfig  | 1 +
 configs/kmeter1_defconfig| 1 +
 configs/kmopti2_defconfig| 1 +
 configs/kmsupx5_defconfig| 1 +
 configs/kmtepr2_defconfig| 1 +
 configs/socrates_defconfig   | 1 +
 configs/tuge1_defconfig  | 1 +
 configs/tuxx1_defconfig  | 1 +
 include/configs/MPC837XERDB.h| 1 -
 include/configs/MPC8548CDS.h | 1 -
 include/configs/P1010RDB.h   | 1 -
 include/configs/P2041RDB.h   | 1 -
 include/configs/T102xRDB.h   | 1 -
 include/configs/T104xRDB.h   | 1 -
 include/configs/T208xQDS.h   | 1 -
 include/configs/T208xRDB.h   | 1 -
 include/configs/T4240RDB.h   | 1 -
 include/configs/gazerbeam.h  | 1 -
 include/configs/km/km-mpc83xx.h  | 1 -
 include/configs/kmcent2.h| 1 -
 include/configs/p1_p2_rdb_pc.h   | 1 -
 include/configs/socrates.h   | 1 -
 94 files

[PATCH 08/21] powerpc: Migrate SYS_L3_SIZE to Kconfig

2022-10-28 Thread Tom Rini
Introduce three options, one for each observed L3 cache size, and have
the size select'd as needed.

Signed-off-by: Tom Rini 
---
 arch/powerpc/cpu/mpc85xx/Kconfig | 24 
 include/configs/P2041RDB.h   |  2 --
 include/configs/T102xRDB.h   |  1 -
 include/configs/T104xRDB.h   |  1 -
 include/configs/T208xQDS.h   |  1 -
 include/configs/T208xRDB.h   |  1 -
 include/configs/T4240RDB.h   |  1 -
 include/configs/kmcent2.h|  1 -
 8 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/cpu/mpc85xx/Kconfig b/arch/powerpc/cpu/mpc85xx/Kconfig
index 7abfe26d35dd..24d3f1f20c25 100644
--- a/arch/powerpc/cpu/mpc85xx/Kconfig
+++ b/arch/powerpc/cpu/mpc85xx/Kconfig
@@ -165,6 +165,7 @@ config TARGET_P2041RDB
select BOARD_LATE_INIT if CHAIN_OF_TRUST
select FSL_CORENET
select PHYS_64BIT
+   select SYS_L3_SIZE_1024KB
imply CMD_SATA
imply FSL_SATA
 
@@ -182,6 +183,7 @@ config TARGET_T1024RDB
select SUPPORT_SPL
select PHYS_64BIT
select FSL_DDR_INTERACTIVE
+   select SYS_L3_SIZE_256KB
imply CMD_EEPROM
imply PANIC_HANG
 
@@ -191,6 +193,7 @@ config TARGET_T1042RDB
select BOARD_LATE_INIT if CHAIN_OF_TRUST
select SUPPORT_SPL
select PHYS_64BIT
+   select SYS_L3_SIZE_256KB
 
 config TARGET_T1042D4RDB
bool "Support T1042D4RDB"
@@ -198,6 +201,7 @@ config TARGET_T1042D4RDB
select BOARD_LATE_INIT if CHAIN_OF_TRUST
select SUPPORT_SPL
select PHYS_64BIT
+   select SYS_L3_SIZE_256KB
imply PANIC_HANG
 
 config TARGET_T1042RDB_PI
@@ -206,6 +210,7 @@ config TARGET_T1042RDB_PI
select BOARD_LATE_INIT if CHAIN_OF_TRUST
select SUPPORT_SPL
select PHYS_64BIT
+   select SYS_L3_SIZE_256KB
imply PANIC_HANG
 
 config TARGET_T2080QDS
@@ -216,6 +221,7 @@ config TARGET_T2080QDS
select PHYS_64BIT
select FSL_DDR_FIRST_SLOT_QUAD_CAPABLE
select FSL_DDR_INTERACTIVE
+   select SYS_L3_SIZE_512KB
imply CMD_SATA
 
 config TARGET_T2080RDB
@@ -224,6 +230,7 @@ config TARGET_T2080RDB
select BOARD_LATE_INIT if CHAIN_OF_TRUST
select SUPPORT_SPL
select PHYS_64BIT
+   select SYS_L3_SIZE_512KB
imply CMD_SATA
imply PANIC_HANG
 
@@ -233,6 +240,7 @@ config TARGET_T4240RDB
select SUPPORT_SPL
select PHYS_64BIT
select FSL_DDR_FIRST_SLOT_QUAD_CAPABLE
+   select SYS_L3_SIZE_512KB
imply CMD_SATA
imply PANIC_HANG
 
@@ -244,6 +252,7 @@ config TARGET_KMCENT2
bool "Support kmcent2"
select VENDOR_KM
select FSL_CORENET
+   select SYS_L3_SIZE_256KB
 
 endchoice
 
@@ -1296,6 +1305,21 @@ config SYS_L2_SIZE
 config BACKSIDE_L2_CACHE
bool
 
+config SYS_L3_SIZE_256KB
+   bool
+
+config SYS_L3_SIZE_512KB
+   bool
+
+config SYS_L3_SIZE_1024KB
+   bool
+
+config SYS_L3_SIZE
+   int
+   default 262144 if SYS_L3_SIZE_256KB
+   default 524288 if SYS_L3_SIZE_512KB
+   default 1048576 if SYS_L3_SIZE_512KB
+
 config SYS_PPC64
bool
 
diff --git a/include/configs/P2041RDB.h b/include/configs/P2041RDB.h
index 0bd3bac97e43..7ccde665607b 100644
--- a/include/configs/P2041RDB.h
+++ b/include/configs/P2041RDB.h
@@ -59,8 +59,6 @@
 #else
 #define CONFIG_SYS_INIT_L3_ADDR_PHYS   CONFIG_SYS_INIT_L3_ADDR
 #endif
-#define CONFIG_SYS_L3_SIZE (1024 << 10)
-#define CONFIG_SYS_INIT_L3_END (CONFIG_SYS_INIT_L3_ADDR + CONFIG_SYS_L3_SIZE)
 
 #ifdef CONFIG_PHYS_64BIT
 #define CONFIG_SYS_DCSRBAR 0xf000
diff --git a/include/configs/T102xRDB.h b/include/configs/T102xRDB.h
index 7630be245c1f..c5c2f8c038b2 100644
--- a/include/configs/T102xRDB.h
+++ b/include/configs/T102xRDB.h
@@ -104,7 +104,6 @@
  *  Config the L3 Cache as L3 SRAM
  */
 #define CONFIG_SYS_INIT_L3_ADDR0xFFFC
-#define CONFIG_SYS_L3_SIZE (256 << 10)
 #define SPL_ENV_ADDR   (CONFIG_SPL_GD_ADDR + 4 * 1024)
 
 #ifdef CONFIG_PHYS_64BIT
diff --git a/include/configs/T104xRDB.h b/include/configs/T104xRDB.h
index 19e3dfbfdb12..532a5541dc87 100644
--- a/include/configs/T104xRDB.h
+++ b/include/configs/T104xRDB.h
@@ -78,7 +78,6 @@
  * (CONFIG_SYS_INIT_L3_VADDR) will be different.
  */
 #define CONFIG_SYS_INIT_L3_VADDR   0xFFFC
-#define CONFIG_SYS_L3_SIZE 256 << 10
 #define SPL_ENV_ADDR   (CONFIG_SPL_GD_ADDR + 4 * 1024)
 
 #define CONFIG_SYS_DCSRBAR 0xf000
diff --git a/include/configs/T208xQDS.h b/include/configs/T208xQDS.h
index 6700560123b7..f97d0fc515b6 100644
--- a/include/configs/T208xQDS.h
+++ b/include/configs/T208xQDS.h
@@ -76,7 +76,6 @@
  * Config the L3 Cache as L3 SRAM
  */
 #define CONFIG_SYS_INIT_L3_ADDR0xFFFC
-#define CONFIG_SYS_L3_SIZE (512 << 10)
 #define SPL_ENV_ADDR   (CONFIG_SPL_GD_ADDR + 4 * 1024)
 
 #define CONFIG_SYS_DCSRBAR 

[PATCH 07/21] powerpc: Migrate SYS_L2_SIZE to Kconfig

2022-10-28 Thread Tom Rini
Introduce two options, one for each observed L2 cache size, and have the
size select'd as needed.

Signed-off-by: Tom Rini 
---
 arch/powerpc/cpu/mpc85xx/Kconfig | 16 
 include/configs/P1010RDB.h   |  3 ---
 include/configs/p1_p2_rdb_pc.h   |  3 ---
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/cpu/mpc85xx/Kconfig b/arch/powerpc/cpu/mpc85xx/Kconfig
index 27f069a1fb37..7abfe26d35dd 100644
--- a/arch/powerpc/cpu/mpc85xx/Kconfig
+++ b/arch/powerpc/cpu/mpc85xx/Kconfig
@@ -113,6 +113,7 @@ config TARGET_P1010RDB_PA
select BOARD_LATE_INIT if CHAIN_OF_TRUST
select SUPPORT_SPL
select SUPPORT_TPL
+   select SYS_L2_SIZE_256KB
imply CMD_EEPROM
imply CMD_SATA
imply PANIC_HANG
@@ -123,6 +124,7 @@ config TARGET_P1010RDB_PB
select BOARD_LATE_INIT if CHAIN_OF_TRUST
select SUPPORT_SPL
select SUPPORT_TPL
+   select SYS_L2_SIZE_256KB
imply CMD_EEPROM
imply CMD_SATA
imply PANIC_HANG
@@ -132,6 +134,7 @@ config TARGET_P1020RDB_PC
select SUPPORT_SPL
select SUPPORT_TPL
select ARCH_P1020
+   select SYS_L2_SIZE_256KB
imply CMD_EEPROM
imply CMD_SATA
imply PANIC_HANG
@@ -141,6 +144,7 @@ config TARGET_P1020RDB_PD
select SUPPORT_SPL
select SUPPORT_TPL
select ARCH_P1020
+   select SYS_L2_SIZE_256KB
imply CMD_EEPROM
imply CMD_SATA
imply PANIC_HANG
@@ -150,6 +154,7 @@ config TARGET_P2020RDB
select SUPPORT_SPL
select SUPPORT_TPL
select ARCH_P2020
+   select SYS_L2_SIZE_512KB
imply CMD_EEPROM
imply CMD_SATA
imply SATA_SIL
@@ -1277,6 +1282,17 @@ config SYS_ETVPE_CLK
default 1
 endif
 
+config SYS_L2_SIZE_256KB
+   bool
+
+config SYS_L2_SIZE_512KB
+   bool
+
+config SYS_L2_SIZE
+   int
+   default 262144 if SYS_L2_SIZE_256KB
+   default 524288 if SYS_L2_SIZE_512KB
+
 config BACKSIDE_L2_CACHE
bool
 
diff --git a/include/configs/P1010RDB.h b/include/configs/P1010RDB.h
index bf9227a3c204..06188cac44f2 100644
--- a/include/configs/P1010RDB.h
+++ b/include/configs/P1010RDB.h
@@ -311,18 +311,15 @@ extern unsigned long get_sdram_size(void);
 #if defined(CONFIG_SDCARD) || defined(CONFIG_SPIFLASH)
 #define CONFIG_SYS_INIT_L2_ADDR0xD000
 #define CONFIG_SYS_INIT_L2_ADDR_PHYS   CONFIG_SYS_INIT_L2_ADDR
-#define CONFIG_SYS_L2_SIZE (256 << 10)
 #define CONFIG_SYS_INIT_L2_END (CONFIG_SYS_INIT_L2_ADDR + CONFIG_SYS_L2_SIZE)
 #elif defined(CONFIG_MTD_RAW_NAND)
 #ifdef CONFIG_TPL_BUILD
 #define CONFIG_SYS_INIT_L2_ADDR0xD000
 #define CONFIG_SYS_INIT_L2_ADDR_PHYS   CONFIG_SYS_INIT_L2_ADDR
-#define CONFIG_SYS_L2_SIZE (256 << 10)
 #define CONFIG_SYS_INIT_L2_END (CONFIG_SYS_INIT_L2_ADDR + CONFIG_SYS_L2_SIZE)
 #else
 #define CONFIG_SYS_INIT_L2_ADDR0xD000
 #define CONFIG_SYS_INIT_L2_ADDR_PHYS   CONFIG_SYS_INIT_L2_ADDR
-#define CONFIG_SYS_L2_SIZE (256 << 10)
 #define CONFIG_SYS_INIT_L2_END (CONFIG_SYS_INIT_L2_ADDR + CONFIG_SYS_L2_SIZE)
 #endif
 #endif
diff --git a/include/configs/p1_p2_rdb_pc.h b/include/configs/p1_p2_rdb_pc.h
index 845578d6990b..e632d852ed54 100644
--- a/include/configs/p1_p2_rdb_pc.h
+++ b/include/configs/p1_p2_rdb_pc.h
@@ -27,7 +27,6 @@
 #define __SW_BOOT_NOR_BANK_UP  0x5c /* (__SW_BOOT_NOR | __SW_NOR_BANK_UP) */
 #define __SW_BOOT_NOR_BANK_LO  0x5e /* (__SW_BOOT_NOR | __SW_NOR_BANK_LO) */
 #define __SW_BOOT_NOR_BANK_MASK0x01 /* (__SW_BOOT_MASK & 
__SW_NOR_BANK_MASK) */
-#define CONFIG_SYS_L2_SIZE (256 << 10)
 #endif
 
 /*
@@ -58,7 +57,6 @@
 #define __SW_BOOT_NOR_BANK_UP  0x64 /* (__SW_BOOT_NOR | __SW_NOR_BANK_UP) */
 #define __SW_BOOT_NOR_BANK_LO  0x66 /* (__SW_BOOT_NOR | __SW_NOR_BANK_LO) */
 #define __SW_BOOT_NOR_BANK_MASK0x01 /* (__SW_BOOT_MASK & 
__SW_NOR_BANK_MASK) */
-#define CONFIG_SYS_L2_SIZE (256 << 10)
 /*
  * Dynamic MTD Partition support with mtdparts
  */
@@ -79,7 +77,6 @@
 #define __SW_BOOT_NOR_BANK_UP  0xc8 /* (__SW_BOOT_NOR | __SW_NOR_BANK_UP) */
 #define __SW_BOOT_NOR_BANK_LO  0xca /* (__SW_BOOT_NOR | __SW_NOR_BANK_LO) */
 #define __SW_BOOT_NOR_BANK_MASK0x01 /* (__SW_BOOT_MASK & 
__SW_NOR_BANK_MASK) */
-#define CONFIG_SYS_L2_SIZE (512 << 10)
 /*
  * Dynamic MTD Partition support with mtdparts
  */
-- 
2.25.1



[PATCH 03/21] Remove dead code

2022-10-28 Thread Tom Rini
This header is unreferenced, remove.

Signed-off-by: Tom Rini 
---
 include/w83c553f.h | 161 -
 1 file changed, 161 deletions(-)
 delete mode 100644 include/w83c553f.h

diff --git a/include/w83c553f.h b/include/w83c553f.h
deleted file mode 100644
index 2403e3401a6f..
--- a/include/w83c553f.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * (C) Copyright 2000
- * Rob Taylor, Flying Pig Systems. r...@flyingpig.com.
- */
-
- /* winbond access routines and defines*/
-
-/* from the winbond data sheet -
- The W83C553F SIO controller with PCI arbiter is a multi-function PCI device.
- Function 0 is the ISA bridge, and Function 1 is the bus master IDE controller.
-*/
-
-/*ISA bridge configuration space*/
-
-#define W83C553F_VID   0x10AD
-#define W83C553F_DID   0x0565
-
-#define WINBOND_PCICONTR   0x40  /*pci control reg*/
-#define WINBOND_SGBAR  0x41  /*scatter/gather base address reg*/
-#define WINBOND_LBCR   0x42  /*Line Buffer Control reg*/
-#define WINBOND_IDEIRCR0x43  /*IDE Interrupt Routing Control  
Reg*/
-#define WINBOND_PCIIRCR0x44  /*PCI Interrupt Routing Control 
Reg*/
-#define WINBOND_BTBAR  0x46  /*BIOS Timer Base Address Register*/
-#define WINBOND_IPADCR 0x48  /*ISA to PCI Address Decoder Control 
Register*/
-#define WINBOND_IRADCR 0x49  /*ISA ROM Address Decoder Control 
Register*/
-#define WINBOND_IPMHSAR0x4a  /*ISA to PCI Memory Hole STart 
Address Register*/
-#define WINBOND_IPMHSR 0x4b  /*ISA to PCI Memory Hols Size Register*/
-#define WINBOND_CDR0x4c  /*Clock Divisor Register*/
-#define WINBOND_CSCR   0x4d  /*Chip Select Control Register*/
-#define WINBOND_ATSCR  0x4e  /*AT System Control register*/
-#define WINBOND_ATBCR  0x4f  /*AT Bus ControL Register*/
-#define WINBOND_IRQBEE0R   0x60  /*IRQ Break Event Enable 0 Register*/
-#define WINBOND_IRQBEE1R   0x61  /*IRQ Break Event Enable 1 Register*/
-#define WINBOND_ABEER  0x62  /*Additional Break Event Enable Register*/
-#define WINBOND_DMABEER0x63  /*DMA Break Event Enable 
Register*/
-
-#define WINDOND_IDECSR 0x40  /*IDE Control/Status Register, Function 
1*/
-
-#define IPADCR_MBE512  0x1
-#define IPADCR_MBE640  0x2
-#define IPADCR_IPATOM4 0x10
-#define IPADCR_IPATOM5 0x20
-#define IPADCR_IPATOM6 0x40
-#define IPADCR_IPATOM7 0x80
-
-#define CSCR_UBIOSCSE  0x10
-#define CSCR_BIOSWP0x20
-
-#define IDECSR_P0EN0x01
-#define IDECSR_P0F16   0x02
-#define IDECSR_P1EN0x10
-#define IDECSR_P1F16   0x20
-#define IDECSR_LEGIRQ  0x800
-
-/*
- * Interrupt controller
- */
-#define W83C553F_PIC1_ICW1 CONFIG_SYS_ISA_IO + 0x20
-#define W83C553F_PIC1_ICW2 CONFIG_SYS_ISA_IO + 0x21
-#define W83C553F_PIC1_ICW3 CONFIG_SYS_ISA_IO + 0x21
-#define W83C553F_PIC1_ICW4 CONFIG_SYS_ISA_IO + 0x21
-#define W83C553F_PIC1_OCW1 CONFIG_SYS_ISA_IO + 0x21
-#define W83C553F_PIC1_OCW2 CONFIG_SYS_ISA_IO + 0x20
-#define W83C553F_PIC1_OCW3 CONFIG_SYS_ISA_IO + 0x20
-#define W83C553F_PIC1_ELC  CONFIG_SYS_ISA_IO + 0x4D0
-#define W83C553F_PIC2_ICW1 CONFIG_SYS_ISA_IO + 0xA0
-#define W83C553F_PIC2_ICW2 CONFIG_SYS_ISA_IO + 0xA1
-#define W83C553F_PIC2_ICW3 CONFIG_SYS_ISA_IO + 0xA1
-#define W83C553F_PIC2_ICW4 CONFIG_SYS_ISA_IO + 0xA1
-#define W83C553F_PIC2_OCW1 CONFIG_SYS_ISA_IO + 0xA1
-#define W83C553F_PIC2_OCW2 CONFIG_SYS_ISA_IO + 0xA0
-#define W83C553F_PIC2_OCW3 CONFIG_SYS_ISA_IO + 0xA0
-#define W83C553F_PIC2_ELC  CONFIG_SYS_ISA_IO + 0x4D1
-
-#define W83C553F_TMR1_CMOD CONFIG_SYS_ISA_IO + 0x43
-
-/*
- * DMA controller
- */
-#define W83C553F_DMA1  CONFIG_SYS_ISA_IO + 0x000   /* channel 0 - 3 */
-#define W83C553F_DMA2  CONFIG_SYS_ISA_IO + 0x0C0   /* channel 4 - 7 */
-
-/* command/status register bit definitions */
-
-#define W83C553F_CS_COM_DACKAL (1<<7)  /* DACK# assert level */
-#define W83C553F_CS_COM_DREQSAL(1<<6)  /* DREQ sense assert level */
-#define W83C553F_CS_COM_GAP(1<<4)  /* group arbitration priority */
-#define W83C553F_CS_COM_CGE(1<<2)  /* channel group enable */
-
-#define W83C553F_CS_STAT_CH0REQ(1<<4)  /* channel 0 (4) DREQ status */
-#define W83C553F_CS_STAT_CH1REQ(1<<5)  /* channel 1 (5) DREQ status */
-#define W83C553F_CS_STAT_CH2REQ(1<<6)  /* channel 2 (6) DREQ status */
-#define W83C553F_CS_STAT_CH3REQ(1<<7)  /* channel 3 (7) DREQ status */
-
-#define W83C553F_CS_STAT_CH0TC (1<<0)  /* channel 0 (4) TC status */
-#define W83C553F_CS_STAT_CH1TC (1<<1)  /* channel 1 (5) TC status */
-#define W83C553F_CS_STAT_CH2TC (1<<2)  /* channel 2 (6) TC status */
-#define W83C553F_CS_STAT_CH3TC (1<<3)  /* channel 3 (7) TC status */
-
-/* mode reg

[PATCH 06/21] fs: jffs2: Move SYS_JFFS2_SORT_FRAGMENTS to Kconfig

2022-10-28 Thread Tom Rini
Move the symbol SYS_JFFS2_SORT_FRAGMENTS to Kconfig and use the only
remaining part of doc/README.JFFS2 that is still relevant and useful to
the help for this option.

Signed-off-by: Tom Rini 
---
 doc/README.JFFS2 | 30 --
 fs/jffs2/Kconfig | 12 
 2 files changed, 12 insertions(+), 30 deletions(-)
 delete mode 100644 doc/README.JFFS2

diff --git a/doc/README.JFFS2 b/doc/README.JFFS2
deleted file mode 100644
index fddefb174690..
--- a/doc/README.JFFS2
+++ /dev/null
@@ -1,30 +0,0 @@
-JFFS2 options and usage.

-
-JFFS2 in U-Boot is a read only implementation of the file system in
-Linux with the same name. To use JFFS2 define CONFIG_CMD_JFFS2.
-
-The module adds three new commands.
-fsload  - load binary file from a file system image
-fsinfo  - print information about file systems
-ls  - list files in a directory
-chpart  - change active partition
-
-If you do now need the commands, you can enable the filesystem separately
-with CONFIG_FS_JFFS2 and call the jffs2 functions yourself.
-
-If you boot from a partition which is mounted writable, and you
-update your boot environment by replacing single files on that
-partition, you should also define CONFIG_SYS_JFFS2_SORT_FRAGMENTS. Scanning
-the JFFS2 filesystem takes *much* longer with this feature, though.
-Sorting is done while inserting into the fragment list, which is
-more or less a bubble sort. That algorithm is known to be O(n^2),
-thus you should really consider if you can avoid it!
-

-
-TODO.
-
-   Remove the assumption that JFFS can dereference a pointer
-   into the disk. The current code do not work with memory holes
-   or hardware with a sliding window (PCMCIA).
diff --git a/fs/jffs2/Kconfig b/fs/jffs2/Kconfig
index 0e79c3409062..3bf01cd03137 100644
--- a/fs/jffs2/Kconfig
+++ b/fs/jffs2/Kconfig
@@ -17,3 +17,15 @@ config JFFS2_NAND
depends on FS_JFFS2
help
  Enable support for NAND flash as the backing store for JFFS2.
+
+config SYS_JFFS2_SORT_FRAGMENTS
+   bool "Enable JFFS2 sorting of filesystem fragments (SLOW!)"
+   depends on FS_JFFS2
+   help
+ If you boot from a partition which is mounted writable, and you
+ update your boot environment by replacing single files on that
+ partition, you should also define CONFIG_SYS_JFFS2_SORT_FRAGMENTS.
+ Scanning the JFFS2 filesystem takes *much* longer with this feature,
+ though.  Sorting is done while inserting into the fragment list,
+ which is more or less a bubble sort. That algorithm is known to be
+ O(n^2), thus you should really consider if you can avoid it!
-- 
2.25.1



[PATCH 05/21] Remove unused symbols CONFIG_SYS_JFFS2_FIRST_BANK et al

2022-10-28 Thread Tom Rini
This removes the following symbols:
   CONFIG_RTC_MCFRRTC
   CONFIG_SYS_JFFS2_FIRST_BANK
   CONFIG_SYS_JFFS2_FIRST_SECTOR
   CONFIG_SYS_JFFS2_NUM_BANKS
   CONFIG_SYS_LBC_CACHE_BASE
   CONFIG_SYS_LIME_SIZE
   CONFIG_SYS_MAMR
   CONFIG_SYS_MCFRRTC_BASE
   CONFIG_SYS_MONITOR_SEC

Signed-off-by: Tom Rini 
---
 README   |  8 
 doc/README.JFFS2 | 10 --
 include/configs/astro_mcf5373l.h | 11 ---
 include/configs/at91sam9263ek.h  |  1 -
 include/configs/socrates.h   |  3 ---
 include/configs/stmark2.h|  4 
 include/configs/tuxx1.h  |  4 
 7 files changed, 41 deletions(-)

diff --git a/README b/README
index 92ad191ae76d..0e01176d4f65 100644
--- a/README
+++ b/README
@@ -762,11 +762,6 @@ The following options need to be configured:
entering dfuMANIFEST state. Host waits this timeout, before
sending again an USB request to the device.
 
-- Journaling Flash filesystem support:
-   CONFIG_SYS_JFFS2_FIRST_SECTOR,
-   CONFIG_SYS_JFFS2_FIRST_BANK, CONFIG_SYS_JFFS2_NUM_BANKS
-   Define these for a default partition on a NOR device
-
 - Keyboard Support:
See Kconfig help for available keyboard drivers.
 
@@ -1814,9 +1809,6 @@ Low Level (hardware related) configuration options:
 - CONFIG_SYS_OR_TIMING_SDRAM:
SDRAM timing
 
-- CONFIG_SYS_MAMR_PTA:
-   periodic timer for refresh
-
 - CONFIG_SYS_SRIO:
Chip has SRIO or not
 
diff --git a/doc/README.JFFS2 b/doc/README.JFFS2
index 0245da0488fb..fddefb174690 100644
--- a/doc/README.JFFS2
+++ b/doc/README.JFFS2
@@ -21,16 +21,6 @@ Sorting is done while inserting into the fragment list, 
which is
 more or less a bubble sort. That algorithm is known to be O(n^2),
 thus you should really consider if you can avoid it!
 
-
-There only one way for JFFS2 to find the disk. It uses the flash_info
-structure to find the start of a JFFS2 disk (called partition in the code)
-and you can change where the partition is with two defines.
-
-CONFIG_SYS_JFFS2_FIRST_BANK
-   defined the first flash bank to use
-
-CONFIG_SYS_JFFS2_FIRST_SECTOR
-   defines the first sector to use
 ---
 
 TODO.
diff --git a/include/configs/astro_mcf5373l.h b/include/configs/astro_mcf5373l.h
index adfadd7c6d72..c79f9ca8f0f4 100644
--- a/include/configs/astro_mcf5373l.h
+++ b/include/configs/astro_mcf5373l.h
@@ -46,9 +46,6 @@
  */
 #ifdef CONFIG_RAM
 #define CONFIG_MONITOR_IS_IN_RAM
-#define ENABLE_JFFS0
-#else
-#define ENABLE_JFFS1
 #endif
 
 /* I2C */
@@ -210,14 +207,6 @@
. = DEFINED(env_offset) ? env_offset : .; \
env/embedded.o(.text*)
 
-#if ENABLE_JFFS
-/* JFFS Partition offset set */
-#define CONFIG_SYS_JFFS2_FIRST_BANK0
-#define CONFIG_SYS_JFFS2_NUM_BANKS 1
-/* 512k reserved for u-boot */
-#define CONFIG_SYS_JFFS2_FIRST_SECTOR  0x40
-#endif
-
 /* Cache Configuration */
 
 #define ICACHE_STATUS  (CONFIG_SYS_INIT_RAM_ADDR + \
diff --git a/include/configs/at91sam9263ek.h b/include/configs/at91sam9263ek.h
index 8c6d1cd1d9d4..4d32e55c642e 100644
--- a/include/configs/at91sam9263ek.h
+++ b/include/configs/at91sam9263ek.h
@@ -41,7 +41,6 @@
 #define PHYS_FLASH_1   0x1000
 #define CONFIG_SYS_FLASH_BASE  PHYS_FLASH_1
 
-#define CONFIG_SYS_MONITOR_SEC 1:0-3
 #define CONFIG_SYS_MONITOR_LEN (256 << 10)
 
 /* Address and size of Primary Environment Sector */
diff --git a/include/configs/socrates.h b/include/configs/socrates.h
index fc00931e0ae1..c75991badab4 100644
--- a/include/configs/socrates.h
+++ b/include/configs/socrates.h
@@ -78,8 +78,6 @@
 /*
  * Flash on the LocalBus
  */
-#define CONFIG_SYS_LBC_CACHE_BASE  0xf000  /* Localbus cacheable   
 */
-
 #define CONFIG_SYS_FLASH0  0xFE00
 #define CONFIG_SYS_FLASH1  0xFC00
 #define CONFIG_SYS_FLASH_BANKS_LIST{ CONFIG_SYS_FLASH1, CONFIG_SYS_FLASH0 }
@@ -108,7 +106,6 @@
 
 /* LIME GDC */
 #define CONFIG_SYS_LIME_BASE   0xc800
-#define CONFIG_SYS_LIME_SIZE   0x0400  /* 64 MB*/
 
 /*
  * General PCI
diff --git a/include/configs/stmark2.h b/include/configs/stmark2.h
index d8a334868f31..8167d250f27f 100644
--- a/include/configs/stmark2.h
+++ b/include/configs/stmark2.h
@@ -34,10 +34,6 @@
"sf write ${loadaddr} 0x0080 ${filesize}\0" \
""
 
-/* Realtime clock */
-#define CONFIG_RTC_MCFRRTC
-#define CONFIG_SYS_MCFRRTC_BASE0xFC0A8000
-
 #define CONFIG_SYS_SBFHDR_SIZE 0x7
 
 /* Input, PCI, Flexbus, and VCO */
diff --git a/include/configs/tuxx1.h b/include/configs/tuxx1.h
index f5a9f1284a3d..7eed31c35f03 100644
--- a/include/configs/tuxx1.h
+++ b/include/configs/tuxx1.h
@@ -31,8 +31,4 @@
 #include "km/km-mpc83xx.h"
 #include "km/km-mpc832x.h"
 
-#define CONFIG_SYS_MAMR(MxMR_GPL_x4DIS | \
-0xc0

[PATCH 04/21] Convert CONFIG_SYS_INTERLAKEN et al to Kconfig

2022-10-28 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_INTERLAKEN
   CONFIG_SYS_ISA_IO
   CONFIG_SYS_ISA_IO_BASE_ADDRESS

Signed-off-by: Tom Rini 
---
 drivers/rtc/mc146818.c   | 2 +-
 include/configs/T208xQDS.h   | 1 -
 include/configs/T208xRDB.h   | 1 -
 include/configs/T4240RDB.h   | 1 -
 include/configs/edison.h | 3 ---
 include/configs/malta.h  | 2 --
 include/configs/x86-common.h | 6 --
 include/mk48t59.h| 4 ++--
 8 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/rtc/mc146818.c b/drivers/rtc/mc146818.c
index 71f96e282e82..122691b97842 100644
--- a/drivers/rtc/mc146818.c
+++ b/drivers/rtc/mc146818.c
@@ -22,7 +22,7 @@
 /* Set this to 1 to clear the CMOS RAM */
 #define CLEAR_CMOS 0
 
-#define RTC_PORT_MC146818  CONFIG_SYS_ISA_IO_BASE_ADDRESS + 0x70
+#define RTC_PORT_MC146818  0x70
 #define RTC_SECONDS0x00
 #define RTC_SECONDS_ALARM  0x01
 #define RTC_MINUTES0x02
diff --git a/include/configs/T208xQDS.h b/include/configs/T208xQDS.h
index 7c83423f99ff..6700560123b7 100644
--- a/include/configs/T208xQDS.h
+++ b/include/configs/T208xQDS.h
@@ -405,7 +405,6 @@
 #define CONFIG_SYS_PMAN
 #define CONFIG_SYS_DPAA_DCE
 #define CONFIG_SYS_DPAA_RMAN   /* RMan */
-#define CONFIG_SYS_INTERLAKEN
 #endif /* CONFIG_NOBQFMAN */
 
 #ifdef CONFIG_SYS_DPAA_FMAN
diff --git a/include/configs/T208xRDB.h b/include/configs/T208xRDB.h
index 78ff50196c2f..4de4a72999e9 100644
--- a/include/configs/T208xRDB.h
+++ b/include/configs/T208xRDB.h
@@ -359,7 +359,6 @@
 #define CONFIG_SYS_PMAN
 #define CONFIG_SYS_DPAA_DCE
 #define CONFIG_SYS_DPAA_RMAN   /* RMan */
-#define CONFIG_SYS_INTERLAKEN
 #endif /* CONFIG_NOBQFMAN */
 
 #ifdef CONFIG_SYS_DPAA_FMAN
diff --git a/include/configs/T4240RDB.h b/include/configs/T4240RDB.h
index 53641fad543a..dc507473b259 100644
--- a/include/configs/T4240RDB.h
+++ b/include/configs/T4240RDB.h
@@ -366,7 +366,6 @@
 #define CONFIG_SYS_PMAN
 #define CONFIG_SYS_DPAA_DCE
 #define CONFIG_SYS_DPAA_RMAN
-#define CONFIG_SYS_INTERLAKEN
 #endif /* CONFIG_NOBQFMAN */
 
 #ifdef CONFIG_SYS_DPAA_FMAN
diff --git a/include/configs/edison.h b/include/configs/edison.h
index 34536ecf8505..c71ef25233bd 100644
--- a/include/configs/edison.h
+++ b/include/configs/edison.h
@@ -14,7 +14,4 @@
 
 #define CONFIG_SYS_MONITOR_LEN (256 * 1024)
 
-/* RTC */
-#define CONFIG_SYS_ISA_IO_BASE_ADDRESS 0
-
 #endif
diff --git a/include/configs/malta.h b/include/configs/malta.h
index 5a42ceef2121..8ffd1f372044 100644
--- a/include/configs/malta.h
+++ b/include/configs/malta.h
@@ -13,8 +13,6 @@
 
 #define CONFIG_MEMSIZE_IN_BYTES
 
-#define CONFIG_SYS_ISA_IO_BASE_ADDRESS 0
-
 /*
  * CPU Configuration
  */
diff --git a/include/configs/x86-common.h b/include/configs/x86-common.h
index 42b2cb2fc85a..8e22d6e5d876 100644
--- a/include/configs/x86-common.h
+++ b/include/configs/x86-common.h
@@ -18,12 +18,6 @@
 /* Generic TPM interfaced through LPC bus */
 #define CONFIG_TPM_TIS_BASE_ADDRESS0xfed4
 
-/*---
- * Real Time Clock Configuration
- */
-#define CONFIG_SYS_ISA_IO_BASE_ADDRESS 0
-#define CONFIG_SYS_ISA_IO  CONFIG_SYS_ISA_IO_BASE_ADDRESS
-
 /*---
  * Serial Configuration
  */
diff --git a/include/mk48t59.h b/include/mk48t59.h
index 5d863ef94160..f95d349c17fb 100644
--- a/include/mk48t59.h
+++ b/include/mk48t59.h
@@ -11,9 +11,9 @@
 
 #if defined(CONFIG_RTC_MK48T59) && defined(CONFIG_CMD_DATE)
 
-#define RTC_PORT_ADDR0 CONFIG_SYS_ISA_IO +  0x70
+#define RTC_PORT_ADDR0 0x70
 #define RTC_PORT_ADDR1 RTC_PORT_ADDR0 +  0x1
-#define RTC_PORT_DATA  CONFIG_SYS_ISA_IO +  0x76
+#define RTC_PORT_DATA  0x76
 
 /* RTC Offsets */
 #define RTC_SECONDS 0x1FF9
-- 
2.25.1



[PATCH 01/21] Convert CONFIG_SYS_I2C_INIT_BOARD to Kconfig

2022-10-28 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_I2C_INIT_BOARD

Signed-off-by: Tom Rini 
---
 README   | 11 ---
 board/keymile/Kconfig|  3 +++
 board/samsung/common/board.c |  4 
 board/samsung/goni/goni.c| 10 --
 drivers/i2c/fsl_i2c.c|  7 ---
 drivers/i2c/mv_i2c.c | 24 
 include/configs/km/pg-wcom-ls102xa.h |  1 -
 7 files changed, 3 insertions(+), 57 deletions(-)

diff --git a/README b/README
index 186f1f9a5ffb..92ad191ae76d 100644
--- a/README
+++ b/README
@@ -1126,17 +1126,6 @@ The following options need to be configured:
You should define these to the GPIO value as given directly to
the generic GPIO functions.
 
-   CONFIG_SYS_I2C_INIT_BOARD
-
-   When a board is reset during an i2c bus transfer
-   chips might think that the current transfer is still
-   in progress. On some boards it is possible to access
-   the i2c SCLK line directly, either by using the
-   processor pin as a GPIO or by having a second pin
-   connected to the bus. If this option is defined a
-   custom i2c_init_board() routine in boards/xxx/board.c
-   is run early in the boot sequence.
-
CONFIG_I2C_MULTI_BUS
 
This option allows the use of multiple I2C buses, each of which
diff --git a/board/keymile/Kconfig b/board/keymile/Kconfig
index 9f784430b1d5..b8f0578a286f 100644
--- a/board/keymile/Kconfig
+++ b/board/keymile/Kconfig
@@ -11,6 +11,9 @@ if VENDOR_KM
 
 menu "KM Board Setup"
 
+config SYS_I2C_INIT_BOARD
+   def_bool y if ARM
+
 config HUSH_INIT_VAR
def_bool y
 
diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
index ff178b7fe677..e476400ecdc8 100644
--- a/board/samsung/common/board.c
+++ b/board/samsung/common/board.c
@@ -177,10 +177,6 @@ int board_early_init_f(void)
return err;
}
 
-#ifdef CONFIG_SYS_I2C_INIT_BOARD
-   board_i2c_init(gd->fdt_blob);
-#endif
-
return exynos_early_init_f();
 }
 #endif
diff --git a/board/samsung/goni/goni.c b/board/samsung/goni/goni.c
index ba25ba27b863..535f8e1e0129 100644
--- a/board/samsung/goni/goni.c
+++ b/board/samsung/goni/goni.c
@@ -33,16 +33,6 @@ int board_init(void)
return 0;
 }
 
-#ifdef CONFIG_SYS_I2C_INIT_BOARD
-void i2c_init_board(void)
-{
-   gpio_request(S5PC110_GPIO_J43, "i2c_clk");
-   gpio_request(S5PC110_GPIO_J40, "i2c_data");
-   gpio_direction_output(S5PC110_GPIO_J43, 1);
-   gpio_direction_output(S5PC110_GPIO_J40, 1);
-}
-#endif
-
 int dram_init(void)
 {
gd->ram_size = PHYS_SDRAM_1_SIZE + PHYS_SDRAM_2_SIZE +
diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c
index 9a3c8241bc64..edbcd83b6469 100644
--- a/drivers/i2c/fsl_i2c.c
+++ b/drivers/i2c/fsl_i2c.c
@@ -271,13 +271,6 @@ static void __i2c_init(const struct fsl_i2c_base *base, 
int speed, int
const unsigned long long timeout = usec2ticks(CONFIG_I2C_MBB_TIMEOUT);
unsigned long long timeval;
 
-#ifdef CONFIG_SYS_I2C_INIT_BOARD
-   /* Call board specific i2c bus reset routine before accessing the
-* environment, which might be in a chip on that bus. For details
-* about this problem see doc/I2C_Edge_Conditions.
-*/
-   i2c_init_board();
-#endif
writeb(0, &base->cr);   /* stop I2C controller */
udelay(5);  /* let it shutdown in peace */
set_i2c_bus_speed(base, i2c_clk, speed);
diff --git a/drivers/i2c/mv_i2c.c b/drivers/i2c/mv_i2c.c
index 0eff3531618c..8ee17f0a4501 100644
--- a/drivers/i2c/mv_i2c.c
+++ b/drivers/i2c/mv_i2c.c
@@ -374,27 +374,6 @@ static int __i2c_write(struct mv_i2c *base, uchar chip, u8 
*addr, int alen,
 
 static struct mv_i2c *base_glob;
 
-static void i2c_board_init(struct mv_i2c *base)
-{
-#ifdef CONFIG_SYS_I2C_INIT_BOARD
-   u32 icr;
-   /*
-* call board specific i2c bus reset routine before accessing the
-* environment, which might be in a chip on that bus. For details
-* about this problem see doc/I2C_Edge_Conditions.
-*
-* disable I2C controller first, otherwhise it thinks we want to
-* talk to the slave port...
-*/
-   icr = readl(&base->icr);
-   writel(readl(&base->icr) & ~(ICR_SCLE | ICR_IUE), &base->icr);
-
-   i2c_init_board();
-
-   writel(icr, &base->icr);
-#endif
-}
-
 #ifdef CONFIG_I2C_MULTI_BUS
 static unsigned long i2c_regs[CONFIG_MV_I2C_NUM] = CONFIG_MV_I2C_REG;
 static unsigned int bus_initialized[CONFIG_MV_I2C_NUM];
@@ -411,7 +390,6 @@ int i2c_set_bus_num(unsigned int bus)
current_bus = bus;
 
if (!bus_initialized[current_bus]) {
-   i2c_board_init(base_glob);
bus_initialized[current_bus] = 1;
}
 
@@ -441,8 +419,6 @@ void i2c_init(

Re: [PATCH 5/5] cyclic: get rid of cyclic_init()

2022-10-28 Thread Rasmus Villemoes
On 28/10/2022 16.10, Stefan Roese wrote:
> On 28.10.22 13:50, Rasmus Villemoes wrote:

>> As for cyclic_uninit(), it was never really the opposite of
>> cyclic_init() since it didn't free the struct cyclic_drv nor set
>> gd->cyclic to NULL. Rename it to cyclic_unregister_all() and use that
>> in test/, and also insert a call at the end of the board_init_f
>> sequence so that gd->cyclic_list is a fresh empty list before we enter
>> board_init_r().
> 
> While reviewing the code, this was the only thing I wanted to
> ask about. Now with this explanation it makes perfect sense.
> Perhaps a small comment with this reasoning in the code here in
> board_init_r would be helpful.

Yeah, so I went back and forth on whether to put it early in
board_init_r or late in board_init_f, but went with the latter so that
whatever free() gets called goes with the same malloc() - i.e. to avoid
introducing any new ordering dependency against when we can initialize
the full malloc. Perhaps something like this above the
cyclic_unregister_all entry in board_init_f sequence:

/*
 * Deregister all cyclic functions before relocation, so that
gd->cyclic_list does not contain any references to pre-relocation
devices. Drivers will register their cyclic functions anew when the
devices are probed again.

This should happen as late as possible so that the window where a
watchdog device is not serviced is as small as possible.
*/

But I don't know if that's too verbose; many other important
initialization functions with implicit ordering dependencies do not have
anything similar. That's not necessarily an argument against starting to
add such comments.

> Reviewed-by: Stefan Roese 
> Tested-by: Stefan Roese 

Thanks,
Rasmus




Re: Support for Banana Pi BPI-P2 Zero

2022-10-28 Thread Martin Thomas

Hi,

I found a solution. I had to use
CONFIG_DEFAULT_DEVICE_TREE="sun8i-h2-plus-bananapi-m2-zero"

This defconfig works!

Best regards

Martin


Am 28.10.22 um 20:38 schrieb Martin Thomas:


Hi Developers,


I am struggling with the u-boot for the Banana Pi BPI-P2 Zero.
I used this defconfig but it has problems with at least the mmc card:

CONFIG_ARM=y
CONFIG_ARCH_SUNXI=y
CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-bananapi-m2-plus-v1.2"
CONFIG_SPL=y
CONFIG_MACH_SUN8I_H3=y
CONFIG_DRAM_CLK=408
CONFIG_MMC0_CD_PIN=""
CONFIG_MMC_SUNXI_SLOT_EXTRA=2
# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
CONFIG_PREBOOT=""
# CONFIG_SYS_DEVICE_NULLDEV is not set
CONFIG_SPL_STACK=0x8000
CONFIG_SYS_PBSIZE=1024
CONFIG_SUN8I_EMAC=y
CONFIG_USB_EHCI_HCD=y


This is the output from serial:
U-Boot SPL 2022.10 (Oct 28 2022 - 20:34:40 +0200)
DRAM: 512 MiB
Trying to boot from MMC1


U-Boot 2022.10 (Oct 28 2022 - 20:34:40 +0200) Allwinner Technology

CPU:   Allwinner H3 (SUN8I 1680)
Model: Banana Pi BPI-M2-Plus v1.2 H3
DRAM:  512 MiB
Core:  68 devices, 19 uclasses, devicetree: separate
WDT:   Not starting watchdog@1c20ca0
MMC:   mmc@1c0f000: 0, mmc@1c1: 2, mmc@1c11000: 1
Loading Environment from FAT... MMC: no card present
** Bad device specification mmc 0 **
In:    serial
Out:   serial
Err:   serial
Net:   Could not get PHY for ethernet@1c3: addr 1
No ethernet found.

Hit any key to stop autoboot:  0
MMC: no card present
Card did not respond to voltage select! : -110
starting USB...
...


Thank you for your help!

Regards

Martin


[PATCH 1/1] doc: update sbi command example

2022-10-28 Thread Heinrich Schuchardt
The output of the sbi command has been changed since the last release of
the man-page. Update the example.

Signed-off-by: Heinrich Schuchardt 
---
 doc/usage/cmd/sbi.rst | 28 +---
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/doc/usage/cmd/sbi.rst b/doc/usage/cmd/sbi.rst
index 96d8861057..627479a49f 100644
--- a/doc/usage/cmd/sbi.rst
+++ b/doc/usage/cmd/sbi.rst
@@ -21,23 +21,29 @@ The output may look like:
 ::
 
 => sbi
-SBI 0.2
-OpenSBI
+SBI 1.0
+OpenSBI 1.1
+Machine:
+  Vendor ID 0
+  Architecture ID 0
+  Implementation ID 0
 Extensions:
-  sbi_set_timer
-  sbi_console_putchar
-  sbi_console_getchar
-  sbi_clear_ipi
-  sbi_send_ipi
-  sbi_remote_fence_i
-  sbi_remote_sfence_vma
-  sbi_remote_sfence_vma_asid
-  sbi_shutdown
+  Set Timer
+  Console Putchar
+  Console Getchar
+  Clear IPI
+  Send IPI
+  Remote FENCE.I
+  Remote SFENCE.VMA
+  Remote SFENCE.VMA with ASID
+  System Shutdown
   SBI Base Functionality
   Timer Extension
   IPI Extension
   RFENCE Extension
   Hart State Management Extension
+  System Reset Extension
+  Performance Monitoring Unit Extension
 
 The first line indicates the version of the RISC-V SBI specification.
 The second line indicates the implementation.
-- 
2.37.2



Re: [RFC 1/1] tools: Dockerfile for armv7

2022-10-28 Thread Tom Rini
On Fri, Oct 28, 2022 at 09:14:13PM +0200, Heinrich Schuchardt wrote:
> On 10/28/22 21:04, Tom Rini wrote:
> > On Sun, Oct 16, 2022 at 12:03:30PM +0200, Heinrich Schuchardt wrote:
> > > On 10/16/22 09:43, Heinrich Schuchardt wrote:
> > > > Provide an armv7 docker environment to build and test the sandbox.
> > > > 
> > > > Signed-off-by: Heinrich Schuchardt
> > > > ---
> > > > I have been discussing with Simon, if we can test sandbox_defconfig
> > > > build on arm in a docker container. This RFC is just a small step on
> > > > the path to it.
> > > 
> > > We also need a separate requirements.txt with pygit2==1.6.1 due the
> > > different version of libgit in the armhf version of Ubuntu Jammy.
> > 
> > So, what are the general best practices to have a Dockerfile that can be
> > / is used for generating multiple platforms worth of images? We should
> > aim for a single Dockerfile that can be used for x86-64, armv7 and
> > aarch64.
> 
> As we execute bash commands in the Dockerfile we could use if/fi and
> case/esac to work around differences between architectures.

For unavoidable differences, yes, OK.

> Except on amd64 we only want to execute the sandbox. So there is no need to
> build GRUB, QEMU, and swtmp/libtmps.

Why? There's no reason one shouldn't be able to run the whole of CI on
aarch64 hosts, unless there's QEMU bugs, or similar issues. The first
use might be just to do sandbox runs but I don't want to limit things
without strong reason ($X doesn't work, would be a good reason to
limit).

-- 
Tom


signature.asc
Description: PGP signature


Re: [RFC 1/1] tools: Dockerfile for armv7

2022-10-28 Thread Heinrich Schuchardt

On 10/28/22 21:04, Tom Rini wrote:

On Sun, Oct 16, 2022 at 12:03:30PM +0200, Heinrich Schuchardt wrote:

On 10/16/22 09:43, Heinrich Schuchardt wrote:

Provide an armv7 docker environment to build and test the sandbox.

Signed-off-by: Heinrich Schuchardt
---
I have been discussing with Simon, if we can test sandbox_defconfig
build on arm in a docker container. This RFC is just a small step on
the path to it.


We also need a separate requirements.txt with pygit2==1.6.1 due the
different version of libgit in the armhf version of Ubuntu Jammy.


So, what are the general best practices to have a Dockerfile that can be
/ is used for generating multiple platforms worth of images? We should
aim for a single Dockerfile that can be used for x86-64, armv7 and
aarch64.



As we execute bash commands in the Dockerfile we could use if/fi and 
case/esac to work around differences between architectures.


Except on amd64 we only want to execute the sandbox. So there is no need 
to build GRUB, QEMU, and swtmp/libtmps.


Best regards

Heinrich


Re: [RFC 1/1] tools: Dockerfile for armv7

2022-10-28 Thread Tom Rini
On Sun, Oct 16, 2022 at 12:03:30PM +0200, Heinrich Schuchardt wrote:
> On 10/16/22 09:43, Heinrich Schuchardt wrote:
> > Provide an armv7 docker environment to build and test the sandbox.
> > 
> > Signed-off-by: Heinrich Schuchardt
> > ---
> > I have been discussing with Simon, if we can test sandbox_defconfig
> > build on arm in a docker container. This RFC is just a small step on
> > the path to it.
> 
> We also need a separate requirements.txt with pygit2==1.6.1 due the
> different version of libgit in the armhf version of Ubuntu Jammy.

So, what are the general best practices to have a Dockerfile that can be
/ is used for generating multiple platforms worth of images? We should
aim for a single Dockerfile that can be used for x86-64, armv7 and
aarch64.

-- 
Tom


signature.asc
Description: PGP signature


Support for Banana Pi BPI-P2 Zero

2022-10-28 Thread Martin Thomas



Hi Developers,


I am struggling with the u-boot for the Banana Pi BPI-P2 Zero.
I used this defconfig but it has problems with at least the mmc card:

CONFIG_ARM=y
CONFIG_ARCH_SUNXI=y
CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-bananapi-m2-plus-v1.2"
CONFIG_SPL=y
CONFIG_MACH_SUN8I_H3=y
CONFIG_DRAM_CLK=408
CONFIG_MMC0_CD_PIN=""
CONFIG_MMC_SUNXI_SLOT_EXTRA=2
# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
CONFIG_PREBOOT=""
# CONFIG_SYS_DEVICE_NULLDEV is not set
CONFIG_SPL_STACK=0x8000
CONFIG_SYS_PBSIZE=1024
CONFIG_SUN8I_EMAC=y
CONFIG_USB_EHCI_HCD=y


This is the output from serial:
U-Boot SPL 2022.10 (Oct 28 2022 - 20:34:40 +0200)
DRAM: 512 MiB
Trying to boot from MMC1


U-Boot 2022.10 (Oct 28 2022 - 20:34:40 +0200) Allwinner Technology

CPU:   Allwinner H3 (SUN8I 1680)
Model: Banana Pi BPI-M2-Plus v1.2 H3
DRAM:  512 MiB
Core:  68 devices, 19 uclasses, devicetree: separate
WDT:   Not starting watchdog@1c20ca0
MMC:   mmc@1c0f000: 0, mmc@1c1: 2, mmc@1c11000: 1
Loading Environment from FAT... MMC: no card present
** Bad device specification mmc 0 **
In:serial
Out:   serial
Err:   serial
Net:   Could not get PHY for ethernet@1c3: addr 1
No ethernet found.

Hit any key to stop autoboot:  0
MMC: no card present
Card did not respond to voltage select! : -110
starting USB...
...


Thank you for your help!

Regards

Martin


mkimage regression: legacy images with Image Type IH_TYPE_FLATDT

2022-10-28 Thread Marc Kleine-Budde
Hello!

ld;dr: I want to create legacy images with Image Type IH_TYPE_FLATDT.

Details:

During the migration of an older system to recent yocto, we noticed that
the u-boot's mkimage doesn't work anymore as expected.

The system runs an older version of u-boot and requires the kernel's dtb
wrapped in a legacy u-boot image.

With the old u-boot (v2009.08) the following command was used to create
the uimage containing the dtb:

| mkimage -A arm -O linux -T flat_dt -C none -d  

e.g.:

| $ mkimage-v2009.08-144-g449609f5b11c -A arm -O linux -T flat_dt -C none -d 
./vivavis-skalar-pro.dtb out-v2009.08-144-g449609f5b11c
| Image Name:   
| Created:  Wed Feb  2 22:22:22 2022
| Image Type:   ARM Linux Flat Device Tree (uncompressed)
| Data Size:21726 Bytes = 21.22 kB = 0.02 MB
| Load Address: 
| Entry Point:  
| 
| $ file out-v2009.08-144-g449609f5b11c
| out-v2009.08-144-g449609f5b11c: u-boot legacy uImage, , Linux/ARM,
| Binary Flat Device Tree BLOB (Not compressed), 21726 bytes, Wed Feb 2
| 21:22:22 2022, Load Address: , Entry Point: , Header
| CRC: 0X945F44C9, Data CRC: 0XDCA9BDD


With the new u-boot:

| $ mkimage -A arm -O linux -T flat_dt -C none -d ./vivavis-skalar-pro.dtb 
out-upstream
| mkimage: Can't set header for FIT Image support: Success
| 
| echo $?
| 1

The command fails.
(...and prints the error message "Success". I'll send a patch to fix that).

An image is (partially) generated, but it's neither a valid legacy image
nor a FIT image:

| $ file out-upstream   
  
| out-upstream: data
| 
| $ hexdump -C out-upstream | head -10
|   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ||
| *
| 0040  d0 0d fe ed 00 00 54 de  00 00 00 38 00 00 50 9c  |..T8..P.|
| 0050  00 00 00 28 00 00 00 11  00 00 00 10 00 00 00 00  |...(|
| 0060  00 00 04 42 00 00 50 64  00 00 00 00 00 00 00 00  |...B..Pd|
| 0070  00 00 00 00 00 00 00 00  00 00 00 01 00 00 00 00  ||
| 0080  00 00 00 03 00 00 00 04  00 00 00 00 00 00 00 01  ||
| 0090  00 00 00 03 00 00 00 04  00 00 00 0f 00 00 00 01  ||
| 00a0  00 00 00 03 00 00 00 13  00 00 00 1b 56 49 56 41  |VIVA|
| 00b0  56 49 53 20 53 6b 61 6c  61 72 2e 70 72 6f 00 00  |VIS Skalar.pro..|


The main difference between the old u-boot and recent u-boot, is that
the old u-boot (obviously) always creates legacy images, with the struct
legacy_img_hdr::ih_type in the header set to the type given with the
'-T' command line argument.

With new mkimage, it's a bit different. The type of the -T command line
parameter is used to select the actual image type. This is done by
iterating over all image types and calling the check_image_type callback
to find a matching image provider.

The FIT image ("fit_common.c") matches on types IH_TYPE_FLATDT (which
corresponds to "-T flat_dt") while the legacy image
("tools/default_image.c") matches on the following image types:

IH_TYPE_STANDALONE, /* Standalone Program   */
IH_TYPE_KERNEL, /* OS Kernel Image  */
IH_TYPE_RAMDISK,/* RAMDisk Image*/
IH_TYPE_MULTI,  /* Multi-File Image */
IH_TYPE_FIRMWARE,   /* Firmware Image   */
IH_TYPE_SCRIPT, /* Script file  */
IH_TYPE_FILESYSTEM, /* Filesystem Image (any type)  */

For work around the problem, I disabled FIT image support entirely and
let the legacy image pick up IH_TYPE_FLATDT, too:

diff --git a/tools/default_image.c b/tools/default_image.c
index 4a067e65862e..ab145001e49d 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -26,7 +26,7 @@ static struct legacy_img_hdr header;
 
 static int image_check_image_types(uint8_t type)
 {
-   if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
+   if (((type > IH_TYPE_INVALID) && (type <= IH_TYPE_FLATDT)) ||
(type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
return EXIT_SUCCESS;
else
diff --git a/tools/fit_common.c b/tools/fit_common.c
index 01649760ac00..a967449103f0 100644
--- a/tools/fit_common.c
+++ b/tools/fit_common.c
@@ -43,9 +43,11 @@ int fit_verify_header(unsigned char *ptr, int image_size,
 
 int fit_check_image_types(uint8_t type)
 {
+#if 0
if (type == IH_TYPE_FLATDT)
return EXIT_SUCCESS;
else
+#endif
return EXIT_FAILURE;
 }

I though of adding a command line parameter to force legacy images,
regardless of the -T value (which means passing the parsed command line
parameters down into the check_image_type callback). Are the better
options or am I using mkimage wrong?

regards,
Marc

-- 
Pengutronix e.K. | Marc Kle

[PATCH v1 1/1] arm64: zynqmp: dynamically mark r5 cores as used

2022-10-28 Thread Lukas Funke
From: Lukas Funke 

When Linux boot takes over control of the pmu
(by signaling PM_INIT_FINALIZE via ipi), pmu will switch off 'unused'
rpu cores. The Xilinx zynqmp fsbl prevents switching off those cores by
marking rpu cores as 'used' when loading code partitions to those cores.
The current u-boot SPL is missing this behaviour, which results in
halting rpu cores during Linux boot.

This commit mimics the xilinx zynqmp fsbl behavior by marking r5 cores as
used when they are released during boot.

Signed-off-by: Lukas Funke 
Signed-off-by: Lukas Funke 
---

 arch/arm/mach-zynqmp/include/mach/hardware.h |  4 ++-
 arch/arm/mach-zynqmp/mp.c| 26 
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-zynqmp/include/mach/hardware.h 
b/arch/arm/mach-zynqmp/include/mach/hardware.h
index a70d6d611b..70221e0305 100644
--- a/arch/arm/mach-zynqmp/include/mach/hardware.h
+++ b/arch/arm/mach-zynqmp/include/mach/hardware.h
@@ -175,7 +175,9 @@ struct csu_regs {
 #define ZYNQMP_PMU_BASEADDR0xFFD8
 
 struct pmu_regs {
-   u32 reserved[18];
+   u32 reserved0[16];
+   u32 gen_storage4; /* 0x40 */
+   u32 reserved1[1];
u32 gen_storage6; /* 0x48 */
 };
 
diff --git a/arch/arm/mach-zynqmp/mp.c b/arch/arm/mach-zynqmp/mp.c
index 949456d530..2891878973 100644
--- a/arch/arm/mach-zynqmp/mp.c
+++ b/arch/arm/mach-zynqmp/mp.c
@@ -42,6 +42,9 @@
 
 #define ZYNQMP_MAX_CORES   6
 
+#define ZYNQMP_RPU0_USE_MASK BIT(1)
+#define ZYNQMP_RPU1_USE_MASK BIT(2)
+
 int is_core_valid(unsigned int core)
 {
if (core < ZYNQMP_MAX_CORES)
@@ -250,6 +253,27 @@ void initialize_tcm(bool mode)
}
 }
 
+static void mark_r5_used(u32 nr, u8 mode)
+{
+   u32 mask = 0;
+
+   if (mode == LOCK) {
+   mask = ZYNQMP_RPU0_USE_MASK | ZYNQMP_RPU1_USE_MASK;
+   } else {
+   switch (nr) {
+   case ZYNQMP_CORE_RPU0:
+   mask = ZYNQMP_RPU0_USE_MASK;
+   break;
+   case ZYNQMP_CORE_RPU1:
+   mask = ZYNQMP_RPU1_USE_MASK;
+   break;
+   default:
+   return;
+   }
+   }
+   zynqmp_mmio_write((ulong)&pmu_base->gen_storage4, mask, mask);
+}
+
 int cpu_release(u32 nr, int argc, char *const argv[])
 {
if (nr <= ZYNQMP_CORE_APU3) {
@@ -305,6 +329,7 @@ int cpu_release(u32 nr, int argc, char *const argv[])
write_tcm_boot_trampoline(boot_addr_uniq);
dcache_enable();
set_r5_halt_mode(nr, RELEASE, LOCK);
+   mark_r5_used(nr, LOCK);
} else if (!strncmp(argv[1], "split", 5)) {
printf("R5 split mode\n");
set_r5_reset(nr, SPLIT);
@@ -317,6 +342,7 @@ int cpu_release(u32 nr, int argc, char *const argv[])
write_tcm_boot_trampoline(boot_addr_uniq);
dcache_enable();
set_r5_halt_mode(nr, RELEASE, SPLIT);
+   mark_r5_used(nr, SPLIT);
} else {
printf("Unsupported mode\n");
return 1;
-- 
2.30.2



[PATCH v1 0/1] Marks real-time processing units (rpu) as used when released

2022-10-28 Thread Lukas Funke


When Linux boot takes over control of the pmu (by signaling
PM_INIT_FINALIZE via ipi), pmu will switch off 'unused' rpu cores.
The Xilinx zynqmp fsbl prevents switching off those cores by marking rpu
cores as 'used' when loading code partitions to those cores.
The current u-boot SPL is missing this behaviour, which results in
halting rpu cores during Linux boot.


Lukas Funke (1):
  arm64: zynqmp: dynamically mark r5 cores as used

 arch/arm/mach-zynqmp/include/mach/hardware.h |  4 ++-
 arch/arm/mach-zynqmp/mp.c| 26 
 2 files changed, 29 insertions(+), 1 deletion(-)

-- 
2.30.2



Re: Adapteva Parallella board

2022-10-28 Thread Martin Husemann
On Thu, Oct 27, 2022 at 11:14:01AM +0200, Michal Simek wrote:
> add DT to tree. If you have ps7_init create folder in board/xilinx/zynq/ 
> folder

I didn't find a ps7_init in the parallela u-boot fork, so skipped that
part...

> export DEVICE_TREE=...

I put the zynq-parallella.dtb that I had in my tftp dir (and use for
regular booting) into arch/arm/dts and set DEVICE_TREE=zynq-parallella

> xilinx_zynq_virt_defconfig

and that gets me to:

[..]
  AR  spl/drivers/built-in.o
  LD  spl/u-boot-spl
  OBJCOPY spl/u-boot-spl-nodtb.bin
  SYM spl/u-boot-spl.sym
  CAT spl/u-boot-spl-dtb.bin
  COPYspl/u-boot-spl.bin
gmake[1]: *** [scripts/Makefile.spl:248: spl/u-boot-spl-align.bin] Error 1
gmake: *** [Makefile:2106: spl/u-boot-spl] Error 2
gmake: *** Deleting file 'spl/u-boot-spl'


Is my dtb not correct for this purpose? How can I easily make the u-boot
build regen it from .dts? I found the slightly hidden dts/.*.cmd files,
do I need to clone one of that and adjust?

Martin


Re: [PATCH v2 1/1] Makefile: rework u-boot-initial-env target

2022-10-28 Thread Pali Rohár
Hello! This is really much better solution! Few comments are below.

On Friday 28 October 2022 18:18:49 Max Krummenacher wrote:
> From: Max Krummenacher 
> 
> With LTO enabled the U-Boot initial environment is no longer stored
> in an easy accessible section in env/common.o. I.e. the section name
> changes from build to build, its content maybe compressed and it is
> annotated with additional data.
> 
> Drop trying to read the initial env with elf tools from the compiler
> specific object file in favour of adding and using a host tool with
> the only functionality of printing the initial env to stdout.
> 
> See also:
> https://lore.kernel.org/all/927b122e-1f62-e790-f5ca-30bae4332...@foss.st.com/
> 
> Signed-off-by: Max Krummenacher 
> 
> ---
> 
> Changes in v2:
> - reworked to build a host tool which prints the configured
>   environment as proposed by Pali Rohár
>   
> https://lore.kernel.org/u-boot/20221018174827.1393211-1-max.oss...@gmail.com/
> - renamed patch, v1 used "Makefile: fix u-boot-initial-env target if lto is 
> enabled"
> 
>  Makefile  |  7 ---
>  scripts/.gitignore|  1 +
>  scripts/Makefile  |  5 +
>  scripts/printinitialenv.c | 44 +++
>  4 files changed, 54 insertions(+), 3 deletions(-)
>  create mode 100644 scripts/printinitialenv.c
> 
> diff --git a/Makefile b/Makefile
> index 0f1174718f7..2f97d63c398 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2442,9 +2442,10 @@ endif
>   $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
>  
>  quiet_cmd_genenv = GENENV  $@
> -cmd_genenv = $(OBJCOPY) --dump-section .rodata.default_environment=$@ 
> env/common.o; \
> - sed --in-place -e 's/\x00/\x0A/g' $@; sed --in-place -e '/^\s*$$/d' $@; 
> \
> - sort --field-separator== -k1,1 --stable $@ -o $@
> +cmd_genenv = \
> + scripts/printinitialenv | \
> + sed -e 's/\x00/\x0A/g' -e '/^\s*$$/d' | \

I think that you do not need this sed anymore as you print newline in
host tool.

> + sort --field-separator== -k1,1 --stable -o $@
>  
>  u-boot-initial-env: u-boot.bin

It is needed to update dependencies for u-boot-initial-env target. Now
it does not depend on u-boot.bin but rather on printinitialenv tool.

>   $(call if_changed,genenv)
> diff --git a/scripts/.gitignore b/scripts/.gitignore
> index 08cc824bac3..6068724a0d4 100644
> --- a/scripts/.gitignore
> +++ b/scripts/.gitignore
> @@ -2,3 +2,4 @@
>  # Generated files
>  #
>  bin2c
> +printinitialenv
> diff --git a/scripts/Makefile b/scripts/Makefile
> index 8731e6cecd7..ba993820571 100644
> --- a/scripts/Makefile
> +++ b/scripts/Makefile
> @@ -5,8 +5,13 @@
>  # ---
>  
>  hostprogs-$(CONFIG_BUILD_BIN2C)  += bin2c
> +hostprogs-y  += printinitialenv

I'm not sure if the scripts/ is the correct directory for the this tool.
Maybe it should be in tools? Lets wait what maintainers or Tom say.

>  
>  always   := $(hostprogs-y)
>  
> +HOSTCFLAGS_printinitialenv.o += \
> + $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
> + -DUSE_HOSTCC
> +
>  # Let clean descend into subdirs
>  subdir-  += basic kconfig dtc
> diff --git a/scripts/printinitialenv.c b/scripts/printinitialenv.c
> new file mode 100644
> index 000..c58b234d679
> --- /dev/null
> +++ b/scripts/printinitialenv.c
> @@ -0,0 +1,44 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * (C) Copyright 2022
> + * Max Krummenacher, Toradex
> + *
> + * Snippets taken from tools/env/fw_env.c
> + *
> + * This prints the list of default environment variables as currently
> + * configured.
> + *
> + */
> +
> +#include 
> +
> +/* Pull in the current config to define the default environment */
> +#include 
> +
> +#ifndef __ASSEMBLY__
> +#define __ASSEMBLY__ /* get only #defines from config.h */
> +#include 
> +#undef   __ASSEMBLY__
> +#else
> +#include 
> +#endif
> +
> +#define DEFAULT_ENV_INSTANCE_STATIC
> +#include 
> +#include 
> +
> +int main(void)
> +{
> + char *env, *nxt;
> +
> + for (env = default_environment; *env; env = nxt + 1) {
> + for (nxt = env; *nxt; ++nxt) {
> + if (nxt >= 
> &default_environment[sizeof(default_environment)]) {
> + fprintf(stderr, "## Error: environment not 
> terminated\n");
> + return -1;
> + }
> + }
> + printf("%s\n", env);
> + }
> + return 0;
> +}
> -- 
> 2.35.3
> 


Re: [PATCH v2] configs: mediatek: enable boot via extlinux

2022-10-28 Thread Tom Rini
On Fri, Oct 28, 2022 at 10:28:27AM +0200, Julien STEPHAN wrote:

> From: Alexandre Mergnat 
> 
> Enable FAT and SYSBOOT to use extlinux boot script
> 
> Signed-off-by: Jerome Brunet 
> Signed-off-by: Alexandre Mergnat 
> Signed-off-by: Julien STEPHAN 
> 
> ---
> V1 -> V2: adding missing CONFIG_ENV_OFFSET config
> ---
>  configs/mt8183_pumpkin_defconfig | 3 +++
>  configs/mt8516_pumpkin_defconfig | 7 +++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/configs/mt8183_pumpkin_defconfig 
> b/configs/mt8183_pumpkin_defconfig
> index 3c96d4eacb..9a7ad160d1 100644
> --- a/configs/mt8183_pumpkin_defconfig
> +++ b/configs/mt8183_pumpkin_defconfig
> @@ -48,8 +48,11 @@ CONFIG_CMD_PART=y
>  # CONFIG_CMD_ITEST is not set
>  # CONFIG_CMD_SETEXPR is not set
>  # CONFIG_CMD_BLOCK_CACHE is not set
> +CONFIG_CMD_SYSBOOT=y
>  CONFIG_CMD_EXT4=y
> +CONFIG_CMD_FAT=y
>  CONFIG_CMD_FS_GENERIC=y
> +# CONFIG_DOS_PARTITION is not set
>  CONFIG_ENV_IS_IN_MMC=y
>  CONFIG_SYS_MMC_ENV_PART=2
>  CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
> diff --git a/configs/mt8516_pumpkin_defconfig 
> b/configs/mt8516_pumpkin_defconfig
> index 0425ffd0f9..86b7b84970 100644
> --- a/configs/mt8516_pumpkin_defconfig
> +++ b/configs/mt8516_pumpkin_defconfig
> @@ -6,6 +6,7 @@ CONFIG_SYS_TEXT_BASE=0x4C00
>  CONFIG_SYS_MALLOC_F_LEN=0x4000
>  CONFIG_NR_DRAM_BANKS=1
>  CONFIG_ENV_SIZE=0x1000
> +CONFIG_ENV_OFFSET=0x0
>  CONFIG_DM_GPIO=y
>  CONFIG_DEFAULT_DEVICE_TREE="mt8516-pumpkin"
>  CONFIG_TARGET_MT8516=y
> @@ -49,6 +50,12 @@ CONFIG_CMD_PART=y
>  # CONFIG_CMD_SETEXPR is not set
>  # CONFIG_CMD_BLOCK_CACHE is not set
>  # CONFIG_CMD_SLEEP is not set
> +CONFIG_CMD_SYSBOOT=y
> +CONFIG_CMD_EXT4=y
> +CONFIG_CMD_FAT=y
> +CONFIG_CMD_FS_GENERIC=y
> +# CONFIG_DOS_PARTITION is not set
> +CONFIG_ENV_IS_IN_MMC=y
>  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>  CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
>  CONFIG_CLK=y

I will take this as is, but I would also encourage looking at enabling
DISTRO_DEFAULTS as that seems like the underlying problem, a platform
aimed at running off the shelf distros not enabling the CONFIG knob to
ensure all the required features are in turn enabled.

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v2 1/1] Makefile: rework u-boot-initial-env target

2022-10-28 Thread Max Krummenacher
From: Max Krummenacher 

With LTO enabled the U-Boot initial environment is no longer stored
in an easy accessible section in env/common.o. I.e. the section name
changes from build to build, its content maybe compressed and it is
annotated with additional data.

Drop trying to read the initial env with elf tools from the compiler
specific object file in favour of adding and using a host tool with
the only functionality of printing the initial env to stdout.

See also:
https://lore.kernel.org/all/927b122e-1f62-e790-f5ca-30bae4332...@foss.st.com/

Signed-off-by: Max Krummenacher 

---

Changes in v2:
- reworked to build a host tool which prints the configured
  environment as proposed by Pali Rohár
  https://lore.kernel.org/u-boot/20221018174827.1393211-1-max.oss...@gmail.com/
- renamed patch, v1 used "Makefile: fix u-boot-initial-env target if lto is 
enabled"

 Makefile  |  7 ---
 scripts/.gitignore|  1 +
 scripts/Makefile  |  5 +
 scripts/printinitialenv.c | 44 +++
 4 files changed, 54 insertions(+), 3 deletions(-)
 create mode 100644 scripts/printinitialenv.c

diff --git a/Makefile b/Makefile
index 0f1174718f7..2f97d63c398 100644
--- a/Makefile
+++ b/Makefile
@@ -2442,9 +2442,10 @@ endif
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
 
 quiet_cmd_genenv = GENENV  $@
-cmd_genenv = $(OBJCOPY) --dump-section .rodata.default_environment=$@ 
env/common.o; \
-   sed --in-place -e 's/\x00/\x0A/g' $@; sed --in-place -e '/^\s*$$/d' $@; 
\
-   sort --field-separator== -k1,1 --stable $@ -o $@
+cmd_genenv = \
+   scripts/printinitialenv | \
+   sed -e 's/\x00/\x0A/g' -e '/^\s*$$/d' | \
+   sort --field-separator== -k1,1 --stable -o $@
 
 u-boot-initial-env: u-boot.bin
$(call if_changed,genenv)
diff --git a/scripts/.gitignore b/scripts/.gitignore
index 08cc824bac3..6068724a0d4 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -2,3 +2,4 @@
 # Generated files
 #
 bin2c
+printinitialenv
diff --git a/scripts/Makefile b/scripts/Makefile
index 8731e6cecd7..ba993820571 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -5,8 +5,13 @@
 # ---
 
 hostprogs-$(CONFIG_BUILD_BIN2C)+= bin2c
+hostprogs-y+= printinitialenv
 
 always := $(hostprogs-y)
 
+HOSTCFLAGS_printinitialenv.o += \
+   $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
+   -DUSE_HOSTCC
+
 # Let clean descend into subdirs
 subdir-+= basic kconfig dtc
diff --git a/scripts/printinitialenv.c b/scripts/printinitialenv.c
new file mode 100644
index 000..c58b234d679
--- /dev/null
+++ b/scripts/printinitialenv.c
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2022
+ * Max Krummenacher, Toradex
+ *
+ * Snippets taken from tools/env/fw_env.c
+ *
+ * This prints the list of default environment variables as currently
+ * configured.
+ *
+ */
+
+#include 
+
+/* Pull in the current config to define the default environment */
+#include 
+
+#ifndef __ASSEMBLY__
+#define __ASSEMBLY__ /* get only #defines from config.h */
+#include 
+#undef __ASSEMBLY__
+#else
+#include 
+#endif
+
+#define DEFAULT_ENV_INSTANCE_STATIC
+#include 
+#include 
+
+int main(void)
+{
+   char *env, *nxt;
+
+   for (env = default_environment; *env; env = nxt + 1) {
+   for (nxt = env; *nxt; ++nxt) {
+   if (nxt >= 
&default_environment[sizeof(default_environment)]) {
+   fprintf(stderr, "## Error: environment not 
terminated\n");
+   return -1;
+   }
+   }
+   printf("%s\n", env);
+   }
+   return 0;
+}
-- 
2.35.3



[PATCH v2 0/1] Makefile: rework u-boot-initial-env target

2022-10-28 Thread Max Krummenacher
From: Max Krummenacher 


With CONFIG_LTO enabled the current way of extracting the
configured environment no longer works, i.e. the object file
content changes due to LTO.

Build a host tool which prints the configured environment instead
of using objcopy and friends to achive the same.

The code and Makefile changes were mostly stolen from tools/env/
i.e. the target userspace tools to access the environment.


Changes in v2:
- reworked to build a host tool which prints the configured
  environment as proposed by Pali Rohár
  https://lore.kernel.org/u-boot/20221018174827.1393211-1-max.oss...@gmail.com/
- renamed patch, v1 used "Makefile: fix u-boot-initial-env target if lto is 
enabled"

Max Krummenacher (1):
  Makefile: rework u-boot-initial-env target

 Makefile  |  7 ---
 scripts/.gitignore|  1 +
 scripts/Makefile  |  5 +
 scripts/printinitialenv.c | 44 +++
 4 files changed, 54 insertions(+), 3 deletions(-)
 create mode 100644 scripts/printinitialenv.c

-- 
2.35.3



Re: [PATCH 0/5] cyclic: get rid of (the need for) cyclic_init()

2022-10-28 Thread Tim Harvey
On Fri, Oct 28, 2022 at 4:51 AM Rasmus Villemoes
 wrote:
>
> I have only compile-tested each of these for sandbox_defconfig and
> imx8mq_cm_defconfig. I couldn't even figure out how to run the cyclic
> test inside sandbox by itself, and I don't have any hardware here at
> home. So perhaps just consider these a POC of the overall idea, namely
> to use a list abstraction which doesn't need initialization other than
> what we already guarantee to do for all of struct global_data.
>
> As positive side effects, the generated code will be a little smaller,
> we reduce the use of the early malloc() pool, and the diffstat below
> is also nice.
>
> I don't know if we ever do anything in SPL that would require a call
> to cyclic_unregister_all().
>
> Rasmus Villemoes (5):
>   cyclic: use a flag in gd->flags for recursion protection
>   cyclic: drop redundant cyclic_ready flag
>   list.h: synchronize hlist_for_each_entry* iterators with linux
>   cyclic: switch to using hlist instead of list
>   cyclic: get rid of cyclic_init()
>
>  cmd/cyclic.c  |  5 +--
>  common/board_f.c  |  2 +-
>  common/board_r.c  |  1 -
>  common/cyclic.c   | 50 ++---
>  include/asm-generic/global_data.h |  8 +++--
>  include/cyclic.h  | 35 +++-
>  include/linux/list.h  | 53 +++
>  test/test-main.c  |  3 +-
>  8 files changed, 57 insertions(+), 100 deletions(-)
>
> --
> 2.37.2

Rasmus,

Thanks, this does indeed resolve the SPL and U-Boot regressions
introduced. I verified the watchdig is initalized and cyclic wdt reset
is called in both SPL and U-Boot.

Tested-By: Tim Harvey  # imx8mm-venice-*

I'm not sure if a 'Fixes: 29caf9305b6f ("cyclic: Use schedule()
instead of WATCHDOG_RESET()")' is useful anywhere here.

Best Regards,

Tim


Re: [PATCH v8 0/8] Add MV88E6xxx DSA driver and use on gwventana

2022-10-28 Thread Tim Harvey
On Fri, Oct 28, 2022 at 1:45 AM Vladimir Oltean  wrote:
>
> On Thu, Oct 27, 2022 at 05:49:29PM -0700, Tim Harvey wrote:
> > This series adds a DSA driver for the MV88E6xxx based on
> > drivers/net/phy/mv88e61xx and uses it in the gwventana_gw5904_defconfig.
>
> Looks good, thanks. To me this is ready to go!

Vladimir,

Great - thanks for all the help on this series!

Tim


Re: question about uboot mt7620 RAM_VERSION

2022-10-28 Thread Kang-sen Lu
Hi, Stefan:

Thanks for your effort to build a ubbot.bin (RAM_VERSION) for mt7620
router. I tried it out, using tftp to download it. It did start but having
some errors. I have saved the log for you. It is in the attachment.

I want to report to you that I have built the uboot.bin (ROM_VERSION) for
mt7620, based on the git from  https://github.com/tessel/uboot-mt7620. Yes,
you told me that code was very old. But I can burn that ROM_VERSION into
mt7620 and see it perform kernel boot correctly. My RAM_VERSION also runs
correctly.

I am wondering if you can point me to the latest uboot git tree for mt7620?
I would be interested in trying it out. The reason I need the source code
of uboot is so that I can enhance it for our own requirement.

Thanks.

Kang-sen

On Wed, Oct 26, 2022 at 1:36 AM Stefan Roese  wrote:

> Hi Kang-sen,
>
> On 25.10.22 21:40, Kang-sen Lu wrote:
> > I am sorry that I was working on an old uboot version. You mentioned
> > that you have ported uboot to my7620. I would like to download it. Is it
> > available at this site? https://github.com/u-boot/u-boot
> > .
>
> Unfortunately it's not that easy. As your specific board (router) needs
> to get ported to upstream U-Boot. It might be the case, that at least
> the RAM version of the currently supported MT7620 board "mt7620_rfb"
> works for you. But this is very unlikely - sorry, I don't know this
> board and your router in detail.
>
> I've compiled the binaries for the mt7620_rfb and attached the resulting
> u-boot.bin, which might work as a RAM target for you. Just give it a
> try. The TEXT_BASE is 0x8020, so you should load and boot it from
> there:
>
> => tftp 0x8020 u-boot.bin
> => go 0x8020
>
> Let me know if this produces some output or crashes directly.
>
> Thanks,
> Stefan
>
> > Thanks.
> >
> > Kang-sen
> >
> > On Tue, Oct 25, 2022 at 10:47 AM Stefan Roese  > > wrote:
> >
> > Hi Kang-sen,
> >
> > On 25.10.22 15:25, Kang-sen Lu wrote:
> >  > Thanks for your reply.
> >  >
> >  > I cloned the uboot source code from here:
> >  > https://github.com/tessel/uboot-mt7620
> > 
> >  >  > >
> >  >
> >  > I built the uboot.bin for RAM_VERSION. If I select option 8 at
> > power up
> >  > with the uboot from zbtlink, the new uboot.bin will hang. But if I
> >  > caused saveenv() to happen, by changing tftp filename
> > artificially, the
> >  > uboot.bin for RAM_VERSION will start and run properly, by the
> > uboot from
> >  > zbtlink.
> >
> > Sorry, this is the ancient U-Boot version. I thought you were talking
> > about the mainline U-Boot version, which I ported for MT7620/80 some
> > years ago (with many extensions and fixes by Weijie later on).
> >
> > I don't remember the details of this ancient MT7620 U-Boot version
> > and frankly don't want to dig into this (again).
> >
> >  > Maybe Weijie can comment on the experimental result?
> >
> > Maybe.
> >
> >  > Thanks.
> >  >
> >  > Kang-sen
> >  >
> >  > BTW: How does uboot developer usually run the RAM_VERSION
> > uboot.bin, I
> >  > am curious. Is it loaded with tftp server, or something else?
> >
> > Yes. This is very handy and frequently done. Load the RAM version
> > into RAM to the TEXT_BASE address and start it from there via the
> > "go" command.
> >
> > BTW: Please keep the ML on Cc. It might be that someone else has
> > some answers. Or that this topic is interesting for other
> > people as well.
> >
> > Thanks,
> > Stefan
> >
> >  > On Tue, Oct 25, 2022 at 12:46 AM Stefan Roese  > 
> >  > >> wrote:
> >  >
> >  > Hi Kang-sen,
> >  >
> >  > On 24.10.22 19:58, Kang-sen Lu wrote:
> >  >  > I am wondering if you have read my reply on 10/18. It is
> very
> >  > strange to
> >  >  > find that unless I had uboot to do a saveenv, the
> RAM_VERSION
> >  > uboot.bin
> >  >  > would not run properly in DRAM.
> >  >
> >  > Frankly, I don't really understand this message. It's not
> > clear to
> >  > me, what you are doing and what is working and what is
> failing.
> >  >
> >  > I thought you were trying to boot the current mainline U-Boot
> RAM
> >  > version u-boot.bin. If yes, which build target did you use?
> What
> >  > does it show on the serial console?
> >  >
> >  > Thanks,
> >  > Stefan
> >  >
> >  >  > Thanks.
> >  >  >
> >  >  > Kang-sen
> >  >  >
> >  >  > On Tue, Oct 18, 2022 at 10:05 AM Kang-sen Lu  > 
> >  > >
> >   

Re: [PATCH 0/5] cyclic: get rid of (the need for) cyclic_init()

2022-10-28 Thread Stefan Roese

Hi Rasmus,

On 28.10.22 13:50, Rasmus Villemoes wrote:

I have only compile-tested each of these for sandbox_defconfig and
imx8mq_cm_defconfig. I couldn't even figure out how to run the cyclic
test inside sandbox by itself, and I don't have any hardware here at
home.


There is "cyclic demo" command which can be used to do some tests.
But as I just now noticed, this behaves a bit "abnormal" in sandbox.
This is with and w/o your patchset though. I need to look into this
a bit later.


So perhaps just consider these a POC of the overall idea, namely
to use a list abstraction which doesn't need initialization other than
what we already guarantee to do for all of struct global_data.

As positive side effects, the generated code will be a little smaller,
we reduce the use of the early malloc() pool, and the diffstat below
is also nice.


Fully agreed. :)


I don't know if we ever do anything in SPL that would require a call
to cyclic_unregister_all().


I can't think of anything right now.


Rasmus Villemoes (5):
   cyclic: use a flag in gd->flags for recursion protection
   cyclic: drop redundant cyclic_ready flag
   list.h: synchronize hlist_for_each_entry* iterators with linux
   cyclic: switch to using hlist instead of list
   cyclic: get rid of cyclic_init()

  cmd/cyclic.c  |  5 +--
  common/board_f.c  |  2 +-
  common/board_r.c  |  1 -
  common/cyclic.c   | 50 ++---
  include/asm-generic/global_data.h |  8 +++--
  include/cyclic.h  | 35 +++-
  include/linux/list.h  | 53 +++
  test/test-main.c  |  3 +-
  8 files changed, 57 insertions(+), 100 deletions(-)



Yes, this diffstat is really nice. Thanks a lot for working on this and
improving and fixing this new cyclic infrastructure.

Thanks,
Stefan


Re: [PATCH 5/5] cyclic: get rid of cyclic_init()

2022-10-28 Thread Stefan Roese

On 28.10.22 13:50, Rasmus Villemoes wrote:

Currently, we must call cyclic_init() at some point before
cyclic_register() becomes possible. That turns out to be somewhat
awkward, especially with SPL, and has resulted in a watchdog callback
not being registered, thus causing the board to prematurely reset.

We already rely on gd->cyclic reliably being set to NULL by the asm
code that clears all of gd. Now that the cyclic list is a hlist, and
thus an empty list is represented by a NULL head pointer, and struct
cyclic_drv has no other members, we can just as well drop a level of
indirection and put the hlist_head directly in struct
global_data. This doesn't increase the size of struct global_data,
gets rid of an early malloc(), and generates slightly smaller code.


Elegant, simple, good. Thanks.


But primarily, this avoids having to call cyclic_init() early; the cyclic
infrastructure is simply ready to register callbacks as soon as we
enter C code.

We can still end up with schedule() being called from asm very early,
so we still need to check that gd itself has been properly initialized
[*], but once it has, gd->cyclic_list is perfectly fine to access, and
will just be an empty list.

As for cyclic_uninit(), it was never really the opposite of
cyclic_init() since it didn't free the struct cyclic_drv nor set
gd->cyclic to NULL. Rename it to cyclic_unregister_all() and use that
in test/, and also insert a call at the end of the board_init_f
sequence so that gd->cyclic_list is a fresh empty list before we enter
board_init_r().


While reviewing the code, this was the only thing I wanted to
ask about. Now with this explanation it makes perfect sense.
Perhaps a small comment with this reasoning in the code here in
board_init_r would be helpful.


A small piece of ugliness is that I had to add a cast in
cyclic_get_list() to silence a "discards 'volatile' qualifier"
warning, but that is completely equivalent to the existing handling of
the uclass_root_s list_head member.

[*] I'm not really sure where we guarantee that the register used for
gd contains 0 until it gets explicitly initialized, but that must be
the case, otherwise testing gd for being NULL would not make much sense.

Signed-off-by: Rasmus Villemoes 
---
  common/board_f.c  |  2 +-
  common/board_r.c  |  1 -
  common/cyclic.c   | 32 +++
  include/asm-generic/global_data.h |  4 ++--
  include/cyclic.h  | 27 +++---
  test/test-main.c  |  3 +--
  6 files changed, 14 insertions(+), 55 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index 4355d1c82d..1f9140a065 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -844,7 +844,6 @@ static const init_fnc_t init_sequence_f[] = {
initf_malloc,
log_init,
initf_bootstage,/* uses its own timer, so does not need DM */
-   cyclic_init,
event_init,
  #ifdef CONFIG_BLOBLIST
bloblist_init,
@@ -962,6 +961,7 @@ static const init_fnc_t init_sequence_f[] = {
do_elf_reloc_fixups,
  #endif
clear_bss,
+   cyclic_unregister_all,
  #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
!CONFIG_IS_ENABLED(X86_64)
jump_to_copy,
diff --git a/common/board_r.c b/common/board_r.c
index 92ca2066ee..0e2e63a21b 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -614,7 +614,6 @@ static init_fnc_t init_sequence_r[] = {
  #endif
initr_barrier,
initr_malloc,
-   cyclic_init,
log_init,
initr_bootstage,/* Needs malloc() but has its own timer */
  #if defined(CONFIG_CONSOLE_RECORD)
diff --git a/common/cyclic.c b/common/cyclic.c
index 32d9bf0d02..a49bfc88f5 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -22,7 +22,8 @@ void hw_watchdog_reset(void);
  
  struct hlist_head *cyclic_get_list(void)

  {
-   return &gd->cyclic->cyclic_list;
+   /* Silence "discards 'volatile' qualifier" warning. */
+   return (struct hlist_head *)&gd->cyclic_list;
  }
  
  struct cyclic_info *cyclic_register(cyclic_func_t func, uint64_t delay_us,

@@ -30,11 +31,6 @@ struct cyclic_info *cyclic_register(cyclic_func_t func, 
uint64_t delay_us,
  {
struct cyclic_info *cyclic;
  
-	if (!gd->cyclic) {

-   pr_debug("Cyclic IF not ready yet\n");
-   return NULL;
-   }
-
cyclic = calloc(1, sizeof(struct cyclic_info));
if (!cyclic) {
pr_debug("Memory allocation error\n");
@@ -47,7 +43,7 @@ struct cyclic_info *cyclic_register(cyclic_func_t func, 
uint64_t delay_us,
cyclic->name = strdup(name);
cyclic->delay_us = delay_us;
cyclic->start_time_us = timer_get_us();
-   hlist_add_head(&cyclic->list, &gd->cyclic->cyclic_list);
+   hlist_add_head(&cyclic->list, cyclic_get_list());
  
  	return cyclic;

  }
@@ -71,7 +67,7 @@ void cyclic_run(void)
return;
  
  	gd-

Re: [PATCH 3/5] list.h: synchronize hlist_for_each_entry* iterators with linux

2022-10-28 Thread Stefan Roese

On 28.10.22 13:50, Rasmus Villemoes wrote:

All the way back in 2013, the linux kernel updated the four
hlist_for_each_entry* iterators to require one less auxiliary
variable:

   commit b67bfe0d42cac56c512dd5da4b1b347a23f4b70a
   Author: Sasha Levin 
   Date:   Wed Feb 27 17:06:00 2013 -0800

   hlist: drop the node parameter from iterators

Currently, there is only one "user" of any of these, namely in
fs/ubifs/super.c, but that actually uses the "new-style" form, and
is (obviously, or it wouldn't have built) inside #ifndef __UBOOT__.

Before adding actual users of these, import the version as of linux
v6.1-rc1, including the hlist_entry_safe() helper used by the new
versions.

Signed-off-by: Rasmus Villemoes 
---
  include/linux/list.h | 53 +---
  1 file changed, 25 insertions(+), 28 deletions(-)

diff --git a/include/linux/list.h b/include/linux/list.h
index 3eacf68e3a..6910721c00 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -646,54 +646,51 @@ static inline void hlist_add_after(struct hlist_node *n,
for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
 pos = n)
  
+#define hlist_entry_safe(ptr, type, member) \

+   ({ typeof(ptr) ptr = (ptr); \
+  ptr ? hlist_entry(ptr, type, member) : NULL; \
+   })
+
  /**
   * hlist_for_each_entry   - iterate over list of given type
- * @tpos:  the type * to use as a loop cursor.
- * @pos:   the &struct hlist_node to use as a loop cursor.
+ * @pos:   the type * to use as a loop cursor.
   * @head: the head for your list.
   * @member:   the name of the hlist_node within the struct.
   */
-#define hlist_for_each_entry(tpos, pos, head, member)   \
-   for (pos = (head)->first; \
-pos && ({ prefetch(pos->next); 1;}) &&   \
-   ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
-pos = pos->next)
+#define hlist_for_each_entry(pos, head, member)
\
+   for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
+pos;   \
+pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
  
  /**

   * hlist_for_each_entry_continue - iterate over a hlist continuing after 
current point
- * @tpos:  the type * to use as a loop cursor.
- * @pos:   the &struct hlist_node to use as a loop cursor.
+ * @pos:   the type * to use as a loop cursor.
   * @member:   the name of the hlist_node within the struct.
   */
-#define hlist_for_each_entry_continue(tpos, pos, member)\
-   for (pos = (pos)->next;   \
-pos && ({ prefetch(pos->next); 1;}) &&   \
-   ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
-pos = pos->next)
+#define hlist_for_each_entry_continue(pos, member) \
+   for (pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), 
member);\
+pos;   \
+pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
  
  /**

   * hlist_for_each_entry_from - iterate over a hlist continuing from current 
point
- * @tpos:  the type * to use as a loop cursor.
- * @pos:   the &struct hlist_node to use as a loop cursor.
+ * @pos:   the type * to use as a loop cursor.
   * @member:   the name of the hlist_node within the struct.
   */
-#define hlist_for_each_entry_from(tpos, pos, member)\
-   for (; pos && ({ prefetch(pos->next); 1;}) && \
-   ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
-pos = pos->next)
+#define hlist_for_each_entry_from(pos, member) \
+   for (; pos; \
+pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
  
  /**

   * hlist_for_each_entry_safe - iterate over list of given type safe against 
removal of list entry
- * @tpos:  the type * to use as a loop cursor.
- * @pos:   the &struct hlist_node to use as a loop cursor.
- * @n: another &struct hlist_node to use as temporary storage
+ * @pos:   the type * to use as a loop cursor.
+ * @n: a &struct hlist_node to use as temporary storage
   * @head: the head for your list.
   * @member:   the name of the hlist_node within the struct.
   */
-#define hlist_for_each_entry_safe(tpos, pos, n, head, member)   \
-   for (pos = (head)->first; \
-pos && ({ n = pos->next; 1; }) &&\
-   ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
-pos = n)
+#define hlist_for_e

Re: [PATCH 4/5] cyclic: switch to using hlist instead of list

2022-10-28 Thread Stefan Roese

On 28.10.22 13:50, Rasmus Villemoes wrote:

A hlist is headed by just a single pointer, so can only be traversed
forwards, and insertions can only happen at the head (or before/after
an existing list member). But each list node still consists of two
pointers, so arbitrary elements can still be removed in O(1).

This is precisely what we need for the cyclic_list - we never need to
traverse it backwards, and the order the callbacks appear in the list
should really not matter.

One advantage, and the main reason for doing this switch, is that an
empty list is represented by a NULL head pointer, so unlike a
list_head, it does not need separate C code to initialize - a
memset(,0,) of the containing structure is sufficient.

This is mostly mechanical:

- The iterators are updated with an h prefix, and the type of the
   temporary variable changed to struct hlist_node*.

- Adding/removing is now just hlist_add_head (and not tail) and
   hlist_del().

- struct members and function return values updated.

Signed-off-by: Rasmus Villemoes 
---
  cmd/cyclic.c |  5 +++--
  common/cyclic.c  | 18 ++
  include/cyclic.h |  6 +++---
  3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/cmd/cyclic.c b/cmd/cyclic.c
index c1bc556aad..97324d8240 100644
--- a/cmd/cyclic.c
+++ b/cmd/cyclic.c
@@ -61,10 +61,11 @@ static int do_cyclic_demo(struct cmd_tbl *cmdtp, int flag, 
int argc,
  static int do_cyclic_list(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[])
  {
-   struct cyclic_info *cyclic, *tmp;
+   struct cyclic_info *cyclic;
+   struct hlist_node *tmp;
u64 cnt, freq;
  
-	list_for_each_entry_safe(cyclic, tmp, cyclic_get_list(), list) {

+   hlist_for_each_entry_safe(cyclic, tmp, cyclic_get_list(), list) {
cnt = cyclic->run_cnt * 100ULL * 100ULL;
freq = lldiv(cnt, timer_get_us() - cyclic->start_time_us);
printf("function: %s, cpu-time: %lld us, frequency: %lld.%02d 
times/s\n",
diff --git a/common/cyclic.c b/common/cyclic.c
index d6f11b002e..32d9bf0d02 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -20,7 +20,7 @@ DECLARE_GLOBAL_DATA_PTR;
  
  void hw_watchdog_reset(void);
  
-struct list_head *cyclic_get_list(void)

+struct hlist_head *cyclic_get_list(void)
  {
return &gd->cyclic->cyclic_list;
  }
@@ -47,14 +47,14 @@ struct cyclic_info *cyclic_register(cyclic_func_t func, 
uint64_t delay_us,
cyclic->name = strdup(name);
cyclic->delay_us = delay_us;
cyclic->start_time_us = timer_get_us();
-   list_add_tail(&cyclic->list, &gd->cyclic->cyclic_list);
+   hlist_add_head(&cyclic->list, &gd->cyclic->cyclic_list);
  
  	return cyclic;

  }
  
  int cyclic_unregister(struct cyclic_info *cyclic)

  {
-   list_del(&cyclic->list);
+   hlist_del(&cyclic->list);
free(cyclic);
  
  	return 0;

@@ -62,7 +62,8 @@ int cyclic_unregister(struct cyclic_info *cyclic)
  
  void cyclic_run(void)

  {
-   struct cyclic_info *cyclic, *tmp;
+   struct cyclic_info *cyclic;
+   struct hlist_node *tmp;
uint64_t now, cpu_time;
  
  	/* Prevent recursion */

@@ -70,7 +71,7 @@ void cyclic_run(void)
return;
  
  	gd->flags |= GD_FLG_CYCLIC_RUNNING;

-   list_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list) {
+   hlist_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list) {
/*
 * Check if this cyclic function needs to get called, e.g.
 * do not call the cyclic func too often
@@ -118,9 +119,10 @@ void schedule(void)
  
  int cyclic_uninit(void)

  {
-   struct cyclic_info *cyclic, *tmp;
+   struct cyclic_info *cyclic;
+   struct hlist_node *tmp;
  
-	list_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list)

+   hlist_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list)
cyclic_unregister(cyclic);
  
  	return 0;

@@ -135,7 +137,7 @@ int cyclic_init(void)
return -ENOMEM;
  
  	memset(gd->cyclic, '\0', size);

-   INIT_LIST_HEAD(&gd->cyclic->cyclic_list);
+   INIT_HLIST_HEAD(&gd->cyclic->cyclic_list);
  
  	return 0;

  }
diff --git a/include/cyclic.h b/include/cyclic.h
index 263b74d89b..4a11f9b105 100644
--- a/include/cyclic.h
+++ b/include/cyclic.h
@@ -20,7 +20,7 @@
   * @cyclic_list: Cylic list node
   */
  struct cyclic_drv {
-   struct list_head cyclic_list;
+   struct hlist_head cyclic_list;
  };
  
  /**

@@ -46,7 +46,7 @@ struct cyclic_info {
uint64_t cpu_time_us;
uint64_t run_cnt;
uint64_t next_call;
-   struct list_head list;
+   struct hlist_node list;
bool already_warned;
  };
  
@@ -95,7 +95,7 @@ int cyclic_uninit(void);

   *
   * @return: pointer to cyclic_list
   */
-struct list_head *cyclic_get_list(void);
+struct hlist_head *cyclic_get_list(void);
  
  /**

   * cyclic_run() - Interate over all r

Re: [PATCH 2/5] cyclic: drop redundant cyclic_ready flag

2022-10-28 Thread Stefan Roese

On 28.10.22 13:50, Rasmus Villemoes wrote:

We're already relying on gd->cyclic being NULL before cyclic_init() is
called - i.e., we're relying on all of gd being zeroed before entering
any C code. And when we do populate gd->cyclic, its ->cyclic_ready
member is automatically set to true. So we can actually just rely on
testing gd->cyclic itself.

The only wrinkle is that cyclic_uninit() actually did set
->cyclic_ready to false. However, since it doesn't free gd->cyclic,
the cyclic infrastructure is actually still ready (i.e., the list_head
is properly initialized as an empty list).

Signed-off-by: Rasmus Villemoes 
---
  common/cyclic.c  | 6 ++
  include/cyclic.h | 2 --
  2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/common/cyclic.c b/common/cyclic.c
index ff75c8cadb..d6f11b002e 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -30,7 +30,7 @@ struct cyclic_info *cyclic_register(cyclic_func_t func, 
uint64_t delay_us,
  {
struct cyclic_info *cyclic;
  
-	if (!gd->cyclic->cyclic_ready) {

+   if (!gd->cyclic) {
pr_debug("Cyclic IF not ready yet\n");
return NULL;
}
@@ -112,7 +112,7 @@ void schedule(void)
 * schedule() might get called very early before the cyclic IF is
 * ready. Make sure to only call cyclic_run() when it's initalized.
 */
-   if (gd && gd->cyclic && gd->cyclic->cyclic_ready)
+   if (gd && gd->cyclic)
cyclic_run();
  }
  
@@ -122,7 +122,6 @@ int cyclic_uninit(void)
  
  	list_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list)

cyclic_unregister(cyclic);
-   gd->cyclic->cyclic_ready = false;
  
  	return 0;

  }
@@ -137,7 +136,6 @@ int cyclic_init(void)
  
  	memset(gd->cyclic, '\0', size);

INIT_LIST_HEAD(&gd->cyclic->cyclic_list);
-   gd->cyclic->cyclic_ready = true;
  
  	return 0;

  }
diff --git a/include/cyclic.h b/include/cyclic.h
index 50427baa3f..263b74d89b 100644
--- a/include/cyclic.h
+++ b/include/cyclic.h
@@ -18,11 +18,9 @@
   * struct cyclic_drv - Cyclic driver internal data
   *
   * @cyclic_list: Cylic list node
- * @cyclic_ready: Flag if cyclic infrastructure is ready
   */
  struct cyclic_drv {
struct list_head cyclic_list;
-   bool cyclic_ready;
  };
  
  /**


Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 

Thanks,
Stefan


Re: [PATCH 1/5] cyclic: use a flag in gd->flags for recursion protection

2022-10-28 Thread Stefan Roese

On 28.10.22 13:50, Rasmus Villemoes wrote:

As a preparation for future patches, use a flag in gd->flags rather
than a separate member in (the singleton) struct cyclic_drv to keep
track of whether we're already inside cyclic_run().

Signed-off-by: Rasmus Villemoes 
---
  common/cyclic.c   | 6 +++---
  include/asm-generic/global_data.h | 4 
  include/cyclic.h  | 2 --
  3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/common/cyclic.c b/common/cyclic.c
index 7abb82c16a..ff75c8cadb 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -66,10 +66,10 @@ void cyclic_run(void)
uint64_t now, cpu_time;
  
  	/* Prevent recursion */

-   if (gd->cyclic->cyclic_running)
+   if (gd->flags & GD_FLG_CYCLIC_RUNNING)
return;
  
-	gd->cyclic->cyclic_running = true;

+   gd->flags |= GD_FLG_CYCLIC_RUNNING;
list_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list) {
/*
 * Check if this cyclic function needs to get called, e.g.
@@ -99,7 +99,7 @@ void cyclic_run(void)
}
}
}
-   gd->cyclic->cyclic_running = false;
+   gd->flags &= ~GD_FLG_CYCLIC_RUNNING;
  }
  
  void schedule(void)

diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index 2d55fe2ac0..ca36907b20 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -650,6 +650,10 @@ enum gd_flags {
 * @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests
 */
GD_FLG_FDT_CHANGED = 0x10,
+   /**
+* GD_FLG_CYCLIC_RUNNING: cyclic_run is in progress
+*/
+   GD_FLG_CYCLIC_RUNNING = 0x20,
  };
  
  #endif /* __ASSEMBLY__ */

diff --git a/include/cyclic.h b/include/cyclic.h
index 9c5c4fcc54..50427baa3f 100644
--- a/include/cyclic.h
+++ b/include/cyclic.h
@@ -19,12 +19,10 @@
   *
   * @cyclic_list: Cylic list node
   * @cyclic_ready: Flag if cyclic infrastructure is ready
- * @cyclic_running: Flag if cyclic infrastructure is running
   */
  struct cyclic_drv {
struct list_head cyclic_list;
bool cyclic_ready;
-   bool cyclic_running;
  };
  
  /**


Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 

Thanks,
Stefan


Re: imx8 regression: cyclic_register for watchdog@30280000 failed

2022-10-28 Thread Stefan Roese

Hi Rasmus,

On 28.10.22 14:14, Rasmus Villemoes wrote:

On 26/10/2022 21.06, Tim Harvey wrote:


29caf9305b6f cyclic: Use schedule() instead of WATCHDOG_RESET()
^^^ build issue resolved, boot issue on imx8mm-venice resolved, but
this is where we now encounter watchdog failures in both the SPL and
U-Boot:

SPL:
cyclic_register for watchdog@3028 failed
WDT:   Failed to start watchdog@3028

The failure here is 'Cyclic IF not ready yet' (which should probably
be an error print not a debug print). In this case the watchdog gets
started but never reset via cyclic. This is due to cyclic_init never
being called in the SPL - where is that supposed to occur?


Actually, the code both in current master and at 29caf9305b6f does

 if (!gd->cyclic->cyclic_ready) {
 pr_debug("Cyclic IF not ready yet\n");
 return NULL;
 }

and when cyclic_init() hasn't been called, that gd->cyclic is NULL.


Ugh!


Unfortunately, on the imx8m platforms, 0 is a perfectly valid address
(that's where the bootrom code lives), so the fact that this even
triggers is mostly random, AFAICT; there might as well have been a
non-zero byte at that offset from address 0. But then things would
probably have exploded in interesting ways when the new cyclic_info
would be added to the garbage gd->cyclic->cyclic_list (maybe the write
to that memory would just result in a reset or hang).

Anyway, the series I just sent removes this check entirely and should
work in SPL as well without the cyclic_init(), but please do test.


Thanks again for working on this. I'll try to look into this very soon
(weekend or beginning of next week). Looks very promising. :)

Thanks,
Stefan


[PATCH] mips: mtmips: spl/Kconfig: Set CONFIG_SPL_PAD_TO to 0x0 for ARCH_MTMIPS

2022-10-28 Thread Stefan Roese
It was noticed that while converting CONFIG_SPL_PAD_TO to Kconfig its
value for the MIPS MT762x/8x targets got not ported correctly. Its
default is not 0x1 instead of 0x0. This patch fixes this issue.

Fixes: ca8a329a1b7f ("Convert CONFIG_SPL_PAD_TO et al to Kconfig")
Signed-off-by: Stefan Roese 
Cc: Ruben Winters 
Cc: Weijie Gao 
Cc: Daniel Schwierzeck 
Cc: Tom Rini 
---
 common/spl/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index b738c749fff4..05181bdba3e1 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -98,6 +98,7 @@ config SPL_PAD_TO
default 0x11000 if ARCH_MX7 || (ARCH_MX6 && !MX6_OCRAM_256KB)
default 0x1 if ARCH_KEYSTONE
default 0x8000 if ARCH_SUNXI && !MACH_SUN50I_H616
+   default 0x0 if ARCH_MTMIPS
default TPL_MAX_SIZE if TPL_MAX_SIZE > SPL_MAX_SIZE
default SPL_MAX_SIZE
help
-- 
2.38.1



Re: imx8 regression: cyclic_register for watchdog@30280000 failed

2022-10-28 Thread Rasmus Villemoes
On 26/10/2022 21.06, Tim Harvey wrote:

> 29caf9305b6f cyclic: Use schedule() instead of WATCHDOG_RESET()
> ^^^ build issue resolved, boot issue on imx8mm-venice resolved, but
> this is where we now encounter watchdog failures in both the SPL and
> U-Boot:
> 
> SPL:
> cyclic_register for watchdog@3028 failed
> WDT:   Failed to start watchdog@3028
> 
> The failure here is 'Cyclic IF not ready yet' (which should probably
> be an error print not a debug print). In this case the watchdog gets
> started but never reset via cyclic. This is due to cyclic_init never
> being called in the SPL - where is that supposed to occur?

Actually, the code both in current master and at 29caf9305b6f does

if (!gd->cyclic->cyclic_ready) {
pr_debug("Cyclic IF not ready yet\n");
return NULL;
}

and when cyclic_init() hasn't been called, that gd->cyclic is NULL.
Unfortunately, on the imx8m platforms, 0 is a perfectly valid address
(that's where the bootrom code lives), so the fact that this even
triggers is mostly random, AFAICT; there might as well have been a
non-zero byte at that offset from address 0. But then things would
probably have exploded in interesting ways when the new cyclic_info
would be added to the garbage gd->cyclic->cyclic_list (maybe the write
to that memory would just result in a reset or hang).

Anyway, the series I just sent removes this check entirely and should
work in SPL as well without the cyclic_init(), but please do test.

Rasmus



[PATCH 5/5] cyclic: get rid of cyclic_init()

2022-10-28 Thread Rasmus Villemoes
Currently, we must call cyclic_init() at some point before
cyclic_register() becomes possible. That turns out to be somewhat
awkward, especially with SPL, and has resulted in a watchdog callback
not being registered, thus causing the board to prematurely reset.

We already rely on gd->cyclic reliably being set to NULL by the asm
code that clears all of gd. Now that the cyclic list is a hlist, and
thus an empty list is represented by a NULL head pointer, and struct
cyclic_drv has no other members, we can just as well drop a level of
indirection and put the hlist_head directly in struct
global_data. This doesn't increase the size of struct global_data,
gets rid of an early malloc(), and generates slightly smaller code.

But primarily, this avoids having to call cyclic_init() early; the cyclic
infrastructure is simply ready to register callbacks as soon as we
enter C code.

We can still end up with schedule() being called from asm very early,
so we still need to check that gd itself has been properly initialized
[*], but once it has, gd->cyclic_list is perfectly fine to access, and
will just be an empty list.

As for cyclic_uninit(), it was never really the opposite of
cyclic_init() since it didn't free the struct cyclic_drv nor set
gd->cyclic to NULL. Rename it to cyclic_unregister_all() and use that
in test/, and also insert a call at the end of the board_init_f
sequence so that gd->cyclic_list is a fresh empty list before we enter
board_init_r().

A small piece of ugliness is that I had to add a cast in
cyclic_get_list() to silence a "discards 'volatile' qualifier"
warning, but that is completely equivalent to the existing handling of
the uclass_root_s list_head member.

[*] I'm not really sure where we guarantee that the register used for
gd contains 0 until it gets explicitly initialized, but that must be
the case, otherwise testing gd for being NULL would not make much sense.

Signed-off-by: Rasmus Villemoes 
---
 common/board_f.c  |  2 +-
 common/board_r.c  |  1 -
 common/cyclic.c   | 32 +++
 include/asm-generic/global_data.h |  4 ++--
 include/cyclic.h  | 27 +++---
 test/test-main.c  |  3 +--
 6 files changed, 14 insertions(+), 55 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index 4355d1c82d..1f9140a065 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -844,7 +844,6 @@ static const init_fnc_t init_sequence_f[] = {
initf_malloc,
log_init,
initf_bootstage,/* uses its own timer, so does not need DM */
-   cyclic_init,
event_init,
 #ifdef CONFIG_BLOBLIST
bloblist_init,
@@ -962,6 +961,7 @@ static const init_fnc_t init_sequence_f[] = {
do_elf_reloc_fixups,
 #endif
clear_bss,
+   cyclic_unregister_all,
 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
!CONFIG_IS_ENABLED(X86_64)
jump_to_copy,
diff --git a/common/board_r.c b/common/board_r.c
index 92ca2066ee..0e2e63a21b 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -614,7 +614,6 @@ static init_fnc_t init_sequence_r[] = {
 #endif
initr_barrier,
initr_malloc,
-   cyclic_init,
log_init,
initr_bootstage,/* Needs malloc() but has its own timer */
 #if defined(CONFIG_CONSOLE_RECORD)
diff --git a/common/cyclic.c b/common/cyclic.c
index 32d9bf0d02..a49bfc88f5 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -22,7 +22,8 @@ void hw_watchdog_reset(void);
 
 struct hlist_head *cyclic_get_list(void)
 {
-   return &gd->cyclic->cyclic_list;
+   /* Silence "discards 'volatile' qualifier" warning. */
+   return (struct hlist_head *)&gd->cyclic_list;
 }
 
 struct cyclic_info *cyclic_register(cyclic_func_t func, uint64_t delay_us,
@@ -30,11 +31,6 @@ struct cyclic_info *cyclic_register(cyclic_func_t func, 
uint64_t delay_us,
 {
struct cyclic_info *cyclic;
 
-   if (!gd->cyclic) {
-   pr_debug("Cyclic IF not ready yet\n");
-   return NULL;
-   }
-
cyclic = calloc(1, sizeof(struct cyclic_info));
if (!cyclic) {
pr_debug("Memory allocation error\n");
@@ -47,7 +43,7 @@ struct cyclic_info *cyclic_register(cyclic_func_t func, 
uint64_t delay_us,
cyclic->name = strdup(name);
cyclic->delay_us = delay_us;
cyclic->start_time_us = timer_get_us();
-   hlist_add_head(&cyclic->list, &gd->cyclic->cyclic_list);
+   hlist_add_head(&cyclic->list, cyclic_get_list());
 
return cyclic;
 }
@@ -71,7 +67,7 @@ void cyclic_run(void)
return;
 
gd->flags |= GD_FLG_CYCLIC_RUNNING;
-   hlist_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list) {
+   hlist_for_each_entry_safe(cyclic, tmp, cyclic_get_list(), list) {
/*
 * Check if this cyclic function needs to get called, e.g.
 * do not cal

[PATCH 4/5] cyclic: switch to using hlist instead of list

2022-10-28 Thread Rasmus Villemoes
A hlist is headed by just a single pointer, so can only be traversed
forwards, and insertions can only happen at the head (or before/after
an existing list member). But each list node still consists of two
pointers, so arbitrary elements can still be removed in O(1).

This is precisely what we need for the cyclic_list - we never need to
traverse it backwards, and the order the callbacks appear in the list
should really not matter.

One advantage, and the main reason for doing this switch, is that an
empty list is represented by a NULL head pointer, so unlike a
list_head, it does not need separate C code to initialize - a
memset(,0,) of the containing structure is sufficient.

This is mostly mechanical:

- The iterators are updated with an h prefix, and the type of the
  temporary variable changed to struct hlist_node*.

- Adding/removing is now just hlist_add_head (and not tail) and
  hlist_del().

- struct members and function return values updated.

Signed-off-by: Rasmus Villemoes 
---
 cmd/cyclic.c |  5 +++--
 common/cyclic.c  | 18 ++
 include/cyclic.h |  6 +++---
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/cmd/cyclic.c b/cmd/cyclic.c
index c1bc556aad..97324d8240 100644
--- a/cmd/cyclic.c
+++ b/cmd/cyclic.c
@@ -61,10 +61,11 @@ static int do_cyclic_demo(struct cmd_tbl *cmdtp, int flag, 
int argc,
 static int do_cyclic_list(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[])
 {
-   struct cyclic_info *cyclic, *tmp;
+   struct cyclic_info *cyclic;
+   struct hlist_node *tmp;
u64 cnt, freq;
 
-   list_for_each_entry_safe(cyclic, tmp, cyclic_get_list(), list) {
+   hlist_for_each_entry_safe(cyclic, tmp, cyclic_get_list(), list) {
cnt = cyclic->run_cnt * 100ULL * 100ULL;
freq = lldiv(cnt, timer_get_us() - cyclic->start_time_us);
printf("function: %s, cpu-time: %lld us, frequency: %lld.%02d 
times/s\n",
diff --git a/common/cyclic.c b/common/cyclic.c
index d6f11b002e..32d9bf0d02 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -20,7 +20,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 void hw_watchdog_reset(void);
 
-struct list_head *cyclic_get_list(void)
+struct hlist_head *cyclic_get_list(void)
 {
return &gd->cyclic->cyclic_list;
 }
@@ -47,14 +47,14 @@ struct cyclic_info *cyclic_register(cyclic_func_t func, 
uint64_t delay_us,
cyclic->name = strdup(name);
cyclic->delay_us = delay_us;
cyclic->start_time_us = timer_get_us();
-   list_add_tail(&cyclic->list, &gd->cyclic->cyclic_list);
+   hlist_add_head(&cyclic->list, &gd->cyclic->cyclic_list);
 
return cyclic;
 }
 
 int cyclic_unregister(struct cyclic_info *cyclic)
 {
-   list_del(&cyclic->list);
+   hlist_del(&cyclic->list);
free(cyclic);
 
return 0;
@@ -62,7 +62,8 @@ int cyclic_unregister(struct cyclic_info *cyclic)
 
 void cyclic_run(void)
 {
-   struct cyclic_info *cyclic, *tmp;
+   struct cyclic_info *cyclic;
+   struct hlist_node *tmp;
uint64_t now, cpu_time;
 
/* Prevent recursion */
@@ -70,7 +71,7 @@ void cyclic_run(void)
return;
 
gd->flags |= GD_FLG_CYCLIC_RUNNING;
-   list_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list) {
+   hlist_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list) {
/*
 * Check if this cyclic function needs to get called, e.g.
 * do not call the cyclic func too often
@@ -118,9 +119,10 @@ void schedule(void)
 
 int cyclic_uninit(void)
 {
-   struct cyclic_info *cyclic, *tmp;
+   struct cyclic_info *cyclic;
+   struct hlist_node *tmp;
 
-   list_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list)
+   hlist_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list)
cyclic_unregister(cyclic);
 
return 0;
@@ -135,7 +137,7 @@ int cyclic_init(void)
return -ENOMEM;
 
memset(gd->cyclic, '\0', size);
-   INIT_LIST_HEAD(&gd->cyclic->cyclic_list);
+   INIT_HLIST_HEAD(&gd->cyclic->cyclic_list);
 
return 0;
 }
diff --git a/include/cyclic.h b/include/cyclic.h
index 263b74d89b..4a11f9b105 100644
--- a/include/cyclic.h
+++ b/include/cyclic.h
@@ -20,7 +20,7 @@
  * @cyclic_list: Cylic list node
  */
 struct cyclic_drv {
-   struct list_head cyclic_list;
+   struct hlist_head cyclic_list;
 };
 
 /**
@@ -46,7 +46,7 @@ struct cyclic_info {
uint64_t cpu_time_us;
uint64_t run_cnt;
uint64_t next_call;
-   struct list_head list;
+   struct hlist_node list;
bool already_warned;
 };
 
@@ -95,7 +95,7 @@ int cyclic_uninit(void);
  *
  * @return: pointer to cyclic_list
  */
-struct list_head *cyclic_get_list(void);
+struct hlist_head *cyclic_get_list(void);
 
 /**
  * cyclic_run() - Interate over all registered cyclic functions
-- 
2.37.2



[PATCH 2/5] cyclic: drop redundant cyclic_ready flag

2022-10-28 Thread Rasmus Villemoes
We're already relying on gd->cyclic being NULL before cyclic_init() is
called - i.e., we're relying on all of gd being zeroed before entering
any C code. And when we do populate gd->cyclic, its ->cyclic_ready
member is automatically set to true. So we can actually just rely on
testing gd->cyclic itself.

The only wrinkle is that cyclic_uninit() actually did set
->cyclic_ready to false. However, since it doesn't free gd->cyclic,
the cyclic infrastructure is actually still ready (i.e., the list_head
is properly initialized as an empty list).

Signed-off-by: Rasmus Villemoes 
---
 common/cyclic.c  | 6 ++
 include/cyclic.h | 2 --
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/common/cyclic.c b/common/cyclic.c
index ff75c8cadb..d6f11b002e 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -30,7 +30,7 @@ struct cyclic_info *cyclic_register(cyclic_func_t func, 
uint64_t delay_us,
 {
struct cyclic_info *cyclic;
 
-   if (!gd->cyclic->cyclic_ready) {
+   if (!gd->cyclic) {
pr_debug("Cyclic IF not ready yet\n");
return NULL;
}
@@ -112,7 +112,7 @@ void schedule(void)
 * schedule() might get called very early before the cyclic IF is
 * ready. Make sure to only call cyclic_run() when it's initalized.
 */
-   if (gd && gd->cyclic && gd->cyclic->cyclic_ready)
+   if (gd && gd->cyclic)
cyclic_run();
 }
 
@@ -122,7 +122,6 @@ int cyclic_uninit(void)
 
list_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list)
cyclic_unregister(cyclic);
-   gd->cyclic->cyclic_ready = false;
 
return 0;
 }
@@ -137,7 +136,6 @@ int cyclic_init(void)
 
memset(gd->cyclic, '\0', size);
INIT_LIST_HEAD(&gd->cyclic->cyclic_list);
-   gd->cyclic->cyclic_ready = true;
 
return 0;
 }
diff --git a/include/cyclic.h b/include/cyclic.h
index 50427baa3f..263b74d89b 100644
--- a/include/cyclic.h
+++ b/include/cyclic.h
@@ -18,11 +18,9 @@
  * struct cyclic_drv - Cyclic driver internal data
  *
  * @cyclic_list: Cylic list node
- * @cyclic_ready: Flag if cyclic infrastructure is ready
  */
 struct cyclic_drv {
struct list_head cyclic_list;
-   bool cyclic_ready;
 };
 
 /**
-- 
2.37.2



[PATCH 3/5] list.h: synchronize hlist_for_each_entry* iterators with linux

2022-10-28 Thread Rasmus Villemoes
All the way back in 2013, the linux kernel updated the four
hlist_for_each_entry* iterators to require one less auxiliary
variable:

  commit b67bfe0d42cac56c512dd5da4b1b347a23f4b70a
  Author: Sasha Levin 
  Date:   Wed Feb 27 17:06:00 2013 -0800

  hlist: drop the node parameter from iterators

Currently, there is only one "user" of any of these, namely in
fs/ubifs/super.c, but that actually uses the "new-style" form, and
is (obviously, or it wouldn't have built) inside #ifndef __UBOOT__.

Before adding actual users of these, import the version as of linux
v6.1-rc1, including the hlist_entry_safe() helper used by the new
versions.

Signed-off-by: Rasmus Villemoes 
---
 include/linux/list.h | 53 +---
 1 file changed, 25 insertions(+), 28 deletions(-)

diff --git a/include/linux/list.h b/include/linux/list.h
index 3eacf68e3a..6910721c00 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -646,54 +646,51 @@ static inline void hlist_add_after(struct hlist_node *n,
for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
 pos = n)
 
+#define hlist_entry_safe(ptr, type, member) \
+   ({ typeof(ptr) ptr = (ptr); \
+  ptr ? hlist_entry(ptr, type, member) : NULL; \
+   })
+
 /**
  * hlist_for_each_entry- iterate over list of given type
- * @tpos:  the type * to use as a loop cursor.
- * @pos:   the &struct hlist_node to use as a loop cursor.
+ * @pos:   the type * to use as a loop cursor.
  * @head:  the head for your list.
  * @member:the name of the hlist_node within the struct.
  */
-#define hlist_for_each_entry(tpos, pos, head, member)   \
-   for (pos = (head)->first;\
-pos && ({ prefetch(pos->next); 1;}) &&  \
-   ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
-pos = pos->next)
+#define hlist_for_each_entry(pos, head, member)
\
+   for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
+pos;   \
+pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
 
 /**
  * hlist_for_each_entry_continue - iterate over a hlist continuing after 
current point
- * @tpos:  the type * to use as a loop cursor.
- * @pos:   the &struct hlist_node to use as a loop cursor.
+ * @pos:   the type * to use as a loop cursor.
  * @member:the name of the hlist_node within the struct.
  */
-#define hlist_for_each_entry_continue(tpos, pos, member)\
-   for (pos = (pos)->next;  \
-pos && ({ prefetch(pos->next); 1;}) &&  \
-   ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
-pos = pos->next)
+#define hlist_for_each_entry_continue(pos, member) \
+   for (pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), 
member);\
+pos;   \
+pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
 
 /**
  * hlist_for_each_entry_from - iterate over a hlist continuing from current 
point
- * @tpos:  the type * to use as a loop cursor.
- * @pos:   the &struct hlist_node to use as a loop cursor.
+ * @pos:   the type * to use as a loop cursor.
  * @member:the name of the hlist_node within the struct.
  */
-#define hlist_for_each_entry_from(tpos, pos, member)\
-   for (; pos && ({ prefetch(pos->next); 1;}) &&\
-   ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
-pos = pos->next)
+#define hlist_for_each_entry_from(pos, member) \
+   for (; pos; \
+pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
 
 /**
  * hlist_for_each_entry_safe - iterate over list of given type safe against 
removal of list entry
- * @tpos:  the type * to use as a loop cursor.
- * @pos:   the &struct hlist_node to use as a loop cursor.
- * @n: another &struct hlist_node to use as temporary storage
+ * @pos:   the type * to use as a loop cursor.
+ * @n: a &struct hlist_node to use as temporary storage
  * @head:  the head for your list.
  * @member:the name of the hlist_node within the struct.
  */
-#define hlist_for_each_entry_safe(tpos, pos, n, head, member)   \
-   for (pos = (head)->first;\
-pos && ({ n = pos->next; 1; }) &&   \
-   ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
-pos = n)
+#define hlist_for_each_entry_safe(pos, n, head, member)\
+   for (pos = 

[PATCH 1/5] cyclic: use a flag in gd->flags for recursion protection

2022-10-28 Thread Rasmus Villemoes
As a preparation for future patches, use a flag in gd->flags rather
than a separate member in (the singleton) struct cyclic_drv to keep
track of whether we're already inside cyclic_run().

Signed-off-by: Rasmus Villemoes 
---
 common/cyclic.c   | 6 +++---
 include/asm-generic/global_data.h | 4 
 include/cyclic.h  | 2 --
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/common/cyclic.c b/common/cyclic.c
index 7abb82c16a..ff75c8cadb 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -66,10 +66,10 @@ void cyclic_run(void)
uint64_t now, cpu_time;
 
/* Prevent recursion */
-   if (gd->cyclic->cyclic_running)
+   if (gd->flags & GD_FLG_CYCLIC_RUNNING)
return;
 
-   gd->cyclic->cyclic_running = true;
+   gd->flags |= GD_FLG_CYCLIC_RUNNING;
list_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list) {
/*
 * Check if this cyclic function needs to get called, e.g.
@@ -99,7 +99,7 @@ void cyclic_run(void)
}
}
}
-   gd->cyclic->cyclic_running = false;
+   gd->flags &= ~GD_FLG_CYCLIC_RUNNING;
 }
 
 void schedule(void)
diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index 2d55fe2ac0..ca36907b20 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -650,6 +650,10 @@ enum gd_flags {
 * @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests
 */
GD_FLG_FDT_CHANGED = 0x10,
+   /**
+* GD_FLG_CYCLIC_RUNNING: cyclic_run is in progress
+*/
+   GD_FLG_CYCLIC_RUNNING = 0x20,
 };
 
 #endif /* __ASSEMBLY__ */
diff --git a/include/cyclic.h b/include/cyclic.h
index 9c5c4fcc54..50427baa3f 100644
--- a/include/cyclic.h
+++ b/include/cyclic.h
@@ -19,12 +19,10 @@
  *
  * @cyclic_list: Cylic list node
  * @cyclic_ready: Flag if cyclic infrastructure is ready
- * @cyclic_running: Flag if cyclic infrastructure is running
  */
 struct cyclic_drv {
struct list_head cyclic_list;
bool cyclic_ready;
-   bool cyclic_running;
 };
 
 /**
-- 
2.37.2



[PATCH 0/5] cyclic: get rid of (the need for) cyclic_init()

2022-10-28 Thread Rasmus Villemoes
I have only compile-tested each of these for sandbox_defconfig and
imx8mq_cm_defconfig. I couldn't even figure out how to run the cyclic
test inside sandbox by itself, and I don't have any hardware here at
home. So perhaps just consider these a POC of the overall idea, namely
to use a list abstraction which doesn't need initialization other than
what we already guarantee to do for all of struct global_data.

As positive side effects, the generated code will be a little smaller,
we reduce the use of the early malloc() pool, and the diffstat below
is also nice.

I don't know if we ever do anything in SPL that would require a call
to cyclic_unregister_all().

Rasmus Villemoes (5):
  cyclic: use a flag in gd->flags for recursion protection
  cyclic: drop redundant cyclic_ready flag
  list.h: synchronize hlist_for_each_entry* iterators with linux
  cyclic: switch to using hlist instead of list
  cyclic: get rid of cyclic_init()

 cmd/cyclic.c  |  5 +--
 common/board_f.c  |  2 +-
 common/board_r.c  |  1 -
 common/cyclic.c   | 50 ++---
 include/asm-generic/global_data.h |  8 +++--
 include/cyclic.h  | 35 +++-
 include/linux/list.h  | 53 +++
 test/test-main.c  |  3 +-
 8 files changed, 57 insertions(+), 100 deletions(-)

-- 
2.37.2


Re: Missing variable in *_defconfig of MT7628/MT7688

2022-10-28 Thread Tom Rini
On Fri, Oct 28, 2022 at 01:00:45PM +0200, Stefan Roese wrote:

> Hi Tom,
> 
> please find below a mail from Ruben, remarking that the Kconfig
> conversion of CONFIG_SPL_PAD_TO seems to have gone wrong. At least
> for MIPS MT7620/88. This was the commit from you:
> 
> ca8a329a1b7f ("Convert CONFIG_SPL_PAD_TO et al to Kconfig")
> 
> I just double checked this and Ruben is correct. Before the
> conversion SPL_PAD_TO was 0x0 and now its 0x1.
> 
> I can easily generate a patch changing these defconfig values for
> these MIPS boards. But there might be other boards that could be
> affected, so I wanted to put this issue to the list.

Please just fix the MIPS boards that you can see need fixing, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] rpi: copy the eMMC controller configuration from firmware-supplied DT

2022-10-28 Thread Jian-Hong Pan
Ilya K  於 2022年10月27日 週四 晚上7:48寫道:
>
> FWIW, my vote is for the revised series. Also, we've been shipping both 
> patches downstream in NixOS for a while now, and had no issues with either.
>
> 27.10.2022, 09:27, "Peter Robinson" :
>
> Adding Matthias as the RPi maintainer.
>
> There was also this patch series which fixed it and a few other things
> from the firmware DT [1] which is likely a better fix TBH.
>
> Either way Matthias can we get one of these upstream as even the RPi4
> Model B has moved to the newer rev of the SoCs so it's not a nice
> experience for users if they're not aware of the differences/problems.
>
> Peter
>
> [1] https://lists.denx.de/pipermail/u-boot/2022-August/491455.html

Great! This patch series looks nice, too.

Jian-Hong Pan

> On Wed, Oct 26, 2022 at 12:23 PM Jian-Hong Pan  wrote:
>
>
>  From: Ilya Katsnelson 
>
>  The RPi firmware adjusts the onboard eMMC controller's DMA mapping
>  ranges of the FDT for each BCM2711 SoC revisions on the Pi 4 and RPi 400
>  automatically.
>
>  If the following kernel does not boot with the correct eMMC controller's
>  DMA mapping ranges, the system on the SD card will boot failed and show
>  these error messages:
>
>  mmc1: invalid bus width
>  mmc1: error -22 whilst initialising SD card
>
>  This patch carries the adjustment from RPi firmware to the new loaded
>  FDT for the following kernel.
>
>  Link: https://lists.denx.de/pipermail/u-boot/2021-September/462006.html
>  Fixed: https://bugzilla.kernel.org/show_bug.cgi?id=213753
>  Signed-off-by: Ilya Katsnelson 
>  Signed-off-by: Jian-Hong Pan 
>  ---
>  The code of this patch comes from "[RFC PATCH] rpi: copy the EMMC
>  controller configuration from firmware-supplied DT" [1] basically.
>  I only add the message and some modifcation:
>
>  * Fix the build failed error:
>  board/raspberrypi/rpi/rpi.c: In function 'copy_emmc_config':
>  board/raspberrypi/rpi/rpi.c:553:9: warning: dereferencing 'void *' pointer
>553 | *fw_value = fdt_getprop(fw_fdt, fw_emmc_node, "dma-ranges", &length);
>| ^
>  board/raspberrypi/rpi/rpi.c:553:19: error: invalid use of void expression
>553 | *fw_value = fdt_getprop(fw_fdt, fw_emmc_node, "dma-ranges", &length);
>| ^
>  make[1]: *** [scripts/Makefile.build:258: board/raspberrypi/rpi/rpi.o] Error 
> 1
>
>  * Replace "EMMC" to "eMMC".
>
>  * Replace the printf with log_[levels].
>
>  So, I keep "Ilya Katsnelson " as the author.
>
>  [1]: https://lists.denx.de/pipermail/u-boot/2021-September/462006.html
>
>   board/raspberrypi/rpi/rpi.c | 63 +
>   1 file changed, 63 insertions(+)
>
>  diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
>  index 00afb352bd..d7ff8e269e 100644
>  --- a/board/raspberrypi/rpi/rpi.c
>  +++ b/board/raspberrypi/rpi/rpi.c
>  @@ -504,6 +504,67 @@ void *board_fdt_blob_setup(int *err)
>  return (void *)fw_dtb_pointer;
>   }
>
>  +void copy_emmc_config(void *our_fdt)
>  +{
>  + /*
>  + * As of 2021-09-28, the Pi 4 has two different revisions, one using a
>  + * B0 stepping of the BCM2711 SoC, and one using a C0 stepping.
>  + *
>  + * The two SoC versions have different, incompatible DMA mappings for
>  + * the on-board eMMC controller, which would normally make them require
>  + * two different DTs.
>  + *
>  + * Unfortunately for us, the different revisions don't actually _use_
>  + * different DTs - instead, the proprietary stage0 bootloader reads the DT,
>  + * patches it in-memory, then passes the corrected DT to the OS.
>  + *
>  + * In our case, the OS is actually U-Boot, and U-Boot can choose to
>  + * completely disregard the firmware-supplied DT and load a custom one
>  + * instead, which is used by, e.g., NixOS.
>  + *
>  + * When that happens, the DT patches applied by the firmware are also
>  + * thrown out, which leads to BCM2711C0 boards being unable to boot
>  + * due to them trying to use the hardcoded DMA mappings in the DT
>  + * (which are for the B0 revision).
>  + *
>  + * Work around that by manually copying the DMA region setup from the
>  + * firmware-provided DT into whatever DT we're actually being asked
>  + * to load.
>  + */
>  + void *fw_fdt = (void *)fw_dtb_pointer;
>  + int fw_emmc_node;
>  + int our_emmc_node;
>  + int length;
>  + const void *fw_value;
>  + int result;
>  +
>  + fw_emmc_node = fdt_path_offset(fw_fdt, "emmc2bus");
>  + if (fw_emmc_node < 0) {
>  + log_info("RPi: Failed to find eMMC config in FW DT: %d\n", fw_emmc_node);
>  + return;
>  + }
>  +
>  + our_emmc_node = fdt_path_offset(our_fdt, "emmc2bus");
>  + if (our_emmc_node < 0) {
>  + log_info("RPi: Failed to find eMMC config in our DT: %d\n", our_emmc_node);
>  + return;
>  + }
>  +
>  + fw_value = fdt_getprop(fw_fdt, fw_emmc_node, "dma-ranges", &length);
>  + if (!fw_value) {
>  + log_info("RPi: Failed to get eMMC DMA ranges property from FW DT: %d\n", 
> length);
>  + return;
>  + }
>  +
>  + result = fdt_setprop(our_fdt, our_emmc_node, "dma-range

Re: Missing variable in *_defconfig of MT7628/MT7688

2022-10-28 Thread Stefan Roese

Hi Tom,

please find below a mail from Ruben, remarking that the Kconfig
conversion of CONFIG_SPL_PAD_TO seems to have gone wrong. At least
for MIPS MT7620/88. This was the commit from you:

ca8a329a1b7f ("Convert CONFIG_SPL_PAD_TO et al to Kconfig")

I just double checked this and Ruben is correct. Before the
conversion SPL_PAD_TO was 0x0 and now its 0x1.

I can easily generate a patch changing these defconfig values for
these MIPS boards. But there might be other boards that could be
affected, so I wanted to put this issue to the list.

Thanks,
Stefan

On 27.10.22 14:39, Ruben Winters wrote:

Hi guys,

The CONFIG_SPL_PAD_TO=0 is missing from the defconf.

After removing it from the .h file it was not placed in the _defconf file.

If not placed it will default to 0x1 e.g. equals to 
CONFIG_SPL_MAX_SIZE, and you will get an error spl: failed to boot from 
all boot devices.


Met vriendelijke groet,

Mit freundlichen Grüßen,

Best regards,

*Ruben Winters*

*Research & Development Engineer*


Re: Binman entry 'u-boot-any' not found in list

2022-10-28 Thread Fabio Estevam
[Adding Alper - binmam maintainer and Oliver, who faced the same issue on imx8]

On Fri, Oct 28, 2022 at 7:56 AM Neha Malcom Francis  wrote:
>
> Hi!
>
> U-Boot build for J721E with binman enabled on the latest tip of the
> master branch throws an error when I try to use u-boot-spl-nodtb entry
> in my dtsi.
>
> What I'm trying to do is, to show I've made a small example
> (https://github.com/nehamalcom/u-boot/commit/f53dc83944f7774008afbb24fff42904862e9efe)
> that is:
>
> &binman {
> foo {
> filename = "foo.bin";
> u-boot-spl-nodtb {
> };
> };
> };
>
> which throws the error
> (https://gist.github.com/nehamalcom/4d855db7e4d5bd03aa29099b0e915e53):
>
> binman: Section '/binman/foo': Symbol '_binman_u_boot_any_prop_image_pos'
> in entry '/binman/foo/u-boot-spl-nodtb': Entry 'u-boot-any' not
> found in list (u-boot-spl-nodtb,main-section)
>
>
> This can be traced to the WriteSymbols() in etype/u_boot_spl_nodtb.py.
> On commenting out this function since it's not necessary in our
> use-case, the build was successful
> (https://github.com/nehamalcom/u-boot/commit/5666721860e1d2f759440a00c4aee8b6e89b54b3)
>
> Why is binman not picking up on the "any" and choosing u-boot-spl-nodtb
> from the list?
>
> --
> Thanking You
> Neha Malcom Francis


Binman entry 'u-boot-any' not found in list

2022-10-28 Thread Neha Malcom Francis

Hi!

U-Boot build for J721E with binman enabled on the latest tip of the 
master branch throws an error when I try to use u-boot-spl-nodtb entry 
in my dtsi.


What I'm trying to do is, to show I've made a small example 
(https://github.com/nehamalcom/u-boot/commit/f53dc83944f7774008afbb24fff42904862e9efe) 
that is:


&binman {
foo {
filename = "foo.bin";
u-boot-spl-nodtb {
};
};
};

which throws the error 
(https://gist.github.com/nehamalcom/4d855db7e4d5bd03aa29099b0e915e53):


binman: Section '/binman/foo': Symbol '_binman_u_boot_any_prop_image_pos'
   in entry '/binman/foo/u-boot-spl-nodtb': Entry 'u-boot-any' not 
found in list (u-boot-spl-nodtb,main-section)



This can be traced to the WriteSymbols() in etype/u_boot_spl_nodtb.py. 
On commenting out this function since it's not necessary in our 
use-case, the build was successful 
(https://github.com/nehamalcom/u-boot/commit/5666721860e1d2f759440a00c4aee8b6e89b54b3)


Why is binman not picking up on the "any" and choosing u-boot-spl-nodtb 
from the list?


--
Thanking You
Neha Malcom Francis


Re: [PATCH 2/3] cmd: pxe: support INITRD and FDT selection with FIT

2022-10-28 Thread Neil Armstrong

Hi Patrick,

On 28/10/2022 11:01, Patrick Delaunay wrote:

Since the commit d5ba6188dfbf ("cmd: pxe_utils: Check fdtcontroladdr
in label_boot") the FDT or the FDTDIR label is required in extlinux.conf
and the fallback done by bootm command when only the device tree present
in this command parameters is no more performed when FIT is used for
kernel.

When the label FDT or FDTDIR are absent or if the device tree file is
absent, the PXE command in U-Boot uses the default U-Boot device tree
selected by fdtcontroladdr = gd->fdt_blob, it is the "Scenario 3".

With this scenario the bootm FIP fallback is no more possible with
the extlinux.conf when only "kernel" label is present and is a FIP:

   kernel #[##[##[##[#


Thanks for providing this solution, indeed it solves the original
issue and permits specifying different DT and INITRD configs which
is neat.

I haven't tested it yet, but so far:

Reviewed-by: Neil Armstrong 



Signed-off-by: Patrick Delaunay 
---

  boot/pxe_utils.c| 17 ++---
  doc/README.pxe  |  8 
  include/pxe_utils.h |  2 ++
  3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 844ab72252bf..756b201eda91 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -259,6 +259,7 @@ static struct pxe_label *label_create(void)
  static void label_destroy(struct pxe_label *label)
  {
free(label->name);
+   free(label->kernel_label);
free(label->kernel);
free(label->config);
free(label->append);
@@ -543,9 +544,11 @@ static int label_boot(struct pxe_context *ctx, struct 
pxe_label *label)
kernel_addr = fit_addr;
}
  
-	if (label->initrd) {

+   /* For FIT, the label can be identical to kernel one */
+   if (label->initrd && !strcmp(label->kernel_label, label->initrd)) {
+   initrd_addr_str =  kernel_addr;
+   } else if (label->initrd) {
ulong size;
-
if (get_relfile_envaddr(ctx, label->initrd, "ramdisk_addr_r",
&size) < 0) {
printf("Skipping %s for failure retrieving initrd\n",
@@ -623,8 +626,11 @@ static int label_boot(struct pxe_context *ctx, struct 
pxe_label *label)
 */
bootm_argv[3] = env_get("fdt_addr_r");
  
+	/* For FIT, the label can be identical to kernel one */

+   if (label->fdt && !strcmp(label->kernel_label, label->fdt)) {
+   bootm_argv[3] = kernel_addr;
/* if fdt label is defined then get fdt from server */
-   if (bootm_argv[3]) {
+   } else if (bootm_argv[3]) {
char *fdtfile = NULL;
char *fdtfilefree = NULL;
  
@@ -1165,6 +1171,11 @@ static int parse_label_kernel(char **c, struct pxe_label *label)

if (err < 0)
return err;
  
+	/* copy the kernel label to compare with FDT / INITRD when FIT is used */

+   label->kernel_label = strdup(label->kernel);
+   if (!label->kernel_label)
+   return -ENOMEM;
+
s = strstr(label->kernel, "#");
if (!s)
return 1;
diff --git a/doc/README.pxe b/doc/README.pxe
index d14d2bdcc9b0..172201093d02 100644
--- a/doc/README.pxe
+++ b/doc/README.pxe
@@ -179,11 +179,19 @@ initrd- if this label is chosen, use 
tftp to retrieve the initrd
  at . it will be stored at the address indicated in
  the initrd_addr_r environment variable, and that address
  will be passed to bootm.
+ For FIT image, the initrd can be provided with the same 
value than
+ kernel, including configuration:
+   #[#  
  fdt 	- if this label is chosen, use tftp to retrieve the fdt blob

  at . it will be stored at the address indicated in
  the fdt_addr_r environment variable, and that address will
  be passed to bootm.
+ For FIT image, the device tree can be provided with the 
same value
+ than kernel, including configuration:
+   #[#  
  devicetree- if this label is chosen, use tftp to retrieve the fdt blob

  at . it will be stored at the address indicated in
diff --git a/include/pxe_utils.h b/include/pxe_utils.h
index 4a73b2aace34..1e5e8424f53f 100644
--- a/include/pxe_utils.h
+++ b/include/pxe_utils.h
@@ -28,6 +28,7 @@
   * Create these with the 'label_create' function given below.
   *
   * name - the name of the menu as given on the 'menu label' line.
+ * kernel_label - the kernel label, including FIT config if present.
   * kernel - the path to the kernel file to use for this label.
   * append - kernel command line to use when booting this label
   * initrd - path to the initrd to use for this label.
@@ -40,6 +41,7 @@ struct pxe_label {
char num[4];
char *name;
char *menu;
+  

Re: [PATCH 1/3] cmd: pxe: reorder kernel treatment in label_boot

2022-10-28 Thread Neil Armstrong

On 28/10/2022 11:01, Patrick Delaunay wrote:

Reorder kernel treatment in label_boot at the beginning of the function.

This patch doesn't change the pxe command behavior, it is only a
preliminary step for next patch, build kernel_addr before parsing
the label initrd and fdt to build the next bootm arguments.

Signed-off-by: Patrick Delaunay 
---

  boot/pxe_utils.c | 49 
  1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index d5c215ae2c1d..844ab72252bf 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -522,6 +522,27 @@ static int label_boot(struct pxe_context *ctx, struct 
pxe_label *label)
return 1;
}
  
+	if (get_relfile_envaddr(ctx, label->kernel, "kernel_addr_r",

+   NULL) < 0) {
+   printf("Skipping %s for failure retrieving kernel\n",
+  label->name);
+   return 1;
+   }
+
+   kernel_addr = env_get("kernel_addr_r");
+   /* for FIT, append the configuration identifier */
+   if (label->config) {
+   int len = strlen(kernel_addr) + strlen(label->config) + 1;
+
+   fit_addr = malloc(len);
+   if (!fit_addr) {
+   printf("malloc fail (FIT address)\n");
+   return 1;
+   }
+   snprintf(fit_addr, len, "%s%s", kernel_addr, label->config);
+   kernel_addr = fit_addr;
+   }
+
if (label->initrd) {
ulong size;
  
@@ -529,21 +550,14 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label)

&size) < 0) {
printf("Skipping %s for failure retrieving initrd\n",
   label->name);
-   return 1;
+   goto cleanup;
}
  
  		initrd_addr_str = env_get("ramdisk_addr_r");

size = snprintf(initrd_str, sizeof(initrd_str), "%s:%lx",
initrd_addr_str, size);
if (size >= sizeof(initrd_str))
-   return 1;
-   }
-
-   if (get_relfile_envaddr(ctx, label->kernel, "kernel_addr_r",
-   NULL) < 0) {
-   printf("Skipping %s for failure retrieving kernel\n",
-  label->name);
-   return 1;
+   goto cleanup;
}
  
  	if (label->ipappend & 0x1) {

@@ -573,7 +587,7 @@ static int label_boot(struct pxe_context *ctx, struct 
pxe_label *label)
   strlen(label->append ?: ""),
   strlen(ip_str), strlen(mac_str),
   sizeof(bootargs));
-   return 1;
+   goto cleanup;
}
  
  		if (label->append)

@@ -588,21 +602,6 @@ static int label_boot(struct pxe_context *ctx, struct 
pxe_label *label)
printf("append: %s\n", finalbootargs);
}
  
-	kernel_addr = env_get("kernel_addr_r");

-
-   /* for FIT, append the configuration identifier */
-   if (label->config) {
-   int len = strlen(kernel_addr) + strlen(label->config) + 1;
-
-   fit_addr = malloc(len);
-   if (!fit_addr) {
-   printf("malloc fail (FIT address)\n");
-   return 1;
-   }
-   snprintf(fit_addr, len, "%s%s", kernel_addr, label->config);
-   kernel_addr = fit_addr;
-   }
-
/*
 * fdt usage is optional:
 * It handles the following scenarios.



Reviewed-by: Neil Armstrong 


Re: [PATCH 3/3] cmd: pxe: use strdup to copy config

2022-10-28 Thread Neil Armstrong

On 28/10/2022 11:01, Patrick Delaunay wrote:

Replace malloc and strcpy by strdup in
function parse_label_kernel.

Signed-off-by: Patrick Delaunay 
---

  boot/pxe_utils.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 756b201eda91..84e63c5cb85f 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -1180,11 +1180,10 @@ static int parse_label_kernel(char **c, struct 
pxe_label *label)
if (!s)
return 1;
  
-	label->config = malloc(strlen(s) + 1);

+   label->config = strdup(s);
if (!label->config)
return -ENOMEM;
  
-	strcpy(label->config, s);

*s = 0;
  
  	return 1;



Reviewed-by: Neil Armstrong 



[PATCH 3/3] cmd: pxe: use strdup to copy config

2022-10-28 Thread Patrick Delaunay
Replace malloc and strcpy by strdup in
function parse_label_kernel.

Signed-off-by: Patrick Delaunay 
---

 boot/pxe_utils.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 756b201eda91..84e63c5cb85f 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -1180,11 +1180,10 @@ static int parse_label_kernel(char **c, struct 
pxe_label *label)
if (!s)
return 1;
 
-   label->config = malloc(strlen(s) + 1);
+   label->config = strdup(s);
if (!label->config)
return -ENOMEM;
 
-   strcpy(label->config, s);
*s = 0;
 
return 1;
-- 
2.25.1



[PATCH 2/3] cmd: pxe: support INITRD and FDT selection with FIT

2022-10-28 Thread Patrick Delaunay
Since the commit d5ba6188dfbf ("cmd: pxe_utils: Check fdtcontroladdr
in label_boot") the FDT or the FDTDIR label is required in extlinux.conf
and the fallback done by bootm command when only the device tree present
in this command parameters is no more performed when FIT is used for
kernel.

When the label FDT or FDTDIR are absent or if the device tree file is
absent, the PXE command in U-Boot uses the default U-Boot device tree
selected by fdtcontroladdr = gd->fdt_blob, it is the "Scenario 3".

With this scenario the bootm FIP fallback is no more possible with
the extlinux.conf when only "kernel" label is present and is a FIP:

  kernel #[##[##[##[#
---

 boot/pxe_utils.c| 17 ++---
 doc/README.pxe  |  8 
 include/pxe_utils.h |  2 ++
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 844ab72252bf..756b201eda91 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -259,6 +259,7 @@ static struct pxe_label *label_create(void)
 static void label_destroy(struct pxe_label *label)
 {
free(label->name);
+   free(label->kernel_label);
free(label->kernel);
free(label->config);
free(label->append);
@@ -543,9 +544,11 @@ static int label_boot(struct pxe_context *ctx, struct 
pxe_label *label)
kernel_addr = fit_addr;
}
 
-   if (label->initrd) {
+   /* For FIT, the label can be identical to kernel one */
+   if (label->initrd && !strcmp(label->kernel_label, label->initrd)) {
+   initrd_addr_str =  kernel_addr;
+   } else if (label->initrd) {
ulong size;
-
if (get_relfile_envaddr(ctx, label->initrd, "ramdisk_addr_r",
&size) < 0) {
printf("Skipping %s for failure retrieving initrd\n",
@@ -623,8 +626,11 @@ static int label_boot(struct pxe_context *ctx, struct 
pxe_label *label)
 */
bootm_argv[3] = env_get("fdt_addr_r");
 
+   /* For FIT, the label can be identical to kernel one */
+   if (label->fdt && !strcmp(label->kernel_label, label->fdt)) {
+   bootm_argv[3] = kernel_addr;
/* if fdt label is defined then get fdt from server */
-   if (bootm_argv[3]) {
+   } else if (bootm_argv[3]) {
char *fdtfile = NULL;
char *fdtfilefree = NULL;
 
@@ -1165,6 +1171,11 @@ static int parse_label_kernel(char **c, struct pxe_label 
*label)
if (err < 0)
return err;
 
+   /* copy the kernel label to compare with FDT / INITRD when FIT is used 
*/
+   label->kernel_label = strdup(label->kernel);
+   if (!label->kernel_label)
+   return -ENOMEM;
+
s = strstr(label->kernel, "#");
if (!s)
return 1;
diff --git a/doc/README.pxe b/doc/README.pxe
index d14d2bdcc9b0..172201093d02 100644
--- a/doc/README.pxe
+++ b/doc/README.pxe
@@ -179,11 +179,19 @@ initrd  - if this label is chosen, use tftp 
to retrieve the initrd
  at . it will be stored at the address indicated in
  the initrd_addr_r environment variable, and that address
  will be passed to bootm.
+ For FIT image, the initrd can be provided with the same 
value than
+ kernel, including configuration:
+   #[# - if this label is chosen, use tftp to retrieve the fdt blob
  at . it will be stored at the address indicated in
  the fdt_addr_r environment variable, and that address will
  be passed to bootm.
+ For FIT image, the device tree can be provided with the 
same value
+ than kernel, including configuration:
+   #[#   - if this label is chosen, use tftp to retrieve the fdt 
blob
  at . it will be stored at the address indicated in
diff --git a/include/pxe_utils.h b/include/pxe_utils.h
index 4a73b2aace34..1e5e8424f53f 100644
--- a/include/pxe_utils.h
+++ b/include/pxe_utils.h
@@ -28,6 +28,7 @@
  * Create these with the 'label_create' function given below.
  *
  * name - the name of the menu as given on the 'menu label' line.
+ * kernel_label - the kernel label, including FIT config if present.
  * kernel - the path to the kernel file to use for this label.
  * append - kernel command line to use when booting this label
  * initrd - path to the initrd to use for this label.
@@ -40,6 +41,7 @@ struct pxe_label {
char num[4];
char *name;
char *menu;
+   char *kernel_label;
char *kernel;
char *config;
char *append;
-- 
2.25.1



[PATCH 1/3] cmd: pxe: reorder kernel treatment in label_boot

2022-10-28 Thread Patrick Delaunay
Reorder kernel treatment in label_boot at the beginning of the function.

This patch doesn't change the pxe command behavior, it is only a
preliminary step for next patch, build kernel_addr before parsing
the label initrd and fdt to build the next bootm arguments.

Signed-off-by: Patrick Delaunay 
---

 boot/pxe_utils.c | 49 
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index d5c215ae2c1d..844ab72252bf 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -522,6 +522,27 @@ static int label_boot(struct pxe_context *ctx, struct 
pxe_label *label)
return 1;
}
 
+   if (get_relfile_envaddr(ctx, label->kernel, "kernel_addr_r",
+   NULL) < 0) {
+   printf("Skipping %s for failure retrieving kernel\n",
+  label->name);
+   return 1;
+   }
+
+   kernel_addr = env_get("kernel_addr_r");
+   /* for FIT, append the configuration identifier */
+   if (label->config) {
+   int len = strlen(kernel_addr) + strlen(label->config) + 1;
+
+   fit_addr = malloc(len);
+   if (!fit_addr) {
+   printf("malloc fail (FIT address)\n");
+   return 1;
+   }
+   snprintf(fit_addr, len, "%s%s", kernel_addr, label->config);
+   kernel_addr = fit_addr;
+   }
+
if (label->initrd) {
ulong size;
 
@@ -529,21 +550,14 @@ static int label_boot(struct pxe_context *ctx, struct 
pxe_label *label)
&size) < 0) {
printf("Skipping %s for failure retrieving initrd\n",
   label->name);
-   return 1;
+   goto cleanup;
}
 
initrd_addr_str = env_get("ramdisk_addr_r");
size = snprintf(initrd_str, sizeof(initrd_str), "%s:%lx",
initrd_addr_str, size);
if (size >= sizeof(initrd_str))
-   return 1;
-   }
-
-   if (get_relfile_envaddr(ctx, label->kernel, "kernel_addr_r",
-   NULL) < 0) {
-   printf("Skipping %s for failure retrieving kernel\n",
-  label->name);
-   return 1;
+   goto cleanup;
}
 
if (label->ipappend & 0x1) {
@@ -573,7 +587,7 @@ static int label_boot(struct pxe_context *ctx, struct 
pxe_label *label)
   strlen(label->append ?: ""),
   strlen(ip_str), strlen(mac_str),
   sizeof(bootargs));
-   return 1;
+   goto cleanup;
}
 
if (label->append)
@@ -588,21 +602,6 @@ static int label_boot(struct pxe_context *ctx, struct 
pxe_label *label)
printf("append: %s\n", finalbootargs);
}
 
-   kernel_addr = env_get("kernel_addr_r");
-
-   /* for FIT, append the configuration identifier */
-   if (label->config) {
-   int len = strlen(kernel_addr) + strlen(label->config) + 1;
-
-   fit_addr = malloc(len);
-   if (!fit_addr) {
-   printf("malloc fail (FIT address)\n");
-   return 1;
-   }
-   snprintf(fit_addr, len, "%s%s", kernel_addr, label->config);
-   kernel_addr = fit_addr;
-   }
-
/*
 * fdt usage is optional:
 * It handles the following scenarios.
-- 
2.25.1



[PATCH 0/3] cmd: pxe: support INITRD and FDT selection with FIT

2022-10-28 Thread Patrick Delaunay


Since the commit d5ba6188dfbf ("cmd: pxe_utils: Check fdtcontroladdr
in label_boot") the FDT or the FDTDIR label is required in extlinux.conf
and the fallback done by bootm command when only the device tree is present
in this command parameters is no more performed when FIT is used for
kernel.

The next file "extlinux.conf" no more selects the device tree in FIT
but use the pxe fallback with the device tree of U-Boot.

menu title Select the boot mode
DEFAULT test
LABEL test
KERNEL /fitImage

This serie restores the possibility to use a FIT in extlinux.conf
by using FDT label with the same string.

menu title Select the boot mode
DEFAULT test
LABEL test
KERNEL /fitImage
FDT /fitImage

even when a specific FIT config is used:

menu title Select the boot mode
DEFAULT test
LABEL test
KERNEL /fitImage#config
FDT /fitImage#config

The last commit of the series is only a minor improvement.



Patrick Delaunay (3):
  cmd: pxe: reorder kernel treatment in label_boot
  cmd: pxe: support INITRD and FDT selection with FIT
  cmd: pxe: use strdup to copy config

 boot/pxe_utils.c| 69 +
 doc/README.pxe  |  8 ++
 include/pxe_utils.h |  2 ++
 3 files changed, 49 insertions(+), 30 deletions(-)

-- 
2.25.1



Re: [PATCH v8 0/8] Add MV88E6xxx DSA driver and use on gwventana

2022-10-28 Thread Vladimir Oltean
On Thu, Oct 27, 2022 at 05:49:29PM -0700, Tim Harvey wrote:
> This series adds a DSA driver for the MV88E6xxx based on
> drivers/net/phy/mv88e61xx and uses it in the gwventana_gw5904_defconfig.

Looks good, thanks. To me this is ready to go!

Re: [PATCH] riscv: Rename Andes PLIC to PLICSW

2022-10-28 Thread Rick Chen
> From: Peter Yu-Chien Lin(林宇謙) 
> Sent: Tuesday, October 25, 2022 11:04 PM
> To: u-boot@lists.denx.de
> Cc: Leo Yu-Chi Liang(梁育齊) ; Rick Jian-Zhi Chen(陳建志) 
> ; Peter Yu-Chien Lin(林宇謙) 
> Subject: [PATCH] riscv: Rename Andes PLIC to PLICSW
>
> As PLICSW is used to trigger the software interrupt, we should rename Andes 
> PLIC configuration and file name to reflect the usage. This patch also 
> updates PLMT and PLICSW compatible strings to be consistent with OpenSBI fdt 
> driver.
>
> Signed-off-by: Yu Chien Peter Lin 
> ---
>  arch/riscv/Kconfig|  6 ++---
>  arch/riscv/cpu/ax25/Kconfig   |  2 +-
>  arch/riscv/dts/ae350-u-boot.dtsi  |  2 +-
>  arch/riscv/dts/ae350_32.dts   |  6 ++---
>  arch/riscv/dts/ae350_64.dts   |  6 ++---
>  arch/riscv/include/asm/global_data.h  |  4 +--
>  arch/riscv/include/asm/syscon.h   |  2 +-
>  arch/riscv/lib/Makefile   |  2 +-
>  .../lib/{andes_plic.c => andes_plicsw.c}  | 26 +--
>  9 files changed, 28 insertions(+), 28 deletions(-)  rename 
> arch/riscv/lib/{andes_plic.c => andes_plicsw.c} (76%)

Reviewed-by: Rick Chen 


Re: [PATCH V2 01/13] env: Complete generic support for writable list

2022-10-28 Thread Stefan Herbrechtsmeier

Hi Jan,

Am 27.10.2022 um 14:38 schrieb Jan Kiszka:

On 27.10.22 09:49, Stefan Herbrechtsmeier wrote:

Hi,

Am 05.10.2022 um 10:33 schrieb Jan Kiszka:

From: Jan Kiszka 

This completes what 890feecaab72 started by selecting ENV_APPEND and
ENV_IS_NOWHERE and by moving this driver to top if the list. This
ensures that load operations pick up both the default env and the
permitted parts of the next-prio location. When writing though, we must
use the regular ordering.

With this change, boards only need to define the list of writable
variables but no longer have to provide a custom env_get_location
implementation.

CC: Joe Hershberger 
CC: Marek Vasut 
Signed-off-by: Jan Kiszka 
---
   env/Kconfig |  2 ++
   env/env.c   | 22 ++
   2 files changed, 24 insertions(+)

diff --git a/env/Kconfig b/env/Kconfig
index 24111dfaf47..05b5fbf17d1 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -715,6 +715,8 @@ config ENV_APPEND
     config ENV_WRITEABLE_LIST
   bool "Permit write access only to listed variables"
+    select ENV_IS_NOWHERE
+    select ENV_APPEND
   help
     If defined, only environment variables which explicitly set
the 'w'
     writeable flag can be written and modified at runtime. No
variables
diff --git a/env/env.c b/env/env.c
index 69848fb0608..d0649f9540d 100644
--- a/env/env.c
+++ b/env/env.c
@@ -133,6 +133,28 @@ __weak enum env_location
arch_env_get_location(enum env_operation op, int prio)
   if (prio >= ARRAY_SIZE(env_locations))
   return ENVL_UNKNOWN;
   +    if (IS_ENABLED(CONFIG_ENV_WRITEABLE_LIST)) {
+    /*
+ * In writeable-list mode, ENVL_NOWHERE gains highest prio by
+ * virtually injecting it at prio 0.
+ */
+    if (prio == 0) {
+    /*
+ * Avoid the injection for write operations as that
+ * would block it.
+ */
+    if (op != ENVOP_SAVE && op != ENVOP_ERASE)
+    return ENVL_NOWHERE;

Is it consensus now to use ENVL_NOWHERE as synonym for default
environment? If I remember correct this was rejected in the past and
ENVL_NOWHERE  should only be used if no enviroment is available.

Why don't you call env_set_default(NULL, 0) in env_load() before
env_driver_lookup()?

Worth to explore... if that should avoid this logic here... Let me try.


Additionally we have remove the `#if !CONFIG_IS_ENABLED(ENV_APPEND) 
arround the `return 0` in env_load() and the following change in env_export


--- a/env/common.c
+++ b/env/common.c
@@ -234,7 +234,7 @@ int env_export(env_t *env_out)
 ssize_t    len;

 res = (char *)env_out->data;
-    len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
+    len = hexport_r(&env_htab, '\0', H_EXTERNAL, &res, ENV_SIZE, 0, NULL);
 if (len < 0) {
     pr_err("Cannot export environment: errno = %d\n", errno);
     return 1;

I can't remeber why the H_EXTERNAL in env_export was needed.

Regards

  Stefan




[PATCH v2] configs: mediatek: enable boot via extlinux

2022-10-28 Thread Julien STEPHAN
From: Alexandre Mergnat 

Enable FAT and SYSBOOT to use extlinux boot script

Signed-off-by: Jerome Brunet 
Signed-off-by: Alexandre Mergnat 
Signed-off-by: Julien STEPHAN 

---
V1 -> V2: adding missing CONFIG_ENV_OFFSET config
---
 configs/mt8183_pumpkin_defconfig | 3 +++
 configs/mt8516_pumpkin_defconfig | 7 +++
 2 files changed, 10 insertions(+)

diff --git a/configs/mt8183_pumpkin_defconfig b/configs/mt8183_pumpkin_defconfig
index 3c96d4eacb..9a7ad160d1 100644
--- a/configs/mt8183_pumpkin_defconfig
+++ b/configs/mt8183_pumpkin_defconfig
@@ -48,8 +48,11 @@ CONFIG_CMD_PART=y
 # CONFIG_CMD_ITEST is not set
 # CONFIG_CMD_SETEXPR is not set
 # CONFIG_CMD_BLOCK_CACHE is not set
+CONFIG_CMD_SYSBOOT=y
 CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
+# CONFIG_DOS_PARTITION is not set
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_MMC_ENV_PART=2
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
diff --git a/configs/mt8516_pumpkin_defconfig b/configs/mt8516_pumpkin_defconfig
index 0425ffd0f9..86b7b84970 100644
--- a/configs/mt8516_pumpkin_defconfig
+++ b/configs/mt8516_pumpkin_defconfig
@@ -6,6 +6,7 @@ CONFIG_SYS_TEXT_BASE=0x4C00
 CONFIG_SYS_MALLOC_F_LEN=0x4000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SIZE=0x1000
+CONFIG_ENV_OFFSET=0x0
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="mt8516-pumpkin"
 CONFIG_TARGET_MT8516=y
@@ -49,6 +50,12 @@ CONFIG_CMD_PART=y
 # CONFIG_CMD_SETEXPR is not set
 # CONFIG_CMD_BLOCK_CACHE is not set
 # CONFIG_CMD_SLEEP is not set
+CONFIG_CMD_SYSBOOT=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_DOS_PARTITION is not set
+CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_CLK=y
-- 
2.38.1



Re: [PATCH] ARM: stm32: Add boot counter to DHSOM

2022-10-28 Thread Patrice CHOTARD


On 10/27/22 23:17, Marek Vasut wrote:
> Add boot counter to STM32MP15xx DHSOM. This aligns the software with
> other upstream DHSOM products which already do enable boot counter.
> 
> The boot counter on STM32MP15xx is placed in the TAMP block TAMP_BKPxR
> register 19, right past register 17 and 18 used for CM4 resource table
> and state by the Linux kernel. The TAMP_BKPxR register block is used
> because its contents survives warm reset, but not cold reset.
> 
> Signed-off-by: Marek Vasut 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> ---
>  configs/stm32mp15_dhcom_basic_defconfig | 5 +
>  configs/stm32mp15_dhcor_basic_defconfig | 5 +
>  2 files changed, 10 insertions(+)
> 
> diff --git a/configs/stm32mp15_dhcom_basic_defconfig 
> b/configs/stm32mp15_dhcom_basic_defconfig
> index 3ba396b9671..c8093c4e152 100644
> --- a/configs/stm32mp15_dhcom_basic_defconfig
> +++ b/configs/stm32mp15_dhcom_basic_defconfig
> @@ -8,6 +8,8 @@ CONFIG_DEFAULT_DEVICE_TREE="stm32mp15xx-dhcom-pdk2"
>  CONFIG_SPL_TEXT_BASE=0x2FFC2500
>  CONFIG_SYS_PROMPT="STM32MP> "
>  CONFIG_SPL_MMC=y
> +CONFIG_BOOTCOUNT_BOOTLIMIT=3
> +CONFIG_SYS_BOOTCOUNT_ADDR=0x5C00A14C
>  CONFIG_SPL=y
>  CONFIG_TARGET_DH_STM32MP1_PDK2=y
>  CONFIG_SPL_SPI_FLASH_SUPPORT=y
> @@ -74,6 +76,7 @@ CONFIG_CMD_SPI=y
>  CONFIG_CMD_USB=y
>  CONFIG_CMD_USB_MASS_STORAGE=y
>  CONFIG_SYS_DISABLE_AUTOLOAD=y
> +CONFIG_CMD_BOOTCOUNT=y
>  CONFIG_CMD_CACHE=y
>  CONFIG_CMD_TIME=y
>  CONFIG_CMD_TIMER=y
> @@ -99,6 +102,8 @@ CONFIG_IP_DEFRAG=y
>  CONFIG_TFTP_TSIZE=y
>  CONFIG_STM32_ADC=y
>  CONFIG_SPL_BLOCK_CACHE=y
> +CONFIG_BOOTCOUNT_LIMIT=y
> +CONFIG_SYS_BOOTCOUNT_MAGIC=0xB0C4
>  CONFIG_DFU_MMC=y
>  CONFIG_DFU_MTD=y
>  CONFIG_DFU_RAM=y
> diff --git a/configs/stm32mp15_dhcor_basic_defconfig 
> b/configs/stm32mp15_dhcor_basic_defconfig
> index ddd96ac4d29..7b2b92e15e3 100644
> --- a/configs/stm32mp15_dhcor_basic_defconfig
> +++ b/configs/stm32mp15_dhcor_basic_defconfig
> @@ -8,6 +8,8 @@ CONFIG_DEFAULT_DEVICE_TREE="stm32mp15xx-dhcor-avenger96"
>  CONFIG_SPL_TEXT_BASE=0x2FFC2500
>  CONFIG_SYS_PROMPT="STM32MP> "
>  CONFIG_SPL_MMC=y
> +CONFIG_BOOTCOUNT_BOOTLIMIT=3
> +CONFIG_SYS_BOOTCOUNT_ADDR=0x5C00A14C
>  CONFIG_SPL=y
>  CONFIG_TARGET_DH_STM32MP1_PDK2=y
>  CONFIG_SPL_SPI_FLASH_SUPPORT=y
> @@ -72,6 +74,7 @@ CONFIG_CMD_SPI=y
>  CONFIG_CMD_USB=y
>  CONFIG_CMD_USB_MASS_STORAGE=y
>  CONFIG_SYS_DISABLE_AUTOLOAD=y
> +CONFIG_CMD_BOOTCOUNT=y
>  CONFIG_CMD_CACHE=y
>  CONFIG_CMD_TIME=y
>  CONFIG_CMD_TIMER=y
> @@ -96,6 +99,8 @@ CONFIG_IP_DEFRAG=y
>  CONFIG_TFTP_TSIZE=y
>  CONFIG_STM32_ADC=y
>  CONFIG_SPL_BLOCK_CACHE=y
> +CONFIG_BOOTCOUNT_LIMIT=y
> +CONFIG_SYS_BOOTCOUNT_MAGIC=0xB0C4
>  CONFIG_DFU_MMC=y
>  CONFIG_DFU_MTD=y
>  CONFIG_DFU_RAM=y


Reviewed-by: Patrice Chotard 

Thanks
Patrice