Alexandru Gagniuc | c364019 | 2015-12-15 16:06:15 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Subrata Banik | b7b5666 | 2017-11-28 17:54:15 +0530 | [diff] [blame] | 4 | * Copyright (C) 2015-2017 Intel Corp. |
Alexandru Gagniuc | c364019 | 2015-12-15 16:06:15 -0800 | [diff] [blame] | 5 | * (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 Huber | 628a3c5 | 2018-11-27 14:15:31 +0100 | [diff] [blame] | 18 | #include <stdint.h> |
| 19 | #include <arch/acpi.h> |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 20 | #include <arch/acpigen.h> |
Nico Huber | 628a3c5 | 2018-11-27 14:15:31 +0100 | [diff] [blame] | 21 | #include <bootmode.h> |
Alexandru Gagniuc | c364019 | 2015-12-15 16:06:15 -0800 | [diff] [blame] | 22 | #include <console/console.h> |
| 23 | #include <fsp/util.h> |
| 24 | #include <device/device.h> |
| 25 | #include <device/pci.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 26 | #include <device/pci_ops.h> |
Subrata Banik | b7b5666 | 2017-11-28 17:54:15 +0530 | [diff] [blame] | 27 | #include <intelblocks/graphics.h> |
Patrick Rudolph | c7edf18 | 2017-09-26 19:34:35 +0200 | [diff] [blame] | 28 | #include <drivers/intel/gma/opregion.h> |
Nico Huber | 628a3c5 | 2018-11-27 14:15:31 +0100 | [diff] [blame] | 29 | #include <drivers/intel/gma/libgfxinit.h> |
Alexandru Gagniuc | c364019 | 2015-12-15 16:06:15 -0800 | [diff] [blame] | 30 | |
Naresh G Solanki | 16e9d45 | 2016-09-08 22:27:04 +0530 | [diff] [blame] | 31 | uintptr_t fsp_soc_get_igd_bar(void) |
Alexandru Gagniuc | c364019 | 2015-12-15 16:06:15 -0800 | [diff] [blame] | 32 | { |
Subrata Banik | b7b5666 | 2017-11-28 17:54:15 +0530 | [diff] [blame] | 33 | return graphics_get_memory_base(); |
Alexandru Gagniuc | c364019 | 2015-12-15 16:06:15 -0800 | [diff] [blame] | 34 | } |
| 35 | |
Nico Huber | 628a3c5 | 2018-11-27 14:15:31 +0100 | [diff] [blame] | 36 | void 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 Banik | b7b5666 | 2017-11-28 17:54:15 +0530 | [diff] [blame] | 57 | uintptr_t graphics_soc_write_acpi_opregion(struct device *device, |
| 58 | uintptr_t current, struct acpi_rsdp *rsdp) |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 59 | { |
| 60 | igd_opregion_t *opregion; |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 61 | |
| 62 | printk(BIOS_DEBUG, "ACPI: * IGD OpRegion\n"); |
| 63 | opregion = (igd_opregion_t *)current; |
| 64 | |
Patrick Rudolph | c7edf18 | 2017-09-26 19:34:35 +0200 | [diff] [blame] | 65 | if (intel_gma_init_igd_opregion(opregion) != CB_SUCCESS) |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 66 | return current; |
| 67 | |
Patrick Rudolph | c7edf18 | 2017-09-26 19:34:35 +0200 | [diff] [blame] | 68 | /* FIXME: Add platform specific mailbox initialization */ |
| 69 | |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 70 | current += sizeof(igd_opregion_t); |
Andrey Petrov | 868679f | 2016-05-12 19:11:48 -0700 | [diff] [blame] | 71 | return acpi_align_current(current); |
| 72 | } |