Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/20792
Change subject: drvs/lenovo/hybrid_graphics: Add new hybrid graphics driver
......................................................................
drvs/lenovo/hybrid_graphics: Add new hybrid graphics driver
Introduce a chip_driver that uses devicetree instead of Kconfig.
The new driver has the following advantages:
* No more wasted IGD GFX stolen memory
* Can be used by T500 series
* Is even run on devices that do not have a dGPU installed
* Can disable unused PEG port on devices without dGPU (and save power)
* Use devicetree instead of Kconfig options
* Support for multiple hybrid GPIO active levels
* Support for backlight control GPIO
* Support for _ROM on Optimus capable devices
The driver is split into romstage part and ramstage part.
Every mainboard has to call the driver in romstage to get the requested
GPU state. The mainboard code then has to toggle GPU power or disable the
IGD or PEG port.
The ramstage part does handle the hygrid graphics GPIO, including optional
backlight mux GPIO. Every GPIO can have it's own active level, as defined
in devicetree. Devices are no longer disabled in ramstage.
The existing hybrid graphics driver does the same configuration and should
not interfere with this commit until it has been removed.
Change-Id: Ie467f9a18b35ab3b8a523dbf51c5575db5b374a5
Signed-off-by: Patrick Rudolph <siro(a)das-labor.org>
---
A src/drivers/lenovo/hybrid_graphics/Kconfig
A src/drivers/lenovo/hybrid_graphics/Makefile.inc
A src/drivers/lenovo/hybrid_graphics/chip.h
A src/drivers/lenovo/hybrid_graphics/hybrid_graphics.c
A src/drivers/lenovo/hybrid_graphics/hybrid_graphics.h
A src/drivers/lenovo/hybrid_graphics/romstage.c
6 files changed, 232 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/92/20792/1
diff --git a/src/drivers/lenovo/hybrid_graphics/Kconfig b/src/drivers/lenovo/hybrid_graphics/Kconfig
new file mode 100644
index 0000000..389dfb9
--- /dev/null
+++ b/src/drivers/lenovo/hybrid_graphics/Kconfig
@@ -0,0 +1,3 @@
+config DRIVERS_LENOVO_HYBRID_GRAPHICS
+ bool
+ default n
diff --git a/src/drivers/lenovo/hybrid_graphics/Makefile.inc b/src/drivers/lenovo/hybrid_graphics/Makefile.inc
new file mode 100644
index 0000000..d9e5079
--- /dev/null
+++ b/src/drivers/lenovo/hybrid_graphics/Makefile.inc
@@ -0,0 +1,15 @@
+#
+# This file is part of the coreboot project.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+ramstage-$(CONFIG_DRIVERS_LENOVO_HYBRID_GRAPHICS) += hybrid_graphics.c
+romstage-$(CONFIG_DRIVERS_LENOVO_HYBRID_GRAPHICS) += romstage.c
diff --git a/src/drivers/lenovo/hybrid_graphics/chip.h b/src/drivers/lenovo/hybrid_graphics/chip.h
new file mode 100644
index 0000000..d5ce74e
--- /dev/null
+++ b/src/drivers/lenovo/hybrid_graphics/chip.h
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2017 Patrick Rudolph <siro(a)das-labor.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _LENOVO_HYBRID_GRAPHICS_CHIP_H_
+#define _LENOVO_HYBRID_GRAPHICS_CHIP_H_
+
+#define HYBRID_GRAPHICS_PORT 0xff
+
+#define HYBRID_GRAPHICS_DEVICE 0xf
+
+enum hybrid_graphics_req {
+ HYBRID_GRAPHICS_INTEGRATED = 0,
+ HYBRID_GRAPHICS_DISCRETE = 1,
+ HYBRID_GRAPHICS_DUAL = 2
+};
+
+enum dgpu_detect_lvl {
+ DGPU_INSTALLED = 0,
+ DGPU_NOT_INSTALLED = 1,
+};
+
+struct drivers_lenovo_hybrid_graphics_config {
+ unsigned int detect_gpio;
+
+ unsigned int has_panel_hybrid_gpio;
+ unsigned int panel_hybrid_gpio;
+ unsigned int panel_integrated_lvl;
+
+ unsigned int has_backlight_gpio;
+ unsigned int backlight_gpio;
+ unsigned int backlight_integrated_lvl;
+};
+
+#endif /* _LENOVO_HYBRID_GRAPHICS_CHIP_H_ */
diff --git a/src/drivers/lenovo/hybrid_graphics/hybrid_graphics.c b/src/drivers/lenovo/hybrid_graphics/hybrid_graphics.c
new file mode 100644
index 0000000..ab13747
--- /dev/null
+++ b/src/drivers/lenovo/hybrid_graphics/hybrid_graphics.c
@@ -0,0 +1,73 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2017 Patrick Rudolph <siro(a)das-labor.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <types.h>
+#include <option.h>
+#include <device/device.h>
+#include <device/pci_def.h>
+
+#include <southbridge/intel/common/gpio.h>
+#include <console/console.h>
+#include "chip.h"
+
+/*
+ * Switch panel mux or backlight mux to active GPU.
+ * In case both GPUs are active switch panel mux to integrated.
+ */
+static void lenovo_hybrid_graphics_enable(struct device *dev)
+{
+ const struct drivers_lenovo_hybrid_graphics_config *config;
+ enum hybrid_graphics_req mode = HYBRID_GRAPHICS_INTEGRATED;
+
+ /* Don't confuse anyone else and disable the fake device */
+ dev->enabled = 0;
+
+ config = dev->chip_info;
+ if (!config || (get_gpio(config->detect_gpio) == DGPU_NOT_INSTALLED)) {
+ printk(BIOS_DEBUG, "Hybrid graphics: Not installed\n");
+ return;
+ }
+
+ get_option(&mode, "hybrid_graphics_mode");
+
+ if (mode == HYBRID_GRAPHICS_DISCRETE) {
+ printk(BIOS_DEBUG, "Hybrid graphics:"
+ " Switching panel to discrete GPU.\n");
+
+ if (config->has_panel_hybrid_gpio)
+ set_gpio(config->panel_hybrid_gpio,
+ ~config->panel_integrated_lvl);
+
+ if (config->has_backlight_gpio)
+ set_gpio(config->backlight_gpio,
+ ~config->backlight_integrated_lvl);
+ } else {
+ printk(BIOS_DEBUG, "Hybrid graphics:"
+ " Switching panel to integrated GPU.\n");
+
+ if (config->has_panel_hybrid_gpio)
+ set_gpio(config->panel_hybrid_gpio,
+ config->panel_integrated_lvl);
+
+ if (config->has_backlight_gpio)
+ set_gpio(config->backlight_gpio,
+ config->backlight_integrated_lvl);
+ }
+}
+
+struct chip_operations drivers_lenovo_hybrid_graphics_ops = {
+ CHIP_NAME("Lenovo hybrid graphics driver")
+ .enable_dev = &lenovo_hybrid_graphics_enable
+};
diff --git a/src/drivers/lenovo/hybrid_graphics/hybrid_graphics.h b/src/drivers/lenovo/hybrid_graphics/hybrid_graphics.h
new file mode 100644
index 0000000..b238440
--- /dev/null
+++ b/src/drivers/lenovo/hybrid_graphics/hybrid_graphics.h
@@ -0,0 +1,21 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2017 Patrick Rudolph <siro(a)das-labor.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _DRIVERS_LENOVO_HYBRID_GRAPHICS_H_
+#define _DRIVERS_LENOVO_HYBRID_GRAPHICS_H_
+
+void early_hybrid_graphics(bool *enable_igd, bool *enable_peg);
+
+#endif /* _DRIVERS_LENOVO_HYBRID_GRAPHICS_CHIP_H_ */
diff --git a/src/drivers/lenovo/hybrid_graphics/romstage.c b/src/drivers/lenovo/hybrid_graphics/romstage.c
new file mode 100644
index 0000000..53eb4a0
--- /dev/null
+++ b/src/drivers/lenovo/hybrid_graphics/romstage.c
@@ -0,0 +1,74 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2017 Patrick Rudolph <siro(a)das-labor.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <types.h>
+#include <option.h>
+#include <device/device.h>
+#include <device/pci_def.h>
+
+#include <southbridge/intel/common/gpio.h>
+#include <console/console.h>
+#include "hybrid_graphics.h"
+#include "chip.h"
+
+/*
+ * Returns the hybrid graphics presence and user's card preferences.
+ */
+void early_hybrid_graphics(bool *enable_igd, bool *enable_peg)
+{
+ const struct drivers_lenovo_hybrid_graphics_config *config;
+ const struct device *dev;
+ enum hybrid_graphics_req mode = HYBRID_GRAPHICS_INTEGRATED;
+
+ dev = dev_find_slot_pnp(HYBRID_GRAPHICS_PORT, HYBRID_GRAPHICS_DEVICE);
+
+ if (!dev || !dev->chip_info) {
+ printk(BIOS_ERR, "Hybrid graphics: ERROR\n");
+ *enable_igd = true;
+ *enable_peg = false;
+ return;
+ }
+
+ config = dev->chip_info;
+ if (get_gpio(config->detect_gpio) == DGPU_NOT_INSTALLED) {
+ printk(BIOS_DEBUG, "Hybrid graphics:"
+ " No discrete GPU present.\n");
+ *enable_igd = true;
+ *enable_peg = false;
+ return;
+ }
+
+ get_option(&mode, "hybrid_graphics_mode");
+
+ if (mode == HYBRID_GRAPHICS_DISCRETE) {
+ printk(BIOS_DEBUG, "Hybrid graphics:"
+ " Disabling integrated GPU.\n");
+
+ *enable_igd = false;
+ *enable_peg = true;
+ } else if (mode == HYBRID_GRAPHICS_INTEGRATED) {
+ printk(BIOS_DEBUG, "Hybrid graphics:"
+ " Disabling discrete GPU.\n");
+
+ *enable_igd = true;
+ *enable_peg = false;
+ } else {
+ printk(BIOS_DEBUG, "Hybrid graphics:"
+ " Activating Switchable (both GPUs).\n");
+
+ *enable_igd = true;
+ *enable_peg = true;
+ }
+}
--
To view, visit https://review.coreboot.org/20792
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie467f9a18b35ab3b8a523dbf51c5575db5b374a5
Gerrit-Change-Number: 20792
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <siro(a)das-labor.org>
Marshall Dawson has uploaded this change for review. ( https://review.coreboot.org/20790
Change subject: soc/amd/stoneyridge: Clarify BAR mask in SPI base
......................................................................
soc/amd/stoneyridge: Clarify BAR mask in SPI base
The format of the D14F3xA0 SPI Base_Addr register is different
than a traditional BAR. Change the function to preserve any
enables already in place. Change the AND mask to remove the
reserved field and the enables.
Change-Id: I9a43c029a2e1576703ce9cdc787d18658e9190a5
Signed-off-by: Marshall Dawson <marshalldawson3rd(a)gmail.com>
---
M src/soc/amd/stoneyridge/early_setup.c
1 file changed, 6 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/20790/1
diff --git a/src/soc/amd/stoneyridge/early_setup.c b/src/soc/amd/stoneyridge/early_setup.c
index 68bccc4..ca3447f 100644
--- a/src/soc/amd/stoneyridge/early_setup.c
+++ b/src/soc/amd/stoneyridge/early_setup.c
@@ -242,13 +242,16 @@
{
/* Make sure the base address is predictable */
device_t dev = PCI_DEV(0, PCU_DEV, LPC_FUNC);
+ u32 base, enables;
- u32 base = pci_read_config32(dev, SPIROM_BASE_ADDRESS_REGISTER)
- & 0xfffffff0;
+ base = pci_read_config32(dev, SPIROM_BASE_ADDRESS_REGISTER);
+ enables = base & 0xf;
+ base &= ~0x3f;
+
if (!base) {
base = SPI_BASE_ADDRESS;
pci_write_config32(dev, SPIROM_BASE_ADDRESS_REGISTER, base
- | SPI_ROM_ENABLE);
+ | enables | SPI_ROM_ENABLE);
/* PCI_COMMAND_MEMORY is read-only and enabled. */
}
return (uintptr_t)base;
--
To view, visit https://review.coreboot.org/20790
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9a43c029a2e1576703ce9cdc787d18658e9190a5
Gerrit-Change-Number: 20790
Gerrit-PatchSet: 1
Gerrit-Owner: Marshall Dawson <marshalldawson3rd(a)gmail.com>