diff options
author | Stafford Horne <shorne@gmail.com> | 2022-05-21 10:39:30 +0900 |
---|---|---|
committer | Stafford Horne <shorne@gmail.com> | 2022-05-23 17:15:50 +0900 |
commit | 83da38d82b2f7ac207646e55be94e8bd642e2c39 (patch) | |
tree | c2dee6643ee127c27d9c0e98a6f158b261d34561 /arch/openrisc | |
parent | ed3a88d7dbbb924312a707d5f295b7a31e2f8d2d (diff) | |
download | linux-83da38d82b2f7ac207646e55be94e8bd642e2c39.tar.bz2 |
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 <Jason@zx2c4.com>
Signed-off-by: Stafford Horne <shorne@gmail.com>
Diffstat (limited to 'arch/openrisc')
-rw-r--r-- | arch/openrisc/kernel/process.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c index 4cce95fa6eb5..1d4c0921aafa 100644 --- a/arch/openrisc/kernel/process.c +++ b/arch/openrisc/kernel/process.c @@ -63,6 +63,16 @@ void machine_restart(char *cmd) } /* + * This is used if pm_power_off has not been set by a power management + * driver, in this case we can assume we are on a simulator. On + * OpenRISC simulators l.nop 1 will trigger the simulator exit. + */ +static void default_power_off(void) +{ + __asm__("l.nop 1"); +} + +/* * Similar to machine_power_off, but don't shut off power. Add code * here to freeze the system for e.g. post-mortem debug purpose when * possible. This halt has nothing to do with the idle halt. @@ -77,7 +87,10 @@ void machine_halt(void) void machine_power_off(void) { printk(KERN_INFO "*** MACHINE POWER OFF ***\n"); - __asm__("l.nop 1"); + if (pm_power_off != NULL) + pm_power_off(); + else + default_power_off(); } /* @@ -91,7 +104,7 @@ void arch_cpu_idle(void) mtspr(SPR_PMR, mfspr(SPR_PMR) | SPR_PMR_DME); } -void (*pm_power_off) (void) = machine_power_off; +void (*pm_power_off)(void) = NULL; EXPORT_SYMBOL(pm_power_off); /* |