aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnshuman Khandual <khandual@linux.vnet.ibm.com>2014-08-13 14:27:44 +0530
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-08-13 19:01:36 +1000
commit0a22f85f524f366a3e2ef2af4a3faa0e9cef26ca (patch)
tree8738d392c6bac1af311c49d64ea30f7ffb714a9f
parent41534a8beee61413ef302370375f56542b8f029f (diff)
downloadskiboot-0a22f85f524f366a3e2ef2af4a3faa0e9cef26ca.zip
skiboot-0a22f85f524f366a3e2ef2af4a3faa0e9cef26ca.tar.gz
skiboot-0a22f85f524f366a3e2ef2af4a3faa0e9cef26ca.tar.bz2
dpo: Move the FSP async messagae handling into a separate file
This patch moves the DPO message handling from FSP core code into a separate file to make it more cleaner and to add OPAL interfaces in the subsequent patch. It does not change anything functionally. Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--hw/fsp/Makefile.inc2
-rw-r--r--hw/fsp/fsp-dpo.c94
-rw-r--r--hw/fsp/fsp.c47
-rw-r--r--include/fsp.h3
-rw-r--r--platforms/ibm-fsp/common.c4
5 files changed, 102 insertions, 48 deletions
diff --git a/hw/fsp/Makefile.inc b/hw/fsp/Makefile.inc
index 95f1f04..d4654d5 100644
--- a/hw/fsp/Makefile.inc
+++ b/hw/fsp/Makefile.inc
@@ -3,7 +3,7 @@ SUBDIRS += hw/fsp
FSP_OBJS = fsp.o fsp-console.o fsp-rtc.o fsp-nvram.o fsp-sysparam.o
FSP_OBJS += fsp-surveillance.o fsp-codeupdate.o fsp-sensor.o
FSP_OBJS += fsp-diag.o fsp-leds.o fsp-mem-err.o fsp-op-panel.o
-FSP_OBJS += fsp-elog-read.o fsp-elog-write.o fsp-epow.o
+FSP_OBJS += fsp-elog-read.o fsp-elog-write.o fsp-epow.o fsp-dpo.o
FSP_OBJS += fsp-dump.o fsp-mdst-table.o
FSP_OBJS += fsp-attn.o
FSP = hw/fsp/built-in.o
diff --git a/hw/fsp/fsp-dpo.c b/hw/fsp/fsp-dpo.c
new file mode 100644
index 0000000..23ab1ba
--- /dev/null
+++ b/hw/fsp/fsp-dpo.c
@@ -0,0 +1,94 @@
+/* Copyright 2013-2014 IBM Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * Handle FSP DPO (Delayed Power Off) event notification
+ */
+#include <skiboot.h>
+#include <console.h>
+#include <fsp.h>
+#include <device.h>
+#include <stdio.h>
+#include <opal.h>
+#include <opal-msg.h>
+
+#define PREFIX "FSPDPO: "
+
+static bool fsp_dpo_pending = false;
+
+/* Process FSP DPO init message */
+static void fsp_process_dpo(struct fsp_msg *msg)
+{
+ u32 cmd = FSP_RSP_INIT_DPO;
+ int rc;
+
+ /* DPO message does not have the correct signatures */
+ if ((msg->data.bytes[0] != 0xf4) || (msg->data.bytes[1] != 0x20)) {
+ printf("DPO: Message signatures did not match\n");
+ cmd |= FSP_STATUS_INVALID_CMD;
+ fsp_queue_msg(fsp_mkmsg(cmd, 0), fsp_freemsg);
+ return;
+ }
+
+ /* Sapphire is already in "DPO pending" state */
+ if (fsp_dpo_pending) {
+ printf("DPO: Sapphire is already in DPO pending state\n");
+ cmd |= FSP_STATUS_INVALID_DPOSTATE;
+ fsp_queue_msg(fsp_mkmsg(cmd, 0), fsp_freemsg);
+ return;
+ }
+
+ /* Inform the host about DPO */
+ rc = opal_queue_msg(OPAL_MSG_DPO, NULL, NULL);
+ if (rc) {
+ printf("DPO: OPAL message queuing failed\n");
+ return;
+ }
+
+ /* Acknowledge the FSP on DPO */
+ fsp_queue_msg(fsp_mkmsg(cmd, 0), fsp_freemsg);
+ fsp_dpo_pending = true;
+ /*
+ * Sapphire is now in DPO pending state. After first detecting DPO
+ * condition from Sapphire, the host will have 45 minutes to prepare
+ * the system for shutdown. The host must take all necessary actions
+ * required in that regard and at the end shutdown itself. The host
+ * shutdown sequence eventually will make the call OPAL_CEC_POWER_DOWN
+ * which in turn ask the FSP to shutdown the CEC. If the FSP does not
+ * receive the cec power down command from Sapphire within 45 minutes,
+ * it will assume that the host and the Sapphire has processed the DPO
+ * sequence successfully and hence force power off the system.
+ */
+}
+
+/* Handle DPO sub-command from FSP */
+static bool fsp_dpo_message(u32 cmd_sub_mod, struct fsp_msg *msg)
+{
+ if (cmd_sub_mod == FSP_CMD_INIT_DPO) {
+ printf(PREFIX "SP initiated Delayed Power Off (DPO)\n");
+ fsp_process_dpo(msg);
+ }
+ return false;
+}
+
+static struct fsp_client fsp_dpo_client = {
+ .message = fsp_dpo_message,
+};
+
+void fsp_dpo_init(void)
+{
+ fsp_register_client(&fsp_dpo_client, FSP_MCLASS_SERVICE);
+ printf(PREFIX "FSP DPO support initialized\n");
+}
diff --git a/hw/fsp/fsp.c b/hw/fsp/fsp.c
index 2189bbb..57cba31 100644
--- a/hw/fsp/fsp.c
+++ b/hw/fsp/fsp.c
@@ -100,9 +100,6 @@ static u64 fsp_hir_timeout;
#define FSP_CRITICAL_OP_TIMEOUT 128
#define FSP_DRCR_CLEAR_TIMEOUT 128
-/* DPO pending state */
-static bool fsp_dpo_pending = false;
-
/*
* We keep track on last logged values for some things to print only on
* value changes, but also to releive pressure on the tracer which
@@ -1123,7 +1120,6 @@ static bool fsp_local_command(u32 cmd_sub_mod, struct fsp_msg *msg)
{
u32 cmd = 0;
u32 rsp_data = 0;
- int rc;
switch(cmd_sub_mod) {
case FSP_CMD_CONTINUE_IPL:
@@ -1184,49 +1180,6 @@ static bool fsp_local_command(u32 cmd_sub_mod, struct fsp_msg *msg)
fsp_repost_queued_msgs_post_rr();
}
return true;
- case FSP_CMD_INIT_DPO:
- printf("FSP: SP initiated DPO (Delayed Power Off)\n");
- cmd = FSP_RSP_INIT_DPO;
-
- /* DPO message does not have the correct signatures */
- if ((msg->data.bytes[0] != 0xf4) || (msg->data.bytes[1] != 0x20)) {
- printf("DPO: Message signatures did not match\n");
- cmd |= FSP_STATUS_INVALID_CMD;
- fsp_queue_msg(fsp_mkmsg(cmd, 0), fsp_freemsg);
- return false;
- }
-
- /* Sapphire is already in "DPO pending" state */
- if (fsp_dpo_pending) {
- printf("DPO: Sapphire is already in DPO pending state\n");
- cmd |= FSP_STATUS_INVALID_DPOSTATE;
- fsp_queue_msg(fsp_mkmsg(cmd, 0), fsp_freemsg);
- return false;
- }
-
- /* Inform the host about DPO */
- rc = opal_queue_msg(OPAL_MSG_DPO, NULL, NULL);
- if (rc) {
- printf("DPO: OPAL message queuing failed\n");
- return false;
- }
-
- /* Acknowledge the FSP on DPO */
- fsp_queue_msg(fsp_mkmsg(cmd, 0), fsp_freemsg);
- fsp_dpo_pending = true;
-
- /*
- * Sapphire is now in DPO pending state. After first detecting DPO
- * condition from Sapphire, the host will have 45 minutes to prepare
- * the system for shutdown. The host must take all necessary actions
- * required in that regard and at the end shutdown itself. The host
- * shutdown sequence eventually will make the call OPAL_CEC_POWER_DOWN
- * which in turn ask the FSP to shutdown the CEC. If the FSP does not
- * receive the cec power down command from Sapphire within 45 minutes,
- * it will assume that the host and the Sapphire has processed the DPO
- * sequence successfully and hence force power off the system.
- */
- return true;
case FSP_CMD_CLOSE_HMC_INTF:
/* Close the HMC interface */
/* Though Sapphire does not support a HMC connection, the FSP
diff --git a/include/fsp.h b/include/fsp.h
index 58ea36a..53d03f9 100644
--- a/include/fsp.h
+++ b/include/fsp.h
@@ -761,4 +761,7 @@ extern void fsp_set_led_state(struct fsp_msg *msg);
/* EPOW */
extern void fsp_epow_init(void);
+/* DPO */
+extern void fsp_dpo_init(void);
+
#endif /* __FSP_H */
diff --git a/platforms/ibm-fsp/common.c b/platforms/ibm-fsp/common.c
index 91eaeea..4a2c6c1 100644
--- a/platforms/ibm-fsp/common.c
+++ b/platforms/ibm-fsp/common.c
@@ -146,6 +146,10 @@ void ibm_fsp_init(void)
op_display(OP_LOG, OP_MOD_INIT, 0x000A);
fsp_epow_init();
+ /* EPOW */
+ op_display(OP_LOG, OP_MOD_INIT, 0x000B);
+ fsp_dpo_init();
+
/* Setup console */
if (fsp_present())
fsp_console_add_nodes();