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 typedef int SDIOH_API_RC;
41 /* SDio Host structure */
42 typedef struct sdioh_info sdioh_info_t;
44 /* callback function, taking one arg */
45 typedef void (*sdioh_cb_fn_t) (void *);
47 /* attach, return handler on success, NULL if failed.
48 * The handler shall be provided by all subsequent calls. No local cache
49 * cfghdl points to the starting address of pci device mapped memory
51 extern sdioh_info_t *sdioh_attach(void *cfghdl, uint irq);
52 extern SDIOH_API_RC sdioh_detach(sdioh_info_t *si);
53 extern SDIOH_API_RC sdioh_interrupt_register(sdioh_info_t *si,
54 sdioh_cb_fn_t fn, void *argh);
55 extern SDIOH_API_RC sdioh_interrupt_deregister(sdioh_info_t *si);
57 /* query whether SD interrupt is enabled or not */
58 extern SDIOH_API_RC sdioh_interrupt_query(sdioh_info_t *si, bool *onoff);
60 /* enable or disable SD interrupt */
61 extern SDIOH_API_RC sdioh_interrupt_set(sdioh_info_t *si, bool enable_disable);
63 #if defined(DHD_DEBUG)
64 extern bool sdioh_interrupt_pending(sdioh_info_t *si);
67 extern int sdioh_claim_host_and_lock(sdioh_info_t *si);
68 extern int sdioh_release_host_and_unlock(sdioh_info_t *si);
70 /* read or write one byte using cmd52 */
71 extern SDIOH_API_RC sdioh_request_byte(sdioh_info_t *si, uint rw, uint fnc,
74 /* read or write 2/4 bytes using cmd53 */
75 extern SDIOH_API_RC sdioh_request_word(sdioh_info_t *si, uint cmd_type,
76 uint rw, uint fnc, uint addr,
77 u32 *word, uint nbyte);
79 /* read or write any buffer using cmd53 */
80 extern SDIOH_API_RC sdioh_request_buffer(sdioh_info_t *si, uint pio_dma,
81 uint fix_inc, uint rw, uint fnc_num,
82 u32 addr, uint regwidth,
83 u32 buflen, u8 *buffer,
87 extern SDIOH_API_RC sdioh_cis_read(sdioh_info_t *si, uint fuc, u8 *cis,
90 extern SDIOH_API_RC sdioh_cfg_read(sdioh_info_t *si, uint fuc, u32 addr,
92 extern SDIOH_API_RC sdioh_cfg_write(sdioh_info_t *si, uint fuc, u32 addr,
95 /* query number of io functions */
96 extern uint sdioh_query_iofnum(sdioh_info_t *si);
99 extern int sdioh_iovar_op(sdioh_info_t *si, const char *name,
100 void *params, int plen, void *arg, int len, bool set);
102 /* Issue abort to the specified function and clear controller as needed */
103 extern int sdioh_abort(sdioh_info_t *si, uint fnc);
105 /* Start and Stop SDIO without re-enumerating the SD card. */
106 extern int sdioh_start(sdioh_info_t *si, int stage);
107 extern int sdioh_stop(sdioh_info_t *si);
109 /* Reset and re-initialize the device */
110 extern int sdioh_sdio_reset(sdioh_info_t *si);
112 /* Helper function */
113 void *bcmsdh_get_sdioh(bcmsdh_info_t *sdh);
115 #endif /* _sdio_api_h_ */