Skip to content

Commit 31a60d7

Browse files
committed
kboot_atc: Rename tunables
M3 introduces new tunables that have to be applied before the axi2af ones anyway so let's rename what used to be called fuses to common-a and what used to be called common to common-b. Also add the old name for backwards compatibility Signed-off-by: Sven Peter <sven@svenpeter.dev>
1 parent 6922394 commit 31a60d7

File tree

1 file changed

+45
-13
lines changed

1 file changed

+45
-13
lines changed

src/kboot_atc.c

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ struct atc_fuse_hw {
6969
static const struct adt_tunable_info atc_tunables[] = {
7070
/* global tunables applied after power on or reset */
7171
{"tunable_ATC0AXI2AF", "apple,tunable-axi2af", 0x0, 0x4000, true},
72-
{"tunable_ATC_FABRIC", "apple,tunable-common", 0x45000, 0x4000, true},
73-
{"tunable_USB_ACIOPHY_TOP", "apple,tunable-common", 0x0, 0x4000, true},
74-
{"tunable_AUS_CMN_SHM", "apple,tunable-common", 0xa00, 0x4000, true},
75-
{"tunable_AUS_CMN_TOP", "apple,tunable-common", 0x800, 0x4000, true},
76-
{"tunable_AUSPLL_CORE", "apple,tunable-common", 0x2200, 0x4000, true},
77-
{"tunable_AUSPLL_TOP", "apple,tunable-common", 0x2000, 0x4000, true},
78-
{"tunable_CIO3PLL_CORE", "apple,tunable-common", 0x2a00, 0x4000, true},
79-
{"tunable_CIO3PLL_TOP", "apple,tunable-common", 0x2800, 0x4000, true},
80-
{"tunable_CIO_CIO3PLL_TOP", "apple,tunable-common", 0x2800, 0x4000, false},
72+
{"tunable_ATC_FABRIC", "apple,tunable-common-b", 0x45000, 0x4000, true},
73+
{"tunable_USB_ACIOPHY_TOP", "apple,tunable-common-b", 0x0, 0x4000, true},
74+
{"tunable_AUS_CMN_SHM", "apple,tunable-common-b", 0xa00, 0x4000, true},
75+
{"tunable_AUS_CMN_TOP", "apple,tunable-common-b", 0x800, 0x4000, true},
76+
{"tunable_AUSPLL_CORE", "apple,tunable-common-b", 0x2200, 0x4000, true},
77+
{"tunable_AUSPLL_TOP", "apple,tunable-common-b", 0x2000, 0x4000, true},
78+
{"tunable_CIO3PLL_CORE", "apple,tunable-common-b", 0x2a00, 0x4000, true},
79+
{"tunable_CIO3PLL_TOP", "apple,tunable-common-b", 0x2800, 0x4000, true},
80+
{"tunable_CIO_CIO3PLL_TOP", "apple,tunable-common-b", 0x2800, 0x4000, false},
8181
/* lane-specific tunables applied after a cable is connected */
8282
{"tunable_DP_LN0_AUSPMA_TX_TOP", "apple,tunable-lane0-dp", 0xc000, 0x1000, true},
8383
{"tunable_DP_LN1_AUSPMA_TX_TOP", "apple,tunable-lane1-dp", 0x13000, 0x1000, true},
@@ -281,11 +281,11 @@ static int dt_append_atc_fuses_helper(void *dt, int fdt_node, const struct atc_f
281281
size_t n_fuses)
282282
{
283283
for (size_t i = 0; i < n_fuses; ++i) {
284-
if (fdt_appendprop_u32(dt, fdt_node, "apple,tunable-fuses", fuses[i].reg_offset) < 0)
284+
if (fdt_appendprop_u32(dt, fdt_node, "apple,tunable-common-a", fuses[i].reg_offset) < 0)
285285
return -1;
286-
if (fdt_appendprop_u32(dt, fdt_node, "apple,tunable-fuses", fuses[i].reg_mask) < 0)
286+
if (fdt_appendprop_u32(dt, fdt_node, "apple,tunable-common-a", fuses[i].reg_mask) < 0)
287287
return -1;
288-
if (fdt_appendprop_u32(dt, fdt_node, "apple,tunable-fuses", read_fuse(&fuses[i])) < 0)
288+
if (fdt_appendprop_u32(dt, fdt_node, "apple,tunable-common-a", read_fuse(&fuses[i])) < 0)
289289
return -1;
290290
}
291291

@@ -305,7 +305,7 @@ static int dt_append_fuses(void *dt, int adt_node, int fdt_node, int port)
305305
* property to indicate to the driver that no fuses are intentional.
306306
*/
307307
if (!atc_fuses[i].fuses)
308-
return fdt_setprop(dt, fdt_node, "apple,tunable-fuses", NULL, 0);
308+
return fdt_setprop(dt, fdt_node, "apple,tunable-common-a", NULL, 0);
309309

310310
return dt_append_atc_fuses_helper(dt, fdt_node, atc_fuses[i].fuses, atc_fuses[i].n_fuses);
311311
}
@@ -403,6 +403,36 @@ static void dt_copy_atc_tunables(void *dt, const char *adt_path, const char *dt_
403403
goto cleanup;
404404
}
405405

406+
/*
407+
* For backwards compatibility with downstream drivers copy apple,tunable-common-b to
408+
* apple,tunable-common and apple,tunable-common-a to apple,tunable-fuses.
409+
* Don't remove this before 2027-01-01.
410+
*/
411+
int prop_len;
412+
const void *tunable_common_a = fdt_getprop(dt, fdt_node, "apple,tunable-common-b", &prop_len);
413+
if (!tunable_common_a) {
414+
printf("kboot: Unable to find apple,tunable-common-b for %s\n", adt_path);
415+
goto cleanup;
416+
}
417+
ret = fdt_setprop(dt, fdt_node, "apple,tunable-common", tunable_common_a, prop_len);
418+
if (ret) {
419+
printf("kboot: Unable to copy apple,tunable-common-b to apple,tunable-common for %s\n",
420+
adt_path);
421+
goto cleanup;
422+
}
423+
424+
const void *tunable_common_b = fdt_getprop(dt, fdt_node, "apple,tunable-common-b", &prop_len);
425+
if (!tunable_common_b) {
426+
printf("kboot: Unable to find apple,tunable-common-b for %s\n", adt_path);
427+
goto cleanup;
428+
}
429+
ret = fdt_setprop(dt, fdt_node, "apple,tunable-fuses", tunable_common_b, prop_len);
430+
if (ret) {
431+
printf("kboot: Unable to copy apple,tunable-common-a to apple,tunable-fuses for %s\n",
432+
adt_path);
433+
goto cleanup;
434+
}
435+
406436
return;
407437

408438
cleanup:
@@ -413,6 +443,8 @@ static void dt_copy_atc_tunables(void *dt, const char *adt_path, const char *dt_
413443
*/
414444
for (size_t i = 0; i < sizeof(atc_tunables) / sizeof(*atc_tunables); ++i)
415445
fdt_delprop(dt, fdt_node, atc_tunables[i].fdt_name);
446+
fdt_delprop(dt, fdt_node, "apple,tunable-common-a");
447+
fdt_delprop(dt, fdt_node, "apple,tunable-common");
416448
fdt_delprop(dt, fdt_node, "apple,tunable-fuses");
417449

418450
printf("FDT: Unable to setup ATC tunables for %s - USB3/Thunderbolt will not work\n", adt_path);

0 commit comments

Comments
 (0)