1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Place in devicetree.cb:
5 * chip drivers/ipmi/ocp # OCP specific IPMI porting
6 device pnp ca2.1 on end
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>
19 static enum cb_err
ipmi_set_ppin(struct device
*dev
)
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
);
40 printk(BIOS_DEBUG
, "IPMI: %s command success\n", __func__
);
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 */
57 static void ipmi_set_resources(struct device
*dev
)
61 for (res
= dev
->resource_list
; res
; res
= res
->next
) {
62 if (!(res
->flags
& IORESOURCE_ASSIGNED
))
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
;
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",
90 else if (dev
->path
.pnp
.port
& 1)
91 printk(BIOS_ERR
, "%s: Base address needs to be aligned to 2\n",
97 struct chip_operations drivers_ipmi_ocp_ops
= {
99 .enable_dev
= enable_dev
,