xref: /openbmc/linux/drivers/gpu/drm/i915/i915_suspend.c (revision f97108d1d0facc7902134ebc453b226bbd4d1cdb)
1317c35d1SJesse Barnes /*
2317c35d1SJesse Barnes  *
3317c35d1SJesse Barnes  * Copyright 2008 (c) Intel Corporation
4317c35d1SJesse Barnes  *   Jesse Barnes <jbarnes@virtuousgeek.org>
5317c35d1SJesse Barnes  *
6317c35d1SJesse Barnes  * Permission is hereby granted, free of charge, to any person obtaining a
7317c35d1SJesse Barnes  * copy of this software and associated documentation files (the
8317c35d1SJesse Barnes  * "Software"), to deal in the Software without restriction, including
9317c35d1SJesse Barnes  * without limitation the rights to use, copy, modify, merge, publish,
10317c35d1SJesse Barnes  * distribute, sub license, and/or sell copies of the Software, and to
11317c35d1SJesse Barnes  * permit persons to whom the Software is furnished to do so, subject to
12317c35d1SJesse Barnes  * the following conditions:
13317c35d1SJesse Barnes  *
14317c35d1SJesse Barnes  * The above copyright notice and this permission notice (including the
15317c35d1SJesse Barnes  * next paragraph) shall be included in all copies or substantial portions
16317c35d1SJesse Barnes  * of the Software.
17317c35d1SJesse Barnes  *
18317c35d1SJesse Barnes  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19317c35d1SJesse Barnes  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20317c35d1SJesse Barnes  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21317c35d1SJesse Barnes  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22317c35d1SJesse Barnes  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23317c35d1SJesse Barnes  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24317c35d1SJesse Barnes  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25317c35d1SJesse Barnes  */
26317c35d1SJesse Barnes 
27317c35d1SJesse Barnes #include "drmP.h"
28317c35d1SJesse Barnes #include "drm.h"
29317c35d1SJesse Barnes #include "i915_drm.h"
30f0217c42SEric Anholt #include "intel_drv.h"
31317c35d1SJesse Barnes 
32317c35d1SJesse Barnes static bool i915_pipe_enabled(struct drm_device *dev, enum pipe pipe)
33317c35d1SJesse Barnes {
34317c35d1SJesse Barnes 	struct drm_i915_private *dev_priv = dev->dev_private;
3542048781SZhenyu Wang 	u32	dpll_reg;
36317c35d1SJesse Barnes 
37f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
3842048781SZhenyu Wang 		dpll_reg = (pipe == PIPE_A) ? PCH_DPLL_A: PCH_DPLL_B;
3942048781SZhenyu Wang 	} else {
4042048781SZhenyu Wang 		dpll_reg = (pipe == PIPE_A) ? DPLL_A: DPLL_B;
4142048781SZhenyu Wang 	}
4242048781SZhenyu Wang 
4342048781SZhenyu Wang 	return (I915_READ(dpll_reg) & DPLL_VCO_ENABLE);
44317c35d1SJesse Barnes }
45317c35d1SJesse Barnes 
46317c35d1SJesse Barnes static void i915_save_palette(struct drm_device *dev, enum pipe pipe)
47317c35d1SJesse Barnes {
48317c35d1SJesse Barnes 	struct drm_i915_private *dev_priv = dev->dev_private;
49317c35d1SJesse Barnes 	unsigned long reg = (pipe == PIPE_A ? PALETTE_A : PALETTE_B);
50317c35d1SJesse Barnes 	u32 *array;
51317c35d1SJesse Barnes 	int i;
52317c35d1SJesse Barnes 
53317c35d1SJesse Barnes 	if (!i915_pipe_enabled(dev, pipe))
54317c35d1SJesse Barnes 		return;
55317c35d1SJesse Barnes 
56f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev))
5742048781SZhenyu Wang 		reg = (pipe == PIPE_A) ? LGC_PALETTE_A : LGC_PALETTE_B;
5842048781SZhenyu Wang 
59317c35d1SJesse Barnes 	if (pipe == PIPE_A)
60317c35d1SJesse Barnes 		array = dev_priv->save_palette_a;
61317c35d1SJesse Barnes 	else
62317c35d1SJesse Barnes 		array = dev_priv->save_palette_b;
63317c35d1SJesse Barnes 
64317c35d1SJesse Barnes 	for(i = 0; i < 256; i++)
65317c35d1SJesse Barnes 		array[i] = I915_READ(reg + (i << 2));
66317c35d1SJesse Barnes }
67317c35d1SJesse Barnes 
68317c35d1SJesse Barnes static void i915_restore_palette(struct drm_device *dev, enum pipe pipe)
69317c35d1SJesse Barnes {
70317c35d1SJesse Barnes 	struct drm_i915_private *dev_priv = dev->dev_private;
71317c35d1SJesse Barnes 	unsigned long reg = (pipe == PIPE_A ? PALETTE_A : PALETTE_B);
72317c35d1SJesse Barnes 	u32 *array;
73317c35d1SJesse Barnes 	int i;
74317c35d1SJesse Barnes 
75317c35d1SJesse Barnes 	if (!i915_pipe_enabled(dev, pipe))
76317c35d1SJesse Barnes 		return;
77317c35d1SJesse Barnes 
78f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev))
7942048781SZhenyu Wang 		reg = (pipe == PIPE_A) ? LGC_PALETTE_A : LGC_PALETTE_B;
8042048781SZhenyu Wang 
81317c35d1SJesse Barnes 	if (pipe == PIPE_A)
82317c35d1SJesse Barnes 		array = dev_priv->save_palette_a;
83317c35d1SJesse Barnes 	else
84317c35d1SJesse Barnes 		array = dev_priv->save_palette_b;
85317c35d1SJesse Barnes 
86317c35d1SJesse Barnes 	for(i = 0; i < 256; i++)
87317c35d1SJesse Barnes 		I915_WRITE(reg + (i << 2), array[i]);
88317c35d1SJesse Barnes }
89317c35d1SJesse Barnes 
90317c35d1SJesse Barnes static u8 i915_read_indexed(struct drm_device *dev, u16 index_port, u16 data_port, u8 reg)
91317c35d1SJesse Barnes {
92317c35d1SJesse Barnes 	struct drm_i915_private *dev_priv = dev->dev_private;
93317c35d1SJesse Barnes 
94317c35d1SJesse Barnes 	I915_WRITE8(index_port, reg);
95317c35d1SJesse Barnes 	return I915_READ8(data_port);
96317c35d1SJesse Barnes }
97317c35d1SJesse Barnes 
98317c35d1SJesse Barnes static u8 i915_read_ar(struct drm_device *dev, u16 st01, u8 reg, u16 palette_enable)
99317c35d1SJesse Barnes {
100317c35d1SJesse Barnes 	struct drm_i915_private *dev_priv = dev->dev_private;
101317c35d1SJesse Barnes 
102317c35d1SJesse Barnes 	I915_READ8(st01);
103317c35d1SJesse Barnes 	I915_WRITE8(VGA_AR_INDEX, palette_enable | reg);
104317c35d1SJesse Barnes 	return I915_READ8(VGA_AR_DATA_READ);
105317c35d1SJesse Barnes }
106317c35d1SJesse Barnes 
107317c35d1SJesse Barnes static void i915_write_ar(struct drm_device *dev, u16 st01, u8 reg, u8 val, u16 palette_enable)
108317c35d1SJesse Barnes {
109317c35d1SJesse Barnes 	struct drm_i915_private *dev_priv = dev->dev_private;
110317c35d1SJesse Barnes 
111317c35d1SJesse Barnes 	I915_READ8(st01);
112317c35d1SJesse Barnes 	I915_WRITE8(VGA_AR_INDEX, palette_enable | reg);
113317c35d1SJesse Barnes 	I915_WRITE8(VGA_AR_DATA_WRITE, val);
114317c35d1SJesse Barnes }
115317c35d1SJesse Barnes 
116317c35d1SJesse Barnes static void i915_write_indexed(struct drm_device *dev, u16 index_port, u16 data_port, u8 reg, u8 val)
117317c35d1SJesse Barnes {
118317c35d1SJesse Barnes 	struct drm_i915_private *dev_priv = dev->dev_private;
119317c35d1SJesse Barnes 
120317c35d1SJesse Barnes 	I915_WRITE8(index_port, reg);
121317c35d1SJesse Barnes 	I915_WRITE8(data_port, val);
122317c35d1SJesse Barnes }
123317c35d1SJesse Barnes 
124317c35d1SJesse Barnes static void i915_save_vga(struct drm_device *dev)
125317c35d1SJesse Barnes {
126317c35d1SJesse Barnes 	struct drm_i915_private *dev_priv = dev->dev_private;
127317c35d1SJesse Barnes 	int i;
128317c35d1SJesse Barnes 	u16 cr_index, cr_data, st01;
129317c35d1SJesse Barnes 
130317c35d1SJesse Barnes 	/* VGA color palette registers */
131317c35d1SJesse Barnes 	dev_priv->saveDACMASK = I915_READ8(VGA_DACMASK);
132317c35d1SJesse Barnes 
133317c35d1SJesse Barnes 	/* MSR bits */
134317c35d1SJesse Barnes 	dev_priv->saveMSR = I915_READ8(VGA_MSR_READ);
135317c35d1SJesse Barnes 	if (dev_priv->saveMSR & VGA_MSR_CGA_MODE) {
136317c35d1SJesse Barnes 		cr_index = VGA_CR_INDEX_CGA;
137317c35d1SJesse Barnes 		cr_data = VGA_CR_DATA_CGA;
138317c35d1SJesse Barnes 		st01 = VGA_ST01_CGA;
139317c35d1SJesse Barnes 	} else {
140317c35d1SJesse Barnes 		cr_index = VGA_CR_INDEX_MDA;
141317c35d1SJesse Barnes 		cr_data = VGA_CR_DATA_MDA;
142317c35d1SJesse Barnes 		st01 = VGA_ST01_MDA;
143317c35d1SJesse Barnes 	}
144317c35d1SJesse Barnes 
145317c35d1SJesse Barnes 	/* CRT controller regs */
146317c35d1SJesse Barnes 	i915_write_indexed(dev, cr_index, cr_data, 0x11,
147317c35d1SJesse Barnes 			   i915_read_indexed(dev, cr_index, cr_data, 0x11) &
148317c35d1SJesse Barnes 			   (~0x80));
149317c35d1SJesse Barnes 	for (i = 0; i <= 0x24; i++)
150317c35d1SJesse Barnes 		dev_priv->saveCR[i] =
151317c35d1SJesse Barnes 			i915_read_indexed(dev, cr_index, cr_data, i);
152317c35d1SJesse Barnes 	/* Make sure we don't turn off CR group 0 writes */
153317c35d1SJesse Barnes 	dev_priv->saveCR[0x11] &= ~0x80;
154317c35d1SJesse Barnes 
155317c35d1SJesse Barnes 	/* Attribute controller registers */
156317c35d1SJesse Barnes 	I915_READ8(st01);
157317c35d1SJesse Barnes 	dev_priv->saveAR_INDEX = I915_READ8(VGA_AR_INDEX);
158317c35d1SJesse Barnes 	for (i = 0; i <= 0x14; i++)
159317c35d1SJesse Barnes 		dev_priv->saveAR[i] = i915_read_ar(dev, st01, i, 0);
160317c35d1SJesse Barnes 	I915_READ8(st01);
161317c35d1SJesse Barnes 	I915_WRITE8(VGA_AR_INDEX, dev_priv->saveAR_INDEX);
162317c35d1SJesse Barnes 	I915_READ8(st01);
163317c35d1SJesse Barnes 
164317c35d1SJesse Barnes 	/* Graphics controller registers */
165317c35d1SJesse Barnes 	for (i = 0; i < 9; i++)
166317c35d1SJesse Barnes 		dev_priv->saveGR[i] =
167317c35d1SJesse Barnes 			i915_read_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, i);
168317c35d1SJesse Barnes 
169317c35d1SJesse Barnes 	dev_priv->saveGR[0x10] =
170317c35d1SJesse Barnes 		i915_read_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x10);
171317c35d1SJesse Barnes 	dev_priv->saveGR[0x11] =
172317c35d1SJesse Barnes 		i915_read_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x11);
173317c35d1SJesse Barnes 	dev_priv->saveGR[0x18] =
174317c35d1SJesse Barnes 		i915_read_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x18);
175317c35d1SJesse Barnes 
176317c35d1SJesse Barnes 	/* Sequencer registers */
177317c35d1SJesse Barnes 	for (i = 0; i < 8; i++)
178317c35d1SJesse Barnes 		dev_priv->saveSR[i] =
179317c35d1SJesse Barnes 			i915_read_indexed(dev, VGA_SR_INDEX, VGA_SR_DATA, i);
180317c35d1SJesse Barnes }
181317c35d1SJesse Barnes 
182317c35d1SJesse Barnes static void i915_restore_vga(struct drm_device *dev)
183317c35d1SJesse Barnes {
184317c35d1SJesse Barnes 	struct drm_i915_private *dev_priv = dev->dev_private;
185317c35d1SJesse Barnes 	int i;
186317c35d1SJesse Barnes 	u16 cr_index, cr_data, st01;
187317c35d1SJesse Barnes 
188317c35d1SJesse Barnes 	/* MSR bits */
189317c35d1SJesse Barnes 	I915_WRITE8(VGA_MSR_WRITE, dev_priv->saveMSR);
190317c35d1SJesse Barnes 	if (dev_priv->saveMSR & VGA_MSR_CGA_MODE) {
191317c35d1SJesse Barnes 		cr_index = VGA_CR_INDEX_CGA;
192317c35d1SJesse Barnes 		cr_data = VGA_CR_DATA_CGA;
193317c35d1SJesse Barnes 		st01 = VGA_ST01_CGA;
194317c35d1SJesse Barnes 	} else {
195317c35d1SJesse Barnes 		cr_index = VGA_CR_INDEX_MDA;
196317c35d1SJesse Barnes 		cr_data = VGA_CR_DATA_MDA;
197317c35d1SJesse Barnes 		st01 = VGA_ST01_MDA;
198317c35d1SJesse Barnes 	}
199317c35d1SJesse Barnes 
200317c35d1SJesse Barnes 	/* Sequencer registers, don't write SR07 */
201317c35d1SJesse Barnes 	for (i = 0; i < 7; i++)
202317c35d1SJesse Barnes 		i915_write_indexed(dev, VGA_SR_INDEX, VGA_SR_DATA, i,
203317c35d1SJesse Barnes 				   dev_priv->saveSR[i]);
204317c35d1SJesse Barnes 
205317c35d1SJesse Barnes 	/* CRT controller regs */
206317c35d1SJesse Barnes 	/* Enable CR group 0 writes */
207317c35d1SJesse Barnes 	i915_write_indexed(dev, cr_index, cr_data, 0x11, dev_priv->saveCR[0x11]);
208317c35d1SJesse Barnes 	for (i = 0; i <= 0x24; i++)
209317c35d1SJesse Barnes 		i915_write_indexed(dev, cr_index, cr_data, i, dev_priv->saveCR[i]);
210317c35d1SJesse Barnes 
211317c35d1SJesse Barnes 	/* Graphics controller regs */
212317c35d1SJesse Barnes 	for (i = 0; i < 9; i++)
213317c35d1SJesse Barnes 		i915_write_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, i,
214317c35d1SJesse Barnes 				   dev_priv->saveGR[i]);
215317c35d1SJesse Barnes 
216317c35d1SJesse Barnes 	i915_write_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x10,
217317c35d1SJesse Barnes 			   dev_priv->saveGR[0x10]);
218317c35d1SJesse Barnes 	i915_write_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x11,
219317c35d1SJesse Barnes 			   dev_priv->saveGR[0x11]);
220317c35d1SJesse Barnes 	i915_write_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x18,
221317c35d1SJesse Barnes 			   dev_priv->saveGR[0x18]);
222317c35d1SJesse Barnes 
223317c35d1SJesse Barnes 	/* Attribute controller registers */
224317c35d1SJesse Barnes 	I915_READ8(st01); /* switch back to index mode */
225317c35d1SJesse Barnes 	for (i = 0; i <= 0x14; i++)
226317c35d1SJesse Barnes 		i915_write_ar(dev, st01, i, dev_priv->saveAR[i], 0);
227317c35d1SJesse Barnes 	I915_READ8(st01); /* switch back to index mode */
228317c35d1SJesse Barnes 	I915_WRITE8(VGA_AR_INDEX, dev_priv->saveAR_INDEX | 0x20);
229317c35d1SJesse Barnes 	I915_READ8(st01);
230317c35d1SJesse Barnes 
231317c35d1SJesse Barnes 	/* VGA color palette registers */
232317c35d1SJesse Barnes 	I915_WRITE8(VGA_DACMASK, dev_priv->saveDACMASK);
233317c35d1SJesse Barnes }
234317c35d1SJesse Barnes 
235fccdaba4SZhao Yakui static void i915_save_modeset_reg(struct drm_device *dev)
236317c35d1SJesse Barnes {
237317c35d1SJesse Barnes 	struct drm_i915_private *dev_priv = dev->dev_private;
238317c35d1SJesse Barnes 
239fccdaba4SZhao Yakui 	if (drm_core_check_feature(dev, DRIVER_MODESET))
240fccdaba4SZhao Yakui 		return;
2411341d655SBen Gamari 
2423ff99164SDave Airlie 	if (IS_IRONLAKE(dev)) {
2435586c8bcSZhenyu Wang 		dev_priv->savePCH_DREF_CONTROL = I915_READ(PCH_DREF_CONTROL);
2445586c8bcSZhenyu Wang 		dev_priv->saveDISP_ARB_CTL = I915_READ(DISP_ARB_CTL);
2455586c8bcSZhenyu Wang 	}
2465586c8bcSZhenyu Wang 
247317c35d1SJesse Barnes 	/* Pipe & plane A info */
248317c35d1SJesse Barnes 	dev_priv->savePIPEACONF = I915_READ(PIPEACONF);
249317c35d1SJesse Barnes 	dev_priv->savePIPEASRC = I915_READ(PIPEASRC);
250f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
25142048781SZhenyu Wang 		dev_priv->saveFPA0 = I915_READ(PCH_FPA0);
25242048781SZhenyu Wang 		dev_priv->saveFPA1 = I915_READ(PCH_FPA1);
25342048781SZhenyu Wang 		dev_priv->saveDPLL_A = I915_READ(PCH_DPLL_A);
25442048781SZhenyu Wang 	} else {
255317c35d1SJesse Barnes 		dev_priv->saveFPA0 = I915_READ(FPA0);
256317c35d1SJesse Barnes 		dev_priv->saveFPA1 = I915_READ(FPA1);
257317c35d1SJesse Barnes 		dev_priv->saveDPLL_A = I915_READ(DPLL_A);
25842048781SZhenyu Wang 	}
259f2b115e6SAdam Jackson 	if (IS_I965G(dev) && !IS_IRONLAKE(dev))
260317c35d1SJesse Barnes 		dev_priv->saveDPLL_A_MD = I915_READ(DPLL_A_MD);
261317c35d1SJesse Barnes 	dev_priv->saveHTOTAL_A = I915_READ(HTOTAL_A);
262317c35d1SJesse Barnes 	dev_priv->saveHBLANK_A = I915_READ(HBLANK_A);
263317c35d1SJesse Barnes 	dev_priv->saveHSYNC_A = I915_READ(HSYNC_A);
264317c35d1SJesse Barnes 	dev_priv->saveVTOTAL_A = I915_READ(VTOTAL_A);
265317c35d1SJesse Barnes 	dev_priv->saveVBLANK_A = I915_READ(VBLANK_A);
266317c35d1SJesse Barnes 	dev_priv->saveVSYNC_A = I915_READ(VSYNC_A);
267f2b115e6SAdam Jackson 	if (!IS_IRONLAKE(dev))
268317c35d1SJesse Barnes 		dev_priv->saveBCLRPAT_A = I915_READ(BCLRPAT_A);
269317c35d1SJesse Barnes 
270f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
2715586c8bcSZhenyu Wang 		dev_priv->savePIPEA_DATA_M1 = I915_READ(PIPEA_DATA_M1);
2725586c8bcSZhenyu Wang 		dev_priv->savePIPEA_DATA_N1 = I915_READ(PIPEA_DATA_N1);
2735586c8bcSZhenyu Wang 		dev_priv->savePIPEA_LINK_M1 = I915_READ(PIPEA_LINK_M1);
2745586c8bcSZhenyu Wang 		dev_priv->savePIPEA_LINK_N1 = I915_READ(PIPEA_LINK_N1);
2755586c8bcSZhenyu Wang 
27642048781SZhenyu Wang 		dev_priv->saveFDI_TXA_CTL = I915_READ(FDI_TXA_CTL);
27742048781SZhenyu Wang 		dev_priv->saveFDI_RXA_CTL = I915_READ(FDI_RXA_CTL);
27842048781SZhenyu Wang 
27942048781SZhenyu Wang 		dev_priv->savePFA_CTL_1 = I915_READ(PFA_CTL_1);
28042048781SZhenyu Wang 		dev_priv->savePFA_WIN_SZ = I915_READ(PFA_WIN_SZ);
28142048781SZhenyu Wang 		dev_priv->savePFA_WIN_POS = I915_READ(PFA_WIN_POS);
28242048781SZhenyu Wang 
2835586c8bcSZhenyu Wang 		dev_priv->saveTRANSACONF = I915_READ(TRANSACONF);
28442048781SZhenyu Wang 		dev_priv->saveTRANS_HTOTAL_A = I915_READ(TRANS_HTOTAL_A);
28542048781SZhenyu Wang 		dev_priv->saveTRANS_HBLANK_A = I915_READ(TRANS_HBLANK_A);
28642048781SZhenyu Wang 		dev_priv->saveTRANS_HSYNC_A = I915_READ(TRANS_HSYNC_A);
28742048781SZhenyu Wang 		dev_priv->saveTRANS_VTOTAL_A = I915_READ(TRANS_VTOTAL_A);
28842048781SZhenyu Wang 		dev_priv->saveTRANS_VBLANK_A = I915_READ(TRANS_VBLANK_A);
28942048781SZhenyu Wang 		dev_priv->saveTRANS_VSYNC_A = I915_READ(TRANS_VSYNC_A);
29042048781SZhenyu Wang 	}
29142048781SZhenyu Wang 
292317c35d1SJesse Barnes 	dev_priv->saveDSPACNTR = I915_READ(DSPACNTR);
293317c35d1SJesse Barnes 	dev_priv->saveDSPASTRIDE = I915_READ(DSPASTRIDE);
294317c35d1SJesse Barnes 	dev_priv->saveDSPASIZE = I915_READ(DSPASIZE);
295317c35d1SJesse Barnes 	dev_priv->saveDSPAPOS = I915_READ(DSPAPOS);
296317c35d1SJesse Barnes 	dev_priv->saveDSPAADDR = I915_READ(DSPAADDR);
297317c35d1SJesse Barnes 	if (IS_I965G(dev)) {
298317c35d1SJesse Barnes 		dev_priv->saveDSPASURF = I915_READ(DSPASURF);
299317c35d1SJesse Barnes 		dev_priv->saveDSPATILEOFF = I915_READ(DSPATILEOFF);
300317c35d1SJesse Barnes 	}
301317c35d1SJesse Barnes 	i915_save_palette(dev, PIPE_A);
302317c35d1SJesse Barnes 	dev_priv->savePIPEASTAT = I915_READ(PIPEASTAT);
303317c35d1SJesse Barnes 
304317c35d1SJesse Barnes 	/* Pipe & plane B info */
305317c35d1SJesse Barnes 	dev_priv->savePIPEBCONF = I915_READ(PIPEBCONF);
306317c35d1SJesse Barnes 	dev_priv->savePIPEBSRC = I915_READ(PIPEBSRC);
307f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
30842048781SZhenyu Wang 		dev_priv->saveFPB0 = I915_READ(PCH_FPB0);
30942048781SZhenyu Wang 		dev_priv->saveFPB1 = I915_READ(PCH_FPB1);
31042048781SZhenyu Wang 		dev_priv->saveDPLL_B = I915_READ(PCH_DPLL_B);
31142048781SZhenyu Wang 	} else {
312317c35d1SJesse Barnes 		dev_priv->saveFPB0 = I915_READ(FPB0);
313317c35d1SJesse Barnes 		dev_priv->saveFPB1 = I915_READ(FPB1);
314317c35d1SJesse Barnes 		dev_priv->saveDPLL_B = I915_READ(DPLL_B);
31542048781SZhenyu Wang 	}
316f2b115e6SAdam Jackson 	if (IS_I965G(dev) && !IS_IRONLAKE(dev))
317317c35d1SJesse Barnes 		dev_priv->saveDPLL_B_MD = I915_READ(DPLL_B_MD);
318317c35d1SJesse Barnes 	dev_priv->saveHTOTAL_B = I915_READ(HTOTAL_B);
319317c35d1SJesse Barnes 	dev_priv->saveHBLANK_B = I915_READ(HBLANK_B);
320317c35d1SJesse Barnes 	dev_priv->saveHSYNC_B = I915_READ(HSYNC_B);
321317c35d1SJesse Barnes 	dev_priv->saveVTOTAL_B = I915_READ(VTOTAL_B);
322317c35d1SJesse Barnes 	dev_priv->saveVBLANK_B = I915_READ(VBLANK_B);
323317c35d1SJesse Barnes 	dev_priv->saveVSYNC_B = I915_READ(VSYNC_B);
324f2b115e6SAdam Jackson 	if (!IS_IRONLAKE(dev))
32542048781SZhenyu Wang 		dev_priv->saveBCLRPAT_B = I915_READ(BCLRPAT_B);
32642048781SZhenyu Wang 
327f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
3285586c8bcSZhenyu Wang 		dev_priv->savePIPEB_DATA_M1 = I915_READ(PIPEB_DATA_M1);
3295586c8bcSZhenyu Wang 		dev_priv->savePIPEB_DATA_N1 = I915_READ(PIPEB_DATA_N1);
3305586c8bcSZhenyu Wang 		dev_priv->savePIPEB_LINK_M1 = I915_READ(PIPEB_LINK_M1);
3315586c8bcSZhenyu Wang 		dev_priv->savePIPEB_LINK_N1 = I915_READ(PIPEB_LINK_N1);
3325586c8bcSZhenyu Wang 
33342048781SZhenyu Wang 		dev_priv->saveFDI_TXB_CTL = I915_READ(FDI_TXB_CTL);
33442048781SZhenyu Wang 		dev_priv->saveFDI_RXB_CTL = I915_READ(FDI_RXB_CTL);
33542048781SZhenyu Wang 
33642048781SZhenyu Wang 		dev_priv->savePFB_CTL_1 = I915_READ(PFB_CTL_1);
33742048781SZhenyu Wang 		dev_priv->savePFB_WIN_SZ = I915_READ(PFB_WIN_SZ);
33842048781SZhenyu Wang 		dev_priv->savePFB_WIN_POS = I915_READ(PFB_WIN_POS);
33942048781SZhenyu Wang 
3405586c8bcSZhenyu Wang 		dev_priv->saveTRANSBCONF = I915_READ(TRANSBCONF);
34142048781SZhenyu Wang 		dev_priv->saveTRANS_HTOTAL_B = I915_READ(TRANS_HTOTAL_B);
34242048781SZhenyu Wang 		dev_priv->saveTRANS_HBLANK_B = I915_READ(TRANS_HBLANK_B);
34342048781SZhenyu Wang 		dev_priv->saveTRANS_HSYNC_B = I915_READ(TRANS_HSYNC_B);
34442048781SZhenyu Wang 		dev_priv->saveTRANS_VTOTAL_B = I915_READ(TRANS_VTOTAL_B);
34542048781SZhenyu Wang 		dev_priv->saveTRANS_VBLANK_B = I915_READ(TRANS_VBLANK_B);
34642048781SZhenyu Wang 		dev_priv->saveTRANS_VSYNC_B = I915_READ(TRANS_VSYNC_B);
34742048781SZhenyu Wang 	}
348317c35d1SJesse Barnes 
349317c35d1SJesse Barnes 	dev_priv->saveDSPBCNTR = I915_READ(DSPBCNTR);
350317c35d1SJesse Barnes 	dev_priv->saveDSPBSTRIDE = I915_READ(DSPBSTRIDE);
351317c35d1SJesse Barnes 	dev_priv->saveDSPBSIZE = I915_READ(DSPBSIZE);
352317c35d1SJesse Barnes 	dev_priv->saveDSPBPOS = I915_READ(DSPBPOS);
353317c35d1SJesse Barnes 	dev_priv->saveDSPBADDR = I915_READ(DSPBADDR);
354b9bfdfe6SJesse Barnes 	if (IS_I965GM(dev) || IS_GM45(dev)) {
355317c35d1SJesse Barnes 		dev_priv->saveDSPBSURF = I915_READ(DSPBSURF);
356317c35d1SJesse Barnes 		dev_priv->saveDSPBTILEOFF = I915_READ(DSPBTILEOFF);
357317c35d1SJesse Barnes 	}
358317c35d1SJesse Barnes 	i915_save_palette(dev, PIPE_B);
359317c35d1SJesse Barnes 	dev_priv->savePIPEBSTAT = I915_READ(PIPEBSTAT);
360fccdaba4SZhao Yakui 	return;
361fccdaba4SZhao Yakui }
3621341d655SBen Gamari 
363fccdaba4SZhao Yakui static void i915_restore_modeset_reg(struct drm_device *dev)
364fccdaba4SZhao Yakui {
365fccdaba4SZhao Yakui 	struct drm_i915_private *dev_priv = dev->dev_private;
36642048781SZhenyu Wang 	int dpll_a_reg, fpa0_reg, fpa1_reg;
36742048781SZhenyu Wang 	int dpll_b_reg, fpb0_reg, fpb1_reg;
368317c35d1SJesse Barnes 
369fccdaba4SZhao Yakui 	if (drm_core_check_feature(dev, DRIVER_MODESET))
370fccdaba4SZhao Yakui 		return;
371fccdaba4SZhao Yakui 
372f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
37342048781SZhenyu Wang 		dpll_a_reg = PCH_DPLL_A;
37442048781SZhenyu Wang 		dpll_b_reg = PCH_DPLL_B;
37542048781SZhenyu Wang 		fpa0_reg = PCH_FPA0;
37642048781SZhenyu Wang 		fpb0_reg = PCH_FPB0;
37742048781SZhenyu Wang 		fpa1_reg = PCH_FPA1;
37842048781SZhenyu Wang 		fpb1_reg = PCH_FPB1;
37942048781SZhenyu Wang 	} else {
38042048781SZhenyu Wang 		dpll_a_reg = DPLL_A;
38142048781SZhenyu Wang 		dpll_b_reg = DPLL_B;
38242048781SZhenyu Wang 		fpa0_reg = FPA0;
38342048781SZhenyu Wang 		fpb0_reg = FPB0;
38442048781SZhenyu Wang 		fpa1_reg = FPA1;
38542048781SZhenyu Wang 		fpb1_reg = FPB1;
38642048781SZhenyu Wang 	}
38742048781SZhenyu Wang 
3883ff99164SDave Airlie 	if (IS_IRONLAKE(dev)) {
3895586c8bcSZhenyu Wang 		I915_WRITE(PCH_DREF_CONTROL, dev_priv->savePCH_DREF_CONTROL);
3905586c8bcSZhenyu Wang 		I915_WRITE(DISP_ARB_CTL, dev_priv->saveDISP_ARB_CTL);
3915586c8bcSZhenyu Wang 	}
3925586c8bcSZhenyu Wang 
393fccdaba4SZhao Yakui 	/* Pipe & plane A info */
394fccdaba4SZhao Yakui 	/* Prime the clock */
395fccdaba4SZhao Yakui 	if (dev_priv->saveDPLL_A & DPLL_VCO_ENABLE) {
39642048781SZhenyu Wang 		I915_WRITE(dpll_a_reg, dev_priv->saveDPLL_A &
397fccdaba4SZhao Yakui 			   ~DPLL_VCO_ENABLE);
398fccdaba4SZhao Yakui 		DRM_UDELAY(150);
399fccdaba4SZhao Yakui 	}
40042048781SZhenyu Wang 	I915_WRITE(fpa0_reg, dev_priv->saveFPA0);
40142048781SZhenyu Wang 	I915_WRITE(fpa1_reg, dev_priv->saveFPA1);
402fccdaba4SZhao Yakui 	/* Actually enable it */
40342048781SZhenyu Wang 	I915_WRITE(dpll_a_reg, dev_priv->saveDPLL_A);
404fccdaba4SZhao Yakui 	DRM_UDELAY(150);
405f2b115e6SAdam Jackson 	if (IS_I965G(dev) && !IS_IRONLAKE(dev))
406fccdaba4SZhao Yakui 		I915_WRITE(DPLL_A_MD, dev_priv->saveDPLL_A_MD);
407fccdaba4SZhao Yakui 	DRM_UDELAY(150);
408fccdaba4SZhao Yakui 
409fccdaba4SZhao Yakui 	/* Restore mode */
410fccdaba4SZhao Yakui 	I915_WRITE(HTOTAL_A, dev_priv->saveHTOTAL_A);
411fccdaba4SZhao Yakui 	I915_WRITE(HBLANK_A, dev_priv->saveHBLANK_A);
412fccdaba4SZhao Yakui 	I915_WRITE(HSYNC_A, dev_priv->saveHSYNC_A);
413fccdaba4SZhao Yakui 	I915_WRITE(VTOTAL_A, dev_priv->saveVTOTAL_A);
414fccdaba4SZhao Yakui 	I915_WRITE(VBLANK_A, dev_priv->saveVBLANK_A);
415fccdaba4SZhao Yakui 	I915_WRITE(VSYNC_A, dev_priv->saveVSYNC_A);
416f2b115e6SAdam Jackson 	if (!IS_IRONLAKE(dev))
417fccdaba4SZhao Yakui 		I915_WRITE(BCLRPAT_A, dev_priv->saveBCLRPAT_A);
418fccdaba4SZhao Yakui 
419f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
4205586c8bcSZhenyu Wang 		I915_WRITE(PIPEA_DATA_M1, dev_priv->savePIPEA_DATA_M1);
4215586c8bcSZhenyu Wang 		I915_WRITE(PIPEA_DATA_N1, dev_priv->savePIPEA_DATA_N1);
4225586c8bcSZhenyu Wang 		I915_WRITE(PIPEA_LINK_M1, dev_priv->savePIPEA_LINK_M1);
4235586c8bcSZhenyu Wang 		I915_WRITE(PIPEA_LINK_N1, dev_priv->savePIPEA_LINK_N1);
4245586c8bcSZhenyu Wang 
42542048781SZhenyu Wang 		I915_WRITE(FDI_RXA_CTL, dev_priv->saveFDI_RXA_CTL);
42642048781SZhenyu Wang 		I915_WRITE(FDI_TXA_CTL, dev_priv->saveFDI_TXA_CTL);
42742048781SZhenyu Wang 
42842048781SZhenyu Wang 		I915_WRITE(PFA_CTL_1, dev_priv->savePFA_CTL_1);
42942048781SZhenyu Wang 		I915_WRITE(PFA_WIN_SZ, dev_priv->savePFA_WIN_SZ);
43042048781SZhenyu Wang 		I915_WRITE(PFA_WIN_POS, dev_priv->savePFA_WIN_POS);
43142048781SZhenyu Wang 
4325586c8bcSZhenyu Wang 		I915_WRITE(TRANSACONF, dev_priv->saveTRANSACONF);
43342048781SZhenyu Wang 		I915_WRITE(TRANS_HTOTAL_A, dev_priv->saveTRANS_HTOTAL_A);
43442048781SZhenyu Wang 		I915_WRITE(TRANS_HBLANK_A, dev_priv->saveTRANS_HBLANK_A);
43542048781SZhenyu Wang 		I915_WRITE(TRANS_HSYNC_A, dev_priv->saveTRANS_HSYNC_A);
43642048781SZhenyu Wang 		I915_WRITE(TRANS_VTOTAL_A, dev_priv->saveTRANS_VTOTAL_A);
43742048781SZhenyu Wang 		I915_WRITE(TRANS_VBLANK_A, dev_priv->saveTRANS_VBLANK_A);
43842048781SZhenyu Wang 		I915_WRITE(TRANS_VSYNC_A, dev_priv->saveTRANS_VSYNC_A);
43942048781SZhenyu Wang 	}
44042048781SZhenyu Wang 
441fccdaba4SZhao Yakui 	/* Restore plane info */
442fccdaba4SZhao Yakui 	I915_WRITE(DSPASIZE, dev_priv->saveDSPASIZE);
443fccdaba4SZhao Yakui 	I915_WRITE(DSPAPOS, dev_priv->saveDSPAPOS);
444fccdaba4SZhao Yakui 	I915_WRITE(PIPEASRC, dev_priv->savePIPEASRC);
445fccdaba4SZhao Yakui 	I915_WRITE(DSPAADDR, dev_priv->saveDSPAADDR);
446fccdaba4SZhao Yakui 	I915_WRITE(DSPASTRIDE, dev_priv->saveDSPASTRIDE);
447fccdaba4SZhao Yakui 	if (IS_I965G(dev)) {
448fccdaba4SZhao Yakui 		I915_WRITE(DSPASURF, dev_priv->saveDSPASURF);
449fccdaba4SZhao Yakui 		I915_WRITE(DSPATILEOFF, dev_priv->saveDSPATILEOFF);
450fccdaba4SZhao Yakui 	}
451fccdaba4SZhao Yakui 
452fccdaba4SZhao Yakui 	I915_WRITE(PIPEACONF, dev_priv->savePIPEACONF);
453fccdaba4SZhao Yakui 
454fccdaba4SZhao Yakui 	i915_restore_palette(dev, PIPE_A);
455fccdaba4SZhao Yakui 	/* Enable the plane */
456fccdaba4SZhao Yakui 	I915_WRITE(DSPACNTR, dev_priv->saveDSPACNTR);
457fccdaba4SZhao Yakui 	I915_WRITE(DSPAADDR, I915_READ(DSPAADDR));
458fccdaba4SZhao Yakui 
459fccdaba4SZhao Yakui 	/* Pipe & plane B info */
460fccdaba4SZhao Yakui 	if (dev_priv->saveDPLL_B & DPLL_VCO_ENABLE) {
46142048781SZhenyu Wang 		I915_WRITE(dpll_b_reg, dev_priv->saveDPLL_B &
462fccdaba4SZhao Yakui 			   ~DPLL_VCO_ENABLE);
463fccdaba4SZhao Yakui 		DRM_UDELAY(150);
464fccdaba4SZhao Yakui 	}
46542048781SZhenyu Wang 	I915_WRITE(fpb0_reg, dev_priv->saveFPB0);
46642048781SZhenyu Wang 	I915_WRITE(fpb1_reg, dev_priv->saveFPB1);
467fccdaba4SZhao Yakui 	/* Actually enable it */
46842048781SZhenyu Wang 	I915_WRITE(dpll_b_reg, dev_priv->saveDPLL_B);
469fccdaba4SZhao Yakui 	DRM_UDELAY(150);
4703ff99164SDave Airlie 	if (IS_I965G(dev) && !IS_IRONLAKE(dev))
471fccdaba4SZhao Yakui 		I915_WRITE(DPLL_B_MD, dev_priv->saveDPLL_B_MD);
472fccdaba4SZhao Yakui 	DRM_UDELAY(150);
473fccdaba4SZhao Yakui 
474fccdaba4SZhao Yakui 	/* Restore mode */
475fccdaba4SZhao Yakui 	I915_WRITE(HTOTAL_B, dev_priv->saveHTOTAL_B);
476fccdaba4SZhao Yakui 	I915_WRITE(HBLANK_B, dev_priv->saveHBLANK_B);
477fccdaba4SZhao Yakui 	I915_WRITE(HSYNC_B, dev_priv->saveHSYNC_B);
478fccdaba4SZhao Yakui 	I915_WRITE(VTOTAL_B, dev_priv->saveVTOTAL_B);
479fccdaba4SZhao Yakui 	I915_WRITE(VBLANK_B, dev_priv->saveVBLANK_B);
480fccdaba4SZhao Yakui 	I915_WRITE(VSYNC_B, dev_priv->saveVSYNC_B);
481f2b115e6SAdam Jackson 	if (!IS_IRONLAKE(dev))
482fccdaba4SZhao Yakui 		I915_WRITE(BCLRPAT_B, dev_priv->saveBCLRPAT_B);
483fccdaba4SZhao Yakui 
484f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
4855586c8bcSZhenyu Wang 		I915_WRITE(PIPEB_DATA_M1, dev_priv->savePIPEB_DATA_M1);
4865586c8bcSZhenyu Wang 		I915_WRITE(PIPEB_DATA_N1, dev_priv->savePIPEB_DATA_N1);
4875586c8bcSZhenyu Wang 		I915_WRITE(PIPEB_LINK_M1, dev_priv->savePIPEB_LINK_M1);
4885586c8bcSZhenyu Wang 		I915_WRITE(PIPEB_LINK_N1, dev_priv->savePIPEB_LINK_N1);
4895586c8bcSZhenyu Wang 
49042048781SZhenyu Wang 		I915_WRITE(FDI_RXB_CTL, dev_priv->saveFDI_RXB_CTL);
49142048781SZhenyu Wang 		I915_WRITE(FDI_TXB_CTL, dev_priv->saveFDI_TXB_CTL);
49242048781SZhenyu Wang 
49342048781SZhenyu Wang 		I915_WRITE(PFB_CTL_1, dev_priv->savePFB_CTL_1);
49442048781SZhenyu Wang 		I915_WRITE(PFB_WIN_SZ, dev_priv->savePFB_WIN_SZ);
49542048781SZhenyu Wang 		I915_WRITE(PFB_WIN_POS, dev_priv->savePFB_WIN_POS);
49642048781SZhenyu Wang 
4975586c8bcSZhenyu Wang 		I915_WRITE(TRANSBCONF, dev_priv->saveTRANSBCONF);
49842048781SZhenyu Wang 		I915_WRITE(TRANS_HTOTAL_B, dev_priv->saveTRANS_HTOTAL_B);
49942048781SZhenyu Wang 		I915_WRITE(TRANS_HBLANK_B, dev_priv->saveTRANS_HBLANK_B);
50042048781SZhenyu Wang 		I915_WRITE(TRANS_HSYNC_B, dev_priv->saveTRANS_HSYNC_B);
50142048781SZhenyu Wang 		I915_WRITE(TRANS_VTOTAL_B, dev_priv->saveTRANS_VTOTAL_B);
50242048781SZhenyu Wang 		I915_WRITE(TRANS_VBLANK_B, dev_priv->saveTRANS_VBLANK_B);
50342048781SZhenyu Wang 		I915_WRITE(TRANS_VSYNC_B, dev_priv->saveTRANS_VSYNC_B);
50442048781SZhenyu Wang 	}
50542048781SZhenyu Wang 
506fccdaba4SZhao Yakui 	/* Restore plane info */
507fccdaba4SZhao Yakui 	I915_WRITE(DSPBSIZE, dev_priv->saveDSPBSIZE);
508fccdaba4SZhao Yakui 	I915_WRITE(DSPBPOS, dev_priv->saveDSPBPOS);
509fccdaba4SZhao Yakui 	I915_WRITE(PIPEBSRC, dev_priv->savePIPEBSRC);
510fccdaba4SZhao Yakui 	I915_WRITE(DSPBADDR, dev_priv->saveDSPBADDR);
511fccdaba4SZhao Yakui 	I915_WRITE(DSPBSTRIDE, dev_priv->saveDSPBSTRIDE);
512fccdaba4SZhao Yakui 	if (IS_I965G(dev)) {
513fccdaba4SZhao Yakui 		I915_WRITE(DSPBSURF, dev_priv->saveDSPBSURF);
514fccdaba4SZhao Yakui 		I915_WRITE(DSPBTILEOFF, dev_priv->saveDSPBTILEOFF);
515fccdaba4SZhao Yakui 	}
516fccdaba4SZhao Yakui 
517fccdaba4SZhao Yakui 	I915_WRITE(PIPEBCONF, dev_priv->savePIPEBCONF);
518fccdaba4SZhao Yakui 
519fccdaba4SZhao Yakui 	i915_restore_palette(dev, PIPE_B);
520fccdaba4SZhao Yakui 	/* Enable the plane */
521fccdaba4SZhao Yakui 	I915_WRITE(DSPBCNTR, dev_priv->saveDSPBCNTR);
522fccdaba4SZhao Yakui 	I915_WRITE(DSPBADDR, I915_READ(DSPBADDR));
523fccdaba4SZhao Yakui 
524fccdaba4SZhao Yakui 	return;
525fccdaba4SZhao Yakui }
5261341d655SBen Gamari 
5271341d655SBen Gamari void i915_save_display(struct drm_device *dev)
528fccdaba4SZhao Yakui {
529fccdaba4SZhao Yakui 	struct drm_i915_private *dev_priv = dev->dev_private;
530fccdaba4SZhao Yakui 
531fccdaba4SZhao Yakui 	/* Display arbitration control */
532fccdaba4SZhao Yakui 	dev_priv->saveDSPARB = I915_READ(DSPARB);
533fccdaba4SZhao Yakui 
534fccdaba4SZhao Yakui 	/* This is only meaningful in non-KMS mode */
535fccdaba4SZhao Yakui 	/* Don't save them in KMS mode */
536fccdaba4SZhao Yakui 	i915_save_modeset_reg(dev);
5371341d655SBen Gamari 
5381fd1c624SEric Anholt 	/* Cursor state */
5391fd1c624SEric Anholt 	dev_priv->saveCURACNTR = I915_READ(CURACNTR);
5401fd1c624SEric Anholt 	dev_priv->saveCURAPOS = I915_READ(CURAPOS);
5411fd1c624SEric Anholt 	dev_priv->saveCURABASE = I915_READ(CURABASE);
5421fd1c624SEric Anholt 	dev_priv->saveCURBCNTR = I915_READ(CURBCNTR);
5431fd1c624SEric Anholt 	dev_priv->saveCURBPOS = I915_READ(CURBPOS);
5441fd1c624SEric Anholt 	dev_priv->saveCURBBASE = I915_READ(CURBBASE);
5451fd1c624SEric Anholt 	if (!IS_I9XX(dev))
5461fd1c624SEric Anholt 		dev_priv->saveCURSIZE = I915_READ(CURSIZE);
5471fd1c624SEric Anholt 
548317c35d1SJesse Barnes 	/* CRT state */
549f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
55042048781SZhenyu Wang 		dev_priv->saveADPA = I915_READ(PCH_ADPA);
55142048781SZhenyu Wang 	} else {
552317c35d1SJesse Barnes 		dev_priv->saveADPA = I915_READ(ADPA);
55342048781SZhenyu Wang 	}
554317c35d1SJesse Barnes 
555317c35d1SJesse Barnes 	/* LVDS state */
556f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
55742048781SZhenyu Wang 		dev_priv->savePP_CONTROL = I915_READ(PCH_PP_CONTROL);
55842048781SZhenyu Wang 		dev_priv->saveBLC_PWM_CTL = I915_READ(BLC_PWM_PCH_CTL1);
55942048781SZhenyu Wang 		dev_priv->saveBLC_PWM_CTL2 = I915_READ(BLC_PWM_PCH_CTL2);
56042048781SZhenyu Wang 		dev_priv->saveBLC_CPU_PWM_CTL = I915_READ(BLC_PWM_CPU_CTL);
56142048781SZhenyu Wang 		dev_priv->saveBLC_CPU_PWM_CTL2 = I915_READ(BLC_PWM_CPU_CTL2);
56242048781SZhenyu Wang 		dev_priv->saveLVDS = I915_READ(PCH_LVDS);
56342048781SZhenyu Wang 	} else {
564317c35d1SJesse Barnes 		dev_priv->savePP_CONTROL = I915_READ(PP_CONTROL);
565317c35d1SJesse Barnes 		dev_priv->savePFIT_PGM_RATIOS = I915_READ(PFIT_PGM_RATIOS);
566317c35d1SJesse Barnes 		dev_priv->saveBLC_PWM_CTL = I915_READ(BLC_PWM_CTL);
5670eb96d6eSJesse Barnes 		dev_priv->saveBLC_HIST_CTL = I915_READ(BLC_HIST_CTL);
568317c35d1SJesse Barnes 		if (IS_I965G(dev))
569317c35d1SJesse Barnes 			dev_priv->saveBLC_PWM_CTL2 = I915_READ(BLC_PWM_CTL2);
570317c35d1SJesse Barnes 		if (IS_MOBILE(dev) && !IS_I830(dev))
571317c35d1SJesse Barnes 			dev_priv->saveLVDS = I915_READ(LVDS);
57242048781SZhenyu Wang 	}
57342048781SZhenyu Wang 
574f2b115e6SAdam Jackson 	if (!IS_I830(dev) && !IS_845G(dev) && !IS_IRONLAKE(dev))
575317c35d1SJesse Barnes 		dev_priv->savePFIT_CONTROL = I915_READ(PFIT_CONTROL);
57642048781SZhenyu Wang 
577f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
57842048781SZhenyu Wang 		dev_priv->savePP_ON_DELAYS = I915_READ(PCH_PP_ON_DELAYS);
57942048781SZhenyu Wang 		dev_priv->savePP_OFF_DELAYS = I915_READ(PCH_PP_OFF_DELAYS);
58042048781SZhenyu Wang 		dev_priv->savePP_DIVISOR = I915_READ(PCH_PP_DIVISOR);
58142048781SZhenyu Wang 	} else {
582317c35d1SJesse Barnes 		dev_priv->savePP_ON_DELAYS = I915_READ(PP_ON_DELAYS);
583317c35d1SJesse Barnes 		dev_priv->savePP_OFF_DELAYS = I915_READ(PP_OFF_DELAYS);
584317c35d1SJesse Barnes 		dev_priv->savePP_DIVISOR = I915_READ(PP_DIVISOR);
58542048781SZhenyu Wang 	}
586317c35d1SJesse Barnes 
587a4fc5ed6SKeith Packard 	/* Display Port state */
588a4fc5ed6SKeith Packard 	if (SUPPORTS_INTEGRATED_DP(dev)) {
589a4fc5ed6SKeith Packard 		dev_priv->saveDP_B = I915_READ(DP_B);
590a4fc5ed6SKeith Packard 		dev_priv->saveDP_C = I915_READ(DP_C);
591a4fc5ed6SKeith Packard 		dev_priv->saveDP_D = I915_READ(DP_D);
592a4fc5ed6SKeith Packard 		dev_priv->savePIPEA_GMCH_DATA_M = I915_READ(PIPEA_GMCH_DATA_M);
593a4fc5ed6SKeith Packard 		dev_priv->savePIPEB_GMCH_DATA_M = I915_READ(PIPEB_GMCH_DATA_M);
594a4fc5ed6SKeith Packard 		dev_priv->savePIPEA_GMCH_DATA_N = I915_READ(PIPEA_GMCH_DATA_N);
595a4fc5ed6SKeith Packard 		dev_priv->savePIPEB_GMCH_DATA_N = I915_READ(PIPEB_GMCH_DATA_N);
596a4fc5ed6SKeith Packard 		dev_priv->savePIPEA_DP_LINK_M = I915_READ(PIPEA_DP_LINK_M);
597a4fc5ed6SKeith Packard 		dev_priv->savePIPEB_DP_LINK_M = I915_READ(PIPEB_DP_LINK_M);
598a4fc5ed6SKeith Packard 		dev_priv->savePIPEA_DP_LINK_N = I915_READ(PIPEA_DP_LINK_N);
599a4fc5ed6SKeith Packard 		dev_priv->savePIPEB_DP_LINK_N = I915_READ(PIPEB_DP_LINK_N);
600a4fc5ed6SKeith Packard 	}
601317c35d1SJesse Barnes 	/* FIXME: save TV & SDVO state */
602317c35d1SJesse Barnes 
603317c35d1SJesse Barnes 	/* FBC state */
60406027f91SJesse Barnes 	if (IS_GM45(dev)) {
60506027f91SJesse Barnes 		dev_priv->saveDPFC_CB_BASE = I915_READ(DPFC_CB_BASE);
60606027f91SJesse Barnes 	} else {
607317c35d1SJesse Barnes 		dev_priv->saveFBC_CFB_BASE = I915_READ(FBC_CFB_BASE);
608317c35d1SJesse Barnes 		dev_priv->saveFBC_LL_BASE = I915_READ(FBC_LL_BASE);
609317c35d1SJesse Barnes 		dev_priv->saveFBC_CONTROL2 = I915_READ(FBC_CONTROL2);
610317c35d1SJesse Barnes 		dev_priv->saveFBC_CONTROL = I915_READ(FBC_CONTROL);
61106027f91SJesse Barnes 	}
612317c35d1SJesse Barnes 
613317c35d1SJesse Barnes 	/* VGA state */
614317c35d1SJesse Barnes 	dev_priv->saveVGA0 = I915_READ(VGA0);
615317c35d1SJesse Barnes 	dev_priv->saveVGA1 = I915_READ(VGA1);
616317c35d1SJesse Barnes 	dev_priv->saveVGA_PD = I915_READ(VGA_PD);
617f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev))
61842048781SZhenyu Wang 		dev_priv->saveVGACNTRL = I915_READ(CPU_VGACNTRL);
61942048781SZhenyu Wang 	else
620317c35d1SJesse Barnes 		dev_priv->saveVGACNTRL = I915_READ(VGACNTRL);
621317c35d1SJesse Barnes 
622317c35d1SJesse Barnes 	i915_save_vga(dev);
623317c35d1SJesse Barnes }
624317c35d1SJesse Barnes 
6251341d655SBen Gamari void i915_restore_display(struct drm_device *dev)
626317c35d1SJesse Barnes {
627317c35d1SJesse Barnes 	struct drm_i915_private *dev_priv = dev->dev_private;
628461cba2dSPeng Li 
629881ee988SKeith Packard 	/* Display arbitration */
630317c35d1SJesse Barnes 	I915_WRITE(DSPARB, dev_priv->saveDSPARB);
631317c35d1SJesse Barnes 
632a4fc5ed6SKeith Packard 	/* Display port ratios (must be done before clock is set) */
633a4fc5ed6SKeith Packard 	if (SUPPORTS_INTEGRATED_DP(dev)) {
634a4fc5ed6SKeith Packard 		I915_WRITE(PIPEA_GMCH_DATA_M, dev_priv->savePIPEA_GMCH_DATA_M);
635a4fc5ed6SKeith Packard 		I915_WRITE(PIPEB_GMCH_DATA_M, dev_priv->savePIPEB_GMCH_DATA_M);
636a4fc5ed6SKeith Packard 		I915_WRITE(PIPEA_GMCH_DATA_N, dev_priv->savePIPEA_GMCH_DATA_N);
637a4fc5ed6SKeith Packard 		I915_WRITE(PIPEB_GMCH_DATA_N, dev_priv->savePIPEB_GMCH_DATA_N);
638a4fc5ed6SKeith Packard 		I915_WRITE(PIPEA_DP_LINK_M, dev_priv->savePIPEA_DP_LINK_M);
639a4fc5ed6SKeith Packard 		I915_WRITE(PIPEB_DP_LINK_M, dev_priv->savePIPEB_DP_LINK_M);
640a4fc5ed6SKeith Packard 		I915_WRITE(PIPEA_DP_LINK_N, dev_priv->savePIPEA_DP_LINK_N);
641a4fc5ed6SKeith Packard 		I915_WRITE(PIPEB_DP_LINK_N, dev_priv->savePIPEB_DP_LINK_N);
642a4fc5ed6SKeith Packard 	}
6431341d655SBen Gamari 
644fccdaba4SZhao Yakui 	/* This is only meaningful in non-KMS mode */
645fccdaba4SZhao Yakui 	/* Don't restore them in KMS mode */
646fccdaba4SZhao Yakui 	i915_restore_modeset_reg(dev);
6471341d655SBen Gamari 
6481fd1c624SEric Anholt 	/* Cursor state */
6491fd1c624SEric Anholt 	I915_WRITE(CURAPOS, dev_priv->saveCURAPOS);
6501fd1c624SEric Anholt 	I915_WRITE(CURACNTR, dev_priv->saveCURACNTR);
6511fd1c624SEric Anholt 	I915_WRITE(CURABASE, dev_priv->saveCURABASE);
6521fd1c624SEric Anholt 	I915_WRITE(CURBPOS, dev_priv->saveCURBPOS);
6531fd1c624SEric Anholt 	I915_WRITE(CURBCNTR, dev_priv->saveCURBCNTR);
6541fd1c624SEric Anholt 	I915_WRITE(CURBBASE, dev_priv->saveCURBBASE);
6551fd1c624SEric Anholt 	if (!IS_I9XX(dev))
6561fd1c624SEric Anholt 		I915_WRITE(CURSIZE, dev_priv->saveCURSIZE);
6571fd1c624SEric Anholt 
658317c35d1SJesse Barnes 	/* CRT state */
659f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev))
66042048781SZhenyu Wang 		I915_WRITE(PCH_ADPA, dev_priv->saveADPA);
66142048781SZhenyu Wang 	else
662317c35d1SJesse Barnes 		I915_WRITE(ADPA, dev_priv->saveADPA);
663317c35d1SJesse Barnes 
664317c35d1SJesse Barnes 	/* LVDS state */
665f2b115e6SAdam Jackson 	if (IS_I965G(dev) && !IS_IRONLAKE(dev))
666317c35d1SJesse Barnes 		I915_WRITE(BLC_PWM_CTL2, dev_priv->saveBLC_PWM_CTL2);
66742048781SZhenyu Wang 
668f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
66942048781SZhenyu Wang 		I915_WRITE(PCH_LVDS, dev_priv->saveLVDS);
67042048781SZhenyu Wang 	} else if (IS_MOBILE(dev) && !IS_I830(dev))
671317c35d1SJesse Barnes 		I915_WRITE(LVDS, dev_priv->saveLVDS);
67242048781SZhenyu Wang 
673f2b115e6SAdam Jackson 	if (!IS_I830(dev) && !IS_845G(dev) && !IS_IRONLAKE(dev))
674317c35d1SJesse Barnes 		I915_WRITE(PFIT_CONTROL, dev_priv->savePFIT_CONTROL);
675317c35d1SJesse Barnes 
676f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
67742048781SZhenyu Wang 		I915_WRITE(BLC_PWM_PCH_CTL1, dev_priv->saveBLC_PWM_CTL);
67842048781SZhenyu Wang 		I915_WRITE(BLC_PWM_PCH_CTL2, dev_priv->saveBLC_PWM_CTL2);
67942048781SZhenyu Wang 		I915_WRITE(BLC_PWM_CPU_CTL, dev_priv->saveBLC_CPU_PWM_CTL);
68042048781SZhenyu Wang 		I915_WRITE(BLC_PWM_CPU_CTL2, dev_priv->saveBLC_CPU_PWM_CTL2);
68142048781SZhenyu Wang 		I915_WRITE(PCH_PP_ON_DELAYS, dev_priv->savePP_ON_DELAYS);
68242048781SZhenyu Wang 		I915_WRITE(PCH_PP_OFF_DELAYS, dev_priv->savePP_OFF_DELAYS);
68342048781SZhenyu Wang 		I915_WRITE(PCH_PP_DIVISOR, dev_priv->savePP_DIVISOR);
68442048781SZhenyu Wang 		I915_WRITE(PCH_PP_CONTROL, dev_priv->savePP_CONTROL);
685*f97108d1SJesse Barnes 		I915_WRITE(RSTDBYCTL, dev_priv->saveRSTDBYCTL);
68642048781SZhenyu Wang 	} else {
687317c35d1SJesse Barnes 		I915_WRITE(PFIT_PGM_RATIOS, dev_priv->savePFIT_PGM_RATIOS);
688317c35d1SJesse Barnes 		I915_WRITE(BLC_PWM_CTL, dev_priv->saveBLC_PWM_CTL);
6890eb96d6eSJesse Barnes 		I915_WRITE(BLC_HIST_CTL, dev_priv->saveBLC_HIST_CTL);
690317c35d1SJesse Barnes 		I915_WRITE(PP_ON_DELAYS, dev_priv->savePP_ON_DELAYS);
691317c35d1SJesse Barnes 		I915_WRITE(PP_OFF_DELAYS, dev_priv->savePP_OFF_DELAYS);
692317c35d1SJesse Barnes 		I915_WRITE(PP_DIVISOR, dev_priv->savePP_DIVISOR);
693317c35d1SJesse Barnes 		I915_WRITE(PP_CONTROL, dev_priv->savePP_CONTROL);
69442048781SZhenyu Wang 	}
695317c35d1SJesse Barnes 
696a4fc5ed6SKeith Packard 	/* Display Port state */
697a4fc5ed6SKeith Packard 	if (SUPPORTS_INTEGRATED_DP(dev)) {
698a4fc5ed6SKeith Packard 		I915_WRITE(DP_B, dev_priv->saveDP_B);
699a4fc5ed6SKeith Packard 		I915_WRITE(DP_C, dev_priv->saveDP_C);
700a4fc5ed6SKeith Packard 		I915_WRITE(DP_D, dev_priv->saveDP_D);
701a4fc5ed6SKeith Packard 	}
702317c35d1SJesse Barnes 	/* FIXME: restore TV & SDVO state */
703317c35d1SJesse Barnes 
704317c35d1SJesse Barnes 	/* FBC info */
70506027f91SJesse Barnes 	if (IS_GM45(dev)) {
70606027f91SJesse Barnes 		g4x_disable_fbc(dev);
70706027f91SJesse Barnes 		I915_WRITE(DPFC_CB_BASE, dev_priv->saveDPFC_CB_BASE);
70806027f91SJesse Barnes 	} else {
70906027f91SJesse Barnes 		i8xx_disable_fbc(dev);
710317c35d1SJesse Barnes 		I915_WRITE(FBC_CFB_BASE, dev_priv->saveFBC_CFB_BASE);
711317c35d1SJesse Barnes 		I915_WRITE(FBC_LL_BASE, dev_priv->saveFBC_LL_BASE);
712317c35d1SJesse Barnes 		I915_WRITE(FBC_CONTROL2, dev_priv->saveFBC_CONTROL2);
713317c35d1SJesse Barnes 		I915_WRITE(FBC_CONTROL, dev_priv->saveFBC_CONTROL);
71406027f91SJesse Barnes 	}
715317c35d1SJesse Barnes 
716317c35d1SJesse Barnes 	/* VGA state */
717f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev))
71842048781SZhenyu Wang 		I915_WRITE(CPU_VGACNTRL, dev_priv->saveVGACNTRL);
71942048781SZhenyu Wang 	else
720317c35d1SJesse Barnes 		I915_WRITE(VGACNTRL, dev_priv->saveVGACNTRL);
721317c35d1SJesse Barnes 	I915_WRITE(VGA0, dev_priv->saveVGA0);
722317c35d1SJesse Barnes 	I915_WRITE(VGA1, dev_priv->saveVGA1);
723317c35d1SJesse Barnes 	I915_WRITE(VGA_PD, dev_priv->saveVGA_PD);
724317c35d1SJesse Barnes 	DRM_UDELAY(150);
725317c35d1SJesse Barnes 
7261341d655SBen Gamari 	i915_restore_vga(dev);
7271341d655SBen Gamari }
7281341d655SBen Gamari 
7291341d655SBen Gamari int i915_save_state(struct drm_device *dev)
7301341d655SBen Gamari {
7311341d655SBen Gamari 	struct drm_i915_private *dev_priv = dev->dev_private;
7321341d655SBen Gamari 	int i;
7331341d655SBen Gamari 
7341341d655SBen Gamari 	pci_read_config_byte(dev->pdev, LBB, &dev_priv->saveLBB);
7351341d655SBen Gamari 
7361341d655SBen Gamari 	/* Hardware status page */
7371341d655SBen Gamari 	dev_priv->saveHWS = I915_READ(HWS_PGA);
7381341d655SBen Gamari 
7391341d655SBen Gamari 	i915_save_display(dev);
7401341d655SBen Gamari 
7411341d655SBen Gamari 	/* Interrupt state */
742f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
74342048781SZhenyu Wang 		dev_priv->saveDEIER = I915_READ(DEIER);
74442048781SZhenyu Wang 		dev_priv->saveDEIMR = I915_READ(DEIMR);
74542048781SZhenyu Wang 		dev_priv->saveGTIER = I915_READ(GTIER);
74642048781SZhenyu Wang 		dev_priv->saveGTIMR = I915_READ(GTIMR);
74742048781SZhenyu Wang 		dev_priv->saveFDI_RXA_IMR = I915_READ(FDI_RXA_IMR);
74842048781SZhenyu Wang 		dev_priv->saveFDI_RXB_IMR = I915_READ(FDI_RXB_IMR);
749*f97108d1SJesse Barnes 		dev_priv->saveRSTDBYCTL = I915_READ(RSTDBYCTL);
75042048781SZhenyu Wang 	} else {
7511341d655SBen Gamari 		dev_priv->saveIER = I915_READ(IER);
7521341d655SBen Gamari 		dev_priv->saveIMR = I915_READ(IMR);
75342048781SZhenyu Wang 	}
7541341d655SBen Gamari 
755*f97108d1SJesse Barnes 	if (IS_IRONLAKE_M(dev))
756*f97108d1SJesse Barnes 		ironlake_disable_drps(dev);
757*f97108d1SJesse Barnes 
7581341d655SBen Gamari 	/* Cache mode state */
7591341d655SBen Gamari 	dev_priv->saveCACHE_MODE_0 = I915_READ(CACHE_MODE_0);
7601341d655SBen Gamari 
7611341d655SBen Gamari 	/* Memory Arbitration state */
7621341d655SBen Gamari 	dev_priv->saveMI_ARB_STATE = I915_READ(MI_ARB_STATE);
7631341d655SBen Gamari 
7641341d655SBen Gamari 	/* Scratch space */
7651341d655SBen Gamari 	for (i = 0; i < 16; i++) {
7661341d655SBen Gamari 		dev_priv->saveSWF0[i] = I915_READ(SWF00 + (i << 2));
7671341d655SBen Gamari 		dev_priv->saveSWF1[i] = I915_READ(SWF10 + (i << 2));
7681341d655SBen Gamari 	}
7691341d655SBen Gamari 	for (i = 0; i < 3; i++)
7701341d655SBen Gamari 		dev_priv->saveSWF2[i] = I915_READ(SWF30 + (i << 2));
7711341d655SBen Gamari 
7721341d655SBen Gamari 	/* Fences */
7731341d655SBen Gamari 	if (IS_I965G(dev)) {
7741341d655SBen Gamari 		for (i = 0; i < 16; i++)
7751341d655SBen Gamari 			dev_priv->saveFENCE[i] = I915_READ64(FENCE_REG_965_0 + (i * 8));
7761341d655SBen Gamari 	} else {
7771341d655SBen Gamari 		for (i = 0; i < 8; i++)
7781341d655SBen Gamari 			dev_priv->saveFENCE[i] = I915_READ(FENCE_REG_830_0 + (i * 4));
7791341d655SBen Gamari 
7801341d655SBen Gamari 		if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev))
7811341d655SBen Gamari 			for (i = 0; i < 8; i++)
7821341d655SBen Gamari 				dev_priv->saveFENCE[i+8] = I915_READ(FENCE_REG_945_8 + (i * 4));
7831341d655SBen Gamari 	}
7841341d655SBen Gamari 
7851341d655SBen Gamari 	return 0;
7861341d655SBen Gamari }
7871341d655SBen Gamari 
7881341d655SBen Gamari int i915_restore_state(struct drm_device *dev)
7891341d655SBen Gamari {
7901341d655SBen Gamari 	struct drm_i915_private *dev_priv = dev->dev_private;
7911341d655SBen Gamari 	int i;
7921341d655SBen Gamari 
7931341d655SBen Gamari 	pci_write_config_byte(dev->pdev, LBB, dev_priv->saveLBB);
7941341d655SBen Gamari 
7951341d655SBen Gamari 	/* Hardware status page */
7961341d655SBen Gamari 	I915_WRITE(HWS_PGA, dev_priv->saveHWS);
7971341d655SBen Gamari 
7981341d655SBen Gamari 	/* Fences */
7991341d655SBen Gamari 	if (IS_I965G(dev)) {
8001341d655SBen Gamari 		for (i = 0; i < 16; i++)
8011341d655SBen Gamari 			I915_WRITE64(FENCE_REG_965_0 + (i * 8), dev_priv->saveFENCE[i]);
8021341d655SBen Gamari 	} else {
8031341d655SBen Gamari 		for (i = 0; i < 8; i++)
8041341d655SBen Gamari 			I915_WRITE(FENCE_REG_830_0 + (i * 4), dev_priv->saveFENCE[i]);
8051341d655SBen Gamari 		if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev))
8061341d655SBen Gamari 			for (i = 0; i < 8; i++)
8071341d655SBen Gamari 				I915_WRITE(FENCE_REG_945_8 + (i * 4), dev_priv->saveFENCE[i+8]);
8081341d655SBen Gamari 	}
8091341d655SBen Gamari 
8101341d655SBen Gamari 	i915_restore_display(dev);
8111341d655SBen Gamari 
8121341d655SBen Gamari 	/* Interrupt state */
813f2b115e6SAdam Jackson 	if (IS_IRONLAKE(dev)) {
81442048781SZhenyu Wang 		I915_WRITE(DEIER, dev_priv->saveDEIER);
81542048781SZhenyu Wang 		I915_WRITE(DEIMR, dev_priv->saveDEIMR);
81642048781SZhenyu Wang 		I915_WRITE(GTIER, dev_priv->saveGTIER);
81742048781SZhenyu Wang 		I915_WRITE(GTIMR, dev_priv->saveGTIMR);
81842048781SZhenyu Wang 		I915_WRITE(FDI_RXA_IMR, dev_priv->saveFDI_RXA_IMR);
81942048781SZhenyu Wang 		I915_WRITE(FDI_RXB_IMR, dev_priv->saveFDI_RXB_IMR);
82042048781SZhenyu Wang 	} else {
8211341d655SBen Gamari 		I915_WRITE (IER, dev_priv->saveIER);
8221341d655SBen Gamari 		I915_WRITE (IMR,  dev_priv->saveIMR);
82342048781SZhenyu Wang 	}
8241341d655SBen Gamari 
825317c35d1SJesse Barnes 	/* Clock gating state */
8267e8b60faSAndrew Lutomirski 	intel_init_clock_gating(dev);
827317c35d1SJesse Barnes 
828*f97108d1SJesse Barnes 	if (IS_IRONLAKE_M(dev))
829*f97108d1SJesse Barnes 		ironlake_enable_drps(dev);
830*f97108d1SJesse Barnes 
831317c35d1SJesse Barnes 	/* Cache mode state */
832317c35d1SJesse Barnes 	I915_WRITE (CACHE_MODE_0, dev_priv->saveCACHE_MODE_0 | 0xffff0000);
833317c35d1SJesse Barnes 
834317c35d1SJesse Barnes 	/* Memory arbitration state */
835317c35d1SJesse Barnes 	I915_WRITE (MI_ARB_STATE, dev_priv->saveMI_ARB_STATE | 0xffff0000);
836317c35d1SJesse Barnes 
837317c35d1SJesse Barnes 	for (i = 0; i < 16; i++) {
838317c35d1SJesse Barnes 		I915_WRITE(SWF00 + (i << 2), dev_priv->saveSWF0[i]);
839819e0064SRoel Kluin 		I915_WRITE(SWF10 + (i << 2), dev_priv->saveSWF1[i]);
840317c35d1SJesse Barnes 	}
841317c35d1SJesse Barnes 	for (i = 0; i < 3; i++)
842317c35d1SJesse Barnes 		I915_WRITE(SWF30 + (i << 2), dev_priv->saveSWF2[i]);
843317c35d1SJesse Barnes 
844f0217c42SEric Anholt 	/* I2C state */
845f0217c42SEric Anholt 	intel_i2c_reset_gmbus(dev);
846f0217c42SEric Anholt 
847317c35d1SJesse Barnes 	return 0;
848317c35d1SJesse Barnes }
849317c35d1SJesse Barnes 
850