Skip to contentSkip to conversation

board: ti: j721e,j7200: fix do_main_cpsw0_qsgmii_phyinit

PATCH In review Siddharth Vadapalli 3 participants 7 messages Feb 2 – Feb 16

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 board: ti: j721e,j7200: fix do_main_cpsw0_qsgmii_phyinit

Since commit 27cc5951c862 ("include: env: ti: add default for do_main_cpsw0_qsgmii_phyinit"), the value of the environment variable do_main_cpsw0_qsgmii_phyinit happened to remain '0' and couldn't be changed without user intervention. This behavior is due to the following cyclic dependency:
A) ti_common.env sets do_main_cpsw0_qsgmii_phyinit to '0' and its value can only be updated automatically by main_cpsw0_qsgmii_phyinit.
B) main_cpsw0_qsgmii_phyinit is defined in j721e.env and it can run only if 'do_main_cpsw0_qsgmii_phyinit' is already '1' which isn't possible unless the user manually assigns the value.

Fix the aforementioned cyclic dependency by using board_late_init() to detect the QSGMII Daughtercard and set do_main_cpsw0_qsgmii_phyinit.

Additionally, to address the issue of do_main_cpsw0_qsgmii_phyinit being 'undefined' for other platforms, replace:

	if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1;
with:
	if env exists do_main_cpsw0_qsgmii_phyinit;

in ti_common.env.

Fixes 27cc5951c862 ("include: env: ti: add default for do_main_cpsw0_qsgmii_phyinit")

---

Hello,

This patch is based on commit
eed514b11d0 video: correct label for cyclic video_idle of the master branch of U-Boot.

Patch has been tested on:
1. J721E-EVM (Has a QSGMII Daughtercard)
https://gist.github.com/Siddharth-Vadapalli-at-TI/0b453ca7d9e133263ebe10f79b3f685f
2. J7200-EVM (Has a QSGMII Daughtercard)
https://gist.github.com/Siddharth-Vadapalli-at-TI/3f408ec145e71404ef46194b8c1d4f5b
3. AM625-SK (Does not have a QSGMII Daughtercard and the 'undefined variable' error isn't seen):
https://gist.github.com/Siddharth-Vadapalli-at-TI/a16d4a02701b7ef594fd1b98ee015144

Regards,
Siddharth.

 board/ti/j7200/j7200.env     |  1 -
 board/ti/j721e/evm.c         | 16 ++++++++++++++++
 board/ti/j721e/j721e.env     |  3 ---
 include/env/ti/ti_common.env |  3 +--
 4 files changed, 17 insertions(+), 6 deletions(-)
board/ti/j7200/j7200.env +0 -1
index 292fc72fd58..e22a954d8db 100644
@@ -26,7 +26,6 @@ bootdir=/boot
 rd_spec=-
 
 #if CONFIG_TARGET_J7200_A72_EVM
-do_main_cpsw0_qsgmii_phyinit=1
 init_main_cpsw0_qsgmii_phy=gpio set gpio@22_17;
 	gpio clear gpio@22_16
 main_cpsw0_qsgmii_phyinit=
board/ti/j721e/evm.c +16 -0
index e030fe7dc87..d82bf4af7e8 100644
@@ -403,6 +403,19 @@ static void setup_serial(void)
 	env_set("serial#", serial_string);
 }
 
