summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/include/nvodm_tmon.h
blob: ebe90f2b7079e904e83b29a909b24a25775889d4 (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
/*
 * Copyright (c) 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.
 *
 */

/** 
 * @file
 * <b>NVIDIA Tegra ODM Kit:
 *         Temperature Monitor Interface</b>
 *
 * @b Description: Defines the ODM interface for Temperature Monitor (TMON).
 * 
 */

#ifndef INCLUDED_NVODM_TMON_H
#define INCLUDED_NVODM_TMON_H

#include "nvcommon.h"
#include "nvodm_services.h"

#if defined(__cplusplus)
extern "C"
{
#endif

/**
 * @defgroup nvodm_tmon Temperature Monitor Adaptation Interface 
 *   
 * This is the temperature monitor (TMON) ODM adaptation interface, which
 * handles the abstraction of external devices monitoring temperature zones
 * on NVIDIA SoC based platforms. For the clients of this API, each zone has
 * its own monitoring device. Dependencies introduced by multi-channel devices
 * capable of monitoring several zones are resolved inside the implementation
 * layer.
 * 
 * @ingroup nvodm_adaptation
 * @{
 */

/**
 * Defines an opaque handle for TMON device.
 */
typedef struct NvOdmTmonDeviceRec *NvOdmTmonDeviceHandle;

/**
 * Defines an opaque handle to the TMON interrupt interface.
 */
typedef struct NvOdmTmonIntrRec *NvOdmTmonIntrHandle;

/**
 * Defines temperature zones.
 */
typedef enum
{
    /// Specifies ambient temperature zone.
    NvOdmTmonZoneID_Ambient = 1,

    /// Specifies SoC core temperature zone.
    NvOdmTmonZoneID_Core,

    NvOdmTmonZoneID_Num,
    /// Ignore -- Forces compilers to make 32-bit enums.
    NvOdmTmonZoneID_Force32 = 0x7FFFFFFFUL
} NvOdmTmonZoneID;

/**
 * Defines temperature monitoring configuration parameters.
 */
typedef enum
{
    /// Identifies temperature sampling interval in ms.
    NvOdmTmonConfigParam_SampleMs = 1,

    /// Identifies High temperature boundary for TMON out of limit
    ///  interrupt (in degrees C).
    NvOdmTmonConfigParam_IntrLimitHigh,

    /// Identifies Low temperature boundary for TMON out of limit
    ///  interrupt (in degrees C).
    NvOdmTmonConfigParam_IntrLimitLow,

    /// Identifies temperature threshold for TMON comparator that
    ///  controls h/w critical shutdown mechanism (in degrees C).
    NvOdmTmonConfigParam_HwLimitCrit,

    NvOdmTmonConfigParam_Num,
    /// Ignore -- Forces compilers to make 32-bit enums.
    NvOdmTmonConfigParam_Force32 = 0x7FFFFFFFUL
} NvOdmTmonConfigParam;

/// Special value for configuration parameters.
#define ODM_TMON_PARAMETER_UNSPECIFIED (0x7FFFFFFF)

/**
 * Holds configuration parameter capabilities.
 */
typedef struct NvOdmTmonParameterCapsRec
{ 
    /// Specifies maximum parameter value (units depend on the parameter).
    NvS32 MaxValue;

    /// Specifies minimum parameter value (units depend on the parameter).
    NvS32 MinValue;

    /// Specifies ODM protection attribute; if \c NV_TRUE TMON ODM Kit would
    ///  not allow to change the parameter.
    NvBool OdmProtected;
} NvOdmTmonParameterCaps;

/**
 * Holds temperature monitoring device capabilities.
 */
typedef struct NvOdmTmonCapabilitiesRec
{ 
    /// Specifies maximum temperature limit for TMON operations (in degrees C).
    NvS32 Tmax;

    /// Specifies minimum temperature limit for TMON operations (in degrees C).
    NvS32 Tmin;

    /// Specifies support for TMON out of limit interrupt.
    NvBool IntrSupported;

    /// Specifies support for TMON hardware critical shutdown mechanism.
    NvBool HwCriticalSupported;

    /// Specifies support for TMON hardware auto-cooling mechanism (e.g., fan).
    NvBool HwCoolingSupported;
} NvOdmTmonCapabilities;


/**
 * Gets a handle to the TMON in the specified zone.
 *
 * @param ZoneId The targeted temperature zone.
 * 
 * @return TMON handle, NULL if zone is not monitored.
 */
NvOdmTmonDeviceHandle
NvOdmTmonDeviceOpen(NvOdmTmonZoneID ZoneId);

/**
 * Closes the TMON handle. 
 *
 * @param hTmon The TMON handle to be closed.
 *  If NULL, this API has no effect.
 */
void NvOdmTmonDeviceClose(NvOdmTmonDeviceHandle hTmon);

/**
 * Gets TMON device capabilities.
 *
 * @param hTmon A handle to the TMON device.
 * @param pCaps A pointer to the TMON device capabilities returned by the ODM.
 */
void
NvOdmTmonCapabilitiesGet(
    NvOdmTmonDeviceHandle hTmon,
    NvOdmTmonCapabilities* pCaps);

/**
 * Gets TMON configuration parameter capabilities.
 *
 * @param hTmon A handle to the TMON device.
 * @param ParamId The targeted parameter. 
 * @param pCaps A pointer to the targeted parameter capabilities
 *  returned by the ODM.
 * 
 *  Special value ::ODM_TMON_PARAMETER_UNSPECIFIED is returned as maximum and
 *  minimum value in capabilities structure if the targeted parameter is not
 *  supported.
 */
void
NvOdmTmonParameterCapsGet(
    NvOdmTmonDeviceHandle hTmon,
    NvOdmTmonConfigParam ParamId,
    NvOdmTmonParameterCaps* pCaps);

/**
 * Gets current zone temperature.
 *
 * @param hTmon A handle to the TMON device.
 * @param pDegreesC A pointer to the zone temperature (in degrees C)
 *  returned by the ODM.
 * 
 * @return NV_TRUE if successful, or NV_FALSE otherwise.
 */
NvBool
NvOdmTmonTemperatureGet(
    NvOdmTmonDeviceHandle hTmon,
    NvS32* pDegreesC);

/**
 * Configures specified TMON parameter for the temperature zone.
 *
 * @param hTmon A handle to the TMON device.
 * @param ParamId The targeted parameter to be updated. 
 * @param pSetting A pointer to a variable with parameter settings.
 *  On entry, specifies new requested settings, on exit, actually configured
 *  settings as the best approximation of the request.
 * 
 *  The requested setting is clipped to the maximum/minimum values for the
 *  respective parameter. If special value ::ODM_TMON_PARAMETER_UNSPECIFIED is
 *  specified on entry, current parameter value is preserved and retrieved on
 *  exit. If special value \c ODM_TMON_PARAMETER_UNSPECIFIED is returned on exit,
 *  the targeted parameter is not supported for the given zone.
 * 
 * @return NV_TRUE if successful, or NV_FALSE otherwise
 */
NvBool
NvOdmTmonParameterConfig(
    NvOdmTmonDeviceHandle hTmon,
    NvOdmTmonConfigParam ParamId,
    NvS32* pSetting);

/**
 * Suspends temperature zone monitoring.
 * 
 * @param hTmon A handle to the TMON device.
 * 
 * @return NV_TRUE if successful, or NV_FALSE otherwise.
 */
NvBool NvOdmTmonSuspend(NvOdmTmonDeviceHandle hTmon);

/**
 * Resumes temperature zone monitoring.
 * 
 * @param hTmon A handle to the TMON device.
 * 
 * @return NV_TRUE if successful, or NV_FALSE otherwise.
 */
NvBool NvOdmTmonResume(NvOdmTmonDeviceHandle hTmon);

/**
 * Registers for TMON out of limit interrupt.
 * 
 * @param hTmon A handle to the TMON device.
 * @param Callback The callback function that is called when TMON
 *  interrupt triggers.
 * @param arg The argument passed to the callback when it is
 *  invoked by TMON IST.
 * 
 * @return TMON interrupt handle, NULL if failed to register.
 */
NvOdmTmonIntrHandle
NvOdmTmonIntrRegister(
    NvOdmTmonDeviceHandle hTmon,
    NvOdmInterruptHandler Callback,
    void* arg);

/**
 * Unregisters TMON interrupt.
 * 
 * @param hTmon A handle to the TMON device.
 * @param hIntr A TMON interrupt handle.
 *  If NULL, this API has no effect.
 */
void
NvOdmTmonIntrUnregister(
    NvOdmTmonDeviceHandle hTmon,
    NvOdmTmonIntrHandle hIntr);

#if defined(__cplusplus)
}
#endif

/** @} */

#endif // INCLUDED_NVODM_TMON_H