diff --git a/src/kboot.c b/src/kboot.c index 285a03022..868c0aff3 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -2715,18 +2715,32 @@ static int dt_reserve_asc_firmware(const char *adt_path, const char *adt_path_al return dt_reserve_asc_segments(adt_path, adt_path_alt, fdt_path, remap, base, false); } -static int dt_set_ave(void) -{ - if (chip_id != T8140) - return 0; +/* + * The AVE video encoder runs firmware that iBoot preloads. The ADT calls the + * encoder "ave" on the M2 and A18 Pro and "ave0" on the M1 Pro/Max and M4 Pro. + * The DT node is found by its compatible, so describing a SoC's encoder is all + * it takes. + */ +static const char *const ave_compatibles[] = { + "apple,t6000-ave", + "apple,t8112-ave", + "apple,t8140-ave", + "apple,t6041-ave", +}; - const char *path = "/soc/video-codec@285100000"; - int node = fdt_path_offset(dt, path); - if (node < 0) - return 0; +static int dt_set_ave_node(int node) +{ + char path[64]; + if (fdt_get_path(dt, node, path, sizeof(path))) + bail("FDT: AVE node path too long\n"); const char *reason = "invalid ADT firmware segments"; - int anode = adt_path_offset(adt, "/arm-io/ave"); + const char *adt_path = "/arm-io/ave"; + int anode = adt_path_offset(adt, adt_path); + if (anode < 0) { + adt_path = "/arm-io/ave0"; + anode = adt_path_offset(adt, adt_path); + } if (anode < 0) { reason = "ADT node absent"; goto disable; @@ -2794,7 +2808,7 @@ static int dt_set_ave(void) for (size_t i = 0; i < count; i++) crcs[i] = tinf_crc32((void *)seg[i].phys, seg[i].size); - if (dt_reserve_asc_firmware("/arm-io/ave", NULL, path, true, 0)) { + if (dt_reserve_asc_firmware(adt_path, NULL, path, true, 0)) { reason = "firmware reservation failed"; goto disable; } @@ -2818,6 +2832,16 @@ static int dt_set_ave(void) return 0; } +static int dt_set_ave(void) +{ + for (size_t i = 0; i < ARRAY_SIZE(ave_compatibles); i++) { + int node = fdt_node_offset_by_compatible(dt, -1, ave_compatibles[i]); + if (node >= 0) + return dt_set_ave_node(node); + } + return 0; +} + static const char dcpext_aliases[][8] = { "dcpext", "dcpext0", "dcpext1", "dcpext2", "dcpext3", "dcpext4", "dcpext5", "dcpext6", "dcpext7",