Alexandru Gagniuc | c364019 | 2015-12-15 16:06:15 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2015-2016 Intel Corp. |
| 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 | |
| 18 | #include <console/console.h> |
| 19 | #include <fsp/util.h> |
| 20 | #include <device/device.h> |
| 21 | #include <device/pci.h> |
| 22 | #include <device/pci_ids.h> |
| 23 | #include <soc/pci_ids.h> |
| 24 | |
| 25 | static uintptr_t framebuffer_bar = (uintptr_t)NULL; |
| 26 | |
| 27 | void lb_framebuffer(struct lb_header *header) |
| 28 | { |
| 29 | enum cb_err ret; |
| 30 | struct lb_framebuffer *framebuffer; |
| 31 | |
| 32 | framebuffer = (void *)lb_new_record(header); |
| 33 | ret = fsp_fill_lb_framebuffer(framebuffer); |
| 34 | if (ret != CB_SUCCESS) { |
| 35 | printk(BIOS_ALERT, "FSP did not return a valid framebuffer\n"); |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | if (!framebuffer_bar) { |
| 40 | printk(BIOS_ALERT, "Framebuffer BAR invalid (00:02.0 BAR2)\n"); |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | /* Resource allocator can move the BAR around after FSP configures it */ |
| 45 | framebuffer->physical_address = framebuffer_bar; |
| 46 | printk(BIOS_DEBUG, "Graphics framebuffer located at 0x%llx\n", |
| 47 | framebuffer->physical_address); |
| 48 | } |
| 49 | |
| 50 | static void igd_set_resources(struct device *dev) |
| 51 | { |
| 52 | framebuffer_bar = find_resource(dev, PCI_BASE_ADDRESS_2)->base; |
| 53 | pci_dev_set_resources(dev); |
| 54 | } |
| 55 | |
| 56 | static const struct device_operations igd_ops = { |
| 57 | .read_resources = pci_dev_read_resources, |
| 58 | .set_resources = igd_set_resources, |
| 59 | .enable_resources = pci_dev_enable_resources, |
| 60 | .init = pci_dev_init, |
| 61 | .enable = DEVICE_NOOP |
| 62 | }; |
| 63 | |
| 64 | static const struct pci_driver integrated_graphics_driver __pci_driver = { |
| 65 | .ops = &igd_ops, |
| 66 | .vendor = PCI_VENDOR_ID_INTEL, |
| 67 | .device = PCI_DEVICE_ID_APOLLOLAKE_IGD, |
| 68 | }; |