Loading...
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * PS3 System Manager core.
4 *
5 * Copyright (C) 2007 Sony Computer Entertainment Inc.
6 * Copyright 2007 Sony Corp.
7 */
8
9#include <linux/kernel.h>
10#include <linux/export.h>
11#include <asm/lv1call.h>
12#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);
34 ps3_sys_manager_ops = *ops;
35}
36EXPORT_SYMBOL_GPL(ps3_sys_manager_register_ops);
37
38void __noreturn ps3_sys_manager_power_off(void)
39{
40 if (ps3_sys_manager_ops.power_off)
41 ps3_sys_manager_ops.power_off(ps3_sys_manager_ops.dev);
42
43 ps3_sys_manager_halt();
44}
45
46void __noreturn ps3_sys_manager_restart(void)
47{
48 if (ps3_sys_manager_ops.restart)
49 ps3_sys_manager_ops.restart(ps3_sys_manager_ops.dev);
50
51 ps3_sys_manager_halt();
52}
53
54void __noreturn ps3_sys_manager_halt(void)
55{
56 pr_emerg("System Halted, OK to turn off power\n");
57 local_irq_disable();
58 while (1)
59 lv1_pause(1);
60}
61
1/*
2 * PS3 System Manager core.
3 *
4 * Copyright (C) 2007 Sony Computer Entertainment Inc.
5 * Copyright 2007 Sony Corp.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <asm/lv1call.h>
23#include <asm/ps3.h>
24
25/**
26 * Staticly linked routines that allow late binding of a loaded sys-manager
27 * module.
28 */
29
30static struct ps3_sys_manager_ops ps3_sys_manager_ops;
31
32/**
33 * ps3_register_sys_manager_ops - Bind ps3_sys_manager_ops to a module.
34 * @ops: struct ps3_sys_manager_ops.
35 *
36 * To be called from ps3_sys_manager_probe() and ps3_sys_manager_remove() to
37 * register call back ops for power control. Copies data to the static
38 * variable ps3_sys_manager_ops.
39 */
40
41void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops)
42{
43 BUG_ON(!ops);
44 BUG_ON(!ops->dev);
45 ps3_sys_manager_ops = ops ? *ops : ps3_sys_manager_ops;
46}
47EXPORT_SYMBOL_GPL(ps3_sys_manager_register_ops);
48
49void ps3_sys_manager_power_off(void)
50{
51 if (ps3_sys_manager_ops.power_off)
52 ps3_sys_manager_ops.power_off(ps3_sys_manager_ops.dev);
53
54 ps3_sys_manager_halt();
55}
56
57void ps3_sys_manager_restart(void)
58{
59 if (ps3_sys_manager_ops.restart)
60 ps3_sys_manager_ops.restart(ps3_sys_manager_ops.dev);
61
62 ps3_sys_manager_halt();
63}
64
65void ps3_sys_manager_halt(void)
66{
67 pr_emerg("System Halted, OK to turn off power\n");
68 local_irq_disable();
69 while (1)
70 lv1_pause(1);
71}
72