summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2019-11-22 16:56:56 -0700
committerCommit Bot <commit-bot@chromium.org>2019-12-04 00:02:47 +0000
commita1f2cfe2146c818be848876a24415a72ad36933c (patch)
treed87d5883382e123154fe38675b4e0c885117f168
parent4e8dbf5c9b1dee8e6ee1734af58f2ba204045e5c (diff)
downloadchrome-ec-a1f2cfe2146c818be848876a24415a72ad36933c.tar.gz
volteer: enable thermal management
Configure fan for PWM operation. Enable thermal management policies. BUG=b:143768086 BRANCH=none TEST=make buildall TEST=use 'thermalset' to force high and halt temperature conditions, verify AP is alerted and halted Change-Id: I6362ce9d5a0edbd231e3f9464dfccf34d4f1c7a0 Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1946774 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--baseboard/volteer/baseboard.c143
-rw-r--r--baseboard/volteer/baseboard.h29
-rw-r--r--board/volteer/gpio.inc7
3 files changed, 160 insertions, 19 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);
-
diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h
index cd0569fc4a..41eb887d4e 100644
--- a/baseboard/volteer/baseboard.h
+++ b/baseboard/volteer/baseboard.h
@@ -60,6 +60,14 @@
/* Sensors */
+/* Thermal features */
+#define CONFIG_FANS FAN_CH_COUNT
+#define CONFIG_TEMP_SENSOR
+#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_EN_PP3300_A
+#define CONFIG_THERMISTOR
+#define CONFIG_STEINHART_HART_3V3_30K9_47K_4050B
+#define CONFIG_THROTTLE_AP
+
/* Common charger defines */
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGER
@@ -170,9 +178,30 @@ enum pwm_channel {
PWM_CH_LED1_BLUE = 0,
PWM_CH_LED2_GREEN,
PWM_CH_LED3_RED,
+ PWM_CH_FAN,
PWM_CH_COUNT
};
+enum fan_channel {
+ FAN_CH_0 = 0,
+ /* Number of FAN channels */
+ FAN_CH_COUNT,
+};
+
+enum mft_channel {
+ MFT_CH_0 = 0,
+ /* Number of MFT channels */
+ MFT_CH_COUNT,
+};
+
+enum temp_sensor_id {
+ TEMP_SENSOR_1_CHARGER,
+ TEMP_SENSOR_2_PP3300_REGULATOR,
+ TEMP_SENSOR_3_DDR_SOC,
+ TEMP_SENSOR_4_FAN,
+ TEMP_SENSOR_COUNT
+};
+
enum usbc_port {
USBC_PORT_C0 = 0,
USBC_PORT_COUNT
diff --git a/board/volteer/gpio.inc b/board/volteer/gpio.inc
index 3e6042b4b8..a098509fe2 100644
--- a/board/volteer/gpio.inc
+++ b/board/volteer/gpio.inc
@@ -91,8 +91,6 @@ GPIO(EN_PP3300_AG, PIN(8, 5), GPIO_OUT_LOW)
* default. */
GPIO(LED_SIDESEL_4_L, PIN(6, 0), GPIO_OUT_LOW)
-GPIO(EN_PP5000_FAN, PIN(6, 1), GPIO_OUT_LOW)
-
/*
* eDP backlight - both PCH and EC have enable pins that must be high
* for the backlight to turn on. Default state is high, and can be turned
@@ -131,6 +129,11 @@ ALTERNATE(PIN_MASK(B, BIT(3) | BIT(2)), 0, MODULE_I2C, 0)
ALTERNATE(PIN_MASK(C, BIT(2) | BIT(3) | BIT(4)), 0, MODULE_PWM, 0) /* LED{3,2,1}_L */
+/* Fan signals */
+GPIO(EN_PP5000_FAN, PIN(6, 1), GPIO_OUT_LOW)
+ALTERNATE(PIN_MASK(B, BIT(7)), 0, MODULE_PWM, 0) /* FAN_PWM */
+ALTERNATE(PIN_MASK(4, BIT(0)), 0, MODULE_PWM, 0) /* FAN_SPEED_TACH */
+
/* Keyboard pins */
#define GPIO_KB_INPUT (GPIO_INPUT | GPIO_PULL_UP)
ALTERNATE(PIN_MASK(3, 0x03), 0, MODULE_KEYBOARD_SCAN, GPIO_KB_INPUT) /* KSI_00-01 */