Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 2 | |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 3 | #include <console/console.h> |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 4 | #include <device/device.h> |
| 5 | #include <device/pci.h> |
| 6 | #include <device/pci_ids.h> |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 7 | #include <device/pci_ops.h> |
Arthur Heymans | de14ea7 | 2016-09-04 16:01:11 +0200 | [diff] [blame] | 8 | #include <commonlib/helpers.h> |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 9 | #include <drivers/intel/gma/intel_bios.h> |
Arthur Heymans | de14ea7 | 2016-09-04 16:01:11 +0200 | [diff] [blame] | 10 | #include <drivers/intel/gma/edid.h> |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 11 | #include <drivers/intel/gma/i915.h> |
Patrick Rudolph | f6aa7d9 | 2017-09-29 18:28:23 +0200 | [diff] [blame] | 12 | #include <drivers/intel/gma/opregion.h> |
Nico Huber | f2dd049 | 2017-10-29 15:42:44 +0100 | [diff] [blame] | 13 | #include <drivers/intel/gma/libgfxinit.h> |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 14 | #include <pc80/vga.h> |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 15 | |
Elyes HAOUAS | bf0970e | 2019-03-21 11:10:03 +0100 | [diff] [blame] | 16 | #include "chip.h" |
| 17 | #include "drivers/intel/gma/i915_reg.h" |
| 18 | #include "x4x.h" |
| 19 | |
Arthur Heymans | de14ea7 | 2016-09-04 16:01:11 +0200 | [diff] [blame] | 20 | #define BASE_FREQUENCY 96000 |
| 21 | |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 22 | static void gma_func0_init(struct device *dev) |
| 23 | { |
Nico Huber | f2a0be2 | 2020-04-26 17:01:25 +0200 | [diff] [blame] | 24 | intel_gma_init_igd_opregion(); |
| 25 | |
Nico Huber | dd59762 | 2020-04-26 19:46:35 +0200 | [diff] [blame] | 26 | if (!CONFIG(NO_GFX_INIT)) |
| 27 | pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER); |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 28 | |
Arthur Heymans | de14ea7 | 2016-09-04 16:01:11 +0200 | [diff] [blame] | 29 | /* configure GMBUSFREQ */ |
Nico Huber | 15b83da | 2019-01-12 15:05:20 +0100 | [diff] [blame] | 30 | pci_update_config16(dev, 0xcc, ~0x1ff, 0xbc); |
Arthur Heymans | de14ea7 | 2016-09-04 16:01:11 +0200 | [diff] [blame] | 31 | |
Stefan Tauner | 3e3bae0 | 2018-09-03 19:02:13 +0200 | [diff] [blame] | 32 | int vga_disable = (pci_read_config16(dev, D0F0_GGC) & 2) >> 1; |
Arthur Heymans | 2e7efe6 | 2017-05-06 18:05:57 +0200 | [diff] [blame] | 33 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 34 | if (CONFIG(MAINBOARD_USE_LIBGFXINIT)) { |
Arthur Heymans | e6c8f7e | 2018-08-09 11:31:51 +0200 | [diff] [blame] | 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 | } |
Arthur Heymans | 2e7efe6 | 2017-05-06 18:05:57 +0200 | [diff] [blame] | 42 | } else { |
Damien Zammit | 216fc50 | 2016-01-22 19:13:18 +1100 | [diff] [blame] | 43 | pci_dev_init(dev); |
Arthur Heymans | 2e7efe6 | 2017-05-06 18:05:57 +0200 | [diff] [blame] | 44 | } |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 45 | } |
| 46 | |
Arthur Heymans | c80748c | 2017-02-26 23:04:51 +0100 | [diff] [blame] | 47 | static void gma_func0_disable(struct device *dev) |
| 48 | { |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 49 | struct device *dev_host = pcidev_on_root(0, 0); |
Arthur Heymans | c80748c | 2017-02-26 23:04:51 +0100 | [diff] [blame] | 50 | |
Angel Pons | 4a9569a | 2020-06-08 01:39:25 +0200 | [diff] [blame] | 51 | /* VGA cycles to discrete GPU */ |
| 52 | pci_or_config16(dev_host, D0F0_GGC, 1 << 1); |
Arthur Heymans | c80748c | 2017-02-26 23:04:51 +0100 | [diff] [blame] | 53 | } |
| 54 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 55 | static void gma_generate_ssdt(const struct device *device) |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 56 | { |
Matt DeVillier | 33f89ee | 2020-03-30 22:16:37 -0500 | [diff] [blame] | 57 | const struct northbridge_intel_x4x_config *chip = device->chip_info; |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 58 | |
Matt DeVillier | 33f89ee | 2020-03-30 22:16:37 -0500 | [diff] [blame] | 59 | drivers_intel_gma_displays_ssdt_generate(&chip->gfx); |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 60 | } |
| 61 | |
Patrick Rudolph | f6aa7d9 | 2017-09-29 18:28:23 +0200 | [diff] [blame] | 62 | static const char *gma_acpi_name(const struct device *dev) |
| 63 | { |
| 64 | return "GFX0"; |
| 65 | } |
| 66 | |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 67 | static struct device_operations gma_func0_ops = { |
Matt DeVillier | 33f89ee | 2020-03-30 22:16:37 -0500 | [diff] [blame] | 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, |
Angel Pons | 1fc0edd | 2020-05-31 00:03:28 +0200 | [diff] [blame] | 73 | .ops_pci = &pci_dev_ops_pci, |
Matt DeVillier | 33f89ee | 2020-03-30 22:16:37 -0500 | [diff] [blame] | 74 | .disable = gma_func0_disable, |
| 75 | .acpi_name = gma_acpi_name, |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 76 | }; |
| 77 | |
Arthur Heymans | 70a1dda | 2017-03-09 01:58:24 +0100 | [diff] [blame] | 78 | static const unsigned short pci_device_ids[] = { |
Arthur Heymans | 9e70ce0 | 2016-12-16 15:32:32 +0100 | [diff] [blame] | 79 | 0x2e02, /* Eaglelake */ |
| 80 | 0x2e12, /* Q43/Q45 */ |
| 81 | 0x2e22, /* G43/G45 */ |
| 82 | 0x2e32, /* G41 */ |
| 83 | 0x2e42, /* B43 */ |
| 84 | 0x2e92, /* B43_I */ |
| 85 | 0 |
Damien Zammit | 43a1f78 | 2015-08-19 15:16:59 +1000 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | static const struct pci_driver gma __pci_driver = { |
| 89 | .ops = &gma_func0_ops, |
| 90 | .vendor = PCI_VENDOR_ID_INTEL, |
| 91 | .devices = pci_device_ids, |
| 92 | }; |