diff options
author | Yuval Peress <peress@chromium.org> | 2021-07-21 13:08:29 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-07-22 16:06:15 +0000 |
commit | d22b18489f721a0f8030381df4b7fb62e7738968 (patch) | |
tree | 60e43d9a6309506635e5b8da0d479ceae0951be7 /zephyr/shim/chip/npcx | |
parent | 8ad65a6f25a8237cf9d991141fd4a3f3fc366565 (diff) | |
download | chrome-ec-d22b18489f721a0f8030381df4b7fb62e7738968.tar.gz |
zephyr: Remove NPCX dependency from shim/src/espi.c
Allow building the zephyr/shim/src/espi.c for other SOCs by adding
inline functions to abstract away these concepts. Each SOC should
then implement these under the zephyr/shim/chip/<soc> specific
directory.
BRANCH=none
BUG=b:189954415
TEST=zmake testall
Signed-off-by: Yuval Peress <peress@chromium.org>
Change-Id: I776bd65326b509ada3b271177ae727a32d4f96da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3044400
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'zephyr/shim/chip/npcx')
-rw-r--r-- | zephyr/shim/chip/npcx/CMakeLists.txt | 1 | ||||
-rw-r--r-- | zephyr/shim/chip/npcx/espi.c | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/zephyr/shim/chip/npcx/CMakeLists.txt b/zephyr/shim/chip/npcx/CMakeLists.txt index c7cca9939a..a184d678f6 100644 --- a/zephyr/shim/chip/npcx/CMakeLists.txt +++ b/zephyr/shim/chip/npcx/CMakeLists.txt @@ -6,6 +6,7 @@ zephyr_library_include_directories(include) zephyr_library_sources(clock.c) zephyr_library_sources(gpio.c) +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ESPI espi.c) zephyr_library_sources_ifdef(CONFIG_CROS_KB_RAW_NPCX keyboard_raw.c) zephyr_library_sources_ifdef(CONFIG_CROS_SHI_NPCX shi.c) zephyr_library_sources_ifdef(CONFIG_CROS_EC system.c) diff --git a/zephyr/shim/chip/npcx/espi.c b/zephyr/shim/chip/npcx/espi.c new file mode 100644 index 0000000000..163db6007f --- /dev/null +++ b/zephyr/shim/chip/npcx/espi.c @@ -0,0 +1,40 @@ +/* Copyright 2021 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include <device.h> +#include <sys/util.h> + +#include "soc_espi.h" +#include "zephyr_espi_shim.h" + +bool is_acpi_command(uint32_t data) +{ + return (data >> NPCX_ACPI_TYPE_POS) & 0x01; +} + +uint32_t get_acpi_value(uint32_t data) +{ + return (data >> NPCX_ACPI_DATA_POS) & 0xff; +} + +bool is_8042_ibf(uint32_t data) +{ + return (data >> NPCX_8042_EVT_POS) & NPCX_8042_EVT_IBF; +} + +bool is_8042_obe(uint32_t data) +{ + return (data >> NPCX_8042_EVT_POS) & NPCX_8042_EVT_OBE; +} + +uint32_t get_8042_type(uint32_t data) +{ + return (data >> NPCX_8042_TYPE_POS) & 0xFF; +} + +uint32_t get_8042_data(uint32_t data) +{ + return (data >> NPCX_8042_DATA_POS) & 0xFF; +} |