diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2015-11-24 12:33:23 -0800 |
---|---|---|
committer | ChromeOS bot <3su6n15k.default@developer.gserviceaccount.com> | 2015-11-24 23:25:50 +0000 |
commit | 461f2cc2d05f0b2d7a1ca543d3fb0db9e13c603e (patch) | |
tree | f001ee69d76152d896eb1c28e3478fc2e25c0a0b | |
parent | fccc378405dd4cdc7784647dff39b34ea336502f (diff) | |
download | chrome-ec-461f2cc2d05f0b2d7a1ca543d3fb0db9e13c603e.tar.gz |
ryu: add protection against BQ25892 resetting the current limit
When the BQ25892 is done doing its 'USB' detection, it will reset the
input current limit to the value set by the GPIOs.
At this point, we are getting a charger interrupt, so we set PSEL GPIO to '1'
to limit the current to 100mA until we have time to send the i2c message
to set again the proper current limit.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=smaug
BUG=chrome-os-partner:47972
TEST=plug Apple Macbook Type-C charger and various other chargers and
record the current consumed through Twinkie.
Change-Id: I66f9ebdff5386ce8547bcc009e4ea4b12ae8669a
Reviewed-on: https://chromium-review.googlesource.com/314127
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | board/ryu/board.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/board/ryu/board.c b/board/ryu/board.c index 05a0dd471a..d6923f7a29 100644 --- a/board/ryu/board.c +++ b/board/ryu/board.c @@ -225,14 +225,14 @@ void usb_charger_task(void) while (1) { /* Wait for interrupt */ evt = task_wait_event(-1); - /* Got an interrupt from the Pericom BC1.2 chip */ - if (evt & USB_CHG_EVENT_BC12) - usb_charger_bc12_detect(); /* Time to re-verify the VBUS disconnection in the charger */ if (evt & USB_CHG_EVENT_HIZ) { - board_verify_hiz_mode(); board_verify_input_current_limit(); + board_verify_hiz_mode(); } + /* Got an interrupt from the Pericom BC1.2 chip */ + if (evt & USB_CHG_EVENT_BC12) + usb_charger_bc12_detect(); /* * Re-enable interrupts on pericom charger detector since the * chip may periodically reset itself, and come back up with @@ -261,6 +261,12 @@ void usb_evt(enum gpio_signal signal) void charger_interrupt(enum gpio_signal signal) { /* + * Put lower current limit (PSEL=1 => 100mA) + * until we have verified what happened as the charger might have reset + * the limit to 3.25A. + */ + gpio_set_level(GPIO_CHGR_PSEL, 1); + /* * kick the USB_CHG task to verify that the Hi-Z bit is still set * according to our previous desire. */ @@ -856,8 +862,9 @@ int board_vbus_power_path(int enable) static void board_verify_hiz_mode(void) { int enable = !charger_is_forced_discharge(); + int psel_en = !gpio_get_level(GPIO_CHGR_PSEL); /* the VBUS connection is not in the state we want: update it */ - if (enable != typec_power_path) + if (enable != typec_power_path || psel_en != typec_power_path) board_vbus_power_path(typec_power_path); } |