Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 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> |
Paul Gortmaker | 66b15db | 2011-05-27 10:46:24 -0400 | [diff] [blame] | 22 | #include <linux/export.h> |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 23 | #include <asm/lv1call.h> |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 24 | #include <asm/ps3.h> |
| 25 | |
| 26 | /** |
| 27 | * Staticly linked routines that allow late binding of a loaded sys-manager |
| 28 | * module. |
| 29 | */ |
| 30 | |
| 31 | static struct ps3_sys_manager_ops ps3_sys_manager_ops; |
| 32 | |
| 33 | /** |
| 34 | * ps3_register_sys_manager_ops - Bind ps3_sys_manager_ops to a module. |
| 35 | * @ops: struct ps3_sys_manager_ops. |
| 36 | * |
| 37 | * To be called from ps3_sys_manager_probe() and ps3_sys_manager_remove() to |
| 38 | * register call back ops for power control. Copies data to the static |
| 39 | * variable ps3_sys_manager_ops. |
| 40 | */ |
| 41 | |
| 42 | void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops) |
| 43 | { |
| 44 | BUG_ON(!ops); |
| 45 | BUG_ON(!ops->dev); |
| 46 | ps3_sys_manager_ops = ops ? *ops : ps3_sys_manager_ops; |
| 47 | } |
| 48 | EXPORT_SYMBOL_GPL(ps3_sys_manager_register_ops); |
| 49 | |
Geoff Levand | fcc4807 | 2015-01-13 01:00:20 +0000 | [diff] [blame] | 50 | void __noreturn ps3_sys_manager_power_off(void) |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 51 | { |
| 52 | if (ps3_sys_manager_ops.power_off) |
| 53 | ps3_sys_manager_ops.power_off(ps3_sys_manager_ops.dev); |
| 54 | |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 55 | ps3_sys_manager_halt(); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 56 | } |
| 57 | |
Geoff Levand | fcc4807 | 2015-01-13 01:00:20 +0000 | [diff] [blame] | 58 | void __noreturn ps3_sys_manager_restart(void) |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 59 | { |
| 60 | if (ps3_sys_manager_ops.restart) |
| 61 | ps3_sys_manager_ops.restart(ps3_sys_manager_ops.dev); |
| 62 | |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 63 | ps3_sys_manager_halt(); |
| 64 | } |
| 65 | |
Geoff Levand | fcc4807 | 2015-01-13 01:00:20 +0000 | [diff] [blame] | 66 | void __noreturn ps3_sys_manager_halt(void) |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 67 | { |
| 68 | pr_emerg("System Halted, OK to turn off power\n"); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 69 | local_irq_disable(); |
| 70 | while (1) |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 71 | lv1_pause(1); |
Geoff Levand | 66c63b8 | 2007-06-16 08:03:54 +1000 | [diff] [blame] | 72 | } |
Geert Uytterhoeven | ca052f7 | 2008-03-27 11:38:31 +1100 | [diff] [blame] | 73 | |