Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 Chromium OS Authors |
| 5 | * Copyright (C) 2013 Vladimir Serbinenko |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <arch/io.h> |
| 18 | #include <console/console.h> |
| 19 | #include <delay.h> |
| 20 | #include <device/device.h> |
| 21 | #include <device/pci.h> |
| 22 | #include <device/pci_ids.h> |
| 23 | #include <string.h> |
| 24 | #include <device/pci_ops.h> |
| 25 | #include <cpu/x86/msr.h> |
| 26 | #include <cpu/x86/mtrr.h> |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 27 | #include <drivers/intel/gma/edid.h> |
| 28 | #include <drivers/intel/gma/i915.h> |
Patrick Rudolph | 5c82026 | 2017-05-17 19:39:12 +0200 | [diff] [blame] | 29 | #include <drivers/intel/gma/intel_bios.h> |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 30 | #include <pc80/vga.h> |
| 31 | #include <pc80/vga_io.h> |
Patrick Rudolph | 2be2840 | 2017-04-12 16:54:55 +0200 | [diff] [blame] | 32 | #include <southbridge/intel/ibexpeak/nvs.h> |
Patrick Rudolph | 5c82026 | 2017-05-17 19:39:12 +0200 | [diff] [blame] | 33 | #include <northbridge/intel/common/gma_opregion.h> |
Patrick Rudolph | 2be2840 | 2017-04-12 16:54:55 +0200 | [diff] [blame] | 34 | #include <cbmem.h> |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 35 | |
| 36 | #include "chip.h" |
| 37 | #include "nehalem.h" |
| 38 | |
| 39 | struct gt_powermeter { |
| 40 | u16 reg; |
| 41 | u32 value; |
| 42 | }; |
| 43 | |
| 44 | static const struct gt_powermeter snb_pm_gt1[] = { |
| 45 | {0xa200, 0xcc000000}, |
| 46 | {0xa204, 0x07000040}, |
| 47 | {0xa208, 0x0000fe00}, |
| 48 | {0xa20c, 0x00000000}, |
| 49 | {0xa210, 0x17000000}, |
| 50 | {0xa214, 0x00000021}, |
| 51 | {0xa218, 0x0817fe19}, |
| 52 | {0xa21c, 0x00000000}, |
| 53 | {0xa220, 0x00000000}, |
| 54 | {0xa224, 0xcc000000}, |
| 55 | {0xa228, 0x07000040}, |
| 56 | {0xa22c, 0x0000fe00}, |
| 57 | {0xa230, 0x00000000}, |
| 58 | {0xa234, 0x17000000}, |
| 59 | {0xa238, 0x00000021}, |
| 60 | {0xa23c, 0x0817fe19}, |
| 61 | {0xa240, 0x00000000}, |
| 62 | {0xa244, 0x00000000}, |
| 63 | {0xa248, 0x8000421e}, |
| 64 | {0} |
| 65 | }; |
| 66 | |
| 67 | static const struct gt_powermeter snb_pm_gt2[] = { |
| 68 | {0xa200, 0x330000a6}, |
| 69 | {0xa204, 0x402d0031}, |
| 70 | {0xa208, 0x00165f83}, |
| 71 | {0xa20c, 0xf1000000}, |
| 72 | {0xa210, 0x00000000}, |
| 73 | {0xa214, 0x00160016}, |
| 74 | {0xa218, 0x002a002b}, |
| 75 | {0xa21c, 0x00000000}, |
| 76 | {0xa220, 0x00000000}, |
| 77 | {0xa224, 0x330000a6}, |
| 78 | {0xa228, 0x402d0031}, |
| 79 | {0xa22c, 0x00165f83}, |
| 80 | {0xa230, 0xf1000000}, |
| 81 | {0xa234, 0x00000000}, |
| 82 | {0xa238, 0x00160016}, |
| 83 | {0xa23c, 0x002a002b}, |
| 84 | {0xa240, 0x00000000}, |
| 85 | {0xa244, 0x00000000}, |
| 86 | {0xa248, 0x8000421e}, |
| 87 | {0} |
| 88 | }; |
| 89 | |
| 90 | static const struct gt_powermeter ivb_pm_gt1[] = { |
| 91 | {0xa800, 0x00000000}, |
| 92 | {0xa804, 0x00021c00}, |
| 93 | {0xa808, 0x00000403}, |
| 94 | {0xa80c, 0x02001700}, |
| 95 | {0xa810, 0x05000200}, |
| 96 | {0xa814, 0x00000000}, |
| 97 | {0xa818, 0x00690500}, |
| 98 | {0xa81c, 0x0000007f}, |
| 99 | {0xa820, 0x01002501}, |
| 100 | {0xa824, 0x00000300}, |
| 101 | {0xa828, 0x01000331}, |
| 102 | {0xa82c, 0x0000000c}, |
| 103 | {0xa830, 0x00010016}, |
| 104 | {0xa834, 0x01100101}, |
| 105 | {0xa838, 0x00010103}, |
| 106 | {0xa83c, 0x00041300}, |
| 107 | {0xa840, 0x00000b30}, |
| 108 | {0xa844, 0x00000000}, |
| 109 | {0xa848, 0x7f000000}, |
| 110 | {0xa84c, 0x05000008}, |
| 111 | {0xa850, 0x00000001}, |
| 112 | {0xa854, 0x00000004}, |
| 113 | {0xa858, 0x00000007}, |
| 114 | {0xa85c, 0x00000000}, |
| 115 | {0xa860, 0x00010000}, |
| 116 | {0xa248, 0x0000221e}, |
| 117 | {0xa900, 0x00000000}, |
| 118 | {0xa904, 0x00001c00}, |
| 119 | {0xa908, 0x00000000}, |
| 120 | {0xa90c, 0x06000000}, |
| 121 | {0xa910, 0x09000200}, |
| 122 | {0xa914, 0x00000000}, |
| 123 | {0xa918, 0x00590000}, |
| 124 | {0xa91c, 0x00000000}, |
| 125 | {0xa920, 0x04002501}, |
| 126 | {0xa924, 0x00000100}, |
| 127 | {0xa928, 0x03000410}, |
| 128 | {0xa92c, 0x00000000}, |
| 129 | {0xa930, 0x00020000}, |
| 130 | {0xa934, 0x02070106}, |
| 131 | {0xa938, 0x00010100}, |
| 132 | {0xa93c, 0x00401c00}, |
| 133 | {0xa940, 0x00000000}, |
| 134 | {0xa944, 0x00000000}, |
| 135 | {0xa948, 0x10000e00}, |
| 136 | {0xa94c, 0x02000004}, |
| 137 | {0xa950, 0x00000001}, |
| 138 | {0xa954, 0x00000004}, |
| 139 | {0xa960, 0x00060000}, |
| 140 | {0xaa3c, 0x00001c00}, |
| 141 | {0xaa54, 0x00000004}, |
| 142 | {0xaa60, 0x00060000}, |
| 143 | {0} |
| 144 | }; |
| 145 | |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 146 | static const struct gt_powermeter ivb_pm_gt2_17w[] = { |
| 147 | {0xa800, 0x20000000}, |
| 148 | {0xa804, 0x000e3800}, |
| 149 | {0xa808, 0x00000806}, |
| 150 | {0xa80c, 0x0c002f00}, |
| 151 | {0xa810, 0x0c000800}, |
| 152 | {0xa814, 0x00000000}, |
| 153 | {0xa818, 0x00d20d00}, |
| 154 | {0xa81c, 0x000000ff}, |
| 155 | {0xa820, 0x03004b02}, |
| 156 | {0xa824, 0x00000600}, |
| 157 | {0xa828, 0x07000773}, |
| 158 | {0xa82c, 0x00000000}, |
| 159 | {0xa830, 0x00020032}, |
| 160 | {0xa834, 0x1520040d}, |
| 161 | {0xa838, 0x00020105}, |
| 162 | {0xa83c, 0x00083700}, |
| 163 | {0xa840, 0x000016ff}, |
| 164 | {0xa844, 0x00000000}, |
| 165 | {0xa848, 0xff000000}, |
| 166 | {0xa84c, 0x0a000010}, |
| 167 | {0xa850, 0x00000002}, |
| 168 | {0xa854, 0x00000008}, |
| 169 | {0xa858, 0x0000000f}, |
| 170 | {0xa85c, 0x00000000}, |
| 171 | {0xa860, 0x00020000}, |
| 172 | {0xa248, 0x0000221e}, |
| 173 | {0xa900, 0x00000000}, |
| 174 | {0xa904, 0x00003800}, |
| 175 | {0xa908, 0x00000000}, |
| 176 | {0xa90c, 0x0c000000}, |
| 177 | {0xa910, 0x12000800}, |
| 178 | {0xa914, 0x00000000}, |
| 179 | {0xa918, 0x00b20000}, |
| 180 | {0xa91c, 0x00000000}, |
| 181 | {0xa920, 0x08004b02}, |
| 182 | {0xa924, 0x00000300}, |
| 183 | {0xa928, 0x01000820}, |
| 184 | {0xa92c, 0x00000000}, |
| 185 | {0xa930, 0x00030000}, |
| 186 | {0xa934, 0x15150406}, |
| 187 | {0xa938, 0x00020300}, |
| 188 | {0xa93c, 0x00903900}, |
| 189 | {0xa940, 0x00000000}, |
| 190 | {0xa944, 0x00000000}, |
| 191 | {0xa948, 0x20001b00}, |
| 192 | {0xa94c, 0x0a000010}, |
| 193 | {0xa950, 0x00000000}, |
| 194 | {0xa954, 0x00000008}, |
| 195 | {0xa960, 0x00110000}, |
| 196 | {0xaa3c, 0x00003900}, |
| 197 | {0xaa54, 0x00000008}, |
| 198 | {0xaa60, 0x00110000}, |
| 199 | {0} |
| 200 | }; |
| 201 | |
| 202 | static const struct gt_powermeter ivb_pm_gt2_35w[] = { |
| 203 | {0xa800, 0x00000000}, |
| 204 | {0xa804, 0x00030400}, |
| 205 | {0xa808, 0x00000806}, |
| 206 | {0xa80c, 0x0c002f00}, |
| 207 | {0xa810, 0x0c000300}, |
| 208 | {0xa814, 0x00000000}, |
| 209 | {0xa818, 0x00d20d00}, |
| 210 | {0xa81c, 0x000000ff}, |
| 211 | {0xa820, 0x03004b02}, |
| 212 | {0xa824, 0x00000600}, |
| 213 | {0xa828, 0x07000773}, |
| 214 | {0xa82c, 0x00000000}, |
| 215 | {0xa830, 0x00020032}, |
| 216 | {0xa834, 0x1520040d}, |
| 217 | {0xa838, 0x00020105}, |
| 218 | {0xa83c, 0x00083700}, |
| 219 | {0xa840, 0x000016ff}, |
| 220 | {0xa844, 0x00000000}, |
| 221 | {0xa848, 0xff000000}, |
| 222 | {0xa84c, 0x0a000010}, |
| 223 | {0xa850, 0x00000001}, |
| 224 | {0xa854, 0x00000008}, |
| 225 | {0xa858, 0x00000008}, |
| 226 | {0xa85c, 0x00000000}, |
| 227 | {0xa860, 0x00020000}, |
| 228 | {0xa248, 0x0000221e}, |
| 229 | {0xa900, 0x00000000}, |
| 230 | {0xa904, 0x00003800}, |
| 231 | {0xa908, 0x00000000}, |
| 232 | {0xa90c, 0x0c000000}, |
| 233 | {0xa910, 0x12000800}, |
| 234 | {0xa914, 0x00000000}, |
| 235 | {0xa918, 0x00b20000}, |
| 236 | {0xa91c, 0x00000000}, |
| 237 | {0xa920, 0x08004b02}, |
| 238 | {0xa924, 0x00000300}, |
| 239 | {0xa928, 0x01000820}, |
| 240 | {0xa92c, 0x00000000}, |
| 241 | {0xa930, 0x00030000}, |
| 242 | {0xa934, 0x15150406}, |
| 243 | {0xa938, 0x00020300}, |
| 244 | {0xa93c, 0x00903900}, |
| 245 | {0xa940, 0x00000000}, |
| 246 | {0xa944, 0x00000000}, |
| 247 | {0xa948, 0x20001b00}, |
| 248 | {0xa94c, 0x0a000010}, |
| 249 | {0xa950, 0x00000000}, |
| 250 | {0xa954, 0x00000008}, |
| 251 | {0xa960, 0x00110000}, |
| 252 | {0xaa3c, 0x00003900}, |
| 253 | {0xaa54, 0x00000008}, |
| 254 | {0xaa60, 0x00110000}, |
| 255 | {0} |
| 256 | }; |
| 257 | |
| 258 | /* some vga option roms are used for several chipsets but they only have one |
| 259 | * PCI ID in their header. If we encounter such an option rom, we need to do |
Martin Roth | 128c104 | 2016-11-18 09:29:03 -0700 | [diff] [blame] | 260 | * the mapping ourselves |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 261 | */ |
| 262 | |
| 263 | u32 map_oprom_vendev(u32 vendev) |
| 264 | { |
| 265 | u32 new_vendev = vendev; |
| 266 | |
Martin Roth | 128c104 | 2016-11-18 09:29:03 -0700 | [diff] [blame] | 267 | /* none currently. */ |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 268 | |
| 269 | return new_vendev; |
| 270 | } |
| 271 | |
| 272 | static struct resource *gtt_res = NULL; |
| 273 | |
Furquan Shaikh | 77f48cd | 2013-08-19 10:16:50 -0700 | [diff] [blame] | 274 | u32 gtt_read(u32 reg) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 275 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 276 | return read32(res2mmio(gtt_res, reg, 0)); |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 277 | } |
| 278 | |
Furquan Shaikh | 77f48cd | 2013-08-19 10:16:50 -0700 | [diff] [blame] | 279 | void gtt_write(u32 reg, u32 data) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 280 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 281 | write32(res2mmio(gtt_res, reg, 0), data); |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | static inline void gtt_write_powermeter(const struct gt_powermeter *pm) |
| 285 | { |
| 286 | for (; pm && pm->reg; pm++) |
| 287 | gtt_write(pm->reg, pm->value); |
| 288 | } |
| 289 | |
| 290 | #define GTT_RETRY 1000 |
Ronald G. Minnich | 9518b56 | 2013-09-19 16:45:22 -0700 | [diff] [blame] | 291 | int gtt_poll(u32 reg, u32 mask, u32 value) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 292 | { |
| 293 | unsigned try = GTT_RETRY; |
| 294 | u32 data; |
| 295 | |
| 296 | while (try--) { |
| 297 | data = gtt_read(reg); |
| 298 | if ((data & mask) == value) |
| 299 | return 1; |
| 300 | udelay(10); |
| 301 | } |
| 302 | |
| 303 | printk(BIOS_ERR, "GT init timeout\n"); |
| 304 | return 0; |
| 305 | } |
| 306 | |
| 307 | static void gma_pm_init_pre_vbios(struct device *dev) |
| 308 | { |
| 309 | u32 reg32; |
| 310 | |
| 311 | printk(BIOS_DEBUG, "GT Power Management Init\n"); |
| 312 | |
| 313 | gtt_res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 314 | if (!gtt_res || !gtt_res->base) |
| 315 | return; |
| 316 | |
| 317 | if (bridge_silicon_revision() < IVB_STEP_C0) { |
| 318 | /* 1: Enable force wake */ |
| 319 | gtt_write(0xa18c, 0x00000001); |
| 320 | gtt_poll(0x130090, (1 << 0), (1 << 0)); |
| 321 | } else { |
| 322 | gtt_write(0xa180, 1 << 5); |
| 323 | gtt_write(0xa188, 0xffff0001); |
| 324 | gtt_poll(0x130040, (1 << 0), (1 << 0)); |
| 325 | } |
| 326 | |
| 327 | if ((bridge_silicon_revision() & BASE_REV_MASK) == BASE_REV_SNB) { |
| 328 | /* 1d: Set GTT+0x42004 [15:14]=11 (SnB C1+) */ |
| 329 | reg32 = gtt_read(0x42004); |
| 330 | reg32 |= (1 << 14) | (1 << 15); |
| 331 | gtt_write(0x42004, reg32); |
| 332 | } |
| 333 | |
| 334 | if (bridge_silicon_revision() >= IVB_STEP_A0) { |
| 335 | /* Display Reset Acknowledge Settings */ |
| 336 | reg32 = gtt_read(0x45010); |
| 337 | reg32 |= (1 << 1) | (1 << 0); |
| 338 | gtt_write(0x45010, reg32); |
| 339 | } |
| 340 | |
| 341 | /* 2: Get GT SKU from GTT+0x911c[13] */ |
| 342 | reg32 = gtt_read(0x911c); |
| 343 | if ((bridge_silicon_revision() & BASE_REV_MASK) == BASE_REV_SNB) { |
| 344 | if (reg32 & (1 << 13)) { |
| 345 | printk(BIOS_DEBUG, "SNB GT1 Power Meter Weights\n"); |
| 346 | gtt_write_powermeter(snb_pm_gt1); |
| 347 | } else { |
| 348 | printk(BIOS_DEBUG, "SNB GT2 Power Meter Weights\n"); |
| 349 | gtt_write_powermeter(snb_pm_gt2); |
| 350 | } |
| 351 | } else { |
| 352 | u32 unit = MCHBAR32(0x5938) & 0xf; |
| 353 | |
| 354 | if (reg32 & (1 << 13)) { |
| 355 | /* GT1 SKU */ |
| 356 | printk(BIOS_DEBUG, "IVB GT1 Power Meter Weights\n"); |
| 357 | gtt_write_powermeter(ivb_pm_gt1); |
| 358 | } else { |
| 359 | /* GT2 SKU */ |
| 360 | u32 tdp = MCHBAR32(0x5930) & 0x7fff; |
| 361 | tdp /= (1 << unit); |
| 362 | |
| 363 | if (tdp <= 17) { |
| 364 | /* <=17W ULV */ |
| 365 | printk(BIOS_DEBUG, "IVB GT2 17W " |
| 366 | "Power Meter Weights\n"); |
| 367 | gtt_write_powermeter(ivb_pm_gt2_17w); |
| 368 | } else if ((tdp >= 25) && (tdp <= 35)) { |
| 369 | /* 25W-35W */ |
| 370 | printk(BIOS_DEBUG, "IVB GT2 25W-35W " |
| 371 | "Power Meter Weights\n"); |
| 372 | gtt_write_powermeter(ivb_pm_gt2_35w); |
| 373 | } else { |
| 374 | /* All others */ |
| 375 | printk(BIOS_DEBUG, "IVB GT2 35W " |
| 376 | "Power Meter Weights\n"); |
| 377 | gtt_write_powermeter(ivb_pm_gt2_35w); |
| 378 | } |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | /* 3: Gear ratio map */ |
| 383 | gtt_write(0xa004, 0x00000010); |
| 384 | |
| 385 | /* 4: GFXPAUSE */ |
| 386 | gtt_write(0xa000, 0x00070020); |
| 387 | |
| 388 | /* 5: Dynamic EU trip control */ |
| 389 | gtt_write(0xa080, 0x00000004); |
| 390 | |
| 391 | /* 6: ECO bits */ |
| 392 | reg32 = gtt_read(0xa180); |
| 393 | reg32 |= (1 << 26) | (1 << 31); |
| 394 | /* (bit 20=1 for SNB step D1+ / IVB A0+) */ |
| 395 | if (bridge_silicon_revision() >= SNB_STEP_D1) |
| 396 | reg32 |= (1 << 20); |
| 397 | gtt_write(0xa180, reg32); |
| 398 | |
| 399 | /* 6a: for SnB step D2+ only */ |
| 400 | if (((bridge_silicon_revision() & BASE_REV_MASK) == BASE_REV_SNB) && |
| 401 | (bridge_silicon_revision() >= SNB_STEP_D2)) { |
| 402 | reg32 = gtt_read(0x9400); |
| 403 | reg32 |= (1 << 7); |
| 404 | gtt_write(0x9400, reg32); |
| 405 | |
| 406 | reg32 = gtt_read(0x941c); |
| 407 | reg32 &= 0xf; |
| 408 | reg32 |= (1 << 1); |
| 409 | gtt_write(0x941c, reg32); |
| 410 | gtt_poll(0x941c, (1 << 1), (0 << 1)); |
| 411 | } |
| 412 | |
| 413 | if ((bridge_silicon_revision() & BASE_REV_MASK) == BASE_REV_IVB) { |
| 414 | reg32 = gtt_read(0x907c); |
| 415 | reg32 |= (1 << 16); |
| 416 | gtt_write(0x907c, reg32); |
| 417 | |
| 418 | /* 6b: Clocking reset controls */ |
| 419 | gtt_write(0x9424, 0x00000001); |
| 420 | } else { |
| 421 | /* 6b: Clocking reset controls */ |
| 422 | gtt_write(0x9424, 0x00000000); |
| 423 | } |
| 424 | |
| 425 | /* 7 */ |
| 426 | if (gtt_poll(0x138124, (1 << 31), (0 << 31))) { |
| 427 | gtt_write(0x138128, 0x00000029); /* Mailbox Data */ |
| 428 | gtt_write(0x138124, 0x80000004); /* Mailbox Cmd for RC6 VID */ |
| 429 | if (gtt_poll(0x138124, (1 << 31), (0 << 31))) |
| 430 | gtt_write(0x138124, 0x8000000a); |
| 431 | gtt_poll(0x138124, (1 << 31), (0 << 31)); |
| 432 | } |
| 433 | |
| 434 | /* 8 */ |
| 435 | gtt_write(0xa090, 0x00000000); /* RC Control */ |
| 436 | gtt_write(0xa098, 0x03e80000); /* RC1e Wake Rate Limit */ |
| 437 | gtt_write(0xa09c, 0x0028001e); /* RC6/6p Wake Rate Limit */ |
| 438 | gtt_write(0xa0a0, 0x0000001e); /* RC6pp Wake Rate Limit */ |
| 439 | gtt_write(0xa0a8, 0x0001e848); /* RC Evaluation Interval */ |
| 440 | gtt_write(0xa0ac, 0x00000019); /* RC Idle Hysteresis */ |
| 441 | |
| 442 | /* 9 */ |
| 443 | gtt_write(0x2054, 0x0000000a); /* Render Idle Max Count */ |
| 444 | gtt_write(0x12054, 0x0000000a); /* Video Idle Max Count */ |
| 445 | gtt_write(0x22054, 0x0000000a); /* Blitter Idle Max Count */ |
| 446 | |
| 447 | /* 10 */ |
| 448 | gtt_write(0xa0b0, 0x00000000); /* Unblock Ack to Busy */ |
| 449 | gtt_write(0xa0b4, 0x000003e8); /* RC1e Threshold */ |
| 450 | gtt_write(0xa0b8, 0x0000c350); /* RC6 Threshold */ |
| 451 | gtt_write(0xa0bc, 0x000186a0); /* RC6p Threshold */ |
| 452 | gtt_write(0xa0c0, 0x0000fa00); /* RC6pp Threshold */ |
| 453 | |
| 454 | /* 11 */ |
| 455 | gtt_write(0xa010, 0x000f4240); /* RP Down Timeout */ |
| 456 | gtt_write(0xa014, 0x12060000); /* RP Interrupt Limits */ |
| 457 | gtt_write(0xa02c, 0x00015f90); /* RP Up Threshold */ |
| 458 | gtt_write(0xa030, 0x000186a0); /* RP Down Threshold */ |
| 459 | gtt_write(0xa068, 0x000186a0); /* RP Up EI */ |
| 460 | gtt_write(0xa06c, 0x000493e0); /* RP Down EI */ |
| 461 | gtt_write(0xa070, 0x0000000a); /* RP Idle Hysteresis */ |
| 462 | |
| 463 | /* 11a: Enable Render Standby (RC6) */ |
| 464 | if ((bridge_silicon_revision() & BASE_REV_MASK) == BASE_REV_IVB) { |
| 465 | /* |
| 466 | * IvyBridge should also support DeepRenderStandby. |
| 467 | * |
| 468 | * Unfortunately it does not work reliably on all SKUs so |
| 469 | * disable it here and it can be enabled by the kernel. |
| 470 | */ |
| 471 | gtt_write(0xa090, 0x88040000); /* HW RC Control */ |
| 472 | } else { |
| 473 | gtt_write(0xa090, 0x88040000); /* HW RC Control */ |
| 474 | } |
| 475 | |
| 476 | /* 12: Normal Frequency Request */ |
| 477 | /* RPNFREQ_VAL comes from MCHBAR 0x5998 23:16 (8 bits!? use 7) */ |
| 478 | reg32 = MCHBAR32(0x5998); |
| 479 | reg32 >>= 16; |
| 480 | reg32 &= 0xef; |
| 481 | reg32 <<= 25; |
| 482 | gtt_write(0xa008, reg32); |
| 483 | |
| 484 | /* 13: RP Control */ |
| 485 | gtt_write(0xa024, 0x00000592); |
| 486 | |
| 487 | /* 14: Enable PM Interrupts */ |
| 488 | gtt_write(0x4402c, 0x03000076); |
| 489 | |
| 490 | /* Clear 0x6c024 [8:6] */ |
| 491 | reg32 = gtt_read(0x6c024); |
| 492 | reg32 &= ~0x000001c0; |
| 493 | gtt_write(0x6c024, reg32); |
| 494 | } |
| 495 | |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 496 | static void gma_pm_init_post_vbios(struct device *dev) |
| 497 | { |
| 498 | struct northbridge_intel_nehalem_config *conf = dev->chip_info; |
| 499 | u32 reg32; |
| 500 | |
| 501 | printk(BIOS_DEBUG, "GT Power Management Init (post VBIOS)\n"); |
| 502 | |
| 503 | /* 15: Deassert Force Wake */ |
| 504 | if (bridge_silicon_revision() < IVB_STEP_C0) { |
| 505 | gtt_write(0xa18c, gtt_read(0xa18c) & ~1); |
| 506 | gtt_poll(0x130090, (1 << 0), (0 << 0)); |
| 507 | } else { |
| 508 | gtt_write(0xa188, 0x1fffe); |
| 509 | if (gtt_poll(0x130040, (1 << 0), (0 << 0))) |
| 510 | gtt_write(0xa188, gtt_read(0xa188) | 1); |
| 511 | } |
| 512 | |
| 513 | /* 16: SW RC Control */ |
| 514 | gtt_write(0xa094, 0x00060000); |
| 515 | |
| 516 | /* Setup Digital Port Hotplug */ |
| 517 | reg32 = gtt_read(0xc4030); |
| 518 | if (!reg32) { |
| 519 | reg32 = (conf->gpu_dp_b_hotplug & 0x7) << 2; |
| 520 | reg32 |= (conf->gpu_dp_c_hotplug & 0x7) << 10; |
| 521 | reg32 |= (conf->gpu_dp_d_hotplug & 0x7) << 18; |
| 522 | gtt_write(0xc4030, reg32); |
| 523 | } |
| 524 | |
| 525 | /* Setup Panel Power On Delays */ |
| 526 | reg32 = gtt_read(0xc7208); |
| 527 | if (!reg32) { |
| 528 | reg32 = (conf->gpu_panel_port_select & 0x3) << 30; |
| 529 | reg32 |= (conf->gpu_panel_power_up_delay & 0x1fff) << 16; |
| 530 | reg32 |= (conf->gpu_panel_power_backlight_on_delay & 0x1fff); |
| 531 | gtt_write(0xc7208, reg32); |
| 532 | } |
| 533 | |
| 534 | /* Setup Panel Power Off Delays */ |
| 535 | reg32 = gtt_read(0xc720c); |
| 536 | if (!reg32) { |
| 537 | reg32 = (conf->gpu_panel_power_down_delay & 0x1fff) << 16; |
| 538 | reg32 |= (conf->gpu_panel_power_backlight_off_delay & 0x1fff); |
| 539 | gtt_write(0xc720c, reg32); |
| 540 | } |
| 541 | |
| 542 | /* Setup Panel Power Cycle Delay */ |
| 543 | if (conf->gpu_panel_power_cycle_delay) { |
| 544 | reg32 = gtt_read(0xc7210); |
| 545 | reg32 &= ~0xff; |
| 546 | reg32 |= conf->gpu_panel_power_cycle_delay & 0xff; |
| 547 | gtt_write(0xc7210, reg32); |
| 548 | } |
| 549 | |
| 550 | /* Enable Backlight if needed */ |
| 551 | if (conf->gpu_cpu_backlight) { |
| 552 | gtt_write(0x48250, (1 << 31)); |
| 553 | gtt_write(0x48254, conf->gpu_cpu_backlight); |
| 554 | } |
| 555 | if (conf->gpu_pch_backlight) { |
| 556 | gtt_write(0xc8250, (1 << 31)); |
| 557 | gtt_write(0xc8254, conf->gpu_pch_backlight); |
| 558 | } |
| 559 | } |
| 560 | |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 561 | #if IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT) |
| 562 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 563 | static void train_link(u8 *mmio) |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 564 | { |
| 565 | /* Clear interrupts. */ |
| 566 | write32(mmio + DEIIR, 0xffffffff); |
| 567 | |
| 568 | write32(mmio + 0x000f0018, 0x000000ff); |
| 569 | write32(mmio + 0x000f1018, 0x000000ff); |
| 570 | write32(mmio + 0x000f000c, 0x001a2050); |
| 571 | write32(mmio + 0x00060100, 0x001c4000); |
| 572 | write32(mmio + 0x00060100, 0x801c4000); |
| 573 | write32(mmio + 0x000f000c, 0x801a2050); |
| 574 | write32(mmio + 0x00060100, 0x801c4000); |
| 575 | write32(mmio + 0x000f000c, 0x801a2050); |
| 576 | mdelay(1); |
| 577 | |
| 578 | read32(mmio + 0x000f0014); // = 0x00000100 |
| 579 | write32(mmio + 0x000f0014, 0x00000100); |
| 580 | write32(mmio + 0x00060100, 0x901c4000); |
| 581 | write32(mmio + 0x000f000c, 0x901a2050); |
| 582 | mdelay(1); |
| 583 | read32(mmio + 0x000f0014); // = 0x00000600 |
| 584 | } |
| 585 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 586 | static void power_port(u8 *mmio) |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 587 | { |
| 588 | read32(mmio + 0x000e1100); // = 0x00000000 |
| 589 | write32(mmio + 0x000e1100, 0x00000000); |
| 590 | write32(mmio + 0x000e1100, 0x00010000); |
| 591 | read32(mmio + 0x000e1100); // = 0x00010000 |
| 592 | read32(mmio + 0x000e1100); // = 0x00010000 |
| 593 | read32(mmio + 0x000e1100); // = 0x00000000 |
| 594 | write32(mmio + 0x000e1100, 0x00000000); |
| 595 | read32(mmio + 0x000e1100); // = 0x00000000 |
| 596 | read32(mmio + 0x000e4200); // = 0x0000001c |
| 597 | write32(mmio + 0x000e4210, 0x8004003e); |
| 598 | write32(mmio + 0x000e4214, 0x80060002); |
| 599 | write32(mmio + 0x000e4218, 0x01000000); |
| 600 | read32(mmio + 0x000e4210); // = 0x5144003e |
| 601 | write32(mmio + 0x000e4210, 0x5344003e); |
| 602 | read32(mmio + 0x000e4210); // = 0x0144003e |
| 603 | write32(mmio + 0x000e4210, 0x8074003e); |
| 604 | read32(mmio + 0x000e4210); // = 0x5144003e |
| 605 | read32(mmio + 0x000e4210); // = 0x5144003e |
| 606 | write32(mmio + 0x000e4210, 0x5344003e); |
| 607 | read32(mmio + 0x000e4210); // = 0x0144003e |
| 608 | write32(mmio + 0x000e4210, 0x8074003e); |
| 609 | read32(mmio + 0x000e4210); // = 0x5144003e |
| 610 | read32(mmio + 0x000e4210); // = 0x5144003e |
| 611 | write32(mmio + 0x000e4210, 0x5344003e); |
| 612 | read32(mmio + 0x000e4210); // = 0x0144003e |
| 613 | write32(mmio + 0x000e4210, 0x8074003e); |
| 614 | read32(mmio + 0x000e4210); // = 0x5144003e |
| 615 | read32(mmio + 0x000e4210); // = 0x5144003e |
| 616 | write32(mmio + 0x000e4210, 0x5344003e); |
| 617 | write32(mmio + 0x000e4f00, 0x0100030c); |
| 618 | write32(mmio + 0x000e4f04, 0x00b8230c); |
| 619 | write32(mmio + 0x000e4f08, 0x06f8930c); |
| 620 | write32(mmio + 0x000e4f0c, 0x09f8e38e); |
| 621 | write32(mmio + 0x000e4f10, 0x00b8030c); |
| 622 | write32(mmio + 0x000e4f14, 0x0b78830c); |
| 623 | write32(mmio + 0x000e4f18, 0x0ff8d3cf); |
| 624 | write32(mmio + 0x000e4f1c, 0x01e8030c); |
| 625 | write32(mmio + 0x000e4f20, 0x0ff863cf); |
| 626 | write32(mmio + 0x000e4f24, 0x0ff803cf); |
| 627 | write32(mmio + 0x000c4030, 0x00001000); |
| 628 | read32(mmio + 0x000c4000); // = 0x00000000 |
| 629 | write32(mmio + 0x000c4030, 0x00001000); |
| 630 | read32(mmio + 0x000e1150); // = 0x0000001c |
| 631 | write32(mmio + 0x000e1150, 0x0000089c); |
| 632 | write32(mmio + 0x000fcc00, 0x01986f00); |
| 633 | write32(mmio + 0x000fcc0c, 0x01986f00); |
| 634 | write32(mmio + 0x000fcc18, 0x01986f00); |
| 635 | write32(mmio + 0x000fcc24, 0x01986f00); |
| 636 | read32(mmio + 0x000c4000); // = 0x00000000 |
| 637 | read32(mmio + 0x000e1180); // = 0x40000002 |
| 638 | } |
| 639 | |
| 640 | static void intel_gma_init(const struct northbridge_intel_nehalem_config *info, |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 641 | u8 *mmio, u32 physbase, u16 piobase, u32 lfb) |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 642 | { |
| 643 | int i; |
| 644 | u8 edid_data[128]; |
| 645 | struct edid edid; |
Nicolas Reinecke | b142b84 | 2015-10-03 17:32:38 +0200 | [diff] [blame] | 646 | struct edid_mode *mode; |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 647 | u32 hactive, vactive, right_border, bottom_border; |
| 648 | int hpolarity, vpolarity; |
| 649 | u32 vsync, hsync, vblank, hblank, hfront_porch, vfront_porch; |
| 650 | u32 candp1, candn; |
| 651 | u32 best_delta = 0xffffffff; |
| 652 | u32 target_frequency; |
| 653 | u32 pixel_p1 = 1; |
| 654 | u32 pixel_n = 1; |
| 655 | u32 pixel_m1 = 1; |
| 656 | u32 pixel_m2 = 1; |
Vladimir Serbinenko | a71bdc3 | 2014-08-30 00:35:39 +0200 | [diff] [blame] | 657 | u32 link_frequency = info->gfx.link_frequency_270_mhz ? 270000 : 162000; |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 658 | u32 data_m1; |
| 659 | u32 data_n1 = 0x00800000; |
| 660 | u32 link_m1; |
| 661 | u32 link_n1 = 0x00080000; |
| 662 | |
| 663 | write32(mmio + 0x00070080, 0x00000000); |
| 664 | write32(mmio + DSPCNTR(0), 0x00000000); |
| 665 | write32(mmio + 0x00071180, 0x00000000); |
| 666 | write32(mmio + CPU_VGACNTRL, 0x0000298e | VGA_DISP_DISABLE); |
| 667 | write32(mmio + 0x0007019c, 0x00000000); |
| 668 | write32(mmio + 0x0007119c, 0x00000000); |
| 669 | write32(mmio + 0x000fc008, 0x2c010000); |
| 670 | write32(mmio + 0x000fc020, 0x2c010000); |
| 671 | write32(mmio + 0x000fc038, 0x2c010000); |
| 672 | write32(mmio + 0x000fc050, 0x2c010000); |
| 673 | write32(mmio + 0x000fc408, 0x2c010000); |
| 674 | write32(mmio + 0x000fc420, 0x2c010000); |
| 675 | write32(mmio + 0x000fc438, 0x2c010000); |
| 676 | write32(mmio + 0x000fc450, 0x2c010000); |
| 677 | vga_gr_write(0x18, 0); |
| 678 | write32(mmio + 0x00042004, 0x02000000); |
| 679 | write32(mmio + 0x000fd034, 0x8421ffe0); |
| 680 | |
Elyes HAOUAS | cf5430f | 2016-09-13 21:27:22 +0200 | [diff] [blame] | 681 | /* Setup GTT. */ |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 682 | for (i = 0; i < 0x2000; i++) |
| 683 | { |
| 684 | outl((i << 2) | 1, piobase); |
| 685 | outl(physbase + (i << 12) + 1, piobase + 4); |
| 686 | } |
| 687 | |
| 688 | vga_misc_write(0x67); |
| 689 | |
| 690 | const u8 cr[] = { 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f, |
| 691 | 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, |
| 692 | 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, |
| 693 | 0xff |
| 694 | }; |
| 695 | vga_cr_write(0x11, 0); |
| 696 | |
| 697 | for (i = 0; i <= 0x18; i++) |
| 698 | vga_cr_write(i, cr[i]); |
| 699 | |
| 700 | power_port(mmio); |
| 701 | |
Arthur Heymans | 7141ff3 | 2016-10-10 17:49:00 +0200 | [diff] [blame] | 702 | intel_gmbus_read_edid(mmio + PCH_GMBUS0, 3, 0x50, edid_data, |
| 703 | sizeof(edid_data)); |
Vladimir Serbinenko | 428130e | 2015-05-19 09:45:22 +0200 | [diff] [blame] | 704 | intel_gmbus_stop(mmio + PCH_GMBUS0); |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 705 | decode_edid(edid_data, |
| 706 | sizeof(edid_data), &edid); |
Nicolas Reinecke | b142b84 | 2015-10-03 17:32:38 +0200 | [diff] [blame] | 707 | mode = &edid.mode; |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 708 | |
Elyes HAOUAS | cf5430f | 2016-09-13 21:27:22 +0200 | [diff] [blame] | 709 | /* Disable screen memory to prevent garbage from appearing. */ |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 710 | vga_sr_write(1, vga_sr_read(1) | 0x20); |
| 711 | |
| 712 | hactive = edid.x_resolution; |
| 713 | vactive = edid.y_resolution; |
Nicolas Reinecke | b142b84 | 2015-10-03 17:32:38 +0200 | [diff] [blame] | 714 | right_border = mode->hborder; |
| 715 | bottom_border = mode->vborder; |
| 716 | hpolarity = (mode->phsync == '-'); |
| 717 | vpolarity = (mode->pvsync == '-'); |
| 718 | vsync = mode->vspw; |
| 719 | hsync = mode->hspw; |
| 720 | vblank = mode->vbl; |
| 721 | hblank = mode->hbl; |
| 722 | hfront_porch = mode->hso; |
| 723 | vfront_porch = mode->vso; |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 724 | |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 725 | target_frequency = mode->lvds_dual_channel ? mode->pixel_clock |
Nicolas Reinecke | b142b84 | 2015-10-03 17:32:38 +0200 | [diff] [blame] | 726 | : (2 * mode->pixel_clock); |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 727 | vga_textmode_init(); |
Nico Huber | 6d8266b | 2017-05-20 16:46:01 +0200 | [diff] [blame] | 728 | |
| 729 | if (IS_ENABLED(CONFIG_LINEAR_FRAMEBUFFER)) { |
| 730 | vga_sr_write(1, 1); |
| 731 | vga_sr_write(0x2, 0xf); |
| 732 | vga_sr_write(0x3, 0x0); |
| 733 | vga_sr_write(0x4, 0xe); |
| 734 | vga_gr_write(0, 0x0); |
| 735 | vga_gr_write(1, 0x0); |
| 736 | vga_gr_write(2, 0x0); |
| 737 | vga_gr_write(3, 0x0); |
| 738 | vga_gr_write(4, 0x0); |
| 739 | vga_gr_write(5, 0x0); |
| 740 | vga_gr_write(6, 0x5); |
| 741 | vga_gr_write(7, 0xf); |
| 742 | vga_gr_write(0x10, 0x1); |
| 743 | vga_gr_write(0x11, 0); |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 744 | |
| 745 | |
Nico Huber | 6d8266b | 2017-05-20 16:46:01 +0200 | [diff] [blame] | 746 | edid.bytes_per_line = (edid.bytes_per_line + 63) & ~63; |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 747 | |
Nico Huber | 6d8266b | 2017-05-20 16:46:01 +0200 | [diff] [blame] | 748 | write32(mmio + DSPCNTR(0), DISPPLANE_BGRX888); |
| 749 | write32(mmio + DSPADDR(0), 0); |
| 750 | write32(mmio + DSPSTRIDE(0), edid.bytes_per_line); |
| 751 | write32(mmio + DSPSURF(0), 0); |
| 752 | for (i = 0; i < 0x100; i++) |
| 753 | write32(mmio + LGC_PALETTE(0) + 4 * i, i * 0x010101); |
| 754 | } |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 755 | |
Elyes HAOUAS | cf5430f | 2016-09-13 21:27:22 +0200 | [diff] [blame] | 756 | /* Find suitable divisors. */ |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 757 | for (candp1 = 1; candp1 <= 8; candp1++) { |
| 758 | for (candn = 5; candn <= 10; candn++) { |
| 759 | u32 cur_frequency; |
Elyes HAOUAS | cf5430f | 2016-09-13 21:27:22 +0200 | [diff] [blame] | 760 | u32 m; /* 77 - 131. */ |
| 761 | u32 denom; /* 35 - 560. */ |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 762 | u32 current_delta; |
| 763 | |
| 764 | denom = candn * candp1 * 7; |
Martin Roth | 128c104 | 2016-11-18 09:29:03 -0700 | [diff] [blame] | 765 | /* Doesn't overflow for up to |
Elyes HAOUAS | cf5430f | 2016-09-13 21:27:22 +0200 | [diff] [blame] | 766 | 5000000 kHz = 5 GHz. */ |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 767 | m = (target_frequency * denom + 60000) / 120000; |
| 768 | |
| 769 | if (m < 77 || m > 131) |
| 770 | continue; |
| 771 | |
| 772 | cur_frequency = (120000 * m) / denom; |
| 773 | if (target_frequency > cur_frequency) |
| 774 | current_delta = target_frequency - cur_frequency; |
| 775 | else |
| 776 | current_delta = cur_frequency - target_frequency; |
| 777 | |
| 778 | |
| 779 | if (best_delta > current_delta) { |
| 780 | best_delta = current_delta; |
| 781 | pixel_n = candn; |
| 782 | pixel_p1 = candp1; |
| 783 | pixel_m2 = ((m + 3) % 5) + 7; |
| 784 | pixel_m1 = (m - pixel_m2) / 5; |
| 785 | } |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | if (best_delta == 0xffffffff) { |
| 790 | printk (BIOS_ERR, "Couldn't find GFX clock divisors\n"); |
| 791 | return; |
| 792 | } |
| 793 | |
Nicolas Reinecke | b142b84 | 2015-10-03 17:32:38 +0200 | [diff] [blame] | 794 | link_m1 = ((uint64_t)link_n1 * mode->pixel_clock) / link_frequency; |
| 795 | data_m1 = ((uint64_t)data_n1 * 18 * mode->pixel_clock) |
Vladimir Serbinenko | c48f5ef | 2015-10-11 02:05:55 +0200 | [diff] [blame] | 796 | / (link_frequency * 8 * 4); |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 797 | |
| 798 | printk(BIOS_INFO, "bringing up panel at resolution %d x %d\n", |
| 799 | hactive, vactive); |
| 800 | printk(BIOS_DEBUG, "Borders %d x %d\n", |
| 801 | right_border, bottom_border); |
| 802 | printk(BIOS_DEBUG, "Blank %d x %d\n", |
| 803 | hblank, vblank); |
| 804 | printk(BIOS_DEBUG, "Sync %d x %d\n", |
| 805 | hsync, vsync); |
| 806 | printk(BIOS_DEBUG, "Front porch %d x %d\n", |
| 807 | hfront_porch, vfront_porch); |
Vladimir Serbinenko | a71bdc3 | 2014-08-30 00:35:39 +0200 | [diff] [blame] | 808 | printk(BIOS_DEBUG, (info->gfx.use_spread_spectrum_clock |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 809 | ? "Spread spectrum clock\n" : "DREF clock\n")); |
| 810 | printk(BIOS_DEBUG, |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 811 | mode->lvds_dual_channel ? "Dual channel\n" : "Single channel\n"); |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 812 | printk(BIOS_DEBUG, "Polarities %d, %d\n", |
| 813 | hpolarity, vpolarity); |
| 814 | printk(BIOS_DEBUG, "Data M1=%d, N1=%d\n", |
| 815 | data_m1, data_n1); |
| 816 | printk(BIOS_DEBUG, "Link frequency %d kHz\n", |
| 817 | link_frequency); |
| 818 | printk(BIOS_DEBUG, "Link M1=%d, N1=%d\n", |
| 819 | link_m1, link_n1); |
| 820 | printk(BIOS_DEBUG, "Pixel N=%d, M1=%d, M2=%d, P1=%d\n", |
| 821 | pixel_n, pixel_m1, pixel_m2, pixel_p1); |
| 822 | printk(BIOS_DEBUG, "Pixel clock %d kHz\n", |
| 823 | 120000 * (5 * pixel_m1 + pixel_m2) / pixel_n |
| 824 | / (pixel_p1 * 7)); |
| 825 | |
| 826 | write32(mmio + PCH_LVDS, |
| 827 | (hpolarity << 20) | (vpolarity << 21) |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 828 | | (mode->lvds_dual_channel ? LVDS_CLOCK_B_POWERUP_ALL |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 829 | | LVDS_CLOCK_BOTH_POWERUP_ALL : 0) |
| 830 | | LVDS_BORDER_ENABLE | LVDS_CLOCK_A_POWERUP_ALL |
| 831 | | LVDS_DETECTED); |
| 832 | write32(mmio + BLC_PWM_CPU_CTL2, (1 << 31)); |
Vladimir Serbinenko | a71bdc3 | 2014-08-30 00:35:39 +0200 | [diff] [blame] | 833 | write32(mmio + PCH_DREF_CONTROL, (info->gfx.use_spread_spectrum_clock |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 834 | ? 0x1002 : 0x400)); |
| 835 | mdelay(1); |
| 836 | write32(mmio + PCH_PP_CONTROL, PANEL_UNLOCK_REGS |
| 837 | | (read32(mmio + PCH_PP_CONTROL) & ~PANEL_UNLOCK_MASK)); |
| 838 | write32(mmio + _PCH_FP0(0), |
| 839 | ((pixel_n - 2) << 16) |
| 840 | | ((pixel_m1 - 2) << 8) | pixel_m2); |
| 841 | write32(mmio + _PCH_DPLL(0), |
| 842 | DPLL_VCO_ENABLE | DPLLB_MODE_LVDS |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 843 | | (mode->lvds_dual_channel ? DPLLB_LVDS_P2_CLOCK_DIV_7 |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 844 | : DPLLB_LVDS_P2_CLOCK_DIV_14) |
| 845 | | (0x10000 << (pixel_p1 - 1)) |
Vladimir Serbinenko | a71bdc3 | 2014-08-30 00:35:39 +0200 | [diff] [blame] | 846 | | ((info->gfx.use_spread_spectrum_clock ? 3 : 0) << 13) |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 847 | | (0x1 << (pixel_p1 - 1))); |
| 848 | mdelay(1); |
| 849 | write32(mmio + _PCH_DPLL(0), |
| 850 | DPLL_VCO_ENABLE | DPLLB_MODE_LVDS |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 851 | | (mode->lvds_dual_channel ? DPLLB_LVDS_P2_CLOCK_DIV_7 |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 852 | : DPLLB_LVDS_P2_CLOCK_DIV_14) |
| 853 | | (0x10000 << (pixel_p1 - 1)) |
Vladimir Serbinenko | a71bdc3 | 2014-08-30 00:35:39 +0200 | [diff] [blame] | 854 | | ((info->gfx.use_spread_spectrum_clock ? 3 : 0) << 13) |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 855 | | (0x1 << (pixel_p1 - 1))); |
| 856 | /* Re-lock the registers. */ |
| 857 | write32(mmio + PCH_PP_CONTROL, |
| 858 | (read32(mmio + PCH_PP_CONTROL) & ~PANEL_UNLOCK_MASK)); |
| 859 | |
| 860 | write32(mmio + PCH_LVDS, |
| 861 | (hpolarity << 20) | (vpolarity << 21) |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 862 | | (mode->lvds_dual_channel ? LVDS_CLOCK_B_POWERUP_ALL |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 863 | | LVDS_CLOCK_BOTH_POWERUP_ALL : 0) |
| 864 | | LVDS_BORDER_ENABLE | LVDS_CLOCK_A_POWERUP_ALL |
| 865 | | LVDS_DETECTED); |
| 866 | |
| 867 | write32(mmio + HTOTAL(0), |
| 868 | ((hactive + right_border + hblank - 1) << 16) |
| 869 | | (hactive - 1)); |
| 870 | write32(mmio + HBLANK(0), |
| 871 | ((hactive + right_border + hblank - 1) << 16) |
| 872 | | (hactive + right_border - 1)); |
| 873 | write32(mmio + HSYNC(0), |
| 874 | ((hactive + right_border + hfront_porch + hsync - 1) << 16) |
| 875 | | (hactive + right_border + hfront_porch - 1)); |
| 876 | |
| 877 | write32(mmio + VTOTAL(0), ((vactive + bottom_border + vblank - 1) << 16) |
| 878 | | (vactive - 1)); |
| 879 | write32(mmio + VBLANK(0), ((vactive + bottom_border + vblank - 1) << 16) |
| 880 | | (vactive + bottom_border - 1)); |
| 881 | write32(mmio + VSYNC(0), |
| 882 | (vactive + bottom_border + vfront_porch + vsync - 1) |
| 883 | | (vactive + bottom_border + vfront_porch - 1)); |
| 884 | |
| 885 | write32(mmio + PIPECONF(0), PIPECONF_DISABLE); |
| 886 | |
| 887 | write32(mmio + PF_WIN_POS(0), 0); |
Nico Huber | 6d8266b | 2017-05-20 16:46:01 +0200 | [diff] [blame] | 888 | if (IS_ENABLED(CONFIG_LINEAR_FRAMEBUFFER)) { |
| 889 | write32(mmio + PIPESRC(0), (hactive - 1) << 16 | (vactive - 1)); |
| 890 | write32(mmio + PF_CTL(0), 0); |
| 891 | write32(mmio + PF_WIN_SZ(0), 0); |
| 892 | } else { |
| 893 | write32(mmio + PIPESRC(0), (639 << 16) | 399); |
| 894 | write32(mmio + PF_CTL(0), PF_ENABLE | PF_FILTER_MED_3x3); |
| 895 | write32(mmio + PF_WIN_SZ(0), vactive | (hactive << 16)); |
| 896 | } |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 897 | |
| 898 | mdelay(1); |
| 899 | |
| 900 | write32(mmio + PIPE_DATA_M1(0), 0x7e000000 | data_m1); |
| 901 | write32(mmio + PIPE_DATA_N1(0), data_n1); |
| 902 | write32(mmio + PIPE_LINK_M1(0), link_m1); |
| 903 | write32(mmio + PIPE_LINK_N1(0), link_n1); |
| 904 | |
| 905 | write32(mmio + 0x000f000c, 0x00002040); |
| 906 | mdelay(1); |
| 907 | write32(mmio + 0x000f000c, 0x00002050); |
| 908 | write32(mmio + 0x00060100, 0x00044000); |
| 909 | mdelay(1); |
| 910 | write32(mmio + PIPECONF(0), PIPECONF_BPP_6); |
| 911 | write32(mmio + 0x000f0008, 0x00000040); |
| 912 | write32(mmio + 0x000f000c, 0x00022050); |
| 913 | write32(mmio + PIPECONF(0), PIPECONF_BPP_6 | PIPECONF_DITHER_EN); |
| 914 | write32(mmio + PIPECONF(0), PIPECONF_ENABLE | PIPECONF_BPP_6 | PIPECONF_DITHER_EN); |
| 915 | |
Nico Huber | 6d8266b | 2017-05-20 16:46:01 +0200 | [diff] [blame] | 916 | if (IS_ENABLED(CONFIG_LINEAR_FRAMEBUFFER)) |
| 917 | write32(mmio + CPU_VGACNTRL, 0x20298e | VGA_DISP_DISABLE); |
| 918 | else |
| 919 | write32(mmio + CPU_VGACNTRL, 0x20298e); |
| 920 | |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 921 | train_link(mmio); |
| 922 | |
Nico Huber | 6d8266b | 2017-05-20 16:46:01 +0200 | [diff] [blame] | 923 | if (IS_ENABLED(CONFIG_LINEAR_FRAMEBUFFER)) { |
| 924 | write32(mmio + DSPCNTR(0), |
| 925 | DISPLAY_PLANE_ENABLE | DISPPLANE_BGRX888); |
| 926 | mdelay(1); |
| 927 | } |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 928 | |
| 929 | write32(mmio + TRANS_HTOTAL(0), |
| 930 | ((hactive + right_border + hblank - 1) << 16) |
| 931 | | (hactive - 1)); |
| 932 | write32(mmio + TRANS_HBLANK(0), |
| 933 | ((hactive + right_border + hblank - 1) << 16) |
| 934 | | (hactive + right_border - 1)); |
| 935 | write32(mmio + TRANS_HSYNC(0), |
| 936 | ((hactive + right_border + hfront_porch + hsync - 1) << 16) |
| 937 | | (hactive + right_border + hfront_porch - 1)); |
| 938 | |
| 939 | write32(mmio + TRANS_VTOTAL(0), |
| 940 | ((vactive + bottom_border + vblank - 1) << 16) |
| 941 | | (vactive - 1)); |
| 942 | write32(mmio + TRANS_VBLANK(0), |
| 943 | ((vactive + bottom_border + vblank - 1) << 16) |
| 944 | | (vactive + bottom_border - 1)); |
| 945 | write32(mmio + TRANS_VSYNC(0), |
| 946 | (vactive + bottom_border + vfront_porch + vsync - 1) |
| 947 | | (vactive + bottom_border + vfront_porch - 1)); |
| 948 | |
| 949 | write32(mmio + 0x00060100, 0xb01c4000); |
| 950 | write32(mmio + 0x000f000c, 0xb01a2050); |
| 951 | mdelay(1); |
Nico Huber | 6d8266b | 2017-05-20 16:46:01 +0200 | [diff] [blame] | 952 | write32(mmio + TRANSCONF(0), TRANS_ENABLE | TRANS_6BPC | |
| 953 | (IS_ENABLED(CONFIG_LINEAR_FRAMEBUFFER) ? TRANS_STATE_MASK : 0)); |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 954 | write32(mmio + PCH_LVDS, |
| 955 | LVDS_PORT_ENABLE |
| 956 | | (hpolarity << 20) | (vpolarity << 21) |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 957 | | (mode->lvds_dual_channel ? LVDS_CLOCK_B_POWERUP_ALL |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 958 | | LVDS_CLOCK_BOTH_POWERUP_ALL : 0) |
| 959 | | LVDS_BORDER_ENABLE | LVDS_CLOCK_A_POWERUP_ALL |
| 960 | | LVDS_DETECTED); |
| 961 | |
| 962 | write32(mmio + PCH_PP_CONTROL, PANEL_UNLOCK_REGS | PANEL_POWER_OFF); |
| 963 | write32(mmio + PCH_PP_CONTROL, PANEL_UNLOCK_REGS | PANEL_POWER_RESET); |
| 964 | mdelay(1); |
| 965 | write32(mmio + PCH_PP_CONTROL, PANEL_UNLOCK_REGS |
| 966 | | PANEL_POWER_ON | PANEL_POWER_RESET); |
| 967 | |
| 968 | printk (BIOS_DEBUG, "waiting for panel powerup\n"); |
| 969 | while (1) { |
| 970 | u32 reg32; |
| 971 | reg32 = read32(mmio + PCH_PP_STATUS); |
| 972 | if (((reg32 >> 28) & 3) == 0) |
| 973 | break; |
| 974 | } |
| 975 | printk (BIOS_DEBUG, "panel powered up\n"); |
| 976 | |
| 977 | write32(mmio + PCH_PP_CONTROL, PANEL_POWER_ON | PANEL_POWER_RESET); |
| 978 | |
Elyes HAOUAS | cf5430f | 2016-09-13 21:27:22 +0200 | [diff] [blame] | 979 | /* Enable screen memory. */ |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 980 | vga_sr_write(1, vga_sr_read(1) & ~0x20); |
| 981 | |
| 982 | /* Clear interrupts. */ |
| 983 | write32(mmio + DEIIR, 0xffffffff); |
| 984 | write32(mmio + SDEIIR, 0xffffffff); |
| 985 | |
Vladimir Serbinenko | 428130e | 2015-05-19 09:45:22 +0200 | [diff] [blame] | 986 | /* Doesn't change any hw behaviour but vga oprom expects it there. */ |
| 987 | write32(mmio + 0x0004f040, 0x01000008); |
| 988 | write32(mmio + 0x0004f04c, 0x7f7f0000); |
| 989 | write32(mmio + 0x0004f054, 0x0000020d); |
| 990 | |
Nico Huber | 6d8266b | 2017-05-20 16:46:01 +0200 | [diff] [blame] | 991 | if (IS_ENABLED(CONFIG_LINEAR_FRAMEBUFFER)) { |
| 992 | memset((void *)lfb, 0, |
| 993 | edid.x_resolution * edid.y_resolution * 4); |
| 994 | set_vbe_mode_info_valid(&edid, lfb); |
| 995 | } |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 996 | } |
| 997 | |
Vladimir Serbinenko | 5aa28f5 | 2014-05-31 22:26:42 +0200 | [diff] [blame] | 998 | #endif |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 999 | |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 1000 | static void gma_func0_init(struct device *dev) |
| 1001 | { |
| 1002 | u32 reg32; |
| 1003 | |
| 1004 | /* IGD needs to be Bus Master */ |
| 1005 | reg32 = pci_read_config32(dev, PCI_COMMAND); |
| 1006 | reg32 |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO; |
| 1007 | pci_write_config32(dev, PCI_COMMAND, reg32); |
| 1008 | |
| 1009 | /* Init graphics power management */ |
| 1010 | gma_pm_init_pre_vbios(dev); |
| 1011 | |
Nico Huber | d4ebeaf | 2017-05-22 13:49:22 +0200 | [diff] [blame] | 1012 | if (IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT) || |
| 1013 | IS_ENABLED(CONFIG_MAINBOARD_USE_LIBGFXINIT)) { |
| 1014 | u32 physbase; |
| 1015 | struct northbridge_intel_nehalem_config *conf = dev->chip_info; |
| 1016 | struct resource *lfb_res; |
| 1017 | struct resource *pio_res; |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 1018 | |
Nico Huber | d4ebeaf | 2017-05-22 13:49:22 +0200 | [diff] [blame] | 1019 | lfb_res = find_resource(dev, PCI_BASE_ADDRESS_2); |
| 1020 | pio_res = find_resource(dev, PCI_BASE_ADDRESS_4); |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 1021 | |
Nico Huber | d4ebeaf | 2017-05-22 13:49:22 +0200 | [diff] [blame] | 1022 | physbase = pci_read_config32(dev, 0x5c) & ~0xf; |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 1023 | |
Nico Huber | d4ebeaf | 2017-05-22 13:49:22 +0200 | [diff] [blame] | 1024 | if (gtt_res && gtt_res->base && physbase && |
| 1025 | pio_res && pio_res->base && lfb_res && lfb_res->base) { |
| 1026 | printk(BIOS_SPEW, |
| 1027 | "Initializing VGA without OPROM. MMIO 0x%llx\n", |
| 1028 | gtt_res->base); |
| 1029 | if (IS_ENABLED(CONFIG_MAINBOARD_USE_LIBGFXINIT)) { |
| 1030 | int lightup_ok; |
| 1031 | gma_gfxinit(gtt_res->base, lfb_res->base, |
| 1032 | physbase, &lightup_ok); |
| 1033 | } else { |
| 1034 | intel_gma_init(conf, res2mmio(gtt_res, 0, 0), |
| 1035 | physbase, pio_res->base, lfb_res->base); |
| 1036 | } |
Nico Huber | 88c6487 | 2016-10-05 18:02:01 +0200 | [diff] [blame] | 1037 | } |
Nico Huber | d4ebeaf | 2017-05-22 13:49:22 +0200 | [diff] [blame] | 1038 | |
| 1039 | /* Linux relies on VBT for panel info. */ |
| 1040 | generate_fake_intel_oprom(&conf->gfx, dev, |
| 1041 | "$VBT IRONLAKE-MOBILE"); |
| 1042 | } else { |
| 1043 | /* PCI Init, will run VBIOS */ |
| 1044 | pci_dev_init(dev); |
Vladimir Serbinenko | 1315730 | 2014-02-19 22:18:08 +0100 | [diff] [blame] | 1045 | } |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 1046 | |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 1047 | /* Post VBIOS init */ |
| 1048 | gma_pm_init_post_vbios(dev); |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 1049 | } |
| 1050 | |
| 1051 | static void gma_set_subsystem(device_t dev, unsigned vendor, unsigned device) |
| 1052 | { |
| 1053 | if (!vendor || !device) { |
| 1054 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 1055 | pci_read_config32(dev, PCI_VENDOR_ID)); |
| 1056 | } else { |
| 1057 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 1058 | ((device & 0xffff) << 16) | (vendor & |
| 1059 | 0xffff)); |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | static void gma_read_resources(struct device *dev) |
| 1064 | { |
| 1065 | pci_dev_read_resources(dev); |
| 1066 | |
| 1067 | struct resource *res; |
| 1068 | |
| 1069 | /* Set the graphics memory to write combining. */ |
| 1070 | res = find_resource(dev, PCI_BASE_ADDRESS_2); |
| 1071 | if (res == NULL) { |
| 1072 | printk(BIOS_DEBUG, "gma: memory resource not found.\n"); |
| 1073 | return; |
| 1074 | } |
| 1075 | res->flags |= IORESOURCE_RESERVE | IORESOURCE_FIXED | IORESOURCE_ASSIGNED; |
Elyes HAOUAS | cf5430f | 2016-09-13 21:27:22 +0200 | [diff] [blame] | 1076 | pci_write_config32(dev, PCI_BASE_ADDRESS_2, 0xd0000001); |
| 1077 | pci_write_config32(dev, PCI_BASE_ADDRESS_2 + 4, 0); |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 1078 | res->base = (resource_t) 0xd0000000; |
| 1079 | res->size = (resource_t) 0x10000000; |
| 1080 | } |
| 1081 | |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 1082 | const struct i915_gpu_controller_info * |
| 1083 | intel_gma_get_controller_info(void) |
| 1084 | { |
| 1085 | device_t dev = dev_find_slot(0, PCI_DEVFN(0x2,0)); |
| 1086 | if (!dev) { |
| 1087 | return NULL; |
| 1088 | } |
| 1089 | struct northbridge_intel_nehalem_config *chip = dev->chip_info; |
| 1090 | return &chip->gfx; |
| 1091 | } |
| 1092 | |
Alexander Couzens | 5eea458 | 2015-04-12 22:18:55 +0200 | [diff] [blame] | 1093 | static void gma_ssdt(device_t device) |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 1094 | { |
| 1095 | const struct i915_gpu_controller_info *gfx = intel_gma_get_controller_info(); |
| 1096 | if (!gfx) { |
| 1097 | return; |
| 1098 | } |
| 1099 | |
| 1100 | drivers_intel_gma_displays_ssdt_generate(gfx); |
| 1101 | } |
| 1102 | |
Patrick Rudolph | 5c82026 | 2017-05-17 19:39:12 +0200 | [diff] [blame] | 1103 | /* Enable SCI to ACPI _GPE._L06 */ |
| 1104 | static void gma_enable_swsci(void) |
| 1105 | { |
| 1106 | u16 reg16; |
| 1107 | |
| 1108 | /* clear DMISCI status */ |
| 1109 | reg16 = inw(DEFAULT_PMBASE + TCO1_STS); |
| 1110 | reg16 &= DMISCI_STS; |
| 1111 | outw(DEFAULT_PMBASE + TCO1_STS, reg16); |
| 1112 | |
| 1113 | /* clear acpi tco status */ |
| 1114 | outl(DEFAULT_PMBASE + GPE0_STS, TCOSCI_STS); |
| 1115 | |
| 1116 | /* enable acpi tco scis */ |
| 1117 | reg16 = inw(DEFAULT_PMBASE + GPE0_EN); |
| 1118 | reg16 |= TCOSCI_EN; |
| 1119 | outw(DEFAULT_PMBASE + GPE0_EN, reg16); |
| 1120 | } |
| 1121 | |
Patrick Rudolph | 2be2840 | 2017-04-12 16:54:55 +0200 | [diff] [blame] | 1122 | static unsigned long |
| 1123 | gma_write_acpi_tables(struct device *const dev, |
| 1124 | unsigned long current, |
| 1125 | struct acpi_rsdp *const rsdp) |
| 1126 | { |
Patrick Rudolph | 5c82026 | 2017-05-17 19:39:12 +0200 | [diff] [blame] | 1127 | igd_opregion_t *opregion = (igd_opregion_t *)current; |
Patrick Rudolph | 2be2840 | 2017-04-12 16:54:55 +0200 | [diff] [blame] | 1128 | global_nvs_t *gnvs; |
| 1129 | |
Patrick Rudolph | 5c82026 | 2017-05-17 19:39:12 +0200 | [diff] [blame] | 1130 | if (init_igd_opregion(opregion) != CB_SUCCESS) |
| 1131 | return current; |
| 1132 | |
| 1133 | current += sizeof(igd_opregion_t); |
| 1134 | |
| 1135 | /* GNVS has been already set up */ |
| 1136 | gnvs = cbmem_find(CBMEM_ID_ACPI_GNVS); |
| 1137 | if (gnvs) { |
| 1138 | /* IGD OpRegion Base Address */ |
| 1139 | gnvs->aslb = (u32)(uintptr_t)opregion; |
| 1140 | } else { |
| 1141 | printk(BIOS_ERR, "Error: GNVS table not found.\n"); |
Patrick Rudolph | 2be2840 | 2017-04-12 16:54:55 +0200 | [diff] [blame] | 1142 | } |
| 1143 | |
Patrick Rudolph | 5c82026 | 2017-05-17 19:39:12 +0200 | [diff] [blame] | 1144 | gma_enable_swsci(); |
| 1145 | |
| 1146 | current = acpi_align_current(current); |
Patrick Rudolph | 2be2840 | 2017-04-12 16:54:55 +0200 | [diff] [blame] | 1147 | return current; |
| 1148 | } |
| 1149 | |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 1150 | static struct pci_operations gma_pci_ops = { |
| 1151 | .set_subsystem = gma_set_subsystem, |
| 1152 | }; |
| 1153 | |
| 1154 | static struct device_operations gma_func0_ops = { |
| 1155 | .read_resources = gma_read_resources, |
| 1156 | .set_resources = pci_dev_set_resources, |
| 1157 | .enable_resources = pci_dev_enable_resources, |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 1158 | .acpi_fill_ssdt_generator = gma_ssdt, |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 1159 | .init = gma_func0_init, |
| 1160 | .scan_bus = 0, |
| 1161 | .enable = 0, |
| 1162 | .ops_pci = &gma_pci_ops, |
Patrick Rudolph | 2be2840 | 2017-04-12 16:54:55 +0200 | [diff] [blame] | 1163 | .write_acpi_tables = gma_write_acpi_tables, |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 1164 | }; |
| 1165 | |
Elyes HAOUAS | cf5430f | 2016-09-13 21:27:22 +0200 | [diff] [blame] | 1166 | static const unsigned short pci_device_ids[] = { |
| 1167 | 0x0046, 0x0102, 0x0106, 0x010a, 0x0112, |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 1168 | 0x0116, 0x0122, 0x0126, 0x0156, |
| 1169 | 0x0166, |
| 1170 | 0 |
| 1171 | }; |
| 1172 | |
| 1173 | static const struct pci_driver gma __pci_driver = { |
| 1174 | .ops = &gma_func0_ops, |
| 1175 | .vendor = PCI_VENDOR_ID_INTEL, |
| 1176 | .devices = pci_device_ids, |
| 1177 | }; |