3 * Copyright 2008 (c) Intel Corporation
4 * Jesse Barnes <jbarnes@virtuousgeek.org>
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
27 #include "display/intel_fbc.h"
28 #include "display/intel_gmbus.h"
29 #include "display/intel_vga.h"
33 #include "i915_suspend.h"
35 static void i915_save_display(struct drm_i915_private *dev_priv)
37 struct pci_dev *pdev = dev_priv->drm.pdev;
39 /* Display arbitration control */
40 if (INTEL_GEN(dev_priv) <= 4)
41 dev_priv->regfile.saveDSPARB = I915_READ(DSPARB);
43 if (IS_GEN(dev_priv, 4))
44 pci_read_config_word(pdev, GCDGMBUS,
45 &dev_priv->regfile.saveGCDGMBUS);
48 static void i915_restore_display(struct drm_i915_private *dev_priv)
50 struct pci_dev *pdev = dev_priv->drm.pdev;
52 if (IS_GEN(dev_priv, 4))
53 pci_write_config_word(pdev, GCDGMBUS,
54 dev_priv->regfile.saveGCDGMBUS);
56 /* Display arbitration */
57 if (INTEL_GEN(dev_priv) <= 4)
58 I915_WRITE(DSPARB, dev_priv->regfile.saveDSPARB);
60 /* only restore FBC info on the platform that supports FBC*/
61 intel_fbc_global_disable(dev_priv);
63 intel_vga_redisable(dev_priv);
65 intel_gmbus_reset(dev_priv);
68 int i915_save_state(struct drm_i915_private *dev_priv)
72 i915_save_display(dev_priv);
75 if (IS_GEN(dev_priv, 2) && IS_MOBILE(dev_priv)) {
76 for (i = 0; i < 7; i++) {
77 dev_priv->regfile.saveSWF0[i] = I915_READ(SWF0(i));
78 dev_priv->regfile.saveSWF1[i] = I915_READ(SWF1(i));
80 for (i = 0; i < 3; i++)
81 dev_priv->regfile.saveSWF3[i] = I915_READ(SWF3(i));
82 } else if (IS_GEN(dev_priv, 2)) {
83 for (i = 0; i < 7; i++)
84 dev_priv->regfile.saveSWF1[i] = I915_READ(SWF1(i));
85 } else if (HAS_GMCH(dev_priv)) {
86 for (i = 0; i < 16; i++) {
87 dev_priv->regfile.saveSWF0[i] = I915_READ(SWF0(i));
88 dev_priv->regfile.saveSWF1[i] = I915_READ(SWF1(i));
90 for (i = 0; i < 3; i++)
91 dev_priv->regfile.saveSWF3[i] = I915_READ(SWF3(i));
97 int i915_restore_state(struct drm_i915_private *dev_priv)
101 i915_restore_display(dev_priv);
104 if (IS_GEN(dev_priv, 2) && IS_MOBILE(dev_priv)) {
105 for (i = 0; i < 7; i++) {
106 I915_WRITE(SWF0(i), dev_priv->regfile.saveSWF0[i]);
107 I915_WRITE(SWF1(i), dev_priv->regfile.saveSWF1[i]);
109 for (i = 0; i < 3; i++)
110 I915_WRITE(SWF3(i), dev_priv->regfile.saveSWF3[i]);
111 } else if (IS_GEN(dev_priv, 2)) {
112 for (i = 0; i < 7; i++)
113 I915_WRITE(SWF1(i), dev_priv->regfile.saveSWF1[i]);
114 } else if (HAS_GMCH(dev_priv)) {
115 for (i = 0; i < 16; i++) {
116 I915_WRITE(SWF0(i), dev_priv->regfile.saveSWF0[i]);
117 I915_WRITE(SWF1(i), dev_priv->regfile.saveSWF1[i]);
119 for (i = 0; i < 3; i++)
120 I915_WRITE(SWF3(i), dev_priv->regfile.saveSWF3[i]);