[PATCH v4 15/20] board: compulab: Convert imx8mm-cl-iot-gate to UCLASS extension framework
Kory Maincent (TI.com)
kory.maincent at bootlin.com
Wed Oct 22 17:20:26 CEST 2025
Migrate CompuLab imx8mm-cl-iot-gate board extension detection from legacy
implementation to the new UCLASS-based extension board framework.
Signed-off-by: Kory Maincent (TI.com) <kory.maincent at bootlin.com>
---
Change in v3:
- Use U_BOOT_DRVINFO.
Change in v2:
- Fix build errors.
---
arch/arm/mach-imx/imx8m/Kconfig | 4 +-
.../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 67 +++++++++++-----------
2 files changed, 35 insertions(+), 36 deletions(-)
diff --git a/arch/arm/mach-imx/imx8m/Kconfig b/arch/arm/mach-imx/imx8m/Kconfig
index e7bc154b805..5324eff3084 100644
--- a/arch/arm/mach-imx/imx8m/Kconfig
+++ b/arch/arm/mach-imx/imx8m/Kconfig
@@ -359,14 +359,14 @@ config TARGET_IMX8MM_CL_IOT_GATE
select IMX8MM
select SUPPORT_SPL
select IMX8M_LPDDR4
- select SUPPORT_EXTENSION_SCAN
+ select SUPPORT_DM_EXTENSION_SCAN
config TARGET_IMX8MM_CL_IOT_GATE_OPTEE
bool "CompuLab iot-gate-imx8 with optee support"
select IMX8MM
select SUPPORT_SPL
select IMX8M_LPDDR4
- select SUPPORT_EXTENSION_SCAN
+ select SUPPORT_DM_EXTENSION_SCAN
config TARGET_IMX8MP_RSB3720A1_4G
bool "Support i.MX8MP RSB3720A1 4G"
diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c
index be4f293bd4a..260d8757129 100644
--- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c
+++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c
@@ -436,9 +436,10 @@ static int iot_gate_imx8_update_ext_ied(void)
return 0;
}
-int extension_board_scan(struct list_head *extension_list)
+static int iot_gate_imx8_extension_board_scan(struct udevice *dev,
+ struct alist *extension_list)
{
- struct extension *extension = NULL;
+ struct extension extension = {0};
int i;
int ret = 0;
@@ -448,25 +449,21 @@ int extension_board_scan(struct list_head *extension_list)
case IOT_GATE_EXT_EMPTY:
break;
case IOT_GATE_EXT_CAN:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_EXT_CAN");
break;
case IOT_GATE_EXT_IED:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_EXT_IED");
- snprintf(extension->overlay, sizeof(extension->overlay),
+ snprintf(extension.overlay, sizeof(extension.overlay),
"imx8mm-cl-iot-gate-ied.dtbo");
break;
case IOT_GATE_EXT_POE:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_EXT_POE");
break;
case IOT_GATE_EXT_POEV2:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_EXT_POEV2");
break;
default:
@@ -474,10 +471,11 @@ int extension_board_scan(struct list_head *extension_list)
break;
}
- if (extension) {
- snprintf(extension->owner, sizeof(extension->owner),
+ if (extension.name[0]) {
+ snprintf(extension.owner, sizeof(extension.owner),
"Compulab");
- list_add_tail(&extension->list, extension_list);
+ if (!alist_add(extension_list, extension))
+ return -ENOMEM;
ret = 1;
} else
return ret;
@@ -486,44 +484,38 @@ int extension_board_scan(struct list_head *extension_list)
iot_gate_imx8_update_ext_ied();
for (i=0; i<ARRAY_SIZE(iot_gate_imx8_ext_ied_id); i++) {
- extension = NULL;
+ memset(&extension, 0, sizeof(extension));
switch (iot_gate_imx8_ext_ied_id[i]) {
case IOT_GATE_IMX8_CARD_ID_EMPTY:
break;
case IOT_GATE_IMX8_CARD_ID_RS_485:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_IMX8_CARD_ID_RS_485");
break;
case IOT_GATE_IMX8_CARD_ID_RS_232:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_IMX8_CARD_ID_RS_232");
break;
case IOT_GATE_IMX8_CARD_ID_CAN:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_IMX8_CARD_ID_CAN");
- snprintf(extension->overlay, sizeof(extension->overlay),
+ snprintf(extension.overlay, sizeof(extension.overlay),
"imx8mm-cl-iot-gate-ied-can%d.dtbo", i);
break;
case IOT_GATE_IMX8_CARD_ID_TPM:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_IMX8_CARD_ID_TPM");
- snprintf(extension->overlay, sizeof(extension->overlay),
+ snprintf(extension.overlay, sizeof(extension.overlay),
"imx8mm-cl-iot-gate-ied-tpm%d.dtbo", i);
break;
case IOT_GATE_IMX8_CARD_ID_CL420:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_IMX8_CARD_ID_CL420");
- snprintf(extension->overlay, sizeof(extension->overlay),
+ snprintf(extension.overlay, sizeof(extension.overlay),
"imx8mm-cl-iot-gate-ied-can%d.dtbo", i);
break;
case IOT_GATE_IMX8_CARD_ID_DI4O4:
- extension = calloc(1, sizeof(struct extension));
- snprintf(extension->name, sizeof(extension->name),
+ snprintf(extension.name, sizeof(extension.name),
"IOT_GATE_IMX8_CARD_ID_DI4O4");
break;
default:
@@ -531,18 +523,25 @@ int extension_board_scan(struct list_head *extension_list)
__func__, i, iot_gate_imx8_ext_ied_id[i]);
break;
}
- if (extension) {
- snprintf(extension->owner, sizeof(extension->owner),
+ if (extension.name[0]) {
+ snprintf(extension.owner, sizeof(extension.owner),
"Compulab");
- snprintf(extension->other, sizeof(extension->other),
+ snprintf(extension.other, sizeof(extension.other),
"On slot %d", i);
- list_add_tail(&extension->list, extension_list);
+ if (!alist_add(extension_list, extension))
+ return -ENOMEM;
ret = ret + 1;
}
}
return ret;
}
+
+U_BOOT_EXTENSION(iot_gate_imx8_extension, iot_gate_imx8_extension_board_scan);
+
+U_BOOT_DRVINFO(iot_gate_imx8_extension) = {
+ .name = "iot_gate_imx8_extension",
+};
#endif
static int setup_mac_address(void)
--
2.43.0
More information about the U-Boot
mailing list