Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 34 additions & 10 deletions src/kboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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",
Expand Down
Loading