diff options
Diffstat (limited to 'board/cret')
-rw-r--r-- | board/cret/battery.c | 6 | ||||
-rw-r--r-- | board/cret/board.c | 72 | ||||
-rw-r--r-- | board/cret/board.h | 52 | ||||
-rw-r--r-- | board/cret/build.mk | 2 | ||||
-rw-r--r-- | board/cret/cbi_ssfc.c | 6 | ||||
-rw-r--r-- | board/cret/cbi_ssfc.h | 3 | ||||
-rw-r--r-- | board/cret/ec.tasklist | 2 | ||||
-rw-r--r-- | board/cret/gpio.inc | 2 | ||||
-rw-r--r-- | board/cret/led.c | 49 | ||||
-rw-r--r-- | board/cret/usb_pd_policy.c | 6 |
10 files changed, 96 insertions, 104 deletions
diff --git a/board/cret/battery.c b/board/cret/battery.c index ee5def4183..27bfed5355 100644 --- a/board/cret/battery.c +++ b/board/cret/battery.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. * @@ -638,8 +638,8 @@ const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_BYD_1VX1H; int charger_profile_override(struct charge_state_data *curr) { if (chipset_in_state(CHIPSET_STATE_ON)) { - curr->requested_current = MIN(curr->requested_current, - CHARGING_CURRENT_1100MA); + curr->requested_current = + MIN(curr->requested_current, CHARGING_CURRENT_1100MA); } return 0; diff --git a/board/cret/board.c b/board/cret/board.c index 57bddae55e..c9c34d6d32 100644 --- a/board/cret/board.c +++ b/board/cret/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 @@ -86,7 +86,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); - } static void sub_hdmi_hpd_interrupt(enum gpio_signal s) @@ -202,7 +201,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) @@ -220,7 +219,6 @@ __override void board_power_5v_enable(int enable) * DB. */ set_5v_gpio(!!enable); - } __override uint8_t board_get_usb_pd_port_count(void) @@ -239,13 +237,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; @@ -308,8 +304,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); @@ -334,17 +330,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 stprivate_data g_lis2dh_data; static struct lsm6dso_data lsm6dso_data; @@ -424,20 +416,19 @@ unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); /* Thermistors */ const struct temp_sensor_t temp_sensors[] = { - [TEMP_SENSOR_1] = {.name = "Memory", - .type = TEMP_SENSOR_TYPE_BOARD, - .read = get_temp_3v3_51k1_47k_4050b, - .idx = ADC_TEMP_SENSOR_1}, - [TEMP_SENSOR_2] = {.name = "Charger", - .type = TEMP_SENSOR_TYPE_BOARD, - .read = get_temp_3v3_51k1_47k_4050b, - .idx = ADC_TEMP_SENSOR_2}, + [TEMP_SENSOR_1] = { .name = "Memory", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_51k1_47k_4050b, + .idx = ADC_TEMP_SENSOR_1 }, + [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); -__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; @@ -489,12 +480,15 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { .drv = &raa489000_tcpm_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, + }, }, }; @@ -568,8 +562,8 @@ static const struct ec_response_keybd_config cret_keybd = { .capabilities = KEYBD_CAP_SCRNLOCK_KEY, }; -__override const struct ec_response_keybd_config -*board_vivaldi_keybd_config(void) +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) { return &cret_keybd; } diff --git a/board/cret/board.h b/board/cret/board.h index 69394fe218..2080185c7c 100644 --- a/board/cret/board.h +++ b/board/cret/board.h @@ -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. */ @@ -29,6 +29,7 @@ /* Charger */ #define CONFIG_CHARGER_RAA489000 +#define PD_MAX_VOLTAGE_MV 20000 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 #define CONFIG_CHARGER_SENSE_RESISTOR 10 #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE @@ -47,7 +48,7 @@ /* PWM */ #define CONFIG_PWM -#define NPCX7_PWM1_SEL 1 /* GPIO C2 is used as PWM1. */ +#define NPCX7_PWM1_SEL 1 /* GPIO C2 is used as PWM1. */ /* USB */ #define CONFIG_BC12_DETECT_PI3USB9201 @@ -74,23 +75,22 @@ #undef PD_POWER_SUPPLY_TURN_OFF_DELAY #undef CONFIG_USBC_VCONN_SWAP_DELAY_US /* 20% margin added for these timings */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 13080 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 16080 /* us */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 13080 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 16080 /* us */ #undef CONFIG_USBC_VCONN_SWAP_DELAY_US -#define CONFIG_USBC_VCONN_SWAP_DELAY_US 787 /* us */ - +#define CONFIG_USBC_VCONN_SWAP_DELAY_US 787 /* us */ /* I2C configuration */ -#define I2C_PORT_EEPROM NPCX_I2C_PORT7_0 -#define I2C_PORT_BATTERY NPCX_I2C_PORT5_0 -#define I2C_PORT_SENSOR NPCX_I2C_PORT0_0 -#define I2C_PORT_USB_C0 NPCX_I2C_PORT1_0 +#define I2C_PORT_EEPROM NPCX_I2C_PORT7_0 +#define I2C_PORT_BATTERY NPCX_I2C_PORT5_0 +#define I2C_PORT_SENSOR NPCX_I2C_PORT0_0 +#define I2C_PORT_USB_C0 NPCX_I2C_PORT1_0 #define I2C_PORT_SUB_USB_C1 NPCX_I2C_PORT2_0 -#define I2C_PORT_USB_MUX I2C_PORT_USB_C0 +#define I2C_PORT_USB_MUX I2C_PORT_USB_C0 /* TODO(b:147440290): Need to handle multiple charger ICs */ -#define I2C_PORT_CHARGER I2C_PORT_USB_C0 +#define I2C_PORT_CHARGER I2C_PORT_USB_C0 -#define I2C_PORT_ACCEL I2C_PORT_SENSOR +#define I2C_PORT_ACCEL I2C_PORT_SENSOR #define I2C_ADDR_EEPROM_FLAGS 0x50 /* 7b address */ @@ -98,18 +98,17 @@ #define CONFIG_CMD_ACCELS #define CONFIG_CMD_ACCEL_INFO -#define CONFIG_ACCEL_LIS2DE /* Lid accel */ -#define CONFIG_ACCELGYRO_LSM6DSO /* Base accel */ +#define CONFIG_ACCEL_LIS2DE /* Lid accel */ +#define CONFIG_ACCELGYRO_LSM6DSO /* Base accel */ #define CONFIG_ACCEL_LSM6DSO_INT_EVENT \ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) /* Lid operates in forced mode, base in FIFO */ #define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) #define CONFIG_ACCEL_FIFO -#define CONFIG_ACCEL_FIFO_SIZE 256 /* Must be a power of 2 */ +#define CONFIG_ACCEL_FIFO_SIZE 256 /* Must be a power of 2 */ #define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO_SIZE / 3) - #define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT #define CONFIG_LID_ANGLE @@ -132,24 +131,15 @@ #include "registers.h" enum adc_channel { - ADC_TEMP_SENSOR_1, /* ADC0 */ - ADC_TEMP_SENSOR_2, /* ADC1 */ - ADC_VSNS_PP3300_A, /* ADC9 */ + ADC_TEMP_SENSOR_1, /* ADC0 */ + ADC_TEMP_SENSOR_2, /* ADC1 */ + ADC_VSNS_PP3300_A, /* ADC9 */ ADC_CH_COUNT }; -enum sensor_id { - LID_ACCEL, - BASE_ACCEL, - BASE_GYRO, - SENSOR_COUNT -}; +enum sensor_id { LID_ACCEL, BASE_ACCEL, BASE_GYRO, SENSOR_COUNT }; -enum temp_sensor_id { - TEMP_SENSOR_1, - TEMP_SENSOR_2, - TEMP_SENSOR_COUNT -}; +enum temp_sensor_id { TEMP_SENSOR_1, TEMP_SENSOR_2, TEMP_SENSOR_COUNT }; enum pwm_channel { PWM_CH_KBLIGHT, diff --git a/board/cret/build.mk b/board/cret/build.mk index af526189dd..1512a49379 100644 --- a/board/cret/build.mk +++ b/board/cret/build.mk @@ -1,5 +1,5 @@ # -*- makefile -*- -# 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. # diff --git a/board/cret/cbi_ssfc.c b/board/cret/cbi_ssfc.c index c4b859f133..81f3ee0dad 100644 --- a/board/cret/cbi_ssfc.c +++ b/board/cret/cbi_ssfc.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. */ @@ -27,10 +27,10 @@ DECLARE_HOOK(HOOK_INIT, cbi_ssfc_init, HOOK_PRIO_FIRST); enum ec_ssfc_base_sensor get_cbi_ssfc_base_sensor(void) { - return (enum ec_ssfc_base_sensor) cached_ssfc.base_sensor; + return (enum ec_ssfc_base_sensor)cached_ssfc.base_sensor; } enum ec_ssfc_lid_sensor get_cbi_ssfc_lid_sensor(void) { - return (enum ec_ssfc_lid_sensor) cached_ssfc.lid_sensor; + return (enum ec_ssfc_lid_sensor)cached_ssfc.lid_sensor; } diff --git a/board/cret/cbi_ssfc.h b/board/cret/cbi_ssfc.h index 058290de8d..bef606bc72 100644 --- a/board/cret/cbi_ssfc.h +++ b/board/cret/cbi_ssfc.h @@ -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. */ @@ -61,5 +61,4 @@ enum ec_ssfc_base_sensor get_cbi_ssfc_base_sensor(void); */ enum ec_ssfc_lid_sensor get_cbi_ssfc_lid_sensor(void); - #endif /* _DEDEDE_CBI_SSFC__H_ */ diff --git a/board/cret/ec.tasklist b/board/cret/ec.tasklist index ee5333eb17..a98ca6fd86 100644 --- a/board/cret/ec.tasklist +++ b/board/cret/ec.tasklist @@ -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. */ diff --git a/board/cret/gpio.inc b/board/cret/gpio.inc index 352f689620..5f39fedc80 100644 --- a/board/cret/gpio.inc +++ b/board/cret/gpio.inc @@ -1,6 +1,6 @@ /* -*- mode:c -*- * - * 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. */ diff --git a/board/cret/led.c b/board/cret/led.c index edfb4ac761..8a7a343fb3 100644 --- a/board/cret/led.c +++ b/board/cret/led.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. */ @@ -8,8 +8,8 @@ #include "led_common.h" #include "led_onoff_states.h" -#define LED_OFF_LVL 1 -#define LED_ON_LVL 0 +#define LED_OFF_LVL 1 +#define LED_ON_LVL 0 __override const int led_charge_lvl_1 = 10; @@ -17,23 +17,32 @@ __override const int led_charge_lvl_2 = 100; /* Cret: Note there is only LED for charge / power */ __override struct led_descriptor - led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { - [STATE_CHARGING_LVL_1] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC}, - {LED_OFF, 1 * LED_ONE_SEC} }, - [STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} }, - [STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} }, - [STATE_CHARGING_FULL_S5] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_DISCHARGE_S0] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} }, - [STATE_DISCHARGE_S0_BAT_LOW] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC}, - {LED_OFF, 1 * LED_ONE_SEC} }, - [STATE_DISCHARGE_S3] = {{EC_LED_COLOR_WHITE, 1 * LED_ONE_SEC}, - {LED_OFF, 1 * LED_ONE_SEC} }, - [STATE_DISCHARGE_S5] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_BATTERY_ERROR] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC}, - {LED_OFF, 1 * LED_ONE_SEC} }, - [STATE_FACTORY_TEST] = {{EC_LED_COLOR_WHITE, 2 * LED_ONE_SEC}, - {EC_LED_COLOR_AMBER, 2 * LED_ONE_SEC} }, -}; + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_AMBER, + 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_WHITE, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { EC_LED_COLOR_WHITE, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, + 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_DISCHARGE_S3] = { { EC_LED_COLOR_WHITE, + 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_AMBER, + 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_WHITE, + 2 * LED_ONE_SEC }, + { EC_LED_COLOR_AMBER, + 2 * LED_ONE_SEC } }, + }; BUILD_ASSERT(ARRAY_SIZE(led_bat_state_table) == LED_NUM_STATES); const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED }; diff --git a/board/cret/usb_pd_policy.c b/board/cret/usb_pd_policy.c index 15faf41ffc..83c09bb99e 100644 --- a/board/cret/usb_pd_policy.c +++ b/board/cret/usb_pd_policy.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. */ @@ -11,8 +11,8 @@ #include "driver/tcpm/tcpci.h" #include "usb_pd.h" -#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) -#define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) +#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) int pd_check_vconn_swap(int port) { |