diff options
author | Scott Worley <scott.worley@microchip.corp-partner.google.com> | 2017-12-20 15:18:12 -0500 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-12-28 12:35:08 -0800 |
commit | 5b6ec95320d231fb15a9ec69e2eefeb5eed1fd25 (patch) | |
tree | 4d1ce3e29870d4c872fc74312a2de9f22e5e4549 /common/gpio.c | |
parent | 4e9588ddcffb9315b0a74ac62121efb76b7b2202 (diff) | |
download | chrome-ec-5b6ec95320d231fb15a9ec69e2eefeb5eed1fd25.tar.gz |
ec_gpio: Add GPIO power down support
Experimental and disabled by default feature for
powering down GPIO pins on those EC's supporting it.
Pins may be powered down by module ID or pin name.
Goal is to make use of common GPIO pin table.
If enabled, developer must implement power down
support in chip level. Developer re-powers module
pin(s) by calling the current gpio module enable
API in the wake path.
BRANCH=none
BUG=
TEST=Feature is disabled by default. Build all
boards with feature disabled.
Change-Id: Ifacd08e51def6424baf5c78c84b24f1d9f4bc4aa
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
Diffstat (limited to 'common/gpio.c')
-rw-r--r-- | common/gpio.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/common/gpio.c b/common/gpio.c index b0200facfd..0fa949dedb 100644 --- a/common/gpio.c +++ b/common/gpio.c @@ -168,4 +168,38 @@ int gpio_get_ternary(enum gpio_signal signal) return pu && !pd ? 2 : pd; } +#ifdef CONFIG_GPIO_POWER_DOWN +/* + * Power down a group of GPIO pins marked with a module ID + * in board/board_name/gpio.inc + * Hibernation/sleep entry: + * gpio_power_down_module(MODULE_xxxx) + * Chip level code will power down all pins in module. + * Wake: + * Use gpio_config_module to put the module pin(s) + * back to enabled state. Chip level code will re-power + * and configure the pin(s). + * This mechanism does not handle dynamic changing of + * pin configuration at run time. + */ +int gpio_power_down_module(enum module_id id) +{ + const struct gpio_alt_func *af; + int rv = EC_ERROR_INVAL; + + /* Find pins and power down */ + for (af = gpio_alt_funcs; + af < gpio_alt_funcs + ARRAY_SIZE(gpio_alt_funcs); + af++) { + if (af->module_id != id) + continue; /* Pins for some other module */ + + gpio_set_flags_by_mask(af->port, af->mask, GPIO_POWER_DOWN); + rv = EC_SUCCESS; + } + + return rv; +} +#endif /* #ifdef CONFIG_GPIO_POWER_DOWN */ + /*****************************************************************************/ |