blob: 8be2478af78f42177e172df933aed075d22bf009 [file] [log] [blame]
Ander Conselvan de Oliveiraac7f11c2016-03-08 17:46:19 +02001/*
2 * Copyright © 2012-2016 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 */
24
25#ifndef _INTEL_DPLL_MGR_H_
26#define _INTEL_DPLL_MGR_H_
27
28struct drm_i915_private;
Ander Conselvan de Oliveirac2a9fcd2016-03-08 17:46:20 +020029struct intel_crtc;
30struct intel_crtc_state;
Ander Conselvan de Oliveira2edd6442016-03-08 17:46:21 +020031struct intel_shared_dpll;
Ander Conselvan de Oliveiraac7f11c2016-03-08 17:46:19 +020032
33enum intel_dpll_id {
34 DPLL_ID_PRIVATE = -1, /* non-shared dpll in use */
35 /* real shared dpll ids must be >= 0 */
36 DPLL_ID_PCH_PLL_A = 0,
37 DPLL_ID_PCH_PLL_B = 1,
38 /* hsw/bdw */
39 DPLL_ID_WRPLL1 = 0,
40 DPLL_ID_WRPLL2 = 1,
41 DPLL_ID_SPLL = 2,
42
43 /* skl */
44 DPLL_ID_SKL_DPLL1 = 0,
45 DPLL_ID_SKL_DPLL2 = 1,
46 DPLL_ID_SKL_DPLL3 = 2,
47};
48#define I915_NUM_PLLS 3
49
50struct intel_dpll_hw_state {
51 /* i9xx, pch plls */
52 uint32_t dpll;
53 uint32_t dpll_md;
54 uint32_t fp0;
55 uint32_t fp1;
56
57 /* hsw, bdw */
58 uint32_t wrpll;
59 uint32_t spll;
60
61 /* skl */
62 /*
63 * DPLL_CTRL1 has 6 bits for each each this DPLL. We store those in
64 * lower part of ctrl1 and they get shifted into position when writing
65 * the register. This allows us to easily compare the state to share
66 * the DPLL.
67 */
68 uint32_t ctrl1;
69 /* HDMI only, 0 when used for DP */
70 uint32_t cfgcr1, cfgcr2;
71
72 /* bxt */
73 uint32_t ebb0, ebb4, pll0, pll1, pll2, pll3, pll6, pll8, pll9, pll10,
74 pcsdw12;
75};
76
77struct intel_shared_dpll_config {
78 unsigned crtc_mask; /* mask of CRTCs sharing this PLL */
79 struct intel_dpll_hw_state hw_state;
80};
81
Ander Conselvan de Oliveira2edd6442016-03-08 17:46:21 +020082struct intel_shared_dpll_funcs {
Ander Conselvan de Oliveiraac7f11c2016-03-08 17:46:19 +020083 /* The mode_set hook is optional and should be used together with the
84 * intel_prepare_shared_dpll function. */
85 void (*mode_set)(struct drm_i915_private *dev_priv,
86 struct intel_shared_dpll *pll);
87 void (*enable)(struct drm_i915_private *dev_priv,
88 struct intel_shared_dpll *pll);
89 void (*disable)(struct drm_i915_private *dev_priv,
90 struct intel_shared_dpll *pll);
91 bool (*get_hw_state)(struct drm_i915_private *dev_priv,
92 struct intel_shared_dpll *pll,
93 struct intel_dpll_hw_state *hw_state);
94};
95
Ander Conselvan de Oliveira2edd6442016-03-08 17:46:21 +020096struct intel_shared_dpll {
97 struct intel_shared_dpll_config config;
98
99 int active; /* count of number of active CRTCs (i.e. DPMS on) */
100 bool on; /* is the PLL actually active? Disabled during modeset */
101 const char *name;
102 /* should match the index in the dev_priv->shared_dplls array */
103 enum intel_dpll_id id;
104
105 struct intel_shared_dpll_funcs funcs;
106};
107
Ander Conselvan de Oliveiraac7f11c2016-03-08 17:46:19 +0200108#define SKL_DPLL0 0
109#define SKL_DPLL1 1
110#define SKL_DPLL2 2
111#define SKL_DPLL3 3
112
Ander Conselvan de Oliveirac2a9fcd2016-03-08 17:46:20 +0200113/* shared dpll functions */
114struct intel_shared_dpll *
115intel_get_shared_dpll_by_id(struct drm_i915_private *dev_priv,
116 enum intel_dpll_id id);
117enum intel_dpll_id
118intel_get_shared_dpll_id(struct drm_i915_private *dev_priv,
119 struct intel_shared_dpll *pll);
120void
121intel_shared_dpll_config_get(struct intel_shared_dpll_config *config,
122 struct intel_shared_dpll *pll,
123 struct intel_crtc *crtc);
124void
125intel_shared_dpll_config_put(struct intel_shared_dpll_config *config,
126 struct intel_shared_dpll *pll,
127 struct intel_crtc *crtc);
128void assert_shared_dpll(struct drm_i915_private *dev_priv,
129 struct intel_shared_dpll *pll,
130 bool state);
131#define assert_shared_dpll_enabled(d, p) assert_shared_dpll(d, p, true)
132#define assert_shared_dpll_disabled(d, p) assert_shared_dpll(d, p, false)
133struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc,
134 struct intel_crtc_state *state);
135void intel_prepare_shared_dpll(struct intel_crtc *crtc);
136void intel_enable_shared_dpll(struct intel_crtc *crtc);
137void intel_disable_shared_dpll(struct intel_crtc *crtc);
138void intel_shared_dpll_commit(struct drm_atomic_state *state);
139void intel_shared_dpll_init(struct drm_device *dev);
140
Ander Conselvan de Oliveiraac7f11c2016-03-08 17:46:19 +0200141
142#endif /* _INTEL_DPLL_MGR_H_ */