diff options
author | Yilun Lin <yllin@chromium.org> | 2019-11-21 11:31:01 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-10 10:40:27 +0000 |
commit | 313faa4a8c4d4349f6a8857ad7ceb2421a630dfa (patch) | |
tree | ea3776477b20732e937fe8e82804121f5976551e | |
parent | 73d1e0310aa3f13ea20bd3eb2a695ecfc26735d3 (diff) | |
download | chrome-ec-313faa4a8c4d4349f6a8857ad7ceb2421a630dfa.tar.gz |
power/mt8183: correct EN_PP1800_S5_L enable timing
The power rail should be turned on at G3S5 rather than S5S3,
and should be turned off after stay in G3 for 20ms.
TEST=Ensure the power rail is on/off at correct timing
BUG=b:144144075 b:145255107
BRANCH=none
Change-Id: Ie621ab1ac5332da6718201c44266f41aafcac296
Signed-off-by: Yilun Lin <yllin@chromium.org>
Signed-off-by: Eric Yilun Lin <yllin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1928413
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
-rw-r--r-- | board/damu/board.c | 29 | ||||
-rw-r--r-- | board/damu/board.h | 3 | ||||
-rw-r--r-- | board/damu/gpio.inc | 2 | ||||
-rw-r--r-- | board/jacuzzi/board.c | 29 | ||||
-rw-r--r-- | board/jacuzzi/board.h | 5 | ||||
-rw-r--r-- | board/jacuzzi/gpio.inc | 8 | ||||
-rw-r--r-- | board/kappa/board.c | 29 | ||||
-rw-r--r-- | board/kappa/board.h | 3 | ||||
-rw-r--r-- | board/kappa/gpio.inc | 2 | ||||
-rw-r--r-- | power/mt8183.c | 31 |
10 files changed, 51 insertions, 90 deletions
diff --git a/board/damu/board.c b/board/damu/board.c index 7360fd41b4..546fbda4bf 100644 --- a/board/damu/board.c +++ b/board/damu/board.c @@ -253,42 +253,13 @@ static void board_chipset_startup(void) } DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT); -static void disable_pp1800_s5_deferred(void); -DECLARE_DEFERRED(disable_pp1800_s5_deferred); - -static void disable_pp1800_s5_deferred(void) -{ - if (power_get_state() == POWER_G3) - gpio_set_level(GPIO_EN_PP1800_S5_L, 1); - else if (power_get_state() == POWER_S5G3 || - power_get_state() == POWER_S3S5 || - power_get_state() == POWER_S5) - /* pmic is still on, wait a few seconds and try again */ - hook_call_deferred(&disable_pp1800_s5_deferred_data, - SECOND); -} - /* Called on AP S3 -> S5 transition */ static void board_chipset_shutdown(void) { gpio_set_level(GPIO_EN_USBA_5V, 0); - if (board_get_version() >= 1) - /* - * use deferred to make sure pp1800_s5 is turned off after pmic - * off. - */ - hook_call_deferred(&disable_pp1800_s5_deferred_data, - SECOND); } DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT); -void board_chipset_pre_init(void) -{ - if (board_get_version() >= 1) - gpio_set_level(GPIO_EN_PP1800_S5_L, 0); -} -DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, board_chipset_pre_init, HOOK_PRIO_DEFAULT); - int board_get_charger_i2c(void) { /* TODO(b:138415463): confirm the bus allocation for future builds */ diff --git a/board/damu/board.h b/board/damu/board.h index 02a5e28506..fed9012e43 100644 --- a/board/damu/board.h +++ b/board/damu/board.h @@ -17,6 +17,9 @@ #include "baseboard.h" +#undef CONFIG_CHIPSET_POWER_SEQ_VERSION +#define CONFIG_CHIPSET_POWER_SEQ_VERSION 1 + /* TODO(b:135086465) led implementation */ #undef CONFIG_LED_COMMON diff --git a/board/damu/gpio.inc b/board/damu/gpio.inc index 7b4754678e..1e9b815067 100644 --- a/board/damu/gpio.inc +++ b/board/damu/gpio.inc @@ -76,7 +76,7 @@ GPIO(EC_INT_L, PIN(C, 7), GPIO_ODR_HIGH) /* EC_AP_INT_ODL */ GPIO(EC_BOARD_ID_EN_L, PIN(C, 15), GPIO_ODR_HIGH) /* EC_BOARD_ID_EN_ODL */ GPIO(USB_C0_HPD_OD, PIN(F, 1), GPIO_ODR_LOW) GPIO(BOOTBLOCK_EN_L, PIN(C, 1), GPIO_ODR_HIGH) -GPIO(EN_PP1800_S5_L, PIN(A, 14), GPIO_OUT_HIGH) +GPIO(EN_PP1800_S5_L, PIN(A, 14), GPIO_OUT_LOW) GPIO(USB_C0_DISCHARGE, PIN(B, 6), GPIO_OUT_LOW) /* diff --git a/board/jacuzzi/board.c b/board/jacuzzi/board.c index f0cb4d9ddf..ec03ec7c5f 100644 --- a/board/jacuzzi/board.c +++ b/board/jacuzzi/board.c @@ -273,42 +273,13 @@ static void board_chipset_startup(void) } DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT); -static void disable_pp1800_s5_deferred(void); -DECLARE_DEFERRED(disable_pp1800_s5_deferred); - -static void disable_pp1800_s5_deferred(void) -{ - if (power_get_state() == POWER_G3) - gpio_set_level(GPIO_EN_PP1800_S5_L, 1); - else if (power_get_state() == POWER_S5G3 || - power_get_state() == POWER_S3S5 || - power_get_state() == POWER_S5) - /* pmic is still on, wait a few seconds and try again */ - hook_call_deferred(&disable_pp1800_s5_deferred_data, - SECOND); -} - /* Called on AP S3 -> S5 transition */ static void board_chipset_shutdown(void) { gpio_set_level(GPIO_EN_USBA_5V, 0); - if (board_get_version() >= 1) - /* - * use deferred to make sure pp1800_s5 is turned off after pmic - * off. - */ - hook_call_deferred(&disable_pp1800_s5_deferred_data, - SECOND); } DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT); -void board_chipset_pre_init(void) -{ - if (board_get_version() >= 1) - gpio_set_level(GPIO_EN_PP1800_S5_L, 0); -} -DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, board_chipset_pre_init, HOOK_PRIO_DEFAULT); - int board_get_charger_i2c(void) { /* TODO(b:138415463): confirm the bus allocation for future builds */ diff --git a/board/jacuzzi/board.h b/board/jacuzzi/board.h index d964c8e576..e9bf5b8a79 100644 --- a/board/jacuzzi/board.h +++ b/board/jacuzzi/board.h @@ -17,6 +17,11 @@ #include "baseboard.h" +#ifdef BOARD_JUNIPER +#undef CONFIG_CHIPSET_POWER_SEQ_VERSION +#define CONFIG_CHIPSET_POWER_SEQ_VERSION 1 +#endif + /* TODO(b:135086465) led implementation */ #undef CONFIG_LED_COMMON diff --git a/board/jacuzzi/gpio.inc b/board/jacuzzi/gpio.inc index 10957c5328..fed96eda51 100644 --- a/board/jacuzzi/gpio.inc +++ b/board/jacuzzi/gpio.inc @@ -77,9 +77,15 @@ GPIO(EC_INT_L, PIN(C, 7), GPIO_ODR_HIGH) /* EC_AP_INT_ODL */ GPIO(EC_BOARD_ID_EN_L, PIN(C, 15), GPIO_ODR_HIGH) /* EC_BOARD_ID_EN_ODL */ GPIO(USB_C0_HPD_OD, PIN(F, 1), GPIO_ODR_LOW) GPIO(BOOTBLOCK_EN_L, PIN(C, 1), GPIO_ODR_HIGH) -GPIO(EN_PP1800_S5_L, PIN(A, 14), GPIO_OUT_HIGH) GPIO(USB_C0_DISCHARGE, PIN(B, 6), GPIO_OUT_LOW) +#ifdef BOARD_JACUZZI +GPIO(LID_ACCEL_INT_ODL, PIN(A, 14), GPIO_INPUT) +/* Jacuzzi doesn't have EN_PP1800_S5_L. */ +UNIMPLEMENTED(EN_PP1800_S5_L) +#else +GPIO(EN_PP1800_S5_L, PIN(A, 14), GPIO_OUT_LOW) +#endif /* * TODO(b:138352732): On IT88801 expander, To be readded once IT8801 driver and * gpio expander framework has landed. diff --git a/board/kappa/board.c b/board/kappa/board.c index fd1b1f90cc..0c73590d1e 100644 --- a/board/kappa/board.c +++ b/board/kappa/board.c @@ -253,42 +253,13 @@ static void board_chipset_startup(void) } DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT); -static void disable_pp1800_s5_deferred(void); -DECLARE_DEFERRED(disable_pp1800_s5_deferred); - -static void disable_pp1800_s5_deferred(void) -{ - if (power_get_state() == POWER_G3) - gpio_set_level(GPIO_EN_PP1800_S5_L, 1); - else if (power_get_state() == POWER_S5G3 || - power_get_state() == POWER_S3S5 || - power_get_state() == POWER_S5) - /* pmic is still on, wait a few seconds and try again */ - hook_call_deferred(&disable_pp1800_s5_deferred_data, - SECOND); -} - /* Called on AP S3 -> S5 transition */ static void board_chipset_shutdown(void) { gpio_set_level(GPIO_EN_USBA_5V, 0); - if (board_get_version() >= 1) - /* - * use deferred to make sure pp1800_s5 is turned off after pmic - * off. - */ - hook_call_deferred(&disable_pp1800_s5_deferred_data, - SECOND); } DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT); -void board_chipset_pre_init(void) -{ - if (board_get_version() >= 1) - gpio_set_level(GPIO_EN_PP1800_S5_L, 0); -} -DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, board_chipset_pre_init, HOOK_PRIO_DEFAULT); - int board_get_charger_i2c(void) { /* TODO(b:138415463): confirm the bus allocation for future builds */ diff --git a/board/kappa/board.h b/board/kappa/board.h index 7812a71973..420d27af72 100644 --- a/board/kappa/board.h +++ b/board/kappa/board.h @@ -17,6 +17,9 @@ #include "baseboard.h" +#undef CONFIG_CHIPSET_POWER_SEQ_VERSION +#define CONFIG_CHIPSET_POWER_SEQ_VERSION 1 + /* TODO(b:135086465) led implementation */ #undef CONFIG_LED_COMMON diff --git a/board/kappa/gpio.inc b/board/kappa/gpio.inc index 7b4754678e..1e9b815067 100644 --- a/board/kappa/gpio.inc +++ b/board/kappa/gpio.inc @@ -76,7 +76,7 @@ GPIO(EC_INT_L, PIN(C, 7), GPIO_ODR_HIGH) /* EC_AP_INT_ODL */ GPIO(EC_BOARD_ID_EN_L, PIN(C, 15), GPIO_ODR_HIGH) /* EC_BOARD_ID_EN_ODL */ GPIO(USB_C0_HPD_OD, PIN(F, 1), GPIO_ODR_LOW) GPIO(BOOTBLOCK_EN_L, PIN(C, 1), GPIO_ODR_HIGH) -GPIO(EN_PP1800_S5_L, PIN(A, 14), GPIO_OUT_HIGH) +GPIO(EN_PP1800_S5_L, PIN(A, 14), GPIO_OUT_LOW) GPIO(USB_C0_DISCHARGE, PIN(B, 6), GPIO_OUT_LOW) /* diff --git a/power/mt8183.c b/power/mt8183.c index 44012eeb6a..b7ef591932 100644 --- a/power/mt8183.c +++ b/power/mt8183.c @@ -20,6 +20,14 @@ #include "timer.h" #include "util.h" +/* + * mt8183 has two different power sequence versions + * 0: for normal tablet and detachable form factor + * 1: for boards have GPIO_EN_PP1800_S5_L + * CONFIG_CHIPSET_POWER_SEQ_VERSION defaults to 0, re-define the power seq + * version if needed. + */ + /* Console output macros */ #define CPUTS(outstr) cputs(CC_CHIPSET, outstr) #define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args) @@ -57,6 +65,9 @@ */ #define PMIC_FORCE_RESET_TIME (10 * SECOND) +/* Time delay in G3 to deassert EN_PP1800_S5_L */ +#define EN_PP1800_S5_L_DEASSERT_TIME (20 * MSEC) + /* Data structure for a GPIO operation for power sequencing */ struct power_seq_op { /* enum gpio_signal in 8 bits */ @@ -230,6 +241,14 @@ static void power_seq_run(const struct power_seq_op *power_seq_ops, } } +#if CONFIG_CHIPSET_POWER_SEQ_VERSION == 1 +static void deassert_en_pp1800_s5_l(void) +{ + gpio_set_level(GPIO_EN_PP1800_S5_L, 1); +} +DECLARE_DEFERRED(deassert_en_pp1800_s5_l); +#endif + enum power_state power_handle_state(enum power_state state) { /* @@ -249,6 +268,12 @@ enum power_state power_handle_state(enum power_state state) switch (state) { case POWER_G3: + +#if CONFIG_CHIPSET_POWER_SEQ_VERSION == 1 + hook_call_deferred(&deassert_en_pp1800_s5_l_data, + EN_PP1800_S5_L_DEASSERT_TIME); +#endif + /* Go back to S5->G3 if the PMIC unexpectedly starts again. */ if (power_get_signals() & IN_PGOOD_PMIC) return POWER_S5G3; @@ -305,8 +330,14 @@ enum power_state power_handle_state(enum power_state state) case POWER_G3S5: forcing_shutdown = 0; +#if CONFIG_CHIPSET_POWER_SEQ_VERSION == 1 + hook_call_deferred(&deassert_en_pp1800_s5_l_data, -1); +#endif hook_call_deferred(&release_pmic_force_reset_data, -1); gpio_set_level(GPIO_PMIC_FORCE_RESET_ODL, 1); +#if CONFIG_CHIPSET_POWER_SEQ_VERSION == 1 + gpio_set_level(GPIO_EN_PP1800_S5_L, 0); +#endif /* Power up to next state */ return POWER_S5; |