Skip to contentSkip to conversation

Convert extension support to UCLASS and adds its support to boot flows

PATCH Superseded Kory Maincent 4 participants 37 messages Oct 3, 2025 – Oct 8, 2025

Subsystems (5)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Convert extension support to UCLASS and adds its support to boot flows

This series converts the extension board framework to use UCLASS as requested by Simon Glass, then adds extension support to pxe_utils and bootmeth_efi (not tested) to enable extension boards devicetree load in the standard boot process.

The UCLASS implementation provides one driver that manages all extension boards (alternative would be one U-Boot device per extension board). Simon is that what you would expect?

---
Kory Maincent (16):
MAINTAINERS: Add maintainer for extension board support
boot: Move extension board support from cmd/ to boot/
boot: Add UCLASS support for extension boards
board: ti: Exclude cape detection from XPL builds
board: ti: Refactor cape detection code for readability
board: ti: Convert cape detection to use UCLASS framework
board: sunxi: Refactor CHIP board extension code
board: sunxi: Convert extension support to UCLASS framework
board: sandbox: Improve extension board scan implementation
board: sandbox: Convert extension support to UCLASS framework
board: compulab: Convert imx8mm-cl-iot-gate to UCLASS extension framework
boot: Remove legacy extension board support
boot: extension: Move overlay apply custom logic to command level
boot: pxe_utils: Add extension board devicetree overlay support
boot: bootmeth_efi: Refactor distro_efi_try_bootflow_files return logic
boot: bootmeth_efi: Add extension board devicetree overlay support

 MAINTAINERS                                        |   9 +
 .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c        |  60 ++++---
 board/sandbox/sandbox.c                            |  22 ++-
 board/sunxi/chip.c                                 |  33 ++--
 board/ti/common/Makefile                           |   2 +
 board/ti/common/cape_detect.c                      |  52 +++---
 boot/Kconfig                                       |   3 +
 boot/Makefile                                      |   1 +
 boot/bootmeth_efi.c                                |  78 +++++++--
 boot/extension-uclass.c                            | 138 ++++++++++++++++
 boot/pxe_utils.c                                   |  90 ++++++++++
 cmd/Kconfig                                        |   5 +-
 cmd/extension_board.c                              | 183 ++++++++++-----------
 doc/usage/cmd/extension.rst                        |  24 +--
 include/dm/uclass-id.h                             |   1 +
 include/extension_board.h                          |  71 ++++++--
 16 files changed, 544 insertions(+), 228 deletions(-)

---
base-commit: 9710d98e8942151fc0c62d54100d9d27e8263d04
change-id: 20250916-feature_sysboot_extension_board-958dd0072565

Best regards,

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#1 lore raw

PATCH 1/16 MAINTAINERS: Add maintainer for extension board support

Add myself as maintainer for the extension board support that was originally added to track ongoing development and maintenance.

---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
index b030242a2d8..45e4b8a1865 100644
@@ -1183,6 +1183,14 @@ F:	scripts/event_dump.py
 F:	test/common/event.c
 F:	test/py/tests/test_event_dump.py
 
+EXTENSION
+M:	Kory Maincent <[email protected]>
+S:	Maintained
+F:	board/sunxi/chip.c
+F:	board/ti/common/cape_detect.c
+F:	cmd/extension_board.c
+F:	include/extension_board.h
+
 FASTBOOT
 M:	Mattijs Korpershoek <[email protected]>
 S:	Maintained
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/16 boot: Move extension board support from cmd/ to boot/

In reply to Kory Maincent

Relocate extension board support from cmd/ to boot/ directory in preparation for converting the extension framework to use UCLASS. Also improve code style by applying reverse Christmas tree ordering.

---
 MAINTAINERS               |  1 +
 boot/Kconfig              |  3 ++
 boot/Makefile             |  1 +
 boot/extension.c          | 97 ++++++++++++++++++++++++++++++++++++++++++++++
 cmd/Kconfig               |  3 --
 cmd/extension_board.c     | 99 ++---------------------------------------------
 include/extension_board.h | 16 ++++++++
 7 files changed, 122 insertions(+), 98 deletions(-)
MAINTAINERS +1 -0
index 45e4b8a1865..b9fbe5730b4 100644
@@ -1188,6 +1188,7 @@ M:	Kory Maincent <[email protected]>
 S:	Maintained
 F:	board/sunxi/chip.c
 F:	board/ti/common/cape_detect.c
+F:	boot/extension.c
 F:	cmd/extension_board.c
 F:	include/extension_board.h
 
boot/Kconfig +3 -0
index dd047365754..62aa301f18f 100644
@@ -1906,6 +1906,9 @@ endmenu
 
 endif # OF_LIBFDT
 
+config SUPPORT_EXTENSION_SCAN
+        bool
+
 config USE_BOOTARGS
 	bool "Enable boot arguments"
 	help
boot/Makefile +1 -0
index 3da6f7a0914..f60d13130b1 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_BOOT_RETRY) += bootretry.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o bootm_os.o
 obj-$(CONFIG_CMD_BOOTZ) += bootm.o bootm_os.o
 obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
+obj-$(CONFIG_SUPPORT_EXTENSION_SCAN) += extension.o
 
 obj-$(CONFIG_PXE_UTILS) += pxe_utils.o
 
boot/extension.c new file +97 -0

97 lines not on this page · raw message

cmd/Kconfig +0 -3
index 29de857ba7c..986eeeba807 100644
@@ -545,9 +545,6 @@ config CMD_FDT
 	help
 	  Do FDT related setup before booting into the Operating System.
 
-config SUPPORT_EXTENSION_SCAN
-	bool
-
 config CMD_EXTENSION
 	bool "Extension board management command"
 	select CMD_FDT
cmd/extension_board.c +4 -95

129 lines not on this page · raw message

include/extension_board.h +16 -0
index 22e4104bc54..3f70416f005 100644
@@ -9,6 +9,8 @@
 
 #include <linux/list.h>
 
+extern struct list_head extension_list;
+
 struct extension {
 	struct list_head list;
 	char name[32];
@@ -30,4 +32,18 @@ struct extension {
  */
 int extension_board_scan(struct list_head *extension_list);
 
+/**
+ * extension_apply - Apply extension board overlay to the devicetree
+ * @extension: Extension to be applied
+ * Return: Zero on success, negative on failure.
+ */
+int extension_apply(struct extension *extension);
+
+/**
+ * extension_scan - Scan extension boards available.
+ * @show: Flag to enable verbose log
+ * Return: Zero on success, negative on failure.
+ */
+int extension_scan(bool show);
+
 #endif /* __EXTENSION_SUPPORT_H */
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/16 boot: Add UCLASS support for extension boards

In reply to Kory Maincent

Introduce UCLASS-based extension board support to enable more standardized and automatic loading of extension board device tree overlays in preparation for integration with bootstd and pxe_utils.

---
 MAINTAINERS                 |   1 +
 boot/Kconfig                |   3 +
 boot/Makefile               |   1 +
 boot/extension-uclass.c     | 196 ++++++++++++++++++++++++++++++++++++++++++++
 cmd/Kconfig                 |   2 +-
 cmd/extension_board.c       |  50 ++++++++++-
 doc/usage/cmd/extension.rst |  24 +++---
 include/dm/uclass-id.h      |   1 +
 include/extension_board.h   |  64 +++++++++++++++
 9 files changed, 326 insertions(+), 16 deletions(-)
MAINTAINERS +1 -0
index b9fbe5730b4..4afa5dfb020 100644
@@ -1188,6 +1188,7 @@ M:	Kory Maincent <[email protected]>
 S:	Maintained
 F:	board/sunxi/chip.c
 F:	board/ti/common/cape_detect.c
+F:	boot/extension-uclass.c
 F:	boot/extension.c
 F:	cmd/extension_board.c
 F:	include/extension_board.h
boot/Kconfig +3 -0
index 62aa301f18f..159da81bec5 100644
@@ -1909,6 +1909,9 @@ endif # OF_LIBFDT
 config SUPPORT_EXTENSION_SCAN
         bool
 
+config SUPPORT_DM_EXTENSION_SCAN
+        bool
+
 config USE_BOOTARGS
 	bool "Enable boot arguments"
 	help
boot/Makefile +1 -0
index f60d13130b1..aa26070fbb8 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o bootm_os.o
 obj-$(CONFIG_CMD_BOOTZ) += bootm.o bootm_os.o
 obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
 obj-$(CONFIG_SUPPORT_EXTENSION_SCAN) += extension.o
+obj-$(CONFIG_SUPPORT_DM_EXTENSION_SCAN) += extension-uclass.o
 
 obj-$(CONFIG_PXE_UTILS) += pxe_utils.o
 
boot/extension-uclass.c new file +196 -0

196 lines not on this page · raw message

cmd/Kconfig +1 -1
index 986eeeba807..721bdb87c8a 100644
@@ -548,7 +548,7 @@ config CMD_FDT
 config CMD_EXTENSION
 	bool "Extension board management command"
 	select CMD_FDT
-	depends on SUPPORT_EXTENSION_SCAN
+	depends on SUPPORT_EXTENSION_SCAN || SUPPORT_DM_EXTENSION_SCAN
 	help
 	  Enables the "extension" command, which allows to detect
 	  extension boards connected to the system, and apply
cmd/extension_board.c +47 -3

108 lines not on this page · raw message

doc/usage/cmd/extension.rst +12 -12
index 4c261e74951..d82c3fbef0a 100644
@@ -25,9 +25,8 @@ Device Tree overlays depending on the detected extension boards.
 
 The "extension" command comes with three sub-commands:
 
- - "extension scan" makes the generic code call the board-specific
-   extension_board_scan() function to retrieve the list of detected
-   extension boards.
+ - "extension scan" makes the generic code call a board-specific extension
+   function to retrieve the list of detected extension boards.
 
  - "extension list" allows to list the detected extension boards.
 
@@ -98,17 +97,18 @@ Simple extension_board_scan function example
 
 .. code-block:: c
 
-    int extension_board_scan(struct list_head *extension_list)
+    static int foo_extension_board_scan(struct alist *extension_list)
     {
-        struct extension *extension;
+        struct extension extension = {0};
 
-        extension = calloc(1, sizeof(struct extension));
-        snprintf(extension->overlay, sizeof(extension->overlay), "overlay.dtbo");
-        snprintf(extension->name, sizeof(extension->name), "extension board");
-        snprintf(extension->owner, sizeof(extension->owner), "sandbox");
-        snprintf(extension->version, sizeof(extension->version), "1.1");
-        snprintf(extension->other, sizeof(extension->other), "Extension board information");
-        list_add_tail(&extension->list, extension_list);
+        snprintf(extension.overlay, sizeof(extension.overlay), "overlay.dtbo");
+        snprintf(extension.name, sizeof(extension.name), "extension board");
+        snprintf(extension.owner, sizeof(extension.owner), "sandbox");
+        snprintf(extension.version, sizeof(extension.version), "1.1");
+        snprintf(extension.other, sizeof(extension.other), "Extension board information");
+        alist_add(extension_list, extension);
 
         return 1;
     }
+
+    U_BOOT_EXTENSION(foo_extension_name, foo_extension_board_scan);
include/dm/uclass-id.h +1 -0
index 6be59093160..eb6416b5917 100644
@@ -63,6 +63,7 @@ enum uclass_id {
 	UCLASS_ETH,		/* Ethernet device */
 	UCLASS_ETH_PHY,		/* Ethernet PHY device */
 	UCLASS_EXTCON,		/* External Connector Class */
+	UCLASS_EXTENSION,	/* Extension board */
 	UCLASS_FFA,		/* Arm Firmware Framework for Armv8-A */
 	UCLASS_FFA_EMUL,		/* sandbox FF-A device emulator */
 	UCLASS_FIRMWARE,	/* Firmware */
include/extension_board.h +64 -0

79 lines not on this page · raw message

Signature · 1 line
2.43.0
#4 lore raw

PATCH 4/16 board: ti: Exclude cape detection from XPL builds

In reply to Kory Maincent

Disable cape detection functionality in XPL (eXtended Program Loader) images to reduce size and complexity in the early boot stage.

---
 board/ti/common/Makefile | 2 ++
 1 file changed, 2 insertions(+)
board/ti/common/Makefile +2 -0
index caf6b9fa8c1..ec8d314c332 100644
@@ -2,6 +2,8 @@
 # Copyright (C) 2015-2016 Texas Instruments Incorporated - https://www.ti.com/
 
 obj-${CONFIG_TI_I2C_BOARD_DETECT} += board_detect.o
+ifndef CONFIG_XPL_BUILD
 obj-${CONFIG_CMD_EXTENSION} += cape_detect.o
+endif
 obj-${CONFIG_OF_LIBFDT} += fdt_ops.o
 obj-${CONFIG_ARCH_K3} += k3-ddr.o
Signature · 1 line
2.43.0
#5 lore raw

Re: [PATCH 04/16] board: ti: Exclude cape detection from XPL builds

Quoted 13 lines · Kory Maincent

Disable cape detection functionality in XPL (eXtended Program Loader) images to reduce size and complexity in the early boot stage.

---
 board/ti/common/Makefile | 2 ++
 1 file changed, 2 insertions(+)
board/ti/common/Makefile +0 -0
index caf6b9fa8c1..ec8d314c332 100644

board/ti/common/Makefile line 9

Quoted 8 lines
board/ti/common/Makefile +2 -0
@@ -2,6 +2,8 @@
 # Copyright (C) 2015-2016 Texas Instruments Incorporated - https://www.ti.com/
 
 obj-${CONFIG_TI_I2C_BOARD_DETECT} += board_detect.o
+ifndef CONFIG_XPL_BUILD
 obj-${CONFIG_CMD_EXTENSION} += cape_detect.o
+endif
 obj-${CONFIG_OF_LIBFDT} += fdt_ops.o
 obj-${CONFIG_ARCH_K3} += k3-ddr.o

Either here, or maybe later in the series when removing then-legacy code, this should use one of the other non-CMD options and if needed, instead of gating with checking for CONFIG_XPL_BUILD, obj-$(CONFIG_$(PHASE_)FOO) will make things easier in a future where we do need to handle extensions in some xPL phase.

Signature · 1 line
Tom
#6 lore raw

PATCH 5/16 board: ti: Refactor cape detection code for readability

In reply to Kory Maincent

Clean up and reorganize cape detection code structure for improved maintainability and readability.

---
 board/ti/common/cape_detect.c | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)
board/ti/common/cape_detect.c +19 -17
index da805befabc..7786bdda5d1 100644
@@ -24,19 +24,18 @@ static void sanitize_field(char *text, size_t size)
 
 int extension_board_scan(struct list_head *extension_list)
 {
-	struct extension *cape;
-	struct am335x_cape_eeprom_id eeprom_header;
-
-	int num_capes = 0;
-	int ret, i;
-	struct udevice *dev;
 	unsigned char addr;
-
-	char process_cape_part_number[17] = {'0'};
-	char process_cape_version[5] = {'0'};
-	uint8_t cursor = 0;
+	int num_capes = 0;
 
 	for (addr = CAPE_EEPROM_FIRST_ADDR; addr <= CAPE_EEPROM_LAST_ADDR; addr++) {
+		struct am335x_cape_eeprom_id eeprom_header;
+		char process_cape_part_number[17] = {'0'};
+		char process_cape_version[5] = {'0'};
+		struct extension *cape;
+		struct udevice *dev;
+		u8 cursor = 0;
+		int ret, i;
+
 		ret = i2c_get_chip_for_busnum(CONFIG_CAPE_EEPROM_BUS_NUM, addr, 1, &dev);
 		if (ret)
 			continue;
@@ -59,8 +58,8 @@ int extension_board_scan(struct list_head *extension_list)
 		sanitize_field(eeprom_header.part_number, sizeof(eeprom_header.part_number));
 
 		/* Process cape part_number */
-		memset(process_cape_part_number, 0, sizeof(process_cape_part_number));
-		strncpy(process_cape_part_number, eeprom_header.part_number, 16);
+		strlcpy(process_cape_part_number, eeprom_header.part_number,
+			sizeof(process_cape_part_number));
 		/* Some capes end with '.' */
 		for (i = 15; i >= 0; i--) {
 			if (process_cape_part_number[i] == '.')
@@ -70,8 +69,8 @@ int extension_board_scan(struct list_head *extension_list)
 		}
 
 		/* Process cape version */
-		memset(process_cape_version, 0, sizeof(process_cape_version));
-		strncpy(process_cape_version, eeprom_header.version, 4);
+		strlcpy(process_cape_version, eeprom_header.version,
+			sizeof(process_cape_version));
 		for (i = 0; i < 4; i++) {
 			if (process_cape_version[i] == 0)
 				process_cape_version[i] = '0';
@@ -87,9 +86,12 @@ int extension_board_scan(struct list_head *extension_list)
 
 		snprintf(cape->overlay, sizeof(cape->overlay), "%s-%s.dtbo",
 			 process_cape_part_number, process_cape_version);
-		strncpy(cape->name, eeprom_header.board_name, 32);
-		strncpy(cape->version, process_cape_version, 4);
-		strncpy(cape->owner, eeprom_header.manufacturer, 16);
+		strlcpy(cape->name, eeprom_header.board_name,
+			sizeof(eeprom_header.board_name));
+		strlcpy(cape->version, process_cape_version,
+			sizeof(process_cape_version));
+		strlcpy(cape->owner, eeprom_header.manufacturer,
+			sizeof(eeprom_header.manufacturer) + 1);
 		list_add_tail(&cape->list, extension_list);
 		num_capes++;
 	}
Signature · 1 line
2.43.0
#7 lore raw

PATCH 6/16 board: ti: Convert cape detection to use UCLASS framework

In reply to Kory Maincent

Migrate TI board cape detection from legacy extension support to the new UCLASS-based extension board framework.

---
 arch/arm/mach-omap2/am33xx/Kconfig |  2 +-
 arch/arm/mach-omap2/omap5/Kconfig  |  2 +-
 board/ti/common/cape_detect.c      | 24 +++++++++++-------------
 3 files changed, 13 insertions(+), 15 deletions(-)
arch/arm/mach-omap2/am33xx/Kconfig +1 -1
index dff4f1cf202..77f7938305b 100644
@@ -15,7 +15,7 @@ config TARGET_AM335X_EVM
 	select DM_GPIO
 	select DM_SERIAL
 	select TI_I2C_BOARD_DETECT
-	select SUPPORT_EXTENSION_SCAN
+	select SUPPORT_DM_EXTENSION_SCAN
 	imply CMD_DM
 	imply SPL_DM
 	imply SPL_DM_SEQ_ALIAS
arch/arm/mach-omap2/omap5/Kconfig +1 -1
index 5394529658b..819490a8cf8 100644
@@ -38,7 +38,7 @@ config TARGET_AM57XX_EVM
 	select CMD_DDR3
 	select DRA7XX
 	select TI_I2C_BOARD_DETECT
-	select SUPPORT_EXTENSION_SCAN
+	select SUPPORT_DM_EXTENSION_SCAN
 	imply DM_THERMAL
 	imply SCSI
 	imply SPL_THERMAL
board/ti/common/cape_detect.c +11 -13
index 7786bdda5d1..23c93964dc3 100644
@@ -22,7 +22,7 @@ static void sanitize_field(char *text, size_t size)
 	}
 }
 
-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct alist *extension_list)
 {
 	unsigned char addr;
 	int num_capes = 0;
@@ -31,7 +31,7 @@ int extension_board_scan(struct list_head *extension_list)
 		struct am335x_cape_eeprom_id eeprom_header;
 		char process_cape_part_number[17] = {'0'};
 		char process_cape_version[5] = {'0'};
-		struct extension *cape;
+		struct extension cape = {0}, *_cape;
 		struct udevice *dev;
 		u8 cursor = 0;
 		int ret, i;
@@ -78,22 +78,20 @@ int extension_board_scan(struct list_head *extension_list)
 
 		printf("BeagleBone Cape: %s (0x%x)\n", eeprom_header.board_name, addr);
 
-		cape = calloc(1, sizeof(struct extension));
-		if (!cape) {
-			printf("Error in memory allocation\n");
-			return num_capes;
-		}
-
-		snprintf(cape->overlay, sizeof(cape->overlay), "%s-%s.dtbo",
+		snprintf(cape.overlay, sizeof(cape.overlay), "%s-%s.dtbo",
 			 process_cape_part_number, process_cape_version);
-		strlcpy(cape->name, eeprom_header.board_name,
+		strlcpy(cape.name, eeprom_header.board_name,
 			sizeof(eeprom_header.board_name));
-		strlcpy(cape->version, process_cape_version,
+		strlcpy(cape.version, process_cape_version,
 			sizeof(process_cape_version));
-		strlcpy(cape->owner, eeprom_header.manufacturer,
+		strlcpy(cape.owner, eeprom_header.manufacturer,
 			sizeof(eeprom_header.manufacturer) + 1);
-		list_add_tail(&cape->list, extension_list);
+		_cape = alist_add(extension_list, cape);
+		if (!_cape)
+			return -ENOMEM;
 		num_capes++;
 	}
 	return num_capes;
 }
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);
Signature · 1 line
2.43.0
#8 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

Hi Kory,

board/ti/common/cape_detect.c int extension_board_scan(struct list_head *extension_list)

Quoted 60 lines · Kory Maincent

Migrate TI board cape detection from legacy extension support to the new UCLASS-based extension board framework.

---
 arch/arm/mach-omap2/am33xx/Kconfig |  2 +-
 arch/arm/mach-omap2/omap5/Kconfig  |  2 +-
 board/ti/common/cape_detect.c      | 24 +++++++++++-------------
 3 files changed, 13 insertions(+), 15 deletions(-)
arch/arm/mach-omap2/am33xx/Kconfig +1 -1
index dff4f1cf202..77f7938305b 100644
@@ -15,7 +15,7 @@ config TARGET_AM335X_EVM
        select DM_GPIO
        select DM_SERIAL
        select TI_I2C_BOARD_DETECT
-       select SUPPORT_EXTENSION_SCAN
+       select SUPPORT_DM_EXTENSION_SCAN
        imply CMD_DM
        imply SPL_DM
        imply SPL_DM_SEQ_ALIAS
arch/arm/mach-omap2/omap5/Kconfig +1 -1
index 5394529658b..819490a8cf8 100644
@@ -38,7 +38,7 @@ config TARGET_AM57XX_EVM
        select CMD_DDR3
        select DRA7XX
        select TI_I2C_BOARD_DETECT
-       select SUPPORT_EXTENSION_SCAN
+       select SUPPORT_DM_EXTENSION_SCAN
        imply DM_THERMAL
        imply SCSI
        imply SPL_THERMAL
board/ti/common/cape_detect.c +2 -2
index 7786bdda5d1..23c93964dc3 100644
@@ -22,7 +22,7 @@ static void sanitize_field(char *text, size_t size)
        }
 }
 
-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct alist *extension_list)
 {
        unsigned char addr;
        int num_capes = 0;
@@ -31,7 +31,7 @@ int extension_board_scan(struct list_head *extension_list)
                struct am335x_cape_eeprom_id eeprom_header;
                char process_cape_part_number[17] = {'0'};
                char process_cape_version[5] = {'0'};
-               struct extension *cape;
+               struct extension cape = {0}, *_cape;
                struct udevice *dev;
                u8 cursor = 0;
                int ret, i;
@@ -78,22 +78,20 @@ int extension_board_scan(struct list_head *extension_list)

I suppose that a method called scan() could be added to the uclass and implemented by this driver.

Quoted 21 lines
board/ti/common/cape_detect.c +4 -10
                printf("BeagleBone Cape: %s (0x%x)\n", eeprom_header.board_name, addr);
 
-               cape = calloc(1, sizeof(struct extension));
-               if (!cape) {
-                       printf("Error in memory allocation\n");
-                       return num_capes;
-               }
-
-               snprintf(cape->overlay, sizeof(cape->overlay), "%s-%s.dtbo",
+               snprintf(cape.overlay, sizeof(cape.overlay), "%s-%s.dtbo",
                         process_cape_part_number, process_cape_version);
-               strlcpy(cape->name, eeprom_header.board_name,
+               strlcpy(cape.name, eeprom_header.board_name,
                        sizeof(eeprom_header.board_name));
-               strlcpy(cape->version, process_cape_version,
+               strlcpy(cape.version, process_cape_version,
                        sizeof(process_cape_version));
-               strlcpy(cape->owner, eeprom_header.manufacturer,
+               strlcpy(cape.owner, eeprom_header.manufacturer,
                        sizeof(eeprom_header.manufacturer) + 1);

board/ti/common/cape_detect.c int extension_board_scan(struct list_head *extension_list) · line 97

Quoted 10 lines
board/ti/common/cape_detect.c +5 -1
-               list_add_tail(&cape->list, extension_list);
+               _cape = alist_add(extension_list, cape);
+               if (!_cape)
+                       return -ENOMEM;
                num_capes++;
        }
        return num_capes;
 }
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);

Can the extension information go in the devicetree, so boards can select their scheme that way?

Quoted 4 lines
board/ti/common/cape_detect.c +0 -1
--

2.43.0

Regards.
So,pm

#9 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

Quoted 93 lines · Simon Glass

Hi Kory,

board/ti/common/cape_detect.c int extension_board_scan(struct list_head *extension_list)

Quoted 60 lines · Kory Maincent

Migrate TI board cape detection from legacy extension support to the new UCLASS-based extension board framework.

---
 arch/arm/mach-omap2/am33xx/Kconfig |  2 +-
 arch/arm/mach-omap2/omap5/Kconfig  |  2 +-
 board/ti/common/cape_detect.c      | 24 +++++++++++-------------
 3 files changed, 13 insertions(+), 15 deletions(-)
arch/arm/mach-omap2/am33xx/Kconfig +1 -1
index dff4f1cf202..77f7938305b 100644
@@ -15,7 +15,7 @@ config TARGET_AM335X_EVM
        select DM_GPIO
        select DM_SERIAL
        select TI_I2C_BOARD_DETECT
-       select SUPPORT_EXTENSION_SCAN
+       select SUPPORT_DM_EXTENSION_SCAN
        imply CMD_DM
        imply SPL_DM
        imply SPL_DM_SEQ_ALIAS
arch/arm/mach-omap2/omap5/Kconfig +1 -1
index 5394529658b..819490a8cf8 100644
@@ -38,7 +38,7 @@ config TARGET_AM57XX_EVM
        select CMD_DDR3
        select DRA7XX
        select TI_I2C_BOARD_DETECT
-       select SUPPORT_EXTENSION_SCAN
+       select SUPPORT_DM_EXTENSION_SCAN
        imply DM_THERMAL
        imply SCSI
        imply SPL_THERMAL
board/ti/common/cape_detect.c +2 -2
index 7786bdda5d1..23c93964dc3 100644
@@ -22,7 +22,7 @@ static void sanitize_field(char *text, size_t size)
        }
 }
 
