summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2019-11-01 11:30:41 +1100
committerCommit Bot <commit-bot@chromium.org>2019-11-04 02:26:53 +0000
commite7599590e8e5b7510f9a1b0a76665fc753828070 (patch)
treea7e4351219cb6beedad06f0b7510d8cba36b91f3
parent511a810662b1133860737381103810b33cc96592 (diff)
downloadchrome-ec-e7599590e8e5b7510f9a1b0a76665fc753828070.tar.gz
puff: populate ADCs and temperature sensors
Several analog channels are needed for power sequencing, and may as well fill them all in while we're here. BUG=b:143188569 TEST=image builds and links BRANCH=None Change-Id: I99c2def362b11bef0748adfe11cc7356bb1591c6 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1893016 Reviewed-by: Andrew McRae <amcrae@chromium.org>
-rw-r--r--board/puff/board.c95
-rw-r--r--board/puff/board.h15
2 files changed, 90 insertions, 20 deletions
diff --git a/board/puff/board.c b/board/puff/board.c
index 32be3628de..caee044003 100644
--- a/board/puff/board.c
+++ b/board/puff/board.c
@@ -72,6 +72,64 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+const struct adc_t adc_channels[] = {
+ [ADC_SNS_PP3300] = { /* 9/11 voltage divider */
+ .name = "SNS_PP3300",
+ .input_ch = NPCX_ADC_CH2,
+ .factor_mul = ADC_MAX_VOLT * 11,
+ .factor_div = (ADC_READ_MAX + 1) * 9,
+ },
+ [ADC_SNS_PP1050] = {
+ .name = "SNS_PP1050",
+ .input_ch = NPCX_ADC_CH7,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ },
+ [ADC_VBUS] = { /* 5/39 voltage divider */
+ .name = "VBUS",
+ .input_ch = NPCX_ADC_CH4,
+ .factor_mul = ADC_MAX_VOLT * 39,
+ .factor_div = (ADC_READ_MAX + 1) / 5,
+ },
+ [ADC_PPVAR_IMON] = { /* 500 mV/A */
+ .name = "PPVAR_IMON",
+ .input_ch = NPCX_ADC_CH9,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ },
+ [ADC_TEMP_SENSOR_1] = {
+ .name = "TEMP_SENSOR_1",
+ .input_ch = NPCX_ADC_CH0,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ },
+ [ADC_TEMP_SENSOR_2] = {
+ .name = "TEMP_SENSOR_2",
+ .input_ch = NPCX_ADC_CH1,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+
+const struct temp_sensor_t temp_sensors[] = {
+ [TEMP_SENSOR_PP3300] = {
+ .name = "PP3300",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_1,
+ .action_delay_sec = 1,
+ },
+ [TEMP_SENSOR_PP5000] = {
+ .name = "PP5000",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_2,
+ .action_delay_sec = 1,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
+
/******************************************************************************/
/* Wake up pins */
const enum gpio_signal hibernate_wake_pins[] = {
@@ -79,7 +137,7 @@ const enum gpio_signal hibernate_wake_pins[] = {
const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
/******************************************************************************/
-/* Physical fan. This are logically separate from pwm_channels. */
+/* 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 */
@@ -105,28 +163,31 @@ const struct mft_t mft_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(mft_channels) == MFT_CH_COUNT);
-/* ADC channels */
-const struct adc_t adc_channels[] = {
- [ADC_VBUS] = {
- "VBUS", NPCX_ADC_CH4, ADC_MAX_VOLT, ADC_READ_MAX+1, 0},
+/******************************************************************************/
+/* Thermal control; drive fan based on temperature sensors. */
+const static struct ec_thermal_config thermal_a = {
+ .temp_host = {
+ [EC_TEMP_THRESH_WARN] = 0,
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(75),
+ [EC_TEMP_THRESH_HALT] = C_TO_K(80),
+ },
+ .temp_host_release = {
+ [EC_TEMP_THRESH_WARN] = 0,
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(65),
+ [EC_TEMP_THRESH_HALT] = 0,
+ },
+ .temp_fan_off = C_TO_K(25),
+ .temp_fan_max = C_TO_K(50),
};
-BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
-const struct temp_sensor_t temp_sensors[] = {
+struct ec_thermal_config thermal_params[] = {
+ [TEMP_SENSOR_PP3300] = thermal_a,
+ [TEMP_SENSOR_PP5000] = thermal_a,
};
-BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
-
-
-struct ec_thermal_config thermal_params[TEMP_SENSOR_COUNT];
-
-static void setup_fans(void)
-{
-}
+BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
static void board_init(void)
{
- /* Initialize Fans */
- setup_fans();
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
diff --git a/board/puff/board.h b/board/puff/board.h
index 7a6ea0848e..1f4c25dd60 100644
--- a/board/puff/board.h
+++ b/board/puff/board.h
@@ -116,6 +116,7 @@
/* #define CONFIG_DPTF */
#undef CONFIG_FAN_INIT_SPEED
#define CONFIG_FAN_INIT_SPEED 50
+#define CONFIG_TEMP_SENSOR
#define CONFIG_THERMISTOR
#define CONFIG_STEINHART_HART_3V3_30K9_47K_4050B
#define CONFIG_THROTTLE_AP
@@ -169,7 +170,13 @@
#include "registers.h"
enum adc_channel {
- ADC_VBUS,
+ ADC_SNS_PP3300, /* ADC2 */
+ ADC_SNS_PP1050, /* ADC7 */
+ ADC_VBUS, /* ADC4 */
+ ADC_PPVAR_IMON, /* ADC9 */
+ ADC_TEMP_SENSOR_1, /* ADC0 */
+ ADC_TEMP_SENSOR_2, /* ADC1 */
+ /* Number of ADC channels */
ADC_CH_COUNT
};
@@ -184,16 +191,18 @@ enum pwm_channel {
enum fan_channel {
FAN_CH_0,
/* Number of FAN channels */
- FAN_CH_COUNT
+ FAN_CH_COUNT
};
enum mft_channel {
MFT_CH_0 = 0,
/* Number of MFT channels */
- MFT_CH_COUNT,
+ MFT_CH_COUNT,
};
enum temp_sensor_id {
+ TEMP_SENSOR_PP3300,
+ TEMP_SENSOR_PP5000,
TEMP_SENSOR_COUNT
};