1 /* SPDX-License-Identifier: GPL-2.0-only */
5 #include <console/console.h>
10 int ipmi_get_device_id(const struct device
*dev
, struct ipmi_devid_rsp
*rsp
)
14 ret
= ipmi_message(dev
->path
.pnp
.port
, IPMI_NETFN_APPLICATION
, 0,
15 IPMI_BMC_GET_DEVICE_ID
, NULL
, 0, (u8
*)rsp
,
17 if (ret
< sizeof(struct ipmi_rsp
) || rsp
->resp
.completion_code
) {
18 printk(BIOS_ERR
, "IPMI: %s command failed (ret=%d resp=0x%x)\n",
19 __func__
, ret
, rsp
->resp
.completion_code
);
22 if (ret
!= sizeof(*rsp
)) {
23 printk(BIOS_ERR
, "IPMI: %s response truncated\n", __func__
);
29 static int ipmi_get_bmc_self_test_result(const struct device
*dev
,
30 struct ipmi_selftest_rsp
*rsp
)
34 ret
= ipmi_message(dev
->path
.pnp
.port
, IPMI_NETFN_APPLICATION
, 0,
35 IPMI_BMC_GET_SELFTEST_RESULTS
, NULL
, 0, (u8
*)rsp
,
38 if (ret
< sizeof(struct ipmi_rsp
) || rsp
->resp
.completion_code
) {
39 printk(BIOS_ERR
, "IPMI: %s command failed (ret=%d resp=0x%x)\n",
40 __func__
, ret
, rsp
->resp
.completion_code
);
43 if (ret
!= sizeof(*rsp
)) {
44 printk(BIOS_ERR
, "IPMI: %s response truncated\n", __func__
);
51 int ipmi_process_self_test_result(const struct device
*dev
)
54 uint8_t retry_count
= 0;
55 struct ipmi_selftest_rsp selftestrsp
= {0};
57 const struct drivers_ipmi_config
*conf
= dev
->chip_info
;
58 uint8_t retry_limit
= 0;
60 if (conf
&& conf
->wait_for_bmc
)
61 retry_limit
= conf
->bmc_boot_timeout
;
64 /* Try to get self-test results at least once */
67 printk(BIOS_INFO
, "Get BMC self test result...");
68 for (retry_count
= 0; retry_count
< retry_limit
; retry_count
++) {
69 if (!ipmi_get_bmc_self_test_result(dev
, &selftestrsp
))
75 switch (selftestrsp
.result
) {
76 case IPMI_APP_SELFTEST_NO_ERROR
: /* 0x55 */
77 printk(BIOS_DEBUG
, "No Error\n");
79 case IPMI_APP_SELFTEST_NOT_IMPLEMENTED
: /* 0x56 */
80 printk(BIOS_DEBUG
, "Function Not Implemented\n");
82 case IPMI_APP_SELFTEST_ERROR
: /* 0x57 */
83 printk(BIOS_ERR
, "BMC: Corrupted or inaccessible data or device\n");
86 case IPMI_APP_SELFTEST_FATAL_HW_ERROR
: /* 0x58 */
87 printk(BIOS_ERR
, "BMC: Fatal Hardware Error\n");
90 case IPMI_APP_SELFTEST_RESERVED
: /* 0xFF */
91 printk(BIOS_DEBUG
, "Reserved\n");
94 default: /* Other Device Specific Hardware Error */
95 printk(BIOS_ERR
, "BMC: Device Specific Error: 0x%02x\n", selftestrsp
.result
);