blob: 057d65ad555ef2d5c9242649ed6109bfd31af22f [file] [log] [blame]
Aaron Durbin76c37002012-10-30 09:03:43 -05001/*
2 * This file is part of the coreboot project.
3 *
Ronald G. Minnich4f78b182013-04-17 16:57:30 -07004 * Copyright 2012 Google Inc.
Aaron Durbin76c37002012-10-30 09:03:43 -05005 *
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>
21#include <console/console.h>
Kyösti Mälkkiab56b3b2013-11-28 16:44:51 +020022#include <bootmode.h>
Aaron Durbin76c37002012-10-30 09:03:43 -050023#include <delay.h>
24#include <device/device.h>
25#include <device/pci.h>
26#include <device/pci_ids.h>
Ronald G. Minnich5bcca7e2013-06-25 15:56:46 -070027#include <drivers/intel/gma/i915_reg.h>
Furquan Shaikh77f48cd2013-08-19 10:16:50 -070028#include <drivers/intel/gma/i915.h>
Duncan Laurie356833d2013-07-09 15:40:27 -070029#include <cpu/intel/haswell/haswell.h>
Furquan Shaikh77f48cd2013-08-19 10:16:50 -070030#include <stdlib.h>
Ronald G. Minnich9518b562013-09-19 16:45:22 -070031#include <string.h>
Aaron Durbin76c37002012-10-30 09:03:43 -050032
33#include "chip.h"
34#include "haswell.h"
35
Furquan Shaikhcb61ea72013-08-15 15:23:58 -070036#if CONFIG_CHROMEOS
37#include <vendorcode/google/chromeos/chromeos.h>
38#endif
39
Duncan Laurie356833d2013-07-09 15:40:27 -070040struct gt_reg {
41 u32 reg;
42 u32 andmask;
43 u32 ormask;
44};
45
46static const struct gt_reg haswell_gt_setup[] = {
47 /* Enable Counters */
48 { 0x0a248, 0x00000000, 0x00000016 },
49 { 0x0a000, 0x00000000, 0x00070020 },
50 { 0x0a180, 0xff3fffff, 0x15000000 },
51 /* Enable DOP Clock Gating */
52 { 0x09424, 0x00000000, 0x000003fd },
53 /* Enable Unit Level Clock Gating */
54 { 0x09400, 0x00000000, 0x00000080 },
55 { 0x09404, 0x00000000, 0x40401000 },
56 { 0x09408, 0x00000000, 0x00000000 },
57 { 0x0940c, 0x00000000, 0x02000001 },
58 { 0x0a008, 0x00000000, 0x08000000 },
59 /* Wake Rate Limits */
60 { 0x0a090, 0xffffffff, 0x00000000 },
61 { 0x0a098, 0xffffffff, 0x03e80000 },
62 { 0x0a09c, 0xffffffff, 0x00280000 },
63 { 0x0a0a8, 0xffffffff, 0x0001e848 },
64 { 0x0a0ac, 0xffffffff, 0x00000019 },
65 /* Render/Video/Blitter Idle Max Count */
66 { 0x02054, 0x00000000, 0x0000000a },
67 { 0x12054, 0x00000000, 0x0000000a },
68 { 0x22054, 0x00000000, 0x0000000a },
69 /* RC Sleep / RCx Thresholds */
70 { 0x0a0b0, 0xffffffff, 0x00000000 },
71 { 0x0a0b4, 0xffffffff, 0x000003e8 },
72 { 0x0a0b8, 0xffffffff, 0x0000c350 },
73 /* RP Settings */
74 { 0x0a010, 0xffffffff, 0x000f4240 },
75 { 0x0a014, 0xffffffff, 0x12060000 },
76 { 0x0a02c, 0xffffffff, 0x0000e808 },
77 { 0x0a030, 0xffffffff, 0x0003bd08 },
78 { 0x0a068, 0xffffffff, 0x000101d0 },
79 { 0x0a06c, 0xffffffff, 0x00055730 },
80 { 0x0a070, 0xffffffff, 0x0000000a },
81 /* RP Control */
82 { 0x0a024, 0x00000000, 0x00000b92 },
83 /* HW RC6 Control */
84 { 0x0a090, 0x00000000, 0x88040000 },
85 /* Video Frequency Request */
86 { 0x0a00c, 0x00000000, 0x08000000 },
87 { 0 },
88};
89
90static const struct gt_reg haswell_gt_lock[] = {
91 { 0x0a248, 0xffffffff, 0x80000000 },
92 { 0x0a004, 0xffffffff, 0x00000010 },
93 { 0x0a080, 0xffffffff, 0x00000004 },
94 { 0x0a180, 0xffffffff, 0x80000000 },
95 { 0 },
96};
97
Aaron Durbin76c37002012-10-30 09:03:43 -050098/* some vga option roms are used for several chipsets but they only have one
99 * PCI ID in their header. If we encounter such an option rom, we need to do
100 * the mapping ourselfes
101 */
102
103u32 map_oprom_vendev(u32 vendev)
104{
105 u32 new_vendev=vendev;
106
107 switch (vendev) {
Aaron Durbin71161292012-12-13 16:43:32 -0600108 case 0x80860402: /* GT1 Desktop */
109 case 0x80860406: /* GT1 Mobile */
110 case 0x8086040a: /* GT1 Server */
Duncan Laurie26e7dd72012-12-19 09:12:31 -0800111 case 0x80860a06: /* GT1 ULT */
Aaron Durbin71161292012-12-13 16:43:32 -0600112
113 case 0x80860412: /* GT2 Desktop */
114 case 0x80860416: /* GT2 Mobile */
115 case 0x8086041a: /* GT2 Server */
Duncan Laurie26e7dd72012-12-19 09:12:31 -0800116 case 0x80860a16: /* GT2 ULT */
Aaron Durbin71161292012-12-13 16:43:32 -0600117
118 case 0x80860422: /* GT3 Desktop */
119 case 0x80860426: /* GT3 Mobile */
120 case 0x8086042a: /* GT3 Server */
Duncan Laurie26e7dd72012-12-19 09:12:31 -0800121 case 0x80860a26: /* GT3 ULT */
Aaron Durbin71161292012-12-13 16:43:32 -0600122
123 new_vendev=0x80860406; /* GT1 Mobile */
Aaron Durbin76c37002012-10-30 09:03:43 -0500124 break;
125 }
126
127 return new_vendev;
128}
129
130static struct resource *gtt_res = NULL;
131
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700132u32 gtt_read(u32 reg)
Aaron Durbin76c37002012-10-30 09:03:43 -0500133{
Ronald G. Minnich9518b562013-09-19 16:45:22 -0700134 u32 val;
135 val = read32(gtt_res->base + reg);
136 return val;
137
Aaron Durbin76c37002012-10-30 09:03:43 -0500138}
139
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700140void gtt_write(u32 reg, u32 data)
Aaron Durbin76c37002012-10-30 09:03:43 -0500141{
142 write32(gtt_res->base + reg, data);
143}
144
Duncan Laurie356833d2013-07-09 15:40:27 -0700145static inline void gtt_rmw(u32 reg, u32 andmask, u32 ormask)
146{
147 u32 val = gtt_read(reg);
148 val &= andmask;
149 val |= ormask;
150 gtt_write(reg, val);
151}
152
153static inline void gtt_write_regs(const struct gt_reg *gt)
154{
155 for (; gt && gt->reg; gt++) {
156 if (gt->andmask)
157 gtt_rmw(gt->reg, gt->andmask, gt->ormask);
158 else
159 gtt_write(gt->reg, gt->ormask);
160 }
161}
162
Aaron Durbin76c37002012-10-30 09:03:43 -0500163#define GTT_RETRY 1000
Ronald G. Minnich9518b562013-09-19 16:45:22 -0700164int gtt_poll(u32 reg, u32 mask, u32 value)
Aaron Durbin76c37002012-10-30 09:03:43 -0500165{
166 unsigned try = GTT_RETRY;
167 u32 data;
168
169 while (try--) {
170 data = gtt_read(reg);
171 if ((data & mask) == value)
172 return 1;
173 udelay(10);
174 }
175
176 printk(BIOS_ERR, "GT init timeout\n");
177 return 0;
178}
179
Ronald G. Minnich5bcca7e2013-06-25 15:56:46 -0700180static void power_well_enable(void)
181{
182 gtt_write(HSW_PWR_WELL_CTL1, HSW_PWR_WELL_ENABLE);
183 gtt_poll(HSW_PWR_WELL_CTL1, HSW_PWR_WELL_STATE, HSW_PWR_WELL_STATE);
Ronald G. Minnich9518b562013-09-19 16:45:22 -0700184#if CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT
185 /* In the native graphics case, we've got about 20 ms.
186 * after we power up the the AUX channel until we can talk to it.
187 * So get that going right now. We can't turn on the panel, yet, just VDD.
188 */
189 gtt_write(PCH_PP_CONTROL, PCH_PP_UNLOCK| EDP_FORCE_VDD | PANEL_POWER_RESET);
190#endif
Ronald G. Minnich5bcca7e2013-06-25 15:56:46 -0700191}
192
Aaron Durbin76c37002012-10-30 09:03:43 -0500193static void gma_pm_init_pre_vbios(struct device *dev)
194{
Aaron Durbin76c37002012-10-30 09:03:43 -0500195 printk(BIOS_DEBUG, "GT Power Management Init\n");
196
197 gtt_res = find_resource(dev, PCI_BASE_ADDRESS_0);
198 if (!gtt_res || !gtt_res->base)
199 return;
200
Ronald G. Minnich5bcca7e2013-06-25 15:56:46 -0700201 power_well_enable();
202
Duncan Laurie67113e92013-01-10 13:23:04 -0800203 /*
204 * Enable RC6
205 */
Aaron Durbin76c37002012-10-30 09:03:43 -0500206
Duncan Laurie67113e92013-01-10 13:23:04 -0800207 /* Enable Force Wake */
208 gtt_write(0x0a180, 1 << 5);
209 gtt_write(0x0a188, 0x00010001);
210 gtt_poll(0x130044, 1 << 0, 1 << 0);
Aaron Durbin76c37002012-10-30 09:03:43 -0500211
Duncan Laurie356833d2013-07-09 15:40:27 -0700212 /* GT Settings */
213 gtt_write_regs(haswell_gt_setup);
Aaron Durbin76c37002012-10-30 09:03:43 -0500214
Duncan Laurie356833d2013-07-09 15:40:27 -0700215 /* Wait for Mailbox Ready */
216 gtt_poll(0x138124, (1 << 31), (0 << 31));
217 /* Mailbox Data - RC6 VIDS */
218 gtt_write(0x138128, 0x00000000);
219 /* Mailbox Command */
220 gtt_write(0x138124, 0x80000004);
221 /* Wait for Mailbox Ready */
222 gtt_poll(0x138124, (1 << 31), (0 << 31));
Aaron Durbin76c37002012-10-30 09:03:43 -0500223
Duncan Laurie356833d2013-07-09 15:40:27 -0700224 /* Enable PM Interrupts */
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700225 gtt_write(GEN6_PMIER, GEN6_PM_MBOX_EVENT | GEN6_PM_THERMAL_EVENT |
226 GEN6_PM_RP_DOWN_TIMEOUT | GEN6_PM_RP_UP_THRESHOLD |
227 GEN6_PM_RP_DOWN_THRESHOLD | GEN6_PM_RP_UP_EI_EXPIRED |
228 GEN6_PM_RP_DOWN_EI_EXPIRED);
Aaron Durbin76c37002012-10-30 09:03:43 -0500229
Duncan Laurie67113e92013-01-10 13:23:04 -0800230 /* Enable RC6 in idle */
231 gtt_write(0x0a094, 0x00040000);
Duncan Laurie356833d2013-07-09 15:40:27 -0700232
233 /* PM Lock Settings */
234 gtt_write_regs(haswell_gt_lock);
Aaron Durbin76c37002012-10-30 09:03:43 -0500235}
236
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700237static void init_display_planes(void)
238{
239 int pipe, plane;
240
241 /* Disable cursor mode */
242 for (pipe = PIPE_A; pipe <= PIPE_C; pipe++) {
243 gtt_write(CURCNTR_IVB(pipe), CURSOR_MODE_DISABLE);
244 gtt_write(CURBASE_IVB(pipe), 0x00000000);
245 }
246
247 /* Disable primary plane and set surface base address*/
248 for (plane = PLANE_A; plane <= PLANE_C; plane++) {
249 gtt_write(DSPCNTR(plane), DISPLAY_PLANE_DISABLE);
250 gtt_write(DSPSURF(plane), 0x00000000);
251 }
252
253 /* Disable VGA display */
254 gtt_write(CPU_VGACNTRL, CPU_VGA_DISABLE);
255}
256
Duncan Lauriec7f2ab72013-05-28 07:49:09 -0700257static void gma_setup_panel(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -0500258{
259 struct northbridge_intel_haswell_config *conf = dev->chip_info;
260 u32 reg32;
261
262 printk(BIOS_DEBUG, "GT Power Management Init (post VBIOS)\n");
263
Aaron Durbin76c37002012-10-30 09:03:43 -0500264 /* Setup Digital Port Hotplug */
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700265 reg32 = gtt_read(PCH_PORT_HOTPLUG);
Aaron Durbin76c37002012-10-30 09:03:43 -0500266 if (!reg32) {
267 reg32 = (conf->gpu_dp_b_hotplug & 0x7) << 2;
268 reg32 |= (conf->gpu_dp_c_hotplug & 0x7) << 10;
269 reg32 |= (conf->gpu_dp_d_hotplug & 0x7) << 18;
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700270 gtt_write(PCH_PORT_HOTPLUG, reg32);
Aaron Durbin76c37002012-10-30 09:03:43 -0500271 }
272
273 /* Setup Panel Power On Delays */
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700274 reg32 = gtt_read(PCH_PP_ON_DELAYS);
Aaron Durbin76c37002012-10-30 09:03:43 -0500275 if (!reg32) {
276 reg32 = (conf->gpu_panel_port_select & 0x3) << 30;
277 reg32 |= (conf->gpu_panel_power_up_delay & 0x1fff) << 16;
278 reg32 |= (conf->gpu_panel_power_backlight_on_delay & 0x1fff);
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700279 gtt_write(PCH_PP_ON_DELAYS, reg32);
Aaron Durbin76c37002012-10-30 09:03:43 -0500280 }
281
282 /* Setup Panel Power Off Delays */
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700283 reg32 = gtt_read(PCH_PP_OFF_DELAYS);
Aaron Durbin76c37002012-10-30 09:03:43 -0500284 if (!reg32) {
285 reg32 = (conf->gpu_panel_power_down_delay & 0x1fff) << 16;
286 reg32 |= (conf->gpu_panel_power_backlight_off_delay & 0x1fff);
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700287 gtt_write(PCH_PP_OFF_DELAYS, reg32);
Aaron Durbin76c37002012-10-30 09:03:43 -0500288 }
289
290 /* Setup Panel Power Cycle Delay */
291 if (conf->gpu_panel_power_cycle_delay) {
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700292 reg32 = gtt_read(PCH_PP_DIVISOR);
Aaron Durbin76c37002012-10-30 09:03:43 -0500293 reg32 &= ~0xff;
294 reg32 |= conf->gpu_panel_power_cycle_delay & 0xff;
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700295 gtt_write(PCH_PP_DIVISOR, reg32);
Aaron Durbin76c37002012-10-30 09:03:43 -0500296 }
297
298 /* Enable Backlight if needed */
299 if (conf->gpu_cpu_backlight) {
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700300 gtt_write(BLC_PWM_CPU_CTL2, BLC_PWM2_ENABLE);
301 gtt_write(BLC_PWM_CPU_CTL, conf->gpu_cpu_backlight);
Aaron Durbin76c37002012-10-30 09:03:43 -0500302 }
303 if (conf->gpu_pch_backlight) {
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700304 gtt_write(BLC_PWM_PCH_CTL1, BLM_PCH_PWM_ENABLE);
305 gtt_write(BLC_PWM_PCH_CTL2, conf->gpu_pch_backlight);
Aaron Durbin76c37002012-10-30 09:03:43 -0500306 }
Ronald G. Minnich5bcca7e2013-06-25 15:56:46 -0700307
308 /* Get display,pipeline,and DDI registers into a basic sane state */
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700309 power_well_enable();
310
311 init_display_planes();
312
313 /* DDI-A params set:
314 bit 0: Display detected (RO)
315 bit 4: DDI A supports 4 lanes and DDI E is not used
316 bit 7: DDI buffer is idle
317 */
318 gtt_write(DDI_BUF_CTL_A, DDI_BUF_IS_IDLE | DDI_A_4_LANES | DDI_INIT_DISPLAY_DETECTED);
319
320 /* Set FDI registers - is this required? */
Ronald G. Minnich5bcca7e2013-06-25 15:56:46 -0700321 gtt_write(_FDI_RXA_MISC, 0x00200090);
322 gtt_write(_FDI_RXA_MISC, 0x0a000000);
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700323
324 /* Enable the handshake with PCH display when processing reset */
325 gtt_write(NDE_RSTWRN_OPT, RST_PCH_HNDSHK_EN);
326
327 /* undocumented */
Ronald G. Minnich5bcca7e2013-06-25 15:56:46 -0700328 gtt_write(0x42090, 0x04000000);
Ronald G. Minnich5bcca7e2013-06-25 15:56:46 -0700329 gtt_write(0x9840, 0x00000000);
330 gtt_write(0x42090, 0xa4000000);
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700331
332 gtt_write(SOUTH_DSPCLK_GATE_D, PCH_LP_PARTITION_LEVEL_DISABLE);
333
334 /* undocumented */
Ronald G. Minnich5bcca7e2013-06-25 15:56:46 -0700335 gtt_write(0x42080, 0x00004000);
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700336
337 /* Prepare DDI buffers for DP and FDI */
338 intel_prepare_ddi();
339
340 /* Hot plug detect buffer enabled for port A */
341 gtt_write(DIGITAL_PORT_HOTPLUG_CNTRL, DIGITAL_PORTA_HOTPLUG_ENABLE);
342
343 /* Enable HPD buffer for digital port D and B */
344 gtt_write(PCH_PORT_HOTPLUG, PORTD_HOTPLUG_ENABLE | PORTB_HOTPLUG_ENABLE);
345
346 /* Bits 4:0 - Power cycle delay (default 0x6 --> 500ms)
347 Bits 31:8 - Reference divider (0x0004af ----> 24MHz)
348 */
Ronald G. Minnich5bcca7e2013-06-25 15:56:46 -0700349 gtt_write(PCH_PP_DIVISOR, 0x0004af06);
Aaron Durbin76c37002012-10-30 09:03:43 -0500350}
351
Duncan Lauriec7f2ab72013-05-28 07:49:09 -0700352static void gma_pm_init_post_vbios(struct device *dev)
353{
Duncan Laurie356833d2013-07-09 15:40:27 -0700354 int cdclk = 0;
355 int devid = pci_read_config16(dev, PCI_DEVICE_ID);
356 int gpu_is_ulx = 0;
357
358 if (devid == 0x0a0e || devid == 0x0a1e)
359 gpu_is_ulx = 1;
360
361 /* CD Frequency */
Duncan Laurie3106d0f2013-08-12 13:51:22 -0700362 if ((gtt_read(0x42014) & 0x1000000) || gpu_is_ulx || haswell_is_ult())
363 cdclk = 0; /* fixed frequency */
364 else
365 cdclk = 2; /* variable frequency */
Duncan Laurie356833d2013-07-09 15:40:27 -0700366
Duncan Laurie356833d2013-07-09 15:40:27 -0700367 if (gpu_is_ulx || cdclk != 0)
368 gtt_rmw(0x130040, 0xf7ffffff, 0x04000000);
369 else
370 gtt_rmw(0x130040, 0xf3ffffff, 0x00000000);
371
372 /* More magic */
373 if (haswell_is_ult() || gpu_is_ulx) {
Duncan Laurie3106d0f2013-08-12 13:51:22 -0700374 if (!gpu_is_ulx)
Duncan Laurie356833d2013-07-09 15:40:27 -0700375 gtt_write(0x138128, 0x00000000);
376 else
377 gtt_write(0x138128, 0x00000001);
378 gtt_write(0x13812c, 0x00000000);
379 gtt_write(0x138124, 0x80000017);
380 }
381
Duncan Lauriec7f2ab72013-05-28 07:49:09 -0700382 /* Disable Force Wake */
383 gtt_write(0x0a188, 0x00010000);
384 gtt_poll(0x130044, 1 << 0, 0 << 0);
Duncan Laurie356833d2013-07-09 15:40:27 -0700385 gtt_write(0x0a188, 0x00000001);
Duncan Lauriec7f2ab72013-05-28 07:49:09 -0700386}
387
Aaron Durbin76c37002012-10-30 09:03:43 -0500388static void gma_func0_init(struct device *dev)
389{
Ronald G. Minnich4f78b182013-04-17 16:57:30 -0700390 int lightup_ok = 0;
Aaron Durbin76c37002012-10-30 09:03:43 -0500391 u32 reg32;
Ronald G. Minnich2a66d6b2013-03-28 17:01:43 -0700392 u32 graphics_base; //, graphics_size;
Aaron Durbin76c37002012-10-30 09:03:43 -0500393 /* IGD needs to be Bus Master */
394 reg32 = pci_read_config32(dev, PCI_COMMAND);
395 reg32 |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO;
396 pci_write_config32(dev, PCI_COMMAND, reg32);
397
Ronald G. Minnich2a66d6b2013-03-28 17:01:43 -0700398
399 /* the BAR for graphics space is a well known number for
400 * sandy and ivy. And the resource code renumbers it.
401 * So it's almost like having two hardcodes.
402 */
403 graphics_base = dev->resource_list[1].base;
Duncan Lauriec7f2ab72013-05-28 07:49:09 -0700404
Aaron Durbin76c37002012-10-30 09:03:43 -0500405 /* Init graphics power management */
406 gma_pm_init_pre_vbios(dev);
407
Duncan Lauriec7f2ab72013-05-28 07:49:09 -0700408 /* Post VBIOS init */
409 gma_setup_panel(dev);
410
Ronald G. Minnich2a66d6b2013-03-28 17:01:43 -0700411#if CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT
412 printk(BIOS_SPEW, "NATIVE graphics, run native enable\n");
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700413 u32 mmiobase, physbase;
Furquan Shaikhcb61ea72013-08-15 15:23:58 -0700414 /* Default set to 1 since it might be required for
415 stuff like seabios */
416 unsigned int init_fb = 1;
Ronald G. Minnich2a66d6b2013-03-28 17:01:43 -0700417 mmiobase = dev->resource_list[0].base;
418 physbase = pci_read_config32(dev, 0x5c) & ~0xf;
Furquan Shaikhcb61ea72013-08-15 15:23:58 -0700419#ifdef CONFIG_CHROMEOS
420 init_fb = developer_mode_enabled() || recovery_mode_enabled();
421#endif
Furquan Shaikh77f48cd2013-08-19 10:16:50 -0700422 lightup_ok = i915lightup(physbase, mmiobase, graphics_base, init_fb);
Kyösti Mälkkiab56b3b2013-11-28 16:44:51 +0200423 if (lightup_ok)
424 gfx_set_init_done(1);
Ronald G. Minnich2a66d6b2013-03-28 17:01:43 -0700425#endif
Ronald G. Minnich4f78b182013-04-17 16:57:30 -0700426 if (! lightup_ok) {
427 printk(BIOS_SPEW, "FUI did not run; using VBIOS\n");
Stefan Reinauerf1aabec2014-01-22 15:16:30 -0800428 mdelay(CONFIG_PRE_GRAPHICS_DELAY);
Ronald G. Minnich4f78b182013-04-17 16:57:30 -0700429 pci_dev_init(dev);
430 }
431
432 /* Post VBIOS init */
433 gma_pm_init_post_vbios(dev);
Aaron Durbin76c37002012-10-30 09:03:43 -0500434}
435
436static void gma_set_subsystem(device_t dev, unsigned vendor, unsigned device)
437{
438 if (!vendor || !device) {
439 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
440 pci_read_config32(dev, PCI_VENDOR_ID));
441 } else {
442 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
443 ((device & 0xffff) << 16) | (vendor & 0xffff));
444 }
445}
446
447static struct pci_operations gma_pci_ops = {
448 .set_subsystem = gma_set_subsystem,
449};
450
451static struct device_operations gma_func0_ops = {
Vladimir Serbinenko30fe6122014-02-05 23:25:28 +0100452 .read_resources = pci_dev_read_resources,
Aaron Durbin76c37002012-10-30 09:03:43 -0500453 .set_resources = pci_dev_set_resources,
454 .enable_resources = pci_dev_enable_resources,
455 .init = gma_func0_init,
456 .scan_bus = 0,
457 .enable = 0,
458 .ops_pci = &gma_pci_ops,
459};
460
Duncan Lauriedf7be712012-12-17 11:22:57 -0800461static const unsigned short pci_device_ids[] = {
462 0x0402, /* Desktop GT1 */
463 0x0412, /* Desktop GT2 */
464 0x0422, /* Desktop GT3 */
465 0x0406, /* Mobile GT1 */
466 0x0416, /* Mobile GT2 */
467 0x0426, /* Mobile GT3 */
468 0x0d16, /* Mobile 4+3 GT1 */
469 0x0d26, /* Mobile 4+3 GT2 */
470 0x0d36, /* Mobile 4+3 GT3 */
471 0x0a06, /* ULT GT1 */
472 0x0a16, /* ULT GT2 */
473 0x0a26, /* ULT GT3 */
474 0,
475};
Aaron Durbin76c37002012-10-30 09:03:43 -0500476
477static const struct pci_driver pch_lpc __pci_driver = {
478 .ops = &gma_func0_ops,
479 .vendor = PCI_VENDOR_ID_INTEL,
480 .devices = pci_device_ids,
481};