From: Franz Schnyder <[email protected]>

The Apalis iMX8QM and iMX8QP can be distinguished reading out the OTP
fuse word 6. This logic is already used for memory layout selection
and can also be reused to select the corresponding device tree.

Decouple the device tree selection from the Toradex product PID table by
moving the OTP-based QP/QM detection into a helper function used by
both memory layout and device tree selection.

Signed-off-by: Franz Schnyder <[email protected]>
---
 board/toradex/apalis-imx8/apalis-imx8.c | 34 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/board/toradex/apalis-imx8/apalis-imx8.c 
b/board/toradex/apalis-imx8/apalis-imx8.c
index b915673d9e3..ec30ceb3a68 100644
--- a/board/toradex/apalis-imx8/apalis-imx8.c
+++ b/board/toradex/apalis-imx8/apalis-imx8.c
@@ -120,20 +120,26 @@ static void get_tdx_user_fuse(struct tdx_user_fuses 
*tdxuserfuse)
        tdxuserfuse->ramid = fuse_block & GENMASK(3, 0);
 }
 
-void board_mem_get_layout(u64 *phys_sdram_1_start,
-                         u64 *phys_sdram_1_size,
-                         u64 *phys_sdram_2_start,
-                         u64 *phys_sdram_2_size)
+static bool is_imx8qp(void)
 {
-       u32 is_quadplus = 0, val = 0;
-       struct tdx_user_fuses tdxramfuses;
+       u32 val = 0;
        int scierr = sc_misc_otp_fuse_read(-1, 6, &val);
 
        if (!scierr) {
                /* QP has one A72 core disabled */
-               is_quadplus = ((val >> 4) & 0x3) != 0x0;
+               return ((val >> 4) & 0x3) != 0x0;
        }
 
+       return false;
+}
+
+void board_mem_get_layout(u64 *phys_sdram_1_start,
+                         u64 *phys_sdram_1_size,
+                         u64 *phys_sdram_2_start,
+                         u64 *phys_sdram_2_size)
+{
+       struct tdx_user_fuses tdxramfuses;
+
        get_tdx_user_fuse(&tdxramfuses);
 
        *phys_sdram_1_start = PHYS_SDRAM_1;
@@ -154,7 +160,7 @@ void board_mem_get_layout(u64 *phys_sdram_1_start,
                *phys_sdram_2_size = SZ_4G + SZ_2G;
                break;
        default:
-               if (is_quadplus)
+               if (is_imx8qp())
                        /* Our QP based SKUs only have 2 GB RAM 
(PHYS_SDRAM_1_SIZE) */
                        *phys_sdram_2_size = 0x0UL;
                else
@@ -245,18 +251,10 @@ static void select_dt_from_module_version(void)
        else
                env_set("variant", "-v1.1");
 
-       switch (tdx_hw_tag.prodid) {
-       /* Select Apalis iMX8QP device trees */
-       case APALIS_IMX8QP_WIFI_BT:
-       case APALIS_IMX8QP:
-       case APALIS_IMX8QP_WIFI_BT_1300MHZ:
-       case APALIS_IMX8QP_1300MHZ:
+       if (is_imx8qp())
                env_set("soc", "imx8qp");
-               break;
-       default:
+       else
                env_set("soc", "imx8qm");
-               break;
-       }
 }
 
 static int do_select_dt_from_module_version(struct cmd_tbl *cmdtp, int flag,

---
base-commit: 36c377b9859ffb53eb1e39ea31e8d96d1e0fe1e5
change-id: 20260813-simplify-apalis-imx8-ecbb3d1931b5

Best regards,
--  
Franz Schnyder <[email protected]>

Reply via email to