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