diff options
Diffstat (limited to 'baseboard/volteer/baseboard.c')
-rw-r--r-- | baseboard/volteer/baseboard.c | 143 |
1 files changed, 126 insertions, 17 deletions
diff --git a/baseboard/volteer/baseboard.c b/baseboard/volteer/baseboard.c index 4565822977..703a4e9922 100644 --- a/baseboard/volteer/baseboard.c +++ b/baseboard/volteer/baseboard.c @@ -10,12 +10,16 @@ #include "driver/bc12/pi3usb9201.h" #include "driver/ppc/sn5s330.h" #include "driver/tcpm/tusb422.h" +#include "driver/temp_sensor/thermistor.h" +#include "fan.h" +#include "fan_chip.h" #include "gpio.h" #include "hooks.h" #include "i2c.h" #include "keyboard_scan.h" #include "pwm.h" #include "pwm_chip.h" +#include "temp_sensor.h" #include "usbc_ppc.h" #include "usb_mux.h" #include "usb_pd.h" @@ -167,12 +171,134 @@ const struct pwm_t pwm_channels[] = { .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, .freq = 100, }, + [PWM_CH_FAN] = { + .channel = 5, + .flags = PWM_CONFIG_OPEN_DRAIN, + .freq = 25000 + }, }; BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); +/******************************************************************************/ +/* Physical fans. These are logically separate from pwm_channels. */ +const struct fan_conf fan_conf_0 = { + .flags = FAN_USE_RPM_MODE, + .ch = MFT_CH_0, /* Use MFT id to control fan */ + .pgood_gpio = -1, + .enable_gpio = GPIO_EN_PP5000_FAN, +}; +/* + * Fan specs from datasheet: + * Max speed 5900 rpm (+/- 7%), minimum duty cycle 30%. + * Minimum speed not specified by RPM. Set minimum RPM to max speed (with + * margin) x 30%. + * 5900 x 1.07 x 0.30 = 1894, round up to 1900 + */ +const struct fan_rpm fan_rpm_0 = { + .rpm_min = 1900, + .rpm_start = 1900, + .rpm_max = 5900, +}; + +const struct fan_t fans[FAN_CH_COUNT] = { + [FAN_CH_0] = { + .conf = &fan_conf_0, + .rpm = &fan_rpm_0, + }, +}; + +/******************************************************************************/ +/* MFT channels. These are logically separate from pwm_channels. */ +const struct mft_t mft_channels[] = { + [MFT_CH_0] = { + .module = NPCX_MFT_MODULE_1, + .clk_src = TCKC_LFCLK, + .pwm_id = PWM_CH_FAN, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(mft_channels) == MFT_CH_COUNT); +/******************************************************************************/ +/* Temperature sensor configuration */ +const struct temp_sensor_t temp_sensors[] = { + [TEMP_SENSOR_1_CHARGER] = {.name = "Charger", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_30k9_47k_4050b, + .idx = ADC_TEMP_SENSOR_1_CHARGER, + .action_delay_sec = 1}, + [TEMP_SENSOR_2_PP3300_REGULATOR] = {.name = "PP3300 Regulator", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_30k9_47k_4050b, + .idx = ADC_TEMP_SENSOR_2_PP3300_REGULATOR, + .action_delay_sec = 1}, + [TEMP_SENSOR_3_DDR_SOC] = {.name = "DDR and SOC", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_30k9_47k_4050b, + .idx = ADC_TEMP_SENSOR_3_DDR_SOC, + .action_delay_sec = 1}, + [TEMP_SENSOR_4_FAN] = {.name = "Fan", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_30k9_47k_4050b, + .idx = ADC_TEMP_SENSOR_4_FAN, + .action_delay_sec = 1}, +}; +BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); + +/******************************************************************************/ +/* EC thermal management configuration */ + +/* + * TODO: b/144941023 - revisit thermal limits with each board spin. + */ +/* + * Tiger 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) + */ +const static struct ec_thermal_config thermal_cpu = { + .temp_host = { + [EC_TEMP_THRESH_HIGH] = C_TO_K(70), + [EC_TEMP_THRESH_HALT] = C_TO_K(80), + }, + .temp_host_release = { + [EC_TEMP_THRESH_HIGH] = C_TO_K(65), + }, + .temp_fan_off = C_TO_K(35), + .temp_fan_max = C_TO_K(50), +}; + +/* + * 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: waiting on info from hardware team, assuming 80 C for now + */ +const static struct ec_thermal_config thermal_inductor = { + .temp_host = { + [EC_TEMP_THRESH_HIGH] = C_TO_K(75), + [EC_TEMP_THRESH_HALT] = C_TO_K(80), + }, + .temp_host_release = { + [EC_TEMP_THRESH_HIGH] = C_TO_K(65), + }, + .temp_fan_off = C_TO_K(40), + .temp_fan_max = C_TO_K(55), +}; + + +struct ec_thermal_config thermal_params[] = { + [TEMP_SENSOR_1_CHARGER] = thermal_inductor, + [TEMP_SENSOR_2_PP3300_REGULATOR] = thermal_inductor, + [TEMP_SENSOR_3_DDR_SOC] = thermal_cpu, + [TEMP_SENSOR_4_FAN] = thermal_cpu, +}; +BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT); /******************************************************************************/ /* USBC TCPC configuration */ @@ -342,20 +468,3 @@ void board_overcurrent_event(int port, int is_overcurrented) { /* TODO: b/140561826 - check correct operation for Volteer */ } - -/* - * Enable fan for 100% speed when AP is powered on. - * TODO: b/ remove this once PWM control is working. - */ -static void board_chipset_startup(void) -{ - gpio_set_level_verbose(CC_SYSTEM, GPIO_EN_PP5000_FAN, 1); -} -DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT); - -static void board_chipset_shutdown(void) -{ - gpio_set_level_verbose(CC_SYSTEM, GPIO_EN_PP5000_FAN, 0); -} -DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT); - |