diff options
Diffstat (limited to 'board/corori2/board.c')
-rw-r--r-- | board/corori2/board.c | 125 |
1 files changed, 62 insertions, 63 deletions
diff --git a/board/corori2/board.c b/board/corori2/board.c index 0ccd3c3ebc..efebc3af2e 100644 --- a/board/corori2/board.c +++ b/board/corori2/board.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. */ @@ -44,8 +44,8 @@ #include "usb_pd.h" #include "usb_pd_tcpm.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) #define INT_RECHECK_US 5000 @@ -85,7 +85,6 @@ static void usb_c0_interrupt(enum gpio_signal s) /* Check the line again in 5ms */ hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); - } /* C1 interrupt line shared by BC 1.2, TCPC, and charger */ @@ -120,7 +119,6 @@ static void sub_usb_c1_interrupt(enum gpio_signal s) /* Check the line again in 5ms */ hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); - } static void sub_hdmi_hpd_interrupt(enum gpio_signal s) @@ -167,22 +165,22 @@ BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); /* Thermistors */ const struct temp_sensor_t temp_sensors[] = { - [ADC_TEMP_SENSOR_1] = {.name = "Memory", - .type = TEMP_SENSOR_TYPE_BOARD, - .read = get_temp_3v3_51k1_47k_4050b, - .idx = ADC_TEMP_SENSOR_1}, - [ADC_TEMP_SENSOR_2] = {.name = "Charger", - .type = TEMP_SENSOR_TYPE_BOARD, - .read = get_temp_3v3_51k1_47k_4050b, - .idx = ADC_TEMP_SENSOR_2}, + [ADC_TEMP_SENSOR_1] = { .name = "Memory", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_51k1_47k_4050b, + .idx = ADC_TEMP_SENSOR_1 }, + [ADC_TEMP_SENSOR_2] = { .name = "Charger", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_51k1_47k_4050b, + .idx = ADC_TEMP_SENSOR_2 }, }; BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); /* * TODO(b/202062363): Remove when clang is fixed. */ -#define THERMAL_MEMORY \ - { \ +#define THERMAL_MEMORY \ + { \ .temp_host = { \ [EC_TEMP_THRESH_WARN] = 0, \ [EC_TEMP_THRESH_HIGH] = C_TO_K(85), \ @@ -200,8 +198,8 @@ __maybe_unused static const struct ec_thermal_config thermal_memory = /* * TODO(b/202062363): Remove when clang is fixed. */ -#define THERMAL_CHARGER \ - { \ +#define THERMAL_CHARGER \ + { \ .temp_host = { \ [EC_TEMP_THRESH_WARN] = 0, \ [EC_TEMP_THRESH_HIGH] = C_TO_K(80), \ @@ -234,16 +232,17 @@ void board_init(void) if (get_cbi_fw_config_db() == DB_1A_HDMI) { /* Disable i2c on HDMI pins */ - gpio_config_pin(MODULE_I2C, - GPIO_EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL, 0); - gpio_config_pin(MODULE_I2C, - GPIO_EC_I2C_SUB_C1_SCL_HDMI_EN_ODL, 0); + gpio_config_pin(MODULE_I2C, GPIO_EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL, + 0); + gpio_config_pin(MODULE_I2C, GPIO_EC_I2C_SUB_C1_SCL_HDMI_EN_ODL, + 0); /* Set HDMI and sub-rail enables to output */ gpio_set_flags(GPIO_EC_I2C_SUB_C1_SCL_HDMI_EN_ODL, chipset_in_state(CHIPSET_STATE_ON) ? - GPIO_ODR_LOW : GPIO_ODR_HIGH); - gpio_set_flags(GPIO_SUB_C1_INT_EN_RAILS_ODL, GPIO_ODR_HIGH); + GPIO_ODR_LOW : + GPIO_ODR_HIGH); + gpio_set_flags(GPIO_SUB_C1_INT_EN_RAILS_ODL, GPIO_ODR_HIGH); /* Select HDMI option */ gpio_set_level(GPIO_HDMI_SEL_L, 0); @@ -252,8 +251,7 @@ void board_init(void) gpio_enable_interrupt(GPIO_EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL); } else { /* Set SDA as an input */ - gpio_set_flags(GPIO_EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL, - GPIO_INPUT); + gpio_set_flags(GPIO_EC_I2C_SUB_C1_SDA_HDMI_HPD_ODL, GPIO_INPUT); /* Enable C1 interrupt and check if it needs processing */ gpio_enable_interrupt(GPIO_SUB_C1_INT_EN_RAILS_ODL); @@ -320,7 +318,7 @@ static void reconfigure_5v_gpio(void) gpio_set_flags(GPIO_VOLUP_BTN_ODL, GPIO_OUT_LOW); } } -DECLARE_HOOK(HOOK_INIT, reconfigure_5v_gpio, HOOK_PRIO_INIT_I2C+1); +DECLARE_HOOK(HOOK_INIT, reconfigure_5v_gpio, HOOK_PRIO_INIT_I2C + 1); #endif /* BOARD_WADDLEDOO */ static void set_5v_gpio(int level) @@ -361,10 +359,9 @@ __override void board_power_5v_enable(int enable) gpio_set_level(GPIO_SUB_C1_INT_EN_RAILS_ODL, !enable); } else { if (isl923x_set_comparator_inversion(1, !!enable)) - CPRINTS("Failed to %sable sub rails!", enable ? - "en" : "dis"); + CPRINTS("Failed to %sable sub rails!", + enable ? "en" : "dis"); } - } __override uint8_t board_get_usb_pd_port_count(void) @@ -389,13 +386,11 @@ int board_is_sourcing_vbus(int port) tcpc_read(port, TCPC_REG_POWER_STATUS, ®val); return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS); - } int board_set_active_charge_port(int port) { - int is_real_port = (port >= 0 && - port < board_get_usb_pd_port_count()); + int is_real_port = (port >= 0 && port < board_get_usb_pd_port_count()); int i; int old_port; @@ -459,8 +454,8 @@ 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) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); @@ -485,17 +480,13 @@ static struct mutex g_lid_mutex; static struct mutex g_base_mutex; /* Matrices to rotate accelerometers into the standard reference. */ -static const mat33_fp_t lid_standard_ref = { - { 0, FLOAT_TO_FP(1), 0}, - { FLOAT_TO_FP(-1), 0, 0}, - { 0, 0, FLOAT_TO_FP(1)} -}; +static const mat33_fp_t lid_standard_ref = { { 0, FLOAT_TO_FP(1), 0 }, + { FLOAT_TO_FP(-1), 0, 0 }, + { 0, 0, FLOAT_TO_FP(1) } }; -static const mat33_fp_t base_standard_ref = { - { 0, FLOAT_TO_FP(1), 0}, - { FLOAT_TO_FP(-1), 0, 0}, - { 0, 0, FLOAT_TO_FP(1)} -}; +static const mat33_fp_t base_standard_ref = { { 0, FLOAT_TO_FP(1), 0 }, + { FLOAT_TO_FP(-1), 0, 0 }, + { 0, 0, FLOAT_TO_FP(1) } }; static struct accelgyro_saved_data_t g_bma253_data; static struct bmi_drv_data_t g_bmi160_data; @@ -571,9 +562,8 @@ struct motion_sensor_t motion_sensors[] = { const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); -__override void ocpc_get_pid_constants(int *kp, int *kp_div, - int *ki, int *ki_div, - int *kd, int *kd_div) +__override void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki, + int *ki_div, int *kd, int *kd_div) { *kp = 1; *kp_div = 20; @@ -660,25 +650,34 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { }, }; -const struct usb_mux usbc1_retimer = { - .usb_port = 1, - .i2c_port = I2C_PORT_SUB_USB_C1, - .i2c_addr_flags = NB7V904M_I2C_ADDR0, - .driver = &nb7v904m_usb_redriver_drv, +const struct usb_mux_chain usbc1_retimer = { + .mux = + &(const struct usb_mux){ + .usb_port = 1, + .i2c_port = I2C_PORT_SUB_USB_C1, + .i2c_addr_flags = NB7V904M_I2C_ADDR0, + .driver = &nb7v904m_usb_redriver_drv, + }, }; -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, - .i2c_port = I2C_PORT_USB_C0, - .i2c_addr_flags = PI3USB3X532_I2C_ADDR0, - .driver = &pi3usb3x532_usb_mux_driver, + .mux = + &(const struct usb_mux){ + .usb_port = 0, + .i2c_port = I2C_PORT_USB_C0, + .i2c_addr_flags = PI3USB3X532_I2C_ADDR0, + .driver = &pi3usb3x532_usb_mux_driver, + }, }, { - .usb_port = 1, - .i2c_port = I2C_PORT_SUB_USB_C1, - .i2c_addr_flags = PI3USB3X532_I2C_ADDR0, - .driver = &pi3usb3x532_usb_mux_driver, - .next_mux = &usbc1_retimer, + .mux = + &(const struct usb_mux){ + .usb_port = 1, + .i2c_port = I2C_PORT_SUB_USB_C1, + .i2c_addr_flags = PI3USB3X532_I2C_ADDR0, + .driver = &pi3usb3x532_usb_mux_driver, + }, + .next = &usbc1_retimer, } }; @@ -704,7 +703,7 @@ uint16_t tcpc_get_alert_status(void) } if (board_get_usb_pd_port_count() > 1 && - !gpio_get_level(GPIO_SUB_C1_INT_EN_RAILS_ODL)) { + !gpio_get_level(GPIO_SUB_C1_INT_EN_RAILS_ODL)) { if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { /* TCPCI spec Rev 1.0 says to ignore bits 14:12. */ if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0)) |