Skip to content

Commit bd117d7

Browse files
committed
kboot: Add support for handling poweroff on PRC devices with SMC.
Signed-off-by: Nick Chan <towinchenmi@gmail.com>
1 parent 7b7ab7a commit bd117d7

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

src/kboot.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,6 +2082,41 @@ static int dt_set_sep(void)
20822082
return 0;
20832083
}
20842084

2085+
static int dt_set_smc(void)
2086+
{
2087+
const char *region;
2088+
int reboot_node;
2089+
char smc_reboot[32];
2090+
int ret;
2091+
2092+
const char *path = fdt_get_alias(dt, "smc");
2093+
if (path == NULL)
2094+
return 0;
2095+
2096+
snprintf(smc_reboot, 32, "%s/reboot", path);
2097+
2098+
if ((reboot_node = fdt_path_offset(dt, smc_reboot)) < 0)
2099+
return 0;
2100+
2101+
if (fdt_node_check_compatible(dt, reboot_node, "apple,t8015-smc-reboot"))
2102+
return 0;
2103+
2104+
if (!(region = adt_getprop(adt, 0, "region-info", NULL))) {
2105+
printf("ADT: could not get region-info\n");
2106+
return 0;
2107+
}
2108+
2109+
if (strcmp(region, "CH/A")) // PRC
2110+
return 0;
2111+
2112+
ret = fdt_setprop_empty(dt, reboot_node, "prc-poweroff");
2113+
2114+
if (ret)
2115+
bail("FDT: could not set %s.prc-poweroff\n", smc_reboot);
2116+
2117+
return 0;
2118+
}
2119+
20852120
static int dt_set_sio_fwdata(const char *adt_path, const char *fdt_alias)
20862121
{
20872122
int node = fdt_path_offset(dt, fdt_alias);
@@ -2740,6 +2775,8 @@ int kboot_prepare_dt(void *fdt)
27402775
return -1;
27412776
if (dt_set_sep())
27422777
return -1;
2778+
if (dt_set_smc())
2779+
return -1;
27432780
if (dt_set_nvram())
27442781
return -1;
27452782
if (dt_set_ipd())

0 commit comments

Comments
 (0)