diff mbox series

[16/17] Move platform specific PRD functionality to struct platform

Message ID 20190618072925.5299-17-stewart@linux.ibm.com
State Accepted
Headers show
Series FSP code free OPAL | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (dbf27b6c4af84addb36bd3be34f96580aba9c873)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot fail Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Stewart Smith June 18, 2019, 7:29 a.m. UTC
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
---
 hw/prd.c                    | 36 +++++++++++++++++++++++++-----------
 include/platform.h          | 17 +++++++++++++++++
 platforms/ibm-fsp/common.c  |  9 +++++++++
 platforms/ibm-fsp/firenze.c |  1 +
 platforms/ibm-fsp/ibm-fsp.h |  1 +
 platforms/ibm-fsp/zz.c      |  1 +
 6 files changed, 54 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/hw/prd.c b/hw/prd.c
index fea8cf054c24..904ed2c2c64c 100644
--- a/hw/prd.c
+++ b/hw/prd.c
@@ -130,7 +130,9 @@  static void prd_msg_consumed(void *data, int status)
 			      "PRD: Failed to send FSP -> HBRT message\n");
 			notify_status = FSP_STATUS_GENERIC_FAILURE;
 		}
-		hservice_hbrt_msg_response(notify_status);
+		assert(platform.prd);
+		assert(platform.prd->msg_response);
+		platform.prd->msg_response(notify_status);
 		break;
 	case OPAL_PRD_MSG_TYPE_SBE_PASSTHROUGH:
 		proc = msg->sbe_passthrough.chip;
@@ -529,9 +531,11 @@  static int prd_msg_handle_firmware_req(struct opal_prd_msg *msg)
 		rc = 0;
 		break;
 	case PRD_FW_MSG_TYPE_ERROR_LOG:
-		rc = hservice_send_error_log(fw_req->errorlog.plid,
-					     fw_req->errorlog.size,
-					     fw_req->errorlog.data);
+		assert(platform.prd);
+		assert(platform.prd->send_error_log);
+		rc = platform.prd->send_error_log(fw_req->errorlog.plid,
+						  fw_req->errorlog.size,
+						  fw_req->errorlog.data);
 		/* Return generic response to HBRT */
 		fw_resp->type = cpu_to_be64(PRD_FW_MSG_TYPE_RESP_GENERIC);
 		fw_resp->generic_resp.status = cpu_to_be64(rc);
@@ -604,7 +608,9 @@  static int prd_msg_handle_firmware_req(struct opal_prd_msg *msg)
 		unlock(&events_lock);
 
 		/* Send message to FSP */
-		rc = hservice_send_hbrt_msg(&(fw_resp->mbox_msg), data_len);
+		assert(platform.prd);
+		assert(platform.prd->send_hbrt_msg);
+		rc = platform.prd->send_hbrt_msg(&(fw_resp->mbox_msg), data_len);
 
 		/*
 		 * Callback handler from hservice_send_hbrt_msg will take
@@ -669,16 +675,24 @@  static int64_t opal_prd_msg(struct opal_prd_msg *msg)
 		rc = prd_msg_handle_firmware_req(msg);
 		break;
 	case OPAL_PRD_MSG_TYPE_FSP_OCC_RESET_STATUS:
-		rc = fsp_occ_reset_status(msg->fsp_occ_reset_status.chip,
-					  msg->fsp_occ_reset_status.status);
+		assert(platform.prd);
+		assert(platform.prd->fsp_occ_reset_status);
+		rc = platform.prd->fsp_occ_reset_status(
+			msg->fsp_occ_reset_status.chip,
+			msg->fsp_occ_reset_status.status);
 		break;
 	case OPAL_PRD_MSG_TYPE_CORE_SPECIAL_WAKEUP:
-		rc = hservice_wakeup(msg->spl_wakeup.core,
-				     msg->spl_wakeup.mode);
+		assert(platform.prd);
+		assert(platform.prd->wakeup);
+		rc = platform.prd->wakeup(msg->spl_wakeup.core,
+					  msg->spl_wakeup.mode);
 		break;
 	case OPAL_PRD_MSG_TYPE_FSP_OCC_LOAD_START_STATUS:
-		rc = fsp_occ_load_start_status(msg->fsp_occ_reset_status.chip,
-					msg->fsp_occ_reset_status.status);
+		assert(platform.prd);
+		assert(platform.prd->fsp_occ_load_start_status);
+		rc = platform.prd->fsp_occ_load_start_status(
+			msg->fsp_occ_reset_status.chip,
+			msg->fsp_occ_reset_status.status);
 		break;
 	default:
 		prlog(PR_DEBUG, "PRD: Unsupported prd message type : 0x%x\n",
diff --git a/include/platform.h b/include/platform.h
index f17847ac0d60..0326e1a247e4 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -89,6 +89,18 @@  struct platform_psi {
 	void (*fsp_interrupt)(void);
 };
 
+/*
+ * Some PRD functionality is platform specific.
+ */
+struct platform_prd {
+	void (*msg_response)(uint32_t rc);
+	int (*send_error_log)(uint32_t plid, uint32_t dsize, void *data);
+	int (*send_hbrt_msg)(void *data, u64 dsize);
+	int (*wakeup)(uint32_t i_core, uint32_t i_mode);
+	int (*fsp_occ_load_start_status)(u64 chipid, s64 status);
+	int (*fsp_occ_reset_status)(u64 chipid, s64 status);
+};
+
 /*
  * Each platform can provide a set of hooks
  * that can affect the generic code
@@ -108,6 +120,11 @@  struct platform {
 	 */
 	const struct platform_psi *psi;
 
