ahci_imx: depend on CONFIG_MFD_SYSCON
[linux-block.git] / drivers / staging / csr / csr_sdio.h
CommitLineData
635d2b00
GKH
1#ifndef CSR_SDIO_H__
2#define CSR_SDIO_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
635d2b00
GKH
13#include "csr_result.h"
14
635d2b00
GKH
15/* Result Codes */
16#define CSR_SDIO_RESULT_INVALID_VALUE ((CsrResult) 1) /* Invalid argument value */
17#define CSR_SDIO_RESULT_NO_DEVICE ((CsrResult) 2) /* The specified device is no longer present */
18#define CSR_SDIO_RESULT_CRC_ERROR ((CsrResult) 3) /* The transmitted/received data or command response contained a CRC error */
19#define CSR_SDIO_RESULT_TIMEOUT ((CsrResult) 4) /* No command response or data received from device, or function enable/disable did not succeed within timeout period */
20#define CSR_SDIO_RESULT_NOT_RESET ((CsrResult) 5) /* The device was not reset */
21
22/* Features (for use in features member of CsrSdioFunction) */
23#define CSR_SDIO_FEATURE_BYTE_MODE 0x00000001 /* Transfer sizes do not have to be a multiple of block size */
24#define CSR_SDIO_FEATURE_DMA_CAPABLE_MEM_REQUIRED 0x00000002 /* Bulk operations require DMA friendly memory */
25
26/* CsrSdioFunctionId wildcards (for use in CsrSdioFunctionId members) */
27#define CSR_SDIO_ANY_MANF_ID 0xFFFF
28#define CSR_SDIO_ANY_CARD_ID 0xFFFF
29#define CSR_SDIO_ANY_SDIO_FUNCTION 0xFF
30#define CSR_SDIO_ANY_SDIO_INTERFACE 0xFF
31
32/*----------------------------------------------------------------------------*
33 * NAME
34 * CsrSdioFunctionId
35 *
36 * DESCRIPTION
37 * This structure describes one or more functions of a device, based on
38 * four qualitative measures. The CsrSdioFunctionId wildcard defines can be
39 * used for making the CsrSdioFunctionId match more than one function.
40 *
41 * MEMBERS
42 * manfId - Vendor ID (or CSR_SDIO_ANY_MANF_ID).
43 * cardId - Device ID (or CSR_SDIO_ANY_CARD_ID).
44 * sdioFunction - SDIO Function number (or CSR_SDIO_ANY_SDIO_FUNCTION).
45 * sdioInterface - SDIO Standard Interface Code (or CSR_SDIO_ANY_SDIO_INTERFACE)
46 *
47 *----------------------------------------------------------------------------*/
48typedef struct
49{
8c87f69a
GKH
50 u16 manfId; /* Vendor ID to match or CSR_SDIO_ANY_MANF_ID */
51 u16 cardId; /* Device ID to match or CSR_SDIO_ANY_CARD_ID */
7e6f5794
GKH
52 u8 sdioFunction; /* SDIO Function number to match or CSR_SDIO_ANY_SDIO_FUNCTION */
53 u8 sdioInterface; /* SDIO Standard Interface Code to match or CSR_SDIO_ANY_SDIO_INTERFACE */
635d2b00
GKH
54} CsrSdioFunctionId;
55
56/*----------------------------------------------------------------------------*
57 * NAME
58 * CsrSdioFunction
59 *
60 * DESCRIPTION
61 * This structure represents a single function on a device.
62 *
63 * MEMBERS
64 * sdioId - A CsrSdioFunctionId describing this particular function. The
65 * subfield shall not contain any CsrSdioFunctionId wildcards. The
66 * subfields shall describe the specific single function
67 * represented by this structure.
68 * blockSize - Actual configured block size, or 0 if unconfigured.
69 * features - Bit mask with any of CSR_SDIO_FEATURE_* set.
70 * device - Handle of device containing the function. If two functions have
71 * the same device handle, they reside on the same device.
72 * driverData - For use by the Function Driver. The SDIO Driver shall not
73 * attempt to dereference the pointer.
74 * priv - For use by the SDIO Driver. The Function Driver shall not attempt
75 * to dereference the pointer.
76 *
77 *
78 *----------------------------------------------------------------------------*/
79typedef struct
80{
81 CsrSdioFunctionId sdioId;
8c87f69a 82 u16 blockSize; /* Actual configured block size, or 0 if unconfigured */
26a6b2e1 83 u32 features; /* Bit mask with any of CSR_SDIO_FEATURE_* set */
635d2b00
GKH
84 void *device; /* Handle of device containing the function */
85 void *driverData; /* For use by the Function Driver */
86 void *priv; /* For use by the SDIO Driver */
87} CsrSdioFunction;
88
89/*----------------------------------------------------------------------------*
90 * NAME
91 * CsrSdioInsertedCallback, CsrSdioRemovedCallback
92 *
93 * DESCRIPTION
94 * CsrSdioInsertedCallback is called when a function becomes available to
95 * a registered Function Driver that supports the function.
96 * CsrSdioRemovedCallback is called when a function is no longer available
97 * to a Function Driver, either because the device has been removed, or the
98 * Function Driver has been unregistered.
99 *
100 * NOTE: These functions are implemented by the Function Driver, and are
101 * passed as function pointers in the CsrSdioFunctionDriver struct.
102 *
103 * PARAMETERS
104 * function - Pointer to struct representing the function.
105 *
106 *----------------------------------------------------------------------------*/
107typedef void (*CsrSdioInsertedCallback)(CsrSdioFunction *function);
108typedef void (*CsrSdioRemovedCallback)(CsrSdioFunction *function);
109
110/*----------------------------------------------------------------------------*
111 * NAME
112 * CsrSdioInterruptDsrCallback, CsrSdioInterruptCallback
113 *
114 * DESCRIPTION
115 * CsrSdioInterruptCallback is called when an interrupt occurs on the
116 * the device associated with the specified function.
117 *
118 * NOTE: These functions are implemented by the Function Driver, and are
119 * passed as function pointers in the CsrSdioFunctionDriver struct.
120 *
121 * PARAMETERS
122 * function - Pointer to struct representing the function.
123 *
124 * RETURNS (only CsrSdioInterruptCallback)
125 * A pointer to a CsrSdioInterruptDsrCallback function.
126 *
127 *----------------------------------------------------------------------------*/
128typedef void (*CsrSdioInterruptDsrCallback)(CsrSdioFunction *function);
129typedef CsrSdioInterruptDsrCallback (*CsrSdioInterruptCallback)(CsrSdioFunction *function);
130
131/*----------------------------------------------------------------------------*
132 * NAME
133 * CsrSdioSuspendCallback, CsrSdioResumeCallback
134 *
135 * DESCRIPTION
136 * CsrSdioSuspendCallback is called when the system is preparing to go
137 * into a suspended state. CsrSdioResumeCallback is called when the system
138 * has entered an active state again.
139 *
140 * NOTE: These functions are implemented by the Function Driver, and are
141 * passed as function pointers in the CsrSdioFunctionDriver struct.
142 *
143 * PARAMETERS
144 * function - Pointer to struct representing the function.
145 *
146 *----------------------------------------------------------------------------*/
147typedef void (*CsrSdioSuspendCallback)(CsrSdioFunction *function);
148typedef void (*CsrSdioResumeCallback)(CsrSdioFunction *function);
149
150/*----------------------------------------------------------------------------*
151 * NAME
152 * CsrSdioAsyncCallback, CsrSdioAsyncDsrCallback
153 *
154 * DESCRIPTION
155 * CsrSdioAsyncCallback is called when an asynchronous operation completes.
156 *
157 * NOTE: These functions are implemented by the Function Driver, and are
158 * passed as function pointers in the function calls that initiate
159 * the operation.
160 *
161 * PARAMETERS
162 * function - Pointer to struct representing the function.
163 * result - The result of the operation that completed. See the description
164 * of the initiating function for possible result values.
165 *
166 * RETURNS (only CsrSdioAsyncCallback)
167 * A pointer to a CsrSdioAsyncDsrCallback function.
168 *
169 *----------------------------------------------------------------------------*/
170typedef void (*CsrSdioAsyncDsrCallback)(CsrSdioFunction *function, CsrResult result);
171typedef CsrSdioAsyncDsrCallback (*CsrSdioAsyncCallback)(CsrSdioFunction *function, CsrResult result);
172
173/*----------------------------------------------------------------------------*
174 * NAME
175 * CsrSdioFunctionDriver
176 *
177 * DESCRIPTION
178 * Structure representing a Function Driver.
179 *
180 * MEMBERS
181 * inserted - Callback, see description of CsrSdioInsertedCallback.
182 * removed - Callback, see description of CsrSdioRemovedCallback.
183 * intr - Callback, see description of CsrSdioInterruptCallback.
184 * suspend - Callback, see description of CsrSdioSuspendCallback.
185 * resume - Callback, see description of CsrSdioResumeCallback.
186 * ids - Array of CsrSdioFunctionId describing one or more functions that
187 * are supported by the Function Driver.
188 * idsCount - Length of the ids array.
189 * priv - For use by the SDIO Driver. The Function Driver may initialise
190 * it to NULL, but shall otherwise not access the pointer or attempt
191 * to dereference it.
192 *
193 *----------------------------------------------------------------------------*/
194typedef struct
195{
196 CsrSdioInsertedCallback inserted;
197 CsrSdioRemovedCallback removed;
198 CsrSdioInterruptCallback intr;
199 CsrSdioSuspendCallback suspend;
200 CsrSdioResumeCallback resume;
201 CsrSdioFunctionId *ids;
7e6f5794 202 u8 idsCount;
635d2b00
GKH
203 void *priv; /* For use by the SDIO Driver */
204} CsrSdioFunctionDriver;
205
206/*----------------------------------------------------------------------------*
207 * NAME
208 * CsrSdioFunctionDriverRegister
209 *
210 * DESCRIPTION
211 * Register a Function Driver.
212 *
213 * PARAMETERS
214 * functionDriver - Pointer to struct describing the Function Driver.
215 *
216 * RETURNS
217 * CSR_RESULT_SUCCESS - The Function Driver was successfully
218 * registered.
219 * CSR_RESULT_FAILURE - Unable to register the function driver,
220 * because of an unspecified/unknown error. The
221 * Function Driver has not been registered.
222 * CSR_SDIO_RESULT_INVALID_VALUE - The specified Function Driver pointer
223 * does not point at a valid Function
224 * Driver structure, or some of the members
225 * contain invalid entries.
226 *
227 *----------------------------------------------------------------------------*/
228CsrResult CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *functionDriver);
229
230/*----------------------------------------------------------------------------*
231 * NAME
232 * CsrSdioFunctionDriverUnregister
233 *
234 * DESCRIPTION
235 * Unregister a previously registered Function Driver.
236 *
237 * PARAMETERS
238 * functionDriver - pointer to struct describing the Function Driver.
239 *
240 *----------------------------------------------------------------------------*/
241void CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *functionDriver);
242
243/*----------------------------------------------------------------------------*
244 * NAME
245 * CsrSdioFunctionEnable, CsrSdioFunctionDisable
246 *
247 * DESCRIPTION
248 * Enable/disable the specified function by setting/clearing the
249 * corresponding bit in the I/O Enable register in function 0, and then
250 * periodically reading the related bit in the I/O Ready register until it
251 * is set/clear, limited by an implementation defined timeout.
252 *
253 * PARAMETERS
254 * function - Pointer to struct representing the function.
255 *
256 * RETURNS
257 * CSR_RESULT_SUCCESS - The specified function was enabled/disabled.
258 * CSR_RESULT_FAILURE - Unspecified/unknown error.
259 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
4445d254 260 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The state of the
635d2b00
GKH
261 * related bit in the I/O Enable register is
262 * undefined.
263 * CSR_SDIO_RESULT_TIMEOUT - No response from the device, or the related
264 * bit in the I/O ready register was not
265 * set/cleared within the timeout period.
266 *
267 * NOTE: If the SDIO R5 response is available, and either of the
268 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
269 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
270 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
271 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
272 * COM_CRC_ERROR bits shall be ignored.
273 *
274 * If the CSPI response is available, and any of the
275 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
276 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
277 *
278 *----------------------------------------------------------------------------*/
279CsrResult CsrSdioFunctionEnable(CsrSdioFunction *function);
280CsrResult CsrSdioFunctionDisable(CsrSdioFunction *function);
281
282/*----------------------------------------------------------------------------*
283 * NAME
284 * CsrSdioInterruptEnable, CsrSdioInterruptDisable
285 *
286 * DESCRIPTION
287 * Enable/disable the interrupt for the specified function by
288 * setting/clearing the corresponding bit in the INT Enable register in
289 * function 0.
290 *
291 * PARAMETERS
292 * function - Pointer to struct representing the function.
293 *
294 * RETURNS
295 * CSR_RESULT_SUCCESS - The specified function was enabled/disabled.
296 * CSR_RESULT_FAILURE - Unspecified/unknown error.
297 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
4445d254 298 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The state of the
635d2b00
GKH
299 * related bit in the INT Enable register is
300 * unchanged.
301 * CSR_SDIO_RESULT_INVALID_VALUE - The specified function cannot be
302 * enabled/disabled, because it either
303 * does not exist or it is not possible to
304 * individually enable/disable functions.
305 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
306 *
307 * NOTE: If the SDIO R5 response is available, and either of the
308 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
309 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
310 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
311 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
312 * COM_CRC_ERROR bits shall be ignored.
313 *
314 * If the CSPI response is available, and any of the
315 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
316 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
317 *
318 *----------------------------------------------------------------------------*/
319CsrResult CsrSdioInterruptEnable(CsrSdioFunction *function);
320CsrResult CsrSdioInterruptDisable(CsrSdioFunction *function);
321
322/*----------------------------------------------------------------------------*
323 * NAME
324 * CsrSdioInterruptAcknowledge
325 *
326 * DESCRIPTION
327 * Acknowledge that a signalled interrupt has been handled. Shall only
328 * be called once, and exactly once for each signalled interrupt to the
329 * corresponding function.
330 *
331 * PARAMETERS
332 * function - Pointer to struct representing the function to which the
333 * event was signalled.
334 *
335 *----------------------------------------------------------------------------*/
336void CsrSdioInterruptAcknowledge(CsrSdioFunction *function);
337
338/*----------------------------------------------------------------------------*
339 * NAME
340 * CsrSdioInsertedAcknowledge, CsrSdioRemovedAcknowledge
341 *
342 * DESCRIPTION
343 * Acknowledge that a signalled inserted/removed event has been handled.
344 * Shall only be called once, and exactly once for each signalled event to
345 * the corresponding function.
346 *
347 * PARAMETERS
348 * function - Pointer to struct representing the function to which the
349 * inserted was signalled.
350 * result (CsrSdioInsertedAcknowledge only)
351 * CSR_RESULT_SUCCESS - The Function Driver has accepted the
352 * function, and the function is attached to
353 * the Function Driver until the
354 * CsrSdioRemovedCallback is called and
355 * acknowledged.
356 * CSR_RESULT_FAILURE - Unable to accept the function. The
357 * function is not attached to the Function
358 * Driver, and it may be passed to another
359 * Function Driver which supports the
360 * function.
361 *
362 *----------------------------------------------------------------------------*/
363void CsrSdioInsertedAcknowledge(CsrSdioFunction *function, CsrResult result);
364void CsrSdioRemovedAcknowledge(CsrSdioFunction *function);
365
366/*----------------------------------------------------------------------------*
367 * NAME
368 * CsrSdioSuspendAcknowledge, CsrSdioResumeAcknowledge
369 *
370 * DESCRIPTION
371 * Acknowledge that a signalled suspend event has been handled. Shall only
372 * be called once, and exactly once for each signalled event to the
373 * corresponding function.
374 *
375 * PARAMETERS
376 * function - Pointer to struct representing the function to which the
377 * event was signalled.
378 * result
379 * CSR_RESULT_SUCCESS - Successfully suspended/resumed.
380 * CSR_RESULT_FAILURE - Unspecified/unknown error.
381 *
382 *----------------------------------------------------------------------------*/
383void CsrSdioSuspendAcknowledge(CsrSdioFunction *function, CsrResult result);
384void CsrSdioResumeAcknowledge(CsrSdioFunction *function, CsrResult result);
385
386/*----------------------------------------------------------------------------*
387 * NAME
388 * CsrSdioBlockSizeSet
389 *
390 * DESCRIPTION
391 * Set the block size to use for the function. The actual configured block
392 * size shall be the minimum of:
393 * 1) Maximum block size supported by the function.
394 * 2) Maximum block size supported by the host controller.
395 * 3) The block size specified by the blockSize argument.
396 *
397 * When this function returns, the actual configured block size is
398 * available in the blockSize member of the function struct.
399 *
400 * PARAMETERS
401 * function - Pointer to struct representing the function.
402 * blockSize - Block size to use for the function. Valid range is 1 to
403 * 2048.
404 *
405 * RETURNS
406 * CSR_RESULT_SUCCESS - The block size register on the chip
407 * was updated.
408 * CSR_RESULT_FAILURE - Unspecified/unknown error.
409 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
410 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
4445d254 411 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The configured block
635d2b00
GKH
412 * size is undefined.
413 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
414 *
415 * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER
416 * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned.
417 * If the ERROR bit is set (but not FUNCTION_NUMBER),
418 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
419 * COM_CRC_ERROR bits shall be ignored.
420 *
421 * If the CSPI response is available, and any of the
422 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
423 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
424 *
425 * NOTE: Setting the block size requires two individual operations. The
426 * implementation shall ignore the OUT_OF_RANGE bit of the SDIO R5
427 * response for the first operation, as the partially configured
428 * block size may be out of range, even if the final block size
429 * (after the second operation) is in the valid range.
430 *
431 *----------------------------------------------------------------------------*/
8c87f69a 432CsrResult CsrSdioBlockSizeSet(CsrSdioFunction *function, u16 blockSize);
635d2b00
GKH
433
434/*----------------------------------------------------------------------------*
435 * NAME
436 * CsrSdioMaxBusClockFrequencySet
437 *
438 * DESCRIPTION
439 * Set the maximum clock frequency to use for the device associated with
440 * the specified function. The actual configured clock frequency for the
441 * device shall be the minimum of:
442 * 1) Maximum clock frequency supported by the device.
443 * 2) Maximum clock frequency supported by the host controller.
444 * 3) Maximum clock frequency specified for any function on the same
445 * device.
446 *
447 * If the clock frequency exceeds 25MHz, it is the responsibility of the
448 * SDIO driver to enable high speed mode on the device, using the standard
449 * defined procedure, before increasing the frequency beyond the limit.
450 *
451 * Note that the clock frequency configured affects all functions on the
452 * same device.
453 *
454 * PARAMETERS
455 * function - Pointer to struct representing the function.
456 * maxFrequency - The maximum clock frequency for the function in Hertz.
457 *
458 * RETURNS
4445d254 459 * CSR_RESULT_SUCCESS - The maximum clock frequency was successfully
635d2b00
GKH
460 * set for the function.
461 * CSR_RESULT_FAILURE - Unspecified/unknown error.
462 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
463 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
464 *
465 * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER
466 * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned.
467 * If the ERROR bit is set (but not FUNCTION_NUMBER),
468 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
469 * COM_CRC_ERROR bits shall be ignored.
470 *
471 * If the CSPI response is available, and any of the
472 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
473 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
474 *
475 *
476 *----------------------------------------------------------------------------*/
26a6b2e1 477CsrResult CsrSdioMaxBusClockFrequencySet(CsrSdioFunction *function, u32 maxFrequency);
635d2b00
GKH
478
479/*----------------------------------------------------------------------------*
480 * NAME
481 * CsrSdioRead8, CsrSdioWrite8, CsrSdioRead8Async, CsrSdioWrite8Async
482 *
483 * DESCRIPTION
484 * Read/write an 8bit value from/to the specified register address.
485 *
486 * PARAMETERS
487 * function - Pointer to struct representing the function.
488 * address - Register address within the function.
489 * data - The data to read/write.
490 * callback - The function to call on operation completion.
491 *
492 * RETURNS
493 * CSR_RESULT_SUCCESS - The data was successfully read/written.
494 * CSR_RESULT_FAILURE - Unspecified/unknown error.
495 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
496 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
4445d254 497 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. No data read/written.
635d2b00
GKH
498 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
499 *
500 * NOTE: If the SDIO R5 response is available, and either of the
501 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
502 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
503 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
504 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
505 * COM_CRC_ERROR bits shall be ignored.
506 *
507 * If the CSPI response is available, and any of the
508 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
509 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
510 *
511 * NOTE: The CsrSdioRead8Async and CsrSdioWrite8Async functions return
512 * immediately, and the supplied callback function is called when the
513 * operation is complete. The result value is given as an argument to
514 * the callback function.
515 *
516 *----------------------------------------------------------------------------*/
26a6b2e1
GKH
517CsrResult CsrSdioRead8(CsrSdioFunction *function, u32 address, u8 *data);
518CsrResult CsrSdioWrite8(CsrSdioFunction *function, u32 address, u8 data);
519void CsrSdioRead8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
520void CsrSdioWrite8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
635d2b00
GKH
521
522/*----------------------------------------------------------------------------*
523 * NAME
524 * CsrSdioRead16, CsrSdioWrite16, CsrSdioRead16Async, CsrSdioWrite16Async
525 *
526 * DESCRIPTION
527 * Read/write a 16bit value from/to the specified register address.
528 *
529 * PARAMETERS
530 * function - Pointer to struct representing the function.
531 * address - Register address within the function.
532 * data - The data to read/write.
533 * callback - The function to call on operation completion.
534 *
535 * RETURNS
536 * CSR_RESULT_SUCCESS - The data was successfully read/written.
537 * CSR_RESULT_FAILURE - Unspecified/unknown error.
538 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
539 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
4445d254 540 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. Data may have been
635d2b00
GKH
541 * partially read/written.
542 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
543 *
544 * NOTE: If the SDIO R5 response is available, and either of the
545 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
546 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
547 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
548 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
549 * COM_CRC_ERROR bits shall be ignored.
550 *
551 * If the CSPI response is available, and any of the
552 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
553 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
554 *
555 * NOTE: The CsrSdioRead16Async and CsrSdioWrite16Async functions return
556 * immediately, and the supplied callback function is called when the
557 * operation is complete. The result value is given as an argument to
558 * the callback function.
559 *
560 *----------------------------------------------------------------------------*/
26a6b2e1
GKH
561CsrResult CsrSdioRead16(CsrSdioFunction *function, u32 address, u16 *data);
562CsrResult CsrSdioWrite16(CsrSdioFunction *function, u32 address, u16 data);
563void CsrSdioRead16Async(CsrSdioFunction *function, u32 address, u16 *data, CsrSdioAsyncCallback callback);
564void CsrSdioWrite16Async(CsrSdioFunction *function, u32 address, u16 data, CsrSdioAsyncCallback callback);
635d2b00
GKH
565
566/*----------------------------------------------------------------------------*
567 * NAME
568 * CsrSdioF0Read8, CsrSdioF0Write8, CsrSdioF0Read8Async,
569 * CsrSdioF0Write8Async
570 *
571 * DESCRIPTION
572 * Read/write an 8bit value from/to the specified register address in
573 * function 0.
574 *
575 * PARAMETERS
576 * function - Pointer to struct representing the function.
577 * address - Register address within the function.
578 * data - The data to read/write.
579 * callback - The function to call on operation completion.
580 *
581 * RETURNS
582 * CSR_RESULT_SUCCESS - The data was successfully read/written.
583 * CSR_RESULT_FAILURE - Unspecified/unknown error.
584 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
585 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
4445d254 586 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. No data read/written.
635d2b00
GKH
587 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
588 *
589 * NOTE: If the SDIO R5 response is available, and either of the
590 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
591 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
592 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
593 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
594 * COM_CRC_ERROR bits shall be ignored.
595 *
596 * If the CSPI response is available, and any of the
597 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
598 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
599 *
600 * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return
601 * immediately, and the supplied callback function is called when the
602 * operation is complete. The result value is given as an argument to
603 * the callback function.
604 *
605 *----------------------------------------------------------------------------*/
26a6b2e1
GKH
606CsrResult CsrSdioF0Read8(CsrSdioFunction *function, u32 address, u8 *data);
607CsrResult CsrSdioF0Write8(CsrSdioFunction *function, u32 address, u8 data);
608void CsrSdioF0Read8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
609void CsrSdioF0Write8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
635d2b00
GKH
610
611/*----------------------------------------------------------------------------*
612 * NAME
613 * CsrSdioRead, CsrSdioWrite, CsrSdioReadAsync, CsrSdioWriteAsync
614 *
615 * DESCRIPTION
616 * Read/write a specified number of bytes from/to the specified register
617 * address.
618 *
619 * PARAMETERS
620 * function - Pointer to struct representing the function.
621 * address - Register address within the function.
622 * data - The data to read/write.
623 * length - Number of byte to read/write.
624 * callback - The function to call on operation completion.
625 *
626 * RETURNS
627 * CSR_RESULT_SUCCESS - The data was successfully read/written.
628 * CSR_RESULT_FAILURE - Unspecified/unknown error.
629 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
630 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
4445d254 631 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. Data may have been
635d2b00
GKH
632 * partially read/written.
633 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
634 *
635 * NOTE: If the SDIO R5 response is available, and either of the
636 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
637 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
638 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
639 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
640 * COM_CRC_ERROR bits shall be ignored.
641 *
642 * If the CSPI response is available, and any of the
643 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
644 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
645 *
646 * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return
647 * immediately, and the supplied callback function is called when the
648 * operation is complete. The result value is given as an argument to
649 * the callback function.
650 *
651 *----------------------------------------------------------------------------*/
26a6b2e1
GKH
652CsrResult CsrSdioRead(CsrSdioFunction *function, u32 address, void *data, u32 length);
653CsrResult CsrSdioWrite(CsrSdioFunction *function, u32 address, const void *data, u32 length);
654void CsrSdioReadAsync(CsrSdioFunction *function, u32 address, void *data, u32 length, CsrSdioAsyncCallback callback);
655void CsrSdioWriteAsync(CsrSdioFunction *function, u32 address, const void *data, u32 length, CsrSdioAsyncCallback callback);
635d2b00
GKH
656
657/*----------------------------------------------------------------------------*
658 * NAME
659 * CsrSdioPowerOn, CsrSdioPowerOff
660 *
661 * DESCRIPTION
662 * Power on/off the device.
663 *
664 * PARAMETERS
665 * function - Pointer to struct representing the function that resides on
666 * the device to power on/off.
667 *
668 * RETURNS (only CsrSdioPowerOn)
4445d254 669 * CSR_RESULT_SUCCESS - Power was successfully reapplied and the device
635d2b00
GKH
670 * has been reinitialised.
671 * CSR_RESULT_FAILURE - Unspecified/unknown error.
672 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
4445d254 673 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred during reinitialisation.
635d2b00
GKH
674 * CSR_SDIO_RESULT_TIMEOUT - No response from the device during
675 * reinitialisation.
676 * CSR_SDIO_RESULT_NOT_RESET - The power was not removed by the
677 * CsrSdioPowerOff call. The state of the
678 * device is unchanged.
679 *
680 *----------------------------------------------------------------------------*/
681CsrResult CsrSdioPowerOn(CsrSdioFunction *function);
682void CsrSdioPowerOff(CsrSdioFunction *function);
683
684/*----------------------------------------------------------------------------*
685 * NAME
686 * CsrSdioHardReset
687 *
688 * DESCRIPTION
689 * Perform a hardware reset of the device.
690 *
691 * PARAMETERS
692 * function - Pointer to struct representing the function that resides on
693 * the device to hard reset.
694 *
695 * RETURNS
4445d254 696 * CSR_RESULT_SUCCESS - Reset was successfully performed and the device
635d2b00
GKH
697 * has been reinitialised.
698 * CSR_RESULT_FAILURE - Unspecified/unknown error.
699 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
4445d254 700 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred during reinitialisation.
635d2b00
GKH
701 * CSR_SDIO_RESULT_TIMEOUT - No response from the device during
702 * reinitialisation.
703 * CSR_SDIO_RESULT_NOT_RESET - The reset was not applied because it is not
704 * supported. The state of the device is
705 * unchanged.
706 *
707 *----------------------------------------------------------------------------*/
708CsrResult CsrSdioHardReset(CsrSdioFunction *function);
709
710/*----------------------------------------------------------------------------*
711 * NAME
712 * CsrSdioFunctionActive, CsrSdioFunctionIdle
713 *
714 * DESCRIPTION
715 *
716 * PARAMETERS
717 * function - Pointer to struct representing the function.
718 *
719 *----------------------------------------------------------------------------*/
720void CsrSdioFunctionActive(CsrSdioFunction *function);
721void CsrSdioFunctionIdle(CsrSdioFunction *function);
722
635d2b00 723#endif