board: ti: cape_detect: Add overlay name lookup table for extension boards
PATCH v2 1/1 board: ti: cape_detect: Add overlay name lookup table for extension boards
From: "Kory Maincent (TI)" <[email protected]>
Some extension boards have EEPROM part numbers that do not directly match their devicetree overlay filenames. Introduce a static name_mapping table and a set_cape_overlay() helper that translates the part number and version strings read from the EEPROM into the correct overlay filename.
When no entry matches, fall back to the existing behavior of constructing the overlay name as "<part_number>-<version>.dtbo" directly from the EEPROM content.
Add an initial entry mapping BB-GREEN-HDMI revision 00A0 to am335x-bone-hdmi-00a0.dtbo.
---
Changes in v2:
- Use ARRAY_SIZE instead of null-terminated array.
- Declare the function static
--- board/ti/common/cape_detect.c | 42 +++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-)
board/ti/common/cape_detect.c +40 -2
@@ -13,6 +13,44 @@#include "cape_detect.h" +struct name_mapping { +char part_number[17 ]; +char version[5 ]; +char overlay[64 ]; +}; + +static struct name_mapping extension_mapping[] = { + { +"BB-GREEN-HDMI" , +"00A0" , +"am335x-bone-hdmi-00a0.dtbo" , + } +}; + +static void set_cape_overlay (char *overlay,char *part_number,char *version) +{ +struct name_mapping *mapping; + +for (int i =0 ; i <ARRAY_SIZE (extension_mapping); i++) { + mapping = &extension_mapping[i]; + +if (strncmp (mapping->part_number, part_number, +sizeof (mapping->part_number))) +continue ; + +if (strncmp (mapping->version, version, +sizeof (mapping->version))) +continue ; + +strlcpy (overlay, mapping->overlay,sizeof (mapping->overlay)); +return ; + } + +/* Use default name extracted from the EEPROM */ +snprintf (overlay,sizeof (extension_mapping[0 ].overlay),"%s-%s.dtbo" , + part_number, version); +} +static void sanitize_field (char *text,size_t size) {char *c =NULL ;
@@ -82,8 +120,8 @@ static int ti_extension_board_scan(struct udevice *dev,printf ("BeagleBone Cape: %s (0x%x)\n" , eeprom_header.board_name, addr); -snprintf (cape.overlay,sizeof (cape.overlay),"%s-%s.dtbo" , - process_cape_part_number, process_cape_version); +set_cape_overlay (cape.overlay, process_cape_part_number, + process_cape_version);strlcpy (cape.name, eeprom_header.board_name,sizeof (eeprom_header.board_name)); strlcpy(cape.version, process_cape_version,
Signature · 1 line
2.43.0
Quoted 10 lines · Kory Maincent
Some extension boards have EEPROM part numbers that do not directly match their devicetree overlay filenames. Introduce a static
name_mappingtable and aset_cape_overlay()helper that translates the part number and version strings read from the EEPROM into the correct overlay filename.When no entry matches, fall back to the existing behavior of constructing the overlay name as "<part_number>-<version>.dtbo" directly from the EEPROM content.
[...]
Applied to u-boot/master, thanks!
[1/1] board: ti: cape_detect: Add overlay name lookup table for extension boards
commit: 3abc7c1d46de4211b2d11051033566c9ad2c2740
Signature · 1 line
Tom