i915_suspend.c 15.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*
 *
 * Copyright 2008 (c) Intel Corporation
 *   Jesse Barnes <jbarnes@virtuousgeek.org>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

27 28
#include <drm/drmP.h>
#include <drm/i915_drm.h>
29
#include "intel_drv.h"
30
#include "i915_reg.h"
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

static u8 i915_read_indexed(struct drm_device *dev, u16 index_port, u16 data_port, u8 reg)
{
	struct drm_i915_private *dev_priv = dev->dev_private;

	I915_WRITE8(index_port, reg);
	return I915_READ8(data_port);
}

static u8 i915_read_ar(struct drm_device *dev, u16 st01, u8 reg, u16 palette_enable)
{
	struct drm_i915_private *dev_priv = dev->dev_private;

	I915_READ8(st01);
	I915_WRITE8(VGA_AR_INDEX, palette_enable | reg);
	return I915_READ8(VGA_AR_DATA_READ);
}

static void i915_write_ar(struct drm_device *dev, u16 st01, u8 reg, u8 val, u16 palette_enable)
{
	struct drm_i915_private *dev_priv = dev->dev_private;

	I915_READ8(st01);
	I915_WRITE8(VGA_AR_INDEX, palette_enable | reg);
	I915_WRITE8(VGA_AR_DATA_WRITE, val);
}

static void i915_write_indexed(struct drm_device *dev, u16 index_port, u16 data_port, u8 reg, u8 val)
{
	struct drm_i915_private *dev_priv = dev->dev_private;

	I915_WRITE8(index_port, reg);
	I915_WRITE8(data_port, val);
}

static void i915_save_vga(struct drm_device *dev)
{
	struct drm_i915_private *dev_priv = dev->dev_private;
	int i;
	u16 cr_index, cr_data, st01;

72 73 74 75 76 77 78 79 80
	/* VGA state */
	dev_priv->regfile.saveVGA0 = I915_READ(VGA0);
	dev_priv->regfile.saveVGA1 = I915_READ(VGA1);
	dev_priv->regfile.saveVGA_PD = I915_READ(VGA_PD);
	if (HAS_PCH_SPLIT(dev))
		dev_priv->regfile.saveVGACNTRL = I915_READ(CPU_VGACNTRL);
	else
		dev_priv->regfile.saveVGACNTRL = I915_READ(VGACNTRL);

81
	/* VGA color palette registers */
82
	dev_priv->regfile.saveDACMASK = I915_READ8(VGA_DACMASK);
83 84

	/* MSR bits */
85 86
	dev_priv->regfile.saveMSR = I915_READ8(VGA_MSR_READ);
	if (dev_priv->regfile.saveMSR & VGA_MSR_CGA_MODE) {
87 88 89 90 91 92 93 94 95 96 97 98 99 100
		cr_index = VGA_CR_INDEX_CGA;
		cr_data = VGA_CR_DATA_CGA;
		st01 = VGA_ST01_CGA;
	} else {
		cr_index = VGA_CR_INDEX_MDA;
		cr_data = VGA_CR_DATA_MDA;
		st01 = VGA_ST01_MDA;
	}

	/* CRT controller regs */
	i915_write_indexed(dev, cr_index, cr_data, 0x11,
			   i915_read_indexed(dev, cr_index, cr_data, 0x11) &
			   (~0x80));
	for (i = 0; i <= 0x24; i++)
101
		dev_priv->regfile.saveCR[i] =
102 103
			i915_read_indexed(dev, cr_index, cr_data, i);
	/* Make sure we don't turn off CR group 0 writes */
104
	dev_priv->regfile.saveCR[0x11] &= ~0x80;
105 106 107

	/* Attribute controller registers */
	I915_READ8(st01);
108
	dev_priv->regfile.saveAR_INDEX = I915_READ8(VGA_AR_INDEX);
109
	for (i = 0; i <= 0x14; i++)
110
		dev_priv->regfile.saveAR[i] = i915_read_ar(dev, st01, i, 0);
111
	I915_READ8(st01);
112
	I915_WRITE8(VGA_AR_INDEX, dev_priv->regfile.saveAR_INDEX);
113 114 115 116
	I915_READ8(st01);

	/* Graphics controller registers */
	for (i = 0; i < 9; i++)
117
		dev_priv->regfile.saveGR[i] =
118 119
			i915_read_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, i);

