summaryrefslogtreecommitdiff
path: root/common/espi.c
diff options
context:
space:
mode:
authorScott Worley <scott.worley@microchip.corp-partner.google.com>2017-12-20 12:23:59 -0500
committerchrome-bot <chrome-bot@chromium.org>2018-01-02 15:48:20 -0800
commitd813935b827b55f4650365a5e9e8096e47122f07 (patch)
tree32d0ef28e42c9b540770a5e4572e163e80f62b52 /common/espi.c
parentb74f6a576a822f43872f07aebb6909a457a84afa (diff)
downloadchrome-ec-d813935b827b55f4650365a5e9e8096e47122f07.tar.gz
espi: Add API to test if signal is eSPI virtual wire
Add espi_signal_is_vw in new file common/espi.c for testing if a signal is an eSPI virtual wire. API used in power common and intel_x86. Fix CONFIG_BRINGUP support for eSPI (off by default). Add espi_vw_get_wire_name returning a pointer to constant string. Chip modules do not need to maintain names of eSPI signals. BRANCH=none BUG= TEST=Build poppy and other eSPI enabled boards. Test power state machine. Change-Id: I13319e79d208c69092a02ec3ac655477d3043d61 Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/836818 Commit-Ready: Randall Spangler <rspangler@chromium.org> Tested-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/espi.c')
-rw-r--r--common/espi.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/common/espi.c b/common/espi.c
new file mode 100644
index 0000000000..4c6a0ed1c2
--- /dev/null
+++ b/common/espi.c
@@ -0,0 +1,67 @@
+/* Copyright (c) 2017 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.
+ */
+
+/* eSPI common functionality for Chrome EC */
+
+#include "common.h"
+#include "gpio.h"
+#include "registers.h"
+#include "espi.h"
+#include "timer.h"
+#include "util.h"
+
+
+const char *espi_vw_names[] = {
+ "VW_SLP_S3_L",
+ "VW_SLP_S4_L",
+ "VW_SLP_S5_L",
+ "VW_SUS_STAT_L",
+ "VW_PLTRST_L",
+ "VW_OOB_RST_WARN",
+ "VW_OOB_RST_ACK",
+ "VW_WAKE_L",
+ "VW_PME_L",
+ "VW_ERROR_FATAL",
+ "VW_ERROR_NON_FATAL",
+ /* Merge bit 3/0 into one signal. Need to set them simultaneously */
+ "VW_SLAVE_BTLD_STATUS_DONE",
+ "VW_SCI_L",
+ "VW_SMI_L",
+ "VW_RCIN_L",
+ "VW_HOST_RST_ACK",
+ "VW_HOST_RST_WARN",
+ "VW_SUS_ACK",
+ "VW_SUS_WARN_L",
+ "VW_SUS_PWRDN_ACK_L",
+ "VW_SLP_A_L",
+ "VW_SLP_LAN",
+ "VW_SLP_WLAN",
+};
+BUILD_ASSERT(ARRAY_SIZE(espi_vw_names) == VW_SIGNAL_COUNT);
+
+
+const char *espi_vw_get_wire_name(enum espi_vw_signal signal)
+{
+ int idx;
+
+ if ((uint32_t)signal > VW_SIGNAL_BASE) {
+ idx = (uint32_t)signal - (VW_SIGNAL_BASE + 1);
+ if (idx < ARRAY_SIZE(espi_vw_names))
+ return espi_vw_names[idx];
+ }
+
+ return NULL;
+}
+
+
+int espi_signal_is_vw(int signal)
+{
+ enum espi_vw_signal sig = (enum espi_vw_signal)signal;
+
+ if ((sig > VW_SIGNAL_BASE) && (sig < VW_SIGNAL_BASE_END))
+ return 1;
+
+ return 0;
+}