diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-03-06 09:13:09 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-03-07 03:38:38 +0000 |
commit | d09405203fea4d19d5c1bcb7a25a7142062d6849 (patch) | |
tree | e474acc0e3bcb3bb554059401d99bd414a9ec68f | |
parent | 41436f478d8902130b50b561ad477ef20e42d5fc (diff) | |
download | chrome-ec-d09405203fea4d19d5c1bcb7a25a7142062d6849.tar.gz |
samus: ryu: allow charge ramp on CDP and proprietary chargers
Modify charge ramp so that when it ramps it ramps from 500mA and
up to the maximum allowed by that supplier. Also modify Samus and
Ryu to use charge ramping for CDP and proprietary chargers due
to the possibility that they may not be able to supply the amount
that is supposed to be guaranteed by their advertisement.
BUG=chrome-os-partner:37549
BRANCH=samus
TEST=test on a proprietary charger, make sure we can ramp. test
a DCP and make sure we also ramp as before.
Change-Id: I08fd43c8f0b21aa54d114fbe5a1296c9556357e4
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/256972
Reviewed-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
-rw-r--r-- | board/ryu/board.c | 9 | ||||
-rw-r--r-- | board/samus_pd/board.c | 9 | ||||
-rw-r--r-- | common/charge_ramp.c | 12 | ||||
-rw-r--r-- | include/charge_ramp.h | 3 | ||||
-rw-r--r-- | test/charge_ramp.c | 2 |
5 files changed, 27 insertions, 8 deletions
diff --git a/board/ryu/board.c b/board/ryu/board.c index 220fce39d3..6b35bf06dd 100644 --- a/board/ryu/board.c +++ b/board/ryu/board.c @@ -477,19 +477,24 @@ void board_set_charge_limit(int charge_ma) int board_is_ramp_allowed(int supplier) { return supplier == CHARGE_SUPPLIER_BC12_DCP || - supplier == CHARGE_SUPPLIER_BC12_SDP; + 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 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; } diff --git a/board/samus_pd/board.c b/board/samus_pd/board.c index 5e6100c85d..14c407f8df 100644 --- a/board/samus_pd/board.c +++ b/board/samus_pd/board.c @@ -731,19 +731,24 @@ int board_is_ramp_allowed(int supplier) return 0; else return supplier == CHARGE_SUPPLIER_BC12_DCP || - supplier == CHARGE_SUPPLIER_BC12_SDP; + 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 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; } diff --git a/common/charge_ramp.c b/common/charge_ramp.c index 9b38b1f0fe..dbe14e11d4 100644 --- a/common/charge_ramp.c +++ b/common/charge_ramp.c @@ -35,6 +35,7 @@ /* Current ramp increment */ #define RAMP_CURR_INCR_MA 64 #define RAMP_CURR_DELAY (500*MSEC) +#define RAMP_CURR_START_MA 500 /* How much to backoff the input current limit when limit has been found */ #define RAMP_ICL_BACKOFF (2*RAMP_CURR_INCR_MA) @@ -102,8 +103,15 @@ void chg_ramp_charge_supplier_change(int port, int supplier, int current, /* Set new active port, set ramp state, and wake ramp task */ active_port = port; active_sup = supplier; - min_icl = current; - max_icl = board_get_ramp_current_limit(active_sup); + + /* Set min and max input current limit based on if ramp is allowed */ + if (board_is_ramp_allowed(active_sup)) { + min_icl = RAMP_CURR_START_MA; + max_icl = board_get_ramp_current_limit(active_sup, current); + } else { + min_icl = max_icl = current; + } + reg_time = registration_time; if (ramp_st != CHG_RAMP_STABILIZE) { ramp_st = (active_port == CHARGE_PORT_NONE) ? diff --git a/include/charge_ramp.h b/include/charge_ramp.h index 629499e6ac..c6e0531496 100644 --- a/include/charge_ramp.h +++ b/include/charge_ramp.h @@ -29,10 +29,11 @@ int board_is_ramp_allowed(int supplier); * Get the maximum current limit that we are allowed to ramp to * * @supplier Active supplier type + * @sup_curr Input current limit based on supplier * * @return Maximum current in mA */ -int board_get_ramp_current_limit(int supplier); +int board_get_ramp_current_limit(int supplier, int sup_curr); /** * Check if board is consuming full input current diff --git a/test/charge_ramp.c b/test/charge_ramp.c index e853b46e93..5001c1a664 100644 --- a/test/charge_ramp.c +++ b/test/charge_ramp.c @@ -58,7 +58,7 @@ void board_set_charge_limit(int limit_ma) task_set_event(TASK_ID_TEST_RUNNER, TASK_EVENT_OVERCURRENT, 0); } -int board_get_ramp_current_limit(int supplier) +int board_get_ramp_current_limit(int supplier, int sup_curr) { if (supplier == CHARGE_SUPPLIER_TEST9) return 1600; |