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
16 changes: 16 additions & 0 deletions src/kboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -12688,6 +12688,12 @@ __attribute__((unused)) static int dt_transfer_virtios(void)
* performance-controller node ("apple,<soc>-clpc") as
* apple,low-power-frequency-max-mhz, in the same unit. Without either,
* nothing is done.
*
* With the ceiling, the package power target of Low Power mode
* (pkg-lpm-power-target, watts in 8.24 fixed point; 255.0 means none) goes
* to the same node as apple,low-power-mw, in milliwatts, where the node names
* the SMC power reading the OS holds at it (apple,power-key-id). Other nodes
* keep their own target, if any.
*/
static int dt_set_clpc_low_power(void)
{
Expand All @@ -12699,6 +12705,11 @@ static int dt_set_clpc_low_power(void)
if (ADT_GETPROP(adt, anode, "cpu-low-power-frequency-max", &mhz) < 0 || !mhz)
return 0;

u32 target, mw = 0;
if (ADT_GETPROP(adt, anode, "pkg-lpm-power-target", &target) >= 0 && target &&
target < (255U << 24))
mw = (u32)(((u64)target * 1000) >> 24);

for (int node = fdt_next_node(dt, -1, NULL); node >= 0; node = fdt_next_node(dt, node, NULL)) {
int count = fdt_stringlist_count(dt, node, "compatible");
bool clpc = false;
Expand All @@ -12719,6 +12730,11 @@ static int dt_set_clpc_low_power(void)
if (fdt_setprop_u32(dt, node, "apple,low-power-frequency-max-mhz", mhz))
bail("FDT: CLPC: cannot set apple,low-power-frequency-max-mhz\n");
printf("FDT: CLPC: Low Power mode CPU ceiling %u MHz\n", mhz);
if (mw && fdt_getprop(dt, node, "apple,power-key-id", NULL)) {
if (fdt_setprop_u32(dt, node, "apple,low-power-mw", mw))
bail("FDT: CLPC: cannot set apple,low-power-mw\n");
printf("FDT: CLPC: Low Power mode power target %u mW\n", mw);
}
return 0;
}

Expand Down
Loading