Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Side by Side Diff: arch/arm/mach-tegra/nv/include/nvrm_i2c.h

Issue 3256004: [ARM] tegra: add nvos/nvrm/nvmap drivers (Closed) Base URL: ssh://git@gitrw.chromium.org/kernel.git
Patch Set: remove ap15 headers Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2009 NVIDIA Corporation.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * Neither the name of the NVIDIA Corporation nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32
33 #ifndef INCLUDED_nvrm_i2c_H
34 #define INCLUDED_nvrm_i2c_H
35
36
37 #if defined(__cplusplus)
38 extern "C"
39 {
40 #endif
41
42 #include "nvrm_pinmux.h"
43 #include "nvrm_module.h"
44 #include "nvrm_init.h"
45
46 #include "nvos.h"
47 #include "nvcommon.h"
48
49 /**
50 * NvRmI2cHandle is an opaque handle to the NvRmI2cStructRec interface
51 */
52
53 typedef struct NvRmI2cRec *NvRmI2cHandle;
54
55 /**
56 * @brief Defines the I2C capability structure. It contains the
57 * capabilities/limitations (like maximum bytes transferred,
58 * supported clock speed) of the hardware.
59 */
60
61 typedef struct NvRmI2cCapabilitiesRec
62 {
63
64 /**
65 * Maximum number of packet length in bytes which can be transferred
66 * between start and the stop pulses.
67 */
68 NvU32 MaximumPacketLengthInBytes;
69
70 /// Maximum speed which I2C controller can support.
71 NvU32 MaximumClockSpeed;
72
73 /// Minimum speed which I2C controller can support.
74 NvU32 MinimumClockSpeed;
75 } NvRmI2cCapabilities;
76
77 /**
78 * @brief Initializes and opens the i2c channel. This function allocates the
79 * handle for the i2c channel and provides it to the client.
80 *
81 * Assert encountered in debug mode if passed parameter is invalid.
82 *
83 * @param hDevice Handle to the Rm device which is required by Rm to acquire
84 * the resources from RM.
85 * @param IoModule The IO module to set, it is either NvOdmIoModule_I2c
86 * or NvOdmIoModule_I2c_Pmu
87 * @param instance Instance of the i2c driver to be opened.
88 * @param phI2c Points to the location where the I2C handle shall be stored.
89 *
90 * @retval NvSuccess Indicates that the I2c channel has successfully opened.
91 * @retval NvError_InsufficientMemory Indicates that function fails to allocate
92 * the memory.
93 * @retval NvError_NotInitialized Indicates the I2c initialization failed.
94 */
95
96 NvError NvRmI2cOpen(
97 NvRmDeviceHandle hDevice,
98 NvU32 IoModule,
99 NvU32 instance,
100 NvRmI2cHandle * phI2c );
101
102 /**
103 * @brief Closes the i2c channel. This function frees the memory allocated for
104 * the i2c handle for the i2c channel.
105 * This function de-initializes the i2c channel. This API never fails.
106 *
107 * @param hI2c A handle from NvRmI2cOpen(). If hI2c is NULL, this API does
108 * nothing.
109 */
110
111 void NvRmI2cClose(
112 NvRmI2cHandle hI2c );
113
114 // Maximum number of bytes that can be sent between the i2c start and stop condi tions
115 #define NVRM_I2C_PACKETSIZE (8)
116
117 // Maximum number of bytes that can be sent between the i2c start and repeat sta rt condition.
118 #define NVRM_I2C_PACKETSIZE_WITH_NOSTOP (4)
119
120 /// Indicates a I2C read transaction.
121 #define NVRM_I2C_READ (0x1)
122
123 /// Indicates that it is a write transaction
124 #define NVRM_I2C_WRITE (0x2)
125
126 /// Indicates that there is no STOP following this transaction. This also implie s
127 /// that there is always one more transaction following a transaction with
128 /// NVRM_I2C_NOSTOP attribute.
129 #define NVRM_I2C_NOSTOP (0x4)
130
131 // Some devices doesn't support ACK. By, setting this flag, master will not
132 // expect the generation of ACK from the device.
133 #define NVRM_I2C_NOACK (0x8)
134
135 // Software I2C using GPIO. Doesn't use the hardware controllers. This path
136 // should be used only for testing.
137 #define NVRM_I2C_SOFTWARE_CONTROLLER (0x10)
138
139 typedef struct NvRmI2cTransactionInfoRec
140 {
141
142 /// Flags to indicate the transaction details, like write/read or read
143 /// without a stop or write without a stop.
144 NvU32 Flags;
145
146 /// Number of bytes to be transferred.
147 NvU32 NumBytes;
148
149 /// I2C slave device address
150 NvU32 Address;
151
152 /// Indicates that the address is a 10-bit address.
153 NvBool Is10BitAddress;
154 } NvRmI2cTransactionInfo;
155
156 /**
157 * @brief Does multiple I2C transactions. Each transaction can be a read or writ e.
158 *
159 * AP15 I2C controller has the following limitations:
160 * - Any read/write transaction is limited to NVRM_I2C_PACKETSIZE
161 * - All transactions will be terminated by STOP unless NVRM_I2C_NOSTOP flag
162 * is specified. Specifying NVRM_I2C_NOSTOP means, *next* transaction will star t
163 * with a repeat start, with NO stop between transactions.
164 * - When NVRM_I2C_NOSTOP is specified for a transaction -
165 * 1. Next transaction will start with repeat start.
166 * 2. Next transaction is mandatory.
167 * 3. Next Next transaction cannot have NVRM_I2C_NOSTOP flag set. i.e no
168 * back to back repeat starts.
169 * 4. Current and next transactions are limited to size
170 * NVRM_I2C_PACKETSIZE_WITH_NOSTOP.
171 * 5. Finally, current transactions and next Transaction should be of same
172 * size.
173 *
174 * This imposes some limitations on how the hardware can be used. However, the
175 * API itself doesn't have any limitations. If the HW cannot be used, it falls
176 * back to GPIO based I2C. Gpio I2C bypasses Hw controller and bit bangs the
177 * SDA/SCL lines of I2C.
178 *
179 * @param hI2c Handle to the I2C channel.
180 * @param I2cPinMap for I2C controllers which are being multiplexed across
181 * multiple pin mux configurations, this specifies which pin mux configur ation
182 * should be used for the transaction. Must be 0 when the ODM pin mux qu ery
183 * specifies a non-multiplexed configuration for the controller.
184 * @param WaitTimeoutInMilliSeconds Timeout for the transcation.
185 * @param ClockSpeedKHz Clock speed in KHz.
186 * @param Data Continous stream of data
187 * @param DataLength Length of the data stream
188 * @param Transcations Pointer to the NvRmI2cTransactionInfo structure
189 * @param NumOfTransactions Number of transcations
190 *
191 *
192 * @retval NvSuccess Indicates the operation succeeded.
193 * @retval NvError_NotSupported Indicates assumption on parameter values violate d.
194 * @retval NvError_InvalidState Indicates that the last read call is not
195 * completed.
196 * @retval NvError_ControllerBusy Indicates controller is presently busy with an
197 * i2c transaction.
198 * @retval NvError_InvalidDeviceAddress Indicates that the slave device address
199 * is invalid
200 */
201
202 NvError NvRmI2cTransaction(
203 NvRmI2cHandle hI2c,
204 NvU32 I2cPinMap,
205 NvU32 WaitTimeoutInMilliSeconds,
206 NvU32 ClockSpeedKHz,
207 NvU8 * Data,
208 NvU32 DataLen,
209 NvRmI2cTransactionInfo * Transaction,
210 NvU32 NumOfTransactions );
211
212 #if defined(__cplusplus)
213 }
214 #endif
215
216 #endif
OLDNEW
« no previous file with comments | « arch/arm/mach-tegra/nv/include/nvrm_hardware_access.h ('k') | arch/arm/mach-tegra/nv/include/nvrm_init.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698