aboutsummaryrefslogtreecommitdiffstats
path: root/include/ctrl/ctrlclk.h
blob: fbd56770fa0c2473734afa2ef6bd7fb880eb3779 (plain) (blame)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
 * general p state infrastructure
 *
 * Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
 *
 * 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 AUTHORS OR COPYRIGHT HOLDERS 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.
 */
#ifndef NVGPU_CTRLCLK_H
#define NVGPU_CTRLCLK_H

#include "ctrlboardobj.h"
#include "ctrlclkavfs.h"
#include "ctrlvolt.h"

#define CTRL_CLK_CLK_DELTA_MAX_VOLT_RAILS 4

/* valid clock domain values */
#define CTRL_CLK_DOMAIN_MCLK                                (0x00000010)
#define CTRL_CLK_DOMAIN_HOSTCLK                             (0x00000020)
#define CTRL_CLK_DOMAIN_DISPCLK                             (0x00000040)
#define CTRL_CLK_DOMAIN_GPC2CLK                             (0x00010000)
#define CTRL_CLK_DOMAIN_XBAR2CLK                            (0x00040000)
#define CTRL_CLK_DOMAIN_SYS2CLK                             (0x00800000)
#define CTRL_CLK_DOMAIN_HUB2CLK                             (0x01000000)
#define CTRL_CLK_DOMAIN_PWRCLK                              (0x00080000)
#define CTRL_CLK_DOMAIN_NVDCLK                              (0x00100000)
#define CTRL_CLK_DOMAIN_PCIEGENCLK                          (0x00200000)

#define CTRL_CLK_DOMAIN_GPCCLK                              (0x00000001)
#define CTRL_CLK_DOMAIN_XBARCLK                             (0x00000002)
#define CTRL_CLK_DOMAIN_SYSCLK                              (0x00000004)
#define CTRL_CLK_DOMAIN_HUBCLK                              (0x00000008)

#define CTRL_CLK_CLK_DOMAIN_TYPE_3X                                  0x01
#define CTRL_CLK_CLK_DOMAIN_TYPE_3X_FIXED                            0x02
#define CTRL_CLK_CLK_DOMAIN_TYPE_3X_PROG                             0x03
#define CTRL_CLK_CLK_DOMAIN_TYPE_3X_MASTER                           0x04
#define CTRL_CLK_CLK_DOMAIN_TYPE_3X_SLAVE                            0x05
#define CTRL_CLK_CLK_DOMAIN_TYPE_30_PROG                             0x06
#define CTRL_CLK_CLK_DOMAIN_TYPE_35_MASTER                           0x07
#define CTRL_CLK_CLK_DOMAIN_TYPE_35_SLAVE                            0x08
#define CTRL_CLK_CLK_DOMAIN_TYPE_35_PROG                             0x09

#define CTRL_CLK_CLK_DOMAIN_3X_PROG_ORDERING_INDEX_INVALID 0xFF
#define CTRL_CLK_CLK_DOMAIN_INDEX_INVALID                           0xFF

#define CTRL_CLK_CLK_PROG_TYPE_1X                              0x01
#define CTRL_CLK_CLK_PROG_TYPE_1X_MASTER                       0x02
#define CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_RATIO                 0x03
#define CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_TABLE                 0x04
#define CTRL_CLK_CLK_PROG_TYPE_UNKNOWN                         255

/*!
 * Enumeration of CLK_PROG source types.
 */
#define CTRL_CLK_PROG_1X_SOURCE_PLL                            0x00
#define CTRL_CLK_PROG_1X_SOURCE_ONE_SOURCE                     0x01
#define CTRL_CLK_PROG_1X_SOURCE_FLL                            0x02
#define CTRL_CLK_PROG_1X_SOURCE_INVALID                        255

#define CTRL_CLK_CLK_PROG_1X_MASTER_VF_ENTRY_MAX_ENTRIES 4
#define CTRL_CLK_PROG_1X_MASTER_MAX_SLAVE_ENTRIES 6

#define CTRL_CLK_CLK_VF_POINT_IDX_INVALID                      255

#define CTRL_CLK_CLK_VF_POINT_TYPE_FREQ                         0x01
#define CTRL_CLK_CLK_VF_POINT_TYPE_VOLT                         0x02
#define CTRL_CLK_CLK_VF_POINT_TYPE_UNKNOWN                      255

