diff options
-rw-r--r-- | board/rambi/board.c | 3 | ||||
-rw-r--r-- | board/rambi/board.h | 3 | ||||
-rw-r--r-- | common/charge_state.c | 11 | ||||
-rw-r--r-- | include/charge_state.h | 11 | ||||
-rw-r--r-- | include/temp_sensor.h | 2 |
5 files changed, 30 insertions, 0 deletions
diff --git a/board/rambi/board.c b/board/rambi/board.c index cdef1c11b1..d4497d9901 100644 --- a/board/rambi/board.c +++ b/board/rambi/board.c @@ -7,6 +7,7 @@ #include "adc.h" #include "adc_chip.h" #include "backlight.h" +#include "charge_state.h" #include "charger.h" #include "common.h" #include "driver/temp_sensor/tmp432.h" @@ -185,6 +186,7 @@ const struct temp_sensor_t temp_sensors[] = { TMP432_IDX_REMOTE1, 4}, {"TMP432_CPU_bottom", TEMP_SENSOR_TYPE_BOARD, tmp432_get_val, TMP432_IDX_REMOTE2, 4}, + {"Battery", TEMP_SENSOR_TYPE_BATTERY, charge_temp_sensor_get_val, 0, 4}, }; BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); @@ -196,6 +198,7 @@ struct ec_thermal_config thermal_params[] = { {{0, 0, 0}, 0, 0}, {{0, 0, 0}, 0, 0}, {{0, 0, 0}, 0, 0}, + {{0, 0, 0}, 0, 0}, }; BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT); diff --git a/board/rambi/board.h b/board/rambi/board.h index 95736b2e09..091c9d9d04 100644 --- a/board/rambi/board.h +++ b/board/rambi/board.h @@ -179,6 +179,9 @@ enum temp_sensor_id { TEMP_SENSOR_I2C_TMP432_REMOTE1, TEMP_SENSOR_I2C_TMP432_REMOTE2, + /* Battery temperature sensor */ + TEMP_SENSOR_BATTERY, + TEMP_SENSOR_COUNT }; diff --git a/common/charge_state.c b/common/charge_state.c index 16bb69b428..53c1dda5d2 100644 --- a/common/charge_state.c +++ b/common/charge_state.c @@ -664,6 +664,17 @@ int charge_get_percent(void) return task_ctx.curr.batt.state_of_charge; } +int charge_temp_sensor_get_val(int idx, int *temp_ptr) +{ + const struct batt_params *batt = &task_ctx.curr.batt; + + if (!(batt->flags & BATT_FLAG_RESPONSIVE)) + return EC_ERROR_UNKNOWN; + + *temp_ptr = C_TO_K(DECI_KELVIN_TO_CELSIUS(batt->temperature)); + return EC_SUCCESS; +} + int charge_want_shutdown(void) { return (charge_get_state() == PWR_STATE_DISCHARGE) && diff --git a/include/charge_state.h b/include/charge_state.h index 7aaf77b93d..152e767295 100644 --- a/include/charge_state.h +++ b/include/charge_state.h @@ -143,5 +143,16 @@ int charge_want_shutdown(void); #else static inline int charge_want_shutdown(void) { return 0; } #endif + +/** + * Get the last polled battery/charger temperature. + * + * @param idx Sensor index to read. + * @param temp_ptr Destination for temperature in K. + * + * @return EC_SUCCESS if successful, non-zero if error. + */ +int charge_temp_sensor_get_val(int idx, int *temp_ptr); + #endif /* __CROS_EC_CHARGE_STATE_H */ diff --git a/include/temp_sensor.h b/include/temp_sensor.h index cd1b80d892..61f218d5d7 100644 --- a/include/temp_sensor.h +++ b/include/temp_sensor.h @@ -23,6 +23,8 @@ enum temp_sensor_type { TEMP_SENSOR_TYPE_BOARD, /* Case temperature sensors. */ TEMP_SENSOR_TYPE_CASE, + /* Battery temperature sensors. */ + TEMP_SENSOR_TYPE_BATTERY, TEMP_SENSOR_TYPE_COUNT }; |