hc
2023-02-13 e440ec23c5a540cdd3f7464e8779219be6fd3d95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Definitions for API from sdio common code (bcmsdh) to individual
 * host controller drivers.
 *
 * Copyright (C) 1999-2017, Broadcom Corporation
 * 
 *      Unless you and Broadcom execute a separate written software license
 * agreement governing use of this software, this software is licensed to you
 * under the terms of the GNU General Public License version 2 (the "GPL"),
 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
 * following added to such license:
 * 
 *      As a special exception, the copyright holders of this software give you
 * permission to link this software with independent modules, and to copy and
 * distribute the resulting executable under terms of your choice, provided that
 * you also meet, for each linked independent module, the terms and conditions of
 * the license of that module.  An independent module is a module which is not
 * derived from this software.  The special exception does not apply to any
 * modifications of the software.
 * 
 *      Notwithstanding the above, under no circumstances may you combine this
 * software in any way with any other Broadcom software provided under a license
 * other than the GPL, without Broadcom's express prior written consent.
 *
 *
 * <<Broadcom-WL-IPTag/Open:>>
 *
 * $Id: bcmsdbus.h 644725 2016-06-21 12:26:04Z $
 */
 
#ifndef    _sdio_api_h_
#define    _sdio_api_h_
 
#if defined(BT_OVER_SDIO)
#include <linux/mmc/sdio_func.h>
#endif /* defined (BT_OVER_SDIO) */
 
 
#define SDIOH_API_RC_SUCCESS                          (0x00)
#define SDIOH_API_RC_FAIL                          (0x01)
#define SDIOH_API_SUCCESS(status) (status == 0)
 
#define SDIOH_READ              0    /* Read request */
#define SDIOH_WRITE             1    /* Write request */
 
#define SDIOH_DATA_FIX          0    /* Fixed addressing */
#define SDIOH_DATA_INC          1    /* Incremental addressing */
 
#define SDIOH_CMD_TYPE_NORMAL   0       /* Normal command */
#define SDIOH_CMD_TYPE_APPEND   1       /* Append command */
#define SDIOH_CMD_TYPE_CUTTHRU  2       /* Cut-through command */
 
#define SDIOH_DATA_PIO          0       /* PIO mode */
#define SDIOH_DATA_DMA          1       /* DMA mode */
 
/* Max number of glommed pkts */
#ifdef CUSTOM_MAX_TXGLOM_SIZE
#define SDPCM_MAXGLOM_SIZE  CUSTOM_MAX_TXGLOM_SIZE
#else
#define SDPCM_MAXGLOM_SIZE    36
#endif /* CUSTOM_MAX_TXGLOM_SIZE */
 
#define SDPCM_TXGLOM_CPY 0            /* SDIO 2.0 should use copy mode */
#define SDPCM_TXGLOM_MDESC    1        /* SDIO 3.0 should use multi-desc mode */
 
#ifdef CUSTOM_DEF_TXGLOM_SIZE
#define SDPCM_DEFGLOM_SIZE  CUSTOM_DEF_TXGLOM_SIZE
#else
#define SDPCM_DEFGLOM_SIZE SDPCM_MAXGLOM_SIZE
#endif /* CUSTOM_DEF_TXGLOM_SIZE */
 
#if SDPCM_DEFGLOM_SIZE > SDPCM_MAXGLOM_SIZE
#warning "SDPCM_DEFGLOM_SIZE cannot be higher than SDPCM_MAXGLOM_SIZE!!"
#undef SDPCM_DEFGLOM_SIZE
#define SDPCM_DEFGLOM_SIZE SDPCM_MAXGLOM_SIZE
#endif
 
#ifdef PKT_STATICS
typedef struct pkt_statics {
   uint16    event_count;
   uint32    event_size;
   uint16    ctrl_count;
   uint32    ctrl_size;
   uint32    data_count;
   uint32    data_size;
   uint32    glom_cnt[SDPCM_MAXGLOM_SIZE];
   uint16    glom_max;
   uint16    glom_count;
   uint32    glom_size;
   uint16    test_count;
   uint32    test_size;
   uint32    glom_cnt_us[SDPCM_MAXGLOM_SIZE];
} pkt_statics_t;
#endif
 
typedef int SDIOH_API_RC;
 
/* SDio Host structure */
typedef struct sdioh_info sdioh_info_t;
 
