diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2017-10-11 14:02:09 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-10-19 12:56:41 -0700 |
commit | e7dfbf35a403dfa71bb839c3e722a347447be3f5 (patch) | |
tree | bb430b4127eebcb557d445f8defc6c5c06faa0cf /board | |
parent | 87dbec5dfa4e0341d6714ec42c2648448bfec1f7 (diff) | |
download | chrome-ec-e7dfbf35a403dfa71bb839c3e722a347447be3f5.tar.gz |
servo_v4: Use charge_manager for input port / ILIM selection
BUG=chromium:769895
BRANCH=servo
TEST=On servo_v4, attach OEM Apple charger to power port and verify
negotiation to 9V and port / ILIM selection from charge_manager. Attach
samus to DUT port and verify 9V charging.
Change-Id: Icf16f6e8c99af4fbb48a83b7a36f550c20f5fd69
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/713944
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/servo_v4/board.h | 5 | ||||
-rw-r--r-- | board/servo_v4/usb_pd_policy.c | 66 |
2 files changed, 28 insertions, 43 deletions
diff --git a/board/servo_v4/board.h b/board/servo_v4/board.h index e79da62c7e..071599460b 100644 --- a/board/servo_v4/board.h +++ b/board/servo_v4/board.h @@ -70,6 +70,9 @@ #undef CONFIG_WATCHDOG_HELP #undef CONFIG_LID_SWITCH +/* Remove console commands / features for flash / RAM savings */ +#undef CONFIG_CONSOLE_CMDHELP + /* Enable control of I2C over USB */ #define CONFIG_USB_I2C #define CONFIG_I2C @@ -85,6 +88,7 @@ */ #undef CONFIG_TASK_PROFILING +#define CONFIG_CHARGE_MANAGER #define CONFIG_USB_POWER_DELIVERY #define CONFIG_USB_PD_DTS #define CONFIG_CMD_PD @@ -151,6 +155,7 @@ enum usb_strings { /* ADC signal */ enum adc_channel { + ADC_VBUS = -1, ADC_CHG_CC1_PD = 0, ADC_CHG_CC2_PD, ADC_DUT_CC1_PD, diff --git a/board/servo_v4/usb_pd_policy.c b/board/servo_v4/usb_pd_policy.c index 224ca7396a..2e707d85c8 100644 --- a/board/servo_v4/usb_pd_policy.c +++ b/board/servo_v4/usb_pd_policy.c @@ -55,7 +55,7 @@ struct vbus_prop { int ma; }; static struct vbus_prop vbus[CONFIG_USB_PD_PORT_COUNT]; -static struct vbus_prop vbus_pend; +static int charge_port_is_active; static uint8_t vbus_rp = TYPEC_RP_RESERVED; static int disable_dts_mode; @@ -124,17 +124,13 @@ static void board_manage_dut_port(void) pd_update_contract(DUT); } -static void board_manage_chg_port(void) +static void update_ports(void) { - /* Update the voltage/current values for CHG port */ - vbus[CHG].mv = vbus_pend.mv; - vbus[CHG].ma = vbus_pend.ma; - /* * CHG Vbus has changed states, update PDO that reflects CHG port * state */ - if (!vbus[CHG].mv) { + if (!vbus[CHG].mv || !charge_port_is_active) { /* CHG Vbus has dropped, so always source DUT Vbus from host */ gpio_set_level(GPIO_HOST_OR_CHG_CTL, 0); chg_pdo_cnt = 0; @@ -161,31 +157,28 @@ static void board_manage_chg_port(void) /* Call DUT port manager to update Rp and possible PD contract */ board_manage_dut_port(); } -DECLARE_DEFERRED(board_manage_chg_port); -static void board_update_chg_vbus(int max_ma, int vbus_mv) +int board_set_active_charge_port(int charge_port) { - /* - * Determine if vbus from CHG port has changed values and if the current - * state of CHG vbus is on or off. If the change is on, then schedule a - * deferred callback. If the change is off, then act immediately. - */ - if (VBUS_UNCHANGED(vbus[CHG].mv, vbus_pend.mv, vbus_mv) && - VBUS_UNCHANGED(vbus[CHG].ma, vbus_pend.ma, max_ma)) - /* No change in CHG VBUS detected, nothing else to do. */ - return; + if (charge_port == DUT) + return -1; - /* CHG port voltage and current values are now pending */ - vbus_pend.mv = vbus_mv; - vbus_pend.ma = max_ma; + charge_port_is_active = (charge_port == CHG); + update_ports(); - if (vbus_mv) - /* Wait enough time for PD contract to be established */ - hook_call_deferred(&board_manage_chg_port_data, - PD_T_SINK_WAIT_CAP * 3); - else - /* Update CHG port status now since vbus is off */ - hook_call_deferred(&board_manage_chg_port_data, 0); + return 0; +} + +void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) +{ + if (port != CHG) + return; + + /* Update the voltage/current values for CHG port */ + vbus[CHG].mv = charge_mv; + vbus[CHG].ma = charge_ma; + update_ports(); } int pd_tcpc_cc_nc(int port, int cc_volt, int cc_sel) @@ -355,11 +348,12 @@ int board_select_rp_value(int port, int rp) int charge_manager_get_source_pdo(const uint32_t **src_pdo, const int port) { int pdo_cnt; + /* * If CHG is providing VBUS, then advertise what's available on the CHG * port, otherwise used the fixed value that matches host capabilities. */ - if (vbus[CHG].mv) { + if (vbus[CHG].mv && charge_port_is_active) { *src_pdo = pd_src_chg_pdo; pdo_cnt = chg_pdo_cnt; } else { @@ -434,20 +428,6 @@ void pd_power_supply_reset(int port) vbus[DUT].ma = 0; } -void pd_set_input_current_limit(int port, uint32_t max_ma, - uint32_t supply_voltage) -{ - if (port == CHG) - board_update_chg_vbus(max_ma, supply_voltage); -} - -void typec_set_input_current_limit(int port, uint32_t max_ma, - uint32_t supply_voltage) -{ - if (port == CHG) - board_update_chg_vbus(max_ma, supply_voltage); -} - int pd_snk_is_vbus_provided(int port) { |