summaryrefslogtreecommitdiff
path: root/chip/lm4/peci.c
diff options
context:
space:
mode:
Diffstat (limited to 'chip/lm4/peci.c')
-rw-r--r--chip/lm4/peci.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/chip/lm4/peci.c b/chip/lm4/peci.c
index 780ecd40b6..88e13d18c1 100644
--- a/chip/lm4/peci.c
+++ b/chip/lm4/peci.c
@@ -16,6 +16,10 @@
#include "temp_sensor.h"
#include "util.h"
+/* Max junction temperature for processor in degrees C */
+/* TODO: read TjMax from processor via PECI */
+#define PECI_TJMAX 105
+
/* Initial PECI baud rate */
#define PECI_BAUD_RATE 100000
@@ -62,15 +66,7 @@ int peci_temp_sensor_get_val(int idx, int *temp_ptr)
}
}
- /*
- * Require at least two valid samples. When the AP transitions into S0,
- * it is possible, depending on the timing of the PECI sample, to read
- * an invalid temperature. This is very rare, but when it does happen
- * the temperature returned is CONFIG_PECI_TJMAX. Requiring two valid
- * samples here assures us that one bad maximum temperature reading
- * when entering S0 won't cause us to trigger an over temperature.
- */
- if (success_cnt < 2)
+ if (!success_cnt)
return EC_ERROR_UNKNOWN;
*temp_ptr = sum / success_cnt;
@@ -104,7 +100,7 @@ static void peci_freq_changed(void)
(PECI_POLL_INTERVAL_MS * (freq / 1000 / 4096));
/* Set up temperature monitoring to report in degrees K */
- LM4_PECI_CTL = ((CONFIG_PECI_TJMAX + 273) << 22) | 0x0001 |
+ LM4_PECI_CTL = ((PECI_TJMAX + 273) << 22) | 0x0001 |
(PECI_RETRY_COUNT << 12) |
(PECI_ERROR_BYPASS << 11);
}
@@ -114,9 +110,9 @@ static void peci_init(void)
{
int i;
- /* Enable the PECI module in run and sleep modes. */
- clock_enable_peripheral(CGC_OFFSET_PECI, 0x1,
- CGC_MODE_RUN | CGC_MODE_SLEEP);
+ /* Enable the PECI module and delay a few clocks */
+ LM4_SYSTEM_RCGCPECI = 1;
+ clock_wait_cycles(3);
/* Configure GPIOs */
gpio_config_module(MODULE_PECI, 1);