[PATCH 0/2] apalis/colibri imx6/imx6ull/imx7: Add fastboot supp

2023-11-09 Thread Hiago De Franco
This patch series introduces Fastboot support on all Apalis iMX6,
Colibri iMX6, Colibri iMX6ULL and Colibri iMX7 machines. It includes the
necessary configurations in their respective defconfig files and
implements logic in the boards files to determine whether SDP or Fastboot
will be utilized.

Hiago De Franco (2):
  apalis/colibri imx6/imx6ull/imx7: defconfig: Enable fastboot support
  board: apalis/colibri imx6/imx6ull/imx7: Add fastboot bootcmd support

 board/toradex/apalis_imx6/apalis_imx6.c | 13 -
 board/toradex/colibri-imx6ull/colibri-imx6ull.c | 13 -
 board/toradex/colibri_imx6/colibri_imx6.c   | 13 -
 board/toradex/colibri_imx7/colibri_imx7.c   | 14 +-
 configs/apalis_imx6_defconfig   |  3 +++
 configs/colibri-imx6ull-emmc_defconfig  |  3 +++
 configs/colibri-imx6ull_defconfig   |  3 +++
 configs/colibri_imx6_defconfig  |  3 +++
 configs/colibri_imx7_defconfig  |  3 +++
 configs/colibri_imx7_emmc_defconfig |  4 ++--
 10 files changed, 50 insertions(+), 22 deletions(-)

-- 
2.42.0



[PATCH 1/2] apalis/colibri imx6/imx6ull/imx7: defconfig: Enable fastboot support

2023-11-09 Thread Hiago De Franco
Add fastboot support for Apalis iMX6, Colibri iMX6, Colibri iMX6ULL and
Colibri iMX7 boards. Remove CONFIG_FASTBOOT_BUF_SIZE from
colibri_imx7_emmc_defconfig to get the default value of 0x700 instead
of 0x1000, to make it consistent with the other boards.

Signed-off-by: Hiago De Franco 
---
 configs/apalis_imx6_defconfig  | 3 +++
 configs/colibri-imx6ull-emmc_defconfig | 3 +++
 configs/colibri-imx6ull_defconfig  | 3 +++
 configs/colibri_imx6_defconfig | 3 +++
 configs/colibri_imx7_defconfig | 3 +++
 configs/colibri_imx7_emmc_defconfig| 4 ++--
 6 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig
index aa9cf77960..570ade5119 100644
--- a/configs/apalis_imx6_defconfig
+++ b/configs/apalis_imx6_defconfig
@@ -87,6 +87,9 @@ CONFIG_DWC_AHSATA=y
 CONFIG_LBA48=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_ENV=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x1442
+CONFIG_FASTBOOT_UUU_SUPPORT=y
 CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_MXC=y
diff --git a/configs/colibri-imx6ull-emmc_defconfig 
b/configs/colibri-imx6ull-emmc_defconfig
index 2fead59f5f..20cba723ee 100644
--- a/configs/colibri-imx6ull-emmc_defconfig
+++ b/configs/colibri-imx6ull-emmc_defconfig
@@ -64,6 +64,9 @@ CONFIG_SERVERIP="192.168.10.1"
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_ENV=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x8110
+CONFIG_FASTBOOT_UUU_SUPPORT=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_SUPPORT_EMMC_BOOT=y
diff --git a/configs/colibri-imx6ull_defconfig 
b/configs/colibri-imx6ull_defconfig
index 5164374c67..d904621f5e 100644
--- a/configs/colibri-imx6ull_defconfig
+++ b/configs/colibri-imx6ull_defconfig
@@ -75,6 +75,9 @@ CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_ENV=y
 CONFIG_DFU_NAND=y
 CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x8110
+CONFIG_FASTBOOT_UUU_SUPPORT=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_FSL_USDHC=y
diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index 51f3eeca75..cd68264eca 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -85,6 +85,9 @@ CONFIG_SERVERIP="192.168.10.1"
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_ENV=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x1442
+CONFIG_FASTBOOT_UUU_SUPPORT=y
 CONFIG_DM_I2C=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_MXC=y
diff --git a/configs/colibri_imx7_defconfig b/configs/colibri_imx7_defconfig
index eba2b41c84..e24a606bc4 100644
--- a/configs/colibri_imx7_defconfig
+++ b/configs/colibri_imx7_defconfig
@@ -72,6 +72,9 @@ CONFIG_BOUNCE_BUFFER=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_ENV=y
 CONFIG_DFU_NAND=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x8110
+CONFIG_FASTBOOT_UUU_SUPPORT=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_FSL_USDHC=y
diff --git a/configs/colibri_imx7_emmc_defconfig 
b/configs/colibri_imx7_emmc_defconfig
index 49a51e9272..687dbb5e3e 100644
--- a/configs/colibri_imx7_emmc_defconfig
+++ b/configs/colibri_imx7_emmc_defconfig
@@ -62,9 +62,9 @@ CONFIG_SERVERIP="192.168.10.1"
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_ENV=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
-CONFIG_FASTBOOT_BUF_ADDR=0x8200
-CONFIG_FASTBOOT_BUF_SIZE=0x1000
+CONFIG_FASTBOOT_BUF_ADDR=0x8110
 CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_UUU_SUPPORT=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_DM_I2C=y
-- 
2.42.0



[PATCH 2/2] board: apalis/colibri imx6/imx6ull/imx7: Add fastboot bootcmd support

2023-11-09 Thread Hiago De Franco
This commit adds support for Fastboot boot commands by checking both
CONFIG_CMD_USB_SDP and CONFIG_USB_FUNCTION_FASTBOOT. If either of these
configurations is set, it indicates that the board is in recovery mode
and can use either SDP or Fastboot.

The default option remains the SDP command, but if
CONFIG_CMD_FASTBOOT is set, it changes to 'fastboot usb 0' as
the boot command.

