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/posix/espi.c | |
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/posix/espi.c')
-rw-r--r-- | zephyr/shim/chip/posix/espi.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/zephyr/shim/chip/posix/espi.c b/zephyr/shim/chip/posix/espi.c new file mode 100644 index 0000000000..cf348744d7 --- /dev/null +++ b/zephyr/shim/chip/posix/espi.c @@ -0,0 +1,49 @@ +/* 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 <sys/util.h> +#include "zephyr_espi_shim.h" + +#define ACPI_TYPE_POS 0U +#define ACPI_DATA_POS 8U + +/* 8042 event data format */ +#define POSIX_8042_EVT_POS 16U +#define POSIX_8042_DATA_POS 8U +#define POSIX_8042_TYPE_POS 0U + +/* 8042 event type format */ +#define POSIX_8042_EVT_IBF BIT(0) +#define POSIX_8042_EVT_OBE BIT(1) + +bool is_acpi_command(uint32_t data) +{ + return (data >> ACPI_TYPE_POS) & 0x01; +} + +uint32_t get_acpi_value(uint32_t data) +{ + return (data >> ACPI_TYPE_POS) & 0xff; +} + +bool is_POSIX_8042_ibf(uint32_t data) +{ + return (data >> POSIX_8042_EVT_POS) & POSIX_8042_EVT_IBF; +} + +bool is_POSIX_8042_obe(uint32_t data) +{ + return (data >> POSIX_8042_EVT_POS) & POSIX_8042_EVT_OBE; +} + +uint32_t get_POSIX_8042_type(uint32_t data) +{ + return (data >> POSIX_8042_TYPE_POS) & 0xFF; +} + +uint32_t get_POSIX_8042_data(uint32_t data) +{ + return (data >> POSIX_8042_DATA_POS) & 0xFF; +} |