blob: bda08c54c0bf4e8cf71b4ec6e8bca4d853252c5c [file] [log] [blame]
Subrata Banikcb771a22017-11-28 16:26:08 +05301/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Google Inc.
5 * Copyright (C) 2015-2017 Intel Corporation.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
Matt DeVillier76d17712017-07-01 12:25:46 -050017#include <cbmem.h>
Subrata Banikcb771a22017-11-28 16:26:08 +053018#include <console/console.h>
19#include <device/pci.h>
20#include <drivers/intel/gma/i915_reg.h>
21#include <intelblocks/graphics.h>
Patrick Rudolphc7edf182017-09-26 19:34:35 +020022#include <drivers/intel/gma/opregion.h>
Matt DeVillier76d17712017-07-01 12:25:46 -050023#include <soc/nvs.h>
Subrata Banikcb771a22017-11-28 16:26:08 +053024#include <soc/ramstage.h>
25
26uintptr_t fsp_soc_get_igd_bar(void)
27{
28 return graphics_get_memory_base();
29}
30
31void graphics_soc_init(struct device *dev)
32{
33 u32 ddi_buf_ctl;
34
35 /*
36 * Enable DDI-A (eDP) 4-lane operation if the link is not up yet.
37 * This will allow the kernel to use 4-lane eDP links properly
38 * if the VBIOS or GOP driver does not execute.
39 */
40 ddi_buf_ctl = graphics_gtt_read(DDI_BUF_CTL_A);
41 if (!acpi_is_wakeup_s3() && !(ddi_buf_ctl & DDI_BUF_CTL_ENABLE)) {
42 ddi_buf_ctl |= DDI_A_4_LANES;
43 graphics_gtt_write(DDI_BUF_CTL_A, ddi_buf_ctl);
44 }
45
46 /*
47 * GFX PEIM module inside FSP binary is taking care of graphics
48 * initialization based on INTEL_GMA_ADD_VBT_DATA_FILE Kconfig
49 * option and input VBT file. Hence no need to load/execute legacy VGA
50 * OpROM in order to initialize GFX.
51 *
52 * In case of non-FSP solution, SoC need to select VGA_ROM_RUN
53 * Kconfig to perform GFX initialization through VGA OpRom.
54 */
55 if (IS_ENABLED(CONFIG_INTEL_GMA_ADD_VBT_DATA_FILE))
56 return;
57
58 /* IGD needs to Bus Master */
59 u32 reg32 = pci_read_config32(dev, PCI_COMMAND);
60 reg32 |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO;
61 pci_write_config32(dev, PCI_COMMAND, reg32);
62
63 /* Initialize PCI device, load/execute BIOS Option ROM */
64 pci_dev_init(dev);
Matt DeVillier76d17712017-07-01 12:25:46 -050065
66 intel_gma_restore_opregion();
67}
68
69uintptr_t gma_get_gnvs_aslb(const void *gnvs)
70{
71 const global_nvs_t *gnvs_ptr = gnvs;
72 return (uintptr_t)(gnvs_ptr ? gnvs_ptr->aslb : 0);
73}
74
75void gma_set_gnvs_aslb(void *gnvs, uintptr_t aslb)
76{
77 global_nvs_t *gnvs_ptr = gnvs;
78 if (gnvs_ptr)
79 gnvs_ptr->aslb = aslb;
Subrata Banikcb771a22017-11-28 16:26:08 +053080}
81
82/* Initialize IGD OpRegion, called from ACPI code */
83static void update_igd_opregion(igd_opregion_t *opregion)
84{
Patrick Rudolphc7edf182017-09-26 19:34:35 +020085 /* FIXME: Add platform specific mailbox initialization */
Subrata Banikcb771a22017-11-28 16:26:08 +053086}
87
88uintptr_t graphics_soc_write_acpi_opregion(struct device *device,
89 uintptr_t current, struct acpi_rsdp *rsdp)
90{
91 igd_opregion_t *opregion;
Matt DeVillier76d17712017-07-01 12:25:46 -050092 global_nvs_t *gnvs = cbmem_find(CBMEM_ID_ACPI_GNVS);
Subrata Banikcb771a22017-11-28 16:26:08 +053093
94 /* If GOP is not used, exit here */
95 if (!IS_ENABLED(CONFIG_INTEL_GMA_ADD_VBT_DATA_FILE))
96 return current;
97
98 /* If IGD is disabled, exit here */
99 if (pci_read_config16(device, PCI_VENDOR_ID) == 0xFFFF)
100 return current;
101
102 printk(BIOS_DEBUG, "ACPI: * IGD OpRegion\n");
103 opregion = (igd_opregion_t *)current;
104
Patrick Rudolphc7edf182017-09-26 19:34:35 +0200105 if (intel_gma_init_igd_opregion(opregion) != CB_SUCCESS)
Subrata Banikcb771a22017-11-28 16:26:08 +0530106 return current;
Matt DeVillier76d17712017-07-01 12:25:46 -0500107 if (gnvs)
108 gnvs->aslb = (u32)(uintptr_t)opregion;
Subrata Banikcb771a22017-11-28 16:26:08 +0530109 update_igd_opregion(opregion);
110 current += sizeof(igd_opregion_t);
111 current = acpi_align_current(current);
112
113 printk(BIOS_DEBUG, "current = %lx\n", current);
114 return current;
115}