0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #ifndef _INTEL_DPLL_MGR_H_
0026 #define _INTEL_DPLL_MGR_H_
0027
0028 #include <linux/types.h>
0029
0030 #include "intel_wakeref.h"
0031
0032
0033 #define abs_diff(a, b) ({ \
0034 typeof(a) __a = (a); \
0035 typeof(b) __b = (b); \
0036 (void) (&__a == &__b); \
0037 __a > __b ? (__a - __b) : (__b - __a); })
0038
0039 enum tc_port;
0040 struct drm_i915_private;
0041 struct intel_atomic_state;
0042 struct intel_crtc;
0043 struct intel_crtc_state;
0044 struct intel_encoder;
0045 struct intel_shared_dpll;
0046 struct intel_shared_dpll_funcs;
0047
0048
0049
0050
0051
0052
0053 enum intel_dpll_id {
0054
0055
0056
0057 DPLL_ID_PRIVATE = -1,
0058
0059
0060
0061
0062 DPLL_ID_PCH_PLL_A = 0,
0063
0064
0065
0066 DPLL_ID_PCH_PLL_B = 1,
0067
0068
0069
0070
0071
0072 DPLL_ID_WRPLL1 = 0,
0073
0074
0075
0076 DPLL_ID_WRPLL2 = 1,
0077
0078
0079
0080 DPLL_ID_SPLL = 2,
0081
0082
0083
0084 DPLL_ID_LCPLL_810 = 3,
0085
0086
0087
0088 DPLL_ID_LCPLL_1350 = 4,
0089
0090
0091
0092 DPLL_ID_LCPLL_2700 = 5,
0093
0094
0095
0096
0097
0098 DPLL_ID_SKL_DPLL0 = 0,
0099
0100
0101
0102 DPLL_ID_SKL_DPLL1 = 1,
0103
0104
0105
0106 DPLL_ID_SKL_DPLL2 = 2,
0107
0108
0109
0110 DPLL_ID_SKL_DPLL3 = 3,
0111
0112
0113
0114
0115
0116 DPLL_ID_ICL_DPLL0 = 0,
0117
0118
0119
0120 DPLL_ID_ICL_DPLL1 = 1,
0121
0122
0123
0124 DPLL_ID_EHL_DPLL4 = 2,
0125
0126
0127
0128 DPLL_ID_ICL_TBTPLL = 2,
0129
0130
0131
0132
0133 DPLL_ID_ICL_MGPLL1 = 3,
0134
0135
0136
0137
0138 DPLL_ID_ICL_MGPLL2 = 4,
0139
0140
0141
0142
0143 DPLL_ID_ICL_MGPLL3 = 5,
0144
0145
0146
0147
0148 DPLL_ID_ICL_MGPLL4 = 6,
0149
0150
0151
0152 DPLL_ID_TGL_MGPLL5 = 7,
0153
0154
0155
0156 DPLL_ID_TGL_MGPLL6 = 8,
0157
0158
0159
0160
0161 DPLL_ID_DG1_DPLL0 = 0,
0162
0163
0164
0165 DPLL_ID_DG1_DPLL1 = 1,
0166
0167
0168
0169 DPLL_ID_DG1_DPLL2 = 2,
0170
0171
0172
0173 DPLL_ID_DG1_DPLL3 = 3,
0174 };
0175
0176 #define I915_NUM_PLLS 9
0177
0178 enum icl_port_dpll_id {
0179 ICL_PORT_DPLL_DEFAULT,
0180 ICL_PORT_DPLL_MG_PHY,
0181
0182 ICL_PORT_DPLL_COUNT,
0183 };
0184
0185 struct intel_dpll_hw_state {
0186
0187 u32 dpll;
0188 u32 dpll_md;
0189 u32 fp0;
0190 u32 fp1;
0191
0192
0193 u32 wrpll;
0194 u32 spll;
0195
0196
0197
0198
0199
0200
0201
0202
0203 u32 ctrl1;
0204
0205 u32 cfgcr1, cfgcr2;
0206
0207
0208 u32 cfgcr0;
0209
0210
0211 u32 div0;
0212
0213
0214 u32 ebb0, ebb4, pll0, pll1, pll2, pll3, pll6, pll8, pll9, pll10, pcsdw12;
0215
0216
0217
0218
0219
0220 u32 mg_refclkin_ctl;
0221 u32 mg_clktop2_coreclkctl1;
0222 u32 mg_clktop2_hsclkctl;
0223 u32 mg_pll_div0;
0224 u32 mg_pll_div1;
0225 u32 mg_pll_lf;
0226 u32 mg_pll_frac_lock;
0227 u32 mg_pll_ssc;
0228 u32 mg_pll_bias;
0229 u32 mg_pll_tdc_coldst_bias;
0230 u32 mg_pll_bias_mask;
0231 u32 mg_pll_tdc_coldst_bias_mask;
0232 };
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244 struct intel_shared_dpll_state {
0245
0246
0247
0248 u8 pipe_mask;
0249
0250
0251
0252
0253
0254 struct intel_dpll_hw_state hw_state;
0255 };
0256
0257
0258
0259
0260 struct dpll_info {
0261
0262
0263
0264 const char *name;
0265
0266
0267
0268
0269 const struct intel_shared_dpll_funcs *funcs;
0270
0271
0272
0273
0274
0275 enum intel_dpll_id id;
0276
0277 #define INTEL_DPLL_ALWAYS_ON (1 << 0)
0278
0279
0280
0281
0282
0283
0284
0285 u32 flags;
0286 };
0287
0288
0289
0290
0291 struct intel_shared_dpll {
0292
0293
0294
0295
0296
0297
0298 struct intel_shared_dpll_state state;
0299
0300
0301
0302
0303 u8 active_mask;
0304
0305
0306
0307
0308 bool on;
0309
0310
0311
0312
0313 const struct dpll_info *info;
0314
0315
0316
0317
0318
0319 intel_wakeref_t wakeref;
0320 };
0321
0322 #define SKL_DPLL0 0
0323 #define SKL_DPLL1 1
0324 #define SKL_DPLL2 2
0325 #define SKL_DPLL3 3
0326
0327
0328 struct intel_shared_dpll *
0329 intel_get_shared_dpll_by_id(struct drm_i915_private *dev_priv,
0330 enum intel_dpll_id id);
0331 enum intel_dpll_id
0332 intel_get_shared_dpll_id(struct drm_i915_private *dev_priv,
0333 struct intel_shared_dpll *pll);
0334 void assert_shared_dpll(struct drm_i915_private *dev_priv,
0335 struct intel_shared_dpll *pll,
0336 bool state);
0337 #define assert_shared_dpll_enabled(d, p) assert_shared_dpll(d, p, true)
0338 #define assert_shared_dpll_disabled(d, p) assert_shared_dpll(d, p, false)
0339 int intel_compute_shared_dplls(struct intel_atomic_state *state,
0340 struct intel_crtc *crtc,
0341 struct intel_encoder *encoder);
0342 int intel_reserve_shared_dplls(struct intel_atomic_state *state,
0343 struct intel_crtc *crtc,
0344 struct intel_encoder *encoder);
0345 void intel_release_shared_dplls(struct intel_atomic_state *state,
0346 struct intel_crtc *crtc);
0347 void icl_set_active_port_dpll(struct intel_crtc_state *crtc_state,
0348 enum icl_port_dpll_id port_dpll_id);
0349 void intel_update_active_dpll(struct intel_atomic_state *state,
0350 struct intel_crtc *crtc,
0351 struct intel_encoder *encoder);
0352 int intel_dpll_get_freq(struct drm_i915_private *i915,
0353 const struct intel_shared_dpll *pll,
0354 const struct intel_dpll_hw_state *pll_state);
0355 bool intel_dpll_get_hw_state(struct drm_i915_private *i915,
0356 struct intel_shared_dpll *pll,
0357 struct intel_dpll_hw_state *hw_state);
0358 void intel_enable_shared_dpll(const struct intel_crtc_state *crtc_state);
0359 void intel_disable_shared_dpll(const struct intel_crtc_state *crtc_state);
0360 void intel_shared_dpll_swap_state(struct intel_atomic_state *state);
0361 void intel_shared_dpll_init(struct drm_i915_private *dev_priv);
0362 void intel_dpll_update_ref_clks(struct drm_i915_private *dev_priv);
0363 void intel_dpll_readout_hw_state(struct drm_i915_private *dev_priv);
0364 void intel_dpll_sanitize_state(struct drm_i915_private *dev_priv);
0365
0366 void intel_dpll_dump_hw_state(struct drm_i915_private *dev_priv,
0367 const struct intel_dpll_hw_state *hw_state);
0368 enum intel_dpll_id icl_tc_port_to_pll_id(enum tc_port tc_port);
0369 bool intel_dpll_is_combophy(enum intel_dpll_id id);
0370
0371 void intel_shared_dpll_state_verify(struct intel_crtc *crtc,
0372 struct intel_crtc_state *old_crtc_state,
0373 struct intel_crtc_state *new_crtc_state);
0374 void intel_shared_dpll_verify_disabled(struct drm_i915_private *i915);
0375
0376 #endif