blob: 714a1394ebf8debf1d89417308e72d759ad7079d [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>
Julius Werner4ee4bd52014-10-20 13:46:39 -070031#include <soc/cpu.h>
32#include <soc/ramstage.h>
33#include <soc/systemagent.h>
34#include <soc/intel/broadwell/chip.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070035
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
Duncan Laurie84b9cf42014-07-31 10:46:57 -0700151 /* GFXPAUSE settings (set based on stepping) */
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700152
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 Laurie84b9cf42014-07-31 10:46:57 -0700169 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x138158, 0x00000009),
170 REG_RES_WRITE32(PCI_BASE_ADDRESS_0, 0x13815c, 0x0000000d),
171
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700172 /*
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
223static 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'Callaghan986e85c2014-10-29 12:15:34 +1100231 REG_RES_POLL32(PCI_BASE_ADDRESS_0, FORCEWAKE_ACK_HSW, 1, 0, GT_RETRY),
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700232
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
241u32 map_oprom_vendev(u32 vendev)
242{
243 return SA_IGD_OPROM_VENDEV;
244}
245
246static struct resource *gtt_res = NULL;
247
248static unsigned long gtt_read(unsigned long reg)
249{
250 u32 val;
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800251 val = read32(res2mmio(gtt_res, reg, 0));
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700252 return val;
253
254}
255
256static void gtt_write(unsigned long reg, unsigned long data)
257{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800258 write32(res2mmio(gtt_res, reg, 0), data);
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700259}
260
261static 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
269static int gtt_poll(u32 reg, u32 mask, u32 value)
270{
271 unsigned try = GT_RETRY;
272 u32 data;
273
274 while (try--) {
275 data = gtt_read(reg);
276 if ((data & mask) == value)
277 return 1;
278 udelay(10);
279 }
280
281 printk(BIOS_ERR, "GT init timeout\n");
282 return 0;
283}
284
285static void igd_setup_panel(struct device *dev)
286{
287 config_t *conf = dev->chip_info;
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) {
302 reg32 = (conf->gpu_panel_port_select & 0x3) << 30;
303 reg32 |= (conf->gpu_panel_power_up_delay & 0x1fff) << 16;
304 reg32 |= (conf->gpu_panel_power_backlight_on_delay & 0x1fff);
305 gtt_write(PCH_PP_ON_DELAYS, reg32);
306 }
307
308 /* Setup Panel Power Off Delays */
309 reg32 = gtt_read(PCH_PP_OFF_DELAYS);
310 if (!reg32) {
311 reg32 = (conf->gpu_panel_power_down_delay & 0x1fff) << 16;
312 reg32 |= (conf->gpu_panel_power_backlight_off_delay & 0x1fff);
313 gtt_write(PCH_PP_OFF_DELAYS, reg32);
314 }
315
316 /* Setup Panel Power Cycle Delay */
317 if (conf->gpu_panel_power_cycle_delay) {
318 reg32 = gtt_read(PCH_PP_DIVISOR);
319 reg32 &= ~0xff;
320 reg32 |= conf->gpu_panel_power_cycle_delay & 0xff;
321 gtt_write(PCH_PP_DIVISOR, reg32);
322 }
323
324 /* Enable Backlight if needed */
325 if (conf->gpu_cpu_backlight) {
326 gtt_write(BLC_PWM_CPU_CTL2, BLC_PWM2_ENABLE);
327 gtt_write(BLC_PWM_CPU_CTL, conf->gpu_cpu_backlight);
328 }
329 if (conf->gpu_pch_backlight) {
330 gtt_write(BLC_PWM_PCH_CTL1, BLM_PCH_PWM_ENABLE);
331 gtt_write(BLC_PWM_PCH_CTL2, conf->gpu_pch_backlight);
332 }
333}
334
335static void igd_cdclk_init_haswell(struct device *dev)
336{
337 config_t *conf = dev->chip_info;
338 int cdclk = conf->cdclk;
339 int devid = pci_read_config16(dev, PCI_DEVICE_ID);
340 int gpu_is_ulx = 0;
341 u32 dpdiv, lpcll;
342
343 /* Check for ULX GT1 or GT2 */
344 if (devid == 0x0a0e || devid == 0x0a1e)
345 gpu_is_ulx = 1;
346
347 /* 675MHz is not supported on haswell */
348 if (cdclk == GT_CDCLK_675)
349 cdclk = GT_CDCLK_337;
350
351 /* If CD clock is fixed or ULT then set to 450MHz */
352 if ((gtt_read(0x42014) & 0x1000000) || cpu_is_ult())
353 cdclk = GT_CDCLK_450;
354
355 /* 540MHz is not supported on ULX */
356 if (gpu_is_ulx && cdclk == GT_CDCLK_540)
357 cdclk = GT_CDCLK_337;
358
359 /* 337.5MHz is not supported on non-ULT/ULX */
360 if (!gpu_is_ulx && !cpu_is_ult() && cdclk == GT_CDCLK_337)
361 cdclk = GT_CDCLK_450;
362
363 /* Set variables based on CD Clock setting */
364 switch (cdclk) {
365 case GT_CDCLK_337:
366 dpdiv = 169;
367 lpcll = (1 << 26);
368 break;
369 case GT_CDCLK_450:
370 dpdiv = 225;
371 lpcll = 0;
372 break;
373 case GT_CDCLK_540:
374 dpdiv = 270;
375 lpcll = (1 << 26);
376 break;
377 default:
378 return;
379 }
380
381 /* Set LPCLL_CTL CD Clock Frequency Select */
382 gtt_rmw(0x130040, 0xf3ffffff, lpcll);
383
384 /* ULX: Inform power controller of selected frequency */
385 if (gpu_is_ulx) {
386 if (cdclk == GT_CDCLK_450)
387 gtt_write(0x138128, 0x00000000); /* 450MHz */
388 else
389 gtt_write(0x138128, 0x00000001); /* 337.5MHz */
390 gtt_write(0x13812c, 0x00000000);
391 gtt_write(0x138124, 0x80000017);
392 }
393
394 /* Set CPU DP AUX 2X bit clock dividers */
395 gtt_rmw(0x64010, 0xfffff800, dpdiv);
396 gtt_rmw(0x64810, 0xfffff800, dpdiv);
397}
398
399static void igd_cdclk_init_broadwell(struct device *dev)
400{
401 config_t *conf = dev->chip_info;
402 int cdclk = conf->cdclk;
403 u32 dpdiv, lpcll, pwctl, cdset;
404
405 /* Inform power controller of upcoming frequency change */
406 gtt_write(0x138128, 0);
407 gtt_write(0x13812c, 0);
408 gtt_write(0x138124, 0x80000018);
409
410 /* Poll GT driver mailbox for run/busy clear */
411 if (!gtt_poll(0x138124, (1 << 31), (0 << 31)))
412 cdclk = GT_CDCLK_450;
413
414 if (gtt_read(0x42014) & 0x1000000) {
415 /* If CD clock is fixed then set to 450MHz */
416 cdclk = GT_CDCLK_450;
417 } else {
418 /* Program CD clock to highest supported freq */
419 if (cpu_is_ult())
420 cdclk = GT_CDCLK_540;
421 else
422 cdclk = GT_CDCLK_675;
423 }
424
425 /* CD clock frequency 675MHz not supported on ULT */
426 if (cpu_is_ult() && cdclk == GT_CDCLK_675)
427 cdclk = GT_CDCLK_540;
428
429 /* Set variables based on CD Clock setting */
430 switch (cdclk) {
431 case GT_CDCLK_337:
432 cdset = 337;
433 lpcll = (1 << 27);
434 pwctl = 2;
435 dpdiv = 169;
436 break;
437 case GT_CDCLK_450:
438 cdset = 449;
439 lpcll = 0;
440 pwctl = 0;
441 dpdiv = 225;
442 break;
443 case GT_CDCLK_540:
444 cdset = 539;
445 lpcll = (1 << 26);
446 pwctl = 1;
447 dpdiv = 270;
448 break;
449 case GT_CDCLK_675:
450 cdset = 674;
451 lpcll = (1 << 26) | (1 << 27);
452 pwctl = 3;
453 dpdiv = 338;
454 default:
455 return;
456 }
457
458 /* Set LPCLL_CTL CD Clock Frequency Select */
459 gtt_rmw(0x130040, 0xf3ffffff, lpcll);
460
461 /* Inform power controller of selected frequency */
462 gtt_write(0x138128, pwctl);
463 gtt_write(0x13812c, 0);
464 gtt_write(0x138124, 0x80000017);
465
466 /* Program CD Clock Frequency */
467 gtt_rmw(0x46200, 0xfffffc00, cdset);
468
469 /* Set CPU DP AUX 2X bit clock dividers */
470 gtt_rmw(0x64010, 0xfffff800, dpdiv);
471 gtt_rmw(0x64810, 0xfffff800, dpdiv);
472}
473
474static void igd_init(struct device *dev)
475{
476 int is_broadwell = !!(cpu_family_model() == BROADWELL_FAMILY_ULT);
477 u32 rp1_gfx_freq;
478
479 /* IGD needs to be Bus Master */
480 u32 reg32 = pci_read_config32(dev, PCI_COMMAND);
481 reg32 |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO;
482 pci_write_config32(dev, PCI_COMMAND, reg32);
483
484 gtt_res = find_resource(dev, PCI_BASE_ADDRESS_0);
485 if (!gtt_res || !gtt_res->base)
486 return;
487
488 /* Wait for any configured pre-graphics delay */
489 mdelay(CONFIG_PRE_GRAPHICS_DELAY);
490
491 /* Early init steps */
492 if (is_broadwell) {
493 reg_script_run_on_dev(dev, broadwell_early_init_script);
Duncan Laurie84b9cf42014-07-31 10:46:57 -0700494
495 /* Set GFXPAUSE based on stepping */
496 if (cpu_stepping() <= (CPUID_BROADWELL_E0 & 0xf) &&
497 systemagent_revision() <= 9) {
498 gtt_write(0xa000, 0x300ff);
499 } else {
500 gtt_write(0xa000, 0x30020);
501 }
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700502 } else {
503 reg_script_run_on_dev(dev, haswell_early_init_script);
504 }
505
506 /* Set RP1 graphics frequency */
507 rp1_gfx_freq = (MCHBAR32(0x5998) >> 8) & 0xff;
508 gtt_write(0xa008, rp1_gfx_freq << 24);
509
510 /* Post VBIOS panel setup */
511 igd_setup_panel(dev);
512
513 /* Initialize PCI device, load/execute BIOS Option ROM */
514 pci_dev_init(dev);
515
516 /* Late init steps */
517 if (is_broadwell) {
518 igd_cdclk_init_broadwell(dev);
519 reg_script_run_on_dev(dev, broadwell_late_init_script);
520 } else {
521 igd_cdclk_init_haswell(dev);
522 reg_script_run_on_dev(dev, haswell_late_init_script);
523 }
Duncan Laurie61680272014-05-05 12:42:35 -0500524
Marc Jonesa6354a12014-12-26 22:11:14 -0700525 if (!gfx_get_init_done()) {
Duncan Laurie61680272014-05-05 12:42:35 -0500526 /*
527 * Enable DDI-A if the Option ROM did not execute:
528 *
529 * bit 0: Display detected (RO)
530 * bit 4: DDI A supports 4 lanes and DDI E is not used
531 * bit 7: DDI buffer is idle
532 */
533 gtt_write(DDI_BUF_CTL_A, DDI_BUF_IS_IDLE | DDI_A_4_LANES |
534 DDI_INIT_DISPLAY_DETECTED);
535 }
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700536}
537
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700538static struct device_operations igd_ops = {
Marc Jonesa6354a12014-12-26 22:11:14 -0700539 .read_resources = &pci_dev_read_resources,
Duncan Lauriec88c54c2014-04-30 16:36:13 -0700540 .set_resources = &pci_dev_set_resources,
541 .enable_resources = &pci_dev_enable_resources,
542 .init = &igd_init,
543 .ops_pci = &broadwell_pci_ops,
544};
545
546static const unsigned short pci_device_ids[] = {
547 IGD_HASWELL_ULT_GT1,
548 IGD_HASWELL_ULT_GT2,
549 IGD_HASWELL_ULT_GT3,
550 IGD_BROADWELL_U_GT1,
551 IGD_BROADWELL_U_GT2,
552 IGD_BROADWELL_U_GT3_15W,
553 IGD_BROADWELL_U_GT3_28W,
554 IGD_BROADWELL_Y_GT2,
555 IGD_BROADWELL_H_GT2,
556 IGD_BROADWELL_H_GT3,
557 0,
558};
559
560static const struct pci_driver igd_driver __pci_driver = {
561 .ops = &igd_ops,
562 .vendor = PCI_VENDOR_ID_INTEL,
563 .devices = pci_device_ids,
564};