bcmsdbus.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Definitions for API from sdio common code (bcmsdh) to individual
  3. * host controller drivers.
  4. *
  5. * Portions of this code are copyright (c) 2020 Cypress Semiconductor Corporation
  6. *
  7. * Copyright (C) 1999-2020, Broadcom Corporation
  8. *
  9. * Unless you and Broadcom execute a separate written software license
  10. * agreement governing use of this software, this software is licensed to you
  11. * under the terms of the GNU General Public License version 2 (the "GPL"),
  12. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  13. * following added to such license:
  14. *
  15. * As a special exception, the copyright holders of this software give you
  16. * permission to link this software with independent modules, and to copy and
  17. * distribute the resulting executable under terms of your choice, provided that
  18. * you also meet, for each linked independent module, the terms and conditions of
  19. * the license of that module. An independent module is a module which is not
  20. * derived from this software. The special exception does not apply to any
  21. * modifications of the software.
  22. *
  23. * Notwithstanding the above, under no circumstances may you combine this
  24. * software in any way with any other Broadcom software provided under a license
  25. * other than the GPL, without Broadcom's express prior written consent.
  26. *
  27. *
  28. * <<Broadcom-WL-IPTag/Open:>>
  29. *
  30. * $Id: bcmsdbus.h 689948 2017-03-14 05:21:03Z $
  31. */
  32. #ifndef _sdio_api_h_
  33. #define _sdio_api_h_
  34. #if defined(BT_OVER_SDIO)
  35. #include <linux/mmc/sdio_func.h>
  36. #endif /* defined (BT_OVER_SDIO) */
  37. #define SDIOH_API_RC_SUCCESS (0x00)
  38. #define SDIOH_API_RC_FAIL (0x01)
  39. #define SDIOH_API_SUCCESS(status) (status == 0)
  40. #define SDIOH_READ 0 /* Read request */
  41. #define SDIOH_WRITE 1 /* Write request */
  42. #define SDIOH_DATA_FIX 0 /* Fixed addressing */
  43. #define SDIOH_DATA_INC 1 /* Incremental addressing */
  44. #define SDIOH_CMD_TYPE_NORMAL 0 /* Normal command */
  45. #define SDIOH_CMD_TYPE_APPEND 1 /* Append command */
  46. #define SDIOH_CMD_TYPE_CUTTHRU 2 /* Cut-through command */
  47. #define SDIOH_DATA_PIO 0 /* PIO mode */
  48. #define SDIOH_DATA_DMA 1 /* DMA mode */
  49. /* Max number of glommed pkts */
  50. #ifdef CUSTOM_MAX_TXGLOM_SIZE
  51. #define SDPCM_MAXGLOM_SIZE CUSTOM_MAX_TXGLOM_SIZE
  52. #else
  53. #define SDPCM_MAXGLOM_SIZE 40
  54. #endif /* CUSTOM_MAX_TXGLOM_SIZE */
  55. #define SDPCM_TXGLOM_CPY 0 /* SDIO 2.0 should use copy mode */
  56. #define SDPCM_TXGLOM_MDESC 1 /* SDIO 3.0 should use multi-desc mode */
  57. #ifdef CUSTOM_DEF_TXGLOM_SIZE
  58. #define SDPCM_DEFGLOM_SIZE CUSTOM_DEF_TXGLOM_SIZE
  59. #else
  60. #define SDPCM_DEFGLOM_SIZE SDPCM_MAXGLOM_SIZE
  61. #endif /* CUSTOM_DEF_TXGLOM_SIZE */
  62. #if SDPCM_DEFGLOM_SIZE > SDPCM_MAXGLOM_SIZE
  63. #warning "SDPCM_DEFGLOM_SIZE cannot be higher than SDPCM_MAXGLOM_SIZE!!"
  64. #undef SDPCM_DEFGLOM_SIZE
  65. #define SDPCM_DEFGLOM_SIZE SDPCM_MAXGLOM_SIZE
  66. #endif // endif
  67. typedef int SDIOH_API_RC;
  68. /* SDio Host structure */
  69. typedef struct sdioh_info sdioh_info_t;
  70. /* callback function, taking one arg */
  71. typedef void (*sdioh_cb_fn_t)(void *);
  72. #if defined(BT_OVER_SDIO)
  73. extern
  74. void sdioh_sdmmc_card_enable_func_f3(sdioh_info_t *sd, struct sdio_func *func);
  75. #endif /* defined (BT_OVER_SDIO) */
  76. extern SDIOH_API_RC sdioh_interrupt_register(sdioh_info_t *si, sdioh_cb_fn_t fn, void *argh);
  77. extern SDIOH_API_RC sdioh_interrupt_deregister(sdioh_info_t *si);
  78. /* query whether SD interrupt is enabled or not */
  79. extern SDIOH_API_RC sdioh_interrupt_query(sdioh_info_t *si, bool *onoff);
  80. /* enable or disable SD interrupt */
  81. extern SDIOH_API_RC sdioh_interrupt_set(sdioh_info_t *si, bool enable_disable);
  82. #if defined(DHD_DEBUG)
  83. extern bool sdioh_interrupt_pending(sdioh_info_t *si);
  84. #endif // endif
  85. /* read or write one byte using cmd52 */
  86. extern SDIOH_API_RC sdioh_request_byte(sdioh_info_t *si, uint rw, uint fnc, uint addr, uint8 *byte);
  87. /* read or write 2/4 bytes using cmd53 */
  88. extern SDIOH_API_RC sdioh_request_word(sdioh_info_t *si, uint cmd_type, uint rw, uint fnc,
  89. uint addr, uint32 *word, uint nbyte);
  90. /* read or write any buffer using cmd53 */
  91. extern SDIOH_API_RC sdioh_request_buffer(sdioh_info_t *si, uint pio_dma, uint fix_inc,
  92. uint rw, uint fnc_num, uint32 addr, uint regwidth, uint32 buflen, uint8 *buffer,
  93. void *pkt);
  94. /* get cis data */
  95. extern SDIOH_API_RC sdioh_cis_read(sdioh_info_t *si, uint fuc, uint8 *cis, uint32 length);
  96. extern SDIOH_API_RC sdioh_cfg_read(sdioh_info_t *si, uint fuc, uint32 addr, uint8 *data);
  97. extern SDIOH_API_RC sdioh_cfg_write(sdioh_info_t *si, uint fuc, uint32 addr, uint8 *data);
  98. /* query number of io functions */
  99. extern uint sdioh_query_iofnum(sdioh_info_t *si);
  100. /* handle iovars */
  101. extern int sdioh_iovar_op(sdioh_info_t *si, const char *name,
  102. void *params, int plen, void *arg, int len, bool set);
  103. /* Issue abort to the specified function and clear controller as needed */
  104. extern int sdioh_abort(sdioh_info_t *si, uint fnc);
  105. /* Start and Stop SDIO without re-enumerating the SD card. */
  106. extern int sdioh_start(sdioh_info_t *si, int stage);
  107. extern int sdioh_stop(sdioh_info_t *si);
  108. /* Wait system lock free */
  109. extern int sdioh_waitlockfree(sdioh_info_t *si);
  110. /* Reset and re-initialize the device */
  111. extern int sdioh_sdio_reset(sdioh_info_t *si);
  112. #ifdef BCMSPI
  113. /* Function to pass gSPI specific device-status bits to dhd. */
  114. extern uint32 sdioh_get_dstatus(sdioh_info_t *si);
  115. /* chipid and chiprev info for lower layers to control sw WAR's for hw bugs. */
  116. extern void sdioh_chipinfo(sdioh_info_t *si, uint32 chip, uint32 chiprev);
  117. extern void sdioh_dwordmode(sdioh_info_t *si, bool set);
  118. #endif /* BCMSPI */
  119. #if defined(BCMSDIOH_STD)
  120. #define SDIOH_SLEEP_ENABLED
  121. #endif // endif
  122. extern SDIOH_API_RC sdioh_sleep(sdioh_info_t *si, bool enab);
  123. /* GPIO support */
  124. extern SDIOH_API_RC sdioh_gpio_init(sdioh_info_t *sd);
  125. extern bool sdioh_gpioin(sdioh_info_t *sd, uint32 gpio);
  126. extern SDIOH_API_RC sdioh_gpioouten(sdioh_info_t *sd, uint32 gpio);
  127. extern SDIOH_API_RC sdioh_gpioout(sdioh_info_t *sd, uint32 gpio, bool enab);
  128. #endif /* _sdio_api_h_ */