Skip to contentSkip to conversation

udoo: neo: Fix the board model printing

PATCH In review Fabio Estevam 3 participants 8 messages Jan 3, 2022 – Jan 8, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 udoo: neo: Fix the board model printing

Currently, the board model is not printed correctly:

Board: UDOO Neo UNDEFINED

Read the model type in SPL and store it the internal OCRAM, so that U-Boot proper can retrieve it correctly.

---
This applies on top of Peter's series:
https://lore.kernel.org/all/[email protected]/T/

 board/udoo/neo/neo.c | 91 ++++++++++++++++++++++++--------------------
 1 file changed, 50 insertions(+), 41 deletions(-)
board/udoo/neo/neo.c +50 -41
index 62f81fff6817..0c0d3f615d18 100644
@@ -75,6 +75,8 @@ enum {
 #define BOARD_DETECT_PAD_CFG (MUX_PAD_CTRL(BOARD_DETECT_PAD_CTRL) |	\
 	MUX_MODE_SION)
 
+#define OCRAM_START	0x8f8000
+
 int dram_init(void)
 {
 	gd->ram_size = imx_ddr_size();
@@ -235,13 +237,6 @@ static iomux_v3_cfg_t const phy_control_pads[] = {
 	MUX_PAD_CTRL(ENET_CLK_PAD_CTRL),
 };
 
-static iomux_v3_cfg_t const board_recognition_pads[] = {
-	/*Connected to R184*/
-	MX6_PAD_NAND_READY_B__GPIO4_IO_13 | BOARD_DETECT_PAD_CFG,
-	/*Connected to R185*/
-	MX6_PAD_NAND_ALE__GPIO4_IO_0 | BOARD_DETECT_PAD_CFG,
-};
-
 static iomux_v3_cfg_t const wdog_b_pad = {
 	MX6_PAD_GPIO1_IO13__GPIO1_IO_13 | MUX_PAD_CTRL(WDOG_PAD_CTRL),
 };
@@ -308,34 +303,6 @@ int board_init(void)
 	return 0;
 }
 
-static int get_board_value(void)
-{
-	int r184, r185;
-
-	imx_iomux_v3_setup_multiple_pads(board_recognition_pads,
-					 ARRAY_SIZE(board_recognition_pads));
-
-	gpio_request(IMX_GPIO_NR(4, 13), "r184");
-	gpio_request(IMX_GPIO_NR(4, 0), "r185");
-	gpio_direction_input(IMX_GPIO_NR(4, 13));
-	gpio_direction_input(IMX_GPIO_NR(4, 0));
-
-	r184 = gpio_get_value(IMX_GPIO_NR(4, 13));
-	r185 = gpio_get_value(IMX_GPIO_NR(4, 0));
-
-	/*
-	 * Machine selection -
-	 * Machine          r184,    r185
-	 * ---------------------------------
-	 * Basic              0        0
-	 * Basic Ks           0        1
-	 * Full               1        0
-	 * Extended           1        1
-	 */
-
-	return (r184 << 1) + r185;
-}
-
 int board_early_init_f(void)
 {
 	setup_iomux_uart();
@@ -368,9 +335,9 @@ int board_mmc_init(struct bd_info *bis)
 	return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
 }
 
