[coreboot-gerrit] Change in coreboot[master]: soc/intel/common/block: Add Intel common Graphics controller support

Subrata Banik (Code Review) gerrit at coreboot.org
Tue Nov 28 14:10:33 CET 2017


Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/22614


Change subject: soc/intel/common/block: Add Intel common Graphics controller support
......................................................................

soc/intel/common/block: Add Intel common Graphics controller support

SoC need to select specific macros to compile common
graphics code.

Change-Id: Idbc73854ce9fc21a8a3e3663a98e01fc94d5a5e4
Signed-off-by: Subrata Banik <subrata.banik at intel.com>
---
A src/soc/intel/common/block/graphics/Kconfig
A src/soc/intel/common/block/graphics/Makefile.inc
A src/soc/intel/common/block/graphics/graphics.c
A src/soc/intel/common/block/include/intelblocks/graphics.h
4 files changed, 184 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/22614/1

diff --git a/src/soc/intel/common/block/graphics/Kconfig b/src/soc/intel/common/block/graphics/Kconfig
new file mode 100644
index 0000000..4ab9200
--- /dev/null
+++ b/src/soc/intel/common/block/graphics/Kconfig
@@ -0,0 +1,4 @@
+config SOC_INTEL_COMMON_BLOCK_GRAPHICS
+	bool
+	help
+	  Intel Processor common Graphics support
diff --git a/src/soc/intel/common/block/graphics/Makefile.inc b/src/soc/intel/common/block/graphics/Makefile.inc
new file mode 100644
index 0000000..44dfc7e
--- /dev/null
+++ b/src/soc/intel/common/block/graphics/Makefile.inc
@@ -0,0 +1 @@
+ramstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_GRAPHICS) += graphics.c
diff --git a/src/soc/intel/common/block/graphics/graphics.c b/src/soc/intel/common/block/graphics/graphics.c
new file mode 100644
index 0000000..f35725c
--- /dev/null
+++ b/src/soc/intel/common/block/graphics/graphics.c
@@ -0,0 +1,128 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2017 Intel Corp.
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 <device/device.h>
+#include <device/pci.h>
+#include <device/pci_ids.h>
+#include <intelblocks/graphics.h>
+#include <soc/pci_devs.h>
+
+/* SoC Overrides */
+__attribute__((weak)) void graphics_soc_init(struct device *dev)
+{
+	/* no-op */
+}
+
+__attribute__((weak)) uintptr_t graphics_soc_write_acpi_opregion(
+		device_t device, uintptr_t current,
+		struct acpi_rsdp *rsdp)
+{
+	return 0;
+}
+
+uintptr_t graphics_get_memory_base(void)
+{
+	struct device *dev = SA_DEV_IGD;
+	struct resource *gm_res;
+
+	/*
+	 * GFX PCI config space offset 0x18 know as Graphics
+	 * Memory Range Address (GMADR)
+	 */
+	gm_res = find_resource(dev, PCI_BASE_ADDRESS_2);
+	if (!gm_res || !gm_res->base)
+		return 0;
+
+	return gm_res->base;
+}
+
+static uintptr_t graphics_get_gtt_base(void)
+{
+	struct device *dev = SA_DEV_IGD;
+	struct resource *gtt_res;
+
+	/*
+	 * GFX PCI config space offset 0x10 know as Graphics
+	 * Translation Table Memory Mapped Range Address
+	 * (GTTMMADR)
+	 */
+	gtt_res = find_resource(dev, PCI_BASE_ADDRESS_0);
+	if (!gtt_res || !gtt_res->base)
+		return 0;
+
+	return gtt_res->base;
+}
+
+uintptr_t graphics_gtt_read(uintptr_t reg)
+{
+	uint32_t val;
+	val = read32((void *)(graphics_get_gtt_base() + reg));
+	return val;
+}
+
+void graphics_gtt_write(uintptr_t reg, uintptr_t data)
+{
+	write32((void *)(graphics_get_gtt_base() + reg), data);
+}
+
+void graphics_gtt_rmw(uint32_t reg, uint32_t andmask, uint32_t ormask)
+{
+	uint32_t val = graphics_gtt_read(reg);
+	val &= andmask;
+	val |= ormask;
+	graphics_gtt_write(reg, val);
+}
+
+static const struct device_operations graphics_ops = {
+	.read_resources   = pci_dev_read_resources,
+	.set_resources    = pci_dev_set_resources,
+	.enable_resources = pci_dev_enable_resources,
+	.init             = graphics_soc_init,
+	.write_acpi_tables = graphics_soc_write_acpi_opregion,
+};
+
+static const unsigned short pci_device_ids[] = {
+	PCI_DEVICE_ID_INTEL_APL_IGD_HD_505,
+	PCI_DEVICE_ID_INTEL_APL_IGD_HD_500,
+	PCI_DEVICE_ID_INTEL_CNL_GT2_ULX_1,
+	PCI_DEVICE_ID_INTEL_CNL_GT2_ULX_2,
+	PCI_DEVICE_ID_INTEL_CNL_GT2_ULX_3,
+	PCI_DEVICE_ID_INTEL_CNL_GT2_ULX_4,
+	PCI_DEVICE_ID_INTEL_CNL_GT2_ULT_1,
+	PCI_DEVICE_ID_INTEL_CNL_GT2_ULT_2,
+	PCI_DEVICE_ID_INTEL_CNL_GT2_ULT_3,
+	PCI_DEVICE_ID_INTEL_CNL_GT2_ULT_4,
+	PCI_DEVICE_ID_INTEL_GLK_IGD,
+	PCI_DEVICE_ID_INTEL_GLK_IGD_EU12,
+	PCI_DEVICE_ID_INTEL_KBL_GT1_SULTM,
+	PCI_DEVICE_ID_INTEL_KBL_GT2_SULXM,
+	PCI_DEVICE_ID_INTEL_KBL_GT2_SULTM,
+	PCI_DEVICE_ID_INTEL_KBL_GT2_SULTMR,
+	PCI_DEVICE_ID_INTEL_KBL_GT2_SHALM,
+	PCI_DEVICE_ID_INTEL_SKL_GT1_SULTM,
+	PCI_DEVICE_ID_INTEL_SKL_GT2_SULXM,
+	PCI_DEVICE_ID_INTEL_SKL_GT2_SULTM,
+	PCI_DEVICE_ID_INTEL_SKL_GT2_SHALM,
+	PCI_DEVICE_ID_INTEL_SKL_GT2_SWKSM,
+	PCI_DEVICE_ID_INTEL_SKL_GT4_SHALM,
+	0,
+};
+
+static const struct pci_driver graphics_driver __pci_driver = {
+	.ops		= &graphics_ops,
+	.vendor		= PCI_VENDOR_ID_INTEL,
+	.devices	= pci_device_ids,
+};
diff --git a/src/soc/intel/common/block/include/intelblocks/graphics.h b/src/soc/intel/common/block/include/intelblocks/graphics.h
new file mode 100644
index 0000000..69a1f36
--- /dev/null
+++ b/src/soc/intel/common/block/include/intelblocks/graphics.h
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2017 Intel Corporation.
+ *
+ * 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 SOC_INTEL_COMMON_BLOCK_GRAPHICS_H
+#define SOC_INTEL_COMMON_BLOCK_GRAPHICS_H
+
+/*
+ * SoC overrides
+ *
+ * All new SoC must implement below functionality.
+ */
+
+/*
+ * Perform Graphics Initialization in ramstage
+ * Input:
+ * struct device *dev: device structure
+ */
+void graphics_soc_init(struct device *dev);
+
+/*
+ * Write ASL entry for Graphics opregion
+ * Input:
+ * device_t device: device structure
+ * current: start address of graphics opregion
+ * rsdp: pointer to RSDT (and XSDT) structure
+ *
+ * Output:
+ * 0 = Error, >0 = End address of graphics opregion
+ */
+uintptr_t graphics_soc_write_acpi_opregion(device_t device,
+		uintptr_t current, struct acpi_rsdp *rsdp);
+
+/* Graphics MMIO register read/write APIs */
+uintptr_t graphics_gtt_read(uintptr_t reg);
+void graphics_gtt_write(uintptr_t reg, uintptr_t data);
+void graphics_gtt_rmw(uint32_t reg, uint32_t andmask, uint32_t ormask);
+uintptr_t graphics_get_memory_base(void);
+
+#endif	/* SOC_INTEL_COMMON_BLOCK_GRAPHICS_H */

-- 
To view, visit https://review.coreboot.org/22614
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idbc73854ce9fc21a8a3e3663a98e01fc94d5a5e4
Gerrit-Change-Number: 22614
Gerrit-PatchSet: 1
Gerrit-Owner: Subrata Banik <subrata.banik at intel.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171128/14b41b14/attachment-0001.html>


More information about the coreboot-gerrit mailing list