summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/include/nvddk_usbphy.h
blob: 4dd8a2a63aac08074e974caa5c647d78b9b0759d (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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/*
 * 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
 * @brief <b>NVIDIA Driver Development Kit:
 *           NvDDK USB PHY functions</b>
 *
 * @b Description: Defines USB PHY private functions
 *
 */

#ifndef INCLUDED_NVDDK_USBPHY_H
#define INCLUDED_NVDDK_USBPHY_H

#include "nvcommon.h"
#include "nvrm_init.h"
#include "nvos.h"


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


/**
 * Opaque handle to a Usb phy device.
 */
typedef struct NvDdkUsbPhyRec *NvDdkUsbPhyHandle;


/**
 * Enum defining USB Phy-specific IOCTL types.
 */
typedef enum
{
    /**
     * Gets the USB VBUS status.
     *
     * @par Inputs:
     * None.
     *
     * @par Outputs:
     * ::NvDdkUsbPhyIoctl_VBusStatusOutputArgs.
     *
     * @retval NvError_Success 
     * @retval NvError_BadParameter Output Argument is invalid.
     */
    NvDdkUsbPhyIoctlType_VBusStatus,

    /**
     * Configures the VBUS Interrupt.
     *
     * @par Inputs:
     * ::NvDdkUsbPhyIoctl_VBusInterruptInputArgs.
     *
     * @par Outputs:
     * None.
     *
     * @retval NvError_Success 
     * @retval NvError_BadParameter Input Argument is invalid.
     */
    NvDdkUsbPhyIoctlType_VBusInterrupt,

    /**
     * Gets the USB ID pin status.
     *
     * @par Inputs:
     * None.
     *
     * @par Outputs:
     * ::NvDdkUsbPhyIoctl_IdPinStatusOutputArgs.
     *
     * @retval NvError_Success 
     * @retval NvError_BadParameter Output Argument is invalid.
     */
    NvDdkUsbPhyIoctlType_IdPinStatus,

    /**
     * Configures the USB Id pin Interrupt.
     *
     * @par Inputs:
     * ::NvDdkUsbPhyIoctl_IdPinInterruptInputArgs.
     *
     * @par Outputs:
     * None.
     *
     * @retval NvError_Success 
     * @retval NvError_BadParameter Input Argument is invalid.
     */
    NvDdkUsbPhyIoctlType_IdPinInterrupt,

    /**
     * Gets the USB Dedicated charger status.
     *
     * @par Inputs:
     * None.
     *
     * @par Outputs:
     * ::NvDdkUsbPhyIoctl_DedicatedChargerStatusOutputArgs.
     *
     * @retval NvError_Success 
     * @retval NvError_BadParameter Output Argument is invalid.
     */
    NvDdkUsbPhyIoctlType_DedicatedChargerStatus,

    /**
     * Configures the USB dedicated charger detection.
     *
     * @par Inputs:
     * ::NvDdkUsbPhyIoctl_DedicatedChargerDetectionInputArgs.
     *
     * @par Outputs:
     * None.
     *
     * @retval NvError_Success 
     * @retval NvError_BadParameter Input Argument is invalid.
     */
    NvDdkUsbPhyIoctlType_DedicatedChargerDetection,

     /**
     * Configures the Busy hints for the USB controller
     *
     * @par Inputs:
    * ::NvDdkUsbPhyIoctl_UsbBusyHintsOnOffInputArgs.
    *
     * @par Outputs:
     * None.
     *
     * @retval NvError_Success 
     * @retval NvError_BadParameter Input Argument is invalid.
     */
    NvDdkUsbPhyIoctlType_UsbBusyHintsOnOff,

    NvDdkUsbPhyIoctlType_Num,
    /**
     * Ignore -- Forces compilers to make 32-bit enums.
     */
    NvDdkUsbPhyIoctlType_Force32 = 0x7FFFFFFF
} NvDdkUsbPhyIoctlType;

/**
 * VBUS status IOCTL output arguments.
 */
typedef struct NvDdkUsbPhyIoctl_VBusStatusOutputArgsRec
{
    // VBUS status: If Set to NV_TRUE VBUS is detected else VBUS is not detected.
    NvBool VBusDetected;
} NvDdkUsbPhyIoctl_VBusStatusOutputArgs;

/**
 * VBUS Interrupt configuration IOCTL input arguments.
 */
typedef struct NvDdkUsbPhyIoctl_VBusInterruptInputArgsRec
{
    // VBUS Interrupt: If Set to NV_TRUE VBUS interrupt is enabled else disabled.
    NvBool EnableVBusInterrupt;
} NvDdkUsbPhyIoctl_VBusInterruptInputArgs;

/**
 * USB Id pin status IOCTL output arguments.
 */
typedef struct NvDdkUsbPhyIoctl_IdPinStatusOutputArgsRec
{
    // VBUS status: If Set to NV_TRUE Id pin is low else Id pin is high.
    NvBool IdPinSetToLow;
} NvDdkUsbPhyIoctl_IdPinStatusOutputArgs;

/*
 * USB Id pin Interrupt configuration IOCTL input arguments.
 */
typedef struct NvDdkUsbPhyIoctl_IdPinInterruptInputArgsRec
{
    // VBUS Interrupt: If Set to NV_TRUE Id pin interrupt is enabled else disabled.
    NvBool EnableIdPinInterrupt;
} NvDdkUsbPhyIoctl_IdPinInterruptInputArgs;


/**
 * USB dedicated charger status IOCTL output arguments.
 */
typedef struct NvDdkUsbPhyIoctl_DedicatedChargerStatusOutputArgsRec
{
    // Dedicated Charger status: If Set to NV_TRUE charger is detected else Id not detected.
    NvBool ChargerDetected;
} NvDdkUsbPhyIoctl_DedicatedChargerStatusOutputArgs;

/*
 * USB dedicated charger configuration IOCTL input arguments.
 */
typedef struct NvDdkUsbPhyIoctl_DedicatedChargerDetectionInputArgsRec
{
    // Charger Interrupt: If Set to NV_TRUE charger interrupt is enabled else disabled.
    NvBool EnableChargerInterrupt;
    // Charger detection: If set to NV_TRUE enables the charger detection else disables.
    NvBool EnableChargerDetection;
} NvDdkUsbPhyIoctl_DedicatedChargerDetectionInputArgs;



/**
 * USB busy hints configuration IOCTL input arguments.
 */
typedef struct NvDdkUsbPhyIoctl_UsbBusyHintsOnOffInputArgsRec
{
    // Busy hints on/off: If set to NV_TRUE enables the busy hintson else disables.
    NvBool OnOff;
    // Requested boost duration in milliseconds.
    // if BoostDurationMs = NV_WAIT_INFINITE, then busy hints will be on untill
    // busy hints are off. This is valid only if OnOff = NV_TRUE
    NvU32 BoostDurationMs;
} NvDdkUsbPhyIoctl_UsbBusyHintsOnOffInputArgs;

/**
 * Opens the Usb Phy, allocates the resources and initializes the phy.
 *
 * @param hRmDevice Handle to the Rm device, which is required to 
 * acquire the resources from RM.
 * @param Instance Instance of specific device.
 * @param hUsbPhy returns the USB phy handle.
 *
 * @retval NvSuccess
 * @retval NvError_Timeout If phy clock is not stable in expected time.
 */
NvError NvDdkUsbPhyOpen(
    NvRmDeviceHandle hRm, 
    NvU32 Instance, 
    NvDdkUsbPhyHandle *hUsbPhy);

/**
 * Power down the Phy safely and release all the resources allocated.
 *
 * @param hUsbPhy Handle acquired during the NvDdkUsbPhyOpen() call.
 *
 */
void NvDdkUsbPhyClose(NvDdkUsbPhyHandle hUsbPhy);

/**
 * Powers up the device. It could be taking out of low power mode or 
 * reinitializing.
 *
 * @param hUsbPhy Handle acquired during the NvDdkUsbPhyOpen() call.
 * @param IsHostMode indicates the host mode or not.
 * @param IsDpd  Deep sleep power up or not .
 *
 * @retval NvSuccess
 * @retval NvError_Timeout If phy clock is not stable in expected time.
 */
NvError NvDdkUsbPhyPowerUp(NvDdkUsbPhyHandle hUsbPhy, NvBool IsHostMode, NvBool IsDpd);

/**
 * Powers down the PHY. It could be low power mode or shutdown.
 *
 * @param hUsbPhy Handle acquired during the NvDdkUsbPhyOpen() call.
 * @param IsHostMode indicates the host mode or not.
 * @param IsDpd Handle Deep sleep power down or not .
 *
 * @retval NvSuccess
 */
NvError NvDdkUsbPhyPowerDown(NvDdkUsbPhyHandle hUsbPhy, NvBool IsHostMode, NvBool IsDpd);

/**
 * Perform an I/O control operation on the device.
 *
 * @param hBlockDev Handle acquired during the NvDdkXxxBlockDevOpen() call.
 * @param IoctlType Type of control operation to perform.
 * @param InputArgs A pointer to input arguments buffer.
 * @param OutputArgs A pointer to output arguments buffer.
 *
 * @retval NvError_Success IOCTL is successful.
 * @retval NvError_NotSupported \a Opcode is not recognized.
 * @retval NvError_InvalidParameter \a InputArgs or \a OutputArgs is
 *   incorrect.
 */
NvError NvDdkUsbPhyIoctl(
    NvDdkUsbPhyHandle hUsbPhy,
    NvDdkUsbPhyIoctlType IoctlType,
    const void *InputArgs,
    void *OutputArgs);

/**
 * Waits until Phy clock is stable.
 *
 * @param hUsbPhy Handle acquired during the NvDdkUsbPhyOpen() call.
 *
 * @retval NvSuccess If phy clock is stable.
 * @retval NvError_Timeout If phy clock is not stable in expected time.
 */
NvError NvDdkUsbPhyWaitForStableClock(NvDdkUsbPhyHandle hUsbPhy);

/**
 * Configures Prefetcher for USB.
 *
 * @param hUsbPhy Handle acquired during the NvDdkUsbPhyOpen() call.
 * @param Enable If NV_TRUE, prefetcher is enabled, else disabled.
 *
 */
void NvDdkUsbPhyMemoryPrefetch(NvDdkUsbPhyHandle hUsbPhy, NvBool Enable);

#if defined(__cplusplus)
}
#endif

/** @}*/
#endif // INCLUDED_NVDDK_USBPHY_H