2 * Copyright (c) 2010 Broadcom Corporation
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #define SDIOH_API_RC_SUCCESS (0x00)
21 #define SDIOH_API_RC_FAIL (0x01)
22 #define SDIOH_API_SUCCESS(status) (status == 0)
24 #define SDIOH_READ 0 /* Read request */
25 #define SDIOH_WRITE 1 /* Write request */
27 #define SDIOH_DATA_FIX 0 /* Fixed addressing */
28 #define SDIOH_DATA_INC 1 /* Incremental addressing */
30 #define SDIOH_CMD_TYPE_NORMAL 0 /* Normal command */
31 #define SDIOH_CMD_TYPE_APPEND 1 /* Append command */
32 #define SDIOH_CMD_TYPE_CUTTHRU 2 /* Cut-through command */
34 #define SDIOH_DATA_PIO 0 /* PIO mode */
35 #define SDIOH_DATA_DMA 1 /* DMA mode */
37 typedef int SDIOH_API_RC
;
39 /* SDio Host structure */
40 typedef struct sdioh_info sdioh_info_t
;
42 /* callback function, taking one arg */
43 typedef void (*sdioh_cb_fn_t
) (void *);
45 /* attach, return handler on success, NULL if failed.
46 * The handler shall be provided by all subsequent calls. No local cache
47 * cfghdl points to the starting address of pci device mapped memory
49 extern sdioh_info_t
*sdioh_attach(void *cfghdl
, uint irq
);
50 extern SDIOH_API_RC
sdioh_detach(sdioh_info_t
*si
);
51 extern SDIOH_API_RC
sdioh_interrupt_register(sdioh_info_t
*si
,
52 sdioh_cb_fn_t fn
, void *argh
);
53 extern SDIOH_API_RC
sdioh_interrupt_deregister(sdioh_info_t
*si
);
55 /* query whether SD interrupt is enabled or not */
56 extern SDIOH_API_RC
sdioh_interrupt_query(sdioh_info_t
*si
, bool *onoff
);
58 /* enable or disable SD interrupt */
59 extern SDIOH_API_RC
sdioh_interrupt_set(sdioh_info_t
*si
, bool enable_disable
);
61 #if defined(DHD_DEBUG)
62 extern bool sdioh_interrupt_pending(sdioh_info_t
*si
);
65 extern int sdioh_claim_host_and_lock(sdioh_info_t
*si
);
66 extern int sdioh_release_host_and_unlock(sdioh_info_t
*si
);
68 /* read or write one byte using cmd52 */
69 extern SDIOH_API_RC
sdioh_request_byte(sdioh_info_t
*si
, uint rw
, uint fnc
,
72 /* read or write 2/4 bytes using cmd53 */
73 extern SDIOH_API_RC
sdioh_request_word(sdioh_info_t
*si
, uint cmd_type
,
74 uint rw
, uint fnc
, uint addr
,
75 u32
*word
, uint nbyte
);
77 /* read or write any buffer using cmd53 */
78 extern SDIOH_API_RC
sdioh_request_buffer(sdioh_info_t
*si
, uint pio_dma
,
79 uint fix_inc
, uint rw
, uint fnc_num
,
80 u32 addr
, uint regwidth
,
81 u32 buflen
, u8
*buffer
,
85 extern SDIOH_API_RC
sdioh_cis_read(sdioh_info_t
*si
, uint fuc
, u8
*cis
,
88 extern SDIOH_API_RC
sdioh_cfg_read(sdioh_info_t
*si
, uint fuc
, u32 addr
,
90 extern SDIOH_API_RC
sdioh_cfg_write(sdioh_info_t
*si
, uint fuc
, u32 addr
,
93 /* query number of io functions */
94 extern uint
sdioh_query_iofnum(sdioh_info_t
*si
);
97 extern int sdioh_iovar_op(sdioh_info_t
*si
, const char *name
,
98 void *params
, int plen
, void *arg
, int len
, bool set
);
100 /* Issue abort to the specified function and clear controller as needed */
101 extern int sdioh_abort(sdioh_info_t
*si
, uint fnc
);
103 /* Start and Stop SDIO without re-enumerating the SD card. */
104 extern int sdioh_start(sdioh_info_t
*si
, int stage
);
105 extern int sdioh_stop(sdioh_info_t
*si
);
107 /* Reset and re-initialize the device */
108 extern int sdioh_sdio_reset(sdioh_info_t
*si
);
110 /* Helper function */
111 void *bcmsdh_get_sdioh(bcmsdh_info_t
*sdh
);
113 #endif /* _sdio_api_h_ */