drvs/lenovo/hybrid_graphics/romstage: Fix dGPU activation

While the older boards use a GPIO that has no state, the newer boards'
PMH7 does have a state, that even remains after reboot.

Don't assume default values in PMH7 and instead always program it.

Fixes dGPU doesn't show up when switching from integrated to discrete
GPU. The workaround of removing all power is no longer necessary.

Change-Id: I30ec19e13269cb254e51ad1fab3b10ad1a49e86e
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-on: https://review.coreboot.org/22341
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
This commit is contained in:
Patrick Rudolph 2017-11-04 20:13:22 +01:00 committed by Martin Roth
parent 35325e1688
commit e07e39098a
1 changed files with 19 additions and 8 deletions

View File

@ -76,20 +76,31 @@ void early_hybrid_graphics(bool *enable_igd, bool *enable_peg)
}
/*
* Need to do power handling here as we know there's a dGPU to
* turn off. Support GPIO and Thinker1.
* Need to do power handling here as we know there's a dGPU.
* Support GPIO and Thinker1.
*/
if (!*enable_peg) {
if (config->has_dgpu_power_gpio) {
if (config->has_dgpu_power_gpio) {
if (*enable_peg)
set_gpio(config->dgpu_power_gpio,
!config->dgpu_power_off_lvl);
else
set_gpio(config->dgpu_power_gpio,
config->dgpu_power_off_lvl);
} else if (config->has_thinker1) {
} else if (config->has_thinker1) {
const size_t power_en = !!(pmh7_register_read(0x50) & 0x08);
if (*enable_peg && !power_en) {
pmh7_register_clear_bit(0x50, 7); // DGPU_RST
pmh7_register_set_bit(0x50, 3); // DGPU_PWR
mdelay(10);
pmh7_register_set_bit(0x50, 7); // DGPU_RST
mdelay(50);
} else if (!*enable_peg && power_en) {
pmh7_register_clear_bit(0x50, 7); // DGPU_RST
udelay(100);
pmh7_register_clear_bit(0x50, 3); // DGPU_PWR
} else {
printk(BIOS_ERR, "Hybrid graphics:"
" FIXME: dGPU power not disabled !\n");
}
} else {
printk(BIOS_ERR, "Hybrid graphics:"
" FIXME: dGPU power handling not implemented\n");
}
}