mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-03 13:39:53 +00:00
We'd defined them in a number of different files. This moves definitions to timer.h, and uses them everywhere we have large delays (since 10*SECOND is less typo-prone than 10000000). Also add msleep() and sleep() inline functions. No need for mdelay() or delay(), since any delays that long should use sleep funcs instead of spin-waiting. BUG=chrome-os-partner:15579 BRANCH=none TEST=boot system; taskinfo displays similar numbers to before Change-Id: I2a92a9f10f46b6b7b6571759b1f8ab4ecfbf8259 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36726
83 lines
1.7 KiB
C
83 lines
1.7 KiB
C
/* 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.
|
|
*/
|
|
|
|
/* Mock temperature sensor module for Chrome EC */
|
|
|
|
#include "common.h"
|
|
#include "console.h"
|
|
#include "temp_sensor.h"
|
|
#include "timer.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];
|
|
|
|
static int temp_val[TEMP_SENSOR_TYPE_COUNT];
|
|
|
|
int temp_sensor_powered(enum temp_sensor_id id)
|
|
{
|
|
/* Always powered */
|
|
return 1;
|
|
}
|
|
|
|
|
|
int temp_sensor_read(enum temp_sensor_id id)
|
|
{
|
|
return temp_val[temp_sensors[id].type];
|
|
}
|
|
|
|
|
|
void temp_sensor_task(void)
|
|
{
|
|
/* Do nothing */
|
|
while (1)
|
|
sleep(5);
|
|
}
|
|
|
|
|
|
static int command_set_temp(int argc, char **argv, int type)
|
|
{
|
|
char *e;
|
|
int t;
|
|
|
|
ASSERT(argc == 2);
|
|
t = strtoi(argv[1], &e, 0);
|
|
temp_val[type] = t;
|
|
return EC_SUCCESS;
|
|
}
|
|
|
|
|
|
static int command_set_cpu_temp(int argc, char **argv)
|
|
{
|
|
return command_set_temp(argc, argv, TEMP_SENSOR_TYPE_CPU);
|
|
}
|
|
DECLARE_CONSOLE_COMMAND(setcputemp, command_set_cpu_temp,
|
|
"value",
|
|
"Set mock CPU temperature value",
|
|
NULL);
|
|
|
|
|
|
static int command_set_board_temp(int argc, char **argv)
|
|
{
|
|
return command_set_temp(argc, argv, TEMP_SENSOR_TYPE_BOARD);
|
|
}
|
|
DECLARE_CONSOLE_COMMAND(setboardtemp, command_set_board_temp,
|
|
"value",
|
|
"Set mock board temperature value",
|
|
NULL);
|
|
|
|
|
|
static int command_set_case_temp(int argc, char **argv)
|
|
{
|
|
return command_set_temp(argc, argv, TEMP_SENSOR_TYPE_CASE);
|
|
}
|
|
DECLARE_CONSOLE_COMMAND(setcasetemp, command_set_case_temp,
|
|
"value",
|
|
"Set mock case temperature value",
|
|
NULL);
|