From e07e39098aaac1c0be80bae6447b04de530da949 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Sat, 4 Nov 2017 20:13:22 +0100 Subject: 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 Reviewed-on: https://review.coreboot.org/22341 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans --- src/drivers/lenovo/hybrid_graphics/romstage.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/lenovo/hybrid_graphics/romstage.c b/src/drivers/lenovo/hybrid_graphics/romstage.c index 9009c5841a..8814916872 100644 --- a/src/drivers/lenovo/hybrid_graphics/romstage.c +++ b/src/drivers/lenovo/hybrid_graphics/romstage.c @@ -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"); } } -- cgit v1.2.3