• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Definitions for API from sdio common code (bcmsdh) to individual
3  * host controller drivers.
4  *
5  * Copyright (C) 1999-2013, 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 408155 2013-06-17 21:52:27Z $
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 #ifdef BCMSDIOH_TXGLOM
50 /* Max number of glommed pkts */
51 #ifdef CUSTOM_MAX_TXGLOM_SIZE
52 #define SDPCM_MAXGLOM_SIZE  CUSTOM_MAX_TXGLOM_SIZE
53 #else
54 #define SDPCM_MAXGLOM_SIZE	10
55 #endif /* CUSTOM_MAX_TXGLOM_SIZE */
56 
57 #define SDPCM_TXGLOM_CPY 0			/* SDIO 2.0 should use copy mode */
58 #define SDPCM_TXGLOM_MDESC	1		/* SDIO 3.0 should use multi-desc mode */
59 
60 #ifdef BCMSDIOH_TXGLOM_HIGHSPEED
61 #define SDPCM_DEFGLOM_MODE	SDPCM_TXGLOM_MDESC
62 #ifdef CUSTOM_DEF_TXGLOM_SIZE
63 #define SDPCM_DEFGLOM_SIZE  CUSTOM_DEF_TXGLOM_SIZE
64 #else
65 #define SDPCM_DEFGLOM_SIZE  10
66 #endif /* CUSTOM_DEF_TXGLOM_SIZE */
67 #else
68 #define SDPCM_DEFGLOM_MODE	SDPCM_TXGLOM_CPY
69 #define SDPCM_DEFGLOM_SIZE  3
70 #endif /* BCMSDIOH_TXGLOM_HIGHSPEED */
71 
72 #if SDPCM_DEFGLOM_SIZE > SDPCM_MAXGLOM_SIZE
73 #warning "SDPCM_DEFGLOM_SIZE cannot be higher than SDPCM_MAXGLOM_SIZE!!"
74 #undef SDPCM_DEFGLOM_SIZE
75 #define SDPCM_DEFGLOM_SIZE SDPCM_MAXGLOM_SIZE
76 #endif
77 #endif /* BCMSDIOH_TXGLOM */
78 
79 typedef int SDIOH_API_RC;
80 
81 /* SDio Host structure */
82 typedef struct sdioh_info sdioh_info_t;
83 
84 /* callback function, taking one arg */
85 typedef void (*sdioh_cb_fn_t)(void *);
86 
87 /* attach, return handler on success, NULL if failed.
88  *  The handler shall be provided by all subsequent calls. No local cache
89  *  cfghdl points to the starting address of pci device mapped memory
90  */
91 extern sdioh_info_t * sdioh_attach(osl_t *osh, void *cfghdl, uint irq);
92 extern SDIOH_API_RC sdioh_detach(osl_t *osh, sdioh_info_t *si);
93 extern SDIOH_API_RC sdioh_interrupt_register(sdioh_info_t *si, sdioh_cb_fn_t fn, void *argh);
94 extern SDIOH_API_RC sdioh_interrupt_deregister(sdioh_info_t *si);
95 
96 /* query whether SD interrupt is enabled or not */
97 extern SDIOH_API_RC sdioh_interrupt_query(sdioh_info_t *si, bool *onoff);
98 
99 /* enable or disable SD interrupt */
100 extern SDIOH_API_RC sdioh_interrupt_set(sdioh_info_t *si, bool enable_disable);
101 
102 #if defined(DHD_DEBUG)
103 extern bool sdioh_interrupt_pending(sdioh_info_t *si);
104 #endif
105 
106 /* read or write one byte using cmd52 */
107 extern SDIOH_API_RC sdioh_request_byte(sdioh_info_t *si, uint rw, uint fnc, uint addr, uint8 *byte);
108 
109 /* read or write 2/4 bytes using cmd53 */
110 extern SDIOH_API_RC sdioh_request_word(sdioh_info_t *si, uint cmd_type, uint rw, uint fnc,
111 	uint addr, uint32 *word, uint nbyte);
112 
113 /* read or write any buffer using cmd53 */
114 extern SDIOH_API_RC sdioh_request_buffer(sdioh_info_t *si, uint pio_dma, uint fix_inc,
115 	uint rw, uint fnc_num, uint32 addr, uint regwidth, uint32 buflen, uint8 *buffer,
116 	void *pkt);
117 
118 #ifdef BCMSDIOH_TXGLOM
119 extern void	sdioh_glom_post(sdioh_info_t *sd, uint8 *frame, void *pkt, uint len);
120 extern void sdioh_glom_clear(sdioh_info_t *sd);
121 extern uint sdioh_set_mode(sdioh_info_t *sd, uint mode);
122 extern bool sdioh_glom_enabled(void);
123 #else
124 #define sdioh_glom_post(a, b, c, d)
125 #define sdioh_glom_clear(a)
126 #define sdioh_set_mode(a) (0)
127 #define sdioh_glom_enabled() (FALSE)
128 #endif
129 
130 /* get cis data */
131 extern SDIOH_API_RC sdioh_cis_read(sdioh_info_t *si, uint fuc, uint8 *cis, uint32 length);
132 
133 extern SDIOH_API_RC sdioh_cfg_read(sdioh_info_t *si, uint fuc, uint32 addr, uint8 *data);
134 extern SDIOH_API_RC sdioh_cfg_write(sdioh_info_t *si, uint fuc, uint32 addr, uint8 *data);
135 
136 /* query number of io functions */
137 extern uint sdioh_query_iofnum(sdioh_info_t *si);
138 
139 /* handle iovars */
140 extern int sdioh_iovar_op(sdioh_info_t *si, const char *name,
141                           void *params, int plen, void *arg, int len, bool set);
142 
143 /* Issue abort to the specified function and clear controller as needed */
144 extern int sdioh_abort(sdioh_info_t *si, uint fnc);
145 
146 /* Start and Stop SDIO without re-enumerating the SD card. */
147 extern int sdioh_start(sdioh_info_t *si, int stage);
148 extern int sdioh_stop(sdioh_info_t *si);
149 
150 /* Wait system lock free */
151 extern int sdioh_waitlockfree(sdioh_info_t *si);
152 
153 /* Reset and re-initialize the device */
154 extern int sdioh_sdio_reset(sdioh_info_t *si);
155 
156 /* Helper function */
157 void *bcmsdh_get_sdioh(bcmsdh_info_t *sdh);
158 
159 
160 
161 #if defined(BCMSDIOH_STD)
162 	#define SDIOH_SLEEP_ENABLED
163 #endif
164 extern SDIOH_API_RC sdioh_sleep(sdioh_info_t *si, bool enab);
165 
166 /* GPIO support */
167 extern SDIOH_API_RC sdioh_gpio_init(sdioh_info_t *sd);
168 extern bool sdioh_gpioin(sdioh_info_t *sd, uint32 gpio);
169 extern SDIOH_API_RC sdioh_gpioouten(sdioh_info_t *sd, uint32 gpio);
170 extern SDIOH_API_RC sdioh_gpioout(sdioh_info_t *sd, uint32 gpio, bool enab);
171 
172 #endif /* _sdio_api_h_ */
173