summaryrefslogtreecommitdiff
path: root/board/crota
diff options
context:
space:
mode:
Diffstat (limited to 'board/crota')
-rw-r--r--board/crota/battery.c44
-rw-r--r--board/crota/board.c29
-rw-r--r--board/crota/board.h198
-rw-r--r--board/crota/build.mk2
-rw-r--r--board/crota/charger.c12
-rw-r--r--board/crota/ec.tasklist2
-rw-r--r--board/crota/fans.c185
-rw-r--r--board/crota/fw_config.c4
-rw-r--r--board/crota/fw_config.h19
-rw-r--r--board/crota/gpio.inc10
-rw-r--r--board/crota/i2c.c20
-rw-r--r--board/crota/keyboard.c6
-rw-r--r--board/crota/led.c49
-rw-r--r--board/crota/pwm.c2
-rw-r--r--board/crota/sensors.c241
-rw-r--r--board/crota/usbc_config.c85
-rw-r--r--board/crota/usbc_config.h10
17 files changed, 516 insertions, 402 deletions
diff --git a/board/crota/battery.c b/board/crota/battery.c
index 5bdf307b07..4738b5910f 100644
--- a/board/crota/battery.c
+++ b/board/crota/battery.c
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -63,7 +63,7 @@ const struct board_batt_params board_battery_info[] = {
},
},
/* BYD 13076993-009 Battery Information */
- [BATTERY_BYD] = {
+ [BATTERY_BYD_GSL4] = {
.fuel_gauge = {
.manuf_name = "BYD",
.device_name = "DELL WV3K8",
@@ -210,7 +210,7 @@ const struct board_batt_params board_battery_info[] = {
/* SWD 1002000008482 Battery Information */
[BATTERY_SWD_ATL3] = {
.fuel_gauge = {
- .manuf_name = "SWD-ATL3.661",
+ .manuf_name = "SWD-ATL3.660",
.device_name = "DELL VKYJX",
.ship_mode = {
.reg_addr = 0x00,
@@ -323,6 +323,35 @@ const struct board_batt_params board_battery_info[] = {
.discharging_max_c = 70,
},
},
+ /* BYD 13148981-00 Battery Information */
+ [BATTERY_BYD_CSL4] = {
+ .fuel_gauge = {
+ .manuf_name = "BYD",
+ .device_name = "DELL JGCCT",
+ .ship_mode = {
+ .reg_addr = 0x00,
+ .reg_data = { 0x0010, 0x0010 },
+ },
+ .fet = {
+ .mfgacc_support = 0,
+ .reg_addr = 0x00,
+ .reg_mask = 0x2000,
+ .disconnect_val = 0x2000,
+ }
+ },
+ .batt_info = {
+ .voltage_max = 17400, /* mV */
+ .voltage_normal = 15000, /* mV */
+ .voltage_min = 12000, /* mV */
+ .precharge_current = 256, /* mA */
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 60,
+ .charging_min_c = 0,
+ .charging_max_c = 60,
+ .discharging_min_c = 0,
+ .discharging_max_c = 70,
+ },
+ },
/* Sunwoda 1002000009262 Battery Information */
[BATTERY_SWD_ATL4] = {
.fuel_gauge = {
@@ -392,6 +421,11 @@ enum battery_present battery_hw_present(void)
batt_pres = GPIO_EC_BATT_PRES_ODL;
- /* The GPIO is low when the battery is physically present */
- return gpio_get_level(batt_pres) ? BP_NO : BP_YES;
+ /*
+ * The GPIO is low when the battery is physically present.
+ * But if battery cell voltage < 2.5V, it will not able to
+ * pull down EC_BATT_PRES_ODL. So we need to set pre-charge
+ * current even EC_BATT_PRES_ODL is high.
+ */
+ return gpio_get_level(batt_pres) ? BP_NOT_SURE : BP_YES;
}
diff --git a/board/crota/board.c b/board/crota/board.c
index 855eeabb81..04f64bd2a5 100644
--- a/board/crota/board.c
+++ b/board/crota/board.c
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -10,13 +10,12 @@
#include "common.h"
#include "compile_time_macros.h"
#include "console.h"
-#include "extpower.h"
#include "gpio.h"
#include "gpio_signal.h"
#include "hooks.h"
#include "driver/accel_lis2dw12.h"
+#include "driver/accelgyro_bmi260.h"
#include "driver/accelgyro_lsm6dso.h"
-#include "driver/als_tcs3400.h"
#include "fw_config.h"
#include "hooks.h"
#include "lid_switch.h"
@@ -31,8 +30,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)
__override void board_cbi_init(void)
{
@@ -56,23 +55,3 @@ static void board_chipset_suspend(void)
gpio_set_level(GPIO_EC_KB_BL_EN_L, 1);
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);
-
-#ifdef CONFIG_USB_PORT_POWER_DUMB_CUSTOM_HOOK
-static void usb_port_startup(void)
-{
- gpio_set_level(GPIO_EN_PP5000_USBA_R, 1);
-}
-DECLARE_HOOK(HOOK_CHIPSET_STARTUP, usb_port_startup, HOOK_PRIO_DEFAULT);
-
-static void usba_power(void)
-{
- if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
- if (extpower_is_present())
- gpio_set_level(GPIO_EN_PP5000_USBA_R, 1);
- else
- gpio_set_level(GPIO_EN_PP5000_USBA_R, 0);
- }
-}
-DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, usba_power, HOOK_PRIO_DEFAULT);
-DECLARE_HOOK(HOOK_AC_CHANGE, usba_power, HOOK_PRIO_DEFAULT);
-#endif /* CONFIG_USB_PORT_POWER_DUMB_CUSTOM_HOOK */
diff --git a/board/crota/board.h b/board/crota/board.h
index 46f3eb7755..0271a369bc 100644
--- a/board/crota/board.h
+++ b/board/crota/board.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -22,7 +22,11 @@
#define CONFIG_MP2964
/* Sensors */
-#define CONFIG_ACCELGYRO_LSM6DSO /* Base accel */
+#define CONFIG_ACCELGYRO_BMI260 /* Base accel/gyro */
+#define CONFIG_ACCELGYRO_BMI260_INT_EVENT \
+ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
+
+#define CONFIG_ACCELGYRO_LSM6DSO /* Base accel/gyro */
#define CONFIG_ACCEL_LSM6DSO_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL)
@@ -36,14 +40,14 @@
/* 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_LIS2DWL
#define CONFIG_ACCEL_LIS2DW12_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL)
#define CONFIG_BODY_DETECTION
-#define CONFIG_BODY_DETECTION_SENSOR BASE_ACCEL
+#define CONFIG_BODY_DETECTION_SENSOR BASE_ACCEL
#define CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR 150 /* % */
#define CONFIG_GESTURE_DETECTION
#define CONFIG_GESTURE_DETECTION_MASK BIT(CONFIG_BODY_DETECTION_SENSOR)
@@ -54,16 +58,15 @@
#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_USB_PORT_POWER_DUMB_CUSTOM_HOOK
/* USB Type C and USB PD defines */
#define CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY
#define CONFIG_IO_EXPANDER
#define CONFIG_IO_EXPANDER_NCT38XX
-#define CONFIG_IO_EXPANDER_PORT_COUNT 2
+#define CONFIG_IO_EXPANDER_PORT_COUNT 2
#define CONFIG_USBC_RETIMER_INTEL_BB
@@ -78,17 +81,17 @@
#define CONFIG_USB_PD_FRS_PPC
/* 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 60000
-#define PD_MAX_CURRENT_MA 3000
-#define PD_MAX_VOLTAGE_MV 20000
+#define PD_OPERATING_POWER_MW 15000
+#define PD_MAX_POWER_MW 60000
+#define PD_MAX_CURRENT_MA 3000
+#define PD_MAX_VOLTAGE_MV 20000
/*
* Macros for GPIO signals used in common code that don't match the
@@ -96,35 +99,35 @@
* 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_KBD_KSO2 GPIO_EC_KSO_02_INV
-#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_TEMP_SENSOR_POWER GPIO_SEQ_EC_DSW_PWROK
+#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_KBD_KSO2 GPIO_EC_KSO_02_INV
+#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_TEMP_SENSOR_POWER GPIO_SEQ_EC_DSW_PWROK
/*
* 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_VOLUME_DOWN_L GPIO_EC_VOLDN_BTN_ODL
-#define GPIO_VOLUME_UP_L GPIO_EC_VOLUP_BTN_ODL
-#define GPIO_WP_L GPIO_EC_WP_ODL
-
-#define GPIO_ID_1_EC_KB_BL_EN GPIO_EC_BATT_PRES_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_VOLUME_DOWN_L GPIO_EC_VOLDN_BTN_ODL
+#define GPIO_VOLUME_UP_L GPIO_EC_VOLUP_BTN_ODL
+#define GPIO_WP_L GPIO_EC_WP_ODL
+
+#define GPIO_ID_1_EC_KB_BL_EN GPIO_EC_BATT_PRES_ODL
/* System has back-lit keyboard */
#define CONFIG_PWM_KBLIGHT
@@ -134,47 +137,48 @@
/* I2C Bus Configuration */
-#define I2C_PORT_SENSOR NPCX_I2C_PORT0_0
+#define I2C_PORT_SENSOR NPCX_I2C_PORT0_0
+
+#define I2C_PORT_USB_C0_C1_TCPC NPCX_I2C_PORT1_0
+#define I2C_PORT_USB_C1_TCPC NPCX_I2C_PORT4_1
-#define I2C_PORT_USB_C0_C1_TCPC NPCX_I2C_PORT1_0
-#define I2C_PORT_USB_C1_TCPC NPCX_I2C_PORT4_1
+#define I2C_PORT_USB_C0_C1_PPC NPCX_I2C_PORT2_0
+#define I2C_PORT_USB_C1_PPC NPCX_I2C_PORT6_1
-#define I2C_PORT_USB_C0_C1_PPC NPCX_I2C_PORT2_0
-#define I2C_PORT_USB_C1_PPC NPCX_I2C_PORT6_1
+#define I2C_PORT_USB_C0_C1_BC12 NPCX_I2C_PORT2_0
+#define I2C_PORT_USB_C1_BC12 NPCX_I2C_PORT6_1
-#define I2C_PORT_USB_C0_C1_BC12 NPCX_I2C_PORT2_0
-#define I2C_PORT_USB_C1_BC12 NPCX_I2C_PORT6_1
+#define I2C_PORT_USB_C0_C1_MUX NPCX_I2C_PORT3_0
+#define I2C_PORT_USB_C1_MUX NPCX_I2C_PORT6_1
-#define I2C_PORT_USB_C0_C1_MUX NPCX_I2C_PORT3_0
-#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_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 this to avoid error on CONFIG_ACCELGYRO_BMI_COMM_I2C */
+#define I2C_PORT_ACCEL I2C_PORT_SENSOR
-#define I2C_ADDR_EEPROM_FLAGS 0x50
+#define I2C_ADDR_EEPROM_FLAGS 0x50
-#define I2C_ADDR_MP2964_FLAGS 0x20
+#define I2C_ADDR_MP2964_FLAGS 0x20
/*
* see b/174768555#comment22
*/
-#define USBC_PORT_C0_BB_RETIMER_I2C_ADDR 0x58
-#define USBC_PORT_C1_SOC_BB_RETIMER_I2C_ADDR 0x54
+#define USBC_PORT_C0_BB_RETIMER_I2C_ADDR 0x58
+#define USBC_PORT_C1_SOC_BB_RETIMER_I2C_ADDR 0x54
/* Type-C connector facing Burnside Bridge retimer */
-#define USBC_PORT_C1_BB_RETIMER_I2C_ADDR 0x56
+#define USBC_PORT_C1_BB_RETIMER_I2C_ADDR 0x56
/* Enabling Thunderbolt-compatible mode */
#define CONFIG_USB_PD_TBT_COMPAT_MODE
/* Enabling USB4 mode */
#define CONFIG_USB_PD_USB4
+#define CONFIG_USB_PD_DATA_RESET_MSG
-/*
- * TODO: b/229934138, Disable BBR firmware update temporarily.
- */
/* Retimer */
-#undef CONFIG_USBC_RETIMER_FW_UPDATE
+#define CONFIG_USBC_RETIMER_FW_UPDATE
/* Thermal features */
#define CONFIG_THERMISTOR
@@ -182,59 +186,55 @@
#define CONFIG_TEMP_SENSOR_POWER
#define CONFIG_STEINHART_HART_3V3_30K9_47K_4050B
-#define CONFIG_FANS FAN_CH_COUNT
-
/* LED defines */
#define CONFIG_LED_ONOFF_STATES
#define CONFIG_LED_ONOFF_STATES_BAT_LOW 10
+/* Fan features */
+#define CONFIG_CUSTOM_FAN_CONTROL
+#define CONFIG_FANS FAN_CH_COUNT
+#define CONFIG_FAN_DYNAMIC
+#define RPM_DEVIATION 1
+
/* Charger defines */
#define CONFIG_CHARGER_BQ25720
#define CONFIG_CHARGER_BQ25720_VSYS_TH2_CUSTOM
-#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 70
+#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 70
#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
#define CONFIG_CHARGER_BQ25710_PSYS_SENSING
+#define CONFIG_CHARGER_BQ25710_PP_ACOK
#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"
enum adc_channel {
- ADC_TEMP_SENSOR_1_DDR_SOC,
- ADC_TEMP_SENSOR_2_AMBIENT,
+ ADC_TEMP_SENSOR_1_SOC,
+ ADC_TEMP_SENSOR_2_DDR,
ADC_TEMP_SENSOR_3_CHARGER,
- ADC_TEMP_SENSOR_4_WWAN,
+ ADC_TEMP_SENSOR_4_AMBIENT,
ADC_CH_COUNT
};
enum temp_sensor_id {
- TEMP_SENSOR_1_DDR_SOC,
- TEMP_SENSOR_2_AMBIENT,
+ TEMP_SENSOR_1_SOC,
+ TEMP_SENSOR_2_DDR,
TEMP_SENSOR_3_CHARGER,
- TEMP_SENSOR_4_WWAN,
+ TEMP_SENSOR_4_AMBIENT,
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_C1_NCT38XX,
- IOEX_PORT_COUNT
-};
+enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_C1_NCT38XX, IOEX_PORT_COUNT };
enum battery_type {
BATTERY_ATL,
- BATTERY_BYD,
+ BATTERY_BYD_GSL4,
BATTERY_COM,
BATTERY_LGC,
BATTERY_SMP_ATL3,
@@ -243,29 +243,35 @@ enum battery_type {
BATTERY_SWD_COS3,
BATTERY_SMP_ATL4,
BATTERY_SMP_COS4,
+ BATTERY_BYD_CSL4,
BATTERY_SWD_ATL4,
BATTERY_SWD_COS4,
BATTERY_TYPE_COUNT
};
enum pwm_channel {
- PWM_CH_LED2 = 0, /* PWM0 (white charger) */
- PWM_CH_LED1, /* PWM2 (orange charger) */
- PWM_CH_KBLIGHT, /* PWM3 */
- PWM_CH_FAN, /* PWM5 */
+ PWM_CH_LED2 = 0, /* PWM0 (white charger) */
+ PWM_CH_LED1, /* PWM2 (orange charger) */
+ PWM_CH_KBLIGHT, /* PWM3 */
+ 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 fan_rpm_table {
+ RPM_TABLE_CPU0,
+ RPM_TABLE_CPU1,
+ RPM_TABLE_DDR,
+ RPM_TABLE_CHARGER,
+ RPM_TABLE_AMBIENT,
+ FAN_RPM_TABLE_COUNT
};
+enum mft_channel { MFT_CH_0 = 0, MFT_CH_COUNT };
+
+void motion_interrupt(enum gpio_signal signal);
+
#endif /* !__ASSEMBLER__ */
#endif /* __CROS_EC_BOARD_H */
diff --git a/board/crota/build.mk b/board/crota/build.mk
index cd6a38a852..8b85854cf0 100644
--- a/board/crota/build.mk
+++ b/board/crota/build.mk
@@ -1,5 +1,5 @@
# -*- makefile -*-
-# Copyright 2022 The Chromium OS Authors. All rights reserved.
+# Copyright 2022 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/crota/charger.c b/board/crota/charger.c
index e6a5c446d7..c7dcf7b0c1 100644
--- a/board/crota/charger.c
+++ b/board/crota/charger.c
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -15,9 +15,8 @@
#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)
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
/* Charger Chip Configuration */
const struct charger_config_t chg_chips[] = {
@@ -84,7 +83,6 @@ int board_set_active_charge_port(int port)
__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);
+ charge_set_input_current_limit(
+ MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
diff --git a/board/crota/ec.tasklist b/board/crota/ec.tasklist
index 296654d39d..17eeb4ae7c 100644
--- a/board/crota/ec.tasklist
+++ b/board/crota/ec.tasklist
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 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/crota/fans.c b/board/crota/fans.c
index 27f5bca929..17e19dc863 100644
--- a/board/crota/fans.c
+++ b/board/crota/fans.c
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -12,6 +12,16 @@
#include "fan.h"
#include "hooks.h"
#include "pwm.h"
+#include "timer.h"
+#include "thermal.h"
+#include "util.h"
+
+#define SENSOR_SOC_FAN_OFF 30
+#define SENSOR_SOC_FAN_MID 47
+#define SENSOR_SOC_FAN_MAX 53
+#define SENSOR_DDR_FAN_TURN_OFF 37
+#define SENSOR_DDR_FAN_TURN_ON 38
+#define RECORD_TIME (2 * MINUTE)
/* MFT channels. These are logically separate from pwm_channels. */
const struct mft_t mft_channels[] = {
@@ -25,65 +35,152 @@ 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,
};
-/*
- * TOOD(b/181271666): thermistor placement and calibration
- *
- * Prototype fan spins at about 4200 RPM at 100% PWM, this
- * is specific to board ID 2 and might also apears in later
- * boards as well.
- */
-static const struct fan_rpm fan_rpm_0 = {
- .rpm_min = 2200,
- .rpm_start = 2200,
- .rpm_max = 4200,
+static const struct fan_rpm rpm_table[FAN_RPM_TABLE_COUNT] = {
+ [RPM_TABLE_CPU0] = {
+ .rpm_min = 2200,
+ .rpm_start = 2200,
+ .rpm_max = 3700,
+ },
+
+ [RPM_TABLE_CPU1] = {
+ .rpm_min = 3700,
+ .rpm_start = 3700,
+ .rpm_max = 4000,
+ },
+
+ [RPM_TABLE_DDR] = {
+ .rpm_min = 4000,
+ .rpm_start = 4000,
+ .rpm_max = 4200,
+ },
+
+ [RPM_TABLE_CHARGER] = {
+ .rpm_min = 4000,
+ .rpm_start = 4000,
+ .rpm_max = 4200,
+ },
+
+ [RPM_TABLE_AMBIENT] = {
+ .rpm_min = 4000,
+ .rpm_start = 4000,
+ .rpm_max = 4200,
+ },
};
-const struct fan_t fans[FAN_CH_COUNT] = {
+struct fan_t fans[FAN_CH_COUNT] = {
[FAN_CH_0] = {
.conf = &fan_conf_0,
- .rpm = &fan_rpm_0,
+ .rpm = &rpm_table[RPM_TABLE_CPU0],
},
};
-#ifndef CONFIG_FANS
-
-/*
- * TODO(b/181271666): use static fan speeds until fan and sensors are
- * tuned. for now, use:
- *
- * AP off: 33%
- * AP on: 100%
- */
-
-static void fan_slow(void)
+static void fan_get_rpm(int fan)
{
- const int duty_pct = 33;
-
- ccprints("%s: speed %d%%", __func__, duty_pct);
+ static timestamp_t deadline;
- pwm_enable(PWM_CH_FAN, 1);
- pwm_set_duty(PWM_CH_FAN, duty_pct);
+ /* Record actual RPM every 2 minutes. */
+ if (timestamp_expired(deadline, NULL)) {
+ ccprints("fan actual rpm: %d", fan_get_rpm_actual(FAN_CH(fan)));
+ deadline.val += RECORD_TIME;
+ }
}
-static void fan_max(void)
+static void fan_set_percent(int fan, int pct)
{
- const int duty_pct = 100;
+ int new_rpm;
- ccprints("%s: speed %d%%", __func__, duty_pct);
-
- pwm_enable(PWM_CH_FAN, 1);
- pwm_set_duty(PWM_CH_FAN, duty_pct);
+ new_rpm = fan_percent_to_rpm(fan, pct);
+ fan_set_rpm_target(FAN_CH(fan), new_rpm);
+ fan_get_rpm(fan);
}
-DECLARE_HOOK(HOOK_INIT, fan_slow, HOOK_PRIO_DEFAULT);
-DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, fan_slow, HOOK_PRIO_DEFAULT);
-DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, fan_slow, HOOK_PRIO_DEFAULT);
-DECLARE_HOOK(HOOK_CHIPSET_RESET, fan_max, HOOK_PRIO_FIRST);
-DECLARE_HOOK(HOOK_CHIPSET_RESUME, fan_max, HOOK_PRIO_DEFAULT);
-
-#endif /* CONFIG_FANS */
+void board_override_fan_control(int fan, int *tmp)
+{
+ /*
+ * Crota's fan speed is control by four sensors.
+ *
+ * Sensor charger control the speed when system's temperature
+ * is too high.
+ * Other sensors control normal loading's speed.
+ *
+ * When sensor charger is triggered, the fan speed is only
+ * control by sensor charger, avoid heat damage to system.
+ * When other sensors is triggered, the fan is control
+ * by other sensors.
+ *
+ * Sensor SOC has two slopes for fan speed.
+ * Sensor DDR also become a fan on/off switch.
+ */
+ static int pct;
+ int sensor_soc;
+ int sensor_ddr;
+ int sensor_charger;
+ int sensor_ambient;
+
+ /* Decide sensor SOC temperature using which slope. */
+ if (tmp[TEMP_SENSOR_1_SOC] > SENSOR_SOC_FAN_MID) {
+ thermal_params[TEMP_SENSOR_1_SOC].temp_fan_off =
+ C_TO_K(SENSOR_SOC_FAN_MID);
+ thermal_params[TEMP_SENSOR_1_SOC].temp_fan_max =
+ C_TO_K(SENSOR_SOC_FAN_MAX);
+ } else {
+ thermal_params[TEMP_SENSOR_1_SOC].temp_fan_off =
+ C_TO_K(SENSOR_SOC_FAN_OFF);
+ thermal_params[TEMP_SENSOR_1_SOC].temp_fan_max =
+ C_TO_K(SENSOR_SOC_FAN_MID);
+ }
+
+ sensor_soc = thermal_fan_percent(
+ thermal_params[TEMP_SENSOR_1_SOC].temp_fan_off,
+ thermal_params[TEMP_SENSOR_1_SOC].temp_fan_max,
+ C_TO_K(tmp[TEMP_SENSOR_1_SOC]));
+ sensor_ddr = thermal_fan_percent(
+ thermal_params[TEMP_SENSOR_2_DDR].temp_fan_off,
+ thermal_params[TEMP_SENSOR_2_DDR].temp_fan_max,
+ C_TO_K(tmp[TEMP_SENSOR_2_DDR]));
+ sensor_charger = thermal_fan_percent(
+ thermal_params[TEMP_SENSOR_3_CHARGER].temp_fan_off,
+ thermal_params[TEMP_SENSOR_3_CHARGER].temp_fan_max,
+ C_TO_K(tmp[TEMP_SENSOR_3_CHARGER]));
+ sensor_ambient = thermal_fan_percent(
+ thermal_params[TEMP_SENSOR_4_AMBIENT].temp_fan_off,
+ thermal_params[TEMP_SENSOR_4_AMBIENT].temp_fan_max,
+ C_TO_K(tmp[TEMP_SENSOR_4_AMBIENT]));
+
+ /*
+ * Sensor DDR turn on when temperature > 38,
+ * turn off when temperature < 37
+ */
+ if ((tmp[TEMP_SENSOR_2_DDR]) < SENSOR_DDR_FAN_TURN_OFF) {
+ pct = 0;
+ } else if ((tmp[TEMP_SENSOR_2_DDR]) > SENSOR_DDR_FAN_TURN_ON) {
+ /*
+ * Decide which sensor was triggered and choose table.
+ * Priority: charger > soc > ddr > ambient
+ */
+ if (sensor_charger) {
+ fans[fan].rpm = &rpm_table[RPM_TABLE_CHARGER];
+ pct = sensor_charger;
+ } else if (sensor_soc) {
+ if (tmp[TEMP_SENSOR_1_SOC] > SENSOR_SOC_FAN_MID)
+ fans[fan].rpm = &rpm_table[RPM_TABLE_CPU1];
+ else
+ fans[fan].rpm = &rpm_table[RPM_TABLE_CPU0];
+ pct = sensor_soc;
+ } else if (sensor_ddr) {
+ fans[fan].rpm = &rpm_table[RPM_TABLE_DDR];
+ pct = sensor_ddr;
+ } else {
+ fans[fan].rpm = &rpm_table[RPM_TABLE_AMBIENT];
+ pct = sensor_ambient;
+ }
+ }
+
+ /* Transfer percent to rpm. */
+ fan_set_percent(fan, pct);
+}
diff --git a/board/crota/fw_config.c b/board/crota/fw_config.c
index 35fc466fd1..5feb8a2d3e 100644
--- a/board/crota/fw_config.c
+++ b/board/crota/fw_config.c
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 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 "cros_board_info.h"
#include "fw_config.h"
-#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
static union brya_cbi_fw_config fw_config;
BUILD_ASSERT(sizeof(fw_config) == sizeof(uint32_t));
diff --git a/board/crota/fw_config.h b/board/crota/fw_config.h
index f441650ec6..407af32472 100644
--- a/board/crota/fw_config.h
+++ b/board/crota/fw_config.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -14,10 +14,7 @@
* Source of truth is the project/brya/brya/config.star configuration file.
*/
-enum ec_cfg_usb_db_type {
- DB_USB_ABSENT = 0,
- DB_USB_ABSENT2 = 15
-};
+enum ec_cfg_usb_db_type { DB_USB_ABSENT = 0, DB_USB_ABSENT2 = 15 };
enum ec_cfg_keyboard_backlight_type {
KEYBOARD_BACKLIGHT_DISABLED = 0,
@@ -26,12 +23,12 @@ enum ec_cfg_keyboard_backlight_type {
union brya_cbi_fw_config {
struct {
- enum ec_cfg_usb_db_type usb_db : 4;
- uint32_t sd_db : 2;
- uint32_t lte_db : 1;
- enum ec_cfg_keyboard_backlight_type kb_bl : 1;
- uint32_t audio : 3;
- uint32_t reserved_1 : 21;
+ enum ec_cfg_usb_db_type usb_db : 4;
+ uint32_t sd_db : 2;
+ uint32_t lte_db : 1;
+ enum ec_cfg_keyboard_backlight_type kb_bl : 1;
+ uint32_t audio : 3;
+ uint32_t reserved_1 : 21;
};
uint32_t raw_value;
};
diff --git a/board/crota/gpio.inc b/board/crota/gpio.inc
index 655fc68060..7668442b7b 100644
--- a/board/crota/gpio.inc
+++ b/board/crota/gpio.inc
@@ -1,6 +1,6 @@
/* -*- mode:c -*-
*
- * Copyright 2022 The Chromium OS Authors. All rights reserved.
+ * Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -10,10 +10,10 @@
/* INTERRUPT GPIOs: */
GPIO_INT(ACOK_OD, PIN(0, 0), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, extpower_interrupt)
GPIO_INT(EC_ACCEL_INT_R_L, PIN(8, 1), GPIO_SEL_1P8V | GPIO_INT_FALLING, lis2dw12_interrupt)
-GPIO_INT(EC_IMU_INT_R_L, PIN(5, 6), GPIO_SEL_1P8V | GPIO_INT_FALLING, lsm6dso_interrupt)
+GPIO_INT(EC_IMU_INT_R_L, PIN(5, 6), GPIO_SEL_1P8V | GPIO_INT_FALLING, motion_interrupt)
GPIO_INT(EC_PROCHOT_IN_L, PIN(F, 0), GPIO_INT_BOTH, throttle_ap_prochot_input_interrupt)
-GPIO_INT(EC_VOLDN_BTN_ODL, PIN(9, 3), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
-GPIO_INT(EC_VOLUP_BTN_ODL, PIN(9, 7), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
+GPIO_INT(EC_VOLDN_BTN_ODL, PIN(9, 7), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
+GPIO_INT(EC_VOLUP_BTN_ODL, PIN(9, 3), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
GPIO_INT(EC_WP_ODL, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt)
GPIO_INT(GSC_EC_PWR_BTN_ODL, PIN(0, 1), GPIO_INT_BOTH | GPIO_HIB_WAKE_LOW, power_button_interrupt)
GPIO_INT(LID_OPEN, PIN(D, 2), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, lid_interrupt)
@@ -69,6 +69,7 @@ GPIO(PCH_PWROK, PIN(7, 2), GPIO_OUT_LOW)
GPIO(SYS_RST_ODL, PIN(C, 5), GPIO_ODR_HIGH)
GPIO(USB_C0_C1_TCPC_RST_ODL, PIN(A, 7), GPIO_ODR_LOW)
GPIO(VCCST_PWRGD_OD, PIN(A, 4), GPIO_ODR_LOW)
+GPIO(EC_SENSOR_STRAP, PIN(5, 7), GPIO_INPUT)
/* UART alternate functions */
ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* GPIO64/CR_SIN1, GPO65/CR_SOUT1/FLPRG1_L */
@@ -109,7 +110,6 @@ UNUSED(PIN(D, 6)) /* GPOD6/CR_SOUT3/SHDF_ESPI_L */
UNUSED(PIN(3, 2)) /* GPO32/TRIS_L */
UNUSED(PIN(3, 5)) /* GPO35/CR_SOUT4/TEST_L */
UNUSED(PIN(6, 6)) /* GPIO66 */
-UNUSED(PIN(5, 7)) /* GPIO57/SER_IRQ/ESPI_ALERT_L */
UNUSED(PIN(D, 4)) /* GPIOD4/CR_SIN3 */
UNUSED(PIN(5, 0)) /* GPIO50 */
UNUSED(PIN(F, 5)) /* GPIOF5/I2C5_SCL1 */
diff --git a/board/crota/i2c.c b/board/crota/i2c.c
index 1fc1126282..681e600bf2 100644
--- a/board/crota/i2c.c
+++ b/board/crota/i2c.c
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -9,7 +9,7 @@
#include "hooks.h"
#include "i2c.h"
-#define BOARD_ID_FAST_PLUS_CAPABLE 2
+#define BOARD_ID_FAST_PLUS_CAPABLE 2
/* I2C port map configuration */
const struct i2c_port_t i2c_ports[] = {
@@ -63,19 +63,3 @@ const struct i2c_port_t i2c_ports[] = {
},
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
-
-/*
- * I2C controllers are initialized in main.c. This sets the speed much
- * later, but before I2C peripherals are initialized.
- */
-static void set_board_legacy_i2c_speeds(void)
-{
- if (get_board_id() >= BOARD_ID_FAST_PLUS_CAPABLE)
- return;
-
- ccprints("setting USB DB I2C buses to 400 kHz\n");
-
- i2c_set_freq(I2C_PORT_USB_C0_C1_TCPC, I2C_FREQ_400KHZ);
- i2c_set_freq(I2C_PORT_USB_C0_C1_PPC, I2C_FREQ_400KHZ);
-}
-DECLARE_HOOK(HOOK_INIT, set_board_legacy_i2c_speeds, HOOK_PRIO_INIT_I2C - 1);
diff --git a/board/crota/keyboard.c b/board/crota/keyboard.c
index d193ac9034..8911d48b81 100644
--- a/board/crota/keyboard.c
+++ b/board/crota/keyboard.c
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 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 @@ static const struct ec_response_keybd_config crota_kb = {
.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 &crota_kb;
}
diff --git a/board/crota/led.c b/board/crota/led.c
index 0a9c9503fe..83f3789e36 100644
--- a/board/crota/led.c
+++ b/board/crota/led.c
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -8,6 +8,7 @@
#include <stdint.h>
#include "charge_manager.h"
+#include "charge_state.h"
#include "common.h"
#include "compile_time_macros.h"
#include "ec_commands.h"
@@ -21,23 +22,27 @@
#define BAT_LED_OFF_LVL 0
__override const int led_charge_lvl_1 = 5;
-__override const int led_charge_lvl_2 = 100;
+__override const int led_charge_lvl_2 = 96;
__override struct led_descriptor
- led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = {
- [STATE_CHARGING_LVL_1] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} },
- [STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} },
- [STATE_CHARGING_FULL_CHARGE] = {{LED_OFF, LED_INDEFINITE} },
- [STATE_DISCHARGE_S0] = {{LED_OFF, LED_INDEFINITE} },
- [STATE_DISCHARGE_S0_BAT_LOW] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} },
- [STATE_DISCHARGE_S3] = {{LED_OFF, LED_INDEFINITE} },
- [STATE_DISCHARGE_S5] = {{LED_OFF, LED_INDEFINITE} },
- [STATE_BATTERY_ERROR] = {{LED_OFF, LED_INDEFINITE} },
- [STATE_FACTORY_TEST] = {
- {EC_LED_COLOR_WHITE, 1 * LED_ONE_SEC},
- {LED_OFF, 1 * LED_ONE_SEC}
- },
-};
+ led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = {
+ [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_WHITE,
+ LED_INDEFINITE } },
+ [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_WHITE,
+ LED_INDEFINITE } },
+ [STATE_CHARGING_FULL_CHARGE] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER,
+ LED_INDEFINITE } },
+ [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } },
+ [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,
+ 1 * LED_ONE_SEC },
+ { LED_OFF, 1 * LED_ONE_SEC } },
+ };
const enum ec_led_id supported_led_ids[] = {
EC_LED_ID_BATTERY_LED,
@@ -87,3 +92,15 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
return EC_SUCCESS;
}
+
+__override enum led_states board_led_get_state(enum led_states desired_state)
+{
+ /* Make sure when battery is pre-charging, the LED will blinking.
+ * Otherwise it will wait 30 seconds then blinking.
+ */
+ if (charge_get_state() == PWR_STATE_IDLE) {
+ if (charge_get_flags() & CHARGE_FLAG_EXTERNAL_POWER)
+ desired_state = STATE_BATTERY_ERROR;
+ }
+ return desired_state;
+}
diff --git a/board/crota/pwm.c b/board/crota/pwm.c
index 51bee909ff..26da4e4f7d 100644
--- a/board/crota/pwm.c
+++ b/board/crota/pwm.c
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 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/crota/sensors.c b/board/crota/sensors.c
index baa82f7b56..bbd2686512 100644
--- a/board/crota/sensors.c
+++ b/board/crota/sensors.c
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 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 "accelgyro.h"
#include "adc.h"
#include "driver/accel_lis2dw12.h"
+#include "driver/accelgyro_bmi_common.h"
#include "driver/accelgyro_lsm6dso.h"
-#include "driver/als_tcs3400_public.h"
#include "gpio.h"
#include "hooks.h"
#include "motion_sense.h"
@@ -19,15 +19,15 @@
/* ADC configuration */
const struct adc_t adc_channels[] = {
- [ADC_TEMP_SENSOR_1_DDR_SOC] = {
- .name = "TEMP_DDR_SOC",
+ [ADC_TEMP_SENSOR_1_SOC] = {
+ .name = "TEMP_SOC",
.input_ch = NPCX_ADC_CH0,
.factor_mul = ADC_MAX_VOLT,
.factor_div = ADC_READ_MAX + 1,
.shift = 0,
},
- [ADC_TEMP_SENSOR_2_AMBIENT] = {
- .name = "TEMP_AMBIENT",
+ [ADC_TEMP_SENSOR_2_DDR] = {
+ .name = "TEMP_DDR",
.input_ch = NPCX_ADC_CH1,
.factor_mul = ADC_MAX_VOLT,
.factor_div = ADC_READ_MAX + 1,
@@ -40,8 +40,8 @@ const struct adc_t adc_channels[] = {
.factor_div = ADC_READ_MAX + 1,
.shift = 0,
},
- [ADC_TEMP_SENSOR_4_WWAN] = {
- .name = "TEMP_WWAN",
+ [ADC_TEMP_SENSOR_4_AMBIENT] = {
+ .name = "TEMP_AMBIENT",
.input_ch = NPCX_ADC_CH7,
.factor_mul = ADC_MAX_VOLT,
.factor_div = ADC_READ_MAX + 1,
@@ -54,20 +54,19 @@ K_MUTEX_DEFINE(g_lid_accel_mutex);
K_MUTEX_DEFINE(g_base_accel_mutex);
static struct stprivate_data g_lis2dw12_data;
static struct lsm6dso_data lsm6dso_data;
+static struct bmi_drv_data_t g_bmi260_data;
-/* TODO(b/184779333): calibrate the orientation matrix on later board stage */
-static const mat33_fp_t lid_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 lid_standard_ref = { { FLOAT_TO_FP(1), 0, 0 },
+ { 0, FLOAT_TO_FP(-1), 0 },
+ { 0, 0, FLOAT_TO_FP(-1) } };
-/* TODO(b/184779743): verify orientation matrix */
-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) } };
+
+static const mat33_fp_t base_standard_ref_id_1 = { { 0, FLOAT_TO_FP(1), 0 },
+ { FLOAT_TO_FP(1), 0, 0 },
+ { 0, 0, FLOAT_TO_FP(-1) } };
struct motion_sensor_t motion_sensors[] = {
[LID_ACCEL] = {
@@ -145,6 +144,75 @@ struct motion_sensor_t motion_sensors[] = {
};
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
+struct motion_sensor_t bmi260_base_accel = {
+ .name = "Base Accel",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_BMI260,
+ .type = MOTIONSENSE_TYPE_ACCEL,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &bmi260_drv,
+ .mutex = &g_base_accel_mutex,
+ .drv_data = &g_bmi260_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr_flags = BMI260_ADDR0_FLAGS,
+ .rot_standard_ref = &base_standard_ref_id_1,
+ .min_frequency = BMI_ACCEL_MIN_FREQ,
+ .max_frequency = BMI_ACCEL_MAX_FREQ,
+ .default_range = 4, /* g */
+ .config = {
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
+ /* Sensor on in S3 */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 10000 | ROUND_UP_FLAG,
+ .ec_rate = 100 * MSEC,
+ },
+ },
+};
+struct motion_sensor_t bmi260_base_gyro = {
+ .name = "Base Gyro",
+ .active_mask = SENSOR_ACTIVE_S0_S3,
+ .chip = MOTIONSENSE_CHIP_BMI260,
+ .type = MOTIONSENSE_TYPE_GYRO,
+ .location = MOTIONSENSE_LOC_BASE,
+ .drv = &bmi260_drv,
+ .mutex = &g_base_accel_mutex,
+ .drv_data = &g_bmi260_data,
+ .port = I2C_PORT_SENSOR,
+ .i2c_spi_addr_flags = BMI260_ADDR0_FLAGS,
+ .default_range = 1000, /* dps */
+ .rot_standard_ref = &base_standard_ref_id_1,
+ .min_frequency = BMI_GYRO_MIN_FREQ,
+ .max_frequency = BMI_GYRO_MAX_FREQ,
+};
+
+void motion_interrupt(enum gpio_signal signal)
+{
+ if (get_board_id() > 1) {
+ if (gpio_get_level(GPIO_EC_SENSOR_STRAP) == 0)
+ bmi260_interrupt(signal);
+ else
+ lsm6dso_interrupt(signal);
+ } else
+ lsm6dso_interrupt(signal);
+}
+
+static void board_update_motion_sensor_config(void)
+{
+ if (get_board_id() > 1 && gpio_get_level(GPIO_EC_SENSOR_STRAP) == 0) {
+ motion_sensors[BASE_ACCEL] = bmi260_base_accel;
+ motion_sensors[BASE_GYRO] = bmi260_base_gyro;
+ ccprints("BASE IMU is BMI260");
+ } else {
+ ccprints("BASE IMU is LSM6DSO");
+ }
+}
+DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_update_motion_sensor_config,
+ HOOK_PRIO_INIT_I2C + 1);
+
static void baseboard_sensors_init(void)
{
/* Enable gpio interrupt for lid accel sensor */
@@ -156,17 +224,17 @@ 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",
+ [TEMP_SENSOR_1_SOC] = {
+ .name = "SOC",
.type = TEMP_SENSOR_TYPE_BOARD,
.read = get_temp_3v3_30k9_47k_4050b,
- .idx = ADC_TEMP_SENSOR_1_DDR_SOC,
+ .idx = ADC_TEMP_SENSOR_1_SOC,
},
- [TEMP_SENSOR_2_AMBIENT] = {
- .name = "Ambient",
+ [TEMP_SENSOR_2_DDR] = {
+ .name = "DDR",
.type = TEMP_SENSOR_TYPE_BOARD,
.read = get_temp_3v3_30k9_47k_4050b,
- .idx = ADC_TEMP_SENSOR_2_AMBIENT,
+ .idx = ADC_TEMP_SENSOR_2_DDR,
},
[TEMP_SENSOR_3_CHARGER] = {
.name = "Charger",
@@ -174,124 +242,53 @@ const struct temp_sensor_t temp_sensors[] = {
.read = get_temp_3v3_30k9_47k_4050b,
.idx = ADC_TEMP_SENSOR_3_CHARGER,
},
- [TEMP_SENSOR_4_WWAN] = {
- .name = "WWAN",
+ [TEMP_SENSOR_4_AMBIENT] = {
+ .name = "Ambient",
.type = TEMP_SENSOR_TYPE_BOARD,
.read = get_temp_3v3_30k9_47k_4050b,
- .idx = ADC_TEMP_SENSOR_4_WWAN,
+ .idx = ADC_TEMP_SENSOR_4_AMBIENT,
},
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
-/*
- * TODO(b/180681346): update for Alder Lake/brya
- *
- * Alder Lake specifies 100 C as maximum TDP temperature. THRMTRIP# occurs at
- * 130 C. However, sensor is located next to DDR, so we need to use the lower
- * DDR temperature limit (85 C)
- */
-/*
- * TODO(b/202062363): Remove when clang is fixed.
- */
-#define THERMAL_CPU \
- { \
+#define THERMAL_CPU \
+ { \
.temp_host = { \
- [EC_TEMP_THRESH_HIGH] = C_TO_K(85), \
- [EC_TEMP_THRESH_HALT] = C_TO_K(90), \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(77), \
+ [EC_TEMP_THRESH_HALT] = C_TO_K(80), \
}, \
.temp_host_release = { \
- [EC_TEMP_THRESH_HIGH] = C_TO_K(80), \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(77), \
}, \
- .temp_fan_off = C_TO_K(35), \
- .temp_fan_max = C_TO_K(60), \
+ .temp_fan_off = C_TO_K(30), \
+ .temp_fan_max = C_TO_K(47), \
}
__maybe_unused static const struct ec_thermal_config thermal_cpu = THERMAL_CPU;
-/*
- * TODO(b/180681346): update for Alder Lake/brya
- *
- * Inductor limits - used for both charger and PP3300 regulator
- *
- * Need to use the lower of the charger IC, PP3300 regulator, and the inductors
- *
- * Charger max recommended temperature 100C, max absolute temperature 125C
- * PP3300 regulator: operating range -40 C to 145 C
- *
- * Inductors: limit of 125c
- * PCB: limit is 80c
- */
-/*
- * TODO(b/202062363): Remove when clang is fixed.
- */
-#define THERMAL_AMBIENT \
- { \
- .temp_host = { \
- [EC_TEMP_THRESH_HIGH] = C_TO_K(85), \
- [EC_TEMP_THRESH_HALT] = C_TO_K(90), \
- }, \
- .temp_host_release = { \
- [EC_TEMP_THRESH_HIGH] = C_TO_K(80), \
- }, \
- .temp_fan_off = C_TO_K(35), \
- .temp_fan_max = C_TO_K(60), \
+#define THERMAL_DDR \
+ { \
+ .temp_fan_off = C_TO_K(56), .temp_fan_max = C_TO_K(59), \
}
-__maybe_unused static const struct ec_thermal_config thermal_ambient =
- THERMAL_AMBIENT;
+__maybe_unused static const struct ec_thermal_config thermal_ddr = THERMAL_DDR;
-/*
- * Inductor limits - used for both charger and PP3300 regulator
- *
- * Need to use the lower of the charger IC, PP3300 regulator, and the inductors
- *
- * Charger max recommended temperature 125C, max absolute temperature 150C
- * PP3300 regulator: operating range -40 C to 125 C
- *
- * Inductors: limit of 125c
- * PCB: limit is 80c
- */
-/*
- * TODO(b/202062363): Remove when clang is fixed.
- */
-#define THERMAL_CHARGER \
- { \
- .temp_host = { \
- [EC_TEMP_THRESH_HIGH] = C_TO_K(105), \
- [EC_TEMP_THRESH_HALT] = C_TO_K(120), \
- }, \
- .temp_host_release = { \
- [EC_TEMP_THRESH_HIGH] = C_TO_K(90), \
- }, \
- .temp_fan_off = C_TO_K(35), \
- .temp_fan_max = C_TO_K(65), \
+#define THERMAL_CHARGER \
+ { \
+ .temp_fan_off = C_TO_K(67), .temp_fan_max = C_TO_K(70), \
}
__maybe_unused static const struct ec_thermal_config thermal_charger =
THERMAL_CHARGER;
-/*
- * TODO(b/180681346): update for brya WWAN module
- */
-/*
- * TODO(b/202062363): Remove when clang is fixed.
- */
-#define THERMAL_WWAN \
- { \
- .temp_host = { \
- [EC_TEMP_THRESH_HIGH] = C_TO_K(130), \
- [EC_TEMP_THRESH_HALT] = C_TO_K(130), \
- }, \
- .temp_host_release = { \
- [EC_TEMP_THRESH_HIGH] = C_TO_K(100), \
- }, \
- .temp_fan_off = C_TO_K(35), \
- .temp_fan_max = C_TO_K(60), \
+#define THERMAL_AMBIENT \
+ { \
+ .temp_fan_off = C_TO_K(38), .temp_fan_max = C_TO_K(45), \
}
-__maybe_unused static const struct ec_thermal_config thermal_wwan =
- THERMAL_WWAN;
+__maybe_unused static const struct ec_thermal_config thermal_ambient =
+ THERMAL_AMBIENT;
struct ec_thermal_config thermal_params[] = {
- [TEMP_SENSOR_1_DDR_SOC] = THERMAL_CPU,
- [TEMP_SENSOR_2_AMBIENT] = THERMAL_AMBIENT,
+ [TEMP_SENSOR_1_SOC] = THERMAL_CPU,
+ [TEMP_SENSOR_2_DDR] = THERMAL_DDR,
[TEMP_SENSOR_3_CHARGER] = THERMAL_CHARGER,
- [TEMP_SENSOR_4_WWAN] = THERMAL_WWAN,
+ [TEMP_SENSOR_4_AMBIENT] = THERMAL_AMBIENT,
};
BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
diff --git a/board/crota/usbc_config.c b/board/crota/usbc_config.c
index a06631489f..84b0934dd8 100644
--- a/board/crota/usbc_config.c
+++ b/board/crota/usbc_config.c
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -36,15 +36,11 @@
#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)
#ifdef CONFIG_ZEPHYR
-enum ioex_port {
- IOEX_C0_NCT38XX = 0,
- IOEX_C1_NCT38XX,
- IOEX_PORT_COUNT
-};
+enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_C1_NCT38XX, IOEX_PORT_COUNT };
#endif /* CONFIG_ZEPHYR */
/* USBC TCPC configuration */
@@ -102,40 +98,53 @@ BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == USBC_PORT_COUNT);
unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
/* USBC mux configuration - Alder Lake includes internal mux */
-static const struct usb_mux usbc0_tcss_usb_mux = {
- .usb_port = USBC_PORT_C0,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
+static const struct usb_mux_chain usbc0_tcss_usb_mux = {
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = USBC_PORT_C0,
+ .driver = &virtual_usb_mux_driver,
+ .hpd_update = &virtual_hpd_update,
+ },
};
-static const struct usb_mux usbc1_tcss_usb_mux = {
- .usb_port = USBC_PORT_C1,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
+static const struct usb_mux_chain usbc1_tcss_usb_mux = {
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = USBC_PORT_C1,
+ .driver = &virtual_usb_mux_driver,
+ .hpd_update = &virtual_hpd_update,
+ },
};
-struct usb_mux soc_side_bb_retimer_usb_mux = {
- .usb_port = USBC_PORT_C1,
- .driver = &bb_usb_retimer,
- .hpd_update = bb_retimer_hpd_update,
- .i2c_port = I2C_PORT_USB_C0_C1_MUX,
- .i2c_addr_flags = USBC_PORT_C1_SOC_BB_RETIMER_I2C_ADDR,
- .next_mux = &usbc1_tcss_usb_mux,
+struct usb_mux_chain soc_side_bb_retimer_usb_mux = {
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = USBC_PORT_C1,
+ .driver = &bb_usb_retimer,
+ .hpd_update = bb_retimer_hpd_update,
+ .i2c_port = I2C_PORT_USB_C0_C1_MUX,
+ .i2c_addr_flags = USBC_PORT_C1_SOC_BB_RETIMER_I2C_ADDR,
+ },
+ .next = &usbc1_tcss_usb_mux,
};
-const struct usb_mux usb_muxes[] = {
+const struct usb_mux_chain usb_muxes[] = {
[USBC_PORT_C0] = {
- .usb_port = USBC_PORT_C0,
- .driver = &bb_usb_retimer,
- .hpd_update = bb_retimer_hpd_update,
- .i2c_port = I2C_PORT_USB_C0_C1_MUX,
- .i2c_addr_flags = USBC_PORT_C0_BB_RETIMER_I2C_ADDR,
- .next_mux = &usbc0_tcss_usb_mux,
+ .mux = &(const struct usb_mux) {
+ .usb_port = USBC_PORT_C0,
+ .driver = &bb_usb_retimer,
+ .hpd_update = bb_retimer_hpd_update,
+ .i2c_port = I2C_PORT_USB_C0_C1_MUX,
+ .i2c_addr_flags = USBC_PORT_C0_BB_RETIMER_I2C_ADDR,
+ },
+ .next = &usbc0_tcss_usb_mux,
},
[USBC_PORT_C1] = {
- .usb_port = USBC_PORT_C1,
- .driver = &bb_usb_retimer,
- .hpd_update = bb_retimer_hpd_update,
- .i2c_port = I2C_PORT_USB_C0_C1_MUX,
- .i2c_addr_flags = USBC_PORT_C1_BB_RETIMER_I2C_ADDR,
- .next_mux = &soc_side_bb_retimer_usb_mux,
+ .mux = &(const struct usb_mux) {
+ .usb_port = USBC_PORT_C1,
+ .driver = &bb_usb_retimer,
+ .hpd_update = bb_retimer_hpd_update,
+ .i2c_port = I2C_PORT_USB_C0_C1_MUX,
+ .i2c_addr_flags = USBC_PORT_C1_BB_RETIMER_I2C_ADDR,
+ },
+ .next = &soc_side_bb_retimer_usb_mux,
},
};
BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT);
@@ -204,8 +213,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;
}
diff --git a/board/crota/usbc_config.h b/board/crota/usbc_config.h
index 55134ce79e..63e077ea95 100644
--- a/board/crota/usbc_config.h
+++ b/board/crota/usbc_config.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -9,14 +9,10 @@
#define __CROS_EC_USBC_CONFIG_H
#ifndef CONFIG_ZEPHYR
-#define CONFIG_USB_PD_PORT_MAX_COUNT 2
+#define CONFIG_USB_PD_PORT_MAX_COUNT 2
#endif
-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);