struct ctrl_clk_clk_prog_1x_master_source_fll {
	u32 base_vfsmooth_volt_uv;
	u32 max_vf_ramprate;
	u32 max_freq_stepsize_mhz;
};

union ctrl_clk_clk_prog_1x_master_source_data {
	struct ctrl_clk_clk_prog_1x_master_source_fll fll;
};

struct ctrl_clk_clk_vf_point_info_freq {
	u16 freq_mhz;
};

struct ctrl_clk_clk_vf_point_info_volt {
	u32  sourceVoltageuV;
	u8  vfGainVfeEquIdx;
	u8  clkDomainIdx;
};

struct ctrl_clk_clk_prog_1x_master_vf_entry {
	u8 vfe_idx;
	u8 gain_vfe_idx;
	u8 vf_point_idx_first;
	u8 vf_point_idx_last;
};

struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry {
	u8 clk_dom_idx;
	u8 ratio;
};

struct ctrl_clk_clk_prog_1x_master_table_slave_entry {
	u8 clk_dom_idx;
	u16 freq_mhz;
};

struct ctrl_clk_clk_prog_1x_source_pll {
	u8 pll_idx;
	u8 freq_step_size_mhz;
};

union ctrl_clk_freq_delta_data {
	s32 delta_khz;
	s16 delta_percent;
};
struct ctrl_clk_freq_delta {
	u8 type;
	union ctrl_clk_freq_delta_data data;
};

struct ctrl_clk_clk_delta {
	struct ctrl_clk_freq_delta freq_delta;
	int volt_deltauv[CTRL_CLK_CLK_DELTA_MAX_VOLT_RAILS];
};

struct ctrl_clk_vin_v10 {
	u32 slope;
	u32 intercept;
};

struct ctrl_clk_vin_v20 {
	s8 offset;
	s8 gain;
};

union ctrl_clk_vin_data_v20 {
	struct ctrl_clk_vin_v10 cal_v10;
	struct ctrl_clk_vin_v20 cal_v20;
};

struct ctrl_clk_vin_device_info_data_v10 {
	struct ctrl_clk_vin_v10 vin_cal;
};

struct ctrl_clk_vin_device_info_data_v20 {
	u8 cal_type;
	union ctrl_clk_vin_data_v20 vin_cal;
};

union ctrl_clk_clk_prog_1x_source_data {
	struct ctrl_clk_clk_prog_1x_source_pll pll;
};

struct ctrl_clk_vf_pair {
	u16 freq_mhz;
	u32 voltage_uv;
};

struct ctrl_clk_clk_domain_list_item {
	u32  clk_domain;
	u32  clk_freq_khz;
	u32  clk_flags;
	u8   current_regime_id;
	u8   target_regime_id;
};

struct ctrl_clk_clk_domain_list_item_v1 {
	u32  clk_domain;
	u32  clk_freq_khz;
	u8   regime_id;
	u8   source;
};

struct ctrl_clk_clk_domain_list {
	u8 num_domains;
	struct ctrl_clk_clk_domain_list_item_v1
		clk_domains[CTRL_BOARDOBJ_MAX_BOARD_OBJECTS];
};

#define CTRL_CLK_VF_PAIR_FREQ_MHZ_GET(pvfpair)                          \
	((pvfpair)->freq_mhz)

#define CTRL_CLK_VF_PAIR_VOLTAGE_UV_GET(pvfpair)                        \
	((pvfpair)->voltage_uv)

#define CTRL_CLK_VF_PAIR_FREQ_MHZ_SET(pvfpair, _freqmhz)                \
	(((pvfpair)->freq_mhz) = (_freqmhz))

#define CTRL_CLK_VF_PAIR_FREQ_MHZ_SET(pvfpair, _freqmhz)                \
	(((pvfpair)->freq_mhz) = (_freqmhz))


#define CTRL_CLK_VF_PAIR_VOLTAGE_UV_SET(pvfpair, _voltageuv)	        \
	(((pvfpair)->voltage_uv) = (_voltageuv))

#endif /* NVGPU_CTRLCLK_H */