diff options
author | Aseda Aboagye <aaboagye@google.com> | 2020-02-19 20:41:48 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-21 10:30:11 +0000 |
commit | d3b9d8ad4739d6f65fcc321105a7031d15e1b3a0 (patch) | |
tree | bfcce8365f2d7c8bef0839dd19f482c356b4b416 | |
parent | bbbd07dbe113d0c65c15c6ef997bb55fa82575e6 (diff) | |
download | chrome-ec-d3b9d8ad4739d6f65fcc321105a7031d15e1b3a0.tar.gz |
power/common: Add board specific API for 5V control
Some boards need different mechanisms to enable/disable the 5V rail
that's not simply setting the PP5000_EN GPIO. This commit adds a new
board specific API to control the 5V rail. If a board needs something
more complex, they should define `board_power_5v_enable`.
BUG=b:149794574
BRANCH=None
TEST=Add definition for waddledoo, build and flash, verify that
sub-board 5V is turn on as well.
Change-Id: I333e3fb8f2b4e7f1907c792c0e35581150857f17
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2065494
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | include/power.h | 10 | ||||
-rw-r--r-- | power/common.c | 14 |
2 files changed, 19 insertions, 5 deletions
diff --git a/include/power.h b/include/power.h index b471264f99..410f412502 100644 --- a/include/power.h +++ b/include/power.h @@ -264,6 +264,16 @@ void power_reset_host_sleep_state(void); #endif /* CONFIG_POWER_TRACK_HOST_SLEEP_STATE */ /** + * Board specific implementation to enable/disable the PP5000 rail. + * + * NOTE: The default implementation is to simply set GPIO_EN_PP5000. If a + * board's implementation differs, they should implement this function. + * + * @param enable: 0 to disable PP5000 rail , otherwise enable PP5000 rail. + */ +__override_proto void board_power_5v_enable(int enable); + +/** * Enable/Disable the PP5000 rail. * * This function will turn on the 5V rail immediately if requested. However, diff --git a/power/common.c b/power/common.c index ee2c690b91..7c3ccc1475 100644 --- a/power/common.c +++ b/power/common.c @@ -898,6 +898,14 @@ DECLARE_CONSOLE_COMMAND(pause_in_s5, command_pause_in_s5, #endif /* CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5 */ #ifdef CONFIG_POWER_PP5000_CONTROL +__overridable void board_power_5v_enable(int enable) +{ + if (enable) + gpio_set_level(GPIO_EN_PP5000, 1); + else + gpio_set_level(GPIO_EN_PP5000, 0); +} + /* 5V enable request bitmask from various tasks. */ static uint32_t pwr_5v_en_req; static struct mutex pwr_5v_ctl_mtx; @@ -915,11 +923,7 @@ void power_5v_enable(task_id_t tid, int enable) * If there are any outstanding requests for the rail to be enabled, * turn on the rail. Otherwise, turn it off. */ - if (pwr_5v_en_req) - gpio_set_level(GPIO_EN_PP5000, 1); - else - gpio_set_level(GPIO_EN_PP5000, 0); - + board_power_5v_enable(pwr_5v_en_req); mutex_unlock(&pwr_5v_ctl_mtx); } |