summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/nvrm/core/ap20/ap20rm_clocks.h
blob: f86b63d7bf1a7bc0d96ff2b2e02fd5fb2198ae44 (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
/*
 * 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_AP20RM_CLOCKS_H
#define INCLUDED_AP20RM_CLOCKS_H

#include "nvrm_clocks.h"
#include "nvodm_query_memc.h"

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

extern const NvRmModuleClockInfo g_Ap20ModuleClockTable[];
extern const NvU32 g_Ap20ModuleClockTableSize;

// Minimum PLLX VCO frequency for reliable operation of DCC circuit
#define NVRM_PLLX_DCC_VCO_MIN (600000)

// Default PLLC output frequency
#define NVRM_PLLC_DEFAULT_FREQ_KHZ (600000)

// Defines number of EMC frequency steps for DFS 
#define NVRM_AP20_DFS_EMC_FREQ_STEPS (8)

// Defines maximum APB frequency (bug 559823)
#define NVRM_AP20_APB_MAX_KHZ (125000)

// Defines graphics Host frequency
#define NVRM_AP20_HOST_KHZ (108000)

// Defines main clock doubler support
#define NVRM_AP20_USE_OSC_DOUBLER (0)

/**
 * Defines frequency steps derived from PLLP0 fixed output to be used as System
 * clock source frequency. The frequency specified in kHz, and it will be rounded
 * up to the closest divider output. 
 */
#define NVRM_AP20_PLLP_POLICY_SYSTEM_CLOCK \
    PLLP_POLICY_ENTRY(24000)   /* PLLP divider 16, output frequency  24,000kHz */ \
    PLLP_POLICY_ENTRY(54000)   /* PLLP divider  6, output frequency  54,000kHz */ \
    PLLP_POLICY_ENTRY(72000)   /* PLLP divider  4, output frequency  72,000kHz */ \
    PLLP_POLICY_ENTRY(108000)  /* PLLP divider  2, output frequency 108,000kHz */ \
    PLLP_POLICY_ENTRY(216000)  /* PLLP divider  0, output frequency 216,000kHz */

/**
 * Defines frequency steps derived from PLLP0 fixed output to be used as CPU
 * clock source frequency. The frequency specified in kHz, and it will be rounded
 * up to the closest divider output. On AP20 we will use only main PLLP0 output,
 * and no divided down steps, so that PLLP_OUT4 divider output is available as
 * a source for external devices.
 */
#define NVRM_AP20_PLLP_POLICY_CPU_CLOCK \
    PLLP_POLICY_ENTRY(216000)  /* PLLP divider  0, output frequency 216,000kHz */

// On AP20 PLLP4 is used as 24MHz source for external devices. This setting will
// overwrite initial PLLP4 frequency after boot/resume from LP0.
#define NVRM_AP20_FIXED_PLLP4_SETTING (16)   /* 216 / (1 + 16/2) = 24 */

/**
 * Combines EMC 2x frequency and the respective set of EMC timing parameters for
 * pre-defined EMC configurations (DDR clock is running at EMC 1x frequency)
 */
typedef struct NvRmAp20EmcTimingConfigRec
{
    NvRmFreqKHz Emc2xKHz;
    const NvOdmSdramControllerConfigAdv* pOdmEmcConfig;
    NvU32 Emc2xClockSource;
    NvU32 Emc2xDivisor;
    NvU32 Emc2xUndividedIndex;
    NvRmFreqKHz CpuLimitKHz;
} NvRmAp20EmcTimingConfig;

/*****************************************************************************/

/**
 * Enables/disables module clock.
 * 
 * @param hDevice The RM device handle.
 * @param ModuleId Combined module ID and instance of the target module.
 * @param ClockState Target clock state.
 */
void
Ap20EnableModuleClock(
    NvRmDeviceHandle hDevice,
    NvRmModuleID ModuleId,
    ModuleClockState ClockState);

// Separate API to control TVDAC clock independently of TVO
// (when TVDAC is used for CRT)  
void
Ap20EnableTvDacClock(
    NvRmDeviceHandle hDevice,
    ModuleClockState ClockState);

/**
 * Resets module (assert/delay/deassert reset signal) if the hold paramter is
 * NV_FLASE. If the hols paramter is NV_TRUE, just assert the reset and return.
 * 
 * @param hDevice The RM device handle.
 * @param Module Combined module ID and instance of the target module.
 * @param hold      To hold or relese the reset.
 */
void 
AP20ModuleReset(NvRmDeviceHandle hDevice, NvRmModuleID ModuleId, NvBool hold);

/**
 * Resets 2D module.
 * 
 * @param hRmDevice The RM device handle. 
 */
void
NvRmPrivAp20Reset2D(NvRmDeviceHandle hRmDevice);

/**
 * Initializes clock source table.
 * 
 * @return Pointer to the clock sources descriptor table.
 */
NvRmClockSourceInfo* NvRmPrivAp20ClockSourceTableInit(void);

/**
 * Initializes PLL references table.
 * 
 * @param pPllReferencesTable A pointer to a pointer which this function sets
 *  to the PLL reference table base. 
 * @param pPllReferencesTableSize A pointer to a variable which this function
 *  sets to the PLL reference table size.
 */
void
NvRmPrivAp20PllReferenceTableInit(
    NvRmPllReference** pPllReferencesTable,
    NvU32* pPllReferencesTableSize);

/**
 * Controls PLLE.
 * 
 * @param hRmDevice The RM device handle.
 * @param Enable Specifies if PLLE should be enabled or disabled (PLLE power
 *  management is not supported, and it is never disabled as of now).
 */
void NvRmPrivAp20PllEControl(NvRmDeviceHandle hRmDevice, NvBool Enable);

/**
 * Initializes configuration structures and tables for DVFS controlled clocks.
 * 
 * @param hRmDevice The RM device handle. 
 */
void
NvRmPrivAp20ScaledClockConfigInit(NvRmDeviceHandle hRmDevice);

/**
 * Configures oscillator (main) clock doubler.
 * 
 * @param hRmDevice The RM device handle.
 * @param OscKHz Oscillator (main) clock frequency in kHz.
 * 
 * @return NvSuccess if the specified oscillator frequency is supported, and
 * NvError_NotSupported, otherwise.
 */
NvError
NvRmPrivAp20OscDoublerConfigure(
    NvRmDeviceHandle hRmDevice,
    NvRmFreqKHz OscKHz);

/**
 * Configures maximum core and memory clocks.
 * 
 * @param hRmDevice The RM device handle.
 */
void
NvRmPrivAp20FastClockConfig(NvRmDeviceHandle hRmDevice);

/**
 * Gets module frequency synchronized with EMC speed.
 * 
 * @param hRmDevice The RM device handle.
 * @param Module The target module ID.
 * 
 * @return Module frequency in kHz.
 */
NvRmFreqKHz NvRmPrivAp20GetEmcSyncFreq(
    NvRmDeviceHandle hRmDevice,
    NvRmModuleID Module);

/**
 * Clips EMC frequency high limit to one of the fixed DFS EMC configurations,
 * and if necessary adjust CPU high limit respectively.
 * 
 * @param hRmDevice The RM device handle.
 * @param pCpuHighKHz A pointer to the variable, which contains CPU frequency
 *  high limit in KHz (on entry - requested limit, on exit - clipped limit)
 * @param pEmcHighKHz A pointer to the variable, which contains EMC frequency
 *  high limit in KHz (on entry - requested limit, on exit - clipped limit)
 */
void
NvRmPrivAp20ClipCpuEmcHighLimits(
    NvRmDeviceHandle hRmDevice,
    NvRmFreqKHz* pCpuHighKHz,
    NvRmFreqKHz* pEmcHighKHz);

/**
 * Gets frequencies of DFS controlled clocks
 * 
 * @param hRmDevice The RM device handle.
 * @param pDfsKHz Output storage pointer for DFS clock frequencies structure
 *  (all frequencies returned in kHz).
 */
void
NvRmPrivAp20DfsClockFreqGet(
    NvRmDeviceHandle hRmDevice,
    NvRmDfsFrequencies* pDfsKHz);

/**
 * Configures DFS controlled clocks
 * 
 * @param hRmDevice The RM device handle.
 * @param pMaxKHz Pointer to the DFS clock frequencies upper limits
 * @param pDfsKHz Pointer to the target DFS frequencies structure on entry;
 *  updated with actual DFS clock frequencies on exit.
 * 
 * @return NV_TRUE if clock configuration is completed; NV_FALSE if this
 *  function has to be called again to complete configuration.
 */
NvBool
NvRmPrivAp20DfsClockConfigure(
    NvRmDeviceHandle hRmDevice,
    const NvRmDfsFrequencies* pMaxKHz,
    NvRmDfsFrequencies* pDfsKHz);

/**
 * Gets DFS domains frequencies to be set for suspend (LP1) entry/exit.
 *
 * @param hRmDevice The RM device handle.
 * @param TargetMv Targeted suspend core voltage in mV.
 * @param pDfsKHz Pointer to a structure filled in by this function with
 *  output clock frequencies.
 */
void
NvRmPrivAp20DfsSuspendFreqGet(
    NvRmDeviceHandle hRmDevice,
    NvRmMilliVolts TargetMv,
    NvRmDfsFrequencies* pDfsKHz);

/**
 * Configures the sdio tap delay
 * 
 * @param hRmDevice The RM device handle.
 * @param Module The target module ID.
 * @param ClkSourceOffset Clock source offset.
 * @param ConfiguredFreqKHz The configured frequency in KHz.
 * 
 */
void
NvRmPrivAp20SdioTapDelayConfigure(
    NvRmDeviceHandle hRmDevice,
    NvRmModuleID ModuleId,
    NvU32 ClkSourceOffset,
    NvRmFreqKHz ConfiguredFreqKHz);

#ifdef __cplusplus
}
#endif  /* __cplusplus */

#endif  // INCLUDED_AP20RM_CLOCKS_H