+static void qsgmii_daughtercard_env_update(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ext_cards); i++) {
+		if (!strcmp(ext_cards[i].card_name, "J7X-VSC8514-ETH") &&
+		    daughter_card_detect_flags[i]) {
+			env_set("do_main_cpsw0_qsgmii_phyinit", "1");
+			return;
+		}
+	}
+}
+
 int board_late_init(void)
 {
 	if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {
@@ -412,6 +425,9 @@ int board_late_init(void)
 		/* Check for and probe any plugged-in daughtercards */
 		if (board_is_j721e_som() || board_is_j7200_som())
 			probe_daughtercards();
+
+		/* Update env for power-on-reset of the QSGMII Daughtercard */
+		qsgmii_daughtercard_env_update();
 	}
 
 	return 0;
board/ti/j721e/j721e.env +0 -3
index ead7fbdb212..34f5f63d60a 100644
@@ -29,9 +29,6 @@ rd_spec=-
 init_main_cpsw0_qsgmii_phy=gpio set gpio@22_17;
 	gpio clear gpio@22_16
 main_cpsw0_qsgmii_phyinit=
-	if test $board_name = J721EX-PM1-SOM || test $board_name = J721EX-PM2-SOM || test $board_name = j721e; then
-		do_main_cpsw0_qsgmii_phyinit=1; else
-		do_main_cpsw0_qsgmii_phyinit=0; fi;
 	if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1 && test ${dorprocboot} -eq 1 && test ${boot} = mmc; then
 		run init_main_cpsw0_qsgmii_phy;			\
 	fi;
include/env/ti/ti_common.env +1 -2
index 03e3267ef8a..a0ed83f52ac 100644
@@ -22,11 +22,10 @@ get_fit_overlaystring=
 	done;
 get_fit_config=setexpr name_fit_config gsub / _ conf-${fdtfile}
 run_fit=run get_fit_config; bootm ${addr_fit}#${name_fit_config}${overlaystring}
-do_main_cpsw0_qsgmii_phyinit=0
 bootcmd_ti_mmc=
 	run init_${boot};
 #if CONFIG_CMD_REMOTEPROC
-	if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1;
+	if env exists do_main_cpsw0_qsgmii_phyinit;
 		then run main_cpsw0_qsgmii_phyinit;
 	fi;
 	run boot_rprocs;
Signature · 1 line
2.51.1
#1 lore raw
Quoted 114 lines · Siddharth Vadapalli

Since commit 27cc5951c862 ("include: env: ti: add default for do_main_cpsw0_qsgmii_phyinit"), the value of the environment variable do_main_cpsw0_qsgmii_phyinit happened to remain '0' and couldn't be changed without user intervention. This behavior is due to the following cyclic dependency:
A) ti_common.env sets do_main_cpsw0_qsgmii_phyinit to '0' and its value can only be updated automatically by main_cpsw0_qsgmii_phyinit.
B) main_cpsw0_qsgmii_phyinit is defined in j721e.env and it can run only if 'do_main_cpsw0_qsgmii_phyinit' is already '1' which isn't possible unless the user manually assigns the value.

Fix the aforementioned cyclic dependency by using board_late_init() to detect the QSGMII Daughtercard and set do_main_cpsw0_qsgmii_phyinit.

Additionally, to address the issue of do_main_cpsw0_qsgmii_phyinit being 'undefined' for other platforms, replace:

	if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1;
with:
	if env exists do_main_cpsw0_qsgmii_phyinit;

in ti_common.env.

Fixes 27cc5951c862 ("include: env: ti: add default for do_main_cpsw0_qsgmii_phyinit")

---

Hello,

This patch is based on commit
eed514b11d0 video: correct label for cyclic video_idle of the master branch of U-Boot.

Patch has been tested on:
1. J721E-EVM (Has a QSGMII Daughtercard)
https://gist.github.com/Siddharth-Vadapalli-at-TI/0b453ca7d9e133263ebe10f79b3f685f
2. J7200-EVM (Has a QSGMII Daughtercard)
https://gist.github.com/Siddharth-Vadapalli-at-TI/3f408ec145e71404ef46194b8c1d4f5b
3. AM625-SK (Does not have a QSGMII Daughtercard and the 'undefined variable' error isn't seen):
https://gist.github.com/Siddharth-Vadapalli-at-TI/a16d4a02701b7ef594fd1b98ee015144

Regards,
Siddharth.

 board/ti/j7200/j7200.env     |  1 -
 board/ti/j721e/evm.c         | 16 ++++++++++++++++
 board/ti/j721e/j721e.env     |  3 ---
 include/env/ti/ti_common.env |  3 +--
 4 files changed, 17 insertions(+), 6 deletions(-)
board/ti/j7200/j7200.env +0 -1
index 292fc72fd58..e22a954d8db 100644
@@ -26,7 +26,6 @@ bootdir=/boot
 rd_spec=-
 
 #if CONFIG_TARGET_J7200_A72_EVM
-do_main_cpsw0_qsgmii_phyinit=1
 init_main_cpsw0_qsgmii_phy=gpio set gpio@22_17;
 	gpio clear gpio@22_16
 main_cpsw0_qsgmii_phyinit=
board/ti/j721e/evm.c +16 -0
index e030fe7dc87..d82bf4af7e8 100644
@@ -403,6 +403,19 @@ static void setup_serial(void)
 	env_set("serial#", serial_string);
 }
 
