Skip to content

Commit 706a86c

Browse files
JohnWC-YehTerrails
authored andcommitted
fwk: azalea: fix temp readout fail
Azalea support virtual wire index 33h for AMD zstate. Unable to read temperature through i2c when entering low power state. EC can only resume CPU temperature polling no sooner than 5ms after exit from low power state BRANCH=fwk-lotus-azalea-19573 BUG=https://app.clickup.com/t/86eq8nzqf TEST= check didn't read the value over I2C when entering Z8 state Signed-off-by: johnwc_yeh <[email protected]>
1 parent 2f7a9ea commit 706a86c

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

driver/sb_rmi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ int sb_rmi_mailbox_xfer(int cmd, uint32_t msg_in, uint32_t *msg_out_ptr)
111111
const int ap_comm_failure_threshold = 2;
112112
static int ap_comm_failure_count;
113113

114-
if (!chipset_in_state(CHIPSET_STATE_ON))
114+
if (!chipset_in_state(CHIPSET_STATE_ON) || chipset_in_low_power_mode())
115115
return EC_ERROR_NOT_POWERED;
116116

117117
/**
@@ -270,7 +270,7 @@ int sb_rmi_mailbox_xfer(int cmd, uint32_t msg_in, uint32_t *msg_out_ptr)
270270
const int ap_comm_failure_threshold = 2;
271271
static int ap_comm_failure_count;
272272

273-
if (!chipset_in_state(CHIPSET_STATE_ON))
273+
if (!chipset_in_state(CHIPSET_STATE_ON) || chipset_in_low_power_mode())
274274
return EC_ERROR_NOT_POWERED;
275275

276276
mutex_lock(&sb_rmi_mutex);

driver/temp_sensor/sb_tsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int sb_tsi_get_val(int idx, int *temp_ptr)
3030
if (idx != 0)
3131
return EC_ERROR_PARAM1;
3232
/* FT4 SB-TSI sensor only powered in S0 */
33-
if (!chipset_in_state(CHIPSET_STATE_ON))
33+
if (!chipset_in_state(CHIPSET_STATE_ON) || chipset_in_low_power_mode())
3434
return EC_ERROR_NOT_POWERED;
3535
/* Read the value over I2C */
3636
ret = raw_read8(SB_TSI_TEMP_H, temp_ptr);

include/chipset.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,21 @@ __override_proto enum critical_shutdown
251251
board_system_is_idle(uint64_t last_shutdown_time, uint64_t *target,
252252
uint64_t now);
253253

254+
/**
255+
* Check if chipset is in low power mode
256+
*
257+
* Newer AMD SoCs support modern standby as well as the AMD version of runtime
258+
* low power states. To coordinate these runtime low-power states with EC, the
259+
* APU communicates the transition through the eSPI virtual wires. On transition
260+
* to the low power state, APU transmits the corresponding virtual wire to EC.
261+
* Any downstream transaction to EC or assertion of ESPI_ALERT# is treated as exit
262+
* from the low power state.
263+
* Sequence for all low power state (modern standby/SLP_MSC, Z8/9/10) are identical.
264+
*
265+
* @return non-zero if the chipset is in low power mode
266+
*/
267+
__override_proto int chipset_in_low_power_mode(void);
268+
254269
#ifdef CONFIG_CMD_AP_RESET_LOG
255270

256271
/**

power/common.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,11 @@ static void preserve_enable_5v_state(void)
11521152
DECLARE_HOOK(HOOK_SYSJUMP, preserve_enable_5v_state, HOOK_PRIO_DEFAULT);
11531153
#endif /* defined(CONFIG_POWER_PP5000_CONTROL) */
11541154

1155+
__overridable int chipset_in_low_power_mode(void)
1156+
{
1157+
return false;
1158+
}
1159+
11551160
#ifdef CONFIG_POWERSEQ_FAKE_CONTROL
11561161
static int command_power_fake(int argc, const char **argv)
11571162
{

zephyr/program/framework/azalea/src/stt.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "temp_sensor/pct2075.h"
1111
#include "temp_sensor/temp_sensor.h"
1212

13+
#define NPCX_ESPI_VWEVSM_ADDR ((volatile uint32_t *)0x4000a160)
14+
1315
int board_get_soc_temp_mk(int *temp_mk)
1416
{
1517
if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
@@ -27,3 +29,19 @@ int board_get_ambient_temp_mk(int *temp_mk)
2729
return f75303_get_val_mk(
2830
F75303_SENSOR_ID(DT_NODELABEL(ddr_f75303)), temp_mk);
2931
}
32+
33+
__override int chipset_in_low_power_mode(void)
34+
{
35+
volatile uint32_t *address;
36+
uint32_t val;
37+
bool in_low_power_mode = false;
38+
39+
address = NPCX_ESPI_VWEVSM_ADDR;
40+
/* Get Wire field */
41+
val = *address & 0x0F;
42+
43+
if (val != 0)
44+
in_low_power_mode = true;
45+
46+
return in_low_power_mode;
47+
}

0 commit comments

Comments
 (0)