summaryrefslogtreecommitdiff
path: root/board/vell/sensors.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/vell/sensors.c')
-rw-r--r--board/vell/sensors.c252
1 files changed, 85 insertions, 167 deletions
diff --git a/board/vell/sensors.c b/board/vell/sensors.c
index 0a4b0198bd..46bc33e492 100644
--- a/board/vell/sensors.c
+++ b/board/vell/sensors.c
@@ -6,8 +6,6 @@
#include "common.h"
#include "accelgyro.h"
#include "adc.h"
-#include "driver/accel_lis2dw12.h"
-#include "driver/accelgyro_lsm6dso.h"
#include "driver/als_tcs3400_public.h"
#include "hooks.h"
#include "motion_sense.h"
@@ -17,56 +15,44 @@
/* ADC configuration */
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_CHARGER] = {
+ .name = "TEMP_CHARGER",
.input_ch = NPCX_ADC_CH1,
.factor_mul = ADC_MAX_VOLT,
.factor_div = ADC_READ_MAX + 1,
.shift = 0,
},
- [ADC_TEMP_SENSOR_3_CHARGER] = {
- .name = "TEMP_CHARGER",
+ [ADC_TEMP_SENSOR_3_WWAN] = {
+ .name = "TEMP_WWAN",
.input_ch = NPCX_ADC_CH6,
.factor_mul = ADC_MAX_VOLT,
.factor_div = ADC_READ_MAX + 1,
.shift = 0,
},
- [ADC_TEMP_SENSOR_4_WWAN] = {
- .name = "TEMP_WWAN",
+ [ADC_TEMP_SENSOR_4_DDR] = {
+ .name = "TEMP_DDR",
.input_ch = NPCX_ADC_CH7,
.factor_mul = ADC_MAX_VOLT,
.factor_div = ADC_READ_MAX + 1,
.shift = 0,
},
+ [ADC_TEMP_SENSOR_5_REGULATOR] = {
+ .name = "TEMP_REGULATOR",
+ .input_ch = NPCX_ADC_CH4,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ },
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
-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;
-
-/* TODO(b/184779333): calibrate the orientation matrix on later board stage */
-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)}
-};
-
-/* 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)}
-};
-
/* TCS3400 private data */
static struct als_drv_data_t g_tcs3400_data = {
.als_cal.scale = 1,
@@ -122,85 +108,6 @@ static struct tcs3400_rgb_drv_data_t g_tcs3400_rgb_data = {
};
struct motion_sensor_t motion_sensors[] = {
- [LID_ACCEL] = {
- .name = "Lid Accel",
- .active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_LIS2DW12,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &lis2dw12_drv,
- .mutex = &g_lid_accel_mutex,
- .drv_data = &g_lis2dw12_data,
- .int_signal = GPIO_EC_ACCEL_INT_R_L,
- .port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = LIS2DW12_ADDR0,
- .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
- .rot_standard_ref = &lid_standard_ref, /* identity matrix */
- .default_range = 2, /* g */
- .min_frequency = LIS2DW12_ODR_MIN_VAL,
- .max_frequency = LIS2DW12_ODR_MAX_VAL,
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
- },
- /* Sensor on for lid angle detection */
- [SENSOR_CONFIG_EC_S3] = {
- .odr = 10000 | ROUND_UP_FLAG,
- },
- },
- },
-
- [BASE_ACCEL] = {
- .name = "Base Accel",
- .active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_LSM6DSO,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &lsm6dso_drv,
- .mutex = &g_base_accel_mutex,
- .drv_data = LSM6DSO_ST_DATA(lsm6dso_data,
- MOTIONSENSE_TYPE_ACCEL),
- .int_signal = GPIO_EC_IMU_INT_R_L,
- .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
- .port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = LSM6DSO_ADDR0_FLAGS,
- .rot_standard_ref = &base_standard_ref,
- .default_range = 4, /* g */
- .min_frequency = LSM6DSO_ODR_MIN_VAL,
- .max_frequency = LSM6DSO_ODR_MAX_VAL,
- .config = {
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 13000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
- },
- [SENSOR_CONFIG_EC_S3] = {
- .odr = 10000 | ROUND_UP_FLAG,
- .ec_rate = 100 * MSEC,
- },
- },
- },
-
- [BASE_GYRO] = {
- .name = "Base Gyro",
- .active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_LSM6DSO,
- .type = MOTIONSENSE_TYPE_GYRO,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &lsm6dso_drv,
- .mutex = &g_base_accel_mutex,
- .drv_data = LSM6DSO_ST_DATA(lsm6dso_data,
- MOTIONSENSE_TYPE_GYRO),
- .int_signal = GPIO_EC_IMU_INT_R_L,
- .flags = MOTIONSENSE_FLAG_INT_SIGNAL,
- .port = I2C_PORT_SENSOR,
- .i2c_spi_addr_flags = LSM6DSO_ADDR0_FLAGS,
- .default_range = 1000 | ROUND_UP_FLAG, /* dps */
- .rot_standard_ref = &base_standard_ref,
- .min_frequency = LSM6DSO_ODR_MIN_VAL,
- .max_frequency = LSM6DSO_ODR_MAX_VAL,
- },
-
[CLEAR_ALS] = {
.name = "Clear Light",
.active_mask = SENSOR_ACTIVE_S0_S3,
@@ -249,46 +156,48 @@ BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT);
static void baseboard_sensors_init(void)
{
- /* Enable gpio interrupt for lid accel sensor */
- gpio_enable_interrupt(GPIO_EC_ACCEL_INT_R_L);
/* Enable interrupt for the TCS3400 color light sensor */
gpio_enable_interrupt(GPIO_EC_ALS_RGB_INT_R_L);
- /* Enable gpio interrupt for base accelgyro sensor */
- gpio_enable_interrupt(GPIO_EC_IMU_INT_R_L);
}
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_CHARGER] = {
+ .name = "Charger",
.type = TEMP_SENSOR_TYPE_BOARD,
.read = get_temp_3v3_30k9_47k_4050b,
- .idx = ADC_TEMP_SENSOR_2_AMBIENT,
+ .idx = ADC_TEMP_SENSOR_2_CHARGER,
},
- [TEMP_SENSOR_3_CHARGER] = {
- .name = "Charger",
+ [TEMP_SENSOR_3_WWAN] = {
+ .name = "WWAN",
.type = TEMP_SENSOR_TYPE_BOARD,
.read = get_temp_3v3_30k9_47k_4050b,
- .idx = ADC_TEMP_SENSOR_3_CHARGER,
+ .idx = ADC_TEMP_SENSOR_3_WWAN,
},
- [TEMP_SENSOR_4_WWAN] = {
- .name = "WWAN",
+ [TEMP_SENSOR_4_DDR] = {
+ .name = "DDR",
.type = TEMP_SENSOR_TYPE_BOARD,
.read = get_temp_3v3_30k9_47k_4050b,
- .idx = ADC_TEMP_SENSOR_4_WWAN,
+ .idx = ADC_TEMP_SENSOR_4_DDR,
+ },
+ [TEMP_SENSOR_5_REGULATOR] = {
+ .name = "Regulator",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_5_REGULATOR,
},
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
/*
- * TODO(b/180681346): update for Alder Lake/brya
+ * TODO(b/203839956): update for Alder Lake/vell
*
* 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
@@ -312,17 +221,7 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
__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/203839956): update for Alder Lake/vell
*/
/*
* TODO(b/202062363): Remove when clang is fixed.
@@ -343,15 +242,7 @@ __maybe_unused static const struct ec_thermal_config thermal_ambient =
THERMAL_AMBIENT;
/*
- * 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/203839956): update for Alder Lake/vell
*/
/*
* TODO(b/202062363): Remove when clang is fixed.
@@ -372,7 +263,7 @@ __maybe_unused static const struct ec_thermal_config thermal_charger =
THERMAL_CHARGER;
/*
- * TODO(b/180681346): update for brya WWAN module
+ * TODO(b/203839956): update for vell WWAN module
*/
/*
* TODO(b/202062363): Remove when clang is fixed.
@@ -392,27 +283,54 @@ __maybe_unused static const struct ec_thermal_config thermal_charger =
__maybe_unused static const struct ec_thermal_config thermal_wwan =
THERMAL_WWAN;
-struct ec_thermal_config thermal_params[] = {
- [TEMP_SENSOR_1_DDR_SOC] = THERMAL_CPU,
- [TEMP_SENSOR_2_AMBIENT] = THERMAL_AMBIENT,
- [TEMP_SENSOR_3_CHARGER] = THERMAL_CHARGER,
- [TEMP_SENSOR_4_WWAN] = THERMAL_WWAN,
-};
-BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
+/*
+ * TODO(b/203839956): update for Alder Lake/vell
+ */
+/*
+ * TODO(b/202062363): Remove when clang is fixed.
+ */
-static void board_thermals_init(void)
-{
- if (get_board_id() == 1) {
- /*
- * Board ID 1 only has 3 sensors and the AMBIENT sensor
- * ADC pins have been reassigned, so we're down to 2
- * sensors that can easily be configured. So, alias the
- * AMBIENT sensor ADC channel to the unimplemented ADC
- * slots.
- */
- adc_channels[ADC_TEMP_SENSOR_3_CHARGER].input_ch = NPCX_ADC_CH1;
- adc_channels[ADC_TEMP_SENSOR_4_WWAN].input_ch = NPCX_ADC_CH1;
+#define THERMAL_DDR \
+ { \
+ .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), \
}
-}
+__maybe_unused static const struct ec_thermal_config thermal_ddr =
+ THERMAL_DDR;
+
+/*
+ * TODO(b/203839956): update for Alder Lake/vell
+ */
+/*
+ * TODO(b/202062363): Remove when clang is fixed.
+ */
+
+#define THERMAL_REGULATOR \
+ { \
+ .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), \
+ }
+__maybe_unused static const struct ec_thermal_config thermal_regulator =
+ THERMAL_REGULATOR;
-DECLARE_HOOK(HOOK_INIT, board_thermals_init, HOOK_PRIO_INIT_CHIPSET);
+struct ec_thermal_config thermal_params[] = {
+ [TEMP_SENSOR_1_SOC] = thermal_cpu,
+ [TEMP_SENSOR_2_CHARGER] = thermal_charger,
+ [TEMP_SENSOR_3_WWAN] = thermal_wwan,
+ [TEMP_SENSOR_4_DDR] = thermal_ddr,
+ [TEMP_SENSOR_5_REGULATOR] = thermal_regulator,
+};