+static void qsgmii_daughtercard_env_update(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ext_cards); i++) {
+		if (!strcmp(ext_cards[i].card_name, "J7X-VSC8514-ETH") &&
+		    daughter_card_detect_flags[i]) {
+			env_set("do_main_cpsw0_qsgmii_phyinit", "1");
+			return;
+		}
+	}
+}
+
 int board_late_init(void)
 {
 	if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {
@@ -412,6 +425,9 @@ int board_late_init(void)
 		/* Check for and probe any plugged-in daughtercards */
 		if (board_is_j721e_som() || board_is_j7200_som())
 			probe_daughtercards();
+
+		/* Update env for power-on-reset of the QSGMII Daughtercard */
+		qsgmii_daughtercard_env_update();
 	}
 
 	return 0;
board/ti/j721e/j721e.env +0 -3
index ead7fbdb212..34f5f63d60a 100644
@@ -29,9 +29,6 @@ rd_spec=-
 init_main_cpsw0_qsgmii_phy=gpio set gpio@22_17;
 	gpio clear gpio@22_16
 main_cpsw0_qsgmii_phyinit=
-	if test $board_name = J721EX-PM1-SOM || test $board_name = J721EX-PM2-SOM || test $board_name = j721e; then
-		do_main_cpsw0_qsgmii_phyinit=1; else
-		do_main_cpsw0_qsgmii_phyinit=0; fi;
 	if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1 && test ${dorprocboot} -eq 1 && test ${boot} = mmc; then
 		run init_main_cpsw0_qsgmii_phy;			\
 	fi;
include/env/ti/ti_common.env +0 -0
index 03e3267ef8a..a0ed83f52ac 100644

include/env/ti/ti_common.env get_fit_overlaystring= · line 28

Quoted 9 lines
include/env/ti/ti_common.env +1 -2
@@ -22,11 +22,10 @@ get_fit_overlaystring=
 	done;
 get_fit_config=setexpr name_fit_config gsub / _ conf-${fdtfile}
 run_fit=run get_fit_config; bootm ${addr_fit}#${name_fit_config}${overlaystring}
-do_main_cpsw0_qsgmii_phyinit=0
 bootcmd_ti_mmc=
 	run init_${boot};
 #if CONFIG_CMD_REMOTEPROC
-	if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1;
+	if env exists do_main_cpsw0_qsgmii_phyinit;

The patch looks good to me however I wonder if we should factor out cpsw0_qsgmii related envs out of ti_common.env since as far as I can tell we only seem to be using it for the j721e/j7200 devices.

Quoted 3 lines
include/env/ti/ti_common.env +0 -0
 		then run main_cpsw0_qsgmii_phyinit;
 	fi;
 	run boot_rprocs;
#2 lore raw
Quoted 26 lines · Anshul Dalal
Quoted 25 lines · Siddharth Vadapalli

Since commit 27cc5951c862 ("include: env: ti: add default for do_main_cpsw0_qsgmii_phyinit"), the value of the environment variable do_main_cpsw0_qsgmii_phyinit happened to remain '0' and couldn't be changed without user intervention. This behavior is due to the following cyclic dependency:
A) ti_common.env sets do_main_cpsw0_qsgmii_phyinit to '0' and its value can only be updated automatically by main_cpsw0_qsgmii_phyinit.
B) main_cpsw0_qsgmii_phyinit is defined in j721e.env and it can run only if 'do_main_cpsw0_qsgmii_phyinit' is already '1' which isn't possible unless the user manually assigns the value.

Fix the aforementioned cyclic dependency by using board_late_init() to detect the QSGMII Daughtercard and set do_main_cpsw0_qsgmii_phyinit.

