1 /* SPDX-License-Identifier: GPL-2.0-only */
5 #include <console/console.h>
6 #include <drivers/ipmi/ipmi_if.h>
9 #include "ipmi_supermicro_oem.h"
11 #define IPMI_NETFN_OEM 0x30
12 #define IPMI_LUN0_AC_SET_BIOS_VER 0x100
13 #define IPMI_LUN0_AC_SET_BIOS_DATE 0x101
14 #define IPMI_LUN0_SET_BIOS_STRING 0xac
16 struct ipmi_oem_set_bios_str
{
18 char str
[16]; // NULL terminated string
21 static void set_coreboot_ver(const uint16_t kcs_port
)
23 const char *coreboot_ver
= COREBOOT_VERSION
;
24 struct ipmi_oem_set_bios_str bios_ver
;
29 /* Only 8 characters are visible in UI. Cut of on first dash */
30 for (i
= 0; i
< 15; i
++) {
31 if (coreboot_ver
[i
] == '-')
33 bios_ver
.str
[i
] = coreboot_ver
[i
];
36 bios_ver
.ver
= IPMI_LUN0_AC_SET_BIOS_VER
;
38 ret
= ipmi_message(kcs_port
, IPMI_NETFN_OEM
, 0, IPMI_LUN0_SET_BIOS_STRING
,
39 (const unsigned char *)&bios_ver
, sizeof(bios_ver
),
40 (unsigned char *)&rsp
, sizeof(rsp
));
41 if (ret
< sizeof(rsp
) || rsp
.completion_code
) {
42 printk(BIOS_ERR
, "BMC_IPMI: %s command failed (ret=%d resp=0x%x)\n",
43 __func__
, ret
, rsp
.completion_code
);
47 static void set_coreboot_date(const uint16_t kcs_port
)
49 struct ipmi_oem_set_bios_str bios_ver
;
53 strncpy(bios_ver
.str
, COREBOOT_DMI_DATE
, 15);
55 bios_ver
.ver
= IPMI_LUN0_AC_SET_BIOS_DATE
;
57 ret
= ipmi_message(kcs_port
, IPMI_NETFN_OEM
, 0, IPMI_LUN0_SET_BIOS_STRING
,
58 (const unsigned char *)&bios_ver
, sizeof(bios_ver
),
59 (unsigned char *)&rsp
, sizeof(rsp
));
60 if (ret
< sizeof(rsp
) || rsp
.completion_code
) {
61 printk(BIOS_ERR
, "BMC_IPMI: %s command failed (ret=%d resp=0x%x)\n",
62 __func__
, ret
, rsp
.completion_code
);
66 void supermicro_ipmi_oem(const uint16_t kcs_port
)
68 set_coreboot_ver(kcs_port
);
69 set_coreboot_date(kcs_port
);