dce_clocks.h 3.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/*
 * Copyright 2012-16 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors: AMD
 *
 */


#ifndef _DCE_CLOCKS_H_
#define _DCE_CLOCKS_H_

30
#include "display_clock.h"
31 32 33

#define CLK_COMMON_REG_LIST_DCE_BASE() \
	.DPREFCLK_CNTL = mmDPREFCLK_CNTL, \
34
	.DENTIST_DISPCLK_CNTL = mmDENTIST_DISPCLK_CNTL
35

36 37 38
#define CLK_COMMON_REG_LIST_DCN_BASE() \
	SR(DENTIST_DISPCLK_CNTL)

39 40 41 42 43
#define CLK_SF(reg_name, field_name, post_fix)\
	.field_name = reg_name ## __ ## field_name ## post_fix

#define CLK_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(mask_sh) \
	CLK_SF(DPREFCLK_CNTL, DPREFCLK_SRC_SEL, mask_sh), \
44
	CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DPREFCLK_WDIVIDER, mask_sh)
45

46
#define CLK_COMMON_MASK_SH_LIST_DCN_COMMON_BASE(mask_sh) \
47
	CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_WDIVIDER, mask_sh),\
48
	CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_CHG_DONE, mask_sh)
49

50 51
#define CLK_REG_FIELD_LIST(type) \
	type DPREFCLK_SRC_SEL; \
52 53
	type DENTIST_DPREFCLK_WDIVIDER; \
	type DENTIST_DISPCLK_WDIVIDER; \
54
	type DENTIST_DISPCLK_CHG_DONE;
55

56
struct dccg_shift {
57
	CLK_REG_FIELD_LIST(uint8_t)
58 59
};

60
struct dccg_mask {
61
	CLK_REG_FIELD_LIST(uint32_t)
62 63
};

64
struct dccg_registers {
65 66 67 68
	uint32_t DPREFCLK_CNTL;
	uint32_t DENTIST_DISPCLK_CNTL;
};

69 70
struct dce_dccg {
	struct dccg base;
71 72 73
	const struct dccg_registers *regs;
	const struct dccg_shift *clk_shift;
	const struct dccg_mask *clk_mask;
74 75 76

	struct state_dependent_clocks max_clks_by_state[DM_PP_CLOCKS_MAX_STATES];

77
	int dentist_vco_freq_khz;
78 79 80 81 82

	/* Cache the status of DFS-bypass feature*/
	bool dfs_bypass_enabled;
	/* Cache the display clock returned by VBIOS if DFS-bypass is enabled.
	 * This is basically "Crystal Frequency In KHz" (XTALIN) frequency */
83
	int dfs_bypass_disp_clk;
84

85 86 87 88 89 90
	/* Flag for Enabled SS on DPREFCLK */
	bool ss_on_dprefclk;
	/* DPREFCLK SS percentage (if down-spread enabled) */
	int dprefclk_ss_percentage;
	/* DPREFCLK SS percentage Divider (100 or 1000) */
	int dprefclk_ss_divider;
91 92 93
};


94
struct dccg *dce_dccg_create(
95
	struct dc_context *ctx,
96 97 98
	const struct dccg_registers *regs,
	const struct dccg_shift *clk_shift,
	const struct dccg_mask *clk_mask);
99

100
struct dccg *dce110_dccg_create(
101
	struct dc_context *ctx,
102 103 104
	const struct dccg_registers *regs,
	const struct dccg_shift *clk_shift,
	const struct dccg_mask *clk_mask);
105

106
struct dccg *dce112_dccg_create(
107
	struct dc_context *ctx,
108 109 110
	const struct dccg_registers *regs,
	const struct dccg_shift *clk_shift,
	const struct dccg_mask *clk_mask);
111

112
struct dccg *dce120_dccg_create(struct dc_context *ctx);
113

114
#ifdef CONFIG_DRM_AMD_DC_DCN1_0
115
struct dccg *dcn1_dccg_create(struct dc_context *ctx);
116
#endif
117

118
void dce_dccg_destroy(struct dccg **dccg);
119 120

#endif /* _DCE_CLOCKS_H_ */