Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2012-2014 Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 21 | * IN THE SOFTWARE. |
| 22 | * |
| 23 | * Authors: |
| 24 | * Eugeni Dodonov <eugeni.dodonov@intel.com> |
| 25 | * Daniel Vetter <daniel.vetter@ffwll.ch> |
| 26 | * |
| 27 | */ |
| 28 | |
| 29 | #include <linux/pm_runtime.h> |
| 30 | #include <linux/vgaarb.h> |
| 31 | |
| 32 | #include "i915_drv.h" |
| 33 | #include "intel_drv.h" |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 34 | |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 35 | /** |
| 36 | * DOC: runtime pm |
| 37 | * |
| 38 | * The i915 driver supports dynamic enabling and disabling of entire hardware |
| 39 | * blocks at runtime. This is especially important on the display side where |
| 40 | * software is supposed to control many power gates manually on recent hardware, |
| 41 | * since on the GT side a lot of the power management is done by the hardware. |
| 42 | * But even there some manual control at the device level is required. |
| 43 | * |
| 44 | * Since i915 supports a diverse set of platforms with a unified codebase and |
| 45 | * hardware engineers just love to shuffle functionality around between power |
| 46 | * domains there's a sizeable amount of indirection required. This file provides |
| 47 | * generic functions to the driver for grabbing and releasing references for |
| 48 | * abstract power domains. It then maps those to the actual power wells |
| 49 | * present for a given platform. |
| 50 | */ |
| 51 | |
Suketu Shah | 5aefb23 | 2015-04-16 14:22:10 +0530 | [diff] [blame] | 52 | bool intel_display_power_well_is_enabled(struct drm_i915_private *dev_priv, |
Imre Deak | 438b8dc | 2017-07-11 23:42:30 +0300 | [diff] [blame] | 53 | enum i915_power_well_id power_well_id); |
Suketu Shah | 5aefb23 | 2015-04-16 14:22:10 +0530 | [diff] [blame] | 54 | |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 55 | static struct i915_power_well * |
Imre Deak | 438b8dc | 2017-07-11 23:42:30 +0300 | [diff] [blame] | 56 | lookup_power_well(struct drm_i915_private *dev_priv, |
| 57 | enum i915_power_well_id power_well_id); |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 58 | |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 59 | const char * |
| 60 | intel_display_power_domain_str(enum intel_display_power_domain domain) |
| 61 | { |
| 62 | switch (domain) { |
| 63 | case POWER_DOMAIN_PIPE_A: |
| 64 | return "PIPE_A"; |
| 65 | case POWER_DOMAIN_PIPE_B: |
| 66 | return "PIPE_B"; |
| 67 | case POWER_DOMAIN_PIPE_C: |
| 68 | return "PIPE_C"; |
| 69 | case POWER_DOMAIN_PIPE_A_PANEL_FITTER: |
| 70 | return "PIPE_A_PANEL_FITTER"; |
| 71 | case POWER_DOMAIN_PIPE_B_PANEL_FITTER: |
| 72 | return "PIPE_B_PANEL_FITTER"; |
| 73 | case POWER_DOMAIN_PIPE_C_PANEL_FITTER: |
| 74 | return "PIPE_C_PANEL_FITTER"; |
| 75 | case POWER_DOMAIN_TRANSCODER_A: |
| 76 | return "TRANSCODER_A"; |
| 77 | case POWER_DOMAIN_TRANSCODER_B: |
| 78 | return "TRANSCODER_B"; |
| 79 | case POWER_DOMAIN_TRANSCODER_C: |
| 80 | return "TRANSCODER_C"; |
| 81 | case POWER_DOMAIN_TRANSCODER_EDP: |
| 82 | return "TRANSCODER_EDP"; |
Jani Nikula | 4d1de97 | 2016-03-18 17:05:42 +0200 | [diff] [blame] | 83 | case POWER_DOMAIN_TRANSCODER_DSI_A: |
| 84 | return "TRANSCODER_DSI_A"; |
| 85 | case POWER_DOMAIN_TRANSCODER_DSI_C: |
| 86 | return "TRANSCODER_DSI_C"; |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 87 | case POWER_DOMAIN_PORT_DDI_A_LANES: |
| 88 | return "PORT_DDI_A_LANES"; |
| 89 | case POWER_DOMAIN_PORT_DDI_B_LANES: |
| 90 | return "PORT_DDI_B_LANES"; |
| 91 | case POWER_DOMAIN_PORT_DDI_C_LANES: |
| 92 | return "PORT_DDI_C_LANES"; |
| 93 | case POWER_DOMAIN_PORT_DDI_D_LANES: |
| 94 | return "PORT_DDI_D_LANES"; |
| 95 | case POWER_DOMAIN_PORT_DDI_E_LANES: |
| 96 | return "PORT_DDI_E_LANES"; |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 97 | case POWER_DOMAIN_PORT_DDI_A_IO: |
| 98 | return "PORT_DDI_A_IO"; |
| 99 | case POWER_DOMAIN_PORT_DDI_B_IO: |
| 100 | return "PORT_DDI_B_IO"; |
| 101 | case POWER_DOMAIN_PORT_DDI_C_IO: |
| 102 | return "PORT_DDI_C_IO"; |
| 103 | case POWER_DOMAIN_PORT_DDI_D_IO: |
| 104 | return "PORT_DDI_D_IO"; |
| 105 | case POWER_DOMAIN_PORT_DDI_E_IO: |
| 106 | return "PORT_DDI_E_IO"; |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 107 | case POWER_DOMAIN_PORT_DSI: |
| 108 | return "PORT_DSI"; |
| 109 | case POWER_DOMAIN_PORT_CRT: |
| 110 | return "PORT_CRT"; |
| 111 | case POWER_DOMAIN_PORT_OTHER: |
| 112 | return "PORT_OTHER"; |
| 113 | case POWER_DOMAIN_VGA: |
| 114 | return "VGA"; |
| 115 | case POWER_DOMAIN_AUDIO: |
| 116 | return "AUDIO"; |
| 117 | case POWER_DOMAIN_PLLS: |
| 118 | return "PLLS"; |
| 119 | case POWER_DOMAIN_AUX_A: |
| 120 | return "AUX_A"; |
| 121 | case POWER_DOMAIN_AUX_B: |
| 122 | return "AUX_B"; |
| 123 | case POWER_DOMAIN_AUX_C: |
| 124 | return "AUX_C"; |
| 125 | case POWER_DOMAIN_AUX_D: |
| 126 | return "AUX_D"; |
Rodrigo Vivi | a324fca | 2018-01-29 15:22:15 -0800 | [diff] [blame^] | 127 | case POWER_DOMAIN_AUX_F: |
| 128 | return "AUX_F"; |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 129 | case POWER_DOMAIN_GMBUS: |
| 130 | return "GMBUS"; |
| 131 | case POWER_DOMAIN_INIT: |
| 132 | return "INIT"; |
| 133 | case POWER_DOMAIN_MODESET: |
| 134 | return "MODESET"; |
Tvrtko Ursulin | b687637 | 2017-12-05 13:28:54 +0000 | [diff] [blame] | 135 | case POWER_DOMAIN_GT_IRQ: |
| 136 | return "GT_IRQ"; |
Daniel Stone | 9895ad0 | 2015-11-20 15:55:33 +0000 | [diff] [blame] | 137 | default: |
| 138 | MISSING_CASE(domain); |
| 139 | return "?"; |
| 140 | } |
| 141 | } |
| 142 | |
Damien Lespiau | e8ca932 | 2015-07-30 18:20:26 -0300 | [diff] [blame] | 143 | static void intel_power_well_enable(struct drm_i915_private *dev_priv, |
| 144 | struct i915_power_well *power_well) |
| 145 | { |
| 146 | DRM_DEBUG_KMS("enabling %s\n", power_well->name); |
| 147 | power_well->ops->enable(dev_priv, power_well); |
| 148 | power_well->hw_enabled = true; |
| 149 | } |
| 150 | |
Damien Lespiau | dcddab3 | 2015-07-30 18:20:27 -0300 | [diff] [blame] | 151 | static void intel_power_well_disable(struct drm_i915_private *dev_priv, |
| 152 | struct i915_power_well *power_well) |
| 153 | { |
| 154 | DRM_DEBUG_KMS("disabling %s\n", power_well->name); |
| 155 | power_well->hw_enabled = false; |
| 156 | power_well->ops->disable(dev_priv, power_well); |
| 157 | } |
| 158 | |
Imre Deak | b409ca9 | 2016-06-13 16:44:33 +0300 | [diff] [blame] | 159 | static void intel_power_well_get(struct drm_i915_private *dev_priv, |
| 160 | struct i915_power_well *power_well) |
| 161 | { |
| 162 | if (!power_well->count++) |
| 163 | intel_power_well_enable(dev_priv, power_well); |
| 164 | } |
| 165 | |
| 166 | static void intel_power_well_put(struct drm_i915_private *dev_priv, |
| 167 | struct i915_power_well *power_well) |
| 168 | { |
| 169 | WARN(!power_well->count, "Use count on power well %s is already zero", |
| 170 | power_well->name); |
| 171 | |
| 172 | if (!--power_well->count) |
| 173 | intel_power_well_disable(dev_priv, power_well); |
| 174 | } |
| 175 | |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 176 | /** |
| 177 | * __intel_display_power_is_enabled - unlocked check for a power domain |
| 178 | * @dev_priv: i915 device instance |
| 179 | * @domain: power domain to check |
| 180 | * |
| 181 | * This is the unlocked version of intel_display_power_is_enabled() and should |
| 182 | * only be used from error capture and recovery code where deadlocks are |
| 183 | * possible. |
| 184 | * |
| 185 | * Returns: |
| 186 | * True when the power domain is enabled, false otherwise. |
| 187 | */ |
Daniel Vetter | f458ebb | 2014-09-30 10:56:39 +0200 | [diff] [blame] | 188 | bool __intel_display_power_is_enabled(struct drm_i915_private *dev_priv, |
| 189 | enum intel_display_power_domain domain) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 190 | { |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 191 | struct i915_power_well *power_well; |
| 192 | bool is_enabled; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 193 | |
Sagar Arun Kamble | ad1443f | 2017-10-10 22:30:04 +0100 | [diff] [blame] | 194 | if (dev_priv->runtime_pm.suspended) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 195 | return false; |
| 196 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 197 | is_enabled = true; |
| 198 | |
Imre Deak | 75ccb2e | 2017-02-17 17:39:43 +0200 | [diff] [blame] | 199 | for_each_power_domain_well_rev(dev_priv, power_well, BIT_ULL(domain)) { |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 200 | if (power_well->always_on) |
| 201 | continue; |
| 202 | |
| 203 | if (!power_well->hw_enabled) { |
| 204 | is_enabled = false; |
| 205 | break; |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | return is_enabled; |
| 210 | } |
| 211 | |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 212 | /** |
Damien Lespiau | f61ccae | 2014-11-25 13:45:41 +0000 | [diff] [blame] | 213 | * intel_display_power_is_enabled - check for a power domain |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 214 | * @dev_priv: i915 device instance |
| 215 | * @domain: power domain to check |
| 216 | * |
| 217 | * This function can be used to check the hw power domain state. It is mostly |
| 218 | * used in hardware state readout functions. Everywhere else code should rely |
| 219 | * upon explicit power domain reference counting to ensure that the hardware |
| 220 | * block is powered up before accessing it. |
| 221 | * |
| 222 | * Callers must hold the relevant modesetting locks to ensure that concurrent |
| 223 | * threads can't disable the power well while the caller tries to read a few |
| 224 | * registers. |
| 225 | * |
| 226 | * Returns: |
| 227 | * True when the power domain is enabled, false otherwise. |
| 228 | */ |
Daniel Vetter | f458ebb | 2014-09-30 10:56:39 +0200 | [diff] [blame] | 229 | bool intel_display_power_is_enabled(struct drm_i915_private *dev_priv, |
| 230 | enum intel_display_power_domain domain) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 231 | { |
| 232 | struct i915_power_domains *power_domains; |
| 233 | bool ret; |
| 234 | |
| 235 | power_domains = &dev_priv->power_domains; |
| 236 | |
| 237 | mutex_lock(&power_domains->lock); |
Daniel Vetter | f458ebb | 2014-09-30 10:56:39 +0200 | [diff] [blame] | 238 | ret = __intel_display_power_is_enabled(dev_priv, domain); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 239 | mutex_unlock(&power_domains->lock); |
| 240 | |
| 241 | return ret; |
| 242 | } |
| 243 | |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 244 | /** |
| 245 | * intel_display_set_init_power - set the initial power domain state |
| 246 | * @dev_priv: i915 device instance |
| 247 | * @enable: whether to enable or disable the initial power domain state |
| 248 | * |
| 249 | * For simplicity our driver load/unload and system suspend/resume code assumes |
| 250 | * that all power domains are always enabled. This functions controls the state |
| 251 | * of this little hack. While the initial power domain state is enabled runtime |
| 252 | * pm is effectively disabled. |
| 253 | */ |
Daniel Vetter | d9bc89d9 | 2014-09-30 10:56:40 +0200 | [diff] [blame] | 254 | void intel_display_set_init_power(struct drm_i915_private *dev_priv, |
| 255 | bool enable) |
| 256 | { |
| 257 | if (dev_priv->power_domains.init_power_on == enable) |
| 258 | return; |
| 259 | |
| 260 | if (enable) |
| 261 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
| 262 | else |
| 263 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
| 264 | |
| 265 | dev_priv->power_domains.init_power_on = enable; |
| 266 | } |
| 267 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 268 | /* |
| 269 | * Starting with Haswell, we have a "Power Down Well" that can be turned off |
| 270 | * when not needed anymore. We have 4 registers that can request the power well |
| 271 | * to be enabled, and it will only be disabled if none of the registers is |
| 272 | * requesting it to be enabled. |
| 273 | */ |
Imre Deak | 001bd2c | 2017-07-12 18:54:13 +0300 | [diff] [blame] | 274 | static void hsw_power_well_post_enable(struct drm_i915_private *dev_priv, |
| 275 | u8 irq_pipe_mask, bool has_vga) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 276 | { |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 277 | struct pci_dev *pdev = dev_priv->drm.pdev; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 278 | |
| 279 | /* |
| 280 | * After we re-enable the power well, if we touch VGA register 0x3d5 |
| 281 | * we'll get unclaimed register interrupts. This stops after we write |
| 282 | * anything to the VGA MSR register. The vgacon module uses this |
| 283 | * register all the time, so if we unbind our driver and, as a |
| 284 | * consequence, bind vgacon, we'll get stuck in an infinite loop at |
| 285 | * console_unlock(). So make here we touch the VGA MSR register, making |
| 286 | * sure vgacon can keep working normally without triggering interrupts |
| 287 | * and error messages. |
| 288 | */ |
Imre Deak | 001bd2c | 2017-07-12 18:54:13 +0300 | [diff] [blame] | 289 | if (has_vga) { |
| 290 | vga_get_uninterruptible(pdev, VGA_RSRC_LEGACY_IO); |
| 291 | outb(inb(VGA_MSR_READ), VGA_MSR_WRITE); |
| 292 | vga_put(pdev, VGA_RSRC_LEGACY_IO); |
| 293 | } |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 294 | |
Imre Deak | 001bd2c | 2017-07-12 18:54:13 +0300 | [diff] [blame] | 295 | if (irq_pipe_mask) |
| 296 | gen8_irq_power_well_post_enable(dev_priv, irq_pipe_mask); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 297 | } |
| 298 | |
Imre Deak | 001bd2c | 2017-07-12 18:54:13 +0300 | [diff] [blame] | 299 | static void hsw_power_well_pre_disable(struct drm_i915_private *dev_priv, |
| 300 | u8 irq_pipe_mask) |
Ville Syrjälä | aae8ba8 | 2016-02-19 20:47:30 +0200 | [diff] [blame] | 301 | { |
Imre Deak | 001bd2c | 2017-07-12 18:54:13 +0300 | [diff] [blame] | 302 | if (irq_pipe_mask) |
| 303 | gen8_irq_power_well_pre_disable(dev_priv, irq_pipe_mask); |
Ville Syrjälä | aae8ba8 | 2016-02-19 20:47:30 +0200 | [diff] [blame] | 304 | } |
| 305 | |
Ville Syrjälä | aae8ba8 | 2016-02-19 20:47:30 +0200 | [diff] [blame] | 306 | |
Imre Deak | 76347c0 | 2017-07-06 17:40:36 +0300 | [diff] [blame] | 307 | static void hsw_wait_for_power_well_enable(struct drm_i915_private *dev_priv, |
| 308 | struct i915_power_well *power_well) |
Imre Deak | 42d9366 | 2017-06-29 18:37:01 +0300 | [diff] [blame] | 309 | { |
Imre Deak | 438b8dc | 2017-07-11 23:42:30 +0300 | [diff] [blame] | 310 | enum i915_power_well_id id = power_well->id; |
Imre Deak | 42d9366 | 2017-06-29 18:37:01 +0300 | [diff] [blame] | 311 | |
| 312 | /* Timeout for PW1:10 us, AUX:not specified, other PWs:20 us. */ |
| 313 | WARN_ON(intel_wait_for_register(dev_priv, |
Imre Deak | 9c3a16c | 2017-08-14 18:15:30 +0300 | [diff] [blame] | 314 | HSW_PWR_WELL_CTL_DRIVER(id), |
Imre Deak | 1af474f | 2017-07-06 17:40:34 +0300 | [diff] [blame] | 315 | HSW_PWR_WELL_CTL_STATE(id), |
| 316 | HSW_PWR_WELL_CTL_STATE(id), |
Imre Deak | 42d9366 | 2017-06-29 18:37:01 +0300 | [diff] [blame] | 317 | 1)); |
| 318 | } |
| 319 | |
Imre Deak | 76347c0 | 2017-07-06 17:40:36 +0300 | [diff] [blame] | 320 | static u32 hsw_power_well_requesters(struct drm_i915_private *dev_priv, |
| 321 | enum i915_power_well_id id) |
Imre Deak | 42d9366 | 2017-06-29 18:37:01 +0300 | [diff] [blame] | 322 | { |
Imre Deak | 1af474f | 2017-07-06 17:40:34 +0300 | [diff] [blame] | 323 | u32 req_mask = HSW_PWR_WELL_CTL_REQ(id); |
Imre Deak | 42d9366 | 2017-06-29 18:37:01 +0300 | [diff] [blame] | 324 | u32 ret; |
| 325 | |
Imre Deak | 9c3a16c | 2017-08-14 18:15:30 +0300 | [diff] [blame] | 326 | ret = I915_READ(HSW_PWR_WELL_CTL_BIOS(id)) & req_mask ? 1 : 0; |
| 327 | ret |= I915_READ(HSW_PWR_WELL_CTL_DRIVER(id)) & req_mask ? 2 : 0; |
| 328 | ret |= I915_READ(HSW_PWR_WELL_CTL_KVMR) & req_mask ? 4 : 0; |
| 329 | ret |= I915_READ(HSW_PWR_WELL_CTL_DEBUG(id)) & req_mask ? 8 : 0; |
Imre Deak | 42d9366 | 2017-06-29 18:37:01 +0300 | [diff] [blame] | 330 | |
| 331 | return ret; |
| 332 | } |
| 333 | |
Imre Deak | 76347c0 | 2017-07-06 17:40:36 +0300 | [diff] [blame] | 334 | static void hsw_wait_for_power_well_disable(struct drm_i915_private *dev_priv, |
| 335 | struct i915_power_well *power_well) |
Imre Deak | 42d9366 | 2017-06-29 18:37:01 +0300 | [diff] [blame] | 336 | { |
Imre Deak | 438b8dc | 2017-07-11 23:42:30 +0300 | [diff] [blame] | 337 | enum i915_power_well_id id = power_well->id; |
Imre Deak | 42d9366 | 2017-06-29 18:37:01 +0300 | [diff] [blame] | 338 | bool disabled; |
| 339 | u32 reqs; |
| 340 | |
| 341 | /* |
| 342 | * Bspec doesn't require waiting for PWs to get disabled, but still do |
| 343 | * this for paranoia. The known cases where a PW will be forced on: |
| 344 | * - a KVMR request on any power well via the KVMR request register |
| 345 | * - a DMC request on PW1 and MISC_IO power wells via the BIOS and |
| 346 | * DEBUG request registers |
| 347 | * Skip the wait in case any of the request bits are set and print a |
| 348 | * diagnostic message. |
| 349 | */ |
Imre Deak | 9c3a16c | 2017-08-14 18:15:30 +0300 | [diff] [blame] | 350 | wait_for((disabled = !(I915_READ(HSW_PWR_WELL_CTL_DRIVER(id)) & |
Imre Deak | 1af474f | 2017-07-06 17:40:34 +0300 | [diff] [blame] | 351 | HSW_PWR_WELL_CTL_STATE(id))) || |
Imre Deak | 76347c0 | 2017-07-06 17:40:36 +0300 | [diff] [blame] | 352 | (reqs = hsw_power_well_requesters(dev_priv, id)), 1); |
Imre Deak | 42d9366 | 2017-06-29 18:37:01 +0300 | [diff] [blame] | 353 | if (disabled) |
| 354 | return; |
| 355 | |
| 356 | DRM_DEBUG_KMS("%s forced on (bios:%d driver:%d kvmr:%d debug:%d)\n", |
| 357 | power_well->name, |
| 358 | !!(reqs & 1), !!(reqs & 2), !!(reqs & 4), !!(reqs & 8)); |
| 359 | } |
| 360 | |
Imre Deak | b2891eb | 2017-07-11 23:42:35 +0300 | [diff] [blame] | 361 | static void gen9_wait_for_power_well_fuses(struct drm_i915_private *dev_priv, |
| 362 | enum skl_power_gate pg) |
| 363 | { |
| 364 | /* Timeout 5us for PG#0, for other PGs 1us */ |
| 365 | WARN_ON(intel_wait_for_register(dev_priv, SKL_FUSE_STATUS, |
| 366 | SKL_FUSE_PG_DIST_STATUS(pg), |
| 367 | SKL_FUSE_PG_DIST_STATUS(pg), 1)); |
| 368 | } |
| 369 | |
Imre Deak | ec46d48 | 2017-07-06 17:40:33 +0300 | [diff] [blame] | 370 | static void hsw_power_well_enable(struct drm_i915_private *dev_priv, |
| 371 | struct i915_power_well *power_well) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 372 | { |
Imre Deak | 1af474f | 2017-07-06 17:40:34 +0300 | [diff] [blame] | 373 | enum i915_power_well_id id = power_well->id; |
Imre Deak | b2891eb | 2017-07-11 23:42:35 +0300 | [diff] [blame] | 374 | bool wait_fuses = power_well->hsw.has_fuses; |
Chris Wilson | 320671f | 2017-10-02 11:04:16 +0100 | [diff] [blame] | 375 | enum skl_power_gate uninitialized_var(pg); |
Imre Deak | 1af474f | 2017-07-06 17:40:34 +0300 | [diff] [blame] | 376 | u32 val; |
| 377 | |
Imre Deak | b2891eb | 2017-07-11 23:42:35 +0300 | [diff] [blame] | 378 | if (wait_fuses) { |
| 379 | pg = SKL_PW_TO_PG(id); |
| 380 | /* |
| 381 | * For PW1 we have to wait both for the PW0/PG0 fuse state |
| 382 | * before enabling the power well and PW1/PG1's own fuse |
| 383 | * state after the enabling. For all other power wells with |
| 384 | * fuses we only have to wait for that PW/PG's fuse state |
| 385 | * after the enabling. |
| 386 | */ |
| 387 | if (pg == SKL_PG1) |
| 388 | gen9_wait_for_power_well_fuses(dev_priv, SKL_PG0); |
| 389 | } |
| 390 | |
Imre Deak | 9c3a16c | 2017-08-14 18:15:30 +0300 | [diff] [blame] | 391 | val = I915_READ(HSW_PWR_WELL_CTL_DRIVER(id)); |
| 392 | I915_WRITE(HSW_PWR_WELL_CTL_DRIVER(id), val | HSW_PWR_WELL_CTL_REQ(id)); |
Imre Deak | 76347c0 | 2017-07-06 17:40:36 +0300 | [diff] [blame] | 393 | hsw_wait_for_power_well_enable(dev_priv, power_well); |
Imre Deak | 001bd2c | 2017-07-12 18:54:13 +0300 | [diff] [blame] | 394 | |
Lucas De Marchi | ddd39e4 | 2017-11-28 14:05:53 -0800 | [diff] [blame] | 395 | /* Display WA #1178: cnl */ |
| 396 | if (IS_CANNONLAKE(dev_priv) && |
| 397 | (id == CNL_DISP_PW_AUX_B || id == CNL_DISP_PW_AUX_C || |
| 398 | id == CNL_DISP_PW_AUX_D)) { |
| 399 | val = I915_READ(CNL_AUX_ANAOVRD1(id)); |
| 400 | val |= CNL_AUX_ANAOVRD1_ENABLE | CNL_AUX_ANAOVRD1_LDO_BYPASS; |
| 401 | I915_WRITE(CNL_AUX_ANAOVRD1(id), val); |
| 402 | } |
| 403 | |
Imre Deak | b2891eb | 2017-07-11 23:42:35 +0300 | [diff] [blame] | 404 | if (wait_fuses) |
| 405 | gen9_wait_for_power_well_fuses(dev_priv, pg); |
| 406 | |
Imre Deak | 001bd2c | 2017-07-12 18:54:13 +0300 | [diff] [blame] | 407 | hsw_power_well_post_enable(dev_priv, power_well->hsw.irq_pipe_mask, |
| 408 | power_well->hsw.has_vga); |
Imre Deak | ec46d48 | 2017-07-06 17:40:33 +0300 | [diff] [blame] | 409 | } |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 410 | |
Imre Deak | ec46d48 | 2017-07-06 17:40:33 +0300 | [diff] [blame] | 411 | static void hsw_power_well_disable(struct drm_i915_private *dev_priv, |
| 412 | struct i915_power_well *power_well) |
| 413 | { |
Imre Deak | 1af474f | 2017-07-06 17:40:34 +0300 | [diff] [blame] | 414 | enum i915_power_well_id id = power_well->id; |
| 415 | u32 val; |
| 416 | |
Imre Deak | 001bd2c | 2017-07-12 18:54:13 +0300 | [diff] [blame] | 417 | hsw_power_well_pre_disable(dev_priv, power_well->hsw.irq_pipe_mask); |
| 418 | |
Imre Deak | 9c3a16c | 2017-08-14 18:15:30 +0300 | [diff] [blame] | 419 | val = I915_READ(HSW_PWR_WELL_CTL_DRIVER(id)); |
| 420 | I915_WRITE(HSW_PWR_WELL_CTL_DRIVER(id), |
| 421 | val & ~HSW_PWR_WELL_CTL_REQ(id)); |
Imre Deak | 76347c0 | 2017-07-06 17:40:36 +0300 | [diff] [blame] | 422 | hsw_wait_for_power_well_disable(dev_priv, power_well); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 423 | } |
| 424 | |
Imre Deak | d42539b | 2017-07-06 17:40:39 +0300 | [diff] [blame] | 425 | /* |
| 426 | * We should only use the power well if we explicitly asked the hardware to |
| 427 | * enable it, so check if it's enabled and also check if we've requested it to |
| 428 | * be enabled. |
| 429 | */ |
| 430 | static bool hsw_power_well_enabled(struct drm_i915_private *dev_priv, |
| 431 | struct i915_power_well *power_well) |
| 432 | { |
| 433 | enum i915_power_well_id id = power_well->id; |
| 434 | u32 mask = HSW_PWR_WELL_CTL_REQ(id) | HSW_PWR_WELL_CTL_STATE(id); |
| 435 | |
Imre Deak | 9c3a16c | 2017-08-14 18:15:30 +0300 | [diff] [blame] | 436 | return (I915_READ(HSW_PWR_WELL_CTL_DRIVER(id)) & mask) == mask; |
Imre Deak | d42539b | 2017-07-06 17:40:39 +0300 | [diff] [blame] | 437 | } |
| 438 | |
A.Sunil Kamath | 664326f | 2014-11-24 13:37:44 +0530 | [diff] [blame] | 439 | static void assert_can_enable_dc9(struct drm_i915_private *dev_priv) |
| 440 | { |
Imre Deak | 9c3a16c | 2017-08-14 18:15:30 +0300 | [diff] [blame] | 441 | enum i915_power_well_id id = SKL_DISP_PW_2; |
| 442 | |
Imre Deak | bfcdabe | 2016-04-01 16:02:37 +0300 | [diff] [blame] | 443 | WARN_ONCE((I915_READ(DC_STATE_EN) & DC_STATE_EN_DC9), |
| 444 | "DC9 already programmed to be enabled.\n"); |
| 445 | WARN_ONCE(I915_READ(DC_STATE_EN) & DC_STATE_EN_UPTO_DC5, |
| 446 | "DC5 still not disabled to enable DC9.\n"); |
Imre Deak | 9c3a16c | 2017-08-14 18:15:30 +0300 | [diff] [blame] | 447 | WARN_ONCE(I915_READ(HSW_PWR_WELL_CTL_DRIVER(id)) & |
| 448 | HSW_PWR_WELL_CTL_REQ(id), |
Imre Deak | e8a3a2a | 2017-06-29 18:37:00 +0300 | [diff] [blame] | 449 | "Power well 2 on.\n"); |
Imre Deak | bfcdabe | 2016-04-01 16:02:37 +0300 | [diff] [blame] | 450 | WARN_ONCE(intel_irqs_enabled(dev_priv), |
| 451 | "Interrupts not disabled yet.\n"); |
A.Sunil Kamath | 664326f | 2014-11-24 13:37:44 +0530 | [diff] [blame] | 452 | |
| 453 | /* |
| 454 | * TODO: check for the following to verify the conditions to enter DC9 |
| 455 | * state are satisfied: |
| 456 | * 1] Check relevant display engine registers to verify if mode set |
| 457 | * disable sequence was followed. |
| 458 | * 2] Check if display uninitialize sequence is initialized. |
| 459 | */ |
| 460 | } |
| 461 | |
| 462 | static void assert_can_disable_dc9(struct drm_i915_private *dev_priv) |
| 463 | { |
Imre Deak | bfcdabe | 2016-04-01 16:02:37 +0300 | [diff] [blame] | 464 | WARN_ONCE(intel_irqs_enabled(dev_priv), |
| 465 | "Interrupts not disabled yet.\n"); |
| 466 | WARN_ONCE(I915_READ(DC_STATE_EN) & DC_STATE_EN_UPTO_DC5, |
| 467 | "DC5 still not disabled.\n"); |
A.Sunil Kamath | 664326f | 2014-11-24 13:37:44 +0530 | [diff] [blame] | 468 | |
| 469 | /* |
| 470 | * TODO: check for the following to verify DC9 state was indeed |
| 471 | * entered before programming to disable it: |
| 472 | * 1] Check relevant display engine registers to verify if mode |
| 473 | * set disable sequence was followed. |
| 474 | * 2] Check if display uninitialize sequence is initialized. |
| 475 | */ |
| 476 | } |
| 477 | |
Mika Kuoppala | 779cb5d | 2016-02-18 17:58:09 +0200 | [diff] [blame] | 478 | static void gen9_write_dc_state(struct drm_i915_private *dev_priv, |
| 479 | u32 state) |
| 480 | { |
| 481 | int rewrites = 0; |
| 482 | int rereads = 0; |
| 483 | u32 v; |
| 484 | |
| 485 | I915_WRITE(DC_STATE_EN, state); |
| 486 | |
| 487 | /* It has been observed that disabling the dc6 state sometimes |
| 488 | * doesn't stick and dmc keeps returning old value. Make sure |
| 489 | * the write really sticks enough times and also force rewrite until |
| 490 | * we are confident that state is exactly what we want. |
| 491 | */ |
| 492 | do { |
| 493 | v = I915_READ(DC_STATE_EN); |
| 494 | |
| 495 | if (v != state) { |
| 496 | I915_WRITE(DC_STATE_EN, state); |
| 497 | rewrites++; |
| 498 | rereads = 0; |
| 499 | } else if (rereads++ > 5) { |
| 500 | break; |
| 501 | } |
| 502 | |
| 503 | } while (rewrites < 100); |
| 504 | |
| 505 | if (v != state) |
| 506 | DRM_ERROR("Writing dc state to 0x%x failed, now 0x%x\n", |
| 507 | state, v); |
| 508 | |
| 509 | /* Most of the times we need one retry, avoid spam */ |
| 510 | if (rewrites > 1) |
| 511 | DRM_DEBUG_KMS("Rewrote dc state to 0x%x %d times\n", |
| 512 | state, rewrites); |
| 513 | } |
| 514 | |
Imre Deak | da2f41d | 2016-04-20 20:27:56 +0300 | [diff] [blame] | 515 | static u32 gen9_dc_mask(struct drm_i915_private *dev_priv) |
A.Sunil Kamath | 664326f | 2014-11-24 13:37:44 +0530 | [diff] [blame] | 516 | { |
Imre Deak | da2f41d | 2016-04-20 20:27:56 +0300 | [diff] [blame] | 517 | u32 mask; |
A.Sunil Kamath | 664326f | 2014-11-24 13:37:44 +0530 | [diff] [blame] | 518 | |
Imre Deak | 13ae3a0 | 2015-11-04 19:24:16 +0200 | [diff] [blame] | 519 | mask = DC_STATE_EN_UPTO_DC5; |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 520 | if (IS_GEN9_LP(dev_priv)) |
Imre Deak | 13ae3a0 | 2015-11-04 19:24:16 +0200 | [diff] [blame] | 521 | mask |= DC_STATE_EN_DC9; |
| 522 | else |
| 523 | mask |= DC_STATE_EN_UPTO_DC6; |
A.Sunil Kamath | 664326f | 2014-11-24 13:37:44 +0530 | [diff] [blame] | 524 | |
Imre Deak | da2f41d | 2016-04-20 20:27:56 +0300 | [diff] [blame] | 525 | return mask; |
| 526 | } |
| 527 | |
| 528 | void gen9_sanitize_dc_state(struct drm_i915_private *dev_priv) |
| 529 | { |
| 530 | u32 val; |
| 531 | |
| 532 | val = I915_READ(DC_STATE_EN) & gen9_dc_mask(dev_priv); |
| 533 | |
| 534 | DRM_DEBUG_KMS("Resetting DC state tracking from %02x to %02x\n", |
| 535 | dev_priv->csr.dc_state, val); |
| 536 | dev_priv->csr.dc_state = val; |
| 537 | } |
| 538 | |
| 539 | static void gen9_set_dc_state(struct drm_i915_private *dev_priv, uint32_t state) |
| 540 | { |
| 541 | uint32_t val; |
| 542 | uint32_t mask; |
| 543 | |
Imre Deak | a37baf3 | 2016-02-29 22:49:03 +0200 | [diff] [blame] | 544 | if (WARN_ON_ONCE(state & ~dev_priv->csr.allowed_dc_mask)) |
| 545 | state &= dev_priv->csr.allowed_dc_mask; |
Patrik Jakobsson | 443646c | 2015-11-16 15:01:06 +0100 | [diff] [blame] | 546 | |
A.Sunil Kamath | 664326f | 2014-11-24 13:37:44 +0530 | [diff] [blame] | 547 | val = I915_READ(DC_STATE_EN); |
Imre Deak | da2f41d | 2016-04-20 20:27:56 +0300 | [diff] [blame] | 548 | mask = gen9_dc_mask(dev_priv); |
Imre Deak | 13ae3a0 | 2015-11-04 19:24:16 +0200 | [diff] [blame] | 549 | DRM_DEBUG_KMS("Setting DC state from %02x to %02x\n", |
| 550 | val & mask, state); |
Patrik Jakobsson | 832dba8 | 2016-02-18 17:21:11 +0200 | [diff] [blame] | 551 | |
| 552 | /* Check if DMC is ignoring our DC state requests */ |
| 553 | if ((val & mask) != dev_priv->csr.dc_state) |
| 554 | DRM_ERROR("DC state mismatch (0x%x -> 0x%x)\n", |
| 555 | dev_priv->csr.dc_state, val & mask); |
| 556 | |
Imre Deak | 13ae3a0 | 2015-11-04 19:24:16 +0200 | [diff] [blame] | 557 | val &= ~mask; |
| 558 | val |= state; |
Mika Kuoppala | 779cb5d | 2016-02-18 17:58:09 +0200 | [diff] [blame] | 559 | |
| 560 | gen9_write_dc_state(dev_priv, val); |
Patrik Jakobsson | 832dba8 | 2016-02-18 17:21:11 +0200 | [diff] [blame] | 561 | |
| 562 | dev_priv->csr.dc_state = val & mask; |
A.Sunil Kamath | 664326f | 2014-11-24 13:37:44 +0530 | [diff] [blame] | 563 | } |
| 564 | |
Imre Deak | 13ae3a0 | 2015-11-04 19:24:16 +0200 | [diff] [blame] | 565 | void bxt_enable_dc9(struct drm_i915_private *dev_priv) |
| 566 | { |
| 567 | assert_can_enable_dc9(dev_priv); |
| 568 | |
| 569 | DRM_DEBUG_KMS("Enabling DC9\n"); |
| 570 | |
Imre Deak | 7859799 | 2016-06-16 16:37:20 +0300 | [diff] [blame] | 571 | intel_power_sequencer_reset(dev_priv); |
Imre Deak | 13ae3a0 | 2015-11-04 19:24:16 +0200 | [diff] [blame] | 572 | gen9_set_dc_state(dev_priv, DC_STATE_EN_DC9); |
| 573 | } |
| 574 | |
A.Sunil Kamath | 664326f | 2014-11-24 13:37:44 +0530 | [diff] [blame] | 575 | void bxt_disable_dc9(struct drm_i915_private *dev_priv) |
| 576 | { |
A.Sunil Kamath | 664326f | 2014-11-24 13:37:44 +0530 | [diff] [blame] | 577 | assert_can_disable_dc9(dev_priv); |
| 578 | |
| 579 | DRM_DEBUG_KMS("Disabling DC9\n"); |
| 580 | |
Imre Deak | 13ae3a0 | 2015-11-04 19:24:16 +0200 | [diff] [blame] | 581 | gen9_set_dc_state(dev_priv, DC_STATE_DISABLE); |
Imre Deak | 8090ba8 | 2016-08-10 14:07:33 +0300 | [diff] [blame] | 582 | |
| 583 | intel_pps_unlock_regs_wa(dev_priv); |
A.Sunil Kamath | 664326f | 2014-11-24 13:37:44 +0530 | [diff] [blame] | 584 | } |
| 585 | |
Daniel Vetter | af5fead | 2015-10-28 23:58:57 +0200 | [diff] [blame] | 586 | static void assert_csr_loaded(struct drm_i915_private *dev_priv) |
| 587 | { |
| 588 | WARN_ONCE(!I915_READ(CSR_PROGRAM(0)), |
| 589 | "CSR program storage start is NULL\n"); |
| 590 | WARN_ONCE(!I915_READ(CSR_SSP_BASE), "CSR SSP Base Not fine\n"); |
| 591 | WARN_ONCE(!I915_READ(CSR_HTP_SKL), "CSR HTP Not fine\n"); |
| 592 | } |
| 593 | |
Suketu Shah | 5aefb23 | 2015-04-16 14:22:10 +0530 | [diff] [blame] | 594 | static void assert_can_enable_dc5(struct drm_i915_private *dev_priv) |
Suketu Shah | dc17430 | 2015-04-17 19:46:16 +0530 | [diff] [blame] | 595 | { |
Suketu Shah | 5aefb23 | 2015-04-16 14:22:10 +0530 | [diff] [blame] | 596 | bool pg2_enabled = intel_display_power_well_is_enabled(dev_priv, |
| 597 | SKL_DISP_PW_2); |
| 598 | |
Jesse Barnes | 6ff8ab0 | 2015-09-10 08:20:28 -0700 | [diff] [blame] | 599 | WARN_ONCE(pg2_enabled, "PG2 not disabled to enable DC5.\n"); |
Suketu Shah | 5aefb23 | 2015-04-16 14:22:10 +0530 | [diff] [blame] | 600 | |
Jesse Barnes | 6ff8ab0 | 2015-09-10 08:20:28 -0700 | [diff] [blame] | 601 | WARN_ONCE((I915_READ(DC_STATE_EN) & DC_STATE_EN_UPTO_DC5), |
| 602 | "DC5 already programmed to be enabled.\n"); |
Imre Deak | c9b8846 | 2015-12-15 20:10:34 +0200 | [diff] [blame] | 603 | assert_rpm_wakelock_held(dev_priv); |
Suketu Shah | 5aefb23 | 2015-04-16 14:22:10 +0530 | [diff] [blame] | 604 | |
| 605 | assert_csr_loaded(dev_priv); |
| 606 | } |
| 607 | |
Imre Deak | f62c79b | 2016-04-20 20:27:57 +0300 | [diff] [blame] | 608 | void gen9_enable_dc5(struct drm_i915_private *dev_priv) |
Suketu Shah | 5aefb23 | 2015-04-16 14:22:10 +0530 | [diff] [blame] | 609 | { |
Suketu Shah | 5aefb23 | 2015-04-16 14:22:10 +0530 | [diff] [blame] | 610 | assert_can_enable_dc5(dev_priv); |
A.Sunil Kamath | 6b457d3 | 2015-04-16 14:22:09 +0530 | [diff] [blame] | 611 | |
| 612 | DRM_DEBUG_KMS("Enabling DC5\n"); |
| 613 | |
Lucas De Marchi | 53421c2 | 2017-12-04 15:22:10 -0800 | [diff] [blame] | 614 | /* Wa Display #1183: skl,kbl,cfl */ |
| 615 | if (IS_GEN9_BC(dev_priv)) |
| 616 | I915_WRITE(GEN8_CHICKEN_DCPR_1, I915_READ(GEN8_CHICKEN_DCPR_1) | |
| 617 | SKL_SELECT_ALTERNATE_DC_EXIT); |
| 618 | |
Imre Deak | 13ae3a0 | 2015-11-04 19:24:16 +0200 | [diff] [blame] | 619 | gen9_set_dc_state(dev_priv, DC_STATE_EN_UPTO_DC5); |
Suketu Shah | dc17430 | 2015-04-17 19:46:16 +0530 | [diff] [blame] | 620 | } |
| 621 | |
Suketu Shah | 93c7cb6 | 2015-04-16 14:22:13 +0530 | [diff] [blame] | 622 | static void assert_can_enable_dc6(struct drm_i915_private *dev_priv) |
Suketu Shah | f75a198 | 2015-04-16 14:22:11 +0530 | [diff] [blame] | 623 | { |
Jesse Barnes | 6ff8ab0 | 2015-09-10 08:20:28 -0700 | [diff] [blame] | 624 | WARN_ONCE(I915_READ(UTIL_PIN_CTL) & UTIL_PIN_ENABLE, |
| 625 | "Backlight is not disabled.\n"); |
| 626 | WARN_ONCE((I915_READ(DC_STATE_EN) & DC_STATE_EN_UPTO_DC6), |
| 627 | "DC6 already programmed to be enabled.\n"); |
Suketu Shah | 93c7cb6 | 2015-04-16 14:22:13 +0530 | [diff] [blame] | 628 | |
| 629 | assert_csr_loaded(dev_priv); |
| 630 | } |
| 631 | |
Animesh Manna | 0a9d2be | 2015-09-29 11:01:59 +0530 | [diff] [blame] | 632 | void skl_enable_dc6(struct drm_i915_private *dev_priv) |
Suketu Shah | 93c7cb6 | 2015-04-16 14:22:13 +0530 | [diff] [blame] | 633 | { |
Suketu Shah | 93c7cb6 | 2015-04-16 14:22:13 +0530 | [diff] [blame] | 634 | assert_can_enable_dc6(dev_priv); |
A.Sunil Kamath | 74b4f37 | 2015-04-16 14:22:12 +0530 | [diff] [blame] | 635 | |
| 636 | DRM_DEBUG_KMS("Enabling DC6\n"); |
| 637 | |
Imre Deak | 13ae3a0 | 2015-11-04 19:24:16 +0200 | [diff] [blame] | 638 | gen9_set_dc_state(dev_priv, DC_STATE_EN_UPTO_DC6); |
| 639 | |
Suketu Shah | f75a198 | 2015-04-16 14:22:11 +0530 | [diff] [blame] | 640 | } |
| 641 | |
Animesh Manna | 0a9d2be | 2015-09-29 11:01:59 +0530 | [diff] [blame] | 642 | void skl_disable_dc6(struct drm_i915_private *dev_priv) |
Suketu Shah | f75a198 | 2015-04-16 14:22:11 +0530 | [diff] [blame] | 643 | { |
A.Sunil Kamath | 74b4f37 | 2015-04-16 14:22:12 +0530 | [diff] [blame] | 644 | DRM_DEBUG_KMS("Disabling DC6\n"); |
| 645 | |
Lucas De Marchi | 53421c2 | 2017-12-04 15:22:10 -0800 | [diff] [blame] | 646 | /* Wa Display #1183: skl,kbl,cfl */ |
| 647 | if (IS_GEN9_BC(dev_priv)) |
| 648 | I915_WRITE(GEN8_CHICKEN_DCPR_1, I915_READ(GEN8_CHICKEN_DCPR_1) | |
| 649 | SKL_SELECT_ALTERNATE_DC_EXIT); |
| 650 | |
Imre Deak | 13ae3a0 | 2015-11-04 19:24:16 +0200 | [diff] [blame] | 651 | gen9_set_dc_state(dev_priv, DC_STATE_DISABLE); |
Suketu Shah | f75a198 | 2015-04-16 14:22:11 +0530 | [diff] [blame] | 652 | } |
| 653 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 654 | static void hsw_power_well_sync_hw(struct drm_i915_private *dev_priv, |
| 655 | struct i915_power_well *power_well) |
| 656 | { |
Imre Deak | 1af474f | 2017-07-06 17:40:34 +0300 | [diff] [blame] | 657 | enum i915_power_well_id id = power_well->id; |
| 658 | u32 mask = HSW_PWR_WELL_CTL_REQ(id); |
Imre Deak | 9c3a16c | 2017-08-14 18:15:30 +0300 | [diff] [blame] | 659 | u32 bios_req = I915_READ(HSW_PWR_WELL_CTL_BIOS(id)); |
Imre Deak | 1af474f | 2017-07-06 17:40:34 +0300 | [diff] [blame] | 660 | |
Imre Deak | 16e8491 | 2017-02-17 17:39:45 +0200 | [diff] [blame] | 661 | /* Take over the request bit if set by BIOS. */ |
Imre Deak | 1af474f | 2017-07-06 17:40:34 +0300 | [diff] [blame] | 662 | if (bios_req & mask) { |
Imre Deak | 9c3a16c | 2017-08-14 18:15:30 +0300 | [diff] [blame] | 663 | u32 drv_req = I915_READ(HSW_PWR_WELL_CTL_DRIVER(id)); |
Imre Deak | 1af474f | 2017-07-06 17:40:34 +0300 | [diff] [blame] | 664 | |
| 665 | if (!(drv_req & mask)) |
Imre Deak | 9c3a16c | 2017-08-14 18:15:30 +0300 | [diff] [blame] | 666 | I915_WRITE(HSW_PWR_WELL_CTL_DRIVER(id), drv_req | mask); |
| 667 | I915_WRITE(HSW_PWR_WELL_CTL_BIOS(id), bios_req & ~mask); |
Imre Deak | 16e8491 | 2017-02-17 17:39:45 +0200 | [diff] [blame] | 668 | } |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 669 | } |
| 670 | |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 671 | static void bxt_dpio_cmn_power_well_enable(struct drm_i915_private *dev_priv, |
| 672 | struct i915_power_well *power_well) |
| 673 | { |
Imre Deak | b5565a2 | 2017-07-06 17:40:29 +0300 | [diff] [blame] | 674 | bxt_ddi_phy_init(dev_priv, power_well->bxt.phy); |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 675 | } |
| 676 | |
| 677 | static void bxt_dpio_cmn_power_well_disable(struct drm_i915_private *dev_priv, |
| 678 | struct i915_power_well *power_well) |
| 679 | { |
Imre Deak | b5565a2 | 2017-07-06 17:40:29 +0300 | [diff] [blame] | 680 | bxt_ddi_phy_uninit(dev_priv, power_well->bxt.phy); |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | static bool bxt_dpio_cmn_power_well_enabled(struct drm_i915_private *dev_priv, |
| 684 | struct i915_power_well *power_well) |
| 685 | { |
Imre Deak | b5565a2 | 2017-07-06 17:40:29 +0300 | [diff] [blame] | 686 | return bxt_ddi_phy_is_enabled(dev_priv, power_well->bxt.phy); |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 687 | } |
| 688 | |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 689 | static void bxt_verify_ddi_phy_power_wells(struct drm_i915_private *dev_priv) |
| 690 | { |
| 691 | struct i915_power_well *power_well; |
| 692 | |
| 693 | power_well = lookup_power_well(dev_priv, BXT_DPIO_CMN_A); |
| 694 | if (power_well->count > 0) |
Imre Deak | b5565a2 | 2017-07-06 17:40:29 +0300 | [diff] [blame] | 695 | bxt_ddi_phy_verify_state(dev_priv, power_well->bxt.phy); |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 696 | |
| 697 | power_well = lookup_power_well(dev_priv, BXT_DPIO_CMN_BC); |
| 698 | if (power_well->count > 0) |
Imre Deak | b5565a2 | 2017-07-06 17:40:29 +0300 | [diff] [blame] | 699 | bxt_ddi_phy_verify_state(dev_priv, power_well->bxt.phy); |
Ander Conselvan de Oliveira | 0a116ce | 2016-12-02 10:23:51 +0200 | [diff] [blame] | 700 | |
| 701 | if (IS_GEMINILAKE(dev_priv)) { |
| 702 | power_well = lookup_power_well(dev_priv, GLK_DPIO_CMN_C); |
| 703 | if (power_well->count > 0) |
Imre Deak | b5565a2 | 2017-07-06 17:40:29 +0300 | [diff] [blame] | 704 | bxt_ddi_phy_verify_state(dev_priv, power_well->bxt.phy); |
Ander Conselvan de Oliveira | 0a116ce | 2016-12-02 10:23:51 +0200 | [diff] [blame] | 705 | } |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 706 | } |
| 707 | |
Patrik Jakobsson | 9f836f9 | 2015-11-16 16:20:01 +0100 | [diff] [blame] | 708 | static bool gen9_dc_off_power_well_enabled(struct drm_i915_private *dev_priv, |
| 709 | struct i915_power_well *power_well) |
| 710 | { |
| 711 | return (I915_READ(DC_STATE_EN) & DC_STATE_EN_UPTO_DC5_DC6_MASK) == 0; |
| 712 | } |
| 713 | |
Ville Syrjälä | 18a8067 | 2016-05-16 16:59:40 +0300 | [diff] [blame] | 714 | static void gen9_assert_dbuf_enabled(struct drm_i915_private *dev_priv) |
| 715 | { |
| 716 | u32 tmp = I915_READ(DBUF_CTL); |
| 717 | |
| 718 | WARN((tmp & (DBUF_POWER_STATE | DBUF_POWER_REQUEST)) != |
| 719 | (DBUF_POWER_STATE | DBUF_POWER_REQUEST), |
| 720 | "Unexpected DBuf power power state (0x%08x)\n", tmp); |
| 721 | } |
| 722 | |
Patrik Jakobsson | 9f836f9 | 2015-11-16 16:20:01 +0100 | [diff] [blame] | 723 | static void gen9_dc_off_power_well_enable(struct drm_i915_private *dev_priv, |
| 724 | struct i915_power_well *power_well) |
| 725 | { |
Ville Syrjälä | 49cd97a | 2017-02-07 20:33:45 +0200 | [diff] [blame] | 726 | struct intel_cdclk_state cdclk_state = {}; |
| 727 | |
Imre Deak | 5b773eb | 2016-02-29 22:49:05 +0200 | [diff] [blame] | 728 | gen9_set_dc_state(dev_priv, DC_STATE_DISABLE); |
Imre Deak | adc7f04 | 2016-04-04 17:27:10 +0300 | [diff] [blame] | 729 | |
Ville Syrjälä | 49cd97a | 2017-02-07 20:33:45 +0200 | [diff] [blame] | 730 | dev_priv->display.get_cdclk(dev_priv, &cdclk_state); |
Ville Syrjälä | 64600bd | 2017-10-24 12:52:08 +0300 | [diff] [blame] | 731 | /* Can't read out voltage_level so can't use intel_cdclk_changed() */ |
| 732 | WARN_ON(intel_cdclk_needs_modeset(&dev_priv->cdclk.hw, &cdclk_state)); |
Ville Syrjälä | 342be92 | 2016-05-13 23:41:39 +0300 | [diff] [blame] | 733 | |
Ville Syrjälä | 18a8067 | 2016-05-16 16:59:40 +0300 | [diff] [blame] | 734 | gen9_assert_dbuf_enabled(dev_priv); |
| 735 | |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 736 | if (IS_GEN9_LP(dev_priv)) |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 737 | bxt_verify_ddi_phy_power_wells(dev_priv); |
Patrik Jakobsson | 9f836f9 | 2015-11-16 16:20:01 +0100 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | static void gen9_dc_off_power_well_disable(struct drm_i915_private *dev_priv, |
| 741 | struct i915_power_well *power_well) |
| 742 | { |
Imre Deak | f74ed08 | 2016-04-18 14:48:21 +0300 | [diff] [blame] | 743 | if (!dev_priv->csr.dmc_payload) |
| 744 | return; |
| 745 | |
Imre Deak | a37baf3 | 2016-02-29 22:49:03 +0200 | [diff] [blame] | 746 | if (dev_priv->csr.allowed_dc_mask & DC_STATE_EN_UPTO_DC6) |
Patrik Jakobsson | 9f836f9 | 2015-11-16 16:20:01 +0100 | [diff] [blame] | 747 | skl_enable_dc6(dev_priv); |
Imre Deak | a37baf3 | 2016-02-29 22:49:03 +0200 | [diff] [blame] | 748 | else if (dev_priv->csr.allowed_dc_mask & DC_STATE_EN_UPTO_DC5) |
Patrik Jakobsson | 9f836f9 | 2015-11-16 16:20:01 +0100 | [diff] [blame] | 749 | gen9_enable_dc5(dev_priv); |
| 750 | } |
| 751 | |
Imre Deak | 3c1b38e | 2017-02-17 17:39:42 +0200 | [diff] [blame] | 752 | static void i9xx_power_well_sync_hw_noop(struct drm_i915_private *dev_priv, |
| 753 | struct i915_power_well *power_well) |
Patrik Jakobsson | 9f836f9 | 2015-11-16 16:20:01 +0100 | [diff] [blame] | 754 | { |
Patrik Jakobsson | 9f836f9 | 2015-11-16 16:20:01 +0100 | [diff] [blame] | 755 | } |
| 756 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 757 | static void i9xx_always_on_power_well_noop(struct drm_i915_private *dev_priv, |
| 758 | struct i915_power_well *power_well) |
| 759 | { |
| 760 | } |
| 761 | |
| 762 | static bool i9xx_always_on_power_well_enabled(struct drm_i915_private *dev_priv, |
| 763 | struct i915_power_well *power_well) |
| 764 | { |
| 765 | return true; |
| 766 | } |
| 767 | |
Ville Syrjälä | 2ee0da1 | 2017-06-01 17:36:16 +0300 | [diff] [blame] | 768 | static void i830_pipes_power_well_enable(struct drm_i915_private *dev_priv, |
| 769 | struct i915_power_well *power_well) |
| 770 | { |
| 771 | if ((I915_READ(PIPECONF(PIPE_A)) & PIPECONF_ENABLE) == 0) |
| 772 | i830_enable_pipe(dev_priv, PIPE_A); |
| 773 | if ((I915_READ(PIPECONF(PIPE_B)) & PIPECONF_ENABLE) == 0) |
| 774 | i830_enable_pipe(dev_priv, PIPE_B); |
| 775 | } |
| 776 | |
| 777 | static void i830_pipes_power_well_disable(struct drm_i915_private *dev_priv, |
| 778 | struct i915_power_well *power_well) |
| 779 | { |
| 780 | i830_disable_pipe(dev_priv, PIPE_B); |
| 781 | i830_disable_pipe(dev_priv, PIPE_A); |
| 782 | } |
| 783 | |
| 784 | static bool i830_pipes_power_well_enabled(struct drm_i915_private *dev_priv, |
| 785 | struct i915_power_well *power_well) |
| 786 | { |
| 787 | return I915_READ(PIPECONF(PIPE_A)) & PIPECONF_ENABLE && |
| 788 | I915_READ(PIPECONF(PIPE_B)) & PIPECONF_ENABLE; |
| 789 | } |
| 790 | |
| 791 | static void i830_pipes_power_well_sync_hw(struct drm_i915_private *dev_priv, |
| 792 | struct i915_power_well *power_well) |
| 793 | { |
| 794 | if (power_well->count > 0) |
| 795 | i830_pipes_power_well_enable(dev_priv, power_well); |
| 796 | else |
| 797 | i830_pipes_power_well_disable(dev_priv, power_well); |
| 798 | } |
| 799 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 800 | static void vlv_set_power_well(struct drm_i915_private *dev_priv, |
| 801 | struct i915_power_well *power_well, bool enable) |
| 802 | { |
Imre Deak | 438b8dc | 2017-07-11 23:42:30 +0300 | [diff] [blame] | 803 | enum i915_power_well_id power_well_id = power_well->id; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 804 | u32 mask; |
| 805 | u32 state; |
| 806 | u32 ctrl; |
| 807 | |
| 808 | mask = PUNIT_PWRGT_MASK(power_well_id); |
| 809 | state = enable ? PUNIT_PWRGT_PWR_ON(power_well_id) : |
| 810 | PUNIT_PWRGT_PWR_GATE(power_well_id); |
| 811 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 812 | mutex_lock(&dev_priv->pcu_lock); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 813 | |
| 814 | #define COND \ |
| 815 | ((vlv_punit_read(dev_priv, PUNIT_REG_PWRGT_STATUS) & mask) == state) |
| 816 | |
| 817 | if (COND) |
| 818 | goto out; |
| 819 | |
| 820 | ctrl = vlv_punit_read(dev_priv, PUNIT_REG_PWRGT_CTRL); |
| 821 | ctrl &= ~mask; |
| 822 | ctrl |= state; |
| 823 | vlv_punit_write(dev_priv, PUNIT_REG_PWRGT_CTRL, ctrl); |
| 824 | |
| 825 | if (wait_for(COND, 100)) |
Masanari Iida | 7e35ab8 | 2015-05-10 01:00:23 +0900 | [diff] [blame] | 826 | DRM_ERROR("timeout setting power well state %08x (%08x)\n", |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 827 | state, |
| 828 | vlv_punit_read(dev_priv, PUNIT_REG_PWRGT_CTRL)); |
| 829 | |
| 830 | #undef COND |
| 831 | |
| 832 | out: |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 833 | mutex_unlock(&dev_priv->pcu_lock); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 834 | } |
| 835 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 836 | static void vlv_power_well_enable(struct drm_i915_private *dev_priv, |
| 837 | struct i915_power_well *power_well) |
| 838 | { |
| 839 | vlv_set_power_well(dev_priv, power_well, true); |
| 840 | } |
| 841 | |
| 842 | static void vlv_power_well_disable(struct drm_i915_private *dev_priv, |
| 843 | struct i915_power_well *power_well) |
| 844 | { |
| 845 | vlv_set_power_well(dev_priv, power_well, false); |
| 846 | } |
| 847 | |
| 848 | static bool vlv_power_well_enabled(struct drm_i915_private *dev_priv, |
| 849 | struct i915_power_well *power_well) |
| 850 | { |
Imre Deak | 438b8dc | 2017-07-11 23:42:30 +0300 | [diff] [blame] | 851 | enum i915_power_well_id power_well_id = power_well->id; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 852 | bool enabled = false; |
| 853 | u32 mask; |
| 854 | u32 state; |
| 855 | u32 ctrl; |
| 856 | |
| 857 | mask = PUNIT_PWRGT_MASK(power_well_id); |
| 858 | ctrl = PUNIT_PWRGT_PWR_ON(power_well_id); |
| 859 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 860 | mutex_lock(&dev_priv->pcu_lock); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 861 | |
| 862 | state = vlv_punit_read(dev_priv, PUNIT_REG_PWRGT_STATUS) & mask; |
| 863 | /* |
| 864 | * We only ever set the power-on and power-gate states, anything |
| 865 | * else is unexpected. |
| 866 | */ |
| 867 | WARN_ON(state != PUNIT_PWRGT_PWR_ON(power_well_id) && |
| 868 | state != PUNIT_PWRGT_PWR_GATE(power_well_id)); |
| 869 | if (state == ctrl) |
| 870 | enabled = true; |
| 871 | |
| 872 | /* |
| 873 | * A transient state at this point would mean some unexpected party |
| 874 | * is poking at the power controls too. |
| 875 | */ |
| 876 | ctrl = vlv_punit_read(dev_priv, PUNIT_REG_PWRGT_CTRL) & mask; |
| 877 | WARN_ON(ctrl != state); |
| 878 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 879 | mutex_unlock(&dev_priv->pcu_lock); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 880 | |
| 881 | return enabled; |
| 882 | } |
| 883 | |
Ville Syrjälä | 766078d | 2016-04-11 16:56:30 +0300 | [diff] [blame] | 884 | static void vlv_init_display_clock_gating(struct drm_i915_private *dev_priv) |
| 885 | { |
Hans de Goede | 721d484 | 2016-12-02 15:29:04 +0100 | [diff] [blame] | 886 | u32 val; |
| 887 | |
| 888 | /* |
| 889 | * On driver load, a pipe may be active and driving a DSI display. |
| 890 | * Preserve DPOUNIT_CLOCK_GATE_DISABLE to avoid the pipe getting stuck |
| 891 | * (and never recovering) in this case. intel_dsi_post_disable() will |
| 892 | * clear it when we turn off the display. |
| 893 | */ |
| 894 | val = I915_READ(DSPCLK_GATE_D); |
| 895 | val &= DPOUNIT_CLOCK_GATE_DISABLE; |
| 896 | val |= VRHUNIT_CLOCK_GATE_DISABLE; |
| 897 | I915_WRITE(DSPCLK_GATE_D, val); |
Ville Syrjälä | 766078d | 2016-04-11 16:56:30 +0300 | [diff] [blame] | 898 | |
| 899 | /* |
| 900 | * Disable trickle feed and enable pnd deadline calculation |
| 901 | */ |
| 902 | I915_WRITE(MI_ARB_VLV, MI_ARB_DISPLAY_TRICKLE_FEED_DISABLE); |
| 903 | I915_WRITE(CBR1_VLV, 0); |
Ville Syrjälä | 19ab4ed | 2016-04-27 17:43:22 +0300 | [diff] [blame] | 904 | |
| 905 | WARN_ON(dev_priv->rawclk_freq == 0); |
| 906 | |
| 907 | I915_WRITE(RAWCLK_FREQ_VLV, |
| 908 | DIV_ROUND_CLOSEST(dev_priv->rawclk_freq, 1000)); |
Ville Syrjälä | 766078d | 2016-04-11 16:56:30 +0300 | [diff] [blame] | 909 | } |
| 910 | |
Ville Syrjälä | 2be7d54 | 2015-06-29 15:25:51 +0300 | [diff] [blame] | 911 | static void vlv_display_power_well_init(struct drm_i915_private *dev_priv) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 912 | { |
Lyude | 9504a89 | 2016-06-21 17:03:42 -0400 | [diff] [blame] | 913 | struct intel_encoder *encoder; |
Ville Syrjälä | 5a8fbb7 | 2015-06-29 15:25:53 +0300 | [diff] [blame] | 914 | enum pipe pipe; |
| 915 | |
| 916 | /* |
| 917 | * Enable the CRI clock source so we can get at the |
| 918 | * display and the reference clock for VGA |
| 919 | * hotplug / manual detection. Supposedly DSI also |
| 920 | * needs the ref clock up and running. |
| 921 | * |
| 922 | * CHV DPLL B/C have some issues if VGA mode is enabled. |
| 923 | */ |
Tvrtko Ursulin | 801388c | 2016-11-16 08:55:44 +0000 | [diff] [blame] | 924 | for_each_pipe(dev_priv, pipe) { |
Ville Syrjälä | 5a8fbb7 | 2015-06-29 15:25:53 +0300 | [diff] [blame] | 925 | u32 val = I915_READ(DPLL(pipe)); |
| 926 | |
| 927 | val |= DPLL_REF_CLK_ENABLE_VLV | DPLL_VGA_MODE_DIS; |
| 928 | if (pipe != PIPE_A) |
| 929 | val |= DPLL_INTEGRATED_CRI_CLK_VLV; |
| 930 | |
| 931 | I915_WRITE(DPLL(pipe), val); |
| 932 | } |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 933 | |
Ville Syrjälä | 766078d | 2016-04-11 16:56:30 +0300 | [diff] [blame] | 934 | vlv_init_display_clock_gating(dev_priv); |
| 935 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 936 | spin_lock_irq(&dev_priv->irq_lock); |
| 937 | valleyview_enable_display_irqs(dev_priv); |
| 938 | spin_unlock_irq(&dev_priv->irq_lock); |
| 939 | |
| 940 | /* |
| 941 | * During driver initialization/resume we can avoid restoring the |
| 942 | * part of the HW/SW state that will be inited anyway explicitly. |
| 943 | */ |
| 944 | if (dev_priv->power_domains.initializing) |
| 945 | return; |
| 946 | |
Daniel Vetter | b963291 | 2014-09-30 10:56:44 +0200 | [diff] [blame] | 947 | intel_hpd_init(dev_priv); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 948 | |
Lyude | 9504a89 | 2016-06-21 17:03:42 -0400 | [diff] [blame] | 949 | /* Re-enable the ADPA, if we have one */ |
| 950 | for_each_intel_encoder(&dev_priv->drm, encoder) { |
| 951 | if (encoder->type == INTEL_OUTPUT_ANALOG) |
| 952 | intel_crt_reset(&encoder->base); |
| 953 | } |
| 954 | |
Tvrtko Ursulin | 29b74b7 | 2016-11-16 08:55:39 +0000 | [diff] [blame] | 955 | i915_redisable_vga_power_on(dev_priv); |
Imre Deak | 8090ba8 | 2016-08-10 14:07:33 +0300 | [diff] [blame] | 956 | |
| 957 | intel_pps_unlock_regs_wa(dev_priv); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 958 | } |
| 959 | |
Ville Syrjälä | 2be7d54 | 2015-06-29 15:25:51 +0300 | [diff] [blame] | 960 | static void vlv_display_power_well_deinit(struct drm_i915_private *dev_priv) |
| 961 | { |
| 962 | spin_lock_irq(&dev_priv->irq_lock); |
| 963 | valleyview_disable_display_irqs(dev_priv); |
| 964 | spin_unlock_irq(&dev_priv->irq_lock); |
| 965 | |
Ville Syrjälä | 2230fde | 2016-02-19 18:41:52 +0200 | [diff] [blame] | 966 | /* make sure we're done processing display irqs */ |
Chris Wilson | 91c8a32 | 2016-07-05 10:40:23 +0100 | [diff] [blame] | 967 | synchronize_irq(dev_priv->drm.irq); |
Ville Syrjälä | 2230fde | 2016-02-19 18:41:52 +0200 | [diff] [blame] | 968 | |
Imre Deak | 7859799 | 2016-06-16 16:37:20 +0300 | [diff] [blame] | 969 | intel_power_sequencer_reset(dev_priv); |
Lyude | 19625e8 | 2016-06-21 17:03:44 -0400 | [diff] [blame] | 970 | |
Lyude | b64b540 | 2016-10-26 12:36:09 -0400 | [diff] [blame] | 971 | /* Prevent us from re-enabling polling on accident in late suspend */ |
| 972 | if (!dev_priv->drm.dev->power.is_suspended) |
| 973 | intel_hpd_poll_init(dev_priv); |
Ville Syrjälä | 2be7d54 | 2015-06-29 15:25:51 +0300 | [diff] [blame] | 974 | } |
| 975 | |
| 976 | static void vlv_display_power_well_enable(struct drm_i915_private *dev_priv, |
| 977 | struct i915_power_well *power_well) |
| 978 | { |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 979 | WARN_ON_ONCE(power_well->id != PUNIT_POWER_WELL_DISP2D); |
Ville Syrjälä | 2be7d54 | 2015-06-29 15:25:51 +0300 | [diff] [blame] | 980 | |
| 981 | vlv_set_power_well(dev_priv, power_well, true); |
| 982 | |
| 983 | vlv_display_power_well_init(dev_priv); |
| 984 | } |
| 985 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 986 | static void vlv_display_power_well_disable(struct drm_i915_private *dev_priv, |
| 987 | struct i915_power_well *power_well) |
| 988 | { |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 989 | WARN_ON_ONCE(power_well->id != PUNIT_POWER_WELL_DISP2D); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 990 | |
Ville Syrjälä | 2be7d54 | 2015-06-29 15:25:51 +0300 | [diff] [blame] | 991 | vlv_display_power_well_deinit(dev_priv); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 992 | |
| 993 | vlv_set_power_well(dev_priv, power_well, false); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 994 | } |
| 995 | |
| 996 | static void vlv_dpio_cmn_power_well_enable(struct drm_i915_private *dev_priv, |
| 997 | struct i915_power_well *power_well) |
| 998 | { |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 999 | WARN_ON_ONCE(power_well->id != PUNIT_POWER_WELL_DPIO_CMN_BC); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1000 | |
Ville Syrjälä | 5a8fbb7 | 2015-06-29 15:25:53 +0300 | [diff] [blame] | 1001 | /* since ref/cri clock was enabled */ |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1002 | udelay(1); /* >10ns for cmnreset, >0ns for sidereset */ |
| 1003 | |
| 1004 | vlv_set_power_well(dev_priv, power_well, true); |
| 1005 | |
| 1006 | /* |
| 1007 | * From VLV2A0_DP_eDP_DPIO_driver_vbios_notes_10.docx - |
| 1008 | * 6. De-assert cmn_reset/side_reset. Same as VLV X0. |
| 1009 | * a. GUnit 0x2110 bit[0] set to 1 (def 0) |
| 1010 | * b. The other bits such as sfr settings / modesel may all |
| 1011 | * be set to 0. |
| 1012 | * |
| 1013 | * This should only be done on init and resume from S3 with |
| 1014 | * both PLLs disabled, or we risk losing DPIO and PLL |
| 1015 | * synchronization. |
| 1016 | */ |
| 1017 | I915_WRITE(DPIO_CTL, I915_READ(DPIO_CTL) | DPIO_CMNRST); |
| 1018 | } |
| 1019 | |
| 1020 | static void vlv_dpio_cmn_power_well_disable(struct drm_i915_private *dev_priv, |
| 1021 | struct i915_power_well *power_well) |
| 1022 | { |
| 1023 | enum pipe pipe; |
| 1024 | |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 1025 | WARN_ON_ONCE(power_well->id != PUNIT_POWER_WELL_DPIO_CMN_BC); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1026 | |
| 1027 | for_each_pipe(dev_priv, pipe) |
| 1028 | assert_pll_disabled(dev_priv, pipe); |
| 1029 | |
| 1030 | /* Assert common reset */ |
| 1031 | I915_WRITE(DPIO_CTL, I915_READ(DPIO_CTL) & ~DPIO_CMNRST); |
| 1032 | |
| 1033 | vlv_set_power_well(dev_priv, power_well, false); |
| 1034 | } |
| 1035 | |
Ander Conselvan de Oliveira | d8fc70b | 2017-02-09 11:31:21 +0200 | [diff] [blame] | 1036 | #define POWER_DOMAIN_MASK (GENMASK_ULL(POWER_DOMAIN_NUM - 1, 0)) |
Ville Syrjälä | 3014227 | 2015-07-08 23:46:01 +0300 | [diff] [blame] | 1037 | |
Imre Deak | 438b8dc | 2017-07-11 23:42:30 +0300 | [diff] [blame] | 1038 | static struct i915_power_well * |
| 1039 | lookup_power_well(struct drm_i915_private *dev_priv, |
| 1040 | enum i915_power_well_id power_well_id) |
Ville Syrjälä | 3014227 | 2015-07-08 23:46:01 +0300 | [diff] [blame] | 1041 | { |
| 1042 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
Ville Syrjälä | 3014227 | 2015-07-08 23:46:01 +0300 | [diff] [blame] | 1043 | int i; |
| 1044 | |
Imre Deak | fc17f22 | 2015-11-04 19:24:11 +0200 | [diff] [blame] | 1045 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 1046 | struct i915_power_well *power_well; |
| 1047 | |
| 1048 | power_well = &power_domains->power_wells[i]; |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 1049 | if (power_well->id == power_well_id) |
Ville Syrjälä | 3014227 | 2015-07-08 23:46:01 +0300 | [diff] [blame] | 1050 | return power_well; |
| 1051 | } |
| 1052 | |
| 1053 | return NULL; |
| 1054 | } |
| 1055 | |
| 1056 | #define BITS_SET(val, bits) (((val) & (bits)) == (bits)) |
| 1057 | |
| 1058 | static void assert_chv_phy_status(struct drm_i915_private *dev_priv) |
| 1059 | { |
| 1060 | struct i915_power_well *cmn_bc = |
| 1061 | lookup_power_well(dev_priv, PUNIT_POWER_WELL_DPIO_CMN_BC); |
| 1062 | struct i915_power_well *cmn_d = |
| 1063 | lookup_power_well(dev_priv, PUNIT_POWER_WELL_DPIO_CMN_D); |
| 1064 | u32 phy_control = dev_priv->chv_phy_control; |
| 1065 | u32 phy_status = 0; |
Ville Syrjälä | 3be60de | 2015-09-08 18:05:45 +0300 | [diff] [blame] | 1066 | u32 phy_status_mask = 0xffffffff; |
Ville Syrjälä | 3014227 | 2015-07-08 23:46:01 +0300 | [diff] [blame] | 1067 | |
Ville Syrjälä | 3be60de | 2015-09-08 18:05:45 +0300 | [diff] [blame] | 1068 | /* |
| 1069 | * The BIOS can leave the PHY is some weird state |
| 1070 | * where it doesn't fully power down some parts. |
| 1071 | * Disable the asserts until the PHY has been fully |
| 1072 | * reset (ie. the power well has been disabled at |
| 1073 | * least once). |
| 1074 | */ |
| 1075 | if (!dev_priv->chv_phy_assert[DPIO_PHY0]) |
| 1076 | phy_status_mask &= ~(PHY_STATUS_CMN_LDO(DPIO_PHY0, DPIO_CH0) | |
| 1077 | PHY_STATUS_SPLINE_LDO(DPIO_PHY0, DPIO_CH0, 0) | |
| 1078 | PHY_STATUS_SPLINE_LDO(DPIO_PHY0, DPIO_CH0, 1) | |
| 1079 | PHY_STATUS_CMN_LDO(DPIO_PHY0, DPIO_CH1) | |
| 1080 | PHY_STATUS_SPLINE_LDO(DPIO_PHY0, DPIO_CH1, 0) | |
| 1081 | PHY_STATUS_SPLINE_LDO(DPIO_PHY0, DPIO_CH1, 1)); |
| 1082 | |
| 1083 | if (!dev_priv->chv_phy_assert[DPIO_PHY1]) |
| 1084 | phy_status_mask &= ~(PHY_STATUS_CMN_LDO(DPIO_PHY1, DPIO_CH0) | |
| 1085 | PHY_STATUS_SPLINE_LDO(DPIO_PHY1, DPIO_CH0, 0) | |
| 1086 | PHY_STATUS_SPLINE_LDO(DPIO_PHY1, DPIO_CH0, 1)); |
| 1087 | |
Ville Syrjälä | 3014227 | 2015-07-08 23:46:01 +0300 | [diff] [blame] | 1088 | if (cmn_bc->ops->is_enabled(dev_priv, cmn_bc)) { |
| 1089 | phy_status |= PHY_POWERGOOD(DPIO_PHY0); |
| 1090 | |
| 1091 | /* this assumes override is only used to enable lanes */ |
| 1092 | if ((phy_control & PHY_CH_POWER_DOWN_OVRD_EN(DPIO_PHY0, DPIO_CH0)) == 0) |
| 1093 | phy_control |= PHY_CH_POWER_DOWN_OVRD(0xf, DPIO_PHY0, DPIO_CH0); |
| 1094 | |
| 1095 | if ((phy_control & PHY_CH_POWER_DOWN_OVRD_EN(DPIO_PHY0, DPIO_CH1)) == 0) |
| 1096 | phy_control |= PHY_CH_POWER_DOWN_OVRD(0xf, DPIO_PHY0, DPIO_CH1); |
| 1097 | |
| 1098 | /* CL1 is on whenever anything is on in either channel */ |
| 1099 | if (BITS_SET(phy_control, |
| 1100 | PHY_CH_POWER_DOWN_OVRD(0xf, DPIO_PHY0, DPIO_CH0) | |
| 1101 | PHY_CH_POWER_DOWN_OVRD(0xf, DPIO_PHY0, DPIO_CH1))) |
| 1102 | phy_status |= PHY_STATUS_CMN_LDO(DPIO_PHY0, DPIO_CH0); |
| 1103 | |
| 1104 | /* |
| 1105 | * The DPLLB check accounts for the pipe B + port A usage |
| 1106 | * with CL2 powered up but all the lanes in the second channel |
| 1107 | * powered down. |
| 1108 | */ |
| 1109 | if (BITS_SET(phy_control, |
| 1110 | PHY_CH_POWER_DOWN_OVRD(0xf, DPIO_PHY0, DPIO_CH1)) && |
| 1111 | (I915_READ(DPLL(PIPE_B)) & DPLL_VCO_ENABLE) == 0) |
| 1112 | phy_status |= PHY_STATUS_CMN_LDO(DPIO_PHY0, DPIO_CH1); |
| 1113 | |
| 1114 | if (BITS_SET(phy_control, |
| 1115 | PHY_CH_POWER_DOWN_OVRD(0x3, DPIO_PHY0, DPIO_CH0))) |
| 1116 | phy_status |= PHY_STATUS_SPLINE_LDO(DPIO_PHY0, DPIO_CH0, 0); |
| 1117 | if (BITS_SET(phy_control, |
| 1118 | PHY_CH_POWER_DOWN_OVRD(0xc, DPIO_PHY0, DPIO_CH0))) |
| 1119 | phy_status |= PHY_STATUS_SPLINE_LDO(DPIO_PHY0, DPIO_CH0, 1); |
| 1120 | |
| 1121 | if (BITS_SET(phy_control, |
| 1122 | PHY_CH_POWER_DOWN_OVRD(0x3, DPIO_PHY0, DPIO_CH1))) |
| 1123 | phy_status |= PHY_STATUS_SPLINE_LDO(DPIO_PHY0, DPIO_CH1, 0); |
| 1124 | if (BITS_SET(phy_control, |
| 1125 | PHY_CH_POWER_DOWN_OVRD(0xc, DPIO_PHY0, DPIO_CH1))) |
| 1126 | phy_status |= PHY_STATUS_SPLINE_LDO(DPIO_PHY0, DPIO_CH1, 1); |
| 1127 | } |
| 1128 | |
| 1129 | if (cmn_d->ops->is_enabled(dev_priv, cmn_d)) { |
| 1130 | phy_status |= PHY_POWERGOOD(DPIO_PHY1); |
| 1131 | |
| 1132 | /* this assumes override is only used to enable lanes */ |
| 1133 | if ((phy_control & PHY_CH_POWER_DOWN_OVRD_EN(DPIO_PHY1, DPIO_CH0)) == 0) |
| 1134 | phy_control |= PHY_CH_POWER_DOWN_OVRD(0xf, DPIO_PHY1, DPIO_CH0); |
| 1135 | |
| 1136 | if (BITS_SET(phy_control, |
| 1137 | PHY_CH_POWER_DOWN_OVRD(0xf, DPIO_PHY1, DPIO_CH0))) |
| 1138 | phy_status |= PHY_STATUS_CMN_LDO(DPIO_PHY1, DPIO_CH0); |
| 1139 | |
| 1140 | if (BITS_SET(phy_control, |
| 1141 | PHY_CH_POWER_DOWN_OVRD(0x3, DPIO_PHY1, DPIO_CH0))) |
| 1142 | phy_status |= PHY_STATUS_SPLINE_LDO(DPIO_PHY1, DPIO_CH0, 0); |
| 1143 | if (BITS_SET(phy_control, |
| 1144 | PHY_CH_POWER_DOWN_OVRD(0xc, DPIO_PHY1, DPIO_CH0))) |
| 1145 | phy_status |= PHY_STATUS_SPLINE_LDO(DPIO_PHY1, DPIO_CH0, 1); |
| 1146 | } |
| 1147 | |
Ville Syrjälä | 3be60de | 2015-09-08 18:05:45 +0300 | [diff] [blame] | 1148 | phy_status &= phy_status_mask; |
| 1149 | |
Ville Syrjälä | 3014227 | 2015-07-08 23:46:01 +0300 | [diff] [blame] | 1150 | /* |
| 1151 | * The PHY may be busy with some initial calibration and whatnot, |
| 1152 | * so the power state can take a while to actually change. |
| 1153 | */ |
Chris Wilson | 919fcd5 | 2016-06-30 15:33:35 +0100 | [diff] [blame] | 1154 | if (intel_wait_for_register(dev_priv, |
| 1155 | DISPLAY_PHY_STATUS, |
| 1156 | phy_status_mask, |
| 1157 | phy_status, |
| 1158 | 10)) |
| 1159 | DRM_ERROR("Unexpected PHY_STATUS 0x%08x, expected 0x%08x (PHY_CONTROL=0x%08x)\n", |
| 1160 | I915_READ(DISPLAY_PHY_STATUS) & phy_status_mask, |
| 1161 | phy_status, dev_priv->chv_phy_control); |
Ville Syrjälä | 3014227 | 2015-07-08 23:46:01 +0300 | [diff] [blame] | 1162 | } |
| 1163 | |
| 1164 | #undef BITS_SET |
| 1165 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1166 | static void chv_dpio_cmn_power_well_enable(struct drm_i915_private *dev_priv, |
| 1167 | struct i915_power_well *power_well) |
| 1168 | { |
| 1169 | enum dpio_phy phy; |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 1170 | enum pipe pipe; |
| 1171 | uint32_t tmp; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1172 | |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 1173 | WARN_ON_ONCE(power_well->id != PUNIT_POWER_WELL_DPIO_CMN_BC && |
| 1174 | power_well->id != PUNIT_POWER_WELL_DPIO_CMN_D); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1175 | |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 1176 | if (power_well->id == PUNIT_POWER_WELL_DPIO_CMN_BC) { |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 1177 | pipe = PIPE_A; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1178 | phy = DPIO_PHY0; |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 1179 | } else { |
| 1180 | pipe = PIPE_C; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1181 | phy = DPIO_PHY1; |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 1182 | } |
Ville Syrjälä | 5a8fbb7 | 2015-06-29 15:25:53 +0300 | [diff] [blame] | 1183 | |
| 1184 | /* since ref/cri clock was enabled */ |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1185 | udelay(1); /* >10ns for cmnreset, >0ns for sidereset */ |
| 1186 | vlv_set_power_well(dev_priv, power_well, true); |
| 1187 | |
| 1188 | /* Poll for phypwrgood signal */ |
Chris Wilson | ffebb83 | 2016-06-30 15:33:36 +0100 | [diff] [blame] | 1189 | if (intel_wait_for_register(dev_priv, |
| 1190 | DISPLAY_PHY_STATUS, |
| 1191 | PHY_POWERGOOD(phy), |
| 1192 | PHY_POWERGOOD(phy), |
| 1193 | 1)) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1194 | DRM_ERROR("Display PHY %d is not power up\n", phy); |
| 1195 | |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 1196 | mutex_lock(&dev_priv->sb_lock); |
| 1197 | |
| 1198 | /* Enable dynamic power down */ |
| 1199 | tmp = vlv_dpio_read(dev_priv, pipe, CHV_CMN_DW28); |
Ville Syrjälä | ee27921 | 2015-07-08 23:45:57 +0300 | [diff] [blame] | 1200 | tmp |= DPIO_DYNPWRDOWNEN_CH0 | DPIO_CL1POWERDOWNEN | |
| 1201 | DPIO_SUS_CLK_CONFIG_GATE_CLKREQ; |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 1202 | vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW28, tmp); |
| 1203 | |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 1204 | if (power_well->id == PUNIT_POWER_WELL_DPIO_CMN_BC) { |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 1205 | tmp = vlv_dpio_read(dev_priv, pipe, _CHV_CMN_DW6_CH1); |
| 1206 | tmp |= DPIO_DYNPWRDOWNEN_CH1; |
| 1207 | vlv_dpio_write(dev_priv, pipe, _CHV_CMN_DW6_CH1, tmp); |
Ville Syrjälä | 3e28878 | 2015-07-08 23:45:58 +0300 | [diff] [blame] | 1208 | } else { |
| 1209 | /* |
| 1210 | * Force the non-existing CL2 off. BXT does this |
| 1211 | * too, so maybe it saves some power even though |
| 1212 | * CL2 doesn't exist? |
| 1213 | */ |
| 1214 | tmp = vlv_dpio_read(dev_priv, pipe, CHV_CMN_DW30); |
| 1215 | tmp |= DPIO_CL2_LDOFUSE_PWRENB; |
| 1216 | vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW30, tmp); |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 1217 | } |
| 1218 | |
| 1219 | mutex_unlock(&dev_priv->sb_lock); |
| 1220 | |
Ville Syrjälä | 7072246 | 2015-04-10 18:21:28 +0300 | [diff] [blame] | 1221 | dev_priv->chv_phy_control |= PHY_COM_LANE_RESET_DEASSERT(phy); |
| 1222 | I915_WRITE(DISPLAY_PHY_CONTROL, dev_priv->chv_phy_control); |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 1223 | |
| 1224 | DRM_DEBUG_KMS("Enabled DPIO PHY%d (PHY_CONTROL=0x%08x)\n", |
| 1225 | phy, dev_priv->chv_phy_control); |
Ville Syrjälä | 3014227 | 2015-07-08 23:46:01 +0300 | [diff] [blame] | 1226 | |
| 1227 | assert_chv_phy_status(dev_priv); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1228 | } |
| 1229 | |
| 1230 | static void chv_dpio_cmn_power_well_disable(struct drm_i915_private *dev_priv, |
| 1231 | struct i915_power_well *power_well) |
| 1232 | { |
| 1233 | enum dpio_phy phy; |
| 1234 | |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 1235 | WARN_ON_ONCE(power_well->id != PUNIT_POWER_WELL_DPIO_CMN_BC && |
| 1236 | power_well->id != PUNIT_POWER_WELL_DPIO_CMN_D); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1237 | |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 1238 | if (power_well->id == PUNIT_POWER_WELL_DPIO_CMN_BC) { |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1239 | phy = DPIO_PHY0; |
| 1240 | assert_pll_disabled(dev_priv, PIPE_A); |
| 1241 | assert_pll_disabled(dev_priv, PIPE_B); |
| 1242 | } else { |
| 1243 | phy = DPIO_PHY1; |
| 1244 | assert_pll_disabled(dev_priv, PIPE_C); |
| 1245 | } |
| 1246 | |
Ville Syrjälä | 7072246 | 2015-04-10 18:21:28 +0300 | [diff] [blame] | 1247 | dev_priv->chv_phy_control &= ~PHY_COM_LANE_RESET_DEASSERT(phy); |
| 1248 | I915_WRITE(DISPLAY_PHY_CONTROL, dev_priv->chv_phy_control); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1249 | |
| 1250 | vlv_set_power_well(dev_priv, power_well, false); |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 1251 | |
| 1252 | DRM_DEBUG_KMS("Disabled DPIO PHY%d (PHY_CONTROL=0x%08x)\n", |
| 1253 | phy, dev_priv->chv_phy_control); |
Ville Syrjälä | 3014227 | 2015-07-08 23:46:01 +0300 | [diff] [blame] | 1254 | |
Ville Syrjälä | 3be60de | 2015-09-08 18:05:45 +0300 | [diff] [blame] | 1255 | /* PHY is fully reset now, so we can enable the PHY state asserts */ |
| 1256 | dev_priv->chv_phy_assert[phy] = true; |
| 1257 | |
Ville Syrjälä | 3014227 | 2015-07-08 23:46:01 +0300 | [diff] [blame] | 1258 | assert_chv_phy_status(dev_priv); |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 1259 | } |
| 1260 | |
Ville Syrjälä | 6669e39 | 2015-07-08 23:46:00 +0300 | [diff] [blame] | 1261 | static void assert_chv_phy_powergate(struct drm_i915_private *dev_priv, enum dpio_phy phy, |
| 1262 | enum dpio_channel ch, bool override, unsigned int mask) |
| 1263 | { |
| 1264 | enum pipe pipe = phy == DPIO_PHY0 ? PIPE_A : PIPE_C; |
| 1265 | u32 reg, val, expected, actual; |
| 1266 | |
Ville Syrjälä | 3be60de | 2015-09-08 18:05:45 +0300 | [diff] [blame] | 1267 | /* |
| 1268 | * The BIOS can leave the PHY is some weird state |
| 1269 | * where it doesn't fully power down some parts. |
| 1270 | * Disable the asserts until the PHY has been fully |
| 1271 | * reset (ie. the power well has been disabled at |
| 1272 | * least once). |
| 1273 | */ |
| 1274 | if (!dev_priv->chv_phy_assert[phy]) |
| 1275 | return; |
| 1276 | |
Ville Syrjälä | 6669e39 | 2015-07-08 23:46:00 +0300 | [diff] [blame] | 1277 | if (ch == DPIO_CH0) |
| 1278 | reg = _CHV_CMN_DW0_CH0; |
| 1279 | else |
| 1280 | reg = _CHV_CMN_DW6_CH1; |
| 1281 | |
| 1282 | mutex_lock(&dev_priv->sb_lock); |
| 1283 | val = vlv_dpio_read(dev_priv, pipe, reg); |
| 1284 | mutex_unlock(&dev_priv->sb_lock); |
| 1285 | |
| 1286 | /* |
| 1287 | * This assumes !override is only used when the port is disabled. |
| 1288 | * All lanes should power down even without the override when |
| 1289 | * the port is disabled. |
| 1290 | */ |
| 1291 | if (!override || mask == 0xf) { |
| 1292 | expected = DPIO_ALLDL_POWERDOWN | DPIO_ANYDL_POWERDOWN; |
| 1293 | /* |
| 1294 | * If CH1 common lane is not active anymore |
| 1295 | * (eg. for pipe B DPLL) the entire channel will |
| 1296 | * shut down, which causes the common lane registers |
| 1297 | * to read as 0. That means we can't actually check |
| 1298 | * the lane power down status bits, but as the entire |
| 1299 | * register reads as 0 it's a good indication that the |
| 1300 | * channel is indeed entirely powered down. |
| 1301 | */ |
| 1302 | if (ch == DPIO_CH1 && val == 0) |
| 1303 | expected = 0; |
| 1304 | } else if (mask != 0x0) { |
| 1305 | expected = DPIO_ANYDL_POWERDOWN; |
| 1306 | } else { |
| 1307 | expected = 0; |
| 1308 | } |
| 1309 | |
| 1310 | if (ch == DPIO_CH0) |
| 1311 | actual = val >> DPIO_ANYDL_POWERDOWN_SHIFT_CH0; |
| 1312 | else |
| 1313 | actual = val >> DPIO_ANYDL_POWERDOWN_SHIFT_CH1; |
| 1314 | actual &= DPIO_ALLDL_POWERDOWN | DPIO_ANYDL_POWERDOWN; |
| 1315 | |
| 1316 | WARN(actual != expected, |
| 1317 | "Unexpected DPIO lane power down: all %d, any %d. Expected: all %d, any %d. (0x%x = 0x%08x)\n", |
| 1318 | !!(actual & DPIO_ALLDL_POWERDOWN), !!(actual & DPIO_ANYDL_POWERDOWN), |
| 1319 | !!(expected & DPIO_ALLDL_POWERDOWN), !!(expected & DPIO_ANYDL_POWERDOWN), |
| 1320 | reg, val); |
| 1321 | } |
| 1322 | |
Ville Syrjälä | b0b3384 | 2015-07-08 23:45:55 +0300 | [diff] [blame] | 1323 | bool chv_phy_powergate_ch(struct drm_i915_private *dev_priv, enum dpio_phy phy, |
| 1324 | enum dpio_channel ch, bool override) |
| 1325 | { |
| 1326 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 1327 | bool was_override; |
| 1328 | |
| 1329 | mutex_lock(&power_domains->lock); |
| 1330 | |
| 1331 | was_override = dev_priv->chv_phy_control & PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); |
| 1332 | |
| 1333 | if (override == was_override) |
| 1334 | goto out; |
| 1335 | |
| 1336 | if (override) |
| 1337 | dev_priv->chv_phy_control |= PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); |
| 1338 | else |
| 1339 | dev_priv->chv_phy_control &= ~PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); |
| 1340 | |
| 1341 | I915_WRITE(DISPLAY_PHY_CONTROL, dev_priv->chv_phy_control); |
| 1342 | |
| 1343 | DRM_DEBUG_KMS("Power gating DPIO PHY%d CH%d (DPIO_PHY_CONTROL=0x%08x)\n", |
| 1344 | phy, ch, dev_priv->chv_phy_control); |
| 1345 | |
Ville Syrjälä | 3014227 | 2015-07-08 23:46:01 +0300 | [diff] [blame] | 1346 | assert_chv_phy_status(dev_priv); |
| 1347 | |
Ville Syrjälä | b0b3384 | 2015-07-08 23:45:55 +0300 | [diff] [blame] | 1348 | out: |
| 1349 | mutex_unlock(&power_domains->lock); |
| 1350 | |
| 1351 | return was_override; |
| 1352 | } |
| 1353 | |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 1354 | void chv_phy_powergate_lanes(struct intel_encoder *encoder, |
| 1355 | bool override, unsigned int mask) |
| 1356 | { |
| 1357 | struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); |
| 1358 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 1359 | enum dpio_phy phy = vlv_dport_to_phy(enc_to_dig_port(&encoder->base)); |
| 1360 | enum dpio_channel ch = vlv_dport_to_channel(enc_to_dig_port(&encoder->base)); |
| 1361 | |
| 1362 | mutex_lock(&power_domains->lock); |
| 1363 | |
| 1364 | dev_priv->chv_phy_control &= ~PHY_CH_POWER_DOWN_OVRD(0xf, phy, ch); |
| 1365 | dev_priv->chv_phy_control |= PHY_CH_POWER_DOWN_OVRD(mask, phy, ch); |
| 1366 | |
| 1367 | if (override) |
| 1368 | dev_priv->chv_phy_control |= PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); |
| 1369 | else |
| 1370 | dev_priv->chv_phy_control &= ~PHY_CH_POWER_DOWN_OVRD_EN(phy, ch); |
| 1371 | |
| 1372 | I915_WRITE(DISPLAY_PHY_CONTROL, dev_priv->chv_phy_control); |
| 1373 | |
| 1374 | DRM_DEBUG_KMS("Power gating DPIO PHY%d CH%d lanes 0x%x (PHY_CONTROL=0x%08x)\n", |
| 1375 | phy, ch, mask, dev_priv->chv_phy_control); |
| 1376 | |
Ville Syrjälä | 3014227 | 2015-07-08 23:46:01 +0300 | [diff] [blame] | 1377 | assert_chv_phy_status(dev_priv); |
| 1378 | |
Ville Syrjälä | 6669e39 | 2015-07-08 23:46:00 +0300 | [diff] [blame] | 1379 | assert_chv_phy_powergate(dev_priv, phy, ch, override, mask); |
| 1380 | |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 1381 | mutex_unlock(&power_domains->lock); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1382 | } |
| 1383 | |
| 1384 | static bool chv_pipe_power_well_enabled(struct drm_i915_private *dev_priv, |
| 1385 | struct i915_power_well *power_well) |
| 1386 | { |
Imre Deak | f49193c | 2017-07-06 17:40:23 +0300 | [diff] [blame] | 1387 | enum pipe pipe = PIPE_A; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1388 | bool enabled; |
| 1389 | u32 state, ctrl; |
| 1390 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1391 | mutex_lock(&dev_priv->pcu_lock); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1392 | |
| 1393 | state = vlv_punit_read(dev_priv, PUNIT_REG_DSPFREQ) & DP_SSS_MASK(pipe); |
| 1394 | /* |
| 1395 | * We only ever set the power-on and power-gate states, anything |
| 1396 | * else is unexpected. |
| 1397 | */ |
| 1398 | WARN_ON(state != DP_SSS_PWR_ON(pipe) && state != DP_SSS_PWR_GATE(pipe)); |
| 1399 | enabled = state == DP_SSS_PWR_ON(pipe); |
| 1400 | |
| 1401 | /* |
| 1402 | * A transient state at this point would mean some unexpected party |
| 1403 | * is poking at the power controls too. |
| 1404 | */ |
| 1405 | ctrl = vlv_punit_read(dev_priv, PUNIT_REG_DSPFREQ) & DP_SSC_MASK(pipe); |
| 1406 | WARN_ON(ctrl << 16 != state); |
| 1407 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1408 | mutex_unlock(&dev_priv->pcu_lock); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1409 | |
| 1410 | return enabled; |
| 1411 | } |
| 1412 | |
| 1413 | static void chv_set_pipe_power_well(struct drm_i915_private *dev_priv, |
| 1414 | struct i915_power_well *power_well, |
| 1415 | bool enable) |
| 1416 | { |
Imre Deak | f49193c | 2017-07-06 17:40:23 +0300 | [diff] [blame] | 1417 | enum pipe pipe = PIPE_A; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1418 | u32 state; |
| 1419 | u32 ctrl; |
| 1420 | |
| 1421 | state = enable ? DP_SSS_PWR_ON(pipe) : DP_SSS_PWR_GATE(pipe); |
| 1422 | |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1423 | mutex_lock(&dev_priv->pcu_lock); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1424 | |
| 1425 | #define COND \ |
| 1426 | ((vlv_punit_read(dev_priv, PUNIT_REG_DSPFREQ) & DP_SSS_MASK(pipe)) == state) |
| 1427 | |
| 1428 | if (COND) |
| 1429 | goto out; |
| 1430 | |
| 1431 | ctrl = vlv_punit_read(dev_priv, PUNIT_REG_DSPFREQ); |
| 1432 | ctrl &= ~DP_SSC_MASK(pipe); |
| 1433 | ctrl |= enable ? DP_SSC_PWR_ON(pipe) : DP_SSC_PWR_GATE(pipe); |
| 1434 | vlv_punit_write(dev_priv, PUNIT_REG_DSPFREQ, ctrl); |
| 1435 | |
| 1436 | if (wait_for(COND, 100)) |
Masanari Iida | 7e35ab8 | 2015-05-10 01:00:23 +0900 | [diff] [blame] | 1437 | DRM_ERROR("timeout setting power well state %08x (%08x)\n", |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1438 | state, |
| 1439 | vlv_punit_read(dev_priv, PUNIT_REG_DSPFREQ)); |
| 1440 | |
| 1441 | #undef COND |
| 1442 | |
| 1443 | out: |
Sagar Arun Kamble | 9f81750 | 2017-10-10 22:30:05 +0100 | [diff] [blame] | 1444 | mutex_unlock(&dev_priv->pcu_lock); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1445 | } |
| 1446 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1447 | static void chv_pipe_power_well_enable(struct drm_i915_private *dev_priv, |
| 1448 | struct i915_power_well *power_well) |
| 1449 | { |
Imre Deak | f49193c | 2017-07-06 17:40:23 +0300 | [diff] [blame] | 1450 | WARN_ON_ONCE(power_well->id != CHV_DISP_PW_PIPE_A); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1451 | |
| 1452 | chv_set_pipe_power_well(dev_priv, power_well, true); |
Ville Syrjälä | afd6275 | 2014-10-30 19:43:03 +0200 | [diff] [blame] | 1453 | |
Ville Syrjälä | 2be7d54 | 2015-06-29 15:25:51 +0300 | [diff] [blame] | 1454 | vlv_display_power_well_init(dev_priv); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1455 | } |
| 1456 | |
| 1457 | static void chv_pipe_power_well_disable(struct drm_i915_private *dev_priv, |
| 1458 | struct i915_power_well *power_well) |
| 1459 | { |
Imre Deak | f49193c | 2017-07-06 17:40:23 +0300 | [diff] [blame] | 1460 | WARN_ON_ONCE(power_well->id != CHV_DISP_PW_PIPE_A); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1461 | |
Ville Syrjälä | 2be7d54 | 2015-06-29 15:25:51 +0300 | [diff] [blame] | 1462 | vlv_display_power_well_deinit(dev_priv); |
Ville Syrjälä | afd6275 | 2014-10-30 19:43:03 +0200 | [diff] [blame] | 1463 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1464 | chv_set_pipe_power_well(dev_priv, power_well, false); |
| 1465 | } |
| 1466 | |
Imre Deak | 0973128 | 2016-02-17 14:17:42 +0200 | [diff] [blame] | 1467 | static void |
| 1468 | __intel_display_power_get_domain(struct drm_i915_private *dev_priv, |
| 1469 | enum intel_display_power_domain domain) |
| 1470 | { |
| 1471 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 1472 | struct i915_power_well *power_well; |
Imre Deak | 0973128 | 2016-02-17 14:17:42 +0200 | [diff] [blame] | 1473 | |
Imre Deak | 75ccb2e | 2017-02-17 17:39:43 +0200 | [diff] [blame] | 1474 | for_each_power_domain_well(dev_priv, power_well, BIT_ULL(domain)) |
Imre Deak | b409ca9 | 2016-06-13 16:44:33 +0300 | [diff] [blame] | 1475 | intel_power_well_get(dev_priv, power_well); |
Imre Deak | 0973128 | 2016-02-17 14:17:42 +0200 | [diff] [blame] | 1476 | |
| 1477 | power_domains->domain_use_count[domain]++; |
| 1478 | } |
| 1479 | |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 1480 | /** |
| 1481 | * intel_display_power_get - grab a power domain reference |
| 1482 | * @dev_priv: i915 device instance |
| 1483 | * @domain: power domain to reference |
| 1484 | * |
| 1485 | * This function grabs a power domain reference for @domain and ensures that the |
| 1486 | * power domain and all its parents are powered up. Therefore users should only |
| 1487 | * grab a reference to the innermost power domain they need. |
| 1488 | * |
| 1489 | * Any power domain reference obtained by this function must have a symmetric |
| 1490 | * call to intel_display_power_put() to release the reference again. |
| 1491 | */ |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1492 | void intel_display_power_get(struct drm_i915_private *dev_priv, |
| 1493 | enum intel_display_power_domain domain) |
| 1494 | { |
Imre Deak | 0973128 | 2016-02-17 14:17:42 +0200 | [diff] [blame] | 1495 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1496 | |
| 1497 | intel_runtime_pm_get(dev_priv); |
| 1498 | |
Imre Deak | 0973128 | 2016-02-17 14:17:42 +0200 | [diff] [blame] | 1499 | mutex_lock(&power_domains->lock); |
| 1500 | |
| 1501 | __intel_display_power_get_domain(dev_priv, domain); |
| 1502 | |
| 1503 | mutex_unlock(&power_domains->lock); |
| 1504 | } |
| 1505 | |
| 1506 | /** |
| 1507 | * intel_display_power_get_if_enabled - grab a reference for an enabled display power domain |
| 1508 | * @dev_priv: i915 device instance |
| 1509 | * @domain: power domain to reference |
| 1510 | * |
| 1511 | * This function grabs a power domain reference for @domain and ensures that the |
| 1512 | * power domain and all its parents are powered up. Therefore users should only |
| 1513 | * grab a reference to the innermost power domain they need. |
| 1514 | * |
| 1515 | * Any power domain reference obtained by this function must have a symmetric |
| 1516 | * call to intel_display_power_put() to release the reference again. |
| 1517 | */ |
| 1518 | bool intel_display_power_get_if_enabled(struct drm_i915_private *dev_priv, |
| 1519 | enum intel_display_power_domain domain) |
| 1520 | { |
| 1521 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 1522 | bool is_enabled; |
| 1523 | |
| 1524 | if (!intel_runtime_pm_get_if_in_use(dev_priv)) |
| 1525 | return false; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1526 | |
| 1527 | mutex_lock(&power_domains->lock); |
| 1528 | |
Imre Deak | 0973128 | 2016-02-17 14:17:42 +0200 | [diff] [blame] | 1529 | if (__intel_display_power_is_enabled(dev_priv, domain)) { |
| 1530 | __intel_display_power_get_domain(dev_priv, domain); |
| 1531 | is_enabled = true; |
| 1532 | } else { |
| 1533 | is_enabled = false; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1534 | } |
| 1535 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1536 | mutex_unlock(&power_domains->lock); |
Imre Deak | 0973128 | 2016-02-17 14:17:42 +0200 | [diff] [blame] | 1537 | |
| 1538 | if (!is_enabled) |
| 1539 | intel_runtime_pm_put(dev_priv); |
| 1540 | |
| 1541 | return is_enabled; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1542 | } |
| 1543 | |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 1544 | /** |
| 1545 | * intel_display_power_put - release a power domain reference |
| 1546 | * @dev_priv: i915 device instance |
| 1547 | * @domain: power domain to reference |
| 1548 | * |
| 1549 | * This function drops the power domain reference obtained by |
| 1550 | * intel_display_power_get() and might power down the corresponding hardware |
| 1551 | * block right away if this is the last reference. |
| 1552 | */ |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1553 | void intel_display_power_put(struct drm_i915_private *dev_priv, |
| 1554 | enum intel_display_power_domain domain) |
| 1555 | { |
| 1556 | struct i915_power_domains *power_domains; |
| 1557 | struct i915_power_well *power_well; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1558 | |
| 1559 | power_domains = &dev_priv->power_domains; |
| 1560 | |
| 1561 | mutex_lock(&power_domains->lock); |
| 1562 | |
Daniel Stone | 11c86db | 2015-11-20 15:55:34 +0000 | [diff] [blame] | 1563 | WARN(!power_domains->domain_use_count[domain], |
| 1564 | "Use count on domain %s is already zero\n", |
| 1565 | intel_display_power_domain_str(domain)); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1566 | power_domains->domain_use_count[domain]--; |
| 1567 | |
Imre Deak | 75ccb2e | 2017-02-17 17:39:43 +0200 | [diff] [blame] | 1568 | for_each_power_domain_well_rev(dev_priv, power_well, BIT_ULL(domain)) |
Imre Deak | b409ca9 | 2016-06-13 16:44:33 +0300 | [diff] [blame] | 1569 | intel_power_well_put(dev_priv, power_well); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1570 | |
| 1571 | mutex_unlock(&power_domains->lock); |
| 1572 | |
| 1573 | intel_runtime_pm_put(dev_priv); |
| 1574 | } |
| 1575 | |
Imre Deak | 965a79a | 2017-07-06 17:40:40 +0300 | [diff] [blame] | 1576 | #define I830_PIPES_POWER_DOMAINS ( \ |
| 1577 | BIT_ULL(POWER_DOMAIN_PIPE_A) | \ |
| 1578 | BIT_ULL(POWER_DOMAIN_PIPE_B) | \ |
| 1579 | BIT_ULL(POWER_DOMAIN_PIPE_A_PANEL_FITTER) | \ |
| 1580 | BIT_ULL(POWER_DOMAIN_PIPE_B_PANEL_FITTER) | \ |
| 1581 | BIT_ULL(POWER_DOMAIN_TRANSCODER_A) | \ |
| 1582 | BIT_ULL(POWER_DOMAIN_TRANSCODER_B) | \ |
Ander Conselvan de Oliveira | d8fc70b | 2017-02-09 11:31:21 +0200 | [diff] [blame] | 1583 | BIT_ULL(POWER_DOMAIN_INIT)) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1584 | |
Ville Syrjälä | 465ac0c | 2016-04-18 14:02:27 +0300 | [diff] [blame] | 1585 | #define VLV_DISPLAY_POWER_DOMAINS ( \ |
Ander Conselvan de Oliveira | d8fc70b | 2017-02-09 11:31:21 +0200 | [diff] [blame] | 1586 | BIT_ULL(POWER_DOMAIN_PIPE_A) | \ |
| 1587 | BIT_ULL(POWER_DOMAIN_PIPE_B) | \ |
| 1588 | BIT_ULL(POWER_DOMAIN_PIPE_A_PANEL_FITTER) | \ |
| 1589 | BIT_ULL(POWER_DOMAIN_PIPE_B_PANEL_FITTER) | \ |
| 1590 | BIT_ULL(POWER_DOMAIN_TRANSCODER_A) | \ |
| 1591 | BIT_ULL(POWER_DOMAIN_TRANSCODER_B) | \ |
| 1592 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_LANES) | \ |
| 1593 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_LANES) | \ |
| 1594 | BIT_ULL(POWER_DOMAIN_PORT_DSI) | \ |
| 1595 | BIT_ULL(POWER_DOMAIN_PORT_CRT) | \ |
| 1596 | BIT_ULL(POWER_DOMAIN_VGA) | \ |
| 1597 | BIT_ULL(POWER_DOMAIN_AUDIO) | \ |
| 1598 | BIT_ULL(POWER_DOMAIN_AUX_B) | \ |
| 1599 | BIT_ULL(POWER_DOMAIN_AUX_C) | \ |
| 1600 | BIT_ULL(POWER_DOMAIN_GMBUS) | \ |
| 1601 | BIT_ULL(POWER_DOMAIN_INIT)) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1602 | |
| 1603 | #define VLV_DPIO_CMN_BC_POWER_DOMAINS ( \ |
Ander Conselvan de Oliveira | d8fc70b | 2017-02-09 11:31:21 +0200 | [diff] [blame] | 1604 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_LANES) | \ |
| 1605 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_LANES) | \ |
| 1606 | BIT_ULL(POWER_DOMAIN_PORT_CRT) | \ |
| 1607 | BIT_ULL(POWER_DOMAIN_AUX_B) | \ |
| 1608 | BIT_ULL(POWER_DOMAIN_AUX_C) | \ |
| 1609 | BIT_ULL(POWER_DOMAIN_INIT)) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1610 | |
| 1611 | #define VLV_DPIO_TX_B_LANES_01_POWER_DOMAINS ( \ |
Ander Conselvan de Oliveira | d8fc70b | 2017-02-09 11:31:21 +0200 | [diff] [blame] | 1612 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_LANES) | \ |
| 1613 | BIT_ULL(POWER_DOMAIN_AUX_B) | \ |
| 1614 | BIT_ULL(POWER_DOMAIN_INIT)) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1615 | |
| 1616 | #define VLV_DPIO_TX_B_LANES_23_POWER_DOMAINS ( \ |
Ander Conselvan de Oliveira | d8fc70b | 2017-02-09 11:31:21 +0200 | [diff] [blame] | 1617 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_LANES) | \ |
| 1618 | BIT_ULL(POWER_DOMAIN_AUX_B) | \ |
| 1619 | BIT_ULL(POWER_DOMAIN_INIT)) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1620 | |
| 1621 | #define VLV_DPIO_TX_C_LANES_01_POWER_DOMAINS ( \ |
Ander Conselvan de Oliveira | d8fc70b | 2017-02-09 11:31:21 +0200 | [diff] [blame] | 1622 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_LANES) | \ |
| 1623 | BIT_ULL(POWER_DOMAIN_AUX_C) | \ |
| 1624 | BIT_ULL(POWER_DOMAIN_INIT)) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1625 | |
| 1626 | #define VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS ( \ |
Ander Conselvan de Oliveira | d8fc70b | 2017-02-09 11:31:21 +0200 | [diff] [blame] | 1627 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_LANES) | \ |
| 1628 | BIT_ULL(POWER_DOMAIN_AUX_C) | \ |
| 1629 | BIT_ULL(POWER_DOMAIN_INIT)) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1630 | |
Ville Syrjälä | 465ac0c | 2016-04-18 14:02:27 +0300 | [diff] [blame] | 1631 | #define CHV_DISPLAY_POWER_DOMAINS ( \ |
Ander Conselvan de Oliveira | d8fc70b | 2017-02-09 11:31:21 +0200 | [diff] [blame] | 1632 | BIT_ULL(POWER_DOMAIN_PIPE_A) | \ |
| 1633 | BIT_ULL(POWER_DOMAIN_PIPE_B) | \ |
| 1634 | BIT_ULL(POWER_DOMAIN_PIPE_C) | \ |
| 1635 | BIT_ULL(POWER_DOMAIN_PIPE_A_PANEL_FITTER) | \ |
| 1636 | BIT_ULL(POWER_DOMAIN_PIPE_B_PANEL_FITTER) | \ |
| 1637 | BIT_ULL(POWER_DOMAIN_PIPE_C_PANEL_FITTER) | \ |
| 1638 | BIT_ULL(POWER_DOMAIN_TRANSCODER_A) | \ |
| 1639 | BIT_ULL(POWER_DOMAIN_TRANSCODER_B) | \ |
| 1640 | BIT_ULL(POWER_DOMAIN_TRANSCODER_C) | \ |
| 1641 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_LANES) | \ |
| 1642 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_LANES) | \ |
| 1643 | BIT_ULL(POWER_DOMAIN_PORT_DDI_D_LANES) | \ |
| 1644 | BIT_ULL(POWER_DOMAIN_PORT_DSI) | \ |
| 1645 | BIT_ULL(POWER_DOMAIN_VGA) | \ |
| 1646 | BIT_ULL(POWER_DOMAIN_AUDIO) | \ |
| 1647 | BIT_ULL(POWER_DOMAIN_AUX_B) | \ |
| 1648 | BIT_ULL(POWER_DOMAIN_AUX_C) | \ |
| 1649 | BIT_ULL(POWER_DOMAIN_AUX_D) | \ |
| 1650 | BIT_ULL(POWER_DOMAIN_GMBUS) | \ |
| 1651 | BIT_ULL(POWER_DOMAIN_INIT)) |
Ville Syrjälä | 465ac0c | 2016-04-18 14:02:27 +0300 | [diff] [blame] | 1652 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1653 | #define CHV_DPIO_CMN_BC_POWER_DOMAINS ( \ |
Ander Conselvan de Oliveira | d8fc70b | 2017-02-09 11:31:21 +0200 | [diff] [blame] | 1654 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_LANES) | \ |
| 1655 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_LANES) | \ |
| 1656 | BIT_ULL(POWER_DOMAIN_AUX_B) | \ |
| 1657 | BIT_ULL(POWER_DOMAIN_AUX_C) | \ |
| 1658 | BIT_ULL(POWER_DOMAIN_INIT)) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1659 | |
| 1660 | #define CHV_DPIO_CMN_D_POWER_DOMAINS ( \ |
Ander Conselvan de Oliveira | d8fc70b | 2017-02-09 11:31:21 +0200 | [diff] [blame] | 1661 | BIT_ULL(POWER_DOMAIN_PORT_DDI_D_LANES) | \ |
| 1662 | BIT_ULL(POWER_DOMAIN_AUX_D) | \ |
| 1663 | BIT_ULL(POWER_DOMAIN_INIT)) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1664 | |
Imre Deak | 965a79a | 2017-07-06 17:40:40 +0300 | [diff] [blame] | 1665 | #define HSW_DISPLAY_POWER_DOMAINS ( \ |
| 1666 | BIT_ULL(POWER_DOMAIN_PIPE_B) | \ |
| 1667 | BIT_ULL(POWER_DOMAIN_PIPE_C) | \ |
| 1668 | BIT_ULL(POWER_DOMAIN_PIPE_A_PANEL_FITTER) | \ |
| 1669 | BIT_ULL(POWER_DOMAIN_PIPE_B_PANEL_FITTER) | \ |
| 1670 | BIT_ULL(POWER_DOMAIN_PIPE_C_PANEL_FITTER) | \ |
| 1671 | BIT_ULL(POWER_DOMAIN_TRANSCODER_A) | \ |
| 1672 | BIT_ULL(POWER_DOMAIN_TRANSCODER_B) | \ |
| 1673 | BIT_ULL(POWER_DOMAIN_TRANSCODER_C) | \ |
| 1674 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_LANES) | \ |
| 1675 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_LANES) | \ |
| 1676 | BIT_ULL(POWER_DOMAIN_PORT_DDI_D_LANES) | \ |
| 1677 | BIT_ULL(POWER_DOMAIN_PORT_CRT) | /* DDI E */ \ |
| 1678 | BIT_ULL(POWER_DOMAIN_VGA) | \ |
| 1679 | BIT_ULL(POWER_DOMAIN_AUDIO) | \ |
| 1680 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1681 | |
| 1682 | #define BDW_DISPLAY_POWER_DOMAINS ( \ |
| 1683 | BIT_ULL(POWER_DOMAIN_PIPE_B) | \ |
| 1684 | BIT_ULL(POWER_DOMAIN_PIPE_C) | \ |
| 1685 | BIT_ULL(POWER_DOMAIN_PIPE_B_PANEL_FITTER) | \ |
| 1686 | BIT_ULL(POWER_DOMAIN_PIPE_C_PANEL_FITTER) | \ |
| 1687 | BIT_ULL(POWER_DOMAIN_TRANSCODER_A) | \ |
| 1688 | BIT_ULL(POWER_DOMAIN_TRANSCODER_B) | \ |
| 1689 | BIT_ULL(POWER_DOMAIN_TRANSCODER_C) | \ |
| 1690 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_LANES) | \ |
| 1691 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_LANES) | \ |
| 1692 | BIT_ULL(POWER_DOMAIN_PORT_DDI_D_LANES) | \ |
| 1693 | BIT_ULL(POWER_DOMAIN_PORT_CRT) | /* DDI E */ \ |
| 1694 | BIT_ULL(POWER_DOMAIN_VGA) | \ |
| 1695 | BIT_ULL(POWER_DOMAIN_AUDIO) | \ |
| 1696 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1697 | |
| 1698 | #define SKL_DISPLAY_POWERWELL_2_POWER_DOMAINS ( \ |
| 1699 | BIT_ULL(POWER_DOMAIN_TRANSCODER_A) | \ |
| 1700 | BIT_ULL(POWER_DOMAIN_PIPE_B) | \ |
| 1701 | BIT_ULL(POWER_DOMAIN_TRANSCODER_B) | \ |
| 1702 | BIT_ULL(POWER_DOMAIN_PIPE_C) | \ |
| 1703 | BIT_ULL(POWER_DOMAIN_TRANSCODER_C) | \ |
| 1704 | BIT_ULL(POWER_DOMAIN_PIPE_B_PANEL_FITTER) | \ |
| 1705 | BIT_ULL(POWER_DOMAIN_PIPE_C_PANEL_FITTER) | \ |
| 1706 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_LANES) | \ |
| 1707 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_LANES) | \ |
| 1708 | BIT_ULL(POWER_DOMAIN_PORT_DDI_D_LANES) | \ |
| 1709 | BIT_ULL(POWER_DOMAIN_PORT_DDI_E_LANES) | \ |
| 1710 | BIT_ULL(POWER_DOMAIN_AUX_B) | \ |
| 1711 | BIT_ULL(POWER_DOMAIN_AUX_C) | \ |
| 1712 | BIT_ULL(POWER_DOMAIN_AUX_D) | \ |
| 1713 | BIT_ULL(POWER_DOMAIN_AUDIO) | \ |
| 1714 | BIT_ULL(POWER_DOMAIN_VGA) | \ |
| 1715 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1716 | #define SKL_DISPLAY_DDI_IO_A_E_POWER_DOMAINS ( \ |
| 1717 | BIT_ULL(POWER_DOMAIN_PORT_DDI_A_IO) | \ |
| 1718 | BIT_ULL(POWER_DOMAIN_PORT_DDI_E_IO) | \ |
| 1719 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1720 | #define SKL_DISPLAY_DDI_IO_B_POWER_DOMAINS ( \ |
| 1721 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_IO) | \ |
| 1722 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1723 | #define SKL_DISPLAY_DDI_IO_C_POWER_DOMAINS ( \ |
| 1724 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_IO) | \ |
| 1725 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1726 | #define SKL_DISPLAY_DDI_IO_D_POWER_DOMAINS ( \ |
| 1727 | BIT_ULL(POWER_DOMAIN_PORT_DDI_D_IO) | \ |
| 1728 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1729 | #define SKL_DISPLAY_DC_OFF_POWER_DOMAINS ( \ |
| 1730 | SKL_DISPLAY_POWERWELL_2_POWER_DOMAINS | \ |
Tvrtko Ursulin | b687637 | 2017-12-05 13:28:54 +0000 | [diff] [blame] | 1731 | BIT_ULL(POWER_DOMAIN_GT_IRQ) | \ |
Imre Deak | 965a79a | 2017-07-06 17:40:40 +0300 | [diff] [blame] | 1732 | BIT_ULL(POWER_DOMAIN_MODESET) | \ |
| 1733 | BIT_ULL(POWER_DOMAIN_AUX_A) | \ |
| 1734 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1735 | |
| 1736 | #define BXT_DISPLAY_POWERWELL_2_POWER_DOMAINS ( \ |
| 1737 | BIT_ULL(POWER_DOMAIN_TRANSCODER_A) | \ |
| 1738 | BIT_ULL(POWER_DOMAIN_PIPE_B) | \ |
| 1739 | BIT_ULL(POWER_DOMAIN_TRANSCODER_B) | \ |
| 1740 | BIT_ULL(POWER_DOMAIN_PIPE_C) | \ |
| 1741 | BIT_ULL(POWER_DOMAIN_TRANSCODER_C) | \ |
| 1742 | BIT_ULL(POWER_DOMAIN_PIPE_B_PANEL_FITTER) | \ |
| 1743 | BIT_ULL(POWER_DOMAIN_PIPE_C_PANEL_FITTER) | \ |
| 1744 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_LANES) | \ |
| 1745 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_LANES) | \ |
| 1746 | BIT_ULL(POWER_DOMAIN_AUX_B) | \ |
| 1747 | BIT_ULL(POWER_DOMAIN_AUX_C) | \ |
| 1748 | BIT_ULL(POWER_DOMAIN_AUDIO) | \ |
| 1749 | BIT_ULL(POWER_DOMAIN_VGA) | \ |
Imre Deak | 965a79a | 2017-07-06 17:40:40 +0300 | [diff] [blame] | 1750 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1751 | #define BXT_DISPLAY_DC_OFF_POWER_DOMAINS ( \ |
| 1752 | BXT_DISPLAY_POWERWELL_2_POWER_DOMAINS | \ |
Tvrtko Ursulin | b687637 | 2017-12-05 13:28:54 +0000 | [diff] [blame] | 1753 | BIT_ULL(POWER_DOMAIN_GT_IRQ) | \ |
Imre Deak | 965a79a | 2017-07-06 17:40:40 +0300 | [diff] [blame] | 1754 | BIT_ULL(POWER_DOMAIN_MODESET) | \ |
| 1755 | BIT_ULL(POWER_DOMAIN_AUX_A) | \ |
Ville Syrjälä | 54c105d | 2017-12-08 23:37:37 +0200 | [diff] [blame] | 1756 | BIT_ULL(POWER_DOMAIN_GMBUS) | \ |
Imre Deak | 965a79a | 2017-07-06 17:40:40 +0300 | [diff] [blame] | 1757 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1758 | #define BXT_DPIO_CMN_A_POWER_DOMAINS ( \ |
| 1759 | BIT_ULL(POWER_DOMAIN_PORT_DDI_A_LANES) | \ |
| 1760 | BIT_ULL(POWER_DOMAIN_AUX_A) | \ |
| 1761 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1762 | #define BXT_DPIO_CMN_BC_POWER_DOMAINS ( \ |
| 1763 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_LANES) | \ |
| 1764 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_LANES) | \ |
| 1765 | BIT_ULL(POWER_DOMAIN_AUX_B) | \ |
| 1766 | BIT_ULL(POWER_DOMAIN_AUX_C) | \ |
| 1767 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1768 | |
| 1769 | #define GLK_DISPLAY_POWERWELL_2_POWER_DOMAINS ( \ |
| 1770 | BIT_ULL(POWER_DOMAIN_TRANSCODER_A) | \ |
| 1771 | BIT_ULL(POWER_DOMAIN_PIPE_B) | \ |
| 1772 | BIT_ULL(POWER_DOMAIN_TRANSCODER_B) | \ |
| 1773 | BIT_ULL(POWER_DOMAIN_PIPE_C) | \ |
| 1774 | BIT_ULL(POWER_DOMAIN_TRANSCODER_C) | \ |
| 1775 | BIT_ULL(POWER_DOMAIN_PIPE_B_PANEL_FITTER) | \ |
| 1776 | BIT_ULL(POWER_DOMAIN_PIPE_C_PANEL_FITTER) | \ |
| 1777 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_LANES) | \ |
| 1778 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_LANES) | \ |
| 1779 | BIT_ULL(POWER_DOMAIN_AUX_B) | \ |
| 1780 | BIT_ULL(POWER_DOMAIN_AUX_C) | \ |
| 1781 | BIT_ULL(POWER_DOMAIN_AUDIO) | \ |
| 1782 | BIT_ULL(POWER_DOMAIN_VGA) | \ |
| 1783 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1784 | #define GLK_DISPLAY_DDI_IO_A_POWER_DOMAINS ( \ |
| 1785 | BIT_ULL(POWER_DOMAIN_PORT_DDI_A_IO)) |
| 1786 | #define GLK_DISPLAY_DDI_IO_B_POWER_DOMAINS ( \ |
| 1787 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_IO)) |
| 1788 | #define GLK_DISPLAY_DDI_IO_C_POWER_DOMAINS ( \ |
| 1789 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_IO)) |
| 1790 | #define GLK_DPIO_CMN_A_POWER_DOMAINS ( \ |
| 1791 | BIT_ULL(POWER_DOMAIN_PORT_DDI_A_LANES) | \ |
| 1792 | BIT_ULL(POWER_DOMAIN_AUX_A) | \ |
| 1793 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1794 | #define GLK_DPIO_CMN_B_POWER_DOMAINS ( \ |
| 1795 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_LANES) | \ |
| 1796 | BIT_ULL(POWER_DOMAIN_AUX_B) | \ |
| 1797 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1798 | #define GLK_DPIO_CMN_C_POWER_DOMAINS ( \ |
| 1799 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_LANES) | \ |
| 1800 | BIT_ULL(POWER_DOMAIN_AUX_C) | \ |
| 1801 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1802 | #define GLK_DISPLAY_AUX_A_POWER_DOMAINS ( \ |
| 1803 | BIT_ULL(POWER_DOMAIN_AUX_A) | \ |
| 1804 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1805 | #define GLK_DISPLAY_AUX_B_POWER_DOMAINS ( \ |
| 1806 | BIT_ULL(POWER_DOMAIN_AUX_B) | \ |
| 1807 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1808 | #define GLK_DISPLAY_AUX_C_POWER_DOMAINS ( \ |
| 1809 | BIT_ULL(POWER_DOMAIN_AUX_C) | \ |
| 1810 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1811 | #define GLK_DISPLAY_DC_OFF_POWER_DOMAINS ( \ |
| 1812 | GLK_DISPLAY_POWERWELL_2_POWER_DOMAINS | \ |
Tvrtko Ursulin | b687637 | 2017-12-05 13:28:54 +0000 | [diff] [blame] | 1813 | BIT_ULL(POWER_DOMAIN_GT_IRQ) | \ |
Imre Deak | 965a79a | 2017-07-06 17:40:40 +0300 | [diff] [blame] | 1814 | BIT_ULL(POWER_DOMAIN_MODESET) | \ |
| 1815 | BIT_ULL(POWER_DOMAIN_AUX_A) | \ |
Ville Syrjälä | 156961a | 2017-12-08 23:37:36 +0200 | [diff] [blame] | 1816 | BIT_ULL(POWER_DOMAIN_GMBUS) | \ |
Imre Deak | 965a79a | 2017-07-06 17:40:40 +0300 | [diff] [blame] | 1817 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1818 | |
| 1819 | #define CNL_DISPLAY_POWERWELL_2_POWER_DOMAINS ( \ |
| 1820 | BIT_ULL(POWER_DOMAIN_TRANSCODER_A) | \ |
| 1821 | BIT_ULL(POWER_DOMAIN_PIPE_B) | \ |
| 1822 | BIT_ULL(POWER_DOMAIN_TRANSCODER_B) | \ |
| 1823 | BIT_ULL(POWER_DOMAIN_PIPE_C) | \ |
| 1824 | BIT_ULL(POWER_DOMAIN_TRANSCODER_C) | \ |
| 1825 | BIT_ULL(POWER_DOMAIN_PIPE_B_PANEL_FITTER) | \ |
| 1826 | BIT_ULL(POWER_DOMAIN_PIPE_C_PANEL_FITTER) | \ |
| 1827 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_LANES) | \ |
| 1828 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_LANES) | \ |
| 1829 | BIT_ULL(POWER_DOMAIN_PORT_DDI_D_LANES) | \ |
Imre Deak | 965a79a | 2017-07-06 17:40:40 +0300 | [diff] [blame] | 1830 | BIT_ULL(POWER_DOMAIN_AUX_B) | \ |
| 1831 | BIT_ULL(POWER_DOMAIN_AUX_C) | \ |
| 1832 | BIT_ULL(POWER_DOMAIN_AUX_D) | \ |
Rodrigo Vivi | a324fca | 2018-01-29 15:22:15 -0800 | [diff] [blame^] | 1833 | BIT_ULL(POWER_DOMAIN_AUX_F) | \ |
Imre Deak | 965a79a | 2017-07-06 17:40:40 +0300 | [diff] [blame] | 1834 | BIT_ULL(POWER_DOMAIN_AUDIO) | \ |
| 1835 | BIT_ULL(POWER_DOMAIN_VGA) | \ |
| 1836 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1837 | #define CNL_DISPLAY_DDI_A_IO_POWER_DOMAINS ( \ |
| 1838 | BIT_ULL(POWER_DOMAIN_PORT_DDI_A_IO) | \ |
Imre Deak | 965a79a | 2017-07-06 17:40:40 +0300 | [diff] [blame] | 1839 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1840 | #define CNL_DISPLAY_DDI_B_IO_POWER_DOMAINS ( \ |
| 1841 | BIT_ULL(POWER_DOMAIN_PORT_DDI_B_IO) | \ |
| 1842 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1843 | #define CNL_DISPLAY_DDI_C_IO_POWER_DOMAINS ( \ |
| 1844 | BIT_ULL(POWER_DOMAIN_PORT_DDI_C_IO) | \ |
| 1845 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1846 | #define CNL_DISPLAY_DDI_D_IO_POWER_DOMAINS ( \ |
| 1847 | BIT_ULL(POWER_DOMAIN_PORT_DDI_D_IO) | \ |
| 1848 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1849 | #define CNL_DISPLAY_AUX_A_POWER_DOMAINS ( \ |
| 1850 | BIT_ULL(POWER_DOMAIN_AUX_A) | \ |
| 1851 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1852 | #define CNL_DISPLAY_AUX_B_POWER_DOMAINS ( \ |
| 1853 | BIT_ULL(POWER_DOMAIN_AUX_B) | \ |
| 1854 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1855 | #define CNL_DISPLAY_AUX_C_POWER_DOMAINS ( \ |
| 1856 | BIT_ULL(POWER_DOMAIN_AUX_C) | \ |
| 1857 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1858 | #define CNL_DISPLAY_AUX_D_POWER_DOMAINS ( \ |
| 1859 | BIT_ULL(POWER_DOMAIN_AUX_D) | \ |
| 1860 | BIT_ULL(POWER_DOMAIN_INIT)) |
Rodrigo Vivi | a324fca | 2018-01-29 15:22:15 -0800 | [diff] [blame^] | 1861 | #define CNL_DISPLAY_AUX_F_POWER_DOMAINS ( \ |
| 1862 | BIT_ULL(POWER_DOMAIN_AUX_F) | \ |
| 1863 | BIT_ULL(POWER_DOMAIN_INIT)) |
Imre Deak | 965a79a | 2017-07-06 17:40:40 +0300 | [diff] [blame] | 1864 | #define CNL_DISPLAY_DC_OFF_POWER_DOMAINS ( \ |
| 1865 | CNL_DISPLAY_POWERWELL_2_POWER_DOMAINS | \ |
Tvrtko Ursulin | 6e7a3f5 | 2018-01-11 08:24:17 +0000 | [diff] [blame] | 1866 | BIT_ULL(POWER_DOMAIN_GT_IRQ) | \ |
Imre Deak | 965a79a | 2017-07-06 17:40:40 +0300 | [diff] [blame] | 1867 | BIT_ULL(POWER_DOMAIN_MODESET) | \ |
| 1868 | BIT_ULL(POWER_DOMAIN_AUX_A) | \ |
Ville Syrjälä | 2ee0da1 | 2017-06-01 17:36:16 +0300 | [diff] [blame] | 1869 | BIT_ULL(POWER_DOMAIN_INIT)) |
| 1870 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1871 | static const struct i915_power_well_ops i9xx_always_on_power_well_ops = { |
Imre Deak | 3c1b38e | 2017-02-17 17:39:42 +0200 | [diff] [blame] | 1872 | .sync_hw = i9xx_power_well_sync_hw_noop, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1873 | .enable = i9xx_always_on_power_well_noop, |
| 1874 | .disable = i9xx_always_on_power_well_noop, |
| 1875 | .is_enabled = i9xx_always_on_power_well_enabled, |
| 1876 | }; |
| 1877 | |
| 1878 | static const struct i915_power_well_ops chv_pipe_power_well_ops = { |
Imre Deak | 3c1b38e | 2017-02-17 17:39:42 +0200 | [diff] [blame] | 1879 | .sync_hw = i9xx_power_well_sync_hw_noop, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1880 | .enable = chv_pipe_power_well_enable, |
| 1881 | .disable = chv_pipe_power_well_disable, |
| 1882 | .is_enabled = chv_pipe_power_well_enabled, |
| 1883 | }; |
| 1884 | |
| 1885 | static const struct i915_power_well_ops chv_dpio_cmn_power_well_ops = { |
Imre Deak | 3c1b38e | 2017-02-17 17:39:42 +0200 | [diff] [blame] | 1886 | .sync_hw = i9xx_power_well_sync_hw_noop, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1887 | .enable = chv_dpio_cmn_power_well_enable, |
| 1888 | .disable = chv_dpio_cmn_power_well_disable, |
| 1889 | .is_enabled = vlv_power_well_enabled, |
| 1890 | }; |
| 1891 | |
| 1892 | static struct i915_power_well i9xx_always_on_power_well[] = { |
| 1893 | { |
| 1894 | .name = "always-on", |
| 1895 | .always_on = 1, |
| 1896 | .domains = POWER_DOMAIN_MASK, |
| 1897 | .ops = &i9xx_always_on_power_well_ops, |
Imre Deak | 029d80d | 2017-07-06 17:40:25 +0300 | [diff] [blame] | 1898 | .id = I915_DISP_PW_ALWAYS_ON, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1899 | }, |
| 1900 | }; |
| 1901 | |
Ville Syrjälä | 2ee0da1 | 2017-06-01 17:36:16 +0300 | [diff] [blame] | 1902 | static const struct i915_power_well_ops i830_pipes_power_well_ops = { |
| 1903 | .sync_hw = i830_pipes_power_well_sync_hw, |
| 1904 | .enable = i830_pipes_power_well_enable, |
| 1905 | .disable = i830_pipes_power_well_disable, |
| 1906 | .is_enabled = i830_pipes_power_well_enabled, |
| 1907 | }; |
| 1908 | |
| 1909 | static struct i915_power_well i830_power_wells[] = { |
| 1910 | { |
| 1911 | .name = "always-on", |
| 1912 | .always_on = 1, |
| 1913 | .domains = POWER_DOMAIN_MASK, |
| 1914 | .ops = &i9xx_always_on_power_well_ops, |
Imre Deak | 029d80d | 2017-07-06 17:40:25 +0300 | [diff] [blame] | 1915 | .id = I915_DISP_PW_ALWAYS_ON, |
Ville Syrjälä | 2ee0da1 | 2017-06-01 17:36:16 +0300 | [diff] [blame] | 1916 | }, |
| 1917 | { |
| 1918 | .name = "pipes", |
| 1919 | .domains = I830_PIPES_POWER_DOMAINS, |
| 1920 | .ops = &i830_pipes_power_well_ops, |
Imre Deak | 120b56a | 2017-07-11 23:42:31 +0300 | [diff] [blame] | 1921 | .id = I830_DISP_PW_PIPES, |
Ville Syrjälä | 2ee0da1 | 2017-06-01 17:36:16 +0300 | [diff] [blame] | 1922 | }, |
| 1923 | }; |
| 1924 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1925 | static const struct i915_power_well_ops hsw_power_well_ops = { |
| 1926 | .sync_hw = hsw_power_well_sync_hw, |
| 1927 | .enable = hsw_power_well_enable, |
| 1928 | .disable = hsw_power_well_disable, |
| 1929 | .is_enabled = hsw_power_well_enabled, |
| 1930 | }; |
| 1931 | |
Patrik Jakobsson | 9f836f9 | 2015-11-16 16:20:01 +0100 | [diff] [blame] | 1932 | static const struct i915_power_well_ops gen9_dc_off_power_well_ops = { |
Imre Deak | 3c1b38e | 2017-02-17 17:39:42 +0200 | [diff] [blame] | 1933 | .sync_hw = i9xx_power_well_sync_hw_noop, |
Patrik Jakobsson | 9f836f9 | 2015-11-16 16:20:01 +0100 | [diff] [blame] | 1934 | .enable = gen9_dc_off_power_well_enable, |
| 1935 | .disable = gen9_dc_off_power_well_disable, |
| 1936 | .is_enabled = gen9_dc_off_power_well_enabled, |
| 1937 | }; |
| 1938 | |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 1939 | static const struct i915_power_well_ops bxt_dpio_cmn_power_well_ops = { |
Imre Deak | 3c1b38e | 2017-02-17 17:39:42 +0200 | [diff] [blame] | 1940 | .sync_hw = i9xx_power_well_sync_hw_noop, |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 1941 | .enable = bxt_dpio_cmn_power_well_enable, |
| 1942 | .disable = bxt_dpio_cmn_power_well_disable, |
| 1943 | .is_enabled = bxt_dpio_cmn_power_well_enabled, |
| 1944 | }; |
| 1945 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1946 | static struct i915_power_well hsw_power_wells[] = { |
| 1947 | { |
| 1948 | .name = "always-on", |
| 1949 | .always_on = 1, |
Ville Syrjälä | 998bd66 | 2016-04-18 14:02:26 +0300 | [diff] [blame] | 1950 | .domains = POWER_DOMAIN_MASK, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1951 | .ops = &i9xx_always_on_power_well_ops, |
Imre Deak | 029d80d | 2017-07-06 17:40:25 +0300 | [diff] [blame] | 1952 | .id = I915_DISP_PW_ALWAYS_ON, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1953 | }, |
| 1954 | { |
| 1955 | .name = "display", |
| 1956 | .domains = HSW_DISPLAY_POWER_DOMAINS, |
| 1957 | .ops = &hsw_power_well_ops, |
Imre Deak | fb9248e | 2017-07-11 23:42:32 +0300 | [diff] [blame] | 1958 | .id = HSW_DISP_PW_GLOBAL, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 1959 | { |
| 1960 | .hsw.has_vga = true, |
| 1961 | }, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1962 | }, |
| 1963 | }; |
| 1964 | |
| 1965 | static struct i915_power_well bdw_power_wells[] = { |
| 1966 | { |
| 1967 | .name = "always-on", |
| 1968 | .always_on = 1, |
Ville Syrjälä | 998bd66 | 2016-04-18 14:02:26 +0300 | [diff] [blame] | 1969 | .domains = POWER_DOMAIN_MASK, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1970 | .ops = &i9xx_always_on_power_well_ops, |
Imre Deak | 029d80d | 2017-07-06 17:40:25 +0300 | [diff] [blame] | 1971 | .id = I915_DISP_PW_ALWAYS_ON, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1972 | }, |
| 1973 | { |
| 1974 | .name = "display", |
| 1975 | .domains = BDW_DISPLAY_POWER_DOMAINS, |
| 1976 | .ops = &hsw_power_well_ops, |
Imre Deak | fb9248e | 2017-07-11 23:42:32 +0300 | [diff] [blame] | 1977 | .id = HSW_DISP_PW_GLOBAL, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 1978 | { |
| 1979 | .hsw.irq_pipe_mask = BIT(PIPE_B) | BIT(PIPE_C), |
| 1980 | .hsw.has_vga = true, |
| 1981 | }, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1982 | }, |
| 1983 | }; |
| 1984 | |
| 1985 | static const struct i915_power_well_ops vlv_display_power_well_ops = { |
Imre Deak | 3c1b38e | 2017-02-17 17:39:42 +0200 | [diff] [blame] | 1986 | .sync_hw = i9xx_power_well_sync_hw_noop, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1987 | .enable = vlv_display_power_well_enable, |
| 1988 | .disable = vlv_display_power_well_disable, |
| 1989 | .is_enabled = vlv_power_well_enabled, |
| 1990 | }; |
| 1991 | |
| 1992 | static const struct i915_power_well_ops vlv_dpio_cmn_power_well_ops = { |
Imre Deak | 3c1b38e | 2017-02-17 17:39:42 +0200 | [diff] [blame] | 1993 | .sync_hw = i9xx_power_well_sync_hw_noop, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 1994 | .enable = vlv_dpio_cmn_power_well_enable, |
| 1995 | .disable = vlv_dpio_cmn_power_well_disable, |
| 1996 | .is_enabled = vlv_power_well_enabled, |
| 1997 | }; |
| 1998 | |
| 1999 | static const struct i915_power_well_ops vlv_dpio_power_well_ops = { |
Imre Deak | 3c1b38e | 2017-02-17 17:39:42 +0200 | [diff] [blame] | 2000 | .sync_hw = i9xx_power_well_sync_hw_noop, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2001 | .enable = vlv_power_well_enable, |
| 2002 | .disable = vlv_power_well_disable, |
| 2003 | .is_enabled = vlv_power_well_enabled, |
| 2004 | }; |
| 2005 | |
| 2006 | static struct i915_power_well vlv_power_wells[] = { |
| 2007 | { |
| 2008 | .name = "always-on", |
| 2009 | .always_on = 1, |
Ville Syrjälä | 998bd66 | 2016-04-18 14:02:26 +0300 | [diff] [blame] | 2010 | .domains = POWER_DOMAIN_MASK, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2011 | .ops = &i9xx_always_on_power_well_ops, |
Imre Deak | 438b8dc | 2017-07-11 23:42:30 +0300 | [diff] [blame] | 2012 | .id = I915_DISP_PW_ALWAYS_ON, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2013 | }, |
| 2014 | { |
| 2015 | .name = "display", |
| 2016 | .domains = VLV_DISPLAY_POWER_DOMAINS, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2017 | .id = PUNIT_POWER_WELL_DISP2D, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2018 | .ops = &vlv_display_power_well_ops, |
| 2019 | }, |
| 2020 | { |
| 2021 | .name = "dpio-tx-b-01", |
| 2022 | .domains = VLV_DPIO_TX_B_LANES_01_POWER_DOMAINS | |
| 2023 | VLV_DPIO_TX_B_LANES_23_POWER_DOMAINS | |
| 2024 | VLV_DPIO_TX_C_LANES_01_POWER_DOMAINS | |
| 2025 | VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS, |
| 2026 | .ops = &vlv_dpio_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2027 | .id = PUNIT_POWER_WELL_DPIO_TX_B_LANES_01, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2028 | }, |
| 2029 | { |
| 2030 | .name = "dpio-tx-b-23", |
| 2031 | .domains = VLV_DPIO_TX_B_LANES_01_POWER_DOMAINS | |
| 2032 | VLV_DPIO_TX_B_LANES_23_POWER_DOMAINS | |
| 2033 | VLV_DPIO_TX_C_LANES_01_POWER_DOMAINS | |
| 2034 | VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS, |
| 2035 | .ops = &vlv_dpio_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2036 | .id = PUNIT_POWER_WELL_DPIO_TX_B_LANES_23, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2037 | }, |
| 2038 | { |
| 2039 | .name = "dpio-tx-c-01", |
| 2040 | .domains = VLV_DPIO_TX_B_LANES_01_POWER_DOMAINS | |
| 2041 | VLV_DPIO_TX_B_LANES_23_POWER_DOMAINS | |
| 2042 | VLV_DPIO_TX_C_LANES_01_POWER_DOMAINS | |
| 2043 | VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS, |
| 2044 | .ops = &vlv_dpio_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2045 | .id = PUNIT_POWER_WELL_DPIO_TX_C_LANES_01, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2046 | }, |
| 2047 | { |
| 2048 | .name = "dpio-tx-c-23", |
| 2049 | .domains = VLV_DPIO_TX_B_LANES_01_POWER_DOMAINS | |
| 2050 | VLV_DPIO_TX_B_LANES_23_POWER_DOMAINS | |
| 2051 | VLV_DPIO_TX_C_LANES_01_POWER_DOMAINS | |
| 2052 | VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS, |
| 2053 | .ops = &vlv_dpio_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2054 | .id = PUNIT_POWER_WELL_DPIO_TX_C_LANES_23, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2055 | }, |
| 2056 | { |
| 2057 | .name = "dpio-common", |
| 2058 | .domains = VLV_DPIO_CMN_BC_POWER_DOMAINS, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2059 | .id = PUNIT_POWER_WELL_DPIO_CMN_BC, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2060 | .ops = &vlv_dpio_cmn_power_well_ops, |
| 2061 | }, |
| 2062 | }; |
| 2063 | |
| 2064 | static struct i915_power_well chv_power_wells[] = { |
| 2065 | { |
| 2066 | .name = "always-on", |
| 2067 | .always_on = 1, |
Ville Syrjälä | 998bd66 | 2016-04-18 14:02:26 +0300 | [diff] [blame] | 2068 | .domains = POWER_DOMAIN_MASK, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2069 | .ops = &i9xx_always_on_power_well_ops, |
Imre Deak | 029d80d | 2017-07-06 17:40:25 +0300 | [diff] [blame] | 2070 | .id = I915_DISP_PW_ALWAYS_ON, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2071 | }, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2072 | { |
| 2073 | .name = "display", |
Ville Syrjälä | baa4e57 | 2014-10-27 16:07:32 +0200 | [diff] [blame] | 2074 | /* |
Ville Syrjälä | fde61e4 | 2015-05-26 20:22:39 +0300 | [diff] [blame] | 2075 | * Pipe A power well is the new disp2d well. Pipe B and C |
| 2076 | * power wells don't actually exist. Pipe A power well is |
| 2077 | * required for any pipe to work. |
Ville Syrjälä | baa4e57 | 2014-10-27 16:07:32 +0200 | [diff] [blame] | 2078 | */ |
Ville Syrjälä | 465ac0c | 2016-04-18 14:02:27 +0300 | [diff] [blame] | 2079 | .domains = CHV_DISPLAY_POWER_DOMAINS, |
Imre Deak | f49193c | 2017-07-06 17:40:23 +0300 | [diff] [blame] | 2080 | .id = CHV_DISP_PW_PIPE_A, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2081 | .ops = &chv_pipe_power_well_ops, |
| 2082 | }, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2083 | { |
| 2084 | .name = "dpio-common-bc", |
Ville Syrjälä | 71849b6 | 2015-04-10 18:21:29 +0300 | [diff] [blame] | 2085 | .domains = CHV_DPIO_CMN_BC_POWER_DOMAINS, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2086 | .id = PUNIT_POWER_WELL_DPIO_CMN_BC, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2087 | .ops = &chv_dpio_cmn_power_well_ops, |
| 2088 | }, |
| 2089 | { |
| 2090 | .name = "dpio-common-d", |
Ville Syrjälä | 71849b6 | 2015-04-10 18:21:29 +0300 | [diff] [blame] | 2091 | .domains = CHV_DPIO_CMN_D_POWER_DOMAINS, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2092 | .id = PUNIT_POWER_WELL_DPIO_CMN_D, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2093 | .ops = &chv_dpio_cmn_power_well_ops, |
| 2094 | }, |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2095 | }; |
| 2096 | |
Suketu Shah | 5aefb23 | 2015-04-16 14:22:10 +0530 | [diff] [blame] | 2097 | bool intel_display_power_well_is_enabled(struct drm_i915_private *dev_priv, |
Imre Deak | 438b8dc | 2017-07-11 23:42:30 +0300 | [diff] [blame] | 2098 | enum i915_power_well_id power_well_id) |
Suketu Shah | 5aefb23 | 2015-04-16 14:22:10 +0530 | [diff] [blame] | 2099 | { |
| 2100 | struct i915_power_well *power_well; |
| 2101 | bool ret; |
| 2102 | |
| 2103 | power_well = lookup_power_well(dev_priv, power_well_id); |
| 2104 | ret = power_well->ops->is_enabled(dev_priv, power_well); |
| 2105 | |
| 2106 | return ret; |
| 2107 | } |
| 2108 | |
Satheeshakrishna M | 94dd513 | 2015-02-04 13:57:44 +0000 | [diff] [blame] | 2109 | static struct i915_power_well skl_power_wells[] = { |
| 2110 | { |
| 2111 | .name = "always-on", |
| 2112 | .always_on = 1, |
Ville Syrjälä | 998bd66 | 2016-04-18 14:02:26 +0300 | [diff] [blame] | 2113 | .domains = POWER_DOMAIN_MASK, |
Satheeshakrishna M | 94dd513 | 2015-02-04 13:57:44 +0000 | [diff] [blame] | 2114 | .ops = &i9xx_always_on_power_well_ops, |
Imre Deak | 438b8dc | 2017-07-11 23:42:30 +0300 | [diff] [blame] | 2115 | .id = I915_DISP_PW_ALWAYS_ON, |
Satheeshakrishna M | 94dd513 | 2015-02-04 13:57:44 +0000 | [diff] [blame] | 2116 | }, |
| 2117 | { |
| 2118 | .name = "power well 1", |
Imre Deak | 4a76f29 | 2015-11-04 19:24:15 +0200 | [diff] [blame] | 2119 | /* Handled by the DMC firmware */ |
| 2120 | .domains = 0, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2121 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2122 | .id = SKL_DISP_PW_1, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 2123 | { |
| 2124 | .hsw.has_fuses = true, |
| 2125 | }, |
Satheeshakrishna M | 94dd513 | 2015-02-04 13:57:44 +0000 | [diff] [blame] | 2126 | }, |
| 2127 | { |
| 2128 | .name = "MISC IO power well", |
Imre Deak | 4a76f29 | 2015-11-04 19:24:15 +0200 | [diff] [blame] | 2129 | /* Handled by the DMC firmware */ |
| 2130 | .domains = 0, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2131 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2132 | .id = SKL_DISP_PW_MISC_IO, |
Satheeshakrishna M | 94dd513 | 2015-02-04 13:57:44 +0000 | [diff] [blame] | 2133 | }, |
| 2134 | { |
Patrik Jakobsson | 9f836f9 | 2015-11-16 16:20:01 +0100 | [diff] [blame] | 2135 | .name = "DC off", |
| 2136 | .domains = SKL_DISPLAY_DC_OFF_POWER_DOMAINS, |
| 2137 | .ops = &gen9_dc_off_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2138 | .id = SKL_DISP_PW_DC_OFF, |
Patrik Jakobsson | 9f836f9 | 2015-11-16 16:20:01 +0100 | [diff] [blame] | 2139 | }, |
| 2140 | { |
Satheeshakrishna M | 94dd513 | 2015-02-04 13:57:44 +0000 | [diff] [blame] | 2141 | .name = "power well 2", |
| 2142 | .domains = SKL_DISPLAY_POWERWELL_2_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2143 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2144 | .id = SKL_DISP_PW_2, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 2145 | { |
| 2146 | .hsw.irq_pipe_mask = BIT(PIPE_B) | BIT(PIPE_C), |
| 2147 | .hsw.has_vga = true, |
| 2148 | .hsw.has_fuses = true, |
| 2149 | }, |
Satheeshakrishna M | 94dd513 | 2015-02-04 13:57:44 +0000 | [diff] [blame] | 2150 | }, |
| 2151 | { |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 2152 | .name = "DDI A/E IO power well", |
| 2153 | .domains = SKL_DISPLAY_DDI_IO_A_E_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2154 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2155 | .id = SKL_DISP_PW_DDI_A_E, |
Satheeshakrishna M | 94dd513 | 2015-02-04 13:57:44 +0000 | [diff] [blame] | 2156 | }, |
| 2157 | { |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 2158 | .name = "DDI B IO power well", |
| 2159 | .domains = SKL_DISPLAY_DDI_IO_B_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2160 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2161 | .id = SKL_DISP_PW_DDI_B, |
Satheeshakrishna M | 94dd513 | 2015-02-04 13:57:44 +0000 | [diff] [blame] | 2162 | }, |
| 2163 | { |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 2164 | .name = "DDI C IO power well", |
| 2165 | .domains = SKL_DISPLAY_DDI_IO_C_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2166 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2167 | .id = SKL_DISP_PW_DDI_C, |
Satheeshakrishna M | 94dd513 | 2015-02-04 13:57:44 +0000 | [diff] [blame] | 2168 | }, |
| 2169 | { |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 2170 | .name = "DDI D IO power well", |
| 2171 | .domains = SKL_DISPLAY_DDI_IO_D_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2172 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2173 | .id = SKL_DISP_PW_DDI_D, |
Satheeshakrishna M | 94dd513 | 2015-02-04 13:57:44 +0000 | [diff] [blame] | 2174 | }, |
| 2175 | }; |
| 2176 | |
Satheeshakrishna M | 0b4a2a3 | 2014-07-11 14:51:13 +0530 | [diff] [blame] | 2177 | static struct i915_power_well bxt_power_wells[] = { |
| 2178 | { |
| 2179 | .name = "always-on", |
| 2180 | .always_on = 1, |
Ville Syrjälä | 998bd66 | 2016-04-18 14:02:26 +0300 | [diff] [blame] | 2181 | .domains = POWER_DOMAIN_MASK, |
Satheeshakrishna M | 0b4a2a3 | 2014-07-11 14:51:13 +0530 | [diff] [blame] | 2182 | .ops = &i9xx_always_on_power_well_ops, |
Imre Deak | 029d80d | 2017-07-06 17:40:25 +0300 | [diff] [blame] | 2183 | .id = I915_DISP_PW_ALWAYS_ON, |
Satheeshakrishna M | 0b4a2a3 | 2014-07-11 14:51:13 +0530 | [diff] [blame] | 2184 | }, |
| 2185 | { |
| 2186 | .name = "power well 1", |
Imre Deak | d7d7c9e | 2016-04-01 16:02:42 +0300 | [diff] [blame] | 2187 | .domains = 0, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2188 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2189 | .id = SKL_DISP_PW_1, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 2190 | { |
| 2191 | .hsw.has_fuses = true, |
| 2192 | }, |
Satheeshakrishna M | 0b4a2a3 | 2014-07-11 14:51:13 +0530 | [diff] [blame] | 2193 | }, |
| 2194 | { |
Patrik Jakobsson | 9f836f9 | 2015-11-16 16:20:01 +0100 | [diff] [blame] | 2195 | .name = "DC off", |
| 2196 | .domains = BXT_DISPLAY_DC_OFF_POWER_DOMAINS, |
| 2197 | .ops = &gen9_dc_off_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2198 | .id = SKL_DISP_PW_DC_OFF, |
Patrik Jakobsson | 9f836f9 | 2015-11-16 16:20:01 +0100 | [diff] [blame] | 2199 | }, |
| 2200 | { |
Satheeshakrishna M | 0b4a2a3 | 2014-07-11 14:51:13 +0530 | [diff] [blame] | 2201 | .name = "power well 2", |
| 2202 | .domains = BXT_DISPLAY_POWERWELL_2_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2203 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2204 | .id = SKL_DISP_PW_2, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 2205 | { |
| 2206 | .hsw.irq_pipe_mask = BIT(PIPE_B) | BIT(PIPE_C), |
| 2207 | .hsw.has_vga = true, |
| 2208 | .hsw.has_fuses = true, |
| 2209 | }, |
Patrik Jakobsson | 9f836f9 | 2015-11-16 16:20:01 +0100 | [diff] [blame] | 2210 | }, |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 2211 | { |
| 2212 | .name = "dpio-common-a", |
| 2213 | .domains = BXT_DPIO_CMN_A_POWER_DOMAINS, |
| 2214 | .ops = &bxt_dpio_cmn_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2215 | .id = BXT_DPIO_CMN_A, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 2216 | { |
| 2217 | .bxt.phy = DPIO_PHY1, |
| 2218 | }, |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 2219 | }, |
| 2220 | { |
| 2221 | .name = "dpio-common-bc", |
| 2222 | .domains = BXT_DPIO_CMN_BC_POWER_DOMAINS, |
| 2223 | .ops = &bxt_dpio_cmn_power_well_ops, |
Ander Conselvan de Oliveira | 01c3faa | 2016-10-06 19:22:14 +0300 | [diff] [blame] | 2224 | .id = BXT_DPIO_CMN_BC, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 2225 | { |
| 2226 | .bxt.phy = DPIO_PHY0, |
| 2227 | }, |
Imre Deak | 9c8d0b8 | 2016-06-13 16:44:34 +0300 | [diff] [blame] | 2228 | }, |
Satheeshakrishna M | 0b4a2a3 | 2014-07-11 14:51:13 +0530 | [diff] [blame] | 2229 | }; |
| 2230 | |
Ander Conselvan de Oliveira | 0d03926 | 2016-12-02 10:23:50 +0200 | [diff] [blame] | 2231 | static struct i915_power_well glk_power_wells[] = { |
| 2232 | { |
| 2233 | .name = "always-on", |
| 2234 | .always_on = 1, |
| 2235 | .domains = POWER_DOMAIN_MASK, |
| 2236 | .ops = &i9xx_always_on_power_well_ops, |
Imre Deak | 029d80d | 2017-07-06 17:40:25 +0300 | [diff] [blame] | 2237 | .id = I915_DISP_PW_ALWAYS_ON, |
Ander Conselvan de Oliveira | 0d03926 | 2016-12-02 10:23:50 +0200 | [diff] [blame] | 2238 | }, |
| 2239 | { |
| 2240 | .name = "power well 1", |
| 2241 | /* Handled by the DMC firmware */ |
| 2242 | .domains = 0, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2243 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 0d03926 | 2016-12-02 10:23:50 +0200 | [diff] [blame] | 2244 | .id = SKL_DISP_PW_1, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 2245 | { |
| 2246 | .hsw.has_fuses = true, |
| 2247 | }, |
Ander Conselvan de Oliveira | 0d03926 | 2016-12-02 10:23:50 +0200 | [diff] [blame] | 2248 | }, |
| 2249 | { |
| 2250 | .name = "DC off", |
| 2251 | .domains = GLK_DISPLAY_DC_OFF_POWER_DOMAINS, |
| 2252 | .ops = &gen9_dc_off_power_well_ops, |
| 2253 | .id = SKL_DISP_PW_DC_OFF, |
| 2254 | }, |
| 2255 | { |
| 2256 | .name = "power well 2", |
| 2257 | .domains = GLK_DISPLAY_POWERWELL_2_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2258 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 0d03926 | 2016-12-02 10:23:50 +0200 | [diff] [blame] | 2259 | .id = SKL_DISP_PW_2, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 2260 | { |
| 2261 | .hsw.irq_pipe_mask = BIT(PIPE_B) | BIT(PIPE_C), |
| 2262 | .hsw.has_vga = true, |
| 2263 | .hsw.has_fuses = true, |
| 2264 | }, |
Ander Conselvan de Oliveira | 0d03926 | 2016-12-02 10:23:50 +0200 | [diff] [blame] | 2265 | }, |
| 2266 | { |
Ander Conselvan de Oliveira | 0a116ce | 2016-12-02 10:23:51 +0200 | [diff] [blame] | 2267 | .name = "dpio-common-a", |
| 2268 | .domains = GLK_DPIO_CMN_A_POWER_DOMAINS, |
| 2269 | .ops = &bxt_dpio_cmn_power_well_ops, |
| 2270 | .id = BXT_DPIO_CMN_A, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 2271 | { |
| 2272 | .bxt.phy = DPIO_PHY1, |
| 2273 | }, |
Ander Conselvan de Oliveira | 0a116ce | 2016-12-02 10:23:51 +0200 | [diff] [blame] | 2274 | }, |
| 2275 | { |
| 2276 | .name = "dpio-common-b", |
| 2277 | .domains = GLK_DPIO_CMN_B_POWER_DOMAINS, |
| 2278 | .ops = &bxt_dpio_cmn_power_well_ops, |
| 2279 | .id = BXT_DPIO_CMN_BC, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 2280 | { |
| 2281 | .bxt.phy = DPIO_PHY0, |
| 2282 | }, |
Ander Conselvan de Oliveira | 0a116ce | 2016-12-02 10:23:51 +0200 | [diff] [blame] | 2283 | }, |
| 2284 | { |
| 2285 | .name = "dpio-common-c", |
| 2286 | .domains = GLK_DPIO_CMN_C_POWER_DOMAINS, |
| 2287 | .ops = &bxt_dpio_cmn_power_well_ops, |
| 2288 | .id = GLK_DPIO_CMN_C, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 2289 | { |
| 2290 | .bxt.phy = DPIO_PHY2, |
| 2291 | }, |
Ander Conselvan de Oliveira | 0a116ce | 2016-12-02 10:23:51 +0200 | [diff] [blame] | 2292 | }, |
| 2293 | { |
Ander Conselvan de Oliveira | 0d03926 | 2016-12-02 10:23:50 +0200 | [diff] [blame] | 2294 | .name = "AUX A", |
| 2295 | .domains = GLK_DISPLAY_AUX_A_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2296 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 0d03926 | 2016-12-02 10:23:50 +0200 | [diff] [blame] | 2297 | .id = GLK_DISP_PW_AUX_A, |
| 2298 | }, |
| 2299 | { |
| 2300 | .name = "AUX B", |
| 2301 | .domains = GLK_DISPLAY_AUX_B_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2302 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 0d03926 | 2016-12-02 10:23:50 +0200 | [diff] [blame] | 2303 | .id = GLK_DISP_PW_AUX_B, |
| 2304 | }, |
| 2305 | { |
| 2306 | .name = "AUX C", |
| 2307 | .domains = GLK_DISPLAY_AUX_C_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2308 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 0d03926 | 2016-12-02 10:23:50 +0200 | [diff] [blame] | 2309 | .id = GLK_DISP_PW_AUX_C, |
| 2310 | }, |
| 2311 | { |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 2312 | .name = "DDI A IO power well", |
| 2313 | .domains = GLK_DISPLAY_DDI_IO_A_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2314 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 0d03926 | 2016-12-02 10:23:50 +0200 | [diff] [blame] | 2315 | .id = GLK_DISP_PW_DDI_A, |
| 2316 | }, |
| 2317 | { |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 2318 | .name = "DDI B IO power well", |
| 2319 | .domains = GLK_DISPLAY_DDI_IO_B_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2320 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 0d03926 | 2016-12-02 10:23:50 +0200 | [diff] [blame] | 2321 | .id = SKL_DISP_PW_DDI_B, |
| 2322 | }, |
| 2323 | { |
Ander Conselvan de Oliveira | 62b6956 | 2017-02-24 16:19:59 +0200 | [diff] [blame] | 2324 | .name = "DDI C IO power well", |
| 2325 | .domains = GLK_DISPLAY_DDI_IO_C_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2326 | .ops = &hsw_power_well_ops, |
Ander Conselvan de Oliveira | 0d03926 | 2016-12-02 10:23:50 +0200 | [diff] [blame] | 2327 | .id = SKL_DISP_PW_DDI_C, |
| 2328 | }, |
| 2329 | }; |
| 2330 | |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2331 | static struct i915_power_well cnl_power_wells[] = { |
| 2332 | { |
| 2333 | .name = "always-on", |
| 2334 | .always_on = 1, |
| 2335 | .domains = POWER_DOMAIN_MASK, |
| 2336 | .ops = &i9xx_always_on_power_well_ops, |
Imre Deak | 029d80d | 2017-07-06 17:40:25 +0300 | [diff] [blame] | 2337 | .id = I915_DISP_PW_ALWAYS_ON, |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2338 | }, |
| 2339 | { |
| 2340 | .name = "power well 1", |
| 2341 | /* Handled by the DMC firmware */ |
| 2342 | .domains = 0, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2343 | .ops = &hsw_power_well_ops, |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2344 | .id = SKL_DISP_PW_1, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 2345 | { |
| 2346 | .hsw.has_fuses = true, |
| 2347 | }, |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2348 | }, |
| 2349 | { |
| 2350 | .name = "AUX A", |
| 2351 | .domains = CNL_DISPLAY_AUX_A_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2352 | .ops = &hsw_power_well_ops, |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2353 | .id = CNL_DISP_PW_AUX_A, |
| 2354 | }, |
| 2355 | { |
| 2356 | .name = "AUX B", |
| 2357 | .domains = CNL_DISPLAY_AUX_B_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2358 | .ops = &hsw_power_well_ops, |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2359 | .id = CNL_DISP_PW_AUX_B, |
| 2360 | }, |
| 2361 | { |
| 2362 | .name = "AUX C", |
| 2363 | .domains = CNL_DISPLAY_AUX_C_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2364 | .ops = &hsw_power_well_ops, |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2365 | .id = CNL_DISP_PW_AUX_C, |
| 2366 | }, |
| 2367 | { |
| 2368 | .name = "AUX D", |
| 2369 | .domains = CNL_DISPLAY_AUX_D_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2370 | .ops = &hsw_power_well_ops, |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2371 | .id = CNL_DISP_PW_AUX_D, |
| 2372 | }, |
| 2373 | { |
| 2374 | .name = "DC off", |
| 2375 | .domains = CNL_DISPLAY_DC_OFF_POWER_DOMAINS, |
| 2376 | .ops = &gen9_dc_off_power_well_ops, |
| 2377 | .id = SKL_DISP_PW_DC_OFF, |
| 2378 | }, |
| 2379 | { |
| 2380 | .name = "power well 2", |
| 2381 | .domains = CNL_DISPLAY_POWERWELL_2_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2382 | .ops = &hsw_power_well_ops, |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2383 | .id = SKL_DISP_PW_2, |
Imre Deak | 0a44594 | 2017-08-14 18:15:29 +0300 | [diff] [blame] | 2384 | { |
| 2385 | .hsw.irq_pipe_mask = BIT(PIPE_B) | BIT(PIPE_C), |
| 2386 | .hsw.has_vga = true, |
| 2387 | .hsw.has_fuses = true, |
| 2388 | }, |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2389 | }, |
| 2390 | { |
| 2391 | .name = "DDI A IO power well", |
| 2392 | .domains = CNL_DISPLAY_DDI_A_IO_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2393 | .ops = &hsw_power_well_ops, |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2394 | .id = CNL_DISP_PW_DDI_A, |
| 2395 | }, |
| 2396 | { |
| 2397 | .name = "DDI B IO power well", |
| 2398 | .domains = CNL_DISPLAY_DDI_B_IO_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2399 | .ops = &hsw_power_well_ops, |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2400 | .id = SKL_DISP_PW_DDI_B, |
| 2401 | }, |
| 2402 | { |
| 2403 | .name = "DDI C IO power well", |
| 2404 | .domains = CNL_DISPLAY_DDI_C_IO_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2405 | .ops = &hsw_power_well_ops, |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2406 | .id = SKL_DISP_PW_DDI_C, |
| 2407 | }, |
| 2408 | { |
| 2409 | .name = "DDI D IO power well", |
| 2410 | .domains = CNL_DISPLAY_DDI_D_IO_POWER_DOMAINS, |
Imre Deak | 4196b91 | 2017-07-11 23:42:36 +0300 | [diff] [blame] | 2411 | .ops = &hsw_power_well_ops, |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2412 | .id = SKL_DISP_PW_DDI_D, |
| 2413 | }, |
Rodrigo Vivi | a324fca | 2018-01-29 15:22:15 -0800 | [diff] [blame^] | 2414 | { |
| 2415 | .name = "AUX F", |
| 2416 | .domains = CNL_DISPLAY_AUX_F_POWER_DOMAINS, |
| 2417 | .ops = &hsw_power_well_ops, |
| 2418 | .id = CNL_DISP_PW_AUX_F, |
| 2419 | }, |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2420 | }; |
| 2421 | |
Imre Deak | 1b0e3a0 | 2015-11-05 23:04:11 +0200 | [diff] [blame] | 2422 | static int |
| 2423 | sanitize_disable_power_well_option(const struct drm_i915_private *dev_priv, |
| 2424 | int disable_power_well) |
| 2425 | { |
| 2426 | if (disable_power_well >= 0) |
| 2427 | return !!disable_power_well; |
| 2428 | |
Imre Deak | 1b0e3a0 | 2015-11-05 23:04:11 +0200 | [diff] [blame] | 2429 | return 1; |
| 2430 | } |
| 2431 | |
Imre Deak | a37baf3 | 2016-02-29 22:49:03 +0200 | [diff] [blame] | 2432 | static uint32_t get_allowed_dc_mask(const struct drm_i915_private *dev_priv, |
| 2433 | int enable_dc) |
| 2434 | { |
| 2435 | uint32_t mask; |
| 2436 | int requested_dc; |
| 2437 | int max_dc; |
| 2438 | |
Rodrigo Vivi | 6d6a897 | 2017-07-06 13:45:08 -0700 | [diff] [blame] | 2439 | if (IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv)) { |
Imre Deak | a37baf3 | 2016-02-29 22:49:03 +0200 | [diff] [blame] | 2440 | max_dc = 2; |
| 2441 | mask = 0; |
Ander Conselvan de Oliveira | cc3f90f | 2016-12-02 10:23:49 +0200 | [diff] [blame] | 2442 | } else if (IS_GEN9_LP(dev_priv)) { |
Imre Deak | a37baf3 | 2016-02-29 22:49:03 +0200 | [diff] [blame] | 2443 | max_dc = 1; |
| 2444 | /* |
| 2445 | * DC9 has a separate HW flow from the rest of the DC states, |
| 2446 | * not depending on the DMC firmware. It's needed by system |
| 2447 | * suspend/resume, so allow it unconditionally. |
| 2448 | */ |
| 2449 | mask = DC_STATE_EN_DC9; |
| 2450 | } else { |
| 2451 | max_dc = 0; |
| 2452 | mask = 0; |
| 2453 | } |
| 2454 | |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 2455 | if (!i915_modparams.disable_power_well) |
Imre Deak | 66e2c4c | 2016-02-29 22:49:04 +0200 | [diff] [blame] | 2456 | max_dc = 0; |
| 2457 | |
Imre Deak | a37baf3 | 2016-02-29 22:49:03 +0200 | [diff] [blame] | 2458 | if (enable_dc >= 0 && enable_dc <= max_dc) { |
| 2459 | requested_dc = enable_dc; |
| 2460 | } else if (enable_dc == -1) { |
| 2461 | requested_dc = max_dc; |
| 2462 | } else if (enable_dc > max_dc && enable_dc <= 2) { |
| 2463 | DRM_DEBUG_KMS("Adjusting requested max DC state (%d->%d)\n", |
| 2464 | enable_dc, max_dc); |
| 2465 | requested_dc = max_dc; |
| 2466 | } else { |
| 2467 | DRM_ERROR("Unexpected value for enable_dc (%d)\n", enable_dc); |
| 2468 | requested_dc = max_dc; |
| 2469 | } |
| 2470 | |
| 2471 | if (requested_dc > 1) |
| 2472 | mask |= DC_STATE_EN_UPTO_DC6; |
| 2473 | if (requested_dc > 0) |
| 2474 | mask |= DC_STATE_EN_UPTO_DC5; |
| 2475 | |
| 2476 | DRM_DEBUG_KMS("Allowed DC state mask %02x\n", mask); |
| 2477 | |
| 2478 | return mask; |
| 2479 | } |
| 2480 | |
Imre Deak | 21792c6 | 2017-07-11 23:42:33 +0300 | [diff] [blame] | 2481 | static void assert_power_well_ids_unique(struct drm_i915_private *dev_priv) |
| 2482 | { |
| 2483 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2484 | u64 power_well_ids; |
| 2485 | int i; |
| 2486 | |
| 2487 | power_well_ids = 0; |
| 2488 | for (i = 0; i < power_domains->power_well_count; i++) { |
| 2489 | enum i915_power_well_id id = power_domains->power_wells[i].id; |
| 2490 | |
| 2491 | WARN_ON(id >= sizeof(power_well_ids) * 8); |
| 2492 | WARN_ON(power_well_ids & BIT_ULL(id)); |
| 2493 | power_well_ids |= BIT_ULL(id); |
| 2494 | } |
| 2495 | } |
| 2496 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2497 | #define set_power_wells(power_domains, __power_wells) ({ \ |
| 2498 | (power_domains)->power_wells = (__power_wells); \ |
| 2499 | (power_domains)->power_well_count = ARRAY_SIZE(__power_wells); \ |
| 2500 | }) |
| 2501 | |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 2502 | /** |
| 2503 | * intel_power_domains_init - initializes the power domain structures |
| 2504 | * @dev_priv: i915 device instance |
| 2505 | * |
| 2506 | * Initializes the power domain structures for @dev_priv depending upon the |
| 2507 | * supported platform. |
| 2508 | */ |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2509 | int intel_power_domains_init(struct drm_i915_private *dev_priv) |
| 2510 | { |
| 2511 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2512 | |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 2513 | i915_modparams.disable_power_well = |
| 2514 | sanitize_disable_power_well_option(dev_priv, |
| 2515 | i915_modparams.disable_power_well); |
| 2516 | dev_priv->csr.allowed_dc_mask = |
| 2517 | get_allowed_dc_mask(dev_priv, i915_modparams.enable_dc); |
Imre Deak | 1b0e3a0 | 2015-11-05 23:04:11 +0200 | [diff] [blame] | 2518 | |
Ander Conselvan de Oliveira | d8fc70b | 2017-02-09 11:31:21 +0200 | [diff] [blame] | 2519 | BUILD_BUG_ON(POWER_DOMAIN_NUM > 64); |
Ville Syrjälä | f0ab43e | 2015-11-09 16:48:19 +0100 | [diff] [blame] | 2520 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2521 | mutex_init(&power_domains->lock); |
| 2522 | |
| 2523 | /* |
| 2524 | * The enabling order will be from lower to higher indexed wells, |
| 2525 | * the disabling order is reversed. |
| 2526 | */ |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2527 | if (IS_HASWELL(dev_priv)) { |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2528 | set_power_wells(power_domains, hsw_power_wells); |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2529 | } else if (IS_BROADWELL(dev_priv)) { |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2530 | set_power_wells(power_domains, bdw_power_wells); |
Rodrigo Vivi | b976dc5 | 2017-01-23 10:32:37 -0800 | [diff] [blame] | 2531 | } else if (IS_GEN9_BC(dev_priv)) { |
Satheeshakrishna M | 94dd513 | 2015-02-04 13:57:44 +0000 | [diff] [blame] | 2532 | set_power_wells(power_domains, skl_power_wells); |
Ville Syrjälä | 8bcd3dd | 2017-06-06 13:30:39 -0700 | [diff] [blame] | 2533 | } else if (IS_CANNONLAKE(dev_priv)) { |
| 2534 | set_power_wells(power_domains, cnl_power_wells); |
Rodrigo Vivi | a324fca | 2018-01-29 15:22:15 -0800 | [diff] [blame^] | 2535 | |
| 2536 | /* |
| 2537 | * Aux IO is getting enabled for all ports |
| 2538 | * regardless the presence or use. So, in order to avoid |
| 2539 | * timeouts, lets remove it from the list |
| 2540 | * for the SKUs without port F. |
| 2541 | */ |
| 2542 | if (!IS_CNL_WITH_PORT_F(dev_priv)) |
| 2543 | power_domains->power_well_count -= 1; |
| 2544 | |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2545 | } else if (IS_BROXTON(dev_priv)) { |
Satheeshakrishna M | 0b4a2a3 | 2014-07-11 14:51:13 +0530 | [diff] [blame] | 2546 | set_power_wells(power_domains, bxt_power_wells); |
Ander Conselvan de Oliveira | 0d03926 | 2016-12-02 10:23:50 +0200 | [diff] [blame] | 2547 | } else if (IS_GEMINILAKE(dev_priv)) { |
| 2548 | set_power_wells(power_domains, glk_power_wells); |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2549 | } else if (IS_CHERRYVIEW(dev_priv)) { |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2550 | set_power_wells(power_domains, chv_power_wells); |
Joonas Lahtinen | 2d1fe07 | 2016-04-07 11:08:05 +0300 | [diff] [blame] | 2551 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2552 | set_power_wells(power_domains, vlv_power_wells); |
Ville Syrjälä | 2ee0da1 | 2017-06-01 17:36:16 +0300 | [diff] [blame] | 2553 | } else if (IS_I830(dev_priv)) { |
| 2554 | set_power_wells(power_domains, i830_power_wells); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2555 | } else { |
| 2556 | set_power_wells(power_domains, i9xx_always_on_power_well); |
| 2557 | } |
| 2558 | |
Imre Deak | 21792c6 | 2017-07-11 23:42:33 +0300 | [diff] [blame] | 2559 | assert_power_well_ids_unique(dev_priv); |
| 2560 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2561 | return 0; |
| 2562 | } |
| 2563 | |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 2564 | /** |
| 2565 | * intel_power_domains_fini - finalizes the power domain structures |
| 2566 | * @dev_priv: i915 device instance |
| 2567 | * |
| 2568 | * Finalizes the power domain structures for @dev_priv depending upon the |
| 2569 | * supported platform. This function also disables runtime pm and ensures that |
| 2570 | * the device stays powered up so that the driver can be reloaded. |
| 2571 | */ |
Daniel Vetter | f458ebb | 2014-09-30 10:56:39 +0200 | [diff] [blame] | 2572 | void intel_power_domains_fini(struct drm_i915_private *dev_priv) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2573 | { |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 2574 | struct device *kdev = &dev_priv->drm.pdev->dev; |
Imre Deak | 25b181b | 2015-12-17 13:44:56 +0200 | [diff] [blame] | 2575 | |
Imre Deak | aabee1b | 2015-12-15 20:10:29 +0200 | [diff] [blame] | 2576 | /* |
| 2577 | * The i915.ko module is still not prepared to be loaded when |
Daniel Vetter | f458ebb | 2014-09-30 10:56:39 +0200 | [diff] [blame] | 2578 | * the power well is not enabled, so just enable it in case |
Imre Deak | aabee1b | 2015-12-15 20:10:29 +0200 | [diff] [blame] | 2579 | * we're going to unload/reload. |
| 2580 | * The following also reacquires the RPM reference the core passed |
| 2581 | * to the driver during loading, which is dropped in |
| 2582 | * intel_runtime_pm_enable(). We have to hand back the control of the |
| 2583 | * device to the core with this reference held. |
| 2584 | */ |
Daniel Vetter | f458ebb | 2014-09-30 10:56:39 +0200 | [diff] [blame] | 2585 | intel_display_set_init_power(dev_priv, true); |
Imre Deak | d314cd4 | 2015-11-17 17:44:23 +0200 | [diff] [blame] | 2586 | |
| 2587 | /* Remove the refcount we took to keep power well support disabled. */ |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 2588 | if (!i915_modparams.disable_power_well) |
Imre Deak | d314cd4 | 2015-11-17 17:44:23 +0200 | [diff] [blame] | 2589 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Imre Deak | 25b181b | 2015-12-17 13:44:56 +0200 | [diff] [blame] | 2590 | |
| 2591 | /* |
| 2592 | * Remove the refcount we took in intel_runtime_pm_enable() in case |
| 2593 | * the platform doesn't support runtime PM. |
| 2594 | */ |
| 2595 | if (!HAS_RUNTIME_PM(dev_priv)) |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 2596 | pm_runtime_put(kdev); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2597 | } |
| 2598 | |
Imre Deak | 30eade1 | 2015-11-04 19:24:13 +0200 | [diff] [blame] | 2599 | static void intel_power_domains_sync_hw(struct drm_i915_private *dev_priv) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2600 | { |
| 2601 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2602 | struct i915_power_well *power_well; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2603 | |
| 2604 | mutex_lock(&power_domains->lock); |
Imre Deak | 75ccb2e | 2017-02-17 17:39:43 +0200 | [diff] [blame] | 2605 | for_each_power_well(dev_priv, power_well) { |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2606 | power_well->ops->sync_hw(dev_priv, power_well); |
| 2607 | power_well->hw_enabled = power_well->ops->is_enabled(dev_priv, |
| 2608 | power_well); |
| 2609 | } |
| 2610 | mutex_unlock(&power_domains->lock); |
| 2611 | } |
| 2612 | |
Ville Syrjälä | 70c2c18 | 2016-05-13 23:41:30 +0300 | [diff] [blame] | 2613 | static void gen9_dbuf_enable(struct drm_i915_private *dev_priv) |
| 2614 | { |
| 2615 | I915_WRITE(DBUF_CTL, I915_READ(DBUF_CTL) | DBUF_POWER_REQUEST); |
| 2616 | POSTING_READ(DBUF_CTL); |
| 2617 | |
| 2618 | udelay(10); |
| 2619 | |
| 2620 | if (!(I915_READ(DBUF_CTL) & DBUF_POWER_STATE)) |
| 2621 | DRM_ERROR("DBuf power enable timeout\n"); |
| 2622 | } |
| 2623 | |
| 2624 | static void gen9_dbuf_disable(struct drm_i915_private *dev_priv) |
| 2625 | { |
| 2626 | I915_WRITE(DBUF_CTL, I915_READ(DBUF_CTL) & ~DBUF_POWER_REQUEST); |
| 2627 | POSTING_READ(DBUF_CTL); |
| 2628 | |
| 2629 | udelay(10); |
| 2630 | |
| 2631 | if (I915_READ(DBUF_CTL) & DBUF_POWER_STATE) |
| 2632 | DRM_ERROR("DBuf power disable timeout!\n"); |
| 2633 | } |
| 2634 | |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 2635 | static void skl_display_core_init(struct drm_i915_private *dev_priv, |
Imre Deak | 443a93a | 2016-04-04 15:42:57 +0300 | [diff] [blame] | 2636 | bool resume) |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 2637 | { |
| 2638 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
Imre Deak | 443a93a | 2016-04-04 15:42:57 +0300 | [diff] [blame] | 2639 | struct i915_power_well *well; |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 2640 | uint32_t val; |
| 2641 | |
Imre Deak | d26fa1d | 2015-11-04 19:24:17 +0200 | [diff] [blame] | 2642 | gen9_set_dc_state(dev_priv, DC_STATE_DISABLE); |
| 2643 | |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 2644 | /* enable PCH reset handshake */ |
| 2645 | val = I915_READ(HSW_NDE_RSTWRN_OPT); |
| 2646 | I915_WRITE(HSW_NDE_RSTWRN_OPT, val | RESET_PCH_HANDSHAKE_ENABLE); |
| 2647 | |
| 2648 | /* enable PG1 and Misc I/O */ |
| 2649 | mutex_lock(&power_domains->lock); |
Imre Deak | 443a93a | 2016-04-04 15:42:57 +0300 | [diff] [blame] | 2650 | |
| 2651 | well = lookup_power_well(dev_priv, SKL_DISP_PW_1); |
| 2652 | intel_power_well_enable(dev_priv, well); |
| 2653 | |
| 2654 | well = lookup_power_well(dev_priv, SKL_DISP_PW_MISC_IO); |
| 2655 | intel_power_well_enable(dev_priv, well); |
| 2656 | |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 2657 | mutex_unlock(&power_domains->lock); |
| 2658 | |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 2659 | skl_init_cdclk(dev_priv); |
| 2660 | |
Ville Syrjälä | 70c2c18 | 2016-05-13 23:41:30 +0300 | [diff] [blame] | 2661 | gen9_dbuf_enable(dev_priv); |
| 2662 | |
Ville Syrjälä | 9f7eb31 | 2016-05-13 23:41:29 +0300 | [diff] [blame] | 2663 | if (resume && dev_priv->csr.dmc_payload) |
Imre Deak | 2abc525 | 2016-03-04 21:57:41 +0200 | [diff] [blame] | 2664 | intel_csr_load_program(dev_priv); |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 2665 | } |
| 2666 | |
| 2667 | static void skl_display_core_uninit(struct drm_i915_private *dev_priv) |
| 2668 | { |
| 2669 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
Imre Deak | 443a93a | 2016-04-04 15:42:57 +0300 | [diff] [blame] | 2670 | struct i915_power_well *well; |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 2671 | |
Imre Deak | d26fa1d | 2015-11-04 19:24:17 +0200 | [diff] [blame] | 2672 | gen9_set_dc_state(dev_priv, DC_STATE_DISABLE); |
| 2673 | |
Ville Syrjälä | 70c2c18 | 2016-05-13 23:41:30 +0300 | [diff] [blame] | 2674 | gen9_dbuf_disable(dev_priv); |
| 2675 | |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 2676 | skl_uninit_cdclk(dev_priv); |
| 2677 | |
| 2678 | /* The spec doesn't call for removing the reset handshake flag */ |
| 2679 | /* disable PG1 and Misc I/O */ |
Imre Deak | 443a93a | 2016-04-04 15:42:57 +0300 | [diff] [blame] | 2680 | |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 2681 | mutex_lock(&power_domains->lock); |
Imre Deak | 443a93a | 2016-04-04 15:42:57 +0300 | [diff] [blame] | 2682 | |
Imre Deak | edfda8e | 2017-06-29 18:36:59 +0300 | [diff] [blame] | 2683 | /* |
| 2684 | * BSpec says to keep the MISC IO power well enabled here, only |
| 2685 | * remove our request for power well 1. |
Imre Deak | 42d9366 | 2017-06-29 18:37:01 +0300 | [diff] [blame] | 2686 | * Note that even though the driver's request is removed power well 1 |
| 2687 | * may stay enabled after this due to DMC's own request on it. |
Imre Deak | edfda8e | 2017-06-29 18:36:59 +0300 | [diff] [blame] | 2688 | */ |
Imre Deak | 443a93a | 2016-04-04 15:42:57 +0300 | [diff] [blame] | 2689 | well = lookup_power_well(dev_priv, SKL_DISP_PW_1); |
| 2690 | intel_power_well_disable(dev_priv, well); |
| 2691 | |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 2692 | mutex_unlock(&power_domains->lock); |
Imre Deak | 846c6b2 | 2017-06-29 18:36:58 +0300 | [diff] [blame] | 2693 | |
| 2694 | usleep_range(10, 30); /* 10 us delay per Bspec */ |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 2695 | } |
| 2696 | |
Imre Deak | d7d7c9e | 2016-04-01 16:02:42 +0300 | [diff] [blame] | 2697 | void bxt_display_core_init(struct drm_i915_private *dev_priv, |
| 2698 | bool resume) |
| 2699 | { |
| 2700 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2701 | struct i915_power_well *well; |
| 2702 | uint32_t val; |
| 2703 | |
| 2704 | gen9_set_dc_state(dev_priv, DC_STATE_DISABLE); |
| 2705 | |
| 2706 | /* |
| 2707 | * NDE_RSTWRN_OPT RST PCH Handshake En must always be 0b on BXT |
| 2708 | * or else the reset will hang because there is no PCH to respond. |
| 2709 | * Move the handshake programming to initialization sequence. |
| 2710 | * Previously was left up to BIOS. |
| 2711 | */ |
| 2712 | val = I915_READ(HSW_NDE_RSTWRN_OPT); |
| 2713 | val &= ~RESET_PCH_HANDSHAKE_ENABLE; |
| 2714 | I915_WRITE(HSW_NDE_RSTWRN_OPT, val); |
| 2715 | |
| 2716 | /* Enable PG1 */ |
| 2717 | mutex_lock(&power_domains->lock); |
| 2718 | |
| 2719 | well = lookup_power_well(dev_priv, SKL_DISP_PW_1); |
| 2720 | intel_power_well_enable(dev_priv, well); |
| 2721 | |
| 2722 | mutex_unlock(&power_domains->lock); |
| 2723 | |
Imre Deak | 324513c | 2016-06-13 16:44:36 +0300 | [diff] [blame] | 2724 | bxt_init_cdclk(dev_priv); |
Ville Syrjälä | 70c2c18 | 2016-05-13 23:41:30 +0300 | [diff] [blame] | 2725 | |
| 2726 | gen9_dbuf_enable(dev_priv); |
| 2727 | |
Imre Deak | d7d7c9e | 2016-04-01 16:02:42 +0300 | [diff] [blame] | 2728 | if (resume && dev_priv->csr.dmc_payload) |
| 2729 | intel_csr_load_program(dev_priv); |
| 2730 | } |
| 2731 | |
| 2732 | void bxt_display_core_uninit(struct drm_i915_private *dev_priv) |
| 2733 | { |
| 2734 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2735 | struct i915_power_well *well; |
| 2736 | |
| 2737 | gen9_set_dc_state(dev_priv, DC_STATE_DISABLE); |
| 2738 | |
Ville Syrjälä | 70c2c18 | 2016-05-13 23:41:30 +0300 | [diff] [blame] | 2739 | gen9_dbuf_disable(dev_priv); |
| 2740 | |
Imre Deak | 324513c | 2016-06-13 16:44:36 +0300 | [diff] [blame] | 2741 | bxt_uninit_cdclk(dev_priv); |
Imre Deak | d7d7c9e | 2016-04-01 16:02:42 +0300 | [diff] [blame] | 2742 | |
| 2743 | /* The spec doesn't call for removing the reset handshake flag */ |
| 2744 | |
Imre Deak | 42d9366 | 2017-06-29 18:37:01 +0300 | [diff] [blame] | 2745 | /* |
| 2746 | * Disable PW1 (PG1). |
| 2747 | * Note that even though the driver's request is removed power well 1 |
| 2748 | * may stay enabled after this due to DMC's own request on it. |
| 2749 | */ |
Imre Deak | d7d7c9e | 2016-04-01 16:02:42 +0300 | [diff] [blame] | 2750 | mutex_lock(&power_domains->lock); |
| 2751 | |
| 2752 | well = lookup_power_well(dev_priv, SKL_DISP_PW_1); |
| 2753 | intel_power_well_disable(dev_priv, well); |
| 2754 | |
| 2755 | mutex_unlock(&power_domains->lock); |
Imre Deak | 846c6b2 | 2017-06-29 18:36:58 +0300 | [diff] [blame] | 2756 | |
| 2757 | usleep_range(10, 30); /* 10 us delay per Bspec */ |
Imre Deak | d7d7c9e | 2016-04-01 16:02:42 +0300 | [diff] [blame] | 2758 | } |
| 2759 | |
Paulo Zanoni | e0b8acf | 2017-08-21 17:03:55 -0700 | [diff] [blame] | 2760 | enum { |
| 2761 | PROCMON_0_85V_DOT_0, |
| 2762 | PROCMON_0_95V_DOT_0, |
| 2763 | PROCMON_0_95V_DOT_1, |
| 2764 | PROCMON_1_05V_DOT_0, |
| 2765 | PROCMON_1_05V_DOT_1, |
| 2766 | }; |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 2767 | |
| 2768 | static const struct cnl_procmon { |
| 2769 | u32 dw1, dw9, dw10; |
Paulo Zanoni | e0b8acf | 2017-08-21 17:03:55 -0700 | [diff] [blame] | 2770 | } cnl_procmon_values[] = { |
| 2771 | [PROCMON_0_85V_DOT_0] = |
| 2772 | { .dw1 = 0x00000000, .dw9 = 0x62AB67BB, .dw10 = 0x51914F96, }, |
| 2773 | [PROCMON_0_95V_DOT_0] = |
| 2774 | { .dw1 = 0x00000000, .dw9 = 0x86E172C7, .dw10 = 0x77CA5EAB, }, |
| 2775 | [PROCMON_0_95V_DOT_1] = |
| 2776 | { .dw1 = 0x00000000, .dw9 = 0x93F87FE1, .dw10 = 0x8AE871C5, }, |
| 2777 | [PROCMON_1_05V_DOT_0] = |
| 2778 | { .dw1 = 0x00000000, .dw9 = 0x98FA82DD, .dw10 = 0x89E46DC1, }, |
| 2779 | [PROCMON_1_05V_DOT_1] = |
| 2780 | { .dw1 = 0x00440000, .dw9 = 0x9A00AB25, .dw10 = 0x8AE38FF1, }, |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 2781 | }; |
| 2782 | |
Paulo Zanoni | ade5ee7 | 2017-08-21 17:03:56 -0700 | [diff] [blame] | 2783 | static void cnl_set_procmon_ref_values(struct drm_i915_private *dev_priv) |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 2784 | { |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 2785 | const struct cnl_procmon *procmon; |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 2786 | u32 val; |
| 2787 | |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 2788 | val = I915_READ(CNL_PORT_COMP_DW3); |
Paulo Zanoni | e0b8acf | 2017-08-21 17:03:55 -0700 | [diff] [blame] | 2789 | switch (val & (PROCESS_INFO_MASK | VOLTAGE_INFO_MASK)) { |
| 2790 | default: |
| 2791 | MISSING_CASE(val); |
| 2792 | case VOLTAGE_INFO_0_85V | PROCESS_INFO_DOT_0: |
| 2793 | procmon = &cnl_procmon_values[PROCMON_0_85V_DOT_0]; |
| 2794 | break; |
| 2795 | case VOLTAGE_INFO_0_95V | PROCESS_INFO_DOT_0: |
| 2796 | procmon = &cnl_procmon_values[PROCMON_0_95V_DOT_0]; |
| 2797 | break; |
| 2798 | case VOLTAGE_INFO_0_95V | PROCESS_INFO_DOT_1: |
| 2799 | procmon = &cnl_procmon_values[PROCMON_0_95V_DOT_1]; |
| 2800 | break; |
| 2801 | case VOLTAGE_INFO_1_05V | PROCESS_INFO_DOT_0: |
| 2802 | procmon = &cnl_procmon_values[PROCMON_1_05V_DOT_0]; |
| 2803 | break; |
| 2804 | case VOLTAGE_INFO_1_05V | PROCESS_INFO_DOT_1: |
| 2805 | procmon = &cnl_procmon_values[PROCMON_1_05V_DOT_1]; |
| 2806 | break; |
| 2807 | } |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 2808 | |
| 2809 | val = I915_READ(CNL_PORT_COMP_DW1); |
| 2810 | val &= ~((0xff << 16) | 0xff); |
| 2811 | val |= procmon->dw1; |
| 2812 | I915_WRITE(CNL_PORT_COMP_DW1, val); |
| 2813 | |
| 2814 | I915_WRITE(CNL_PORT_COMP_DW9, procmon->dw9); |
| 2815 | I915_WRITE(CNL_PORT_COMP_DW10, procmon->dw10); |
Paulo Zanoni | ade5ee7 | 2017-08-21 17:03:56 -0700 | [diff] [blame] | 2816 | } |
| 2817 | |
| 2818 | static void cnl_display_core_init(struct drm_i915_private *dev_priv, bool resume) |
| 2819 | { |
| 2820 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2821 | struct i915_power_well *well; |
| 2822 | u32 val; |
| 2823 | |
| 2824 | gen9_set_dc_state(dev_priv, DC_STATE_DISABLE); |
| 2825 | |
| 2826 | /* 1. Enable PCH Reset Handshake */ |
| 2827 | val = I915_READ(HSW_NDE_RSTWRN_OPT); |
| 2828 | val |= RESET_PCH_HANDSHAKE_ENABLE; |
| 2829 | I915_WRITE(HSW_NDE_RSTWRN_OPT, val); |
| 2830 | |
| 2831 | /* 2. Enable Comp */ |
| 2832 | val = I915_READ(CHICKEN_MISC_2); |
| 2833 | val &= ~CNL_COMP_PWR_DOWN; |
| 2834 | I915_WRITE(CHICKEN_MISC_2, val); |
| 2835 | |
| 2836 | cnl_set_procmon_ref_values(dev_priv); |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 2837 | |
| 2838 | val = I915_READ(CNL_PORT_COMP_DW0); |
| 2839 | val |= COMP_INIT; |
| 2840 | I915_WRITE(CNL_PORT_COMP_DW0, val); |
| 2841 | |
| 2842 | /* 3. */ |
| 2843 | val = I915_READ(CNL_PORT_CL1CM_DW5); |
| 2844 | val |= CL_POWER_DOWN_ENABLE; |
| 2845 | I915_WRITE(CNL_PORT_CL1CM_DW5, val); |
| 2846 | |
Imre Deak | b38131f | 2017-06-29 18:37:02 +0300 | [diff] [blame] | 2847 | /* |
| 2848 | * 4. Enable Power Well 1 (PG1). |
| 2849 | * The AUX IO power wells will be enabled on demand. |
| 2850 | */ |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 2851 | mutex_lock(&power_domains->lock); |
| 2852 | well = lookup_power_well(dev_priv, SKL_DISP_PW_1); |
| 2853 | intel_power_well_enable(dev_priv, well); |
| 2854 | mutex_unlock(&power_domains->lock); |
| 2855 | |
| 2856 | /* 5. Enable CD clock */ |
| 2857 | cnl_init_cdclk(dev_priv); |
| 2858 | |
| 2859 | /* 6. Enable DBUF */ |
| 2860 | gen9_dbuf_enable(dev_priv); |
Imre Deak | 57522c4 | 2017-10-03 12:51:58 +0300 | [diff] [blame] | 2861 | |
| 2862 | if (resume && dev_priv->csr.dmc_payload) |
| 2863 | intel_csr_load_program(dev_priv); |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 2864 | } |
| 2865 | |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 2866 | static void cnl_display_core_uninit(struct drm_i915_private *dev_priv) |
| 2867 | { |
| 2868 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 2869 | struct i915_power_well *well; |
| 2870 | u32 val; |
| 2871 | |
| 2872 | gen9_set_dc_state(dev_priv, DC_STATE_DISABLE); |
| 2873 | |
| 2874 | /* 1. Disable all display engine functions -> aready done */ |
| 2875 | |
| 2876 | /* 2. Disable DBUF */ |
| 2877 | gen9_dbuf_disable(dev_priv); |
| 2878 | |
| 2879 | /* 3. Disable CD clock */ |
| 2880 | cnl_uninit_cdclk(dev_priv); |
| 2881 | |
Imre Deak | b38131f | 2017-06-29 18:37:02 +0300 | [diff] [blame] | 2882 | /* |
| 2883 | * 4. Disable Power Well 1 (PG1). |
| 2884 | * The AUX IO power wells are toggled on demand, so they are already |
| 2885 | * disabled at this point. |
| 2886 | */ |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 2887 | mutex_lock(&power_domains->lock); |
| 2888 | well = lookup_power_well(dev_priv, SKL_DISP_PW_1); |
| 2889 | intel_power_well_disable(dev_priv, well); |
| 2890 | mutex_unlock(&power_domains->lock); |
| 2891 | |
Imre Deak | 846c6b2 | 2017-06-29 18:36:58 +0300 | [diff] [blame] | 2892 | usleep_range(10, 30); /* 10 us delay per Bspec */ |
| 2893 | |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 2894 | /* 5. Disable Comp */ |
| 2895 | val = I915_READ(CHICKEN_MISC_2); |
Paulo Zanoni | 746a517 | 2017-07-14 14:52:28 -0300 | [diff] [blame] | 2896 | val |= CNL_COMP_PWR_DOWN; |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 2897 | I915_WRITE(CHICKEN_MISC_2, val); |
| 2898 | } |
| 2899 | |
Ville Syrjälä | 7072246 | 2015-04-10 18:21:28 +0300 | [diff] [blame] | 2900 | static void chv_phy_control_init(struct drm_i915_private *dev_priv) |
| 2901 | { |
| 2902 | struct i915_power_well *cmn_bc = |
| 2903 | lookup_power_well(dev_priv, PUNIT_POWER_WELL_DPIO_CMN_BC); |
| 2904 | struct i915_power_well *cmn_d = |
| 2905 | lookup_power_well(dev_priv, PUNIT_POWER_WELL_DPIO_CMN_D); |
| 2906 | |
| 2907 | /* |
| 2908 | * DISPLAY_PHY_CONTROL can get corrupted if read. As a |
| 2909 | * workaround never ever read DISPLAY_PHY_CONTROL, and |
| 2910 | * instead maintain a shadow copy ourselves. Use the actual |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 2911 | * power well state and lane status to reconstruct the |
| 2912 | * expected initial value. |
Ville Syrjälä | 7072246 | 2015-04-10 18:21:28 +0300 | [diff] [blame] | 2913 | */ |
| 2914 | dev_priv->chv_phy_control = |
Ville Syrjälä | bc28454 | 2015-05-26 20:22:38 +0300 | [diff] [blame] | 2915 | PHY_LDO_SEQ_DELAY(PHY_LDO_DELAY_600NS, DPIO_PHY0) | |
| 2916 | PHY_LDO_SEQ_DELAY(PHY_LDO_DELAY_600NS, DPIO_PHY1) | |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 2917 | PHY_CH_POWER_MODE(PHY_CH_DEEP_PSR, DPIO_PHY0, DPIO_CH0) | |
| 2918 | PHY_CH_POWER_MODE(PHY_CH_DEEP_PSR, DPIO_PHY0, DPIO_CH1) | |
| 2919 | PHY_CH_POWER_MODE(PHY_CH_DEEP_PSR, DPIO_PHY1, DPIO_CH0); |
| 2920 | |
| 2921 | /* |
| 2922 | * If all lanes are disabled we leave the override disabled |
| 2923 | * with all power down bits cleared to match the state we |
| 2924 | * would use after disabling the port. Otherwise enable the |
| 2925 | * override and set the lane powerdown bits accding to the |
| 2926 | * current lane status. |
| 2927 | */ |
| 2928 | if (cmn_bc->ops->is_enabled(dev_priv, cmn_bc)) { |
| 2929 | uint32_t status = I915_READ(DPLL(PIPE_A)); |
| 2930 | unsigned int mask; |
| 2931 | |
| 2932 | mask = status & DPLL_PORTB_READY_MASK; |
| 2933 | if (mask == 0xf) |
| 2934 | mask = 0x0; |
| 2935 | else |
| 2936 | dev_priv->chv_phy_control |= |
| 2937 | PHY_CH_POWER_DOWN_OVRD_EN(DPIO_PHY0, DPIO_CH0); |
| 2938 | |
| 2939 | dev_priv->chv_phy_control |= |
| 2940 | PHY_CH_POWER_DOWN_OVRD(mask, DPIO_PHY0, DPIO_CH0); |
| 2941 | |
| 2942 | mask = (status & DPLL_PORTC_READY_MASK) >> 4; |
| 2943 | if (mask == 0xf) |
| 2944 | mask = 0x0; |
| 2945 | else |
| 2946 | dev_priv->chv_phy_control |= |
| 2947 | PHY_CH_POWER_DOWN_OVRD_EN(DPIO_PHY0, DPIO_CH1); |
| 2948 | |
| 2949 | dev_priv->chv_phy_control |= |
| 2950 | PHY_CH_POWER_DOWN_OVRD(mask, DPIO_PHY0, DPIO_CH1); |
| 2951 | |
Ville Syrjälä | 7072246 | 2015-04-10 18:21:28 +0300 | [diff] [blame] | 2952 | dev_priv->chv_phy_control |= PHY_COM_LANE_RESET_DEASSERT(DPIO_PHY0); |
Ville Syrjälä | 3be60de | 2015-09-08 18:05:45 +0300 | [diff] [blame] | 2953 | |
| 2954 | dev_priv->chv_phy_assert[DPIO_PHY0] = false; |
| 2955 | } else { |
| 2956 | dev_priv->chv_phy_assert[DPIO_PHY0] = true; |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 2957 | } |
| 2958 | |
| 2959 | if (cmn_d->ops->is_enabled(dev_priv, cmn_d)) { |
| 2960 | uint32_t status = I915_READ(DPIO_PHY_STATUS); |
| 2961 | unsigned int mask; |
| 2962 | |
| 2963 | mask = status & DPLL_PORTD_READY_MASK; |
| 2964 | |
| 2965 | if (mask == 0xf) |
| 2966 | mask = 0x0; |
| 2967 | else |
| 2968 | dev_priv->chv_phy_control |= |
| 2969 | PHY_CH_POWER_DOWN_OVRD_EN(DPIO_PHY1, DPIO_CH0); |
| 2970 | |
| 2971 | dev_priv->chv_phy_control |= |
| 2972 | PHY_CH_POWER_DOWN_OVRD(mask, DPIO_PHY1, DPIO_CH0); |
| 2973 | |
Ville Syrjälä | 7072246 | 2015-04-10 18:21:28 +0300 | [diff] [blame] | 2974 | dev_priv->chv_phy_control |= PHY_COM_LANE_RESET_DEASSERT(DPIO_PHY1); |
Ville Syrjälä | 3be60de | 2015-09-08 18:05:45 +0300 | [diff] [blame] | 2975 | |
| 2976 | dev_priv->chv_phy_assert[DPIO_PHY1] = false; |
| 2977 | } else { |
| 2978 | dev_priv->chv_phy_assert[DPIO_PHY1] = true; |
Ville Syrjälä | e0fce78 | 2015-07-08 23:45:54 +0300 | [diff] [blame] | 2979 | } |
| 2980 | |
| 2981 | I915_WRITE(DISPLAY_PHY_CONTROL, dev_priv->chv_phy_control); |
| 2982 | |
| 2983 | DRM_DEBUG_KMS("Initial PHY_CONTROL=0x%08x\n", |
| 2984 | dev_priv->chv_phy_control); |
Ville Syrjälä | 7072246 | 2015-04-10 18:21:28 +0300 | [diff] [blame] | 2985 | } |
| 2986 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2987 | static void vlv_cmnlane_wa(struct drm_i915_private *dev_priv) |
| 2988 | { |
| 2989 | struct i915_power_well *cmn = |
| 2990 | lookup_power_well(dev_priv, PUNIT_POWER_WELL_DPIO_CMN_BC); |
| 2991 | struct i915_power_well *disp2d = |
| 2992 | lookup_power_well(dev_priv, PUNIT_POWER_WELL_DISP2D); |
| 2993 | |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2994 | /* If the display might be already active skip this */ |
Ville Syrjälä | 5d93a6e | 2014-10-16 20:52:33 +0300 | [diff] [blame] | 2995 | if (cmn->ops->is_enabled(dev_priv, cmn) && |
| 2996 | disp2d->ops->is_enabled(dev_priv, disp2d) && |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 2997 | I915_READ(DPIO_CTL) & DPIO_CMNRST) |
| 2998 | return; |
| 2999 | |
| 3000 | DRM_DEBUG_KMS("toggling display PHY side reset\n"); |
| 3001 | |
| 3002 | /* cmnlane needs DPLL registers */ |
| 3003 | disp2d->ops->enable(dev_priv, disp2d); |
| 3004 | |
| 3005 | /* |
| 3006 | * From VLV2A0_DP_eDP_HDMI_DPIO_driver_vbios_notes_11.docx: |
| 3007 | * Need to assert and de-assert PHY SB reset by gating the |
| 3008 | * common lane power, then un-gating it. |
| 3009 | * Simply ungating isn't enough to reset the PHY enough to get |
| 3010 | * ports and lanes running. |
| 3011 | */ |
| 3012 | cmn->ops->disable(dev_priv, cmn); |
| 3013 | } |
| 3014 | |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 3015 | /** |
| 3016 | * intel_power_domains_init_hw - initialize hardware power domain state |
| 3017 | * @dev_priv: i915 device instance |
Tvrtko Ursulin | 14bb2c1 | 2016-06-03 14:02:17 +0100 | [diff] [blame] | 3018 | * @resume: Called from resume code paths or not |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 3019 | * |
| 3020 | * This function initializes the hardware power domain state and enables all |
Imre Deak | 8d8c386 | 2017-02-17 17:39:46 +0200 | [diff] [blame] | 3021 | * power wells belonging to the INIT power domain. Power wells in other |
| 3022 | * domains (and not in the INIT domain) are referenced or disabled during the |
| 3023 | * modeset state HW readout. After that the reference count of each power well |
| 3024 | * must match its HW enabled state, see intel_power_domains_verify_state(). |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 3025 | */ |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 3026 | void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3027 | { |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3028 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 3029 | |
| 3030 | power_domains->initializing = true; |
| 3031 | |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 3032 | if (IS_CANNONLAKE(dev_priv)) { |
| 3033 | cnl_display_core_init(dev_priv, resume); |
| 3034 | } else if (IS_GEN9_BC(dev_priv)) { |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 3035 | skl_display_core_init(dev_priv, resume); |
Ander Conselvan de Oliveira | b817c44 | 2016-12-02 10:23:56 +0200 | [diff] [blame] | 3036 | } else if (IS_GEN9_LP(dev_priv)) { |
Imre Deak | d7d7c9e | 2016-04-01 16:02:42 +0300 | [diff] [blame] | 3037 | bxt_display_core_init(dev_priv, resume); |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 3038 | } else if (IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | 770effb | 2015-07-08 23:45:51 +0300 | [diff] [blame] | 3039 | mutex_lock(&power_domains->lock); |
Ville Syrjälä | 7072246 | 2015-04-10 18:21:28 +0300 | [diff] [blame] | 3040 | chv_phy_control_init(dev_priv); |
Ville Syrjälä | 770effb | 2015-07-08 23:45:51 +0300 | [diff] [blame] | 3041 | mutex_unlock(&power_domains->lock); |
Tvrtko Ursulin | 11a914c | 2016-10-13 11:03:08 +0100 | [diff] [blame] | 3042 | } else if (IS_VALLEYVIEW(dev_priv)) { |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3043 | mutex_lock(&power_domains->lock); |
| 3044 | vlv_cmnlane_wa(dev_priv); |
| 3045 | mutex_unlock(&power_domains->lock); |
| 3046 | } |
| 3047 | |
| 3048 | /* For now, we need the power well to be always enabled. */ |
| 3049 | intel_display_set_init_power(dev_priv, true); |
Imre Deak | d314cd4 | 2015-11-17 17:44:23 +0200 | [diff] [blame] | 3050 | /* Disable power support if the user asked so. */ |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 3051 | if (!i915_modparams.disable_power_well) |
Imre Deak | d314cd4 | 2015-11-17 17:44:23 +0200 | [diff] [blame] | 3052 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
Imre Deak | 30eade1 | 2015-11-04 19:24:13 +0200 | [diff] [blame] | 3053 | intel_power_domains_sync_hw(dev_priv); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3054 | power_domains->initializing = false; |
| 3055 | } |
| 3056 | |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 3057 | /** |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 3058 | * intel_power_domains_suspend - suspend power domain state |
| 3059 | * @dev_priv: i915 device instance |
| 3060 | * |
| 3061 | * This function prepares the hardware power domain state before entering |
| 3062 | * system suspend. It must be paired with intel_power_domains_init_hw(). |
| 3063 | */ |
| 3064 | void intel_power_domains_suspend(struct drm_i915_private *dev_priv) |
| 3065 | { |
Imre Deak | d314cd4 | 2015-11-17 17:44:23 +0200 | [diff] [blame] | 3066 | /* |
| 3067 | * Even if power well support was disabled we still want to disable |
| 3068 | * power wells while we are system suspended. |
| 3069 | */ |
Michal Wajdeczko | 4f044a8 | 2017-09-19 19:38:44 +0000 | [diff] [blame] | 3070 | if (!i915_modparams.disable_power_well) |
Imre Deak | d314cd4 | 2015-11-17 17:44:23 +0200 | [diff] [blame] | 3071 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
Imre Deak | 2622d79 | 2016-02-29 22:49:02 +0200 | [diff] [blame] | 3072 | |
Ville Syrjälä | d8d4a51 | 2017-06-09 15:26:00 -0700 | [diff] [blame] | 3073 | if (IS_CANNONLAKE(dev_priv)) |
| 3074 | cnl_display_core_uninit(dev_priv); |
| 3075 | else if (IS_GEN9_BC(dev_priv)) |
Imre Deak | 2622d79 | 2016-02-29 22:49:02 +0200 | [diff] [blame] | 3076 | skl_display_core_uninit(dev_priv); |
Ander Conselvan de Oliveira | b817c44 | 2016-12-02 10:23:56 +0200 | [diff] [blame] | 3077 | else if (IS_GEN9_LP(dev_priv)) |
Imre Deak | d7d7c9e | 2016-04-01 16:02:42 +0300 | [diff] [blame] | 3078 | bxt_display_core_uninit(dev_priv); |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 3079 | } |
| 3080 | |
Imre Deak | 8d8c386 | 2017-02-17 17:39:46 +0200 | [diff] [blame] | 3081 | static void intel_power_domains_dump_info(struct drm_i915_private *dev_priv) |
| 3082 | { |
| 3083 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 3084 | struct i915_power_well *power_well; |
| 3085 | |
| 3086 | for_each_power_well(dev_priv, power_well) { |
| 3087 | enum intel_display_power_domain domain; |
| 3088 | |
| 3089 | DRM_DEBUG_DRIVER("%-25s %d\n", |
| 3090 | power_well->name, power_well->count); |
| 3091 | |
| 3092 | for_each_power_domain(domain, power_well->domains) |
| 3093 | DRM_DEBUG_DRIVER(" %-23s %d\n", |
| 3094 | intel_display_power_domain_str(domain), |
| 3095 | power_domains->domain_use_count[domain]); |
| 3096 | } |
| 3097 | } |
| 3098 | |
| 3099 | /** |
| 3100 | * intel_power_domains_verify_state - verify the HW/SW state for all power wells |
| 3101 | * @dev_priv: i915 device instance |
| 3102 | * |
| 3103 | * Verify if the reference count of each power well matches its HW enabled |
| 3104 | * state and the total refcount of the domains it belongs to. This must be |
| 3105 | * called after modeset HW state sanitization, which is responsible for |
| 3106 | * acquiring reference counts for any power wells in use and disabling the |
| 3107 | * ones left on by BIOS but not required by any active output. |
| 3108 | */ |
| 3109 | void intel_power_domains_verify_state(struct drm_i915_private *dev_priv) |
| 3110 | { |
| 3111 | struct i915_power_domains *power_domains = &dev_priv->power_domains; |
| 3112 | struct i915_power_well *power_well; |
| 3113 | bool dump_domain_info; |
| 3114 | |
| 3115 | mutex_lock(&power_domains->lock); |
| 3116 | |
| 3117 | dump_domain_info = false; |
| 3118 | for_each_power_well(dev_priv, power_well) { |
| 3119 | enum intel_display_power_domain domain; |
| 3120 | int domains_count; |
| 3121 | bool enabled; |
| 3122 | |
| 3123 | /* |
| 3124 | * Power wells not belonging to any domain (like the MISC_IO |
| 3125 | * and PW1 power wells) are under FW control, so ignore them, |
| 3126 | * since their state can change asynchronously. |
| 3127 | */ |
| 3128 | if (!power_well->domains) |
| 3129 | continue; |
| 3130 | |
| 3131 | enabled = power_well->ops->is_enabled(dev_priv, power_well); |
| 3132 | if ((power_well->count || power_well->always_on) != enabled) |
| 3133 | DRM_ERROR("power well %s state mismatch (refcount %d/enabled %d)", |
| 3134 | power_well->name, power_well->count, enabled); |
| 3135 | |
| 3136 | domains_count = 0; |
| 3137 | for_each_power_domain(domain, power_well->domains) |
| 3138 | domains_count += power_domains->domain_use_count[domain]; |
| 3139 | |
| 3140 | if (power_well->count != domains_count) { |
| 3141 | DRM_ERROR("power well %s refcount/domain refcount mismatch " |
| 3142 | "(refcount %d/domains refcount %d)\n", |
| 3143 | power_well->name, power_well->count, |
| 3144 | domains_count); |
| 3145 | dump_domain_info = true; |
| 3146 | } |
| 3147 | } |
| 3148 | |
| 3149 | if (dump_domain_info) { |
| 3150 | static bool dumped; |
| 3151 | |
| 3152 | if (!dumped) { |
| 3153 | intel_power_domains_dump_info(dev_priv); |
| 3154 | dumped = true; |
| 3155 | } |
| 3156 | } |
| 3157 | |
| 3158 | mutex_unlock(&power_domains->lock); |
| 3159 | } |
| 3160 | |
Imre Deak | 73dfc22 | 2015-11-17 17:33:53 +0200 | [diff] [blame] | 3161 | /** |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 3162 | * intel_runtime_pm_get - grab a runtime pm reference |
| 3163 | * @dev_priv: i915 device instance |
| 3164 | * |
| 3165 | * This function grabs a device-level runtime pm reference (mostly used for GEM |
| 3166 | * code to ensure the GTT or GT is on) and ensures that it is powered up. |
| 3167 | * |
| 3168 | * Any runtime pm reference obtained by this function must have a symmetric |
| 3169 | * call to intel_runtime_pm_put() to release the reference again. |
| 3170 | */ |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3171 | void intel_runtime_pm_get(struct drm_i915_private *dev_priv) |
| 3172 | { |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 3173 | struct pci_dev *pdev = dev_priv->drm.pdev; |
| 3174 | struct device *kdev = &pdev->dev; |
Imre Deak | f507382 | 2017-03-28 12:38:55 +0300 | [diff] [blame] | 3175 | int ret; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3176 | |
Imre Deak | f507382 | 2017-03-28 12:38:55 +0300 | [diff] [blame] | 3177 | ret = pm_runtime_get_sync(kdev); |
| 3178 | WARN_ONCE(ret < 0, "pm_runtime_get_sync() failed: %d\n", ret); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 3179 | |
Sagar Arun Kamble | ad1443f | 2017-10-10 22:30:04 +0100 | [diff] [blame] | 3180 | atomic_inc(&dev_priv->runtime_pm.wakeref_count); |
Imre Deak | c9b8846 | 2015-12-15 20:10:34 +0200 | [diff] [blame] | 3181 | assert_rpm_wakelock_held(dev_priv); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3182 | } |
| 3183 | |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 3184 | /** |
Imre Deak | 0973128 | 2016-02-17 14:17:42 +0200 | [diff] [blame] | 3185 | * intel_runtime_pm_get_if_in_use - grab a runtime pm reference if device in use |
| 3186 | * @dev_priv: i915 device instance |
| 3187 | * |
| 3188 | * This function grabs a device-level runtime pm reference if the device is |
| 3189 | * already in use and ensures that it is powered up. |
| 3190 | * |
| 3191 | * Any runtime pm reference obtained by this function must have a symmetric |
| 3192 | * call to intel_runtime_pm_put() to release the reference again. |
| 3193 | */ |
| 3194 | bool intel_runtime_pm_get_if_in_use(struct drm_i915_private *dev_priv) |
| 3195 | { |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 3196 | struct pci_dev *pdev = dev_priv->drm.pdev; |
| 3197 | struct device *kdev = &pdev->dev; |
Imre Deak | 0973128 | 2016-02-17 14:17:42 +0200 | [diff] [blame] | 3198 | |
Chris Wilson | 135dc79 | 2016-02-25 21:10:28 +0000 | [diff] [blame] | 3199 | if (IS_ENABLED(CONFIG_PM)) { |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 3200 | int ret = pm_runtime_get_if_in_use(kdev); |
Imre Deak | 0973128 | 2016-02-17 14:17:42 +0200 | [diff] [blame] | 3201 | |
Chris Wilson | 135dc79 | 2016-02-25 21:10:28 +0000 | [diff] [blame] | 3202 | /* |
| 3203 | * In cases runtime PM is disabled by the RPM core and we get |
| 3204 | * an -EINVAL return value we are not supposed to call this |
| 3205 | * function, since the power state is undefined. This applies |
| 3206 | * atm to the late/early system suspend/resume handlers. |
| 3207 | */ |
Imre Deak | f507382 | 2017-03-28 12:38:55 +0300 | [diff] [blame] | 3208 | WARN_ONCE(ret < 0, |
| 3209 | "pm_runtime_get_if_in_use() failed: %d\n", ret); |
Chris Wilson | 135dc79 | 2016-02-25 21:10:28 +0000 | [diff] [blame] | 3210 | if (ret <= 0) |
| 3211 | return false; |
| 3212 | } |
Imre Deak | 0973128 | 2016-02-17 14:17:42 +0200 | [diff] [blame] | 3213 | |
Sagar Arun Kamble | ad1443f | 2017-10-10 22:30:04 +0100 | [diff] [blame] | 3214 | atomic_inc(&dev_priv->runtime_pm.wakeref_count); |
Imre Deak | 0973128 | 2016-02-17 14:17:42 +0200 | [diff] [blame] | 3215 | assert_rpm_wakelock_held(dev_priv); |
| 3216 | |
| 3217 | return true; |
| 3218 | } |
| 3219 | |
| 3220 | /** |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 3221 | * intel_runtime_pm_get_noresume - grab a runtime pm reference |
| 3222 | * @dev_priv: i915 device instance |
| 3223 | * |
| 3224 | * This function grabs a device-level runtime pm reference (mostly used for GEM |
| 3225 | * code to ensure the GTT or GT is on). |
| 3226 | * |
| 3227 | * It will _not_ power up the device but instead only check that it's powered |
| 3228 | * on. Therefore it is only valid to call this functions from contexts where |
| 3229 | * the device is known to be powered up and where trying to power it up would |
| 3230 | * result in hilarity and deadlocks. That pretty much means only the system |
| 3231 | * suspend/resume code where this is used to grab runtime pm references for |
| 3232 | * delayed setup down in work items. |
| 3233 | * |
| 3234 | * Any runtime pm reference obtained by this function must have a symmetric |
| 3235 | * call to intel_runtime_pm_put() to release the reference again. |
| 3236 | */ |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3237 | void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv) |
| 3238 | { |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 3239 | struct pci_dev *pdev = dev_priv->drm.pdev; |
| 3240 | struct device *kdev = &pdev->dev; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3241 | |
Imre Deak | c9b8846 | 2015-12-15 20:10:34 +0200 | [diff] [blame] | 3242 | assert_rpm_wakelock_held(dev_priv); |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 3243 | pm_runtime_get_noresume(kdev); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 3244 | |
Sagar Arun Kamble | ad1443f | 2017-10-10 22:30:04 +0100 | [diff] [blame] | 3245 | atomic_inc(&dev_priv->runtime_pm.wakeref_count); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3246 | } |
| 3247 | |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 3248 | /** |
| 3249 | * intel_runtime_pm_put - release a runtime pm reference |
| 3250 | * @dev_priv: i915 device instance |
| 3251 | * |
| 3252 | * This function drops the device-level runtime pm reference obtained by |
| 3253 | * intel_runtime_pm_get() and might power down the corresponding |
| 3254 | * hardware block right away if this is the last reference. |
| 3255 | */ |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3256 | void intel_runtime_pm_put(struct drm_i915_private *dev_priv) |
| 3257 | { |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 3258 | struct pci_dev *pdev = dev_priv->drm.pdev; |
| 3259 | struct device *kdev = &pdev->dev; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3260 | |
Imre Deak | 542db3c | 2015-12-15 20:10:36 +0200 | [diff] [blame] | 3261 | assert_rpm_wakelock_held(dev_priv); |
Sagar Arun Kamble | ad1443f | 2017-10-10 22:30:04 +0100 | [diff] [blame] | 3262 | atomic_dec(&dev_priv->runtime_pm.wakeref_count); |
Imre Deak | 1f814da | 2015-12-16 02:52:19 +0200 | [diff] [blame] | 3263 | |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 3264 | pm_runtime_mark_last_busy(kdev); |
| 3265 | pm_runtime_put_autosuspend(kdev); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3266 | } |
| 3267 | |
Daniel Vetter | e4e7684 | 2014-09-30 10:56:42 +0200 | [diff] [blame] | 3268 | /** |
| 3269 | * intel_runtime_pm_enable - enable runtime pm |
| 3270 | * @dev_priv: i915 device instance |
| 3271 | * |
| 3272 | * This function enables runtime pm at the end of the driver load sequence. |
| 3273 | * |
| 3274 | * Note that this function does currently not enable runtime pm for the |
| 3275 | * subordinate display power domains. That is only done on the first modeset |
| 3276 | * using intel_display_set_init_power(). |
| 3277 | */ |
Daniel Vetter | f458ebb | 2014-09-30 10:56:39 +0200 | [diff] [blame] | 3278 | void intel_runtime_pm_enable(struct drm_i915_private *dev_priv) |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3279 | { |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 3280 | struct pci_dev *pdev = dev_priv->drm.pdev; |
David Weinehall | 52a05c3 | 2016-08-22 13:32:44 +0300 | [diff] [blame] | 3281 | struct device *kdev = &pdev->dev; |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3282 | |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 3283 | pm_runtime_set_autosuspend_delay(kdev, 10000); /* 10s */ |
| 3284 | pm_runtime_mark_last_busy(kdev); |
Imre Deak | cbc68dc | 2015-12-17 19:04:33 +0200 | [diff] [blame] | 3285 | |
Imre Deak | 25b181b | 2015-12-17 13:44:56 +0200 | [diff] [blame] | 3286 | /* |
| 3287 | * Take a permanent reference to disable the RPM functionality and drop |
| 3288 | * it only when unloading the driver. Use the low level get/put helpers, |
| 3289 | * so the driver's own RPM reference tracking asserts also work on |
| 3290 | * platforms without RPM support. |
| 3291 | */ |
Tvrtko Ursulin | 6772ffe | 2016-10-13 11:02:55 +0100 | [diff] [blame] | 3292 | if (!HAS_RUNTIME_PM(dev_priv)) { |
Imre Deak | f507382 | 2017-03-28 12:38:55 +0300 | [diff] [blame] | 3293 | int ret; |
| 3294 | |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 3295 | pm_runtime_dont_use_autosuspend(kdev); |
Imre Deak | f507382 | 2017-03-28 12:38:55 +0300 | [diff] [blame] | 3296 | ret = pm_runtime_get_sync(kdev); |
| 3297 | WARN(ret < 0, "pm_runtime_get_sync() failed: %d\n", ret); |
Imre Deak | cbc68dc | 2015-12-17 19:04:33 +0200 | [diff] [blame] | 3298 | } else { |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 3299 | pm_runtime_use_autosuspend(kdev); |
Imre Deak | cbc68dc | 2015-12-17 19:04:33 +0200 | [diff] [blame] | 3300 | } |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3301 | |
Imre Deak | aabee1b | 2015-12-15 20:10:29 +0200 | [diff] [blame] | 3302 | /* |
| 3303 | * The core calls the driver load handler with an RPM reference held. |
| 3304 | * We drop that here and will reacquire it during unloading in |
| 3305 | * intel_power_domains_fini(). |
| 3306 | */ |
David Weinehall | c49d13e | 2016-08-22 13:32:42 +0300 | [diff] [blame] | 3307 | pm_runtime_put_autosuspend(kdev); |
Daniel Vetter | 9c065a7 | 2014-09-30 10:56:38 +0200 | [diff] [blame] | 3308 | } |