summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2018-03-08 15:02:17 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-03-09 20:05:13 -0800
commitef4e70174ac2797f0c02753685b35d038a317a6a (patch)
tree9edd3ebb8ae1da806a874835c11e13a119b31de1
parentb593d1c05b150fdad68c474ef0e521d5d9c3acea (diff)
downloadchrome-ec-ef4e70174ac2797f0c02753685b35d038a317a6a.tar.gz
usbc: add config support for multiple (and no) vbus adc channels
yorp measures each port's vbus separately on a deticated ADC. Also, add config to take care of ADV_VBUS -1 case too. BRANCH=none BUG=b:74127309 TEST=none Change-Id: I6f4df96caffc3b527b69e67358631dd448172cde Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/956555 Reviewed-by: Edward Hill <ecgh@chromium.org>
-rw-r--r--board/grunt/board.h2
-rw-r--r--board/servo_v4/board.h4
-rw-r--r--board/yorp/board.c5
-rw-r--r--board/yorp/board.h4
-rw-r--r--board/zoombini/board.h2
-rw-r--r--common/charge_manager.c16
-rw-r--r--include/charge_manager.h10
-rw-r--r--include/config.h5
8 files changed, 34 insertions, 14 deletions
diff --git a/board/grunt/board.h b/board/grunt/board.h
index 8b69a0cf42..f656c73b9c 100644
--- a/board/grunt/board.h
+++ b/board/grunt/board.h
@@ -91,6 +91,7 @@
#define CONFIG_USB_PD_TCPM_TCPCI
#define CONFIG_USB_PD_TRY_SRC
#define CONFIG_USB_PD_VBUS_DETECT_PPC
+#define CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT
#define CONFIG_USBC_PPC_SN5S330
#define CONFIG_USBC_SS_MUX
#define CONFIG_USBC_SS_MUX_DFP_ONLY
@@ -172,7 +173,6 @@
#include "registers.h"
enum adc_channel {
- ADC_VBUS = -1,
ADC_TEMP_SENSOR_CHARGER,
ADC_TEMP_SENSOR_SOC,
ADC_CH_COUNT
diff --git a/board/servo_v4/board.h b/board/servo_v4/board.h
index 2b027af5c1..f28c2f8902 100644
--- a/board/servo_v4/board.h
+++ b/board/servo_v4/board.h
@@ -100,6 +100,7 @@
#define CONFIG_USB_PD_TCPM_STUB
#undef CONFIG_USB_PD_PULLUP
#define CONFIG_USB_PD_PULLUP TYPEC_RP_USB
+#define CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT
/* Override PD_ROLE_DEFAULT in usb_pd.h */
#define PD_ROLE_DEFAULT(port) ((port) ? PD_ROLE_SOURCE : PD_ROLE_SINK)
@@ -159,8 +160,7 @@ enum usb_strings {
/* ADC signal */
enum adc_channel {
- ADC_VBUS = -1,
- ADC_CHG_CC1_PD = 0,
+ ADC_CHG_CC1_PD,
ADC_CHG_CC2_PD,
ADC_DUT_CC1_PD,
ADC_DUT_CC2_PD,
diff --git a/board/yorp/board.c b/board/yorp/board.c
index 2423998dac..e00b1313aa 100644
--- a/board/yorp/board.c
+++ b/board/yorp/board.c
@@ -124,6 +124,11 @@ void chipset_do_shutdown(void)
;
}
+enum adc_channel board_get_vbus_adc(int port)
+{
+ return port ? ADC_VBUS_C1 : ADC_VBUS_C0;
+}
+
/**
* Reset all system PD/TCPC MCUs -- currently only called from
* handle_pending_reboot() in common/power.c just before hard
diff --git a/board/yorp/board.h b/board/yorp/board.h
index e0db5dbfe6..f7d226ef74 100644
--- a/board/yorp/board.h
+++ b/board/yorp/board.h
@@ -8,9 +8,6 @@
#ifndef __CROS_EC_BOARD_H
#define __CROS_EC_BOARD_H
-/* TODO, Fast follow: make a new config option that uses port */
-#define ADC_VBUS ADC_VBUS_C0
-
/* Optional features */
#define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands while in dev. */
@@ -74,6 +71,7 @@
#define CONFIG_USBC_VCONN_SWAP
#define CONFIG_CMD_PD_CONTROL
#define CONFIG_BC12_DETECT_BQ24392
+#define CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT
/* TODO(b/74388692): Adding USB-A BC 1.2 charging support */
diff --git a/board/zoombini/board.h b/board/zoombini/board.h
index 583d2e0a3f..0f6f52d316 100644
--- a/board/zoombini/board.h
+++ b/board/zoombini/board.h
@@ -132,6 +132,7 @@
#define CONFIG_USB_PD_TCPM_PS8805
#define CONFIG_USB_PD_TCPM_TCPCI
#define CONFIG_USB_PD_TCPM_MUX
+#define CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT
#define CONFIG_USBC_PPC_SN5S330
#define CONFIG_USBC_SS_MUX
#define CONFIG_USBC_VCONN
@@ -214,7 +215,6 @@ POWER_SIGNAL_MASK(PP5000_PGOOD)
/* ADC signal */
enum adc_channel {
- ADC_VBUS = -1,
ADC_TEMP_SENSOR_SOC,
ADC_TEMP_SENSOR_CHARGER,
#ifdef BOARD_MEOWTH
diff --git a/common/charge_manager.c b/common/charge_manager.c
index 2a97e66235..b5fdfa7af9 100644
--- a/common/charge_manager.c
+++ b/common/charge_manager.c
@@ -370,15 +370,17 @@ 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_MEASURE_CHARGER
+#if defined(CONFIG_USB_PD_VBUS_MEASURE_CHARGER)
r->meas.voltage_now = charger_get_vbus_voltage(port);
+#elif defined(CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT)
+ r->meas.voltage_now =
+ adc_read_channel(board_get_vbus_adc(port));
+#elif defined(CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT)
+ /* No VBUS ADC channel - voltage is unknown */
+ r->meas.voltage_now = 0;
#else
- if (ADC_VBUS >= 0)
- r->meas.voltage_now =
- adc_read_channel(ADC_VBUS);
- else
- /* No VBUS ADC channel - voltage is unknown */
- r->meas.voltage_now = 0;
+ /* There is a single ADC that measures joint Vbus */
+ r->meas.voltage_now = adc_read_channel(ADC_VBUS);
#endif
}
}
diff --git a/include/charge_manager.h b/include/charge_manager.h
index 1e988203e8..e314b4cd3d 100644
--- a/include/charge_manager.h
+++ b/include/charge_manager.h
@@ -227,4 +227,14 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
*/
int board_vbus_source_enabled(int port);
+#ifdef CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT
+/**
+ * Gets the adc_channel for the specified port.
+ *
+ * @param port PD port.
+ * @return adc_channel that measures the Vbus voltage.
+ */
+enum adc_channel board_get_vbus_adc(int port);
+#endif /* CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT */
+
#endif /* __CROS_EC_CHARGE_MANAGER_H */
diff --git a/include/config.h b/include/config.h
index a6cf65efa1..31c2972b15 100644
--- a/include/config.h
+++ b/include/config.h
@@ -2854,6 +2854,11 @@
#undef CONFIG_USB_PD_VBUS_DETECT_PPC
#undef CONFIG_USB_PD_VBUS_DETECT_NONE
+/* Define if the there is a separate ADC channel for each USB-C Vbus voltage */
+#undef CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT
+
+/* Define if the there is no hardware to measure Vbus voltage */
+#undef CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT
/* Define the type-c port controller I2C base address. */
#define CONFIG_TCPC_I2C_BASE_ADDR 0x9c