diff options
-rw-r--r-- | board/brya/board.h | 19 | ||||
-rw-r--r-- | board/brya/build.mk | 1 | ||||
-rw-r--r-- | board/brya/sensors.c | 46 |
3 files changed, 65 insertions, 1 deletions
diff --git a/board/brya/board.h b/board/brya/board.h index 4a603df8ee..d5e1b23d70 100644 --- a/board/brya/board.h +++ b/board/brya/board.h @@ -14,7 +14,6 @@ /* * Disable features enabled by default. */ -#undef CONFIG_ADC #undef CONFIG_HIBERNATE #undef CONFIG_SPI_FLASH #undef CONFIG_SWITCH @@ -71,11 +70,29 @@ #define I2C_PORT_CHARGER NPCX_I2C_PORT7_0 #define I2C_PORT_EEPROM NPCX_I2C_PORT7_0 +/* Thermal features */ +#define CONFIG_THERMISTOR +#define CONFIG_TEMP_SENSOR +#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_SEQ_EC_DSW_PWROK +#define CONFIG_STEINHART_HART_3V3_30K9_47K_4050B + #ifndef __ASSEMBLER__ #include "gpio_signal.h" /* needed by registers.h */ #include "registers.h" +enum adc_channel { + ADC_TEMP_SENSOR_1_DDR_SOC, + ADC_TEMP_SENSOR_2_CHARGER, + ADC_CH_COUNT +}; + +enum temp_sensor_id { + TEMP_SENSOR_1_DDR_SOC, + TEMP_SENSOR_2_CHARGER, + TEMP_SENSOR_COUNT +}; + enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_C2_NCT38XX, diff --git a/board/brya/build.mk b/board/brya/build.mk index ce658b6e2f..bfe748269e 100644 --- a/board/brya/build.mk +++ b/board/brya/build.mk @@ -17,4 +17,5 @@ board-y+=board.o board-y+=fans.o board-y+=i2c.o board-y+=pwm.o +board-y+=sensors.o board-y+=usbc_config.o diff --git a/board/brya/sensors.c b/board/brya/sensors.c new file mode 100644 index 0000000000..bb51eb245b --- /dev/null +++ b/board/brya/sensors.c @@ -0,0 +1,46 @@ +/* Copyright 2021 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" + +#include "adc_chip.h" +#include "temp_sensor.h" +#include "thermistor.h" + +/* ADC configuration */ +const struct adc_t adc_channels[] = { + [ADC_TEMP_SENSOR_1_DDR_SOC] = { + .name = "TEMP_DDR_SOC", + .input_ch = NPCX_ADC_CH0, + .factor_mul = ADC_MAX_VOLT, + .factor_div = ADC_READ_MAX + 1, + .shift = 0, + }, + [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, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); + +/* Temperature sensor configuration */ +const struct temp_sensor_t temp_sensors[] = { + [TEMP_SENSOR_1_DDR_SOC] = { + .name = "DDR and SOC", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_30k9_47k_4050b, + .idx = ADC_TEMP_SENSOR_1_DDR_SOC + }, + [TEMP_SENSOR_2_CHARGER] = { + .name = "Charger", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_30k9_47k_4050b, + .idx = ADC_TEMP_SENSOR_2_CHARGER + }, +}; +BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); |