1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2016 Google, Inc
13 #include <asm/intel_regs.h>
17 #include <asm/arch/pch.h>
18 #include <asm/arch/sandybridge.h>
20 DECLARE_GLOBAL_DATA_PTR;
22 struct gt_powermeter {
27 /* These are magic values - unfortunately the meaning is unknown */
28 static const struct gt_powermeter snb_pm_gt1[] = {
29 { 0xa200, 0xcc000000 },
30 { 0xa204, 0x07000040 },
31 { 0xa208, 0x0000fe00 },
32 { 0xa20c, 0x00000000 },
33 { 0xa210, 0x17000000 },
34 { 0xa214, 0x00000021 },
35 { 0xa218, 0x0817fe19 },
36 { 0xa21c, 0x00000000 },
37 { 0xa220, 0x00000000 },
38 { 0xa224, 0xcc000000 },
39 { 0xa228, 0x07000040 },
40 { 0xa22c, 0x0000fe00 },
41 { 0xa230, 0x00000000 },
42 { 0xa234, 0x17000000 },
43 { 0xa238, 0x00000021 },
44 { 0xa23c, 0x0817fe19 },
45 { 0xa240, 0x00000000 },
46 { 0xa244, 0x00000000 },
47 { 0xa248, 0x8000421e },
51 static const struct gt_powermeter snb_pm_gt2[] = {
52 { 0xa200, 0x330000a6 },
53 { 0xa204, 0x402d0031 },
54 { 0xa208, 0x00165f83 },
55 { 0xa20c, 0xf1000000 },
56 { 0xa210, 0x00000000 },
57 { 0xa214, 0x00160016 },
58 { 0xa218, 0x002a002b },
59 { 0xa21c, 0x00000000 },
60 { 0xa220, 0x00000000 },
61 { 0xa224, 0x330000a6 },
62 { 0xa228, 0x402d0031 },
63 { 0xa22c, 0x00165f83 },
64 { 0xa230, 0xf1000000 },
65 { 0xa234, 0x00000000 },
66 { 0xa238, 0x00160016 },
67 { 0xa23c, 0x002a002b },
68 { 0xa240, 0x00000000 },
69 { 0xa244, 0x00000000 },
70 { 0xa248, 0x8000421e },
74 static const struct gt_powermeter ivb_pm_gt1[] = {
75 { 0xa800, 0x00000000 },
76 { 0xa804, 0x00021c00 },
77 { 0xa808, 0x00000403 },
78 { 0xa80c, 0x02001700 },
79 { 0xa810, 0x05000200 },
80 { 0xa814, 0x00000000 },
81 { 0xa818, 0x00690500 },
82 { 0xa81c, 0x0000007f },
83 { 0xa820, 0x01002501 },
84 { 0xa824, 0x00000300 },
85 { 0xa828, 0x01000331 },
86 { 0xa82c, 0x0000000c },
87 { 0xa830, 0x00010016 },
88 { 0xa834, 0x01100101 },
89 { 0xa838, 0x00010103 },
90 { 0xa83c, 0x00041300 },
91 { 0xa840, 0x00000b30 },
92 { 0xa844, 0x00000000 },
93 { 0xa848, 0x7f000000 },
94 { 0xa84c, 0x05000008 },
95 { 0xa850, 0x00000001 },
96 { 0xa854, 0x00000004 },
97 { 0xa858, 0x00000007 },
98 { 0xa85c, 0x00000000 },
99 { 0xa860, 0x00010000 },
100 { 0xa248, 0x0000221e },
101 { 0xa900, 0x00000000 },
102 { 0xa904, 0x00001c00 },
103 { 0xa908, 0x00000000 },
104 { 0xa90c, 0x06000000 },
105 { 0xa910, 0x09000200 },
106 { 0xa914, 0x00000000 },
107 { 0xa918, 0x00590000 },
108 { 0xa91c, 0x00000000 },
109 { 0xa920, 0x04002501 },
110 { 0xa924, 0x00000100 },
111 { 0xa928, 0x03000410 },
112 { 0xa92c, 0x00000000 },
113 { 0xa930, 0x00020000 },
114 { 0xa934, 0x02070106 },
115 { 0xa938, 0x00010100 },
116 { 0xa93c, 0x00401c00 },
117 { 0xa940, 0x00000000 },
118 { 0xa944, 0x00000000 },
119 { 0xa948, 0x10000e00 },
120 { 0xa94c, 0x02000004 },
121 { 0xa950, 0x00000001 },
122 { 0xa954, 0x00000004 },
123 { 0xa960, 0x00060000 },
124 { 0xaa3c, 0x00001c00 },
125 { 0xaa54, 0x00000004 },
126 { 0xaa60, 0x00060000 },
130 static const struct gt_powermeter ivb_pm_gt2_17w[] = {
131 { 0xa800, 0x20000000 },
132 { 0xa804, 0x000e3800 },
133 { 0xa808, 0x00000806 },
134 { 0xa80c, 0x0c002f00 },
135 { 0xa810, 0x0c000800 },
136 { 0xa814, 0x00000000 },
137 { 0xa818, 0x00d20d00 },
138 { 0xa81c, 0x000000ff },
139 { 0xa820, 0x03004b02 },
140 { 0xa824, 0x00000600 },
141 { 0xa828, 0x07000773 },
142 { 0xa82c, 0x00000000 },
143 { 0xa830, 0x00020032 },
144 { 0xa834, 0x1520040d },
145 { 0xa838, 0x00020105 },
146 { 0xa83c, 0x00083700 },
147 { 0xa840, 0x000016ff },
148 { 0xa844, 0x00000000 },
149 { 0xa848, 0xff000000 },
150 { 0xa84c, 0x0a000010 },
151 { 0xa850, 0x00000002 },
152 { 0xa854, 0x00000008 },
153 { 0xa858, 0x0000000f },
154 { 0xa85c, 0x00000000 },
155 { 0xa860, 0x00020000 },
156 { 0xa248, 0x0000221e },
157 { 0xa900, 0x00000000 },
158 { 0xa904, 0x00003800 },
159 { 0xa908, 0x00000000 },
160 { 0xa90c, 0x0c000000 },
161 { 0xa910, 0x12000800 },
162 { 0xa914, 0x00000000 },
163 { 0xa918, 0x00b20000 },
164 { 0xa91c, 0x00000000 },
165 { 0xa920, 0x08004b02 },
166 { 0xa924, 0x00000300 },
167 { 0xa928, 0x01000820 },
168 { 0xa92c, 0x00000000 },
169 { 0xa930, 0x00030000 },
170 { 0xa934, 0x15150406 },
171 { 0xa938, 0x00020300 },
172 { 0xa93c, 0x00903900 },
173 { 0xa940, 0x00000000 },
174 { 0xa944, 0x00000000 },
175 { 0xa948, 0x20001b00 },
176 { 0xa94c, 0x0a000010 },
177 { 0xa950, 0x00000000 },
178 { 0xa954, 0x00000008 },
179 { 0xa960, 0x00110000 },
180 { 0xaa3c, 0x00003900 },
181 { 0xaa54, 0x00000008 },
182 { 0xaa60, 0x00110000 },
186 static const struct gt_powermeter ivb_pm_gt2_35w[] = {
187 { 0xa800, 0x00000000 },
188 { 0xa804, 0x00030400 },
189 { 0xa808, 0x00000806 },
190 { 0xa80c, 0x0c002f00 },
191 { 0xa810, 0x0c000300 },
192 { 0xa814, 0x00000000 },
193 { 0xa818, 0x00d20d00 },
194 { 0xa81c, 0x000000ff },
195 { 0xa820, 0x03004b02 },
196 { 0xa824, 0x00000600 },
197 { 0xa828, 0x07000773 },
198 { 0xa82c, 0x00000000 },
199 { 0xa830, 0x00020032 },
200 { 0xa834, 0x1520040d },
201 { 0xa838, 0x00020105 },
202 { 0xa83c, 0x00083700 },
203 { 0xa840, 0x000016ff },
204 { 0xa844, 0x00000000 },
205 { 0xa848, 0xff000000 },
206 { 0xa84c, 0x0a000010 },
207 { 0xa850, 0x00000001 },
208 { 0xa854, 0x00000008 },
209 { 0xa858, 0x00000008 },
210 { 0xa85c, 0x00000000 },
211 { 0xa860, 0x00020000 },
212 { 0xa248, 0x0000221e },
213 { 0xa900, 0x00000000 },
214 { 0xa904, 0x00003800 },
215 { 0xa908, 0x00000000 },
216 { 0xa90c, 0x0c000000 },
217 { 0xa910, 0x12000800 },
218 { 0xa914, 0x00000000 },
219 { 0xa918, 0x00b20000 },
220 { 0xa91c, 0x00000000 },
221 { 0xa920, 0x08004b02 },
222 { 0xa924, 0x00000300 },
223 { 0xa928, 0x01000820 },
224 { 0xa92c, 0x00000000 },
225 { 0xa930, 0x00030000 },
226 { 0xa934, 0x15150406 },
227 { 0xa938, 0x00020300 },
228 { 0xa93c, 0x00903900 },
229 { 0xa940, 0x00000000 },
230 { 0xa944, 0x00000000 },
231 { 0xa948, 0x20001b00 },
232 { 0xa94c, 0x0a000010 },
233 { 0xa950, 0x00000000 },
234 { 0xa954, 0x00000008 },
235 { 0xa960, 0x00110000 },
236 { 0xaa3c, 0x00003900 },
237 { 0xaa54, 0x00000008 },
238 { 0xaa60, 0x00110000 },
242 static inline u32 gtt_read(void *bar, u32 reg)
244 return readl(bar + reg);
247 static inline void gtt_write(void *bar, u32 reg, u32 data)
249 writel(data, bar + reg);
252 static void gtt_write_powermeter(void *bar, const struct gt_powermeter *pm)
254 for (; pm && pm->reg; pm++)
255 gtt_write(bar, pm->reg, pm->value);
258 #define GTT_RETRY 1000
259 static int gtt_poll(void *bar, u32 reg, u32 mask, u32 value)
261 unsigned try = GTT_RETRY;
265 data = gtt_read(bar, reg);
266 if ((data & mask) == value)
271 printf("GT init timeout\n");
275 static int gma_pm_init_pre_vbios(void *gtt_bar, int rev)
279 debug("GT Power Management Init, silicon = %#x\n", rev);
281 if (rev < IVB_STEP_C0) {
282 /* 1: Enable force wake */
283 gtt_write(gtt_bar, 0xa18c, 0x00000001);
284 gtt_poll(gtt_bar, 0x130090, (1 << 0), (1 << 0));
286 gtt_write(gtt_bar, 0xa180, 1 << 5);
287 gtt_write(gtt_bar, 0xa188, 0xffff0001);
288 gtt_poll(gtt_bar, 0x130040, (1 << 0), (1 << 0));
291 if ((rev & BASE_REV_MASK) == BASE_REV_SNB) {
292 /* 1d: Set GTT+0x42004 [15:14]=11 (SnB C1+) */
293 reg32 = gtt_read(gtt_bar, 0x42004);
294 reg32 |= (1 << 14) | (1 << 15);
295 gtt_write(gtt_bar, 0x42004, reg32);
298 if (rev >= IVB_STEP_A0) {
299 /* Display Reset Acknowledge Settings */
300 reg32 = gtt_read(gtt_bar, 0x45010);
301 reg32 |= (1 << 1) | (1 << 0);
302 gtt_write(gtt_bar, 0x45010, reg32);
305 /* 2: Get GT SKU from GTT+0x911c[13] */
306 reg32 = gtt_read(gtt_bar, 0x911c);
307 if ((rev & BASE_REV_MASK) == BASE_REV_SNB) {
308 if (reg32 & (1 << 13)) {
309 debug("SNB GT1 Power Meter Weights\n");
310 gtt_write_powermeter(gtt_bar, snb_pm_gt1);
312 debug("SNB GT2 Power Meter Weights\n");
313 gtt_write_powermeter(gtt_bar, snb_pm_gt2);
316 u32 unit = readl(MCHBAR_REG(0x5938)) & 0xf;
318 if (reg32 & (1 << 13)) {
320 debug("IVB GT1 Power Meter Weights\n");
321 gtt_write_powermeter(gtt_bar, ivb_pm_gt1);
324 u32 tdp = readl(MCHBAR_REG(0x5930)) & 0x7fff;
329 debug("IVB GT2 17W Power Meter Weights\n");
330 gtt_write_powermeter(gtt_bar, ivb_pm_gt2_17w);
331 } else if ((tdp >= 25) && (tdp <= 35)) {
333 debug("IVB GT2 25W-35W Power Meter Weights\n");
334 gtt_write_powermeter(gtt_bar, ivb_pm_gt2_35w);
337 debug("IVB GT2 35W Power Meter Weights\n");
338 gtt_write_powermeter(gtt_bar, ivb_pm_gt2_35w);
343 /* 3: Gear ratio map */
344 gtt_write(gtt_bar, 0xa004, 0x00000010);
347 gtt_write(gtt_bar, 0xa000, 0x00070020);
349 /* 5: Dynamic EU trip control */
350 gtt_write(gtt_bar, 0xa080, 0x00000004);
353 reg32 = gtt_read(gtt_bar, 0xa180);
354 reg32 |= (1 << 26) | (1 << 31);
355 /* (bit 20=1 for SNB step D1+ / IVB A0+) */
356 if (rev >= SNB_STEP_D1)
358 gtt_write(gtt_bar, 0xa180, reg32);
360 /* 6a: for SnB step D2+ only */
361 if (((rev & BASE_REV_MASK) == BASE_REV_SNB) &&
362 (rev >= SNB_STEP_D2)) {
363 reg32 = gtt_read(gtt_bar, 0x9400);
365 gtt_write(gtt_bar, 0x9400, reg32);
367 reg32 = gtt_read(gtt_bar, 0x941c);
370 gtt_write(gtt_bar, 0x941c, reg32);
371 gtt_poll(gtt_bar, 0x941c, (1 << 1), (0 << 1));
374 if ((rev & BASE_REV_MASK) == BASE_REV_IVB) {
375 reg32 = gtt_read(gtt_bar, 0x907c);
377 gtt_write(gtt_bar, 0x907c, reg32);
379 /* 6b: Clocking reset controls */
380 gtt_write(gtt_bar, 0x9424, 0x00000001);
382 /* 6b: Clocking reset controls */
383 gtt_write(gtt_bar, 0x9424, 0x00000000);
387 if (gtt_poll(gtt_bar, 0x138124, (1 << 31), (0 << 31))) {
388 gtt_write(gtt_bar, 0x138128, 0x00000029); /* Mailbox Data */
389 /* Mailbox Cmd for RC6 VID */
390 gtt_write(gtt_bar, 0x138124, 0x80000004);
391 if (gtt_poll(gtt_bar, 0x138124, (1 << 31), (0 << 31)))
392 gtt_write(gtt_bar, 0x138124, 0x8000000a);
393 gtt_poll(gtt_bar, 0x138124, (1 << 31), (0 << 31));
397 gtt_write(gtt_bar, 0xa090, 0x00000000); /* RC Control */
398 gtt_write(gtt_bar, 0xa098, 0x03e80000); /* RC1e Wake Rate Limit */
399 gtt_write(gtt_bar, 0xa09c, 0x0028001e); /* RC6/6p Wake Rate Limit */
400 gtt_write(gtt_bar, 0xa0a0, 0x0000001e); /* RC6pp Wake Rate Limit */
401 gtt_write(gtt_bar, 0xa0a8, 0x0001e848); /* RC Evaluation Interval */
402 gtt_write(gtt_bar, 0xa0ac, 0x00000019); /* RC Idle Hysteresis */
405 gtt_write(gtt_bar, 0x2054, 0x0000000a); /* Render Idle Max Count */
406 gtt_write(gtt_bar, 0x12054, 0x0000000a); /* Video Idle Max Count */
407 gtt_write(gtt_bar, 0x22054, 0x0000000a); /* Blitter Idle Max Count */
410 gtt_write(gtt_bar, 0xa0b0, 0x00000000); /* Unblock Ack to Busy */
411 gtt_write(gtt_bar, 0xa0b4, 0x000003e8); /* RC1e Threshold */
412 gtt_write(gtt_bar, 0xa0b8, 0x0000c350); /* RC6 Threshold */
413 gtt_write(gtt_bar, 0xa0bc, 0x000186a0); /* RC6p Threshold */
414 gtt_write(gtt_bar, 0xa0c0, 0x0000fa00); /* RC6pp Threshold */
417 gtt_write(gtt_bar, 0xa010, 0x000f4240); /* RP Down Timeout */
418 gtt_write(gtt_bar, 0xa014, 0x12060000); /* RP Interrupt Limits */
419 gtt_write(gtt_bar, 0xa02c, 0x00015f90); /* RP Up Threshold */
420 gtt_write(gtt_bar, 0xa030, 0x000186a0); /* RP Down Threshold */
421 gtt_write(gtt_bar, 0xa068, 0x000186a0); /* RP Up EI */
422 gtt_write(gtt_bar, 0xa06c, 0x000493e0); /* RP Down EI */
423 gtt_write(gtt_bar, 0xa070, 0x0000000a); /* RP Idle Hysteresis */
425 /* 11a: Enable Render Standby (RC6) */
426 if ((rev & BASE_REV_MASK) == BASE_REV_IVB) {
428 * IvyBridge should also support DeepRenderStandby.
430 * Unfortunately it does not work reliably on all SKUs so
431 * disable it here and it can be enabled by the kernel.
433 gtt_write(gtt_bar, 0xa090, 0x88040000); /* HW RC Control */
435 gtt_write(gtt_bar, 0xa090, 0x88040000); /* HW RC Control */
438 /* 12: Normal Frequency Request */
439 /* RPNFREQ_VAL comes from MCHBAR 0x5998 23:16 (8 bits!? use 7) */
440 reg32 = readl(MCHBAR_REG(0x5998));
444 gtt_write(gtt_bar, 0xa008, reg32);
447 gtt_write(gtt_bar, 0xa024, 0x00000592);
449 /* 14: Enable PM Interrupts */
450 gtt_write(gtt_bar, 0x4402c, 0x03000076);
452 /* Clear 0x6c024 [8:6] */
453 reg32 = gtt_read(gtt_bar, 0x6c024);
454 reg32 &= ~0x000001c0;
455 gtt_write(gtt_bar, 0x6c024, reg32);
460 static int gma_pm_init_post_vbios(struct udevice *dev, int rev, void *gtt_bar)
462 const void *blob = gd->fdt_blob;
463 int node = dev_of_offset(dev);
464 u32 reg32, cycle_delay;
466 debug("GT Power Management Init (post VBIOS)\n");
468 /* 15: Deassert Force Wake */
469 if (rev < IVB_STEP_C0) {
470 gtt_write(gtt_bar, 0xa18c, gtt_read(gtt_bar, 0xa18c) & ~1);
471 gtt_poll(gtt_bar, 0x130090, (1 << 0), (0 << 0));
473 gtt_write(gtt_bar, 0xa188, 0x1fffe);
474 if (gtt_poll(gtt_bar, 0x130040, (1 << 0), (0 << 0))) {
475 gtt_write(gtt_bar, 0xa188,
476 gtt_read(gtt_bar, 0xa188) | 1);
480 /* 16: SW RC Control */
481 gtt_write(gtt_bar, 0xa094, 0x00060000);
483 /* Setup Digital Port Hotplug */
484 reg32 = gtt_read(gtt_bar, 0xc4030);
488 if (fdtdec_get_int_array(blob, node, "intel,dp_hotplug",
489 dp_hotplug, ARRAY_SIZE(dp_hotplug)))
492 reg32 = (dp_hotplug[0] & 0x7) << 2;
493 reg32 |= (dp_hotplug[0] & 0x7) << 10;
494 reg32 |= (dp_hotplug[0] & 0x7) << 18;
495 gtt_write(gtt_bar, 0xc4030, reg32);
498 /* Setup Panel Power On Delays */
499 reg32 = gtt_read(gtt_bar, 0xc7208);
501 reg32 = (unsigned)fdtdec_get_int(blob, node,
502 "panel-port-select", 0) << 30;
503 reg32 |= fdtdec_get_int(blob, node, "panel-power-up-delay", 0)
505 reg32 |= fdtdec_get_int(blob, node,
506 "panel-power-backlight-on-delay", 0);
507 gtt_write(gtt_bar, 0xc7208, reg32);
510 /* Setup Panel Power Off Delays */
511 reg32 = gtt_read(gtt_bar, 0xc720c);
513 reg32 = fdtdec_get_int(blob, node, "panel-power-down-delay", 0)
515 reg32 |= fdtdec_get_int(blob, node,
516 "panel-power-backlight-off-delay", 0);
517 gtt_write(gtt_bar, 0xc720c, reg32);
520 /* Setup Panel Power Cycle Delay */
521 cycle_delay = fdtdec_get_int(blob, node,
522 "intel,panel-power-cycle-delay", 0);
524 reg32 = gtt_read(gtt_bar, 0xc7210);
526 reg32 |= cycle_delay;
527 gtt_write(gtt_bar, 0xc7210, reg32);
530 /* Enable Backlight if needed */
531 reg32 = fdtdec_get_int(blob, node, "intel,cpu-backlight", 0);
533 gtt_write(gtt_bar, 0x48250, (1 << 31));
534 gtt_write(gtt_bar, 0x48254, reg32);
536 reg32 = fdtdec_get_int(blob, node, "intel,pch-backlight", 0);
538 gtt_write(gtt_bar, 0xc8250, (1 << 31));
539 gtt_write(gtt_bar, 0xc8254, reg32);
546 * Some vga option roms are used for several chipsets but they only have one
547 * PCI ID in their header. If we encounter such an option rom, we need to do
548 * the mapping ourselves.
551 uint32_t board_map_oprom_vendev(uint32_t vendev)
554 case 0x80860102: /* GT1 Desktop */
555 case 0x8086010a: /* GT1 Server */
556 case 0x80860112: /* GT2 Desktop */
557 case 0x80860116: /* GT2 Mobile */
558 case 0x80860122: /* GT2 Desktop >=1.3GHz */
559 case 0x80860126: /* GT2 Mobile >=1.3GHz */
560 case 0x80860156: /* IVB */
561 case 0x80860166: /* IVB */
562 return 0x80860106; /* GT1 Mobile */
568 static int int15_handler(void)
572 debug("%s: INT15 function %04x!\n", __func__, M.x86.R_AX);
574 switch (M.x86.R_AX) {
577 * Set Panel Fitting Hook:
578 * bit 2 = Graphics Stretching
579 * bit 1 = Text Stretching
580 * bit 0 = Centering (do not set with bit1 or bit2)
581 * 0 = video bios default
584 M.x86.R_CL = 0x00; /* Use video bios default */
589 * Boot Display Device Hook:
600 M.x86.R_CX = 0x0000; /* Use video bios default */
605 * Hook to select active LFP configuration:
606 * 00h = No LVDS, VBIOS does not enable LVDS
607 * 01h = Int-LVDS, LFP driven by integrated LVDS decoder
608 * 02h = SVDO-LVDS, LFP driven by SVDO decoder
609 * 03h = eDP, LFP Driven by Int-DisplayPort encoder
612 M.x86.R_CX = 0x0003; /* eDP */
616 switch (M.x86.R_CH) {
630 /* Get SG/Non-SG mode */
636 /* Interrupt was not handled */
637 debug("Unknown INT15 5f70 function: 0x%02x\n",
646 debug("Unknown INT15 function %04x!\n", M.x86.R_AX);
652 static void sandybridge_setup_graphics(struct udevice *dev,
653 struct udevice *video_dev)
659 dm_pci_read_config16(video_dev, PCI_DEVICE_ID, ®16);
661 case 0x0102: /* GT1 Desktop */
662 case 0x0106: /* GT1 Mobile */
663 case 0x010a: /* GT1 Server */
664 case 0x0112: /* GT2 Desktop */
665 case 0x0116: /* GT2 Mobile */
666 case 0x0122: /* GT2 Desktop >=1.3GHz */
667 case 0x0126: /* GT2 Mobile >=1.3GHz */
668 case 0x0156: /* IvyBridge */
669 case 0x0166: /* IvyBridge */
672 debug("Graphics not supported by this CPU/chipset\n");
676 debug("Initialising Graphics\n");
678 /* Setup IGD memory by setting GGC[7:3] = 1 for 32MB */
679 dm_pci_read_config16(dev, GGC, ®16);
682 /* Program GTT memory by setting GGC[9:8] = 2MB */
685 /* Enable VGA decode */
687 dm_pci_write_config16(dev, GGC, reg16);
689 /* Enable 256MB aperture */
690 dm_pci_read_config8(video_dev, MSAC, ®8);
693 dm_pci_write_config8(video_dev, MSAC, reg8);
695 /* Erratum workarounds */
696 reg32 = readl(MCHBAR_REG(0x5f00));
697 reg32 |= (1 << 9) | (1 << 10);
698 writel(reg32, MCHBAR_REG(0x5f00));
700 /* Enable SA Clock Gating */
701 reg32 = readl(MCHBAR_REG(0x5f00));
702 writel(reg32 | 1, MCHBAR_REG(0x5f00));
704 /* GPU RC6 workaround for sighting 366252 */
705 reg32 = readl(MCHBAR_REG(0x5d14));
707 writel(reg32, MCHBAR_REG(0x5d14));
710 reg32 = readl(MCHBAR_REG(0x6120));
712 writel(reg32, MCHBAR_REG(0x6120));
714 reg32 = readl(MCHBAR_REG(0x5418));
715 reg32 |= (1 << 4) | (1 << 5);
716 writel(reg32, MCHBAR_REG(0x5418));
719 static int gma_func0_init(struct udevice *dev)
721 struct udevice *nbridge;
728 /* Enable PCH Display Port */
729 writew(0x0010, RCB_REG(DISPBDF));
730 setbits_le32(RCB_REG(FD2), PCH_ENABLE_DBDF);
732 ret = uclass_first_device_err(UCLASS_NORTHBRIDGE, &nbridge);
735 rev = bridge_silicon_revision(nbridge);
736 sandybridge_setup_graphics(nbridge, dev);
738 /* IGD needs to be Bus Master */
739 dm_pci_read_config32(dev, PCI_COMMAND, ®32);
740 reg32 |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO;
741 dm_pci_write_config32(dev, PCI_COMMAND, reg32);
743 /* Use write-combining for the graphics memory, 256MB */
744 base = dm_pci_read_bar32(dev, 2);
745 mtrr_add_request(MTRR_TYPE_WRCOMB, base, 256 << 20);
748 gtt_bar = (void *)(ulong)dm_pci_read_bar32(dev, 0);
749 debug("GT bar %p\n", gtt_bar);
750 ret = gma_pm_init_pre_vbios(gtt_bar, rev);
757 static int bd82x6x_video_probe(struct udevice *dev)
762 rev = gma_func0_init(dev);
765 ret = vbe_setup_video(dev, int15_handler);
769 /* Post VBIOS init */
770 gtt_bar = (void *)(ulong)dm_pci_read_bar32(dev, 0);
771 ret = gma_pm_init_post_vbios(dev, rev, gtt_bar);
778 static const struct udevice_id bd82x6x_video_ids[] = {
779 { .compatible = "intel,gma" },
783 U_BOOT_DRIVER(bd82x6x_video) = {
784 .name = "bd82x6x_video",
786 .of_match = bd82x6x_video_ids,
787 .probe = bd82x6x_video_probe,