Skip to content

Commit 83da38d

Browse files
committed
openrisc: Allow power off handler overriding
The OpenRISC platform always defines a default pm_power_off hanlder which is only useful for simulators. Having this set also means power management drivers like syscon-power are not able to wire in their own pm_power_off handlers. Fix this by not setting the pm_power_off handler by default and fallback to the simulator power off handler if no handler is set. This has been tested with a new OpenRISC virt platform I am working on for QEMU. https://github.com/stffrdhrn/qemu/commits/or1k-virt Cc: Jason A. Donenfeld <[email protected]> Signed-off-by: Stafford Horne <[email protected]>
1 parent ed3a88d commit 83da38d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

arch/openrisc/kernel/process.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ void machine_restart(char *cmd)
6262
while (1);
6363
}
6464

65+
/*
66+
* This is used if pm_power_off has not been set by a power management
67+
* driver, in this case we can assume we are on a simulator. On
68+
* OpenRISC simulators l.nop 1 will trigger the simulator exit.
69+
*/
70+
static void default_power_off(void)
71+
{
72+
__asm__("l.nop 1");
73+
}
74+
6575
/*
6676
* Similar to machine_power_off, but don't shut off power. Add code
6777
* here to freeze the system for e.g. post-mortem debug purpose when
@@ -77,7 +87,10 @@ void machine_halt(void)
7787
void machine_power_off(void)
7888
{
7989
printk(KERN_INFO "*** MACHINE POWER OFF ***\n");
80-
__asm__("l.nop 1");
90+
if (pm_power_off != NULL)
91+
pm_power_off();
92+
else
93+
default_power_off();
8194
}
8295

8396
/*
@@ -91,7 +104,7 @@ void arch_cpu_idle(void)
91104
mtspr(SPR_PMR, mfspr(SPR_PMR) | SPR_PMR_DME);
92105
}
93106

94-
void (*pm_power_off) (void) = machine_power_off;
107+
void (*pm_power_off)(void) = NULL;
95108
EXPORT_SYMBOL(pm_power_off);
96109

97110
/*

0 commit comments

Comments
 (0)