From bff5a49e6d06c13e67b1a72470dc1d9a2326eb16 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Thu, 25 Oct 2012 16:41:00 -0700 Subject: Clean up thermal modules No functional changes. BUG=chrome-os-partner:15579 BRANCH=none TEST='temps' should print good temperatures Change-Id: I20bd2376b86f1e9d2f9a91016ed90bb933235021 Signed-off-by: Randall Spangler Reviewed-on: https://gerrit.chromium.org/gerrit/36611 --- common/temp_sensor.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'common/temp_sensor.c') diff --git a/common/temp_sensor.c b/common/temp_sensor.c index 7f5a5e7a53..ecbe6c0825 100644 --- a/common/temp_sensor.c +++ b/common/temp_sensor.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +/* Copyright (c) 2012 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. */ @@ -20,10 +20,8 @@ #include "tmp006.h" #include "util.h" -/* Defined in board_temp_sensor.c. Must be in the same order as - * in enum temp_sensor_id. - */ -extern const struct temp_sensor_t temp_sensors[TEMP_SENSOR_COUNT]; +/* Default temperature to report in mapped memory */ +#define MAPPED_TEMP_DEFAULT (296 - EC_TEMP_SENSOR_OFFSET) int temp_sensor_read(enum temp_sensor_id id, int *temp_ptr) { @@ -93,17 +91,18 @@ void temp_sensor_task(void) uint8_t *base, *base_b; /* - * Initialize memory-mapped data. We initialize valid sensors to 23 C - * so that if a temperature value is read before we actually poll the - * sensors, we don't end up with an insane value. + * Initialize memory-mapped data so that if a temperature value is read + * before we actually poll the sensors, we don't end up with an insane + * value. */ base = host_get_memmap(EC_MEMMAP_TEMP_SENSOR); base_b = host_get_memmap(EC_MEMMAP_TEMP_SENSOR_B); for (i = 0; i < TEMP_SENSOR_COUNT; ++i) { if (i < EC_TEMP_SENSOR_ENTRIES) - base[i] = 0x60; /* 23 C */ + base[i] = MAPPED_TEMP_DEFAULT; else - base_b[i - EC_TEMP_SENSOR_ENTRIES] = 0x60; /* 23 C */ + base_b[i - EC_TEMP_SENSOR_ENTRIES] = + MAPPED_TEMP_DEFAULT; } /* Set the rest of memory region to SENSOR_NOT_PRESENT */ @@ -163,3 +162,26 @@ DECLARE_CONSOLE_COMMAND(temps, command_temps, NULL, "Print temp sensors", NULL); + +/*****************************************************************************/ +/* Host commands */ + +int temp_sensor_command_get_info(struct host_cmd_handler_args *args) +{ + const struct ec_params_temp_sensor_get_info *p = args->params; + struct ec_response_temp_sensor_get_info *r = args->response; + int id = p->id; + + if (id >= TEMP_SENSOR_COUNT) + return EC_RES_ERROR; + + strzcpy(r->sensor_name, temp_sensors[id].name, sizeof(r->sensor_name)); + r->sensor_type = temp_sensors[id].type; + + args->response_size = sizeof(*r); + + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_TEMP_SENSOR_GET_INFO, + temp_sensor_command_get_info, + EC_VER_MASK(0)); -- cgit v1.2.1