Skip to content

Commit 462c65d

Browse files
authored
Merge pull request #441 from FrameworkComputer/hx30.reduce_call_gettemp_function
Reduced the frequency to execute the PECI over eSPI transaction
2 parents 458090b + 0478215 commit 462c65d

2 files changed

Lines changed: 39 additions & 13 deletions

File tree

board/hx30/peci_customization.c

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "chipset.h"
77
#include "console.h"
88
#include "board.h"
9+
#include "hooks.h"
910
#include "host_command.h"
1011
#include "peci.h"
1112
#include "peci_customization.h"
@@ -16,6 +17,8 @@
1617
#define CPUTS(outstr) cputs(CC_THERMAL, outstr)
1718
#define CPRINTS(format, args...) cprints(CC_THERMAL, format, ## args)
1819

20+
static int peci_temp;
21+
1922
/*****************************************************************************/
2023
/* Internal functions */
2124

@@ -250,22 +253,36 @@ __override int stop_read_peci_temp(void)
250253

251254
int peci_over_espi_temp_sensor_get_val(int idx, int *temp_ptr)
252255
{
253-
int i, rv;
256+
if (peci_temp == 0xfffe)
257+
return EC_ERROR_NOT_POWERED;
258+
259+
if (peci_temp == 0xffff)
260+
return EC_ERROR_INVAL;
261+
262+
*temp_ptr = peci_temp;
263+
264+
return EC_SUCCESS;
265+
}
266+
267+
void read_peci_over_espi_gettemp(void)
268+
{
269+
int rv;
270+
int i;
254271

255272
rv = stop_read_peci_temp();
256273

257-
if (rv != EC_SUCCESS)
258-
return rv;
274+
if (rv != EC_SUCCESS) {
275+
peci_temp = 0xfffe;
276+
} else {
277+
for (i = 0; i < 2; i++) {
278+
rv = peci_over_espi_get_cpu_temp(&peci_temp);
279+
if (!rv)
280+
break;
281+
msleep(10);
282+
}
259283

260-
/*
261-
* Retry reading PECI CPU temperature if the first sample is
262-
* invalid or failed to obtain.
263-
*/
264-
for (i = 0; i < 2; i++) {
265-
rv = peci_over_espi_get_cpu_temp(temp_ptr);
266-
if (!rv)
267-
break;
284+
if (rv != EC_SUCCESS)
285+
peci_temp = 0xffff;
268286
}
269-
270-
return rv;
271287
}
288+
DECLARE_HOOK(HOOK_SECOND, read_peci_over_espi_gettemp, HOOK_PRIO_DEFAULT);

board/hx30/peci_customization.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,13 @@ int peci_update_PL1(int watt);
6060
int peci_update_PL2(int watt);
6161
int peci_update_PL4(int watt);
6262
int peci_update_PsysPL2(int watt);
63+
64+
/**
65+
* This function return the peci gettemp value from global variant, the
66+
* actually value is read from read_peci_over_espi_gettemp();
67+
*
68+
* @param idx no used
69+
* @param temp_ptr return temp value pointer
70+
* @return int return get value status
71+
*/
6372
int peci_over_espi_temp_sensor_get_val(int idx, int *temp_ptr);

0 commit comments

Comments
 (0)