summaryrefslogtreecommitdiff
path: root/board/trogdor/usbc_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/trogdor/usbc_config.c')
-rw-r--r--board/trogdor/usbc_config.c60
1 files changed, 29 insertions, 31 deletions
diff --git a/board/trogdor/usbc_config.c b/board/trogdor/usbc_config.c
index a25b63bff9..39a54f659e 100644
--- a/board/trogdor/usbc_config.c
+++ b/board/trogdor/usbc_config.c
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -25,8 +25,8 @@
#include "usbc_ocp.h"
#include "usbc_ppc.h"
-#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
-#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
const struct charger_config_t chg_chips[] = {
{
@@ -132,16 +132,12 @@ void ppc_interrupt(enum gpio_signal signal)
/* Power Path Controller */
struct ppc_config_t ppc_chips[] = {
- {
- .i2c_port = I2C_PORT_TCPC0,
- .i2c_addr_flags = SN5S330_ADDR0_FLAGS,
- .drv = &sn5s330_drv
- },
- {
- .i2c_port = I2C_PORT_TCPC1,
- .i2c_addr_flags = SN5S330_ADDR0_FLAGS,
- .drv = &sn5s330_drv
- },
+ { .i2c_port = I2C_PORT_TCPC0,
+ .i2c_addr_flags = SN5S330_ADDR0_FLAGS,
+ .drv = &sn5s330_drv },
+ { .i2c_port = I2C_PORT_TCPC1,
+ .i2c_addr_flags = SN5S330_ADDR0_FLAGS,
+ .drv = &sn5s330_drv },
};
unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
@@ -172,16 +168,22 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
* to AP. But the TCPC chip is also needed to know the HPD status; otherwise,
* the mux misbehaves.
*/
-const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .usb_port = 0,
- .driver = &tcpci_tcpm_usb_mux_driver,
- .hpd_update = &ps8xxx_tcpc_update_hpd_status,
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = 0,
+ .driver = &tcpci_tcpm_usb_mux_driver,
+ .hpd_update = &ps8xxx_tcpc_update_hpd_status,
+ },
},
{
- .usb_port = 1,
- .driver = &tcpci_tcpm_usb_mux_driver,
- .hpd_update = &ps8xxx_tcpc_update_hpd_status,
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = 1,
+ .driver = &tcpci_tcpm_usb_mux_driver,
+ .hpd_update = &ps8xxx_tcpc_update_hpd_status,
+ },
}
};
@@ -234,7 +236,7 @@ void board_tcpc_init(void)
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
- USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
@@ -280,8 +282,7 @@ void board_overcurrent_event(int port, int is_overcurrented)
int board_set_active_charge_port(int port)
{
- int is_real_port = (port >= 0 &&
- port < CONFIG_USB_PD_PORT_MAX_COUNT);
+ int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
int i;
if (!is_real_port && port != CHARGE_PORT_NONE)
@@ -309,7 +310,6 @@ int board_set_active_charge_port(int port)
return EC_ERROR_INVAL;
}
-
CPRINTS("New charge port: p%d", port);
/*
@@ -333,23 +333,21 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
+ int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
* critical, as we may brownout.
*/
- if (supplier == CHARGE_SUPPLIER_PD &&
- charge_ma < 1500 &&
+ if (supplier == CHARGE_SUPPLIER_PD && charge_ma < 1500 &&
charge_get_percent() < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON) {
CPRINTS("Using max ilim %d", max_ma);
charge_ma = max_ma;
}
- charge_set_input_current_limit(MAX(charge_ma,
- CONFIG_CHARGER_INPUT_CURRENT),
- charge_mv);
+ charge_set_input_current_limit(
+ MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
uint16_t tcpc_get_alert_status(void)