mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
driver/temp_sensor: Add support thermistor on EC's own ADC
Add support for ADC / thermistor reads on the EC's ADC This will support now only ncp15wb but we can expand it at future time. BUG=chrome-os-partner:44764 TEST=make buildall -j Manual on celes with subsequent commit. Boot to S0, run "temps". Verify that temperatures are. See temperature is changing BRANCH=None Change-Id: If26d24b803dcff00c4c24e4e1f71d3b0de8e6738 Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com> Reviewed-on: https://chromium-review.googlesource.com/296872 Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
@@ -54,6 +54,7 @@ driver-$(CONFIG_REGULATOR_IR357X)+=regulator_ir357x.o
|
||||
|
||||
# Temperature sensors
|
||||
driver-$(CONFIG_TEMP_SENSOR_BD99992GW)+=temp_sensor/bd99992gw.o
|
||||
driver-$(CONFIG_TEMP_SENSOR_EC_ADC)+=temp_sensor/ec_adc.o
|
||||
driver-$(CONFIG_TEMP_SENSOR_G781)+=temp_sensor/g781.o
|
||||
driver-$(CONFIG_TEMP_SENSOR_TMP006)+=temp_sensor/tmp006.o
|
||||
driver-$(CONFIG_TEMP_SENSOR_TMP432)+=temp_sensor/tmp432.o
|
||||
|
||||
56
driver/temp_sensor/ec_adc.c
Normal file
56
driver/temp_sensor/ec_adc.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/* Copyright 2015 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.
|
||||
*/
|
||||
|
||||
/* EC_ADC driver for Chrome EC */
|
||||
|
||||
#include "adc.h"
|
||||
#include "common.h"
|
||||
#include "console.h"
|
||||
#include "ec_adc.h"
|
||||
#include "thermistor.h"
|
||||
#include "util.h"
|
||||
|
||||
/* Get temperature from requested sensor */
|
||||
static int get_temp(int idx, int *temp_ptr)
|
||||
{
|
||||
int temp_raw = 0;
|
||||
|
||||
/* Read 10-bit ADC result */
|
||||
temp_raw = adc_read_channel(idx);
|
||||
|
||||
if (temp_raw == ADC_READ_ERROR)
|
||||
return EC_ERROR_UNKNOWN;
|
||||
|
||||
/* TODO : Need modification here if the result is not 10-bit */
|
||||
|
||||
/* If there is no thermistor calculation function.
|
||||
* 1. Add adjusting function like thermistor_ncp15wb.c
|
||||
* 2. Place function here with ifdef
|
||||
* 3. define it on board.h
|
||||
*/
|
||||
#ifdef CONFIG_THERMISTOR_NCP15WB
|
||||
*temp_ptr = ncp15wb_calculate_temp((uint16_t) temp_raw);
|
||||
#else
|
||||
#error "Unknown thermistor for ec_adc"
|
||||
return EC_ERROR_UNKNOWN;
|
||||
#endif
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
int ec_adc_get_val(int idx, int *temp_ptr)
|
||||
{
|
||||
int ret;
|
||||
int temp_c;
|
||||
|
||||
if(idx < 0 || idx >= ADC_CH_COUNT)
|
||||
return EC_ERROR_INVAL;
|
||||
|
||||
ret = get_temp(idx, &temp_c);
|
||||
if (ret == EC_SUCCESS)
|
||||
*temp_ptr = C_TO_K(temp_c);
|
||||
|
||||
return ret;
|
||||
}
|
||||
24
driver/temp_sensor/ec_adc.h
Normal file
24
driver/temp_sensor/ec_adc.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/* Copyright 2015 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.
|
||||
*/
|
||||
|
||||
/* ec_adc which uses adc and thermistors module for Chrome EC
|
||||
* Some EC has it's own ADC modules, define here EC's max ADC channels.
|
||||
* We can consider every channel as a thermal sensor.
|
||||
*/
|
||||
|
||||
#ifndef __CROS_EC_TEMP_SENSOR_EC_ADC_H
|
||||
#define __CROS_EC_TEMP_SENSOR_EC_ADC_H
|
||||
|
||||
/**
|
||||
* Get the latest value from the sensor.
|
||||
*
|
||||
* @param idx ADC channel to read.
|
||||
* @param temp_ptr Destination for temperature in K.
|
||||
*
|
||||
* @return EC_SUCCESS if successful, non-zero if error.
|
||||
*/
|
||||
int ec_adc_get_val(int idx, int *temp_ptr);
|
||||
|
||||
#endif /* __CROS_EC_TEMP_SENSOR_EC_ADC_H */
|
||||
@@ -1493,6 +1493,7 @@
|
||||
|
||||
/* Support particular temperature sensor chips */
|
||||
#undef CONFIG_TEMP_SENSOR_BD99992GW /* BD99992GW PMIC, on I2C bus */
|
||||
#undef CONFIG_TEMP_SENSOR_EC_ADC /* Thermistors on EC's own ADC */
|
||||
#undef CONFIG_TEMP_SENSOR_G781 /* G781 sensor, on I2C bus */
|
||||
#undef CONFIG_TEMP_SENSOR_TMP006 /* TI TMP006 sensor, on I2C bus */
|
||||
#undef CONFIG_TEMP_SENSOR_TMP432 /* TI TMP432 sensor, on I2C bus */
|
||||
|
||||
Reference in New Issue
Block a user