mb/lenovo: Support dual graphics for xx20/xx30 ThinkPads
Add CMOS option that allows to use both integrated and discrete GPU.
Tested on ThinkPad W530.
Change-Id: I8842fef0fa1235eb91abf6b7e655ed4d8598adc7
Signed-off-by: Evgeny Zinoviev <me@ch1p.com>
Reviewed-on: https://review.coreboot.org/28393
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/ec/lenovo/pmh7/pmh7.c b/src/ec/lenovo/pmh7/pmh7.c
index b160fd0..f7b798b 100644
--- a/src/ec/lenovo/pmh7/pmh7.c
+++ b/src/ec/lenovo/pmh7/pmh7.c
@@ -19,6 +19,7 @@
#include <device/pnp.h>
#include <stdlib.h>
#include <pc80/mc146818rtc.h>
+#include <delay.h>
#include "pmh7.h"
#include "chip.h"
@@ -64,6 +65,26 @@
pmh7_register_set_bit(0x62, 0);
}
+void pmh7_dgpu_power_enable(int onoff)
+{
+ if (onoff) {
+ 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 {
+ pmh7_register_clear_bit(0x50, 7); // DGPU_RST
+ udelay(100);
+ pmh7_register_clear_bit(0x50, 3); // DGPU_PWR
+ }
+}
+
+bool pmh7_dgpu_power_state(void)
+{
+ return (pmh7_register_read(0x50) & 0x08) == 8;
+}
+
void pmh7_register_set_bit(int reg, int bit)
{
char val;
diff --git a/src/ec/lenovo/pmh7/pmh7.h b/src/ec/lenovo/pmh7/pmh7.h
index d486ceb..a641fce 100644
--- a/src/ec/lenovo/pmh7/pmh7.h
+++ b/src/ec/lenovo/pmh7/pmh7.h
@@ -35,5 +35,7 @@
void pmh7_touchpad_enable(int onoff);
void pmh7_ultrabay_power_enable(int onoff);
void pmh7_trackpoint_enable(int onoff);
+void pmh7_dgpu_power_enable(int onoff);
+bool pmh7_dgpu_power_state(void);
#endif /* EC_LENOVO_PMH7_H */