Angel Pons | f94ac9a | 2020-04-05 15:46:48 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpi.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 4 | #include <device/mmio.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 5 | #include <device/pci_ops.h> |
Marc Jones | a6354a1 | 2014-12-26 22:11:14 -0700 | [diff] [blame] | 6 | #include <bootmode.h> |
Michael Niewöhner | 44fa0d4 | 2020-12-28 15:00:39 +0100 | [diff] [blame] | 7 | #include <commonlib/helpers.h> |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 8 | #include <console/console.h> |
Angel Pons | 9d733de | 2020-11-23 13:15:19 +0100 | [diff] [blame] | 9 | #include <cpu/intel/haswell/haswell.h> |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 10 | #include <delay.h> |
| 11 | #include <device/device.h> |
| 12 | #include <device/pci.h> |
| 13 | #include <device/pci_ids.h> |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 14 | #include <string.h> |
| 15 | #include <reg_script.h> |
Matt DeVillier | 53e2446 | 2016-08-05 02:20:15 -0500 | [diff] [blame] | 16 | #include <drivers/intel/gma/i915.h> |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 17 | #include <drivers/intel/gma/i915_reg.h> |
Nico Huber | a06689c | 2019-10-08 20:56:41 +0200 | [diff] [blame] | 18 | #include <drivers/intel/gma/libgfxinit.h> |
Matt DeVillier | 773488f | 2017-10-18 12:27:25 -0500 | [diff] [blame] | 19 | #include <drivers/intel/gma/opregion.h> |
Duncan Laurie | 1e6b591 | 2015-01-30 16:33:43 -0800 | [diff] [blame] | 20 | #include <soc/pm.h> |
Julius Werner | 4ee4bd5 | 2014-10-20 13:46:39 -0700 | [diff] [blame] | 21 | #include <soc/systemagent.h> |
| 22 | #include <soc/intel/broadwell/chip.h> |
Philipp Deppenwiese | fea2429 | 2017-10-17 17:02:29 +0200 | [diff] [blame] | 23 | #include <security/vboot/vbnv.h> |
Matt DeVillier | f8960a6 | 2016-11-16 23:37:43 -0600 | [diff] [blame] | 24 | #include <soc/igd.h> |
Elyes HAOUAS | 27d02d8 | 2019-05-15 21:11:39 +0200 | [diff] [blame] | 25 | #include <types.h> |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 26 | |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 27 | #define GT_RETRY 1000 |
| 28 | enum { |
| 29 | GT_CDCLK_DEFAULT = 0, |
| 30 | GT_CDCLK_337, |
| 31 | GT_CDCLK_450, |
| 32 | GT_CDCLK_540, |
| 33 | GT_CDCLK_675, |
| 34 | }; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 35 | |
Matt DeVillier | f8960a6 | 2016-11-16 23:37:43 -0600 | [diff] [blame] | 36 | static u32 reg_em4; |
| 37 | static u32 reg_em5; |
| 38 | |
| 39 | u32 igd_get_reg_em4(void) { return reg_em4; } |
| 40 | u32 igd_get_reg_em5(void) { return reg_em5; } |
| 41 | |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 42 | struct reg_script haswell_early_init_script[] = { |
| 43 | /* Enable Force Wake */ |
| 44 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa180, 0x00000020), |
| 45 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa188, 0x00010001), |
Edward O'Callaghan | 986e85c | 2014-10-29 12:15:34 +1100 | [diff] [blame] | 46 | REG_RES_POLL32(PCI_BASE_ADDRESS_0, FORCEWAKE_ACK_HSW, 1, 1, GT_RETRY), |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 47 | |
| 48 | /* Enable Counters */ |
| 49 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa248, 0x00000016), |
| 50 | |
| 51 | /* GFXPAUSE settings */ |
| 52 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa000, 0x00070020), |
| 53 | |
| 54 | /* ECO Settings */ |
| 55 | REG_RES_RMW32(PCI_BASE_ADDRESS_0, 0xa180, 0xff3fffff, 0x15000000), |
| 56 | |
| 57 | /* Enable DOP Clock Gating */ |
| 58 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x9424, 0x000003fd), |
| 59 | |
| 60 | /* Enable Unit Level Clock Gating */ |
| 61 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x9400, 0x00000080), |
| 62 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x9404, 0x40401000), |
| 63 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x9408, 0x00000000), |
| 64 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x940c, 0x02000001), |
| 65 | |
| 66 | /* |
| 67 | * RC6 Settings |
| 68 | */ |
| 69 | |
| 70 | /* Wake Rate Limits */ |
| 71 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa090, 0x00000000), |
| 72 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa098, 0x03e80000), |
| 73 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa09c, 0x00280000), |
| 74 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa0a8, 0x0001e848), |
| 75 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa0ac, 0x00000019), |
| 76 | |
| 77 | /* Render/Video/Blitter Idle Max Count */ |
| 78 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x02054, 0x0000000a), |
| 79 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x12054, 0x0000000a), |
| 80 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x22054, 0x0000000a), |
| 81 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x1a054, 0x0000000a), |
| 82 | |
| 83 | /* RC Sleep / RCx Thresholds */ |
| 84 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa0b0, 0x00000000), |
| 85 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa0b4, 0x000003e8), |
| 86 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa0b8, 0x0000c350), |
| 87 | |
| 88 | /* RP Settings */ |
| 89 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa010, 0x000f4240), |
| 90 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa014, 0x12060000), |
| 91 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa02c, 0x0000e808), |
| 92 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa030, 0x0003bd08), |
| 93 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa068, 0x000101d0), |
| 94 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa06c, 0x00055730), |
| 95 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0xa070, 0x0000000a), |
| 96 | |
| 97 | /* RP Control */ |
| 98 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa024, 0x00000b92), |
| 99 | |
| 100 | /* HW RC6 Control */ |
| 101 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa090, 0x88040000), |
| 102 | |
| 103 | /* Video Frequency Request */ |
| 104 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa00c, 0x08000000), |
| 105 | |
| 106 | /* Set RC6 VIDs */ |
| 107 | REG_RES_POLL32(PCI_BASE_ADDRESS_0, 0x138124, (1 << 31), 0, GT_RETRY), |
| 108 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x138128, 0), |
| 109 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x138124, 0x80000004), |
| 110 | REG_RES_POLL32(PCI_BASE_ADDRESS_0, 0x138124, (1 << 31), 0, GT_RETRY), |
| 111 | |
| 112 | /* Enable PM Interrupts */ |
| 113 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x4402c, 0x03000076), |
| 114 | |
| 115 | /* Enable RC6 in idle */ |
| 116 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa094, 0x00040000), |
| 117 | |
| 118 | REG_SCRIPT_END |
| 119 | }; |
| 120 | |
| 121 | static const struct reg_script haswell_late_init_script[] = { |
| 122 | /* Lock settings */ |
| 123 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a248, (1 << 31)), |
| 124 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a004, (1 << 4)), |
| 125 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a080, (1 << 2)), |
| 126 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a180, (1 << 31)), |
| 127 | |
| 128 | /* Disable Force Wake */ |
| 129 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa188, 0x00010000), |
Edward O'Callaghan | 986e85c | 2014-10-29 12:15:34 +1100 | [diff] [blame] | 130 | REG_RES_POLL32(PCI_BASE_ADDRESS_0, FORCEWAKE_ACK_HSW, 1, 0, GT_RETRY), |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 131 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa188, 0x00000001), |
| 132 | |
| 133 | /* Enable power well for DP and Audio */ |
| 134 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x45400, (1 << 31)), |
| 135 | REG_RES_POLL32(PCI_BASE_ADDRESS_0, 0x45400, |
| 136 | (1 << 30), (1 << 30), GT_RETRY), |
| 137 | |
| 138 | REG_SCRIPT_END |
| 139 | }; |
| 140 | |
| 141 | static const struct reg_script broadwell_early_init_script[] = { |
| 142 | /* Enable Force Wake */ |
| 143 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa188, 0x00010001), |
Edward O'Callaghan | 986e85c | 2014-10-29 12:15:34 +1100 | [diff] [blame] | 144 | REG_RES_POLL32(PCI_BASE_ADDRESS_0, FORCEWAKE_ACK_HSW, 1, 1, GT_RETRY), |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 145 | |
| 146 | /* Enable push bus metric control and shift */ |
| 147 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa248, 0x00000004), |
| 148 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa250, 0x000000ff), |
| 149 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa25c, 0x00000010), |
| 150 | |
Duncan Laurie | 84b9cf4 | 2014-07-31 10:46:57 -0700 | [diff] [blame] | 151 | /* GFXPAUSE settings (set based on stepping) */ |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 152 | |
| 153 | /* ECO Settings */ |
| 154 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa180, 0x45200000), |
| 155 | |
| 156 | /* Enable DOP Clock Gating */ |
| 157 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x9424, 0x000000fd), |
| 158 | |
| 159 | /* Enable Unit Level Clock Gating */ |
| 160 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x9400, 0x00000000), |
| 161 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x9404, 0x40401000), |
| 162 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x9408, 0x00000000), |
| 163 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x940c, 0x02000001), |
| 164 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x1a054, 0x0000000a), |
| 165 | |
| 166 | /* Video Frequency Request */ |
| 167 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa00c, 0x08000000), |
| 168 | |
Duncan Laurie | 84b9cf4 | 2014-07-31 10:46:57 -0700 | [diff] [blame] | 169 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x138158, 0x00000009), |
| 170 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x13815c, 0x0000000d), |
| 171 | |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 172 | /* |
| 173 | * RC6 Settings |
| 174 | */ |
| 175 | |
| 176 | /* Wake Rate Limits */ |
| 177 | REG_RES_RMW32(PCI_BASE_ADDRESS_0, 0x0a090, 0, 0), |
| 178 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a098, 0x03e80000), |
| 179 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a09c, 0x00280000), |
| 180 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a0a8, 0x0001e848), |
| 181 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a0ac, 0x00000019), |
| 182 | |
| 183 | /* Render/Video/Blitter Idle Max Count */ |
| 184 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x02054, 0x0000000a), |
| 185 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x12054, 0x0000000a), |
| 186 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x22054, 0x0000000a), |
| 187 | |
| 188 | /* RC Sleep / RCx Thresholds */ |
| 189 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a0b0, 0x00000000), |
| 190 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a0b8, 0x00000271), |
| 191 | |
| 192 | /* RP Settings */ |
| 193 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a010, 0x000f4240), |
| 194 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a014, 0x12060000), |
| 195 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a02c, 0x0000e808), |
| 196 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a030, 0x0003bd08), |
| 197 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a068, 0x000101d0), |
| 198 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a06c, 0x00055730), |
| 199 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a070, 0x0000000a), |
| 200 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a168, 0x00000006), |
| 201 | |
| 202 | /* RP Control */ |
| 203 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa024, 0x00000b92), |
| 204 | |
| 205 | /* HW RC6 Control */ |
| 206 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa090, 0x90040000), |
| 207 | |
| 208 | /* Set RC6 VIDs */ |
| 209 | REG_RES_POLL32(PCI_BASE_ADDRESS_0, 0x138124, (1 << 31), 0, GT_RETRY), |
| 210 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x138128, 0), |
| 211 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x138124, 0x80000004), |
| 212 | REG_RES_POLL32(PCI_BASE_ADDRESS_0, 0x138124, (1 << 31), 0, GT_RETRY), |
| 213 | |
| 214 | /* Enable PM Interrupts */ |
| 215 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x4402c, 0x03000076), |
| 216 | |
| 217 | /* Enable RC6 in idle */ |
| 218 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa094, 0x00040000), |
| 219 | |
| 220 | REG_SCRIPT_END |
| 221 | }; |
| 222 | |
| 223 | static const struct reg_script broadwell_late_init_script[] = { |
| 224 | /* Lock settings */ |
| 225 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a248, (1 << 31)), |
| 226 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a000, (1 << 18)), |
| 227 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a180, (1 << 31)), |
| 228 | |
| 229 | /* Disable Force Wake */ |
| 230 | REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa188, 0x00010000), |
Edward O'Callaghan | 986e85c | 2014-10-29 12:15:34 +1100 | [diff] [blame] | 231 | REG_RES_POLL32(PCI_BASE_ADDRESS_0, FORCEWAKE_ACK_HSW, 1, 0, GT_RETRY), |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 232 | |
| 233 | /* Enable power well for DP and Audio */ |
| 234 | REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x45400, (1 << 31)), |
| 235 | REG_RES_POLL32(PCI_BASE_ADDRESS_0, 0x45400, |
| 236 | (1 << 30), (1 << 30), GT_RETRY), |
| 237 | |
| 238 | REG_SCRIPT_END |
| 239 | }; |
| 240 | |
| 241 | u32 map_oprom_vendev(u32 vendev) |
| 242 | { |
| 243 | return SA_IGD_OPROM_VENDEV; |
| 244 | } |
| 245 | |
| 246 | static struct resource *gtt_res = NULL; |
| 247 | |
Matt DeVillier | 53e2446 | 2016-08-05 02:20:15 -0500 | [diff] [blame] | 248 | u32 gtt_read(u32 reg) |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 249 | { |
| 250 | u32 val; |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 251 | val = read32(res2mmio(gtt_res, reg, 0)); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 252 | return val; |
| 253 | |
| 254 | } |
| 255 | |
Matt DeVillier | 53e2446 | 2016-08-05 02:20:15 -0500 | [diff] [blame] | 256 | void gtt_write(u32 reg, u32 data) |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 257 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 258 | write32(res2mmio(gtt_res, reg, 0), data); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | static inline void gtt_rmw(u32 reg, u32 andmask, u32 ormask) |
| 262 | { |
| 263 | u32 val = gtt_read(reg); |
| 264 | val &= andmask; |
| 265 | val |= ormask; |
| 266 | gtt_write(reg, val); |
| 267 | } |
| 268 | |
Matt DeVillier | 53e2446 | 2016-08-05 02:20:15 -0500 | [diff] [blame] | 269 | int gtt_poll(u32 reg, u32 mask, u32 value) |
| 270 | { unsigned int try = GT_RETRY; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 271 | u32 data; |
| 272 | |
| 273 | while (try--) { |
| 274 | data = gtt_read(reg); |
| 275 | if ((data & mask) == value) |
| 276 | return 1; |
| 277 | udelay(10); |
| 278 | } |
| 279 | |
| 280 | printk(BIOS_ERR, "GT init timeout\n"); |
| 281 | return 0; |
| 282 | } |
| 283 | |
Angel Pons | 14cd17a | 2020-10-23 14:49:36 +0200 | [diff] [blame] | 284 | static void gma_setup_panel(struct device *dev) |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 285 | { |
Angel Pons | 9126093 | 2021-06-14 12:39:16 +0200 | [diff] [blame] | 286 | struct soc_intel_broadwell_config *conf = config_of(dev); |
Michael Niewöhner | 97e21d3 | 2020-12-28 00:49:33 +0100 | [diff] [blame] | 287 | const struct i915_gpu_panel_config *panel_cfg = &conf->panel_cfg; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 288 | u32 reg32; |
| 289 | |
| 290 | /* Setup Digital Port Hotplug */ |
| 291 | reg32 = gtt_read(PCH_PORT_HOTPLUG); |
| 292 | if (!reg32) { |
| 293 | reg32 = (conf->gpu_dp_b_hotplug & 0x7) << 2; |
| 294 | reg32 |= (conf->gpu_dp_c_hotplug & 0x7) << 10; |
| 295 | reg32 |= (conf->gpu_dp_d_hotplug & 0x7) << 18; |
| 296 | gtt_write(PCH_PORT_HOTPLUG, reg32); |
| 297 | } |
| 298 | |
| 299 | /* Setup Panel Power On Delays */ |
| 300 | reg32 = gtt_read(PCH_PP_ON_DELAYS); |
| 301 | if (!reg32) { |
Michael Niewöhner | 97e21d3 | 2020-12-28 00:49:33 +0100 | [diff] [blame] | 302 | reg32 |= ((panel_cfg->up_delay_ms * 10) & 0x1fff) << 16; |
| 303 | reg32 |= (panel_cfg->backlight_on_delay_ms * 10) & 0x1fff; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 304 | gtt_write(PCH_PP_ON_DELAYS, reg32); |
| 305 | } |
| 306 | |
| 307 | /* Setup Panel Power Off Delays */ |
| 308 | reg32 = gtt_read(PCH_PP_OFF_DELAYS); |
| 309 | if (!reg32) { |
Michael Niewöhner | 97e21d3 | 2020-12-28 00:49:33 +0100 | [diff] [blame] | 310 | reg32 = ((panel_cfg->down_delay_ms * 10) & 0x1fff) << 16; |
| 311 | reg32 |= (panel_cfg->backlight_off_delay_ms * 10) & 0x1fff; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 312 | gtt_write(PCH_PP_OFF_DELAYS, reg32); |
| 313 | } |
| 314 | |
| 315 | /* Setup Panel Power Cycle Delay */ |
Michael Niewöhner | 97e21d3 | 2020-12-28 00:49:33 +0100 | [diff] [blame] | 316 | if (panel_cfg->cycle_delay_ms) { |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 317 | reg32 = gtt_read(PCH_PP_DIVISOR); |
Michael Niewöhner | 3054a19 | 2020-12-28 15:00:39 +0100 | [diff] [blame] | 318 | reg32 &= ~0x1f; |
Michael Niewöhner | 97e21d3 | 2020-12-28 00:49:33 +0100 | [diff] [blame] | 319 | reg32 |= (DIV_ROUND_UP(panel_cfg->cycle_delay_ms, 100) + 1) & 0x1f; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 320 | gtt_write(PCH_PP_DIVISOR, reg32); |
| 321 | } |
| 322 | |
Nico Huber | 3b57a7c | 2019-10-08 20:24:05 +0200 | [diff] [blame] | 323 | /* So far all devices seem to use the PCH PWM function. |
| 324 | The CPU PWM registers are all zero after reset. */ |
Michael Niewöhner | 97e21d3 | 2020-12-28 00:49:33 +0100 | [diff] [blame] | 325 | if (panel_cfg->backlight_pwm_hz) { |
Nico Huber | 3b57a7c | 2019-10-08 20:24:05 +0200 | [diff] [blame] | 326 | /* For Lynx Point-LP: |
| 327 | Reference clock is 24MHz. We can choose either a 16 |
| 328 | or a 128 step increment. Use 16 if we would have less |
| 329 | than 100 steps otherwise. */ |
Angel Pons | 14cd17a | 2020-10-23 14:49:36 +0200 | [diff] [blame] | 330 | const unsigned int refclock = 24 * MHz; |
| 331 | const unsigned int hz_limit = refclock / 128 / 100; |
Nico Huber | 3b57a7c | 2019-10-08 20:24:05 +0200 | [diff] [blame] | 332 | unsigned int pwm_increment, pwm_period; |
| 333 | u32 south_chicken2; |
| 334 | |
| 335 | south_chicken2 = gtt_read(SOUTH_CHICKEN2); |
Michael Niewöhner | 97e21d3 | 2020-12-28 00:49:33 +0100 | [diff] [blame] | 336 | if (panel_cfg->backlight_pwm_hz > hz_limit) { |
Nico Huber | 3b57a7c | 2019-10-08 20:24:05 +0200 | [diff] [blame] | 337 | pwm_increment = 16; |
Nico Huber | e47132b | 2020-03-23 01:33:23 +0100 | [diff] [blame] | 338 | south_chicken2 |= 1 << 5; |
Nico Huber | 3b57a7c | 2019-10-08 20:24:05 +0200 | [diff] [blame] | 339 | } else { |
| 340 | pwm_increment = 128; |
Nico Huber | e47132b | 2020-03-23 01:33:23 +0100 | [diff] [blame] | 341 | south_chicken2 &= ~(1 << 5); |
Nico Huber | 3b57a7c | 2019-10-08 20:24:05 +0200 | [diff] [blame] | 342 | } |
| 343 | gtt_write(SOUTH_CHICKEN2, south_chicken2); |
| 344 | |
Michael Niewöhner | 97e21d3 | 2020-12-28 00:49:33 +0100 | [diff] [blame] | 345 | pwm_period = refclock / pwm_increment / panel_cfg->backlight_pwm_hz; |
Angel Pons | 14cd17a | 2020-10-23 14:49:36 +0200 | [diff] [blame] | 346 | printk(BIOS_INFO, |
| 347 | "GMA: Setting backlight PWM frequency to %uMHz / %u / %u = %uHz\n", |
| 348 | refclock / MHz, pwm_increment, pwm_period, |
| 349 | DIV_ROUND_CLOSEST(refclock, pwm_increment * pwm_period)); |
| 350 | |
Nico Huber | 3b57a7c | 2019-10-08 20:24:05 +0200 | [diff] [blame] | 351 | /* Start with a 50% duty cycle. */ |
| 352 | gtt_write(BLC_PWM_PCH_CTL2, pwm_period << 16 | pwm_period / 2); |
| 353 | |
| 354 | gtt_write(BLC_PWM_PCH_CTL1, |
Michael Niewöhner | 97e21d3 | 2020-12-28 00:49:33 +0100 | [diff] [blame] | 355 | (panel_cfg->backlight_polarity == GPU_BACKLIGHT_POLARITY_LOW) << 29 | |
Nico Huber | 3b57a7c | 2019-10-08 20:24:05 +0200 | [diff] [blame] | 356 | BLM_PCH_OVERRIDE_ENABLE | BLM_PCH_PWM_ENABLE); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 357 | } |
| 358 | } |
| 359 | |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 360 | static int igd_get_cdclk_haswell(u32 *const cdsel, int *const inform_pc, |
| 361 | struct device *const dev) |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 362 | { |
Angel Pons | 9126093 | 2021-06-14 12:39:16 +0200 | [diff] [blame] | 363 | const struct soc_intel_broadwell_config *const conf = config_of(dev); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 364 | int cdclk = conf->cdclk; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 365 | |
| 366 | /* Check for ULX GT1 or GT2 */ |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 367 | const int devid = pci_read_config16(dev, PCI_DEVICE_ID); |
Angel Pons | 9eaca7d | 2020-10-23 22:01:44 +0200 | [diff] [blame] | 368 | const int cpu_is_ult = cpu_family_model() == HASWELL_FAMILY_ULT; |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 369 | const int gpu_is_ulx = devid == IGD_HASWELL_ULX_GT1 || |
| 370 | devid == IGD_HASWELL_ULX_GT2; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 371 | |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 372 | /* Check for fixed fused clock */ |
| 373 | if (gtt_read(0x42014) & 1 << 24) |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 374 | cdclk = GT_CDCLK_450; |
| 375 | |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 376 | /* |
| 377 | * ULX defaults to 337MHz with possible override for 450MHz |
| 378 | * ULT is fixed at 450MHz |
| 379 | * others default to 540MHz with possible override for 450MHz |
| 380 | */ |
| 381 | if (gpu_is_ulx && cdclk <= GT_CDCLK_337) |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 382 | cdclk = GT_CDCLK_337; |
Angel Pons | 9eaca7d | 2020-10-23 22:01:44 +0200 | [diff] [blame] | 383 | else if (gpu_is_ulx || cpu_is_ult || |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 384 | cdclk == GT_CDCLK_337 || cdclk == GT_CDCLK_450) |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 385 | cdclk = GT_CDCLK_450; |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 386 | else |
| 387 | cdclk = GT_CDCLK_540; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 388 | |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 389 | *cdsel = cdclk != GT_CDCLK_450; |
| 390 | *inform_pc = gpu_is_ulx; |
| 391 | return cdclk; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 392 | } |
| 393 | |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 394 | static int igd_get_cdclk_broadwell(u32 *const cdsel, int *const inform_pc, |
| 395 | struct device *const dev) |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 396 | { |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 397 | static const u32 cdsel_by_cdclk[] = { 0, 2, 0, 1, 3 }; |
Angel Pons | 9126093 | 2021-06-14 12:39:16 +0200 | [diff] [blame] | 398 | const struct soc_intel_broadwell_config *const conf = config_of(dev); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 399 | int cdclk = conf->cdclk; |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 400 | |
| 401 | /* Check for ULX */ |
| 402 | const int devid = pci_read_config16(dev, PCI_DEVICE_ID); |
Angel Pons | 9eaca7d | 2020-10-23 22:01:44 +0200 | [diff] [blame] | 403 | const int cpu_is_ult = cpu_family_model() == BROADWELL_FAMILY_ULT; |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 404 | const int gpu_is_ulx = devid == IGD_BROADWELL_Y_GT2; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 405 | |
| 406 | /* Inform power controller of upcoming frequency change */ |
| 407 | gtt_write(0x138128, 0); |
| 408 | gtt_write(0x13812c, 0); |
| 409 | gtt_write(0x138124, 0x80000018); |
| 410 | |
| 411 | /* Poll GT driver mailbox for run/busy clear */ |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 412 | if (gtt_poll(0x138124, (1 << 31), (0 << 31))) { |
| 413 | *inform_pc = 1; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 414 | } else { |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 415 | cdclk = GT_CDCLK_450; |
| 416 | *inform_pc = 0; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 417 | } |
| 418 | |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 419 | /* Check for fixed fused clock */ |
| 420 | if (gtt_read(0x42014) & 1 << 24) |
| 421 | cdclk = GT_CDCLK_450; |
| 422 | |
| 423 | /* |
| 424 | * ULX defaults to 450MHz with possible override up to 540MHz |
| 425 | * ULT defaults to 540MHz with possible override up to 675MHz |
| 426 | * others default to 675MHz with possible override for lower freqs |
| 427 | */ |
| 428 | if (cdclk == GT_CDCLK_337) |
| 429 | cdclk = GT_CDCLK_337; |
| 430 | else if (cdclk == GT_CDCLK_450 || |
| 431 | (gpu_is_ulx && cdclk == GT_CDCLK_DEFAULT)) |
| 432 | cdclk = GT_CDCLK_450; |
| 433 | else if (cdclk == GT_CDCLK_540 || gpu_is_ulx || |
Angel Pons | 9eaca7d | 2020-10-23 22:01:44 +0200 | [diff] [blame] | 434 | (cpu_is_ult && cdclk == GT_CDCLK_DEFAULT)) |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 435 | cdclk = GT_CDCLK_540; |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 436 | else |
| 437 | cdclk = GT_CDCLK_675; |
| 438 | |
| 439 | *cdsel = cdsel_by_cdclk[cdclk]; |
| 440 | return cdclk; |
| 441 | } |
| 442 | |
| 443 | static void igd_cdclk_init(struct device *dev, const int is_broadwell) |
| 444 | { |
| 445 | u32 dpdiv, cdsel, cdval; |
| 446 | int cdclk, inform_pc; |
| 447 | |
| 448 | if (is_broadwell) |
| 449 | cdclk = igd_get_cdclk_broadwell(&cdsel, &inform_pc, dev); |
| 450 | else |
| 451 | cdclk = igd_get_cdclk_haswell(&cdsel, &inform_pc, dev); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 452 | |
| 453 | /* Set variables based on CD Clock setting */ |
| 454 | switch (cdclk) { |
| 455 | case GT_CDCLK_337: |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 456 | cdval = 337; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 457 | dpdiv = 169; |
Matt DeVillier | f8960a6 | 2016-11-16 23:37:43 -0600 | [diff] [blame] | 458 | reg_em4 = 16; |
| 459 | reg_em5 = 225; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 460 | break; |
| 461 | case GT_CDCLK_450: |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 462 | cdval = 449; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 463 | dpdiv = 225; |
Matt DeVillier | f8960a6 | 2016-11-16 23:37:43 -0600 | [diff] [blame] | 464 | reg_em4 = 4; |
| 465 | reg_em5 = 75; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 466 | break; |
| 467 | case GT_CDCLK_540: |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 468 | cdval = 539; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 469 | dpdiv = 270; |
Matt DeVillier | f8960a6 | 2016-11-16 23:37:43 -0600 | [diff] [blame] | 470 | reg_em4 = 4; |
| 471 | reg_em5 = 90; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 472 | break; |
| 473 | case GT_CDCLK_675: |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 474 | cdval = 674; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 475 | dpdiv = 338; |
Matt DeVillier | f8960a6 | 2016-11-16 23:37:43 -0600 | [diff] [blame] | 476 | reg_em4 = 8; |
| 477 | reg_em5 = 225; |
Angel Pons | b8a8249 | 2021-01-29 18:49:18 +0100 | [diff] [blame] | 478 | break; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 479 | default: |
| 480 | return; |
| 481 | } |
| 482 | |
| 483 | /* Set LPCLL_CTL CD Clock Frequency Select */ |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 484 | gtt_rmw(0x130040, 0xf3ffffff, cdsel << 26); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 485 | |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 486 | if (inform_pc) { |
| 487 | /* Inform power controller of selected frequency */ |
| 488 | gtt_write(0x138128, cdsel); |
| 489 | gtt_write(0x13812c, 0); |
| 490 | gtt_write(0x138124, 0x80000017); |
| 491 | } |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 492 | |
| 493 | /* Program CD Clock Frequency */ |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 494 | gtt_rmw(0x46200, 0xfffffc00, cdval); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 495 | |
| 496 | /* Set CPU DP AUX 2X bit clock dividers */ |
| 497 | gtt_rmw(0x64010, 0xfffff800, dpdiv); |
| 498 | gtt_rmw(0x64810, 0xfffff800, dpdiv); |
| 499 | } |
| 500 | |
| 501 | static void igd_init(struct device *dev) |
| 502 | { |
| 503 | int is_broadwell = !!(cpu_family_model() == BROADWELL_FAMILY_ULT); |
| 504 | u32 rp1_gfx_freq; |
| 505 | |
Nico Huber | f2a0be2 | 2020-04-26 17:01:25 +0200 | [diff] [blame] | 506 | intel_gma_init_igd_opregion(); |
| 507 | |
Angel Pons | c1bfbe0 | 2021-11-03 13:18:53 +0100 | [diff] [blame] | 508 | gtt_res = probe_resource(dev, PCI_BASE_ADDRESS_0); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 509 | if (!gtt_res || !gtt_res->base) |
| 510 | return; |
| 511 | |
Nico Huber | dd59762 | 2020-04-26 19:46:35 +0200 | [diff] [blame] | 512 | if (!CONFIG(NO_GFX_INIT)) |
| 513 | pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER); |
| 514 | |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 515 | /* Early init steps */ |
| 516 | if (is_broadwell) { |
| 517 | reg_script_run_on_dev(dev, broadwell_early_init_script); |
Duncan Laurie | 84b9cf4 | 2014-07-31 10:46:57 -0700 | [diff] [blame] | 518 | |
| 519 | /* Set GFXPAUSE based on stepping */ |
Angel Pons | 9d733de | 2020-11-23 13:15:19 +0100 | [diff] [blame] | 520 | if (cpu_stepping() <= (CPUID_BROADWELL_ULT_E0 & 0xf) && |
Duncan Laurie | 84b9cf4 | 2014-07-31 10:46:57 -0700 | [diff] [blame] | 521 | systemagent_revision() <= 9) { |
| 522 | gtt_write(0xa000, 0x300ff); |
| 523 | } else { |
| 524 | gtt_write(0xa000, 0x30020); |
| 525 | } |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 526 | } else { |
| 527 | reg_script_run_on_dev(dev, haswell_early_init_script); |
| 528 | } |
| 529 | |
| 530 | /* Set RP1 graphics frequency */ |
Angel Pons | a8753e9 | 2021-04-17 14:34:37 +0200 | [diff] [blame] | 531 | rp1_gfx_freq = (mchbar_read32(0x5998) >> 8) & 0xff; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 532 | gtt_write(0xa008, rp1_gfx_freq << 24); |
| 533 | |
| 534 | /* Post VBIOS panel setup */ |
Angel Pons | 14cd17a | 2020-10-23 14:49:36 +0200 | [diff] [blame] | 535 | gma_setup_panel(dev); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 536 | |
| 537 | /* Initialize PCI device, load/execute BIOS Option ROM */ |
| 538 | pci_dev_init(dev); |
| 539 | |
| 540 | /* Late init steps */ |
Nico Huber | e392f41 | 2016-12-07 19:29:08 +0100 | [diff] [blame] | 541 | igd_cdclk_init(dev, is_broadwell); |
Lee Leahy | 8a9c7dc | 2017-03-17 10:43:25 -0700 | [diff] [blame] | 542 | if (is_broadwell) |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 543 | reg_script_run_on_dev(dev, broadwell_late_init_script); |
Lee Leahy | 8a9c7dc | 2017-03-17 10:43:25 -0700 | [diff] [blame] | 544 | else |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 545 | reg_script_run_on_dev(dev, haswell_late_init_script); |
Duncan Laurie | 6168027 | 2014-05-05 12:42:35 -0500 | [diff] [blame] | 546 | |
Duncan Laurie | 49efaf2 | 2014-10-09 16:13:24 -0700 | [diff] [blame] | 547 | if (gfx_get_init_done()) { |
| 548 | /* |
| 549 | * Work around VBIOS issue that is not clearing first 64 |
| 550 | * bytes of the framebuffer during VBE mode set. |
| 551 | */ |
| 552 | struct resource *fb = find_resource(dev, PCI_BASE_ADDRESS_2); |
| 553 | memset((void *)((u32)fb->base), 0, 64); |
| 554 | } |
| 555 | |
Kyösti Mälkki | 1ec23c9 | 2015-05-29 06:18:18 +0300 | [diff] [blame] | 556 | if (!gfx_get_init_done() && !acpi_is_wakeup_s3()) { |
Duncan Laurie | 6168027 | 2014-05-05 12:42:35 -0500 | [diff] [blame] | 557 | /* |
| 558 | * Enable DDI-A if the Option ROM did not execute: |
| 559 | * |
| 560 | * bit 0: Display detected (RO) |
| 561 | * bit 4: DDI A supports 4 lanes and DDI E is not used |
| 562 | * bit 7: DDI buffer is idle |
| 563 | */ |
| 564 | gtt_write(DDI_BUF_CTL_A, DDI_BUF_IS_IDLE | DDI_A_4_LANES | |
| 565 | DDI_INIT_DISPLAY_DETECTED); |
| 566 | } |
Matt DeVillier | 773488f | 2017-10-18 12:27:25 -0500 | [diff] [blame] | 567 | |
Nico Huber | a06689c | 2019-10-08 20:56:41 +0200 | [diff] [blame] | 568 | if (CONFIG(MAINBOARD_USE_LIBGFXINIT)) { |
| 569 | int lightup_ok; |
| 570 | gma_gfxinit(&lightup_ok); |
| 571 | gfx_set_init_done(lightup_ok); |
| 572 | } |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 573 | } |
| 574 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 575 | static void gma_generate_ssdt(const struct device *dev) |
Matt DeVillier | 53e2446 | 2016-08-05 02:20:15 -0500 | [diff] [blame] | 576 | { |
| 577 | const struct soc_intel_broadwell_config *chip = dev->chip_info; |
| 578 | |
| 579 | drivers_intel_gma_displays_ssdt_generate(&chip->gfx); |
| 580 | } |
| 581 | |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 582 | static struct device_operations igd_ops = { |
Angel Pons | 257b00f | 2020-10-25 02:49:29 +0200 | [diff] [blame] | 583 | .read_resources = pci_dev_read_resources, |
| 584 | .set_resources = pci_dev_set_resources, |
| 585 | .enable_resources = pci_dev_enable_resources, |
| 586 | .init = igd_init, |
Matt DeVillier | 53e2446 | 2016-08-05 02:20:15 -0500 | [diff] [blame] | 587 | .acpi_fill_ssdt = gma_generate_ssdt, |
Angel Pons | 257b00f | 2020-10-25 02:49:29 +0200 | [diff] [blame] | 588 | .ops_pci = &pci_dev_ops_pci, |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 589 | }; |
| 590 | |
| 591 | static const unsigned short pci_device_ids[] = { |
| 592 | IGD_HASWELL_ULT_GT1, |
| 593 | IGD_HASWELL_ULT_GT2, |
| 594 | IGD_HASWELL_ULT_GT3, |
| 595 | IGD_BROADWELL_U_GT1, |
| 596 | IGD_BROADWELL_U_GT2, |
| 597 | IGD_BROADWELL_U_GT3_15W, |
| 598 | IGD_BROADWELL_U_GT3_28W, |
| 599 | IGD_BROADWELL_Y_GT2, |
| 600 | IGD_BROADWELL_H_GT2, |
| 601 | IGD_BROADWELL_H_GT3, |
| 602 | 0, |
| 603 | }; |
| 604 | |
| 605 | static const struct pci_driver igd_driver __pci_driver = { |
| 606 | .ops = &igd_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 607 | .vendor = PCI_VID_INTEL, |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 608 | .devices = pci_device_ids, |
| 609 | }; |