PageRenderTime 33ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/bcmdhd/include/bcmsdh.h

https://bitbucket.org/Tofe/picasso-kernel
C Header | 238 lines | 87 code | 45 blank | 106 comment | 2 complexity | 5e2081bfa8b9a973ea24f075ff8347dc MD5 | raw file
  1. /*
  2. * SDIO host client driver interface of Broadcom HNBU
  3. * export functions to client drivers
  4. * abstract OS and BUS specific details of SDIO
  5. *
  6. * Copyright (C) 1999-2013, Broadcom Corporation
  7. *
  8. * Unless you and Broadcom execute a separate written software license
  9. * agreement governing use of this software, this software is licensed to you
  10. * under the terms of the GNU General Public License version 2 (the "GPL"),
  11. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  12. * following added to such license:
  13. *
  14. * As a special exception, the copyright holders of this software give you
  15. * permission to link this software with independent modules, and to copy and
  16. * distribute the resulting executable under terms of your choice, provided that
  17. * you also meet, for each linked independent module, the terms and conditions of
  18. * the license of that module. An independent module is a module which is not
  19. * derived from this software. The special exception does not apply to any
  20. * modifications of the software.
  21. *
  22. * Notwithstanding the above, under no circumstances may you combine this
  23. * software in any way with any other Broadcom software provided under a license
  24. * other than the GPL, without Broadcom's express prior written consent.
  25. *
  26. * $Id: bcmsdh.h 391577 2013-03-18 21:28:17Z $
  27. */
  28. /**
  29. * @file bcmsdh.h
  30. */
  31. #ifndef _bcmsdh_h_
  32. #define _bcmsdh_h_
  33. #define BCMSDH_ERROR_VAL 0x0001 /* Error */
  34. #define BCMSDH_INFO_VAL 0x0002 /* Info */
  35. extern const uint bcmsdh_msglevel;
  36. #define BCMSDH_ERROR(x)
  37. #define BCMSDH_INFO(x)
  38. #if (defined(BCMSDIOH_STD) || defined(BCMSDIOH_BCM) || defined(BCMSDIOH_SPI))
  39. #define BCMSDH_ADAPTER
  40. #endif /* BCMSDIO && (BCMSDIOH_STD || BCMSDIOH_BCM || BCMSDIOH_SPI) */
  41. /* forward declarations */
  42. typedef struct bcmsdh_info bcmsdh_info_t;
  43. typedef void (*bcmsdh_cb_fn_t)(void *);
  44. extern struct device *pm_dev;
  45. /* Attach and build an interface to the underlying SD host driver.
  46. * - Allocates resources (structs, arrays, mem, OS handles, etc) needed by bcmsdh.
  47. * - Returns the bcmsdh handle and virtual address base for register access.
  48. * The returned handle should be used in all subsequent calls, but the bcmsh
  49. * implementation may maintain a single "default" handle (e.g. the first or
  50. * most recent one) to enable single-instance implementations to pass NULL.
  51. */
  52. extern bcmsdh_info_t *bcmsdh_attach(osl_t *osh, void *cfghdl, void **regsva, uint irq);
  53. /* Detach - freeup resources allocated in attach */
  54. extern int bcmsdh_detach(osl_t *osh, void *sdh);
  55. /* Query if SD device interrupts are enabled */
  56. extern bool bcmsdh_intr_query(void *sdh);
  57. /* Enable/disable SD interrupt */
  58. extern int bcmsdh_intr_enable(void *sdh);
  59. extern int bcmsdh_intr_disable(void *sdh);
  60. /* Register/deregister device interrupt handler. */
  61. extern int bcmsdh_intr_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh);
  62. extern int bcmsdh_intr_dereg(void *sdh);
  63. /* Enable/disable SD card interrupt forward */
  64. extern void bcmsdh_intr_forward(void *sdh, bool pass);
  65. #if defined(DHD_DEBUG)
  66. /* Query pending interrupt status from the host controller */
  67. extern bool bcmsdh_intr_pending(void *sdh);
  68. #endif
  69. /* Register a callback to be called if and when bcmsdh detects
  70. * device removal. No-op in the case of non-removable/hardwired devices.
  71. */
  72. extern int bcmsdh_devremove_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh);
  73. /* Access SDIO address space (e.g. CCCR) using CMD52 (single-byte interface).
  74. * fn: function number
  75. * addr: unmodified SDIO-space address
  76. * data: data byte to write
  77. * err: pointer to error code (or NULL)
  78. */
  79. extern uint8 bcmsdh_cfg_read(void *sdh, uint func, uint32 addr, int *err);
  80. extern void bcmsdh_cfg_write(void *sdh, uint func, uint32 addr, uint8 data, int *err);
  81. /* Read/Write 4bytes from/to cfg space */
  82. extern uint32 bcmsdh_cfg_read_word(void *sdh, uint fnc_num, uint32 addr, int *err);
  83. extern void bcmsdh_cfg_write_word(void *sdh, uint fnc_num, uint32 addr, uint32 data, int *err);
  84. /* Read CIS content for specified function.
  85. * fn: function whose CIS is being requested (0 is common CIS)
  86. * cis: pointer to memory location to place results
  87. * length: number of bytes to read
  88. * Internally, this routine uses the values from the cis base regs (0x9-0xB)
  89. * to form an SDIO-space address to read the data from.
  90. */
  91. extern int bcmsdh_cis_read(void *sdh, uint func, uint8 *cis, uint length);
  92. /* Synchronous access to device (client) core registers via CMD53 to F1.
  93. * addr: backplane address (i.e. >= regsva from attach)
  94. * size: register width in bytes (2 or 4)
  95. * data: data for register write
  96. */
  97. extern uint32 bcmsdh_reg_read(void *sdh, uint32 addr, uint size);
  98. extern uint32 bcmsdh_reg_write(void *sdh, uint32 addr, uint size, uint32 data);
  99. /* set sb address window */
  100. extern int bcmsdhsdio_set_sbaddr_window(void *sdh, uint32 address, bool force_set);
  101. /* Indicate if last reg read/write failed */
  102. extern bool bcmsdh_regfail(void *sdh);
  103. /* Buffer transfer to/from device (client) core via cmd53.
  104. * fn: function number
  105. * addr: backplane address (i.e. >= regsva from attach)
  106. * flags: backplane width, address increment, sync/async
  107. * buf: pointer to memory data buffer
  108. * nbytes: number of bytes to transfer to/from buf
  109. * pkt: pointer to packet associated with buf (if any)
  110. * complete: callback function for command completion (async only)
  111. * handle: handle for completion callback (first arg in callback)
  112. * Returns 0 or error code.
  113. * NOTE: Async operation is not currently supported.
  114. */
  115. typedef void (*bcmsdh_cmplt_fn_t)(void *handle, int status, bool sync_waiting);
  116. extern int bcmsdh_send_buf(void *sdh, uint32 addr, uint fn, uint flags,
  117. uint8 *buf, uint nbytes, void *pkt,
  118. bcmsdh_cmplt_fn_t complete_fn, void *handle);
  119. extern int bcmsdh_recv_buf(void *sdh, uint32 addr, uint fn, uint flags,
  120. uint8 *buf, uint nbytes, void *pkt,
  121. bcmsdh_cmplt_fn_t complete_fn, void *handle);
  122. extern void bcmsdh_glom_post(void *sdh, uint8 *frame, void *pkt, uint len);
  123. extern void bcmsdh_glom_clear(void *sdh);
  124. extern uint bcmsdh_set_mode(void *sdh, uint mode);
  125. extern bool bcmsdh_glom_enabled(void);
  126. /* Flags bits */
  127. #define SDIO_REQ_4BYTE 0x1 /* Four-byte target (backplane) width (vs. two-byte) */
  128. #define SDIO_REQ_FIXED 0x2 /* Fixed address (FIFO) (vs. incrementing address) */
  129. #define SDIO_REQ_ASYNC 0x4 /* Async request (vs. sync request) */
  130. #define SDIO_BYTE_MODE 0x8 /* Byte mode request(non-block mode) */
  131. /* Pending (non-error) return code */
  132. #define BCME_PENDING 1
  133. /* Read/write to memory block (F1, no FIFO) via CMD53 (sync only).
  134. * rw: read or write (0/1)
  135. * addr: direct SDIO address
  136. * buf: pointer to memory data buffer
  137. * nbytes: number of bytes to transfer to/from buf
  138. * Returns 0 or error code.
  139. */
  140. extern int bcmsdh_rwdata(void *sdh, uint rw, uint32 addr, uint8 *buf, uint nbytes);
  141. /* Issue an abort to the specified function */
  142. extern int bcmsdh_abort(void *sdh, uint fn);
  143. /* Start SDIO Host Controller communication */
  144. extern int bcmsdh_start(void *sdh, int stage);
  145. /* Stop SDIO Host Controller communication */
  146. extern int bcmsdh_stop(void *sdh);
  147. /* Wait system lock free */
  148. extern int bcmsdh_waitlockfree(void *sdh);
  149. /* Returns the "Device ID" of target device on the SDIO bus. */
  150. extern int bcmsdh_query_device(void *sdh);
  151. /* Returns the number of IO functions reported by the device */
  152. extern uint bcmsdh_query_iofnum(void *sdh);
  153. /* Miscellaneous knob tweaker. */
  154. extern int bcmsdh_iovar_op(void *sdh, const char *name,
  155. void *params, int plen, void *arg, int len, bool set);
  156. /* Reset and reinitialize the device */
  157. extern int bcmsdh_reset(bcmsdh_info_t *sdh);
  158. /* helper functions */
  159. extern void *bcmsdh_get_sdioh(bcmsdh_info_t *sdh);
  160. /* callback functions */
  161. typedef struct {
  162. /* attach to device */
  163. void *(*attach)(uint16 vend_id, uint16 dev_id, uint16 bus, uint16 slot,
  164. uint16 func, uint bustype, void * regsva, osl_t * osh,
  165. void * param);
  166. /* detach from device */
  167. void (*detach)(void *ch);
  168. } bcmsdh_driver_t;
  169. /* platform specific/high level functions */
  170. extern int bcmsdh_register(bcmsdh_driver_t *driver);
  171. extern void bcmsdh_unregister(void);
  172. extern bool bcmsdh_chipmatch(uint16 vendor, uint16 device);
  173. extern void bcmsdh_device_remove(void * sdh);
  174. extern int bcmsdh_reg_sdio_notify(void* semaphore);
  175. extern void bcmsdh_unreg_sdio_notify(void);
  176. #if defined(OOB_INTR_ONLY)
  177. extern int bcmsdh_register_oob_intr(void * dhdp);
  178. extern void bcmsdh_unregister_oob_intr(void);
  179. extern void bcmsdh_oob_intr_set(bool enable);
  180. #endif
  181. /* Function to pass device-status bits to DHD. */
  182. extern uint32 bcmsdh_get_dstatus(void *sdh);
  183. /* Function to return current window addr */
  184. extern uint32 bcmsdh_cur_sbwad(void *sdh);
  185. /* Function to pass chipid and rev to lower layers for controlling pr's */
  186. extern void bcmsdh_chipinfo(void *sdh, uint32 chip, uint32 chiprev);
  187. extern int bcmsdh_sleep(void *sdh, bool enab);
  188. /* GPIO support */
  189. extern int bcmsdh_gpio_init(void *sd);
  190. extern bool bcmsdh_gpioin(void *sd, uint32 gpio);
  191. extern int bcmsdh_gpioouten(void *sd, uint32 gpio);
  192. extern int bcmsdh_gpioout(void *sd, uint32 gpio, bool enab);
  193. #endif /* _bcmsdh_h_ */