Signed-off-by: Hiago De Franco 
---
 board/toradex/apalis_imx6/apalis_imx6.c | 13 -
 board/toradex/colibri-imx6ull/colibri-imx6ull.c | 13 -
 board/toradex/colibri_imx6/colibri_imx6.c   | 13 -
 board/toradex/colibri_imx7/colibri_imx7.c   | 14 +-
 4 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index fa6b7226fe..6fc14b5858 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -701,13 +701,16 @@ int board_late_init(void)
env_set("board_rev", env_str);
 #endif /* CONFIG_BOARD_LATE_INIT */
 
-#ifdef CONFIG_CMD_USB_SDP
-   if (is_boot_from_usb()) {
-   printf("Serial Downloader recovery mode, using sdp command\n");
+   if (IS_ENABLED(CONFIG_USB) && is_boot_from_usb()) {
env_set("bootdelay", "0");
-   env_set("bootcmd", "sdp 0");
+   if (IS_ENABLED(CONFIG_CMD_USB_SDP)) {
+   printf("Serial Downloader recovery mode, using sdp 
command\n");
+   env_set("bootcmd", "sdp 0");
+   } else if (IS_ENABLED(CONFIG_CMD_FASTBOOT)) {
+   printf("Fastboot recovery mode, using fastboot 
command\n");
+   env_set("bootcmd", "fastboot usb 0");
+   }
}
-#endif /* CONFIG_CMD_USB_SDP */
 
return 0;
 }
diff --git a/board/toradex/colibri-imx6ull/colibri-imx6ull.c 
b/board/toradex/colibri-imx6ull/colibri-imx6ull.c
index 48fdb1e097..58f62a8a47 100644
--- a/board/toradex/colibri-imx6ull/colibri-imx6ull.c
+++ b/board/toradex/colibri-imx6ull/colibri-imx6ull.c
@@ -187,13 +187,16 @@ int board_late_init(void)
add_board_boot_modes(board_boot_modes);
 #endif
 
-#ifdef CONFIG_CMD_USB_SDP
-   if (is_boot_from_usb()) {
-   printf("Serial Downloader recovery mode, using sdp command\n");
+   if (IS_ENABLED(CONFIG_USB) && is_boot_from_usb()) {
env_set("bootdelay", "0");
-   env_set("bootcmd", "sdp 0");
+   if (IS_ENABLED(CONFIG_CMD_USB_SDP)) {
+   printf("Serial Downloader recovery mode, using sdp 
command\n");
+   env_set("bootcmd", "sdp 0");
+   } else if (IS_ENABLED(CONFIG_CMD_FASTBOOT)) {
+   printf("Fastboot recovery mode, using fastboot 
command\n");
+   env_set("bootcmd", "fastboot usb 0");
+   }
}
-#endif /* CONFIG_CMD_USB_SDP */
 
 #if defined(CONFIG_VIDEO)
setup_lcd();
diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index e6c9b10570..32940690a7 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -621,13 +621,16 @@ int board_late_init(void)
env_set("board_rev", env_str);
 #endif
 
-#ifdef CONFIG_CMD_USB_SDP
-   if (is_boot_from_usb()) {
-   printf("Serial Downloader recovery mode, using sdp command\n");
+   if (IS_ENABLED(CONFIG_USB) && is_boot_from_usb()) {
env_set("bootdelay", "0");
-   env_set("bootcmd", "sdp 0");
+   if (IS_ENABLED(CONFIG_CMD_USB_SDP)) {
+   printf("Serial Downloader recovery mode, using sdp 
command\n");
+   env_set("bootcmd", "sdp 0");
+   } else if (IS_ENABLED(CONFIG_CMD_FASTBOOT)) {
+   printf("Fastboot recovery mode, using fastboot 
command\n");
+   env_set("bootcmd", "fastboot usb 0");
+   }
}
-#endif /* CONFIG_CMD_USB_SDP */
 
return 0;
 }
diff --git a/board/toradex/colibri_imx7/colibri_imx7.c 
b/board/toradex/colibri_imx7/colibri_imx7.c
index f0356af008..7ef2e24307 100644
--- a/board/toradex/colibri_imx7/colibri_imx7.c
+++ b/board/toradex/colibri_imx7/colibri_imx7.c
@@ -360,13 +360,17 @@ int board_late_init(void)
setup_lcd();
 #endif
 
-#if defined(CONFIG_CMD_USB_SDP)
-   if (is_boot_from_usb()) {
-   printf("Serial Downloader recovery mode, using sdp comma

[PATCH v1] board: colibri_imx7: fix emmc detection

2023-12-12 Thread Hiago De Franco
From: Marcel Ziswiler 

Later versions of Colibri iMX7D V1.1B modules use a "new" SoC fusing. The
difference lies in whether we enable the boot ROM to use the eMMC reset
signal. Depending on the SoC fuse, the boot ROM configures this pin as a
GPIO output to drive the reset signal. Our eMMC vs NAND detection
currently only sets that signal to a GPIO without explicitly setting any
direction. Previously, by default, it was set as an input. As the boot ROM
now configures it as an output, we receive a value of zero instead of one,
indicating the absence of the pull-up on eMMC modules.

To fix this, set the SION bit, allowing the reading back of the value
even if it is configured as an output by the boot ROM. It's important to
note that with the new SoC fusing, we now read back what the boot ROM
drives rather than the real value caused by the pull-up resistor. However,
if it were ever driven low, the eMMC would permanently be reset.

In addition, remove hard-coded variant in the eMMC build case as since the
commit 0c39564d0281 ("toradex: colibri_imx7: Enable nand/emmc detection
and set boot variant") will anyways always get overridden by the detection
routing in board code.

Fixes: 0c39564d ("toradex: colibri_imx7: Enable nand/emmc detection and set 
boot variant")
Signed-off-by: Marcel Ziswiler 
Signed-off-by: Hiago De Franco 
---
 board/toradex/colibri_imx7/colibri_imx7.c | 6 +++---
 include/configs/colibri_imx7.h| 1 -
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/board/toradex/colibri_imx7/colibri_imx7.c 
b/board/toradex/colibri_imx7/colibri_imx7.c
index f0356af008..3e7c5d64c3 100644
--- a/board/toradex/colibri_imx7/colibri_imx7.c
+++ b/board/toradex/colibri_imx7/colibri_imx7.c
@@ -66,7 +66,7 @@ int dram_init(void)
 }
 
 static iomux_v3_cfg_t const flash_detection_pads[] = {
-   MX7D_PAD_SD3_RESET_B__GPIO6_IO11 | MUX_PAD_CTRL(FLASH_DETECTION_CTRL),
+   MX7D_PAD_SD3_RESET_B__GPIO6_IO11 | MUX_PAD_CTRL(FLASH_DETECTION_CTRL) | 
MUX_MODE_SION,
 };
 
 static iomux_v3_cfg_t const uart1_pads[] = {
@@ -193,9 +193,9 @@ int board_init(void)
gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
 
/*
-* Enable GPIO on NAND_WE_B/eMMC_RST with 100k pull-down. eMMC_RST
+* Enable GPIO SION on NAND_WE_B/eMMC_RST with 100k pull-down. eMMC_RST
 * is pulled high with 4.7k for eMMC devices. This allows to reliably
-* detect eMMC/NAND flash
+* detect eMMC vs NAND flash.
 */
imx_iomux_v3_setup_multiple_pads(flash_detection_pads, 
ARRAY_SIZE(flash_detection_pads));
gpio_request(FLASH_DET_GPIO, "flash-detection-gpio");
diff --git a/include/configs/colibri_imx7.h b/include/configs/colibri_imx7.h
index 03f8ed1478..7a9f4afe7d 100644
--- a/include/configs/colibri_imx7.h
+++ b/include/configs/colibri_imx7.h
@@ -101,7 +101,6 @@
UBI_BOOTCMD
 #elif defined(CONFIG_TARGET_COLIBRI_IMX7_EMMC)
 #define MODULE_EXTRA_ENV_SETTINGS \
-   "variant=-emmc\0" \
EMMC_ANDROID_BOOTCMD
 #endif
 
-- 
2.43.0



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

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

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

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

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



[PATCH] tools/scripts/Kconfig: Update references from kconfig-language.txt to rst

2024-08-19 Thread Hiago De Franco
From: Hiago De Franco 

The Linux kernel documentation has transitioned from using
kconfig-language.txt to kconfig-language.rst. Therefore update all
occurrences of kconfig-language.txt.

Signed-off-by: Hiago De Franco 
---
 Kconfig|  2 +-
 scripts/kconfig/symbol.c   |  2 +-
 .../tests/err_recursive_dep/expected_stderr| 14 +++---
 tools/buildman/kconfiglib.py   | 10 +-
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/Kconfig b/Kconfig
index 82df59f176ec..29c42249a221 100644
--- a/Kconfig
+++ b/Kconfig
@@ -1,6 +1,6 @@
 #
 # For a description of the syntax of this configuration file,
-# see the file Documentation/kbuild/kconfig-language.txt in the
+# see the file Documentation/kbuild/kconfig-language.rst in the
 # Linux kernel source tree.
 #
 mainmenu "U-Boot $(UBOOTVERSION) Configuration"
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 703b9b899ee9..5245804bb337 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -1117,7 +1117,7 @@ static void sym_check_print_recursive(struct symbol 
*last_sym)
}
 
fprintf(stderr,
-   "For a resolution refer to 
Documentation/kbuild/kconfig-language.txt\n"
+   "For a resolution refer to 
Documentation/kbuild/kconfig-language.rst\n"
"subsection \"Kconfig recursive dependency limitations\"\n"
"\n");
 
diff --git a/scripts/kconfig/tests/err_recursive_dep/expected_stderr 
b/scripts/kconfig/tests/err_recursive_dep/expected_stderr
index 84679b104655..c9f4abf9a791 100644
--- a/scripts/kconfig/tests/err_recursive_dep/expected_stderr
+++ b/scripts/kconfig/tests/err_recursive_dep/expected_stderr
@@ -1,38 +1,38 @@
 Kconfig:11:error: recursive dependency detected!
 Kconfig:11:symbol B is selected by B
-For a resolution refer to Documentation/kbuild/kconfig-language.txt
+For a resolution refer to Documentation/kbuild/kconfig-language.rst
 subsection "Kconfig recursive dependency limitations"
 
 Kconfig:5:error: recursive dependency detected!
 Kconfig:5: symbol A depends on A
-For a resolution refer to Documentation/kbuild/kconfig-language.txt
+For a resolution refer to Documentation/kbuild/kconfig-language.rst
 subsection "Kconfig recursive dependency limitations"
 
 Kconfig:17:error: recursive dependency detected!
 Kconfig:17:symbol C1 depends on C2
 Kconfig:21:symbol C2 depends on C1
-For a resolution refer to Documentation/kbuild/kconfig-language.txt
+For a resolution refer to Documentation/kbuild/kconfig-language.rst
 subsection "Kconfig recursive dependency limitations"
 
 Kconfig:32:error: recursive dependency detected!
 Kconfig:32:symbol D2 is selected by D1
 Kconfig:27:symbol D1 depends on D2
-For a resolution refer to Documentation/kbuild/kconfig-language.txt
+For a resolution refer to Documentation/kbuild/kconfig-language.rst
 subsection "Kconfig recursive dependency limitations"
 
 Kconfig:37:error: recursive dependency detected!
 Kconfig:37:symbol E1 depends on E2
 Kconfig:42:symbol E2 is implied by E1
-For a resolution refer to Documentation/kbuild/kconfig-language.txt
+For a resolution refer to Documentation/kbuild/kconfig-language.rst
 subsection "Kconfig recursive dependency limitations"
 
 Kconfig:60:error: recursive dependency detected!
 Kconfig:60:symbol G depends on G
-For a resolution refer to Documentation/kbuild/kconfig-language.txt
+For a resolution refer to Documentation/kbuild/kconfig-language.rst
 subsection "Kconfig recursive dependency limitations"
 
 Kconfig:51:error: recursive dependency detected!
 Kconfig:51:symbol F2 depends on F1
 Kconfig:49:symbol F1 default value contains F2
-For a resolution refer to Documentation/kbuild/kconfig-language.txt
+For a resolution refer to Documentation/kbuild/kconfig-language.rst
 subsection "Kconfig recursive dependency limitations"
diff --git a/tools/buildman/kconfiglib.py b/tools/buildman/kconfiglib.py
index b9f37567559a..27abbf9a7a11 100644
--- a/tools/buildman/kconfiglib.py
+++ b/tools/buildman/kconfiglib.py
@@ -6,7 +6,7 @@ Overview
 
 
 Kconfiglib is a Python 2/3 library for scripting and extracting information
-from Kconfig 
(https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt)
+from Kconfig 
(https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.rst)
 configuration systems.
 
 See the homepage at https://github.com/ulfalizer/Kconfiglib for a longer
@@ -709,7 +709,7 @@ class Kconfig(object):
 
 mainmenu_text:
   The prompt (title) of the top menu (top_node). Defaults to "Main menu".
-  Can be changed with the 'mainmenu' statement (see kconfig-language.txt).
+  Can be changed with the 'mainmenu' statement (see k

[PATCH] fs: Fix SPL build if SPL_FS_LOADER is enabled and FS_LOADER is disabled

2024-08-26 Thread Hiago De Franco
From: Hiago De Franco 

When SPL_FS_LOADER is set to y and FS_LOADER is not enabled, the SPL build
fails with the following errors:

  AR  spl/boot/built-in.o
  LD  spl/u-boot-spl
arm-none-linux-gnueabihf-ld.bfd: drivers/misc/fs_loader.o: in function
`fw_get_filesystem_firmware':
/u-boot/drivers/misc/fs_loader.c:162: undefined reference to
`fs_set_blk_dev'
arm-none-linux-gnueabihf-ld.bfd: /home/frh/tdx/src/u-boot/drivers/misc/
fs_loader.c:185: undefined reference to `fs_read'
arm-none-linux-gnueabihf-ld.bfd: drivers/misc/fs_loader.o: in function
`select_fs_dev':
/u-boot/drivers/misc/fs_loader.c:89: undefined reference to
`fs_set_blk_dev_with_part'
make[1]: *** [scripts/Makefile.spl:527: spl/u-boot-spl] Error 1
make: *** [Makefile:2055: spl/u-boot-spl] Error 2

Fix it by replacing the FS_LOADER with SPL_FS_LOADER in the Makefile, so
the fs.c with the necessary function definitions are compiled.

Fixes: b071a07743d4 ("drivers: misc: Makefile: Enable fs_loader compilation at 
SPL Level")
Suggested-by: Francesco Dolcini 
Signed-off-by: Hiago De Franco 
---
 fs/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/Makefile b/fs/Makefile
index 7b05c79e0ccf..a3ee0a361d3d 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -5,7 +5,7 @@
 # Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
 
 ifdef CONFIG_SPL_BUILD
-obj-$(CONFIG_FS_LOADER) += fs.o
+obj-$(CONFIG_SPL_FS_LOADER) += fs.o
 obj-$(CONFIG_SPL_FS_FAT) += fat/
 obj-$(CONFIG_SPL_FS_EXT4) += ext4/
 obj-$(CONFIG_SPL_FS_CBFS) += cbfs/
-- 
2.39.2



[PATCH] configs: verdin-imx8m[mp]: set CONFIG_SPL_LOAD_FIT_ADDRESS

2024-08-29 Thread Hiago De Franco
From: Rogerio Guerra Borin 

Set the CONFIG_SPL_LOAD_FIT_ADDRESS for both verdin-imx8mm and
verdin-imx8mp configurations to specify the load address for FIT images
loaded by the SPL.

As per lastest instructions from NXP, the generation of a HABv4 CSF
(Command Sequence File) requires the U-Boot FIT image (u-boot.itb) load
address to be set to a fixed value when binman is used. The address is
defined by CONFIG_SPL_LOAD_FIT_ADDRESS.

Here we set CONFIG_SPL_LOAD_FIT_ADDRESS to an address 64MB past the
start of the DDR memory leaving plenty of room for the various DDR-
residing artifacts to be moved to their usual load addresses which are
close to the start of the DDR.

Signed-off-by: Rogerio Guerra Borin 
Signed-off-by: Hiago De Franco 
---
 configs/verdin-imx8mm_defconfig | 1 +
 configs/verdin-imx8mp_defconfig | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/verdin-imx8mm_defconfig b/configs/verdin-imx8mm_defconfig
index ef7f3b1bc10d..a6f92f3d070e 100644
--- a/configs/verdin-imx8mm_defconfig
+++ b/configs/verdin-imx8mm_defconfig
@@ -29,6 +29,7 @@ CONFIG_FIT=y
 CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_LOAD_FIT_ADDRESS=0x4400
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTDELAY=1
 CONFIG_OF_SYSTEM_SETUP=y
diff --git a/configs/verdin-imx8mp_defconfig b/configs/verdin-imx8mp_defconfig
index fca91f7b1eee..594fea3a1b03 100644
--- a/configs/verdin-imx8mp_defconfig
+++ b/configs/verdin-imx8mp_defconfig
@@ -38,6 +38,7 @@ CONFIG_FIT=y
 CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_LOAD_FIT_ADDRESS=0x4400
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTDELAY=1
 CONFIG_OF_SYSTEM_SETUP=y
-- 
2.39.2



RE: [PATCH 1/2] clk: clk-imx8qxp: Add LPUART IPG entries

2024-03-09 Thread Hiago De Franco
On 09.03.2024 01:15, Peng Fan wrote:
> > Subject: [PATCH 1/2] clk: clk-imx8qxp: Add LPUART IPG entries
> > 
> > Since commit cc7df0b9e8bc ("serial: lpuart: Enable IPG clock") the colibri-
> > imx8qxp board no longer boots.
> > 
> > The reason is that the imx8qxp clock driver does not handle the LPUART IPG
> > clocks inside get_rate(), set_rate() and enable() functions.
> > 
> > Fix the boot regression by adding the LPUART IPG entries.
> > 
> > Fixes: cc7df0b9e8bc ("serial: lpuart: Enable IPG clock")
> > Reported-by: Marcel Ziswiler 
> > Signed-off-by: Fabio Estevam 
> 
> Reviewed-by: Peng Fan 

Tested-by: Hiago De Franco  # Toradex Colibri iMX8X

> > ---
> >  drivers/clk/imx/clk-imx8qxp.c | 13 -
> >  1 file changed, 12 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/clk/imx/clk-imx8qxp.c b/drivers/clk/imx/clk-imx8qxp.c
> > index 8bf7e325481..d900d4cd528 100644
> > --- a/drivers/clk/imx/clk-imx8qxp.c
> > +++ b/drivers/clk/imx/clk-imx8qxp.c
> > @@ -88,20 +88,23 @@ ulong imx8_clk_get_rate(struct clk *clk)
> > resource = SC_R_SDHC_1;
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > -   case IMX8QXP_UART0_IPG_CLK:
> > case IMX8QXP_UART0_CLK:
> > +   case IMX8QXP_UART0_IPG_CLK:
> > resource = SC_R_UART_0;
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > case IMX8QXP_UART1_CLK:
> > +   case IMX8QXP_UART1_IPG_CLK:
> > resource = SC_R_UART_1;
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > case IMX8QXP_UART2_CLK:
> > +   case IMX8QXP_UART2_IPG_CLK:
> > resource = SC_R_UART_2;
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > case IMX8QXP_UART3_CLK:
> > +   case IMX8QXP_UART3_IPG_CLK:
> > resource = SC_R_UART_3;
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > @@ -170,18 +173,22 @@ ulong imx8_clk_set_rate(struct clk *clk, unsigned
> > long rate)
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > case IMX8QXP_UART0_CLK:
> > +   case IMX8QXP_UART0_IPG_CLK:
> > resource = SC_R_UART_0;
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > case IMX8QXP_UART1_CLK:
> > +   case IMX8QXP_UART1_IPG_CLK:
> > resource = SC_R_UART_1;
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > case IMX8QXP_UART2_CLK:
> > +   case IMX8QXP_UART2_IPG_CLK:
> > resource = SC_R_UART_2;
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > case IMX8QXP_UART3_CLK:
> > +   case IMX8QXP_UART3_IPG_CLK:
> > resource = SC_R_UART_3;
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > @@ -263,18 +270,22 @@ int __imx8_clk_enable(struct clk *clk, bool enable)
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > case IMX8QXP_UART0_CLK:
> > +   case IMX8QXP_UART0_IPG_CLK:
> > resource = SC_R_UART_0;
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > case IMX8QXP_UART1_CLK:
> > +   case IMX8QXP_UART1_IPG_CLK:
> > resource = SC_R_UART_1;
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > case IMX8QXP_UART2_CLK:
> > +   case IMX8QXP_UART2_IPG_CLK:
> > resource = SC_R_UART_2;
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > case IMX8QXP_UART3_CLK:
> > +   case IMX8QXP_UART3_IPG_CLK:
> > resource = SC_R_UART_3;
> > pm_clk = SC_PM_CLK_PER;
> > break;
> > --
> > 2.34.1
> 


Re: [PATCH] colibri-imx8x: Fix sc_misc_otp_fuse_read() error check

2024-03-13 Thread Hiago De Franco
On 13.03.2024 08:09, Marcel Ziswiler wrote:
> Hi Fabio
> 
> Thanks!
> 
> On Tue, 2024-03-12 at 21:36 -0300, Fabio Estevam wrote:
> > Commit aa6e698a7acd ("imx: toradex/colibri-imx8x: correct SCU API usage")
> > made an incorrect logic change in the error code check of
> > sc_misc_otp_fuse_read():
> > 
> > -   if (sc_err == SC_ERR_NONE) {
> > +   if (sc_err) {
> >     /* DX has two A35 cores disabled */
> >     return (val & 0xf) != 0x0;
> >     }
> > 
> > The other changes in this commit are correct.
> > 
> > sc_misc_otp_fuse_read() returns 0 on a successful fuse read.
> > 
> > This inversion causes board_mem_get_layout() to report incorrect RAM size.
> > 
> > Go back the original error check logic to fix the problem.
> > 
> > Fixes: aa6e698a7acd ("imx: toradex/colibri-imx8x: correct SCU API usage")
> > Reported-by: Hiago De Franco 
> > Signed-off-by: Fabio Estevam 
> 
> Acked-by: Marcel Ziswiler 
> 

Tested-by: Hiago De Franco  # Toradex Colibri iMX8X 
1GB

> > diff --git a/board/toradex/colibri-imx8x/colibri-imx8x.c 
> > b/board/toradex/colibri-imx8x/colibri-imx8x.c
> > index 2c673a4a6b06..6fc8076163c6 100644
> > --- a/board/toradex/colibri-imx8x/colibri-imx8x.c
> > +++ b/board/toradex/colibri-imx8x/colibri-imx8x.c
> > @@ -46,7 +46,7 @@ static int is_imx8dx(void)
> >     u32 val = 0;
> >     int sc_err = sc_misc_otp_fuse_read(-1, 6, &val);
> >  
> > -   if (sc_err) {
> > +   if (!sc_err) {
> >     /* DX has two A35 cores disabled */
> >     return (val & 0xf) != 0x0;
> >     }
> 
> Cheers
> 
> Marcel


[PATCH v1] board: toradex: verdin-am62_r5: Increase SPL_STACK_R_MALLOC_SIMPLE_LEN

2024-03-20 Thread Hiago De Franco
From: Hiago De Franco 

Increase the SPL_STACK_R_MALLOC_SIMPLE_LEN to 0x20 to accommodate the
size of tispl.bin fit image. With the recent upgrade of ti-linux-firmware
from version v9.1.0 to v9.2.5, the size of tispl.bin fit image has
increased to 1.4MB, causing allocation errors in the R5 SPL:

```
alloc space exhausted
Could not get FIT buffer of 1325056 bytes
check CONFIG_SPL_SYS_MALLOC_SIZE
```

Signed-off-by: Hiago De Franco 
---
 configs/verdin-am62_r5_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/verdin-am62_r5_defconfig b/configs/verdin-am62_r5_defconfig
index a3febdcb6941..5b4b81c925a0 100644
--- a/configs/verdin-am62_r5_defconfig
+++ b/configs/verdin-am62_r5_defconfig
@@ -35,7 +35,7 @@ CONFIG_SPL_BSS_MAX_SIZE=0x3000
 CONFIG_SPL_SYS_REPORT_STACK_F_USAGE=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_STACK_R=y
-CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x14
+CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x20
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_SYS_MALLOC=y
 CONFIG_SPL_HAS_CUSTOM_MALLOC_START=y
-- 
2.39.2



Re: [PATCH] arm64: Fix map_range() not splitting mapped blocks

2024-03-25 Thread Hiago De Franco
On Mon, Mar 18, 2024 at 04:46:55PM -0300, Fabio Estevam wrote:
> Hi Pierre,
> 
> On Mon, Mar 18, 2024 at 4:35 PM Pierre-Clément Tosi  wrote:
> >
> > The implementation of map_range() creates the requested mapping by
> > walking the page tables, iterating over multiple PTEs and/or descending
> > into existing table mappings as needed. When doing so, it assumes any
> > pre-existing valid PTE to be a table mapping. This assumption is wrong
> > if the platform code attempts to successively map two overlapping ranges
> > where the latter intersects a block mapping created for the former.
> >
> > As a result, map_range() treats the existing block mapping as a table
> > mapping and descends into it i.e. starts interpreting the
> > previously-mapped range as an array of PTEs, writing to them and
> > potentially even descending further (extra fun with MMIO ranges!).
> >
> > Instead, pass any valid non-table mapping to split_block(), which
> > ensures that it actually was a block mapping (calls panic() otherwise)
> > before splitting it.
> >
> > Fixes: 41e2787f5ec4 ("arm64: Reduce add_map() complexity")
> > Signed-off-by: Pierre-Clément Tosi 
> 
> This fixes the boot regression on colibri-imx8x.
> 
> Thanks a lot for your fix!
> 
> Tested-by: Fabio Estevam 

Tested-by: Hiago De Franco  # Toradex Verdin AM62

On Sat, Mar 23, 2024 at 10:34:54AM -0400, Tom Rini wrote:
> On Fri, Mar 22, 2024 at 04:33:03PM -0300, Fabio Estevam wrote:
> > On Fri, Mar 22, 2024 at 4:31 PM Fabio Estevam  wrote:
> > 
> > > As Pierre's explanation addresses Marc's concern,
> > > do you think this can go to 2024.01 to fix the boot regression on 
> > > imx8qxp/8qm?
> > 
> > I meant 2024.04, sorry.
> 
> How much testing has this seen outside of imx?

Tom, I tested with the AM62 TI arm processor (Toradex Verdin AM62) and
it works fine.

U-Boot 2024.04-rc4-1-g5db2e36c8e97 (Mar 25 2024 - 17:28:20 -0300)

SoC:   AM62X SR1.0 HS-FS
DRAM:  1 GiB
Core:  138 devices, 29 uclasses, devicetree: separate
MMC:   mmc@fa1: 0, mmc@fa0: 1
Loading Environment from MMC... OK
In:serial@280
Out:   serial@280
Err:   serial@280
Model: Toradex 0074 Verdin AM62 Dual 1GB IT V1.1A
Serial#: 15133548
Carrier: Toradex Dahlia V1.1C, Serial# 10952631

I've added my Tested-by as well.

> 
> -- 
> Tom

Best Regards,

Hiago.


Re: [PATCH] imx8: Add a default reset_cpu() implementation

2024-03-26 Thread Hiago De Franco
On Tue, Mar 26, 2024 at 09:19:49AM -0300, Fabio Estevam wrote:
> From: Fabio Estevam 
> 
> Add a weak default reset_cpu() implementation just like
> it is done on arch/arm/mach-imx/cpu.c.
> 
> This allows the removal of the empty reset_cpu() in several
> board files.
> 
> Signed-off-by: Fabio Estevam 

Thanks Fabio!

Tested-by: Hiago De Franco  # Toradex Colibri iMX8X

> ---
>  arch/arm/mach-imx/imx8/cpu.c  |  4 
>  board/advantech/imx8qm_dmsse20_a1/imx8qm_dmsse20_a1.c | 11 ---
>  board/advantech/imx8qm_rom7720_a1/imx8qm_rom7720_a1.c |  8 
>  board/congatec/cgtqmx8/cgtqmx8.c  |  7 ---
>  board/freescale/imx8qm_mek/imx8qm_mek.c   |  8 
>  board/freescale/imx8qxp_mek/imx8qxp_mek.c |  8 
>  board/toradex/apalis-imx8/apalis-imx8.c   |  8 
>  board/toradex/colibri-imx8x/colibri-imx8x.c   |  8 
>  8 files changed, 4 insertions(+), 58 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c
> index 0b91e448a5d..6e643188f40 100644
> --- a/arch/arm/mach-imx/imx8/cpu.c
> +++ b/arch/arm/mach-imx/imx8/cpu.c
> @@ -84,6 +84,10 @@ static char *get_reset_cause(void)
>   }
>  }
>  
> +__weak void reset_cpu(void)
> +{
> +}
> +
>  int arch_cpu_init(void)
>  {
>  #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RECOVER_DATA_SECTION)
> diff --git a/board/advantech/imx8qm_dmsse20_a1/imx8qm_dmsse20_a1.c 
> b/board/advantech/imx8qm_dmsse20_a1/imx8qm_dmsse20_a1.c
> index 8b4d73052eb..56b7bdb57c9 100644
> --- a/board/advantech/imx8qm_dmsse20_a1/imx8qm_dmsse20_a1.c
> +++ b/board/advantech/imx8qm_dmsse20_a1/imx8qm_dmsse20_a1.c
> @@ -136,17 +136,6 @@ void detail_board_ddr_info(void)
>   puts("\nDDR");
>  }
>  
> -/*
> - * Board specific reset that is system reset.
> - */
> -void reset_cpu(void)
> -{
> - puts("SCI reboot request");
> -
> - while (1)
> - putc('.');
> -}
> -
>  #ifdef CONFIG_OF_BOARD_SETUP
>  int ft_board_setup(void *blob, struct bd_info *bd)
>  {
> diff --git a/board/advantech/imx8qm_rom7720_a1/imx8qm_rom7720_a1.c 
> b/board/advantech/imx8qm_rom7720_a1/imx8qm_rom7720_a1.c
> index 206ce7d5c13..7f766a688bb 100644
> --- a/board/advantech/imx8qm_rom7720_a1/imx8qm_rom7720_a1.c
> +++ b/board/advantech/imx8qm_rom7720_a1/imx8qm_rom7720_a1.c
> @@ -112,14 +112,6 @@ int board_init(void)
>   return 0;
>  }
>  
> -/*
> - * Board specific reset that is system reset.
> - */
> -void reset_cpu(void)
> -{
> - /* TODO */
> -}
> -
>  int board_mmc_get_env_dev(int devno)
>  {
>   return devno;
> diff --git a/board/congatec/cgtqmx8/cgtqmx8.c 
> b/board/congatec/cgtqmx8/cgtqmx8.c
> index 26189ff66f5..3b01354bb6b 100644
> --- a/board/congatec/cgtqmx8/cgtqmx8.c
> +++ b/board/congatec/cgtqmx8/cgtqmx8.c
> @@ -371,13 +371,6 @@ void detail_board_ddr_info(void)
>   puts("\nDDR");
>  }
>  
> -/*
> - * Board specific reset that is system reset.
> - */
> -void reset_cpu(void)
> -{
> - /* TODO */
> -}
>  
>  #ifdef CONFIG_OF_BOARD_SETUP
>  int ft_board_setup(void *blob, struct bd_info *bd)
> diff --git a/board/freescale/imx8qm_mek/imx8qm_mek.c 
> b/board/freescale/imx8qm_mek/imx8qm_mek.c
> index d96d1d07bb1..2b209c8886f 100644
> --- a/board/freescale/imx8qm_mek/imx8qm_mek.c
> +++ b/board/freescale/imx8qm_mek/imx8qm_mek.c
> @@ -102,14 +102,6 @@ int board_init(void)
>   return 0;
>  }
>  
> -/*
> - * Board specific reset that is system reset.
> - */
> -void reset_cpu(void)
> -{
> - /* TODO */
> -}
> -
>  #ifdef CONFIG_OF_BOARD_SETUP
>  int ft_board_setup(void *blob, struct bd_info *bd)
>  {
> diff --git a/board/freescale/imx8qxp_mek/imx8qxp_mek.c 
> b/board/freescale/imx8qxp_mek/imx8qxp_mek.c
> index 516cefd2f24..833bee55462 100644
> --- a/board/freescale/imx8qxp_mek/imx8qxp_mek.c
> +++ b/board/freescale/imx8qxp_mek/imx8qxp_mek.c
> @@ -126,14 +126,6 @@ int board_init(void)
>   return 0;
>  }
>  
> -/*
> - * Board specific reset that is system reset.
> - */
> -void reset_cpu(void)
> -{
> - /* TODO */
> -}
> -
>  #ifdef CONFIG_OF_BOARD_SETUP
>  int ft_board_setup(void *blob, struct bd_info *bd)
>  {
> diff --git a/board/toradex/apalis-imx8/apalis-imx8.c 
> b/board/toradex/apalis-imx8/apalis-imx8.c
> index 49719f2f553..0f993e644d7 100644
> --- a/board/toradex/apalis-imx8/apalis-imx8.c
> +++ b/board/toradex/apalis-imx8/apalis-imx8.c
> @@ -291,14 +291,6 @@ int board_init(void)
>   return 0;
>  }
>  
> -/*
> - * Board specif

[PATCH v1] board: toradex: colibri-imx8x: Remove board_gpio_init

2024-03-27 Thread Hiago De Franco
From: Hiago De Franco 

On Colibri iMX8X, the gpio initialization and usage should be handled by
the device tree, not by the colibri-imx8x.c code. Therefore, remove it.

Signed-off-by: Hiago De Franco 
---
 board/toradex/colibri-imx8x/colibri-imx8x.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/board/toradex/colibri-imx8x/colibri-imx8x.c 
b/board/toradex/colibri-imx8x/colibri-imx8x.c
index 6fc8076163c6..1474297e1814 100644
--- a/board/toradex/colibri-imx8x/colibri-imx8x.c
+++ b/board/toradex/colibri-imx8x/colibri-imx8x.c
@@ -93,15 +93,6 @@ int board_early_init_f(void)
return 0;
 }
 
-#if IS_ENABLED(CONFIG_DM_GPIO)
-static void board_gpio_init(void)
-{
-   /* TODO */
-}
-#else
-static inline void board_gpio_init(void) {}
-#endif
-
 #if IS_ENABLED(CONFIG_FEC_MXC)
 #include 
 
@@ -128,8 +119,6 @@ static void select_dt_from_module_version(void)
 
 int board_init(void)
 {
-   board_gpio_init();
-
if (IS_ENABLED(CONFIG_IMX_SNVS_SEC_SC_AUTO)) {
int ret = snvs_security_sc_init();
 
-- 
2.39.2



[PATCH] toradex: colibri_imx7: Enable nand/emmc detection and set boot variant

2023-10-02 Thread Hiago De Franco
From: Hiago De Franco 

Add detection of eMMC vs NAND devices on the Colibri iMX7
board. A GPIO is configured to detect the presence of an on-board resistor
that is configured differently based on the flash memory used. Depending on
the detection result, the 'variant' environment variable is set to '-emmc'
or cleared, indicating the type of storage device.

This enhancement improves variant detection during system initialization
through USB recovery mode, where U-Boot is loaded directly to RAM. This
allows variant detection for an accurate device tree selection.

Signed-off-by: Hiago De Franco 
---
 board/toradex/colibri_imx7/colibri_imx7.c | 24 +++
 1 file changed, 24 insertions(+)

diff --git a/board/toradex/colibri_imx7/colibri_imx7.c 
b/board/toradex/colibri_imx7/colibri_imx7.c
index 119e67b47f..f0356af008 100644
--- a/board/toradex/colibri_imx7/colibri_imx7.c
+++ b/board/toradex/colibri_imx7/colibri_imx7.c
@@ -53,6 +53,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #define USB_CDET_GPIO  IMX_GPIO_NR(7, 14)
 
+#define FLASH_DETECTION_CTRL (PAD_CTL_HYS | PAD_CTL_PUE)
+#define FLASH_DET_GPIO IMX_GPIO_NR(6, 11)
+
+static bool is_emmc;
+
 int dram_init(void)
 {
gd->ram_size = get_ram_size((void *)PHYS_SDRAM, imx_ddr_size());
@@ -60,6 +65,10 @@ int dram_init(void)
return 0;
 }
 
+static iomux_v3_cfg_t const flash_detection_pads[] = {
+   MX7D_PAD_SD3_RESET_B__GPIO6_IO11 | MUX_PAD_CTRL(FLASH_DETECTION_CTRL),
+};
+
 static iomux_v3_cfg_t const uart1_pads[] = {
MX7D_PAD_UART1_RX_DATA__UART1_DTE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
MX7D_PAD_UART1_TX_DATA__UART1_DTE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
@@ -183,6 +192,16 @@ int board_init(void)
/* address of boot parameters */
gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
 
+   /*
+* Enable GPIO on NAND_WE_B/eMMC_RST with 100k pull-down. eMMC_RST
+* is pulled high with 4.7k for eMMC devices. This allows to reliably
+* detect eMMC/NAND flash
+*/
+   imx_iomux_v3_setup_multiple_pads(flash_detection_pads, 
ARRAY_SIZE(flash_detection_pads));
+   gpio_request(FLASH_DET_GPIO, "flash-detection-gpio");
+   is_emmc = gpio_get_value(FLASH_DET_GPIO);
+   gpio_free(FLASH_DET_GPIO);
+
 #ifdef CONFIG_FEC_MXC
setup_fec();
 #endif
@@ -348,6 +367,11 @@ int board_late_init(void)
env_set("bootcmd", "sdp 0");
}
 #endif
+   if (is_emmc)
+   env_set("variant", "-emmc");
+   else
+   env_set("variant", "");
+
return 0;
 }
 #endif /* CONFIG_BOARD_LATE_INIT */
-- 
2.40.1



[PATCH] arm: mach-imx: Makefile: Extend u-boot-nand.imx padding

2023-10-03 Thread Hiago De Franco
From: Hiago De Franco 

Extend the padding process of u-boot-nand.imx target by adding 10k bytes
of zeros to the end of the binary using the 'dd' command.

The existing padding method did not generate a functional binary,
as discussed in more detail in this thread [1]. Instead, we adopt the
end-padding calculation method documented in 'board/doc/colibri_imx7.rst'
as a reference, which is relevant for iMX7 with NAND storage.

Adding 10k bytes of zeros provides an approximate value that makes the
proper padding for these NAND devices.

[1] 
https://lore.kernel.org/all/cac4tdfuqffqzrqfv5age_xtbfy1agr2sepn_fzedexhwjdr...@mail.gmail.com/

Signed-off-by: Hiago De Franco 
---
 arch/arm/mach-imx/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index aebfa6517b..6904cf3880 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -142,7 +142,9 @@ u-boot.imx: u-boot.bin u-boot.cfgout $(PLUGIN).bin FORCE
$(call if_changed,mkimage)
 
 quiet_cmd_u-boot-nand_imx = GEN $@
-cmd_u-boot-nand_imx = (dd bs=1024 count=1 if=/dev/zero 2>/dev/null) | cat - $< 
> $@
+cmd_u-boot-nand_imx = (dd bs=1024 count=1 if=/dev/zero 2>/dev/null) | cat - $< 
> $@.zero-padded ; \
+ (dd bs=10k count=1 if=/dev/zero 2>/dev/null) | cat 
$@.zero-padded - > $@ ; \
+ rm -f $@.zero-padded
 
 u-boot-nand.imx: u-boot.imx FORCE
$(call if_changed,u-boot-nand_imx)
-- 
2.40.1