Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright 2008 (c) Intel Corporation |
| 4 | * Jesse Barnes <jbarnes@virtuousgeek.org> |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the |
| 8 | * "Software"), to deal in the Software without restriction, including |
| 9 | * without limitation the rights to use, copy, modify, merge, publish, |
| 10 | * distribute, sub license, and/or sell copies of the Software, and to |
| 11 | * permit persons to whom the Software is furnished to do so, subject to |
| 12 | * the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice (including the |
| 15 | * next paragraph) shall be included in all copies or substantial portions |
| 16 | * of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
| 21 | * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR |
| 22 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 23 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 24 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 25 | */ |
| 26 | |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 27 | #include <drm/drmP.h> |
| 28 | #include <drm/i915_drm.h> |
Eric Anholt | f0217c4 | 2009-12-01 11:56:30 -0800 | [diff] [blame] | 29 | #include "intel_drv.h" |
Eugeni Dodonov | 5e5b7fa | 2012-01-07 23:40:34 -0200 | [diff] [blame] | 30 | #include "i915_reg.h" |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 31 | |
| 32 | static bool i915_pipe_enabled(struct drm_device *dev, enum pipe pipe) |
| 33 | { |
| 34 | struct drm_i915_private *dev_priv = dev->dev_private; |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 35 | u32 dpll_reg; |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 36 | |
Eugeni Dodonov | 07c1e8c | 2012-01-07 23:40:35 -0200 | [diff] [blame] | 37 | /* On IVB, 3rd pipe shares PLL with another one */ |
| 38 | if (pipe > 1) |
| 39 | return false; |
| 40 | |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 41 | if (HAS_PCH_SPLIT(dev)) |
Jesse Barnes | ee7b9f9 | 2012-04-20 17:11:53 +0100 | [diff] [blame] | 42 | dpll_reg = _PCH_DPLL(pipe); |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 43 | else |
| 44 | dpll_reg = (pipe == PIPE_A) ? _DPLL_A : _DPLL_B; |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 45 | |
| 46 | return (I915_READ(dpll_reg) & DPLL_VCO_ENABLE); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | static void i915_save_palette(struct drm_device *dev, enum pipe pipe) |
| 50 | { |
| 51 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 52 | unsigned long reg = (pipe == PIPE_A ? _PALETTE_A : _PALETTE_B); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 53 | u32 *array; |
| 54 | int i; |
| 55 | |
| 56 | if (!i915_pipe_enabled(dev, pipe)) |
| 57 | return; |
| 58 | |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 59 | if (HAS_PCH_SPLIT(dev)) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 60 | reg = (pipe == PIPE_A) ? _LGC_PALETTE_A : _LGC_PALETTE_B; |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 61 | |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 62 | if (pipe == PIPE_A) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 63 | array = dev_priv->regfile.save_palette_a; |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 64 | else |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 65 | array = dev_priv->regfile.save_palette_b; |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 66 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 67 | for (i = 0; i < 256; i++) |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 68 | array[i] = I915_READ(reg + (i << 2)); |
| 69 | } |
| 70 | |
| 71 | static void i915_restore_palette(struct drm_device *dev, enum pipe pipe) |
| 72 | { |
| 73 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 74 | unsigned long reg = (pipe == PIPE_A ? _PALETTE_A : _PALETTE_B); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 75 | u32 *array; |
| 76 | int i; |
| 77 | |
| 78 | if (!i915_pipe_enabled(dev, pipe)) |
| 79 | return; |
| 80 | |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 81 | if (HAS_PCH_SPLIT(dev)) |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 82 | reg = (pipe == PIPE_A) ? _LGC_PALETTE_A : _LGC_PALETTE_B; |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 83 | |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 84 | if (pipe == PIPE_A) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 85 | array = dev_priv->regfile.save_palette_a; |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 86 | else |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 87 | array = dev_priv->regfile.save_palette_b; |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 88 | |
Akshay Joshi | 0206e35 | 2011-08-16 15:34:10 -0400 | [diff] [blame] | 89 | for (i = 0; i < 256; i++) |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 90 | I915_WRITE(reg + (i << 2), array[i]); |
| 91 | } |
| 92 | |
| 93 | static u8 i915_read_indexed(struct drm_device *dev, u16 index_port, u16 data_port, u8 reg) |
| 94 | { |
| 95 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 96 | |
| 97 | I915_WRITE8(index_port, reg); |
| 98 | return I915_READ8(data_port); |
| 99 | } |
| 100 | |
| 101 | static u8 i915_read_ar(struct drm_device *dev, u16 st01, u8 reg, u16 palette_enable) |
| 102 | { |
| 103 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 104 | |
| 105 | I915_READ8(st01); |
| 106 | I915_WRITE8(VGA_AR_INDEX, palette_enable | reg); |
| 107 | return I915_READ8(VGA_AR_DATA_READ); |
| 108 | } |
| 109 | |
| 110 | static void i915_write_ar(struct drm_device *dev, u16 st01, u8 reg, u8 val, u16 palette_enable) |
| 111 | { |
| 112 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 113 | |
| 114 | I915_READ8(st01); |
| 115 | I915_WRITE8(VGA_AR_INDEX, palette_enable | reg); |
| 116 | I915_WRITE8(VGA_AR_DATA_WRITE, val); |
| 117 | } |
| 118 | |
| 119 | static void i915_write_indexed(struct drm_device *dev, u16 index_port, u16 data_port, u8 reg, u8 val) |
| 120 | { |
| 121 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 122 | |
| 123 | I915_WRITE8(index_port, reg); |
| 124 | I915_WRITE8(data_port, val); |
| 125 | } |
| 126 | |
| 127 | static void i915_save_vga(struct drm_device *dev) |
| 128 | { |
| 129 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 130 | int i; |
| 131 | u16 cr_index, cr_data, st01; |
| 132 | |
| 133 | /* VGA color palette registers */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 134 | dev_priv->regfile.saveDACMASK = I915_READ8(VGA_DACMASK); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 135 | |
| 136 | /* MSR bits */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 137 | dev_priv->regfile.saveMSR = I915_READ8(VGA_MSR_READ); |
| 138 | if (dev_priv->regfile.saveMSR & VGA_MSR_CGA_MODE) { |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 139 | cr_index = VGA_CR_INDEX_CGA; |
| 140 | cr_data = VGA_CR_DATA_CGA; |
| 141 | st01 = VGA_ST01_CGA; |
| 142 | } else { |
| 143 | cr_index = VGA_CR_INDEX_MDA; |
| 144 | cr_data = VGA_CR_DATA_MDA; |
| 145 | st01 = VGA_ST01_MDA; |
| 146 | } |
| 147 | |
| 148 | /* CRT controller regs */ |
| 149 | i915_write_indexed(dev, cr_index, cr_data, 0x11, |
| 150 | i915_read_indexed(dev, cr_index, cr_data, 0x11) & |
| 151 | (~0x80)); |
| 152 | for (i = 0; i <= 0x24; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 153 | dev_priv->regfile.saveCR[i] = |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 154 | i915_read_indexed(dev, cr_index, cr_data, i); |
| 155 | /* Make sure we don't turn off CR group 0 writes */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 156 | dev_priv->regfile.saveCR[0x11] &= ~0x80; |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 157 | |
| 158 | /* Attribute controller registers */ |
| 159 | I915_READ8(st01); |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 160 | dev_priv->regfile.saveAR_INDEX = I915_READ8(VGA_AR_INDEX); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 161 | for (i = 0; i <= 0x14; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 162 | dev_priv->regfile.saveAR[i] = i915_read_ar(dev, st01, i, 0); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 163 | I915_READ8(st01); |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 164 | I915_WRITE8(VGA_AR_INDEX, dev_priv->regfile.saveAR_INDEX); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 165 | I915_READ8(st01); |
| 166 | |
| 167 | /* Graphics controller registers */ |
| 168 | for (i = 0; i < 9; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 169 | dev_priv->regfile.saveGR[i] = |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 170 | i915_read_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, i); |
| 171 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 172 | dev_priv->regfile.saveGR[0x10] = |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 173 | i915_read_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x10); |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 174 | dev_priv->regfile.saveGR[0x11] = |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 175 | i915_read_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x11); |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 176 | dev_priv->regfile.saveGR[0x18] = |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 177 | i915_read_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x18); |
| 178 | |
| 179 | /* Sequencer registers */ |
| 180 | for (i = 0; i < 8; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 181 | dev_priv->regfile.saveSR[i] = |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 182 | i915_read_indexed(dev, VGA_SR_INDEX, VGA_SR_DATA, i); |
| 183 | } |
| 184 | |
| 185 | static void i915_restore_vga(struct drm_device *dev) |
| 186 | { |
| 187 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 188 | int i; |
| 189 | u16 cr_index, cr_data, st01; |
| 190 | |
| 191 | /* MSR bits */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 192 | I915_WRITE8(VGA_MSR_WRITE, dev_priv->regfile.saveMSR); |
| 193 | if (dev_priv->regfile.saveMSR & VGA_MSR_CGA_MODE) { |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 194 | cr_index = VGA_CR_INDEX_CGA; |
| 195 | cr_data = VGA_CR_DATA_CGA; |
| 196 | st01 = VGA_ST01_CGA; |
| 197 | } else { |
| 198 | cr_index = VGA_CR_INDEX_MDA; |
| 199 | cr_data = VGA_CR_DATA_MDA; |
| 200 | st01 = VGA_ST01_MDA; |
| 201 | } |
| 202 | |
| 203 | /* Sequencer registers, don't write SR07 */ |
| 204 | for (i = 0; i < 7; i++) |
| 205 | i915_write_indexed(dev, VGA_SR_INDEX, VGA_SR_DATA, i, |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 206 | dev_priv->regfile.saveSR[i]); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 207 | |
| 208 | /* CRT controller regs */ |
| 209 | /* Enable CR group 0 writes */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 210 | i915_write_indexed(dev, cr_index, cr_data, 0x11, dev_priv->regfile.saveCR[0x11]); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 211 | for (i = 0; i <= 0x24; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 212 | i915_write_indexed(dev, cr_index, cr_data, i, dev_priv->regfile.saveCR[i]); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 213 | |
| 214 | /* Graphics controller regs */ |
| 215 | for (i = 0; i < 9; i++) |
| 216 | i915_write_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, i, |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 217 | dev_priv->regfile.saveGR[i]); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 218 | |
| 219 | i915_write_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x10, |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 220 | dev_priv->regfile.saveGR[0x10]); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 221 | i915_write_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x11, |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 222 | dev_priv->regfile.saveGR[0x11]); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 223 | i915_write_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x18, |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 224 | dev_priv->regfile.saveGR[0x18]); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 225 | |
| 226 | /* Attribute controller registers */ |
| 227 | I915_READ8(st01); /* switch back to index mode */ |
| 228 | for (i = 0; i <= 0x14; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 229 | i915_write_ar(dev, st01, i, dev_priv->regfile.saveAR[i], 0); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 230 | I915_READ8(st01); /* switch back to index mode */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 231 | I915_WRITE8(VGA_AR_INDEX, dev_priv->regfile.saveAR_INDEX | 0x20); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 232 | I915_READ8(st01); |
| 233 | |
| 234 | /* VGA color palette registers */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 235 | I915_WRITE8(VGA_DACMASK, dev_priv->regfile.saveDACMASK); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 236 | } |
| 237 | |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 238 | static void i915_save_modeset_reg(struct drm_device *dev) |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 239 | { |
| 240 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 312817a | 2010-11-22 11:50:11 +0000 | [diff] [blame] | 241 | int i; |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 242 | |
Chris Wilson | f3c91c1 | 2010-11-21 09:56:00 +0000 | [diff] [blame] | 243 | /* Cursor state */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 244 | dev_priv->regfile.saveCURACNTR = I915_READ(_CURACNTR); |
| 245 | dev_priv->regfile.saveCURAPOS = I915_READ(_CURAPOS); |
| 246 | dev_priv->regfile.saveCURABASE = I915_READ(_CURABASE); |
| 247 | dev_priv->regfile.saveCURBCNTR = I915_READ(_CURBCNTR); |
| 248 | dev_priv->regfile.saveCURBPOS = I915_READ(_CURBPOS); |
| 249 | dev_priv->regfile.saveCURBBASE = I915_READ(_CURBBASE); |
Chris Wilson | f3c91c1 | 2010-11-21 09:56:00 +0000 | [diff] [blame] | 250 | if (IS_GEN2(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 251 | dev_priv->regfile.saveCURSIZE = I915_READ(CURSIZE); |
Chris Wilson | f3c91c1 | 2010-11-21 09:56:00 +0000 | [diff] [blame] | 252 | |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 253 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 254 | dev_priv->regfile.savePCH_DREF_CONTROL = I915_READ(PCH_DREF_CONTROL); |
| 255 | dev_priv->regfile.saveDISP_ARB_CTL = I915_READ(DISP_ARB_CTL); |
Zhenyu Wang | 5586c8b | 2009-11-06 02:13:02 +0000 | [diff] [blame] | 256 | } |
| 257 | |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 258 | /* Pipe & plane A info */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 259 | dev_priv->regfile.savePIPEACONF = I915_READ(_PIPEACONF); |
| 260 | dev_priv->regfile.savePIPEASRC = I915_READ(_PIPEASRC); |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 261 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 262 | dev_priv->regfile.saveFPA0 = I915_READ(_PCH_FPA0); |
| 263 | dev_priv->regfile.saveFPA1 = I915_READ(_PCH_FPA1); |
| 264 | dev_priv->regfile.saveDPLL_A = I915_READ(_PCH_DPLL_A); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 265 | } else { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 266 | dev_priv->regfile.saveFPA0 = I915_READ(_FPA0); |
| 267 | dev_priv->regfile.saveFPA1 = I915_READ(_FPA1); |
| 268 | dev_priv->regfile.saveDPLL_A = I915_READ(_DPLL_A); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 269 | } |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 270 | if (INTEL_INFO(dev)->gen >= 4 && !HAS_PCH_SPLIT(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 271 | dev_priv->regfile.saveDPLL_A_MD = I915_READ(_DPLL_A_MD); |
| 272 | dev_priv->regfile.saveHTOTAL_A = I915_READ(_HTOTAL_A); |
| 273 | dev_priv->regfile.saveHBLANK_A = I915_READ(_HBLANK_A); |
| 274 | dev_priv->regfile.saveHSYNC_A = I915_READ(_HSYNC_A); |
| 275 | dev_priv->regfile.saveVTOTAL_A = I915_READ(_VTOTAL_A); |
| 276 | dev_priv->regfile.saveVBLANK_A = I915_READ(_VBLANK_A); |
| 277 | dev_priv->regfile.saveVSYNC_A = I915_READ(_VSYNC_A); |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 278 | if (!HAS_PCH_SPLIT(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 279 | dev_priv->regfile.saveBCLRPAT_A = I915_READ(_BCLRPAT_A); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 280 | |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 281 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 282 | dev_priv->regfile.savePIPEA_DATA_M1 = I915_READ(_PIPEA_DATA_M1); |
| 283 | dev_priv->regfile.savePIPEA_DATA_N1 = I915_READ(_PIPEA_DATA_N1); |
| 284 | dev_priv->regfile.savePIPEA_LINK_M1 = I915_READ(_PIPEA_LINK_M1); |
| 285 | dev_priv->regfile.savePIPEA_LINK_N1 = I915_READ(_PIPEA_LINK_N1); |
Zhenyu Wang | 5586c8b | 2009-11-06 02:13:02 +0000 | [diff] [blame] | 286 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 287 | dev_priv->regfile.saveFDI_TXA_CTL = I915_READ(_FDI_TXA_CTL); |
| 288 | dev_priv->regfile.saveFDI_RXA_CTL = I915_READ(_FDI_RXA_CTL); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 289 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 290 | dev_priv->regfile.savePFA_CTL_1 = I915_READ(_PFA_CTL_1); |
| 291 | dev_priv->regfile.savePFA_WIN_SZ = I915_READ(_PFA_WIN_SZ); |
| 292 | dev_priv->regfile.savePFA_WIN_POS = I915_READ(_PFA_WIN_POS); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 293 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 294 | dev_priv->regfile.saveTRANSACONF = I915_READ(_TRANSACONF); |
| 295 | dev_priv->regfile.saveTRANS_HTOTAL_A = I915_READ(_TRANS_HTOTAL_A); |
| 296 | dev_priv->regfile.saveTRANS_HBLANK_A = I915_READ(_TRANS_HBLANK_A); |
| 297 | dev_priv->regfile.saveTRANS_HSYNC_A = I915_READ(_TRANS_HSYNC_A); |
| 298 | dev_priv->regfile.saveTRANS_VTOTAL_A = I915_READ(_TRANS_VTOTAL_A); |
| 299 | dev_priv->regfile.saveTRANS_VBLANK_A = I915_READ(_TRANS_VBLANK_A); |
| 300 | dev_priv->regfile.saveTRANS_VSYNC_A = I915_READ(_TRANS_VSYNC_A); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 301 | } |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 302 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 303 | dev_priv->regfile.saveDSPACNTR = I915_READ(_DSPACNTR); |
| 304 | dev_priv->regfile.saveDSPASTRIDE = I915_READ(_DSPASTRIDE); |
| 305 | dev_priv->regfile.saveDSPASIZE = I915_READ(_DSPASIZE); |
| 306 | dev_priv->regfile.saveDSPAPOS = I915_READ(_DSPAPOS); |
| 307 | dev_priv->regfile.saveDSPAADDR = I915_READ(_DSPAADDR); |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 308 | if (INTEL_INFO(dev)->gen >= 4) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 309 | dev_priv->regfile.saveDSPASURF = I915_READ(_DSPASURF); |
| 310 | dev_priv->regfile.saveDSPATILEOFF = I915_READ(_DSPATILEOFF); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 311 | } |
| 312 | i915_save_palette(dev, PIPE_A); |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 313 | dev_priv->regfile.savePIPEASTAT = I915_READ(_PIPEASTAT); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 314 | |
| 315 | /* Pipe & plane B info */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 316 | dev_priv->regfile.savePIPEBCONF = I915_READ(_PIPEBCONF); |
| 317 | dev_priv->regfile.savePIPEBSRC = I915_READ(_PIPEBSRC); |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 318 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 319 | dev_priv->regfile.saveFPB0 = I915_READ(_PCH_FPB0); |
| 320 | dev_priv->regfile.saveFPB1 = I915_READ(_PCH_FPB1); |
| 321 | dev_priv->regfile.saveDPLL_B = I915_READ(_PCH_DPLL_B); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 322 | } else { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 323 | dev_priv->regfile.saveFPB0 = I915_READ(_FPB0); |
| 324 | dev_priv->regfile.saveFPB1 = I915_READ(_FPB1); |
| 325 | dev_priv->regfile.saveDPLL_B = I915_READ(_DPLL_B); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 326 | } |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 327 | if (INTEL_INFO(dev)->gen >= 4 && !HAS_PCH_SPLIT(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 328 | dev_priv->regfile.saveDPLL_B_MD = I915_READ(_DPLL_B_MD); |
| 329 | dev_priv->regfile.saveHTOTAL_B = I915_READ(_HTOTAL_B); |
| 330 | dev_priv->regfile.saveHBLANK_B = I915_READ(_HBLANK_B); |
| 331 | dev_priv->regfile.saveHSYNC_B = I915_READ(_HSYNC_B); |
| 332 | dev_priv->regfile.saveVTOTAL_B = I915_READ(_VTOTAL_B); |
| 333 | dev_priv->regfile.saveVBLANK_B = I915_READ(_VBLANK_B); |
| 334 | dev_priv->regfile.saveVSYNC_B = I915_READ(_VSYNC_B); |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 335 | if (!HAS_PCH_SPLIT(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 336 | dev_priv->regfile.saveBCLRPAT_B = I915_READ(_BCLRPAT_B); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 337 | |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 338 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 339 | dev_priv->regfile.savePIPEB_DATA_M1 = I915_READ(_PIPEB_DATA_M1); |
| 340 | dev_priv->regfile.savePIPEB_DATA_N1 = I915_READ(_PIPEB_DATA_N1); |
| 341 | dev_priv->regfile.savePIPEB_LINK_M1 = I915_READ(_PIPEB_LINK_M1); |
| 342 | dev_priv->regfile.savePIPEB_LINK_N1 = I915_READ(_PIPEB_LINK_N1); |
Zhenyu Wang | 5586c8b | 2009-11-06 02:13:02 +0000 | [diff] [blame] | 343 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 344 | dev_priv->regfile.saveFDI_TXB_CTL = I915_READ(_FDI_TXB_CTL); |
| 345 | dev_priv->regfile.saveFDI_RXB_CTL = I915_READ(_FDI_RXB_CTL); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 346 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 347 | dev_priv->regfile.savePFB_CTL_1 = I915_READ(_PFB_CTL_1); |
| 348 | dev_priv->regfile.savePFB_WIN_SZ = I915_READ(_PFB_WIN_SZ); |
| 349 | dev_priv->regfile.savePFB_WIN_POS = I915_READ(_PFB_WIN_POS); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 350 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 351 | dev_priv->regfile.saveTRANSBCONF = I915_READ(_TRANSBCONF); |
| 352 | dev_priv->regfile.saveTRANS_HTOTAL_B = I915_READ(_TRANS_HTOTAL_B); |
| 353 | dev_priv->regfile.saveTRANS_HBLANK_B = I915_READ(_TRANS_HBLANK_B); |
| 354 | dev_priv->regfile.saveTRANS_HSYNC_B = I915_READ(_TRANS_HSYNC_B); |
| 355 | dev_priv->regfile.saveTRANS_VTOTAL_B = I915_READ(_TRANS_VTOTAL_B); |
| 356 | dev_priv->regfile.saveTRANS_VBLANK_B = I915_READ(_TRANS_VBLANK_B); |
| 357 | dev_priv->regfile.saveTRANS_VSYNC_B = I915_READ(_TRANS_VSYNC_B); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 358 | } |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 359 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 360 | dev_priv->regfile.saveDSPBCNTR = I915_READ(_DSPBCNTR); |
| 361 | dev_priv->regfile.saveDSPBSTRIDE = I915_READ(_DSPBSTRIDE); |
| 362 | dev_priv->regfile.saveDSPBSIZE = I915_READ(_DSPBSIZE); |
| 363 | dev_priv->regfile.saveDSPBPOS = I915_READ(_DSPBPOS); |
| 364 | dev_priv->regfile.saveDSPBADDR = I915_READ(_DSPBADDR); |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 365 | if (INTEL_INFO(dev)->gen >= 4) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 366 | dev_priv->regfile.saveDSPBSURF = I915_READ(_DSPBSURF); |
| 367 | dev_priv->regfile.saveDSPBTILEOFF = I915_READ(_DSPBTILEOFF); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 368 | } |
| 369 | i915_save_palette(dev, PIPE_B); |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 370 | dev_priv->regfile.savePIPEBSTAT = I915_READ(_PIPEBSTAT); |
Chris Wilson | 312817a | 2010-11-22 11:50:11 +0000 | [diff] [blame] | 371 | |
| 372 | /* Fences */ |
| 373 | switch (INTEL_INFO(dev)->gen) { |
Daniel Vetter | 775d17b | 2011-10-09 21:52:01 +0200 | [diff] [blame] | 374 | case 7: |
Chris Wilson | 312817a | 2010-11-22 11:50:11 +0000 | [diff] [blame] | 375 | case 6: |
| 376 | for (i = 0; i < 16; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 377 | dev_priv->regfile.saveFENCE[i] = I915_READ64(FENCE_REG_SANDYBRIDGE_0 + (i * 8)); |
Chris Wilson | 312817a | 2010-11-22 11:50:11 +0000 | [diff] [blame] | 378 | break; |
| 379 | case 5: |
| 380 | case 4: |
| 381 | for (i = 0; i < 16; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 382 | dev_priv->regfile.saveFENCE[i] = I915_READ64(FENCE_REG_965_0 + (i * 8)); |
Chris Wilson | 312817a | 2010-11-22 11:50:11 +0000 | [diff] [blame] | 383 | break; |
| 384 | case 3: |
| 385 | if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev)) |
| 386 | for (i = 0; i < 8; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 387 | dev_priv->regfile.saveFENCE[i+8] = I915_READ(FENCE_REG_945_8 + (i * 4)); |
Chris Wilson | 312817a | 2010-11-22 11:50:11 +0000 | [diff] [blame] | 388 | case 2: |
| 389 | for (i = 0; i < 8; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 390 | dev_priv->regfile.saveFENCE[i] = I915_READ(FENCE_REG_830_0 + (i * 4)); |
Chris Wilson | 312817a | 2010-11-22 11:50:11 +0000 | [diff] [blame] | 391 | break; |
| 392 | } |
| 393 | |
Daniel Vetter | 7fdd74a | 2012-10-11 20:08:25 +0200 | [diff] [blame] | 394 | /* CRT state */ |
| 395 | if (HAS_PCH_SPLIT(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 396 | dev_priv->regfile.saveADPA = I915_READ(PCH_ADPA); |
Daniel Vetter | 7fdd74a | 2012-10-11 20:08:25 +0200 | [diff] [blame] | 397 | else |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 398 | dev_priv->regfile.saveADPA = I915_READ(ADPA); |
Daniel Vetter | 7fdd74a | 2012-10-11 20:08:25 +0200 | [diff] [blame] | 399 | |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 400 | return; |
| 401 | } |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 402 | |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 403 | static void i915_restore_modeset_reg(struct drm_device *dev) |
| 404 | { |
| 405 | struct drm_i915_private *dev_priv = dev->dev_private; |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 406 | int dpll_a_reg, fpa0_reg, fpa1_reg; |
| 407 | int dpll_b_reg, fpb0_reg, fpb1_reg; |
Chris Wilson | 312817a | 2010-11-22 11:50:11 +0000 | [diff] [blame] | 408 | int i; |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 409 | |
Daniel Vetter | 2e9723a | 2013-01-25 17:53:19 +0100 | [diff] [blame^] | 410 | /* Display port ratios (must be done before clock is set) */ |
| 411 | if (SUPPORTS_INTEGRATED_DP(dev)) { |
| 412 | I915_WRITE(_PIPEA_GMCH_DATA_M, dev_priv->regfile.savePIPEA_GMCH_DATA_M); |
| 413 | I915_WRITE(_PIPEB_GMCH_DATA_M, dev_priv->regfile.savePIPEB_GMCH_DATA_M); |
| 414 | I915_WRITE(_PIPEA_GMCH_DATA_N, dev_priv->regfile.savePIPEA_GMCH_DATA_N); |
| 415 | I915_WRITE(_PIPEB_GMCH_DATA_N, dev_priv->regfile.savePIPEB_GMCH_DATA_N); |
| 416 | I915_WRITE(_PIPEA_DP_LINK_M, dev_priv->regfile.savePIPEA_DP_LINK_M); |
| 417 | I915_WRITE(_PIPEB_DP_LINK_M, dev_priv->regfile.savePIPEB_DP_LINK_M); |
| 418 | I915_WRITE(_PIPEA_DP_LINK_N, dev_priv->regfile.savePIPEA_DP_LINK_N); |
| 419 | I915_WRITE(_PIPEB_DP_LINK_N, dev_priv->regfile.savePIPEB_DP_LINK_N); |
| 420 | } |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 421 | |
Chris Wilson | 312817a | 2010-11-22 11:50:11 +0000 | [diff] [blame] | 422 | /* Fences */ |
| 423 | switch (INTEL_INFO(dev)->gen) { |
Daniel Vetter | 775d17b | 2011-10-09 21:52:01 +0200 | [diff] [blame] | 424 | case 7: |
Chris Wilson | 312817a | 2010-11-22 11:50:11 +0000 | [diff] [blame] | 425 | case 6: |
| 426 | for (i = 0; i < 16; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 427 | I915_WRITE64(FENCE_REG_SANDYBRIDGE_0 + (i * 8), dev_priv->regfile.saveFENCE[i]); |
Chris Wilson | 312817a | 2010-11-22 11:50:11 +0000 | [diff] [blame] | 428 | break; |
| 429 | case 5: |
| 430 | case 4: |
| 431 | for (i = 0; i < 16; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 432 | I915_WRITE64(FENCE_REG_965_0 + (i * 8), dev_priv->regfile.saveFENCE[i]); |
Chris Wilson | 312817a | 2010-11-22 11:50:11 +0000 | [diff] [blame] | 433 | break; |
| 434 | case 3: |
| 435 | case 2: |
| 436 | if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev)) |
| 437 | for (i = 0; i < 8; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 438 | I915_WRITE(FENCE_REG_945_8 + (i * 4), dev_priv->regfile.saveFENCE[i+8]); |
Chris Wilson | 312817a | 2010-11-22 11:50:11 +0000 | [diff] [blame] | 439 | for (i = 0; i < 8; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 440 | I915_WRITE(FENCE_REG_830_0 + (i * 4), dev_priv->regfile.saveFENCE[i]); |
Chris Wilson | 312817a | 2010-11-22 11:50:11 +0000 | [diff] [blame] | 441 | break; |
| 442 | } |
| 443 | |
| 444 | |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 445 | if (HAS_PCH_SPLIT(dev)) { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 446 | dpll_a_reg = _PCH_DPLL_A; |
| 447 | dpll_b_reg = _PCH_DPLL_B; |
| 448 | fpa0_reg = _PCH_FPA0; |
| 449 | fpb0_reg = _PCH_FPB0; |
| 450 | fpa1_reg = _PCH_FPA1; |
| 451 | fpb1_reg = _PCH_FPB1; |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 452 | } else { |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 453 | dpll_a_reg = _DPLL_A; |
| 454 | dpll_b_reg = _DPLL_B; |
| 455 | fpa0_reg = _FPA0; |
| 456 | fpb0_reg = _FPB0; |
| 457 | fpa1_reg = _FPA1; |
| 458 | fpb1_reg = _FPB1; |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 459 | } |
| 460 | |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 461 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 462 | I915_WRITE(PCH_DREF_CONTROL, dev_priv->regfile.savePCH_DREF_CONTROL); |
| 463 | I915_WRITE(DISP_ARB_CTL, dev_priv->regfile.saveDISP_ARB_CTL); |
Zhenyu Wang | 5586c8b | 2009-11-06 02:13:02 +0000 | [diff] [blame] | 464 | } |
| 465 | |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 466 | /* Pipe & plane A info */ |
| 467 | /* Prime the clock */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 468 | if (dev_priv->regfile.saveDPLL_A & DPLL_VCO_ENABLE) { |
| 469 | I915_WRITE(dpll_a_reg, dev_priv->regfile.saveDPLL_A & |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 470 | ~DPLL_VCO_ENABLE); |
Chris Wilson | 72bcb26 | 2010-08-14 14:41:22 +0100 | [diff] [blame] | 471 | POSTING_READ(dpll_a_reg); |
| 472 | udelay(150); |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 473 | } |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 474 | I915_WRITE(fpa0_reg, dev_priv->regfile.saveFPA0); |
| 475 | I915_WRITE(fpa1_reg, dev_priv->regfile.saveFPA1); |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 476 | /* Actually enable it */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 477 | I915_WRITE(dpll_a_reg, dev_priv->regfile.saveDPLL_A); |
Chris Wilson | 72bcb26 | 2010-08-14 14:41:22 +0100 | [diff] [blame] | 478 | POSTING_READ(dpll_a_reg); |
| 479 | udelay(150); |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 480 | if (INTEL_INFO(dev)->gen >= 4 && !HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 481 | I915_WRITE(_DPLL_A_MD, dev_priv->regfile.saveDPLL_A_MD); |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 482 | POSTING_READ(_DPLL_A_MD); |
Chris Wilson | 72bcb26 | 2010-08-14 14:41:22 +0100 | [diff] [blame] | 483 | } |
| 484 | udelay(150); |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 485 | |
| 486 | /* Restore mode */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 487 | I915_WRITE(_HTOTAL_A, dev_priv->regfile.saveHTOTAL_A); |
| 488 | I915_WRITE(_HBLANK_A, dev_priv->regfile.saveHBLANK_A); |
| 489 | I915_WRITE(_HSYNC_A, dev_priv->regfile.saveHSYNC_A); |
| 490 | I915_WRITE(_VTOTAL_A, dev_priv->regfile.saveVTOTAL_A); |
| 491 | I915_WRITE(_VBLANK_A, dev_priv->regfile.saveVBLANK_A); |
| 492 | I915_WRITE(_VSYNC_A, dev_priv->regfile.saveVSYNC_A); |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 493 | if (!HAS_PCH_SPLIT(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 494 | I915_WRITE(_BCLRPAT_A, dev_priv->regfile.saveBCLRPAT_A); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 495 | |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 496 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 497 | I915_WRITE(_PIPEA_DATA_M1, dev_priv->regfile.savePIPEA_DATA_M1); |
| 498 | I915_WRITE(_PIPEA_DATA_N1, dev_priv->regfile.savePIPEA_DATA_N1); |
| 499 | I915_WRITE(_PIPEA_LINK_M1, dev_priv->regfile.savePIPEA_LINK_M1); |
| 500 | I915_WRITE(_PIPEA_LINK_N1, dev_priv->regfile.savePIPEA_LINK_N1); |
Zhenyu Wang | 5586c8b | 2009-11-06 02:13:02 +0000 | [diff] [blame] | 501 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 502 | I915_WRITE(_FDI_RXA_CTL, dev_priv->regfile.saveFDI_RXA_CTL); |
| 503 | I915_WRITE(_FDI_TXA_CTL, dev_priv->regfile.saveFDI_TXA_CTL); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 504 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 505 | I915_WRITE(_PFA_CTL_1, dev_priv->regfile.savePFA_CTL_1); |
| 506 | I915_WRITE(_PFA_WIN_SZ, dev_priv->regfile.savePFA_WIN_SZ); |
| 507 | I915_WRITE(_PFA_WIN_POS, dev_priv->regfile.savePFA_WIN_POS); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 508 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 509 | I915_WRITE(_TRANSACONF, dev_priv->regfile.saveTRANSACONF); |
| 510 | I915_WRITE(_TRANS_HTOTAL_A, dev_priv->regfile.saveTRANS_HTOTAL_A); |
| 511 | I915_WRITE(_TRANS_HBLANK_A, dev_priv->regfile.saveTRANS_HBLANK_A); |
| 512 | I915_WRITE(_TRANS_HSYNC_A, dev_priv->regfile.saveTRANS_HSYNC_A); |
| 513 | I915_WRITE(_TRANS_VTOTAL_A, dev_priv->regfile.saveTRANS_VTOTAL_A); |
| 514 | I915_WRITE(_TRANS_VBLANK_A, dev_priv->regfile.saveTRANS_VBLANK_A); |
| 515 | I915_WRITE(_TRANS_VSYNC_A, dev_priv->regfile.saveTRANS_VSYNC_A); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 516 | } |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 517 | |
| 518 | /* Restore plane info */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 519 | I915_WRITE(_DSPASIZE, dev_priv->regfile.saveDSPASIZE); |
| 520 | I915_WRITE(_DSPAPOS, dev_priv->regfile.saveDSPAPOS); |
| 521 | I915_WRITE(_PIPEASRC, dev_priv->regfile.savePIPEASRC); |
| 522 | I915_WRITE(_DSPAADDR, dev_priv->regfile.saveDSPAADDR); |
| 523 | I915_WRITE(_DSPASTRIDE, dev_priv->regfile.saveDSPASTRIDE); |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 524 | if (INTEL_INFO(dev)->gen >= 4) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 525 | I915_WRITE(_DSPASURF, dev_priv->regfile.saveDSPASURF); |
| 526 | I915_WRITE(_DSPATILEOFF, dev_priv->regfile.saveDSPATILEOFF); |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 527 | } |
| 528 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 529 | I915_WRITE(_PIPEACONF, dev_priv->regfile.savePIPEACONF); |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 530 | |
| 531 | i915_restore_palette(dev, PIPE_A); |
| 532 | /* Enable the plane */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 533 | I915_WRITE(_DSPACNTR, dev_priv->regfile.saveDSPACNTR); |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 534 | I915_WRITE(_DSPAADDR, I915_READ(_DSPAADDR)); |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 535 | |
| 536 | /* Pipe & plane B info */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 537 | if (dev_priv->regfile.saveDPLL_B & DPLL_VCO_ENABLE) { |
| 538 | I915_WRITE(dpll_b_reg, dev_priv->regfile.saveDPLL_B & |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 539 | ~DPLL_VCO_ENABLE); |
Chris Wilson | 72bcb26 | 2010-08-14 14:41:22 +0100 | [diff] [blame] | 540 | POSTING_READ(dpll_b_reg); |
| 541 | udelay(150); |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 542 | } |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 543 | I915_WRITE(fpb0_reg, dev_priv->regfile.saveFPB0); |
| 544 | I915_WRITE(fpb1_reg, dev_priv->regfile.saveFPB1); |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 545 | /* Actually enable it */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 546 | I915_WRITE(dpll_b_reg, dev_priv->regfile.saveDPLL_B); |
Chris Wilson | 72bcb26 | 2010-08-14 14:41:22 +0100 | [diff] [blame] | 547 | POSTING_READ(dpll_b_reg); |
| 548 | udelay(150); |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 549 | if (INTEL_INFO(dev)->gen >= 4 && !HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 550 | I915_WRITE(_DPLL_B_MD, dev_priv->regfile.saveDPLL_B_MD); |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 551 | POSTING_READ(_DPLL_B_MD); |
Chris Wilson | 72bcb26 | 2010-08-14 14:41:22 +0100 | [diff] [blame] | 552 | } |
| 553 | udelay(150); |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 554 | |
| 555 | /* Restore mode */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 556 | I915_WRITE(_HTOTAL_B, dev_priv->regfile.saveHTOTAL_B); |
| 557 | I915_WRITE(_HBLANK_B, dev_priv->regfile.saveHBLANK_B); |
| 558 | I915_WRITE(_HSYNC_B, dev_priv->regfile.saveHSYNC_B); |
| 559 | I915_WRITE(_VTOTAL_B, dev_priv->regfile.saveVTOTAL_B); |
| 560 | I915_WRITE(_VBLANK_B, dev_priv->regfile.saveVBLANK_B); |
| 561 | I915_WRITE(_VSYNC_B, dev_priv->regfile.saveVSYNC_B); |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 562 | if (!HAS_PCH_SPLIT(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 563 | I915_WRITE(_BCLRPAT_B, dev_priv->regfile.saveBCLRPAT_B); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 564 | |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 565 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 566 | I915_WRITE(_PIPEB_DATA_M1, dev_priv->regfile.savePIPEB_DATA_M1); |
| 567 | I915_WRITE(_PIPEB_DATA_N1, dev_priv->regfile.savePIPEB_DATA_N1); |
| 568 | I915_WRITE(_PIPEB_LINK_M1, dev_priv->regfile.savePIPEB_LINK_M1); |
| 569 | I915_WRITE(_PIPEB_LINK_N1, dev_priv->regfile.savePIPEB_LINK_N1); |
Zhenyu Wang | 5586c8b | 2009-11-06 02:13:02 +0000 | [diff] [blame] | 570 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 571 | I915_WRITE(_FDI_RXB_CTL, dev_priv->regfile.saveFDI_RXB_CTL); |
| 572 | I915_WRITE(_FDI_TXB_CTL, dev_priv->regfile.saveFDI_TXB_CTL); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 573 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 574 | I915_WRITE(_PFB_CTL_1, dev_priv->regfile.savePFB_CTL_1); |
| 575 | I915_WRITE(_PFB_WIN_SZ, dev_priv->regfile.savePFB_WIN_SZ); |
| 576 | I915_WRITE(_PFB_WIN_POS, dev_priv->regfile.savePFB_WIN_POS); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 577 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 578 | I915_WRITE(_TRANSBCONF, dev_priv->regfile.saveTRANSBCONF); |
| 579 | I915_WRITE(_TRANS_HTOTAL_B, dev_priv->regfile.saveTRANS_HTOTAL_B); |
| 580 | I915_WRITE(_TRANS_HBLANK_B, dev_priv->regfile.saveTRANS_HBLANK_B); |
| 581 | I915_WRITE(_TRANS_HSYNC_B, dev_priv->regfile.saveTRANS_HSYNC_B); |
| 582 | I915_WRITE(_TRANS_VTOTAL_B, dev_priv->regfile.saveTRANS_VTOTAL_B); |
| 583 | I915_WRITE(_TRANS_VBLANK_B, dev_priv->regfile.saveTRANS_VBLANK_B); |
| 584 | I915_WRITE(_TRANS_VSYNC_B, dev_priv->regfile.saveTRANS_VSYNC_B); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 585 | } |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 586 | |
| 587 | /* Restore plane info */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 588 | I915_WRITE(_DSPBSIZE, dev_priv->regfile.saveDSPBSIZE); |
| 589 | I915_WRITE(_DSPBPOS, dev_priv->regfile.saveDSPBPOS); |
| 590 | I915_WRITE(_PIPEBSRC, dev_priv->regfile.savePIPEBSRC); |
| 591 | I915_WRITE(_DSPBADDR, dev_priv->regfile.saveDSPBADDR); |
| 592 | I915_WRITE(_DSPBSTRIDE, dev_priv->regfile.saveDSPBSTRIDE); |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 593 | if (INTEL_INFO(dev)->gen >= 4) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 594 | I915_WRITE(_DSPBSURF, dev_priv->regfile.saveDSPBSURF); |
| 595 | I915_WRITE(_DSPBTILEOFF, dev_priv->regfile.saveDSPBTILEOFF); |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 596 | } |
| 597 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 598 | I915_WRITE(_PIPEBCONF, dev_priv->regfile.savePIPEBCONF); |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 599 | |
| 600 | i915_restore_palette(dev, PIPE_B); |
| 601 | /* Enable the plane */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 602 | I915_WRITE(_DSPBCNTR, dev_priv->regfile.saveDSPBCNTR); |
Jesse Barnes | 9db4a9c | 2011-02-07 12:26:52 -0800 | [diff] [blame] | 603 | I915_WRITE(_DSPBADDR, I915_READ(_DSPBADDR)); |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 604 | |
Chris Wilson | f3c91c1 | 2010-11-21 09:56:00 +0000 | [diff] [blame] | 605 | /* Cursor state */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 606 | I915_WRITE(_CURAPOS, dev_priv->regfile.saveCURAPOS); |
| 607 | I915_WRITE(_CURACNTR, dev_priv->regfile.saveCURACNTR); |
| 608 | I915_WRITE(_CURABASE, dev_priv->regfile.saveCURABASE); |
| 609 | I915_WRITE(_CURBPOS, dev_priv->regfile.saveCURBPOS); |
| 610 | I915_WRITE(_CURBCNTR, dev_priv->regfile.saveCURBCNTR); |
| 611 | I915_WRITE(_CURBBASE, dev_priv->regfile.saveCURBBASE); |
Chris Wilson | f3c91c1 | 2010-11-21 09:56:00 +0000 | [diff] [blame] | 612 | if (IS_GEN2(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 613 | I915_WRITE(CURSIZE, dev_priv->regfile.saveCURSIZE); |
Chris Wilson | f3c91c1 | 2010-11-21 09:56:00 +0000 | [diff] [blame] | 614 | |
Daniel Vetter | 7fdd74a | 2012-10-11 20:08:25 +0200 | [diff] [blame] | 615 | /* CRT state */ |
| 616 | if (HAS_PCH_SPLIT(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 617 | I915_WRITE(PCH_ADPA, dev_priv->regfile.saveADPA); |
Daniel Vetter | 7fdd74a | 2012-10-11 20:08:25 +0200 | [diff] [blame] | 618 | else |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 619 | I915_WRITE(ADPA, dev_priv->regfile.saveADPA); |
Daniel Vetter | 7fdd74a | 2012-10-11 20:08:25 +0200 | [diff] [blame] | 620 | |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 621 | return; |
| 622 | } |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 623 | |
Keith Packard | d70bed1 | 2011-06-29 00:30:34 -0700 | [diff] [blame] | 624 | static void i915_save_display(struct drm_device *dev) |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 625 | { |
| 626 | struct drm_i915_private *dev_priv = dev->dev_private; |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 627 | |
| 628 | /* Display arbitration control */ |
Paulo Zanoni | 8de0add | 2013-01-18 18:29:03 -0200 | [diff] [blame] | 629 | if (INTEL_INFO(dev)->gen <= 4) |
| 630 | dev_priv->regfile.saveDSPARB = I915_READ(DSPARB); |
Zhao Yakui | fccdaba | 2009-07-08 14:13:14 +0800 | [diff] [blame] | 631 | |
| 632 | /* This is only meaningful in non-KMS mode */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 633 | /* Don't regfile.save them in KMS mode */ |
Daniel Vetter | 2e9723a | 2013-01-25 17:53:19 +0100 | [diff] [blame^] | 634 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
| 635 | i915_save_modeset_reg(dev); |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 636 | |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 637 | /* LVDS state */ |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 638 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 639 | dev_priv->regfile.savePP_CONTROL = I915_READ(PCH_PP_CONTROL); |
| 640 | dev_priv->regfile.saveBLC_PWM_CTL = I915_READ(BLC_PWM_PCH_CTL1); |
| 641 | dev_priv->regfile.saveBLC_PWM_CTL2 = I915_READ(BLC_PWM_PCH_CTL2); |
| 642 | dev_priv->regfile.saveBLC_CPU_PWM_CTL = I915_READ(BLC_PWM_CPU_CTL); |
| 643 | dev_priv->regfile.saveBLC_CPU_PWM_CTL2 = I915_READ(BLC_PWM_CPU_CTL2); |
| 644 | dev_priv->regfile.saveLVDS = I915_READ(PCH_LVDS); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 645 | } else { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 646 | dev_priv->regfile.savePP_CONTROL = I915_READ(PP_CONTROL); |
| 647 | dev_priv->regfile.savePFIT_PGM_RATIOS = I915_READ(PFIT_PGM_RATIOS); |
| 648 | dev_priv->regfile.saveBLC_PWM_CTL = I915_READ(BLC_PWM_CTL); |
| 649 | dev_priv->regfile.saveBLC_HIST_CTL = I915_READ(BLC_HIST_CTL); |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 650 | if (INTEL_INFO(dev)->gen >= 4) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 651 | dev_priv->regfile.saveBLC_PWM_CTL2 = I915_READ(BLC_PWM_CTL2); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 652 | if (IS_MOBILE(dev) && !IS_I830(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 653 | dev_priv->regfile.saveLVDS = I915_READ(LVDS); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 654 | } |
| 655 | |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 656 | if (!IS_I830(dev) && !IS_845G(dev) && !HAS_PCH_SPLIT(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 657 | dev_priv->regfile.savePFIT_CONTROL = I915_READ(PFIT_CONTROL); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 658 | |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 659 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 660 | dev_priv->regfile.savePP_ON_DELAYS = I915_READ(PCH_PP_ON_DELAYS); |
| 661 | dev_priv->regfile.savePP_OFF_DELAYS = I915_READ(PCH_PP_OFF_DELAYS); |
| 662 | dev_priv->regfile.savePP_DIVISOR = I915_READ(PCH_PP_DIVISOR); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 663 | } else { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 664 | dev_priv->regfile.savePP_ON_DELAYS = I915_READ(PP_ON_DELAYS); |
| 665 | dev_priv->regfile.savePP_OFF_DELAYS = I915_READ(PP_OFF_DELAYS); |
| 666 | dev_priv->regfile.savePP_DIVISOR = I915_READ(PP_DIVISOR); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 667 | } |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 668 | |
Daniel Vetter | f81183f | 2012-10-17 11:32:55 +0200 | [diff] [blame] | 669 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) { |
| 670 | /* Display Port state */ |
| 671 | if (SUPPORTS_INTEGRATED_DP(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 672 | dev_priv->regfile.saveDP_B = I915_READ(DP_B); |
| 673 | dev_priv->regfile.saveDP_C = I915_READ(DP_C); |
| 674 | dev_priv->regfile.saveDP_D = I915_READ(DP_D); |
| 675 | dev_priv->regfile.savePIPEA_GMCH_DATA_M = I915_READ(_PIPEA_GMCH_DATA_M); |
| 676 | dev_priv->regfile.savePIPEB_GMCH_DATA_M = I915_READ(_PIPEB_GMCH_DATA_M); |
| 677 | dev_priv->regfile.savePIPEA_GMCH_DATA_N = I915_READ(_PIPEA_GMCH_DATA_N); |
| 678 | dev_priv->regfile.savePIPEB_GMCH_DATA_N = I915_READ(_PIPEB_GMCH_DATA_N); |
| 679 | dev_priv->regfile.savePIPEA_DP_LINK_M = I915_READ(_PIPEA_DP_LINK_M); |
| 680 | dev_priv->regfile.savePIPEB_DP_LINK_M = I915_READ(_PIPEB_DP_LINK_M); |
| 681 | dev_priv->regfile.savePIPEA_DP_LINK_N = I915_READ(_PIPEA_DP_LINK_N); |
| 682 | dev_priv->regfile.savePIPEB_DP_LINK_N = I915_READ(_PIPEB_DP_LINK_N); |
Daniel Vetter | f81183f | 2012-10-17 11:32:55 +0200 | [diff] [blame] | 683 | } |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 684 | /* FIXME: regfile.save TV & SDVO state */ |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 685 | } |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 686 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 687 | /* Only regfile.save FBC state on the platform that supports FBC */ |
Zhao Yakui | a2c459e | 2010-03-19 17:05:10 +0800 | [diff] [blame] | 688 | if (I915_HAS_FBC(dev)) { |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 689 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 690 | dev_priv->regfile.saveDPFC_CB_BASE = I915_READ(ILK_DPFC_CB_BASE); |
Zhao Yakui | b52eb4d | 2010-06-12 14:32:27 +0800 | [diff] [blame] | 691 | } else if (IS_GM45(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 692 | dev_priv->regfile.saveDPFC_CB_BASE = I915_READ(DPFC_CB_BASE); |
Zhao Yakui | a2c459e | 2010-03-19 17:05:10 +0800 | [diff] [blame] | 693 | } else { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 694 | dev_priv->regfile.saveFBC_CFB_BASE = I915_READ(FBC_CFB_BASE); |
| 695 | dev_priv->regfile.saveFBC_LL_BASE = I915_READ(FBC_LL_BASE); |
| 696 | dev_priv->regfile.saveFBC_CONTROL2 = I915_READ(FBC_CONTROL2); |
| 697 | dev_priv->regfile.saveFBC_CONTROL = I915_READ(FBC_CONTROL); |
Zhao Yakui | a2c459e | 2010-03-19 17:05:10 +0800 | [diff] [blame] | 698 | } |
Jesse Barnes | 06027f9 | 2009-10-05 13:47:26 -0700 | [diff] [blame] | 699 | } |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 700 | |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 701 | /* VGA state */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 702 | dev_priv->regfile.saveVGA0 = I915_READ(VGA0); |
| 703 | dev_priv->regfile.saveVGA1 = I915_READ(VGA1); |
| 704 | dev_priv->regfile.saveVGA_PD = I915_READ(VGA_PD); |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 705 | if (HAS_PCH_SPLIT(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 706 | dev_priv->regfile.saveVGACNTRL = I915_READ(CPU_VGACNTRL); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 707 | else |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 708 | dev_priv->regfile.saveVGACNTRL = I915_READ(VGACNTRL); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 709 | |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 710 | i915_save_vga(dev); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 711 | } |
| 712 | |
Keith Packard | d70bed1 | 2011-06-29 00:30:34 -0700 | [diff] [blame] | 713 | static void i915_restore_display(struct drm_device *dev) |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 714 | { |
| 715 | struct drm_i915_private *dev_priv = dev->dev_private; |
Peng Li | 461cba2 | 2008-11-18 12:39:02 +0800 | [diff] [blame] | 716 | |
Keith Packard | 881ee98 | 2008-11-02 23:08:44 -0800 | [diff] [blame] | 717 | /* Display arbitration */ |
Paulo Zanoni | 8de0add | 2013-01-18 18:29:03 -0200 | [diff] [blame] | 718 | if (INTEL_INFO(dev)->gen <= 4) |
| 719 | I915_WRITE(DSPARB, dev_priv->regfile.saveDSPARB); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 720 | |
Daniel Vetter | 2e9723a | 2013-01-25 17:53:19 +0100 | [diff] [blame^] | 721 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
| 722 | i915_restore_modeset_reg(dev); |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 723 | |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 724 | /* LVDS state */ |
Chris Wilson | a6c45cf | 2010-09-17 00:32:17 +0100 | [diff] [blame] | 725 | if (INTEL_INFO(dev)->gen >= 4 && !HAS_PCH_SPLIT(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 726 | I915_WRITE(BLC_PWM_CTL2, dev_priv->regfile.saveBLC_PWM_CTL2); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 727 | |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 728 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 729 | I915_WRITE(PCH_LVDS, dev_priv->regfile.saveLVDS); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 730 | } else if (IS_MOBILE(dev) && !IS_I830(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 731 | I915_WRITE(LVDS, dev_priv->regfile.saveLVDS); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 732 | |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 733 | if (!IS_I830(dev) && !IS_845G(dev) && !HAS_PCH_SPLIT(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 734 | I915_WRITE(PFIT_CONTROL, dev_priv->regfile.savePFIT_CONTROL); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 735 | |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 736 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 737 | I915_WRITE(BLC_PWM_PCH_CTL1, dev_priv->regfile.saveBLC_PWM_CTL); |
| 738 | I915_WRITE(BLC_PWM_PCH_CTL2, dev_priv->regfile.saveBLC_PWM_CTL2); |
Takashi Iwai | 6db65cb | 2012-06-21 15:30:41 +0200 | [diff] [blame] | 739 | /* NOTE: BLC_PWM_CPU_CTL must be written after BLC_PWM_CPU_CTL2; |
| 740 | * otherwise we get blank eDP screen after S3 on some machines |
| 741 | */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 742 | I915_WRITE(BLC_PWM_CPU_CTL2, dev_priv->regfile.saveBLC_CPU_PWM_CTL2); |
| 743 | I915_WRITE(BLC_PWM_CPU_CTL, dev_priv->regfile.saveBLC_CPU_PWM_CTL); |
| 744 | I915_WRITE(PCH_PP_ON_DELAYS, dev_priv->regfile.savePP_ON_DELAYS); |
| 745 | I915_WRITE(PCH_PP_OFF_DELAYS, dev_priv->regfile.savePP_OFF_DELAYS); |
| 746 | I915_WRITE(PCH_PP_DIVISOR, dev_priv->regfile.savePP_DIVISOR); |
| 747 | I915_WRITE(PCH_PP_CONTROL, dev_priv->regfile.savePP_CONTROL); |
Jesse Barnes | 88271da | 2011-01-05 12:01:24 -0800 | [diff] [blame] | 748 | I915_WRITE(RSTDBYCTL, |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 749 | dev_priv->regfile.saveMCHBAR_RENDER_STANDBY); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 750 | } else { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 751 | I915_WRITE(PFIT_PGM_RATIOS, dev_priv->regfile.savePFIT_PGM_RATIOS); |
| 752 | I915_WRITE(BLC_PWM_CTL, dev_priv->regfile.saveBLC_PWM_CTL); |
| 753 | I915_WRITE(BLC_HIST_CTL, dev_priv->regfile.saveBLC_HIST_CTL); |
| 754 | I915_WRITE(PP_ON_DELAYS, dev_priv->regfile.savePP_ON_DELAYS); |
| 755 | I915_WRITE(PP_OFF_DELAYS, dev_priv->regfile.savePP_OFF_DELAYS); |
| 756 | I915_WRITE(PP_DIVISOR, dev_priv->regfile.savePP_DIVISOR); |
| 757 | I915_WRITE(PP_CONTROL, dev_priv->regfile.savePP_CONTROL); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 758 | } |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 759 | |
Daniel Vetter | f81183f | 2012-10-17 11:32:55 +0200 | [diff] [blame] | 760 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) { |
| 761 | /* Display Port state */ |
| 762 | if (SUPPORTS_INTEGRATED_DP(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 763 | I915_WRITE(DP_B, dev_priv->regfile.saveDP_B); |
| 764 | I915_WRITE(DP_C, dev_priv->regfile.saveDP_C); |
| 765 | I915_WRITE(DP_D, dev_priv->regfile.saveDP_D); |
Daniel Vetter | f81183f | 2012-10-17 11:32:55 +0200 | [diff] [blame] | 766 | } |
| 767 | /* FIXME: restore TV & SDVO state */ |
Keith Packard | a4fc5ed | 2009-04-07 16:16:42 -0700 | [diff] [blame] | 768 | } |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 769 | |
Zhao Yakui | a2c459e | 2010-03-19 17:05:10 +0800 | [diff] [blame] | 770 | /* only restore FBC info on the platform that supports FBC*/ |
Chris Wilson | 43a9539 | 2011-07-08 12:22:36 +0100 | [diff] [blame] | 771 | intel_disable_fbc(dev); |
Zhao Yakui | a2c459e | 2010-03-19 17:05:10 +0800 | [diff] [blame] | 772 | if (I915_HAS_FBC(dev)) { |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 773 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 774 | I915_WRITE(ILK_DPFC_CB_BASE, dev_priv->regfile.saveDPFC_CB_BASE); |
Zhao Yakui | b52eb4d | 2010-06-12 14:32:27 +0800 | [diff] [blame] | 775 | } else if (IS_GM45(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 776 | I915_WRITE(DPFC_CB_BASE, dev_priv->regfile.saveDPFC_CB_BASE); |
Zhao Yakui | a2c459e | 2010-03-19 17:05:10 +0800 | [diff] [blame] | 777 | } else { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 778 | I915_WRITE(FBC_CFB_BASE, dev_priv->regfile.saveFBC_CFB_BASE); |
| 779 | I915_WRITE(FBC_LL_BASE, dev_priv->regfile.saveFBC_LL_BASE); |
| 780 | I915_WRITE(FBC_CONTROL2, dev_priv->regfile.saveFBC_CONTROL2); |
| 781 | I915_WRITE(FBC_CONTROL, dev_priv->regfile.saveFBC_CONTROL); |
Zhao Yakui | a2c459e | 2010-03-19 17:05:10 +0800 | [diff] [blame] | 782 | } |
Jesse Barnes | 06027f9 | 2009-10-05 13:47:26 -0700 | [diff] [blame] | 783 | } |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 784 | /* VGA state */ |
Chris Wilson | 90eb77b | 2010-08-14 14:41:23 +0100 | [diff] [blame] | 785 | if (HAS_PCH_SPLIT(dev)) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 786 | I915_WRITE(CPU_VGACNTRL, dev_priv->regfile.saveVGACNTRL); |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 787 | else |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 788 | I915_WRITE(VGACNTRL, dev_priv->regfile.saveVGACNTRL); |
Ben Widawsky | 483f179 | 2011-06-22 09:55:01 -0700 | [diff] [blame] | 789 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 790 | I915_WRITE(VGA0, dev_priv->regfile.saveVGA0); |
| 791 | I915_WRITE(VGA1, dev_priv->regfile.saveVGA1); |
| 792 | I915_WRITE(VGA_PD, dev_priv->regfile.saveVGA_PD); |
Chris Wilson | 72bcb26 | 2010-08-14 14:41:22 +0100 | [diff] [blame] | 793 | POSTING_READ(VGA_PD); |
| 794 | udelay(150); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 795 | |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 796 | i915_restore_vga(dev); |
| 797 | } |
| 798 | |
| 799 | int i915_save_state(struct drm_device *dev) |
| 800 | { |
| 801 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 802 | int i; |
| 803 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 804 | pci_read_config_byte(dev->pdev, LBB, &dev_priv->regfile.saveLBB); |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 805 | |
Keith Packard | d70bed1 | 2011-06-29 00:30:34 -0700 | [diff] [blame] | 806 | mutex_lock(&dev->struct_mutex); |
| 807 | |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 808 | i915_save_display(dev); |
| 809 | |
Daniel Vetter | 905c27b | 2012-10-17 11:32:56 +0200 | [diff] [blame] | 810 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) { |
| 811 | /* Interrupt state */ |
| 812 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 813 | dev_priv->regfile.saveDEIER = I915_READ(DEIER); |
| 814 | dev_priv->regfile.saveDEIMR = I915_READ(DEIMR); |
| 815 | dev_priv->regfile.saveGTIER = I915_READ(GTIER); |
| 816 | dev_priv->regfile.saveGTIMR = I915_READ(GTIMR); |
| 817 | dev_priv->regfile.saveFDI_RXA_IMR = I915_READ(_FDI_RXA_IMR); |
| 818 | dev_priv->regfile.saveFDI_RXB_IMR = I915_READ(_FDI_RXB_IMR); |
| 819 | dev_priv->regfile.saveMCHBAR_RENDER_STANDBY = |
Daniel Vetter | 905c27b | 2012-10-17 11:32:56 +0200 | [diff] [blame] | 820 | I915_READ(RSTDBYCTL); |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 821 | dev_priv->regfile.savePCH_PORT_HOTPLUG = I915_READ(PCH_PORT_HOTPLUG); |
Daniel Vetter | 905c27b | 2012-10-17 11:32:56 +0200 | [diff] [blame] | 822 | } else { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 823 | dev_priv->regfile.saveIER = I915_READ(IER); |
| 824 | dev_priv->regfile.saveIMR = I915_READ(IMR); |
Daniel Vetter | 905c27b | 2012-10-17 11:32:56 +0200 | [diff] [blame] | 825 | } |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 826 | } |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 827 | |
Daniel Vetter | 8090c6b | 2012-06-24 16:42:32 +0200 | [diff] [blame] | 828 | intel_disable_gt_powersave(dev); |
Jesse Barnes | f97108d | 2010-01-29 11:27:07 -0800 | [diff] [blame] | 829 | |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 830 | /* Cache mode state */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 831 | dev_priv->regfile.saveCACHE_MODE_0 = I915_READ(CACHE_MODE_0); |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 832 | |
| 833 | /* Memory Arbitration state */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 834 | dev_priv->regfile.saveMI_ARB_STATE = I915_READ(MI_ARB_STATE); |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 835 | |
| 836 | /* Scratch space */ |
| 837 | for (i = 0; i < 16; i++) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 838 | dev_priv->regfile.saveSWF0[i] = I915_READ(SWF00 + (i << 2)); |
| 839 | dev_priv->regfile.saveSWF1[i] = I915_READ(SWF10 + (i << 2)); |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 840 | } |
| 841 | for (i = 0; i < 3; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 842 | dev_priv->regfile.saveSWF2[i] = I915_READ(SWF30 + (i << 2)); |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 843 | |
Keith Packard | d70bed1 | 2011-06-29 00:30:34 -0700 | [diff] [blame] | 844 | mutex_unlock(&dev->struct_mutex); |
| 845 | |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 846 | return 0; |
| 847 | } |
| 848 | |
| 849 | int i915_restore_state(struct drm_device *dev) |
| 850 | { |
| 851 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 852 | int i; |
| 853 | |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 854 | pci_write_config_byte(dev->pdev, LBB, dev_priv->regfile.saveLBB); |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 855 | |
Keith Packard | d70bed1 | 2011-06-29 00:30:34 -0700 | [diff] [blame] | 856 | mutex_lock(&dev->struct_mutex); |
| 857 | |
Ben Gamari | 1341d65 | 2009-09-14 17:48:42 -0400 | [diff] [blame] | 858 | i915_restore_display(dev); |
| 859 | |
Daniel Vetter | 905c27b | 2012-10-17 11:32:56 +0200 | [diff] [blame] | 860 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) { |
| 861 | /* Interrupt state */ |
| 862 | if (HAS_PCH_SPLIT(dev)) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 863 | I915_WRITE(DEIER, dev_priv->regfile.saveDEIER); |
| 864 | I915_WRITE(DEIMR, dev_priv->regfile.saveDEIMR); |
| 865 | I915_WRITE(GTIER, dev_priv->regfile.saveGTIER); |
| 866 | I915_WRITE(GTIMR, dev_priv->regfile.saveGTIMR); |
| 867 | I915_WRITE(_FDI_RXA_IMR, dev_priv->regfile.saveFDI_RXA_IMR); |
| 868 | I915_WRITE(_FDI_RXB_IMR, dev_priv->regfile.saveFDI_RXB_IMR); |
| 869 | I915_WRITE(PCH_PORT_HOTPLUG, dev_priv->regfile.savePCH_PORT_HOTPLUG); |
Daniel Vetter | 905c27b | 2012-10-17 11:32:56 +0200 | [diff] [blame] | 870 | } else { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 871 | I915_WRITE(IER, dev_priv->regfile.saveIER); |
| 872 | I915_WRITE(IMR, dev_priv->regfile.saveIMR); |
Daniel Vetter | 905c27b | 2012-10-17 11:32:56 +0200 | [diff] [blame] | 873 | } |
Zhenyu Wang | 4204878 | 2009-10-21 15:27:01 +0800 | [diff] [blame] | 874 | } |
Keith Packard | d70bed1 | 2011-06-29 00:30:34 -0700 | [diff] [blame] | 875 | |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 876 | /* Cache mode state */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 877 | I915_WRITE(CACHE_MODE_0, dev_priv->regfile.saveCACHE_MODE_0 | 0xffff0000); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 878 | |
| 879 | /* Memory arbitration state */ |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 880 | I915_WRITE(MI_ARB_STATE, dev_priv->regfile.saveMI_ARB_STATE | 0xffff0000); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 881 | |
| 882 | for (i = 0; i < 16; i++) { |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 883 | I915_WRITE(SWF00 + (i << 2), dev_priv->regfile.saveSWF0[i]); |
| 884 | I915_WRITE(SWF10 + (i << 2), dev_priv->regfile.saveSWF1[i]); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 885 | } |
| 886 | for (i = 0; i < 3; i++) |
Daniel Vetter | f4c956a | 2012-11-02 19:55:02 +0100 | [diff] [blame] | 887 | I915_WRITE(SWF30 + (i << 2), dev_priv->regfile.saveSWF2[i]); |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 888 | |
Keith Packard | d70bed1 | 2011-06-29 00:30:34 -0700 | [diff] [blame] | 889 | mutex_unlock(&dev->struct_mutex); |
| 890 | |
Chris Wilson | f899fc6 | 2010-07-20 15:44:45 -0700 | [diff] [blame] | 891 | intel_i2c_reset(dev); |
Eric Anholt | f0217c4 | 2009-12-01 11:56:30 -0800 | [diff] [blame] | 892 | |
Jesse Barnes | 317c35d | 2008-08-25 15:11:06 -0700 | [diff] [blame] | 893 | return 0; |
| 894 | } |