summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/nvrm/core/common/nvrm_clocks_limits_private.h
blob: fb8bb3b0e781fd54e0373b06f1fbd454a233bf41 (plain)
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/*
 * Copyright (c) 2008-2009 NVIDIA Corporation.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * Neither the name of the NVIDIA Corporation nor the names of its contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */

#ifndef INCLUDED_NVRM_CLOCKS_LIMITS_PRIVATE_H
#define INCLUDED_NVRM_CLOCKS_LIMITS_PRIVATE_H

#include "nvrm_power_private.h"

#ifdef __cplusplus
extern "C"
{
#endif  /* __cplusplus */

// Maximum supported SoC process corners
#define NVRM_PROCESS_CORNERS (4)

// Maximum supported core and/or CPU voltage characterization steps
#define NVRM_VOLTAGE_STEPS (7)

// Minimum required core voltage resolution
#define NVRM_CORE_RESOLUTION_MV (25)

/// Maximum safe core voltage step
#define NVRM_SAFE_VOLTAGE_STEP_MV (100)

// Minimum system bus frequency
#define NVRM_BUS_MIN_KHZ (32)

// Minimum SDRAM bus frequency
#define NVRM_SDRAM_MIN_KHZ (12000)

// ID used by RM to record clock sources V/F dependencies
#define NVRM_DEVID_CLK_SRC (1000)

/**
 * Oscillator (main) clock doubler configuration record
 */
typedef struct NvRmOscDoublerConfigRec
{
    NvRmFreqKHz OscKHz;
    NvU32 Taps[NVRM_PROCESS_CORNERS];
} NvRmOscDoublerConfig;

/**
 * Module clocks limits arranged according to the HW module IDs.
 */
typedef struct NvRmScaledClkLimitsRec
{
    NvU32 HwDeviceId;
    NvU32 SubClockId;
    NvRmFreqKHz MinKHz;
    NvRmFreqKHz MaxKHzList[NVRM_VOLTAGE_STEPS];
} NvRmScaledClkLimits;

/**
 * Combines maximum limits for modules depended on SoC SKU
 */
typedef struct NvRmSKUedLimitsRec
{
    NvRmFreqKHz CpuMaxKHz;
    NvRmFreqKHz AvpMaxKHz;
    NvRmFreqKHz VdeMaxKHz;
    NvRmFreqKHz McMaxKHz;
    NvRmFreqKHz Emc2xMaxKHz;
    NvRmFreqKHz TDMaxKHz;
    NvRmFreqKHz DisplayAPixelMaxKHz;
    NvRmFreqKHz DisplayBPixelMaxKHz;
    NvRmMilliVolts NominalCoreMv;   // for common core rail
    NvRmMilliVolts NominalCpuMv;    // for dedicated CPU rail
} NvRmSKUedLimits;

/**
 * Combines SoC frequency/voltage shmoo data
 * (includes data for CPU on the common core rail)
 */
typedef struct NvRmSocShmooRec
{
    const NvU32* ShmooVoltages;
    NvU32 ShmooVmaxIndex;

    const NvRmScaledClkLimits* ScaledLimitsList;
    NvU32 ScaledLimitsListSize;

    const NvRmSKUedLimits* pSKUedLimits;

    const NvRmOscDoublerConfig* OscDoublerCfgList;
    NvU32 OscDoublerCfgListSize;

    NvU32 DqsibOffset;
    NvRmMilliVolts SvopLowVoltage;
    NvU32 SvopLowSetting;
    NvU32 SvopHighSetting;
} NvRmSocShmoo;

/**
 * Combines frequency/voltage shmoo data for CPU on the dedicated voltage rail
 * (separated from common SoC core rail)
 */
typedef struct NvRmCpuShmooRec
{
    const NvU32* ShmooVoltages;
    NvU32 ShmooVmaxIndex;

    const NvRmScaledClkLimits* pScaledCpuLimits;
} NvRmCpuShmoo;

/**
 * Combines chip SKU and process corner records with shmoo data
 */
typedef struct NvRmChipFlavorRec
{
    NvU16 sku;

    NvU16 corner;
    const NvRmSocShmoo* pSocShmoo; // shmoo core rail (may include CPU)

    NvU16 CpuCorner;
    const NvRmCpuShmoo* pCpuShmoo; // shmoo dedicated CPU rail (NULL if none)
} NvRmChipFlavor;

/**
 * Combines module clock frequency limits
 */
typedef struct NvRmModuleClockLimitsRec
{
    NvRmFreqKHz MinKHz;
    NvRmFreqKHz MaxKHz;
} NvRmModuleClockLimits;

/**
 * Initializes module clock limits table.
 * 
 * @param hRmDevice The RM device handle. 
 * 
 * @return A pointer to the module clock limits table
 */
const NvRmModuleClockLimits*
NvRmPrivClockLimitsInit(NvRmDeviceHandle hRmDevice);

/**
 * Gets list of maximum frequencies for the specified module clock in
 * ascending order of scaling voltage levels.
 * 
 * @param hRmDevice The RM device handle.
 * @param Module  The targeted module ID.
 * @param pListSize A pointer to a variable filled with list size (i.e.,
 *  number of scaling voltage levels)
 * 
 * @return Pointer to the frequencies list (NULL if the module is not present,
 *  or the list does not exist)
 */
const NvRmFreqKHz*
NvRmPrivModuleVscaleGetMaxKHzList(
    NvRmDeviceHandle hRmDevice,
    NvRmModuleID Module,
    NvU32* pListSize);

/**
 * Gets core voltage level required for operation of the specified module
 * at the specified frequency.
 * 
 * @param hRmDevice The RM device handle.
 * @param Module  The targeted module ID.
 * @param FreqKHz The trageted module frequency in kHz.
 * 
 * @return Core voltage level in mV.
 */
NvRmMilliVolts
NvRmPrivModuleVscaleGetMV(
    NvRmDeviceHandle hRmDevice,
    NvRmModuleID Module,
    NvRmFreqKHz FreqKHz);

/**
 * Gets minimum core voltage level required for operation of all non-DFS
 * modules at current frequencies.
 * 
 * @param hRmDevice The RM device handle.
 * 
 * @return Core voltage level in mV.
 */
NvRmMilliVolts
NvRmPrivModulesGetOperationalMV(NvRmDeviceHandle hRmDevice);

/**
 * Gets minimum core voltage level required to use module clock source with
 * specified frequency.
 * 
 * @param hRmDevice The RM device handle.
 * 
 * @return Core voltage level in mV.
 */
NvRmMilliVolts
NvRmPrivSourceVscaleGetMV(NvRmDeviceHandle hRmDevice, NvRmFreqKHz FreqKHz);

/**
 * Gets SoC nominal core voltage.
 * 
 * @param hRmDevice The RM device handle.
 * 
 * @return Nominal core voltage in mV.
 */
NvRmMilliVolts
NvRmPrivGetNominalMV(NvRmDeviceHandle hRmDevice);

/**
 * Gets number of delay taps for Oscillator Doubler.
 * 
 * @param hRmDevice The RM device handle.
 * @param OscKHz Oscillator (main) frequency in KHz.
 * @param pTaps A pointer to the variable, filled with number of delay taps.
 * 
 * @return NvSuccess if the specified oscillator frequency is supported, and
 * NvError_NotSupported, otherwise.
 */
NvError
NvRmPrivGetOscDoublerTaps(
    NvRmDeviceHandle hRmDevice,
    NvRmFreqKHz OscKHz,
    NvU32* pTaps);

/**
 * Gets RAM SVOP low voltage parameters.
 * 
 * @param hRmDevice The RM device handle.
 * @param pSvopLowMv A pointer to a variable filled with SVOP low voltage
 *  threshold in mv.
 * @param pSvopLvSetting A pointer to a variable filled with SVOP low voltage
 *  settings.
 * @param pSvopHvSetting A pointer to a variable filled with SVOP high voltage
 *  settings.
 */
void
NvRmPrivGetSvopParameters(
    NvRmDeviceHandle hRmDevice,
    NvRmMilliVolts* pSvopLowMv,
    NvU32* pSvopLvSetting,
    NvU32* pSvopHvSetting);

/**
 * Gets 32-bit offset to ODM EMC DQSIB settings.
 * 
 * @param hRmDevice The RM device handle.
 * 
 * @return DQSIB offset.
 */
NvU32
NvRmPrivGetEmcDqsibOffset(NvRmDeviceHandle hRmDevice);

/**
 * Verifies if SoC has dedicated CPU voltage rail.
 * 
 * @param hRmDevice The RM device handle.
 * 
 * @return NV_TRUE if SoC has dedicated CPU voltage rail,
 *  and NV_FALSE if CPU is on common SoC core rail.
 */
NvBool NvRmPrivIsCpuRailDedicated(NvRmDeviceHandle hRmDevice);

/**
 * Initializes SoC characterization data base
 * 
 * @param hRmDevice The RM device handle.
 * @param pChipFlavor a pointer to the chip "flavor" structure
 *  that this function fills in
 * 
 * @return NvSuccess if completed successfully, or NvError_NotSupported,
 *  otherwise.
 */
NvError
NvRmPrivChipShmooDataInit(
    NvRmDeviceHandle hRmDevice,
    NvRmChipFlavor* pChipFlavor);

#ifdef __cplusplus
}
#endif  /* __cplusplus */

#endif  // INCLUDED_NVRM_CLOCKS_LIMITS_PRIVATE_H