From 0e34d7082af5a8a863f335c87eb64a8eee02fcd5 Mon Sep 17 00:00:00 2001 From: Lora Lin Date: Fri, 4 Aug 2023 15:29:53 +0800 Subject: [PATCH] Artemis: cb: Support to record sensor alert event Description: - Support to record VR/power brick/power monitor sensor alert event. Motivation: - Support to record VR/power brick/power monitor sensor alert event. Note: - JIRA link: https://metainfra.atlassian.net/browse/T17GTART-73 Test Plan: - Build code: Pass - Record VR alert event: Pass - Record P1V25 alert event: Pass - Record P12V ACCL2/3 alert event: Pass - AC cycle/DC cycle/Reset would not trigger event: Pass Log: [ BIC console ] // VR alert event uart:~$ gpio get GPIO0_E_H 8 Reading GPIO0_E_H pin 8 Value 1 uart:~$ gpio conf GPIO0_E_H 8 out Configuring GPIO0_E_H pin 8 uart:~$ gpio get GPIO0_E_H 8 Reading GPIO0_E_H pin 8 Value 0 uart:~$ gpio conf GPIO0_E_H 8 in Configuring GPIO0_E_H pin 8 uart:~$ gpio get GPIO0_E_H 8 Reading GPIO0_E_H pin 8 Value 1 // P1V25 alert event uart:~$ gpio get GPIO0_A_D 3 Reading GPIO0_A_D pin 3 Value 1 uart:~$ gpio conf GPIO0_A_D 3 out Configuring GPIO0_A_D pin 3 uart:~$ gpio get GPIO0_A_D 3 Reading GPIO0_A_D pin 3 Value 0 uart:~$ gpio conf GPIO0_A_D 3 in Configuring GPIO0_A_D pin 3 uart:~$ gpio get GPIO0_A_D 3 Reading GPIO0_A_D pin 3 Value 1 // P12V ACCL2/3 alert event uart:~$ gpio get GPIO0_A_D 5 Reading GPIO0_A_D pin 5 Value 1 uart:~$ gpio conf GPIO0_A_D 5 out Configuring GPIO0_A_D pin 5 uart:~$ gpio get GPIO0_A_D 5 Reading GPIO0_A_D pin 5 Value 0 uart:~$ gpio conf GPIO0_A_D 5 in Configuring GPIO0_A_D pin 5 uart:~$ gpio get GPIO0_A_D 5 Reading GPIO0_A_D pin 5 Value 1 uart:~$ uart:~$ gpio get GPIO0_A_D 6 Reading GPIO0_A_D pin 6 Value 1 uart:~$ gpio conf GPIO0_A_D 6 out Configuring GPIO0_A_D pin 6 uart:~$ gpio get GPIO0_A_D 6 Reading GPIO0_A_D pin 6 Value 0 uart:~$ gpio conf GPIO0_A_D 6 in Configuring GPIO0_A_D pin 6 uart:~$ gpio get GPIO0_A_D 6 Reading GPIO0_A_D pin 6 Value 1 [ BMC console ] root@bmc-oob:~# log-util all --print 2018 Mar 09 04:41:51 log-util: User cleared all logs 4 nic0 2018-03-09 04:42:27 ipmid SEL Entry: FRU: 4, Record: Standard (0x02), Time: 2018-03-09 04:42:27, Sensor: BIC SENSOR STATUS (0x10), Event Data: (01FFFF) P0V8 VR Alert status(0x01FFFF) Assertion 4 nic0 2018-03-09 04:42:33 ipmid SEL Entry: FRU: 4, Record: Standard (0x02), Time: 2018-03-09 04:42:33, Sensor: BIC SENSOR STATUS (0x10), Event Data: (01FFFF) P0V8 VR Alert status(0x01FFFF) Deassertion 4 nic0 2018-03-09 04:43:58 ipmid SEL Entry: FRU: 4, Record: Standard (0x02), Time: 2018-03-09 04:43:58, Sensor: BIC SENSOR STATUS (0x10), Event Data: (0300FF) P1V25 Monitor Alert (Device: SQ52205) status(0x0300FF) Assertion 4 nic0 2018-03-09 04:44:05 ipmid SEL Entry: FRU: 4, Record: Standard (0x02), Time: 2018-03-09 04:44:05, Sensor: BIC SENSOR STATUS (0x10), Event Data: (0300FF) P1V25 Monitor Alert (Device: SQ52205) status(0x0300FF) Deassertion 4 nic0 2018-03-09 04:44:22 ipmid SEL Entry: FRU: 4, Record: Standard (0x02), Time: 2018-03-09 04:44:22, Sensor: BIC SENSOR STATUS (0x10), Event Data: (0500FF) P12V ACCL2 Monitor Alert (Device: INA233) status(0x0500FF) Assertion 4 nic0 2018-03-09 04:44:26 ipmid SEL Entry: FRU: 4, Record: Standard (0x02), Time: 2018-03-09 04:44:26, Sensor: BIC SENSOR STATUS (0x10), Event Data: (0500FF) P12V ACCL2 Monitor Alert (Device: INA233) status(0x0500FF) Deassertion 4 nic0 2018-03-09 04:44:36 ipmid SEL Entry: FRU: 4, Record: Standard (0x02), Time: 2018-03-09 04:44:36, Sensor: BIC SENSOR STATUS (0x10), Event Data: (0600FF) P12V ACCL3 Monitor Alert (Device: INA233) status(0x0600FF) Assertion 4 nic0 2018-03-09 04:44:42 ipmid SEL Entry: FRU: 4, Record: Standard (0x02), Time: 2018-03-09 04:44:42, Sensor: BIC SENSOR STATUS (0x10), Event Data: (0600FF) P12V ACCL3 Monitor Alert (Device: INA233) status(0x0600FF) Deassertion --- .../at-cb/src/ipmi/include/plat_ipmi.h | 3 + meta-facebook/at-cb/src/ipmi/plat_ipmi.c | 32 +++++++ meta-facebook/at-cb/src/platform/plat_class.c | 4 +- meta-facebook/at-cb/src/platform/plat_gpio.c | 28 +++--- meta-facebook/at-cb/src/platform/plat_gpio.h | 7 +- meta-facebook/at-cb/src/platform/plat_isr.c | 92 ++++++++++++++++++- meta-facebook/at-cb/src/platform/plat_isr.h | 24 +++++ .../at-cb/src/platform/plat_sensor_table.h | 19 ++++ 8 files changed, 189 insertions(+), 20 deletions(-) diff --git a/meta-facebook/at-cb/src/ipmi/include/plat_ipmi.h b/meta-facebook/at-cb/src/ipmi/include/plat_ipmi.h index 68c974aaa8..98f0642190 100644 --- a/meta-facebook/at-cb/src/ipmi/include/plat_ipmi.h +++ b/meta-facebook/at-cb/src/ipmi/include/plat_ipmi.h @@ -18,6 +18,7 @@ #define PLAT_IPMI_H #include +#include "ipmi.h" #define BIC_FW_DATA_LENGTH 7 #define VR_FW_VERSION_LEN 4 @@ -84,4 +85,6 @@ enum CB_FIRMWARE_COMPONENT { CB_COMPNT_MAX, }; +void pal_construct_ipmi_add_sel_msg(ipmi_msg *msg, common_addsel_msg_t *sel_msg); + #endif diff --git a/meta-facebook/at-cb/src/ipmi/plat_ipmi.c b/meta-facebook/at-cb/src/ipmi/plat_ipmi.c index 7e1941e135..dcdc12a8a2 100644 --- a/meta-facebook/at-cb/src/ipmi/plat_ipmi.c +++ b/meta-facebook/at-cb/src/ipmi/plat_ipmi.c @@ -36,6 +36,7 @@ #include "plat_dev.h" #include "fru.h" #include "app_handler.h" +#include "plat_ipmb.h" LOG_MODULE_REGISTER(plat_ipmi); @@ -50,6 +51,37 @@ struct SWITCH_MUX_INFO pcie_switch_mux_info[PEX_MAX_NUMBER] = { .bic_to_flash_value = GPIO_LOW }, }; +void pal_construct_ipmi_add_sel_msg(ipmi_msg *msg, common_addsel_msg_t *sel_msg) +{ + CHECK_NULL_ARG(msg); + CHECK_NULL_ARG(sel_msg); + + static uint16_t record_id = 0x1; + uint8_t system_event_record = 0x02; + uint8_t evt_msg_version = 0x04; + + msg->data_len = 16; + msg->InF_source = SELF; + msg->InF_target = sel_msg->InF_target; + msg->netfn = NETFN_STORAGE_REQ; + msg->cmd = CMD_STORAGE_ADD_SEL; + msg->data[0] = (record_id & 0xFF); // Record id byte 0, lsb + msg->data[1] = ((record_id >> 8) & 0xFF); // Record id byte 1 + msg->data[2] = system_event_record; // Record type + msg->data[3] = 0x00; // Timestamp, bmc would fill up for bic + msg->data[4] = 0x00; // Timestamp, bmc would fill up for bic + msg->data[5] = 0x00; // Timestamp, bmc would fill up for bic + msg->data[6] = 0x00; // Timestamp, bmc would fill up for bic + msg->data[7] = (SELF_I2C_ADDRESS << 1); // Generator id + msg->data[8] = 0x00; // Generator id + msg->data[9] = evt_msg_version; // Event message format version + memcpy(&msg->data[10], &sel_msg->sensor_type, + sizeof(common_addsel_msg_t) - sizeof(uint8_t)); + record_id++; + + return; +} + void OEM_1S_GET_FW_VERSION(ipmi_msg *msg) { CHECK_NULL_ARG(msg); diff --git a/meta-facebook/at-cb/src/platform/plat_class.c b/meta-facebook/at-cb/src/platform/plat_class.c index f527deee04..1178133641 100644 --- a/meta-facebook/at-cb/src/platform/plat_class.c +++ b/meta-facebook/at-cb/src/platform/plat_class.c @@ -147,7 +147,7 @@ void check_accl_device_presence_status_via_ioexp() ret = i2c_master_read(&msg, retry); if (ret != 0) { LOG_ERR("Fail to read cpld offset: 0x%x", CPLD_ACCL_1_6_PRESENT_OFFSET); - return false; + return; } reg_val = msg.data[0]; @@ -162,7 +162,7 @@ void check_accl_device_presence_status_via_ioexp() ret = i2c_master_read(&msg, retry); if (ret != 0) { LOG_ERR("Fail to read cpld offset: 0x%x", CPLD_ACCL_1_6_PRESENT_OFFSET); - return false; + return; } reg_val |= msg.data[0]; diff --git a/meta-facebook/at-cb/src/platform/plat_gpio.c b/meta-facebook/at-cb/src/platform/plat_gpio.c index cf4cef94b7..d00a4de394 100644 --- a/meta-facebook/at-cb/src/platform/plat_gpio.c +++ b/meta-facebook/at-cb/src/platform/plat_gpio.c @@ -59,10 +59,10 @@ GPIO_CFG plat_gpio_cfg[] = { { CHIP_GPIO, 0, DISABLE, DISABLE, GPIO_INPUT, GPIO_LOW, PUSH_PULL, GPIO_INT_DISABLE, NULL }, { CHIP_GPIO, 1, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, { CHIP_GPIO, 2, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, - { CHIP_GPIO, 3, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, + { CHIP_GPIO, 3, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_P1V25_ALERT }, { CHIP_GPIO, 4, DISABLE, DISABLE, GPIO_INPUT, GPIO_LOW, PUSH_PULL, GPIO_INT_DISABLE, NULL }, - { CHIP_GPIO, 5, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, - { CHIP_GPIO, 6, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, + { CHIP_GPIO, 5, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_P12V_ACCL2_ALERT }, + { CHIP_GPIO, 6, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_P12V_ACCL3_ALERT }, { CHIP_GPIO, 7, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_FALLING, ISR_FIO_BUTTON }, /** Group B: 08-15 **/ @@ -106,7 +106,7 @@ GPIO_CFG plat_gpio_cfg[] = { { CHIP_GPIO, 39, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, /** Group F: 40-47 **/ - { CHIP_GPIO, 40, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, + { CHIP_GPIO, 40, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_VR_ALERT }, { CHIP_GPIO, 41, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, { CHIP_GPIO, 42, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, { CHIP_GPIO, 43, ENABLE, DISABLE, GPIO_OUTPUT, GPIO_HIGH, OPEN_DRAIN, GPIO_INT_DISABLE, NULL }, @@ -267,11 +267,11 @@ GPIO_CFG plat_gpio_cfg[] = { }; GPIO_CFG update_gpio_cfg[] = { - { CHIP_GPIO, 4, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, - { CHIP_GPIO, 10, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, - { CHIP_GPIO, 11, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, - { CHIP_GPIO, 12, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, - { CHIP_GPIO, 19, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, + { CHIP_GPIO, 4, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_P12V_ACCL1_ALERT }, + { CHIP_GPIO, 10, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_P12V_ACCL4_ALERT }, + { CHIP_GPIO, 11, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_P12V_ACCL5_ALERT }, + { CHIP_GPIO, 12, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_P12V_ACCL6_ALERT }, + { CHIP_GPIO, 19, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_P12V_ACCL7_ALERT }, { CHIP_GPIO, 30, DISABLE, DISABLE, GPIO_INPUT, GPIO_LOW, PUSH_PULL, GPIO_INT_DISABLE, NULL }, { CHIP_GPIO, 44, ENABLE, DISABLE, GPIO_OUTPUT, GPIO_HIGH, OPEN_DRAIN, GPIO_INT_DISABLE, NULL }, { CHIP_GPIO, 45, ENABLE, DISABLE, GPIO_OUTPUT, GPIO_HIGH, OPEN_DRAIN, GPIO_INT_DISABLE, NULL }, @@ -289,11 +289,11 @@ GPIO_CFG update_gpio_cfg[] = { { CHIP_GPIO, 99, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, { CHIP_GPIO, 100, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, { CHIP_GPIO, 101, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, - { CHIP_GPIO, 127, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, - { CHIP_GPIO, 131, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, - { CHIP_GPIO, 132, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, - { CHIP_GPIO, 145, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, - { CHIP_GPIO, 146, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_DISABLE, NULL }, + { CHIP_GPIO, 127, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_P12V_ACCL10_ALERT }, + { CHIP_GPIO, 131, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_P12V_ACCL11_ALERT }, + { CHIP_GPIO, 132, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_P12V_ACCL12_ALERT }, + { CHIP_GPIO, 145, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_P12V_ACCL8_ALERT }, + { CHIP_GPIO, 146, ENABLE, DISABLE, GPIO_INPUT, GPIO_HIGH, PUSH_PULL, GPIO_INT_EDGE_BOTH, ISR_P12V_ACCL9_ALERT }, }; // clang-format on diff --git a/meta-facebook/at-cb/src/platform/plat_gpio.h b/meta-facebook/at-cb/src/platform/plat_gpio.h index 3dbcaf04bc..e080e439aa 100644 --- a/meta-facebook/at-cb/src/platform/plat_gpio.h +++ b/meta-facebook/at-cb/src/platform/plat_gpio.h @@ -329,9 +329,10 @@ #define gpio_name_to_num(x) x, enum _GPIO_NUMS_ { - name_gpioA name_gpioB name_gpioC name_gpioD name_gpioE name_gpioF name_gpioG name_gpioH - name_gpioI name_gpioJ name_gpioK name_gpioL name_gpioM name_gpioN name_gpioO - name_gpioP name_gpioQ name_gpioR name_gpioS name_gpioT name_gpioU + update_name_gpioA update_name_gpioB update_name_gpioC update_name_gpioD name_gpioE + name_gpioF name_gpioG name_gpioH name_gpioI name_gpioJ name_gpioK update_name_gpioL + update_name_gpioM name_gpioN name_gpioO update_name_gpioP update_name_gpioQ + name_gpioR update_name_gpioS name_gpioT name_gpioU }; extern enum _GPIO_NUMS_ GPIO_NUMS; diff --git a/meta-facebook/at-cb/src/platform/plat_isr.c b/meta-facebook/at-cb/src/platform/plat_isr.c index e1e92b90dc..a671437d6a 100644 --- a/meta-facebook/at-cb/src/platform/plat_isr.c +++ b/meta-facebook/at-cb/src/platform/plat_isr.c @@ -18,14 +18,73 @@ #include "ipmi.h" #include "ipmb.h" #include "pldm.h" +#include "libipmi.h" #include "plat_isr.h" #include "plat_gpio.h" #include "plat_mctp.h" +#include "plat_ipmi.h" #include "plat_class.h" #include "util_worker.h" +#include "plat_sensor_table.h" LOG_MODULE_REGISTER(plat_isr); +add_sel_info add_sel_work_item[] = { + { .is_init = false, .gpio_num = SMB_P0V8_ALERT_N, .sel_msg = { 0 } }, + { .is_init = false, .gpio_num = SMB_P1V25_ALRT_N_R, .sel_msg = { 0 } }, + { .is_init = false, .gpio_num = INA233_ACCL1_ALRT_N_R, .sel_msg = { 0 } }, + { .is_init = false, .gpio_num = INA233_ACCL2_ALRT_N_R, .sel_msg = { 0 } }, + { .is_init = false, .gpio_num = INA233_ACCL3_ALRT_N_R, .sel_msg = { 0 } }, + { .is_init = false, .gpio_num = INA233_ACCL4_ALRT_N_R, .sel_msg = { 0 } }, + { .is_init = false, .gpio_num = INA233_ACCL5_ALRT_N_R, .sel_msg = { 0 } }, + { .is_init = false, .gpio_num = INA233_ACCL6_ALRT_N_R, .sel_msg = { 0 } }, + { .is_init = false, .gpio_num = INA233_ACCL7_ALRT_N_R, .sel_msg = { 0 } }, + { .is_init = false, .gpio_num = INA233_ACCL8_ALRT_N_R, .sel_msg = { 0 } }, + { .is_init = false, .gpio_num = INA233_ACCL9_ALRT_N_R, .sel_msg = { 0 } }, + { .is_init = false, .gpio_num = INA233_ACCL10_ALRT_N_R, .sel_msg = { 0 } }, + { .is_init = false, .gpio_num = INA233_ACCL11_ALRT_N_R, .sel_msg = { 0 } }, + { .is_init = false, .gpio_num = INA233_ACCL12_ALRT_N_R, .sel_msg = { 0 } }, +}; + +add_sel_info *get_addsel_work(uint8_t gpio_num) +{ + uint8_t index = 0; + + for (index = 0; index < ARRAY_SIZE(add_sel_work_item); ++index) { + if (gpio_num == add_sel_work_item[index].gpio_num) { + return &add_sel_work_item[index]; + } + } + + return NULL; +} + +#define ISR_SENSOR_ALERT(device, gpio_pin_name, event_name, board_id) \ + void ISR_##device##_ALERT() \ + { \ + add_sel_info *work = get_addsel_work(gpio_pin_name); \ + if (work == NULL) { \ + LOG_ERR("Fail to find addsel work, gpio num: %d", gpio_pin_name); \ + return; \ + } \ + if (work->is_init != true) { \ + k_work_init_delayable(&(work->add_sel_work), add_sel_work_handler); \ + work->is_init = true; \ + } \ + work->sel_msg.InF_target = MCTP; \ + work->sel_msg.sensor_type = IPMI_OEM_SENSOR_TYPE_SYS_STA; \ + work->sel_msg.sensor_number = SENSOR_NUM_BIC_SENSOR_ALERT; \ + work->sel_msg.event_data1 = OEM_IPMI_EVENT_##event_name##_ALERT; \ + work->sel_msg.event_data2 = gpio_get(board_id); \ + work->sel_msg.event_data3 = ADDSEL_EVENT_DATA_DEFAULT; \ + if (gpio_get(work->gpio_num) == LOW_ACTIVE) { \ + work->sel_msg.event_type = IPMI_EVENT_TYPE_SENSOR_SPECIFIC; \ + } else { \ + work->sel_msg.event_type = IPMI_OEM_EVENT_TYPE_DEASSERT; \ + } \ + k_work_schedule_for_queue(&plat_work_q, &work->add_sel_work, K_NO_WAIT); \ + } + K_WORK_DELAYABLE_DEFINE(fio_power_button_work, fio_power_button_work_handler); void fio_power_button_work_handler() { @@ -57,6 +116,22 @@ void fio_power_button_work_handler() } } +void add_sel_work_handler(struct k_work *work_item) +{ + struct k_work_delayable *dwork = k_work_delayable_from_work(work_item); + add_sel_info *work_info = CONTAINER_OF(dwork, add_sel_info, add_sel_work); + + int ret = 0; + ipmi_msg msg = { 0 }; + + pal_construct_ipmi_add_sel_msg(&msg, &work_info->sel_msg); + ret = pal_pldm_send_ipmi_request(&msg, MCTP_EID_BMC); + if (ret < 0) { + LOG_ERR("Failed to addsel to BMC, ret: %d, gpio num: 0x%x", ret, + work_info->gpio_num); + } +} + void ISR_FIO_BUTTON() { k_work_schedule_for_queue(&plat_work_q, &fio_power_button_work, @@ -66,4 +141,19 @@ void ISR_FIO_BUTTON() void ISR_POWER_STATUS_CHANGE() { get_acb_power_status(); -} +}; + +ISR_SENSOR_ALERT(VR, SMB_P0V8_ALERT_N, P0V8_VR, BOARD_ID0) +ISR_SENSOR_ALERT(P1V25, SMB_P1V25_ALRT_N_R, P1V25_MONITOR, BOARD_ID0) +ISR_SENSOR_ALERT(P12V_ACCL1, INA233_ACCL1_ALRT_N_R, P12V_ACCL1_MONITOR, BOARD_ID0) +ISR_SENSOR_ALERT(P12V_ACCL2, INA233_ACCL2_ALRT_N_R, P12V_ACCL2_MONITOR, BOARD_ID0) +ISR_SENSOR_ALERT(P12V_ACCL3, INA233_ACCL3_ALRT_N_R, P12V_ACCL3_MONITOR, BOARD_ID0) +ISR_SENSOR_ALERT(P12V_ACCL4, INA233_ACCL4_ALRT_N_R, P12V_ACCL4_MONITOR, BOARD_ID0) +ISR_SENSOR_ALERT(P12V_ACCL5, INA233_ACCL5_ALRT_N_R, P12V_ACCL5_MONITOR, BOARD_ID0) +ISR_SENSOR_ALERT(P12V_ACCL6, INA233_ACCL6_ALRT_N_R, P12V_ACCL6_MONITOR, BOARD_ID0) +ISR_SENSOR_ALERT(P12V_ACCL7, INA233_ACCL7_ALRT_N_R, P12V_ACCL7_MONITOR, BOARD_ID0) +ISR_SENSOR_ALERT(P12V_ACCL8, INA233_ACCL8_ALRT_N_R, P12V_ACCL8_MONITOR, BOARD_ID0) +ISR_SENSOR_ALERT(P12V_ACCL9, INA233_ACCL9_ALRT_N_R, P12V_ACCL9_MONITOR, BOARD_ID0) +ISR_SENSOR_ALERT(P12V_ACCL10, INA233_ACCL10_ALRT_N_R, P12V_ACCL10_MONITOR, BOARD_ID0) +ISR_SENSOR_ALERT(P12V_ACCL11, INA233_ACCL11_ALRT_N_R, P12V_ACCL11_MONITOR, BOARD_ID0) +ISR_SENSOR_ALERT(P12V_ACCL12, INA233_ACCL12_ALRT_N_R, P12V_ACCL12_MONITOR, BOARD_ID0) diff --git a/meta-facebook/at-cb/src/platform/plat_isr.h b/meta-facebook/at-cb/src/platform/plat_isr.h index beabf16b7a..22e9c20be7 100644 --- a/meta-facebook/at-cb/src/platform/plat_isr.h +++ b/meta-facebook/at-cb/src/platform/plat_isr.h @@ -18,15 +18,39 @@ #define PLAT_FUNC_H #include +#include "ipmi.h" #define PRESS_FIO_BUTTON_DELAY_MS 4000 +#define ADDSEL_EVENT_DATA_DEFAULT 0xFF enum BUTTON_OPTIONAL { OPTIONAL_AC_OFF = 0x01, }; +typedef struct _add_sel_info { + bool is_init; + uint8_t gpio_num; + common_addsel_msg_t sel_msg; + struct k_work_delayable add_sel_work; +} add_sel_info; + void ISR_FIO_BUTTON(); void ISR_POWER_STATUS_CHANGE(); +void ISR_VR_ALERT(); +void ISR_P1V25_ALERT(); +void ISR_P12V_ACCL1_ALERT(); +void ISR_P12V_ACCL2_ALERT(); +void ISR_P12V_ACCL3_ALERT(); +void ISR_P12V_ACCL4_ALERT(); +void ISR_P12V_ACCL5_ALERT(); +void ISR_P12V_ACCL6_ALERT(); +void ISR_P12V_ACCL7_ALERT(); +void ISR_P12V_ACCL8_ALERT(); +void ISR_P12V_ACCL9_ALERT(); +void ISR_P12V_ACCL10_ALERT(); +void ISR_P12V_ACCL11_ALERT(); +void ISR_P12V_ACCL12_ALERT(); void fio_power_button_work_handler(); +void vr_alert_work_handler(); #endif diff --git a/meta-facebook/at-cb/src/platform/plat_sensor_table.h b/meta-facebook/at-cb/src/platform/plat_sensor_table.h index b8acaaa6b1..4311c800bf 100644 --- a/meta-facebook/at-cb/src/platform/plat_sensor_table.h +++ b/meta-facebook/at-cb/src/platform/plat_sensor_table.h @@ -280,6 +280,25 @@ #define ACCL_POWER_GOOD_TIME_DEFAULT 0 #define ACCL_SENSOR_POLL_DELAY_MS 10000 +/** Event **/ +#define SENSOR_NUM_BIC_SENSOR_ALERT 0x10 + +#define OEM_IPMI_EVENT_P0V8_VR_ALERT 0x01 +#define OEM_IPMI_EVENT_POWER_BRICK_ALERT 0x02 +#define OEM_IPMI_EVENT_P1V25_MONITOR_ALERT 0x03 +#define OEM_IPMI_EVENT_P12V_ACCL1_MONITOR_ALERT 0x04 +#define OEM_IPMI_EVENT_P12V_ACCL2_MONITOR_ALERT 0x05 +#define OEM_IPMI_EVENT_P12V_ACCL3_MONITOR_ALERT 0x06 +#define OEM_IPMI_EVENT_P12V_ACCL4_MONITOR_ALERT 0x07 +#define OEM_IPMI_EVENT_P12V_ACCL5_MONITOR_ALERT 0x08 +#define OEM_IPMI_EVENT_P12V_ACCL6_MONITOR_ALERT 0x09 +#define OEM_IPMI_EVENT_P12V_ACCL7_MONITOR_ALERT 0x0A +#define OEM_IPMI_EVENT_P12V_ACCL8_MONITOR_ALERT 0x0B +#define OEM_IPMI_EVENT_P12V_ACCL9_MONITOR_ALERT 0x0C +#define OEM_IPMI_EVENT_P12V_ACCL10_MONITOR_ALERT 0x0D +#define OEM_IPMI_EVENT_P12V_ACCL11_MONITOR_ALERT 0x0E +#define OEM_IPMI_EVENT_P12V_ACCL12_MONITOR_ALERT 0x0F + typedef struct _sensor_compatible_cfg { uint8_t num; uint8_t port;