From e37d771001684246fa714873b37d65e7fe806fe2 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Thu, 26 Jul 2018 20:02:38 +0200 Subject: superio/ite/it8720f: fix power control init The existing code for modifying the power state after power loss of the system only implemented the transitions from power off to either power on or power keep properly. Since I don't have a board with this chip, I couldn't test the patch on real hardware. The two cases described above were tested before the original patch was merged, so I'd expect this to work. Change-Id: I3c26a2837e451dbfd3cee82e9beedc0f4a90af03 Signed-off-by: Felix Held Reviewed-on: https://review.coreboot.org/27648 Tested-by: build bot (Jenkins) Reviewed-by: Samuel Holland Reviewed-by: Paul Menzel Reviewed-by: Martin Roth --- src/superio/ite/it8720f/it8720f.h | 4 ++++ src/superio/ite/it8720f/superio.c | 24 +++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 'src/superio') diff --git a/src/superio/ite/it8720f/it8720f.h b/src/superio/ite/it8720f/it8720f.h index f8b7efbc56..093e895821 100644 --- a/src/superio/ite/it8720f/it8720f.h +++ b/src/superio/ite/it8720f/it8720f.h @@ -30,4 +30,8 @@ #define IT8720F_GPIO 0x07 /* GPIO (including SPI flash interface) */ #define IT8720F_CIR 0x0a /* Consumer IR */ +/* Registers in LDNs */ +#define IT8720F_EC_PCR1 0xf2 +#define IT8720F_EC_PCR2 0xf4 + #endif /* SUPERIO_ITE_IT8720F_H */ diff --git a/src/superio/ite/it8720f/superio.c b/src/superio/ite/it8720f/superio.c index 142686e939..48bbfb2019 100644 --- a/src/superio/ite/it8720f/superio.c +++ b/src/superio/ite/it8720f/superio.c @@ -33,17 +33,27 @@ static void power_control_init(struct device *dev) { int power_on = MAINBOARD_POWER_OFF; - u8 addr, value; + u8 value; get_option(&power_on, "power_on_after_fail"); - if (power_on == MAINBOARD_POWER_OFF) - return; + pnp_enter_conf_mode(dev); pnp_set_logical_device(dev); - addr = power_on == MAINBOARD_POWER_KEEP ? 0xf2 : 0xf4; - value = pnp_read_config(dev, addr); - value |= BIT(5); - pnp_write_config(dev, addr, value); + + value = pnp_read_config(dev, IT8720F_EC_PCR1); + if (power_on == MAINBOARD_POWER_KEEP) + value |= (1 << 5); + else + value &= ~(1 << 5); + pnp_write_config(dev, IT8720F_EC_PCR1, value); + + value = pnp_read_config(dev, IT8720F_EC_PCR2); + if (power_on == MAINBOARD_POWER_ON) + value |= (1 << 5); + else + value &= ~(1 << 5); + pnp_write_config(dev, IT8720F_EC_PCR2, value); + pnp_exit_conf_mode(dev); } -- cgit v1.2.3