diff options
author | Ben Lok <ben.lok@mediatek.com> | 2015-11-25 19:44:11 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-12-01 08:14:21 -0800 |
commit | 744f7c2782cfd9a224315465005e80a8af4e0ef9 (patch) | |
tree | 47b0ac3a5fd311b8cd3e53d5d827962cc576db7c | |
parent | 53fa1d1f0938f7021727880207631f2c9b82e115 (diff) | |
download | chrome-ec-744f7c2782cfd9a224315465005e80a8af4e0ef9.tar.gz |
oak: enable HW charge ramping
refer to commit 75f740fa, enabling the option on oak too.
BUG=none
BRANCH=none
TEST=plug in CDP, SDP, DCP, type-C, and PD charger. Make sure
we ramp to a reasonable value for the correct suppliers.
Make sure we don't ramp for type-C and PD chargers.
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Change-Id: I9c6a0726e9cb23af59d5841c63a81897ae624998
Reviewed-on: https://chromium-review.googlesource.com/314436
Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r-- | board/oak/board.c | 34 | ||||
-rw-r--r-- | board/oak/board.h | 1 |
2 files changed, 35 insertions, 0 deletions
diff --git a/board/oak/board.c b/board/oak/board.c index 687ad628dc..fef8387663 100644 --- a/board/oak/board.c +++ b/board/oak/board.c @@ -290,6 +290,40 @@ void board_set_charge_limit(int charge_ma) CONFIG_CHARGER_INPUT_CURRENT)); } +/** + * Return whether ramping is allowed for given supplier + */ +int board_is_ramp_allowed(int supplier) +{ + /* Don't allow ramping in RO when write protected */ + if (system_get_image_copy() != SYSTEM_IMAGE_RW + && system_is_locked()) + return 0; + else + return supplier == CHARGE_SUPPLIER_BC12_DCP || + supplier == CHARGE_SUPPLIER_BC12_SDP || + supplier == CHARGE_SUPPLIER_BC12_CDP || + supplier == CHARGE_SUPPLIER_PROPRIETARY; +} + +/** + * Return the maximum allowed input current + */ +int board_get_ramp_current_limit(int supplier, int sup_curr) +{ + switch (supplier) { + case CHARGE_SUPPLIER_BC12_DCP: + return 2000; + case CHARGE_SUPPLIER_BC12_SDP: + return 1000; + case CHARGE_SUPPLIER_BC12_CDP: + case CHARGE_SUPPLIER_PROPRIETARY: + return sup_curr; + default: + return 500; + } +} + static void hpd_irq_deferred(void) { gpio_set_level(GPIO_USB_DP_HPD, 1); diff --git a/board/oak/board.h b/board/oak/board.h index 4e74091721..6b366d96c1 100644 --- a/board/oak/board.h +++ b/board/oak/board.h @@ -18,6 +18,7 @@ #define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_PRESENT_L #define CONFIG_BATTERY_SMART #define CONFIG_CHARGE_MANAGER +#define CONFIG_CHARGE_RAMP_HW #define CONFIG_CHARGER #define CONFIG_CHARGER_INPUT_CURRENT 512 |