Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelv...
[pandora-kernel.git] / drivers / staging / brcm80211 / include / bcmsdbus.h
1 /*
2  * Copyright (c) 2010 Broadcom Corporation
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 #ifndef _sdio_api_h_
18 #define _sdio_api_h_
19
20 #define SDIOH_API_RC_SUCCESS                          (0x00)
21 #define SDIOH_API_RC_FAIL                             (0x01)
22 #define SDIOH_API_SUCCESS(status) (status == 0)
23
24 #define SDIOH_READ              0       /* Read request */
25 #define SDIOH_WRITE             1       /* Write request */
26
27 #define SDIOH_DATA_FIX          0       /* Fixed addressing */
28 #define SDIOH_DATA_INC          1       /* Incremental addressing */
29
30 #define SDIOH_CMD_TYPE_NORMAL   0       /* Normal command */
31 #define SDIOH_CMD_TYPE_APPEND   1       /* Append command */
32 #define SDIOH_CMD_TYPE_CUTTHRU  2       /* Cut-through command */
33
34 #define SDIOH_DATA_PIO          0       /* PIO mode */
35 #define SDIOH_DATA_DMA          1       /* DMA mode */
36
37 typedef int SDIOH_API_RC;
38
39 /* SDio Host structure */
40 typedef struct sdioh_info sdioh_info_t;
41
42 /* callback function, taking one arg */
43 typedef void (*sdioh_cb_fn_t) (void *);
44
45 /* attach, return handler on success, NULL if failed.
46  *  The handler shall be provided by all subsequent calls. No local cache
47  *  cfghdl points to the starting address of pci device mapped memory
48  */
49 extern sdioh_info_t *sdioh_attach(osl_t *osh, void *cfghdl, uint irq);
50 extern SDIOH_API_RC sdioh_detach(osl_t *osh, sdioh_info_t *si);
51 extern SDIOH_API_RC sdioh_interrupt_register(sdioh_info_t *si,
52                                              sdioh_cb_fn_t fn, void *argh);
53 extern SDIOH_API_RC sdioh_interrupt_deregister(sdioh_info_t *si);
54
55 /* query whether SD interrupt is enabled or not */
56 extern SDIOH_API_RC sdioh_interrupt_query(sdioh_info_t *si, bool *onoff);
57
58 /* enable or disable SD interrupt */
59 extern SDIOH_API_RC sdioh_interrupt_set(sdioh_info_t *si, bool enable_disable);
60
61 #if defined(BCMDBG)
62 extern bool sdioh_interrupt_pending(sdioh_info_t *si);
63 #endif
64
65 extern int sdioh_claim_host_and_lock(sdioh_info_t *si);
66 extern int sdioh_release_host_and_unlock(sdioh_info_t *si);
67
68 /* read or write one byte using cmd52 */
69 extern SDIOH_API_RC sdioh_request_byte(sdioh_info_t *si, uint rw, uint fnc,
70                                        uint addr, u8 *byte);
71
72 /* read or write 2/4 bytes using cmd53 */
73 extern SDIOH_API_RC sdioh_request_word(sdioh_info_t *si, uint cmd_type,
74                                        uint rw, uint fnc, uint addr,
75                                        u32 *word, uint nbyte);
76
77 /* read or write any buffer using cmd53 */
78 extern SDIOH_API_RC sdioh_request_buffer(sdioh_info_t *si, uint pio_dma,
79                                          uint fix_inc, uint rw, uint fnc_num,
80                                          u32 addr, uint regwidth,
81                                          u32 buflen, u8 *buffer,
82                                          void *pkt);
83
84 /* get cis data */
85 extern SDIOH_API_RC sdioh_cis_read(sdioh_info_t *si, uint fuc, u8 *cis,
86                                    u32 length);
87
88 extern SDIOH_API_RC sdioh_cfg_read(sdioh_info_t *si, uint fuc, u32 addr,
89                                    u8 *data);
90 extern SDIOH_API_RC sdioh_cfg_write(sdioh_info_t *si, uint fuc, u32 addr,
91                                     u8 *data);
92
93 /* query number of io functions */
94 extern uint sdioh_query_iofnum(sdioh_info_t *si);
95
96 /* handle iovars */
97 extern int sdioh_iovar_op(sdioh_info_t *si, const char *name,
98                           void *params, int plen, void *arg, int len, bool set);
99
100 /* Issue abort to the specified function and clear controller as needed */
101 extern int sdioh_abort(sdioh_info_t *si, uint fnc);
102
103 /* Start and Stop SDIO without re-enumerating the SD card. */
104 extern int sdioh_start(sdioh_info_t *si, int stage);
105 extern int sdioh_stop(sdioh_info_t *si);
106
107 /* Reset and re-initialize the device */
108 extern int sdioh_sdio_reset(sdioh_info_t *si);
109
110 /* Helper function */
111 void *bcmsdh_get_sdioh(bcmsdh_info_t *sdh);
112
113 #endif                          /* _sdio_api_h_ */