HACK: pmc: Add hack to force S0ix entry on lemp11
lemp11 sometimes fails to reach C10 and gets stuck in C0 during s2idle. For some reason, sending a PMC SCI allows the CPU to go to C10. Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
committed by
Jeremy Soller
parent
f8d1123934
commit
01885609e8
@ -19,6 +19,8 @@ extern uint8_t sci_extra;
|
|||||||
|
|
||||||
enum EcOs acpi_ecos = EC_OS_NONE;
|
enum EcOs acpi_ecos = EC_OS_NONE;
|
||||||
|
|
||||||
|
extern bool pmc_s0_hack;
|
||||||
|
|
||||||
static uint8_t fcmd = 0;
|
static uint8_t fcmd = 0;
|
||||||
static uint8_t fdat = 0;
|
static uint8_t fdat = 0;
|
||||||
static uint8_t fbuf[4] = { 0, 0, 0, 0 };
|
static uint8_t fbuf[4] = { 0, 0, 0, 0 };
|
||||||
@ -130,7 +132,11 @@ uint8_t acpi_read(uint8_t addr) {
|
|||||||
|
|
||||||
ACPI_16(0x42, battery_info.cycle_count);
|
ACPI_16(0x42, battery_info.cycle_count);
|
||||||
|
|
||||||
ACPI_8(0x68, acpi_ecos);
|
case 0x68:
|
||||||
|
data = acpi_ecos;
|
||||||
|
// HACK: Kick PMC to fix suspend on lemp11
|
||||||
|
pmc_s0_hack = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 0xBC:
|
case 0xBC:
|
||||||
data = battery_get_start_threshold();
|
data = battery_get_start_threshold();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
#include <arch/time.h>
|
||||||
#include <arch/delay.h>
|
#include <arch/delay.h>
|
||||||
#include <board/acpi.h>
|
#include <board/acpi.h>
|
||||||
#include <board/gpio.h>
|
#include <board/gpio.h>
|
||||||
@ -8,6 +9,12 @@
|
|||||||
#include <common/debug.h>
|
#include <common/debug.h>
|
||||||
#include <ec/espi.h>
|
#include <ec/espi.h>
|
||||||
|
|
||||||
|
#ifndef PMC_S0IX_HACK
|
||||||
|
#define PMC_S0IX_HACK 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool pmc_s0_hack = false;
|
||||||
|
|
||||||
void pmc_init(void) {
|
void pmc_init(void) {
|
||||||
*(PMC_1.control) = 0x41;
|
*(PMC_1.control) = 0x41;
|
||||||
*(PMC_2.control) = 0x41;
|
*(PMC_2.control) = 0x41;
|
||||||
@ -180,9 +187,37 @@ static void pmc_on_output_empty(struct Pmc * pmc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if PMC_S0IX_HACK
|
||||||
|
// HACK: Kick PMC to fix suspend on lemp11
|
||||||
|
static void pmc_hack(void) {
|
||||||
|
static bool pmc_s0_hack2 = false;
|
||||||
|
static uint32_t last_time = 0;
|
||||||
|
// Get time the system requested S0ix (ACPI MS0X)
|
||||||
|
if (pmc_s0_hack) {
|
||||||
|
last_time = time_get();
|
||||||
|
pmc_s0_hack = false;
|
||||||
|
pmc_s0_hack2 = true;
|
||||||
|
}
|
||||||
|
uint32_t time = time_get();
|
||||||
|
// If SLP_S0# not asserted after 5 seconds, apply the hack
|
||||||
|
if ((time - last_time) >= 5000) {
|
||||||
|
if (pmc_s0_hack2 && gpio_get(&SLP_S0_N)) {
|
||||||
|
DEBUG("FIXME: PMC HACK\n");
|
||||||
|
pmc_sci(&PMC_1, 0x50);
|
||||||
|
}
|
||||||
|
pmc_s0_hack2 = false;
|
||||||
|
last_time = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static void pmc_hack(void) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
void pmc_event(struct Pmc * pmc) {
|
void pmc_event(struct Pmc * pmc) {
|
||||||
uint8_t sts;
|
uint8_t sts;
|
||||||
|
|
||||||
|
pmc_hack();
|
||||||
|
|
||||||
// Read command/data if available
|
// Read command/data if available
|
||||||
sts = pmc_status(pmc);
|
sts = pmc_status(pmc);
|
||||||
if (sts & PMC_STS_IBF) {
|
if (sts & PMC_STS_IBF) {
|
||||||
|
@ -7,6 +7,8 @@ CFLAGS+=-DEC_ESPI=1
|
|||||||
|
|
||||||
# Use S0ix
|
# Use S0ix
|
||||||
CFLAGS+=-DUSE_S0IX=1
|
CFLAGS+=-DUSE_S0IX=1
|
||||||
|
# Apply PMC hack for S0ix
|
||||||
|
CFLAGS+=-DPMC_S0IX_HACK=1
|
||||||
|
|
||||||
# Include keyboard
|
# Include keyboard
|
||||||
KEYBOARD=14in_83
|
KEYBOARD=14in_83
|
||||||
|
Reference in New Issue
Block a user