genvif: Type_C_Power_Source

BUG=b:172437970
BRANCH=none
TEST=verify XML output

Signed-off-by: Denis Brockus <dbrockus@google.com>
Change-Id: Icc7c679aab72b96b2a7e308944be00f1ab3d9029
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2540008
Tested-by: Denis Brockus <dbrockus@chromium.org>
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
This commit is contained in:
Denis Brockus 2020-11-16 09:13:56 -07:00 committed by Commit Bot
parent 5c8f8d83d4
commit 72f06af17e
1 changed files with 17 additions and 8 deletions

View File

@ -76,6 +76,11 @@ enum bc_1_2_support {
BC_1_2_SUPPORT_BOTH = 3
};
enum power_source {
POWER_EXTERNAL = 0,
POWER_UFP = 1,
POWER_BOTH = 2,
};
/*
* TAG Name Strings
@ -2928,25 +2933,29 @@ static void init_vif_component_usb_type_c_fields(
IS_ENABLED(CONFIG_USB_ALT_MODE_ADAPTER));
{
int ps = 1;
int ps = POWER_UFP;
#if defined(CONFIG_DEDICATED_CHARGE_PORT_COUNT)
if (CONFIG_DEDICATED_CHARGE_PORT_COUNT == 1)
ps = 0;
#endif
if (IS_ENABLED(CONFIG_BATTERY))
ps = POWER_BOTH;
#if defined(CONFIG_DEDICATED_CHARGE_PORT_COUNT)
else if (CONFIG_DEDICATED_CHARGE_PORT_COUNT == 1)
ps = POWER_EXTERNAL;
else if (CONFIG_DEDICATED_CHARGE_PORT_COUNT > 1)
ps = POWER_BOTH;
#endif
switch (ps) {
case 0:
case POWER_EXTERNAL:
set_vif_field(&vif_fields[Type_C_Power_Source],
vif_component_name[Type_C_Power_Source],
"0", "Externally Powered");
break;
case 1:
case POWER_UFP:
set_vif_field(&vif_fields[Type_C_Power_Source],
vif_component_name[Type_C_Power_Source],
"1", "UFP-powered");
break;
case 2:
case POWER_BOTH:
set_vif_field(&vif_fields[Type_C_Power_Source],
vif_component_name[Type_C_Power_Source],
"2", "Both");