PageRenderTime 23ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/FOSS_S1/linux-quic-git-2186caf8a22515c67d814a04143f421a789b874d-r3/linux-quic/drivers/net/wireless/bcmdhd/include/bcmsdh.h

https://gitlab.com/cybok/BMW-OpenSource
C Header | 219 lines | 78 code | 40 blank | 101 comment | 0 complexity | 7b43e0dee14fdeee5ee7a0f178424cef 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-2011, 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 300017 2011-12-01 20:30:27Z $
  27. */
  28. #ifndef _bcmsdh_h_
  29. #define _bcmsdh_h_
  30. #define BCMSDH_ERROR_VAL 0x0001 /* Error */
  31. #define BCMSDH_INFO_VAL 0x0002 /* Info */
  32. extern const uint bcmsdh_msglevel;
  33. #define BCMSDH_ERROR(x)
  34. #define BCMSDH_INFO(x)
  35. /* forward declarations */
  36. typedef struct bcmsdh_info bcmsdh_info_t;
  37. typedef void (*bcmsdh_cb_fn_t)(void *);
  38. /* Attach and build an interface to the underlying SD host driver.
  39. * - Allocates resources (structs, arrays, mem, OS handles, etc) needed by bcmsdh.
  40. * - Returns the bcmsdh handle and virtual address base for register access.
  41. * The returned handle should be used in all subsequent calls, but the bcmsh
  42. * implementation may maintain a single "default" handle (e.g. the first or
  43. * most recent one) to enable single-instance implementations to pass NULL.
  44. */
  45. extern bcmsdh_info_t *bcmsdh_attach(osl_t *osh, void *cfghdl, void **regsva, uint irq);
  46. /* Detach - freeup resources allocated in attach */
  47. extern int bcmsdh_detach(osl_t *osh, void *sdh);
  48. /* Query if SD device interrupts are enabled */
  49. extern bool bcmsdh_intr_query(void *sdh);
  50. /* Enable/disable SD interrupt */
  51. extern int bcmsdh_intr_enable(void *sdh);
  52. extern int bcmsdh_intr_disable(void *sdh);
  53. /* Register/deregister device interrupt handler. */
  54. extern int bcmsdh_intr_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh);
  55. extern int bcmsdh_intr_dereg(void *sdh);
  56. #if defined(DHD_DEBUG)
  57. /* Query pending interrupt status from the host controller */
  58. extern bool bcmsdh_intr_pending(void *sdh);
  59. #endif
  60. #ifdef BCMLXSDMMC
  61. extern int bcmsdh_claim_host_and_lock(void *sdh);
  62. extern int bcmsdh_release_host_and_unlock(void *sdh);
  63. #endif /* BCMLXSDMMC */
  64. /* Register a callback to be called if and when bcmsdh detects
  65. * device removal. No-op in the case of non-removable/hardwired devices.
  66. */
  67. extern int bcmsdh_devremove_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh);
  68. /* Access SDIO address space (e.g. CCCR) using CMD52 (single-byte interface).
  69. * fn: function number
  70. * addr: unmodified SDIO-space address
  71. * data: data byte to write
  72. * err: pointer to error code (or NULL)
  73. */
  74. extern uint8 bcmsdh_cfg_read(void *sdh, uint func, uint32 addr, int *err);
  75. extern void bcmsdh_cfg_write(void *sdh, uint func, uint32 addr, uint8 data, int *err);
  76. /* Read/Write 4bytes from/to cfg space */
  77. extern uint32 bcmsdh_cfg_read_word(void *sdh, uint fnc_num, uint32 addr, int *err);
  78. extern void bcmsdh_cfg_write_word(void *sdh, uint fnc_num, uint32 addr, uint32 data, int *err);
  79. /* Read CIS content for specified function.
  80. * fn: function whose CIS is being requested (0 is common CIS)
  81. * cis: pointer to memory location to place results
  82. * length: number of bytes to read
  83. * Internally, this routine uses the values from the cis base regs (0x9-0xB)
  84. * to form an SDIO-space address to read the data from.
  85. */
  86. extern int bcmsdh_cis_read(void *sdh, uint func, uint8 *cis, uint length);
  87. /* Synchronous access to device (client) core registers via CMD53 to F1.
  88. * addr: backplane address (i.e. >= regsva from attach)
  89. * size: register width in bytes (2 or 4)
  90. * data: data for register write
  91. */
  92. extern uint32 bcmsdh_reg_read(void *sdh, uint32 addr, uint size);
  93. extern uint32 bcmsdh_reg_write(void *sdh, uint32 addr, uint size, uint32 data);
  94. /* Indicate if last reg read/write failed */
  95. extern bool bcmsdh_regfail(void *sdh);
  96. /* Buffer transfer to/from device (client) core via cmd53.
  97. * fn: function number
  98. * addr: backplane address (i.e. >= regsva from attach)
  99. * flags: backplane width, address increment, sync/async
  100. * buf: pointer to memory data buffer
  101. * nbytes: number of bytes to transfer to/from buf
  102. * pkt: pointer to packet associated with buf (if any)
  103. * complete: callback function for command completion (async only)
  104. * handle: handle for completion callback (first arg in callback)
  105. * Returns 0 or error code.
  106. * NOTE: Async operation is not currently supported.
  107. */
  108. typedef void (*bcmsdh_cmplt_fn_t)(void *handle, int status, bool sync_waiting);
  109. extern int bcmsdh_send_buf(void *sdh, uint32 addr, uint fn, uint flags,
  110. uint8 *buf, uint nbytes, void *pkt,
  111. bcmsdh_cmplt_fn_t complete, void *handle);
  112. extern int bcmsdh_recv_buf(void *sdh, uint32 addr, uint fn, uint flags,
  113. uint8 *buf, uint nbytes, void *pkt,
  114. bcmsdh_cmplt_fn_t complete, void *handle);
  115. /* Flags bits */
  116. #define SDIO_REQ_4BYTE 0x1 /* Four-byte target (backplane) width (vs. two-byte) */
  117. #define SDIO_REQ_FIXED 0x2 /* Fixed address (FIFO) (vs. incrementing address) */
  118. #define SDIO_REQ_ASYNC 0x4 /* Async request (vs. sync request) */
  119. /* Pending (non-error) return code */
  120. #define BCME_PENDING 1
  121. /* Read/write to memory block (F1, no FIFO) via CMD53 (sync only).
  122. * rw: read or write (0/1)
  123. * addr: direct SDIO address
  124. * buf: pointer to memory data buffer
  125. * nbytes: number of bytes to transfer to/from buf
  126. * Returns 0 or error code.
  127. */
  128. extern int bcmsdh_rwdata(void *sdh, uint rw, uint32 addr, uint8 *buf, uint nbytes);
  129. /* Issue an abort to the specified function */
  130. extern int bcmsdh_abort(void *sdh, uint fn);
  131. /* Start SDIO Host Controller communication */
  132. extern int bcmsdh_start(void *sdh, int stage);
  133. /* Stop SDIO Host Controller communication */
  134. extern int bcmsdh_stop(void *sdh);
  135. /* Wait system lock free */
  136. extern int bcmsdh_waitlockfree(void *sdh);
  137. /* Returns the "Device ID" of target device on the SDIO bus. */
  138. extern int bcmsdh_query_device(void *sdh);
  139. /* Returns the number of IO functions reported by the device */
  140. extern uint bcmsdh_query_iofnum(void *sdh);
  141. /* Miscellaneous knob tweaker. */
  142. extern int bcmsdh_iovar_op(void *sdh, const char *name,
  143. void *params, int plen, void *arg, int len, bool set);
  144. /* Reset and reinitialize the device */
  145. extern int bcmsdh_reset(bcmsdh_info_t *sdh);
  146. /* helper functions */
  147. extern void *bcmsdh_get_sdioh(bcmsdh_info_t *sdh);
  148. /* callback functions */
  149. typedef struct {
  150. /* attach to device */
  151. void *(*attach)(uint16 vend_id, uint16 dev_id, uint16 bus, uint16 slot,
  152. uint16 func, uint bustype, void * regsva, osl_t * osh,
  153. void * param);
  154. /* detach from device */
  155. void (*detach)(void *ch);
  156. } bcmsdh_driver_t;
  157. /* platform specific/high level functions */
  158. extern int bcmsdh_register(bcmsdh_driver_t *driver);
  159. extern void bcmsdh_unregister(void);
  160. extern bool bcmsdh_chipmatch(uint16 vendor, uint16 device);
  161. extern void bcmsdh_device_remove(void * sdh);
  162. #if defined(OOB_INTR_ONLY)
  163. extern int bcmsdh_register_oob_intr(void * dhdp);
  164. extern void bcmsdh_unregister_oob_intr(void);
  165. extern void bcmsdh_oob_intr_set(bool enable);
  166. #endif /* defined(OOB_INTR_ONLY) */
  167. /* Function to pass device-status bits to DHD. */
  168. extern uint32 bcmsdh_get_dstatus(void *sdh);
  169. /* Function to return current window addr */
  170. extern uint32 bcmsdh_cur_sbwad(void *sdh);
  171. /* Function to pass chipid and rev to lower layers for controlling pr's */
  172. extern void bcmsdh_chipinfo(void *sdh, uint32 chip, uint32 chiprev);
  173. extern int bcmsdh_sleep(void *sdh, bool enab);
  174. /* GPIO support */
  175. extern int bcmsdh_gpio_init(void *sd);
  176. extern bool bcmsdh_gpioin(void *sd, uint32 gpio);
  177. extern int bcmsdh_gpioouten(void *sd, uint32 gpio);
  178. extern int bcmsdh_gpioout(void *sd, uint32 gpio, bool enab);
  179. #endif /* _bcmsdh_h_ */