Additionally, to address the issue of do_main_cpsw0_qsgmii_phyinit being 'undefined' for other platforms, replace:

	if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1;
with:
	if env exists do_main_cpsw0_qsgmii_phyinit;

in ti_common.env.

Fixes 27cc5951c862 ("include: env: ti: add default for do_main_cpsw0_qsgmii_phyinit")

---

[TRIMMED]

Quoted 10 lines
Quoted 10 lines
include/env/ti/ti_common.env +0 -1
index 03e3267ef8a..a0ed83f52ac 100644
@@ -22,11 +22,10 @@ get_fit_overlaystring=
 	done;
 get_fit_config=setexpr name_fit_config gsub / _ conf-${fdtfile}
 run_fit=run get_fit_config; bootm ${addr_fit}#${name_fit_config}${overlaystring}
-do_main_cpsw0_qsgmii_phyinit=0
 bootcmd_ti_mmc=
Quoted 8 lines

include/env/ti/ti_common.env get_fit_overlaystring= · line 28

Quoted 4 lines
include/env/ti/ti_common.env +1 -1
 	run init_${boot};
 #if CONFIG_CMD_REMOTEPROC
-	if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1;
+	if env exists do_main_cpsw0_qsgmii_phyinit;

The patch looks good to me however I wonder if we should factor out cpsw0_qsgmii related envs out of ti_common.env since as far as I can tell we only seem to be using it for the j721e/j7200 devices.

Please refer to the following commit from 22 July 2023:
https://github.com/u-boot/u-boot/commit/4ae1a2470ce7895b747c85a140aaf8b647ae6a32
The commit added:
run main_cpsw0_qsgmii_phyinit
in include/environment/ti/ti_armv7_common.env and ti_armv7_common.env eventually got renamed to ti_common.env by:
https://github.com/u-boot/u-boot/commit/bf9c61acb6caed97114029d2dc1e91b148cd9b8a

Although I agree with your feedback in that it will make more sense for do_main_cpsw0_qsgmii_phyinit to be present in the board specific env, given the background pointed out above, it seems to me that we are simply going in circles by undoing the changes that were previously made. Nevertheless, if you think that it should be moved to the board environment, I will do so in a future cleanup patch.

Regards,
Siddharth.

#3 lore raw
Quoted 57 lines · Siddharth Vadapalli
Quoted 26 lines · Anshul Dalal
Quoted 25 lines · Siddharth Vadapalli

Since commit 27cc5951c862 ("include: env: ti: add default for do_main_cpsw0_qsgmii_phyinit"), the value of the environment variable do_main_cpsw0_qsgmii_phyinit happened to remain '0' and couldn't be changed without user intervention. This behavior is due to the following cyclic dependency:
A) ti_common.env sets do_main_cpsw0_qsgmii_phyinit to '0' and its value can only be updated automatically by main_cpsw0_qsgmii_phyinit.
B) main_cpsw0_qsgmii_phyinit is defined in j721e.env and it can run only if 'do_main_cpsw0_qsgmii_phyinit' is already '1' which isn't possible unless the user manually assigns the value.

Fix the aforementioned cyclic dependency by using board_late_init() to detect the QSGMII Daughtercard and set do_main_cpsw0_qsgmii_phyinit.

Additionally, to address the issue of do_main_cpsw0_qsgmii_phyinit being 'undefined' for other platforms, replace:

	if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1;
with:
	if env exists do_main_cpsw0_qsgmii_phyinit;

in ti_common.env.

Fixes 27cc5951c862 ("include: env: ti: add default for do_main_cpsw0_qsgmii_phyinit")

---

[TRIMMED]

Quoted 10 lines
Quoted 10 lines
include/env/ti/ti_common.env +0 -1
index 03e3267ef8a..a0ed83f52ac 100644
@@ -22,11 +22,10 @@ get_fit_overlaystring=
 	done;
 get_fit_config=setexpr name_fit_config gsub / _ conf-${fdtfile}
 run_fit=run get_fit_config; bootm ${addr_fit}#${name_fit_config}${overlaystring}
-do_main_cpsw0_qsgmii_phyinit=0
 bootcmd_ti_mmc=
