ec/starlabs/merlin/ite: Adjust the mirror flag handling

In EC versions older than 1.18, if the mirror flag was enabled, the
EC would mirror once the system reached S5.

When a mirror is successful, the system will automatically power
on, as it acts like it's been in G3. This led to machines turning on
when the intention was them to be off.

In 1.18 and later, they're installed when turning on. The result was
slower boot times when mirroring, but no unwanted powering on.

Because of this, coreboot no longer needs to power off when setting
the mirror flag.

Change-Id: I973c1ecd59f32d3353ca392769b44aadf5fcc9c3
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/78200
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
This commit is contained in:
Sean Rhodes 2023-09-20 14:51:57 +01:00 committed by Matt DeVillier
parent 8902dfa2bd
commit ded5a601b5
2 changed files with 7 additions and 36 deletions

View File

@ -102,8 +102,6 @@
#define MIRROR_DISABLED 0x00 #define MIRROR_DISABLED 0x00
#define MIRROR_ENABLED 0xaa #define MIRROR_ENABLED 0xaa
#define MIRROR_ATTEMPTS 1
uint16_t ec_get_version(void); uint16_t ec_get_version(void);
void ec_mirror_flag(void); void ec_mirror_flag(void);

View File

@ -27,39 +27,6 @@ static uint8_t get_ec_value_from_option(const char *name,
return lut[index]; return lut[index];
} }
static void ec_mirror_with_count(void)
{
unsigned int cmos_mirror_flag_counter = get_uint_option("mirror_flag_counter", UINT_MAX);
if (cmos_mirror_flag_counter == UINT_MAX)
return;
printk(BIOS_DEBUG, "ITE: mirror_flag_counter = %u\n", cmos_mirror_flag_counter);
/* Avoid boot loops by only trying a state change once */
if (cmos_mirror_flag_counter < MIRROR_ATTEMPTS) {
cmos_mirror_flag_counter++;
set_uint_option("mirror_flag_counter", cmos_mirror_flag_counter);
printk(BIOS_DEBUG, "ITE: Mirror attempt %u/%u.\n", cmos_mirror_flag_counter,
MIRROR_ATTEMPTS);
/* Write the EC mirror flag */
ec_write(ECRAM_MIRROR_FLAG, MIRROR_ENABLED);
/* Check what has been written */
if (ec_read(ECRAM_MIRROR_FLAG) == MIRROR_ENABLED)
poweroff();
} else {
/*
* If the mirror flags fails after 1 attempt, it will
* likely need a cold boot, or recovering.
*/
printk(BIOS_ERR, "ITE: Failed to mirror the EC in %u attempts!\n",
MIRROR_ATTEMPTS);
}
}
void ec_mirror_flag(void) void ec_mirror_flag(void)
{ {
/* /*
@ -74,12 +41,18 @@ void ec_mirror_flag(void)
*/ */
uint16_t ec_version = ec_get_version(); uint16_t ec_version = ec_get_version();
/* Full mirror support was added in EC 1.18 (0x0112) */
if (ec_version < 0x0112)
return;
if (CONFIG(EC_STARLABS_MIRROR_SUPPORT) && if (CONFIG(EC_STARLABS_MIRROR_SUPPORT) &&
(CONFIG(DRIVERS_INTEL_USB4_RETIMER) || get_uint_option("mirror_flag", 0)) && (CONFIG(DRIVERS_INTEL_USB4_RETIMER) || get_uint_option("mirror_flag", 0)) &&
(ec_version != CONFIG_EC_STARLABS_MIRROR_VERSION)) { (ec_version != CONFIG_EC_STARLABS_MIRROR_VERSION)) {
printk(BIOS_ERR, "ITE: EC version 0x%x doesn't match coreboot version 0x%x.\n", printk(BIOS_ERR, "ITE: EC version 0x%x doesn't match coreboot version 0x%x.\n",
ec_version, CONFIG_EC_STARLABS_MIRROR_VERSION); ec_version, CONFIG_EC_STARLABS_MIRROR_VERSION);
ec_mirror_with_count();
ec_write(ECRAM_MIRROR_FLAG, MIRROR_ENABLED);
} }
} }