Debian Codegraph @

src/northbridge/intel/x4x/gma.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <console/console.h>
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <device/pci_ids.h>
7 #include <device/pci_ops.h>
8 #include <commonlib/helpers.h>
9 #include <drivers/intel/gma/intel_bios.h>
10 #include <drivers/intel/gma/edid.h>
11 #include <drivers/intel/gma/i915.h>
12 #include <drivers/intel/gma/opregion.h>
13 #include <drivers/intel/gma/libgfxinit.h>
14 #include <pc80/vga.h>
15
16 #include "chip.h"
17 #include "drivers/intel/gma/i915_reg.h"
18 #include "x4x.h"
19
20 #define BASE_FREQUENCY 96000
21
22 static void gma_func0_init(struct device *dev)
23 {
24 intel_gma_init_igd_opregion();
25
26 if (!CONFIG(NO_GFX_INIT))
27 pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER);
28
29 /* configure GMBUSFREQ */
30 pci_update_config16(dev, 0xcc, ~0x1ff, 0xbc);
31
32 int vga_disable = (pci_read_config16(dev, D0F0_GGC) & 2) >> 1;
33
34 if (CONFIG(MAINBOARD_USE_LIBGFXINIT)) {
35 if (vga_disable) {
36 printk(BIOS_INFO,
37 "IGD is not decoding legacy VGA MEM and IO: skipping NATIVE graphic init\n");
38 } else {
39 int lightup_ok;
40 gma_gfxinit(&lightup_ok);
41 }
42 } else {
43 pci_dev_init(dev);
44 }
45 }
46
47 static void gma_func0_disable(struct device *dev)
48 {
49 struct device *dev_host = pcidev_on_root(0, 0);
50
51 /* VGA cycles to discrete GPU */
52 pci_or_config16(dev_host, D0F0_GGC, 1 << 1);
53 }
54
55 static void gma_generate_ssdt(const struct device *device)
56 {
57 const struct northbridge_intel_x4x_config *chip = device->chip_info;
58
59 drivers_intel_gma_displays_ssdt_generate(&chip->gfx);
60 }
61
62 static const char *gma_acpi_name(const struct device *dev)
63 {
64 return "GFX0";
65 }
66
67 static struct device_operations gma_func0_ops = {
68 .read_resources = pci_dev_read_resources,
69 .set_resources = pci_dev_set_resources,
70 .enable_resources = pci_dev_enable_resources,
71 .acpi_fill_ssdt = gma_generate_ssdt,
72 .init = gma_func0_init,
73 .ops_pci = &pci_dev_ops_pci,
74 .vga_disable = gma_func0_disable,
75 .acpi_name = gma_acpi_name,
76 };
77
78 static const unsigned short pci_device_ids[] = {
79 0x2e02, /* Eaglelake */
80 0x2e12, /* Q43/Q45 */
81 0x2e22, /* G43/G45 */
82 0x2e32, /* G41 */
83 0x2e42, /* B43 */
84 0x2e92, /* B43_I */
85 0
86 };
87
88 static const struct pci_driver gma __pci_driver = {
89 .ops = &gma_func0_ops,
90 .vendor = PCI_VID_INTEL,
91 .devices = pci_device_ids,
92 };