Quoted 8 lines

include/env/ti/ti_common.env get_fit_overlaystring= · line 28

Quoted 4 lines
include/env/ti/ti_common.env +1 -1
 	run init_${boot};
 #if CONFIG_CMD_REMOTEPROC
-	if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1;
+	if env exists do_main_cpsw0_qsgmii_phyinit;

The patch looks good to me however I wonder if we should factor out cpsw0_qsgmii related envs out of ti_common.env since as far as I can tell we only seem to be using it for the j721e/j7200 devices.

Please refer to the following commit from 22 July 2023:
https://github.com/u-boot/u-boot/commit/4ae1a2470ce7895b747c85a140aaf8b647ae6a32
The commit added:
run main_cpsw0_qsgmii_phyinit
in include/environment/ti/ti_armv7_common.env and ti_armv7_common.env eventually got renamed to ti_common.env by:
https://github.com/u-boot/u-boot/commit/bf9c61acb6caed97114029d2dc1e91b148cd9b8a

Quoted 6 lines

Although I agree with your feedback in that it will make more sense for do_main_cpsw0_qsgmii_phyinit to be present in the board specific env, given the background pointed out above, it seems to me that we are simply going in circles by undoing the changes that were previously made. Nevertheless, if you think that it should be moved to the board environment, I will do so in a future cleanup patch.

The patch that added main_cpsw0_qsgmii_phyinit was actually based on the commit 14439cd71c1a ("configs: k3: make consistent bootcmd across all k3 socs") where main_cpsw0_qsgmii_phyinit was factored out form the j721e/j7200 defconfigs to the common env. I think this could be better handled by having a board level hook such as follows:

	--- a/include/env/ti/ti_common.env
	+++ b/include/env/ti/ti_common.env
	@@ -22,14 +22,10 @@ get_fit_overlaystring=
		done;
	 get_fit_config=setexpr name_fit_config gsub / _ conf-${fdtfile}
	 run_fit=run get_fit_config; bootm ${addr_fit}#${name_fit_config}${overlaystring}
	+init_board=
	 bootcmd_ti_mmc=
		run init_${boot};
	-#if CONFIG_CMD_REMOTEPROC
	-       if env exists do_main_cpsw0_qsgmii_phyinit;
	-               then run main_cpsw0_qsgmii_phyinit;
	-       fi;
	-       run boot_rprocs;
	-#endif
	+       run init_board;
		if test ${boot_fit} -eq 1;
			then run get_fit_${boot}; run get_fit_overlaystring; run run_fit;
		else;

with init_board being used as required in the board's env as follows:

	--- a/board/ti/j7200/j7200.env
	+++ b/board/ti/j7200/j7200.env
	@@ -34,6 +34,13 @@ main_cpsw0_qsgmii_phyinit=
		fi;
	 #endif

	+#if CONFIG_CMD_REMOTEPROC
	+init_board=
	+       if env exists do_main_cpsw0_qsgmii_phyinit;
	+               then run main_cpsw0_qsgmii_phyinit;
	+       fi;
	+       run boot_rprocs;
	+#endif
	 #if CONFIG_TARGET_J7200_A72_EVM
	 rproc_fw_binaries= 1 /lib/firmware/j7200-mcu-r5f0_1-fw 2 /lib/firmware/j7200-main-r5f0_0-fw 3 /lib/firmware/j7200-main-r5f0_1-fw
	 #endif

Regards,
Anshul

#4 lore raw
Quoted 71 lines · Anshul Dalal
Quoted 57 lines · Siddharth Vadapalli
Quoted 26 lines · Anshul Dalal
Quoted 25 lines · Siddharth Vadapalli

Since commit 27cc5951c862 ("include: env: ti: add default for do_main_cpsw0_qsgmii_phyinit"), the value of the environment variable do_main_cpsw0_qsgmii_phyinit happened to remain '0' and couldn't be changed without user intervention. This behavior is due to the following cyclic dependency:
A) ti_common.env sets do_main_cpsw0_qsgmii_phyinit to '0' and its value can only be updated automatically by main_cpsw0_qsgmii_phyinit.
B) main_cpsw0_qsgmii_phyinit is defined in j721e.env and it can run only if 'do_main_cpsw0_qsgmii_phyinit' is already '1' which isn't possible unless the user manually assigns the value.