-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct alist *extension_list)
 {
        unsigned char addr;
        int num_capes = 0;
@@ -31,7 +31,7 @@ int extension_board_scan(struct list_head *extension_list)
                struct am335x_cape_eeprom_id eeprom_header;
                char process_cape_part_number[17] = {'0'};
                char process_cape_version[5] = {'0'};
-               struct extension *cape;
+               struct extension cape = {0}, *_cape;
                struct udevice *dev;
                u8 cursor = 0;
                int ret, i;
@@ -78,22 +78,20 @@ int extension_board_scan(struct list_head *extension_list)

I suppose that a method called scan() could be added to the uclass and implemented by this driver.

Quoted 26 lines
board/ti/common/cape_detect.c +7 -11
                printf("BeagleBone Cape: %s (0x%x)\n", eeprom_header.board_name, addr);
 
-               cape = calloc(1, sizeof(struct extension));
-               if (!cape) {
-                       printf("Error in memory allocation\n");
-                       return num_capes;
-               }
-
-               snprintf(cape->overlay, sizeof(cape->overlay), "%s-%s.dtbo",
+               snprintf(cape.overlay, sizeof(cape.overlay), "%s-%s.dtbo",
                         process_cape_part_number, process_cape_version);
-               strlcpy(cape->name, eeprom_header.board_name,
+               strlcpy(cape.name, eeprom_header.board_name,
                        sizeof(eeprom_header.board_name));
-               strlcpy(cape->version, process_cape_version,
+               strlcpy(cape.version, process_cape_version,
                        sizeof(process_cape_version));
-               strlcpy(cape->owner, eeprom_header.manufacturer,
+               strlcpy(cape.owner, eeprom_header.manufacturer,
                        sizeof(eeprom_header.manufacturer) + 1);
-               list_add_tail(&cape->list, extension_list);
+               _cape = alist_add(extension_list, cape);
+               if (!_cape)
+                       return -ENOMEM;
                num_capes++;
Quoted 8 lines

board/ti/common/cape_detect.c int extension_board_scan(struct list_head *extension_list) · line 97

Quoted 5 lines
board/ti/common/cape_detect.c +2 -0
        }
        return num_capes;
 }
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);

Can the extension information go in the devicetree, so boards can select their scheme that way?

Since we're scanning to see what extension boards are present and so what device tree overlays to apply, I don't think that can work?

Signature · 1 line
Tom
#10 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

Hi Tom,

Quoted 104 lines · Tom Rini
Quoted 93 lines · Simon Glass

Hi Kory,

board/ti/common/cape_detect.c int extension_board_scan(struct list_head *extension_list)

Quoted 60 lines · Kory Maincent

Migrate TI board cape detection from legacy extension support to the new UCLASS-based extension board framework.

---
 arch/arm/mach-omap2/am33xx/Kconfig |  2 +-
 arch/arm/mach-omap2/omap5/Kconfig  |  2 +-
 board/ti/common/cape_detect.c      | 24 +++++++++++-------------
 3 files changed, 13 insertions(+), 15 deletions(-)
arch/arm/mach-omap2/am33xx/Kconfig +1 -1
index dff4f1cf202..77f7938305b 100644
@@ -15,7 +15,7 @@ config TARGET_AM335X_EVM
        select DM_GPIO
        select DM_SERIAL
        select TI_I2C_BOARD_DETECT
-       select SUPPORT_EXTENSION_SCAN
+       select SUPPORT_DM_EXTENSION_SCAN
        imply CMD_DM
        imply SPL_DM
        imply SPL_DM_SEQ_ALIAS
arch/arm/mach-omap2/omap5/Kconfig +1 -1
index 5394529658b..819490a8cf8 100644
@@ -38,7 +38,7 @@ config TARGET_AM57XX_EVM
        select CMD_DDR3
        select DRA7XX
        select TI_I2C_BOARD_DETECT
-       select SUPPORT_EXTENSION_SCAN
+       select SUPPORT_DM_EXTENSION_SCAN
        imply DM_THERMAL
        imply SCSI
        imply SPL_THERMAL
board/ti/common/cape_detect.c +2 -2
index 7786bdda5d1..23c93964dc3 100644
@@ -22,7 +22,7 @@ static void sanitize_field(char *text, size_t size)
        }
 }
 
