blob: e061b7d0632bdc01900ef81dae52f7afee0b9180 [file] [log] [blame]
Thomas Gleixner873e65b2019-05-27 08:55:15 +02001// SPDX-License-Identifier: GPL-2.0-only
Geoff Levand66c63b82007-06-16 08:03:54 +10002/*
3 * PS3 System Manager core.
4 *
5 * Copyright (C) 2007 Sony Computer Entertainment Inc.
6 * Copyright 2007 Sony Corp.
Geoff Levand66c63b82007-06-16 08:03:54 +10007 */
8
9#include <linux/kernel.h>
Paul Gortmaker66b15db2011-05-27 10:46:24 -040010#include <linux/export.h>
Geert Uytterhoevenca052f72008-03-27 11:38:31 +110011#include <asm/lv1call.h>
Geoff Levand66c63b82007-06-16 08:03:54 +100012#include <asm/ps3.h>
13
14/**
15 * Staticly linked routines that allow late binding of a loaded sys-manager
16 * module.
17 */
18
19static struct ps3_sys_manager_ops ps3_sys_manager_ops;
20
21/**
22 * ps3_register_sys_manager_ops - Bind ps3_sys_manager_ops to a module.
23 * @ops: struct ps3_sys_manager_ops.
24 *
25 * To be called from ps3_sys_manager_probe() and ps3_sys_manager_remove() to
26 * register call back ops for power control. Copies data to the static
27 * variable ps3_sys_manager_ops.
28 */
29
30void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops)
31{
32 BUG_ON(!ops);
33 BUG_ON(!ops->dev);
Dan Carpenter96efbab92020-03-27 20:26:23 +000034 ps3_sys_manager_ops = *ops;
Geoff Levand66c63b82007-06-16 08:03:54 +100035}
36EXPORT_SYMBOL_GPL(ps3_sys_manager_register_ops);
37
Geoff Levandfcc48072015-01-13 01:00:20 +000038void __noreturn ps3_sys_manager_power_off(void)
Geoff Levand66c63b82007-06-16 08:03:54 +100039{
40 if (ps3_sys_manager_ops.power_off)
41 ps3_sys_manager_ops.power_off(ps3_sys_manager_ops.dev);
42
Geert Uytterhoevenca052f72008-03-27 11:38:31 +110043 ps3_sys_manager_halt();
Geoff Levand66c63b82007-06-16 08:03:54 +100044}
45
Geoff Levandfcc48072015-01-13 01:00:20 +000046void __noreturn ps3_sys_manager_restart(void)
Geoff Levand66c63b82007-06-16 08:03:54 +100047{
48 if (ps3_sys_manager_ops.restart)
49 ps3_sys_manager_ops.restart(ps3_sys_manager_ops.dev);
50
Geert Uytterhoevenca052f72008-03-27 11:38:31 +110051 ps3_sys_manager_halt();
52}
53
Geoff Levandfcc48072015-01-13 01:00:20 +000054void __noreturn ps3_sys_manager_halt(void)
Geert Uytterhoevenca052f72008-03-27 11:38:31 +110055{
56 pr_emerg("System Halted, OK to turn off power\n");
Geoff Levand66c63b82007-06-16 08:03:54 +100057 local_irq_disable();
58 while (1)
Geert Uytterhoevenca052f72008-03-27 11:38:31 +110059 lv1_pause(1);
Geoff Levand66c63b82007-06-16 08:03:54 +100060}
Geert Uytterhoevenca052f72008-03-27 11:38:31 +110061