summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2018-09-12 13:12:31 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-09-20 21:29:58 -0700
commitfd3f9b9a304bb4838bd0b015981e1798b15552f6 (patch)
treef2ba226c0c7020beda9ee1739057e5a116f60673 /driver
parentf0ea1b379d4661c4334a50d1cc68c573b6cf84cd (diff)
downloadchrome-ec-fd3f9b9a304bb4838bd0b015981e1798b15552f6.tar.gz
chgmgr: Set available voltage to 0 on disconnect
Currently, available current is consistently set to zero when a supplier is disconnected across BC 1.2 drivers, PD task, usb charger task but voltage is set to zero only in some places. This patch will set available voltage consistently to 0 on disconnected ports. This change should have no impact externally or internally because currently ports are treated as a disconnected port as long as available current is zero. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=chromium:841944 BRANCH=none TEST=Verify ectool usbpdpower 1 return 'Port 1: Disconnected' and 'Port 1: SNK (not charging)' without and with a BJ adapter connected respectively on Fizz. Verify ectool usbpdpower prints 'Disconnected' and 'SNK Charger PD' on Vayne without and with USB-C charger, respectively. Verify ectool usbpdpower prints 'Disconnected' and 'SNK Charger Type-C' on Vayne without and with a phone USB-C charger, respectively. Change-Id: I9aca575a4a4240ec1f669c55437decaedf758a77 Reviewed-on: https://chromium-review.googlesource.com/1222092 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/bc12/pi3usb9281.c8
-rw-r--r--driver/charger/bd9995x.c5
-rw-r--r--driver/charger/rt946x.c4
3 files changed, 6 insertions, 11 deletions
diff --git a/driver/bc12/pi3usb9281.c b/driver/bc12/pi3usb9281.c
index be1bfdee18..9bdf875468 100644
--- a/driver/bc12/pi3usb9281.c
+++ b/driver/bc12/pi3usb9281.c
@@ -289,11 +289,9 @@ void usb_charger_set_switches(int port, enum usb_switch setting)
static void bc12_detect(int port)
{
int device_type, charger_status;
- struct charge_port_info charge;
+ struct charge_port_info charge = {0};
int type;
- charge.voltage = USB_CHARGER_VOLTAGE_MV;
-
if (usb_charger_port_is_sourcing_vbus(port)) {
/* If we're sourcing VBUS then we're not charging */
device_type = charger_status = 0;
@@ -364,11 +362,11 @@ static void bc12_detect(int port)
else
type = CHARGE_SUPPLIER_OTHER;
+ charge.voltage = USB_CHARGER_VOLTAGE_MV;
charge.current = pi3usb9281_get_ilim(device_type,
charger_status);
charge_manager_update_charge(type, port, &charge);
- } else { /* Detachment: update available charge to 0 */
- charge.current = 0;
+ } else { /* Detachment */
charge_manager_update_charge(
CHARGE_SUPPLIER_PROPRIETARY,
port,
diff --git a/driver/charger/bd9995x.c b/driver/charger/bd9995x.c
index e57b12567d..5423099e52 100644
--- a/driver/charger/bd9995x.c
+++ b/driver/charger/bd9995x.c
@@ -438,10 +438,7 @@ static int bd9995x_bc12_check_type(int port)
static void bd9995x_bc12_detach(int port, int type)
{
- struct charge_port_info charge = {
- .voltage = USB_CHARGER_VOLTAGE_MV,
- .current = 0,
- };
+ struct charge_port_info charge = {0};
/* Update charge manager */
charge_manager_update_charge(type, port, &charge);
diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c
index cf22186ca8..757d5a3c0d 100644
--- a/driver/charger/rt946x.c
+++ b/driver/charger/rt946x.c
@@ -907,8 +907,6 @@ void usb_charger_task(void *u)
int bc12_type = CHARGE_SUPPLIER_NONE;
int reg = 0;
- charge.voltage = USB_CHARGER_VOLTAGE_MV;
-
while (1) {
rt946x_read8(RT946X_REG_DPDMIRQ, &reg);
@@ -916,6 +914,7 @@ void usb_charger_task(void *u)
if (reg & RT946X_MASK_DPDMIRQ_ATTACH) {
bc12_type = rt946x_get_bc12_device_type();
if (bc12_type != CHARGE_SUPPLIER_NONE) {
+ charge.voltage = USB_CHARGER_VOLTAGE_MV;
charge.current =
rt946x_get_bc12_ilim(bc12_type);
charge_manager_update_charge(bc12_type,
@@ -927,6 +926,7 @@ void usb_charger_task(void *u)
/* VBUS detach event */
if (reg & RT946X_MASK_DPDMIRQ_DETACH) {
charge.current = 0;
+ charge.voltage = 0;
charge_manager_update_charge(bc12_type, 0, &charge);
rt946x_enable_bc12_detection(1);
}