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_READ 0 /* Read request */
23 #define SDIOH_WRITE 1 /* Write request */
25 #define SDIOH_DATA_FIX 0 /* Fixed addressing */
26 #define SDIOH_DATA_INC 1 /* Incremental addressing */
28 #define SDIOH_CMD_TYPE_NORMAL 0 /* Normal command */
29 #define SDIOH_CMD_TYPE_APPEND 1 /* Append command */
30 #define SDIOH_CMD_TYPE_CUTTHRU 2 /* Cut-through command */
32 #define SDIOH_DATA_PIO 0 /* PIO mode */
33 #define SDIOH_DATA_DMA 1 /* DMA mode */
35 /* internal return code */
39 /* Common msglevel constants */
40 #define SDH_ERROR_VAL 0x0001 /* Error */
41 #define SDH_TRACE_VAL 0x0002 /* Trace */
42 #define SDH_INFO_VAL 0x0004 /* Info */
43 #define SDH_DEBUG_VAL 0x0008 /* Debug */
44 #define SDH_DATA_VAL 0x0010 /* Data */
45 #define SDH_CTRL_VAL 0x0020 /* Control Regs */
46 #define SDH_LOG_VAL 0x0040 /* Enable bcmlog */
47 #define SDH_DMA_VAL 0x0080 /* DMA */
52 if ((sd_msglevel & SDH_ERROR_VAL) && net_ratelimit()) \
57 if ((sd_msglevel & SDH_TRACE_VAL) && net_ratelimit()) \
62 if ((sd_msglevel & SDH_INFO_VAL) && net_ratelimit()) \
67 if ((sd_msglevel & SDH_DEBUG_VAL) && net_ratelimit()) \
72 if ((sd_msglevel & SDH_DATA_VAL) && net_ratelimit()) \
77 if ((sd_msglevel & SDH_CTRL_VAL) && net_ratelimit()) \
96 struct osl_info
*osh
; /* osh handler */
97 bool client_intr_enabled
; /* interrupt connnected flag */
98 bool intr_handler_valid
; /* client driver interrupt handler valid */
99 void (*intr_handler
)(void *); /* registered interrupt handler */
100 void *intr_handler_arg
; /* argument to call interrupt handler */
101 u16 intmask
; /* Current active interrupts */
102 void *sdos_info
; /* Pointer to per-OS private data */
104 uint irq
; /* Client irq */
105 int intrcount
; /* Client interrupts */
106 bool sd_blockmode
; /* sd_blockmode == false => 64 Byte Cmd 53s. */
107 /* Must be on for sd_multiblock to be effective */
108 bool use_client_ints
; /* If this is false, make sure to restore */
109 int client_block_size
[SDIOD_MAX_IOFUNCS
]; /* Blocksize */
110 u8 num_funcs
; /* Supported funcs on client */
112 u32 func_cis_ptr
[SDIOD_MAX_IOFUNCS
];
114 uint max_dma_descriptors
; /* DMA Descriptors supported by this controller. */
115 /* SDDMA_DESCRIPTOR SGList[32]; *//* Scatter/Gather DMA List */
118 struct brcmf_sdmmc_instance
{
119 struct sdioh_info
*sd
;
120 struct sdio_func
*func
[SDIOD_MAX_IOFUNCS
];
124 /* Allocate/init/free per-OS private data */
125 extern int brcmf_sdioh_osinit(struct sdioh_info
*sd
);
126 extern void brcmf_sdioh_osfree(struct sdioh_info
*sd
);
128 /* OS-independent interrupt handler */
129 extern bool brcmf_sdioh_check_client_intr(struct sdioh_info
*sd
);
131 /* Core interrupt enable/disable of device interrupts */
132 extern void brcmf_sdioh_dev_intr_on(struct sdioh_info
*sd
);
133 extern void brcmf_sdioh_dev_intr_off(struct sdioh_info
*sd
);
135 /* Register mapping routines */
136 extern u32
*brcmf_sdioh_reg_map(s32 addr
, int size
);
137 extern void brcmf_sdioh_reg_unmap(s32 addr
, int size
);
139 /* Interrupt (de)registration routines */
140 extern int brcmf_sdioh_register_irq(struct sdioh_info
*sd
, uint irq
);
141 extern void brcmf_sdioh_free_irq(uint irq
, struct sdioh_info
*sd
);
143 /* attach, return handler on success, NULL if failed.
144 * The handler shall be provided by all subsequent calls. No local cache
145 * cfghdl points to the starting address of pci device mapped memory
147 extern struct sdioh_info
*brcmf_sdioh_attach(void *cfghdl
, uint irq
);
148 extern int brcmf_sdioh_detach(struct sdioh_info
*si
);
151 brcmf_sdioh_interrupt_register(struct sdioh_info
*si
,
152 void (*sdioh_cb_fn
)(void *), void *argh
);
154 extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info
*si
);
156 /* query whether SD interrupt is enabled or not */
158 brcmf_sdioh_interrupt_query(struct sdioh_info
*si
, bool *onoff
);
160 /* enable or disable SD interrupt */
162 brcmf_sdioh_interrupt_set(struct sdioh_info
*si
, bool enable_disable
);
164 /* read or write one byte using cmd52 */
166 brcmf_sdioh_request_byte(struct sdioh_info
*si
, uint rw
, uint fnc
, uint addr
,
169 /* read or write 2/4 bytes using cmd53 */
171 brcmf_sdioh_request_word(struct sdioh_info
*si
, uint cmd_type
,
172 uint rw
, uint fnc
, uint addr
,
173 u32
*word
, uint nbyte
);
175 /* read or write any buffer using cmd53 */
177 brcmf_sdioh_request_buffer(struct sdioh_info
*si
, uint pio_dma
,
178 uint fix_inc
, uint rw
, uint fnc_num
,
179 u32 addr
, uint regwidth
,
180 u32 buflen
, u8
*buffer
, struct sk_buff
*pkt
);
184 brcmf_sdioh_cis_read(struct sdioh_info
*si
, uint fuc
, u8
*cis
, u32 length
);
187 brcmf_sdioh_cfg_read(struct sdioh_info
*si
, uint fuc
, u32 addr
, u8
*data
);
189 brcmf_sdioh_cfg_write(struct sdioh_info
*si
, uint fuc
, u32 addr
, u8
*data
);
191 /* query number of io functions */
192 extern uint
brcmf_sdioh_query_iofnum(struct sdioh_info
*si
);
195 extern int brcmf_sdioh_iovar_op(struct sdioh_info
*si
, const char *name
,
196 void *params
, int plen
, void *arg
, int len
, bool set
);
198 /* Issue abort to the specified function and clear controller as needed */
199 extern int brcmf_sdioh_abort(struct sdioh_info
*si
, uint fnc
);
201 /* Helper function */
202 void *brcmf_sdcard_get_sdioh(struct brcmf_sdio_card
*card
);
204 /* Watchdog timer interface for pm ops */
205 extern void brcmf_sdio_wdtmr_enable(bool enable
);
207 extern uint sd_msglevel
; /* Debug message level */
209 extern struct brcmf_sdmmc_instance
*gInstance
;
211 #endif /* _sdio_api_h_ */
This page took 0.037582 seconds and 5 git commands to generate.