120
	dev_priv->regfile.saveGR[0x10] =
121
		i915_read_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x10);
122
	dev_priv->regfile.saveGR[0x11] =
123
		i915_read_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x11);
124
	dev_priv->regfile.saveGR[0x18] =
125 126 127 128
		i915_read_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x18);

	/* Sequencer registers */
	for (i = 0; i < 8; i++)
129
		dev_priv->regfile.saveSR[i] =
130 131 132 133 134 135 136 137 138
			i915_read_indexed(dev, VGA_SR_INDEX, VGA_SR_DATA, i);
}

static void i915_restore_vga(struct drm_device *dev)
{
	struct drm_i915_private *dev_priv = dev->dev_private;
	int i;
	u16 cr_index, cr_data, st01;

139 140 141 142 143 144 145 146 147 148 149 150
	/* VGA state */
	if (HAS_PCH_SPLIT(dev))
		I915_WRITE(CPU_VGACNTRL, dev_priv->regfile.saveVGACNTRL);
	else
		I915_WRITE(VGACNTRL, dev_priv->regfile.saveVGACNTRL);

	I915_WRITE(VGA0, dev_priv->regfile.saveVGA0);
	I915_WRITE(VGA1, dev_priv->regfile.saveVGA1);
	I915_WRITE(VGA_PD, dev_priv->regfile.saveVGA_PD);
	POSTING_READ(VGA_PD);
	udelay(150);

151
	/* MSR bits */
152 153
	I915_WRITE8(VGA_MSR_WRITE, dev_priv->regfile.saveMSR);
	if (dev_priv->regfile.saveMSR & VGA_MSR_CGA_MODE) {
154 155 156 157 158 159 160 161 162 163 164 165
		cr_index = VGA_CR_INDEX_CGA;
		cr_data = VGA_CR_DATA_CGA;
		st01 = VGA_ST01_CGA;
	} else {
		cr_index = VGA_CR_INDEX_MDA;
		cr_data = VGA_CR_DATA_MDA;
		st01 = VGA_ST01_MDA;
	}

	/* Sequencer registers, don't write SR07 */
	for (i = 0; i < 7; i++)
		i915_write_indexed(dev, VGA_SR_INDEX, VGA_SR_DATA, i,
166
				   dev_priv->regfile.saveSR[i]);
167 168 169

	/* CRT controller regs */
	/* Enable CR group 0 writes */
170
	i915_write_indexed(dev, cr_index, cr_data, 0x11, dev_priv->regfile.saveCR[0x11]);
171
	for (i = 0; i <= 0x24; i++)
172
		i915_write_indexed(dev, cr_index, cr_data, i, dev_priv->regfile.saveCR[i]);
173 174 175 176

	/* Graphics controller regs */
	for (i = 0; i < 9; i++)
		i915_write_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, i,
177
				   dev_priv->regfile.saveGR[i]);
178 179

	i915_write_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x10,
180
			   dev_priv->regfile.saveGR[0x10]);
181
	i915_write_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x11,
182
			   dev_priv->regfile.saveGR[0x11]);
183
	i915_write_indexed(dev, VGA_GR_INDEX, VGA_GR_DATA, 0x18,
184
			   dev_priv->regfile.saveGR[0x18]);
185 186 187 188

	/* Attribute controller registers */
	I915_READ8(st01); /* switch back to index mode */
	for (i = 0; i <= 0x14; i++)
189
		i915_write_ar(dev, st01, i, dev_priv->regfile.saveAR[i], 0);
190
	I915_READ8(st01); /* switch back to index mode */
191
	I915_WRITE8(VGA_AR_INDEX, dev_priv->regfile.saveAR_INDEX | 0x20);
192 193 194
	I915_READ8(st01);

	/* VGA color palette registers */