Fix the aforementioned cyclic dependency by using board_late_init() to detect the QSGMII Daughtercard and set do_main_cpsw0_qsgmii_phyinit.

Additionally, to address the issue of do_main_cpsw0_qsgmii_phyinit being 'undefined' for other platforms, replace:

	if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1;
with:
	if env exists do_main_cpsw0_qsgmii_phyinit;

in ti_common.env.

Fixes 27cc5951c862 ("include: env: ti: add default for do_main_cpsw0_qsgmii_phyinit")

---

[TRIMMED]

Quoted 10 lines
Quoted 10 lines
include/env/ti/ti_common.env +0 -1
index 03e3267ef8a..a0ed83f52ac 100644
@@ -22,11 +22,10 @@ get_fit_overlaystring=
 	done;
 get_fit_config=setexpr name_fit_config gsub / _ conf-${fdtfile}
 run_fit=run get_fit_config; bootm ${addr_fit}#${name_fit_config}${overlaystring}
-do_main_cpsw0_qsgmii_phyinit=0
 bootcmd_ti_mmc=
Quoted 8 lines

include/env/ti/ti_common.env get_fit_overlaystring= · line 28

Quoted 4 lines
include/env/ti/ti_common.env +1 -1
 	run init_${boot};
 #if CONFIG_CMD_REMOTEPROC
-	if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1;
+	if env exists do_main_cpsw0_qsgmii_phyinit;

The patch looks good to me however I wonder if we should factor out cpsw0_qsgmii related envs out of ti_common.env since as far as I can tell we only seem to be using it for the j721e/j7200 devices.

Please refer to the following commit from 22 July 2023:
https://github.com/u-boot/u-boot/commit/4ae1a2470ce7895b747c85a140aaf8b647ae6a32
The commit added:
run main_cpsw0_qsgmii_phyinit
in include/environment/ti/ti_armv7_common.env and ti_armv7_common.env eventually got renamed to ti_common.env by:
https://github.com/u-boot/u-boot/commit/bf9c61acb6caed97114029d2dc1e91b148cd9b8a

Quoted 6 lines

Although I agree with your feedback in that it will make more sense for do_main_cpsw0_qsgmii_phyinit to be present in the board specific env, given the background pointed out above, it seems to me that we are simply going in circles by undoing the changes that were previously made. Nevertheless, if you think that it should be moved to the board environment, I will do so in a future cleanup patch.

The patch that added main_cpsw0_qsgmii_phyinit was actually based on the commit 14439cd71c1a ("configs: k3: make consistent bootcmd across all k3 socs") where main_cpsw0_qsgmii_phyinit was factored out form the j721e/j7200 defconfigs to the common env. I think this could be better handled by having a board level hook such as follows:

Quoted 16 lines
	--- a/include/env/ti/ti_common.env
	+++ b/include/env/ti/ti_common.env
	@@ -22,14 +22,10 @@ get_fit_overlaystring=
		done;
	 get_fit_config=setexpr name_fit_config gsub / _ conf-${fdtfile}
	 run_fit=run get_fit_config; bootm ${addr_fit}#${name_fit_config}${overlaystring}
	+init_board=
	 bootcmd_ti_mmc=
		run init_${boot};
	-#if CONFIG_CMD_REMOTEPROC
	-       if env exists do_main_cpsw0_qsgmii_phyinit;
	-               then run main_cpsw0_qsgmii_phyinit;
	-       fi;
	-       run boot_rprocs;
	-#endif
	+       run init_board;

This assumes that it is defined for all boards and we will run into the following error for those boards which don't have it in their env:
## Error: "init_board" not defined
So it needs to be updated to:

	if env exists init_board;
		then run init_board;
	fi;
Quoted 6 lines
		if test ${boot_fit} -eq 1;
			then run get_fit_${boot}; run get_fit_overlaystring; run run_fit;
		else;

with init_board being used as required in the board's env as follows:

