src/drivers/ipmi: Add function to get BMC revision

Provide a way to get BMC revision.

Tested=On OCP Delta Lake, function can get BMC revision well.

Signed-off-by: Tim Chu <Tim.Chu@quantatw.com>
Change-Id: Iaaa4e8bf181a38452b53c83a762c7b648e95e643
Reviewed-on: https://review.coreboot.org/c/coreboot/+/46070
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jonathan Zhang <jonzhang@fb.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
This commit is contained in:
Tim Chu 2020-10-06 01:40:53 -07:00 committed by Patrick Georgi
parent cbcd8a02fc
commit 278ad21fa9
2 changed files with 20 additions and 0 deletions

View File

@ -33,6 +33,8 @@ extern int ipmi_kcs_message(int port, int netfn, int lun, int cmd,
* returns CB_SUCCESS on success and CB_ERR if an error occurred. */ * returns CB_SUCCESS on success and CB_ERR if an error occurred. */
enum cb_err ipmi_kcs_premem_init(const u16 port, const u16 device); enum cb_err ipmi_kcs_premem_init(const u16 port, const u16 device);
void ipmi_bmc_version(uint8_t *ipmi_bmc_major_revision, uint8_t *ipmi_bmc_minor_revision);
struct ipmi_rsp { struct ipmi_rsp {
uint8_t lun; uint8_t lun;
uint8_t cmd; uint8_t cmd;

View File

@ -29,6 +29,9 @@
static u8 ipmi_revision_major = 0x1; static u8 ipmi_revision_major = 0x1;
static u8 ipmi_revision_minor = 0x0; static u8 ipmi_revision_minor = 0x0;
static u8 bmc_revision_major = 0x0;
static u8 bmc_revision_minor = 0x0;
static int ipmi_get_device_id(struct device *dev, struct ipmi_devid_rsp *rsp) static int ipmi_get_device_id(struct device *dev, struct ipmi_devid_rsp *rsp)
{ {
int ret; int ret;
@ -145,6 +148,9 @@ static void ipmi_kcs_init(struct device *dev)
ipmi_revision_minor = IPMI_IPMI_VERSION_MINOR(rsp.ipmi_version); ipmi_revision_minor = IPMI_IPMI_VERSION_MINOR(rsp.ipmi_version);
ipmi_revision_major = IPMI_IPMI_VERSION_MAJOR(rsp.ipmi_version); ipmi_revision_major = IPMI_IPMI_VERSION_MAJOR(rsp.ipmi_version);
bmc_revision_major = rsp.fw_rev1;
bmc_revision_minor = rsp.fw_rev2;
memcpy(&man_id, rsp.manufacturer_id, memcpy(&man_id, rsp.manufacturer_id,
sizeof(rsp.manufacturer_id)); sizeof(rsp.manufacturer_id));
@ -273,6 +279,18 @@ static void ipmi_ssdt(const struct device *dev)
} }
#endif #endif
void ipmi_bmc_version(uint8_t *ipmi_bmc_major_revision, uint8_t *ipmi_bmc_minor_revision)
{
if (!bmc_revision_major || !bmc_revision_minor) {
printk(BIOS_ERR, "IPMI: BMC revision missing\n");
*ipmi_bmc_major_revision = 0;
*ipmi_bmc_minor_revision = 0;
} else {
*ipmi_bmc_major_revision = bmc_revision_major;
*ipmi_bmc_minor_revision = bmc_revision_minor;
}
}
#if CONFIG(GENERATE_SMBIOS_TABLES) #if CONFIG(GENERATE_SMBIOS_TABLES)
static int ipmi_smbios_data(struct device *dev, int *handle, static int ipmi_smbios_data(struct device *dev, int *handle,
unsigned long *current) unsigned long *current)