summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEdward Hill <ecgh@chromium.org>2019-10-10 15:43:02 -0600
committerCommit Bot <commit-bot@chromium.org>2019-10-25 18:52:08 +0000
commit9f392b0d616f6fec17d213736e6bf9f4217392e4 (patch)
tree85eb83515d93fa2cd5fe036d270b2811ff9101cb /include
parent7eded13a72691fdce4d66f59c5b119969afa35c0 (diff)
downloadchrome-ec-9f392b0d616f6fec17d213736e6bf9f4217392e4.tar.gz
GPIO/IOEX/eSPI: Give different IO signals unique values
There are 3 different IO signal types used by the EC. Ensure they each use a unique range of values so we can tell them apart. 1) Local GPIO => 0 to 0x0FFF 2) IO expander GPIO => 0x1000 to 0x1FFF 3) eSPI virtual wire signals => 0x2000 to 0x2FFF BUG=b:138600691 BRANCH=none TEST=IO expander signals still work on Trembyle Change-Id: I63fadb4bb4573ed3dd121c24e3bd40a00873e29f Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1854778 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/espi.h11
-rw-r--r--include/gpio_signal.h27
-rw-r--r--include/ioexpander.h10
3 files changed, 41 insertions, 7 deletions
diff --git a/include/espi.h b/include/espi.h
index 2795f9aacb..6d4de73330 100644
--- a/include/espi.h
+++ b/include/espi.h
@@ -12,8 +12,9 @@
/* Signal through VW */
enum espi_vw_signal {
- VW_SIGNAL_BASE = GPIO_COUNT,
- VW_SLP_S3_L, /* index 02h (In) */
+ /* The first valid VW signal is 0x2000 */
+ VW_SIGNAL_START = IOEX_LIMIT + 1,
+ VW_SLP_S3_L = VW_SIGNAL_START, /* index 02h (In) */
VW_SLP_S4_L,
VW_SLP_S5_L,
VW_SUS_STAT_L, /* index 03h (In) */
@@ -37,10 +38,12 @@ enum espi_vw_signal {
VW_SLP_A_L,
VW_SLP_LAN, /* index 42h (In) */
VW_SLP_WLAN,
- VW_SIGNAL_BASE_END,
+ VW_SIGNAL_END,
+ VW_LIMIT = 0x2FFF
};
+BUILD_ASSERT(VW_SIGNAL_END < VW_LIMIT);
-#define VW_SIGNAL_COUNT (VW_SIGNAL_BASE_END - VW_SIGNAL_BASE - 1)
+#define VW_SIGNAL_COUNT (VW_SIGNAL_END - VW_SIGNAL_START)
/**
* Set eSPI Virtual-Wire signal to Host
diff --git a/include/gpio_signal.h b/include/gpio_signal.h
index e863b7c415..478e83dca5 100644
--- a/include/gpio_signal.h
+++ b/include/gpio_signal.h
@@ -6,21 +6,44 @@
#ifndef __CROS_EC_GPIO_SIGNAL_H
#define __CROS_EC_GPIO_SIGNAL_H
+#include "compile_time_macros.h"
+
+/*
+ * There are 3 different IO signal types used by the EC.
+ * Ensure they each use a unique range of values so we can tell them apart.
+ * 1) Local GPIO => 0 to 0x0FFF
+ * 2) IO expander GPIO => 0x1000 to 0x1FFF
+ * 3) eSPI virtual wire signals (defined in include/espi.h) => 0x2000 to 0x2FFF
+ */
+
#define GPIO(name, pin, flags) GPIO_##name,
#define UNIMPLEMENTED(name) GPIO_##name,
#define GPIO_INT(name, pin, flags, signal) GPIO_##name,
+#define GPIO_SIGNAL_START 0 /* The first valid GPIO signal is 0 */
+
enum gpio_signal {
#include "gpio.wrap"
- GPIO_COUNT
+ GPIO_COUNT,
+ /* Ensure that sizeof gpio_signal is large enough for ioex_signal */
+ GPIO_LIMIT = 0x0FFF
};
+BUILD_ASSERT(GPIO_COUNT < GPIO_LIMIT);
#define IOEX(name, expin, flags) IOEX_##name,
#define IOEX_INT(name, expin, flags, signal) IOEX_##name,
enum ioex_signal {
+ /* The first valid IOEX signal is 0x1000 */
+ IOEX_SIGNAL_START = GPIO_LIMIT + 1,
+ /* Used to ensure that the first IOEX signal is same as start */
+ __IOEX_PLACEHOLDER = GPIO_LIMIT,
#include "gpio.wrap"
- IOEX_COUNT
+ IOEX_SIGNAL_END,
+ IOEX_LIMIT = 0x1FFF
};
+BUILD_ASSERT(IOEX_SIGNAL_END < IOEX_LIMIT);
+
+#define IOEX_COUNT (IOEX_SIGNAL_END - IOEX_SIGNAL_START)
#endif /* __CROS_EC_GPIO_SIGNAL_H */
diff --git a/include/ioexpander.h b/include/ioexpander.h
index 150db65750..206b0a390c 100644
--- a/include/ioexpander.h
+++ b/include/ioexpander.h
@@ -148,5 +148,13 @@ int ioex_init(int ioex);
* @returns name of the given IOEX signal
*/
const char *ioex_get_name(enum ioex_signal signal);
-#endif /* __CROS_EC_IOEXPANDER_H */
+/*
+ * Check if signal is an IO expander signal or GPIO signal.
+ *
+ * @param signal GPIO or IOEX signal
+ * @return 1 if signal is IOEX else return 0
+ */
+int signal_is_ioex(int signal);
+
+#endif /* __CROS_EC_IOEXPANDER_H */