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 <felix-coreboot@felixheld.de>
Reviewed-on: https://review.coreboot.org/27648
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Felix Held 2018-07-26 20:02:38 +02:00
parent b6f2e7bd4c
commit e37d771001
2 changed files with 21 additions and 7 deletions

View File

@ -30,4 +30,8 @@
#define IT8720F_GPIO 0x07 /* GPIO (including SPI flash interface) */ #define IT8720F_GPIO 0x07 /* GPIO (including SPI flash interface) */
#define IT8720F_CIR 0x0a /* Consumer IR */ #define IT8720F_CIR 0x0a /* Consumer IR */
/* Registers in LDNs */
#define IT8720F_EC_PCR1 0xf2
#define IT8720F_EC_PCR2 0xf4
#endif /* SUPERIO_ITE_IT8720F_H */ #endif /* SUPERIO_ITE_IT8720F_H */

View File

@ -33,17 +33,27 @@
static void power_control_init(struct device *dev) static void power_control_init(struct device *dev)
{ {
int power_on = MAINBOARD_POWER_OFF; int power_on = MAINBOARD_POWER_OFF;
u8 addr, value; u8 value;
get_option(&power_on, "power_on_after_fail"); get_option(&power_on, "power_on_after_fail");
if (power_on == MAINBOARD_POWER_OFF)
return;
pnp_enter_conf_mode(dev); pnp_enter_conf_mode(dev);
pnp_set_logical_device(dev); pnp_set_logical_device(dev);
addr = power_on == MAINBOARD_POWER_KEEP ? 0xf2 : 0xf4;
value = pnp_read_config(dev, addr); value = pnp_read_config(dev, IT8720F_EC_PCR1);
value |= BIT(5); if (power_on == MAINBOARD_POWER_KEEP)
pnp_write_config(dev, addr, value); 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); pnp_exit_conf_mode(dev);
} }