blob: 9c842c41684acd79adc2b9bceb5bb08e7abe6d3e [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001// SPDX-License-Identifier: GPL-2.0-only
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00002/*
3 * Copyright (C) 2012 Regents of the University of California
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00004 */
5
6#include <linux/reboot.h>
David Brazdil0f672f62019-12-10 10:32:29 +00007#include <linux/pm.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00008
David Brazdil0f672f62019-12-10 10:32:29 +00009static void default_power_off(void)
10{
Olivier Deprez157378f2022-04-04 15:47:50 +020011 while (1)
12 wait_for_interrupt();
David Brazdil0f672f62019-12-10 10:32:29 +000013}
14
Olivier Deprez92d4c212022-12-06 15:05:30 +010015void (*pm_power_off)(void) = NULL;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000016EXPORT_SYMBOL(pm_power_off);
17
18void machine_restart(char *cmd)
19{
20 do_kernel_restart(cmd);
21 while (1);
22}
23
24void machine_halt(void)
25{
Olivier Deprez92d4c212022-12-06 15:05:30 +010026 if (pm_power_off != NULL)
27 pm_power_off();
28 else
29 default_power_off();
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000030}
31
32void machine_power_off(void)
33{
Olivier Deprez92d4c212022-12-06 15:05:30 +010034 if (pm_power_off != NULL)
35 pm_power_off();
36 else
37 default_power_off();
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000038}