summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew McRae <amcrae@google.com>2022-10-20 13:30:19 +1100
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-21 23:24:15 +0000
commitcaf76c98a56b3caa61d0d17b150b6b74f00142af (patch)
treecad0e527aa8485464181b23d73998011e5914cf1
parent5fbf200722a89fc48411a5392219ad29772a48fe (diff)
downloadchrome-ec-caf76c98a56b3caa61d0d17b150b6b74f00142af.tar.gz
gpio: Read actual pin level rather than the output set
Read the actual pin level rather than the value that was set for the output GPIO. Code that requires obtaining the value that was written to the output should use the legacy gpio_get_flags() or the zephyr gpio_pin_get_config() API. This change essentially reverts the fix for b/236094811, which is no longer needed since the GPIOs in question are handled by the Zephyr AP power signal API. BUG=b:254057906 TEST=./twister -T zephyr/test/drivers BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: Iaf51b0c4f9b821fe9b00c10023209a93f718f8e4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3963945 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/shim/src/gpio.c24
-rw-r--r--zephyr/test/drivers/boards/native_posix.overlay2
-rw-r--r--zephyr/test/drivers/prj.conf1
3 files changed, 1 insertions, 26 deletions
diff --git a/zephyr/shim/src/gpio.c b/zephyr/shim/src/gpio.c
index 9738bf3de2..d317553357 100644
--- a/zephyr/shim/src/gpio.c
+++ b/zephyr/shim/src/gpio.c
@@ -95,30 +95,6 @@ int gpio_get_level(enum gpio_signal signal)
if (!gpio_is_implemented(signal))
return 0;
- /*
- * If an output GPIO, get the configured value of the output
- * rather than the raw value of the pin.
- */
- if (IS_ENABLED(CONFIG_GPIO_GET_CONFIG) &&
- configs[signal].init_flags & GPIO_OUTPUT) {
- int rv;
- gpio_flags_t flags;
-
- rv = gpio_pin_get_config_dt(&configs[signal].spec, &flags);
- if (rv == 0) {
- return (flags & GPIO_OUTPUT_INIT_HIGH) ? 1 : 0;
- }
- /*
- * -ENOSYS is returned when this API call is not supported,
- * so drop into the default method of returning the pin value.
- */
- if (rv != -ENOSYS) {
- LOG_ERR("Cannot get config for %s (%d)",
- configs[signal].name, rv);
- return 0;
- }
- }
-
const int l = gpio_pin_get_raw(configs[signal].spec.port,
configs[signal].spec.pin);
diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay
index 6d9b74fc64..bac078ccd8 100644
--- a/zephyr/test/drivers/boards/native_posix.overlay
+++ b/zephyr/test/drivers/boards/native_posix.overlay
@@ -209,7 +209,7 @@
enum-name = "GPIO_VOLUME_UP_L";
};
gpio_en_pp5000_usba_r: en_pp5000_usba_r {
- gpios = <&gpio1 5 GPIO_OUTPUT_LOW>;
+ gpios = <&gpio1 5 (GPIO_INPUT | GPIO_OUTPUT_LOW)>;
enum-name = "GPIO_EN_PP5000_USBA_R";
};
gpio_ec_pg_pin_temp: ec_pg_pin_temp {
diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf
index 04b9bdd820..eea05e6bef 100644
--- a/zephyr/test/drivers/prj.conf
+++ b/zephyr/test/drivers/prj.conf
@@ -46,7 +46,6 @@ CONFIG_LOG=y
CONFIG_I2C=y
CONFIG_I2C_EMUL=y
CONFIG_GPIO=y
-CONFIG_GPIO_GET_CONFIG=y
CONFIG_GPIO_EMUL=y
CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY=49
CONFIG_EEPROM=y