1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2019 Intel Corporation
6 #ifndef __INTEL_DISPLAY_POWER_H__
7 #define __INTEL_DISPLAY_POWER_H__
9 #include "intel_display.h"
10 #include "intel_runtime_pm.h"
13 struct drm_i915_private
;
16 enum intel_display_power_domain
{
17 POWER_DOMAIN_DISPLAY_CORE
,
22 POWER_DOMAIN_PIPE_A_PANEL_FITTER
,
23 POWER_DOMAIN_PIPE_B_PANEL_FITTER
,
24 POWER_DOMAIN_PIPE_C_PANEL_FITTER
,
25 POWER_DOMAIN_PIPE_D_PANEL_FITTER
,
26 POWER_DOMAIN_TRANSCODER_A
,
27 POWER_DOMAIN_TRANSCODER_B
,
28 POWER_DOMAIN_TRANSCODER_C
,
29 POWER_DOMAIN_TRANSCODER_D
,
30 POWER_DOMAIN_TRANSCODER_EDP
,
31 /* VDSC/joining for eDP/DSI transcoder (ICL) or pipe A (TGL) */
32 POWER_DOMAIN_TRANSCODER_VDSC_PW2
,
33 POWER_DOMAIN_TRANSCODER_DSI_A
,
34 POWER_DOMAIN_TRANSCODER_DSI_C
,
35 POWER_DOMAIN_PORT_DDI_A_LANES
,
36 POWER_DOMAIN_PORT_DDI_B_LANES
,
37 POWER_DOMAIN_PORT_DDI_C_LANES
,
38 POWER_DOMAIN_PORT_DDI_D_LANES
,
39 POWER_DOMAIN_PORT_DDI_E_LANES
,
40 POWER_DOMAIN_PORT_DDI_F_LANES
,
41 POWER_DOMAIN_PORT_DDI_G_LANES
,
42 POWER_DOMAIN_PORT_DDI_H_LANES
,
43 POWER_DOMAIN_PORT_DDI_I_LANES
,
44 POWER_DOMAIN_PORT_DDI_A_IO
,
45 POWER_DOMAIN_PORT_DDI_B_IO
,
46 POWER_DOMAIN_PORT_DDI_C_IO
,
47 POWER_DOMAIN_PORT_DDI_D_IO
,
48 POWER_DOMAIN_PORT_DDI_E_IO
,
49 POWER_DOMAIN_PORT_DDI_F_IO
,
50 POWER_DOMAIN_PORT_DDI_G_IO
,
51 POWER_DOMAIN_PORT_DDI_H_IO
,
52 POWER_DOMAIN_PORT_DDI_I_IO
,
53 POWER_DOMAIN_PORT_DSI
,
54 POWER_DOMAIN_PORT_CRT
,
55 POWER_DOMAIN_PORT_OTHER
,
67 POWER_DOMAIN_AUX_IO_A
,
68 POWER_DOMAIN_AUX_C_TBT
,
69 POWER_DOMAIN_AUX_D_TBT
,
70 POWER_DOMAIN_AUX_E_TBT
,
71 POWER_DOMAIN_AUX_F_TBT
,
72 POWER_DOMAIN_AUX_G_TBT
,
73 POWER_DOMAIN_AUX_H_TBT
,
74 POWER_DOMAIN_AUX_I_TBT
,
78 POWER_DOMAIN_DPLL_DC_OFF
,
87 * IDs used to look up power wells. Power wells accessed directly bypassing
88 * the power domains framework must be assigned a unique ID. The rest of power
89 * wells must be assigned DISP_PW_ID_NONE.
91 enum i915_power_well_id
{
95 BXT_DISP_PW_DPIO_CMN_A
,
96 VLV_DISP_PW_DPIO_CMN_BC
,
97 GLK_DISP_PW_DPIO_CMN_C
,
98 CHV_DISP_PW_DPIO_CMN_D
,
106 #define POWER_DOMAIN_PIPE(pipe) ((pipe) + POWER_DOMAIN_PIPE_A)
107 #define POWER_DOMAIN_PIPE_PANEL_FITTER(pipe) \
108 ((pipe) + POWER_DOMAIN_PIPE_A_PANEL_FITTER)
109 #define POWER_DOMAIN_TRANSCODER(tran) \
110 ((tran) == TRANSCODER_EDP ? POWER_DOMAIN_TRANSCODER_EDP : \
111 (tran) + POWER_DOMAIN_TRANSCODER_A)
113 struct i915_power_well
;
115 struct i915_power_well_ops
{
117 * Synchronize the well's hw state to match the current sw state, for
118 * example enable/disable it based on the current refcount. Called
119 * during driver init and resume time, possibly after first calling
120 * the enable/disable handlers.
122 void (*sync_hw
)(struct drm_i915_private
*dev_priv
,
123 struct i915_power_well
*power_well
);
125 * Enable the well and resources that depend on it (for example
126 * interrupts located on the well). Called after the 0->1 refcount
129 void (*enable
)(struct drm_i915_private
*dev_priv
,
130 struct i915_power_well
*power_well
);
132 * Disable the well and resources that depend on it. Called after
133 * the 1->0 refcount transition.
135 void (*disable
)(struct drm_i915_private
*dev_priv
,
136 struct i915_power_well
*power_well
);
137 /* Returns the hw enabled state. */
138 bool (*is_enabled
)(struct drm_i915_private
*dev_priv
,
139 struct i915_power_well
*power_well
);
142 struct i915_power_well_regs
{
149 /* Power well structure for haswell */
150 struct i915_power_well_desc
{
154 /* unique identifier for this power well */
155 enum i915_power_well_id id
;
157 * Arbitraty data associated with this power well. Platform and power
163 * request/status flag index in the PUNIT power well
164 * control/status registers.
172 const struct i915_power_well_regs
*regs
;
174 * request/status flag index in the power well
175 * constrol/status registers.
178 /* Mask of pipes whose IRQ logic is backed by the pw */
180 /* The pw is backing the VGA functionality */
184 * The pw is for an ICL+ TypeC PHY port in
190 const struct i915_power_well_ops
*ops
;
193 struct i915_power_well
{
194 const struct i915_power_well_desc
*desc
;
195 /* power well enable/disable usage count */
197 /* cached hw enabled state */
201 struct i915_power_domains
{
203 * Power wells needed for initialization at driver init and suspend
204 * time are on. They are kept on until after the first modeset.
207 bool display_core_suspended
;
208 int power_well_count
;
210 intel_wakeref_t wakeref
;
213 int domain_use_count
[POWER_DOMAIN_NUM
];
215 struct delayed_work async_put_work
;
216 intel_wakeref_t async_put_wakeref
;
217 u64 async_put_domains
[2];
219 struct i915_power_well
*power_wells
;
222 #define for_each_power_domain(domain, mask) \
223 for ((domain) = 0; (domain) < POWER_DOMAIN_NUM; (domain)++) \
224 for_each_if(BIT_ULL(domain) & (mask))
226 #define for_each_power_well(__dev_priv, __power_well) \
227 for ((__power_well) = (__dev_priv)->power_domains.power_wells; \
228 (__power_well) - (__dev_priv)->power_domains.power_wells < \
229 (__dev_priv)->power_domains.power_well_count; \
232 #define for_each_power_well_reverse(__dev_priv, __power_well) \
233 for ((__power_well) = (__dev_priv)->power_domains.power_wells + \
234 (__dev_priv)->power_domains.power_well_count - 1; \
235 (__power_well) - (__dev_priv)->power_domains.power_wells >= 0; \
238 #define for_each_power_domain_well(__dev_priv, __power_well, __domain_mask) \
239 for_each_power_well(__dev_priv, __power_well) \
240 for_each_if((__power_well)->desc->domains & (__domain_mask))
242 #define for_each_power_domain_well_reverse(__dev_priv, __power_well, __domain_mask) \
243 for_each_power_well_reverse(__dev_priv, __power_well) \
244 for_each_if((__power_well)->desc->domains & (__domain_mask))
246 int intel_power_domains_init(struct drm_i915_private
*dev_priv
);
247 void intel_power_domains_cleanup(struct drm_i915_private
*dev_priv
);
248 void intel_power_domains_init_hw(struct drm_i915_private
*dev_priv
, bool resume
);
249 void intel_power_domains_driver_remove(struct drm_i915_private
*dev_priv
);
250 void intel_power_domains_enable(struct drm_i915_private
*dev_priv
);
251 void intel_power_domains_disable(struct drm_i915_private
*dev_priv
);
252 void intel_power_domains_suspend(struct drm_i915_private
*dev_priv
,
253 enum i915_drm_suspend_mode
);
254 void intel_power_domains_resume(struct drm_i915_private
*dev_priv
);
256 void intel_display_power_suspend_late(struct drm_i915_private
*i915
);
257 void intel_display_power_resume_early(struct drm_i915_private
*i915
);
258 void intel_display_power_suspend(struct drm_i915_private
*i915
);
259 void intel_display_power_resume(struct drm_i915_private
*i915
);
260 void intel_display_power_set_target_dc_state(struct drm_i915_private
*dev_priv
,
264 intel_display_power_domain_str(enum intel_display_power_domain domain
);
266 bool intel_display_power_is_enabled(struct drm_i915_private
*dev_priv
,
267 enum intel_display_power_domain domain
);
268 bool __intel_display_power_is_enabled(struct drm_i915_private
*dev_priv
,
269 enum intel_display_power_domain domain
);
270 intel_wakeref_t
intel_display_power_get(struct drm_i915_private
*dev_priv
,
271 enum intel_display_power_domain domain
);
273 intel_display_power_get_if_enabled(struct drm_i915_private
*dev_priv
,
274 enum intel_display_power_domain domain
);
275 void intel_display_power_put_unchecked(struct drm_i915_private
*dev_priv
,
276 enum intel_display_power_domain domain
);
277 void __intel_display_power_put_async(struct drm_i915_private
*i915
,
278 enum intel_display_power_domain domain
,
279 intel_wakeref_t wakeref
);
280 void intel_display_power_flush_work(struct drm_i915_private
*i915
);
281 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
282 void intel_display_power_put(struct drm_i915_private
*dev_priv
,
283 enum intel_display_power_domain domain
,
284 intel_wakeref_t wakeref
);
286 intel_display_power_put_async(struct drm_i915_private
*i915
,
287 enum intel_display_power_domain domain
,
288 intel_wakeref_t wakeref
)
290 __intel_display_power_put_async(i915
, domain
, wakeref
);
294 intel_display_power_put(struct drm_i915_private
*i915
,
295 enum intel_display_power_domain domain
,
296 intel_wakeref_t wakeref
)
298 intel_display_power_put_unchecked(i915
, domain
);
302 intel_display_power_put_async(struct drm_i915_private
*i915
,
303 enum intel_display_power_domain domain
,
304 intel_wakeref_t wakeref
)
306 __intel_display_power_put_async(i915
, domain
, -1);
310 #define with_intel_display_power(i915, domain, wf) \
311 for ((wf) = intel_display_power_get((i915), (domain)); (wf); \
312 intel_display_power_put_async((i915), (domain), (wf)), (wf) = 0)
314 void icl_dbuf_slices_update(struct drm_i915_private
*dev_priv
,
317 void chv_phy_powergate_lanes(struct intel_encoder
*encoder
,
318 bool override
, unsigned int mask
);
319 bool chv_phy_powergate_ch(struct drm_i915_private
*dev_priv
, enum dpio_phy phy
,
320 enum dpio_channel ch
, bool override
);
322 #endif /* __INTEL_DISPLAY_POWER_H__ */