195
	I915_WRITE8(VGA_DACMASK, dev_priv->regfile.saveDACMASK);
196 197
}

198
static void i915_save_display(struct drm_device *dev)
199 200 201 202
{
	struct drm_i915_private *dev_priv = dev->dev_private;

	/* Display arbitration control */
203 204
	if (INTEL_INFO(dev)->gen <= 4)
		dev_priv->regfile.saveDSPARB = I915_READ(DSPARB);
205 206

	/* This is only meaningful in non-KMS mode */
207
	/* Don't regfile.save them in KMS mode */
208
	if (!drm_core_check_feature(dev, DRIVER_MODESET))
209
		i915_save_display_reg(dev);
210

211
	/* LVDS state */
212
	if (HAS_PCH_SPLIT(dev)) {
213 214 215 216 217 218
		dev_priv->regfile.savePP_CONTROL = I915_READ(PCH_PP_CONTROL);
		dev_priv->regfile.saveBLC_PWM_CTL = I915_READ(BLC_PWM_PCH_CTL1);
		dev_priv->regfile.saveBLC_PWM_CTL2 = I915_READ(BLC_PWM_PCH_CTL2);
		dev_priv->regfile.saveBLC_CPU_PWM_CTL = I915_READ(BLC_PWM_CPU_CTL);
		dev_priv->regfile.saveBLC_CPU_PWM_CTL2 = I915_READ(BLC_PWM_CPU_CTL2);
		dev_priv->regfile.saveLVDS = I915_READ(PCH_LVDS);
219
	} else {
220 221 222 223
		dev_priv->regfile.savePP_CONTROL = I915_READ(PP_CONTROL);
		dev_priv->regfile.savePFIT_PGM_RATIOS = I915_READ(PFIT_PGM_RATIOS);
		dev_priv->regfile.saveBLC_PWM_CTL = I915_READ(BLC_PWM_CTL);
		dev_priv->regfile.saveBLC_HIST_CTL = I915_READ(BLC_HIST_CTL);
224
		if (INTEL_INFO(dev)->gen >= 4)
225
			dev_priv->regfile.saveBLC_PWM_CTL2 = I915_READ(BLC_PWM_CTL2);
226
		if (IS_MOBILE(dev) && !IS_I830(dev))
227
			dev_priv->regfile.saveLVDS = I915_READ(LVDS);
228 229
	}

230
	if (!IS_I830(dev) && !IS_845G(dev) && !HAS_PCH_SPLIT(dev))
231
		dev_priv->regfile.savePFIT_CONTROL = I915_READ(PFIT_CONTROL);
232

233
	if (HAS_PCH_SPLIT(dev)) {
234 235 236
		dev_priv->regfile.savePP_ON_DELAYS = I915_READ(PCH_PP_ON_DELAYS);
		dev_priv->regfile.savePP_OFF_DELAYS = I915_READ(PCH_PP_OFF_DELAYS);
		dev_priv->regfile.savePP_DIVISOR = I915_READ(PCH_PP_DIVISOR);
237
	} else {
238 239 240
		dev_priv->regfile.savePP_ON_DELAYS = I915_READ(PP_ON_DELAYS);
		dev_priv->regfile.savePP_OFF_DELAYS = I915_READ(PP_OFF_DELAYS);
		dev_priv->regfile.savePP_DIVISOR = I915_READ(PP_DIVISOR);
241
	}
242

243 244 245
	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
		/* Display Port state */
		if (SUPPORTS_INTEGRATED_DP(dev)) {
246 247 248 249 250 251 252 253 254 255 256
			dev_priv->regfile.saveDP_B = I915_READ(DP_B);
			dev_priv->regfile.saveDP_C = I915_READ(DP_C);
			dev_priv->regfile.saveDP_D = I915_READ(DP_D);
			dev_priv->regfile.savePIPEA_GMCH_DATA_M = I915_READ(_PIPEA_GMCH_DATA_M);
			dev_priv->regfile.savePIPEB_GMCH_DATA_M = I915_READ(_PIPEB_GMCH_DATA_M);
			dev_priv->regfile.savePIPEA_GMCH_DATA_N = I915_READ(_PIPEA_GMCH_DATA_N);
			dev_priv->regfile.savePIPEB_GMCH_DATA_N = I915_READ(_PIPEB_GMCH_DATA_N);
			dev_priv->regfile.savePIPEA_DP_LINK_M = I915_READ(_PIPEA_DP_LINK_M);
			dev_priv->regfile.savePIPEB_DP_LINK_M = I915_READ(_PIPEB_DP_LINK_M);
			dev_priv->regfile.savePIPEA_DP_LINK_N = I915_READ(_PIPEA_DP_LINK_N);
			dev_priv->regfile.savePIPEB_DP_LINK_N = I915_READ(_PIPEB_DP_LINK_N);
257
		}
258
		/* FIXME: regfile.save TV & SDVO state */
259
	}