Quoted 16 lines
	--- a/board/ti/j7200/j7200.env
	+++ b/board/ti/j7200/j7200.env
	@@ -34,6 +34,13 @@ main_cpsw0_qsgmii_phyinit=
		fi;
	 #endif

	+#if CONFIG_CMD_REMOTEPROC
	+init_board=
	+       if env exists do_main_cpsw0_qsgmii_phyinit;
	+               then run main_cpsw0_qsgmii_phyinit;
	+       fi;
	+       run boot_rprocs;
	+#endif
	 #if CONFIG_TARGET_J7200_A72_EVM
	 rproc_fw_binaries= 1 /lib/firmware/j7200-mcu-r5f0_1-fw 2 /lib/firmware/j7200-main-r5f0_0-fw 3 /lib/firmware/j7200-main-r5f0_1-fw
	 #endif

With the minor comment above, this diff looks good to me. Please let me know if you plan on posting the patch for it.

Additionally, since this is unrelated to the current patch, please acknowledge that you have no concerns with the current patch.

Regards,
Siddharth.

Reviewed-by
#5 lore raw
Quoted 89 lines · Siddharth Vadapalli
Quoted 71 lines · Anshul Dalal
Quoted 57 lines · Siddharth Vadapalli
Quoted 26 lines · Anshul Dalal
Quoted 25 lines · Siddharth Vadapalli

Since commit 27cc5951c862 ("include: env: ti: add default for do_main_cpsw0_qsgmii_phyinit"), the value of the environment variable do_main_cpsw0_qsgmii_phyinit happened to remain '0' and couldn't be changed without user intervention. This behavior is due to the following cyclic dependency:
A) ti_common.env sets do_main_cpsw0_qsgmii_phyinit to '0' and its value can only be updated automatically by main_cpsw0_qsgmii_phyinit.
B) main_cpsw0_qsgmii_phyinit is defined in j721e.env and it can run only if 'do_main_cpsw0_qsgmii_phyinit' is already '1' which isn't possible unless the user manually assigns the value.

Fix the aforementioned cyclic dependency by using board_late_init() to detect the QSGMII Daughtercard and set do_main_cpsw0_qsgmii_phyinit.

Additionally, to address the issue of do_main_cpsw0_qsgmii_phyinit being 'undefined' for other platforms, replace:

	if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1;
with:
	if env exists do_main_cpsw0_qsgmii_phyinit;

in ti_common.env.

Fixes 27cc5951c862 ("include: env: ti: add default for do_main_cpsw0_qsgmii_phyinit")

---

[TRIMMED]

Quoted 10 lines
Quoted 10 lines
include/env/ti/ti_common.env +0 -1
index 03e3267ef8a..a0ed83f52ac 100644
@@ -22,11 +22,10 @@ get_fit_overlaystring=
 	done;
 get_fit_config=setexpr name_fit_config gsub / _ conf-${fdtfile}
 run_fit=run get_fit_config; bootm ${addr_fit}#${name_fit_config}${overlaystring}
-do_main_cpsw0_qsgmii_phyinit=0
 bootcmd_ti_mmc=
Quoted 8 lines

include/env/ti/ti_common.env get_fit_overlaystring= · line 28

Quoted 4 lines
include/env/ti/ti_common.env +1 -1
 	run init_${boot};
 #if CONFIG_CMD_REMOTEPROC
-	if test ${do_main_cpsw0_qsgmii_phyinit} -eq 1;
+	if env exists do_main_cpsw0_qsgmii_phyinit;

The patch looks good to me however I wonder if we should factor out cpsw0_qsgmii related envs out of ti_common.env since as far as I can tell we only seem to be using it for the j721e/j7200 devices.

Please refer to the following commit from 22 July 2023:
https://github.com/u-boot/u-boot/commit/4ae1a2470ce7895b747c85a140aaf8b647ae6a32
The commit added:
run main_cpsw0_qsgmii_phyinit
in include/environment/ti/ti_armv7_common.env and ti_armv7_common.env eventually got renamed to ti_common.env by:
https://github.com/u-boot/u-boot/commit/bf9c61acb6caed97114029d2dc1e91b148cd9b8a

Quoted 6 lines

