summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/glkrvp/chg_usb_pd.c5
-rw-r--r--board/glkrvp_ite/chg_usb_pd.c5
-rw-r--r--common/charge_manager.c4
-rw-r--r--common/usb_charger.c14
-rw-r--r--driver/bc12/pi3usb9281.c8
-rw-r--r--driver/charger/bd9995x.c5
-rw-r--r--driver/charger/rt946x.c4
7 files changed, 16 insertions, 29 deletions
diff --git a/board/glkrvp/chg_usb_pd.c b/board/glkrvp/chg_usb_pd.c
index 581f9aecf5..65866b7c06 100644
--- a/board/glkrvp/chg_usb_pd.c
+++ b/board/glkrvp/chg_usb_pd.c
@@ -162,10 +162,7 @@ DECLARE_HOOK(HOOK_AC_CHANGE, board_dc_jack_handle, HOOK_PRIO_FIRST);
static void board_charge_init(void)
{
int port, supplier;
- struct charge_port_info charge_init = {
- .current = 0,
- .voltage = USB_CHARGER_VOLTAGE_MV,
- };
+ struct charge_port_info charge_init = {0};
/* Initialize all charge suppliers to seed the charge manager */
for (port = 0; port < CHARGE_PORT_COUNT; port++) {
diff --git a/board/glkrvp_ite/chg_usb_pd.c b/board/glkrvp_ite/chg_usb_pd.c
index b0c8488175..5ef8d7a77e 100644
--- a/board/glkrvp_ite/chg_usb_pd.c
+++ b/board/glkrvp_ite/chg_usb_pd.c
@@ -166,10 +166,7 @@ DECLARE_HOOK(HOOK_AC_CHANGE, board_dc_jack_handle, HOOK_PRIO_FIRST);
static void board_charge_init(void)
{
int port, supplier;
- struct charge_port_info charge_init = {
- .current = 0,
- .voltage = USB_CHARGER_VOLTAGE_MV,
- };
+ struct charge_port_info charge_init = {0};
/* Initialize all charge suppliers to seed the charge manager */
for (port = 0; port < CHARGE_PORT_COUNT; port++) {
diff --git a/common/charge_manager.c b/common/charge_manager.c
index 7ae0400262..315610328b 100644
--- a/common/charge_manager.c
+++ b/common/charge_manager.c
@@ -583,8 +583,10 @@ static void charge_manager_refresh(void)
* Zero the available charge on the rejected port so that
* it is no longer chosen.
*/
- for (i = 0; i < CHARGE_SUPPLIER_COUNT; ++i)
+ for (i = 0; i < CHARGE_SUPPLIER_COUNT; ++i) {
available_charge[i][new_port].current = 0;
+ available_charge[i][new_port].voltage = 0;
+ }
}
active_charge_port_initialized = 1;
diff --git a/common/usb_charger.c b/common/usb_charger.c
index e42fee48bd..545907ea72 100644
--- a/common/usb_charger.c
+++ b/common/usb_charger.c
@@ -25,14 +25,12 @@
static void update_vbus_supplier(int port, int vbus_level)
{
- struct charge_port_info charge;
+ struct charge_port_info charge = {0};
- charge.voltage = USB_CHARGER_VOLTAGE_MV;
-
- if (vbus_level && !usb_charger_port_is_sourcing_vbus(port))
+ if (vbus_level && !usb_charger_port_is_sourcing_vbus(port)) {
+ charge.voltage = USB_CHARGER_VOLTAGE_MV;
charge.current = USB_CHARGER_MIN_CURR_MA;
- else
- charge.current = 0;
+ }
charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, port, &charge);
}
@@ -85,11 +83,9 @@ void usb_charger_vbus_change(int port, int vbus_level)
static void usb_charger_init(void)
{
int i;
- struct charge_port_info charge_none;
+ struct charge_port_info charge_none = {0};
/* Initialize all charge suppliers */
- charge_none.voltage = USB_CHARGER_VOLTAGE_MV;
- charge_none.current = 0;
for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
charge_manager_update_charge(CHARGE_SUPPLIER_PROPRIETARY,
i,
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);
}