forked from Minki/linux
f2928e224d
Set pm_power_off to NULL like on all other architectures, check if it is set in machine_halt() and machine_power_off() and fallback to default_power_off if no other power driver got registered. This brings riscv architecture inline with all other architectures, and allows to reuse exiting power drivers unmodified. Kernels without legacy SBI v0.1 extensions (CONFIG_RISCV_SBI_V01 is not set), do not set pm_power_off to sbi_shutdown(). There is no support for SBI v0.3 system reset extension either. This prevents using gpio_poweroff on SiFive HiFive Unmatched. Tested on SiFive HiFive unmatched, with a dtb specifying gpio-poweroff node and kernel complied without CONFIG_RISCV_SBI_V01. BugLink: https://bugs.launchpad.net/bugs/1942806 Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com> Reviewed-by: Anup Patel <anup@brainfault.org> Tested-by: Ron Economos <w6rz@comcast.net> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
39 lines
585 B
C
39 lines
585 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2012 Regents of the University of California
|
|
*/
|
|
|
|
#include <linux/reboot.h>
|
|
#include <linux/pm.h>
|
|
|
|
static void default_power_off(void)
|
|
{
|
|
while (1)
|
|
wait_for_interrupt();
|
|
}
|
|
|
|
void (*pm_power_off)(void) = NULL;
|
|
EXPORT_SYMBOL(pm_power_off);
|
|
|
|
void machine_restart(char *cmd)
|
|
{
|
|
do_kernel_restart(cmd);
|
|
while (1);
|
|
}
|
|
|
|
void machine_halt(void)
|
|
{
|
|
if (pm_power_off != NULL)
|
|
pm_power_off();
|
|
else
|
|
default_power_off();
|
|
}
|
|
|
|
void machine_power_off(void)
|
|
{
|
|
if (pm_power_off != NULL)
|
|
pm_power_off();
|
|
else
|
|
default_power_off();
|
|
}
|