-static char *board_string(void)
+static char *board_string(int type)
 {
-	switch (get_board_value()) {
+	switch (type) {
 	case UDOO_NEO_TYPE_BASIC:
 		return "BASIC";
 	case UDOO_NEO_TYPE_BASIC_KS:
@@ -385,14 +352,18 @@ static char *board_string(void)
 
 int checkboard(void)
 {
-	printf("Board: UDOO Neo %s\n", board_string());
+	int *board_type = (int *)OCRAM_START;
+
+	printf("Board: UDOO Neo %s\n", board_string(*board_type));
 	return 0;
 }
 
 int board_late_init(void)
 {
+	int *board_type = (int *)OCRAM_START;
+
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-	env_set("board_name", board_string());
+	env_set("board_name", board_string(*board_type));
 #endif
 
 	return 0;
@@ -403,6 +374,41 @@ int board_late_init(void)
 #include <linux/libfdt.h>
 #include <asm/arch/mx6-ddr.h>
 
+static const iomux_v3_cfg_t board_recognition_pads[] = {
+	/*Connected to R184*/
+	MX6_PAD_NAND_READY_B__GPIO4_IO_13 | BOARD_DETECT_PAD_CFG,
+	/*Connected to R185*/
+	MX6_PAD_NAND_ALE__GPIO4_IO_0 | BOARD_DETECT_PAD_CFG,
+};
+
+static int get_board_value(void)
+{
+	int r184, r185;
+
+	imx_iomux_v3_setup_multiple_pads(board_recognition_pads,
+					 ARRAY_SIZE(board_recognition_pads));
+
+	gpio_request(IMX_GPIO_NR(4, 13), "r184");
+	gpio_request(IMX_GPIO_NR(4, 0), "r185");
+	gpio_direction_input(IMX_GPIO_NR(4, 13));
+	gpio_direction_input(IMX_GPIO_NR(4, 0));
+
+	r184 = gpio_get_value(IMX_GPIO_NR(4, 13));
+	r185 = gpio_get_value(IMX_GPIO_NR(4, 0));
+
+	/*
+	 * Machine selection -
+	 * Machine          r184,    r185
+	 * ---------------------------------
+	 * Basic              0        0
+	 * Basic Ks           0        1
+	 * Full               1        0
+	 * Extended           1        1
+	 */
+
+	return (r184 << 1) + r185;
+}
+
 static const struct mx6sx_iomux_ddr_regs mx6_ddr_ioregs = {
 	.dram_dqm0 = 0x00000028,
 	.dram_dqm1 = 0x00000028,
@@ -498,7 +504,7 @@ static void ccgr_init(void)
 
 static void spl_dram_init(void)
 {
-	int board = get_board_value();
+	int *board_type = (int *)OCRAM_START;
 
 	struct mx6_ddr_sysinfo sysinfo = {
 		.dsize = 1, /* width of data bus: 1 = 32 bits */
@@ -515,8 +521,11 @@ static void spl_dram_init(void)
 		.rst_to_cke = 0x23,	/* 33 cycles, 500us (JEDEC default) */
 	};
 
+	*board_type = get_board_value();
+
 	mx6sx_dram_iocfg(32, &mx6_ddr_ioregs, &mx6_grp_ioregs);
-	if (board == UDOO_NEO_TYPE_BASIC || board == UDOO_NEO_TYPE_BASIC_KS)
+	if (*board_type == UDOO_NEO_TYPE_BASIC ||
+	    *board_type == UDOO_NEO_TYPE_BASIC_KS)
 		mx6_dram_cfg(&sysinfo, &neo_basic_mmcd_calib,
 			     &neo_basic_mem_ddr);
 	else
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 udoo: neo: Do not print the Model information

By default the Model information from DT is printed:

CPU:   Freescale i.MX6SX rev1.2 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 63C
Reset cause: POR
Model: UDOO Neo Basic
Board: UDOO Neo FULL
I2C:   ready

As the udoo basic DT is used, such output may be confusing.

Improve it by only printing the Board model instead, which is read from the board identification GPIOs.

---
This applies on top of Peter's series:
https://lore.kernel.org/all/[email protected]/T

 board/udoo/neo/neo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
board/udoo/neo/neo.c +2 -1
index 0c0d3f615d18..da6a0b4e9247 100644
@@ -350,7 +350,8 @@ static char *board_string(int type)
 	return "UNDEFINED";
 }
 
-int checkboard(void)
+/* Override the default implementation, DT model is not accurate */
+int show_board_info(void)
 {
 	int *board_type = (int *)OCRAM_START;
 
Signature · 1 line
2.25.1
Acked-by Tested-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] udoo: neo: Do not print the Model information

Quoted 9 lines · Fabio Estevam

By default the Model information from DT is printed:

CPU:   Freescale i.MX6SX rev1.2 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 63C
Reset cause: POR
Model: UDOO Neo Basic
Board: UDOO Neo FULL
I2C:   ready
Quoted 4 lines

As the udoo basic DT is used, such output may be confusing.

Improve it by only printing the Board model instead, which is read from the board identification GPIOs.

Hi Fabio,
Thanks, I test your patch on basic and extended model. Below some logs seems all work properly. I hope I helped the cause :)

- BASIC log:
-------------------------------------------------------------------------
U-Boot 2022.01-rc4-00034-g19f31e718f-dirty (Jan 05 2022 - 21:38:32 +0100)

CPU:   Freescale i.MX6SX rev1.2 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 32C
Reset cause: POR
Model: UDOO Neo Basic
Board: UDOO Neo BASIC
I2C:   ready
DRAM:  512 MiB
PMIC:  PFUZE3000 DEV_ID=0x30 REV_ID=0x11
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Net:   eth0: ethernet@2188000 [PRIME]

Hit
--------------------------------------------------------------------------

- EXTENDED LOG:
--------------------------------------------------------------------------
U-Boot 2022.01-rc4-00034-g19f31e718f-dirty (Jan 05 2022 - 21:38:32 +0100)

CPU:   Freescale i.MX6SX rev1.2 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 42C
Reset cause: POR
Model: UDOO Neo Basic
Board: UDOO Neo EXTENDED
I2C:   ready
DRAM:  1 GiB
PMIC:  PFUZE3000 DEV_ID=0x30 REV_ID=0x11
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial

Net:
Error: ethernet@2188000 address not set.
No ethernet found.

Hit any key to stop autoboot: 0
----------------------------------------------------------------------------

Tommaso

Quoted 26 lines

---
This applies on top of Peter's series:
https://lore.kernel.org/all/[email protected]/T

 board/udoo/neo/neo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
board/udoo/neo/neo.c +2 -1
index 0c0d3f615d18..da6a0b4e9247 100644
@@ -350,7 +350,8 @@ static char *board_string(int type)
 	return "UNDEFINED";
 }
 
-int checkboard(void)
+/* Override the default implementation, DT model is not accurate */
+int show_board_info(void)
 {
 	int *board_type = (int *)OCRAM_START;
 
Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH 2/2] udoo: neo: Do not print the Model information

Hi Tommaso,

Quoted 3 lines · Tommaso Merciai

Hi Fabio,
Thanks, I test your patch on basic and extended model. Below some logs seems all work properly. I hope I helped the cause :)

Yes, thanks a lot!

Quoted 8 lines

- BASIC log:
-------------------------------------------------------------------------
U-Boot 2022.01-rc4-00034-g19f31e718f-dirty (Jan 05 2022 - 21:38:32 +0100)

CPU:   Freescale i.MX6SX rev1.2 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 32C
Reset cause: POR
Model: UDOO Neo Basic

I assume you have only applied 1/2 and not 2/2.

With 2/2 applied the Model line should not be printed.

Thanks

#4 lore raw

Re: [PATCH 2/2] udoo: neo: Do not print the Model information

Quoted 19 lines · Fabio Estevam

Hi Tommaso,

Quoted 3 lines · Tommaso Merciai

Hi Fabio,
Thanks, I test your patch on basic and extended model. Below some logs seems all work properly. I hope I helped the cause :)

Yes, thanks a lot!

Quoted 8 lines

- BASIC log:
-------------------------------------------------------------------------
U-Boot 2022.01-rc4-00034-g19f31e718f-dirty (Jan 05 2022 - 21:38:32 +0100)

CPU:   Freescale i.MX6SX rev1.2 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 32C
Reset cause: POR
Model: UDOO Neo Basic
Quoted 5 lines

I assume you have only applied 1/2 and not 2/2.

With 2/2 applied the Model line should not be printed.

Thanks

Yes, Fabio. Sorry, I forgot. Below test with 2/2.

U-Boot 2022.01-rc4-00034-g19f31e718f-dirty (Jan 05 2022 - 22:07:22 +0100)

CPU:   Freescale i.MX6SX rev1.2 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 45C
Reset cause: POR
Board: UDOO Neo BASIC
I2C:   ready
DRAM:  512 MiB
PMIC:  PFUZE3000 DEV_ID=0x30 REV_ID=0x11
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Net:   eth0: ethernet@2188000
Hit any key to stop autoboot:  0

U-Boot 2022.01-rc4-00034-g19f31e718f-dirty (Jan 05 2022 - 22:07:22 +0100)

CPU:   Freescale i.MX6SX rev1.2 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 35C
Reset cause: POR
Board: UDOO Neo EXTENDED
I2C:   ready
DRAM:  1 GiB
PMIC:  PFUZE3000 DEV_ID=0x30 REV_ID=0x11
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial

Net:
Error: ethernet@2188000 address not set.
No ethernet found.

Hit any key to stop autoboot: 0

Thanks,
Tommaso

#7 lore raw
In reply to Fabio Estevam
Quoted 8 lines · Fabio Estevam

Currently, the board model is not printed correctly:

Board: UDOO Neo UNDEFINED

Read the model type in SPL and store it the internal OCRAM, so that U-Boot proper can retrieve it correctly.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#6 lore raw

Re: [PATCH 2/2] udoo: neo: Do not print the Model information

In reply to Fabio Estevam
Quoted 9 lines · Fabio Estevam

By default the Model information from DT is printed:

CPU:   Freescale i.MX6SX rev1.2 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 63C
Reset cause: POR
Model: UDOO Neo Basic
Board: UDOO Neo FULL
I2C:   ready
Quoted 8 lines

As the udoo basic DT is used, such output may be confusing.

Improve it by only printing the Board model instead, which is read from the board identification GPIOs.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#5 lore raw

Re: [PATCH 2/2] udoo: neo: Do not print the Model information

In reply to Tommaso Merciai
Quoted 10 lines · Tommaso Merciai
Quoted 9 lines · Fabio Estevam

Hi Tommaso,

Quoted 3 lines · Tommaso Merciai

Hi Fabio,
Thanks, I test your patch on basic and extended model. Below some logs seems all work properly. I hope I helped the cause :)

