Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 Chromium OS Authors |
| 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. |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <arch/io.h> |
| 17 | #include <console/console.h> |
Kyösti Mälkki | ab56b3b | 2013-11-28 16:44:51 +0200 | [diff] [blame] | 18 | #include <bootmode.h> |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 19 | #include <delay.h> |
Vladimir Serbinenko | f2e206a | 2014-02-23 00:13:56 +0100 | [diff] [blame] | 20 | #include <string.h> |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 21 | #include <device/device.h> |
| 22 | #include <device/pci.h> |
| 23 | #include <device/pci_ids.h> |
Ronald G. Minnich | 69efaa0 | 2013-02-26 10:07:40 -0800 | [diff] [blame] | 24 | #include <device/pci_ops.h> |
| 25 | #include <cpu/x86/msr.h> |
| 26 | #include <cpu/x86/mtrr.h> |
Patrick Rudolph | 281ccca | 2017-04-12 16:55:32 +0200 | [diff] [blame] | 27 | #include <southbridge/intel/bd82x6x/nvs.h> |
Patrick Rudolph | 402e9c1 | 2017-05-18 18:26:30 +0200 | [diff] [blame] | 28 | #include <northbridge/intel/common/gma_opregion.h> |
Patrick Rudolph | 281ccca | 2017-04-12 16:55:32 +0200 | [diff] [blame] | 29 | #include <cbmem.h> |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 30 | |
| 31 | #include "chip.h" |
| 32 | #include "sandybridge.h" |
Patrick Rudolph | 45a0dbc | 2017-03-30 17:07:42 +0200 | [diff] [blame] | 33 | #include "gma.h" |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 34 | |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 35 | struct gt_powermeter { |
| 36 | u16 reg; |
| 37 | u32 value; |
| 38 | }; |
| 39 | |
Stefan Reinauer | 4c8027a | 2012-09-07 10:53:56 -0700 | [diff] [blame] | 40 | static const struct gt_powermeter snb_pm_gt1[] = { |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 41 | { 0xa200, 0xcc000000 }, |
| 42 | { 0xa204, 0x07000040 }, |
| 43 | { 0xa208, 0x0000fe00 }, |
| 44 | { 0xa20c, 0x00000000 }, |
| 45 | { 0xa210, 0x17000000 }, |
| 46 | { 0xa214, 0x00000021 }, |
| 47 | { 0xa218, 0x0817fe19 }, |
| 48 | { 0xa21c, 0x00000000 }, |
| 49 | { 0xa220, 0x00000000 }, |
| 50 | { 0xa224, 0xcc000000 }, |
| 51 | { 0xa228, 0x07000040 }, |
| 52 | { 0xa22c, 0x0000fe00 }, |
| 53 | { 0xa230, 0x00000000 }, |
| 54 | { 0xa234, 0x17000000 }, |
| 55 | { 0xa238, 0x00000021 }, |
| 56 | { 0xa23c, 0x0817fe19 }, |
| 57 | { 0xa240, 0x00000000 }, |
| 58 | { 0xa244, 0x00000000 }, |
| 59 | { 0xa248, 0x8000421e }, |
| 60 | { 0 } |
| 61 | }; |
| 62 | |
Stefan Reinauer | 4c8027a | 2012-09-07 10:53:56 -0700 | [diff] [blame] | 63 | static const struct gt_powermeter snb_pm_gt2[] = { |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 64 | { 0xa200, 0x330000a6 }, |
| 65 | { 0xa204, 0x402d0031 }, |
| 66 | { 0xa208, 0x00165f83 }, |
| 67 | { 0xa20c, 0xf1000000 }, |
| 68 | { 0xa210, 0x00000000 }, |
| 69 | { 0xa214, 0x00160016 }, |
| 70 | { 0xa218, 0x002a002b }, |
| 71 | { 0xa21c, 0x00000000 }, |
| 72 | { 0xa220, 0x00000000 }, |
| 73 | { 0xa224, 0x330000a6 }, |
| 74 | { 0xa228, 0x402d0031 }, |
| 75 | { 0xa22c, 0x00165f83 }, |
| 76 | { 0xa230, 0xf1000000 }, |
| 77 | { 0xa234, 0x00000000 }, |
| 78 | { 0xa238, 0x00160016 }, |
| 79 | { 0xa23c, 0x002a002b }, |
| 80 | { 0xa240, 0x00000000 }, |
| 81 | { 0xa244, 0x00000000 }, |
| 82 | { 0xa248, 0x8000421e }, |
| 83 | { 0 } |
| 84 | }; |
| 85 | |
Stefan Reinauer | 4c8027a | 2012-09-07 10:53:56 -0700 | [diff] [blame] | 86 | static const struct gt_powermeter ivb_pm_gt1[] = { |
Duncan Laurie | 8508cff | 2012-04-12 16:02:43 -0700 | [diff] [blame] | 87 | { 0xa800, 0x00000000 }, |
| 88 | { 0xa804, 0x00021c00 }, |
| 89 | { 0xa808, 0x00000403 }, |
| 90 | { 0xa80c, 0x02001700 }, |
| 91 | { 0xa810, 0x05000200 }, |
| 92 | { 0xa814, 0x00000000 }, |
| 93 | { 0xa818, 0x00690500 }, |
| 94 | { 0xa81c, 0x0000007f }, |
| 95 | { 0xa820, 0x01002501 }, |
| 96 | { 0xa824, 0x00000300 }, |
| 97 | { 0xa828, 0x01000331 }, |
| 98 | { 0xa82c, 0x0000000c }, |
| 99 | { 0xa830, 0x00010016 }, |
| 100 | { 0xa834, 0x01100101 }, |
| 101 | { 0xa838, 0x00010103 }, |
| 102 | { 0xa83c, 0x00041300 }, |
| 103 | { 0xa840, 0x00000b30 }, |
| 104 | { 0xa844, 0x00000000 }, |
| 105 | { 0xa848, 0x7f000000 }, |
| 106 | { 0xa84c, 0x05000008 }, |
| 107 | { 0xa850, 0x00000001 }, |
| 108 | { 0xa854, 0x00000004 }, |
| 109 | { 0xa858, 0x00000007 }, |
| 110 | { 0xa85c, 0x00000000 }, |
| 111 | { 0xa860, 0x00010000 }, |
| 112 | { 0xa248, 0x0000221e }, |
| 113 | { 0xa900, 0x00000000 }, |
| 114 | { 0xa904, 0x00001c00 }, |
| 115 | { 0xa908, 0x00000000 }, |
| 116 | { 0xa90c, 0x06000000 }, |
| 117 | { 0xa910, 0x09000200 }, |
| 118 | { 0xa914, 0x00000000 }, |
| 119 | { 0xa918, 0x00590000 }, |
| 120 | { 0xa91c, 0x00000000 }, |
| 121 | { 0xa920, 0x04002501 }, |
| 122 | { 0xa924, 0x00000100 }, |
| 123 | { 0xa928, 0x03000410 }, |
| 124 | { 0xa92c, 0x00000000 }, |
| 125 | { 0xa930, 0x00020000 }, |
| 126 | { 0xa934, 0x02070106 }, |
| 127 | { 0xa938, 0x00010100 }, |
| 128 | { 0xa93c, 0x00401c00 }, |
| 129 | { 0xa940, 0x00000000 }, |
| 130 | { 0xa944, 0x00000000 }, |
| 131 | { 0xa948, 0x10000e00 }, |
| 132 | { 0xa94c, 0x02000004 }, |
| 133 | { 0xa950, 0x00000001 }, |
| 134 | { 0xa954, 0x00000004 }, |
| 135 | { 0xa960, 0x00060000 }, |
| 136 | { 0xaa3c, 0x00001c00 }, |
| 137 | { 0xaa54, 0x00000004 }, |
| 138 | { 0xaa60, 0x00060000 }, |
| 139 | { 0 } |
| 140 | }; |
| 141 | |
Stefan Reinauer | 4c8027a | 2012-09-07 10:53:56 -0700 | [diff] [blame] | 142 | static const struct gt_powermeter ivb_pm_gt2_17w[] = { |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 143 | { 0xa800, 0x20000000 }, |
| 144 | { 0xa804, 0x000e3800 }, |
| 145 | { 0xa808, 0x00000806 }, |
| 146 | { 0xa80c, 0x0c002f00 }, |
| 147 | { 0xa810, 0x0c000800 }, |
| 148 | { 0xa814, 0x00000000 }, |
| 149 | { 0xa818, 0x00d20d00 }, |
| 150 | { 0xa81c, 0x000000ff }, |
| 151 | { 0xa820, 0x03004b02 }, |
| 152 | { 0xa824, 0x00000600 }, |
| 153 | { 0xa828, 0x07000773 }, |
| 154 | { 0xa82c, 0x00000000 }, |
| 155 | { 0xa830, 0x00020032 }, |
| 156 | { 0xa834, 0x1520040d }, |
| 157 | { 0xa838, 0x00020105 }, |
| 158 | { 0xa83c, 0x00083700 }, |
| 159 | { 0xa840, 0x000016ff }, |
| 160 | { 0xa844, 0x00000000 }, |
| 161 | { 0xa848, 0xff000000 }, |
| 162 | { 0xa84c, 0x0a000010 }, |
Duncan Laurie | 8508cff | 2012-04-12 16:02:43 -0700 | [diff] [blame] | 163 | { 0xa850, 0x00000002 }, |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 164 | { 0xa854, 0x00000008 }, |
Duncan Laurie | 8508cff | 2012-04-12 16:02:43 -0700 | [diff] [blame] | 165 | { 0xa858, 0x0000000f }, |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 166 | { 0xa85c, 0x00000000 }, |
| 167 | { 0xa860, 0x00020000 }, |
| 168 | { 0xa248, 0x0000221e }, |
| 169 | { 0xa900, 0x00000000 }, |
| 170 | { 0xa904, 0x00003800 }, |
| 171 | { 0xa908, 0x00000000 }, |
| 172 | { 0xa90c, 0x0c000000 }, |
Duncan Laurie | 8508cff | 2012-04-12 16:02:43 -0700 | [diff] [blame] | 173 | { 0xa910, 0x12000800 }, |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 174 | { 0xa914, 0x00000000 }, |
| 175 | { 0xa918, 0x00b20000 }, |
| 176 | { 0xa91c, 0x00000000 }, |
| 177 | { 0xa920, 0x08004b02 }, |
Duncan Laurie | 8508cff | 2012-04-12 16:02:43 -0700 | [diff] [blame] | 178 | { 0xa924, 0x00000300 }, |
| 179 | { 0xa928, 0x01000820 }, |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 180 | { 0xa92c, 0x00000000 }, |
| 181 | { 0xa930, 0x00030000 }, |
Duncan Laurie | 8508cff | 2012-04-12 16:02:43 -0700 | [diff] [blame] | 182 | { 0xa934, 0x15150406 }, |
| 183 | { 0xa938, 0x00020300 }, |
| 184 | { 0xa93c, 0x00903900 }, |
| 185 | { 0xa940, 0x00000000 }, |
| 186 | { 0xa944, 0x00000000 }, |
| 187 | { 0xa948, 0x20001b00 }, |
| 188 | { 0xa94c, 0x0a000010 }, |
| 189 | { 0xa950, 0x00000000 }, |
| 190 | { 0xa954, 0x00000008 }, |
| 191 | { 0xa960, 0x00110000 }, |
| 192 | { 0xaa3c, 0x00003900 }, |
| 193 | { 0xaa54, 0x00000008 }, |
| 194 | { 0xaa60, 0x00110000 }, |
| 195 | { 0 } |
| 196 | }; |
| 197 | |
Stefan Reinauer | 4c8027a | 2012-09-07 10:53:56 -0700 | [diff] [blame] | 198 | static const struct gt_powermeter ivb_pm_gt2_35w[] = { |
Duncan Laurie | 8508cff | 2012-04-12 16:02:43 -0700 | [diff] [blame] | 199 | { 0xa800, 0x00000000 }, |
| 200 | { 0xa804, 0x00030400 }, |
| 201 | { 0xa808, 0x00000806 }, |
| 202 | { 0xa80c, 0x0c002f00 }, |
| 203 | { 0xa810, 0x0c000300 }, |
| 204 | { 0xa814, 0x00000000 }, |
| 205 | { 0xa818, 0x00d20d00 }, |
| 206 | { 0xa81c, 0x000000ff }, |
| 207 | { 0xa820, 0x03004b02 }, |
| 208 | { 0xa824, 0x00000600 }, |
| 209 | { 0xa828, 0x07000773 }, |
| 210 | { 0xa82c, 0x00000000 }, |
| 211 | { 0xa830, 0x00020032 }, |
| 212 | { 0xa834, 0x1520040d }, |
| 213 | { 0xa838, 0x00020105 }, |
| 214 | { 0xa83c, 0x00083700 }, |
| 215 | { 0xa840, 0x000016ff }, |
| 216 | { 0xa844, 0x00000000 }, |
| 217 | { 0xa848, 0xff000000 }, |
| 218 | { 0xa84c, 0x0a000010 }, |
| 219 | { 0xa850, 0x00000001 }, |
| 220 | { 0xa854, 0x00000008 }, |
| 221 | { 0xa858, 0x00000008 }, |
| 222 | { 0xa85c, 0x00000000 }, |
| 223 | { 0xa860, 0x00020000 }, |
| 224 | { 0xa248, 0x0000221e }, |
| 225 | { 0xa900, 0x00000000 }, |
| 226 | { 0xa904, 0x00003800 }, |
| 227 | { 0xa908, 0x00000000 }, |
| 228 | { 0xa90c, 0x0c000000 }, |
| 229 | { 0xa910, 0x12000800 }, |
| 230 | { 0xa914, 0x00000000 }, |
| 231 | { 0xa918, 0x00b20000 }, |
| 232 | { 0xa91c, 0x00000000 }, |
| 233 | { 0xa920, 0x08004b02 }, |
| 234 | { 0xa924, 0x00000300 }, |
| 235 | { 0xa928, 0x01000820 }, |
| 236 | { 0xa92c, 0x00000000 }, |
| 237 | { 0xa930, 0x00030000 }, |
| 238 | { 0xa934, 0x15150406 }, |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 239 | { 0xa938, 0x00020300 }, |
| 240 | { 0xa93c, 0x00903900 }, |
| 241 | { 0xa940, 0x00000000 }, |
| 242 | { 0xa944, 0x00000000 }, |
| 243 | { 0xa948, 0x20001b00 }, |
| 244 | { 0xa94c, 0x0a000010 }, |
| 245 | { 0xa950, 0x00000000 }, |
| 246 | { 0xa954, 0x00000008 }, |
| 247 | { 0xa960, 0x00110000 }, |
| 248 | { 0xaa3c, 0x00003900 }, |
| 249 | { 0xaa54, 0x00000008 }, |
| 250 | { 0xaa60, 0x00110000 }, |
| 251 | { 0 } |
| 252 | }; |
| 253 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 254 | /* some vga option roms are used for several chipsets but they only have one |
| 255 | * 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] | 256 | * the mapping ourselves |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 257 | */ |
| 258 | |
| 259 | u32 map_oprom_vendev(u32 vendev) |
| 260 | { |
| 261 | u32 new_vendev=vendev; |
| 262 | |
| 263 | switch (vendev) { |
Martin Roth | e9dfdd9 | 2012-04-26 16:04:18 -0600 | [diff] [blame] | 264 | case 0x80860102: /* GT1 Desktop */ |
| 265 | case 0x8086010a: /* GT1 Server */ |
| 266 | case 0x80860112: /* GT2 Desktop */ |
| 267 | case 0x80860116: /* GT2 Mobile */ |
| 268 | case 0x80860122: /* GT2 Desktop >=1.3GHz */ |
| 269 | case 0x80860126: /* GT2 Mobile >=1.3GHz */ |
Stefan Reinauer | 816e9d1 | 2013-01-14 10:25:43 -0800 | [diff] [blame] | 270 | case 0x80860156: /* IVB */ |
Martin Roth | e9dfdd9 | 2012-04-26 16:04:18 -0600 | [diff] [blame] | 271 | case 0x80860166: /* IVB */ |
| 272 | new_vendev=0x80860106; /* GT1 Mobile */ |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 273 | break; |
| 274 | } |
| 275 | |
| 276 | return new_vendev; |
| 277 | } |
| 278 | |
| 279 | static struct resource *gtt_res = NULL; |
| 280 | |
Vladimir Serbinenko | a71bdc3 | 2014-08-30 00:35:39 +0200 | [diff] [blame] | 281 | u32 gtt_read(u32 reg) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 282 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 283 | return read32(res2mmio(gtt_res, reg, 0)); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 284 | } |
| 285 | |
Vladimir Serbinenko | a71bdc3 | 2014-08-30 00:35:39 +0200 | [diff] [blame] | 286 | void gtt_write(u32 reg, u32 data) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 287 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 288 | write32(res2mmio(gtt_res, reg, 0), data); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 289 | } |
| 290 | |
Stefan Reinauer | 4c8027a | 2012-09-07 10:53:56 -0700 | [diff] [blame] | 291 | static inline void gtt_write_powermeter(const struct gt_powermeter *pm) |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 292 | { |
| 293 | for (; pm && pm->reg; pm++) |
| 294 | gtt_write(pm->reg, pm->value); |
| 295 | } |
| 296 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 297 | #define GTT_RETRY 1000 |
Vladimir Serbinenko | a71bdc3 | 2014-08-30 00:35:39 +0200 | [diff] [blame] | 298 | int gtt_poll(u32 reg, u32 mask, u32 value) |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 299 | { |
| 300 | unsigned try = GTT_RETRY; |
| 301 | u32 data; |
| 302 | |
| 303 | while (try--) { |
| 304 | data = gtt_read(reg); |
| 305 | if ((data & mask) == value) |
| 306 | return 1; |
| 307 | udelay(10); |
| 308 | } |
| 309 | |
| 310 | printk(BIOS_ERR, "GT init timeout\n"); |
| 311 | return 0; |
| 312 | } |
| 313 | |
Patrick Rudolph | 19c2ad8 | 2017-06-30 14:52:01 +0200 | [diff] [blame] | 314 | uintptr_t gma_get_gnvs_aslb(const void *gnvs) |
| 315 | { |
| 316 | const global_nvs_t *gnvs_ptr = gnvs; |
| 317 | return (uintptr_t)(gnvs_ptr ? gnvs_ptr->aslb : 0); |
| 318 | } |
| 319 | |
| 320 | void gma_set_gnvs_aslb(void *gnvs, uintptr_t aslb) |
| 321 | { |
| 322 | global_nvs_t *gnvs_ptr = gnvs; |
| 323 | if (gnvs_ptr) |
| 324 | gnvs_ptr->aslb = aslb; |
| 325 | } |
| 326 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 327 | static void gma_pm_init_pre_vbios(struct device *dev) |
| 328 | { |
| 329 | u32 reg32; |
| 330 | |
| 331 | printk(BIOS_DEBUG, "GT Power Management Init\n"); |
| 332 | |
| 333 | gtt_res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 334 | if (!gtt_res || !gtt_res->base) |
| 335 | return; |
| 336 | |
| 337 | if (bridge_silicon_revision() < IVB_STEP_C0) { |
| 338 | /* 1: Enable force wake */ |
| 339 | gtt_write(0xa18c, 0x00000001); |
Duncan Laurie | da83a5f | 2012-05-25 10:04:17 -0700 | [diff] [blame] | 340 | gtt_poll(0x130090, (1 << 0), (1 << 0)); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 341 | } else { |
| 342 | gtt_write(0xa180, 1 << 5); |
| 343 | gtt_write(0xa188, 0xffff0001); |
Duncan Laurie | da83a5f | 2012-05-25 10:04:17 -0700 | [diff] [blame] | 344 | gtt_poll(0x130040, (1 << 0), (1 << 0)); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | if ((bridge_silicon_revision() & BASE_REV_MASK) == BASE_REV_SNB) { |
| 348 | /* 1d: Set GTT+0x42004 [15:14]=11 (SnB C1+) */ |
| 349 | reg32 = gtt_read(0x42004); |
| 350 | reg32 |= (1 << 14) | (1 << 15); |
| 351 | gtt_write(0x42004, reg32); |
| 352 | } |
| 353 | |
| 354 | if (bridge_silicon_revision() >= IVB_STEP_A0) { |
| 355 | /* Display Reset Acknowledge Settings */ |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 356 | reg32 = gtt_read(0x45010); |
| 357 | reg32 |= (1 << 1) | (1 << 0); |
| 358 | gtt_write(0x45010, reg32); |
| 359 | } |
| 360 | |
| 361 | /* 2: Get GT SKU from GTT+0x911c[13] */ |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 362 | reg32 = gtt_read(0x911c); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 363 | if ((bridge_silicon_revision() & BASE_REV_MASK) == BASE_REV_SNB) { |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 364 | if (reg32 & (1 << 13)) { |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 365 | printk(BIOS_DEBUG, "SNB GT1 Power Meter Weights\n"); |
| 366 | gtt_write_powermeter(snb_pm_gt1); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 367 | } else { |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 368 | printk(BIOS_DEBUG, "SNB GT2 Power Meter Weights\n"); |
| 369 | gtt_write_powermeter(snb_pm_gt2); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 370 | } |
| 371 | } else { |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 372 | u32 unit = MCHBAR32(0x5938) & 0xf; |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 373 | |
Duncan Laurie | 8508cff | 2012-04-12 16:02:43 -0700 | [diff] [blame] | 374 | if (reg32 & (1 << 13)) { |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 375 | /* GT1 SKU */ |
| 376 | printk(BIOS_DEBUG, "IVB GT1 Power Meter Weights\n"); |
| 377 | gtt_write_powermeter(ivb_pm_gt1); |
Duncan Laurie | 8508cff | 2012-04-12 16:02:43 -0700 | [diff] [blame] | 378 | } else { |
| 379 | /* GT2 SKU */ |
| 380 | u32 tdp = MCHBAR32(0x5930) & 0x7fff; |
| 381 | tdp /= (1 << unit); |
| 382 | |
| 383 | if (tdp <= 17) { |
| 384 | /* <=17W ULV */ |
| 385 | printk(BIOS_DEBUG, "IVB GT2 17W " |
| 386 | "Power Meter Weights\n"); |
| 387 | gtt_write_powermeter(ivb_pm_gt2_17w); |
| 388 | } else if ((tdp >= 25) && (tdp <= 35)) { |
| 389 | /* 25W-35W */ |
Duncan Laurie | da83a5f | 2012-05-25 10:04:17 -0700 | [diff] [blame] | 390 | printk(BIOS_DEBUG, "IVB GT2 25W-35W " |
Duncan Laurie | 8508cff | 2012-04-12 16:02:43 -0700 | [diff] [blame] | 391 | "Power Meter Weights\n"); |
| 392 | gtt_write_powermeter(ivb_pm_gt2_35w); |
| 393 | } else { |
| 394 | /* All others */ |
| 395 | printk(BIOS_DEBUG, "IVB GT2 35W " |
| 396 | "Power Meter Weights\n"); |
| 397 | gtt_write_powermeter(ivb_pm_gt2_35w); |
| 398 | } |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 399 | } |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | /* 3: Gear ratio map */ |
| 403 | gtt_write(0xa004, 0x00000010); |
| 404 | |
| 405 | /* 4: GFXPAUSE */ |
| 406 | gtt_write(0xa000, 0x00070020); |
| 407 | |
| 408 | /* 5: Dynamic EU trip control */ |
| 409 | gtt_write(0xa080, 0x00000004); |
| 410 | |
| 411 | /* 6: ECO bits */ |
| 412 | reg32 = gtt_read(0xa180); |
| 413 | reg32 |= (1 << 26) | (1 << 31); |
| 414 | /* (bit 20=1 for SNB step D1+ / IVB A0+) */ |
| 415 | if (bridge_silicon_revision() >= SNB_STEP_D1) |
| 416 | reg32 |= (1 << 20); |
| 417 | gtt_write(0xa180, reg32); |
| 418 | |
| 419 | /* 6a: for SnB step D2+ only */ |
| 420 | if (((bridge_silicon_revision() & BASE_REV_MASK) == BASE_REV_SNB) && |
| 421 | (bridge_silicon_revision() >= SNB_STEP_D2)) { |
| 422 | reg32 = gtt_read(0x9400); |
| 423 | reg32 |= (1 << 7); |
| 424 | gtt_write(0x9400, reg32); |
| 425 | |
| 426 | reg32 = gtt_read(0x941c); |
| 427 | reg32 &= 0xf; |
| 428 | reg32 |= (1 << 1); |
| 429 | gtt_write(0x941c, reg32); |
Duncan Laurie | da83a5f | 2012-05-25 10:04:17 -0700 | [diff] [blame] | 430 | gtt_poll(0x941c, (1 << 1), (0 << 1)); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | if ((bridge_silicon_revision() & BASE_REV_MASK) == BASE_REV_IVB) { |
| 434 | reg32 = gtt_read(0x907c); |
| 435 | reg32 |= (1 << 16); |
| 436 | gtt_write(0x907c, reg32); |
| 437 | |
| 438 | /* 6b: Clocking reset controls */ |
| 439 | gtt_write(0x9424, 0x00000001); |
| 440 | } else { |
| 441 | /* 6b: Clocking reset controls */ |
| 442 | gtt_write(0x9424, 0x00000000); |
| 443 | } |
| 444 | |
| 445 | /* 7 */ |
Duncan Laurie | da83a5f | 2012-05-25 10:04:17 -0700 | [diff] [blame] | 446 | if (gtt_poll(0x138124, (1 << 31), (0 << 31))) { |
| 447 | gtt_write(0x138128, 0x00000029); /* Mailbox Data */ |
| 448 | gtt_write(0x138124, 0x80000004); /* Mailbox Cmd for RC6 VID */ |
| 449 | if (gtt_poll(0x138124, (1 << 31), (0 << 31))) |
| 450 | gtt_write(0x138124, 0x8000000a); |
| 451 | gtt_poll(0x138124, (1 << 31), (0 << 31)); |
| 452 | } |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 453 | |
| 454 | /* 8 */ |
| 455 | gtt_write(0xa090, 0x00000000); /* RC Control */ |
| 456 | gtt_write(0xa098, 0x03e80000); /* RC1e Wake Rate Limit */ |
| 457 | gtt_write(0xa09c, 0x0028001e); /* RC6/6p Wake Rate Limit */ |
| 458 | gtt_write(0xa0a0, 0x0000001e); /* RC6pp Wake Rate Limit */ |
| 459 | gtt_write(0xa0a8, 0x0001e848); /* RC Evaluation Interval */ |
| 460 | gtt_write(0xa0ac, 0x00000019); /* RC Idle Hysteresis */ |
| 461 | |
| 462 | /* 9 */ |
| 463 | gtt_write(0x2054, 0x0000000a); /* Render Idle Max Count */ |
| 464 | gtt_write(0x12054,0x0000000a); /* Video Idle Max Count */ |
| 465 | gtt_write(0x22054,0x0000000a); /* Blitter Idle Max Count */ |
| 466 | |
| 467 | /* 10 */ |
| 468 | gtt_write(0xa0b0, 0x00000000); /* Unblock Ack to Busy */ |
| 469 | gtt_write(0xa0b4, 0x000003e8); /* RC1e Threshold */ |
| 470 | gtt_write(0xa0b8, 0x0000c350); /* RC6 Threshold */ |
| 471 | gtt_write(0xa0bc, 0x000186a0); /* RC6p Threshold */ |
| 472 | gtt_write(0xa0c0, 0x0000fa00); /* RC6pp Threshold */ |
| 473 | |
| 474 | /* 11 */ |
| 475 | gtt_write(0xa010, 0x000f4240); /* RP Down Timeout */ |
| 476 | gtt_write(0xa014, 0x12060000); /* RP Interrupt Limits */ |
| 477 | gtt_write(0xa02c, 0x00015f90); /* RP Up Threshold */ |
| 478 | gtt_write(0xa030, 0x000186a0); /* RP Down Threshold */ |
| 479 | gtt_write(0xa068, 0x000186a0); /* RP Up EI */ |
| 480 | gtt_write(0xa06c, 0x000493e0); /* RP Down EI */ |
| 481 | gtt_write(0xa070, 0x0000000a); /* RP Idle Hysteresis */ |
| 482 | |
| 483 | /* 11a: Enable Render Standby (RC6) */ |
| 484 | if ((bridge_silicon_revision() & BASE_REV_MASK) == BASE_REV_IVB) { |
Duncan Laurie | da83a5f | 2012-05-25 10:04:17 -0700 | [diff] [blame] | 485 | /* |
| 486 | * IvyBridge should also support DeepRenderStandby. |
| 487 | * |
| 488 | * Unfortunately it does not work reliably on all SKUs so |
| 489 | * disable it here and it can be enabled by the kernel. |
| 490 | */ |
| 491 | gtt_write(0xa090, 0x88040000); /* HW RC Control */ |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 492 | } else { |
| 493 | gtt_write(0xa090, 0x88040000); /* HW RC Control */ |
| 494 | } |
| 495 | |
| 496 | /* 12: Normal Frequency Request */ |
| 497 | /* RPNFREQ_VAL comes from MCHBAR 0x5998 23:16 (8 bits!? use 7) */ |
| 498 | reg32 = MCHBAR32(0x5998); |
| 499 | reg32 >>= 16; |
| 500 | reg32 &= 0xef; |
| 501 | reg32 <<= 25; |
| 502 | gtt_write(0xa008, reg32); |
| 503 | |
| 504 | /* 13: RP Control */ |
| 505 | gtt_write(0xa024, 0x00000592); |
| 506 | |
| 507 | /* 14: Enable PM Interrupts */ |
| 508 | gtt_write(0x4402c, 0x03000076); |
| 509 | |
| 510 | /* Clear 0x6c024 [8:6] */ |
| 511 | reg32 = gtt_read(0x6c024); |
| 512 | reg32 &= ~0x000001c0; |
| 513 | gtt_write(0x6c024, reg32); |
Nico Huber | 07e206a | 2016-10-19 15:20:17 +0200 | [diff] [blame] | 514 | |
| 515 | /* Initialize DP buffer translation with recommended defaults */ |
| 516 | gtt_write(0xe4f00, 0x0100030c); |
| 517 | gtt_write(0xe4f04, 0x00b8230c); |
| 518 | gtt_write(0xe4f08, 0x06f8930c); |
| 519 | gtt_write(0xe4f0c, 0x05f8e38e); |
| 520 | gtt_write(0xe4f10, 0x00b8030c); |
| 521 | gtt_write(0xe4f14, 0x0b78830c); |
| 522 | gtt_write(0xe4f18, 0x09f8d3cf); |
| 523 | gtt_write(0xe4f1c, 0x01e8030c); |
| 524 | gtt_write(0xe4f20, 0x09f863cf); |
| 525 | gtt_write(0xe4f24, 0x0ff803cf); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | static void gma_pm_init_post_vbios(struct device *dev) |
| 529 | { |
| 530 | struct northbridge_intel_sandybridge_config *conf = dev->chip_info; |
| 531 | u32 reg32; |
| 532 | |
| 533 | printk(BIOS_DEBUG, "GT Power Management Init (post VBIOS)\n"); |
| 534 | |
| 535 | /* 15: Deassert Force Wake */ |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 536 | if (bridge_silicon_revision() < IVB_STEP_C0) { |
| 537 | gtt_write(0xa18c, gtt_read(0xa18c) & ~1); |
Duncan Laurie | da83a5f | 2012-05-25 10:04:17 -0700 | [diff] [blame] | 538 | gtt_poll(0x130090, (1 << 0), (0 << 0)); |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 539 | } else { |
| 540 | gtt_write(0xa188, 0x1fffe); |
Duncan Laurie | da83a5f | 2012-05-25 10:04:17 -0700 | [diff] [blame] | 541 | if (gtt_poll(0x130040, (1 << 0), (0 << 0))) |
| 542 | gtt_write(0xa188, gtt_read(0xa188) | 1); |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 543 | } |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 544 | |
| 545 | /* 16: SW RC Control */ |
| 546 | gtt_write(0xa094, 0x00060000); |
| 547 | |
| 548 | /* Setup Digital Port Hotplug */ |
| 549 | reg32 = gtt_read(0xc4030); |
| 550 | if (!reg32) { |
| 551 | reg32 = (conf->gpu_dp_b_hotplug & 0x7) << 2; |
| 552 | reg32 |= (conf->gpu_dp_c_hotplug & 0x7) << 10; |
| 553 | reg32 |= (conf->gpu_dp_d_hotplug & 0x7) << 18; |
| 554 | gtt_write(0xc4030, reg32); |
| 555 | } |
| 556 | |
| 557 | /* Setup Panel Power On Delays */ |
| 558 | reg32 = gtt_read(0xc7208); |
| 559 | if (!reg32) { |
| 560 | reg32 = (conf->gpu_panel_port_select & 0x3) << 30; |
| 561 | reg32 |= (conf->gpu_panel_power_up_delay & 0x1fff) << 16; |
| 562 | reg32 |= (conf->gpu_panel_power_backlight_on_delay & 0x1fff); |
| 563 | gtt_write(0xc7208, reg32); |
| 564 | } |
| 565 | |
| 566 | /* Setup Panel Power Off Delays */ |
| 567 | reg32 = gtt_read(0xc720c); |
| 568 | if (!reg32) { |
| 569 | reg32 = (conf->gpu_panel_power_down_delay & 0x1fff) << 16; |
| 570 | reg32 |= (conf->gpu_panel_power_backlight_off_delay & 0x1fff); |
| 571 | gtt_write(0xc720c, reg32); |
| 572 | } |
| 573 | |
| 574 | /* Setup Panel Power Cycle Delay */ |
| 575 | if (conf->gpu_panel_power_cycle_delay) { |
| 576 | reg32 = gtt_read(0xc7210); |
| 577 | reg32 &= ~0xff; |
| 578 | reg32 |= conf->gpu_panel_power_cycle_delay & 0xff; |
| 579 | gtt_write(0xc7210, reg32); |
| 580 | } |
Duncan Laurie | dd585b8 | 2012-04-09 12:05:18 -0700 | [diff] [blame] | 581 | |
| 582 | /* Enable Backlight if needed */ |
| 583 | if (conf->gpu_cpu_backlight) { |
| 584 | gtt_write(0x48250, (1 << 31)); |
| 585 | gtt_write(0x48254, conf->gpu_cpu_backlight); |
| 586 | } |
| 587 | if (conf->gpu_pch_backlight) { |
| 588 | gtt_write(0xc8250, (1 << 31)); |
| 589 | gtt_write(0xc8254, conf->gpu_pch_backlight); |
| 590 | } |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 591 | } |
| 592 | |
Patrick Rudolph | 76b93fe | 2017-06-20 17:55:40 +0200 | [diff] [blame] | 593 | /* Enable SCI to ACPI _GPE._L06 */ |
| 594 | static void gma_enable_swsci(void) |
| 595 | { |
| 596 | u16 reg16; |
| 597 | |
| 598 | /* clear DMISCI status */ |
| 599 | reg16 = inw(DEFAULT_PMBASE + TCO1_STS); |
| 600 | reg16 &= DMISCI_STS; |
| 601 | outw(DEFAULT_PMBASE + TCO1_STS, reg16); |
| 602 | |
| 603 | /* clear acpi tco status */ |
| 604 | outl(DEFAULT_PMBASE + GPE0_STS, TCOSCI_STS); |
| 605 | |
| 606 | /* enable acpi tco scis */ |
| 607 | reg16 = inw(DEFAULT_PMBASE + GPE0_EN); |
| 608 | reg16 |= TCOSCI_EN; |
| 609 | outw(DEFAULT_PMBASE + GPE0_EN, reg16); |
| 610 | } |
| 611 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 612 | static void gma_func0_init(struct device *dev) |
| 613 | { |
| 614 | u32 reg32; |
| 615 | |
| 616 | /* IGD needs to be Bus Master */ |
| 617 | reg32 = pci_read_config32(dev, PCI_COMMAND); |
| 618 | reg32 |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO; |
| 619 | pci_write_config32(dev, PCI_COMMAND, reg32); |
| 620 | |
| 621 | /* Init graphics power management */ |
| 622 | gma_pm_init_pre_vbios(dev); |
| 623 | |
Alexandru Gagniuc | 9647094 | 2015-09-07 03:06:31 -0700 | [diff] [blame] | 624 | if (!IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT)) |
| 625 | /* PCI Init, will run VBIOS */ |
| 626 | pci_dev_init(dev); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 627 | |
| 628 | /* Post VBIOS init */ |
| 629 | gma_pm_init_post_vbios(dev); |
Ronald G. Minnich | 69efaa0 | 2013-02-26 10:07:40 -0800 | [diff] [blame] | 630 | |
Nico Huber | d4ebeaf | 2017-05-22 13:49:22 +0200 | [diff] [blame] | 631 | if (IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT) || |
| 632 | IS_ENABLED(CONFIG_MAINBOARD_USE_LIBGFXINIT)) { |
Alexandru Gagniuc | 9647094 | 2015-09-07 03:06:31 -0700 | [diff] [blame] | 633 | /* This should probably run before post VBIOS init. */ |
| 634 | printk(BIOS_SPEW, "Initializing VGA without OPROM.\n"); |
| 635 | u8 *mmiobase; |
| 636 | u32 iobase, physbase, graphics_base; |
| 637 | struct northbridge_intel_sandybridge_config *conf = dev->chip_info; |
| 638 | iobase = dev->resource_list[2].base; |
| 639 | mmiobase = res2mmio(&dev->resource_list[0], 0, 0); |
| 640 | physbase = pci_read_config32(dev, 0x5c) & ~0xf; |
| 641 | graphics_base = dev->resource_list[1].base; |
Ronald G. Minnich | 69efaa0 | 2013-02-26 10:07:40 -0800 | [diff] [blame] | 642 | |
Nico Huber | 88c6487 | 2016-10-05 18:02:01 +0200 | [diff] [blame] | 643 | int lightup_ok; |
| 644 | if (IS_ENABLED(CONFIG_MAINBOARD_USE_LIBGFXINIT)) { |
| 645 | gma_gfxinit((uintptr_t)mmiobase, graphics_base, |
| 646 | physbase, &lightup_ok); |
| 647 | } else { |
| 648 | lightup_ok = i915lightup_sandy(&conf->gfx, physbase, |
| 649 | iobase, mmiobase, graphics_base); |
| 650 | } |
Alexandru Gagniuc | 9647094 | 2015-09-07 03:06:31 -0700 | [diff] [blame] | 651 | if (lightup_ok) |
| 652 | gfx_set_init_done(1); |
| 653 | } |
Patrick Rudolph | 76b93fe | 2017-06-20 17:55:40 +0200 | [diff] [blame] | 654 | |
| 655 | gma_enable_swsci(); |
| 656 | intel_gma_restore_opregion(); |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 657 | } |
| 658 | |
| 659 | static void gma_set_subsystem(device_t dev, unsigned vendor, unsigned device) |
| 660 | { |
| 661 | if (!vendor || !device) { |
| 662 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 663 | pci_read_config32(dev, PCI_VENDOR_ID)); |
| 664 | } else { |
| 665 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 666 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 667 | } |
| 668 | } |
| 669 | |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 670 | const struct i915_gpu_controller_info * |
| 671 | intel_gma_get_controller_info(void) |
| 672 | { |
| 673 | device_t dev = dev_find_slot(0, PCI_DEVFN(0x2,0)); |
| 674 | if (!dev) { |
| 675 | return NULL; |
| 676 | } |
| 677 | struct northbridge_intel_sandybridge_config *chip = dev->chip_info; |
| 678 | return &chip->gfx; |
| 679 | } |
| 680 | |
Alexander Couzens | 5eea458 | 2015-04-12 22:18:55 +0200 | [diff] [blame] | 681 | static void gma_ssdt(device_t device) |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 682 | { |
| 683 | const struct i915_gpu_controller_info *gfx = intel_gma_get_controller_info(); |
| 684 | if (!gfx) { |
| 685 | return; |
| 686 | } |
| 687 | |
| 688 | drivers_intel_gma_displays_ssdt_generate(gfx); |
| 689 | } |
| 690 | |
Patrick Rudolph | 281ccca | 2017-04-12 16:55:32 +0200 | [diff] [blame] | 691 | static unsigned long |
| 692 | gma_write_acpi_tables(struct device *const dev, |
| 693 | unsigned long current, |
| 694 | struct acpi_rsdp *const rsdp) |
| 695 | { |
Patrick Rudolph | 402e9c1 | 2017-05-18 18:26:30 +0200 | [diff] [blame] | 696 | igd_opregion_t *opregion = (igd_opregion_t *)current; |
Patrick Rudolph | 281ccca | 2017-04-12 16:55:32 +0200 | [diff] [blame] | 697 | global_nvs_t *gnvs; |
| 698 | |
Patrick Rudolph | 402e9c1 | 2017-05-18 18:26:30 +0200 | [diff] [blame] | 699 | if (init_igd_opregion(opregion) != CB_SUCCESS) |
| 700 | return current; |
| 701 | |
| 702 | current += sizeof(igd_opregion_t); |
| 703 | |
| 704 | /* GNVS has been already set up */ |
| 705 | gnvs = cbmem_find(CBMEM_ID_ACPI_GNVS); |
| 706 | if (gnvs) { |
| 707 | /* IGD OpRegion Base Address */ |
Patrick Rudolph | 19c2ad8 | 2017-06-30 14:52:01 +0200 | [diff] [blame] | 708 | gma_set_gnvs_aslb(gnvs, (uintptr_t)opregion); |
Patrick Rudolph | 402e9c1 | 2017-05-18 18:26:30 +0200 | [diff] [blame] | 709 | } else { |
| 710 | printk(BIOS_ERR, "Error: GNVS table not found.\n"); |
Patrick Rudolph | 281ccca | 2017-04-12 16:55:32 +0200 | [diff] [blame] | 711 | } |
| 712 | |
Patrick Rudolph | 402e9c1 | 2017-05-18 18:26:30 +0200 | [diff] [blame] | 713 | current = acpi_align_current(current); |
Patrick Rudolph | 281ccca | 2017-04-12 16:55:32 +0200 | [diff] [blame] | 714 | return current; |
| 715 | } |
| 716 | |
Patrick Rudolph | 3e47fc9 | 2017-06-07 09:44:07 +0200 | [diff] [blame] | 717 | static const char *gma_acpi_name(device_t dev) |
| 718 | { |
| 719 | return "GFX0"; |
| 720 | } |
| 721 | |
Patrick Rudolph | e11f6c3 | 2015-10-15 15:35:12 +0200 | [diff] [blame] | 722 | /* called by pci set_vga_bridge function */ |
| 723 | static void gma_func0_disable(struct device *dev) |
| 724 | { |
| 725 | u16 reg16; |
| 726 | device_t dev_host = dev_find_slot(0, PCI_DEVFN(0,0)); |
| 727 | |
| 728 | reg16 = pci_read_config16(dev_host, GGC); |
| 729 | reg16 |= (1 << 1); /* disable VGA decode */ |
| 730 | pci_write_config16(dev_host, GGC, reg16); |
| 731 | |
| 732 | dev->enabled = 0; |
| 733 | } |
| 734 | |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 735 | static struct pci_operations gma_pci_ops = { |
| 736 | .set_subsystem = gma_set_subsystem, |
| 737 | }; |
| 738 | |
| 739 | static struct device_operations gma_func0_ops = { |
Vladimir Serbinenko | 30fe612 | 2014-02-05 23:25:28 +0100 | [diff] [blame] | 740 | .read_resources = pci_dev_read_resources, |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 741 | .set_resources = pci_dev_set_resources, |
| 742 | .enable_resources = pci_dev_enable_resources, |
Vladimir Serbinenko | dd2bc3f | 2014-10-31 09:16:31 +0100 | [diff] [blame] | 743 | .acpi_fill_ssdt_generator = gma_ssdt, |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 744 | .init = gma_func0_init, |
| 745 | .scan_bus = 0, |
| 746 | .enable = 0, |
Patrick Rudolph | e11f6c3 | 2015-10-15 15:35:12 +0200 | [diff] [blame] | 747 | .disable = gma_func0_disable, |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 748 | .ops_pci = &gma_pci_ops, |
Patrick Rudolph | 3e47fc9 | 2017-06-07 09:44:07 +0200 | [diff] [blame] | 749 | .acpi_name = gma_acpi_name, |
Patrick Rudolph | 281ccca | 2017-04-12 16:55:32 +0200 | [diff] [blame] | 750 | .write_acpi_tables = gma_write_acpi_tables, |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 751 | }; |
| 752 | |
Ronald G. Minnich | 69efaa0 | 2013-02-26 10:07:40 -0800 | [diff] [blame] | 753 | static const unsigned short pci_device_ids[] = { 0x0102, 0x0106, 0x010a, 0x0112, |
| 754 | 0x0116, 0x0122, 0x0126, 0x0156, |
Damien Zammit | 3162a1d | 2015-07-13 16:10:52 +1000 | [diff] [blame] | 755 | 0x0166, 0x0162, 0x0152, |
Ronald G. Minnich | 69efaa0 | 2013-02-26 10:07:40 -0800 | [diff] [blame] | 756 | 0 }; |
| 757 | |
| 758 | static const struct pci_driver gma __pci_driver = { |
| 759 | .ops = &gma_func0_ops, |
| 760 | .vendor = PCI_VENDOR_ID_INTEL, |
| 761 | .devices = pci_device_ids, |
Stefan Reinauer | 00636b0 | 2012-04-04 00:08:51 +0200 | [diff] [blame] | 762 | }; |