Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Ronald G. Minnich | 4f78b18 | 2013-04-17 16:57:30 -0700 | [diff] [blame] | 4 | * Copyright 2012 Google Inc. |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 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> |
| 21 | #include <console/console.h> |
Kyösti Mälkki | ab56b3b | 2013-11-28 16:44:51 +0200 | [diff] [blame] | 22 | #include <bootmode.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 23 | #include <delay.h> |
| 24 | #include <device/device.h> |
| 25 | #include <device/pci.h> |
| 26 | #include <device/pci_ids.h> |
Ronald G. Minnich | 5bcca7e | 2013-06-25 15:56:46 -0700 | [diff] [blame] | 27 | #include <drivers/intel/gma/i915_reg.h> |
Duncan Laurie | 356833d | 2013-07-09 15:40:27 -0700 | [diff] [blame] | 28 | #include <cpu/intel/haswell/haswell.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 29 | |
| 30 | #include "chip.h" |
| 31 | #include "haswell.h" |
| 32 | |
Duncan Laurie | 356833d | 2013-07-09 15:40:27 -0700 | [diff] [blame] | 33 | struct gt_reg { |
| 34 | u32 reg; |
| 35 | u32 andmask; |
| 36 | u32 ormask; |
| 37 | }; |
| 38 | |
| 39 | static const struct gt_reg haswell_gt_setup[] = { |
| 40 | /* Enable Counters */ |
| 41 | { 0x0a248, 0x00000000, 0x00000016 }, |
| 42 | { 0x0a000, 0x00000000, 0x00070020 }, |
| 43 | { 0x0a180, 0xff3fffff, 0x15000000 }, |
| 44 | /* Enable DOP Clock Gating */ |
| 45 | { 0x09424, 0x00000000, 0x000003fd }, |
| 46 | /* Enable Unit Level Clock Gating */ |
| 47 | { 0x09400, 0x00000000, 0x00000080 }, |
| 48 | { 0x09404, 0x00000000, 0x40401000 }, |
| 49 | { 0x09408, 0x00000000, 0x00000000 }, |
| 50 | { 0x0940c, 0x00000000, 0x02000001 }, |
| 51 | { 0x0a008, 0x00000000, 0x08000000 }, |
| 52 | /* Wake Rate Limits */ |
| 53 | { 0x0a090, 0xffffffff, 0x00000000 }, |
| 54 | { 0x0a098, 0xffffffff, 0x03e80000 }, |
| 55 | { 0x0a09c, 0xffffffff, 0x00280000 }, |
| 56 | { 0x0a0a8, 0xffffffff, 0x0001e848 }, |
| 57 | { 0x0a0ac, 0xffffffff, 0x00000019 }, |
| 58 | /* Render/Video/Blitter Idle Max Count */ |
| 59 | { 0x02054, 0x00000000, 0x0000000a }, |
| 60 | { 0x12054, 0x00000000, 0x0000000a }, |
| 61 | { 0x22054, 0x00000000, 0x0000000a }, |
| 62 | /* RC Sleep / RCx Thresholds */ |
| 63 | { 0x0a0b0, 0xffffffff, 0x00000000 }, |
| 64 | { 0x0a0b4, 0xffffffff, 0x000003e8 }, |
| 65 | { 0x0a0b8, 0xffffffff, 0x0000c350 }, |
| 66 | /* RP Settings */ |
| 67 | { 0x0a010, 0xffffffff, 0x000f4240 }, |
| 68 | { 0x0a014, 0xffffffff, 0x12060000 }, |
| 69 | { 0x0a02c, 0xffffffff, 0x0000e808 }, |
| 70 | { 0x0a030, 0xffffffff, 0x0003bd08 }, |
| 71 | { 0x0a068, 0xffffffff, 0x000101d0 }, |
| 72 | { 0x0a06c, 0xffffffff, 0x00055730 }, |
| 73 | { 0x0a070, 0xffffffff, 0x0000000a }, |
| 74 | /* RP Control */ |
| 75 | { 0x0a024, 0x00000000, 0x00000b92 }, |
| 76 | /* HW RC6 Control */ |
| 77 | { 0x0a090, 0x00000000, 0x88040000 }, |
| 78 | /* Video Frequency Request */ |
| 79 | { 0x0a00c, 0x00000000, 0x08000000 }, |
| 80 | { 0 }, |
| 81 | }; |
| 82 | |
| 83 | static const struct gt_reg haswell_gt_lock[] = { |
| 84 | { 0x0a248, 0xffffffff, 0x80000000 }, |
| 85 | { 0x0a004, 0xffffffff, 0x00000010 }, |
| 86 | { 0x0a080, 0xffffffff, 0x00000004 }, |
| 87 | { 0x0a180, 0xffffffff, 0x80000000 }, |
| 88 | { 0 }, |
| 89 | }; |
| 90 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 91 | /* some vga option roms are used for several chipsets but they only have one |
| 92 | * PCI ID in their header. If we encounter such an option rom, we need to do |
| 93 | * the mapping ourselfes |
| 94 | */ |
| 95 | |
| 96 | u32 map_oprom_vendev(u32 vendev) |
| 97 | { |
| 98 | u32 new_vendev=vendev; |
| 99 | |
| 100 | switch (vendev) { |
Aaron Durbin | 7116129 | 2012-12-13 16:43:32 -0600 | [diff] [blame] | 101 | case 0x80860402: /* GT1 Desktop */ |
| 102 | case 0x80860406: /* GT1 Mobile */ |
| 103 | case 0x8086040a: /* GT1 Server */ |
Duncan Laurie | 26e7dd7 | 2012-12-19 09:12:31 -0800 | [diff] [blame] | 104 | case 0x80860a06: /* GT1 ULT */ |
Aaron Durbin | 7116129 | 2012-12-13 16:43:32 -0600 | [diff] [blame] | 105 | |
| 106 | case 0x80860412: /* GT2 Desktop */ |
| 107 | case 0x80860416: /* GT2 Mobile */ |
| 108 | case 0x8086041a: /* GT2 Server */ |
Duncan Laurie | 26e7dd7 | 2012-12-19 09:12:31 -0800 | [diff] [blame] | 109 | case 0x80860a16: /* GT2 ULT */ |
Aaron Durbin | 7116129 | 2012-12-13 16:43:32 -0600 | [diff] [blame] | 110 | |
| 111 | case 0x80860422: /* GT3 Desktop */ |
| 112 | case 0x80860426: /* GT3 Mobile */ |
| 113 | case 0x8086042a: /* GT3 Server */ |
Duncan Laurie | 26e7dd7 | 2012-12-19 09:12:31 -0800 | [diff] [blame] | 114 | case 0x80860a26: /* GT3 ULT */ |
Aaron Durbin | 7116129 | 2012-12-13 16:43:32 -0600 | [diff] [blame] | 115 | |
| 116 | new_vendev=0x80860406; /* GT1 Mobile */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 117 | break; |
| 118 | } |
| 119 | |
| 120 | return new_vendev; |
| 121 | } |
| 122 | |
| 123 | static struct resource *gtt_res = NULL; |
| 124 | |
| 125 | static inline u32 gtt_read(u32 reg) |
| 126 | { |
| 127 | return read32(gtt_res->base + reg); |
| 128 | } |
| 129 | |
| 130 | static inline void gtt_write(u32 reg, u32 data) |
| 131 | { |
| 132 | write32(gtt_res->base + reg, data); |
| 133 | } |
| 134 | |
Duncan Laurie | 356833d | 2013-07-09 15:40:27 -0700 | [diff] [blame] | 135 | static inline void gtt_rmw(u32 reg, u32 andmask, u32 ormask) |
| 136 | { |
| 137 | u32 val = gtt_read(reg); |
| 138 | val &= andmask; |
| 139 | val |= ormask; |
| 140 | gtt_write(reg, val); |
| 141 | } |
| 142 | |
| 143 | static inline void gtt_write_regs(const struct gt_reg *gt) |
| 144 | { |
| 145 | for (; gt && gt->reg; gt++) { |
| 146 | if (gt->andmask) |
| 147 | gtt_rmw(gt->reg, gt->andmask, gt->ormask); |
| 148 | else |
| 149 | gtt_write(gt->reg, gt->ormask); |
| 150 | } |
| 151 | } |
| 152 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 153 | #define GTT_RETRY 1000 |
| 154 | static int gtt_poll(u32 reg, u32 mask, u32 value) |
| 155 | { |
| 156 | unsigned try = GTT_RETRY; |
| 157 | u32 data; |
| 158 | |
| 159 | while (try--) { |
| 160 | data = gtt_read(reg); |
| 161 | if ((data & mask) == value) |
| 162 | return 1; |
| 163 | udelay(10); |
| 164 | } |
| 165 | |
| 166 | printk(BIOS_ERR, "GT init timeout\n"); |
| 167 | return 0; |
| 168 | } |
| 169 | |
Ronald G. Minnich | 5bcca7e | 2013-06-25 15:56:46 -0700 | [diff] [blame] | 170 | static void power_well_enable(void) |
| 171 | { |
| 172 | gtt_write(HSW_PWR_WELL_CTL1, HSW_PWR_WELL_ENABLE); |
| 173 | gtt_poll(HSW_PWR_WELL_CTL1, HSW_PWR_WELL_STATE, HSW_PWR_WELL_STATE); |
| 174 | } |
| 175 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 176 | static void gma_pm_init_pre_vbios(struct device *dev) |
| 177 | { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 178 | printk(BIOS_DEBUG, "GT Power Management Init\n"); |
| 179 | |
| 180 | gtt_res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 181 | if (!gtt_res || !gtt_res->base) |
| 182 | return; |
| 183 | |
Ronald G. Minnich | 5bcca7e | 2013-06-25 15:56:46 -0700 | [diff] [blame] | 184 | power_well_enable(); |
| 185 | |
Duncan Laurie | 67113e9 | 2013-01-10 13:23:04 -0800 | [diff] [blame] | 186 | /* |
| 187 | * Enable RC6 |
| 188 | */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 189 | |
Duncan Laurie | 67113e9 | 2013-01-10 13:23:04 -0800 | [diff] [blame] | 190 | /* Enable Force Wake */ |
| 191 | gtt_write(0x0a180, 1 << 5); |
| 192 | gtt_write(0x0a188, 0x00010001); |
| 193 | gtt_poll(0x130044, 1 << 0, 1 << 0); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 194 | |
Duncan Laurie | 356833d | 2013-07-09 15:40:27 -0700 | [diff] [blame] | 195 | /* GT Settings */ |
| 196 | gtt_write_regs(haswell_gt_setup); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 197 | |
Duncan Laurie | 356833d | 2013-07-09 15:40:27 -0700 | [diff] [blame] | 198 | /* Wait for Mailbox Ready */ |
| 199 | gtt_poll(0x138124, (1 << 31), (0 << 31)); |
| 200 | /* Mailbox Data - RC6 VIDS */ |
| 201 | gtt_write(0x138128, 0x00000000); |
| 202 | /* Mailbox Command */ |
| 203 | gtt_write(0x138124, 0x80000004); |
| 204 | /* Wait for Mailbox Ready */ |
| 205 | gtt_poll(0x138124, (1 << 31), (0 << 31)); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 206 | |
Duncan Laurie | 356833d | 2013-07-09 15:40:27 -0700 | [diff] [blame] | 207 | /* Enable PM Interrupts */ |
| 208 | gtt_write(0x4402c, 0x03000076); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 209 | |
Duncan Laurie | 67113e9 | 2013-01-10 13:23:04 -0800 | [diff] [blame] | 210 | /* Enable RC6 in idle */ |
| 211 | gtt_write(0x0a094, 0x00040000); |
Duncan Laurie | 356833d | 2013-07-09 15:40:27 -0700 | [diff] [blame] | 212 | |
| 213 | /* PM Lock Settings */ |
| 214 | gtt_write_regs(haswell_gt_lock); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 215 | } |
| 216 | |
Duncan Laurie | c7f2ab7 | 2013-05-28 07:49:09 -0700 | [diff] [blame] | 217 | static void gma_setup_panel(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 218 | { |
| 219 | struct northbridge_intel_haswell_config *conf = dev->chip_info; |
| 220 | u32 reg32; |
| 221 | |
| 222 | printk(BIOS_DEBUG, "GT Power Management Init (post VBIOS)\n"); |
| 223 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 224 | /* Setup Digital Port Hotplug */ |
| 225 | reg32 = gtt_read(0xc4030); |
| 226 | if (!reg32) { |
| 227 | reg32 = (conf->gpu_dp_b_hotplug & 0x7) << 2; |
| 228 | reg32 |= (conf->gpu_dp_c_hotplug & 0x7) << 10; |
| 229 | reg32 |= (conf->gpu_dp_d_hotplug & 0x7) << 18; |
| 230 | gtt_write(0xc4030, reg32); |
| 231 | } |
| 232 | |
| 233 | /* Setup Panel Power On Delays */ |
| 234 | reg32 = gtt_read(0xc7208); |
| 235 | if (!reg32) { |
| 236 | reg32 = (conf->gpu_panel_port_select & 0x3) << 30; |
| 237 | reg32 |= (conf->gpu_panel_power_up_delay & 0x1fff) << 16; |
| 238 | reg32 |= (conf->gpu_panel_power_backlight_on_delay & 0x1fff); |
| 239 | gtt_write(0xc7208, reg32); |
| 240 | } |
| 241 | |
| 242 | /* Setup Panel Power Off Delays */ |
| 243 | reg32 = gtt_read(0xc720c); |
| 244 | if (!reg32) { |
| 245 | reg32 = (conf->gpu_panel_power_down_delay & 0x1fff) << 16; |
| 246 | reg32 |= (conf->gpu_panel_power_backlight_off_delay & 0x1fff); |
| 247 | gtt_write(0xc720c, reg32); |
| 248 | } |
| 249 | |
| 250 | /* Setup Panel Power Cycle Delay */ |
| 251 | if (conf->gpu_panel_power_cycle_delay) { |
| 252 | reg32 = gtt_read(0xc7210); |
| 253 | reg32 &= ~0xff; |
| 254 | reg32 |= conf->gpu_panel_power_cycle_delay & 0xff; |
| 255 | gtt_write(0xc7210, reg32); |
| 256 | } |
| 257 | |
| 258 | /* Enable Backlight if needed */ |
| 259 | if (conf->gpu_cpu_backlight) { |
| 260 | gtt_write(0x48250, (1 << 31)); |
| 261 | gtt_write(0x48254, conf->gpu_cpu_backlight); |
| 262 | } |
| 263 | if (conf->gpu_pch_backlight) { |
| 264 | gtt_write(0xc8250, (1 << 31)); |
| 265 | gtt_write(0xc8254, conf->gpu_pch_backlight); |
| 266 | } |
Ronald G. Minnich | 5bcca7e | 2013-06-25 15:56:46 -0700 | [diff] [blame] | 267 | |
| 268 | /* Get display,pipeline,and DDI registers into a basic sane state */ |
| 269 | /* not all these have documented names. */ |
| 270 | gtt_write(0x45400, 0x80000000); |
| 271 | gtt_poll( 0x00045400, 0xc0000000, 0xc0000000); |
| 272 | gtt_write(_CURACNTR, 0x00000000); |
| 273 | gtt_write(_DSPACNTR, (/* DISPPLANE_SEL_PIPE(0=A,1=B) */0x0<<24)|0x00000000); |
| 274 | gtt_write(_DSPBCNTR, 0x00000000); |
| 275 | gtt_write(CPU_VGACNTRL, 0x8000298e); |
| 276 | gtt_write(_DSPASIZE+0xc, 0x00000000); |
| 277 | gtt_write(_DSPBSURF, 0x00000000); |
| 278 | gtt_write(0x4f008, 0x00000000); |
| 279 | gtt_write(0x4f008, 0x00000000); |
| 280 | gtt_write(0x4f008, 0x00000000); |
| 281 | gtt_write(0x4f040, 0x01000001); |
| 282 | gtt_write(0x4f044, 0x00000000); |
| 283 | gtt_write(0x4f048, 0x00000000); |
| 284 | gtt_write(0x4f04c, 0x03030000); |
| 285 | gtt_write(0x4f050, 0x00000000); |
| 286 | gtt_write(0x4f054, 0x00000001); |
| 287 | gtt_write(0x4f058, 0x00000000); |
| 288 | gtt_write(0x4f04c, 0x03450000); |
| 289 | gtt_write(0x4f04c, 0x45450000); |
| 290 | gtt_write(0x4f000, 0x03000400); |
| 291 | gtt_write(DP_A, 0x00000091); /* DDI-A enable */ |
| 292 | gtt_write(_FDI_RXA_MISC, 0x00200090); |
| 293 | gtt_write(_FDI_RXA_MISC, 0x0a000000); |
| 294 | gtt_write(0x46408, 0x00000070); |
| 295 | gtt_write(0x42090, 0x04000000); |
| 296 | gtt_write(0x4f050, 0xc0000000); |
| 297 | gtt_write(0x9840, 0x00000000); |
| 298 | gtt_write(0x42090, 0xa4000000); |
| 299 | gtt_write(SOUTH_DSPCLK_GATE_D, 0x00001000); |
| 300 | gtt_write(0x42080, 0x00004000); |
| 301 | gtt_write(0x64f80, 0x00ffffff); |
| 302 | gtt_write(0x64f84, 0x0007000e); |
| 303 | gtt_write(0x64f88, 0x00d75fff); |
| 304 | gtt_write(0x64f8c, 0x000f000a); |
| 305 | gtt_write(0x64f90, 0x00c30fff); |
| 306 | gtt_write(0x64f94, 0x00060006); |
| 307 | gtt_write(0x64f98, 0x00aaafff); |
| 308 | gtt_write(0x64f9c, 0x001e0000); |
| 309 | gtt_write(0x64fa0, 0x00ffffff); |
| 310 | gtt_write(0x64fa4, 0x000f000a); |
| 311 | gtt_write(0x64fa8, 0x00d75fff); |
| 312 | gtt_write(0x64fac, 0x00160004); |
| 313 | gtt_write(0x64fb0, 0x00c30fff); |
| 314 | gtt_write(0x64fb4, 0x001e0000); |
| 315 | gtt_write(0x64fb8, 0x00ffffff); |
| 316 | gtt_write(0x64fbc, 0x00060006); |
| 317 | gtt_write(0x64fc0, 0x00d75fff); |
| 318 | gtt_write(0x64fc4, 0x001e0000); |
| 319 | gtt_write(DDI_BUF_TRANS_A, 0x00ffffff); |
| 320 | gtt_write(DDI_BUF_TRANS_A+0x4, 0x0006000e); |
| 321 | gtt_write(DDI_BUF_TRANS_A+0x8, 0x00d75fff); |
| 322 | gtt_write(DDI_BUF_TRANS_A+0xc, 0x0005000a); |
| 323 | gtt_write(DDI_BUF_TRANS_A+0x10, 0x00c30fff); |
| 324 | gtt_write(DDI_BUF_TRANS_A+0x14, 0x00040006); |
| 325 | gtt_write(DDI_BUF_TRANS_A+0x18, 0x80aaafff); |
| 326 | gtt_write(DDI_BUF_TRANS_A+0x1c, 0x000b0000); |
| 327 | gtt_write(DDI_BUF_TRANS_A+0x20, 0x00ffffff); |
| 328 | gtt_write(DDI_BUF_TRANS_A+0x24, 0x0005000a); |
| 329 | gtt_write(DDI_BUF_TRANS_A+0x28, 0x00d75fff); |
| 330 | gtt_write(DDI_BUF_TRANS_A+0x2c, 0x000c0004); |
| 331 | gtt_write(DDI_BUF_TRANS_A+0x30, 0x80c30fff); |
| 332 | gtt_write(DDI_BUF_TRANS_A+0x34, 0x000b0000); |
| 333 | gtt_write(DDI_BUF_TRANS_A+0x38, 0x00ffffff); |
| 334 | gtt_write(DDI_BUF_TRANS_A+0x3c, 0x00040006); |
| 335 | gtt_write(DDI_BUF_TRANS_A+0x40, 0x80d75fff); |
| 336 | gtt_write(DDI_BUF_TRANS_A+0x44, 0x000b0000); |
| 337 | gtt_write(DIGITAL_PORT_HOTPLUG_CNTRL, |
| 338 | DIGITAL_PORTA_HOTPLUG_ENABLE |0x00000010); |
| 339 | gtt_write(SDEISR+0x30, |
| 340 | PORTD_HOTPLUG_ENABLE | PORTB_HOTPLUG_ENABLE |0x10100010); |
| 341 | gtt_write(PCH_PP_DIVISOR, 0x0004af06); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 342 | } |
| 343 | |
Duncan Laurie | c7f2ab7 | 2013-05-28 07:49:09 -0700 | [diff] [blame] | 344 | static void gma_pm_init_post_vbios(struct device *dev) |
| 345 | { |
Duncan Laurie | 356833d | 2013-07-09 15:40:27 -0700 | [diff] [blame] | 346 | int cdclk = 0; |
| 347 | int devid = pci_read_config16(dev, PCI_DEVICE_ID); |
| 348 | int gpu_is_ulx = 0; |
| 349 | |
| 350 | if (devid == 0x0a0e || devid == 0x0a1e) |
| 351 | gpu_is_ulx = 1; |
| 352 | |
| 353 | /* CD Frequency */ |
Duncan Laurie | 3106d0f | 2013-08-12 13:51:22 -0700 | [diff] [blame] | 354 | if ((gtt_read(0x42014) & 0x1000000) || gpu_is_ulx || haswell_is_ult()) |
| 355 | cdclk = 0; /* fixed frequency */ |
| 356 | else |
| 357 | cdclk = 2; /* variable frequency */ |
Duncan Laurie | 356833d | 2013-07-09 15:40:27 -0700 | [diff] [blame] | 358 | |
Duncan Laurie | 356833d | 2013-07-09 15:40:27 -0700 | [diff] [blame] | 359 | if (gpu_is_ulx || cdclk != 0) |
| 360 | gtt_rmw(0x130040, 0xf7ffffff, 0x04000000); |
| 361 | else |
| 362 | gtt_rmw(0x130040, 0xf3ffffff, 0x00000000); |
| 363 | |
| 364 | /* More magic */ |
| 365 | if (haswell_is_ult() || gpu_is_ulx) { |
Duncan Laurie | 3106d0f | 2013-08-12 13:51:22 -0700 | [diff] [blame] | 366 | if (!gpu_is_ulx) |
Duncan Laurie | 356833d | 2013-07-09 15:40:27 -0700 | [diff] [blame] | 367 | gtt_write(0x138128, 0x00000000); |
| 368 | else |
| 369 | gtt_write(0x138128, 0x00000001); |
| 370 | gtt_write(0x13812c, 0x00000000); |
| 371 | gtt_write(0x138124, 0x80000017); |
| 372 | } |
| 373 | |
Duncan Laurie | c7f2ab7 | 2013-05-28 07:49:09 -0700 | [diff] [blame] | 374 | /* Disable Force Wake */ |
| 375 | gtt_write(0x0a188, 0x00010000); |
| 376 | gtt_poll(0x130044, 1 << 0, 0 << 0); |
Duncan Laurie | 356833d | 2013-07-09 15:40:27 -0700 | [diff] [blame] | 377 | gtt_write(0x0a188, 0x00000001); |
Duncan Laurie | c7f2ab7 | 2013-05-28 07:49:09 -0700 | [diff] [blame] | 378 | } |
| 379 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 380 | static void gma_func0_init(struct device *dev) |
| 381 | { |
Ronald G. Minnich | 4f78b18 | 2013-04-17 16:57:30 -0700 | [diff] [blame] | 382 | int lightup_ok = 0; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 383 | u32 reg32; |
Ronald G. Minnich | 2a66d6b | 2013-03-28 17:01:43 -0700 | [diff] [blame] | 384 | u32 graphics_base; //, graphics_size; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 385 | /* IGD needs to be Bus Master */ |
| 386 | reg32 = pci_read_config32(dev, PCI_COMMAND); |
| 387 | reg32 |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO; |
| 388 | pci_write_config32(dev, PCI_COMMAND, reg32); |
| 389 | |
Ronald G. Minnich | 2a66d6b | 2013-03-28 17:01:43 -0700 | [diff] [blame] | 390 | |
| 391 | /* the BAR for graphics space is a well known number for |
| 392 | * sandy and ivy. And the resource code renumbers it. |
| 393 | * So it's almost like having two hardcodes. |
| 394 | */ |
| 395 | graphics_base = dev->resource_list[1].base; |
Duncan Laurie | c7f2ab7 | 2013-05-28 07:49:09 -0700 | [diff] [blame] | 396 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 397 | /* Init graphics power management */ |
| 398 | gma_pm_init_pre_vbios(dev); |
| 399 | |
Duncan Laurie | c7f2ab7 | 2013-05-28 07:49:09 -0700 | [diff] [blame] | 400 | /* Post VBIOS init */ |
| 401 | gma_setup_panel(dev); |
| 402 | |
Ronald G. Minnich | 2a66d6b | 2013-03-28 17:01:43 -0700 | [diff] [blame] | 403 | #if CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT |
| 404 | printk(BIOS_SPEW, "NATIVE graphics, run native enable\n"); |
| 405 | u32 iobase, mmiobase, physbase; |
| 406 | iobase = dev->resource_list[2].base; |
| 407 | mmiobase = dev->resource_list[0].base; |
| 408 | physbase = pci_read_config32(dev, 0x5c) & ~0xf; |
| 409 | |
| 410 | int i915lightup(u32 physbase, u32 iobase, u32 mmiobase, u32 gfx); |
Ronald G. Minnich | 4f78b18 | 2013-04-17 16:57:30 -0700 | [diff] [blame] | 411 | lightup_ok = i915lightup(physbase, iobase, mmiobase, graphics_base); |
Kyösti Mälkki | ab56b3b | 2013-11-28 16:44:51 +0200 | [diff] [blame] | 412 | if (lightup_ok) |
| 413 | gfx_set_init_done(1); |
Ronald G. Minnich | 2a66d6b | 2013-03-28 17:01:43 -0700 | [diff] [blame] | 414 | #endif |
Ronald G. Minnich | 4f78b18 | 2013-04-17 16:57:30 -0700 | [diff] [blame] | 415 | if (! lightup_ok) { |
| 416 | printk(BIOS_SPEW, "FUI did not run; using VBIOS\n"); |
| 417 | pci_dev_init(dev); |
| 418 | } |
| 419 | |
| 420 | /* Post VBIOS init */ |
| 421 | gma_pm_init_post_vbios(dev); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | static void gma_set_subsystem(device_t dev, unsigned vendor, unsigned device) |
| 425 | { |
| 426 | if (!vendor || !device) { |
| 427 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 428 | pci_read_config32(dev, PCI_VENDOR_ID)); |
| 429 | } else { |
| 430 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 431 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | static struct pci_operations gma_pci_ops = { |
| 436 | .set_subsystem = gma_set_subsystem, |
| 437 | }; |
| 438 | |
| 439 | static struct device_operations gma_func0_ops = { |
Vladimir Serbinenko | 30fe612 | 2014-02-05 23:25:28 +0100 | [diff] [blame] | 440 | .read_resources = pci_dev_read_resources, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 441 | .set_resources = pci_dev_set_resources, |
| 442 | .enable_resources = pci_dev_enable_resources, |
| 443 | .init = gma_func0_init, |
| 444 | .scan_bus = 0, |
| 445 | .enable = 0, |
| 446 | .ops_pci = &gma_pci_ops, |
| 447 | }; |
| 448 | |
Duncan Laurie | df7be71 | 2012-12-17 11:22:57 -0800 | [diff] [blame] | 449 | static const unsigned short pci_device_ids[] = { |
| 450 | 0x0402, /* Desktop GT1 */ |
| 451 | 0x0412, /* Desktop GT2 */ |
| 452 | 0x0422, /* Desktop GT3 */ |
| 453 | 0x0406, /* Mobile GT1 */ |
| 454 | 0x0416, /* Mobile GT2 */ |
| 455 | 0x0426, /* Mobile GT3 */ |
| 456 | 0x0d16, /* Mobile 4+3 GT1 */ |
| 457 | 0x0d26, /* Mobile 4+3 GT2 */ |
| 458 | 0x0d36, /* Mobile 4+3 GT3 */ |
| 459 | 0x0a06, /* ULT GT1 */ |
| 460 | 0x0a16, /* ULT GT2 */ |
| 461 | 0x0a26, /* ULT GT3 */ |
| 462 | 0, |
| 463 | }; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 464 | |
| 465 | static const struct pci_driver pch_lpc __pci_driver = { |
| 466 | .ops = &gma_func0_ops, |
| 467 | .vendor = PCI_VENDOR_ID_INTEL, |
| 468 | .devices = pci_device_ids, |
| 469 | }; |