Although I agree with your feedback in that it will make more sense for do_main_cpsw0_qsgmii_phyinit to be present in the board specific env, given the background pointed out above, it seems to me that we are simply going in circles by undoing the changes that were previously made. Nevertheless, if you think that it should be moved to the board environment, I will do so in a future cleanup patch.

The patch that added main_cpsw0_qsgmii_phyinit was actually based on the commit 14439cd71c1a ("configs: k3: make consistent bootcmd across all k3 socs") where main_cpsw0_qsgmii_phyinit was factored out form the j721e/j7200 defconfigs to the common env. I think this could be better handled by having a board level hook such as follows:

Quoted 16 lines
	--- a/include/env/ti/ti_common.env
	+++ b/include/env/ti/ti_common.env
	@@ -22,14 +22,10 @@ get_fit_overlaystring=
		done;
	 get_fit_config=setexpr name_fit_config gsub / _ conf-${fdtfile}
	 run_fit=run get_fit_config; bootm ${addr_fit}#${name_fit_config}${overlaystring}
	+init_board=
	 bootcmd_ti_mmc=
		run init_${boot};
	-#if CONFIG_CMD_REMOTEPROC
	-       if env exists do_main_cpsw0_qsgmii_phyinit;
	-               then run main_cpsw0_qsgmii_phyinit;
	-       fi;
	-       run boot_rprocs;
	-#endif
	+       run init_board;
Quoted 8 lines

This assumes that it is defined for all boards and we will run into the following error for those boards which don't have it in their env:
## Error: "init_board" not defined
So it needs to be updated to:

	if env exists init_board;
		then run init_board;
	fi;

I thought setting init_board to empty string above would've taken care of that but I can incorporate your suggestion as well, thanks :)

Quoted 23 lines
Quoted 6 lines
		if test ${boot_fit} -eq 1;
			then run get_fit_${boot}; run get_fit_overlaystring; run run_fit;
		else;

with init_board being used as required in the board's env as follows:

Quoted 16 lines
	--- a/board/ti/j7200/j7200.env
	+++ b/board/ti/j7200/j7200.env
	@@ -34,6 +34,13 @@ main_cpsw0_qsgmii_phyinit=
		fi;
	 #endif

	+#if CONFIG_CMD_REMOTEPROC
	+init_board=
	+       if env exists do_main_cpsw0_qsgmii_phyinit;
	+               then run main_cpsw0_qsgmii_phyinit;
	+       fi;
	+       run boot_rprocs;
	+#endif
	 #if CONFIG_TARGET_J7200_A72_EVM
	 rproc_fw_binaries= 1 /lib/firmware/j7200-mcu-r5f0_1-fw 2 /lib/firmware/j7200-main-r5f0_0-fw 3 /lib/firmware/j7200-main-r5f0_1-fw
	 #endif
Quoted 6 lines

With the minor comment above, this diff looks good to me. Please let me know if you plan on posting the patch for it.

Additionally, since this is unrelated to the current patch, please acknowledge that you have no concerns with the current patch.

Yeah, I can post the refactor once your patch is merged to which I have no objections to.

#6 lore raw
In reply to Siddharth Vadapalli
Quoted 11 lines · Siddharth Vadapalli

Since commit 27cc5951c862 ("include: env: ti: add default for do_main_cpsw0_qsgmii_phyinit"), the value of the environment variable do_main_cpsw0_qsgmii_phyinit happened to remain '0' and couldn't be changed without user intervention. This behavior is due to the following cyclic dependency:
A) ti_common.env sets do_main_cpsw0_qsgmii_phyinit to '0' and its value can only be updated automatically by main_cpsw0_qsgmii_phyinit.
B) main_cpsw0_qsgmii_phyinit is defined in j721e.env and it can run only if 'do_main_cpsw0_qsgmii_phyinit' is already '1' which isn't possible unless the user manually assigns the value.

Quoted 1 line

[...]

Applied to u-boot/master, thanks!

[1/1] board: ti: j721e,j7200: fix do_main_cpsw0_qsgmii_phyinit

      commit: e7ef80f670760b88f99847db9c98ac473edcba8b
Signature · 1 line
Tom