summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/charge_manager.c22
-rw-r--r--include/config.h1
-rw-r--r--zephyr/Kconfig.pd_meas_vbus6
-rw-r--r--zephyr/shim/include/config_chip.h5
4 files changed, 34 insertions, 0 deletions
diff --git a/common/charge_manager.c b/common/charge_manager.c
index 11b7bcac0e..26a6b38a5b 100644
--- a/common/charge_manager.c
+++ b/common/charge_manager.c
@@ -400,6 +400,28 @@ int charge_manager_get_vbus_voltage(int port)
get_current_supplier(port)));
}
+#ifdef CONFIG_CMD_VBUS
+static int command_vbus(int argc, char **argv)
+{
+ /* port = -1 to print all the ports */
+ int port = -1;
+
+ if (argc == 2)
+ port = atoi(argv[1]);
+
+ for (int i = 0; i < board_get_usb_pd_port_count(); i++) {
+ if (port < 0 || i == port)
+ ccprintf("VBUS C%d = %d mV\n", i,
+ charge_manager_get_vbus_voltage(i));
+ }
+
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(vbus, command_vbus,
+ "[port]",
+ "VBUS of the given port");
+#endif
+
/**
* Fills passed power_info structure with current info about the passed port.
*
diff --git a/include/config.h b/include/config.h
index 6814b481d7..9ffaacaa54 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1563,6 +1563,7 @@
#undef CONFIG_CMD_BUTTON
#define CONFIG_CMD_CBI
#undef CONFIG_CMD_PD_SRCCAPS_REDUCED_SIZE
+#undef CONFIG_CMD_VBUS
/*
* HAS_TASK_CHIPSET implies the GSC presence.
diff --git a/zephyr/Kconfig.pd_meas_vbus b/zephyr/Kconfig.pd_meas_vbus
index 9cf0edec0a..cffe35985c 100644
--- a/zephyr/Kconfig.pd_meas_vbus
+++ b/zephyr/Kconfig.pd_meas_vbus
@@ -41,5 +41,11 @@ config PLATFORM_EC_USB_PD_VBUS_MEASURE_BY_BOARD
endchoice # PLATFORM_EC_USB_PD_VBUS_MEASURE_MODE
+config PLATFORM_EC_CMD_VBUS
+ bool "Console command to print VBUS"
+ help
+ Support console command vbus to print the VBUS on each port
+ respectively.
+
endif # PLATFORM_EC_USB_POWER_DELIVERY
endif # PLATFORM_EC_USBC
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 65d4528d4d..080b585b16 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -1099,6 +1099,11 @@ extern struct jump_data mock_jump_data;
#define CONFIG_USB_PD_VBUS_MEASURE_BY_BOARD
#endif /* VBUS-voltage measurement */
+#undef CONFIG_CMD_VBUS
+#ifdef CONFIG_PLATFORM_EC_CMD_VBUS
+#define CONFIG_CMD_VBUS
+#endif
+
#undef CONFIG_USB_CHARGER
#ifdef CONFIG_PLATFORM_EC_USB_CHARGER
#define CONFIG_USB_CHARGER