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 struct ipmi_oem_set_bios_str bios_ver
;
28 /* Only 8 characters are visible in UI. Cut of on first dash */
29 for (i
= 0; i
< 15; i
++) {
30 if (coreboot_version
[i
] == '-')
32 bios_ver
.str
[i
] = coreboot_version
[i
];
35 bios_ver
.ver
= IPMI_LUN0_AC_SET_BIOS_VER
;
37 ret
= ipmi_message(kcs_port
, IPMI_NETFN_OEM
, 0, IPMI_LUN0_SET_BIOS_STRING
,
38 (const unsigned char *)&bios_ver
, sizeof(bios_ver
),
39 (unsigned char *)&rsp
, sizeof(rsp
));
40 if (ret
< sizeof(rsp
) || rsp
.completion_code
) {
41 printk(BIOS_ERR
, "BMC_IPMI: %s command failed (ret=%d resp=0x%x)\n",
42 __func__
, ret
, rsp
.completion_code
);
46 static void set_coreboot_date(const uint16_t kcs_port
)
48 struct ipmi_oem_set_bios_str bios_ver
;
52 strncpy(bios_ver
.str
, coreboot_dmi_date
, 15);
54 bios_ver
.ver
= IPMI_LUN0_AC_SET_BIOS_DATE
;
56 ret
= ipmi_message(kcs_port
, IPMI_NETFN_OEM
, 0, IPMI_LUN0_SET_BIOS_STRING
,
57 (const unsigned char *)&bios_ver
, sizeof(bios_ver
),
58 (unsigned char *)&rsp
, sizeof(rsp
));
59 if (ret
< sizeof(rsp
) || rsp
.completion_code
) {
60 printk(BIOS_ERR
, "BMC_IPMI: %s command failed (ret=%d resp=0x%x)\n",
61 __func__
, ret
, rsp
.completion_code
);
65 void supermicro_ipmi_oem(const uint16_t kcs_port
)
67 set_coreboot_ver(kcs_port
);
68 set_coreboot_date(kcs_port
);