18ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/*
28ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * SDIO host client driver interface of Broadcom HNBU
38ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *     export functions to client drivers
48ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *     abstract OS and BUS specific details of SDIO
58ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *
6832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt * Copyright (C) 1999-2012, Broadcom Corporation
78ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *
8832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt *      Unless you and Broadcom execute a separate written software license
98ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * agreement governing use of this software, this software is licensed to you
108ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * under the terms of the GNU General Public License version 2 (the "GPL"),
118ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * available at http://www.broadcom.com/licenses/GPLv2.php, with the
128ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * following added to such license:
138ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *
148ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *      As a special exception, the copyright holders of this software give you
158ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * permission to link this software with independent modules, and to copy and
168ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * distribute the resulting executable under terms of your choice, provided that
178ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * you also meet, for each linked independent module, the terms and conditions of
188ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * the license of that module.  An independent module is a module which is not
198ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * derived from this software.  The special exception does not apply to any
208ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * modifications of the software.
218ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *
228ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *      Notwithstanding the above, under no circumstances may you combine this
238ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * software in any way with any other Broadcom software provided under a license
248ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * other than the GPL, without Broadcom's express prior written consent.
258ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *
268f237d3133b0672c337c27a1e34daad2b4e76f45Dmitry Shmidt * $Id: bcmsdh.h 347614 2012-07-27 10:24:51Z $
27832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt */
28832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt
29832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt/**
30832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt * @file bcmsdh.h
318ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt */
328ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
338ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt#ifndef	_bcmsdh_h_
348ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt#define	_bcmsdh_h_
358ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
368ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt#define BCMSDH_ERROR_VAL	0x0001 /* Error */
378ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt#define BCMSDH_INFO_VAL		0x0002 /* Info */
388ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern const uint bcmsdh_msglevel;
398ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
408ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt#define BCMSDH_ERROR(x)
418ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt#define BCMSDH_INFO(x)
428ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
43832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt#if (defined(BCMSDIOH_STD) || defined(BCMSDIOH_BCM) || defined(BCMSDIOH_SPI))
44832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt#define BCMSDH_ADAPTER
45832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt#endif /* BCMSDIO && (BCMSDIOH_STD || BCMSDIOH_BCM || BCMSDIOH_SPI) */
46832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt
478ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* forward declarations */
488ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidttypedef struct bcmsdh_info bcmsdh_info_t;
498ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidttypedef void (*bcmsdh_cb_fn_t)(void *);
508ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
518ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Attach and build an interface to the underlying SD host driver.
528ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *  - Allocates resources (structs, arrays, mem, OS handles, etc) needed by bcmsdh.
538ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *  - Returns the bcmsdh handle and virtual address base for register access.
548ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *    The returned handle should be used in all subsequent calls, but the bcmsh
558ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *    implementation may maintain a single "default" handle (e.g. the first or
568ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *    most recent one) to enable single-instance implementations to pass NULL.
578ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt */
584a3a0faf9abf605caf9ff7b27755d867b9ac9403Dmitry Shmidt
5966981be398731073dc68d703327d2cf24bd9c6abDmitry Shmidt#if 0 && (NDISVER >= 0x0630) && 1
604a3a0faf9abf605caf9ff7b27755d867b9ac9403Dmitry Shmidtextern bcmsdh_info_t *bcmsdh_attach(osl_t *osh, void *cfghdl,
614a3a0faf9abf605caf9ff7b27755d867b9ac9403Dmitry Shmidt	void **regsva, uint irq, shared_info_t *sh);
624a3a0faf9abf605caf9ff7b27755d867b9ac9403Dmitry Shmidt#else
638ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern bcmsdh_info_t *bcmsdh_attach(osl_t *osh, void *cfghdl, void **regsva, uint irq);
644a3a0faf9abf605caf9ff7b27755d867b9ac9403Dmitry Shmidt#endif
658ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
668ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Detach - freeup resources allocated in attach */
678ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_detach(osl_t *osh, void *sdh);
688ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
698ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Query if SD device interrupts are enabled */
708ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern bool bcmsdh_intr_query(void *sdh);
718ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
728ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Enable/disable SD interrupt */
738ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_intr_enable(void *sdh);
748ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_intr_disable(void *sdh);
758ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
768ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Register/deregister device interrupt handler. */
778ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_intr_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh);
788ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_intr_dereg(void *sdh);
794a3a0faf9abf605caf9ff7b27755d867b9ac9403Dmitry Shmidt/* Enable/disable SD card interrupt forward */
804a3a0faf9abf605caf9ff7b27755d867b9ac9403Dmitry Shmidtextern void bcmsdh_intr_forward(void *sdh, bool pass);
818ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
828ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt#if defined(DHD_DEBUG)
838ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Query pending interrupt status from the host controller */
848ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern bool bcmsdh_intr_pending(void *sdh);
858ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt#endif
868ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
878ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Register a callback to be called if and when bcmsdh detects
888ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * device removal. No-op in the case of non-removable/hardwired devices.
898ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt */
908ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_devremove_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh);
918ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
928ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Access SDIO address space (e.g. CCCR) using CMD52 (single-byte interface).
938ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   fn:   function number
948ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   addr: unmodified SDIO-space address
958ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   data: data byte to write
968ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   err:  pointer to error code (or NULL)
978ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt */
988ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern uint8 bcmsdh_cfg_read(void *sdh, uint func, uint32 addr, int *err);
998ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern void bcmsdh_cfg_write(void *sdh, uint func, uint32 addr, uint8 data, int *err);
1008ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1018ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Read/Write 4bytes from/to cfg space */
1028ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern uint32 bcmsdh_cfg_read_word(void *sdh, uint fnc_num, uint32 addr, int *err);
1038ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern void bcmsdh_cfg_write_word(void *sdh, uint fnc_num, uint32 addr, uint32 data, int *err);
1048ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1058ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Read CIS content for specified function.
1068ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   fn:     function whose CIS is being requested (0 is common CIS)
1078ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   cis:    pointer to memory location to place results
1088ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   length: number of bytes to read
1098ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * Internally, this routine uses the values from the cis base regs (0x9-0xB)
1108ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * to form an SDIO-space address to read the data from.
1118ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt */
1128ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_cis_read(void *sdh, uint func, uint8 *cis, uint length);
1138ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1148ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Synchronous access to device (client) core registers via CMD53 to F1.
1158ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   addr: backplane address (i.e. >= regsva from attach)
1168ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   size: register width in bytes (2 or 4)
1178ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   data: data for register write
1188ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt */
1198ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern uint32 bcmsdh_reg_read(void *sdh, uint32 addr, uint size);
1208ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern uint32 bcmsdh_reg_write(void *sdh, uint32 addr, uint size, uint32 data);
1218ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
122832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt/* set sb address window */
123832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidtextern int bcmsdhsdio_set_sbaddr_window(void *sdh, uint32 address, bool force_set);
124832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt
1258ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Indicate if last reg read/write failed */
1268ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern bool bcmsdh_regfail(void *sdh);
1278ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1288ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Buffer transfer to/from device (client) core via cmd53.
1298ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   fn:       function number
1308ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   addr:     backplane address (i.e. >= regsva from attach)
1318ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   flags:    backplane width, address increment, sync/async
1328ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   buf:      pointer to memory data buffer
1338ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   nbytes:   number of bytes to transfer to/from buf
1348ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   pkt:      pointer to packet associated with buf (if any)
1358ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   complete: callback function for command completion (async only)
1368ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   handle:   handle for completion callback (first arg in callback)
1378ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * Returns 0 or error code.
1388ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * NOTE: Async operation is not currently supported.
1398ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt */
1408ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidttypedef void (*bcmsdh_cmplt_fn_t)(void *handle, int status, bool sync_waiting);
1418ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_send_buf(void *sdh, uint32 addr, uint fn, uint flags,
1428ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt                           uint8 *buf, uint nbytes, void *pkt,
143832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt                           bcmsdh_cmplt_fn_t complete_fn, void *handle);
1448ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_recv_buf(void *sdh, uint32 addr, uint fn, uint flags,
1458ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt                           uint8 *buf, uint nbytes, void *pkt,
146832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt                           bcmsdh_cmplt_fn_t complete_fn, void *handle);
1478ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1488f237d3133b0672c337c27a1e34daad2b4e76f45Dmitry Shmidtextern void bcmsdh_glom_post(void *sdh, uint8 *frame, uint len);
1498f237d3133b0672c337c27a1e34daad2b4e76f45Dmitry Shmidtextern void bcmsdh_glom_clear(void *sdh);
1508f237d3133b0672c337c27a1e34daad2b4e76f45Dmitry Shmidtextern uint bcmsdh_set_mode(void *sdh, uint mode);
1518f237d3133b0672c337c27a1e34daad2b4e76f45Dmitry Shmidtextern bool bcmsdh_glom_enabled(void);
1528ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Flags bits */
1538ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt#define SDIO_REQ_4BYTE	0x1	/* Four-byte target (backplane) width (vs. two-byte) */
1548ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt#define SDIO_REQ_FIXED	0x2	/* Fixed address (FIFO) (vs. incrementing address) */
1558ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt#define SDIO_REQ_ASYNC	0x4	/* Async request (vs. sync request) */
156832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt#define SDIO_BYTE_MODE	0x8	/* Byte mode request(non-block mode) */
1578ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1588ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Pending (non-error) return code */
1598ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt#define BCME_PENDING	1
1608ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1618ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Read/write to memory block (F1, no FIFO) via CMD53 (sync only).
1628ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   rw:       read or write (0/1)
1638ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   addr:     direct SDIO address
1648ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   buf:      pointer to memory data buffer
1658ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt *   nbytes:   number of bytes to transfer to/from buf
1668ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt * Returns 0 or error code.
1678ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt */
1688ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_rwdata(void *sdh, uint rw, uint32 addr, uint8 *buf, uint nbytes);
1698ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1708ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Issue an abort to the specified function */
1718ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_abort(void *sdh, uint fn);
1728ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1738ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Start SDIO Host Controller communication */
1748ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_start(void *sdh, int stage);
1758ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1768ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Stop SDIO Host Controller communication */
1778ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_stop(void *sdh);
1788ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1798ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Wait system lock free */
1808ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_waitlockfree(void *sdh);
1818ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1828ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Returns the "Device ID" of target device on the SDIO bus. */
1838ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_query_device(void *sdh);
1848ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1858ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Returns the number of IO functions reported by the device */
1868ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern uint bcmsdh_query_iofnum(void *sdh);
1878ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1888ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Miscellaneous knob tweaker. */
1898ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_iovar_op(void *sdh, const char *name,
1908ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt                           void *params, int plen, void *arg, int len, bool set);
1918ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1928ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Reset and reinitialize the device */
1938ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_reset(bcmsdh_info_t *sdh);
1948ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1958ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* helper functions */
1968ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1978ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern void *bcmsdh_get_sdioh(bcmsdh_info_t *sdh);
1988ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
1998ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* callback functions */
2008ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidttypedef struct {
2018ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt	/* attach to device */
2028ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt	void *(*attach)(uint16 vend_id, uint16 dev_id, uint16 bus, uint16 slot,
2038ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt	                uint16 func, uint bustype, void * regsva, osl_t * osh,
2048ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt	                void * param);
2058ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt	/* detach from device */
2068ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt	void (*detach)(void *ch);
2078ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt} bcmsdh_driver_t;
2088ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
2098ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* platform specific/high level functions */
2108ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_register(bcmsdh_driver_t *driver);
2118ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern void bcmsdh_unregister(void);
2128ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern bool bcmsdh_chipmatch(uint16 vendor, uint16 device);
2138ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern void bcmsdh_device_remove(void * sdh);
2148ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
215832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidtextern int bcmsdh_reg_sdio_notify(void* semaphore);
216832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidtextern void bcmsdh_unreg_sdio_notify(void);
217832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt
2188ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt#if defined(OOB_INTR_ONLY)
2198ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_register_oob_intr(void * dhdp);
2208ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern void bcmsdh_unregister_oob_intr(void);
2218ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern void bcmsdh_oob_intr_set(bool enable);
2228f237d3133b0672c337c27a1e34daad2b4e76f45Dmitry Shmidt#endif /* defined(OOB_INTR_ONLY) || defined(BCMSPI_ANDROID) */
223832523286e7a5d2fb5ea9f4b87659508d44cdf45Dmitry Shmidt
2248ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Function to pass device-status bits to DHD. */
2258ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern uint32 bcmsdh_get_dstatus(void *sdh);
2268ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
2278ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Function to return current window addr */
2288ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern uint32 bcmsdh_cur_sbwad(void *sdh);
2298ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
2308ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* Function to pass chipid and rev to lower layers for controlling pr's */
2318ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern void bcmsdh_chipinfo(void *sdh, uint32 chip, uint32 chiprev);
2328ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
2338ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
2348ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_sleep(void *sdh, bool enab);
2358ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
2368ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt/* GPIO support */
2378ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_gpio_init(void *sd);
2388ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern bool bcmsdh_gpioin(void *sd, uint32 gpio);
2398ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_gpioouten(void *sd, uint32 gpio);
2408ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidtextern int bcmsdh_gpioout(void *sd, uint32 gpio, bool enab);
2418ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt
2428ce1727333a1c411bb88330d69f82386a118c6bfDmitry Shmidt#endif	/* _bcmsdh_h_ */
243