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