Abhay Kumar | b0c4cbb | 2017-10-12 11:33:01 -0700 | [diff] [blame] | 1 | /* |
| 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 Kumar | b0c4cbb | 2017-10-12 11:33:01 -0700 | [diff] [blame] | 17 | #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älkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame^] | 22 | #include <device/pci_ops.h> |
Abhay Kumar | 7ebabf9 | 2017-12-09 10:01:02 -0800 | [diff] [blame] | 23 | #include <drivers/intel/gma/i915_reg.h> |
Abhay Kumar | b0c4cbb | 2017-10-12 11:33:01 -0700 | [diff] [blame] | 24 | #include <drivers/intel/gma/opregion.h> |
Subrata Banik | 75c6f4a | 2017-11-28 18:37:48 +0530 | [diff] [blame] | 25 | #include <intelblocks/graphics.h> |
Abhay Kumar | b0c4cbb | 2017-10-12 11:33:01 -0700 | [diff] [blame] | 26 | |
| 27 | uintptr_t fsp_soc_get_igd_bar(void) |
| 28 | { |
Subrata Banik | 75c6f4a | 2017-11-28 18:37:48 +0530 | [diff] [blame] | 29 | return graphics_get_memory_base(); |
Abhay Kumar | b0c4cbb | 2017-10-12 11:33:01 -0700 | [diff] [blame] | 30 | } |
| 31 | |
Abhay Kumar | 7ebabf9 | 2017-12-09 10:01:02 -0800 | [diff] [blame] | 32 | void 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 Huber | 29cc331 | 2018-06-06 17:40:02 +0200 | [diff] [blame] | 50 | * initialization based on INTEL_GMA_ADD_VBT Kconfig |
Abhay Kumar | 7ebabf9 | 2017-12-09 10:01:02 -0800 | [diff] [blame] | 51 | * 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 Huber | 29cc331 | 2018-06-06 17:40:02 +0200 | [diff] [blame] | 57 | if (IS_ENABLED(CONFIG_INTEL_GMA_ADD_VBT)) |
Abhay Kumar | 7ebabf9 | 2017-12-09 10:01:02 -0800 | [diff] [blame] | 58 | 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 Banik | 75c6f4a | 2017-11-28 18:37:48 +0530 | [diff] [blame] | 69 | uintptr_t graphics_soc_write_acpi_opregion(struct device *device, |
| 70 | uintptr_t current, struct acpi_rsdp *rsdp) |
Abhay Kumar | b0c4cbb | 2017-10-12 11:33:01 -0700 | [diff] [blame] | 71 | { |
| 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 | } |