-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct alist *extension_list)
 {
        unsigned char addr;
        int num_capes = 0;
@@ -31,7 +31,7 @@ int extension_board_scan(struct list_head *extension_list)
                struct am335x_cape_eeprom_id eeprom_header;
                char process_cape_part_number[17] = {'0'};
                char process_cape_version[5] = {'0'};
-               struct extension *cape;
+               struct extension cape = {0}, *_cape;
                struct udevice *dev;
                u8 cursor = 0;
                int ret, i;
@@ -78,22 +78,20 @@ int extension_board_scan(struct list_head *extension_list)

I suppose that a method called scan() could be added to the uclass and implemented by this driver.

Quoted 26 lines
board/ti/common/cape_detect.c +7 -11
                printf("BeagleBone Cape: %s (0x%x)\n", eeprom_header.board_name, addr);
 
-               cape = calloc(1, sizeof(struct extension));
-               if (!cape) {
-                       printf("Error in memory allocation\n");
-                       return num_capes;
-               }
-
-               snprintf(cape->overlay, sizeof(cape->overlay), "%s-%s.dtbo",
+               snprintf(cape.overlay, sizeof(cape.overlay), "%s-%s.dtbo",
                         process_cape_part_number, process_cape_version);
-               strlcpy(cape->name, eeprom_header.board_name,
+               strlcpy(cape.name, eeprom_header.board_name,
                        sizeof(eeprom_header.board_name));
-               strlcpy(cape->version, process_cape_version,
+               strlcpy(cape.version, process_cape_version,
                        sizeof(process_cape_version));
-               strlcpy(cape->owner, eeprom_header.manufacturer,
+               strlcpy(cape.owner, eeprom_header.manufacturer,
                        sizeof(eeprom_header.manufacturer) + 1);
-               list_add_tail(&cape->list, extension_list);
+               _cape = alist_add(extension_list, cape);
+               if (!_cape)
+                       return -ENOMEM;
                num_capes++;
Quoted 8 lines

board/ti/common/cape_detect.c int extension_board_scan(struct list_head *extension_list) · line 97

Quoted 5 lines
board/ti/common/cape_detect.c +2 -0
        }
        return num_capes;
 }
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);

Can the extension information go in the devicetree, so boards can select their scheme that way?

Quoted 2 lines

Since we're scanning to see what extension boards are present and so what device tree overlays to apply, I don't think that can work?

My understanding is that the scanning process is board-specific. For example we would not want the Beagle mechanism to be compiled into rpi. The idea of scanning things in a board-specific way seems like a driver to me. Note there is also the SYSINFO uclass which can do similar things.

The overlays being applied here are additions to what should already be a fairly complete devicetree.

If this isn't possible, then where is the information known?

Regards,
SImon

#11 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

Quoted 116 lines · Simon Glass

Hi Tom,

Quoted 104 lines · Tom Rini
Quoted 93 lines · Simon Glass

Hi Kory,

board/ti/common/cape_detect.c int extension_board_scan(struct list_head *extension_list)

Quoted 60 lines · Kory Maincent

Migrate TI board cape detection from legacy extension support to the new UCLASS-based extension board framework.

---
 arch/arm/mach-omap2/am33xx/Kconfig |  2 +-
 arch/arm/mach-omap2/omap5/Kconfig  |  2 +-
 board/ti/common/cape_detect.c      | 24 +++++++++++-------------
 3 files changed, 13 insertions(+), 15 deletions(-)
arch/arm/mach-omap2/am33xx/Kconfig +1 -1
index dff4f1cf202..77f7938305b 100644
@@ -15,7 +15,7 @@ config TARGET_AM335X_EVM
        select DM_GPIO
        select DM_SERIAL
        select TI_I2C_BOARD_DETECT
-       select SUPPORT_EXTENSION_SCAN
+       select SUPPORT_DM_EXTENSION_SCAN
        imply CMD_DM
        imply SPL_DM
        imply SPL_DM_SEQ_ALIAS
arch/arm/mach-omap2/omap5/Kconfig +1 -1
index 5394529658b..819490a8cf8 100644
@@ -38,7 +38,7 @@ config TARGET_AM57XX_EVM
        select CMD_DDR3
        select DRA7XX
        select TI_I2C_BOARD_DETECT
-       select SUPPORT_EXTENSION_SCAN
+       select SUPPORT_DM_EXTENSION_SCAN
        imply DM_THERMAL
        imply SCSI
        imply SPL_THERMAL
board/ti/common/cape_detect.c +2 -2
index 7786bdda5d1..23c93964dc3 100644
@@ -22,7 +22,7 @@ static void sanitize_field(char *text, size_t size)
        }
 }
 
