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