summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/charge_manager.c7
-rw-r--r--include/charge_manager.h6
-rw-r--r--include/config.h3
-rw-r--r--zephyr/shim/include/config_chip.h3
4 files changed, 19 insertions, 0 deletions
diff --git a/common/charge_manager.c b/common/charge_manager.c
index a20ab33068..28fe109f1d 100644
--- a/common/charge_manager.c
+++ b/common/charge_manager.c
@@ -350,6 +350,11 @@ static enum usb_power_roles get_current_power_role(int port,
return role;
}
+__overridable int board_get_vbus_voltage(int port)
+{
+ return 0;
+}
+
static int get_vbus_voltage(int port, enum usb_power_roles current_role)
{
int voltage_mv;
@@ -375,6 +380,8 @@ static int get_vbus_voltage(int port, enum usb_power_roles current_role)
#elif defined(CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT)
/* No VBUS ADC channel - voltage is unknown */
voltage_mv = 0;
+#elif defined(CONFIG_USB_PD_VBUS_MEASURE_BY_BOARD)
+ voltage_mv = board_get_vbus_voltage(port);
#else
/* There is a single ADC that measures joint Vbus */
voltage_mv = adc_read_channel(ADC_VBUS);
diff --git a/include/charge_manager.h b/include/charge_manager.h
index 1c85745be4..cb6591df3b 100644
--- a/include/charge_manager.h
+++ b/include/charge_manager.h
@@ -323,4 +323,10 @@ __override_proto
void board_fill_source_power_info(int port,
struct ec_response_usb_pd_power_info *r);
+/**
+ * Board specific callback to get vbus voltage.
+ *
+ * @param port Dedicated charge port.
+ */
+__override_proto int board_get_vbus_voltage(int port);
#endif /* __CROS_EC_CHARGE_MANAGER_H */
diff --git a/include/config.h b/include/config.h
index 807fd52f17..1366d86662 100644
--- a/include/config.h
+++ b/include/config.h
@@ -4605,6 +4605,9 @@
/* Define if tcpc on the board supports VBUS measurement */
#undef CONFIG_USB_PD_VBUS_MEASURE_TCPC
+/* Define if there is a specific method to measure Vbus voltage */
+#undef CONFIG_USB_PD_VBUS_MEASURE_BY_BOARD
+
/* Define the type-c port controller I2C base address. */
#define CONFIG_TCPC_I2C_BASE_ADDR_FLAGS 0x4E
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index d8d5880133..e4ad0ab28e 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -748,6 +748,7 @@
#undef CONFIG_USB_PD_VBUS_MEASURE_CHARGER
#undef CONFIG_USB_PD_VBUS_MEASURE_TCPC
#undef CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT
+#undef CONFIG_USB_PD_VBUS_MEASURE_BY_BOARD
#ifdef CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_NOT_PRESENT
#define CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT
#elif defined(CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER)
@@ -756,6 +757,8 @@
#define CONFIG_USB_PD_VBUS_MEASURE_TCPC
#elif defined(CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT)
#define CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT
+#elif defined(CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_BY_BOARD)
+#define CONFIG_USB_PD_VBUS_MEASURE_BY_BOARD
#endif /* VBUS-voltage measurement */
#undef CONFIG_USB_CHARGER