Separate VBUS detection and measurement mechanisms

For now we guard charger-based VBUS voltage measurement
behind CONFIG_USB_PD_VBUS_DETECT_CHARGER.
But we should be able to measure VBUS voltage by charger
while detecting VBUS presence by other methods.

BUG=b:67991345
BRANCH=none
TEST=plug in guppy on Scarlet rev2, 'ectool usbpdpower' on console,
and see VBUS is measured as 4975mV

Change-Id: I94cada81159ea4b097001997e2444873ec2d8763
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/789910
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
This commit is contained in:
Philip Chen
2017-11-26 00:11:49 -08:00
committed by chrome-bot
parent a2e2be193a
commit 675bdc2e2c
2 changed files with 12 additions and 1 deletions

View File

@@ -370,7 +370,7 @@ static void charge_manager_fill_power_info(int port,
if (r->role == USB_PD_PORT_POWER_SINK_NOT_CHARGING)
r->meas.voltage_now = 5000;
else {
#ifdef CONFIG_USB_PD_VBUS_DETECT_CHARGER
#ifdef CONFIG_USB_PD_VBUS_MEASURE_CHARGER
r->meas.voltage_now = charger_get_vbus_voltage(port);
#else
if (ADC_VBUS >= 0)

View File

@@ -3094,6 +3094,17 @@
#define CONFIG_BATTERY
#endif
/*****************************************************************************/
/*
* Define CONFIG_USB_PD_VBUS_MEASURE_CHARGER if the charger on the board
* supports VBUS measurement.
*/
#if defined(CONFIG_CHARGER_BD9995X) || \
defined(CONFIG_CHARGER_RT9466) || \
defined(CONFIG_CHARGER_RT9467)
#define CONFIG_USB_PD_VBUS_MEASURE_CHARGER
#endif
/*****************************************************************************/
/*
* Handle task-dependent configs.