From bc05412b1f1f261e9796cd270dfe3a1d115ea5ed Mon Sep 17 00:00:00 2001 From: Kenny Kessler Date: Tue, 23 Oct 2018 16:17:18 -0500 Subject: [PATCH] muc_uart: Add VBUS Flag Check the VOLTAGE_NOW property and if it is above 2 V send back to MUC that VBUS is present. This is needed mostly for Factory test but might come in hPerry later on. Change-Id: I16688520611e6087fb04a7cf8006db71496ec519 Signed-off-by: Kenny Kessler Reviewed-on: https://gerrit.mot.com/1259770 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Ryan Lattrel Reviewed-by: Sridhar Vashist Reviewed-by: Kenneth Kessler Submit-Approved: Jira Key --- drivers/mmi_muc_uart/muc_protocol.h | 1 + drivers/mmi_muc_uart/muc_uart.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/drivers/mmi_muc_uart/muc_protocol.h b/drivers/mmi_muc_uart/muc_protocol.h index 528dacfb65c8..63ffa28e1955 100644 --- a/drivers/mmi_muc_uart/muc_protocol.h +++ b/drivers/mmi_muc_uart/muc_protocol.h @@ -63,6 +63,7 @@ struct power_status_t { bool dc_in; /* DC IN Enabled. */ bool charging; /* Battery Charging. */ bool charger; /* MOD USBC Attached. */ + bool vbus; /* VBUS Present */ int16_t battery_temp; /* Degrees Celsius */ uint16_t battery_capacity; /* % Capacity */ uint16_t battery_max_capacity; /* mAhr */ diff --git a/drivers/mmi_muc_uart/muc_uart.c b/drivers/mmi_muc_uart/muc_uart.c index 740d045861db..96e8333460c7 100644 --- a/drivers/mmi_muc_uart/muc_uart.c +++ b/drivers/mmi_muc_uart/muc_uart.c @@ -604,6 +604,7 @@ static int muc_uart_send_bootmode(struct mod_muc_data_t *mm_data) sizeof(struct boot_mode_t)); } +#define VBUS_PRESENT_UV 2000000 static int muc_uart_send_power_status(struct mod_muc_data_t *mm_data) { struct power_status_t pstatus; @@ -675,6 +676,10 @@ static int muc_uart_send_power_status(struct mod_muc_data_t *mm_data) POWER_SUPPLY_PROP_PRESENT, &pval)) pstatus.dc_in = pval.intval ? 1 : 0; + if (!power_supply_get_property(mm_data->usb_psy, + POWER_SUPPLY_PROP_VOLTAGE_NOW, &pval)) + pstatus.vbus = (pval.intval >= VBUS_PRESENT_UV) ? 1 : 0; + /* TODO */ /* pstatus.reverse_boost; * pstatus.mod_output_current;