blob: 9be598f61abe4083740122f8681fd43b5b84ccdf [file] [log] [blame]
Alexandru Gagniucc3640192015-12-15 16:06:15 -08001/*
2 * This file is part of the coreboot project.
3 *
Subrata Banikb7b56662017-11-28 17:54:15 +05304 * Copyright (C) 2015-2017 Intel Corp.
Alexandru Gagniucc3640192015-12-15 16:06:15 -08005 * (Written by Alexandru Gagniuc <alexandrux.gagniuc@intel.com> for Intel Corp.)
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; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
Nico Huber628a3c52018-11-27 14:15:31 +010018#include <stdint.h>
19#include <arch/acpi.h>
Andrey Petrov868679f2016-05-12 19:11:48 -070020#include <arch/acpigen.h>
Nico Huber628a3c52018-11-27 14:15:31 +010021#include <bootmode.h>
Alexandru Gagniucc3640192015-12-15 16:06:15 -080022#include <console/console.h>
23#include <fsp/util.h>
24#include <device/device.h>
25#include <device/pci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020026#include <device/pci_ops.h>
Subrata Banikb7b56662017-11-28 17:54:15 +053027#include <intelblocks/graphics.h>
Patrick Rudolphc7edf182017-09-26 19:34:35 +020028#include <drivers/intel/gma/opregion.h>
Nico Huber628a3c52018-11-27 14:15:31 +010029#include <drivers/intel/gma/libgfxinit.h>
Alexandru Gagniucc3640192015-12-15 16:06:15 -080030
Naresh G Solanki16e9d452016-09-08 22:27:04 +053031uintptr_t fsp_soc_get_igd_bar(void)
Alexandru Gagniucc3640192015-12-15 16:06:15 -080032{
Subrata Banikb7b56662017-11-28 17:54:15 +053033 return graphics_get_memory_base();
Alexandru Gagniucc3640192015-12-15 16:06:15 -080034}
35
Nico Huber628a3c52018-11-27 14:15:31 +010036void graphics_soc_init(struct device *const dev)
37{
38 if (IS_ENABLED(CONFIG_RUN_FSP_GOP))
39 return;
40
41 uint32_t reg32 = pci_read_config32(dev, PCI_COMMAND);
42 reg32 |= PCI_COMMAND_MASTER;
43 pci_write_config32(dev, PCI_COMMAND, reg32);
44
45 if (IS_ENABLED(CONFIG_MAINBOARD_USE_LIBGFXINIT)) {
46 if (!acpi_is_wakeup_s3() && display_init_required()) {
47 int lightup_ok;
48 gma_gfxinit(&lightup_ok);
49 gfx_set_init_done(lightup_ok);
50 }
51 } else {
52 /* Initialize PCI device, load/execute BIOS Option ROM */
53 pci_dev_init(dev);
54 }
55}
56
Subrata Banikb7b56662017-11-28 17:54:15 +053057uintptr_t graphics_soc_write_acpi_opregion(struct device *device,
58 uintptr_t current, struct acpi_rsdp *rsdp)
Andrey Petrov868679f2016-05-12 19:11:48 -070059{
60 igd_opregion_t *opregion;
Andrey Petrov868679f2016-05-12 19:11:48 -070061
62 printk(BIOS_DEBUG, "ACPI: * IGD OpRegion\n");
63 opregion = (igd_opregion_t *)current;
64
Patrick Rudolphc7edf182017-09-26 19:34:35 +020065 if (intel_gma_init_igd_opregion(opregion) != CB_SUCCESS)
Andrey Petrov868679f2016-05-12 19:11:48 -070066 return current;
67
Patrick Rudolphc7edf182017-09-26 19:34:35 +020068 /* FIXME: Add platform specific mailbox initialization */
69
Andrey Petrov868679f2016-05-12 19:11:48 -070070 current += sizeof(igd_opregion_t);
Andrey Petrov868679f2016-05-12 19:11:48 -070071 return acpi_align_current(current);
72}