blob: 2b3c9007a4a8e9e825b81869296bfffbbe659c77 [file] [log] [blame]
Abhay Kumarb0c4cbb2017-10-12 11:33:01 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2016-2017 Intel Corp.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
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
Abhay Kumarb0c4cbb2017-10-12 11:33:01 -070017#include <arch/acpigen.h>
18#include <console/console.h>
19#include <fsp/util.h>
20#include <device/device.h>
21#include <device/pci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020022#include <device/pci_ops.h>
Abhay Kumar7ebabf92017-12-09 10:01:02 -080023#include <drivers/intel/gma/i915_reg.h>
Abhay Kumarb0c4cbb2017-10-12 11:33:01 -070024#include <drivers/intel/gma/opregion.h>
Subrata Banik75c6f4a2017-11-28 18:37:48 +053025#include <intelblocks/graphics.h>
Abhay Kumarb0c4cbb2017-10-12 11:33:01 -070026
27uintptr_t fsp_soc_get_igd_bar(void)
28{
Subrata Banik75c6f4a2017-11-28 18:37:48 +053029 return graphics_get_memory_base();
Abhay Kumarb0c4cbb2017-10-12 11:33:01 -070030}
31
Abhay Kumar7ebabf92017-12-09 10:01:02 -080032void graphics_soc_init(struct device *dev)
33{
34 uint32_t ddi_buf_ctl;
35
36 /*
37 * Enable DDI-A (eDP) 4-lane operation if the link is not up yet.
38 * This will allow the kernel to use 4-lane eDP links properly
39 * if the VBIOS or GOP driver do not execute.
40 */
41 ddi_buf_ctl = graphics_gtt_read(DDI_BUF_CTL_A);
42 if (!acpi_is_wakeup_s3() && !(ddi_buf_ctl & DDI_BUF_CTL_ENABLE)) {
43 ddi_buf_ctl |= (DDI_A_4_LANES | DDI_INIT_DISPLAY_DETECTED |
44 DDI_BUF_IS_IDLE);
45 graphics_gtt_write(DDI_BUF_CTL_A, ddi_buf_ctl);
46 }
47
48 /*
49 * GFX PEIM module inside FSP binary is taking care of graphics
Nico Huber29cc3312018-06-06 17:40:02 +020050 * initialization based on INTEL_GMA_ADD_VBT Kconfig
Abhay Kumar7ebabf92017-12-09 10:01:02 -080051 * option and input VBT file. Hence no need to load/execute legacy VGA
52 * OpROM in order to initialize GFX.
53 *
54 * In case of non-FSP solution, SoC need to select VGA_ROM_RUN
55 * Kconfig to perform GFX initialization through VGA OpRom.
56 */
Nico Huber29cc3312018-06-06 17:40:02 +020057 if (IS_ENABLED(CONFIG_INTEL_GMA_ADD_VBT))
Abhay Kumar7ebabf92017-12-09 10:01:02 -080058 return;
59
60 /* IGD needs to Bus Master */
61 uint32_t reg32 = pci_read_config32(dev, PCI_COMMAND);
62 reg32 |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO;
63 pci_write_config32(dev, PCI_COMMAND, reg32);
64
65 /* Initialize PCI device, load/execute BIOS Option ROM */
66 pci_dev_init(dev);
67}
68
Subrata Banik75c6f4a2017-11-28 18:37:48 +053069uintptr_t graphics_soc_write_acpi_opregion(struct device *device,
70 uintptr_t current, struct acpi_rsdp *rsdp)
Abhay Kumarb0c4cbb2017-10-12 11:33:01 -070071{
72 igd_opregion_t *opregion;
73
74 printk(BIOS_DEBUG, "ACPI: * IGD OpRegion\n");
75 opregion = (igd_opregion_t *)current;
76
77 if (intel_gma_init_igd_opregion(opregion) != CB_SUCCESS)
78 return current;
79
80 current += sizeof(igd_opregion_t);
81
82 return acpi_align_current(current);
83}