gspi_ops.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. #ifndef __GSPI_OPS_H__
  21. #define __GSPI_OPS_H__
  22. /* follwing defination is based on
  23. * GSPI spec of RTL8723, we temp
  24. * suppose that it will be the same
  25. * for diff chips of GSPI, if not
  26. * we should move it to HAL folder */
  27. #define SPI_LOCAL_DOMAIN 0x0
  28. #define WLAN_IOREG_DOMAIN 0x8
  29. #define FW_FIFO_DOMAIN 0x4
  30. #define TX_HIQ_DOMAIN 0xc
  31. #define TX_MIQ_DOMAIN 0xd
  32. #define TX_LOQ_DOMAIN 0xe
  33. #define RX_RXFIFO_DOMAIN 0x1f
  34. //IO Bus domain address mapping
  35. #define DEFUALT_OFFSET 0x0
  36. #define SPI_LOCAL_OFFSET 0x10250000
  37. #define WLAN_IOREG_OFFSET 0x10260000
  38. #define FW_FIFO_OFFSET 0x10270000
  39. #define TX_HIQ_OFFSET 0x10310000
  40. #define TX_MIQ_OFFSET 0x1032000
  41. #define TX_LOQ_OFFSET 0x10330000
  42. #define RX_RXOFF_OFFSET 0x10340000
  43. //SPI Local registers
  44. #define SPI_REG_TX_CTRL 0x0000 // SPI Tx Control
  45. #define SPI_REG_STATUS_RECOVERY 0x0004
  46. #define SPI_REG_INT_TIMEOUT 0x0006
  47. #define SPI_REG_HIMR 0x0014 // SPI Host Interrupt Mask
  48. #define SPI_REG_HISR 0x0018 // SPI Host Interrupt Service Routine
  49. #define SPI_REG_RX0_REQ_LEN 0x001C // RXDMA Request Length
  50. #define SPI_REG_FREE_TXPG 0x0020 // Free Tx Buffer Page
  51. #define SPI_REG_HCPWM1 0x0024 // HCI Current Power Mode 1
  52. #define SPI_REG_HCPWM2 0x0026 // HCI Current Power Mode 2
  53. #define SPI_REG_HTSFR_INFO 0x0030 // HTSF Informaion
  54. #define SPI_REG_HRPWM1 0x0080 // HCI Request Power Mode 1
  55. #define SPI_REG_HRPWM2 0x0082 // HCI Request Power Mode 2
  56. #define SPI_REG_HPS_CLKR 0x0084 // HCI Power Save Clock
  57. #define SPI_REG_HSUS_CTRL 0x0086 // SPI HCI Suspend Control
  58. #define SPI_REG_HIMR_ON 0x0090 //SPI Host Extension Interrupt Mask Always
  59. #define SPI_REG_HISR_ON 0x0091 //SPI Host Extension Interrupt Status Always
  60. #define SPI_REG_CFG 0x00F0 //SPI Configuration Register
  61. #define SPI_TX_CTRL (SPI_REG_TX_CTRL |SPI_LOCAL_OFFSET)
  62. #define SPI_STATUS_RECOVERY (SPI_REG_STATUS_RECOVERY |SPI_LOCAL_OFFSET)
  63. #define SPI_INT_TIMEOUT (SPI_REG_INT_TIMEOUT |SPI_LOCAL_OFFSET)
  64. #define SPI_HIMR (SPI_REG_HIMR |SPI_LOCAL_OFFSET)
  65. #define SPI_HISR (SPI_REG_HISR |SPI_LOCAL_OFFSET)
  66. #define SPI_RX0_REQ_LEN_1_BYTE (SPI_REG_RX0_REQ_LEN |SPI_LOCAL_OFFSET)
  67. #define SPI_FREE_TXPG (SPI_REG_FREE_TXPG |SPI_LOCAL_OFFSET)
  68. #define SPI_HIMR_DISABLED 0
  69. //SPI HIMR MASK diff with SDIO
  70. #define SPI_HISR_RX_REQUEST BIT(0)
  71. #define SPI_HISR_AVAL BIT(1)
  72. #define SPI_HISR_TXERR BIT(2)
  73. #define SPI_HISR_RXERR BIT(3)
  74. #define SPI_HISR_TXFOVW BIT(4)
  75. #define SPI_HISR_RXFOVW BIT(5)
  76. #define SPI_HISR_TXBCNOK BIT(6)
  77. #define SPI_HISR_TXBCNERR BIT(7)
  78. #define SPI_HISR_BCNERLY_INT BIT(16)
  79. #define SPI_HISR_ATIMEND BIT(17)
  80. #define SPI_HISR_ATIMEND_E BIT(18)
  81. #define SPI_HISR_CTWEND BIT(19)
  82. #define SPI_HISR_C2HCMD BIT(20)
  83. #define SPI_HISR_CPWM1 BIT(21)
  84. #define SPI_HISR_CPWM2 BIT(22)
  85. #define SPI_HISR_HSISR_IND BIT(23)
  86. #define SPI_HISR_GTINT3_IND BIT(24)
  87. #define SPI_HISR_GTINT4_IND BIT(25)
  88. #define SPI_HISR_PSTIMEOUT BIT(26)
  89. #define SPI_HISR_OCPINT BIT(27)
  90. #define SPI_HISR_TSF_BIT32_TOGGLE BIT(29)
  91. #define MASK_SPI_HISR_CLEAR (SPI_HISR_TXERR |\
  92. SPI_HISR_RXERR |\
  93. SPI_HISR_TXFOVW |\
  94. SPI_HISR_RXFOVW |\
  95. SPI_HISR_TXBCNOK |\
  96. SPI_HISR_TXBCNERR |\
  97. SPI_HISR_C2HCMD |\
  98. SPI_HISR_CPWM1 |\
  99. SPI_HISR_CPWM2 |\
  100. SPI_HISR_HSISR_IND |\
  101. SPI_HISR_GTINT3_IND |\
  102. SPI_HISR_GTINT4_IND |\
  103. SPI_HISR_PSTIMEOUT |\
  104. SPI_HISR_OCPINT)
  105. #define REG_LEN_FORMAT(pcmd, x) SET_BITS_TO_LE_4BYTE(pcmd, 0, 8, x)//(x<<(unsigned int)24)
  106. #define REG_ADDR_FORMAT(pcmd,x) SET_BITS_TO_LE_4BYTE(pcmd, 8, 16, x)//(x<<(unsigned int)16)
  107. #define REG_DOMAIN_ID_FORMAT(pcmd,x) SET_BITS_TO_LE_4BYTE(pcmd, 24, 5, x)//(x<<(unsigned int)0)
  108. #define REG_FUN_FORMAT(pcmd,x) SET_BITS_TO_LE_4BYTE(pcmd, 29, 2, x)//(x<<(unsigned int)5)
  109. #define REG_RW_FORMAT(pcmd,x) SET_BITS_TO_LE_4BYTE(pcmd, 31, 1, x)//(x<<(unsigned int)7)
  110. #define FIFO_LEN_FORMAT(pcmd, x) SET_BITS_TO_LE_4BYTE(pcmd, 0, 16, x)//(x<<(unsigned int)24)
  111. //#define FIFO_ADDR_FORMAT(pcmd,x) SET_BITS_TO_LE_4BYTE(pcmd, 8, 16, x)//(x<<(unsigned int)16)
  112. #define FIFO_DOMAIN_ID_FORMAT(pcmd,x) SET_BITS_TO_LE_4BYTE(pcmd, 24, 5, x)//(x<<(unsigned int)0)
  113. #define FIFO_FUN_FORMAT(pcmd,x) SET_BITS_TO_LE_4BYTE(pcmd, 29, 2, x)//(x<<(unsigned int)5)
  114. #define FIFO_RW_FORMAT(pcmd,x) SET_BITS_TO_LE_4BYTE(pcmd, 31, 1, x)//(x<<(unsigned int)7)
  115. //get status dword0
  116. #define GET_STATUS_PUB_PAGE_NUM(status) LE_BITS_TO_4BYTE(status, 24, 8)
  117. #define GET_STATUS_HI_PAGE_NUM(status) LE_BITS_TO_4BYTE(status, 18, 6)
  118. #define GET_STATUS_MID_PAGE_NUM(status) LE_BITS_TO_4BYTE(status, 12, 6)
  119. #define GET_STATUS_LOW_PAGE_NUM(status) LE_BITS_TO_4BYTE(status, 6, 6)
  120. #define GET_STATUS_HISR_HI6BIT(status) LE_BITS_TO_4BYTE(status, 0, 6)
  121. //get status dword1
  122. #define GET_STATUS_HISR_MID8BIT(status) LE_BITS_TO_4BYTE(status + 4, 24, 8)
  123. #define GET_STATUS_HISR_LOW8BIT(status) LE_BITS_TO_4BYTE(status + 4, 16, 8)
  124. #define GET_STATUS_ERROR(status) LE_BITS_TO_4BYTE(status + 4, 17, 1)
  125. #define GET_STATUS_INT(status) LE_BITS_TO_4BYTE(status + 4, 16, 1)
  126. #define GET_STATUS_RX_LENGTH(status) LE_BITS_TO_4BYTE(status + 4, 0, 16)
  127. #define RXDESC_SIZE 24
  128. struct spi_more_data {
  129. unsigned long more_data;
  130. unsigned long len;
  131. };
  132. #ifdef CONFIG_RTL8723A
  133. void rtl8723as_set_hal_ops(PADAPTER padapter);
  134. #define set_hal_ops rtl8723as_set_hal_ops
  135. #endif
  136. #ifdef CONFIG_RTL8188E
  137. void rtl8188es_set_hal_ops(PADAPTER padapter);
  138. #define set_hal_ops rtl8188es_set_hal_ops
  139. #endif
  140. extern void spi_set_chip_endian(PADAPTER padapter);
  141. extern void spi_set_intf_ops(_adapter *padapter,struct _io_ops *pops);
  142. extern void spi_set_chip_endian(PADAPTER padapter);
  143. extern void InitInterrupt8723ASdio(PADAPTER padapter);
  144. extern void InitSysInterrupt8723ASdio(PADAPTER padapter);
  145. extern void EnableInterrupt8723ASdio(PADAPTER padapter);
  146. extern void DisableInterrupt8723ASdio(PADAPTER padapter);
  147. extern void spi_int_hdl(PADAPTER padapter);
  148. extern u8 HalQueryTxBufferStatus8723ASdio(PADAPTER padapter);
  149. extern void InitInterrupt8188ESdio(PADAPTER padapter);
  150. extern void EnableInterrupt8188ESdio(PADAPTER padapter);
  151. extern void DisableInterrupt8188ESdio(PADAPTER padapter);
  152. #ifdef CONFIG_RTL8723B
  153. extern void InitInterrupt8723BSdio(PADAPTER padapter);
  154. extern void InitSysInterrupt8723BSdio(PADAPTER padapter);
  155. extern void EnableInterrupt8723BSdio(PADAPTER padapter);
  156. extern void DisableInterrupt8723BSdio(PADAPTER padapter);
  157. extern u8 HalQueryTxBufferStatus8723BSdio(PADAPTER padapter);
  158. #endif
  159. #endif //__GSPI_OPS_H__