dhd: rename 100.10.315.x to 100.10.545.x
[GitHub/LineageOS/G12/android_hardware_amlogic_kernel-modules_dhd-driver.git] / bcmdhd.100.10.545.x / include / bcmsdbus.h
1 /*
2 * Definitions for API from sdio common code (bcmsdh) to individual
3 * host controller drivers.
4 *
5 * Copyright (C) 1999-2019, Broadcom.
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 *
26 * <<Broadcom-WL-IPTag/Open:>>
27 *
28 * $Id: bcmsdbus.h 689948 2017-03-14 05:21:03Z $
29 */
30
31 #ifndef _sdio_api_h_
32 #define _sdio_api_h_
33
34 #if defined(BT_OVER_SDIO)
35 #include <linux/mmc/sdio_func.h>
36 #endif /* defined (BT_OVER_SDIO) */
37
38 #define SDIOH_API_RC_SUCCESS (0x00)
39 #define SDIOH_API_RC_FAIL (0x01)
40 #define SDIOH_API_SUCCESS(status) (status == 0)
41
42 #define SDIOH_READ 0 /* Read request */
43 #define SDIOH_WRITE 1 /* Write request */
44
45 #define SDIOH_DATA_FIX 0 /* Fixed addressing */
46 #define SDIOH_DATA_INC 1 /* Incremental addressing */
47
48 #define SDIOH_CMD_TYPE_NORMAL 0 /* Normal command */
49 #define SDIOH_CMD_TYPE_APPEND 1 /* Append command */
50 #define SDIOH_CMD_TYPE_CUTTHRU 2 /* Cut-through command */
51
52 #define SDIOH_DATA_PIO 0 /* PIO mode */
53 #define SDIOH_DATA_DMA 1 /* DMA mode */
54
55 /* Max number of glommed pkts */
56 #ifdef CUSTOM_MAX_TXGLOM_SIZE
57 #define SDPCM_MAXGLOM_SIZE CUSTOM_MAX_TXGLOM_SIZE
58 #else
59 #define SDPCM_MAXGLOM_SIZE 36
60 #endif /* CUSTOM_MAX_TXGLOM_SIZE */
61
62 #define SDPCM_TXGLOM_CPY 0 /* SDIO 2.0 should use copy mode */
63 #define SDPCM_TXGLOM_MDESC 1 /* SDIO 3.0 should use multi-desc mode */
64
65 #ifdef CUSTOM_DEF_TXGLOM_SIZE
66 #define SDPCM_DEFGLOM_SIZE CUSTOM_DEF_TXGLOM_SIZE
67 #else
68 #define SDPCM_DEFGLOM_SIZE SDPCM_MAXGLOM_SIZE
69 #endif /* CUSTOM_DEF_TXGLOM_SIZE */
70
71 #if SDPCM_DEFGLOM_SIZE > SDPCM_MAXGLOM_SIZE
72 #warning "SDPCM_DEFGLOM_SIZE cannot be higher than SDPCM_MAXGLOM_SIZE!!"
73 #undef SDPCM_DEFGLOM_SIZE
74 #define SDPCM_DEFGLOM_SIZE SDPCM_MAXGLOM_SIZE
75 #endif // endif
76
77 #ifdef PKT_STATICS
78 typedef struct pkt_statics {
79 uint16 event_count;
80 uint32 event_size;
81 uint16 ctrl_count;
82 uint32 ctrl_size;
83 uint32 data_count;
84 uint32 data_size;
85 uint32 glom_cnt[SDPCM_MAXGLOM_SIZE];
86 uint16 glom_max;
87 uint16 glom_count;
88 uint32 glom_size;
89 uint16 test_count;
90 uint32 test_size;
91 } pkt_statics_t;
92 #endif
93
94 typedef int SDIOH_API_RC;
95
96 /* SDio Host structure */
97 typedef struct sdioh_info sdioh_info_t;
98
99 /* callback function, taking one arg */
100 typedef void (*sdioh_cb_fn_t)(void *);
101 #if defined(BT_OVER_SDIO)
102 extern
103 void sdioh_sdmmc_card_enable_func_f3(sdioh_info_t *sd, struct sdio_func *func);
104 #endif /* defined (BT_OVER_SDIO) */
105
106 extern SDIOH_API_RC sdioh_interrupt_register(sdioh_info_t *si, sdioh_cb_fn_t fn, void *argh);
107 extern SDIOH_API_RC sdioh_interrupt_deregister(sdioh_info_t *si);
108
109 /* query whether SD interrupt is enabled or not */
110 extern SDIOH_API_RC sdioh_interrupt_query(sdioh_info_t *si, bool *onoff);
111
112 /* enable or disable SD interrupt */
113 extern SDIOH_API_RC sdioh_interrupt_set(sdioh_info_t *si, bool enable_disable);
114
115 #if defined(DHD_DEBUG)
116 extern bool sdioh_interrupt_pending(sdioh_info_t *si);
117 #endif // endif
118
119 /* read or write one byte using cmd52 */
120 extern SDIOH_API_RC sdioh_request_byte(sdioh_info_t *si, uint rw, uint fnc, uint addr, uint8 *byte);
121
122 /* read or write 2/4 bytes using cmd53 */
123 extern SDIOH_API_RC sdioh_request_word(sdioh_info_t *si, uint cmd_type, uint rw, uint fnc,
124 uint addr, uint32 *word, uint nbyte);
125
126 /* read or write any buffer using cmd53 */
127 extern SDIOH_API_RC sdioh_request_buffer(sdioh_info_t *si, uint pio_dma, uint fix_inc,
128 uint rw, uint fnc_num, uint32 addr, uint regwidth, uint32 buflen, uint8 *buffer,
129 void *pkt);
130
131 /* get cis data */
132 extern SDIOH_API_RC sdioh_cis_read(sdioh_info_t *si, uint fuc, uint8 *cis, uint32 length);
133 extern SDIOH_API_RC sdioh_cisaddr_read(sdioh_info_t *sd, uint func, uint8 *cisd, uint32 offset);
134
135 extern SDIOH_API_RC sdioh_cfg_read(sdioh_info_t *si, uint fuc, uint32 addr, uint8 *data);
136 extern SDIOH_API_RC sdioh_cfg_write(sdioh_info_t *si, uint fuc, uint32 addr, uint8 *data);
137
138 /* query number of io functions */
139 extern uint sdioh_query_iofnum(sdioh_info_t *si);
140
141 /* handle iovars */
142 extern int sdioh_iovar_op(sdioh_info_t *si, const char *name,
143 void *params, int plen, void *arg, int len, bool set);
144
145 /* Issue abort to the specified function and clear controller as needed */
146 extern int sdioh_abort(sdioh_info_t *si, uint fnc);
147
148 /* Start and Stop SDIO without re-enumerating the SD card. */
149 extern int sdioh_start(sdioh_info_t *si, int stage);
150 extern int sdioh_stop(sdioh_info_t *si);
151
152 /* Wait system lock free */
153 extern int sdioh_waitlockfree(sdioh_info_t *si);
154
155 /* Reset and re-initialize the device */
156 extern int sdioh_sdio_reset(sdioh_info_t *si);
157
158 #ifdef BCMSPI
159 /* Function to pass gSPI specific device-status bits to dhd. */
160 extern uint32 sdioh_get_dstatus(sdioh_info_t *si);
161
162 /* chipid and chiprev info for lower layers to control sw WAR's for hw bugs. */
163 extern void sdioh_chipinfo(sdioh_info_t *si, uint32 chip, uint32 chiprev);
164 extern void sdioh_dwordmode(sdioh_info_t *si, bool set);
165 #endif /* BCMSPI */
166
167 #if defined(BCMSDIOH_STD)
168 #define SDIOH_SLEEP_ENABLED
169 #endif // endif
170 extern SDIOH_API_RC sdioh_sleep(sdioh_info_t *si, bool enab);
171
172 /* GPIO support */
173 extern SDIOH_API_RC sdioh_gpio_init(sdioh_info_t *sd);
174 extern bool sdioh_gpioin(sdioh_info_t *sd, uint32 gpio);
175 extern SDIOH_API_RC sdioh_gpioouten(sdioh_info_t *sd, uint32 gpio);
176 extern SDIOH_API_RC sdioh_gpioout(sdioh_info_t *sd, uint32 gpio, bool enab);
177 extern uint sdioh_set_mode(sdioh_info_t *sd, uint mode);
178
179 #endif /* _sdio_api_h_ */