summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/ryu/board.c9
-rw-r--r--board/samus_pd/board.c9
-rw-r--r--common/charge_ramp.c12
-rw-r--r--include/charge_ramp.h3
-rw-r--r--test/charge_ramp.c2
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;