diff options
author | Jun Lin <CHLin56@nuvoton.com> | 2021-07-26 15:14:33 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-08-10 19:38:41 +0000 |
commit | 23815b617cf50cd210455a0c6b046fb8e12b0805 (patch) | |
tree | 7a3afe7b4d821fd03cea4960de2b5c3dd35464b9 /zephyr | |
parent | 85302111760b33ca52e0e7a212ded68c2967e7b3 (diff) | |
download | chrome-ec-23815b617cf50cd210455a0c6b046fb8e12b0805.tar.gz |
zephyr: eSPI: npcx: unify the access to eSPI event data
Follow PR:37194 to access KBC/ACPI event data via structure if the
Zephyr version is v2.6. Otherwise, use the original chip-vendor-specific
macro on version v2.5.
BUG=none
BRANCH=none
TEST=pass "zmake testall"
TEST=test on Volteer, verify that the platform can boot up to OS screen;
make sure keyboard is functional.
Cq-Depend: chromium:3054142
Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
Change-Id: Iff857809b3c11e734825c113cb8d9913a7a177f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3053140
Tested-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Yuval Peress <peress@chromium.org>
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'zephyr')
-rw-r--r-- | zephyr/shim/chip/npcx/espi.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/zephyr/shim/chip/npcx/espi.c b/zephyr/shim/chip/npcx/espi.c index 163db6007f..7668359686 100644 --- a/zephyr/shim/chip/npcx/espi.c +++ b/zephyr/shim/chip/npcx/espi.c @@ -6,35 +6,73 @@ #include <device.h> #include <sys/util.h> +#include "cros_version.h" +#include "drivers/espi.h" #include "soc_espi.h" #include "zephyr_espi_shim.h" bool is_acpi_command(uint32_t data) { +#if IS_ZEPHYR_VERSION(2, 6) + struct espi_evt_data_acpi *acpi = (struct espi_evt_data_acpi *)&data; + + return acpi->type; +#elif IS_ZEPHYR_VERSION(2, 5) return (data >> NPCX_ACPI_TYPE_POS) & 0x01; +#endif } uint32_t get_acpi_value(uint32_t data) { +#if IS_ZEPHYR_VERSION(2, 6) + struct espi_evt_data_acpi *acpi = (struct espi_evt_data_acpi *)&data; + + return acpi->data; +#elif IS_ZEPHYR_VERSION(2, 5) return (data >> NPCX_ACPI_DATA_POS) & 0xff; +#endif } bool is_8042_ibf(uint32_t data) { +#if IS_ZEPHYR_VERSION(2, 6) + struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data; + + return kbc->evt & HOST_KBC_EVT_IBF; +#elif IS_ZEPHYR_VERSION(2, 5) return (data >> NPCX_8042_EVT_POS) & NPCX_8042_EVT_IBF; +#endif } bool is_8042_obe(uint32_t data) { +#if IS_ZEPHYR_VERSION(2, 6) + struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data; + + return kbc->evt & HOST_KBC_EVT_OBE; +#elif IS_ZEPHYR_VERSION(2, 5) return (data >> NPCX_8042_EVT_POS) & NPCX_8042_EVT_OBE; +#endif } uint32_t get_8042_type(uint32_t data) { +#if IS_ZEPHYR_VERSION(2, 6) + struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data; + + return kbc->type; +#elif IS_ZEPHYR_VERSION(2, 5) return (data >> NPCX_8042_TYPE_POS) & 0xFF; +#endif } uint32_t get_8042_data(uint32_t data) { +#if IS_ZEPHYR_VERSION(2, 6) + struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data; + + return kbc->data; +#elif IS_ZEPHYR_VERSION(2, 5) return (data >> NPCX_8042_DATA_POS) & 0xFF; +#endif } |