summaryrefslogtreecommitdiff
path: root/board/pirika/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/pirika/board.c')
-rw-r--r--board/pirika/board.c177
1 files changed, 83 insertions, 94 deletions
diff --git a/board/pirika/board.c b/board/pirika/board.c
index 7a21d632d2..8913ec0f07 100644
--- a/board/pirika/board.c
+++ b/board/pirika/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.
*/
@@ -41,8 +41,8 @@
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
-#define CPRINTUSB(format, args...) cprints(CC_USBCHARGE, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
+#define CPRINTUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
#define INT_RECHECK_US 5000
@@ -104,8 +104,8 @@ static const struct ec_response_keybd_config pasara_kb = {
},
.capabilities = KEYBD_CAP_SCRNLOCK_KEY | KEYBD_CAP_NUMERIC_KEYPAD,
};
-__override const struct ec_response_keybd_config
-*board_vivaldi_keybd_config(void)
+__override const struct ec_response_keybd_config *
+board_vivaldi_keybd_config(void)
{
if (get_cbi_fw_config_numeric_pad() == NUMERIC_PAD_ABSENT)
return &pirika_kb;
@@ -188,34 +188,26 @@ static void c0_ccsbu_ovp_interrupt(enum gpio_signal s)
/* ADC channels */
const struct adc_t adc_channels[] = {
- [ADC_VSNS_PP3300_A] = {
- .name = "PP3300_A_PGOOD",
- .factor_mul = ADC_MAX_MVOLT,
- .factor_div = ADC_READ_MAX + 1,
- .shift = 0,
- .channel = CHIP_ADC_CH0
- },
- [ADC_TEMP_SENSOR_1] = {
- .name = "TEMP_SENSOR1",
- .factor_mul = ADC_MAX_MVOLT,
- .factor_div = ADC_READ_MAX + 1,
- .shift = 0,
- .channel = CHIP_ADC_CH2
- },
- [ADC_TEMP_SENSOR_2] = {
- .name = "TEMP_SENSOR2",
- .factor_mul = ADC_MAX_MVOLT,
- .factor_div = ADC_READ_MAX + 1,
- .shift = 0,
- .channel = CHIP_ADC_CH3
- },
- [ADC_TEMP_SENSOR_3] = {
- .name = "TEMP_SENSOR3",
- .factor_mul = ADC_MAX_MVOLT,
- .factor_div = ADC_READ_MAX + 1,
- .shift = 0,
- .channel = CHIP_ADC_CH15
- },
+ [ADC_VSNS_PP3300_A] = { .name = "PP3300_A_PGOOD",
+ .factor_mul = ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH0 },
+ [ADC_TEMP_SENSOR_1] = { .name = "TEMP_SENSOR1",
+ .factor_mul = ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH2 },
+ [ADC_TEMP_SENSOR_2] = { .name = "TEMP_SENSOR2",
+ .factor_mul = ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH3 },
+ [ADC_TEMP_SENSOR_3] = { .name = "TEMP_SENSOR3",
+ .factor_mul = ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH15 },
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
@@ -275,40 +267,31 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
};
/* USB Retimer */
-enum tusb544_conf {
- USB_DP = 0,
- USB_DP_INV,
- USB,
- USB_INV,
- DP,
- DP_INV
-};
+enum tusb544_conf { USB_DP = 0, USB_DP_INV, USB, USB_INV, DP, DP_INV };
-static int board_tusb544_set(const struct usb_mux *me,
- mux_state_t mux_state)
+static int board_tusb544_set(const struct usb_mux *me, mux_state_t mux_state)
{
- int rv = EC_SUCCESS;
+ int rv = EC_SUCCESS;
enum tusb544_conf usb_mode = 0;
/* USB */
if (mux_state & USB_PD_MUX_USB_ENABLED) {
/* USB with DP */
if (mux_state & USB_PD_MUX_DP_ENABLED) {
- usb_mode = (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- ? USB_DP_INV
- : USB_DP;
+ usb_mode = (mux_state & USB_PD_MUX_POLARITY_INVERTED) ?
+ USB_DP_INV :
+ USB_DP;
}
/* USB without DP */
else {
- usb_mode = (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- ? USB_INV
- : USB;
+ usb_mode = (mux_state & USB_PD_MUX_POLARITY_INVERTED) ?
+ USB_INV :
+ USB;
}
}
/* DP without USB */
else if (mux_state & USB_PD_MUX_DP_ENABLED) {
- usb_mode = (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- ? DP_INV
- : DP;
+ usb_mode = (mux_state & USB_PD_MUX_POLARITY_INVERTED) ? DP_INV :
+ DP;
}
/* Nothing enabled */
else
@@ -377,28 +360,37 @@ static int board_tusb544_set(const struct usb_mux *me,
return rv;
}
-const struct usb_mux usbc1_retimer = {
- .usb_port = 1,
- .i2c_port = I2C_PORT_SUB_USB_C1,
- .i2c_addr_flags = TUSB544_I2C_ADDR_FLAGS0,
- .driver = &tusb544_drv,
- .board_set = &board_tusb544_set,
+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 = TUSB544_I2C_ADDR_FLAGS0,
+ .driver = &tusb544_drv,
+ .board_set = &board_tusb544_set,
+ },
};
/* USB Muxes */
-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 = IT5205_I2C_ADDR1_FLAGS,
- .driver = &it5205_usb_mux_driver,
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_C0,
+ .i2c_addr_flags = IT5205_I2C_ADDR1_FLAGS,
+ .driver = &it5205_usb_mux_driver,
+ },
},
{
- .usb_port = 1,
- .i2c_port = I2C_PORT_SUB_USB_C1,
- .i2c_addr_flags = IT5205_I2C_ADDR1_FLAGS,
- .driver = &it5205_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 = IT5205_I2C_ADDR1_FLAGS,
+ .driver = &it5205_usb_mux_driver,
+ },
+ .next = &usbc1_retimer,
},
};
@@ -521,8 +513,7 @@ int board_is_sourcing_vbus(int port)
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;
@@ -584,12 +575,10 @@ int board_set_active_charge_port(int port)
charger_discharge_on_ac(0);
return EC_SUCCESS;
-
}
-__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;
@@ -622,7 +611,7 @@ static struct mutex g_lid_mutex;
static struct mutex g_base_mutex;
/* Sensor Data */
-static struct kionix_accel_data g_kx022_data;
+static struct kionix_accel_data g_kx022_data;
static struct lsm6dsm_data lsm6dsm_data = LSM6DSM_DATA;
/* Drivers */
@@ -702,26 +691,26 @@ const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
/* Thermistors */
const struct temp_sensor_t temp_sensors[] = {
- [TEMP_SENSOR_1] = {.name = "Charger",
- .type = TEMP_SENSOR_TYPE_BOARD,
- .read = get_temp_3v3_51k1_47k_4050b,
- .idx = ADC_TEMP_SENSOR_1},
- [TEMP_SENSOR_2] = {.name = "Vcore",
- .type = TEMP_SENSOR_TYPE_BOARD,
- .read = get_temp_3v3_51k1_47k_4050b,
- .idx = ADC_TEMP_SENSOR_2},
- [TEMP_SENSOR_3] = {.name = "Ambient",
- .type = TEMP_SENSOR_TYPE_BOARD,
- .read = get_temp_3v3_51k1_47k_4050b,
- .idx = ADC_TEMP_SENSOR_3},
+ [TEMP_SENSOR_1] = { .name = "Charger",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_1 },
+ [TEMP_SENSOR_2] = { .name = "Vcore",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_2 },
+ [TEMP_SENSOR_3] = { .name = "Ambient",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_3 },
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
/*
* TODO(b/202062363): Remove when clang is fixed.
*/
-#define THERMAL_CHARGER \
- { \
+#define THERMAL_CHARGER \
+ { \
.temp_host = { \
[EC_TEMP_THRESH_HIGH] = C_TO_K(68), \
[EC_TEMP_THRESH_HALT] = C_TO_K(90), \
@@ -735,8 +724,8 @@ __maybe_unused static const struct ec_thermal_config thermal_charger =
/*
* TODO(b/202062363): Remove when clang is fixed.
*/
-#define THERMAL_VCORE \
- { \
+#define THERMAL_VCORE \
+ { \
.temp_host = { \
[EC_TEMP_THRESH_HIGH] = C_TO_K(65), \
[EC_TEMP_THRESH_HALT] = C_TO_K(80), \
@@ -750,8 +739,8 @@ __maybe_unused static const struct ec_thermal_config thermal_vcore =
/*
* TODO(b/202062363): Remove when clang is fixed.
*/
-#define THERMAL_AMBIENT \
- { \
+#define THERMAL_AMBIENT \
+ { \
.temp_host = { \
[EC_TEMP_THRESH_HIGH] = C_TO_K(65), \
[EC_TEMP_THRESH_HALT] = C_TO_K(80), \