]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/gpu/drm/amd/display/dc/dce/dce_clocks.h
Merge remote-tracking branch 'regulator/topic/tps65218' into regulator-next
[linux.git] / drivers / gpu / drm / amd / display / dc / dce / dce_clocks.h
1 /*
2  * Copyright 2012-16 Advanced Micro Devices, Inc.
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 shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * Authors: AMD
23  *
24  */
25
26
27 #ifndef _DCE_CLOCKS_H_
28 #define _DCE_CLOCKS_H_
29
30 #include "display_clock.h"
31
32 #define CLK_COMMON_REG_LIST_DCE_BASE() \
33         .DPREFCLK_CNTL = mmDPREFCLK_CNTL, \
34         .DENTIST_DISPCLK_CNTL = mmDENTIST_DISPCLK_CNTL
35
36 #define CLK_SF(reg_name, field_name, post_fix)\
37         .field_name = reg_name ## __ ## field_name ## post_fix
38
39 #define CLK_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(mask_sh) \
40         CLK_SF(DPREFCLK_CNTL, DPREFCLK_SRC_SEL, mask_sh), \
41         CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DPREFCLK_WDIVIDER, mask_sh)
42
43 #define CLK_REG_FIELD_LIST(type) \
44         type DPREFCLK_SRC_SEL; \
45         type DENTIST_DPREFCLK_WDIVIDER;
46
47 struct dce_disp_clk_shift {
48         CLK_REG_FIELD_LIST(uint8_t)
49 };
50
51 struct dce_disp_clk_mask {
52         CLK_REG_FIELD_LIST(uint32_t)
53 };
54
55 struct dce_disp_clk_registers {
56         uint32_t DPREFCLK_CNTL;
57         uint32_t DENTIST_DISPCLK_CNTL;
58 };
59
60 /* Array identifiers and count for the divider ranges.*/
61 enum dce_divider_range_count {
62         DIVIDER_RANGE_01 = 0,
63         DIVIDER_RANGE_02,
64         DIVIDER_RANGE_03,
65         DIVIDER_RANGE_MAX /* == 3*/
66 };
67
68 enum dce_divider_error_types {
69         INVALID_DID = 0,
70         INVALID_DIVIDER = 1
71 };
72
73 struct dce_divider_range {
74         int div_range_start;
75         /* The end of this range of dividers.*/
76         int div_range_end;
77         /* The distance between each divider in this range.*/
78         int div_range_step;
79         /* The divider id for the lowest divider.*/
80         int did_min;
81         /* The divider id for the highest divider.*/
82         int did_max;
83 };
84
85 struct dce_disp_clk {
86         struct display_clock base;
87         const struct dce_disp_clk_registers *regs;
88         const struct dce_disp_clk_shift *clk_shift;
89         const struct dce_disp_clk_mask *clk_mask;
90
91         struct state_dependent_clocks max_clks_by_state[DM_PP_CLOCKS_MAX_STATES];
92         struct dce_divider_range divider_ranges[DIVIDER_RANGE_MAX];
93
94         bool use_max_disp_clk;
95         int dentist_vco_freq_khz;
96
97         /* Cache the status of DFS-bypass feature*/
98         bool dfs_bypass_enabled;
99         /* Cache the display clock returned by VBIOS if DFS-bypass is enabled.
100          * This is basically "Crystal Frequency In KHz" (XTALIN) frequency */
101         int dfs_bypass_disp_clk;
102
103         /* Flag for Enabled SS on DPREFCLK */
104         bool ss_on_dprefclk;
105         /* DPREFCLK SS percentage (if down-spread enabled) */
106         int dprefclk_ss_percentage;
107         /* DPREFCLK SS percentage Divider (100 or 1000) */
108         int dprefclk_ss_divider;
109
110         /* max disp_clk from PPLIB for max validation display clock*/
111         int max_displ_clk_in_khz;
112 };
113
114
115 struct display_clock *dce_disp_clk_create(
116         struct dc_context *ctx,
117         const struct dce_disp_clk_registers *regs,
118         const struct dce_disp_clk_shift *clk_shift,
119         const struct dce_disp_clk_mask *clk_mask);
120
121 struct display_clock *dce110_disp_clk_create(
122         struct dc_context *ctx,
123         const struct dce_disp_clk_registers *regs,
124         const struct dce_disp_clk_shift *clk_shift,
125         const struct dce_disp_clk_mask *clk_mask);
126
127 struct display_clock *dce112_disp_clk_create(
128         struct dc_context *ctx,
129         const struct dce_disp_clk_registers *regs,
130         const struct dce_disp_clk_shift *clk_shift,
131         const struct dce_disp_clk_mask *clk_mask);
132
133 struct display_clock *dce120_disp_clk_create(struct dc_context *ctx);
134
135 void dce_disp_clk_destroy(struct display_clock **disp_clk);
136
137 #endif /* _DCE_CLOCKS_H_ */