Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *  PS3 System Manager core.
0004  *
0005  *  Copyright (C) 2007 Sony Computer Entertainment Inc.
0006  *  Copyright 2007 Sony Corp.
0007  */
0008 
0009 #include <linux/kernel.h>
0010 #include <linux/export.h>
0011 #include <asm/lv1call.h>
0012 #include <asm/ps3.h>
0013 
0014 /**
0015  * Staticly linked routines that allow late binding of a loaded sys-manager
0016  * module.
0017  */
0018 
0019 static struct ps3_sys_manager_ops ps3_sys_manager_ops;
0020 
0021 /**
0022  * ps3_register_sys_manager_ops - Bind ps3_sys_manager_ops to a module.
0023  * @ops: struct ps3_sys_manager_ops.
0024  *
0025  * To be called from ps3_sys_manager_probe() and ps3_sys_manager_remove() to
0026  * register call back ops for power control.  Copies data to the static
0027  * variable ps3_sys_manager_ops.
0028  */
0029 
0030 void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops)
0031 {
0032     BUG_ON(!ops);
0033     BUG_ON(!ops->dev);
0034     ps3_sys_manager_ops = *ops;
0035 }
0036 EXPORT_SYMBOL_GPL(ps3_sys_manager_register_ops);
0037 
0038 void __noreturn ps3_sys_manager_power_off(void)
0039 {
0040     if (ps3_sys_manager_ops.power_off)
0041         ps3_sys_manager_ops.power_off(ps3_sys_manager_ops.dev);
0042 
0043     ps3_sys_manager_halt();
0044 }
0045 
0046 void __noreturn ps3_sys_manager_restart(void)
0047 {
0048     if (ps3_sys_manager_ops.restart)
0049         ps3_sys_manager_ops.restart(ps3_sys_manager_ops.dev);
0050 
0051     ps3_sys_manager_halt();
0052 }
0053 
0054 void __noreturn ps3_sys_manager_halt(void)
0055 {
0056     pr_emerg("System Halted, OK to turn off power\n");
0057     local_irq_disable();
0058     while (1)
0059         lv1_pause(1);
0060 }
0061