soc: Remove copyright notices
[coreboot.git] / src / soc / intel / braswell / gfx.c
blob41b2c6f2a7332cd02010a536475c3fe2d4784bc3
1 /*
2 * This file is part of the coreboot project.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include "chip.h"
16 #include <console/console.h>
17 #include <device/device.h>
18 #include <device/pci.h>
19 #include <device/pci_ids.h>
20 #include <drivers/intel/gma/opregion.h>
21 #include <reg_script.h>
22 #include <soc/gfx.h>
23 #include <soc/nvs.h>
24 #include <soc/pci_devs.h>
25 #include <soc/ramstage.h>
27 static const struct reg_script gpu_pre_vbios_script[] = {
28 /* Make sure GFX is bus master with MMIO access */
29 REG_PCI_OR32(PCI_COMMAND, PCI_COMMAND_MASTER|PCI_COMMAND_MEMORY),
30 REG_SCRIPT_END
33 static const struct reg_script gfx_post_vbios_script[] = {
34 /* Set Lock bits */
35 REG_PCI_RMW32(GGC, 0xffffffff, GGC_GGCLCK),
36 REG_PCI_RMW32(GSM_BASE, 0xffffffff, GSM_BDSM_LOCK),
37 REG_PCI_RMW32(GTT_BASE, 0xffffffff, GTT_BGSM_LOCK),
38 REG_SCRIPT_END
41 static inline void gfx_run_script(struct device *dev,
42 const struct reg_script *ops)
44 reg_script_run_on_dev(dev, ops);
47 static void gfx_pre_vbios_init(struct device *dev)
49 printk(BIOS_SPEW, "%s/%s (%s)\n",
50 __FILE__, __func__, dev_name(dev));
51 printk(BIOS_INFO, "GFX: Pre VBIOS Init\n");
52 gfx_run_script(dev, gpu_pre_vbios_script);
55 static void gfx_post_vbios_init(struct device *dev)
57 printk(BIOS_SPEW, "%s/%s (%s)\n",
58 __FILE__, __func__, dev_name(dev));
59 printk(BIOS_INFO, "GFX: Post VBIOS Init\n");
60 gfx_run_script(dev, gfx_post_vbios_script);
63 static void gfx_init(struct device *dev)
65 printk(BIOS_SPEW, "%s/%s (%s)\n",
66 __FILE__, __func__, dev_name(dev));
68 if (!CONFIG(RUN_FSP_GOP)) {
69 /* Pre VBIOS Init */
70 gfx_pre_vbios_init(dev);
72 /* Run VBIOS */
73 pci_dev_init(dev);
75 /* Post VBIOS Init */
76 gfx_post_vbios_init(dev);
78 intel_gma_restore_opregion();
81 uintptr_t gma_get_gnvs_aslb(const void *gnvs)
83 const global_nvs_t *gnvs_ptr = gnvs;
84 return (uintptr_t)(gnvs_ptr ? gnvs_ptr->aslb : 0);
87 void gma_set_gnvs_aslb(void *gnvs, uintptr_t aslb)
89 global_nvs_t *gnvs_ptr = gnvs;
90 if (gnvs_ptr)
91 gnvs_ptr->aslb = aslb;
94 static struct device_operations gfx_device_ops = {
95 .read_resources = pci_dev_read_resources,
96 .set_resources = pci_dev_set_resources,
97 .enable_resources = pci_dev_enable_resources,
98 .init = gfx_init,
99 .ops_pci = &soc_pci_ops,
102 static const struct pci_driver gfx_driver __pci_driver = {
103 .ops = &gfx_device_ops,
104 .vendor = PCI_VENDOR_ID_INTEL,
105 .device = GFX_DEVID,