2008-08-26 05:11:06 +07:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2012-10-03 00:01:07 +07:00
|
|
|
#include <drm/drmP.h>
|
|
|
|
#include <drm/i915_drm.h>
|
2009-12-02 02:56:30 +07:00
|
|
|
#include "intel_drv.h"
|
2012-01-08 08:40:34 +07:00
|
|
|
#include "i915_reg.h"
|
2008-08-26 05:11:06 +07:00
|
|
|
|
2016-11-16 15:55:39 +07:00
|
|
|
static void i915_save_display(struct drm_i915_private *dev_priv)
|
2009-07-08 13:13:14 +07:00
|
|
|
{
|
|
|
|
/* Display arbitration control */
|
2016-11-16 15:55:39 +07:00
|
|
|
if (INTEL_GEN(dev_priv) <= 4)
|
2013-01-19 03:29:03 +07:00
|
|
|
dev_priv->regfile.saveDSPARB = I915_READ(DSPARB);
|
2009-07-08 13:13:14 +07:00
|
|
|
|
2014-01-23 21:49:15 +07:00
|
|
|
/* save FBC interval */
|
2016-10-13 17:03:06 +07:00
|
|
|
if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) <= 4 && !IS_G4X(dev_priv))
|
2014-01-23 21:49:15 +07:00
|
|
|
dev_priv->regfile.saveFBC_CONTROL = I915_READ(FBC_CONTROL);
|
2008-08-26 05:11:06 +07:00
|
|
|
}
|
|
|
|
|
2016-11-16 15:55:39 +07:00
|
|
|
static void i915_restore_display(struct drm_i915_private *dev_priv)
|
2008-08-26 05:11:06 +07:00
|
|
|
{
|
2008-11-03 14:08:44 +07:00
|
|
|
/* Display arbitration */
|
2016-11-16 15:55:39 +07:00
|
|
|
if (INTEL_GEN(dev_priv) <= 4)
|
2013-01-19 03:29:03 +07:00
|
|
|
I915_WRITE(DSPARB, dev_priv->regfile.saveDSPARB);
|
2008-08-26 05:11:06 +07:00
|
|
|
|
2010-03-19 16:05:10 +07:00
|
|
|
/* only restore FBC info on the platform that supports FBC*/
|
2016-01-19 20:35:46 +07:00
|
|
|
intel_fbc_global_disable(dev_priv);
|
2014-01-23 21:49:15 +07:00
|
|
|
|
|
|
|
/* restore FBC interval */
|
2016-10-13 17:03:06 +07:00
|
|
|
if (HAS_FBC(dev_priv) && INTEL_GEN(dev_priv) <= 4 && !IS_G4X(dev_priv))
|
2014-01-23 21:49:15 +07:00
|
|
|
I915_WRITE(FBC_CONTROL, dev_priv->regfile.saveFBC_CONTROL);
|
2013-01-25 23:53:22 +07:00
|
|
|
|
2016-11-16 15:55:39 +07:00
|
|
|
i915_redisable_vga(dev_priv);
|
2009-09-15 04:48:42 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
int i915_save_state(struct drm_device *dev)
|
|
|
|
{
|
2016-07-04 17:34:36 +07:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(dev);
|
2016-08-22 17:32:44 +07:00
|
|
|
struct pci_dev *pdev = dev_priv->drm.pdev;
|
2009-09-15 04:48:42 +07:00
|
|
|
int i;
|
|
|
|
|
2011-06-29 14:30:34 +07:00
|
|
|
mutex_lock(&dev->struct_mutex);
|
|
|
|
|
2016-11-16 15:55:39 +07:00
|
|
|
i915_save_display(dev_priv);
|
2009-09-15 04:48:42 +07:00
|
|
|
|
2016-10-13 17:03:10 +07:00
|
|
|
if (IS_GEN4(dev_priv))
|
2016-08-22 17:32:44 +07:00
|
|
|
pci_read_config_word(pdev, GCDGMBUS,
|
2014-12-11 03:16:05 +07:00
|
|
|
&dev_priv->regfile.saveGCDGMBUS);
|
|
|
|
|
2009-09-15 04:48:42 +07:00
|
|
|
/* Cache mode state */
|
2016-11-16 15:55:39 +07:00
|
|
|
if (INTEL_GEN(dev_priv) < 7)
|
2013-10-12 02:09:29 +07:00
|
|
|
dev_priv->regfile.saveCACHE_MODE_0 = I915_READ(CACHE_MODE_0);
|
2009-09-15 04:48:42 +07:00
|
|
|
|
|
|
|
/* Memory Arbitration state */
|
2012-11-03 01:55:02 +07:00
|
|
|
dev_priv->regfile.saveMI_ARB_STATE = I915_READ(MI_ARB_STATE);
|
2009-09-15 04:48:42 +07:00
|
|
|
|
|
|
|
/* Scratch space */
|
2015-09-19 00:03:43 +07:00
|
|
|
if (IS_GEN2(dev_priv) && IS_MOBILE(dev_priv)) {
|
|
|
|
for (i = 0; i < 7; i++) {
|
|
|
|
dev_priv->regfile.saveSWF0[i] = I915_READ(SWF0(i));
|
|
|
|
dev_priv->regfile.saveSWF1[i] = I915_READ(SWF1(i));
|
|
|
|
}
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
dev_priv->regfile.saveSWF3[i] = I915_READ(SWF3(i));
|
|
|
|
} else if (IS_GEN2(dev_priv)) {
|
|
|
|
for (i = 0; i < 7; i++)
|
|
|
|
dev_priv->regfile.saveSWF1[i] = I915_READ(SWF1(i));
|
|
|
|
} else if (HAS_GMCH_DISPLAY(dev_priv)) {
|
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
dev_priv->regfile.saveSWF0[i] = I915_READ(SWF0(i));
|
|
|
|
dev_priv->regfile.saveSWF1[i] = I915_READ(SWF1(i));
|
|
|
|
}
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
dev_priv->regfile.saveSWF3[i] = I915_READ(SWF3(i));
|
2009-09-15 04:48:42 +07:00
|
|
|
}
|
|
|
|
|
2011-06-29 14:30:34 +07:00
|
|
|
mutex_unlock(&dev->struct_mutex);
|
|
|
|
|
2009-09-15 04:48:42 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int i915_restore_state(struct drm_device *dev)
|
|
|
|
{
|
2016-07-04 17:34:36 +07:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(dev);
|
2016-08-22 17:32:44 +07:00
|
|
|
struct pci_dev *pdev = dev_priv->drm.pdev;
|
2009-09-15 04:48:42 +07:00
|
|
|
int i;
|
|
|
|
|
2011-06-29 14:30:34 +07:00
|
|
|
mutex_lock(&dev->struct_mutex);
|
|
|
|
|
2016-11-16 15:55:33 +07:00
|
|
|
i915_gem_restore_fences(dev_priv);
|
2014-12-11 03:16:05 +07:00
|
|
|
|
2016-10-13 17:03:10 +07:00
|
|
|
if (IS_GEN4(dev_priv))
|
2016-08-22 17:32:44 +07:00
|
|
|
pci_write_config_word(pdev, GCDGMBUS,
|
2014-12-11 03:16:05 +07:00
|
|
|
dev_priv->regfile.saveGCDGMBUS);
|
2016-11-16 15:55:39 +07:00
|
|
|
i915_restore_display(dev_priv);
|
2009-09-15 04:48:42 +07:00
|
|
|
|
2008-08-26 05:11:06 +07:00
|
|
|
/* Cache mode state */
|
2016-11-16 15:55:39 +07:00
|
|
|
if (INTEL_GEN(dev_priv) < 7)
|
2013-10-12 02:09:29 +07:00
|
|
|
I915_WRITE(CACHE_MODE_0, dev_priv->regfile.saveCACHE_MODE_0 |
|
|
|
|
0xffff0000);
|
2008-08-26 05:11:06 +07:00
|
|
|
|
|
|
|
/* Memory arbitration state */
|
2012-11-03 01:55:02 +07:00
|
|
|
I915_WRITE(MI_ARB_STATE, dev_priv->regfile.saveMI_ARB_STATE | 0xffff0000);
|
2008-08-26 05:11:06 +07:00
|
|
|
|
2015-09-19 00:03:43 +07:00
|
|
|
/* Scratch space */
|
|
|
|
if (IS_GEN2(dev_priv) && IS_MOBILE(dev_priv)) {
|
|
|
|
for (i = 0; i < 7; i++) {
|
|
|
|
I915_WRITE(SWF0(i), dev_priv->regfile.saveSWF0[i]);
|
|
|
|
I915_WRITE(SWF1(i), dev_priv->regfile.saveSWF1[i]);
|
|
|
|
}
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
I915_WRITE(SWF3(i), dev_priv->regfile.saveSWF3[i]);
|
|
|
|
} else if (IS_GEN2(dev_priv)) {
|
|
|
|
for (i = 0; i < 7; i++)
|
|
|
|
I915_WRITE(SWF1(i), dev_priv->regfile.saveSWF1[i]);
|
|
|
|
} else if (HAS_GMCH_DISPLAY(dev_priv)) {
|
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
I915_WRITE(SWF0(i), dev_priv->regfile.saveSWF0[i]);
|
|
|
|
I915_WRITE(SWF1(i), dev_priv->regfile.saveSWF1[i]);
|
|
|
|
}
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
I915_WRITE(SWF3(i), dev_priv->regfile.saveSWF3[i]);
|
2008-08-26 05:11:06 +07:00
|
|
|
}
|
|
|
|
|
2011-06-29 14:30:34 +07:00
|
|
|
mutex_unlock(&dev->struct_mutex);
|
|
|
|
|
2010-07-21 05:44:45 +07:00
|
|
|
intel_i2c_reset(dev);
|
2009-12-02 02:56:30 +07:00
|
|
|
|
2008-08-26 05:11:06 +07:00
|
|
|
return 0;
|
|
|
|
}
|