diff options
author | Tim Lin <tim2.lin@ite.corp-partner.google.com> | 2021-12-06 17:25:59 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-12-09 22:15:23 +0000 |
commit | 06cb11945d172e7bfcec1f7487a8f769d17e9a65 (patch) | |
tree | 0d7147f420ec6069aad01e50bc0edf62661bed0e | |
parent | 90d9caf160e1f7c6ca91e1ab942b75925df92dfb (diff) | |
download | chrome-ec-06cb11945d172e7bfcec1f7487a8f769d17e9a65.tar.gz |
zephyr: gpio: configure unused gpio pin
Configure unused gpio pin.
BUG=b:192354255
BRANCH=none
TEST=zmake testall
TEST=compared with unconfigured:
S0: power saving ~0.07mA
S3: power saving ~0.19mA
G3: power saving ~0.29mA
hibernate: power saving ~0.3mA
Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
Change-Id: I30fe7954929dd7f818cef193967730ef43f9d7b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3315765
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Keith Short <keithshort@chromium.org>
Commit-Queue: Keith Short <keithshort@chromium.org>
-rw-r--r-- | zephyr/projects/asurada/hayato/gpio.dts | 2 | ||||
-rw-r--r-- | zephyr/shim/chip/it8xxx2/CMakeLists.txt | 1 | ||||
-rw-r--r-- | zephyr/shim/chip/it8xxx2/gpio.c | 55 |
3 files changed, 56 insertions, 2 deletions
diff --git a/zephyr/projects/asurada/hayato/gpio.dts b/zephyr/projects/asurada/hayato/gpio.dts index 380df3103d..971ba4d936 100644 --- a/zephyr/projects/asurada/hayato/gpio.dts +++ b/zephyr/projects/asurada/hayato/gpio.dts @@ -348,8 +348,6 @@ compatible = "unused-gpios"; unused-gpios = - /* uart1_rx */ - <&gpiob 0 GPIO_INPUT>, /* nc_gpg3 */ <&gpiog 3 GPIO_OUT_LOW>, /* nc_gpi7 */ diff --git a/zephyr/shim/chip/it8xxx2/CMakeLists.txt b/zephyr/shim/chip/it8xxx2/CMakeLists.txt index f72f715acf..6f905a20ba 100644 --- a/zephyr/shim/chip/it8xxx2/CMakeLists.txt +++ b/zephyr/shim/chip/it8xxx2/CMakeLists.txt @@ -5,6 +5,7 @@ zephyr_library_include_directories(include) zephyr_library_sources(clock.c) +zephyr_library_sources(gpio.c) zephyr_library_sources_ifdef(CONFIG_CROS_EC system.c) zephyr_library_sources_ifdef(CONFIG_CROS_EC pinmux.c) zephyr_library_sources_ifdef(CONFIG_CROS_KB_RAW_ITE keyboard_raw.c) diff --git a/zephyr/shim/chip/it8xxx2/gpio.c b/zephyr/shim/chip/it8xxx2/gpio.c new file mode 100644 index 0000000000..148e1a97c9 --- /dev/null +++ b/zephyr/shim/chip/it8xxx2/gpio.c @@ -0,0 +1,55 @@ +/* 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 <kernel.h> + +#include <logging/log.h> + +#include "gpio.h" +#include "gpio/gpio.h" + +LOG_MODULE_REGISTER(shim_cros_gpio, LOG_LEVEL_ERR); + +static const struct unused_pin_config unused_pin_configs[] = { + UNUSED_GPIO_CONFIG_LIST +}; + +int gpio_config_unused_pins(void) +{ + for (size_t i = 0; i < ARRAY_SIZE(unused_pin_configs); ++i) { + int rv; + int flags; + const struct device *dev = + device_get_binding(unused_pin_configs[i].dev_name); + + if (dev == NULL) { + LOG_ERR("Not found (%s)", + unused_pin_configs[i].dev_name); + return -ENOTSUP; + } + + /* + * Set the default setting for the floating IOs. The floating + * IOs cause the leakage current. Set unused pins as input with + * internal PU to prevent extra power consumption. + */ + if (unused_pin_configs[i].flags == 0) + flags = GPIO_INPUT | GPIO_PULL_UP; + else + flags = unused_pin_configs[i].flags; + + rv = gpio_pin_configure(dev, unused_pin_configs[i].pin, flags); + + if (rv < 0) { + LOG_ERR("Config failed %s-%d (%d)", + unused_pin_configs[i].dev_name, + unused_pin_configs[i].pin, rv); + return rv; + } + } + + return 0; +} |