diff options
author | Wai-Hong Tam <waihong@google.com> | 2020-09-02 18:20:52 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-09-04 00:25:49 +0000 |
commit | 5a0919d5d2bc4ed9cd2655181aa1024dfe46d83f (patch) | |
tree | 02446d5f9fbaff772a023320e991e5787374818a /board | |
parent | 61ee794d31b4429b8991043ad35e983adf776701 (diff) | |
download | chrome-ec-5a0919d5d2bc4ed9cd2655181aa1024dfe46d83f.tar.gz |
lazor: Fix turning switchcap off when sysjump to RW
The polarity of the enable pins of DA9313 and LN9310 are different.
DA9313 is active-high while LN9310 is active-low. For power saving,
the enable pin of LN9310 has an external pull-up; so EC should
configure it open-drain.
The existing code causes an issue that the switchcap is turned off
when sysjump to RW. We should configure the enable pin properly.
DA9313 is GPIO-controlled without needing any configuration. So the
default setting in gpio.inc should favors DA9313, i.e. GPIO_OUT_LOW;
otherwise, DA9313 may turn on unexpectedly.
In the board init, should not set the level; otherwise, it will
override its level and shutdown the switchcap when sysjump to RW.
LN9313 is similar but a bit tricky. As the gpio.inc configures it
GPIO_OUT_LOW. When sysjump to RW, will output push-pull a short
period of time. As it outputs LOW, should be fine.
The GPIO changes like:
(1) EC boots from RO -> high-Z
(2) GPIO init according to gpio.inc -> push-pull LOW
(3) This function configures it -> open-drain HIGH
(4) Power sequence turns on the switchcap -> open-drain LOW
(5) EC sysjumps to RW
(6) GPIO init according to gpio.inc -> push-pull LOW
(7) This function configures it -> open-drain LOW
BRANCH=None
BUG=b:163867792, b:151393598
TEST=Tested on Lazor: when sysjump to RW, switchcap not off.
Change-Id: Iec8ea7e16f525fa431230546d712c3e081fdab5c
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2391830
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/lazor/board.c | 42 | ||||
-rw-r--r-- | board/lazor/gpio.inc | 2 |
2 files changed, 37 insertions, 7 deletions
diff --git a/board/lazor/board.c b/board/lazor/board.c index 2d0672331b..5de16d4fd9 100644 --- a/board/lazor/board.c +++ b/board/lazor/board.c @@ -260,11 +260,37 @@ static void board_switchcap_init(void) gpio_set_flags(GPIO_SWITCHCAP_PG_INT_L, GPIO_INT_FALLING); gpio_enable_interrupt(GPIO_SWITCHCAP_PG_INT_L); - /* Configure LN9310 enable, open-drain, active low */ - gpio_set_flags(GPIO_SWITCHCAP_ON_L, GPIO_ODR_HIGH); + /* + * Configure LN9310 enable, open-drain output. Don't set the + * level here; otherwise, it will override its value and + * shutdown the switchcap when sysjump to RW. + * + * Note that the gpio.inc configures it GPIO_OUT_LOW. When + * sysjump to RW, will output push-pull a short period of + * time. As it outputs LOW, should be fine. + * + * This GPIO changes like: + * (1) EC boots from RO -> high-Z + * (2) GPIO init according to gpio.inc -> push-pull LOW + * (3) This function configures it -> open-drain HIGH + * (4) Power sequence turns on the switchcap -> open-drain LOW + * (5) EC sysjumps to RW + * (6) GPIO init according to gpio.inc -> push-pull LOW + * (7) This function configures it -> open-drain LOW + */ + gpio_set_flags(GPIO_SWITCHCAP_ON_L, + GPIO_OUTPUT | GPIO_OPEN_DRAIN); - /* Init the switchcap driver */ - ln9310_init(); + /* Only configure the switchcap if not sysjump */ + if (!system_jumped_late()) { + /* + * Deassert the enable pin (set it HIGH), so the + * switchcap won't be enabled after the switchcap is + * configured from standby mode to switching mode. + */ + gpio_set_level(GPIO_SWITCHCAP_ON_L, 1); + ln9310_init(); + } } else { CPRINTS("Use switchcap: DA9313"); @@ -274,8 +300,12 @@ static void board_switchcap_init(void) */ gpio_set_flags(GPIO_DA9313_GPIO0, GPIO_INPUT | GPIO_PULL_DOWN); - /* Configure DA9313 enable, push-pull, active high */ - gpio_set_flags(GPIO_SWITCHCAP_ON, GPIO_OUT_LOW); + /* + * Configure DA9313 enable, push-pull output. Don't set the + * level here; otherwise, it will override its value and + * shutdown the switchcap when sysjump to RW. + */ + gpio_set_flags(GPIO_SWITCHCAP_ON, GPIO_OUTPUT); } } diff --git a/board/lazor/gpio.inc b/board/lazor/gpio.inc index 1d7b9296c9..744cfd96fa 100644 --- a/board/lazor/gpio.inc +++ b/board/lazor/gpio.inc @@ -71,7 +71,7 @@ GPIO(EC_INT_L, PIN(A, 2), GPIO_ODR_HIGH) /* Interrupt line between GPIO(QSIP_ON, PIN(5, 0), GPIO_OUT_LOW) /* Not used, for non-switchcap testing */ /* Power enables */ -GPIO(SWITCHCAP_ON, PIN(D, 5), GPIO_INPUT) /* Enable switch cap; will be configured as output in the board init */ +GPIO(SWITCHCAP_ON, PIN(D, 5), GPIO_OUT_LOW) /* Enable switch cap; will be configured in the board init */ /* TODO(waihong): Remove it. The VBOB switch is for backup. */ GPIO(VBOB_EN, PIN(D, 3), GPIO_OUT_LOW) /* Enable VBOB */ GPIO(EN_PP3300_A, PIN(A, 6), GPIO_OUT_LOW) /* Enable PP3300 */ |