-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct alist *extension_list)
 {
        unsigned char addr;
        int num_capes = 0;
@@ -31,7 +31,7 @@ int extension_board_scan(struct list_head *extension_list)
                struct am335x_cape_eeprom_id eeprom_header;
                char process_cape_part_number[17] = {'0'};
                char process_cape_version[5] = {'0'};
-               struct extension *cape;
+               struct extension cape = {0}, *_cape;
                struct udevice *dev;
                u8 cursor = 0;
                int ret, i;
@@ -78,22 +78,20 @@ int extension_board_scan(struct list_head *extension_list)

I suppose that a method called scan() could be added to the uclass and implemented by this driver.

Quoted 26 lines
board/ti/common/cape_detect.c +7 -11
                printf("BeagleBone Cape: %s (0x%x)\n", eeprom_header.board_name, addr);
 
-               cape = calloc(1, sizeof(struct extension));
-               if (!cape) {
-                       printf("Error in memory allocation\n");
-                       return num_capes;
-               }
-
-               snprintf(cape->overlay, sizeof(cape->overlay), "%s-%s.dtbo",
+               snprintf(cape.overlay, sizeof(cape.overlay), "%s-%s.dtbo",
                         process_cape_part_number, process_cape_version);
-               strlcpy(cape->name, eeprom_header.board_name,
+               strlcpy(cape.name, eeprom_header.board_name,
                        sizeof(eeprom_header.board_name));
-               strlcpy(cape->version, process_cape_version,
+               strlcpy(cape.version, process_cape_version,
                        sizeof(process_cape_version));
-               strlcpy(cape->owner, eeprom_header.manufacturer,
+               strlcpy(cape.owner, eeprom_header.manufacturer,
                        sizeof(eeprom_header.manufacturer) + 1);
-               list_add_tail(&cape->list, extension_list);
+               _cape = alist_add(extension_list, cape);
+               if (!_cape)
+                       return -ENOMEM;
                num_capes++;
Quoted 8 lines

board/ti/common/cape_detect.c int extension_board_scan(struct list_head *extension_list) · line 97

Quoted 5 lines
board/ti/common/cape_detect.c +2 -0
        }
        return num_capes;
 }
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);

Can the extension information go in the devicetree, so boards can select their scheme that way?

Quoted 2 lines

Since we're scanning to see what extension boards are present and so what device tree overlays to apply, I don't think that can work?

My understanding is that the scanning process is board-specific. For example we would not want the Beagle mechanism to be compiled into rpi. The idea of scanning things in a board-specific way seems like a driver to me. Note there is also the SYSINFO uclass which can do similar things.

Quoted 4 lines

The overlays being applied here are additions to what should already be a fairly complete devicetree.

If this isn't possible, then where is the information known?

You're commenting on a patch to the TI specific code, that's only used by TI SoC using platforms that opt-in to the externally defined EEPROM format for these "capes". Perhaps your feedback would make more sense in some other part of the patch series? But even then, I'm not sure it makes sense?

Signature · 1 line
Tom
#12 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

Quoted 15 lines · On Mon, 6 Oct 2025 17:42:40 -0600 Tom Rini <[email protected]> wrote:
Quoted 14 lines · Simon Glass

Hi Tom,

Quoted 11 lines · Tom Rini
Quoted 9 lines · Simon Glass

Hi Kory,

Quoted 5 lines · Kory Maincent

Migrate TI board cape detection from legacy extension support to the new UCLASS-based extension board framework.

...

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
board/ti/common/cape_detect.c +2 -2
-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct alist *extension_list)
 {
        unsigned char addr;
        int num_capes = 0;
@@ -31,7 +31,7 @@ int extension_board_scan(struct list_head
 *extension_list) struct am335x_cape_eeprom_id eeprom_header;
                char process_cape_part_number[17] = {'0'};
                char process_cape_version[5] = {'0'};
-               struct extension *cape;
+               struct extension cape = {0}, *_cape;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

board/ti/common/cape_detect.c int extension_board_scan(struct list_head · line 78

Quoted 5 lines
board/ti/common/cape_detect.c +0 -0
                struct udevice *dev;
                u8 cursor = 0;
                int ret, i;
@@ -78,22 +78,20 @@ int extension_board_scan(struct list_head
 *extension_list)  

I suppose that a method called scan() could be added to the uclass and implemented by this driver.

I don't understand what do you mean by method? Is it different to the UBOOT driver scan ops I have designed?

Quoted 45 lines
Quoted 45 lines
Quoted 36 lines
Quoted 27 lines
Quoted 27 lines
board/ti/common/cape_detect.c +7 -11
                printf("BeagleBone Cape: %s (0x%x)\n",
 eeprom_header.board_name, addr);
 
-               cape = calloc(1, sizeof(struct extension));
-               if (!cape) {
-                       printf("Error in memory allocation\n");
-                       return num_capes;
-               }
-
-               snprintf(cape->overlay, sizeof(cape->overlay),
 "%s-%s.dtbo",
+               snprintf(cape.overlay, sizeof(cape.overlay),
 "%s-%s.dtbo", process_cape_part_number, process_cape_version);
-               strlcpy(cape->name, eeprom_header.board_name,
+               strlcpy(cape.name, eeprom_header.board_name,
                        sizeof(eeprom_header.board_name));
-               strlcpy(cape->version, process_cape_version,
+               strlcpy(cape.version, process_cape_version,
                        sizeof(process_cape_version));
-               strlcpy(cape->owner, eeprom_header.manufacturer,
+               strlcpy(cape.owner, eeprom_header.manufacturer,
                        sizeof(eeprom_header.manufacturer) + 1);
-               list_add_tail(&cape->list, extension_list);
+               _cape = alist_add(extension_list, cape);
+               if (!_cape)
+                       return -ENOMEM;
                num_capes++;
Quoted 8 lines

board/ti/common/cape_detect.c int extension_board_scan(struct list_head *extension_list) · line 97

Quoted 5 lines
board/ti/common/cape_detect.c +2 -0
        }
        return num_capes;
 }
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);  

Can the extension information go in the devicetree, so boards can select their scheme that way?

Quoted 2 lines

Since we're scanning to see what extension boards are present and so what device tree overlays to apply, I don't think that can work?

My understanding is that the scanning process is board-specific. For example we would not want the Beagle mechanism to be compiled into rpi. The idea of scanning things in a board-specific way seems like a driver to me. Note there is also the SYSINFO uclass which can do similar things.

Quoted 4 lines
Quoted 4 lines

The overlays being applied here are additions to what should already be a fairly complete devicetree.

If this isn't possible, then where is the information known?

Oh, so you would prefer to have something like the sysinfo drivers.

Quoted 5 lines

You're commenting on a patch to the TI specific code, that's only used by TI SoC using platforms that opt-in to the externally defined EEPROM format for these "capes". Perhaps your feedback would make more sense in some other part of the patch series? But even then, I'm not sure it makes sense?

I am ok to move the cape scan detection code to a standalone driver with a devicetree compatible match. Just wondering what are the advantages to use standalone drivers instead of having the code in the specific board code as done in this series.

Regards,

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#13 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

Quoted 102 lines · Kory Maincent
Quoted 15 lines · On Mon, 6 Oct 2025 17:42:40 -0600 Tom Rini <[email protected]> wrote:
Quoted 14 lines · Simon Glass

Hi Tom,

Quoted 11 lines · Tom Rini
Quoted 9 lines · Simon Glass

Hi Kory,

Quoted 5 lines · Kory Maincent

Migrate TI board cape detection from legacy extension support to the new UCLASS-based extension board framework.

...

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
board/ti/common/cape_detect.c +2 -2
-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct alist *extension_list)
 {
        unsigned char addr;
        int num_capes = 0;
@@ -31,7 +31,7 @@ int extension_board_scan(struct list_head
 *extension_list) struct am335x_cape_eeprom_id eeprom_header;
                char process_cape_part_number[17] = {'0'};
                char process_cape_version[5] = {'0'};
-               struct extension *cape;
+               struct extension cape = {0}, *_cape;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

board/ti/common/cape_detect.c int extension_board_scan(struct list_head · line 78

Quoted 5 lines
board/ti/common/cape_detect.c +0 -0
                struct udevice *dev;
                u8 cursor = 0;
                int ret, i;
@@ -78,22 +78,20 @@ int extension_board_scan(struct list_head
 *extension_list)  

I suppose that a method called scan() could be added to the uclass and implemented by this driver.

I don't understand what do you mean by method? Is it different to the UBOOT driver scan ops I have designed?

Quoted 45 lines
Quoted 45 lines
Quoted 36 lines
Quoted 27 lines
Quoted 27 lines
board/ti/common/cape_detect.c +7 -11
                printf("BeagleBone Cape: %s (0x%x)\n",
 eeprom_header.board_name, addr);
 
-               cape = calloc(1, sizeof(struct extension));
-               if (!cape) {
-                       printf("Error in memory allocation\n");
-                       return num_capes;
-               }
-
-               snprintf(cape->overlay, sizeof(cape->overlay),
 "%s-%s.dtbo",
+               snprintf(cape.overlay, sizeof(cape.overlay),
 "%s-%s.dtbo", process_cape_part_number, process_cape_version);
-               strlcpy(cape->name, eeprom_header.board_name,
+               strlcpy(cape.name, eeprom_header.board_name,
                        sizeof(eeprom_header.board_name));
-               strlcpy(cape->version, process_cape_version,
+               strlcpy(cape.version, process_cape_version,
                        sizeof(process_cape_version));
-               strlcpy(cape->owner, eeprom_header.manufacturer,
+               strlcpy(cape.owner, eeprom_header.manufacturer,
                        sizeof(eeprom_header.manufacturer) + 1);
-               list_add_tail(&cape->list, extension_list);
+               _cape = alist_add(extension_list, cape);
+               if (!_cape)
+                       return -ENOMEM;
                num_capes++;
Quoted 8 lines

board/ti/common/cape_detect.c int extension_board_scan(struct list_head *extension_list) · line 97

Quoted 5 lines
board/ti/common/cape_detect.c +2 -0
        }
        return num_capes;
 }
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);  

Can the extension information go in the devicetree, so boards can select their scheme that way?

Quoted 2 lines

Since we're scanning to see what extension boards are present and so what device tree overlays to apply, I don't think that can work?

My understanding is that the scanning process is board-specific. For example we would not want the Beagle mechanism to be compiled into rpi. The idea of scanning things in a board-specific way seems like a driver to me. Note there is also the SYSINFO uclass which can do similar things.

Quoted 4 lines
Quoted 4 lines

The overlays being applied here are additions to what should already be a fairly complete devicetree.

If this isn't possible, then where is the information known?

Oh, so you would prefer to have something like the sysinfo drivers.

Quoted 5 lines

You're commenting on a patch to the TI specific code, that's only used by TI SoC using platforms that opt-in to the externally defined EEPROM format for these "capes". Perhaps your feedback would make more sense in some other part of the patch series? But even then, I'm not sure it makes sense?

Quoted 4 lines

I am ok to move the cape scan detection code to a standalone driver with a devicetree compatible match. Just wondering what are the advantages to use standalone drivers instead of having the code in the specific board code as done in this series.

I'm not sure there is an advantage. Especially since in theory we could have more than one built in, and if ti_extension_board_scan(...) doesn't find anything (because the EEPROM is missing/wrong) we could still then call rpi_extension_board_scan(...) and look for that formatted type of EEPROM and then chipanddip_extension_board_scan(...) and look for that and so forth. These extensions are nominally discoverable and so don't need device tree compatibles, was some of the point of all this I would have sworn...

Signature · 1 line
Tom
#14 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

Quoted 108 lines · On Tue, 7 Oct 2025 08:11:48 -0600 Tom Rini <[email protected]> wrote:
Quoted 102 lines · Kory Maincent
Quoted 15 lines · On Mon, 6 Oct 2025 17:42:40 -0600 Tom Rini <[email protected]> wrote:
Quoted 14 lines · Simon Glass

Hi Tom,

Quoted 11 lines · Tom Rini
Quoted 9 lines · Simon Glass

Hi Kory,

Quoted 5 lines · Kory Maincent

Migrate TI board cape detection from legacy extension support to the new UCLASS-based extension board framework.

...

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
(quoted diff) +2 -2
-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct alist *extension_list)
 {
        unsigned char addr;
        int num_capes = 0;
@@ -31,7 +31,7 @@ int extension_board_scan(struct list_head
 *extension_list) struct am335x_cape_eeprom_id eeprom_header;
                char process_cape_part_number[17] = {'0'};
                char process_cape_version[5] = {'0'};
-               struct extension *cape;
+               struct extension cape = {0}, *_cape;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Review int extension_board_scan(struct list_head · line 78

Quoted 5 lines
(quoted diff) +0 -0
                struct udevice *dev;
                u8 cursor = 0;
                int ret, i;
@@ -78,22 +78,20 @@ int extension_board_scan(struct list_head
 *extension_list)    

I suppose that a method called scan() could be added to the uclass and implemented by this driver.

I don't understand what do you mean by method? Is it different to the UBOOT driver scan ops I have designed?

Quoted 45 lines
Quoted 45 lines
Quoted 36 lines
Quoted 27 lines
Quoted 27 lines
(quoted diff) +7 -11
                printf("BeagleBone Cape: %s (0x%x)\n",
 eeprom_header.board_name, addr);
 
-               cape = calloc(1, sizeof(struct extension));
-               if (!cape) {
-                       printf("Error in memory allocation\n");
-                       return num_capes;
-               }
-
-               snprintf(cape->overlay, sizeof(cape->overlay),
 "%s-%s.dtbo",
+               snprintf(cape.overlay, sizeof(cape.overlay),
 "%s-%s.dtbo", process_cape_part_number, process_cape_version);
-               strlcpy(cape->name, eeprom_header.board_name,
+               strlcpy(cape.name, eeprom_header.board_name,
                        sizeof(eeprom_header.board_name));
-               strlcpy(cape->version, process_cape_version,
+               strlcpy(cape.version, process_cape_version,
                        sizeof(process_cape_version));
-               strlcpy(cape->owner, eeprom_header.manufacturer,
+               strlcpy(cape.owner, eeprom_header.manufacturer,
                        sizeof(eeprom_header.manufacturer) + 1);
-               list_add_tail(&cape->list, extension_list);
+               _cape = alist_add(extension_list, cape);
+               if (!_cape)
+                       return -ENOMEM;
                num_capes++;
Quoted 8 lines

Review int extension_board_scan(struct list_head

Quoted 5 lines
(quoted diff) +2 -0
        }
        return num_capes;
 }
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);    

Can the extension information go in the devicetree, so boards can select their scheme that way?

Quoted 2 lines

Since we're scanning to see what extension boards are present and so what device tree overlays to apply, I don't think that can work?

My understanding is that the scanning process is board-specific. For example we would not want the Beagle mechanism to be compiled into rpi. The idea of scanning things in a board-specific way seems like a driver to me. Note there is also the SYSINFO uclass which can do similar things.

Quoted 4 lines
Quoted 4 lines

The overlays being applied here are additions to what should already be a fairly complete devicetree.

If this isn't possible, then where is the information known?

Oh, so you would prefer to have something like the sysinfo drivers.

Quoted 5 lines

You're commenting on a patch to the TI specific code, that's only used by TI SoC using platforms that opt-in to the externally defined EEPROM format for these "capes". Perhaps your feedback would make more sense in some other part of the patch series? But even then, I'm not sure it makes sense?

Quoted 4 lines

I am ok to move the cape scan detection code to a standalone driver with a devicetree compatible match. Just wondering what are the advantages to use standalone drivers instead of having the code in the specific board code as done in this series.

Quoted 8 lines

I'm not sure there is an advantage. Especially since in theory we could have more than one built in, and if ti_extension_board_scan(...) doesn't find anything (because the EEPROM is missing/wrong) we could still then call rpi_extension_board_scan(...) and look for that formatted type of EEPROM and then chipanddip_extension_board_scan(...) and look for that and so forth. These extensions are nominally discoverable and so don't need device tree compatibles, was some of the point of all this I would have sworn...

I think, he means a driver for each type of custom extension board scan functions (4 until now). The U-boot devicetree would be like this:

extension_scan {
	compatible = "bone-cape-scan"; 
};

We could avoid the build of several extension drivers using Kconfig choice symbol to select only one builtin.

On my side I don't really have opinions, it is a matter of code design. For now I don't see real argument to tilt the balance except to do something like sysinfo. We need more arguments from Simon.

Regards,

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#15 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

Quoted 126 lines · Kory Maincent
Quoted 108 lines · On Tue, 7 Oct 2025 08:11:48 -0600 Tom Rini <[email protected]> wrote:
Quoted 102 lines · Kory Maincent
Quoted 15 lines · On Mon, 6 Oct 2025 17:42:40 -0600 Tom Rini <[email protected]> wrote:
Quoted 14 lines · Simon Glass

Hi Tom,

Quoted 11 lines · Tom Rini
Quoted 9 lines · Simon Glass

Hi Kory,

Quoted 5 lines · Kory Maincent

Migrate TI board cape detection from legacy extension support to the new UCLASS-based extension board framework.

...

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
(quoted diff) +2 -2
-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct alist *extension_list)
 {
        unsigned char addr;
        int num_capes = 0;
@@ -31,7 +31,7 @@ int extension_board_scan(struct list_head
 *extension_list) struct am335x_cape_eeprom_id eeprom_header;
                char process_cape_part_number[17] = {'0'};
                char process_cape_version[5] = {'0'};
-               struct extension *cape;
+               struct extension cape = {0}, *_cape;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Review int extension_board_scan(struct list_head · line 78

Quoted 5 lines
(quoted diff) +0 -0
                struct udevice *dev;
                u8 cursor = 0;
                int ret, i;
@@ -78,22 +78,20 @@ int extension_board_scan(struct list_head
 *extension_list)    

I suppose that a method called scan() could be added to the uclass and implemented by this driver.

I don't understand what do you mean by method? Is it different to the UBOOT driver scan ops I have designed?

Quoted 45 lines
Quoted 45 lines
Quoted 36 lines
Quoted 27 lines
Quoted 27 lines
(quoted diff) +7 -11
                printf("BeagleBone Cape: %s (0x%x)\n",
 eeprom_header.board_name, addr);
 
-               cape = calloc(1, sizeof(struct extension));
-               if (!cape) {
-                       printf("Error in memory allocation\n");
-                       return num_capes;
-               }
-
-               snprintf(cape->overlay, sizeof(cape->overlay),
 "%s-%s.dtbo",
+               snprintf(cape.overlay, sizeof(cape.overlay),
 "%s-%s.dtbo", process_cape_part_number, process_cape_version);
-               strlcpy(cape->name, eeprom_header.board_name,
+               strlcpy(cape.name, eeprom_header.board_name,
                        sizeof(eeprom_header.board_name));
-               strlcpy(cape->version, process_cape_version,
+               strlcpy(cape.version, process_cape_version,
                        sizeof(process_cape_version));
-               strlcpy(cape->owner, eeprom_header.manufacturer,
+               strlcpy(cape.owner, eeprom_header.manufacturer,
                        sizeof(eeprom_header.manufacturer) + 1);
-               list_add_tail(&cape->list, extension_list);
+               _cape = alist_add(extension_list, cape);
+               if (!_cape)
+                       return -ENOMEM;
                num_capes++;
Quoted 8 lines

Review int extension_board_scan(struct list_head

Quoted 5 lines
(quoted diff) +2 -0
        }
        return num_capes;
 }
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);    

Can the extension information go in the devicetree, so boards can select their scheme that way?

Quoted 2 lines

Since we're scanning to see what extension boards are present and so what device tree overlays to apply, I don't think that can work?

My understanding is that the scanning process is board-specific. For example we would not want the Beagle mechanism to be compiled into rpi. The idea of scanning things in a board-specific way seems like a driver to me. Note there is also the SYSINFO uclass which can do similar things.

Quoted 4 lines
Quoted 4 lines

The overlays being applied here are additions to what should already be a fairly complete devicetree.

If this isn't possible, then where is the information known?

Oh, so you would prefer to have something like the sysinfo drivers.

Quoted 5 lines

You're commenting on a patch to the TI specific code, that's only used by TI SoC using platforms that opt-in to the externally defined EEPROM format for these "capes". Perhaps your feedback would make more sense in some other part of the patch series? But even then, I'm not sure it makes sense?

Quoted 4 lines

I am ok to move the cape scan detection code to a standalone driver with a devicetree compatible match. Just wondering what are the advantages to use standalone drivers instead of having the code in the specific board code as done in this series.

Quoted 8 lines

I'm not sure there is an advantage. Especially since in theory we could have more than one built in, and if ti_extension_board_scan(...) doesn't find anything (because the EEPROM is missing/wrong) we could still then call rpi_extension_board_scan(...) and look for that formatted type of EEPROM and then chipanddip_extension_board_scan(...) and look for that and so forth. These extensions are nominally discoverable and so don't need device tree compatibles, was some of the point of all this I would have sworn...

I think, he means a driver for each type of custom extension board scan functions (4 until now). The U-boot devicetree would be like this:

extension_scan {
	compatible = "bone-cape-scan"; 
};
Quoted 6 lines

We could avoid the build of several extension drivers using Kconfig choice symbol to select only one builtin.

On my side I don't really have opinions, it is a matter of code design. For now I don't see real argument to tilt the balance except to do something like sysinfo. We need more arguments from Simon.

Yes, and needing to go back to modifying the device trees seems a step backwards here, and something that will be hard to argue for upstream.

Signature · 1 line
Tom
#16 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

Hi,

Quoted 131 lines · Tom Rini
Quoted 129 lines · Kory Maincent
Quoted 108 lines · On Tue, 7 Oct 2025 08:11:48 -0600 Tom Rini <[email protected]> wrote:
Quoted 102 lines · Kory Maincent
Quoted 15 lines · On Mon, 6 Oct 2025 17:42:40 -0600 Tom Rini <[email protected]> wrote:
Quoted 14 lines · Simon Glass

Hi Tom,

Quoted 11 lines · Tom Rini
Quoted 9 lines · Simon Glass

Hi Kory,

Quoted 5 lines · Kory Maincent

Migrate TI board cape detection from legacy extension support to the new UCLASS-based extension board framework.

...

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
(quoted diff) +2 -2
-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct alist *extension_list)
 {
        unsigned char addr;
        int num_capes = 0;
@@ -31,7 +31,7 @@ int extension_board_scan(struct list_head
 *extension_list) struct am335x_cape_eeprom_id eeprom_header;
                char process_cape_part_number[17] = {'0'};
                char process_cape_version[5] = {'0'};
-               struct extension *cape;
+               struct extension cape = {0}, *_cape;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Review int extension_board_scan(struct list_head · line 78

Quoted 5 lines
(quoted diff) +0 -0
                struct udevice *dev;
                u8 cursor = 0;
                int ret, i;
@@ -78,22 +78,20 @@ int extension_board_scan(struct list_head
 *extension_list)

I suppose that a method called scan() could be added to the uclass and implemented by this driver.

I don't understand what do you mean by method? Is it different to the UBOOT driver scan ops I have designed?

Quoted 45 lines
Quoted 45 lines
Quoted 36 lines
Quoted 27 lines
Quoted 27 lines
(quoted diff) +7 -11
                printf("BeagleBone Cape: %s (0x%x)\n",
 eeprom_header.board_name, addr);
 
-               cape = calloc(1, sizeof(struct extension));
-               if (!cape) {
-                       printf("Error in memory allocation\n");
-                       return num_capes;
-               }
-
-               snprintf(cape->overlay, sizeof(cape->overlay),
 "%s-%s.dtbo",
+               snprintf(cape.overlay, sizeof(cape.overlay),
 "%s-%s.dtbo", process_cape_part_number, process_cape_version);
-               strlcpy(cape->name, eeprom_header.board_name,
+               strlcpy(cape.name, eeprom_header.board_name,
                        sizeof(eeprom_header.board_name));
-               strlcpy(cape->version, process_cape_version,
+               strlcpy(cape.version, process_cape_version,
                        sizeof(process_cape_version));
-               strlcpy(cape->owner, eeprom_header.manufacturer,
+               strlcpy(cape.owner, eeprom_header.manufacturer,
                        sizeof(eeprom_header.manufacturer) + 1);
-               list_add_tail(&cape->list, extension_list);
+               _cape = alist_add(extension_list, cape);
+               if (!_cape)
+                       return -ENOMEM;
                num_capes++;
Quoted 8 lines

Review int extension_board_scan(struct list_head

Quoted 5 lines
(quoted diff) +2 -0
        }
        return num_capes;
 }
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);

Can the extension information go in the devicetree, so boards can select their scheme that way?

Quoted 2 lines

Since we're scanning to see what extension boards are present and so what device tree overlays to apply, I don't think that can work?

My understanding is that the scanning process is board-specific. For example we would not want the Beagle mechanism to be compiled into rpi. The idea of scanning things in a board-specific way seems like a driver to me. Note there is also the SYSINFO uclass which can do similar things.

Quoted 4 lines
Quoted 4 lines

The overlays being applied here are additions to what should already be a fairly complete devicetree.

If this isn't possible, then where is the information known?

Oh, so you would prefer to have something like the sysinfo drivers.

Quoted 5 lines

You're commenting on a patch to the TI specific code, that's only used by TI SoC using platforms that opt-in to the externally defined EEPROM format for these "capes". Perhaps your feedback would make more sense in some other part of the patch series? But even then, I'm not sure it makes sense?

Quoted 4 lines

I am ok to move the cape scan detection code to a standalone driver with a devicetree compatible match. Just wondering what are the advantages to use standalone drivers instead of having the code in the specific board code as done in this series.

Quoted 8 lines

I'm not sure there is an advantage. Especially since in theory we could have more than one built in, and if ti_extension_board_scan(...) doesn't find anything (because the EEPROM is missing/wrong) we could still then call rpi_extension_board_scan(...) and look for that formatted type of EEPROM and then chipanddip_extension_board_scan(...) and look for that and so forth. These extensions are nominally discoverable and so don't need device tree compatibles, was some of the point of all this I would have sworn...

I think, he means a driver for each type of custom extension board scan functions (4 until now). The U-boot devicetree would be like this:

extension_scan {
      compatible = "bone-cape-scan";
};

We could avoid the build of several extension drivers using Kconfig choice symbol to select only one builtin.

Quoted 6 lines
Quoted 3 lines

On my side I don't really have opinions, it is a matter of code design. For now I don't see real argument to tilt the balance except to do something like sysinfo. We need more arguments from Simon.

Yes, and needing to go back to modifying the device trees seems a step backwards here, and something that will be hard to argue for upstream.

How do you define the mechanism to read the cape (etc.) information? Presumably it is using a device which is already in the devicetree? So it is the actual extension mechanism that is not present, perhaps?

How does Linux model extensions?

Regards,
Simon

#17 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

Quoted 134 lines · Simon Glass

Hi,

Quoted 131 lines · Tom Rini
Quoted 129 lines · Kory Maincent
Quoted 108 lines · On Tue, 7 Oct 2025 08:11:48 -0600 Tom Rini <[email protected]> wrote:
Quoted 102 lines · Kory Maincent
Quoted 15 lines · On Mon, 6 Oct 2025 17:42:40 -0600 Tom Rini <[email protected]> wrote:
Quoted 14 lines · Simon Glass

Hi Tom,

Quoted 11 lines · Tom Rini
Quoted 9 lines · Simon Glass

Hi Kory,

Quoted 5 lines · Kory Maincent

Migrate TI board cape detection from legacy extension support to the new UCLASS-based extension board framework.

...

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
(quoted diff) +2 -2
-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct alist *extension_list)
 {
        unsigned char addr;
        int num_capes = 0;
@@ -31,7 +31,7 @@ int extension_board_scan(struct list_head
 *extension_list) struct am335x_cape_eeprom_id eeprom_header;
                char process_cape_part_number[17] = {'0'};
                char process_cape_version[5] = {'0'};
-               struct extension *cape;
+               struct extension cape = {0}, *_cape;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Review int extension_board_scan(struct list_head · line 78

Quoted 5 lines
(quoted diff) +0 -0
                struct udevice *dev;
                u8 cursor = 0;
                int ret, i;
@@ -78,22 +78,20 @@ int extension_board_scan(struct list_head
 *extension_list)

I suppose that a method called scan() could be added to the uclass and implemented by this driver.

I don't understand what do you mean by method? Is it different to the UBOOT driver scan ops I have designed?

Quoted 45 lines
Quoted 45 lines
Quoted 36 lines
Quoted 27 lines
Quoted 27 lines
(quoted diff) +7 -11
                printf("BeagleBone Cape: %s (0x%x)\n",
 eeprom_header.board_name, addr);
 
-               cape = calloc(1, sizeof(struct extension));
-               if (!cape) {
-                       printf("Error in memory allocation\n");
-                       return num_capes;
-               }
-
-               snprintf(cape->overlay, sizeof(cape->overlay),
 "%s-%s.dtbo",
+               snprintf(cape.overlay, sizeof(cape.overlay),
 "%s-%s.dtbo", process_cape_part_number, process_cape_version);
-               strlcpy(cape->name, eeprom_header.board_name,
+               strlcpy(cape.name, eeprom_header.board_name,
                        sizeof(eeprom_header.board_name));
-               strlcpy(cape->version, process_cape_version,
+               strlcpy(cape.version, process_cape_version,
                        sizeof(process_cape_version));
-               strlcpy(cape->owner, eeprom_header.manufacturer,
+               strlcpy(cape.owner, eeprom_header.manufacturer,
                        sizeof(eeprom_header.manufacturer) + 1);
-               list_add_tail(&cape->list, extension_list);
+               _cape = alist_add(extension_list, cape);
+               if (!_cape)
+                       return -ENOMEM;
                num_capes++;
Quoted 8 lines

Review int extension_board_scan(struct list_head

Quoted 5 lines
(quoted diff) +2 -0
        }
        return num_capes;
 }
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);

Can the extension information go in the devicetree, so boards can select their scheme that way?

Quoted 2 lines

Since we're scanning to see what extension boards are present and so what device tree overlays to apply, I don't think that can work?

My understanding is that the scanning process is board-specific. For example we would not want the Beagle mechanism to be compiled into rpi. The idea of scanning things in a board-specific way seems like a driver to me. Note there is also the SYSINFO uclass which can do similar things.

Quoted 4 lines
Quoted 4 lines

The overlays being applied here are additions to what should already be a fairly complete devicetree.

If this isn't possible, then where is the information known?

Oh, so you would prefer to have something like the sysinfo drivers.

Quoted 5 lines

You're commenting on a patch to the TI specific code, that's only used by TI SoC using platforms that opt-in to the externally defined EEPROM format for these "capes". Perhaps your feedback would make more sense in some other part of the patch series? But even then, I'm not sure it makes sense?

Quoted 4 lines

I am ok to move the cape scan detection code to a standalone driver with a devicetree compatible match. Just wondering what are the advantages to use standalone drivers instead of having the code in the specific board code as done in this series.

Quoted 8 lines

I'm not sure there is an advantage. Especially since in theory we could have more than one built in, and if ti_extension_board_scan(...) doesn't find anything (because the EEPROM is missing/wrong) we could still then call rpi_extension_board_scan(...) and look for that formatted type of EEPROM and then chipanddip_extension_board_scan(...) and look for that and so forth. These extensions are nominally discoverable and so don't need device tree compatibles, was some of the point of all this I would have sworn...

I think, he means a driver for each type of custom extension board scan functions (4 until now). The U-boot devicetree would be like this:

extension_scan {
      compatible = "bone-cape-scan";
};

We could avoid the build of several extension drivers using Kconfig choice symbol to select only one builtin.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

On my side I don't really have opinions, it is a matter of code design. For now I don't see real argument to tilt the balance except to do something like sysinfo. We need more arguments from Simon.

Yes, and needing to go back to modifying the device trees seems a step backwards here, and something that will be hard to argue for upstream.

How do you define the mechanism to read the cape (etc.) information?

Well, a cape for the TI platforms has to have a properly formatted EEPROM. I forget how the CHIP/DIP thing worked, but I believe it was similar (since it originated in the same era). I also believe Pi is similar as well.

Quoted 4 lines

Presumably it is using a device which is already in the devicetree? So it is the actual extension mechanism that is not present, perhaps?

How does Linux model extensions?

Last I knew it doesn't and much discussion was had to arrive at that point a decade or so ago. I believe FPGA stuff has been allowed since then, but physical extensions not, and it's a bootloader problem. Which is why we've been solving it for a while (it was more ad-hoc before Kory did the current implementation in 2021).

Signature · 1 line
Tom
#18 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

Quoted 154 lines · On Tue, 7 Oct 2025 14:13:36 -0600 Tom Rini <[email protected]> wrote:
Quoted 153 lines · Simon Glass

Hi,

Quoted 149 lines · Tom Rini
Quoted 138 lines · Kory Maincent
Quoted 119 lines · On Tue, 7 Oct 2025 08:11:48 -0600 Tom Rini <[email protected]> wrote:
Quoted 113 lines · Kory Maincent
Quoted 16 lines · On Mon, 6 Oct 2025 17:42:40 -0600 Tom Rini <[email protected]> wrote:
Quoted 15 lines · Simon Glass

Hi Tom,

Quoted 11 lines · Tom Rini
Quoted 9 lines · Simon Glass

Hi Kory,

Quoted 5 lines · Kory Maincent

Migrate TI board cape detection from legacy extension support to the new UCLASS-based extension board framework.

...

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

-int extension_board_scan(struct list_head
*extension_list) +static int

ti_extension_board_scan(struct alist *extension_list) {
        unsigned char addr;
        int num_capes = 0;
(quoted diff) +0 -0
@@ -31,7 +31,7 @@ int extension_board_scan(struct

list_head *extension_list) struct am335x_cape_eeprom_id

eeprom_header; char process_cape_part_number[17] = {'0'};
                char process_cape_version[5] = {'0'};
(quoted diff) +1 -1
-               struct extension *cape;
+               struct extension cape = {0}, *_cape;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Review int extension_board_scan(struct · line 78

Quoted 5 lines
                struct udevice *dev;
                u8 cursor = 0;
                int ret, i;
(quoted diff) +0 -0
@@ -78,22 +78,20 @@ int extension_board_scan(struct
 list_head *extension_list)  

I suppose that a method called scan() could be added to the uclass and implemented by this driver.

I don't understand what do you mean by method? Is it different to the UBOOT driver scan ops I have designed?

Quoted 55 lines
Quoted 55 lines
Quoted 45 lines
Quoted 36 lines
Quoted 36 lines
(quoted diff) +3 -9
                printf("BeagleBone Cape: %s (0x%x)\n",
 eeprom_header.board_name, addr);
 
-               cape = calloc(1, sizeof(struct
 extension));
-               if (!cape) {
-                       printf("Error in memory
 allocation\n");
-                       return num_capes;
-               }
-
-               snprintf(cape->overlay,
 sizeof(cape->overlay), "%s-%s.dtbo",
+               snprintf(cape.overlay,
 sizeof(cape.overlay), "%s-%s.dtbo",
 process_cape_part_number, process_cape_version);
-               strlcpy(cape->name,
 eeprom_header.board_name,
+               strlcpy(cape.name,
 eeprom_header.board_name,
 sizeof(eeprom_header.board_name));
-               strlcpy(cape->version,
 process_cape_version,
+               strlcpy(cape.version,

process_cape_version, sizeof(process_cape_version));
- strlcpy(cape->owner,
eeprom_header.manufacturer,
+ strlcpy(cape.owner,
eeprom_header.manufacturer, sizeof(eeprom_header.manufacturer) + 1);
- list_add_tail(&cape->list,
extension_list);

(quoted diff) +3 -0
+               _cape = alist_add(extension_list, cape);
+               if (!_cape)
+                       return -ENOMEM;
                num_capes++;
Quoted 8 lines

Review

Quoted 5 lines
        }
        return num_capes;

}

(quoted diff) +2 -0
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);  

Can the extension information go in the devicetree, so boards can select their scheme that way?

Quoted 3 lines

Since we're scanning to see what extension boards are present and so what device tree overlays to apply, I don't think that can work?

My understanding is that the scanning process is board-specific. For example we would not want the Beagle mechanism to be compiled into rpi. The idea of scanning things in a board-specific way seems like a driver to me. Note there is also the SYSINFO uclass which can do similar things.

Quoted 4 lines
Quoted 4 lines

The overlays being applied here are additions to what should already be a fairly complete devicetree.

If this isn't possible, then where is the information known?

Oh, so you would prefer to have something like the sysinfo drivers.

Quoted 5 lines

You're commenting on a patch to the TI specific code, that's only used by TI SoC using platforms that opt-in to the externally defined EEPROM format for these "capes". Perhaps your feedback would make more sense in some other part of the patch series? But even then, I'm not sure it makes sense?

Quoted 4 lines

I am ok to move the cape scan detection code to a standalone driver with a devicetree compatible match. Just wondering what are the advantages to use standalone drivers instead of having the code in the specific board code as done in this series.

Quoted 9 lines

I'm not sure there is an advantage. Especially since in theory we could have more than one built in, and if ti_extension_board_scan(...) doesn't find anything (because the EEPROM is missing/wrong) we could still then call rpi_extension_board_scan(...) and look for that formatted type of EEPROM and then chipanddip_extension_board_scan(...) and look for that and so forth. These extensions are nominally discoverable and so don't need device tree compatibles, was some of the point of all this I would have sworn...

I think, he means a driver for each type of custom extension board scan functions (4 until now). The U-boot devicetree would be like this:

extension_scan {
      compatible = "bone-cape-scan";
};
Quoted 6 lines

We could avoid the build of several extension drivers using Kconfig choice symbol to select only one builtin.

On my side I don't really have opinions, it is a matter of code design. For now I don't see real argument to tilt the balance except to do something like sysinfo. We need more arguments from Simon.

Yes, and needing to go back to modifying the device trees seems a step backwards here, and something that will be hard to argue for upstream.

Quoted 6 lines
Quoted 1 line

How do you define the mechanism to read the cape (etc.) information?

Well, a cape for the TI platforms has to have a properly formatted EEPROM. I forget how the CHIP/DIP thing worked, but I believe it was similar (since it originated in the same era). I also believe Pi is similar as well.

The DIP is detected reading the EEPROMs through the W1 bus. On the imx8mm-cl-iot-gate it is more complicated, it is done on probing devices on specific I2C addresses and reading GPIOs.

Quoted 10 lines
Quoted 4 lines

Presumably it is using a device which is already in the devicetree? So it is the actual extension mechanism that is not present, perhaps?

How does Linux model extensions?

Last I knew it doesn't and much discussion was had to arrive at that point a decade or so ago. I believe FPGA stuff has been allowed since then, but physical extensions not, and it's a bootloader problem. Which is why we've been solving it for a while (it was more ad-hoc before Kory did the current implementation in 2021).

Yes, Linux does not support loading external devicetree overlay, even in FPGA subsystem. Even if the core of loading overlay is present for long ago, the only real driver support has been done recently in PCI by Hervé for two PCI drivers:
https://elixir.bootlin.com/linux/v6.17.1/source/drivers/misc/lan966x_pci.c
https://elixir.bootlin.com/linux/v6.17.1/source/drivers/misc/rp1/rp1_pci.c

Here the devicetree overlays are builtin in the drivers, the aim was to be able to load the overlay from x86 boards.

There is also a Linux discussion (with Hervé and Luca) on the generic way to represent a connector in the devicetree, talking about a way to export devicetree symbols.
After some thought, I don't think we should add something in the devicetree now, and wait for the final connector representation when it will land. Meanwhile we should stick to using board specific code.

It it's ok for you I will send v2 keeping this design.

Regards,

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#19 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

In reply to Tom Rini

Hi Tom,

Quoted 153 lines · Tom Rini
Quoted 134 lines · Simon Glass

Hi,

Quoted 131 lines · Tom Rini
Quoted 129 lines · Kory Maincent
Quoted 108 lines · On Tue, 7 Oct 2025 08:11:48 -0600 Tom Rini <[email protected]> wrote:
Quoted 102 lines · Kory Maincent
Quoted 15 lines · On Mon, 6 Oct 2025 17:42:40 -0600 Tom Rini <[email protected]> wrote:
Quoted 14 lines · Simon Glass

Hi Tom,

Quoted 11 lines · Tom Rini
Quoted 9 lines · Simon Glass

Hi Kory,

Quoted 5 lines · Kory Maincent

Migrate TI board cape detection from legacy extension support to the new UCLASS-based extension board framework.

...

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
(quoted diff) +2 -2
-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct alist *extension_list)
 {
        unsigned char addr;
        int num_capes = 0;
@@ -31,7 +31,7 @@ int extension_board_scan(struct list_head
 *extension_list) struct am335x_cape_eeprom_id eeprom_header;
                char process_cape_part_number[17] = {'0'};
                char process_cape_version[5] = {'0'};
-               struct extension *cape;
+               struct extension cape = {0}, *_cape;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Review int extension_board_scan(struct list_head · line 78

Quoted 5 lines
(quoted diff) +0 -0
                struct udevice *dev;
                u8 cursor = 0;
                int ret, i;
@@ -78,22 +78,20 @@ int extension_board_scan(struct list_head
 *extension_list)

I suppose that a method called scan() could be added to the uclass and implemented by this driver.

I don't understand what do you mean by method? Is it different to the UBOOT driver scan ops I have designed?

Quoted 45 lines
Quoted 45 lines
Quoted 36 lines
Quoted 27 lines
Quoted 27 lines
(quoted diff) +7 -11
                printf("BeagleBone Cape: %s (0x%x)\n",
 eeprom_header.board_name, addr);
 
-               cape = calloc(1, sizeof(struct extension));
-               if (!cape) {
-                       printf("Error in memory allocation\n");
-                       return num_capes;
-               }
-
-               snprintf(cape->overlay, sizeof(cape->overlay),
 "%s-%s.dtbo",
+               snprintf(cape.overlay, sizeof(cape.overlay),
 "%s-%s.dtbo", process_cape_part_number, process_cape_version);
-               strlcpy(cape->name, eeprom_header.board_name,
+               strlcpy(cape.name, eeprom_header.board_name,
                        sizeof(eeprom_header.board_name));
-               strlcpy(cape->version, process_cape_version,
+               strlcpy(cape.version, process_cape_version,
                        sizeof(process_cape_version));
-               strlcpy(cape->owner, eeprom_header.manufacturer,
+               strlcpy(cape.owner, eeprom_header.manufacturer,
                        sizeof(eeprom_header.manufacturer) + 1);
-               list_add_tail(&cape->list, extension_list);
+               _cape = alist_add(extension_list, cape);
+               if (!_cape)
+                       return -ENOMEM;
                num_capes++;
Quoted 8 lines

Review int extension_board_scan(struct list_head

Quoted 5 lines
(quoted diff) +2 -0
        }
        return num_capes;
 }
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);

Can the extension information go in the devicetree, so boards can select their scheme that way?

Quoted 2 lines

Since we're scanning to see what extension boards are present and so what device tree overlays to apply, I don't think that can work?

My understanding is that the scanning process is board-specific. For example we would not want the Beagle mechanism to be compiled into rpi. The idea of scanning things in a board-specific way seems like a driver to me. Note there is also the SYSINFO uclass which can do similar things.

Quoted 4 lines
Quoted 4 lines

The overlays being applied here are additions to what should already be a fairly complete devicetree.

If this isn't possible, then where is the information known?

Oh, so you would prefer to have something like the sysinfo drivers.

Quoted 5 lines

You're commenting on a patch to the TI specific code, that's only used by TI SoC using platforms that opt-in to the externally defined EEPROM format for these "capes". Perhaps your feedback would make more sense in some other part of the patch series? But even then, I'm not sure it makes sense?

Quoted 4 lines

I am ok to move the cape scan detection code to a standalone driver with a devicetree compatible match. Just wondering what are the advantages to use standalone drivers instead of having the code in the specific board code as done in this series.

Quoted 8 lines

I'm not sure there is an advantage. Especially since in theory we could have more than one built in, and if ti_extension_board_scan(...) doesn't find anything (because the EEPROM is missing/wrong) we could still then call rpi_extension_board_scan(...) and look for that formatted type of EEPROM and then chipanddip_extension_board_scan(...) and look for that and so forth. These extensions are nominally discoverable and so don't need device tree compatibles, was some of the point of all this I would have sworn...

I think, he means a driver for each type of custom extension board scan functions (4 until now). The U-boot devicetree would be like this:

extension_scan {
      compatible = "bone-cape-scan";
};

We could avoid the build of several extension drivers using Kconfig choice symbol to select only one builtin.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

On my side I don't really have opinions, it is a matter of code design. For now I don't see real argument to tilt the balance except to do something like sysinfo. We need more arguments from Simon.

Yes, and needing to go back to modifying the device trees seems a step backwards here, and something that will be hard to argue for upstream.

How do you define the mechanism to read the cape (etc.) information?

Well, a cape for the TI platforms has to have a properly formatted EEPROM. I forget how the CHIP/DIP thing worked, but I believe it was similar (since it originated in the same era). I also believe Pi is similar as well.

Quoted 3 lines

Presumably it is using a device which is already in the devicetree? So it is the actual extension mechanism that is not present, perhaps?

Quoted 7 lines
Quoted 1 line

How does Linux model extensions?

Last I knew it doesn't and much discussion was had to arrive at that point a decade or so ago. I believe FPGA stuff has been allowed since then, but physical extensions not, and it's a bootloader problem. Which is why we've been solving it for a while (it was more ad-hoc before Kory did the current implementation in 2021).

OK, well the compatible string above at least allows a driver to be selected and all the board-specific stuff can go in there. Perhaps re can just reuse the sysinfo uclass? Perhaps we could talk about this in a future call?

Regards,
Simon

#20 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

Quoted 164 lines · Simon Glass

Hi Tom,

Quoted 153 lines · Tom Rini
Quoted 134 lines · Simon Glass

Hi,

Quoted 131 lines · Tom Rini
Quoted 129 lines · Kory Maincent
Quoted 108 lines · On Tue, 7 Oct 2025 08:11:48 -0600 Tom Rini <[email protected]> wrote:
Quoted 102 lines · Kory Maincent
Quoted 15 lines · On Mon, 6 Oct 2025 17:42:40 -0600 Tom Rini <[email protected]> wrote:
Quoted 14 lines · Simon Glass

Hi Tom,

Quoted 11 lines · Tom Rini
Quoted 9 lines · Simon Glass

Hi Kory,

Quoted 5 lines · Kory Maincent

Migrate TI board cape detection from legacy extension support to the new UCLASS-based extension board framework.

...

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
(quoted diff) +2 -2
-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct alist *extension_list)
 {
        unsigned char addr;
        int num_capes = 0;
@@ -31,7 +31,7 @@ int extension_board_scan(struct list_head
 *extension_list) struct am335x_cape_eeprom_id eeprom_header;
                char process_cape_part_number[17] = {'0'};
                char process_cape_version[5] = {'0'};
-               struct extension *cape;
+               struct extension cape = {0}, *_cape;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Review int extension_board_scan(struct list_head · line 78

Quoted 5 lines
(quoted diff) +0 -0
                struct udevice *dev;
                u8 cursor = 0;
                int ret, i;
@@ -78,22 +78,20 @@ int extension_board_scan(struct list_head
 *extension_list)

I suppose that a method called scan() could be added to the uclass and implemented by this driver.

I don't understand what do you mean by method? Is it different to the UBOOT driver scan ops I have designed?

Quoted 45 lines
Quoted 45 lines
Quoted 36 lines
Quoted 27 lines
Quoted 27 lines
(quoted diff) +7 -11
                printf("BeagleBone Cape: %s (0x%x)\n",
 eeprom_header.board_name, addr);
 
-               cape = calloc(1, sizeof(struct extension));
-               if (!cape) {
-                       printf("Error in memory allocation\n");
-                       return num_capes;
-               }
-
-               snprintf(cape->overlay, sizeof(cape->overlay),
 "%s-%s.dtbo",
+               snprintf(cape.overlay, sizeof(cape.overlay),
 "%s-%s.dtbo", process_cape_part_number, process_cape_version);
-               strlcpy(cape->name, eeprom_header.board_name,
+               strlcpy(cape.name, eeprom_header.board_name,
                        sizeof(eeprom_header.board_name));
-               strlcpy(cape->version, process_cape_version,
+               strlcpy(cape.version, process_cape_version,
                        sizeof(process_cape_version));
-               strlcpy(cape->owner, eeprom_header.manufacturer,
+               strlcpy(cape.owner, eeprom_header.manufacturer,
                        sizeof(eeprom_header.manufacturer) + 1);
-               list_add_tail(&cape->list, extension_list);
+               _cape = alist_add(extension_list, cape);
+               if (!_cape)
+                       return -ENOMEM;
                num_capes++;
Quoted 8 lines

Review int extension_board_scan(struct list_head

Quoted 5 lines
(quoted diff) +2 -0
        }
        return num_capes;
 }
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);

Can the extension information go in the devicetree, so boards can select their scheme that way?

Quoted 2 lines

Since we're scanning to see what extension boards are present and so what device tree overlays to apply, I don't think that can work?

My understanding is that the scanning process is board-specific. For example we would not want the Beagle mechanism to be compiled into rpi. The idea of scanning things in a board-specific way seems like a driver to me. Note there is also the SYSINFO uclass which can do similar things.

Quoted 4 lines
Quoted 4 lines

The overlays being applied here are additions to what should already be a fairly complete devicetree.

If this isn't possible, then where is the information known?

Oh, so you would prefer to have something like the sysinfo drivers.

Quoted 5 lines

You're commenting on a patch to the TI specific code, that's only used by TI SoC using platforms that opt-in to the externally defined EEPROM format for these "capes". Perhaps your feedback would make more sense in some other part of the patch series? But even then, I'm not sure it makes sense?

Quoted 4 lines

I am ok to move the cape scan detection code to a standalone driver with a devicetree compatible match. Just wondering what are the advantages to use standalone drivers instead of having the code in the specific board code as done in this series.

Quoted 8 lines

I'm not sure there is an advantage. Especially since in theory we could have more than one built in, and if ti_extension_board_scan(...) doesn't find anything (because the EEPROM is missing/wrong) we could still then call rpi_extension_board_scan(...) and look for that formatted type of EEPROM and then chipanddip_extension_board_scan(...) and look for that and so forth. These extensions are nominally discoverable and so don't need device tree compatibles, was some of the point of all this I would have sworn...

I think, he means a driver for each type of custom extension board scan functions (4 until now). The U-boot devicetree would be like this:

extension_scan {
      compatible = "bone-cape-scan";
};

We could avoid the build of several extension drivers using Kconfig choice symbol to select only one builtin.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

On my side I don't really have opinions, it is a matter of code design. For now I don't see real argument to tilt the balance except to do something like sysinfo. We need more arguments from Simon.

Yes, and needing to go back to modifying the device trees seems a step backwards here, and something that will be hard to argue for upstream.

How do you define the mechanism to read the cape (etc.) information?

Well, a cape for the TI platforms has to have a properly formatted EEPROM. I forget how the CHIP/DIP thing worked, but I believe it was similar (since it originated in the same era). I also believe Pi is similar as well.

Quoted 3 lines

Presumably it is using a device which is already in the devicetree? So it is the actual extension mechanism that is not present, perhaps?

Quoted 7 lines
Quoted 1 line

How does Linux model extensions?

Last I knew it doesn't and much discussion was had to arrive at that point a decade or so ago. I believe FPGA stuff has been allowed since then, but physical extensions not, and it's a bootloader problem. Which is why we've been solving it for a while (it was more ad-hoc before Kory did the current implementation in 2021).

Quoted 4 lines

OK, well the compatible string above at least allows a driver to be selected and all the board-specific stuff can go in there. Perhaps re can just reuse the sysinfo uclass? Perhaps we could talk about this in a future call?

I don't think we need to introduce more complexity here and Kory should just v2 the current design, given the comments he noted in the other half of the thread. It seems like some future kernel version may support this use case more clearly and then maybe there'll be some compatible string upstream to key off of.

Signature · 1 line
Tom
#21 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

Hi Tom,

Quoted 171 lines · Tom Rini
Quoted 164 lines · Simon Glass

Hi Tom,

Quoted 153 lines · Tom Rini
Quoted 134 lines · Simon Glass

Hi,

Quoted 131 lines · Tom Rini
Quoted 129 lines · Kory Maincent
Quoted 108 lines · On Tue, 7 Oct 2025 08:11:48 -0600 Tom Rini <[email protected]> wrote:
Quoted 102 lines · Kory Maincent
Quoted 15 lines · On Mon, 6 Oct 2025 17:42:40 -0600 Tom Rini <[email protected]> wrote:
Quoted 14 lines · Simon Glass

Hi Tom,

Quoted 11 lines · Tom Rini
Quoted 9 lines · Simon Glass

Hi Kory,

Quoted 5 lines · Kory Maincent

Migrate TI board cape detection from legacy extension support to
the new UCLASS-based extension board framework.

Signed-off-by: Kory Maincent <[email protected]>

...

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

-int extension_board_scan(struct list_head *extension_list)
+static int ti_extension_board_scan(struct alist *extension_list)
{
unsigned char addr;
int num_capes = 0;
@@ -31,7 +31,7 @@ int extension_board_scan(struct list_head
*extension_list) struct am335x_cape_eeprom_id eeprom_header;
char process_cape_part_number[17] = {'0'};
char process_cape_version[5] = {'0'};
- struct extension *cape;
+ struct extension cape = {0}, *_cape;

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

struct udevice *dev;
u8 cursor = 0;
int ret, i;
@@ -78,22 +78,20 @@ int extension_board_scan(struct list_head
*extension_list)

I suppose that a method called scan() could be added to the uclass and implemented by this driver.

I don't understand what do you mean by method? Is it different to the UBOOT driver scan ops I have designed?

Quoted 45 lines
Quoted 45 lines
Quoted 36 lines
Quoted 27 lines
Quoted 27 lines

printf("BeagleBone Cape: %s (0x%x)\n",
eeprom_header.board_name, addr);

- cape = calloc(1, sizeof(struct extension));
- if (!cape) {
- printf("Error in memory allocation\n");
- return num_capes;
- }
-
- snprintf(cape->overlay, sizeof(cape->overlay),
"%s-%s.dtbo",
+ snprintf(cape.overlay, sizeof(cape.overlay),
"%s-%s.dtbo", process_cape_part_number, process_cape_version);
- strlcpy(cape->name, eeprom_header.board_name,
+ strlcpy(cape.name, eeprom_header.board_name,
sizeof(eeprom_header.board_name));
- strlcpy(cape->version, process_cape_version,
+ strlcpy(cape.version, process_cape_version,
sizeof(process_cape_version));
- strlcpy(cape->owner, eeprom_header.manufacturer,
+ strlcpy(cape.owner, eeprom_header.manufacturer,
sizeof(eeprom_header.manufacturer) + 1);
- list_add_tail(&cape->list, extension_list);
+ _cape = alist_add(extension_list, cape);
+ if (!_cape)
+ return -ENOMEM;
num_capes++;

Quoted 8 lines
Quoted 5 lines

}
return num_capes;
}
+
+U_BOOT_EXTENSION(cape, ti_extension_board_scan);

Can the extension information go in the devicetree, so boards can select their scheme that way?

Quoted 2 lines

Since we're scanning to see what extension boards are present and so what device tree overlays to apply, I don't think that can work?

My understanding is that the scanning process is board-specific. For example we would not want the Beagle mechanism to be compiled into rpi. The idea of scanning things in a board-specific way seems like a driver to me. Note there is also the SYSINFO uclass which can do similar things.

Quoted 4 lines
Quoted 4 lines

The overlays being applied here are additions to what should already be a fairly complete devicetree.

If this isn't possible, then where is the information known?

Oh, so you would prefer to have something like the sysinfo drivers.

Quoted 5 lines

You're commenting on a patch to the TI specific code, that's only used by TI SoC using platforms that opt-in to the externally defined EEPROM format for these "capes". Perhaps your feedback would make more sense in some other part of the patch series? But even then, I'm not sure it makes sense?

Quoted 4 lines

I am ok to move the cape scan detection code to a standalone driver with a devicetree compatible match. Just wondering what are the advantages to use standalone drivers instead of having the code in the specific board code as done in this series.

Quoted 8 lines

I'm not sure there is an advantage. Especially since in theory we could have more than one built in, and if ti_extension_board_scan(...) doesn't find anything (because the EEPROM is missing/wrong) we could still then call rpi_extension_board_scan(...) and look for that formatted type of EEPROM and then chipanddip_extension_board_scan(...) and look for that and so forth. These extensions are nominally discoverable and so don't need device tree compatibles, was some of the point of all this I would have sworn...

I think, he means a driver for each type of custom extension board scan functions (4 until now). The U-boot devicetree would be like this:

extension_scan {
      compatible = "bone-cape-scan";
};

We could avoid the build of several extension drivers using Kconfig choice symbol to select only one builtin.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

On my side I don't really have opinions, it is a matter of code design. For now I don't see real argument to tilt the balance except to do something like sysinfo. We need more arguments from Simon.

Yes, and needing to go back to modifying the device trees seems a step backwards here, and something that will be hard to argue for upstream.

How do you define the mechanism to read the cape (etc.) information?

Well, a cape for the TI platforms has to have a properly formatted EEPROM. I forget how the CHIP/DIP thing worked, but I believe it was similar (since it originated in the same era). I also believe Pi is similar as well.

Quoted 3 lines

Presumably it is using a device which is already in the devicetree? So it is the actual extension mechanism that is not present, perhaps?

Quoted 7 lines
Quoted 1 line

How does Linux model extensions?

Last I knew it doesn't and much discussion was had to arrive at that point a decade or so ago. I believe FPGA stuff has been allowed since then, but physical extensions not, and it's a bootloader problem. Which is why we've been solving it for a while (it was more ad-hoc before Kory did the current implementation in 2021).

Quoted 4 lines

OK, well the compatible string above at least allows a driver to be selected and all the board-specific stuff can go in there. Perhaps re can just reuse the sysinfo uclass? Perhaps we could talk about this in a future call?

Quoted 5 lines

I don't think we need to introduce more complexity here and Kory should just v2 the current design, given the comments he noted in the other half of the thread. It seems like some future kernel version may support this use case more clearly and then maybe there'll be some compatible string upstream to key off of.

OK, yes let's see v2.

Regards,
Simon

#22 lore raw

Re: [PATCH 06/16] board: ti: Convert cape detection to use UCLASS framework

In reply to Kory Maincent

Hello,

Sorry for jumping in the middle of the thread, but I only have a small comment.

Quoted 5 lines · On Tue, 7 Oct 2025 18:29:38 +0200 Kory Maincent <[email protected]>…

I think, he means a driver for each type of custom extension board scan functions (4 until now). The U-boot devicetree would be like this:

extension_scan {
	compatible = "bone-cape-scan"; 
};

I'm far from being a DT binding maintainer, but I highly doubt this would be accepted by a DT binding maintainer as this doesn't describe HW at all.

Thomas

Signature · 3 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
#23 lore raw

PATCH 7/16 board: sunxi: Refactor CHIP board extension code

In reply to Kory Maincent

Clean up and improve code structure in the sunxi CHIP board extension detection implementation.

---
 board/sunxi/chip.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
board/sunxi/chip.c +8 -8
index 270af2506d2..ea0d3a56f5f 100644
@@ -42,13 +42,7 @@ struct dip_w1_header {
 
 int extension_board_scan(struct list_head *extension_list)
 {
-	struct extension *dip;
-	struct dip_w1_header w1_header;
 	struct udevice *bus, *dev;
-	u32 vid;
-	u16 pid;
-	int ret;
-
 	int num_dip = 0;
 
 	sunxi_gpio_set_pull(SUNXI_GPD(2), SUNXI_GPIO_PULL_UP);
@@ -60,6 +54,12 @@ int extension_board_scan(struct list_head *extension_list)
 	}
 
 	for_each_w1_device(bus, &dev) {
+		struct dip_w1_header w1_header;
+		struct extension *dip;
+		u32 vid;
+		u16 pid;
+		int ret;
+
 		if (w1_get_device_family(dev) != W1_FAMILY_DS2431)
 			continue;
 
@@ -90,8 +90,8 @@ int extension_board_scan(struct list_head *extension_list)
 
 		snprintf(dip->overlay, sizeof(dip->overlay), "dip-%x-%x.dtbo",
 			 vid, pid);
-		strncpy(dip->name, w1_header.product_name, 32);
-		strncpy(dip->owner, w1_header.vendor_name, 32);
+		strlcpy(dip->name, w1_header.product_name, sizeof(dip->name));
+		strlcpy(dip->owner, w1_header.vendor_name, sizeof(dip->owner));
 		list_add_tail(&dip->list, extension_list);
 		num_dip++;
 	}
Signature · 1 line
2.43.0
#24 lore raw

Re: [PATCH 07/16] board: sunxi: Refactor CHIP board extension code

Quoted 2 lines · On Fri, 03 Oct 2025 18:33:47 +0200 Kory Maincent <[email protected]>…

Clean up and improve code structure in the sunxi CHIP board extension detection implementation.

It seems I forgot to build test CHIP_defconfig because there is a build error here.

pw-bot:cr

Quoted 50 lines
---
 board/sunxi/chip.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
board/sunxi/chip.c +8 -8
index 270af2506d2..ea0d3a56f5f 100644
@@ -42,13 +42,7 @@ struct dip_w1_header {
 
 int extension_board_scan(struct list_head *extension_list)
 {
-	struct extension *dip;
-	struct dip_w1_header w1_header;
 	struct udevice *bus, *dev;
-	u32 vid;
-	u16 pid;
-	int ret;
-
 	int num_dip = 0;
 
 	sunxi_gpio_set_pull(SUNXI_GPD(2), SUNXI_GPIO_PULL_UP);
@@ -60,6 +54,12 @@ int extension_board_scan(struct list_head *extension_list)
 	}
 
 	for_each_w1_device(bus, &dev) {
+		struct dip_w1_header w1_header;
+		struct extension *dip;
+		u32 vid;
+		u16 pid;
+		int ret;
+
 		if (w1_get_device_family(dev) != W1_FAMILY_DS2431)
 			continue;
 
@@ -90,8 +90,8 @@ int extension_board_scan(struct list_head *extension_list)
 
 		snprintf(dip->overlay, sizeof(dip->overlay),
 "dip-%x-%x.dtbo", vid, pid);
-		strncpy(dip->name, w1_header.product_name, 32);
-		strncpy(dip->owner, w1_header.vendor_name, 32);
+		strlcpy(dip->name, w1_header.product_name,
 sizeof(dip->name));
+		strlcpy(dip->owner, w1_header.vendor_name,
 sizeof(dip->owner)); list_add_tail(&dip->list, extension_list);
 		num_dip++;

}

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#25 lore raw

PATCH 8/16 board: sunxi: Convert extension support to UCLASS framework

In reply to Kory Maincent

Migrate sunxi board extension detection from legacy implementation to the new UCLASS-based extension board framework.

---
 arch/arm/mach-sunxi/Kconfig |  2 +-
 board/sunxi/chip.c          | 17 ++++++++---------
 2 files changed, 9 insertions(+), 10 deletions(-)
arch/arm/mach-sunxi/Kconfig +1 -1
index b04ec671696..f5696199516 100644
@@ -1223,7 +1223,7 @@ config BLUETOOTH_DT_DEVICE_FIXUP
 
 config CHIP_DIP_SCAN
 	bool "Enable DIPs detection for CHIP board"
-	select SUPPORT_EXTENSION_SCAN
+	select SUPPORT_DM_EXTENSION_SCAN
 	select W1
 	select W1_GPIO
 	select W1_EEPROM
board/sunxi/chip.c +8 -9
index ea0d3a56f5f..183b8ded170 100644
@@ -40,7 +40,7 @@ struct dip_w1_header {
 	u8      data[16];               /* user data, per-dip specific */
 } __packed;
 
-int extension_board_scan(struct list_head *extension_list)
+static int sunxi_extension_board_scan(struct alist *extension_list)
 {
 	struct udevice *bus, *dev;
 	int num_dip = 0;
@@ -54,6 +54,7 @@ int extension_board_scan(struct list_head *extension_list)
 	}
 
 	for_each_w1_device(bus, &dev) {
+		struct extension dip = {0}, *_dip;
 		struct dip_w1_header w1_header;
 		struct extension *dip;
 		u32 vid;
@@ -82,18 +83,16 @@ int extension_board_scan(struct list_head *extension_list)
 		       w1_header.product_name, pid,
 		       w1_header.vendor_name, vid);
 
-		dip = calloc(1, sizeof(struct extension));
-		if (!dip) {
-			printf("Error in memory allocation\n");
-			return num_dip;
-		}
-
-		snprintf(dip->overlay, sizeof(dip->overlay), "dip-%x-%x.dtbo",
+		snprintf(dip.overlay, sizeof(dip.overlay), "dip-%x-%x.dtbo",
 			 vid, pid);
 		strlcpy(dip->name, w1_header.product_name, sizeof(dip->name));
 		strlcpy(dip->owner, w1_header.vendor_name, sizeof(dip->owner));
-		list_add_tail(&dip->list, extension_list);
+		_dip = alist_add(extension_list, dip);
+		if (!_dip)
+			return -ENOMEM;
 		num_dip++;
 	}
 	return num_dip;
 }
+
+U_BOOT_EXTENSION(dip, sunxi_extension_board_scan);
Signature · 1 line
2.43.0
#26 lore raw

PATCH 9/16 board: sandbox: Improve extension board scan implementation

In reply to Kory Maincent

Enhance the extension board scanning code in sandbox with better error handling and code organization.

---
 board/sandbox/sandbox.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
board/sandbox/sandbox.c +5 -1
index 0dc23a27dfc..c5d7b9651a9 100644
@@ -113,11 +113,15 @@ int ft_board_setup(void *fdt, struct bd_info *bd)
 #ifdef CONFIG_CMD_EXTENSION
 int extension_board_scan(struct list_head *extension_list)
 {
-	struct extension *extension;
 	int i;
 
 	for (i = 0; i < 2; i++) {
+		struct extension *extension;
+
 		extension = calloc(1, sizeof(struct extension));
+		if (!extension)
+			return -ENOMEM;
+
 		snprintf(extension->overlay, sizeof(extension->overlay), "overlay%d.dtbo", i);
 		snprintf(extension->name, sizeof(extension->name), "extension board %d", i);
 		snprintf(extension->owner, sizeof(extension->owner), "sandbox");
Signature · 1 line
2.43.0
#27 lore raw

PATCH 10/16 board: sandbox: Convert extension support to UCLASS framework

In reply to Kory Maincent

Migrate sandbox extension board detection from legacy implementation to the new UCLASS-based extension board framework.

---
 arch/Kconfig            |  2 +-
 board/sandbox/sandbox.c | 24 ++++++++++++------------
 2 files changed, 13 insertions(+), 13 deletions(-)
arch/Kconfig +1 -1
index 7e05e0c2263..5bb65a29f8d 100644
@@ -215,7 +215,7 @@ config SANDBOX
 	select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
 	select SYS_CACHE_SHIFT_4
 	select IRQ
-	select SUPPORT_EXTENSION_SCAN if CMDLINE
+	select SUPPORT_DM_EXTENSION_SCAN if CMDLINE
 	select SUPPORT_ACPI
 	imply BITREVERSE
 	select BLOBLIST
board/sandbox/sandbox.c +12 -12
index c5d7b9651a9..21e1e2583fd 100644
@@ -111,27 +111,27 @@ int ft_board_setup(void *fdt, struct bd_info *bd)
 }
 
 #ifdef CONFIG_CMD_EXTENSION
-int extension_board_scan(struct list_head *extension_list)
+static int sandbox_extension_board_scan(struct alist *extension_list)
 {
 	int i;
 
 	for (i = 0; i < 2; i++) {
-		struct extension *extension;
-
-		extension = calloc(1, sizeof(struct extension));
-		if (!extension)
+		struct extension extension = {0}, *_extension;
+
+		snprintf(extension.overlay, sizeof(extension.overlay), "overlay%d.dtbo", i);
+		snprintf(extension.name, sizeof(extension.name), "extension board %d", i);
+		snprintf(extension.owner, sizeof(extension.owner), "sandbox");
+		snprintf(extension.version, sizeof(extension.version), "1.1");
+		snprintf(extension.other, sizeof(extension.other), "Fictional extension board");
+		_extension = alist_add(extension_list, extension);
+		if (!_extension)
 			return -ENOMEM;
-
-		snprintf(extension->overlay, sizeof(extension->overlay), "overlay%d.dtbo", i);
-		snprintf(extension->name, sizeof(extension->name), "extension board %d", i);
-		snprintf(extension->owner, sizeof(extension->owner), "sandbox");
-		snprintf(extension->version, sizeof(extension->version), "1.1");
-		snprintf(extension->other, sizeof(extension->other), "Fictional extension board");
-		list_add_tail(&extension->list, extension_list);
 	}
 
 	return i;
 }
+
+U_BOOT_EXTENSION(sandbox_extension, extension_board_scan);
 #endif
 
 #ifdef CONFIG_BOARD_LATE_INIT
Signature · 1 line
2.43.0
#28 lore raw

PATCH 11/16 board: compulab: Convert imx8mm-cl-iot-gate to UCLASS extension framework

In reply to Kory Maincent

Migrate CompuLab imx8mm-cl-iot-gate board extension detection from legacy implementation to the new UCLASS-based extension board framework.

---
 arch/arm/mach-imx/imx8m/Kconfig                    |  4 +-
 .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c        | 60 ++++++++++------------
 2 files changed, 30 insertions(+), 34 deletions(-)
arch/arm/mach-imx/imx8m/Kconfig +2 -2
index e7bc154b805..5324eff3084 100644
@@ -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"
board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c +28 -32

132 lines not on this page · raw message

Signature · 1 line
2.43.0
#29 lore raw

PATCH 12/16 boot: Remove legacy extension board support

In reply to Kory Maincent

Remove the legacy extension board implementation now that all boards have been converted to use the new UCLASS-based framework. This eliminates 223 lines of legacy code while preserving functionality through the modern driver model approach.

---
 MAINTAINERS                        |  1 -
 arch/Kconfig                       |  2 +-
 arch/arm/mach-imx/imx8m/Kconfig    |  4 +-
 arch/arm/mach-omap2/am33xx/Kconfig |  2 +-
 arch/arm/mach-omap2/omap5/Kconfig  |  2 +-
 arch/arm/mach-sunxi/Kconfig        |  2 +-
 boot/Kconfig                       |  3 --
 boot/Makefile                      |  3 +-
 boot/extension-uclass.c            | 18 +++----
 boot/extension.c                   | 97 --------------------------------------
 cmd/extension_board.c              | 74 ++++-------------------------
 include/extension_board.h          | 55 ++++++---------------
 12 files changed, 38 insertions(+), 225 deletions(-)
MAINTAINERS +0 -1
index 4afa5dfb020..af90e749b14 100644
@@ -1189,7 +1189,6 @@ S:	Maintained
 F:	board/sunxi/chip.c
 F:	board/ti/common/cape_detect.c
 F:	boot/extension-uclass.c
-F:	boot/extension.c
 F:	cmd/extension_board.c
 F:	include/extension_board.h
 
arch/Kconfig +1 -1
index 5bb65a29f8d..7e05e0c2263 100644
@@ -215,7 +215,7 @@ config SANDBOX
 	select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
 	select SYS_CACHE_SHIFT_4
 	select IRQ
-	select SUPPORT_DM_EXTENSION_SCAN if CMDLINE
+	select SUPPORT_EXTENSION_SCAN if CMDLINE
 	select SUPPORT_ACPI
 	imply BITREVERSE
 	select BLOBLIST
arch/arm/mach-imx/imx8m/Kconfig +2 -2
index 5324eff3084..e7bc154b805 100644
@@ -359,14 +359,14 @@ config TARGET_IMX8MM_CL_IOT_GATE
 	select IMX8MM
 	select SUPPORT_SPL
 	select IMX8M_LPDDR4
-	select SUPPORT_DM_EXTENSION_SCAN
+	select SUPPORT_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_DM_EXTENSION_SCAN
+	select SUPPORT_EXTENSION_SCAN
 
 config TARGET_IMX8MP_RSB3720A1_4G
 	bool "Support i.MX8MP RSB3720A1 4G"
arch/arm/mach-omap2/am33xx/Kconfig +1 -1
index 77f7938305b..dff4f1cf202 100644
@@ -15,7 +15,7 @@ config TARGET_AM335X_EVM
 	select DM_GPIO
 	select DM_SERIAL
 	select TI_I2C_BOARD_DETECT
-	select SUPPORT_DM_EXTENSION_SCAN
+	select SUPPORT_EXTENSION_SCAN
 	imply CMD_DM
 	imply SPL_DM
 	imply SPL_DM_SEQ_ALIAS
arch/arm/mach-omap2/omap5/Kconfig +1 -1
index 819490a8cf8..5394529658b 100644
@@ -38,7 +38,7 @@ config TARGET_AM57XX_EVM
 	select CMD_DDR3
 	select DRA7XX
 	select TI_I2C_BOARD_DETECT
-	select SUPPORT_DM_EXTENSION_SCAN
+	select SUPPORT_EXTENSION_SCAN
 	imply DM_THERMAL
 	imply SCSI
 	imply SPL_THERMAL
arch/arm/mach-sunxi/Kconfig +1 -1
index f5696199516..b04ec671696 100644
@@ -1223,7 +1223,7 @@ config BLUETOOTH_DT_DEVICE_FIXUP
 
 config CHIP_DIP_SCAN
 	bool "Enable DIPs detection for CHIP board"
-	select SUPPORT_DM_EXTENSION_SCAN
+	select SUPPORT_EXTENSION_SCAN
 	select W1
 	select W1_GPIO
 	select W1_EEPROM
boot/Kconfig +0 -3
index 159da81bec5..62aa301f18f 100644
@@ -1909,9 +1909,6 @@ endif # OF_LIBFDT
 config SUPPORT_EXTENSION_SCAN
         bool
 
-config SUPPORT_DM_EXTENSION_SCAN
-        bool
-
 config USE_BOOTARGS
 	bool "Enable boot arguments"
 	help
boot/Makefile +1 -2
index aa26070fbb8..7fb56e7ef37 100644
@@ -9,8 +9,7 @@ obj-$(CONFIG_BOOT_RETRY) += bootretry.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o bootm_os.o
 obj-$(CONFIG_CMD_BOOTZ) += bootm.o bootm_os.o
 obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
-obj-$(CONFIG_SUPPORT_EXTENSION_SCAN) += extension.o
-obj-$(CONFIG_SUPPORT_DM_EXTENSION_SCAN) += extension-uclass.o
+obj-$(CONFIG_SUPPORT_EXTENSION_SCAN) += extension-uclass.o
 
 obj-$(CONFIG_PXE_UTILS) += pxe_utils.o
 
boot/extension-uclass.c +9 -9
index 9dfbeb60d20..1b21aa08944 100644
@@ -61,7 +61,7 @@ static struct udevice *extension_get_dev(void)
 	return NULL;
 }
 
-struct alist *dm_extension_get_list(void)
+struct alist *extension_get_list(void)
 {
 	struct udevice *dev = extension_get_dev();
 
@@ -71,7 +71,7 @@ struct alist *dm_extension_get_list(void)
 	return dev_get_priv(dev);
 }
 
-int dm_extension_probe(struct udevice *dev)
+int extension_probe(struct udevice *dev)
 {
 	struct alist *extension_list = dev_get_priv(dev);
 
@@ -79,7 +79,7 @@ int dm_extension_probe(struct udevice *dev)
 	return 0;
 }
 
-int dm_extension_remove(struct udevice *dev)
+int extension_remove(struct udevice *dev)
 {
 	struct alist *extension_list = dev_get_priv(dev);
 
@@ -87,9 +87,9 @@ int dm_extension_remove(struct udevice *dev)
 	return 0;
 }
 
-int dm_extension_scan(void)
+int extension_scan(void)
 {
-	struct alist *extension_list = dm_extension_get_list();
+	struct alist *extension_list = extension_get_list();
 	struct udevice *dev = extension_get_dev();
 	const struct extension_ops *ops;
 
@@ -154,9 +154,9 @@ static int _extension_apply(const struct extension *extension)
 	return ret;
 }
 
-int dm_extension_apply(int extension_num)
+int extension_apply(int extension_num)
 {
-	struct alist *extension_list = dm_extension_get_list();
+	struct alist *extension_list = extension_get_list();
 	const struct extension *extension;
 
 	if (!extension_list)
@@ -172,9 +172,9 @@ int dm_extension_apply(int extension_num)
 	return _extension_apply(extension);
 }
 
-int dm_extension_apply_all(void)
+int extension_apply_all(void)
 {
-	struct alist *extension_list = dm_extension_get_list();
+	struct alist *extension_list = extension_get_list();
 	const struct extension *extension;
 	int ret;
 
boot/extension.c deleted +0 -97

97 lines not on this page · raw message

cmd/extension_board.c +8 -66

123 lines not on this page · raw message

include/extension_board.h +14 -41

99 lines not on this page · raw message

Signature · 1 line
2.43.0
#30 lore raw

PATCH 13/16 boot: extension: Move overlay apply custom logic to command level

In reply to Kory Maincent

The extension_overlay_cmd environment variable approach is specific to the U-Boot extension_board command, while other boot flows (pxe_utils, bootstd) handle overlay loading differently.

Move the extension_overlay_cmd execution out of the core extension framework to the command level. This decouples the framework from command-specific behavior and prepares for future extension support in other boot flows.

---
 boot/extension-uclass.c   | 68 +++--------------------------------
 cmd/extension_board.c     | 92 +++++++++++++++++++++++++++++++++++++++++++++--
 include/extension_board.h | 12 ++-----
 3 files changed, 98 insertions(+), 74 deletions(-)
boot/extension-uclass.c +5 -63
index 1b21aa08944..840023fa84e 100644
@@ -104,92 +104,34 @@ int extension_scan(void)
 	return ops->scan(extension_list);
 }
 
-static int _extension_apply(const struct extension *extension)
+int extension_apply(struct fdt_header *working_fdt, ulong size)
 {
-	ulong extrasize, overlay_addr;
 	struct fdt_header *blob;
-	char *overlay_cmd;
+	ulong overlay_addr;
 	int ret;
 
-	if (!working_fdt) {
-		printf("No FDT memory address configured. Please configure\n"
-		       "the FDT address via \"fdt addr <address>\" command.\n");
-		return -EINVAL;
-	}
-
-	overlay_cmd = env_get("extension_overlay_cmd");
-	if (!overlay_cmd) {
-		printf("Environment extension_overlay_cmd is missing\n");
-		return -EINVAL;
-	}
-
 	overlay_addr = env_get_hex("extension_overlay_addr", 0);
 	if (!overlay_addr) {
 		printf("Environment extension_overlay_addr is missing\n");
 		return -EINVAL;
 	}
 
-	env_set("extension_overlay_name", extension->overlay);
-	ret = run_command(overlay_cmd, 0);
-	if (ret)
-		return ret;
-
-	extrasize = env_get_hex("filesize", 0);
-	if (!extrasize)
-		return -EINVAL;
-
-	fdt_shrink_to_minimum(working_fdt, extrasize);
+	fdt_shrink_to_minimum(working_fdt, size);
 
 	blob = map_sysmem(overlay_addr, 0);
 	if (!fdt_valid(&blob)) {
-		printf("Invalid overlay devicetree %s\n", extension->overlay);
+		printf("Invalid overlay devicetree\n");
 		return -EINVAL;
 	}
 
 	/* Apply method prints messages on error */
 	ret = fdt_overlay_apply_verbose(working_fdt, blob);
 	if (ret)
-		printf("Failed to apply overlay %s\n", extension->overlay);
+		printf("Failed to apply overlay\n");
 
 	return ret;
 }
 
-int extension_apply(int extension_num)
-{
-	struct alist *extension_list = extension_get_list();
-	const struct extension *extension;
-
-	if (!extension_list)
-		return -ENODEV;
-
-	extension = alist_get(extension_list, extension_num,
-			      struct extension);
-	if (!extension) {
-		printf("Wrong extension number\n");
-		return -ENODEV;
-	}
-
-	return _extension_apply(extension);
-}
-
-int extension_apply_all(void)
-{
-	struct alist *extension_list = extension_get_list();
-	const struct extension *extension;
-	int ret;
-
-	if (!extension_list)
-		return -ENODEV;
-
-	alist_for_each(extension, extension_list) {
-		ret = _extension_apply(extension);
-		if (ret)
-			return ret;
-	}
-
-	return 0;
-}
-
 UCLASS_DRIVER(extension) = {
 	.name	= "extension",
 	.id	= UCLASS_EXTENSION,
cmd/extension_board.c +90 -2

110 lines not on this page · raw message

include/extension_board.h +3 -9
index fc9c33ed354..e12c91abb4c 100644
@@ -41,17 +41,11 @@ int extension_scan(void);
 
 /**
  * extension_apply - Apply extension board overlay to the devicetree
- * @extension_num: Extension number to be applied
+ * @working_fdt: Pointer to working flattened device tree
+ * @size: Size of the devicetree overlay
  * Return: Zero on success, negative on failure.
  */
-int extension_apply(int extension_num);
-
-/**
- * extension_apply_all - Apply all extension board overlays to the
- *			    devicetree
- * Return: Zero on success, negative on failure.
- */
-int extension_apply_all(void);
+int extension_apply(struct fdt_header *working_fdt, ulong size);
 
 struct extension {
 	char name[32];
Signature · 1 line
2.43.0
#31 lore raw

PATCH 14/16 boot: pxe_utils: Add extension board devicetree overlay support

In reply to Kory Maincent

Add support for scanning and applying extension board devicetree overlays during PXE boot. After loading the main board devicetree, the system now scans for available extension boards and applies their overlays automatically.

This enables dynamic hardware configuration for systems with extension boards during boot scenarios which are using pxe_utils.

---
 boot/pxe_utils.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)
boot/pxe_utils.c +90 -0
index eb4d7723481..f28fddfd8b3 100644
@@ -10,6 +10,7 @@
 #include <command.h>
 #include <dm.h>
 #include <env.h>
+#include <extension_board.h>
 #include <image.h>
 #include <log.h>
 #include <malloc.h>
@@ -432,6 +433,93 @@ skip_overlay:
 }
 #endif
 
+/*
+ * label_boot_extension - scan extension boards and load overlay associated
+ */
+
+static void label_boot_extension(struct pxe_context *ctx,
+				 struct pxe_label *label)
+{
+#if CONFIG_IS_ENABLED(SUPPORT_EXTENSION_SCAN)
+	const struct extension *extension;
+	struct fdt_header *working_fdt;
+	struct alist *extension_list;
+	int ret, dir_len, len;
+	char *overlay_dir;
+	const char *slash;
+	ulong fdt_addr;
+
+	ret = extension_scan();
+	if (ret < 0)
+		return;
+
+	extension_list = extension_get_list();
+	if (!extension_list)
+		return;
+
+	/* Get the main fdt and map it */
+	fdt_addr = env_get_hex("fdt_addr_r", 0);
+	working_fdt = map_sysmem(fdt_addr, 0);
+	if (fdt_check_header(working_fdt))
+		return;
+
+	/* Use fdtdir for now as the overlay devicetree directory */
+	if (label->fdtdir) {
+		len = strlen(label->fdtdir);
+		if (!len)
+			slash = "./";
+		else if (label->fdtdir[len - 1] != '/')
+			slash = "/";
+		else
+			slash = "";
+
+		dir_len = strlen(label->fdtdir) + strlen(slash) + 1;
+		overlay_dir = calloc(1, len);
+		if (!overlay_dir)
+			return;
+
+		snprintf(overlay_dir, dir_len, "%s%s", label->fdtdir,
+			 slash);
+	} else {
+		dir_len = 2;
+		snprintf(overlay_dir, dir_len, "/");
+	}
+
+	alist_for_each(extension, extension_list) {
+		char *overlay_file;
+		ulong size;
+
+		len = dir_len + strlen(extension->overlay);
+		overlay_file = calloc(1, len);
+		if (!overlay_file)
+			goto cleanup;
+
+		snprintf(overlay_file, len, "%s%s", overlay_dir,
+			 extension->overlay);
+
+		/* Load extension overlay file */
+		ret = get_relfile_envaddr(ctx, overlay_file,
+					  "extension_overlay_addr",
+					  (enum bootflow_img_t)IH_TYPE_FLATDT,
+					  &size);
+		if (ret < 0) {
+			free(overlay_file);
+			continue;
+		}
+
+		ret = extension_apply(working_fdt, size);
+		if (ret) {
+			free(overlay_file);
+			continue;
+		}
+		free(overlay_file);
+	}
+
+cleanup:
+	free(overlay_dir);
+#endif
+}
+
 /**
  * label_boot() - Boot according to the contents of a pxe_label
  *
@@ -685,6 +773,8 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label)
 			if (label->fdtoverlays)
 				label_boot_fdtoverlay(ctx, label);
 #endif
+			label_boot_extension(ctx, label);
+
 		} else {
 			bootm_argv[3] = NULL;
 		}
Signature · 1 line
2.43.0
#32 lore raw

PATCH 15/16 boot: bootmeth_efi: Refactor distro_efi_try_bootflow_files return logic

In reply to Kory Maincent

Simplify the return path in distro_efi_try_bootflow_files() to prepare for adding extension board support in a subsequent commit.

---
 boot/bootmeth_efi.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)
boot/bootmeth_efi.c +16 -15
index 0af23df3a4a..64de5c08b7b 100644
@@ -148,25 +148,26 @@ static int distro_efi_try_bootflow_files(struct udevice *dev,
 			return log_msg_ret("fil", -ENOMEM);
 	}
 
-	if (!ret) {
-		bflow->fdt_size = size;
-		bflow->fdt_addr = fdt_addr;
-
-		/*
-		 * TODO: Apply extension overlay
-		 *
-		 * Here we need to load and apply the extension overlay. This is
-		 * not implemented. See do_extension_apply(). The extension
-		 * stuff needs an implementation in boot/extension.c so it is
-		 * separate from the command code. Really the extension stuff
-		 * should use the device tree and a uclass / driver interface
-		 * rather than implementing its own list
-		 */
-	} else {
+	if (ret) {
 		log_debug("No device tree available\n");
 		bflow->flags |= BOOTFLOWF_USE_BUILTIN_FDT;
+		return 0;
 	}
 
+	bflow->fdt_size = size;
+	bflow->fdt_addr = fdt_addr;
+
+	/*
+	 * TODO: Apply extension overlay
+	 *
+	 * Here we need to load and apply the extension overlay. This is
+	 * not implemented. See do_extension_apply(). The extension
+	 * stuff needs an implementation in boot/extension.c so it is
+	 * separate from the command code. Really the extension stuff
+	 * should use the device tree and a uclass / driver interface
+	 * rather than implementing its own list
+	 */
+
 	return 0;
 }
 
Signature · 1 line
2.43.0
#33 lore raw

PATCH 16/16 boot: bootmeth_efi: Add extension board devicetree overlay support

In reply to Kory Maincent

Add support for scanning and applying extension board devicetree overlays during EFI boot. After loading the main board devicetree, the system now scans for available extension boards and applies their overlays automatically.

---

Not yet tested, need to find a board with extension boards and supporting EFI boot. Roger Quadros could you test it on your side?

---
 boot/bootmeth_efi.c | 67 ++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 56 insertions(+), 11 deletions(-)
boot/bootmeth_efi.c +56 -11
index 64de5c08b7b..13726a13e07 100644
@@ -16,6 +16,7 @@
 #include <efi.h>
 #include <efi_loader.h>
 #include <env.h>
+#include <extension_board.h>
 #include <fs.h>
 #include <malloc.h>
 #include <mapmem.h>
@@ -99,8 +100,11 @@ static int distro_efi_check(struct udevice *dev, struct bootflow_iter *iter)
 static int distro_efi_try_bootflow_files(struct udevice *dev,
 					 struct bootflow *bflow)
 {
+	ulong fdt_addr, size, overlay_addr;
+	const struct extension *extension;
+	struct fdt_header *working_fdt;
 	struct blk_desc *desc = NULL;
-	ulong fdt_addr, size;
+	struct alist *extension_list;
 	char fname[256];
 	int ret, seq;
 
@@ -157,16 +161,57 @@ static int distro_efi_try_bootflow_files(struct udevice *dev,
 	bflow->fdt_size = size;
 	bflow->fdt_addr = fdt_addr;
 
-	/*
-	 * TODO: Apply extension overlay
-	 *
-	 * Here we need to load and apply the extension overlay. This is
-	 * not implemented. See do_extension_apply(). The extension
-	 * stuff needs an implementation in boot/extension.c so it is
-	 * separate from the command code. Really the extension stuff
-	 * should use the device tree and a uclass / driver interface
-	 * rather than implementing its own list
-	 */
+	if (!CONFIG_IS_ENABLED(SUPPORT_EXTENSION_SCAN))
+		return 0;
+
+	ret = extension_scan();
+	if (ret < 0)
+		return 0;
+
+	extension_list = extension_get_list();
+	if (!extension_list)
+		return 0;
+
+	working_fdt = map_sysmem(fdt_addr, 0);
+	if (fdt_check_header(working_fdt))
+		return 0;
+
+	overlay_addr = env_get_hex("extension_overlay_addr", 0);
+	if (!overlay_addr) {
+		log_debug("Environment extension_overlay_addr is missing\n");
+		return 0;
+	}
+
+	alist_for_each(extension, extension_list) {
+		char *overlay_file;
+		int len;
+
+		len = sizeof(EFI_DIRNAME) + strlen(extension->overlay);
+		overlay_file = calloc(1, len);
+		if (!overlay_file)
+			return -ENOMEM;
+
+		snprintf(overlay_file, len, "%s%s", EFI_DIRNAME,
+			 extension->overlay);
+
+		ret = bootmeth_common_read_file(dev, bflow, overlay_file,
+						overlay_addr,
+						(enum bootflow_img_t)IH_TYPE_FLATDT,
+						&size);
+		if (ret) {
+			log_debug("No device tree overlay\n");
+			free(overlay_file);
+			continue;
+		}
+
+		ret = extension_apply(working_fdt, size);
+		if (ret) {
+			free(overlay_file);
+			continue;
+		}
+		bflow->fdt_size += size;
+		free(overlay_file);
+	}
 
 	return 0;
 }
Signature · 1 line
2.43.0
#34 lore raw
In reply to Kory Maincent
Quoted 10 lines · Kory Maincent

This series converts the extension board framework to use UCLASS as requested by Simon Glass, then adds extension support to pxe_utils and bootmeth_efi (not tested) to enable extension boards devicetree load in the standard boot process.

The UCLASS implementation provides one driver that manages all extension boards (alternative would be one U-Boot device per extension board). Simon is that what you would expect?

This seems good overall, thanks! I'm assuming you were able to test this on a few platforms? Which platforms should we try and find someone to test this on to make sure there's no surprises down the line?

Signature · 1 line
Tom
#35 lore raw
Quoted 11 lines · On Fri, 3 Oct 2025 14:37:35 -0600 Tom Rini <[email protected]> wrote:
Quoted 9 lines · Kory Maincent

This series converts the extension board framework to use UCLASS as requested by Simon Glass, then adds extension support to pxe_utils and bootmeth_efi (not tested) to enable extension boards devicetree load in the standard boot process.

The UCLASS implementation provides one driver that manages all extension boards (alternative would be one U-Boot device per extension board). Simon is that what you would expect?

Quoted 5 lines
Quoted 1 line

This seems good overall, thanks! I'm assuming you were able to test this on a few platforms? Which platforms should we try and find someone to test this on to make sure there's no surprises down the line?

On this version it was only tested on the ti BeagleBone Black board. I first wanted acknowledgment of the current design development.
For the v2 I will test more thoroughly the sunxi DIP scan and the sandboard scan. The only board I don't have is the imx8mm-cl-iot-gate so I hope someone could test this one on his side. I also can't test the efi bootmeth changes.

Regards,

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#36 lore raw
In reply to Kory Maincent

Hi Kory,

Quoted 9 lines · Kory Maincent

This series converts the extension board framework to use UCLASS as requested by Simon Glass, then adds extension support to pxe_utils and bootmeth_efi (not tested) to enable extension boards devicetree load in the standard boot process.

The UCLASS implementation provides one driver that manages all extension boards (alternative would be one U-Boot device per extension board). Simon is that what you would expect?

I believe that allowing board-specific drivers is better, since some will want to check an EEPROM, some will use GPIO, etc.

Also, for testing, we should have a driver for sandbox.

Regards,
Simon

Quoted 48 lines

---
Kory Maincent (16):
MAINTAINERS: Add maintainer for extension board support
boot: Move extension board support from cmd/ to boot/
boot: Add UCLASS support for extension boards
board: ti: Exclude cape detection from XPL builds
board: ti: Refactor cape detection code for readability
board: ti: Convert cape detection to use UCLASS framework
board: sunxi: Refactor CHIP board extension code
board: sunxi: Convert extension support to UCLASS framework
board: sandbox: Improve extension board scan implementation
board: sandbox: Convert extension support to UCLASS framework
board: compulab: Convert imx8mm-cl-iot-gate to UCLASS extension framework
boot: Remove legacy extension board support
boot: extension: Move overlay apply custom logic to command level
boot: pxe_utils: Add extension board devicetree overlay support
boot: bootmeth_efi: Refactor distro_efi_try_bootflow_files return logic
boot: bootmeth_efi: Add extension board devicetree overlay support

 MAINTAINERS                                        |   9 +
 .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c        |  60 ++++---
 board/sandbox/sandbox.c                            |  22 ++-
 board/sunxi/chip.c                                 |  33 ++--
 board/ti/common/Makefile                           |   2 +
 board/ti/common/cape_detect.c                      |  52 +++---
 boot/Kconfig                                       |   3 +
 boot/Makefile                                      |   1 +
 boot/bootmeth_efi.c                                |  78 +++++++--
 boot/extension-uclass.c                            | 138 ++++++++++++++++
 boot/pxe_utils.c                                   |  90 ++++++++++
 cmd/Kconfig                                        |   5 +-
 cmd/extension_board.c                              | 183 ++++++++++-----------
 doc/usage/cmd/extension.rst                        |  24 +--
 include/dm/uclass-id.h                             |   1 +
 include/extension_board.h                          |  71 ++++++--
 16 files changed, 544 insertions(+), 228 deletions(-)

---
base-commit: 9710d98e8942151fc0c62d54100d9d27e8263d04
change-id: 20250916-feature_sysboot_extension_board-958dd0072565

Best regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com