From 3abfb587411dc2a0632105b0e51c778a60e67f21 Mon Sep 17 00:00:00 2001 From: Jay Vasanth Date: Fri, 4 Mar 2022 18:20:58 -0500 Subject: [PATCH] espi: mec172x: Read ACPI EC data in IBF ISR Handle ACPI EC0 and ACPI EC1 IBF ISR by reading input data in the ISR Signed-off-by: Jay Vasanth --- drivers/espi/Kconfig.xec_v2 | 8 +++++++ drivers/espi/espi_mchp_xec_host_v2.c | 33 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/espi/Kconfig.xec_v2 b/drivers/espi/Kconfig.xec_v2 index 351f90c852f..270dbec1ab1 100644 --- a/drivers/espi/Kconfig.xec_v2 +++ b/drivers/espi/Kconfig.xec_v2 @@ -145,4 +145,12 @@ config ESPI_SAF_INIT_PRIORITY help Driver initialization priority for eSPI SAF driver. +config ESPI_PERIPHERAL_ACPI_EC_IBF_EVT_DATA + bool "Read ACPI EC Event Data in IBF ISR" + depends on ESPI_PERIPHERAL_CHANNEL + help + Enable reading event data in ACPI EC IBF ISR. This is used in OS + environment where application expects IBF ISR to read data and pass + to callback. + endif #ESPI_XEC_V2 diff --git a/drivers/espi/espi_mchp_xec_host_v2.c b/drivers/espi/espi_mchp_xec_host_v2.c index 1d59a29716c..1512e7afca1 100644 --- a/drivers/espi/espi_mchp_xec_host_v2.c +++ b/drivers/espi/espi_mchp_xec_host_v2.c @@ -379,6 +379,26 @@ static void acpi_ec0_ibf_isr(const struct device *dev) struct espi_event evt = { ESPI_BUS_PERIPHERAL_NOTIFICATION, ESPI_PERIPHERAL_HOST_IO, ESPI_PERIPHERAL_NODATA }; +#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_EC_IBF_EVT_DATA + struct acpi_ec_regs *acpi_ec0_hw = (struct acpi_ec_regs *)xec_acpi_ec0_cfg.regbase; + + /* Updates to fit Chrome shim layer design */ + struct espi_evt_data_acpi *acpi_evt = + (struct espi_evt_data_acpi *)&evt.evt_data; + + /* Host put data on input buffer of ACPI EC0 channel */ + if (acpi_ec0_hw->EC_STS & MCHP_ACPI_EC_STS_IBF) { + /* Set processing flag before reading command byte */ + acpi_ec0_hw->EC_STS |= MCHP_ACPI_EC_STS_UD1A; + /* + * Indicates if the host sent a command or data. + * 0 = data + * 1 = Command. + */ + acpi_evt->type = acpi_ec0_hw->EC_STS & MCHP_ACPI_EC_STS_CMD ? 1 : 0; + acpi_evt->data = acpi_ec0_hw->OS2EC_DATA; + } +#endif /* CONFIG_ESPI_PERIPHERAL_ACPI_EC_IBF_EVT_DATA */ espi_send_callbacks(&data->callbacks, dev, evt); @@ -514,6 +534,19 @@ static void acpi_ec1_ibf_isr(const struct device *dev) #endif .evt_data = ESPI_PERIPHERAL_NODATA }; +#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_EC_IBF_EVT_DATA + struct acpi_ec_regs *acpi_ec1_hw = (struct acpi_ec_regs *)xec_acpi_ec1_cfg.regbase; + + /* Updates to fit Chrome shim layer design. + * Host put data on input buffer of ACPI EC1 channel. + */ + if (acpi_ec1_hw->EC_STS & MCHP_ACPI_EC_STS_IBF) { + /* Set processing flag before reading command byte */ + acpi_ec1_hw->EC_STS |= MCHP_ACPI_EC_STS_UD1A; + /* Read out input data and clear IBF pending bit */ + evt.evt_data = acpi_ec1_hw->OS2EC_DATA; + } +#endif /* CONFIG_ESPI_PERIPHERAL_ACPI_EC_IBF_EVT_DATA */ espi_send_callbacks(&data->callbacks, dev, evt);