+	/*
+	 * Platform specific PRD handling
+	 */
+	const struct platform_prd *prd;
+
 	/* OpenCAPI platform-specific I2C information */
 	const struct platform_ocapi *ocapi;
 
diff --git a/platforms/ibm-fsp/common.c b/platforms/ibm-fsp/common.c
index ba20d5070353..7f7a1f246206 100644
--- a/platforms/ibm-fsp/common.c
+++ b/platforms/ibm-fsp/common.c
@@ -275,3 +275,12 @@  struct platform_psi fsp_platform_psi = {
 	.link_established = fsp_reinit_fsp,
 	.fsp_interrupt = fsp_interrupt,
 };
+
+struct platform_prd fsp_platform_prd = {
+	.msg_response = hservice_hbrt_msg_response,
+	.send_error_log = hservice_send_error_log,
+	.send_hbrt_msg = hservice_send_hbrt_msg,
+	.wakeup = hservice_wakeup,
+	.fsp_occ_load_start_status = fsp_occ_load_start_status,
+	.fsp_occ_reset_status = fsp_occ_reset_status,
+};
diff --git a/platforms/ibm-fsp/firenze.c b/platforms/ibm-fsp/firenze.c
index 6c25023235e7..232833480f75 100644
--- a/platforms/ibm-fsp/firenze.c
+++ b/platforms/ibm-fsp/firenze.c
@@ -210,6 +210,7 @@  static void firenze_init(void)
 DECLARE_PLATFORM(firenze) = {
 	.name			= "Firenze",
 	.psi			= &fsp_platform_psi,
+	.prd			= &fsp_platform_prd,
 	.probe			= firenze_probe,
 	.init			= firenze_init,
 	.fast_reboot_init	= fsp_console_reset,
diff --git a/platforms/ibm-fsp/ibm-fsp.h b/platforms/ibm-fsp/ibm-fsp.h
index 66139f0c06de..dc3969ec688d 100644
--- a/platforms/ibm-fsp/ibm-fsp.h
+++ b/platforms/ibm-fsp/ibm-fsp.h
@@ -51,5 +51,6 @@  void vpd_preload(struct dt_node *hub_node);
 int fsp_heartbeat_time(void);
 
 extern struct platform_psi fsp_platform_psi;
+extern struct platform_prd fsp_platform_prd;
 
 #endif /*  __IBM_FSP_COMMON_H */
diff --git a/platforms/ibm-fsp/zz.c b/platforms/ibm-fsp/zz.c
index 9e18e406a6f2..ac608f6aba7e 100644
--- a/platforms/ibm-fsp/zz.c
+++ b/platforms/ibm-fsp/zz.c
@@ -72,6 +72,7 @@  static void zz_init(void)
 DECLARE_PLATFORM(zz) = {
 	.name			= "ZZ",
 	.psi			= &fsp_platform_psi,
+	.prd			= &fsp_platform_prd,
 	.probe			= zz_probe,
 	.init			= zz_init,
 	.fast_reboot_init	= fsp_console_reset,