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

Side by Side Diff: arch/arm/mach-tegra/nv/nvrm/dispatch/nvrm_i2c_dispatch.c

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 #define NV_IDL_IS_DISPATCH
34
35 #include "nvcommon.h"
36 #include "nvos.h"
37 #include "nvassert.h"
38 #include "nvreftrack.h"
39 #include "nvidlcmd.h"
40 #include "nvrm_i2c.h"
41
42 #define OFFSET( s, e ) (NvU32)(void *)(&(((s*)0)->e))
43
44
45 typedef struct NvRmI2cTransaction_in_t
46 {
47 NvU32 package_;
48 NvU32 function_;
49 NvRmI2cHandle hI2c;
50 NvU32 I2cPinMap;
51 NvU32 WaitTimeoutInMilliSeconds;
52 NvU32 ClockSpeedKHz;
53 NvU8 * Data;
54 NvU32 DataLen;
55 NvRmI2cTransactionInfo * Transaction;
56 NvU32 NumOfTransactions;
57 } NV_ALIGN(4) NvRmI2cTransaction_in;
58
59 typedef struct NvRmI2cTransaction_inout_t
60 {
61 NvU32 dummy_;
62 } NV_ALIGN(4) NvRmI2cTransaction_inout;
63
64 typedef struct NvRmI2cTransaction_out_t
65 {
66 NvError ret_;
67 } NV_ALIGN(4) NvRmI2cTransaction_out;
68
69 typedef struct NvRmI2cTransaction_params_t
70 {
71 NvRmI2cTransaction_in in;
72 NvRmI2cTransaction_inout inout;
73 NvRmI2cTransaction_out out;
74 } NvRmI2cTransaction_params;
75
76 typedef struct NvRmI2cClose_in_t
77 {
78 NvU32 package_;
79 NvU32 function_;
80 NvRmI2cHandle hI2c;
81 } NV_ALIGN(4) NvRmI2cClose_in;
82
83 typedef struct NvRmI2cClose_inout_t
84 {
85 NvU32 dummy_;
86 } NV_ALIGN(4) NvRmI2cClose_inout;
87
88 typedef struct NvRmI2cClose_out_t
89 {
90 NvU32 dummy_;
91 } NV_ALIGN(4) NvRmI2cClose_out;
92
93 typedef struct NvRmI2cClose_params_t
94 {
95 NvRmI2cClose_in in;
96 NvRmI2cClose_inout inout;
97 NvRmI2cClose_out out;
98 } NvRmI2cClose_params;
99
100 typedef struct NvRmI2cOpen_in_t
101 {
102 NvU32 package_;
103 NvU32 function_;
104 NvRmDeviceHandle hDevice;
105 NvU32 IoModule;
106 NvU32 instance;
107 } NV_ALIGN(4) NvRmI2cOpen_in;
108
109 typedef struct NvRmI2cOpen_inout_t
110 {
111 NvU32 dummy_;
112 } NV_ALIGN(4) NvRmI2cOpen_inout;
113
114 typedef struct NvRmI2cOpen_out_t
115 {
116 NvError ret_;
117 NvRmI2cHandle phI2c;
118 } NV_ALIGN(4) NvRmI2cOpen_out;
119
120 typedef struct NvRmI2cOpen_params_t
121 {
122 NvRmI2cOpen_in in;
123 NvRmI2cOpen_inout inout;
124 NvRmI2cOpen_out out;
125 } NvRmI2cOpen_params;
126
127 static NvError NvRmI2cTransaction_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
128 {
129 NvError err_ = NvSuccess;
130 NvRmI2cTransaction_in *p_in;
131 NvRmI2cTransaction_out *p_out;
132 NvU8 *Data = NULL;
133 NvRmI2cTransactionInfo *Transaction = NULL;
134
135 p_in = (NvRmI2cTransaction_in *)InBuffer;
136 p_out = (NvRmI2cTransaction_out *)((NvU8 *)OutBuffer + OFFSET(NvRmI2cTransac tion_params, out) - OFFSET(NvRmI2cTransaction_params, inout));
137
138 if( p_in->DataLen && p_in->Data )
139 {
140 Data = (NvU8 *)NvOsAlloc( p_in->DataLen * sizeof( NvU8 ) );
141 if( !Data )
142 {
143 err_ = NvError_InsufficientMemory;
144 goto clean;
145 }
146 if( p_in->Data )
147 {
148 err_ = NvOsCopyIn( Data, p_in->Data, p_in->DataLen * sizeof( NvU8 ) );
149 if( err_ != NvSuccess )
150 {
151 err_ = NvError_BadParameter;
152 goto clean;
153 }
154 }
155 }
156 if( p_in->NumOfTransactions && p_in->Transaction )
157 {
158 Transaction = (NvRmI2cTransactionInfo *)NvOsAlloc( p_in->NumOfTransacti ons * sizeof( NvRmI2cTransactionInfo ) );
159 if( !Transaction )
160 {
161 err_ = NvError_InsufficientMemory;
162 goto clean;
163 }
164 if( p_in->Transaction )
165 {
166 err_ = NvOsCopyIn( Transaction, p_in->Transaction, p_in->NumOfTransa ctions * sizeof( NvRmI2cTransactionInfo ) );
167 if( err_ != NvSuccess )
168 {
169 err_ = NvError_BadParameter;
170 goto clean;
171 }
172 }
173 }
174
175 p_out->ret_ = NvRmI2cTransaction( p_in->hI2c, p_in->I2cPinMap, p_in->WaitTim eoutInMilliSeconds, p_in->ClockSpeedKHz, Data, p_in->DataLen, Transaction, p_in- >NumOfTransactions );
176
177 if(p_in->Data && Data)
178 {
179 err_ = NvOsCopyOut( p_in->Data, Data, p_in->DataLen * sizeof( NvU8 ) );
180 if( err_ != NvSuccess )
181 {
182 err_ = NvError_BadParameter;
183 }
184 }
185 clean:
186 NvOsFree( Data );
187 NvOsFree( Transaction );
188 return err_;
189 }
190
191 static NvError NvRmI2cClose_dispatch_( void *InBuffer, NvU32 InSize, void *OutBu ffer, NvU32 OutSize, NvDispatchCtx* Ctx )
192 {
193 NvError err_ = NvSuccess;
194 NvRmI2cClose_in *p_in;
195
196 p_in = (NvRmI2cClose_in *)InBuffer;
197
198
199 NvRmI2cClose( p_in->hI2c );
200
201 return err_;
202 }
203
204 static NvError NvRmI2cOpen_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuf fer, NvU32 OutSize, NvDispatchCtx* Ctx )
205 {
206 NvError err_ = NvSuccess;
207 NvRmI2cOpen_in *p_in;
208 NvRmI2cOpen_out *p_out;
209
210 p_in = (NvRmI2cOpen_in *)InBuffer;
211 p_out = (NvRmI2cOpen_out *)((NvU8 *)OutBuffer + OFFSET(NvRmI2cOpen_params, o ut) - OFFSET(NvRmI2cOpen_params, inout));
212
213
214 p_out->ret_ = NvRmI2cOpen( p_in->hDevice, p_in->IoModule, p_in->instance, &p _out->phI2c );
215
216 return err_;
217 }
218
219 NvError nvrm_i2c_Dispatch( NvU32 function, void *InBuffer, NvU32 InSize, void *O utBuffer, NvU32 OutSize, NvDispatchCtx* Ctx );
220 NvError nvrm_i2c_Dispatch( NvU32 function, void *InBuffer, NvU32 InSize, void *O utBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
221 {
222 NvError err_ = NvSuccess;
223
224 switch( function ) {
225 case 2:
226 err_ = NvRmI2cTransaction_dispatch_( InBuffer, InSize, OutBuffer, OutSiz e, Ctx );
227 break;
228 case 1:
229 err_ = NvRmI2cClose_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx );
230 break;
231 case 0:
232 err_ = NvRmI2cOpen_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx );
233 break;
234 default:
235 err_ = NvError_BadParameter;
236 break;
237 }
238
239 return err_;
240 }
OLDNEW
« no previous file with comments | « arch/arm/mach-tegra/nv/nvrm/dispatch/nvrm_gpio_dispatch.c ('k') | arch/arm/mach-tegra/nv/nvrm/dispatch/nvrm_init_dispatch.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698