ipmi/ocp: Move common OCP/Facebook IPMI OEM codes into drivers/ipmi/ocp

1. These are common OCP/Facebook IPMI OEM commands, move from mainboard
into drivers/ipmi/ocp to avoid code duplication and provide better
reusability.
2. OCP Tioga Pass enables IPMI_OCP driver.

Tested=On OCP Delta Lake and Tioga Pass verify the commands still work
correctly.

Change-Id: Idd116a89239273fd5cc7b06c7768146085a3ed69
Signed-off-by: Johnny Lin <johnny_lin@wiwynn.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/49235
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Marc Jones <marc@marcjonesconsulting.com>
diff --git a/src/drivers/ipmi/ocp/ipmi_ocp.c b/src/drivers/ipmi/ocp/ipmi_ocp.c
index 07628ee..ee38bb0 100644
--- a/src/drivers/ipmi/ocp/ipmi_ocp.c
+++ b/src/drivers/ipmi/ocp/ipmi_ocp.c
@@ -12,6 +12,7 @@
 #include <device/device.h>
 #include <device/pnp.h>
 #include <drivers/ipmi/ipmi_kcs.h>
+#include <drivers/ocp/dmi/ocp_dmi.h>
 #include <intelblocks/cpulib.h>
 #include <string.h>
 #include <types.h>
@@ -115,6 +116,30 @@
 		printk(BIOS_ERR, "IPMI BMC set param 2 processor info failed\n");
 }
 
+static enum cb_err ipmi_set_ppin(struct device *dev)
+{
+	int ret;
+	struct ipmi_rsp rsp;
+	struct ppin_req req = {0};
+
+	req.cpu0_lo = xeon_sp_ppin[0].lo;
+	req.cpu0_hi = xeon_sp_ppin[0].hi;
+	if (CONFIG_MAX_SOCKET > 1) {
+		req.cpu1_lo = xeon_sp_ppin[1].lo;
+		req.cpu1_hi = xeon_sp_ppin[1].hi;
+	}
+	ret = ipmi_kcs_message(dev->path.pnp.port, IPMI_NETFN_OEM, 0x0, IPMI_OEM_SET_PPIN,
+		(const unsigned char *) &req, sizeof(req), (unsigned char *) &rsp, sizeof(rsp));
+
+	if (ret < sizeof(struct ipmi_rsp) || rsp.completion_code) {
+		printk(BIOS_ERR, "IPMI: %s command failed (ret=%d resp=0x%x)\n",
+			__func__, ret, rsp.completion_code);
+			return CB_ERR;
+	}
+	printk(BIOS_DEBUG, "IPMI: %s command success\n", __func__);
+	return CB_SUCCESS;
+}
+
 static void ipmi_ocp_init(struct device *dev)
 {
 	/* Add OCP specific IPMI command */
@@ -126,6 +151,8 @@
 
 	/* Send processor information */
 	ipmi_set_processor_information(dev);
+	if (CONFIG(OCP_DMI))
+		ipmi_set_ppin(dev);
 }
 
 static void ipmi_set_resources(struct device *dev)