kboot: Call dt_set_dcp_firmware() from dt_carveout_reserved_regions()

This avoids having duplicate calls for dcpext* on each mayor SoC
variant. Fixes setting firmware versions for dcpext on t8103 and t8112.

Signed-off-by: Janne Grunau <j@jannau.net>
This commit is contained in:
Janne Grunau 2022-12-04 12:21:50 +01:00 committed by Hector Martin
parent 2abf2b1693
commit 159c553c6a

View file

@ -986,6 +986,37 @@ static int dt_device_set_reserved_mem(int node, dart_dev_t *dart, const char *na
return 0;
}
static int dt_set_dcp_firmware(const char *alias)
{
const char *path = fdt_get_alias(dt, alias);
if (!path)
return 0;
int node = fdt_path_offset(dt, path);
if (node < 0)
return 0;
if (firmware_set_fdt(dt, node, "apple,firmware-version", &os_firmware) < 0)
bail("FDT: Could not set apple,firmware-version for %s\n", path);
const struct fw_version_info *compat;
switch (os_firmware.version) {
case V12_4:
compat = &fw_versions[V12_3];
break;
default:
compat = &os_firmware;
break;
}
if (firmware_set_fdt(dt, node, "apple,firmware-compat", compat) < 0)
bail("FDT: Could not set apple,firmware-compat for %s\n", path);
return 0;
}
struct disp_mapping {
char region_adt[24];
char mem_fdt[24];
@ -1013,6 +1044,10 @@ static int dt_carveout_reserved_regions(const char *dcp_alias, const char *disp_
if (!fdt_get_alias(dt, dcp_alias))
return 0;
ret = dt_set_dcp_firmware(dcp_alias);
if (ret)
return ret;
int node = adt_path_offset(adt, "/chosen/carveout-memory-map");
if (node < 0)
bail("ADT: '/chosen/carveout-memory-map' not found\n");
@ -1268,37 +1303,6 @@ static struct disp_mapping dcpext_reserved_regions_t600x[MAX_DCPEXT][2] = {
#define ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
static int dt_set_dcp_firmware(const char *alias)
{
const char *path = fdt_get_alias(dt, alias);
if (!path)
return 0;
int node = fdt_path_offset(dt, path);
if (node < 0)
return 0;
if (firmware_set_fdt(dt, node, "apple,firmware-version", &os_firmware) < 0)
bail("FDT: Could not set apple,firmware-version for %s\n", path);
const struct fw_version_info *compat;
switch (os_firmware.version) {
case V12_4:
compat = &fw_versions[V12_3];
break;
default:
compat = &os_firmware;
break;
}
if (firmware_set_fdt(dt, node, "apple,firmware-compat", compat) < 0)
bail("FDT: Could not set apple,firmware-compat for %s\n", path);
return 0;
}
static int dt_set_display(void)
{
/* lock dart-disp0 to prevent old software from resetting it */
@ -1313,10 +1317,6 @@ static int dt_set_display(void)
int ret = 0;
ret = dt_set_dcp_firmware("dcp");
if (ret)
return ret;
if (!fdt_node_check_compatible(dt, 0, "apple,t8103")) {
ret = dt_carveout_reserved_regions("dcp", "disp0", "disp0_piodma",
disp_reserved_regions_t8103,
@ -1348,9 +1348,6 @@ static int dt_set_display(void)
char dcpext_alias[16];
snprintf(dcpext_alias, sizeof(dcpext_alias), "dcpext%d", n);
ret = dt_set_dcp_firmware(dcpext_alias);
if (ret)
break;
ret = dt_carveout_reserved_regions(dcpext_alias, NULL, NULL,
dcpext_reserved_regions_t600x[n],
ARRAY_SIZE(dcpext_reserved_regions_t600x[n]));