upload tizen1.0 source
[kernel/linux-2.6.36.git] / drivers / net / wireless / bcm4330 / src / include / bcmsdbus.h
1 /*
2  * Definitions for API from sdio common code (bcmsdh) to individual
3  * host controller drivers.
4  *
5  * Copyright (C) 1999-2011, Broadcom Corporation
6  * 
7  *         Unless you and Broadcom execute a separate written software license
8  * agreement governing use of this software, this software is licensed to you
9  * under the terms of the GNU General Public License version 2 (the "GPL"),
10  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
11  * following added to such license:
12  * 
13  *      As a special exception, the copyright holders of this software give you
14  * permission to link this software with independent modules, and to copy and
15  * distribute the resulting executable under terms of your choice, provided that
16  * you also meet, for each linked independent module, the terms and conditions of
17  * the license of that module.  An independent module is a module which is not
18  * derived from this software.  The special exception does not apply to any
19  * modifications of the software.
20  * 
21  *      Notwithstanding the above, under no circumstances may you combine this
22  * software in any way with any other Broadcom software provided under a license
23  * other than the GPL, without Broadcom's express prior written consent.
24  *
25  * $Id: bcmsdbus.h,v 13.17.86.2 2010-12-23 01:13:20 $
26  */
27
28 #ifndef _sdio_api_h_
29 #define _sdio_api_h_
30
31
32 #define SDIOH_API_RC_SUCCESS                          (0x00)
33 #define SDIOH_API_RC_FAIL                             (0x01)
34 #define SDIOH_API_SUCCESS(status) (status == 0)
35
36 #define SDIOH_READ              0       /* Read request */
37 #define SDIOH_WRITE             1       /* Write request */
38
39 #define SDIOH_DATA_FIX          0       /* Fixed addressing */
40 #define SDIOH_DATA_INC          1       /* Incremental addressing */
41
42 #define SDIOH_CMD_TYPE_NORMAL   0       /* Normal command */
43 #define SDIOH_CMD_TYPE_APPEND   1       /* Append command */
44 #define SDIOH_CMD_TYPE_CUTTHRU  2       /* Cut-through command */
45
46 #define SDIOH_DATA_PIO          0       /* PIO mode */
47 #define SDIOH_DATA_DMA          1       /* DMA mode */
48
49
50 typedef int SDIOH_API_RC;
51
52 /* SDio Host structure */
53 typedef struct sdioh_info sdioh_info_t;
54
55 /* callback function, taking one arg */
56 typedef void (*sdioh_cb_fn_t)(void *);
57
58 /* attach, return handler on success, NULL if failed.
59  *  The handler shall be provided by all subsequent calls. No local cache
60  *  cfghdl points to the starting address of pci device mapped memory
61  */
62 extern sdioh_info_t * sdioh_attach(osl_t *osh, void *cfghdl, uint irq);
63 extern SDIOH_API_RC sdioh_detach(osl_t *osh, sdioh_info_t *si);
64 extern SDIOH_API_RC sdioh_interrupt_register(sdioh_info_t *si, sdioh_cb_fn_t fn, void *argh);
65 extern SDIOH_API_RC sdioh_interrupt_deregister(sdioh_info_t *si);
66
67 /* query whether SD interrupt is enabled or not */
68 extern SDIOH_API_RC sdioh_interrupt_query(sdioh_info_t *si, bool *onoff);
69
70 /* enable or disable SD interrupt */
71 extern SDIOH_API_RC sdioh_interrupt_set(sdioh_info_t *si, bool enable_disable);
72
73 #if defined(DHD_DEBUG)
74 extern bool sdioh_interrupt_pending(sdioh_info_t *si);
75 #endif
76
77 /* read or write one byte using cmd52 */
78 extern SDIOH_API_RC sdioh_request_byte(sdioh_info_t *si, uint rw, uint fnc, uint addr, uint8 *byte);
79
80 /* read or write 2/4 bytes using cmd53 */
81 extern SDIOH_API_RC sdioh_request_word(sdioh_info_t *si, uint cmd_type, uint rw, uint fnc,
82         uint addr, uint32 *word, uint nbyte);
83
84 /* read or write any buffer using cmd53 */
85 extern SDIOH_API_RC sdioh_request_buffer(sdioh_info_t *si, uint pio_dma, uint fix_inc,
86         uint rw, uint fnc_num, uint32 addr, uint regwidth, uint32 buflen, uint8 *buffer,
87         void *pkt);
88
89 /* get cis data */
90 extern SDIOH_API_RC sdioh_cis_read(sdioh_info_t *si, uint fuc, uint8 *cis, uint32 length);
91
92 extern SDIOH_API_RC sdioh_cfg_read(sdioh_info_t *si, uint fuc, uint32 addr, uint8 *data);
93 extern SDIOH_API_RC sdioh_cfg_write(sdioh_info_t *si, uint fuc, uint32 addr, uint8 *data);
94
95 /* query number of io functions */
96 extern uint sdioh_query_iofnum(sdioh_info_t *si);
97
98 /* handle iovars */
99 extern int sdioh_iovar_op(sdioh_info_t *si, const char *name,
100                           void *params, int plen, void *arg, int len, bool set);
101
102 /* Issue abort to the specified function and clear controller as needed */
103 extern int sdioh_abort(sdioh_info_t *si, uint fnc);
104
105 /* Start and Stop SDIO without re-enumerating the SD card. */
106 extern int sdioh_start(sdioh_info_t *si, int stage);
107 extern int sdioh_stop(sdioh_info_t *si);
108
109 /* Wait system lock free */
110 extern int sdioh_waitlockfree(sdioh_info_t *si);
111
112 /* Reset and re-initialize the device */
113 extern int sdioh_sdio_reset(sdioh_info_t *si);
114
115 /* Helper function */
116 void *bcmsdh_get_sdioh(bcmsdh_info_t *sdh);
117
118
119 #ifdef BCMSPI
120 /* Function to pass gSPI specific device-status bits to dhd. */
121 extern uint32 sdioh_get_dstatus(sdioh_info_t *si);
122
123 /* chipid and chiprev info for lower layers to control sw WAR's for hw bugs. */
124 extern void sdioh_chipinfo(sdioh_info_t *si, uint32 chip, uint32 chiprev);
125 extern void sdioh_dwordmode(sdioh_info_t *si, bool set);
126 #endif /* BCMSPI */
127
128 #endif /* _sdio_api_h_ */