]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
board: tqma6: implement ENET errata workaround detection
authorMarkus Niebel <Markus.Niebel@ew.tq-group.com>
Mon, 13 Jul 2026 13:01:05 +0000 (15:01 +0200)
committerFabio Estevam <festevam@gmail.com>
Mon, 27 Jul 2026 16:05:07 +0000 (13:05 -0300)
TQMa6 SOM beginning with hardware rev. 0200 comes in two flavours:
With and without a hardware workaround for ENET errata err006687.
Therefore we need two flavours of device tree. To be able to detect
the presence of the workaround we need to check GPIO1_6 is connected
to I2C bus or not. If the I2C bus is detected, the workaround is not
used and separate I2C buses are used for the SoM and the baseboard.

Later on this detection will be used to select the correct devicetree
at runtime.

Signed-off-by: Markus Niebel <Markus.Niebel@ew.tq-group.com>
Signed-off-by: Max Merchel <Max.Merchel@ew.tq-group.com>
board/tq/tqma6/tqma6.c
board/tq/tqma6/tqma6.h [new file with mode: 0644]

index 005f08c4e5fe427e224cfed4021461abdf9d3e3f..b740ac7d5b1236caded1b31795f653c2becab92d 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/*
+ * Rev. 0200 and newer optionally implements GIGE errata fix.
+ * Use a global var to signal presence of the fix. This should be checked
+ * early. If fix is present, system I2C is I2C1 - otherwise I2C3
+ */
+static int has_enet_workaround = -1;
+
+int tqma6_has_enet_workaround(void)
+{
+       return has_enet_workaround;
+}
+
 int dram_init(void)
 {
        gd->ram_size = imx_ddr_size();
@@ -38,6 +50,36 @@ int dram_init(void)
        return 0;
 }
 
+#define GPIO_REVDET_PAD_CTRL  (PAD_CTL_PUS_100K_DOWN | PAD_CTL_SPEED_LOW | \
+                              PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
+
+static const iomux_v3_cfg_t tqma6_revdet_pads[] = {
+       MX6_PAD_GPIO_6__GPIO1_IO06 | MUX_PAD_CTRL(GPIO_REVDET_PAD_CTRL),
+};
+
+void tqma6_detect_enet_workaround(void)
+{
+       int ret;
+       struct gpio_desc desc;
+
+       imx_iomux_v3_setup_multiple_pads(tqma6_revdet_pads,
+                                        ARRAY_SIZE(tqma6_revdet_pads));
+
+       ret = dm_gpio_lookup_name("GPIO1_6", &desc);
+       if (ret) {
+               pr_err("error: gpio lookup for enet workaround %d\n", ret);
+               return;
+       }
+
+       ret = dm_gpio_get_value(&desc);
+       if (ret == 0)
+               has_enet_workaround = 1;
+       else if (ret > 0)
+               has_enet_workaround = 0;
+
+       dm_gpio_free(NULL, &desc);
+}
+
 int board_early_init_f(void)
 {
        return tq_bb_board_early_init_f();
@@ -99,11 +141,27 @@ int board_late_init(void)
 {
        env_set("board_name", tqma6_get_boardname());
 
+       tqma6_detect_enet_workaround();
+
        tq_bb_board_late_init();
 
        printf("Board: %s on a %s\n", tqma6_get_boardname(),
               tq_bb_get_boardname());
 
+       puts("Enet workaround: ");
+       switch (tqma6_has_enet_workaround()) {
+       case 0:
+               puts("absent");
+               break;
+       case 1:
+               puts("implemented");
+               break;
+       default:
+               puts("Unknown");
+               break;
+       };
+       puts("\n");
+
        return tq_bb_checkboard();
 }
 
diff --git a/board/tq/tqma6/tqma6.h b/board/tq/tqma6/tqma6.h
new file mode 100644 (file)
index 0000000..0cf38a4
--- /dev/null
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2023-2026 TQ-Systems GmbH <u-boot@ew.tq-group.com>,
+ * D-82229 Seefeld, Germany.
+ * Author: Paul Gerber
+ */
+
+#ifndef __TQMA6_H
+#define __TQMA6_H
+
+int tqma6_has_enet_workaround(void);
+
+#endif /* __TQMA6_H */