summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2015-07-30 16:22:20 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-08-03 21:15:56 +0000
commit2bb093151fe5b65948f40b0518dc9c5e86f7b434 (patch)
treef7b64026e02b6a93a221e4ddb90ae2de8b4ec840 /test
parent252d2364f47ddb8447a5dc47a42a4ea7c21b61a4 (diff)
downloadchrome-ec-2bb093151fe5b65948f40b0518dc9c5e86f7b434.tar.gz
driver/temp_sensor: Add support for BD99992GW
Add support for ADC / thermistor reads on the BD99992GW PMIC. BUG=chrome-os-partner:42156 TEST=Manual on Glados with subsequent commit. Boot to S0, run "temps". Verify that temperatures start around 28C and begin to increase after system is powered-on for a long duration. BRANCH=None Change-Id: Ic15f41046130317a0e0c3bce4a923ba624328c0d Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/289935 Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/test_config.h3
-rw-r--r--test/thermal.c53
2 files changed, 56 insertions, 0 deletions
diff --git a/test/test_config.h b/test/test_config.h
index bc517314b6..e2ad96fbad 100644
--- a/test/test_config.h
+++ b/test/test_config.h
@@ -78,6 +78,9 @@ int board_discharge_on_ac(int enabled);
#define CONFIG_CHIPSET_CAN_THROTTLE
#define CONFIG_FANS 1
#define CONFIG_TEMP_SENSOR
+#define CONFIG_TEMP_SENSOR_BD99992GW
+#define I2C_PORT_THERMAL 1
+int bd99992gw_get_temp(uint16_t adc);
#endif
#ifdef TEST_FAN
diff --git a/test/thermal.c b/test/thermal.c
index 10662ffd7d..761dc9358d 100644
--- a/test/thermal.c
+++ b/test/thermal.c
@@ -480,6 +480,58 @@ static int test_several_limits(void)
return EC_SUCCESS;
}
+/* Tests for bd99992gw temperature sensor ADC-to-temp calculation */
+#define LOW_ADC_TEST_VALUE 887 /* 0 C */
+#define HIGH_ADC_TEST_VALUE 100 /* > 100C */
+
+static int test_bd99992_adc_to_temp(void)
+{
+ int i;
+ uint8_t temp;
+ uint8_t new_temp;
+
+ /* ADC value to temperature table, data from datasheet */
+ struct {
+ int adc;
+ int temp;
+ } adc_temp_datapoints[] = {
+ { 615, 30 },
+ { 561, 35 },
+ { 508, 40 },
+ { 407, 50 },
+ { 315, 60 },
+ { 243, 70 },
+ { 186, 80 },
+ { 140, 90 },
+ { 107, 100 },
+ };
+
+
+ /*
+ * Verify that calculated temp is decreasing for entire ADC range,
+ * and that a tick down in ADC value results in no more than 1C
+ * decrease.
+ */
+ i = LOW_ADC_TEST_VALUE;
+ temp = bd99992gw_get_temp(i);
+
+ while (--i > HIGH_ADC_TEST_VALUE) {
+ new_temp = bd99992gw_get_temp(i);
+ TEST_ASSERT(new_temp == temp ||
+ new_temp == temp + 1);
+ temp = new_temp;
+ }
+
+ /* Verify several datapoints are within 1C accuracy */
+ for (i = 0; i < ARRAY_SIZE(adc_temp_datapoints); ++i) {
+ temp = bd99992gw_get_temp(adc_temp_datapoints[i].adc);
+ ASSERT(temp >= adc_temp_datapoints[i].temp - 1 &&
+ temp <= adc_temp_datapoints[i].temp + 1);
+ }
+
+ return EC_SUCCESS;
+}
+
void run_test(void)
{
@@ -492,5 +544,6 @@ void run_test(void)
RUN_TEST(test_one_limit);
RUN_TEST(test_several_limits);
+ RUN_TEST(test_bd99992_adc_to_temp);
test_print_result();
}