summaryrefslogtreecommitdiff
path: root/board/morphius
diff options
context:
space:
mode:
authorZick Wei <zick.wei@quanta.corp-partner.google.com>2020-07-29 15:31:11 +0800
committerCommit Bot <commit-bot@chromium.org>2020-08-03 22:16:15 +0000
commitce93a01527aa9214b6b023f4543209dd7612b80a (patch)
tree3d8a45c19b236ca3a25e76b0c919d15ca17c6dda /board/morphius
parentbc064edfa739ab1b56ef0873467329f0d0456a94 (diff)
downloadchrome-ec-ce93a01527aa9214b6b023f4543209dd7612b80a.tar.gz
zork: move board_get_temp to variant
This patch rename thermal sensor name by placement for morphius, and move board_get_temp from baseboard to variant BUG=b:162325433 BRANCH=none TEST=verify that thermal sensor name change in EC console Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Change-Id: I46dfe5c8ebef29ed6ee7fdf342cfad9d39fe6ca3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2325496 Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'board/morphius')
-rw-r--r--board/morphius/board.c48
-rw-r--r--board/morphius/board.h6
2 files changed, 43 insertions, 11 deletions
diff --git a/board/morphius/board.c b/board/morphius/board.c
index e5d7f4eb48..a4701cf1b0 100644
--- a/board/morphius/board.c
+++ b/board/morphius/board.c
@@ -35,6 +35,7 @@
#include "system.h"
#include "task.h"
#include "temp_sensor.h"
+#include "thermistor.h"
#include "usb_mux.h"
#include "usb_charge.h"
#include "usbc_ppc.h"
@@ -318,6 +319,38 @@ const struct fan_t fans[] = {
};
BUILD_ASSERT(ARRAY_SIZE(fans) == FAN_CH_COUNT);
+int board_get_temp(int idx, int *temp_k)
+{
+ int mv;
+ int temp_c;
+ enum adc_channel channel;
+
+ /* idx is the sensor index set in board temp_sensors[] */
+ switch (idx) {
+ case TEMP_SENSOR_CHARGER:
+ channel = ADC_TEMP_SENSOR_CHARGER;
+ break;
+
+ case TEMP_SENSOR_5V_REGULATOR:
+ /* thermistor is not powered in G3 */
+ if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
+ return EC_ERROR_NOT_POWERED;
+
+ channel = ADC_TEMP_SENSOR_5V_REGULATOR;
+ break;
+ default:
+ return EC_ERROR_INVAL;
+ }
+
+ mv = adc_read_channel(channel);
+ if (mv < 0)
+ return EC_ERROR_INVAL;
+
+ temp_c = thermistor_linear_interpolate(mv, &thermistor_info);
+ *temp_k = C_TO_K(temp_c);
+ return EC_SUCCESS;
+}
+
const struct adc_t adc_channels[] = {
[ADC_TEMP_SENSOR_CHARGER] = {
.name = "CHARGER",
@@ -326,8 +359,8 @@ const struct adc_t adc_channels[] = {
.factor_div = ADC_READ_MAX + 1,
.shift = 0,
},
- [ADC_TEMP_SENSOR_SOC] = {
- .name = "SOC",
+ [ADC_TEMP_SENSOR_5V_REGULATOR] = {
+ .name = "5V_REGULATOR",
.input_ch = NPCX_ADC_CH3,
.factor_mul = ADC_MAX_VOLT,
.factor_div = ADC_READ_MAX + 1,
@@ -343,11 +376,11 @@ const struct temp_sensor_t temp_sensors[] = {
.read = board_get_temp,
.idx = TEMP_SENSOR_CHARGER,
},
- [TEMP_SENSOR_SOC] = {
- .name = "SOC",
+ [TEMP_SENSOR_5V_REGULATOR] = {
+ .name = "5V_REGULATOR",
.type = TEMP_SENSOR_TYPE_BOARD,
.read = board_get_temp,
- .idx = TEMP_SENSOR_SOC,
+ .idx = TEMP_SENSOR_5V_REGULATOR,
},
[TEMP_SENSOR_CPU] = {
.name = "CPU",
@@ -355,8 +388,8 @@ const struct temp_sensor_t temp_sensors[] = {
.read = sb_tsi_get_val,
.idx = 0,
},
- [TEMP_SENSOR_5V_REGULATOR] = {
- .name = "5V_REGULATOR",
+ [TEMP_SENSOR_SSD] = {
+ .name = "SSD",
.type = TEMP_SENSOR_TYPE_BOARD,
.read = tmp432_get_val,
.idx = TMP432_IDX_LOCAL,
@@ -393,7 +426,6 @@ struct ec_thermal_config thermal_params[TEMP_SENSOR_COUNT];
static void setup_fans(void)
{
thermal_params[TEMP_SENSOR_CHARGER] = thermal_thermistor;
- thermal_params[TEMP_SENSOR_SOC] = thermal_thermistor;
thermal_params[TEMP_SENSOR_CPU] = thermal_cpu;
}
DECLARE_HOOK(HOOK_INIT, setup_fans, HOOK_PRIO_DEFAULT);
diff --git a/board/morphius/board.h b/board/morphius/board.h
index 7b87a3a26f..9679273e5e 100644
--- a/board/morphius/board.h
+++ b/board/morphius/board.h
@@ -76,7 +76,7 @@ void ps2_pwr_en_interrupt(enum gpio_signal signal);
enum adc_channel {
ADC_TEMP_SENSOR_CHARGER,
- ADC_TEMP_SENSOR_SOC,
+ ADC_TEMP_SENSOR_5V_REGULATOR,
ADC_CH_COUNT
};
@@ -102,9 +102,9 @@ enum pwm_channel {
enum temp_sensor_id {
TEMP_SENSOR_CHARGER = 0,
- TEMP_SENSOR_SOC,
- TEMP_SENSOR_CPU,
TEMP_SENSOR_5V_REGULATOR,
+ TEMP_SENSOR_CPU,
+ TEMP_SENSOR_SSD,
TEMP_SENSOR_COUNT
};