Thomas Gleixner | 873e65b | 2019-05-27 08:55:15 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 2 | /* |
| 3 | * PS3 System Manager core. |
| 4 | * |
| 5 | * Copyright (C) 2007 Sony Computer Entertainment Inc. |
| 6 | * Copyright 2007 Sony Corp. |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <linux/kernel.h> |
Paul Gortmaker | 66b15db | 2011-05-27 10:46:24 -0400 | [diff] [blame] | 10 | #include <linux/export.h> |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 11 | #include <asm/lv1call.h> |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 12 | #include <asm/ps3.h> |
| 13 | |
| 14 | /** |
| 15 | * Staticly linked routines that allow late binding of a loaded sys-manager |
| 16 | * module. |
| 17 | */ |
| 18 | |
| 19 | static 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 | |
| 30 | void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops) |
| 31 | { |
| 32 | BUG_ON(!ops); |
| 33 | BUG_ON(!ops->dev); |
Dan Carpenter | 96efbab9 | 2020-03-27 20:26:23 +0000 | [diff] [blame] | 34 | ps3_sys_manager_ops = *ops; |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 35 | } |
| 36 | EXPORT_SYMBOL_GPL(ps3_sys_manager_register_ops); |
| 37 | |
Geoff Levand | fcc4807 | 2015-01-13 01:00:20 +0000 | [diff] [blame] | 38 | void __noreturn ps3_sys_manager_power_off(void) |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 39 | { |
| 40 | if (ps3_sys_manager_ops.power_off) |
| 41 | ps3_sys_manager_ops.power_off(ps3_sys_manager_ops.dev); |
| 42 | |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 43 | ps3_sys_manager_halt(); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 44 | } |
| 45 | |
Geoff Levand | fcc4807 | 2015-01-13 01:00:20 +0000 | [diff] [blame] | 46 | void __noreturn ps3_sys_manager_restart(void) |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 47 | { |
| 48 | if (ps3_sys_manager_ops.restart) |
| 49 | ps3_sys_manager_ops.restart(ps3_sys_manager_ops.dev); |
| 50 | |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 51 | ps3_sys_manager_halt(); |
| 52 | } |
| 53 | |
Geoff Levand | fcc4807 | 2015-01-13 01:00:20 +0000 | [diff] [blame] | 54 | void __noreturn ps3_sys_manager_halt(void) |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 55 | { |
| 56 | pr_emerg("System Halted, OK to turn off power\n"); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 57 | local_irq_disable(); |
| 58 | while (1) |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 59 | lv1_pause(1); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 60 | } |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 61 | |