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 #include "sdio_host.h"
22 #define SDIOH_API_RC_SUCCESS (0x00)
23 #define SDIOH_API_RC_FAIL (0x01)
24 #define SDIOH_API_SUCCESS(status) (status == 0)
26 #define SDIOH_READ 0 /* Read request */
27 #define SDIOH_WRITE 1 /* Write request */
29 #define SDIOH_DATA_FIX 0 /* Fixed addressing */
30 #define SDIOH_DATA_INC 1 /* Incremental addressing */
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 */
36 #define SDIOH_DATA_PIO 0 /* PIO mode */
37 #define SDIOH_DATA_DMA 1 /* DMA mode */
39 /* callback function, taking one arg */
40 typedef void (*sdioh_cb_fn_t) (void *);
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
46 extern struct sdioh_info *brcmf_sdioh_attach(void *cfghdl, uint irq);
47 extern int brcmf_sdioh_detach(struct sdioh_info *si);
48 extern int brcmf_sdioh_interrupt_register(struct sdioh_info *si,
49 sdioh_cb_fn_t fn, void *argh);
50 extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *si);
52 /* query whether SD interrupt is enabled or not */
54 brcmf_sdioh_interrupt_query(struct sdioh_info *si, bool *onoff);
56 /* enable or disable SD interrupt */
58 brcmf_sdioh_interrupt_set(struct sdioh_info *si, bool enable_disable);
61 extern bool brcmf_sdioh_interrupt_pending(struct sdioh_info *si);
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);
67 /* read or write one byte using cmd52 */
69 brcmf_sdioh_request_byte(struct sdioh_info *si, uint rw, uint fnc, uint addr,
72 /* read or write 2/4 bytes using cmd53 */
74 brcmf_sdioh_request_word(struct sdioh_info *si, uint cmd_type,
75 uint rw, uint fnc, uint addr,
76 u32 *word, uint nbyte);
78 /* read or write any buffer using cmd53 */
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);
87 brcmf_sdioh_cis_read(struct sdioh_info *si, uint fuc, u8 *cis, u32 length);
90 brcmf_sdioh_cfg_read(struct sdioh_info *si, uint fuc, u32 addr, u8 *data);
92 brcmf_sdioh_cfg_write(struct sdioh_info *si, uint fuc, u32 addr, u8 *data);
94 /* query number of io functions */
95 extern uint brcmf_sdioh_query_iofnum(struct sdioh_info *si);
98 extern int brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name,
99 void *params, int plen, void *arg, int len, bool set);
101 /* Issue abort to the specified function and clear controller as needed */
102 extern int brcmf_sdioh_abort(struct sdioh_info *si, uint fnc);
104 /* Start and Stop SDIO without re-enumerating the SD card. */
105 extern int brcmf_sdioh_start(struct sdioh_info *si, int stage);
106 extern int brcmf_sdioh_stop(struct sdioh_info *si);
108 /* Reset and re-initialize the device */
109 extern int brcmf_sdioh_reset(struct sdioh_info *si);
111 /* Helper function */
112 void *brcmf_sdcard_get_sdioh(struct brcmf_sdio *sdh);
114 /* Watchdog timer interface for pm ops */
115 extern void brcmf_sdio_wdtmr_enable(bool enable);
117 #endif /* _sdio_api_h_ */