drm/i915: Manage HSW/BDW LCPLLs with the shared dpll interface
[deliverable/linux.git] / drivers / gpu / drm / i915 / intel_dpll_mgr.h
CommitLineData
ac7f11c6
ACO
1/*
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
daedf20a
ACO
28/*FIXME: Move this to a more appropriate place. */
29#define abs_diff(a, b) ({ \
30 typeof(a) __a = (a); \
31 typeof(b) __b = (b); \
32 (void) (&__a == &__b); \
33 __a > __b ? (__a - __b) : (__b - __a); })
34
ac7f11c6 35struct drm_i915_private;
c2a9fcd6
ACO
36struct intel_crtc;
37struct intel_crtc_state;
daedf20a 38struct intel_encoder;
ac7f11c6 39
daedf20a 40struct intel_shared_dpll;
f9476a6c
ACO
41struct intel_dpll_mgr;
42
ac7f11c6
ACO
43enum intel_dpll_id {
44 DPLL_ID_PRIVATE = -1, /* non-shared dpll in use */
45 /* real shared dpll ids must be >= 0 */
46 DPLL_ID_PCH_PLL_A = 0,
47 DPLL_ID_PCH_PLL_B = 1,
48 /* hsw/bdw */
49 DPLL_ID_WRPLL1 = 0,
50 DPLL_ID_WRPLL2 = 1,
51 DPLL_ID_SPLL = 2,
9d16da65
ACO
52 DPLL_ID_LCPLL_810 = 3,
53 DPLL_ID_LCPLL_1350 = 4,
54 DPLL_ID_LCPLL_2700 = 5,
ac7f11c6
ACO
55
56 /* skl */
57 DPLL_ID_SKL_DPLL1 = 0,
58 DPLL_ID_SKL_DPLL2 = 1,
59 DPLL_ID_SKL_DPLL3 = 2,
60};
9d16da65
ACO
61#define I915_NUM_PLLS 6
62
63/** Inform the state checker that the DPLL is kept enabled even if not
64 * in use by any crtc.
65 */
66#define INTEL_DPLL_ALWAYS_ON (1 << 0)
ac7f11c6
ACO
67
68struct intel_dpll_hw_state {
69 /* i9xx, pch plls */
70 uint32_t dpll;
71 uint32_t dpll_md;
72 uint32_t fp0;
73 uint32_t fp1;
74
75 /* hsw, bdw */
76 uint32_t wrpll;
77 uint32_t spll;
78
79 /* skl */
80 /*
81 * DPLL_CTRL1 has 6 bits for each each this DPLL. We store those in
82 * lower part of ctrl1 and they get shifted into position when writing
83 * the register. This allows us to easily compare the state to share
84 * the DPLL.
85 */
86 uint32_t ctrl1;
87 /* HDMI only, 0 when used for DP */
88 uint32_t cfgcr1, cfgcr2;
89
90 /* bxt */
91 uint32_t ebb0, ebb4, pll0, pll1, pll2, pll3, pll6, pll8, pll9, pll10,
92 pcsdw12;
93};
94
95struct intel_shared_dpll_config {
96 unsigned crtc_mask; /* mask of CRTCs sharing this PLL */
97 struct intel_dpll_hw_state hw_state;
98};
99
2edd6443 100struct intel_shared_dpll_funcs {
ac7f11c6
ACO
101 /* The mode_set hook is optional and should be used together with the
102 * intel_prepare_shared_dpll function. */
103 void (*mode_set)(struct drm_i915_private *dev_priv,
104 struct intel_shared_dpll *pll);
105 void (*enable)(struct drm_i915_private *dev_priv,
106 struct intel_shared_dpll *pll);
107 void (*disable)(struct drm_i915_private *dev_priv,
108 struct intel_shared_dpll *pll);
109 bool (*get_hw_state)(struct drm_i915_private *dev_priv,
110 struct intel_shared_dpll *pll,
111 struct intel_dpll_hw_state *hw_state);
112};
113
2edd6443
ACO
114struct intel_shared_dpll {
115 struct intel_shared_dpll_config config;
116
117 int active; /* count of number of active CRTCs (i.e. DPMS on) */
118 bool on; /* is the PLL actually active? Disabled during modeset */
119 const char *name;
120 /* should match the index in the dev_priv->shared_dplls array */
121 enum intel_dpll_id id;
122
123 struct intel_shared_dpll_funcs funcs;
9d16da65
ACO
124
125 uint32_t flags;
2edd6443
ACO
126};
127
ac7f11c6
ACO
128#define SKL_DPLL0 0
129#define SKL_DPLL1 1
130#define SKL_DPLL2 2
131#define SKL_DPLL3 3
132
c2a9fcd6
ACO
133/* shared dpll functions */
134struct intel_shared_dpll *
135intel_get_shared_dpll_by_id(struct drm_i915_private *dev_priv,
136 enum intel_dpll_id id);
137enum intel_dpll_id
138intel_get_shared_dpll_id(struct drm_i915_private *dev_priv,
139 struct intel_shared_dpll *pll);
140void
141intel_shared_dpll_config_get(struct intel_shared_dpll_config *config,
142 struct intel_shared_dpll *pll,
143 struct intel_crtc *crtc);
144void
145intel_shared_dpll_config_put(struct intel_shared_dpll_config *config,
146 struct intel_shared_dpll *pll,
147 struct intel_crtc *crtc);
148void assert_shared_dpll(struct drm_i915_private *dev_priv,
149 struct intel_shared_dpll *pll,
150 bool state);
151#define assert_shared_dpll_enabled(d, p) assert_shared_dpll(d, p, true)
152#define assert_shared_dpll_disabled(d, p) assert_shared_dpll(d, p, false)
153struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc,
daedf20a
ACO
154 struct intel_crtc_state *state,
155 struct intel_encoder *encoder);
c2a9fcd6
ACO
156void intel_prepare_shared_dpll(struct intel_crtc *crtc);
157void intel_enable_shared_dpll(struct intel_crtc *crtc);
158void intel_disable_shared_dpll(struct intel_crtc *crtc);
159void intel_shared_dpll_commit(struct drm_atomic_state *state);
160void intel_shared_dpll_init(struct drm_device *dev);
161
ac7f11c6
ACO
162
163#endif /* _INTEL_DPLL_MGR_H_ */
This page took 0.043121 seconds and 5 git commands to generate.