From d603b7a1f844f6e7b4a7582c97fe7e1d9cc24279 Mon Sep 17 00:00:00 2001 From: Yu-An Chen Date: Fri, 5 Mar 2021 15:44:47 +0800 Subject: dedede/metaknight: delay thermal sensor read in the first time Add CONFIG_TEMP_SENSOR_FIRST_READ_DELAY_MS to adjustment delay time of thermal sensor first read. Add 500 ms delay of thermal sensor first read in metaknight. BUG=b:181202521 BRANCH=dedede TEST=DUT do [ec reset|boot from G3] 20 time pass Signed-off-by: yu-an.chen@quanta.corp-partner.google.com Change-Id: I12f5411c8ac3866d7a52807c4eface9e6bdfd5a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2738505 Reviewed-by: Aseda Aboagye Commit-Queue: Aseda Aboagye --- common/thermal.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'common/thermal.c') diff --git a/common/thermal.c b/common/thermal.c index 40577c0d43..e9750931be 100644 --- a/common/thermal.c +++ b/common/thermal.c @@ -53,6 +53,12 @@ BUILD_ASSERT(EC_TEMP_THRESH_COUNT == 3); /* Keep track of which thresholds have triggered */ static cond_t cond_hot[EC_TEMP_THRESH_COUNT]; +/* thermal sensor read delay */ +#if defined(CONFIG_TEMP_SENSOR_POWER_GPIO) && \ + defined(CONFIG_TEMP_SENSOR_FIRST_READ_DELAY_MS) +static int first_read_delay = CONFIG_TEMP_SENSOR_FIRST_READ_DELAY_MS; +#endif + static void thermal_control(void) { int i, j, t, rv, f; @@ -67,6 +73,15 @@ static void thermal_control(void) int temp[TEMP_SENSOR_COUNT]; #endif + /* add delay to ensure thermal sensor is ready when EC boot */ +#if defined(CONFIG_TEMP_SENSOR_POWER_GPIO) && \ + defined(CONFIG_TEMP_SENSOR_FIRST_READ_DELAY_MS) + if (first_read_delay != 0) { + msleep(first_read_delay); + first_read_delay = 0; + } +#endif + /* Get ready to count things */ memset(count_over, 0, sizeof(count_over)); memset(count_under, 0, sizeof(count_under)); -- cgit v1.2.1