Yes, thanks a lot!

It's a pleasure, nice team work :)
Tommaso

Quoted 58 lines
Quoted 10 lines
Quoted 9 lines

- BASIC log:
-------------------------------------------------------------------------
U-Boot 2022.01-rc4-00034-g19f31e718f-dirty (Jan 05 2022 - 21:38:32 +0100)

CPU:   Freescale i.MX6SX rev1.2 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 32C
Reset cause: POR
Model: UDOO Neo Basic
Quoted 5 lines

I assume you have only applied 1/2 and not 2/2.

With 2/2 applied the Model line should not be printed.

Thanks

Yes, Fabio. Sorry, I forgot. Below test with 2/2.

U-Boot 2022.01-rc4-00034-g19f31e718f-dirty (Jan 05 2022 - 22:07:22 +0100)

CPU:   Freescale i.MX6SX rev1.2 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 45C
Reset cause: POR
Board: UDOO Neo BASIC
I2C:   ready
DRAM:  512 MiB
PMIC:  PFUZE3000 DEV_ID=0x30 REV_ID=0x11
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Net:   eth0: ethernet@2188000
Hit any key to stop autoboot:  0

U-Boot 2022.01-rc4-00034-g19f31e718f-dirty (Jan 05 2022 - 22:07:22 +0100)

CPU:   Freescale i.MX6SX rev1.2 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 35C
Reset cause: POR
Board: UDOO Neo EXTENDED
I2C:   ready
DRAM:  1 GiB
PMIC:  PFUZE3000 DEV_ID=0x30 REV_ID=0x11
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial

Net:
Error: ethernet@2188000 address not set.
No ethernet found.

Hit any key to stop autoboot: 0

Thanks,
Tommaso