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 <linux/skbuff.h>
21 extern const uint brcmf_sdio_msglevel
;
27 #define SDIOD_FBR_SIZE 0x100
30 #define SDIO_FUNC_ENABLE_1 0x02
31 #define SDIO_FUNC_ENABLE_2 0x04
34 #define SDIO_FUNC_READY_1 0x02
35 #define SDIO_FUNC_READY_2 0x04
38 #define INTR_STATUS_FUNC1 0x2
39 #define INTR_STATUS_FUNC2 0x4
41 /* Maximum number of I/O funcs */
42 #define SDIOD_MAX_IOFUNCS 7
44 /* forward declarations */
45 struct brcmf_sdio_card
;
47 /* Attach and build an interface to the underlying SD host driver.
48 * - Allocates resources (structs, arrays, mem, OS handles, etc) needed by
50 * - Returns the sdio card handle and virtual address base for register access.
51 * The returned handle should be used in all subsequent calls, but the bcmsh
52 * implementation may maintain a single "default" handle (e.g. the first or
53 * most recent one) to enable single-instance implementations to pass NULL.
55 extern struct brcmf_sdio_card
*brcmf_sdcard_attach(void *cfghdl
, void **regsva
,
58 /* Detach - freeup resources allocated in attach */
59 extern int brcmf_sdcard_detach(struct brcmf_sdio_card
*card
);
61 /* Query if SD device interrupts are enabled */
62 extern bool brcmf_sdcard_intr_query(struct brcmf_sdio_card
*card
);
64 /* Enable/disable SD interrupt */
65 extern int brcmf_sdcard_intr_enable(struct brcmf_sdio_card
*card
);
66 extern int brcmf_sdcard_intr_disable(struct brcmf_sdio_card
*card
);
68 /* Register/deregister device interrupt handler. */
70 brcmf_sdcard_intr_reg(struct brcmf_sdio_card
*card
,
71 void (*fn
)(void *), void *argh
);
73 extern int brcmf_sdcard_intr_dereg(struct brcmf_sdio_card
*card
);
75 /* Register a callback to be called on device removal.
76 * No-op in the case of non-removable/hardwired devices.
79 brcmf_sdcard_devremove_reg(struct brcmf_sdio_card
*card
,
80 void (*fn
)(void *), void *argh
);
82 /* Access SDIO address space (e.g. CCCR) using CMD52 (single-byte interface).
84 * addr: unmodified SDIO-space address
85 * data: data byte to write
86 * err: pointer to error code (or NULL)
88 extern u8
brcmf_sdcard_cfg_read(struct brcmf_sdio_card
*card
, uint func
,
90 extern void brcmf_sdcard_cfg_write(struct brcmf_sdio_card
*card
, uint func
,
91 u32 addr
, u8 data
, int *err
);
93 /* Read/Write 4bytes from/to cfg space */
95 brcmf_sdcard_cfg_read_word(struct brcmf_sdio_card
*card
, uint fnc_num
,
98 extern void brcmf_sdcard_cfg_write_word(struct brcmf_sdio_card
*card
,
99 uint fnc_num
, u32 addr
,
102 /* Read CIS content for specified function.
103 * fn: function whose CIS is being requested (0 is common CIS)
104 * cis: pointer to memory location to place results
105 * length: number of bytes to read
106 * Internally, this routine uses the values from the cis base regs (0x9-0xB)
107 * to form an SDIO-space address to read the data from.
109 extern int brcmf_sdcard_cis_read(struct brcmf_sdio_card
*card
, uint func
,
110 u8
*cis
, uint length
);
112 /* Synchronous access to device (client) core registers via CMD53 to F1.
113 * addr: backplane address (i.e. >= regsva from attach)
114 * size: register width in bytes (2 or 4)
115 * data: data for register write
118 brcmf_sdcard_reg_read(struct brcmf_sdio_card
*card
, u32 addr
, uint size
);
121 brcmf_sdcard_reg_write(struct brcmf_sdio_card
*card
, u32 addr
, uint size
,
124 /* Indicate if last reg read/write failed */
125 extern bool brcmf_sdcard_regfail(struct brcmf_sdio_card
*card
);
127 /* Buffer transfer to/from device (client) core via cmd53.
128 * fn: function number
129 * addr: backplane address (i.e. >= regsva from attach)
130 * flags: backplane width, address increment, sync/async
131 * buf: pointer to memory data buffer
132 * nbytes: number of bytes to transfer to/from buf
133 * pkt: pointer to packet associated with buf (if any)
134 * complete: callback function for command completion (async only)
135 * handle: handle for completion callback (first arg in callback)
136 * Returns 0 or error code.
137 * NOTE: Async operation is not currently supported.
140 brcmf_sdcard_send_buf(struct brcmf_sdio_card
*card
, u32 addr
, uint fn
,
141 uint flags
, u8
*buf
, uint nbytes
, void *pkt
,
142 void (*complete
)(void *handle
, int status
,
146 brcmf_sdcard_recv_buf(struct brcmf_sdio_card
*card
, u32 addr
, uint fn
,
147 uint flags
, u8
*buf
, uint nbytes
, struct sk_buff
*pkt
,
148 void (*complete
)(void *handle
, int status
,
153 #define SDIO_REQ_4BYTE 0x1 /* Four-byte target (backplane) width (vs. two-byte) */
154 #define SDIO_REQ_FIXED 0x2 /* Fixed address (FIFO) (vs. incrementing address) */
155 #define SDIO_REQ_ASYNC 0x4 /* Async request (vs. sync request) */
157 /* Pending (non-error) return code */
158 #define BCME_PENDING 1
160 /* Read/write to memory block (F1, no FIFO) via CMD53 (sync only).
161 * rw: read or write (0/1)
162 * addr: direct SDIO address
163 * buf: pointer to memory data buffer
164 * nbytes: number of bytes to transfer to/from buf
165 * Returns 0 or error code.
167 extern int brcmf_sdcard_rwdata(struct brcmf_sdio_card
*card
, uint rw
, u32 addr
,
168 u8
*buf
, uint nbytes
);
170 /* Issue an abort to the specified function */
171 extern int brcmf_sdcard_abort(struct brcmf_sdio_card
*card
, uint fn
);
173 /* Returns the "Device ID" of target device on the SDIO bus. */
174 extern int brcmf_sdcard_query_device(struct brcmf_sdio_card
*card
);
176 /* Returns the number of IO functions reported by the device */
177 extern uint
brcmf_sdcard_query_iofnum(struct brcmf_sdio_card
*card
);
179 /* Miscellaneous knob tweaker. */
180 extern int brcmf_sdcard_iovar_op(struct brcmf_sdio_card
*card
, const char *name
,
181 void *params
, int plen
, void *arg
, int len
,
184 /* helper functions */
186 extern void *brcmf_sdcard_get_sdioh(struct brcmf_sdio_card
*card
);
188 /* callback functions */
189 struct brcmf_sdioh_driver
{
190 /* attach to device */
191 void *(*attach
) (u16 vend_id
, u16 dev_id
, u16 bus
, u16 slot
,
192 u16 func
, uint bustype
, void *regsva
, void *param
);
193 /* detach from device */
194 void (*detach
) (void *ch
);
199 /* platform specific/high level functions */
200 extern int brcmf_sdio_function_init(void);
201 extern int brcmf_sdio_register(struct brcmf_sdioh_driver
*driver
);
202 extern void brcmf_sdio_unregister(void);
203 extern bool brcmf_sdio_chipmatch(u16 vendor
, u16 device
);
204 extern void brcmf_sdio_function_cleanup(void);
205 extern int brcmf_sdio_probe(struct device
*dev
);
206 extern int brcmf_sdio_remove(struct device
*dev
);
208 /* Function to pass device-status bits to DHD. */
209 extern u32
brcmf_sdcard_get_dstatus(struct brcmf_sdio_card
*card
);
211 /* Function to return current window addr */
212 extern u32
brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card
*card
);
214 /* Function to pass chipid and rev to lower layers for controlling pr's */
215 extern void brcmf_sdcard_chipinfo(struct brcmf_sdio_card
*card
, u32 chip
,
218 #endif /* _BRCM_SDH_H_ */
This page took 0.035551 seconds and 5 git commands to generate.