/* callback function, taking one arg */
typedef void (*sdioh_cb_fn_t)(void *);
#if defined(BT_OVER_SDIO)
extern
void sdioh_sdmmc_card_enable_func_f3(sdioh_info_t *sd, struct sdio_func *func);
#endif /* defined (BT_OVER_SDIO) */
 
extern SDIOH_API_RC sdioh_interrupt_register(sdioh_info_t *si, sdioh_cb_fn_t fn, void *argh);
extern SDIOH_API_RC sdioh_interrupt_deregister(sdioh_info_t *si);
 
/* query whether SD interrupt is enabled or not */
extern SDIOH_API_RC sdioh_interrupt_query(sdioh_info_t *si, bool *onoff);
 
/* enable or disable SD interrupt */
extern SDIOH_API_RC sdioh_interrupt_set(sdioh_info_t *si, bool enable_disable);
 
#if defined(DHD_DEBUG)
extern bool sdioh_interrupt_pending(sdioh_info_t *si);
#endif
 
/* read or write one byte using cmd52 */
extern SDIOH_API_RC sdioh_request_byte(sdioh_info_t *si, uint rw, uint fnc, uint addr, uint8 *byte);
 
/* read or write 2/4 bytes using cmd53 */
extern SDIOH_API_RC sdioh_request_word(sdioh_info_t *si, uint cmd_type, uint rw, uint fnc,
   uint addr, uint32 *word, uint nbyte);
 
/* read or write any buffer using cmd53 */
extern SDIOH_API_RC sdioh_request_buffer(sdioh_info_t *si, uint pio_dma, uint fix_inc,
   uint rw, uint fnc_num, uint32 addr, uint regwidth, uint32 buflen, uint8 *buffer,
   void *pkt);
 
/* get cis data */
extern SDIOH_API_RC sdioh_cis_read(sdioh_info_t *si, uint fuc, uint8 *cis, uint32 length);
extern SDIOH_API_RC sdioh_cisaddr_read(sdioh_info_t *sd, uint func, uint8 *cisd, uint32 offset);
 
extern SDIOH_API_RC sdioh_cfg_read(sdioh_info_t *si, uint fuc, uint32 addr, uint8 *data);
extern SDIOH_API_RC sdioh_cfg_write(sdioh_info_t *si, uint fuc, uint32 addr, uint8 *data);
 
/* query number of io functions */
extern uint sdioh_query_iofnum(sdioh_info_t *si);
 
/* handle iovars */
extern int sdioh_iovar_op(sdioh_info_t *si, const char *name,
                          void *params, int plen, void *arg, int len, bool set);
 
/* Issue abort to the specified function and clear controller as needed */
extern int sdioh_abort(sdioh_info_t *si, uint fnc);
 
/* Start and Stop SDIO without re-enumerating the SD card. */
extern int sdioh_start(sdioh_info_t *si, int stage);
extern int sdioh_stop(sdioh_info_t *si);
 
/* Wait system lock free */
extern int sdioh_waitlockfree(sdioh_info_t *si);
 
/* Reset and re-initialize the device */
extern int sdioh_sdio_reset(sdioh_info_t *si);
 
 
 
#if defined(BCMSDIOH_STD)
   #define SDIOH_SLEEP_ENABLED
#endif
extern SDIOH_API_RC sdioh_sleep(sdioh_info_t *si, bool enab);
 
/* GPIO support */
extern SDIOH_API_RC sdioh_gpio_init(sdioh_info_t *sd);
extern bool sdioh_gpioin(sdioh_info_t *sd, uint32 gpio);
extern SDIOH_API_RC sdioh_gpioouten(sdioh_info_t *sd, uint32 gpio);
extern SDIOH_API_RC sdioh_gpioout(sdioh_info_t *sd, uint32 gpio, bool enab);
extern uint sdioh_set_mode(sdioh_info_t *sd, uint mode);
#ifdef PKT_STATICS
extern uint32 sdioh_get_spend_time(sdioh_info_t *sd);
#endif
#ifdef DHD_LOAD_CHIPALIVE
extern bool sdioh_get_sdmmc_sleep(sdioh_info_t *sd);
extern void sdioh_set_sdmmc_sleep(sdioh_info_t *sd, bool sleep);
#endif
 
#endif /* _sdio_api_h_ */