xref: /linux/drivers/gpu/drm/i915/display/intel_pmdemand.h (revision 3d0fe49454652117522f60bfbefb978ba0e5300b)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2023 Intel Corporation
4  */
5 
6 #ifndef __INTEL_PMDEMAND_H__
7 #define __INTEL_PMDEMAND_H__
8 
9 #include "intel_display_limits.h"
10 #include "intel_global_state.h"
11 
12 struct drm_i915_private;
13 struct intel_atomic_state;
14 struct intel_crtc_state;
15 struct intel_encoder;
16 struct intel_plane_state;
17 
18 struct pmdemand_params {
19 	u16 qclk_gv_bw;
20 	u8 voltage_index;
21 	u8 qclk_gv_index;
22 	u8 active_pipes;
23 	u8 active_dbufs;
24 	/* Total number of non type C active phys from active_phys_mask */
25 	u8 active_phys;
26 	u8 plls;
27 	u16 cdclk_freq_mhz;
28 	/* max from ddi_clocks[] */
29 	u16 ddiclk_max;
30 	u8 scalers;
31 };
32 
33 struct intel_pmdemand_state {
34 	struct intel_global_state base;
35 
36 	/* Maintain a persistent list of port clocks across all crtcs */
37 	int ddi_clocks[I915_MAX_PIPES];
38 
39 	/* Maintain a persistent list of non type C phys mask */
40 	u16 active_combo_phys_mask;
41 
42 	/* Parameters to be configured in the pmdemand registers */
43 	struct pmdemand_params params;
44 };
45 
46 #define to_intel_pmdemand_state(x) container_of((x), \
47 						struct intel_pmdemand_state, \
48 						base)
49 
50 void intel_pmdemand_init_early(struct drm_i915_private *i915);
51 int intel_pmdemand_init(struct drm_i915_private *i915);
52 void intel_pmdemand_init_pmdemand_params(struct drm_i915_private *i915,
53 					 struct intel_pmdemand_state *pmdemand_state);
54 void intel_pmdemand_update_port_clock(struct drm_i915_private *i915,
55 				      struct intel_pmdemand_state *pmdemand_state,
56 				      enum pipe pipe, int port_clock);
57 void intel_pmdemand_update_phys_mask(struct drm_i915_private *i915,
58 				     struct intel_encoder *encoder,
59 				     struct intel_pmdemand_state *pmdemand_state,
60 				     bool clear_bit);
61 void intel_pmdemand_program_dbuf(struct drm_i915_private *i915,
62 				 u8 dbuf_slices);
63 void intel_pmdemand_pre_plane_update(struct intel_atomic_state *state);
64 void intel_pmdemand_post_plane_update(struct intel_atomic_state *state);
65 int intel_pmdemand_atomic_check(struct intel_atomic_state *state);
66 
67 #endif /* __INTEL_PMDEMAND_H__ */
68