diff options
author | Jett Rink <jettrink@chromium.org> | 2018-06-12 15:18:35 -0600 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-06-15 10:56:44 -0700 |
commit | 35ae76ab7060364a2e343b59d58ec86d8e06990b (patch) | |
tree | 58bbfc4f782a39b07cd7eb21eba2e3d4871399e5 /board/coral | |
parent | 33581f7a5f4c657b94b254537671ffe0a6fe6bd2 (diff) | |
download | chrome-ec-35ae76ab7060364a2e343b59d58ec86d8e06990b.tar.gz |
thermistor: move thermistor tables into common code
The exact same 2 lookup tables are in multiple board files. We seem to
reuse the 2 thermistor circuit enough that we should single source them
in a common location.
BRANCH=none
BUG=none
TEST=yorp sensors still function properly
Change-Id: Ic393c609c78c8a51c55a67b639c1fb9e6c387d8a
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1100943
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Justin TerAvest <teravest@chromium.org>
Diffstat (limited to 'board/coral')
-rw-r--r-- | board/coral/board.c | 99 | ||||
-rw-r--r-- | board/coral/board.h | 2 |
2 files changed, 17 insertions, 84 deletions
diff --git a/board/coral/board.c b/board/coral/board.c index 3854e56f28..bc37b92d13 100644 --- a/board/coral/board.c +++ b/board/coral/board.c @@ -412,92 +412,23 @@ static void board_tcpc_init(void) } DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_DEFAULT); -/* - * Data derived from Seinhart-Hart equation in a resistor divider circuit with - * Vdd=3300mV, R = 13.7Kohm, and Murata NCP15WB-series thermistor (B = 4050, - * T0 = 298.15, nominal resistance (R0) = 47Kohm). - */ -#define CHARGER_THERMISTOR_SCALING_FACTOR 13 -static const struct thermistor_data_pair charger_thermistor_data[] = { - { 3044 / CHARGER_THERMISTOR_SCALING_FACTOR, 0 }, - { 2890 / CHARGER_THERMISTOR_SCALING_FACTOR, 10 }, - { 2680 / CHARGER_THERMISTOR_SCALING_FACTOR, 20 }, - { 2418 / CHARGER_THERMISTOR_SCALING_FACTOR, 30 }, - { 2117 / CHARGER_THERMISTOR_SCALING_FACTOR, 40 }, - { 1800 / CHARGER_THERMISTOR_SCALING_FACTOR, 50 }, - { 1490 / CHARGER_THERMISTOR_SCALING_FACTOR, 60 }, - { 1208 / CHARGER_THERMISTOR_SCALING_FACTOR, 70 }, - { 966 / CHARGER_THERMISTOR_SCALING_FACTOR, 80 }, - { 860 / CHARGER_THERMISTOR_SCALING_FACTOR, 85 }, - { 766 / CHARGER_THERMISTOR_SCALING_FACTOR, 90 }, - { 679 / CHARGER_THERMISTOR_SCALING_FACTOR, 95 }, - { 603 / CHARGER_THERMISTOR_SCALING_FACTOR, 100 }, -}; - -static const struct thermistor_info charger_thermistor_info = { - .scaling_factor = CHARGER_THERMISTOR_SCALING_FACTOR, - .num_pairs = ARRAY_SIZE(charger_thermistor_data), - .data = charger_thermistor_data, -}; - -int board_get_charger_temp(int idx, int *temp_ptr) -{ - int mv = adc_read_channel(NPCX_ADC_CH0); - - if (mv < 0) - return -1; - - *temp_ptr = thermistor_linear_interpolate(mv, &charger_thermistor_info); - *temp_ptr = C_TO_K(*temp_ptr); - return 0; -} - -/* - * Data derived from Seinhart-Hart equation in a resistor divider circuit with - * Vdd=3300mV, R = 51.1Kohm, and Murata NCP15WB-series thermistor (B = 4050, - * T0 = 298.15, nominal resistance (R0) = 47Kohm). - */ -#define AMB_THERMISTOR_SCALING_FACTOR 11 -static const struct thermistor_data_pair amb_thermistor_data[] = { - { 2512 / AMB_THERMISTOR_SCALING_FACTOR, 0 }, - { 2158 / AMB_THERMISTOR_SCALING_FACTOR, 10 }, - { 1772 / AMB_THERMISTOR_SCALING_FACTOR, 20 }, - { 1398 / AMB_THERMISTOR_SCALING_FACTOR, 30 }, - { 1070 / AMB_THERMISTOR_SCALING_FACTOR, 40 }, - { 803 / AMB_THERMISTOR_SCALING_FACTOR, 50 }, - { 597 / AMB_THERMISTOR_SCALING_FACTOR, 60 }, - { 443 / AMB_THERMISTOR_SCALING_FACTOR, 70 }, - { 329 / AMB_THERMISTOR_SCALING_FACTOR, 80 }, - { 285 / AMB_THERMISTOR_SCALING_FACTOR, 85 }, - { 247 / AMB_THERMISTOR_SCALING_FACTOR, 90 }, - { 214 / AMB_THERMISTOR_SCALING_FACTOR, 95 }, - { 187 / AMB_THERMISTOR_SCALING_FACTOR, 100 }, -}; - -static const struct thermistor_info amb_thermistor_info = { - .scaling_factor = AMB_THERMISTOR_SCALING_FACTOR, - .num_pairs = ARRAY_SIZE(amb_thermistor_data), - .data = amb_thermistor_data, -}; - -int board_get_ambient_temp(int idx, int *temp_ptr) -{ - int mv = adc_read_channel(NPCX_ADC_CH1); - - if (mv < 0) - return -1; - - *temp_ptr = thermistor_linear_interpolate(mv, &amb_thermistor_info); - *temp_ptr = C_TO_K(*temp_ptr); - return 0; -} - - const struct temp_sensor_t temp_sensors[] = { /* FIXME(dhendrix): tweak action_delay_sec */ - {"Battery", TEMP_SENSOR_TYPE_BATTERY, charge_get_battery_temp, 0, 1}, - {"Ambient", TEMP_SENSOR_TYPE_BOARD, board_get_ambient_temp, 0, 5}, - {"Charger", TEMP_SENSOR_TYPE_BOARD, board_get_charger_temp, 1, 1}, + [TEMP_SENSOR_BATTERY] = {.name = "Battery", + .type = TEMP_SENSOR_TYPE_BATTERY, + .read = charge_get_battery_temp, + .idx = 0, + .action_delay_sec = 1}, + [TEMP_SENSOR_AMBIENT] = {.name = "Ambient", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_51k1_47k_4050b, + .idx = ADC_TEMP_SENSOR_AMB, + .action_delay_sec = 5}, + [TEMP_SENSOR_CHARGER] = {.name = "Charger", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_13k7_47k_4050b, + .idx = ADC_TEMP_SENSOR_CHARGER, + .action_delay_sec = 1}, }; BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); diff --git a/board/coral/board.h b/board/coral/board.h index e392ac38a6..09f9dca66a 100644 --- a/board/coral/board.h +++ b/board/coral/board.h @@ -137,6 +137,8 @@ #define CONFIG_PWM_KBLIGHT #define CONFIG_TEMP_SENSOR #define CONFIG_THERMISTOR_NCP15WB +#define CONFIG_STEINHART_HART_3V3_13K7_47K_4050B +#define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B #define CONFIG_DPTF #define CONFIG_DPTF_DEVICE_ORIENTATION #define CONFIG_SCI_GPIO GPIO_PCH_SCI_L |