blob: 31293e5ed3cf4c90450c085c7ae878db0fc46fde [file] [log] [blame]
Duncan Lauriec88c54c2014-04-30 16:36:13 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Google Inc.
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; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <arch/io.h>
Marc Jonesa6354a12014-12-26 22:11:14 -070021#include <bootmode.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070022#include <console/console.h>
23#include <delay.h>
24#include <device/device.h>
25#include <device/pci.h>
26#include <device/pci_ids.h>
27#include <stdlib.h>
28#include <string.h>
29#include <reg_script.h>
30#include <drivers/intel/gma/i915_reg.h>
31#include <broadwell/cpu.h>
32#include <broadwell/ramstage.h>
33#include <broadwell/systemagent.h>
34#include <chip.h>
35
36#define GT_RETRY 1000
37#define GT_CDCLK_337 0
38#define GT_CDCLK_450 1
39#define GT_CDCLK_540 2
40#define GT_CDCLK_675 3
41
42struct 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'Callaghan986e85c2014-10-29 12:15:34 +110046 REG_RES_POLL32(PCI_BASE_ADDRESS_0, FORCEWAKE_ACK_HSW, 1, 1, GT_RETRY),
Duncan Lauriec88c54c2014-04-30 16:36:13 -070047
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
121static 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'Callaghan986e85c2014-10-29 12:15:34 +1100130 REG_RES_POLL32(PCI_BASE_ADDRESS_0, FORCEWAKE_ACK_HSW, 1, 0, GT_RETRY),
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700131 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
141static const struct reg_script broadwell_early_init_script[] = {
142 /* Enable Force Wake */
143 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa188, 0x00010001),
Edward O'Callaghan986e85c2014-10-29 12:15:34 +1100144 REG_RES_POLL32(PCI_BASE_ADDRESS_0, FORCEWAKE_ACK_HSW, 1, 1, GT_RETRY),
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700145
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
151 /* GFXPAUSE settings */
152 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa000, 0x00030020),
153
154 /* ECO Settings */
155 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa180, 0x45200000),
156
157 /* Enable DOP Clock Gating */
158 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x9424, 0x000000fd),
159
160 /* Enable Unit Level Clock Gating */
161 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x9400, 0x00000000),
162 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x9404, 0x40401000),
163 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x9408, 0x00000000),
164 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x940c, 0x02000001),
165 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x1a054, 0x0000000a),
166
167 /* Video Frequency Request */
168 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa00c, 0x08000000),
169
170 /*
171 * RC6 Settings
172 */
173
174 /* Wake Rate Limits */
175 REG_RES_RMW32(PCI_BASE_ADDRESS_0, 0x0a090, 0, 0),
176 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a098, 0x03e80000),
177 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a09c, 0x00280000),
178 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a0a8, 0x0001e848),
179 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a0ac, 0x00000019),
180
181 /* Render/Video/Blitter Idle Max Count */
182 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x02054, 0x0000000a),
183 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x12054, 0x0000000a),
184 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x22054, 0x0000000a),
185
186 /* RC Sleep / RCx Thresholds */
187 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a0b0, 0x00000000),
188 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a0b8, 0x00000271),
189
190 /* RP Settings */
191 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a010, 0x000f4240),
192 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a014, 0x12060000),
193 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a02c, 0x0000e808),
194 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a030, 0x0003bd08),
195 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a068, 0x000101d0),
196 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a06c, 0x00055730),
197 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a070, 0x0000000a),
198 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a168, 0x00000006),
199
200 /* RP Control */
201 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa024, 0x00000b92),
202
203 /* HW RC6 Control */
204 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa090, 0x90040000),
205
206 /* Set RC6 VIDs */
207 REG_RES_POLL32(PCI_BASE_ADDRESS_0, 0x138124, (1 << 31), 0, GT_RETRY),
208 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x138128, 0),
209 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x138124, 0x80000004),
210 REG_RES_POLL32(PCI_BASE_ADDRESS_0, 0x138124, (1 << 31), 0, GT_RETRY),
211
212 /* Enable PM Interrupts */
213 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x4402c, 0x03000076),
214
215 /* Enable RC6 in idle */
216 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa094, 0x00040000),
217
218 REG_SCRIPT_END
219};
220
221static const struct reg_script broadwell_late_init_script[] = {
222 /* Lock settings */
223 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a248, (1 << 31)),
224 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a000, (1 << 18)),
225 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x0a180, (1 << 31)),
226
227 /* Disable Force Wake */
228 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0xa188, 0x00010000),
Edward O'Callaghan986e85c2014-10-29 12:15:34 +1100229 REG_RES_POLL32(PCI_BASE_ADDRESS_0, FORCEWAKE_ACK_HSW, 1, 0, GT_RETRY),
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700230
231 /* Enable power well for DP and Audio */
232 REG_RES_OR32(PCI_BASE_ADDRESS_0, 0x45400, (1 << 31)),
233 REG_RES_POLL32(PCI_BASE_ADDRESS_0, 0x45400,
234 (1 << 30), (1 << 30), GT_RETRY),
235
236 REG_SCRIPT_END
237};
238
239u32 map_oprom_vendev(u32 vendev)
240{
241 return SA_IGD_OPROM_VENDEV;
242}
243
244static struct resource *gtt_res = NULL;
245
246static unsigned long gtt_read(unsigned long reg)
247{
248 u32 val;
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800249 val = read32(res2mmio(gtt_res, reg, 0));
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700250 return val;
251
252}
253
254static void gtt_write(unsigned long reg, unsigned long data)
255{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800256 write32(res2mmio(gtt_res, reg, 0), data);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700257}
258
259static inline void gtt_rmw(u32 reg, u32 andmask, u32 ormask)
260{
261 u32 val = gtt_read(reg);
262 val &= andmask;
263 val |= ormask;
264 gtt_write(reg, val);
265}
266
267static int gtt_poll(u32 reg, u32 mask, u32 value)
268{
269 unsigned try = GT_RETRY;
270 u32 data;
271
272 while (try--) {
273 data = gtt_read(reg);
274 if ((data & mask) == value)
275 return 1;
276 udelay(10);
277 }
278
279 printk(BIOS_ERR, "GT init timeout\n");
280 return 0;
281}
282
283static void igd_setup_panel(struct device *dev)
284{
285 config_t *conf = dev->chip_info;
286 u32 reg32;
287
288 /* Setup Digital Port Hotplug */
289 reg32 = gtt_read(PCH_PORT_HOTPLUG);
290 if (!reg32) {
291 reg32 = (conf->gpu_dp_b_hotplug & 0x7) << 2;
292 reg32 |= (conf->gpu_dp_c_hotplug & 0x7) << 10;
293 reg32 |= (conf->gpu_dp_d_hotplug & 0x7) << 18;
294 gtt_write(PCH_PORT_HOTPLUG, reg32);
295 }
296
297 /* Setup Panel Power On Delays */
298 reg32 = gtt_read(PCH_PP_ON_DELAYS);
299 if (!reg32) {
300 reg32 = (conf->gpu_panel_port_select & 0x3) << 30;
301 reg32 |= (conf->gpu_panel_power_up_delay & 0x1fff) << 16;
302 reg32 |= (conf->gpu_panel_power_backlight_on_delay & 0x1fff);
303 gtt_write(PCH_PP_ON_DELAYS, reg32);
304 }
305
306 /* Setup Panel Power Off Delays */
307 reg32 = gtt_read(PCH_PP_OFF_DELAYS);
308 if (!reg32) {
309 reg32 = (conf->gpu_panel_power_down_delay & 0x1fff) << 16;
310 reg32 |= (conf->gpu_panel_power_backlight_off_delay & 0x1fff);
311 gtt_write(PCH_PP_OFF_DELAYS, reg32);
312 }
313
314 /* Setup Panel Power Cycle Delay */
315 if (conf->gpu_panel_power_cycle_delay) {
316 reg32 = gtt_read(PCH_PP_DIVISOR);
317 reg32 &= ~0xff;
318 reg32 |= conf->gpu_panel_power_cycle_delay & 0xff;
319 gtt_write(PCH_PP_DIVISOR, reg32);
320 }
321
322 /* Enable Backlight if needed */
323 if (conf->gpu_cpu_backlight) {
324 gtt_write(BLC_PWM_CPU_CTL2, BLC_PWM2_ENABLE);
325 gtt_write(BLC_PWM_CPU_CTL, conf->gpu_cpu_backlight);
326 }
327 if (conf->gpu_pch_backlight) {
328 gtt_write(BLC_PWM_PCH_CTL1, BLM_PCH_PWM_ENABLE);
329 gtt_write(BLC_PWM_PCH_CTL2, conf->gpu_pch_backlight);
330 }
331}
332
333static void igd_cdclk_init_haswell(struct device *dev)
334{
335 config_t *conf = dev->chip_info;
336 int cdclk = conf->cdclk;
337 int devid = pci_read_config16(dev, PCI_DEVICE_ID);
338 int gpu_is_ulx = 0;
339 u32 dpdiv, lpcll;
340
341 /* Check for ULX GT1 or GT2 */
342 if (devid == 0x0a0e || devid == 0x0a1e)
343 gpu_is_ulx = 1;
344
345 /* 675MHz is not supported on haswell */
346 if (cdclk == GT_CDCLK_675)
347 cdclk = GT_CDCLK_337;
348
349 /* If CD clock is fixed or ULT then set to 450MHz */
350 if ((gtt_read(0x42014) & 0x1000000) || cpu_is_ult())
351 cdclk = GT_CDCLK_450;
352
353 /* 540MHz is not supported on ULX */
354 if (gpu_is_ulx && cdclk == GT_CDCLK_540)
355 cdclk = GT_CDCLK_337;
356
357 /* 337.5MHz is not supported on non-ULT/ULX */
358 if (!gpu_is_ulx && !cpu_is_ult() && cdclk == GT_CDCLK_337)
359 cdclk = GT_CDCLK_450;
360
361 /* Set variables based on CD Clock setting */
362 switch (cdclk) {
363 case GT_CDCLK_337:
364 dpdiv = 169;
365 lpcll = (1 << 26);
366 break;
367 case GT_CDCLK_450:
368 dpdiv = 225;
369 lpcll = 0;
370 break;
371 case GT_CDCLK_540:
372 dpdiv = 270;
373 lpcll = (1 << 26);
374 break;
375 default:
376 return;
377 }
378
379 /* Set LPCLL_CTL CD Clock Frequency Select */
380 gtt_rmw(0x130040, 0xf3ffffff, lpcll);
381
382 /* ULX: Inform power controller of selected frequency */
383 if (gpu_is_ulx) {
384 if (cdclk == GT_CDCLK_450)
385 gtt_write(0x138128, 0x00000000); /* 450MHz */
386 else
387 gtt_write(0x138128, 0x00000001); /* 337.5MHz */
388 gtt_write(0x13812c, 0x00000000);
389 gtt_write(0x138124, 0x80000017);
390 }
391
392 /* Set CPU DP AUX 2X bit clock dividers */
393 gtt_rmw(0x64010, 0xfffff800, dpdiv);
394 gtt_rmw(0x64810, 0xfffff800, dpdiv);
395}
396
397static void igd_cdclk_init_broadwell(struct device *dev)
398{
399 config_t *conf = dev->chip_info;
400 int cdclk = conf->cdclk;
401 u32 dpdiv, lpcll, pwctl, cdset;
402
403 /* Inform power controller of upcoming frequency change */
404 gtt_write(0x138128, 0);
405 gtt_write(0x13812c, 0);
406 gtt_write(0x138124, 0x80000018);
407
408 /* Poll GT driver mailbox for run/busy clear */
409 if (!gtt_poll(0x138124, (1 << 31), (0 << 31)))
410 cdclk = GT_CDCLK_450;
411
412 if (gtt_read(0x42014) & 0x1000000) {
413 /* If CD clock is fixed then set to 450MHz */
414 cdclk = GT_CDCLK_450;
415 } else {
416 /* Program CD clock to highest supported freq */
417 if (cpu_is_ult())
418 cdclk = GT_CDCLK_540;
419 else
420 cdclk = GT_CDCLK_675;
421 }
422
423 /* CD clock frequency 675MHz not supported on ULT */
424 if (cpu_is_ult() && cdclk == GT_CDCLK_675)
425 cdclk = GT_CDCLK_540;
426
427 /* Set variables based on CD Clock setting */
428 switch (cdclk) {
429 case GT_CDCLK_337:
430 cdset = 337;
431 lpcll = (1 << 27);
432 pwctl = 2;
433 dpdiv = 169;
434 break;
435 case GT_CDCLK_450:
436 cdset = 449;
437 lpcll = 0;
438 pwctl = 0;
439 dpdiv = 225;
440 break;
441 case GT_CDCLK_540:
442 cdset = 539;
443 lpcll = (1 << 26);
444 pwctl = 1;
445 dpdiv = 270;
446 break;
447 case GT_CDCLK_675:
448 cdset = 674;
449 lpcll = (1 << 26) | (1 << 27);
450 pwctl = 3;
451 dpdiv = 338;
452 default:
453 return;
454 }
455
456 /* Set LPCLL_CTL CD Clock Frequency Select */
457 gtt_rmw(0x130040, 0xf3ffffff, lpcll);
458
459 /* Inform power controller of selected frequency */
460 gtt_write(0x138128, pwctl);
461 gtt_write(0x13812c, 0);
462 gtt_write(0x138124, 0x80000017);
463
464 /* Program CD Clock Frequency */
465 gtt_rmw(0x46200, 0xfffffc00, cdset);
466
467 /* Set CPU DP AUX 2X bit clock dividers */
468 gtt_rmw(0x64010, 0xfffff800, dpdiv);
469 gtt_rmw(0x64810, 0xfffff800, dpdiv);
470}
471
472static void igd_init(struct device *dev)
473{
474 int is_broadwell = !!(cpu_family_model() == BROADWELL_FAMILY_ULT);
475 u32 rp1_gfx_freq;
476
477 /* IGD needs to be Bus Master */
478 u32 reg32 = pci_read_config32(dev, PCI_COMMAND);
479 reg32 |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO;
480 pci_write_config32(dev, PCI_COMMAND, reg32);
481
482 gtt_res = find_resource(dev, PCI_BASE_ADDRESS_0);
483 if (!gtt_res || !gtt_res->base)
484 return;
485
486 /* Wait for any configured pre-graphics delay */
487 mdelay(CONFIG_PRE_GRAPHICS_DELAY);
488
489 /* Early init steps */
490 if (is_broadwell) {
491 reg_script_run_on_dev(dev, broadwell_early_init_script);
492 } else {
493 reg_script_run_on_dev(dev, haswell_early_init_script);
494 }
495
496 /* Set RP1 graphics frequency */
497 rp1_gfx_freq = (MCHBAR32(0x5998) >> 8) & 0xff;
498 gtt_write(0xa008, rp1_gfx_freq << 24);
499
500 /* Post VBIOS panel setup */
501 igd_setup_panel(dev);
502
503 /* Initialize PCI device, load/execute BIOS Option ROM */
504 pci_dev_init(dev);
505
506 /* Late init steps */
507 if (is_broadwell) {
508 igd_cdclk_init_broadwell(dev);
509 reg_script_run_on_dev(dev, broadwell_late_init_script);
510 } else {
511 igd_cdclk_init_haswell(dev);
512 reg_script_run_on_dev(dev, haswell_late_init_script);
513 }
Duncan Laurie61680272014-05-05 12:42:35 -0500514
Marc Jonesa6354a12014-12-26 22:11:14 -0700515 if (!gfx_get_init_done()) {
Duncan Laurie61680272014-05-05 12:42:35 -0500516 /*
517 * Enable DDI-A if the Option ROM did not execute:
518 *
519 * bit 0: Display detected (RO)
520 * bit 4: DDI A supports 4 lanes and DDI E is not used
521 * bit 7: DDI buffer is idle
522 */
523 gtt_write(DDI_BUF_CTL_A, DDI_BUF_IS_IDLE | DDI_A_4_LANES |
524 DDI_INIT_DISPLAY_DETECTED);
525 }
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700526}
527
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700528static struct device_operations igd_ops = {
Marc Jonesa6354a12014-12-26 22:11:14 -0700529 .read_resources = &pci_dev_read_resources,
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700530 .set_resources = &pci_dev_set_resources,
531 .enable_resources = &pci_dev_enable_resources,
532 .init = &igd_init,
533 .ops_pci = &broadwell_pci_ops,
534};
535
536static const unsigned short pci_device_ids[] = {
537 IGD_HASWELL_ULT_GT1,
538 IGD_HASWELL_ULT_GT2,
539 IGD_HASWELL_ULT_GT3,
540 IGD_BROADWELL_U_GT1,
541 IGD_BROADWELL_U_GT2,
542 IGD_BROADWELL_U_GT3_15W,
543 IGD_BROADWELL_U_GT3_28W,
544 IGD_BROADWELL_Y_GT2,
545 IGD_BROADWELL_H_GT2,
546 IGD_BROADWELL_H_GT3,
547 0,
548};
549
550static const struct pci_driver igd_driver __pci_driver = {
551 .ops = &igd_ops,
552 .vendor = PCI_VENDOR_ID_INTEL,
553 .devices = pci_device_ids,
554};