From 05e33b28e72a6eb40393eeb680920eb96a05c752 Mon Sep 17 00:00:00 2001 From: Alexandru M Stan Date: Mon, 23 Apr 2018 11:39:06 -0700 Subject: [PATCH] cheza: Make sure switchcap is configured right Configure switchcap every time we're about to change the signal, just in case it forgot. Feel free to revert this after b/77957956 is fixed. BRANCH=none BUG=b:77957956 TEST="i2cxfer r 0 0xd0 0x2" never shows 0x70, even after a bad brownout (like "gpioset EN_PP5000_A 1" on an unreworked board) Change-Id: I8994cd402ce96d8bf4e436dadfc0e572e7f77a85 Signed-off-by: Alexandru M Stan Reviewed-on: https://chromium-review.googlesource.com/1024501 Commit-Ready: Wai-Hong Tam Tested-by: Wai-Hong Tam Reviewed-by: Wai-Hong Tam --- board/cheza/board.c | 10 ++++++++++ board/cheza/board.h | 2 ++ power/sdm845.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/board/cheza/board.c b/board/cheza/board.c index f2c53de96b..c22c7c6d3e 100644 --- a/board/cheza/board.c +++ b/board/cheza/board.c @@ -32,6 +32,16 @@ const enum gpio_signal hibernate_wake_pins[] = { }; const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins); +void board_set_switchcap(int enable) +{ + /* + * Disable SwitchCap auto-boot and make EN pin level-trigger + * TODO(b/77957956): Remove it after hardware fix. + */ + i2c_write8(I2C_PORT_POWER, DA9313_I2C_ADDR, 0x02, 0x34); + gpio_set_level(GPIO_SWITCHCAP_ON_L, enable); +} + const struct adc_t adc_channels[] = {}; /* Power signal list. Must match order of enum power_signal. */ diff --git a/board/cheza/board.h b/board/cheza/board.h index 19dac3bad7..feec3a9468 100644 --- a/board/cheza/board.h +++ b/board/cheza/board.h @@ -68,6 +68,8 @@ enum adc_channel { ADC_CH_COUNT }; +void board_set_switchcap(int asserted); + #endif /* !defined(__ASSEMBLER__) */ #endif /* __CROS_EC_BOARD_H */ diff --git a/power/sdm845.c b/power/sdm845.c index 4e96c1385e..fb3eb40efc 100644 --- a/power/sdm845.c +++ b/power/sdm845.c @@ -145,7 +145,7 @@ DECLARE_HOOK(HOOK_POWER_BUTTON_CHANGE, powerbtn_sdm845_changed, static void set_system_power(int enable) { CPRINTS("set_system_power(%d)", enable); - gpio_set_level(GPIO_SWITCHCAP_ON_L, enable); + board_set_switchcap(enable); gpio_set_level(GPIO_VBOB_EN, enable); }