260

261
	/* Only regfile.save FBC state on the platform that supports FBC */
262
	if (I915_HAS_FBC(dev)) {
263
		if (HAS_PCH_SPLIT(dev)) {
264
			dev_priv->regfile.saveDPFC_CB_BASE = I915_READ(ILK_DPFC_CB_BASE);
265
		} else if (IS_GM45(dev)) {
266
			dev_priv->regfile.saveDPFC_CB_BASE = I915_READ(DPFC_CB_BASE);
267
		} else {
268 269 270 271
			dev_priv->regfile.saveFBC_CFB_BASE = I915_READ(FBC_CFB_BASE);
			dev_priv->regfile.saveFBC_LL_BASE = I915_READ(FBC_LL_BASE);
			dev_priv->regfile.saveFBC_CONTROL2 = I915_READ(FBC_CONTROL2);
			dev_priv->regfile.saveFBC_CONTROL = I915_READ(FBC_CONTROL);
272
		}
273
	}
274

275 276
	if (!drm_core_check_feature(dev, DRIVER_MODESET))
		i915_save_vga(dev);
277 278
}

279
static void i915_restore_display(struct drm_device *dev)
280 281
{
	struct drm_i915_private *dev_priv = dev->dev_private;
282

283
	/* Display arbitration */
284 285
	if (INTEL_INFO(dev)->gen <= 4)
		I915_WRITE(DSPARB, dev_priv->regfile.saveDSPARB);
286

287
	if (!drm_core_check_feature(dev, DRIVER_MODESET))
288
		i915_restore_display_reg(dev);
289

290
	/* LVDS state */
291
	if (INTEL_INFO(dev)->gen >= 4 && !HAS_PCH_SPLIT(dev))
292
		I915_WRITE(BLC_PWM_CTL2, dev_priv->regfile.saveBLC_PWM_CTL2);
293

294
	if (HAS_PCH_SPLIT(dev)) {
295
		I915_WRITE(PCH_LVDS, dev_priv->regfile.saveLVDS);
296
	} else if (IS_MOBILE(dev) && !IS_I830(dev))
297
		I915_WRITE(LVDS, dev_priv->regfile.saveLVDS);
298

299
	if (!IS_I830(dev) && !IS_845G(dev) && !HAS_PCH_SPLIT(dev))
300
		I915_WRITE(PFIT_CONTROL, dev_priv->regfile.savePFIT_CONTROL);
301

302
	if (HAS_PCH_SPLIT(dev)) {
303 304
		I915_WRITE(BLC_PWM_PCH_CTL1, dev_priv->regfile.saveBLC_PWM_CTL);
		I915_WRITE(BLC_PWM_PCH_CTL2, dev_priv->regfile.saveBLC_PWM_CTL2);
305 306 307
		/* NOTE: BLC_PWM_CPU_CTL must be written after BLC_PWM_CPU_CTL2;
		 * otherwise we get blank eDP screen after S3 on some machines
		 */
308 309 310 311 312 313
		I915_WRITE(BLC_PWM_CPU_CTL2, dev_priv->regfile.saveBLC_CPU_PWM_CTL2);
		I915_WRITE(BLC_PWM_CPU_CTL, dev_priv->regfile.saveBLC_CPU_PWM_CTL);
		I915_WRITE(PCH_PP_ON_DELAYS, dev_priv->regfile.savePP_ON_DELAYS);
		I915_WRITE(PCH_PP_OFF_DELAYS, dev_priv->regfile.savePP_OFF_DELAYS);
		I915_WRITE(PCH_PP_DIVISOR, dev_priv->regfile.savePP_DIVISOR);
		I915_WRITE(PCH_PP_CONTROL, dev_priv->regfile.savePP_CONTROL);
314
		I915_WRITE(RSTDBYCTL,
315
			   dev_priv->regfile.saveMCHBAR_RENDER_STANDBY);
316
	} else {
317 318 319 320 321 322 323
		I915_WRITE(PFIT_PGM_RATIOS, dev_priv->regfile.savePFIT_PGM_RATIOS);
		I915_WRITE(BLC_PWM_CTL, dev_priv->regfile.saveBLC_PWM_CTL);
		I915_WRITE(BLC_HIST_CTL, dev_priv->regfile.saveBLC_HIST_CTL);
		I915_WRITE(PP_ON_DELAYS, dev_priv->regfile.savePP_ON_DELAYS);
		I915_WRITE(PP_OFF_DELAYS, dev_priv->regfile.savePP_OFF_DELAYS);
		I915_WRITE(PP_DIVISOR, dev_priv->regfile.savePP_DIVISOR);
		I915_WRITE(PP_CONTROL, dev_priv->regfile.savePP_CONTROL);
324
	}
325

326 327 328
	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
		/* Display Port state */
		if (SUPPORTS_INTEGRATED_DP(dev)) {
329 330 331
			I915_WRITE(DP_B, dev_priv->regfile.saveDP_B);
			I915_WRITE(DP_C, dev_priv->regfile.saveDP_C);
			I915_WRITE(DP_D, dev_priv->regfile.saveDP_D);
332 333
		}
		/* FIXME: restore TV & SDVO state */
334
	}
