diff --git a/drivers/espi/host_subs_npcx.c b/drivers/espi/host_subs_npcx.c index 23d709c1e20..fa956ea7990 100644 --- a/drivers/espi/host_subs_npcx.c +++ b/drivers/espi/host_subs_npcx.c @@ -230,13 +230,19 @@ static void host_kbc_ibf_isr(void *arg) struct espi_event evt = { ESPI_BUS_PERIPHERAL_NOTIFICATION, ESPI_PERIPHERAL_8042_KBC, ESPI_PERIPHERAL_NODATA }; + struct espi_evt_data_kbc *kbc_evt = + (struct espi_evt_data_kbc *)&evt.evt_data; + /* KBC Input Buffer Full event */ + kbc_evt->evt = HOST_KBC_EVT_IBF; + /* The data in KBC Input Buffer */ + kbc_evt->data = inst_kbc->HIKMDI; /* - * The high byte contains information from the host, and the lower byte - * indicates if the host sent a command or data. 1 = Command. + * Indicates if the host sent a command or data. + * 0 = data + * 1 = Command. */ - evt.evt_data = NPCX_8042_EVT_DATA(NPCX_8042_EVT_IBF, inst_kbc->HIKMDI, - IS_BIT_SET(inst_kbc->HIKMST, NPCX_HIKMST_A2)); + kbc_evt->type = IS_BIT_SET(inst_kbc->HIKMST, NPCX_HIKMST_A2); LOG_DBG("%s: kbc data 0x%02x", __func__, evt.evt_data); espi_send_callbacks(host_sub_data.callbacks, host_sub_data.host_bus_dev, @@ -250,6 +256,8 @@ static void host_kbc_obe_isr(void *arg) struct espi_event evt = { ESPI_BUS_PERIPHERAL_NOTIFICATION, ESPI_PERIPHERAL_8042_KBC, ESPI_PERIPHERAL_NODATA }; + struct espi_evt_data_kbc *kbc_evt = + (struct espi_evt_data_kbc *)&evt.evt_data; /* Disable KBC OBE interrupt first */ inst_kbc->HICTRL &= ~BIT(NPCX_HICTRL_OBECIE); @@ -261,7 +269,10 @@ static void host_kbc_obe_isr(void *arg) * might need to clear status register via espi_api_lpc_write_request() * with E8042_CLEAR_FLAG opcode in callback. */ - evt.evt_data = NPCX_8042_EVT_DATA(NPCX_8042_EVT_OBE, 0, 0); + kbc_evt->evt = HOST_KBC_EVT_OBE; + kbc_evt->data = 0; + kbc_evt->type = 0; + espi_send_callbacks(host_sub_data.callbacks, host_sub_data.host_bus_dev, evt); } @@ -301,16 +312,19 @@ static void host_acpi_process_input_data(uint8_t data) .evt_details = ESPI_PERIPHERAL_HOST_IO, .evt_data = ESPI_PERIPHERAL_NODATA }; + struct espi_evt_data_acpi *acpi_evt = + (struct espi_evt_data_acpi *)&evt.evt_data; LOG_DBG("%s: acpi data 0x%02x", __func__, data); /* - * The high byte contains information from the host, and the lower byte - * indicates if the host sent a command or data. 1 = Command. + * Indicates if the host sent a command or data. + * 0 = data + * 1 = Command. */ - evt.evt_data = (data << NPCX_ACPI_DATA_POS) | - (IS_BIT_SET(inst_acpi->HIPMST, NPCX_HIPMST_CMD) << - NPCX_ACPI_TYPE_POS); + acpi_evt->type = IS_BIT_SET(inst_acpi->HIPMST, NPCX_HIPMST_CMD); + acpi_evt->data = data; + espi_send_callbacks(host_sub_data.callbacks, host_sub_data.host_bus_dev, evt); } diff --git a/include/drivers/espi.h b/include/drivers/espi.h index e9a9aa111d3..7bbeeb44263 100644 --- a/include/drivers/espi.h +++ b/include/drivers/espi.h @@ -253,6 +253,29 @@ enum lpc_peripheral_opcode { #endif /* CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE */ }; +/* KBC 8042 event: Input Buffer Full */ +#define HOST_KBC_EVT_IBF BIT(0) +/* KBC 8042 event: Output Buffer Empty */ +#define HOST_KBC_EVT_OBE BIT(1) +/** + * @brief Bit field definition of evt_data in struct espi_event for KBC. + */ +struct espi_evt_data_kbc { + uint32_t type:8; + uint32_t data:8; + uint32_t evt:8; + uint32_t reserved:8; +}; + +/** + * @brief Bit field definition of evt_data in struct espi_event for ACPI. + */ +struct espi_evt_data_acpi { + uint32_t type:8; + uint32_t data:8; + uint32_t reserved:16; +}; + /** * @brief eSPI event */ diff --git a/soc/arm/nuvoton_npcx/common/soc_espi.h b/soc/arm/nuvoton_npcx/common/soc_espi.h index cdc33e3e7d7..2d75f13f0db 100644 --- a/soc/arm/nuvoton_npcx/common/soc_espi.h +++ b/soc/arm/nuvoton_npcx/common/soc_espi.h @@ -14,28 +14,6 @@ extern "C" { #endif -/* 8042 event data format */ -#define NPCX_8042_EVT_POS 16U -#define NPCX_8042_DATA_POS 8U -#define NPCX_8042_TYPE_POS 0U - -/* 8042 event type format */ -#define NPCX_8042_EVT_IBF BIT(0) -#define NPCX_8042_EVT_OBE BIT(1) - -/* - * The format of event data for KBC 8042 protocol: - * [23:16] - 8042 event type: 1: Input buffer full, 2: Output buffer empty. - * [15:8] - 8042 data: 8-bit 8042 data. - * [0:7] - 8042 protocol type: 0: data type, 1: command type. - */ -#define NPCX_8042_EVT_DATA(event, data, type) (((event) << NPCX_8042_EVT_POS) \ - | ((data) << NPCX_8042_DATA_POS) | ((type) << NPCX_8042_TYPE_POS)); - -/* ACPI event data format */ -#define NPCX_ACPI_DATA_POS 8U -#define NPCX_ACPI_TYPE_POS 0U - /** * @brief Turn on all interrupts of eSPI host interface module. *