summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-04-10 09:58:36 +1200
committerCommit Bot <commit-bot@chromium.org>2021-04-22 22:38:46 +0000
commit964d97811ecf157c5436288d0aad9ba399e4dd72 (patch)
tree638d6504b3a3e603d1c84320b7006e0b49fb53a6
parent0f3b5955efc635ff6f387485733f66e7e1971918 (diff)
downloadchrome-ec-964d97811ecf157c5436288d0aad9ba399e4dd72.tar.gz
zephyr: espi: Reorder to avoid forward declarations
It seems that these perhaps confuse the compiler, producing this warning in some cases: zephyr/shim/src/espi.c:142:13: warning: 'kbc_ibf_obe_handler' used but never defined Reorder the code to fix this. BUG=none BRANCH=none TEST=try on gitlab: https://gitlab.com/zephyr-ec/ec/-/jobs/1167734180 Change-Id: Ic3fbce80974ac978d38c97bdf25a12facf11201f Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2817959 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/shim/src/espi.c163
1 files changed, 80 insertions, 83 deletions
diff --git a/zephyr/shim/src/espi.c b/zephyr/shim/src/espi.c
index 5a2205dd6d..5018978f9a 100644
--- a/zephyr/shim/src/espi.c
+++ b/zephyr/shim/src/espi.c
@@ -137,38 +137,6 @@ 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 kbc_ibf_obe_handler(uint32_t data);
-
-static void espi_peripheral_handler(const struct device *dev,
- struct espi_callback *cb,
- struct espi_event event)
-{
- uint16_t event_type = event.evt_details;
-
- if (IS_ENABLED(CONFIG_PLATFORM_EC_PORT80) &&
- event_type == ESPI_PERIPHERAL_DEBUG_PORT80) {
- 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);
- }
-
- if (IS_ENABLED(CONFIG_ESPI_PERIPHERAL_8042_KBC) &&
- IS_ENABLED(HAS_TASK_KEYPROTO) &&
- event_type == ESPI_PERIPHERAL_8042_KBC) {
- kbc_ibf_obe_handler(event.evt_data);
- }
-}
-
#ifdef CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK
static void espi_chipset_reset(void)
{
@@ -189,57 +157,6 @@ static void espi_reset_handler(const struct device *dev,
#define ESPI_DEV DT_LABEL(DT_NODELABEL(espi0))
static const struct device *espi_dev;
-int zephyr_shim_setup_espi(void)
-{
- static struct {
- struct espi_callback cb;
- espi_callback_handler_t handler;
- enum espi_bus_event event_type;
- } callbacks[] = {
- {
- .handler = espi_vwire_handler,
- .event_type = ESPI_BUS_EVENT_VWIRE_RECEIVED,
- },
- {
- .handler = espi_peripheral_handler,
- .event_type = ESPI_BUS_PERIPHERAL_NOTIFICATION,
- },
-#ifdef CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK
- {
- .handler = espi_reset_handler,
- .event_type = ESPI_BUS_RESET,
- },
-#endif
- };
-
- struct espi_cfg cfg = {
- .io_caps = ESPI_IO_MODE_SINGLE_LINE,
- .channel_caps = ESPI_CHANNEL_VWIRE | ESPI_CHANNEL_PERIPHERAL |
- ESPI_CHANNEL_OOB,
- .max_freq = 20,
- };
-
- espi_dev = device_get_binding(ESPI_DEV);
- if (!espi_dev) {
- LOG_ERR("Failed to find device %s", ESPI_DEV);
- return -1;
- }
-
- /* Configure eSPI */
- if (espi_config(espi_dev, &cfg)) {
- LOG_ERR("Failed to configure eSPI device");
- return -1;
- }
-
- /* Setup callbacks */
- for (size_t i = 0; i < ARRAY_SIZE(callbacks); i++) {
- espi_init_callback(&callbacks[i].cb, callbacks[i].handler,
- callbacks[i].event_type);
- espi_add_callback(espi_dev, &callbacks[i].cb);
- }
-
- return 0;
-}
int espi_vw_set_wire(enum espi_vw_signal signal, uint8_t level)
{
@@ -565,3 +482,83 @@ int lpc_keyboard_input_pending(void)
espi_read_lpc_request(espi_dev, E8042_IBF_HAS_CHAR, &status);
return status;
}
+
+static void espi_peripheral_handler(const struct device *dev,
+ struct espi_callback *cb,
+ struct espi_event event)
+{
+ uint16_t event_type = event.evt_details;
+
+ if (IS_ENABLED(CONFIG_PLATFORM_EC_PORT80) &&
+ event_type == ESPI_PERIPHERAL_DEBUG_PORT80) {
+ 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);
+ }
+
+ if (IS_ENABLED(CONFIG_ESPI_PERIPHERAL_8042_KBC) &&
+ IS_ENABLED(HAS_TASK_KEYPROTO) &&
+ event_type == ESPI_PERIPHERAL_8042_KBC) {
+ kbc_ibf_obe_handler(event.evt_data);
+ }
+}
+
+int zephyr_shim_setup_espi(void)
+{
+ static struct {
+ struct espi_callback cb;
+ espi_callback_handler_t handler;
+ enum espi_bus_event event_type;
+ } callbacks[] = {
+ {
+ .handler = espi_vwire_handler,
+ .event_type = ESPI_BUS_EVENT_VWIRE_RECEIVED,
+ },
+ {
+ .handler = espi_peripheral_handler,
+ .event_type = ESPI_BUS_PERIPHERAL_NOTIFICATION,
+ },
+#ifdef CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK
+ {
+ .handler = espi_reset_handler,
+ .event_type = ESPI_BUS_RESET,
+ },
+#endif
+ };
+
+ struct espi_cfg cfg = {
+ .io_caps = ESPI_IO_MODE_SINGLE_LINE,
+ .channel_caps = ESPI_CHANNEL_VWIRE | ESPI_CHANNEL_PERIPHERAL |
+ ESPI_CHANNEL_OOB,
+ .max_freq = 20,
+ };
+
+ espi_dev = device_get_binding(ESPI_DEV);
+ if (!espi_dev) {
+ LOG_ERR("Failed to find device %s", ESPI_DEV);
+ return -1;
+ }
+
+ /* Configure eSPI */
+ if (espi_config(espi_dev, &cfg)) {
+ LOG_ERR("Failed to configure eSPI device");
+ return -1;
+ }
+
+ /* Setup callbacks */
+ for (size_t i = 0; i < ARRAY_SIZE(callbacks); i++) {
+ espi_init_callback(&callbacks[i].cb, callbacks[i].handler,
+ callbacks[i].event_type);
+ espi_add_callback(espi_dev, &callbacks[i].cb);
+ }
+
+ return 0;
+}