sys-manager-core.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #include <linux/kernel.h>
  9. #include <linux/export.h>
  10. #include <asm/lv1call.h>
  11. #include <asm/ps3.h>
  12. /**
  13. * Staticly linked routines that allow late binding of a loaded sys-manager
  14. * module.
  15. */
  16. static struct ps3_sys_manager_ops ps3_sys_manager_ops;
  17. /**
  18. * ps3_register_sys_manager_ops - Bind ps3_sys_manager_ops to a module.
  19. * @ops: struct ps3_sys_manager_ops.
  20. *
  21. * To be called from ps3_sys_manager_probe() and ps3_sys_manager_remove() to
  22. * register call back ops for power control. Copies data to the static
  23. * variable ps3_sys_manager_ops.
  24. */
  25. void ps3_sys_manager_register_ops(const struct ps3_sys_manager_ops *ops)
  26. {
  27. BUG_ON(!ops);
  28. BUG_ON(!ops->dev);
  29. ps3_sys_manager_ops = *ops;
  30. }
  31. EXPORT_SYMBOL_GPL(ps3_sys_manager_register_ops);
  32. void __noreturn ps3_sys_manager_power_off(void)
  33. {
  34. if (ps3_sys_manager_ops.power_off)
  35. ps3_sys_manager_ops.power_off(ps3_sys_manager_ops.dev);
  36. ps3_sys_manager_halt();
  37. }
  38. void __noreturn ps3_sys_manager_restart(void)
  39. {
  40. if (ps3_sys_manager_ops.restart)
  41. ps3_sys_manager_ops.restart(ps3_sys_manager_ops.dev);
  42. ps3_sys_manager_halt();
  43. }
  44. void __noreturn ps3_sys_manager_halt(void)
  45. {
  46. pr_emerg("System Halted, OK to turn off power\n");
  47. local_irq_disable();
  48. while (1)
  49. lv1_pause(1);
  50. }