diff mbox series

mx6cuboxi: Fix board revision detection

Message ID 20240327114959.2084525-1-festevam@gmail.com
State Accepted
Commit e7b5250612ed4ffbf962911d49c6bb4c520eb1f2
Delegated to: Fabio Estevam
Headers show
Series mx6cuboxi: Fix board revision detection | expand

Commit Message

Fabio Estevam March 27, 2024, 11:49 a.m. UTC
Currently, an i.MX6 Cuboxi board is incorrectly detected
as the HummingBoard model:

U-Boot 2024.04-rc5 (Mar 26 2024 - 15:59:22 +0100)

CPU:   Freescale i.MX6Q rev1.3 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 26C
Reset cause: POR
Model: SolidRun HummingBoard2 Dual/Quad (1.5som+emmc)
gpio@20a4000: set_dir_flags: error: gpio GPIO3_8 not reserved
gpio@20a4000: get_value: error: gpio GPIO3_8 not reserved
gpio@20a8000: set_dir_flags: error: gpio GPIO4_4 not reserved
gpio@20a8000: get_value: error: gpio GPIO4_4 not reserved
gpio@20b0000: set_dir_flags: error: gpio GPIO6_9 not reserved
gpio@20b0000: get_value: error: gpio GPIO6_9 not reserved
Board: MX6 HummingBoard
DRAM:  2 GiB
...

This error happens because request_detect_gpios() uses the GPIO DM
API, but board_type() still uses the legacy non-DM GPIO API.

Fix it by using the GPIO DM API in board_type() to read the
board revision pins in SPL.

Reported-by: Christian Gmeiner <cgmeiner@igalia.com>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 board/solidrun/mx6cuboxi/mx6cuboxi.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Christian Gmeiner March 27, 2024, 11:58 a.m. UTC | #1
>
> Currently, an i.MX6 Cuboxi board is incorrectly detected
> as the HummingBoard model:
>
> U-Boot 2024.04-rc5 (Mar 26 2024 - 15:59:22 +0100)
>
> CPU:   Freescale i.MX6Q rev1.3 996 MHz (running at 792 MHz)
> CPU:   Extended Commercial temperature grade (-20C to 105C) at 26C
> Reset cause: POR
> Model: SolidRun HummingBoard2 Dual/Quad (1.5som+emmc)
> gpio@20a4000: set_dir_flags: error: gpio GPIO3_8 not reserved
> gpio@20a4000: get_value: error: gpio GPIO3_8 not reserved
> gpio@20a8000: set_dir_flags: error: gpio GPIO4_4 not reserved
> gpio@20a8000: get_value: error: gpio GPIO4_4 not reserved
> gpio@20b0000: set_dir_flags: error: gpio GPIO6_9 not reserved
> gpio@20b0000: get_value: error: gpio GPIO6_9 not reserved
> Board: MX6 HummingBoard
> DRAM:  2 GiB
> ...
>
> This error happens because request_detect_gpios() uses the GPIO DM
> API, but board_type() still uses the legacy non-DM GPIO API.
>
> Fix it by using the GPIO DM API in board_type() to read the
> board revision pins in SPL.
>
> Reported-by: Christian Gmeiner <cgmeiner@igalia.com>
> Signed-off-by: Fabio Estevam <festevam@gmail.com>

Tested-by: Christian Gmeiner <cgmeiner@igalia.com>
Fabio Estevam March 30, 2024, 5:37 p.m. UTC | #2
On Wed, Mar 27, 2024 at 8:50 AM Fabio Estevam <festevam@gmail.com> wrote:
>
> Currently, an i.MX6 Cuboxi board is incorrectly detected
> as the HummingBoard model:
>
> U-Boot 2024.04-rc5 (Mar 26 2024 - 15:59:22 +0100)
>
> CPU:   Freescale i.MX6Q rev1.3 996 MHz (running at 792 MHz)
> CPU:   Extended Commercial temperature grade (-20C to 105C) at 26C
> Reset cause: POR
> Model: SolidRun HummingBoard2 Dual/Quad (1.5som+emmc)
> gpio@20a4000: set_dir_flags: error: gpio GPIO3_8 not reserved
> gpio@20a4000: get_value: error: gpio GPIO3_8 not reserved
> gpio@20a8000: set_dir_flags: error: gpio GPIO4_4 not reserved
> gpio@20a8000: get_value: error: gpio GPIO4_4 not reserved
> gpio@20b0000: set_dir_flags: error: gpio GPIO6_9 not reserved
> gpio@20b0000: get_value: error: gpio GPIO6_9 not reserved
> Board: MX6 HummingBoard
> DRAM:  2 GiB
> ...
>
> This error happens because request_detect_gpios() uses the GPIO DM
> API, but board_type() still uses the legacy non-DM GPIO API.
>
> Fix it by using the GPIO DM API in board_type() to read the
> board revision pins in SPL.
>
> Reported-by: Christian Gmeiner <cgmeiner@igalia.com>
> Signed-off-by: Fabio Estevam <festevam@gmail.com>

Applied, thanks.
diff mbox series

Patch

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 8edabf4404c2..7fe515f928a0 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -336,20 +336,17 @@  static enum board_type board_type(void)
 	 * HB             1     1    x
 	 */
 
-	gpio_direction_input(IMX_GPIO_NR(2, 8));
-	val3 = gpio_get_value(IMX_GPIO_NR(2, 8));
+	val3 = !!dm_gpio_get_value(&board_detect_desc[0]);
 
 	if (val3 == 0)
 		return HUMMINGBOARD2;
 
-	gpio_direction_input(IMX_GPIO_NR(3, 4));
-	val2 = gpio_get_value(IMX_GPIO_NR(3, 4));
+	val2 = !!dm_gpio_get_value(&board_detect_desc[1]);
 
 	if (val2 == 0)
 		return HUMMINGBOARD;
 
-	gpio_direction_input(IMX_GPIO_NR(4, 9));
-	val1 = gpio_get_value(IMX_GPIO_NR(4, 9));
+	val1 = !!dm_gpio_get_value(&board_detect_desc[2]);
 
 	if (val1 == 0) {
 		return CUBOXI;
@@ -363,8 +360,8 @@  static bool is_rev_15_som(void)
 	int val1, val2;
 	SETUP_IOMUX_PADS(som_rev_detect);
 
-	val1 = gpio_get_value(IMX_GPIO_NR(6, 0));
-	val2 = gpio_get_value(IMX_GPIO_NR(6, 4));
+	val1 = !!dm_gpio_get_value(&board_detect_desc[3]);
+	val2 = !!dm_gpio_get_value(&board_detect_desc[4]);
 
 	if (val1 == 1 && val2 == 0)
 		return true;