2008-08-25 22:11:06 +00: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-02 17:01:07 +00:00
|
|
|
#include <drm/drmP.h>
|
|
|
|
#include <drm/i915_drm.h>
|
2009-12-01 19:56:30 +00:00
|
|
|
#include "intel_drv.h"
|
2012-01-08 01:40:34 +00:00
|
|
|
#include "i915_reg.h"
|
2008-08-25 22:11:06 +00:00
|
|
|
|
2011-06-29 07:30:34 +00:00
|
|
|
static void i915_save_display(struct drm_device *dev)
|
2009-07-08 06:13:14 +00:00
|
|
|
{
|
|
|
|
struct drm_i915_private *dev_priv = dev->dev_private;
|
|
|
|
|
|
|
|
/* Display arbitration control */
|
2013-01-18 20:29:03 +00:00
|
|
|
if (INTEL_INFO(dev)->gen <= 4)
|
|
|
|
dev_priv->regfile.saveDSPARB = I915_READ(DSPARB);
|
2009-07-08 06:13:14 +00:00
|
|
|
|
2008-08-25 22:11:06 +00:00
|
|
|
/* LVDS state */
|
2014-11-12 15:01:10 +00:00
|
|
|
if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev))
|
|
|
|
dev_priv->regfile.saveLVDS = I915_READ(PCH_LVDS);
|
|
|
|
else if (INTEL_INFO(dev)->gen <= 4 && IS_MOBILE(dev) && !IS_I830(dev))
|
|
|
|
dev_priv->regfile.saveLVDS = I915_READ(LVDS);
|
2009-10-21 07:27:01 +00:00
|
|
|
|
2014-11-12 15:01:10 +00:00
|
|
|
/* Panel power sequencer */
|
2010-08-14 13:41:23 +00:00
|
|
|
if (HAS_PCH_SPLIT(dev)) {
|
2014-11-12 15:01:10 +00:00
|
|
|
dev_priv->regfile.savePP_CONTROL = I915_READ(PCH_PP_CONTROL);
|
2012-11-02 18:55:02 +00:00
|
|
|
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);
|
2014-11-11 14:48:03 +00:00
|
|
|
} else if (!IS_VALLEYVIEW(dev)) {
|
2014-11-12 15:01:10 +00:00
|
|
|
dev_priv->regfile.savePP_CONTROL = I915_READ(PP_CONTROL);
|
2012-11-02 18:55:02 +00:00
|
|
|
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);
|
2009-10-21 07:27:01 +00:00
|
|
|
}
|
2008-08-25 22:11:06 +00:00
|
|
|
|
2014-01-23 14:49:15 +00:00
|
|
|
/* save FBC interval */
|
|
|
|
if (HAS_FBC(dev) && INTEL_INFO(dev)->gen <= 4 && !IS_G4X(dev))
|
|
|
|
dev_priv->regfile.saveFBC_CONTROL = I915_READ(FBC_CONTROL);
|
2008-08-25 22:11:06 +00:00
|
|
|
}
|
|
|
|
|
2011-06-29 07:30:34 +00:00
|
|
|
static void i915_restore_display(struct drm_device *dev)
|
2008-08-25 22:11:06 +00:00
|
|
|
{
|
|
|
|
struct drm_i915_private *dev_priv = dev->dev_private;
|
2013-02-19 20:11:38 +00:00
|
|
|
u32 mask = 0xffffffff;
|
2008-11-18 04:39:02 +00:00
|
|
|
|
2008-11-03 07:08:44 +00:00
|
|
|
/* Display arbitration */
|
2013-01-18 20:29:03 +00:00
|
|
|
if (INTEL_INFO(dev)->gen <= 4)
|
|
|
|
I915_WRITE(DSPARB, dev_priv->regfile.saveDSPARB);
|
2008-08-25 22:11:06 +00:00
|
|
|
|
2015-02-23 11:03:30 +00:00
|
|
|
mask = ~LVDS_PORT_EN;
|
2013-02-19 20:11:38 +00:00
|
|
|
|
2014-11-12 15:01:10 +00:00
|
|
|
/* LVDS state */
|
2013-03-06 23:03:20 +00:00
|
|
|
if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev))
|
2013-02-19 20:11:38 +00:00
|
|
|
I915_WRITE(PCH_LVDS, dev_priv->regfile.saveLVDS & mask);
|
2013-03-06 23:03:20 +00:00
|
|
|
else if (INTEL_INFO(dev)->gen <= 4 && IS_MOBILE(dev) && !IS_I830(dev))
|
2013-02-19 20:11:38 +00:00
|
|
|
I915_WRITE(LVDS, dev_priv->regfile.saveLVDS & mask);
|
2009-10-21 07:27:01 +00:00
|
|
|
|
2014-11-12 15:01:10 +00:00
|
|
|
/* Panel power sequencer */
|
2010-08-14 13:41:23 +00:00
|
|
|
if (HAS_PCH_SPLIT(dev)) {
|
2012-11-02 18:55:02 +00:00
|
|
|
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);
|
2014-11-12 14:25:43 +00:00
|
|
|
} else if (!IS_VALLEYVIEW(dev)) {
|
2012-11-02 18:55:02 +00:00
|
|
|
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);
|
2009-10-21 07:27:01 +00:00
|
|
|
}
|
2008-08-25 22:11:06 +00:00
|
|
|
|
2010-03-19 09:05:10 +00:00
|
|
|
/* only restore FBC info on the platform that supports FBC*/
|
2015-07-07 18:26:04 +00:00
|
|
|
intel_fbc_disable(dev_priv);
|
2014-01-23 14:49:15 +00:00
|
|
|
|
|
|
|
/* restore FBC interval */
|
|
|
|
if (HAS_FBC(dev) && INTEL_INFO(dev)->gen <= 4 && !IS_G4X(dev))
|
|
|
|
I915_WRITE(FBC_CONTROL, dev_priv->regfile.saveFBC_CONTROL);
|
2013-01-25 16:53:22 +00:00
|
|
|
|
2015-02-23 11:03:30 +00:00
|
|
|
i915_redisable_vga(dev);
|
2009-09-14 21:48:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int i915_save_state(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_i915_private *dev_priv = dev->dev_private;
|
|
|
|
int i;
|
|
|
|
|
2011-06-29 07:30:34 +00:00
|
|
|
mutex_lock(&dev->struct_mutex);
|
|
|
|
|
2009-09-14 21:48:42 +00:00
|
|
|
i915_save_display(dev);
|
|
|
|
|
2014-12-10 20:16:05 +00:00
|
|
|
if (IS_GEN4(dev))
|
|
|
|
pci_read_config_word(dev->pdev, GCDGMBUS,
|
|
|
|
&dev_priv->regfile.saveGCDGMBUS);
|
|
|
|
|
2009-09-14 21:48:42 +00:00
|
|
|
/* Cache mode state */
|
2013-10-11 19:09:29 +00:00
|
|
|
if (INTEL_INFO(dev)->gen < 7)
|
|
|
|
dev_priv->regfile.saveCACHE_MODE_0 = I915_READ(CACHE_MODE_0);
|
2009-09-14 21:48:42 +00:00
|
|
|
|
|
|
|
/* Memory Arbitration state */
|
2012-11-02 18:55:02 +00:00
|
|
|
dev_priv->regfile.saveMI_ARB_STATE = I915_READ(MI_ARB_STATE);
|
2009-09-14 21:48:42 +00:00
|
|
|
|
|
|
|
/* Scratch space */
|
|
|
|
for (i = 0; i < 16; i++) {
|
2012-11-02 18:55:02 +00:00
|
|
|
dev_priv->regfile.saveSWF0[i] = I915_READ(SWF00 + (i << 2));
|
|
|
|
dev_priv->regfile.saveSWF1[i] = I915_READ(SWF10 + (i << 2));
|
2009-09-14 21:48:42 +00:00
|
|
|
}
|
|
|
|
for (i = 0; i < 3; i++)
|
2012-11-02 18:55:02 +00:00
|
|
|
dev_priv->regfile.saveSWF2[i] = I915_READ(SWF30 + (i << 2));
|
2009-09-14 21:48:42 +00:00
|
|
|
|
2011-06-29 07:30:34 +00:00
|
|
|
mutex_unlock(&dev->struct_mutex);
|
|
|
|
|
2009-09-14 21:48:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int i915_restore_state(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct drm_i915_private *dev_priv = dev->dev_private;
|
|
|
|
int i;
|
|
|
|
|
2011-06-29 07:30:34 +00:00
|
|
|
mutex_lock(&dev->struct_mutex);
|
|
|
|
|
2013-06-12 09:15:12 +00:00
|
|
|
i915_gem_restore_fences(dev);
|
2014-12-10 20:16:05 +00:00
|
|
|
|
|
|
|
if (IS_GEN4(dev))
|
|
|
|
pci_write_config_word(dev->pdev, GCDGMBUS,
|
|
|
|
dev_priv->regfile.saveGCDGMBUS);
|
2009-09-14 21:48:42 +00:00
|
|
|
i915_restore_display(dev);
|
|
|
|
|
2008-08-25 22:11:06 +00:00
|
|
|
/* Cache mode state */
|
2013-10-11 19:09:29 +00:00
|
|
|
if (INTEL_INFO(dev)->gen < 7)
|
|
|
|
I915_WRITE(CACHE_MODE_0, dev_priv->regfile.saveCACHE_MODE_0 |
|
|
|
|
0xffff0000);
|
2008-08-25 22:11:06 +00:00
|
|
|
|
|
|
|
/* Memory arbitration state */
|
2012-11-02 18:55:02 +00:00
|
|
|
I915_WRITE(MI_ARB_STATE, dev_priv->regfile.saveMI_ARB_STATE | 0xffff0000);
|
2008-08-25 22:11:06 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 16; i++) {
|
2012-11-02 18:55:02 +00:00
|
|
|
I915_WRITE(SWF00 + (i << 2), dev_priv->regfile.saveSWF0[i]);
|
|
|
|
I915_WRITE(SWF10 + (i << 2), dev_priv->regfile.saveSWF1[i]);
|
2008-08-25 22:11:06 +00:00
|
|
|
}
|
|
|
|
for (i = 0; i < 3; i++)
|
2012-11-02 18:55:02 +00:00
|
|
|
I915_WRITE(SWF30 + (i << 2), dev_priv->regfile.saveSWF2[i]);
|
2008-08-25 22:11:06 +00:00
|
|
|
|
2011-06-29 07:30:34 +00:00
|
|
|
mutex_unlock(&dev->struct_mutex);
|
|
|
|
|
2010-07-20 22:44:45 +00:00
|
|
|
intel_i2c_reset(dev);
|
2009-12-01 19:56:30 +00:00
|
|
|
|
2008-08-25 22:11:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|