diff options
author | Dino Li <Dino.Li@ite.com.tw> | 2021-11-16 13:46:55 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-22 17:05:01 +0000 |
commit | 0b293e2fd74ea5aeccafcd310c077791e68af5e2 (patch) | |
tree | ac329bd1af4b727d0b2ea73fbb0c38e2f2ceaa79 | |
parent | c5e905a43164dab966ca055488b7801d6fed9d1b (diff) | |
download | chrome-ec-0b293e2fd74ea5aeccafcd310c077791e68af5e2.tar.gz |
zephyr: espi: move common function to src/espi.c
These six functions can be common. Because they use the event data
struct of common espi driver header file to parse host's request.
BRANCH=none
BUG=none
TEST=zmake testall
On adlrvp, verify that the I/O port (60h/64h, 62h/66h) communication
looks good.
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Change-Id: I4ccb264343a6cc3a0145ec1db60a7eec0bd79350
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3282974
Reviewed-by: Yuval Peress <peress@google.com>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
Tested-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r-- | zephyr/shim/chip/CMakeLists.txt | 2 | ||||
-rw-r--r-- | zephyr/shim/chip/npcx/CMakeLists.txt | 1 | ||||
-rw-r--r-- | zephyr/shim/chip/npcx/espi.c | 53 | ||||
-rw-r--r-- | zephyr/shim/chip/posix/CMakeLists.txt | 5 | ||||
-rw-r--r-- | zephyr/shim/chip/posix/espi.c | 49 | ||||
-rw-r--r-- | zephyr/shim/src/espi.c | 42 |
6 files changed, 42 insertions, 110 deletions
diff --git a/zephyr/shim/chip/CMakeLists.txt b/zephyr/shim/chip/CMakeLists.txt index 5c76a4163a..59b5a6c739 100644 --- a/zephyr/shim/chip/CMakeLists.txt +++ b/zephyr/shim/chip/CMakeLists.txt @@ -6,7 +6,5 @@ if (DEFINED CONFIG_SOC_FAMILY_NPCX) add_subdirectory(npcx) elseif (DEFINED CONFIG_SOC_FAMILY_RISCV_ITE) add_subdirectory(it8xxx2) -elseif (DEFINED CONFIG_SOC_POSIX) - add_subdirectory(posix) endif() diff --git a/zephyr/shim/chip/npcx/CMakeLists.txt b/zephyr/shim/chip/npcx/CMakeLists.txt index d3cd4b48fd..585b072ea8 100644 --- a/zephyr/shim/chip/npcx/CMakeLists.txt +++ b/zephyr/shim/chip/npcx/CMakeLists.txt @@ -13,7 +13,6 @@ 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 deleted file mode 100644 index 2115f388d6..0000000000 --- a/zephyr/shim/chip/npcx/espi.c +++ /dev/null @@ -1,53 +0,0 @@ -/* 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 "drivers/espi.h" -#include "soc_espi.h" -#include "zephyr_espi_shim.h" - -bool is_acpi_command(uint32_t data) -{ - struct espi_evt_data_acpi *acpi = (struct espi_evt_data_acpi *)&data; - - return acpi->type; -} - -uint32_t get_acpi_value(uint32_t data) -{ - struct espi_evt_data_acpi *acpi = (struct espi_evt_data_acpi *)&data; - - return acpi->data; -} - -bool is_8042_ibf(uint32_t data) -{ - struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data; - - return kbc->evt & HOST_KBC_EVT_IBF; -} - -bool is_8042_obe(uint32_t data) -{ - struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data; - - return kbc->evt & HOST_KBC_EVT_OBE; -} - -uint32_t get_8042_type(uint32_t data) -{ - struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data; - - return kbc->type; -} - -uint32_t get_8042_data(uint32_t data) -{ - struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data; - - return kbc->data; -} diff --git a/zephyr/shim/chip/posix/CMakeLists.txt b/zephyr/shim/chip/posix/CMakeLists.txt deleted file mode 100644 index 70e8b6269a..0000000000 --- a/zephyr/shim/chip/posix/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# 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. - -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ESPI espi.c)
\ No newline at end of file diff --git a/zephyr/shim/chip/posix/espi.c b/zephyr/shim/chip/posix/espi.c deleted file mode 100644 index cf348744d7..0000000000 --- a/zephyr/shim/chip/posix/espi.c +++ /dev/null @@ -1,49 +0,0 @@ -/* 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; -} diff --git a/zephyr/shim/src/espi.c b/zephyr/shim/src/espi.c index 12027a6399..f3d80e2071 100644 --- a/zephyr/shim/src/espi.c +++ b/zephyr/shim/src/espi.c @@ -561,3 +561,45 @@ int zephyr_shim_setup_espi(void) return 0; } + +bool is_acpi_command(uint32_t data) +{ + struct espi_evt_data_acpi *acpi = (struct espi_evt_data_acpi *)&data; + + return acpi->type; +} + +uint32_t get_acpi_value(uint32_t data) +{ + struct espi_evt_data_acpi *acpi = (struct espi_evt_data_acpi *)&data; + + return acpi->data; +} + +bool is_8042_ibf(uint32_t data) +{ + struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data; + + return kbc->evt & HOST_KBC_EVT_IBF; +} + +bool is_8042_obe(uint32_t data) +{ + struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data; + + return kbc->evt & HOST_KBC_EVT_OBE; +} + +uint32_t get_8042_type(uint32_t data) +{ + struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data; + + return kbc->type; +} + +uint32_t get_8042_data(uint32_t data) +{ + struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data; + + return kbc->data; +} |