summaryrefslogtreecommitdiff
path: root/zephyr
diff options
context:
space:
mode:
authorWealian Liao <whliao@nuvoton.corp-partner.google.com>2020-12-16 18:22:07 +0800
committerCommit Bot <commit-bot@chromium.org>2020-12-31 04:05:25 +0000
commitc1ef1854e6b3de173837217502bfe1f5f4459f22 (patch)
treef53d5cd9243f81f64a918e228da465372c42df30 /zephyr
parent200b09a3e5de25997eab6c19adf503cee5fa9b8e (diff)
downloadchrome-ec-c1ef1854e6b3de173837217502bfe1f5f4459f22.tar.gz
zephyr: add ACPI handler
Add ACPI handler, which will handle the Host data from the ACPI I/O port for X86 AP. For the Zephyr shim, the ACPI handler is invoked by ESPI_PERIPHERAL_HOST_IO event in ESPI_BUS_PERIPHERAL_NOTIFICATION eSPI event. BRANCH=none BUG=b:175217186 TEST=build & boot EC on volteer Cq-Depend: chromium:2603204 Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: Ic73b113bf863d10c2a9531174aba7b85018986f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2594757 Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'zephyr')
-rw-r--r--zephyr/CMakeLists.txt2
-rw-r--r--zephyr/Kconfig7
-rw-r--r--zephyr/shim/src/espi.c50
3 files changed, 59 insertions, 0 deletions
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
index 78fc2bc86b..68f7382cc6 100644
--- a/zephyr/CMakeLists.txt
+++ b/zephyr/CMakeLists.txt
@@ -45,6 +45,8 @@ zephyr_sources_ifdef(CONFIG_PLATFORM_EC "${PLATFORM_EC}/common/base32.c"
# Now include files that depend on or relate to other CONFIG options, sorted by
# CONFIG
+zephyr_sources_ifdef(CONFIG_PLATFORM_EC_ACPI "${PLATFORM_EC}/common/acpi.c"
+ "${PLATFORM_EC}/common/ec_features.c")
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY "${PLATFORM_EC}/common/battery.c")
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE
"${PLATFORM_EC}/common/battery_fuel_gauge.c")
diff --git a/zephyr/Kconfig b/zephyr/Kconfig
index c7d5f84c9d..f5f433631e 100644
--- a/zephyr/Kconfig
+++ b/zephyr/Kconfig
@@ -55,6 +55,13 @@ config ZEPHYR
#
# Please keep these in alphabetical order
+config PLATFORM_EC_ACPI
+ bool "Enable the ACPI module"
+ default y if AP_X86 && PLATFORM_EC_ESPI
+ help
+ Enable shimming the ACPI handler, which will handle the Host data from
+ the ACPI I/O port for X86 AP.
+
config PLATFORM_EC_CBI
bool "Enable the CBI EEPROM module"
depends on PLATFORM_EC_I2C
diff --git a/zephyr/shim/src/espi.c b/zephyr/shim/src/espi.c
index ee469ab38d..2a81bd0446 100644
--- a/zephyr/shim/src/espi.c
+++ b/zephyr/shim/src/espi.c
@@ -11,6 +11,7 @@
#include <stdint.h>
#include <zephyr.h>
+#include "acpi.h"
#include "chipset.h"
#include "common.h"
#include "espi.h"
@@ -18,6 +19,7 @@
#include "lpc.h"
#include "port80.h"
#include "power.h"
+#include "soc_espi.h"
#include "timer.h"
#include "zephyr_espi_shim.h"
@@ -132,6 +134,7 @@ static void espi_vwire_handler(const struct device *dev,
}
static void handle_host_write(uint32_t data);
+static void handle_acpi_write(uint32_t data);
static void espi_peripheral_handler(const struct device *dev,
struct espi_callback *cb,
@@ -144,6 +147,11 @@ static void espi_peripheral_handler(const struct device *dev,
port_80_write(event.evt_data);
}
+ if (IS_ENABLED(CONFIG_PLATFORM_EC_ACPI) &&
+ event_type == ESPI_PERIPHERAL_HOST_IO) {
+ handle_acpi_write(event.evt_data);
+ }
+
if (IS_ENABLED(CONFIG_PLATFORM_EC_HOSTCMD) &&
event_type == ESPI_PERIPHERAL_EC_HOST_CMD) {
handle_host_write(event.evt_data);
@@ -358,6 +366,32 @@ static void host_command_init(void)
DECLARE_HOOK(HOOK_INIT, host_command_init, HOOK_PRIO_INIT_LPC);
+static void handle_acpi_write(uint32_t data)
+{
+ uint8_t value, result;
+ uint8_t is_cmd = (data >> NPCX_ACPI_TYPE_POS) & 0x01;
+ uint32_t status;
+
+ value = (data >> NPCX_ACPI_DATA_POS) & 0xff;
+
+ /* Handle whatever this was. */
+ if (acpi_ap_to_ec(is_cmd, value, &result)) {
+ data = result;
+ espi_write_lpc_request(espi_dev, EACPI_WRITE_CHAR, &data);
+ }
+
+ /* Clear processing flag */
+ espi_read_lpc_request(espi_dev, EACPI_READ_STS, &status);
+ status &= ~EC_LPC_STATUS_PROCESSING;
+ espi_write_lpc_request(espi_dev, EACPI_WRITE_STS, &status);
+
+ /*
+ * ACPI 5.0-12.6.1: Generate SCI for Input Buffer Empty / Output Buffer
+ * Full condition on the kernel channel.
+ */
+ lpc_generate_sci();
+}
+
static void lpc_send_response_packet(struct host_packet *pkt)
{
uint32_t data;
@@ -399,3 +433,19 @@ static void handle_host_write(uint32_t data)
host_packet_receive(&lpc_packet);
return;
}
+
+void lpc_set_acpi_status_mask(uint8_t mask)
+{
+ uint32_t status;
+ espi_read_lpc_request(espi_dev, EACPI_READ_STS, &status);
+ status |= mask;
+ espi_write_lpc_request(espi_dev, EACPI_WRITE_STS, &status);
+}
+
+void lpc_clear_acpi_status_mask(uint8_t mask)
+{
+ uint32_t status;
+ espi_read_lpc_request(espi_dev, EACPI_READ_STS, &status);
+ status &= ~mask;
+ espi_write_lpc_request(espi_dev, EACPI_WRITE_STS, &status);
+}