diff options
Diffstat (limited to 'board/taniks')
-rw-r--r-- | board/taniks/battery.c | 8 | ||||
-rw-r--r-- | board/taniks/board.c | 19 | ||||
-rw-r--r-- | board/taniks/board.h | 203 | ||||
-rw-r--r-- | board/taniks/build.mk | 2 | ||||
-rw-r--r--[l---------] | board/taniks/charger.c | 91 | ||||
-rw-r--r-- | board/taniks/ec.tasklist | 4 | ||||
-rw-r--r-- | board/taniks/fans.c | 4 | ||||
-rw-r--r-- | board/taniks/fw_config.c | 6 | ||||
-rw-r--r-- | board/taniks/fw_config.h | 30 | ||||
-rw-r--r-- | board/taniks/gpio.inc | 2 | ||||
-rw-r--r-- | board/taniks/i2c.c | 5 | ||||
-rw-r--r-- | board/taniks/keyboard.c | 200 | ||||
-rw-r--r-- | board/taniks/led.c | 63 | ||||
-rw-r--r-- | board/taniks/pwm.c | 10 | ||||
-rw-r--r-- | board/taniks/sensors.c | 72 | ||||
-rw-r--r-- | board/taniks/usbc_config.c | 72 | ||||
-rw-r--r-- | board/taniks/usbc_config.h | 10 |
17 files changed, 387 insertions, 414 deletions
diff --git a/board/taniks/battery.c b/board/taniks/battery.c index f62aae62a1..013c27602c 100644 --- a/board/taniks/battery.c +++ b/board/taniks/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. * @@ -124,7 +124,9 @@ __override bool board_battery_is_initialized(void) bool batt_initialization_state; int batt_status; - batt_initialization_state = (battery_status(&batt_status) ? false : - !!(batt_status & STATUS_INITIALIZED)); + batt_initialization_state = + (battery_status(&batt_status) ? + false : + !!(batt_status & STATUS_INITIALIZED)); return batt_initialization_state; } diff --git a/board/taniks/board.c b/board/taniks/board.c index 894e055b9a..5da998524b 100644 --- a/board/taniks/board.c +++ b/board/taniks/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. */ @@ -34,8 +34,8 @@ #include "gpio_list.h" /* Must come after other header files. */ /* Console output macros */ -#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args) -#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args) +#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args) /******************************************************************************/ /* USB-A charging control */ @@ -60,9 +60,7 @@ __override void board_cbi_init(void) void board_init(void) { -#ifdef SECTION_IS_RW rgbkbd_register_init_setting(&rgbkbd_init_taniks); -#endif } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); @@ -102,8 +100,8 @@ int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state) } if (voltage < BC12_MIN_VOLTAGE) { - CPRINTS("%s: port %d: vbus %d lower than %d", __func__, - port, voltage, BC12_MIN_VOLTAGE); + CPRINTS("%s: port %d: vbus %d lower than %d", __func__, port, + voltage, BC12_MIN_VOLTAGE); return 1; } @@ -119,7 +117,7 @@ enum battery_present battery_hw_present(void) } __override void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) + int max_ma, int charge_mv) { /* * Follow OEM request to limit the input current to @@ -127,7 +125,6 @@ __override void board_set_charge_limit(int port, int supplier, int charge_ma, */ charge_ma = charge_ma * 95 / 100; - 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); } diff --git a/board/taniks/board.h b/board/taniks/board.h index 0756395afa..6cd42ad7bb 100644 --- a/board/taniks/board.h +++ b/board/taniks/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. */ @@ -40,15 +40,14 @@ #define CONFIG_LED_ONOFF_STATES /* Sensors */ -#define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT - +#define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT /* Change Request (b/211078551) * GYRO sensor change from ST LSM6DSOETR3TR to ST LSM6DS3TR-C * LSM6DSOETR3TR base accel/gyro if board id = 0 * LSM6DS3TR-C Base accel/gyro if board id > 0 */ -#define CONFIG_ACCELGYRO_LSM6DSO /* Base accel */ +#define CONFIG_ACCELGYRO_LSM6DSO /* Base accel */ #define CONFIG_ACCEL_LSM6DSO_INT_EVENT \ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) #define CONFIG_ACCELGYRO_LSM6DSM @@ -63,35 +62,34 @@ #define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO_SIZE / 3) /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK \ - (BIT(LID_ACCEL)) +#define CONFIG_ACCEL_FORCE_MODE_MASK (BIT(LID_ACCEL)) /* Lid accel */ #define CONFIG_LID_ANGLE #define CONFIG_LID_ANGLE_UPDATE -#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL -#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL #define CONFIG_ACCEL_BMA4XX #define CONFIG_ACCEL_LIS2DWL - /* Sensor console commands */ #define CONFIG_CMD_ACCELS #define CONFIG_CMD_ACCEL_INFO /* USB Type A Features */ -#define USB_PORT_COUNT 1 +#define USB_PORT_COUNT 1 #define CONFIG_USB_PORT_POWER_DUMB #define CONFIG_IO_EXPANDER #define CONFIG_IO_EXPANDER_NCT38XX -#define CONFIG_IO_EXPANDER_PORT_COUNT 1 +#define CONFIG_IO_EXPANDER_PORT_COUNT 1 /* USB Type C and USB PD defines */ #define CONFIG_USB_PD_TCPM_PS8815 #define CONFIG_USB_PD_TCPM_PS8815_FORCE_DID #define CONFIG_USBC_PPC_SYV682X #define CONFIG_USBC_PPC_NX20P3483 +#define CONFIG_USBC_NX20P348X_RCP_5VSRC_MASK_ENABLE #define CONFIG_USB_PD_FRS_PPC #define CONFIG_USB_PD_FRS @@ -103,17 +101,17 @@ #define CONFIG_HOSTCMD_I2C_CONTROL /* TODO: b/177608416 - measure and check these values on brya */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 30000 /* us */ -#define PD_VCONN_SWAP_DELAY 5000 /* us */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 30000 /* us */ +#define PD_VCONN_SWAP_DELAY 5000 /* us */ /* * Passive USB-C cables only support up to 60W. */ -#define PD_OPERATING_POWER_MW 15000 -#define PD_MAX_POWER_MW 45000 -#define PD_MAX_CURRENT_MA 3000 -#define PD_MAX_VOLTAGE_MV 20000 +#define PD_OPERATING_POWER_MW 15000 +#define PD_MAX_POWER_MW 45000 +#define PD_MAX_CURRENT_MA 3000 +#define PD_MAX_VOLTAGE_MV 20000 /* The lower the input voltage, the higher the power efficiency. */ #define PD_PREFER_LOW_VOLTAGE @@ -124,94 +122,94 @@ * then redefined here to so it's more clear which signal is being used for * which purpose. */ -#define GPIO_AC_PRESENT GPIO_ACOK_OD -#define GPIO_CPU_PROCHOT GPIO_EC_PROCHOT_ODL -#define GPIO_EC_INT_L GPIO_EC_PCH_INT_ODL -#define GPIO_ENABLE_BACKLIGHT GPIO_EC_EN_EDP_BL -#define GPIO_ENTERING_RW GPIO_EC_ENTERING_RW -#define GPIO_KSI_00 GPIO_EC_KSI_00 -#define GPIO_KSI_01 GPIO_EC_KSI_01 -#define GPIO_KSI_02 GPIO_EC_KSI_02 -#define GPIO_KSI_03 GPIO_EC_KSI_03 -#define GPIO_KSI_04 GPIO_EC_KSI_04 -#define GPIO_KSI_05 GPIO_EC_KSI_05 -#define GPIO_KSI_06 GPIO_EC_KSI_06 -#define GPIO_KSI_07 GPIO_EC_KSI_07 -#define GPIO_KSO_00 GPIO_EC_KSO_00 -#define GPIO_KSO_01 GPIO_EC_KSO_01 -#define GPIO_KSO_02 GPIO_EC_KSO_02_R -#define GPIO_KSO_03 GPIO_EC_KSO_03 -#define GPIO_KSO_04 GPIO_EC_KSO_04 -#define GPIO_KSO_05 GPIO_EC_KSO_05 -#define GPIO_KSO_06 GPIO_EC_KSO_06_R -#define GPIO_KSO_07 GPIO_EC_KSO_07_R -#define GPIO_KSO_08 GPIO_EC_KSO_08 -#define GPIO_KSO_09 GPIO_EC_KSO_09 -#define GPIO_KSO_10 GPIO_EC_KSO_10 -#define GPIO_KSO_11 GPIO_EC_KSO_11 -#define GPIO_KSO_12 GPIO_EC_KSO_12 -#define GPIO_KSO_13 GPIO_EC_KSO_13 -#define GPIO_KSO_14 GPIO_EC_KSO_14 -#define GPIO_RFR_KEY_L GPIO_EC_RFR_KEY_ODL_R -#define GPIO_PACKET_MODE_EN GPIO_EC_GSC_PACKET_MODE -#define GPIO_PCH_PWRBTN_L GPIO_EC_PCH_PWR_BTN_ODL -#define GPIO_PCH_RSMRST_L GPIO_EC_PCH_RSMRST_L -#define GPIO_PCH_RTCRST GPIO_EC_PCH_RTCRST -#define GPIO_PCH_SLP_S0_L GPIO_SYS_SLP_S0IX_L -#define GPIO_PCH_SLP_S3_L GPIO_SLP_S3_L +#define GPIO_AC_PRESENT GPIO_ACOK_OD +#define GPIO_CPU_PROCHOT GPIO_EC_PROCHOT_ODL +#define GPIO_EC_INT_L GPIO_EC_PCH_INT_ODL +#define GPIO_ENABLE_BACKLIGHT GPIO_EC_EN_EDP_BL +#define GPIO_ENTERING_RW GPIO_EC_ENTERING_RW +#define GPIO_KSI_00 GPIO_EC_KSI_00 +#define GPIO_KSI_01 GPIO_EC_KSI_01 +#define GPIO_KSI_02 GPIO_EC_KSI_02 +#define GPIO_KSI_03 GPIO_EC_KSI_03 +#define GPIO_KSI_04 GPIO_EC_KSI_04 +#define GPIO_KSI_05 GPIO_EC_KSI_05 +#define GPIO_KSI_06 GPIO_EC_KSI_06 +#define GPIO_KSI_07 GPIO_EC_KSI_07 +#define GPIO_KSO_00 GPIO_EC_KSO_00 +#define GPIO_KSO_01 GPIO_EC_KSO_01 +#define GPIO_KSO_02 GPIO_EC_KSO_02_R +#define GPIO_KSO_03 GPIO_EC_KSO_03 +#define GPIO_KSO_04 GPIO_EC_KSO_04 +#define GPIO_KSO_05 GPIO_EC_KSO_05 +#define GPIO_KSO_06 GPIO_EC_KSO_06_R +#define GPIO_KSO_07 GPIO_EC_KSO_07_R +#define GPIO_KSO_08 GPIO_EC_KSO_08 +#define GPIO_KSO_09 GPIO_EC_KSO_09 +#define GPIO_KSO_10 GPIO_EC_KSO_10 +#define GPIO_KSO_11 GPIO_EC_KSO_11 +#define GPIO_KSO_12 GPIO_EC_KSO_12 +#define GPIO_KSO_13 GPIO_EC_KSO_13 +#define GPIO_KSO_14 GPIO_EC_KSO_14 +#define GPIO_RFR_KEY_L GPIO_EC_RFR_KEY_ODL_R +#define GPIO_PACKET_MODE_EN GPIO_EC_GSC_PACKET_MODE +#define GPIO_PCH_PWRBTN_L GPIO_EC_PCH_PWR_BTN_ODL +#define GPIO_PCH_RSMRST_L GPIO_EC_PCH_RSMRST_L +#define GPIO_PCH_RTCRST GPIO_EC_PCH_RTCRST +#define GPIO_PCH_SLP_S0_L GPIO_SYS_SLP_S0IX_L +#define GPIO_PCH_SLP_S3_L GPIO_SLP_S3_L /* * GPIO_EC_PCH_INT_ODL is used for MKBP events as well as a PCH wakeup * signal. */ -#define GPIO_PCH_WAKE_L GPIO_EC_PCH_INT_ODL -#define GPIO_PG_EC_ALL_SYS_PWRGD GPIO_SEQ_EC_ALL_SYS_PG -#define GPIO_PG_EC_DSW_PWROK GPIO_SEQ_EC_DSW_PWROK -#define GPIO_PG_EC_RSMRST_ODL GPIO_SEQ_EC_RSMRST_ODL -#define GPIO_POWER_BUTTON_L GPIO_GSC_EC_PWR_BTN_ODL -#define GPIO_SYS_RESET_L GPIO_SYS_RST_ODL -#define GPIO_WP_L GPIO_EC_WP_ODL +#define GPIO_PCH_WAKE_L GPIO_EC_PCH_INT_ODL +#define GPIO_PG_EC_ALL_SYS_PWRGD GPIO_SEQ_EC_ALL_SYS_PG +#define GPIO_PG_EC_DSW_PWROK GPIO_SEQ_EC_DSW_PWROK +#define GPIO_PG_EC_RSMRST_ODL GPIO_SEQ_EC_RSMRST_ODL +#define GPIO_POWER_BUTTON_L GPIO_GSC_EC_PWR_BTN_ODL +#define GPIO_SYS_RESET_L GPIO_SYS_RST_ODL +#define GPIO_WP_L GPIO_EC_WP_ODL /* System has back-lit keyboard */ #define CONFIG_PWM #define CONFIG_KEYBOARD_BACKLIGHT /* I2C Bus Configuration */ -#define I2C_PORT_SENSOR NPCX_I2C_PORT0_0 -#define I2C_PORT_USB_C0_TCPC NPCX_I2C_PORT1_0 -#define I2C_PORT_USB_C1_TCPC NPCX_I2C_PORT4_1 -#define I2C_PORT_USB_C0_PPC NPCX_I2C_PORT2_0 -#define I2C_PORT_USB_C1_PPC NPCX_I2C_PORT6_1 -#define I2C_PORT_USB_C0_BC12 NPCX_I2C_PORT2_0 -#define I2C_PORT_USB_C1_BC12 NPCX_I2C_PORT6_1 -#define I2C_PORT_USB_C1_MUX NPCX_I2C_PORT6_1 -#define I2C_PORT_BATTERY NPCX_I2C_PORT5_0 -#define I2C_PORT_CHARGER NPCX_I2C_PORT7_0 -#define I2C_PORT_EEPROM NPCX_I2C_PORT7_0 -#define I2C_PORT_MP2964 NPCX_I2C_PORT7_0 -#define I2C_PORT_KBMCU NPCX_I2C_PORT3_0 - -#define I2C_ADDR_EEPROM_FLAGS 0x50 - -#define I2C_ADDR_MP2964_FLAGS 0x20 +#define I2C_PORT_SENSOR NPCX_I2C_PORT0_0 +#define I2C_PORT_USB_C0_TCPC NPCX_I2C_PORT1_0 +#define I2C_PORT_USB_C1_TCPC NPCX_I2C_PORT4_1 +#define I2C_PORT_USB_C0_PPC NPCX_I2C_PORT2_0 +#define I2C_PORT_USB_C1_PPC NPCX_I2C_PORT6_1 +#define I2C_PORT_USB_C0_BC12 NPCX_I2C_PORT2_0 +#define I2C_PORT_USB_C1_BC12 NPCX_I2C_PORT6_1 +#define I2C_PORT_USB_C1_MUX NPCX_I2C_PORT6_1 +#define I2C_PORT_BATTERY NPCX_I2C_PORT5_0 +#define I2C_PORT_CHARGER NPCX_I2C_PORT7_0 +#define I2C_PORT_EEPROM NPCX_I2C_PORT7_0 +#define I2C_PORT_MP2964 NPCX_I2C_PORT7_0 +#define I2C_PORT_KBMCU NPCX_I2C_PORT3_0 + +#define I2C_ADDR_EEPROM_FLAGS 0x50 + +#define I2C_ADDR_MP2964_FLAGS 0x20 /* Thermal features */ #define CONFIG_THERMISTOR #define CONFIG_TEMP_SENSOR -#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_SEQ_EC_DSW_PWROK +#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_SEQ_EC_DSW_PWROK #define CONFIG_STEINHART_HART_3V3_30K9_47K_4050B /* Fan */ -#define CONFIG_FANS FAN_CH_COUNT +#define CONFIG_FANS FAN_CH_COUNT /* Charger defines */ #define CONFIG_CHARGER_BQ25720 #define CONFIG_CHARGER_BQ25720_VSYS_TH2_CUSTOM /* 37h BIT7:2 VSYS_TH2 6.0V */ -#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 60 +#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 60 #define CONFIG_CHARGE_RAMP_SW -#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10 -#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10 +#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10 +#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10 /* 30h BIT13:12 Enable PSYS 00b */ #define CONFIG_CHARGER_BQ25710_PSYS_SENSING /* 30h BIT7 1.2V enable*/ @@ -232,24 +230,23 @@ #define CONFIG_CHARGER_BQ25710_PP_COMP /* 36h UVP 5600mV */ #define CONFIG_CHARGER_BQ25720_VSYS_UVP_CUSTOM -#define CONFIG_CHARGER_BQ25720_VSYS_UVP \ - BQ25720_CHARGE_OPTION_4_VSYS_UVP__5P6 +#define CONFIG_CHARGER_BQ25720_VSYS_UVP BQ25720_CHARGE_OPTION_4_VSYS_UVP__5P6 /* 3Eh BIT15:8 VSYS_MIN 6.1V */ #define CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_CUSTOM #define CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_MV 6100 /* RGB Keyboard */ -#define GPIO_RGBKBD_SDB_L GPIO_KBMCU_INT_ODL -#ifdef SECTION_IS_RW +#define GPIO_RGBKBD_SDB_L GPIO_KBMCU_INT_ODL + #define CONFIG_RGB_KEYBOARD -#define CONFIG_LED_DRIVER_AW20198 /* Awinic AW20198 on I2C */ -#endif -#define RGB_GRID0_COL 8 -#define RGB_GRID0_ROW 6 +#define CONFIG_LED_DRIVER_AW20198 /* Awinic AW20198 on I2C */ + +#define RGB_GRID0_COL 8 +#define RGB_GRID0_ROW 6 #ifndef __ASSEMBLER__ -#include "gpio_signal.h" /* needed by registers.h */ +#include "gpio_signal.h" /* needed by registers.h */ #include "registers.h" #include "usbc_config.h" @@ -275,17 +272,9 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; -enum sensor_id { - LID_ACCEL = 0, - BASE_ACCEL, - BASE_GYRO, - SENSOR_COUNT -}; +enum sensor_id { LID_ACCEL = 0, BASE_ACCEL, BASE_GYRO, SENSOR_COUNT }; -enum ioex_port { - IOEX_C0_NCT38XX = 0, - IOEX_PORT_COUNT -}; +enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_PORT_COUNT }; enum battery_type { BATTERY_SMP_51W, @@ -295,19 +284,13 @@ enum battery_type { }; enum pwm_channel { - PWM_CH_FAN, /* PWM5 */ + PWM_CH_FAN, /* PWM5 */ PWM_CH_COUNT }; -enum fan_channel { - FAN_CH_0 = 0, - FAN_CH_COUNT -}; +enum fan_channel { FAN_CH_0 = 0, FAN_CH_COUNT }; -enum mft_channel { - MFT_CH_0 = 0, - MFT_CH_COUNT -}; +enum mft_channel { MFT_CH_0 = 0, MFT_CH_COUNT }; void motion_interrupt(enum gpio_signal signal); diff --git a/board/taniks/build.mk b/board/taniks/build.mk index 2afcd5a0f8..7d01cfff96 100644 --- a/board/taniks/build.mk +++ b/board/taniks/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/taniks/charger.c b/board/taniks/charger.c index 476ce97df2..a4fa209246 120000..100644 --- a/board/taniks/charger.c +++ b/board/taniks/charger.c @@ -1 +1,90 @@ -../../baseboard/brya/charger_bq25720.c
\ No newline at end of file +/* 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. + */ + +#include "common.h" + +#include "charge_manager.h" +#include "charge_state_v2.h" +#include "charger.h" +#include "compile_time_macros.h" +#include "console.h" +#include "driver/charger/bq25710.h" +#include "usbc_ppc.h" +#include "usb_pd.h" +#include "util.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +#ifndef CONFIG_ZEPHYR +/* Charger Chip Configuration */ +const struct charger_config_t chg_chips[] = { + { + .i2c_port = I2C_PORT_CHARGER, + .i2c_addr_flags = BQ25710_SMBUS_ADDR1_FLAGS, + .drv = &bq25710_drv, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(chg_chips) == CHARGER_NUM); +#endif + +int board_set_active_charge_port(int port) +{ + int is_valid_port = board_is_usb_pd_port_present(port); + int i; + + if (port == CHARGE_PORT_NONE) { + CPRINTSUSB("Disabling all charger ports"); + + /* Disable all ports. */ + for (i = 0; i < ppc_cnt; i++) { + /* + * Do not return early if one fails otherwise we can + * get into a boot loop assertion failure. + */ + if (ppc_vbus_sink_enable(i, 0)) + CPRINTSUSB("Disabling C%d as sink failed.", i); + } + + return EC_SUCCESS; + } else if (!is_valid_port) { + return EC_ERROR_INVAL; + } + + /* Check if the port is sourcing VBUS. */ + if (ppc_is_sourcing_vbus(port)) { + CPRINTFUSB("Skip enable C%d", port); + return EC_ERROR_INVAL; + } + + CPRINTSUSB("New charge port: C%d", port); + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < ppc_cnt; i++) { + if (i == port) + continue; + + if (ppc_vbus_sink_enable(i, 0)) + CPRINTSUSB("C%d: sink path disable failed.", i); + } + + /* Enable requested charge port. */ + if (ppc_vbus_sink_enable(port, 1)) { + CPRINTSUSB("C%d: sink path enable failed.", port); + return EC_ERROR_UNKNOWN; + } + + return EC_SUCCESS; +} + +__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) +{ + charge_set_input_current_limit( + MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); +} diff --git a/board/taniks/ec.tasklist b/board/taniks/ec.tasklist index 13a5229984..c879d3f77c 100644 --- a/board/taniks/ec.tasklist +++ b/board/taniks/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. */ @@ -12,7 +12,7 @@ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, HOOKS_TASK_STACK_SIZE) \ - TASK_ALWAYS_RW(RGBKBD, rgbkbd_task, NULL, BASEBOARD_RGBKBD_TASK_STACK_SIZE) \ + TASK_ALWAYS(RGBKBD, rgbkbd_task, NULL, BASEBOARD_RGBKBD_TASK_STACK_SIZE) \ TASK_ALWAYS(CHG_RAMP, chg_ramp_task, NULL, BASEBOARD_CHG_RAMP_TASK_STACK_SIZE) \ TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, TASK_STACK_SIZE) \ TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 0, TASK_STACK_SIZE) \ diff --git a/board/taniks/fans.c b/board/taniks/fans.c index d50d3e5506..aeb2ff2caa 100644 --- a/board/taniks/fans.c +++ b/board/taniks/fans.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,7 +25,7 @@ BUILD_ASSERT(ARRAY_SIZE(mft_channels) == MFT_CH_COUNT); static const struct fan_conf fan_conf_0 = { .flags = FAN_USE_RPM_MODE, - .ch = MFT_CH_0, /* Use MFT id to control fan */ + .ch = MFT_CH_0, /* Use MFT id to control fan */ .pgood_gpio = -1, .enable_gpio = GPIO_EN_PP5000_FAN, }; diff --git a/board/taniks/fw_config.c b/board/taniks/fw_config.c index cf1e27ad83..7d6323c868 100644 --- a/board/taniks/fw_config.c +++ b/board/taniks/fw_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. */ @@ -10,7 +10,7 @@ #include "fw_config.h" #include "gpio.h" -#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args) +#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ##args) static union taniks_cbi_fw_config fw_config; BUILD_ASSERT(sizeof(fw_config) == sizeof(uint32_t)); @@ -65,7 +65,7 @@ void board_init_fw_config(void) CPRINTS("CBI: Using board defaults for early board"); if (ec_cfg_has_tabletmode()) { fw_config = fw_config_defaults; - } + } } determine_storage(); diff --git a/board/taniks/fw_config.h b/board/taniks/fw_config.h index 9e1b0ebdf1..05ca552538 100644 --- a/board/taniks/fw_config.h +++ b/board/taniks/fw_config.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. */ @@ -14,20 +14,14 @@ * Source of truth is the project/taniks/taniks/config.star configuration file. */ -enum ec_cfg_usb_db_type { - DB_USB_ABSENT = 0, - DB_USB3_PS8815 = 1 -}; +enum ec_cfg_usb_db_type { DB_USB_ABSENT = 0, DB_USB3_PS8815 = 1 }; enum ec_cfg_keyboard_backlight_type { KEYBOARD_BACKLIGHT_DISABLED = 0, KEYBOARD_BACKLIGHT_ENABLED = 1 }; -enum ec_cfg_tabletmode_type { - TABLETMODE_DISABLED = 0, - TABLETMODE_ENABLED = 1 -}; +enum ec_cfg_tabletmode_type { TABLETMODE_DISABLED = 0, TABLETMODE_ENABLED = 1 }; enum ec_cfg_nvme_status { NVME_DISABLED = 0, @@ -40,11 +34,11 @@ enum ec_cfg_emmc_status { union taniks_cbi_fw_config { struct { - enum ec_cfg_usb_db_type usb_db : 2; - uint32_t sd_db : 2; - enum ec_cfg_keyboard_backlight_type kb_bl : 1; - uint32_t audio : 3; - uint32_t reserved_1 : 4; + enum ec_cfg_usb_db_type usb_db : 2; + uint32_t sd_db : 2; + enum ec_cfg_keyboard_backlight_type kb_bl : 1; + uint32_t audio : 3; + uint32_t reserved_1 : 4; /* b/211079131 - Fw config structure * b/211076082 - Move tablet mode to bit14 * bit8-9: kb_layout @@ -52,10 +46,10 @@ union taniks_cbi_fw_config { * bit12: nvme * bit13: emmc */ - enum ec_cfg_nvme_status nvme_status : 1; - enum ec_cfg_emmc_status emmc_status : 1; - enum ec_cfg_tabletmode_type tabletmode : 1; - uint32_t reserved_2 : 17; + enum ec_cfg_nvme_status nvme_status : 1; + enum ec_cfg_emmc_status emmc_status : 1; + enum ec_cfg_tabletmode_type tabletmode : 1; + uint32_t reserved_2 : 17; }; uint32_t raw_value; }; diff --git a/board/taniks/gpio.inc b/board/taniks/gpio.inc index 0dff3216de..d2c2bdffb9 100644 --- a/board/taniks/gpio.inc +++ b/board/taniks/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/taniks/i2c.c b/board/taniks/i2c.c index 769385c46f..5be2ad4b85 100644 --- a/board/taniks/i2c.c +++ b/board/taniks/i2c.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,7 +44,8 @@ const struct i2c_port_t i2c_ports[] = { }, { /* I2C4 C1 TCPC */ - /* TODO(b/211080526): Change TCPC1's (PS8815) I2C frequency from 400Khz to 1000Khz */ + /* TODO(b/211080526): Change TCPC1's (PS8815) I2C frequency from + 400Khz to 1000Khz */ .name = "tcpc1", .port = I2C_PORT_USB_C1_TCPC, .kbps = 1000, diff --git a/board/taniks/keyboard.c b/board/taniks/keyboard.c index 99099b4661..069627a168 100644 --- a/board/taniks/keyboard.c +++ b/board/taniks/keyboard.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. */ @@ -28,7 +28,7 @@ __override struct keyboard_scan_config keyscan_config = { }; static const struct ec_response_keybd_config taniks_kb = { - .num_top_row_keys = 14, + .num_top_row_keys = 11, .action_keys = { TK_BACK, /* T1 */ TK_REFRESH, /* T2 */ @@ -37,17 +37,47 @@ static const struct ec_response_keybd_config taniks_kb = { TK_SNAPSHOT, /* T5 */ TK_BRIGHTNESS_DOWN, /* T6 */ TK_BRIGHTNESS_UP, /* T7 */ - TK_ABSENT, /* T8 */ - TK_ABSENT, /* T9 */ - TK_ABSENT, /* T10 */ - TK_MICMUTE, /* T11 */ - TK_VOL_MUTE, /* T12 */ - TK_VOL_DOWN, /* T13 */ - TK_VOL_UP, /* T14 */ + TK_MICMUTE, /* T8 */ + TK_VOL_MUTE, /* T9 */ + TK_VOL_DOWN, /* T10 */ + TK_VOL_UP, /* T11 */ }, .capabilities = KEYBD_CAP_SCRNLOCK_KEY | KEYBD_CAP_NUMERIC_KEYPAD, }; +/* + * Row Column info for Top row keys T1 - T15. + * For taniks keyboard layout(T11 - T14) and + * printing(F8 - F11) are different issue. + * Move T11 - T14 row and col setting to T8 - T11. + * Need define row col to mapping matrix layout. + * Change T8 row, col to (0,1) + * Change T9 row, col to (1,5) + * Change T10 row, col to (3,5) + * Change T11 row, col to (0,9) + */ +__override const struct key { + uint8_t row; + uint8_t col; +} vivaldi_keys[] = { + { .row = 0, .col = 2 }, /* T1 */ + { .row = 3, .col = 2 }, /* T2 */ + { .row = 2, .col = 2 }, /* T3 */ + { .row = 1, .col = 2 }, /* T4 */ + { .row = 3, .col = 4 }, /* T5 */ + { .row = 2, .col = 4 }, /* T6 */ + { .row = 1, .col = 4 }, /* T7 */ + { .row = 0, .col = 1 }, /* T8 */ + { .row = 1, .col = 5 }, /* T9 */ + { .row = 3, .col = 5 }, /* T10 */ + { .row = 0, .col = 9 }, /* T11 */ + { .row = 2, .col = 9 }, /* T12 */ + { .row = 1, .col = 9 }, /* T13 */ + { .row = 0, .col = 4 }, /* T14 */ + { .row = 0, .col = 11 }, /* T15 */ +}; +BUILD_ASSERT(ARRAY_SIZE(vivaldi_keys) == MAX_TOP_ROW_KEYS); + static struct rgb_s grid0[RGB_GRID0_COL * RGB_GRID0_ROW]; struct rgbkbd rgbkbds[] = { @@ -66,146 +96,30 @@ const uint8_t rgbkbd_count = ARRAY_SIZE(rgbkbds); const uint8_t rgbkbd_hsize = RGB_GRID0_COL; const uint8_t rgbkbd_vsize = RGB_GRID0_ROW; -#define LED(x, y) RGBKBD_COORD((x), (y)) -#define DELM RGBKBD_DELM +enum ec_rgbkbd_type rgbkbd_type = EC_RGBKBD_TYPE_FOUR_ZONES_40_LEDS; + +#define LED(x, y) RGBKBD_COORD((x), (y)) +#define DELM RGBKBD_DELM + const uint8_t rgbkbd_map[] = { - DELM, /* 0: (null) */ - LED( 0, 0), DELM, /* 1: ~ ` */ - LED( 2, 0), LED( 4, 0), DELM, /* 2: ! 1 */ - LED( 6, 0), DELM, /* 3: @ 2 */ - LED( 0, 1), DELM, /* 4: # 3 */ - LED( 2, 1), DELM, /* 5: $ 4 */ - LED( 4, 1), LED( 6, 1), DELM, /* 6: % 5 */ - LED( 0, 2), DELM, /* 7: ^ 6 */ - LED( 2, 2), DELM, /* 8: & 7 */ - LED( 4, 2), DELM, /* 9: * 8 */ - LED( 6, 2), DELM, /* 10: ( 9 */ - LED( 0, 3), DELM, /* 11: ) 0 */ - LED( 1, 3), DELM, /* 12: _ - */ - LED( 3, 3), DELM, /* 13: + = */ - DELM, /* 14: (null) */ - LED( 5, 3), LED( 6, 3), DELM, /* 15: backspace */ - LED( 0, 0), DELM, /* 16: tab */ - LED( 2, 0), LED( 4, 0), DELM, /* 17: q */ - LED( 6, 0), DELM, /* 18: w */ - LED( 0, 1), DELM, /* 19: e */ - LED( 2, 1), DELM, /* 20: r */ - LED( 4, 1), LED( 6, 1), DELM, /* 21: t */ - LED( 0, 2), DELM, /* 22: y */ - LED( 2, 2), DELM, /* 23: u */ - LED( 4, 2), DELM, /* 24: i */ - LED( 6, 2), DELM, /* 25: o */ - LED( 0, 3), LED( 1, 3), DELM, /* 26: p */ - LED( 3, 3), DELM, /* 27: [ { */ - LED( 5, 3), DELM, /* 28: ] } */ - LED( 6, 3), DELM, /* 29: \ | */ - LED( 0, 0), DELM, /* 30: caps lock */ - LED( 2, 0), LED( 4, 0), DELM, /* 31: a */ - LED( 6, 0), DELM, /* 32: s */ - LED( 0, 1), DELM, /* 33: d */ - LED( 2, 1), DELM, /* 34: f */ - LED( 4, 1), LED( 6, 1), DELM, /* 35: g */ - LED( 0, 2), DELM, /* 36: h */ - LED( 2, 2), DELM, /* 37: j */ - LED( 4, 2), DELM, /* 38: k */ - LED( 6, 4), DELM, /* 39: l */ - LED( 0, 3), LED( 1, 3), DELM, /* 40: ; : */ - LED( 3, 3), DELM, /* 41: " ' */ - DELM, /* 42: (null) */ - LED( 5, 3), LED( 6, 3), DELM, /* 43: enter */ - LED( 1, 0), LED( 3, 0), DELM, /* 44: L-shift */ - DELM, /* 45: (null) */ - LED( 5, 0), DELM, /* 46: z */ - LED( 7, 0), DELM, /* 47: x */ - LED( 1, 1), DELM, /* 48: c */ - LED( 3, 1), DELM, /* 49: v */ - LED( 5, 1), LED( 7, 1), DELM, /* 50: b */ - LED( 1, 2), DELM, /* 51: n */ - LED( 3, 2), DELM, /* 52: m */ - LED( 5, 2), DELM, /* 53: , < */ - LED( 7, 2), DELM, /* 54: . > */ - LED( 2, 3), DELM, /* 55: / ? */ - DELM, /* 56: (null) */ - LED( 4, 3), LED( 7, 3), DELM, /* 57: R-shift */ - LED( 1, 0), LED( 3, 0), DELM, /* 58: L-ctrl */ - LED( 5, 3), LED( 6, 3), DELM, /* 59: power */ - LED( 5, 0), LED( 7, 0), DELM, /* 60: L-alt */ - LED( 1, 1), LED( 3, 1), - LED( 5, 1), LED( 7, 1), - LED( 1, 2), LED( 3, 2), DELM, /* 61: space */ - LED( 5, 2), DELM, /* 62: R-alt */ - DELM, /* 63: (null) */ - LED( 7, 2), DELM, /* 64: R-ctrl */ - DELM, /* 65: (null) */ - DELM, /* 66: (null) */ - DELM, /* 67: (null) */ - DELM, /* 68: (null) */ - DELM, /* 69: (null) */ - DELM, /* 70: (null) */ - DELM, /* 71: (null) */ - DELM, /* 72: (null) */ - DELM, /* 73: (null) */ - DELM, /* 74: (null) */ - DELM, /* 75: (null) */ - LED( 0, 4), DELM, /* 76: delete */ - DELM, /* 77: (null) */ - DELM, /* 78: (null) */ - LED( 2, 3), DELM, /* 79: left */ - LED( 4, 4), DELM, /* 80: home */ - LED( 6, 4), DELM, /* 81: end */ - DELM, /* 82: (null) */ - LED( 4, 3), DELM, /* 83: up */ - LED( 4, 3), DELM, /* 84: down */ - LED( 0, 4), DELM, /* 85: page up */ - LED( 2, 4), DELM, /* 86: page down */ - DELM, /* 87: (null) */ - DELM, /* 88: (null) */ - LED( 7, 3), DELM, /* 89: right */ - DELM, /* 90: (null) */ - LED( 0, 4), DELM, /* 91: numpad 7 */ - LED( 0, 4), DELM, /* 92: numpad 4 */ - LED( 1, 4), DELM, /* 93: numpad 1 */ - DELM, /* 94: (null) */ - LED( 2, 4), DELM, /* 95: numpad / */ - LED( 2, 4), DELM, /* 96: numpad 8 */ - LED( 2, 4), DELM, /* 97: numpad 5 */ - LED( 3, 4), DELM, /* 98: numpad 2 */ - LED( 3, 4), DELM, /* 99: numpad 0 */ - LED( 4, 4), DELM, /* 100: numpad * */ - LED( 4, 4), DELM, /* 101: numpad 9 */ - LED( 4, 4), DELM, /* 102: numpad 6 */ - LED( 5, 4), DELM, /* 103: numpad 3 */ - LED( 5, 4), DELM, /* 104: numpad . */ - LED( 6, 4), DELM, /* 105: numpad - */ - LED( 6, 4), DELM, /* 106: numpad + */ - DELM, /* 107: (null) */ - LED( 7, 4), DELM, /* 108: numpad enter */ - DELM, /* 109: (null) */ - LED( 0, 0), DELM, /* 110: esc */ - LED( 2, 0), LED( 4, 0), DELM, /* T1: back */ - LED( 6, 0), DELM, /* T2: refresh */ - LED( 0, 1), DELM, /* T3: full screen */ - LED( 2, 1), DELM, /* T4: overview */ - LED( 4, 1), LED( 6, 1), DELM, /* T5: snapshot */ - LED( 0, 2), DELM, /* T6: brightness down */ - LED( 2, 2), DELM, /* T7: brightness up */ - DELM, /* T8: (null) */ - DELM, /* T9: (null) */ - DELM, /* T10: (null) */ - LED( 4, 2), DELM, /* T11: mic mute */ - LED( 6, 2), DELM, /* T12: volume mute */ - LED( 0, 3), LED( 1, 3), DELM, /* T13: volume down */ - LED( 3, 3), DELM, /* T14: volume up */ - DELM, /* T15: (null) */ - DELM, /* 126: (null) */ - DELM, /* 127: (null) */ + DELM, LED(0, 0), DELM, LED(1, 0), DELM, LED(2, 0), DELM, LED(3, 0), + DELM, LED(4, 0), DELM, LED(5, 0), DELM, LED(6, 0), DELM, LED(7, 0), + DELM, LED(0, 1), DELM, LED(1, 1), DELM, LED(2, 1), DELM, LED(3, 1), + DELM, LED(4, 1), DELM, LED(5, 1), DELM, LED(6, 1), DELM, LED(7, 1), + DELM, LED(0, 2), DELM, LED(1, 2), DELM, LED(2, 2), DELM, LED(3, 2), + DELM, LED(4, 2), DELM, LED(5, 2), DELM, LED(6, 2), DELM, LED(7, 2), + DELM, LED(0, 3), DELM, LED(1, 3), DELM, LED(2, 3), DELM, LED(3, 3), + DELM, LED(4, 3), DELM, LED(5, 3), DELM, LED(6, 3), DELM, LED(7, 3), + DELM, LED(0, 4), DELM, LED(1, 4), DELM, LED(2, 4), DELM, LED(3, 4), + DELM, LED(4, 4), DELM, LED(5, 4), DELM, LED(6, 4), DELM, LED(7, 4), + DELM, DELM, }; #undef LED #undef DELM const size_t rgbkbd_map_size = ARRAY_SIZE(rgbkbd_map); -__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 &taniks_kb; } diff --git a/board/taniks/led.c b/board/taniks/led.c index 1631bce51f..6b7e0bb6cd 100644 --- a/board/taniks/led.c +++ b/board/taniks/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. */ @@ -14,44 +14,49 @@ #include "led_common.h" #include "gpio.h" -#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args) +#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args) -#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 = 5; __override const int led_charge_lvl_2 = 97; __override struct led_descriptor - led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { - [STATE_CHARGING_LVL_1] = {{EC_LED_COLOR_RED, LED_INDEFINITE} }, - [STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} }, - [STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_GREEN, LED_INDEFINITE} }, - [STATE_DISCHARGE_S0] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_DISCHARGE_S3] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_DISCHARGE_S5] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_BATTERY_ERROR] = {{EC_LED_COLOR_RED, 1 * LED_ONE_SEC}, - {LED_OFF, 1 * LED_ONE_SEC} }, - [STATE_FACTORY_TEST] = {{EC_LED_COLOR_RED, 2 * LED_ONE_SEC}, - {EC_LED_COLOR_GREEN, 2 * LED_ONE_SEC} }, -}; + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_RED, + LED_INDEFINITE } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC }, + { EC_LED_COLOR_GREEN, + 2 * LED_ONE_SEC } }, + }; __override const struct led_descriptor - led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { - [PWR_LED_STATE_ON] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} }, - [PWR_LED_STATE_SUSPEND_AC] = {{EC_LED_COLOR_WHITE, 1 * LED_ONE_SEC}, - {LED_OFF, 3 * LED_ONE_SEC} }, - [PWR_LED_STATE_SUSPEND_NO_AC] = {{EC_LED_COLOR_WHITE, 1 * LED_ONE_SEC}, - {LED_OFF, 3 * LED_ONE_SEC} }, - [PWR_LED_STATE_OFF] = {{LED_OFF, LED_INDEFINITE} }, -}; + led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { + [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } }, + [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE, + 1 * LED_ONE_SEC }, + { LED_OFF, 3 * LED_ONE_SEC } }, + [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE, + 1 * LED_ONE_SEC }, + { LED_OFF, + 3 * LED_ONE_SEC } }, + [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } }, + }; -const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_BATTERY_LED, - EC_LED_ID_POWER_LED -}; +const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED, + EC_LED_ID_POWER_LED }; const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); diff --git a/board/taniks/pwm.c b/board/taniks/pwm.c index 7e834385bf..d23358db5f 100644 --- a/board/taniks/pwm.c +++ b/board/taniks/pwm.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,10 +11,8 @@ #include "pwm_chip.h" const struct pwm_t pwm_channels[] = { - [PWM_CH_FAN] = { - .channel = 5, - .flags = PWM_CONFIG_OPEN_DRAIN, - .freq = 25000 - }, + [PWM_CH_FAN] = { .channel = 5, + .flags = PWM_CONFIG_OPEN_DRAIN, + .freq = 25000 }, }; BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); diff --git a/board/taniks/sensors.c b/board/taniks/sensors.c index d480849036..5371f94081 100644 --- a/board/taniks/sensors.c +++ b/board/taniks/sensors.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. */ @@ -22,8 +22,8 @@ #include "tablet_mode.h" #if 1 -#define CPRINTS(format, args...) ccprints(format, ## args) -#define CPRINTF(format, args...) ccprintf(format, ## args) +#define CPRINTS(format, args...) ccprints(format, ##args) +#define CPRINTF(format, args...) ccprintf(format, ##args) #else #define CPRINTS(format, args...) #define CPRINTF(format, args...) @@ -119,17 +119,13 @@ static struct lsm6dso_data lsm6dso_data; static struct lsm6dsm_data lsm6dsm_data = LSM6DSM_DATA; /* Matrix to rotate lid and base sensor into standard reference frame */ -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 = { - { FLOAT_TO_FP(-1), 0, 0}, - { 0, FLOAT_TO_FP(1), 0}, - { 0, 0, FLOAT_TO_FP(-1)} -}; +static const mat33_fp_t base_standard_ref = { { FLOAT_TO_FP(-1), 0, 0 }, + { 0, FLOAT_TO_FP(1), 0 }, + { 0, 0, FLOAT_TO_FP(-1) } }; struct motion_sensor_t bma422_lid_accel = { .name = "Lid Accel - BMA", @@ -287,7 +283,6 @@ unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); #endif - static void board_detect_motionsensor(void) { int ret; @@ -304,8 +299,8 @@ static void board_detect_motionsensor(void) return; /* Check lid accel chip */ - ret = i2c_read8(I2C_PORT_SENSOR, LIS2DW12_ADDR1, - LIS2DW12_WHO_AM_I_REG, &val); + ret = i2c_read8(I2C_PORT_SENSOR, LIS2DW12_ADDR1, LIS2DW12_WHO_AM_I_REG, + &val); if (ret == 0 && val == LIS2DW12_WHO_AM_I) { CPRINTS("LID_ACCEL is LIS2DW12"); return; @@ -332,7 +327,7 @@ static void board_detect_motionsensor(void) CPRINTS("No LID_ACCEL are detected"); } DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_detect_motionsensor, - HOOK_PRIO_DEFAULT); + HOOK_PRIO_DEFAULT); static void baseboard_sensors_init(void) { @@ -344,27 +339,20 @@ DECLARE_HOOK(HOOK_INIT, baseboard_sensors_init, HOOK_PRIO_INIT_I2C + 1); /* Temperature sensor configuration */ const struct temp_sensor_t temp_sensors[] = { - [TEMP_SENSOR_1_DDR_SOC] = { - .name = "DDR and SOC", - .type = TEMP_SENSOR_TYPE_BOARD, - .read = get_temp_3v3_30k9_47k_4050b, - .idx = ADC_TEMP_SENSOR_1_DDR_SOC - }, - [TEMP_SENSOR_3_CHARGER] = { - .name = "CHARGER", - .type = TEMP_SENSOR_TYPE_BOARD, - .read = get_temp_3v3_30k9_47k_4050b, - .idx = ADC_TEMP_SENSOR_3_CHARGER - }, - [TEMP_SENSOR_4_CPUCHOKE] = { - .name = "CPU CHOKE", - .type = TEMP_SENSOR_TYPE_BOARD, - .read = get_temp_3v3_30k9_47k_4050b, - .idx = ADC_TEMP_SENSOR_4_CPUCHOKE - }, + [TEMP_SENSOR_1_DDR_SOC] = { .name = "DDR and SOC", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_30k9_47k_4050b, + .idx = ADC_TEMP_SENSOR_1_DDR_SOC }, + [TEMP_SENSOR_3_CHARGER] = { .name = "CHARGER", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_30k9_47k_4050b, + .idx = ADC_TEMP_SENSOR_3_CHARGER }, + [TEMP_SENSOR_4_CPUCHOKE] = { .name = "CPU CHOKE", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_30k9_47k_4050b, + .idx = ADC_TEMP_SENSOR_4_CPUCHOKE }, }; - BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); /* @@ -377,8 +365,8 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); /* * TODO(b/202062363): Remove when clang is fixed. */ -#define THERMAL_CPU \ - { \ +#define THERMAL_CPU \ + { \ .temp_host = { \ [EC_TEMP_THRESH_HIGH] = C_TO_K(90), \ [EC_TEMP_THRESH_HALT] = C_TO_K(100), \ @@ -387,7 +375,7 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); [EC_TEMP_THRESH_HIGH] = C_TO_K(85), \ }, \ .temp_fan_off = C_TO_K(35), \ - .temp_fan_max = C_TO_K(60), \ + .temp_fan_max = C_TO_K(70), \ } __maybe_unused static const struct ec_thermal_config thermal_cpu = THERMAL_CPU; @@ -407,8 +395,8 @@ __maybe_unused static const struct ec_thermal_config thermal_cpu = THERMAL_CPU; /* * TODO(b/202062363): Remove when clang is fixed. */ -#define THERMAL_FAN \ - { \ +#define THERMAL_FAN \ + { \ .temp_host = { \ [EC_TEMP_THRESH_HIGH] = C_TO_K(90), \ [EC_TEMP_THRESH_HALT] = C_TO_K(100), \ @@ -417,7 +405,7 @@ __maybe_unused static const struct ec_thermal_config thermal_cpu = THERMAL_CPU; [EC_TEMP_THRESH_HIGH] = C_TO_K(85), \ }, \ .temp_fan_off = C_TO_K(35), \ - .temp_fan_max = C_TO_K(60), \ + .temp_fan_max = C_TO_K(70), \ } __maybe_unused static const struct ec_thermal_config thermal_fan = THERMAL_FAN; diff --git a/board/taniks/usbc_config.c b/board/taniks/usbc_config.c index 0a1b7ff194..71a495c402 100644 --- a/board/taniks/usbc_config.c +++ b/board/taniks/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. */ @@ -34,13 +34,13 @@ #include "usb_pd.h" #include "usb_pd_tcpm.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) #if 0 /* Debug only! */ -#define CPRINTSUSB(format, args...) cprints(CC_USBPD, format, ## args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBPD, format, ## args) +#define CPRINTSUSB(format, args...) cprints(CC_USBPD, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBPD, format, ##args) #else #define CPRINTSUSB(format, args...) #define CPRINTFUSB(format, args...) @@ -99,24 +99,31 @@ unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); * to the virtual_usb_mux_driver so the AP gets notified of mux changes * and updates the TCSS configuration on state changes. */ -static const struct usb_mux usbc1_usb3_db_retimer = { - .usb_port = USBC_PORT_C1, - .driver = &tcpci_tcpm_usb_mux_driver, - .hpd_update = &ps8xxx_tcpc_update_hpd_status, +static const struct usb_mux_chain usbc1_usb3_db_retimer = { + .mux = + &(const struct usb_mux){ + .usb_port = USBC_PORT_C1, + .driver = &tcpci_tcpm_usb_mux_driver, + .hpd_update = &ps8xxx_tcpc_update_hpd_status, + }, }; -const struct usb_mux usb_muxes[] = { +const struct usb_mux_chain usb_muxes[] = { [USBC_PORT_C0] = { - .usb_port = USBC_PORT_C0, - .driver = &virtual_usb_mux_driver, - .hpd_update = &virtual_hpd_update, + .mux = &(const struct usb_mux) { + .usb_port = USBC_PORT_C0, + .driver = &virtual_usb_mux_driver, + .hpd_update = &virtual_hpd_update, + }, }, [USBC_PORT_C1] = { - /* PS8815 DB */ - .usb_port = USBC_PORT_C1, - .driver = &virtual_usb_mux_driver, - .hpd_update = &virtual_hpd_update, - .next_mux = &usbc1_usb3_db_retimer, + .mux = &(const struct usb_mux) { + /* PS8815 DB */ + .usb_port = USBC_PORT_C1, + .driver = &virtual_usb_mux_driver, + .hpd_update = &virtual_hpd_update, + }, + .next = &usbc1_usb3_db_retimer, }, }; BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT); @@ -169,21 +176,20 @@ static void ps8815_reset(void) CPRINTS("%s: patching ps8815 registers", __func__); - if (i2c_read8(I2C_PORT_USB_C1_TCPC, - PS8XXX_I2C_ADDR1_FLAGS, 0x0f, &val) == EC_SUCCESS) + if (i2c_read8(I2C_PORT_USB_C1_TCPC, PS8XXX_I2C_ADDR1_FLAGS, 0x0f, + &val) == EC_SUCCESS) CPRINTS("ps8815: reg 0x0f was %02x", val); else { CPRINTS("delay 10ms to make sure PS8815 is waken from idle"); msleep(10); } - - if (i2c_write8(I2C_PORT_USB_C1_TCPC, - PS8XXX_I2C_ADDR1_FLAGS, 0x0f, 0x31) == EC_SUCCESS) + if (i2c_write8(I2C_PORT_USB_C1_TCPC, PS8XXX_I2C_ADDR1_FLAGS, 0x0f, + 0x31) == EC_SUCCESS) CPRINTS("ps8815: reg 0x0f set to 0x31"); - if (i2c_read8(I2C_PORT_USB_C1_TCPC, - PS8XXX_I2C_ADDR1_FLAGS, 0x0f, &val) == EC_SUCCESS) + if (i2c_read8(I2C_PORT_USB_C1_TCPC, PS8XXX_I2C_ADDR1_FLAGS, 0x0f, + &val) == EC_SUCCESS) CPRINTS("ps8815: reg 0x0f now %02x", val); } @@ -209,10 +215,11 @@ static void board_init_ps8815_detection(void) CPRINTSUSB("%s", __func__); - rv = i2c_read8(I2C_PORT_USB_C1_TCPC, - PS8XXX_I2C_ADDR1_FLAGS, 0x00, &val); + rv = i2c_read8(I2C_PORT_USB_C1_TCPC, PS8XXX_I2C_ADDR1_FLAGS, 0x00, + &val); - db_usb_hw_pres = (rv == EC_SUCCESS)?DB_USB_PRESENT:DB_USB_NOT_PRESENT; + db_usb_hw_pres = (rv == EC_SUCCESS) ? DB_USB_PRESENT : + DB_USB_NOT_PRESENT; if (db_usb_hw_pres == DB_USB_NOT_PRESENT) CPRINTS("DB isn't plugged or something went wrong!"); @@ -230,7 +237,7 @@ static bool board_detect_ps8815_db(void) return true; if (ec_cfg_usb_db_type() == DB_USB3_PS8815 && - db_usb_hw_pres == DB_USB_PRESENT) + db_usb_hw_pres == DB_USB_PRESENT) return true; CPRINTSUSB("No PS8815 DB"); @@ -257,8 +264,7 @@ void board_reset_pd_mcu(void) /* * delay for power-on to reset-off and min. assertion time */ - msleep(GENERIC_MAX(PS8XXX_RESET_DELAY_MS, - PS8815_PWR_H_RST_H_DELAY_MS)); + msleep(GENERIC_MAX(PS8XXX_RESET_DELAY_MS, PS8815_PWR_H_RST_H_DELAY_MS)); gpio_set_level(GPIO_USB_C0_TCPC_RST_ODL, 1); gpio_set_level(GPIO_USB_C1_RT_RST_R_ODL, 1); @@ -274,7 +280,7 @@ void board_reset_pd_mcu(void) */ board_init_ps8815_detection(); usb_mux_hpd_update(USBC_PORT_C1, USB_PD_MUX_HPD_LVL_DEASSERTED | - USB_PD_MUX_HPD_IRQ_DEASSERTED); + USB_PD_MUX_HPD_IRQ_DEASSERTED); } static void board_tcpc_init(void) @@ -385,7 +391,7 @@ __override bool board_is_dts_port(int port) __override uint8_t board_get_usb_pd_port_count(void) { - CPRINTSUSB("%s is called by task_id:%d", __func__, task_get_current()); + CPRINTSUSB("%s is called by task_id:%d", __func__, task_get_current()); if (board_detect_ps8815_db()) return CONFIG_USB_PD_PORT_MAX_COUNT; diff --git a/board/taniks/usbc_config.h b/board/taniks/usbc_config.h index 8bcf365e8d..c9b8a8d71c 100644 --- a/board/taniks/usbc_config.h +++ b/board/taniks/usbc_config.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. */ @@ -8,13 +8,9 @@ #ifndef __CROS_EC_USBC_CONFIG_H #define __CROS_EC_USBC_CONFIG_H -#define CONFIG_USB_PD_PORT_MAX_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 -enum usbc_port { - USBC_PORT_C0 = 0, - USBC_PORT_C1, - USBC_PORT_COUNT -}; +enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; void config_usb_db_type(void); |