<p>Patrick Rudolph has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/20793">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">mb/lenovo/t400: Switch to new hybrid graphics driver<br><br>Use new hybrid graphics driver to get device state.<br>Move remaining code to romstage.c.<br><br>Tested on Lenovo T500:<br>* Linux 4.11.4 on Fedora 25<br>* Integrated (using NGI)<br>* Discrete (using VGA OpROM)<br>* Switchable (using NGI and VGA OpROM), tested with DRI_PRIME<br><br>No regressions found.<br><br>Change-Id: Iad2eccaab19c71f11308853ba9326d8186e67c93<br>Signed-off-by: Patrick Rudolph <siro@das-labor.org><br>---<br>M src/drivers/lenovo/hybrid_graphics.c<br>M src/mainboard/lenovo/t400/Kconfig<br>M src/mainboard/lenovo/t400/Makefile.inc<br>M src/mainboard/lenovo/t400/devicetree.cb<br>D src/mainboard/lenovo/t400/hybrid_graphics.c<br>M src/mainboard/lenovo/t400/romstage.c<br>6 files changed, 29 insertions(+), 104 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/93/20793/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/src/drivers/lenovo/hybrid_graphics.c b/src/drivers/lenovo/hybrid_graphics.c<br>index 9b46646..802823a 100644<br>--- a/src/drivers/lenovo/hybrid_graphics.c<br>+++ b/src/drivers/lenovo/hybrid_graphics.c<br>@@ -112,14 +112,3 @@<br>      .vendor  = PCI_VENDOR_ID_NVIDIA,<br>      .devices = pci_device_ids_nvidia,<br> };<br>-<br>-static const unsigned short pci_device_ids_amd[] = {<br>-             0x9591, /* ATI Mobility Radeon HD 3650 Lenovo T500/W500 */<br>-           0x95c4, /* ATI Mobility Radeon HD 3470 Lenovo T400/R400 */<br>-           0 };<br>-<br>-static const struct pci_driver hybrid_peg_amd __pci_driver = {<br>-     .ops     = &hybrid_graphics_ops,<br>- .vendor  = PCI_VENDOR_ID_ATI,<br>-        .devices = pci_device_ids_amd,<br>-};<br>diff --git a/src/mainboard/lenovo/t400/Kconfig b/src/mainboard/lenovo/t400/Kconfig<br>index decbab7f..8eb5fc5 100644<br>--- a/src/mainboard/lenovo/t400/Kconfig<br>+++ b/src/mainboard/lenovo/t400/Kconfig<br>@@ -21,6 +21,7 @@<br>  select INTEL_INT15<br>    select SUPERIO_NSC_PC87382<br>    select SUPERIO_NSC_PC87384<br>+   select DRIVERS_LENOVO_HYBRID_GRAPHICS<br> <br> config MAINBOARD_DIR<br>       string<br>diff --git a/src/mainboard/lenovo/t400/Makefile.inc b/src/mainboard/lenovo/t400/Makefile.inc<br>index 8ac61bb..c2c82b6 100644<br>--- a/src/mainboard/lenovo/t400/Makefile.inc<br>+++ b/src/mainboard/lenovo/t400/Makefile.inc<br>@@ -17,5 +17,4 @@<br> <br> ramstage-y += dock.c<br> ramstage-y += cstates.c<br>-romstage-y += hybrid_graphics.c<br> ramstage-y += blc.c<br>diff --git a/src/mainboard/lenovo/t400/devicetree.cb b/src/mainboard/lenovo/t400/devicetree.cb<br>index 1adba8b..02a9e72 100644<br>--- a/src/mainboard/lenovo/t400/devicetree.cb<br>+++ b/src/mainboard/lenovo/t400/devicetree.cb<br>@@ -206,6 +206,19 @@<br>                                     end<br>                           end<br> <br>+                               chip drivers/lenovo/hybrid_graphics<br>+                                  device pnp ff.f on end # dummy<br>+<br>+                                    register "detect_gpio" = "21"<br>+<br>+                                 register "has_panel_hybrid_gpio" = "1"<br>+                                   register "panel_hybrid_gpio" = "22"<br>+                                      register "panel_integrated_lvl" = "0"<br>+<br>+                                 register "has_backlight_gpio" = "1"<br>+                                      register "backlight_gpio" = "19"<br>+                                 register "backlight_integrated_lvl" = "0"<br>+                                end<br>                   end<br>                   device pci 1f.2 on # SATA/IDE 1<br>                               subsystemid 0x17aa 0x20f8<br>diff --git a/src/mainboard/lenovo/t400/hybrid_graphics.c b/src/mainboard/lenovo/t400/hybrid_graphics.c<br>deleted file mode 100644<br>index b313ffa..0000000<br>--- a/src/mainboard/lenovo/t400/hybrid_graphics.c<br>+++ /dev/null<br>@@ -1,91 +0,0 @@<br>-/*<br>- * This file is part of the coreboot project.<br>- *<br>- * Copyright (C) 2012 secunet Security Networks AG<br>- *<br>- * This program is free software; you can redistribute it and/or<br>- * modify it under the terms of the GNU General Public License as<br>- * published by the Free Software Foundation; version 2 of<br>- * the License.<br>- *<br>- * This program is distributed in the hope that it will be useful,<br>- * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>- * GNU General Public License for more details.<br>- */<br>-#include <stdint.h><br>-#include <string.h><br>-#include <southbridge/intel/common/gpio.h><br>-#include <northbridge/intel/gm45/gm45.h><br>-#include <console/console.h><br>-#include <option.h><br>-<br>-#define HYBRID_GRAPHICS_INTEGRATED_ONLY 0<br>-#define HYBRID_GRAPHICS_DISCRETE_ONLY 1<br>-#define HYBRID_GRAPHICS_SWITCHABLE 2<br>-<br>-#define MUX_GPIO 22<br>-#define BCL_CTL_GPIO 19<br>-#define GFX_PWR_EN_GPIO 49<br>-<br>-#define HYBRID_DETECT_GPIO 21<br>-<br>-void hybrid_graphics_init(sysinfo_t *sysinfo);<br>-<br>-static bool hybrid_graphics_installed(void)<br>-{<br>-  if (get_gpio(HYBRID_DETECT_GPIO))<br>-            return false;<br>-        else<br>-         return true;<br>-}<br>-<br>-void hybrid_graphics_init(sysinfo_t *sysinfo)<br>-{<br>-      /* Set default mode */<br>-       uint8_t hybrid_graphics_mode =<br>-           HYBRID_GRAPHICS_INTEGRATED_ONLY;<br>-<br>-      if (!hybrid_graphics_installed()) {<br>-          printk(BIOS_DEBUG, "Hybrid graphics not installed.\n");<br>-            /* The display is not connected to a mux or switchable. */<br>-           sysinfo->enable_igd = 1;<br>-          sysinfo->enable_peg = 0;<br>-          return;<br>-      }<br>-<br>- printk(BIOS_DEBUG, "Hybrid graphics available: ");<br>- get_option(&hybrid_graphics_mode, "hybrid_graphics_mode");<br>-<br>-  /* Select appropriate hybrid graphics device */<br>-      switch (hybrid_graphics_mode) {<br>-      default:<br>-     case HYBRID_GRAPHICS_INTEGRATED_ONLY:<br>-                printk(BIOS_DEBUG, "Activating Integrated Only.\n");<br>-               set_gpio(MUX_GPIO, GPIO_LEVEL_LOW);<br>-          set_gpio(BCL_CTL_GPIO, GPIO_LEVEL_LOW);<br>-              set_gpio(GFX_PWR_EN_GPIO, GPIO_LEVEL_LOW);<br>-<br>-                sysinfo->enable_igd = 1;<br>-          sysinfo->enable_peg = 0;<br>-          break;<br>-       case HYBRID_GRAPHICS_DISCRETE_ONLY:<br>-          printk(BIOS_DEBUG, "Activating Discrete Only.\n");<br>-         set_gpio(MUX_GPIO, GPIO_LEVEL_HIGH);<br>-         set_gpio(BCL_CTL_GPIO, GPIO_LEVEL_HIGH);<br>-             set_gpio(GFX_PWR_EN_GPIO, GPIO_LEVEL_HIGH);<br>-<br>-               sysinfo->enable_igd = 0;<br>-          sysinfo->enable_peg = 1;<br>-          break;<br>-       case HYBRID_GRAPHICS_SWITCHABLE:<br>-             printk(BIOS_DEBUG, "Activating Switchable (both GPUs).\n");<br>-                set_gpio(MUX_GPIO, GPIO_LEVEL_LOW);<br>-          set_gpio(BCL_CTL_GPIO, GPIO_LEVEL_LOW);<br>-              set_gpio(GFX_PWR_EN_GPIO, GPIO_LEVEL_HIGH);<br>-<br>-               sysinfo->enable_igd = 1;<br>-          sysinfo->enable_peg = 1;<br>-          break;<br>-       }<br>-}<br>diff --git a/src/mainboard/lenovo/t400/romstage.c b/src/mainboard/lenovo/t400/romstage.c<br>index 2d35650..5f4ac4b 100644<br>--- a/src/mainboard/lenovo/t400/romstage.c<br>+++ b/src/mainboard/lenovo/t400/romstage.c<br>@@ -31,6 +31,7 @@<br> #include <console/console.h><br> #include <southbridge/intel/i82801ix/i82801ix.h><br> #include <northbridge/intel/gm45/gm45.h><br>+#include <drivers/lenovo/hybrid_graphics/hybrid_graphics.h><br> #include <timestamp.h><br> #include "dock.h"<br> #include "gpio.h"<br>@@ -38,7 +39,20 @@<br> #define LPC_DEV PCI_DEV(0, 0x1f, 0)<br> #define MCH_DEV PCI_DEV(0, 0, 0)<br> <br>-void hybrid_graphics_init(sysinfo_t *sysinfo);<br>+#define GFX_PWR_EN_GPIO 49<br>+<br>+static void hybrid_graphics_init(sysinfo_t *sysinfo)<br>+{<br>+  bool peg, igd;<br>+<br>+    early_hybrid_graphics(&igd, &peg);<br>+<br>+        sysinfo->enable_igd = igd;<br>+        sysinfo->enable_peg = peg;<br>+<br>+     /* Toggle dGPU power */<br>+      set_gpio(GFX_PWR_EN_GPIO, peg ? GPIO_LEVEL_HIGH : GPIO_LEVEL_LOW);<br>+}<br> <br> static void early_lpc_setup(void)<br> {<br></pre><p>To view, visit <a href="https://review.coreboot.org/20793">change 20793</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/20793"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Iad2eccaab19c71f11308853ba9326d8186e67c93 </div>
<div style="display:none"> Gerrit-Change-Number: 20793 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Patrick Rudolph <siro@das-labor.org> </div>