21 #include <linux/kernel.h>
22 #include <linux/module.h>
24 #include <linux/reboot.h>
66 #define dump_sm_header(_h) _dump_sm_header(_h, __func__, __LINE__)
234 static unsigned int ps3_sm_force_power_off;
277 dev_dbg(&dev->
core,
"%s:%d: %xh\n", __func__, __LINE__, attr);
314 dev_dbg(&dev->
core,
"%s:%d: (%xh)\n", __func__, __LINE__, op);
326 payload.wake_source = wake_source;
343 static int ps3_sys_manager_send_request_shutdown(
356 dev_dbg(&dev->
core,
"%s:%d\n", __func__, __LINE__);
393 dev_dbg(&dev->
core,
"%s:%d: (%s)\n", __func__, __LINE__,
394 (status ?
"nak" :
"ack"));
428 BUG_ON(result &&
"need to retry here");
430 if (
event.version != 1) {
431 dev_dbg(&dev->
core,
"%s:%d: unsupported event version (%u)\n",
432 __func__, __LINE__,
event.version);
436 switch (
event.type) {
442 ps3_sm_force_power_off = 1;
452 dev_dbg(&dev->
core,
"%s:%d: POWER_RELEASED (%u ms)\n",
453 __func__, __LINE__,
event.value);
460 ps3_sm_force_power_off = 0;
470 dev_dbg(&dev->
core,
"%s:%d: RESET_RELEASED (%u ms)\n",
471 __func__, __LINE__,
event.value);
474 dev_dbg(&dev->
core,
"%s:%d: THERMAL_ALERT (zone %u)\n",
475 __func__, __LINE__,
event.value);
479 dev_dbg(&dev->
core,
"%s:%d: THERMAL_CLEARED (zone %u)\n",
480 __func__, __LINE__,
event.value);
484 __func__, __LINE__,
event.type);
507 dev_dbg(&dev->
core,
"%s:%d\n", __func__, __LINE__);
510 BUG_ON(result &&
"need to retry here");
515 if (
cmd.version != 1) {
516 dev_dbg(&dev->
core,
"%s:%d: unsupported cmd version (%u)\n",
517 __func__, __LINE__,
cmd.version);
523 __func__, __LINE__,
cmd.type);
527 ps3_sys_manager_send_response(dev, 0);
548 if (
header.version != 1) {
549 dev_dbg(&dev->
core,
"%s:%d: unsupported header version (%u)\n",
550 __func__, __LINE__,
header.version);
558 &&
header.payload_size != 16)) {
563 switch (
header.service_id) {
565 dev_dbg(&dev->
core,
"%s:%d: EVENT\n", __func__, __LINE__);
566 return ps3_sys_manager_handle_event(dev);
568 dev_dbg(&dev->
core,
"%s:%d: COMMAND\n", __func__, __LINE__);
569 return ps3_sys_manager_handle_cmd(dev);
571 dev_dbg(&dev->
core,
"%s:%d: REQUEST_ERROR\n", __func__,
576 dev_dbg(&dev->
core,
"%s:%d: unknown service_id (%u)\n",
577 __func__, __LINE__,
header.service_id);
592 ps3_sys_manager_send_request_shutdown(dev);
594 pr_emerg(
"System Halted, OK to turn off power\n");
596 while (ps3_sys_manager_handle_msg(dev)) {
622 dev_dbg(&dev->
core,
"%s:%d\n", __func__, __LINE__);
629 ps3_sys_manager_fin(dev);
646 dev_dbg(&dev->
core,
"%s:%d\n", __func__, __LINE__);
650 if (ps3_sm_force_power_off) {
653 ps3_sys_manager_final_power_off(dev);
658 ps3_sys_manager_send_attr(dev, 0);
662 ps3_sys_manager_fin(dev);
671 pr_debug(
"%s:%d\n", __func__, __LINE__);
687 pr_debug(
"%s:%d: %d\n", __func__, __LINE__, state);
705 ps3_sys_manager_handle_msg(dev);
714 dev_dbg(&dev->
core,
"%s:%d\n", __func__, __LINE__);
716 ops.power_off = ps3_sys_manager_final_power_off;
717 ops.restart = ps3_sys_manager_final_restart;
735 dev_dbg(&dev->
core,
"%s:%d\n", __func__, __LINE__);
741 dev_dbg(&dev->
core,
"%s:%d\n", __func__, __LINE__);
746 .core.core.name =
"ps3_sys_manager",
747 .probe = ps3_sys_manager_probe,
748 .remove = ps3_sys_manager_remove,
749 .shutdown = ps3_sys_manager_shutdown,
750 .work = ps3_sys_manager_work,
753 static int __init ps3_sys_manager_init(
void)
755 if (!firmware_has_feature(FW_FEATURE_PS3_LV1))