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