From 744f7c2782cfd9a224315465005e80a8af4e0ef9 Mon Sep 17 00:00:00 2001 From: Ben Lok Date: Wed, 25 Nov 2015 19:44:11 +0800 Subject: [PATCH] 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 Change-Id: I9c6a0726e9cb23af59d5841c63a81897ae624998 Reviewed-on: https://chromium-review.googlesource.com/314436 Reviewed-by: Alec Berg --- board/oak/board.c | 34 ++++++++++++++++++++++++++++++++++ board/oak/board.h | 1 + 2 files changed, 35 insertions(+) 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