[coreboot-gerrit] New patch to review for coreboot: ec/lenovo/pmh7: Add discrete GPU power function

Patrick Rudolph (siro@das-labor.org) gerrit at coreboot.org
Tue May 3 09:06:51 CEST 2016


Patrick Rudolph (siro at das-labor.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14578

-gerrit

commit e8bbbfb0a872b762df556ee5db4fc2a5ba279a11
Author: Patrick Rudolph <siro at das-labor.org>
Date:   Tue May 3 08:55:15 2016 +0200

    ec/lenovo/pmh7: Add discrete GPU power function
    
    Allow to switch power on Lenovo laptops with discrete GPU.
    Switching of GPU power decreases idle power by 5W.
    
    Tested on Lenovo T520.
    Needs tests on all other Lenovo devices.
    
    Change-Id: I310a3912673558cd1af0582b7f2b23f957473c42
    Signed-off-by: Patrick Rudolph <siro at das-labor.org>
---
 src/drivers/lenovo/hybrid_graphics.c |  4 ++++
 src/ec/lenovo/pmh7/pmh7.c            | 18 +++++++++++++++++-
 src/ec/lenovo/pmh7/pmh7.h            |  1 +
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/drivers/lenovo/hybrid_graphics.c b/src/drivers/lenovo/hybrid_graphics.c
index a90a465..603cef8 100644
--- a/src/drivers/lenovo/hybrid_graphics.c
+++ b/src/drivers/lenovo/hybrid_graphics.c
@@ -24,6 +24,7 @@
 #include <device/pci.h>
 #include <console/console.h>
 #include <southbridge/intel/common/gpio.h>
+#include <ec/lenovo/pmh7/pmh7.h>
 
 /* Hybrid graphics allows to connect LVDS interface to either iGPU
  * or dGPU depending on GPIO level.
@@ -51,6 +52,9 @@ static void hybrid_graphics_disable_peg(struct device *dev)
 	if (peg_dev)
 		peg_dev->enabled = 0;
 
+	/* Disable power */
+	pmh7_discrete_gpu_enable(0);
+
 	printk(BIOS_DEBUG, "Hybrid graphics: Disabled PEG10.\n");
 }
 
diff --git a/src/ec/lenovo/pmh7/pmh7.c b/src/ec/lenovo/pmh7/pmh7.c
index b2c3c08..bb06094 100644
--- a/src/ec/lenovo/pmh7/pmh7.c
+++ b/src/ec/lenovo/pmh7/pmh7.c
@@ -18,11 +18,25 @@
 #include <device/device.h>
 #include <device/pnp.h>
 #include <stdlib.h>
-#include <pc80/mc146818rtc.h>
+#include <option.h>
 
 #include "pmh7.h"
 #include "chip.h"
 
+void pmh7_discrete_gpu_enable(int onoff)
+{
+	/* based on Lenovo T520 */
+	if (onoff) {
+		pmh7_register_set_bit(0x50, 3);
+		pmh7_register_set_bit(0x50, 6);
+		pmh7_register_set_bit(0x50, 7);
+	} else {
+		pmh7_register_clear_bit(0x50, 3);
+		pmh7_register_clear_bit(0x50, 6);
+		pmh7_register_clear_bit(0x50, 7);
+	}
+}
+
 void pmh7_backlight_enable(int onoff)
 {
 	if (onoff)
@@ -121,6 +135,8 @@ static void enable_dev(struct device *dev)
 	if (get_option(&val, "trackpoint") != CB_SUCCESS)
 		val = 1;
 	pmh7_trackpoint_enable(val);
+
+	pmh7_discrete_gpu_enable(1);
 }
 
 struct chip_operations ec_lenovo_pmh7_ops = {
diff --git a/src/ec/lenovo/pmh7/pmh7.h b/src/ec/lenovo/pmh7/pmh7.h
index 772312c..2894d4b 100644
--- a/src/ec/lenovo/pmh7/pmh7.h
+++ b/src/ec/lenovo/pmh7/pmh7.h
@@ -27,6 +27,7 @@ void pmh7_register_clear_bit(int reg, int bit);
 char pmh7_register_read(int reg);
 void pmh7_register_write(int reg, int val);
 
+void pmh7_discrete_gpu_enable(int onoff);
 void pmh7_backlight_enable(int onoff);
 void pmh7_dock_event_enable(int onoff);
 void pmh7_touchpad_enable(int onoff);



More information about the coreboot-gerrit mailing list