335

336
	/* only restore FBC info on the platform that supports FBC*/
337
	intel_disable_fbc(dev);
338
	if (I915_HAS_FBC(dev)) {
339
		if (HAS_PCH_SPLIT(dev)) {
340
			I915_WRITE(ILK_DPFC_CB_BASE, dev_priv->regfile.saveDPFC_CB_BASE);
341
		} else if (IS_GM45(dev)) {
342
			I915_WRITE(DPFC_CB_BASE, dev_priv->regfile.saveDPFC_CB_BASE);
343
		} else {
344 345 346 347
			I915_WRITE(FBC_CFB_BASE, dev_priv->regfile.saveFBC_CFB_BASE);
			I915_WRITE(FBC_LL_BASE, dev_priv->regfile.saveFBC_LL_BASE);
			I915_WRITE(FBC_CONTROL2, dev_priv->regfile.saveFBC_CONTROL2);
			I915_WRITE(FBC_CONTROL, dev_priv->regfile.saveFBC_CONTROL);
348
		}
349
	}
350 351
	if (!drm_core_check_feature(dev, DRIVER_MODESET))
		i915_restore_vga(dev);
352
	else
353
		i915_redisable_vga(dev);
354 355 356 357 358 359 360
}

int i915_save_state(struct drm_device *dev)
{
	struct drm_i915_private *dev_priv = dev->dev_private;
	int i;

361
	pci_read_config_byte(dev->pdev, LBB, &dev_priv->regfile.saveLBB);
362

363 364
	mutex_lock(&dev->struct_mutex);

365 366
	i915_save_display(dev);

367 368 369
	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
		/* Interrupt state */
		if (HAS_PCH_SPLIT(dev)) {
370 371 372 373 374 375 376
			dev_priv->regfile.saveDEIER = I915_READ(DEIER);
			dev_priv->regfile.saveDEIMR = I915_READ(DEIMR);
			dev_priv->regfile.saveGTIER = I915_READ(GTIER);
			dev_priv->regfile.saveGTIMR = I915_READ(GTIMR);
			dev_priv->regfile.saveFDI_RXA_IMR = I915_READ(_FDI_RXA_IMR);
			dev_priv->regfile.saveFDI_RXB_IMR = I915_READ(_FDI_RXB_IMR);
			dev_priv->regfile.saveMCHBAR_RENDER_STANDBY =
377
				I915_READ(RSTDBYCTL);
378
			dev_priv->regfile.savePCH_PORT_HOTPLUG = I915_READ(PCH_PORT_HOTPLUG);
379
		} else {
380 381
			dev_priv->regfile.saveIER = I915_READ(IER);
			dev_priv->regfile.saveIMR = I915_READ(IMR);
382
		}
383
	}
