acpi: Add IORT helper functions
[coreboot2.git] / src / drivers / ipmi / ocp / ipmi_ocp.c
blob0f003aff27ccb2e7eddcbdae7184aab48962b6dc
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * Place in devicetree.cb:
5 * chip drivers/ipmi/ocp # OCP specific IPMI porting
6 device pnp ca2.1 on end
7 * end
8 */
10 #include <console/console.h>
11 #include <device/device.h>
12 #include <device/pnp.h>
13 #include <drivers/ipmi/ipmi_if.h>
14 #include <drivers/ocp/dmi/ocp_dmi.h>
15 #include <types.h>
17 #include "ipmi_ocp.h"
19 static enum cb_err ipmi_set_ppin(struct device *dev)
21 int ret;
22 struct ipmi_rsp rsp;
23 struct ppin_req req = {0};
25 req.cpu0_lo = xeon_sp_ppin[0].lo;
26 req.cpu0_hi = xeon_sp_ppin[0].hi;
27 if (CONFIG_MAX_SOCKET > 1) {
28 req.cpu1_lo = xeon_sp_ppin[1].lo;
29 req.cpu1_hi = xeon_sp_ppin[1].hi;
31 ret = ipmi_message(dev->path.pnp.port, IPMI_NETFN_OEM, 0x0, IPMI_OEM_SET_PPIN,
32 (const unsigned char *)&req, sizeof(req),
33 (unsigned char *)&rsp, sizeof(rsp));
35 if (ret < sizeof(struct ipmi_rsp) || rsp.completion_code) {
36 printk(BIOS_ERR, "IPMI: %s command failed (ret=%d resp=0x%x)\n",
37 __func__, ret, rsp.completion_code);
38 return CB_ERR;
40 printk(BIOS_DEBUG, "IPMI: %s command success\n", __func__);
41 return CB_SUCCESS;
44 static void ipmi_ocp_init(struct device *dev)
46 /* Add OCP specific IPMI command */
49 static void ipmi_ocp_final(struct device *dev)
51 /* Add OCP specific IPMI command */
53 if (CONFIG(OCP_DMI))
54 ipmi_set_ppin(dev);
57 static void ipmi_set_resources(struct device *dev)
59 struct resource *res;
61 for (res = dev->resource_list; res; res = res->next) {
62 if (!(res->flags & IORESOURCE_ASSIGNED))
63 continue;
65 res->flags |= IORESOURCE_STORED;
66 report_resource_stored(dev, res, "");
70 static void ipmi_read_resources(struct device *dev)
72 struct resource *res = new_resource(dev, 0);
73 res->base = dev->path.pnp.port;
74 res->size = 2;
75 res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
78 static struct device_operations ops = {
79 .read_resources = ipmi_read_resources,
80 .set_resources = ipmi_set_resources,
81 .init = ipmi_ocp_init,
82 .final = ipmi_ocp_final,
85 static void enable_dev(struct device *dev)
87 if (dev->path.type != DEVICE_PATH_PNP)
88 printk(BIOS_ERR, "%s: Unsupported device type\n",
89 dev_path(dev));
90 else if (dev->path.pnp.port & 1)
91 printk(BIOS_ERR, "%s: Base address needs to be aligned to 2\n",
92 dev_path(dev));
93 else
94 dev->ops = &ops;
97 struct chip_operations drivers_ipmi_ocp_ops = {
98 .name = "IPMI OCP",
99 .enable_dev = enable_dev,