Commit | Line | Data |
---|---|---|
a9533e7e HP |
1 | /* |
2 | * Copyright (c) 2010 Broadcom Corporation | |
3 | * | |
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. | |
7 | * | |
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. | |
15 | */ | |
16 | ||
17 | #ifndef _sdio_api_h_ | |
18 | #define _sdio_api_h_ | |
19 | ||
c55a1223 RV |
20 | #include "sdio_host.h" |
21 | ||
a9533e7e HP |
22 | #define SDIOH_API_RC_SUCCESS (0x00) |
23 | #define SDIOH_API_RC_FAIL (0x01) | |
24 | #define SDIOH_API_SUCCESS(status) (status == 0) | |
25 | ||
26 | #define SDIOH_READ 0 /* Read request */ | |
27 | #define SDIOH_WRITE 1 /* Write request */ | |
28 | ||
29 | #define SDIOH_DATA_FIX 0 /* Fixed addressing */ | |
30 | #define SDIOH_DATA_INC 1 /* Incremental addressing */ | |
31 | ||
32 | #define SDIOH_CMD_TYPE_NORMAL 0 /* Normal command */ | |
33 | #define SDIOH_CMD_TYPE_APPEND 1 /* Append command */ | |
34 | #define SDIOH_CMD_TYPE_CUTTHRU 2 /* Cut-through command */ | |
35 | ||
36 | #define SDIOH_DATA_PIO 0 /* PIO mode */ | |
37 | #define SDIOH_DATA_DMA 1 /* DMA mode */ | |
38 | ||
a9533e7e HP |
39 | /* callback function, taking one arg */ |
40 | typedef void (*sdioh_cb_fn_t) (void *); | |
41 | ||
42 | /* attach, return handler on success, NULL if failed. | |
43 | * The handler shall be provided by all subsequent calls. No local cache | |
44 | * cfghdl points to the starting address of pci device mapped memory | |
45 | */ | |
294f2439 | 46 | extern struct sdioh_info *brcmf_sdioh_attach(void *cfghdl, uint irq); |
3c793822 RV |
47 | extern int brcmf_sdioh_detach(struct sdioh_info *si); |
48 | extern int brcmf_sdioh_interrupt_register(struct sdioh_info *si, | |
a9533e7e | 49 | sdioh_cb_fn_t fn, void *argh); |
3c793822 | 50 | extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *si); |
a9533e7e HP |
51 | |
52 | /* query whether SD interrupt is enabled or not */ | |
3c793822 | 53 | extern int |
294f2439 | 54 | brcmf_sdioh_interrupt_query(struct sdioh_info *si, bool *onoff); |
a9533e7e HP |
55 | |
56 | /* enable or disable SD interrupt */ | |
3c793822 | 57 | extern int |
294f2439 | 58 | brcmf_sdioh_interrupt_set(struct sdioh_info *si, bool enable_disable); |
a9533e7e | 59 | |
762c2a36 | 60 | #if defined(BCMDBG) |
294f2439 | 61 | extern bool brcmf_sdioh_interrupt_pending(struct sdioh_info *si); |
a9533e7e HP |
62 | #endif |
63 | ||
294f2439 RV |
64 | extern int brcmf_sdioh_claim_host_and_lock(struct sdioh_info *si); |
65 | extern int brcmf_sdioh_release_host_and_unlock(struct sdioh_info *si); | |
a9533e7e HP |
66 | |
67 | /* read or write one byte using cmd52 */ | |
3c793822 | 68 | extern int |
294f2439 | 69 | brcmf_sdioh_request_byte(struct sdioh_info *si, uint rw, uint fnc, uint addr, |
54ca2969 | 70 | u8 *byte); |
a9533e7e HP |
71 | |
72 | /* read or write 2/4 bytes using cmd53 */ | |
3c793822 | 73 | extern int |
294f2439 RV |
74 | brcmf_sdioh_request_word(struct sdioh_info *si, uint cmd_type, |
75 | uint rw, uint fnc, uint addr, | |
76 | u32 *word, uint nbyte); | |
a9533e7e HP |
77 | |
78 | /* read or write any buffer using cmd53 */ | |
3c793822 | 79 | extern int |
294f2439 RV |
80 | brcmf_sdioh_request_buffer(struct sdioh_info *si, uint pio_dma, |
81 | uint fix_inc, uint rw, uint fnc_num, | |
82 | u32 addr, uint regwidth, | |
83 | u32 buflen, u8 *buffer, struct sk_buff *pkt); | |
a9533e7e HP |
84 | |
85 | /* get cis data */ | |
3c793822 | 86 | extern int |
294f2439 | 87 | brcmf_sdioh_cis_read(struct sdioh_info *si, uint fuc, u8 *cis, u32 length); |
a9533e7e | 88 | |
3c793822 | 89 | extern int |
294f2439 | 90 | brcmf_sdioh_cfg_read(struct sdioh_info *si, uint fuc, u32 addr, u8 *data); |
3c793822 | 91 | extern int |
294f2439 | 92 | brcmf_sdioh_cfg_write(struct sdioh_info *si, uint fuc, u32 addr, u8 *data); |
a9533e7e HP |
93 | |
94 | /* query number of io functions */ | |
294f2439 | 95 | extern uint brcmf_sdioh_query_iofnum(struct sdioh_info *si); |
a9533e7e HP |
96 | |
97 | /* handle iovars */ | |
294f2439 | 98 | extern int brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name, |
a9533e7e HP |
99 | void *params, int plen, void *arg, int len, bool set); |
100 | ||
101 | /* Issue abort to the specified function and clear controller as needed */ | |
294f2439 | 102 | extern int brcmf_sdioh_abort(struct sdioh_info *si, uint fnc); |
a9533e7e HP |
103 | |
104 | /* Start and Stop SDIO without re-enumerating the SD card. */ | |
294f2439 RV |
105 | extern int brcmf_sdioh_start(struct sdioh_info *si, int stage); |
106 | extern int brcmf_sdioh_stop(struct sdioh_info *si); | |
a9533e7e HP |
107 | |
108 | /* Reset and re-initialize the device */ | |
294f2439 | 109 | extern int brcmf_sdioh_reset(struct sdioh_info *si); |
a9533e7e HP |
110 | |
111 | /* Helper function */ | |
677226aa | 112 | void *brcmf_sdcard_get_sdioh(struct brcmf_sdio *sdh); |
a9533e7e HP |
113 | |
114 | #endif /* _sdio_api_h_ */ |