PageRenderTime 54ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://gitlab.com/SerenityS/slteskt_kernel
C Header | 254 lines | 106 code | 44 blank | 104 comment | 3 complexity | d97b1b71d436846e485c87b9c02400b9 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-2014, 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 455573 2014-02-14 17:49:31Z $
  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 bcmsdh_info_t *bcmsdh_attach(osl_t *osh, void *sdioh, ulong *regsva);
  45. /**
  46. * BCMSDH API context
  47. */
  48. struct bcmsdh_info
  49. {
  50. bool init_success; /* underlying driver successfully attached */
  51. void *sdioh; /* handler for sdioh */
  52. uint32 vendevid; /* Target Vendor and Device ID on SD bus */
  53. osl_t *osh;
  54. bool regfail; /* Save status of last reg_read/reg_write call */
  55. uint32 sbwad; /* Save backplane window address */
  56. void *os_cxt; /* Pointer to per-OS private data */
  57. };
  58. /* Detach - freeup resources allocated in attach */
  59. extern int bcmsdh_detach(osl_t *osh, void *sdh);
  60. /* Query if SD device interrupts are enabled */
  61. extern bool bcmsdh_intr_query(void *sdh);
  62. /* Enable/disable SD interrupt */
  63. extern int bcmsdh_intr_enable(void *sdh);
  64. extern int bcmsdh_intr_disable(void *sdh);
  65. /* Register/deregister device interrupt handler. */
  66. extern int bcmsdh_intr_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh);
  67. extern int bcmsdh_intr_dereg(void *sdh);
  68. /* Enable/disable SD card interrupt forward */
  69. extern void bcmsdh_intr_forward(void *sdh, bool pass);
  70. #if defined(DHD_DEBUG)
  71. /* Query pending interrupt status from the host controller */
  72. extern bool bcmsdh_intr_pending(void *sdh);
  73. #endif
  74. /* Register a callback to be called if and when bcmsdh detects
  75. * device removal. No-op in the case of non-removable/hardwired devices.
  76. */
  77. extern int bcmsdh_devremove_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh);
  78. /* Access SDIO address space (e.g. CCCR) using CMD52 (single-byte interface).
  79. * fn: function number
  80. * addr: unmodified SDIO-space address
  81. * data: data byte to write
  82. * err: pointer to error code (or NULL)
  83. */
  84. extern uint8 bcmsdh_cfg_read(void *sdh, uint func, uint32 addr, int *err);
  85. extern void bcmsdh_cfg_write(void *sdh, uint func, uint32 addr, uint8 data, int *err);
  86. /* Read/Write 4bytes from/to cfg space */
  87. extern uint32 bcmsdh_cfg_read_word(void *sdh, uint fnc_num, uint32 addr, int *err);
  88. extern void bcmsdh_cfg_write_word(void *sdh, uint fnc_num, uint32 addr, uint32 data, int *err);
  89. /* Read CIS content for specified function.
  90. * fn: function whose CIS is being requested (0 is common CIS)
  91. * cis: pointer to memory location to place results
  92. * length: number of bytes to read
  93. * Internally, this routine uses the values from the cis base regs (0x9-0xB)
  94. * to form an SDIO-space address to read the data from.
  95. */
  96. extern int bcmsdh_cis_read(void *sdh, uint func, uint8 *cis, uint length);
  97. /* Synchronous access to device (client) core registers via CMD53 to F1.
  98. * addr: backplane address (i.e. >= regsva from attach)
  99. * size: register width in bytes (2 or 4)
  100. * data: data for register write
  101. */
  102. extern uint32 bcmsdh_reg_read(void *sdh, uint32 addr, uint size);
  103. extern uint32 bcmsdh_reg_write(void *sdh, uint32 addr, uint size, uint32 data);
  104. /* set sb address window */
  105. extern int bcmsdhsdio_set_sbaddr_window(void *sdh, uint32 address, bool force_set);
  106. /* Indicate if last reg read/write failed */
  107. extern bool bcmsdh_regfail(void *sdh);
  108. /* Buffer transfer to/from device (client) core via cmd53.
  109. * fn: function number
  110. * addr: backplane address (i.e. >= regsva from attach)
  111. * flags: backplane width, address increment, sync/async
  112. * buf: pointer to memory data buffer
  113. * nbytes: number of bytes to transfer to/from buf
  114. * pkt: pointer to packet associated with buf (if any)
  115. * complete: callback function for command completion (async only)
  116. * handle: handle for completion callback (first arg in callback)
  117. * Returns 0 or error code.
  118. * NOTE: Async operation is not currently supported.
  119. */
  120. typedef void (*bcmsdh_cmplt_fn_t)(void *handle, int status, bool sync_waiting);
  121. extern int bcmsdh_send_buf(void *sdh, uint32 addr, uint fn, uint flags,
  122. uint8 *buf, uint nbytes, void *pkt,
  123. bcmsdh_cmplt_fn_t complete_fn, void *handle);
  124. extern int bcmsdh_recv_buf(void *sdh, uint32 addr, uint fn, uint flags,
  125. uint8 *buf, uint nbytes, void *pkt,
  126. bcmsdh_cmplt_fn_t complete_fn, void *handle);
  127. extern void bcmsdh_glom_post(void *sdh, uint8 *frame, void *pkt, uint len);
  128. extern void bcmsdh_glom_clear(void *sdh);
  129. extern uint bcmsdh_set_mode(void *sdh, uint mode);
  130. extern bool bcmsdh_glom_enabled(void);
  131. /* Flags bits */
  132. #define SDIO_REQ_4BYTE 0x1 /* Four-byte target (backplane) width (vs. two-byte) */
  133. #define SDIO_REQ_FIXED 0x2 /* Fixed address (FIFO) (vs. incrementing address) */
  134. #define SDIO_REQ_ASYNC 0x4 /* Async request (vs. sync request) */
  135. #define SDIO_BYTE_MODE 0x8 /* Byte mode request(non-block mode) */
  136. /* Pending (non-error) return code */
  137. #define BCME_PENDING 1
  138. /* Read/write to memory block (F1, no FIFO) via CMD53 (sync only).
  139. * rw: read or write (0/1)
  140. * addr: direct SDIO address
  141. * buf: pointer to memory data buffer
  142. * nbytes: number of bytes to transfer to/from buf
  143. * Returns 0 or error code.
  144. */
  145. extern int bcmsdh_rwdata(void *sdh, uint rw, uint32 addr, uint8 *buf, uint nbytes);
  146. /* Issue an abort to the specified function */
  147. extern int bcmsdh_abort(void *sdh, uint fn);
  148. /* Start SDIO Host Controller communication */
  149. extern int bcmsdh_start(void *sdh, int stage);
  150. /* Stop SDIO Host Controller communication */
  151. extern int bcmsdh_stop(void *sdh);
  152. /* Wait system lock free */
  153. extern int bcmsdh_waitlockfree(void *sdh);
  154. /* Returns the "Device ID" of target device on the SDIO bus. */
  155. extern int bcmsdh_query_device(void *sdh);
  156. /* Returns the number of IO functions reported by the device */
  157. extern uint bcmsdh_query_iofnum(void *sdh);
  158. /* Miscellaneous knob tweaker. */
  159. extern int bcmsdh_iovar_op(void *sdh, const char *name,
  160. void *params, int plen, void *arg, int len, bool set);
  161. /* Reset and reinitialize the device */
  162. extern int bcmsdh_reset(bcmsdh_info_t *sdh);
  163. /* helper functions */
  164. /* callback functions */
  165. typedef struct {
  166. /* probe the device */
  167. void *(*probe)(uint16 vend_id, uint16 dev_id, uint16 bus, uint16 slot,
  168. uint16 func, uint bustype, void * regsva, osl_t * osh,
  169. void * param);
  170. /* remove the device */
  171. void (*remove)(void *context);
  172. /* can we suspend now */
  173. int (*suspend)(void *context);
  174. /* resume from suspend */
  175. int (*resume)(void *context);
  176. } bcmsdh_driver_t;
  177. /* platform specific/high level functions */
  178. extern int bcmsdh_register(bcmsdh_driver_t *driver);
  179. extern void bcmsdh_unregister(void);
  180. extern bool bcmsdh_chipmatch(uint16 vendor, uint16 device);
  181. extern void bcmsdh_device_remove(void * sdh);
  182. extern int bcmsdh_reg_sdio_notify(void* semaphore);
  183. extern void bcmsdh_unreg_sdio_notify(void);
  184. #if defined(OOB_INTR_ONLY) || defined(BCMSPI_ANDROID)
  185. extern int bcmsdh_oob_intr_register(bcmsdh_info_t *bcmsdh, bcmsdh_cb_fn_t oob_irq_handler,
  186. void* oob_irq_handler_context);
  187. extern void bcmsdh_oob_intr_unregister(bcmsdh_info_t *sdh);
  188. extern void bcmsdh_oob_intr_set(bcmsdh_info_t *sdh, bool enable);
  189. #endif /* defined(OOB_INTR_ONLY) || defined(BCMSPI_ANDROID) */
  190. extern void bcmsdh_dev_pm_stay_awake(bcmsdh_info_t *sdh);
  191. extern void bcmsdh_dev_relax(bcmsdh_info_t *sdh);
  192. extern bool bcmsdh_dev_pm_enabled(bcmsdh_info_t *sdh);
  193. int bcmsdh_suspend(bcmsdh_info_t *bcmsdh);
  194. int bcmsdh_resume(bcmsdh_info_t *bcmsdh);
  195. /* Function to pass device-status bits to DHD. */
  196. extern uint32 bcmsdh_get_dstatus(void *sdh);
  197. /* Function to return current window addr */
  198. extern uint32 bcmsdh_cur_sbwad(void *sdh);
  199. /* Function to pass chipid and rev to lower layers for controlling pr's */
  200. extern void bcmsdh_chipinfo(void *sdh, uint32 chip, uint32 chiprev);
  201. #ifdef BCMSPI
  202. extern void bcmsdh_dwordmode(void *sdh, bool set);
  203. #endif /* BCMSPI */
  204. extern int bcmsdh_sleep(void *sdh, bool enab);
  205. /* GPIO support */
  206. extern int bcmsdh_gpio_init(void *sd);
  207. extern bool bcmsdh_gpioin(void *sd, uint32 gpio);
  208. extern int bcmsdh_gpioouten(void *sd, uint32 gpio);
  209. extern int bcmsdh_gpioout(void *sd, uint32 gpio, bool enab);
  210. #endif /* _bcmsdh_h_ */