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 | ||
20 | #define SDIOH_API_RC_SUCCESS (0x00) | |
21 | #define SDIOH_API_RC_FAIL (0x01) | |
22 | #define SDIOH_API_SUCCESS(status) (status == 0) | |
23 | ||
24 | #define SDIOH_READ 0 /* Read request */ | |
25 | #define SDIOH_WRITE 1 /* Write request */ | |
26 | ||
27 | #define SDIOH_DATA_FIX 0 /* Fixed addressing */ | |
28 | #define SDIOH_DATA_INC 1 /* Incremental addressing */ | |
29 | ||
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 */ | |
33 | ||
34 | #define SDIOH_DATA_PIO 0 /* PIO mode */ | |
35 | #define SDIOH_DATA_DMA 1 /* DMA mode */ | |
36 | ||
37 | typedef int SDIOH_API_RC; | |
38 | ||
39 | /* SDio Host structure */ | |
40 | typedef struct sdioh_info sdioh_info_t; | |
41 | ||
42 | /* callback function, taking one arg */ | |
43 | typedef void (*sdioh_cb_fn_t) (void *); | |
44 | ||
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 | |
48 | */ | |
e69284f2 | 49 | extern sdioh_info_t *sdioh_attach(struct osl_info *osh, void *cfghdl, uint irq); |
8da4a3a0 | 50 | extern SDIOH_API_RC sdioh_detach(sdioh_info_t *si); |
7cc4a4c0 | 51 | extern SDIOH_API_RC sdioh_interrupt_register(sdioh_info_t *si, |
a9533e7e | 52 | sdioh_cb_fn_t fn, void *argh); |
7cc4a4c0 | 53 | extern SDIOH_API_RC sdioh_interrupt_deregister(sdioh_info_t *si); |
a9533e7e HP |
54 | |
55 | /* query whether SD interrupt is enabled or not */ | |
7cc4a4c0 | 56 | extern SDIOH_API_RC sdioh_interrupt_query(sdioh_info_t *si, bool *onoff); |
a9533e7e HP |
57 | |
58 | /* enable or disable SD interrupt */ | |
7cc4a4c0 | 59 | extern SDIOH_API_RC sdioh_interrupt_set(sdioh_info_t *si, bool enable_disable); |
a9533e7e | 60 | |
26e80554 | 61 | #if defined(DHD_DEBUG) |
7cc4a4c0 | 62 | extern bool sdioh_interrupt_pending(sdioh_info_t *si); |
a9533e7e HP |
63 | #endif |
64 | ||
7cc4a4c0 JC |
65 | extern int sdioh_claim_host_and_lock(sdioh_info_t *si); |
66 | extern int sdioh_release_host_and_unlock(sdioh_info_t *si); | |
a9533e7e HP |
67 | |
68 | /* read or write one byte using cmd52 */ | |
7cc4a4c0 | 69 | extern SDIOH_API_RC sdioh_request_byte(sdioh_info_t *si, uint rw, uint fnc, |
de9bca63 | 70 | uint addr, u8 *byte); |
a9533e7e HP |
71 | |
72 | /* read or write 2/4 bytes using cmd53 */ | |
7cc4a4c0 | 73 | extern SDIOH_API_RC sdioh_request_word(sdioh_info_t *si, uint cmd_type, |
a9533e7e | 74 | uint rw, uint fnc, uint addr, |
66cbd3ab | 75 | u32 *word, uint nbyte); |
a9533e7e HP |
76 | |
77 | /* read or write any buffer using cmd53 */ | |
7cc4a4c0 | 78 | extern SDIOH_API_RC sdioh_request_buffer(sdioh_info_t *si, uint pio_dma, |
a9533e7e | 79 | uint fix_inc, uint rw, uint fnc_num, |
66cbd3ab GKH |
80 | u32 addr, uint regwidth, |
81 | u32 buflen, u8 *buffer, | |
c26b1378 | 82 | struct sk_buff *pkt); |
a9533e7e HP |
83 | |
84 | /* get cis data */ | |
de9bca63 | 85 | extern SDIOH_API_RC sdioh_cis_read(sdioh_info_t *si, uint fuc, u8 *cis, |
66cbd3ab | 86 | u32 length); |
a9533e7e | 87 | |
66cbd3ab | 88 | extern SDIOH_API_RC sdioh_cfg_read(sdioh_info_t *si, uint fuc, u32 addr, |
de9bca63 | 89 | u8 *data); |
66cbd3ab | 90 | extern SDIOH_API_RC sdioh_cfg_write(sdioh_info_t *si, uint fuc, u32 addr, |
de9bca63 | 91 | u8 *data); |
a9533e7e HP |
92 | |
93 | /* query number of io functions */ | |
7cc4a4c0 | 94 | extern uint sdioh_query_iofnum(sdioh_info_t *si); |
a9533e7e HP |
95 | |
96 | /* handle iovars */ | |
7cc4a4c0 | 97 | extern int sdioh_iovar_op(sdioh_info_t *si, const char *name, |
a9533e7e HP |
98 | void *params, int plen, void *arg, int len, bool set); |
99 | ||
100 | /* Issue abort to the specified function and clear controller as needed */ | |
7cc4a4c0 | 101 | extern int sdioh_abort(sdioh_info_t *si, uint fnc); |
a9533e7e HP |
102 | |
103 | /* Start and Stop SDIO without re-enumerating the SD card. */ | |
7cc4a4c0 JC |
104 | extern int sdioh_start(sdioh_info_t *si, int stage); |
105 | extern int sdioh_stop(sdioh_info_t *si); | |
a9533e7e HP |
106 | |
107 | /* Reset and re-initialize the device */ | |
7cc4a4c0 | 108 | extern int sdioh_sdio_reset(sdioh_info_t *si); |
a9533e7e HP |
109 | |
110 | /* Helper function */ | |
7cc4a4c0 | 111 | void *bcmsdh_get_sdioh(bcmsdh_info_t *sdh); |
a9533e7e HP |
112 | |
113 | #endif /* _sdio_api_h_ */ |