384

385
	intel_disable_gt_powersave(dev);
386

387
	/* Cache mode state */
388
	dev_priv->regfile.saveCACHE_MODE_0 = I915_READ(CACHE_MODE_0);
389 390

	/* Memory Arbitration state */
391
	dev_priv->regfile.saveMI_ARB_STATE = I915_READ(MI_ARB_STATE);
392 393 394

	/* Scratch space */
	for (i = 0; i < 16; i++) {
395 396
		dev_priv->regfile.saveSWF0[i] = I915_READ(SWF00 + (i << 2));
		dev_priv->regfile.saveSWF1[i] = I915_READ(SWF10 + (i << 2));
397 398
	}
	for (i = 0; i < 3; i++)
399
		dev_priv->regfile.saveSWF2[i] = I915_READ(SWF30 + (i << 2));
400

401 402
	mutex_unlock(&dev->struct_mutex);

403 404 405 406 407 408 409 410
	return 0;
}

int i915_restore_state(struct drm_device *dev)
{
	struct drm_i915_private *dev_priv = dev->dev_private;
	int i;

411
	pci_write_config_byte(dev->pdev, LBB, dev_priv->regfile.saveLBB);
412

413 414
	mutex_lock(&dev->struct_mutex);

415 416
	i915_restore_display(dev);

417 418 419
	if (!drm_core_check_feature(dev, DRIVER_MODESET)) {
		/* Interrupt state */
		if (HAS_PCH_SPLIT(dev)) {
420 421 422 423 424 425 426
			I915_WRITE(DEIER, dev_priv->regfile.saveDEIER);
			I915_WRITE(DEIMR, dev_priv->regfile.saveDEIMR);
			I915_WRITE(GTIER, dev_priv->regfile.saveGTIER);
			I915_WRITE(GTIMR, dev_priv->regfile.saveGTIMR);
			I915_WRITE(_FDI_RXA_IMR, dev_priv->regfile.saveFDI_RXA_IMR);
			I915_WRITE(_FDI_RXB_IMR, dev_priv->regfile.saveFDI_RXB_IMR);
			I915_WRITE(PCH_PORT_HOTPLUG, dev_priv->regfile.savePCH_PORT_HOTPLUG);
427
		} else {
428 429
			I915_WRITE(IER, dev_priv->regfile.saveIER);
			I915_WRITE(IMR, dev_priv->regfile.saveIMR);
430
		}
431
	}
432

433
	/* Cache mode state */
434
	I915_WRITE(CACHE_MODE_0, dev_priv->regfile.saveCACHE_MODE_0 | 0xffff0000);
435 436

	/* Memory arbitration state */
437
	I915_WRITE(MI_ARB_STATE, dev_priv->regfile.saveMI_ARB_STATE | 0xffff0000);
438 439

	for (i = 0; i < 16; i++) {
440 441
		I915_WRITE(SWF00 + (i << 2), dev_priv->regfile.saveSWF0[i]);
		I915_WRITE(SWF10 + (i << 2), dev_priv->regfile.saveSWF1[i]);
442 443
	}
	for (i = 0; i < 3; i++)
444
		I915_WRITE(SWF30 + (i << 2), dev_priv->regfile.saveSWF2[i]);
445

446 447
	mutex_unlock(&dev->struct_mutex);

448
	intel_i2c_reset(dev);
449

450 451
	return 0;
}