Lower PECI baud rate and increase poll frequency

We see some intermittent failure on PECI read. This CL lower PECI baud
rate from 150K to 100K. Also, we poll PECI temperature 4 times per
second and average over last 4 values. We only report read error when
last 4 read all fails.

This CL also increases the external path delay, increases retry count,
and also enable timing negotiation error bypass.

BUG=chrome-os-partner:10382
TEST=Still able to read from all temperature sensors

Change-Id: I38cefeabd9e3eff4bb8e4df4138c4ffd49cd84a2
Reviewed-on: https://gerrit.chromium.org/gerrit/26554
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
This commit is contained in:
Vic Yang
2012-07-02 15:26:17 +08:00
committed by Gerrit
parent d29ec56d41
commit 24acac67a3
2 changed files with 49 additions and 18 deletions

View File

@@ -20,16 +20,24 @@
#define PECI_TJMAX 105
/* Initial PECI baud rate */
#define PECI_BAUD_RATE 150000
#define PECI_BAUD_RATE 100000
/* Polling interval for PECI, in ms */
#define PECI_POLL_INTERVAL_MS 200
#define PECI_POLL_INTERVAL_MS 250
/* Internal and external path delays, in ns */
#define PECI_TD_FET_NS 25 /* Guess; TODO: what is real delay */
#define PECI_TD_FET_NS 60 /* Guess; TODO: what is real delay */
#define PECI_TD_INT_NS 80
static int last_temp_val;
/* Number of controller retries. Should be between 0 and 7. */
#define PECI_RETRY_COUNT 4
/* Timing negotiation error bypass. 1 = on. 0 = off. */
#define PECI_ERROR_BYPASS 1
#define TEMP_AVG_LENGTH 4 /* Should be power of 2 */
static int temp_vals[TEMP_AVG_LENGTH];
static int temp_idx = 0;
/* Configures the GPIOs for the PECI module. */
static void configure_gpios(void)
@@ -55,18 +63,29 @@ int peci_get_cpu_temp(void)
int peci_temp_sensor_poll(void)
{
last_temp_val = peci_get_cpu_temp();
if (last_temp_val > 0)
return EC_SUCCESS;
else
return EC_ERROR_UNKNOWN;
temp_vals[temp_idx] = peci_get_cpu_temp();
temp_idx = (temp_idx + 1) & (TEMP_AVG_LENGTH - 1);
return EC_SUCCESS;
}
int peci_temp_sensor_get_val(int idx)
{
return last_temp_val;
int sum = 0;
int success_cnt = 0;
int i;
for (i = 0; i < TEMP_AVG_LENGTH; ++i) {
if (temp_vals[i] >= 0) {
success_cnt++;
sum += temp_vals[i];
}
}
if (success_cnt)
return sum / success_cnt;
else
return -1;
}
@@ -88,7 +107,9 @@ static int peci_freq_changed(void)
(PECI_POLL_INTERVAL_MS * (freq / 1000 / 4096));
/* Set up temperature monitoring to report in degrees K */
LM4_PECI_CTL = ((PECI_TJMAX + 273) << 22) | 0x2001;
LM4_PECI_CTL = ((PECI_TJMAX + 273) << 22) | 0x0001 |
(PECI_RETRY_COUNT << 12) |
(PECI_ERROR_BYPASS << 11);
return EC_SUCCESS;
}

View File

@@ -54,19 +54,25 @@ int temp_sensor_powered(enum temp_sensor_id id)
}
void poll_all_sensors(void)
void poll_slow_sensors(void)
{
/* Poll every second */
#ifdef CONFIG_TMP006
tmp006_poll();
#endif
#ifdef CONFIG_PECI
peci_temp_sensor_poll();
#endif
#ifdef CHIP_lm4
chip_temp_sensor_poll();
#endif
}
static void poll_fast_sensors(void)
{
/* Poll every 1/4 second */
#ifdef CONFIG_PECI
peci_temp_sensor_poll();
#endif
}
static void update_lpc_mapped_memory(void)
{
@@ -91,10 +97,14 @@ static void update_lpc_mapped_memory(void)
void temp_sensor_task(void)
{
int i;
while (1) {
poll_all_sensors();
for (i = 0; i < 4; ++i) {
usleep(250000);
poll_fast_sensors();
}
poll_slow_sensors();
update_lpc_mapped_memory();
usleep(1000000);
}
}