hal.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /*
  2. * Intel Wireless Multicomm 3200 WiFi driver
  3. *
  4. * Copyright (C) 2009 Intel Corporation. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * * Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in
  14. * the documentation and/or other materials provided with the
  15. * distribution.
  16. * * Neither the name of Intel Corporation nor the names of its
  17. * contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. *
  33. * Intel Corporation <ilw@linux.intel.com>
  34. * Samuel Ortiz <samuel.ortiz@intel.com>
  35. * Zhu Yi <yi.zhu@intel.com>
  36. *
  37. */
  38. #ifndef _IWM_HAL_H_
  39. #define _IWM_HAL_H_
  40. #include "umac.h"
  41. #define GET_VAL8(s, name) ((s >> name##_POS) & name##_SEED)
  42. #define GET_VAL16(s, name) ((le16_to_cpu(s) >> name##_POS) & name##_SEED)
  43. #define GET_VAL32(s, name) ((le32_to_cpu(s) >> name##_POS) & name##_SEED)
  44. #define SET_VAL8(s, name, val) \
  45. do { \
  46. s = (s & ~(name##_SEED << name##_POS)) | \
  47. ((val & name##_SEED) << name##_POS); \
  48. } while (0)
  49. #define SET_VAL16(s, name, val) \
  50. do { \
  51. s = cpu_to_le16((le16_to_cpu(s) & ~(name##_SEED << name##_POS)) | \
  52. ((val & name##_SEED) << name##_POS)); \
  53. } while (0)
  54. #define SET_VAL32(s, name, val) \
  55. do { \
  56. s = cpu_to_le32((le32_to_cpu(s) & ~(name##_SEED << name##_POS)) | \
  57. ((val & name##_SEED) << name##_POS)); \
  58. } while (0)
  59. #define UDMA_UMAC_INIT { .eop = 1, \
  60. .credit_group = 0x4, \
  61. .ra_tid = UMAC_HDI_ACT_TBL_IDX_HOST_CMD, \
  62. .lmac_offset = 0 }
  63. #define UDMA_LMAC_INIT { .eop = 1, \
  64. .credit_group = 0x4, \
  65. .ra_tid = UMAC_HDI_ACT_TBL_IDX_HOST_CMD, \
  66. .lmac_offset = 4 }
  67. /* UDMA IN OP CODE -- cmd bits [3:0] */
  68. #define UDMA_HDI_IN_NW_CMD_OPCODE_POS 0
  69. #define UDMA_HDI_IN_NW_CMD_OPCODE_SEED 0xF
  70. #define UDMA_IN_OPCODE_GENERAL_RESP 0x0
  71. #define UDMA_IN_OPCODE_READ_RESP 0x1
  72. #define UDMA_IN_OPCODE_WRITE_RESP 0x2
  73. #define UDMA_IN_OPCODE_PERS_WRITE_RESP 0x5
  74. #define UDMA_IN_OPCODE_PERS_READ_RESP 0x6
  75. #define UDMA_IN_OPCODE_RD_MDFY_WR_RESP 0x7
  76. #define UDMA_IN_OPCODE_EP_MNGMT_MSG 0x8
  77. #define UDMA_IN_OPCODE_CRDT_CHNG_MSG 0x9
  78. #define UDMA_IN_OPCODE_CNTRL_DATABASE_MSG 0xA
  79. #define UDMA_IN_OPCODE_SW_MSG 0xB
  80. #define UDMA_IN_OPCODE_WIFI 0xF
  81. #define UDMA_IN_OPCODE_WIFI_LMAC 0x1F
  82. #define UDMA_IN_OPCODE_WIFI_UMAC 0x2F
  83. /* HW API: udma_hdi_nonwifi API (OUT and IN) */
  84. /* iwm_udma_nonwifi_cmd request response -- bits [9:9] */
  85. #define UDMA_HDI_OUT_NW_CMD_RESP_POS 9
  86. #define UDMA_HDI_OUT_NW_CMD_RESP_SEED 0x1
  87. /* iwm_udma_nonwifi_cmd handle by HW -- bits [11:11] */
  88. #define UDMA_HDI_OUT_NW_CMD_HANDLE_BY_HW_POS 11
  89. #define UDMA_HDI_OUT_NW_CMD_HANDLE_BY_HW_SEED 0x1
  90. /* iwm_udma_nonwifi_cmd sequence-number -- bits [12:15] */
  91. #define UDMA_HDI_OUT_NW_CMD_SEQ_NUM_POS 12
  92. #define UDMA_HDI_OUT_NW_CMD_SEQ_NUM_SEED 0xF
  93. /* UDMA IN Non-WIFI HW sequence number -- bits [12:15] */
  94. #define UDMA_IN_NW_HW_SEQ_NUM_POS 12
  95. #define UDMA_IN_NW_HW_SEQ_NUM_SEED 0xF
  96. /* UDMA IN Non-WIFI HW signature -- bits [16:31] */
  97. #define UDMA_IN_NW_HW_SIG_POS 16
  98. #define UDMA_IN_NW_HW_SIG_SEED 0xFFFF
  99. /* fixed signature */
  100. #define UDMA_IN_NW_HW_SIG 0xCBBC
  101. /* UDMA IN Non-WIFI HW block length -- bits [32:35] */
  102. #define UDMA_IN_NW_HW_LENGTH_SEED 0xF
  103. #define UDMA_IN_NW_HW_LENGTH_POS 32
  104. /* End of HW API: udma_hdi_nonwifi API (OUT and IN) */
  105. #define IWM_SDIO_FW_MAX_CHUNK_SIZE 2032
  106. #define IWM_MAX_WIFI_HEADERS_SIZE 32
  107. #define IWM_MAX_NONWIFI_HEADERS_SIZE 16
  108. #define IWM_MAX_NONWIFI_CMD_BUFF_SIZE (IWM_SDIO_FW_MAX_CHUNK_SIZE - \
  109. IWM_MAX_NONWIFI_HEADERS_SIZE)
  110. #define IWM_MAX_WIFI_CMD_BUFF_SIZE (IWM_SDIO_FW_MAX_CHUNK_SIZE - \
  111. IWM_MAX_WIFI_HEADERS_SIZE)
  112. #define IWM_HAL_CONCATENATE_BUF_SIZE (32 * 1024)
  113. struct iwm_wifi_cmd_buff {
  114. u16 len;
  115. u8 *start;
  116. u8 hdr[IWM_MAX_WIFI_HEADERS_SIZE];
  117. u8 payload[IWM_MAX_WIFI_CMD_BUFF_SIZE];
  118. };
  119. struct iwm_nonwifi_cmd_buff {
  120. u16 len;
  121. u8 *start;
  122. u8 hdr[IWM_MAX_NONWIFI_HEADERS_SIZE];
  123. u8 payload[IWM_MAX_NONWIFI_CMD_BUFF_SIZE];
  124. };
  125. struct iwm_udma_nonwifi_cmd {
  126. u8 opcode;
  127. u8 eop;
  128. u8 resp;
  129. u8 handle_by_hw;
  130. __le32 addr;
  131. __le32 op1_sz;
  132. __le32 op2;
  133. __le16 seq_num;
  134. };
  135. struct iwm_udma_wifi_cmd {
  136. __le16 count;
  137. u8 eop;
  138. u8 credit_group;
  139. u8 ra_tid;
  140. u8 lmac_offset;
  141. };
  142. struct iwm_umac_cmd {
  143. u8 id;
  144. __le16 count;
  145. u8 resp;
  146. __le16 seq_num;
  147. u8 color;
  148. };
  149. struct iwm_lmac_cmd {
  150. u8 id;
  151. __le16 count;
  152. u8 resp;
  153. __le16 seq_num;
  154. };
  155. struct iwm_nonwifi_cmd {
  156. u16 seq_num;
  157. bool resp_received;
  158. struct list_head pending;
  159. struct iwm_udma_nonwifi_cmd udma_cmd;
  160. struct iwm_umac_cmd umac_cmd;
  161. struct iwm_lmac_cmd lmac_cmd;
  162. struct iwm_nonwifi_cmd_buff buf;
  163. u32 flags;
  164. };
  165. struct iwm_wifi_cmd {
  166. u16 seq_num;
  167. struct list_head pending;
  168. struct iwm_udma_wifi_cmd udma_cmd;
  169. struct iwm_umac_cmd umac_cmd;
  170. struct iwm_lmac_cmd lmac_cmd;
  171. struct iwm_wifi_cmd_buff buf;
  172. u32 flags;
  173. };
  174. void iwm_cmd_flush(struct iwm_priv *iwm);
  175. struct iwm_wifi_cmd *iwm_get_pending_wifi_cmd(struct iwm_priv *iwm,
  176. u16 seq_num);
  177. struct iwm_nonwifi_cmd *iwm_get_pending_nonwifi_cmd(struct iwm_priv *iwm,
  178. u8 seq_num, u8 cmd_opcode);
  179. int iwm_hal_send_target_cmd(struct iwm_priv *iwm,
  180. struct iwm_udma_nonwifi_cmd *ucmd,
  181. const void *payload);
  182. int iwm_hal_send_host_cmd(struct iwm_priv *iwm,
  183. struct iwm_udma_wifi_cmd *udma_cmd,
  184. struct iwm_umac_cmd *umac_cmd,
  185. struct iwm_lmac_cmd *lmac_cmd,
  186. const void *payload, u16 payload_size);
  187. int iwm_hal_send_umac_cmd(struct iwm_priv *iwm,
  188. struct iwm_udma_wifi_cmd *udma_cmd,
  189. struct iwm_umac_cmd *umac_cmd,
  190. const void *payload, u16 payload_size);
  191. u16 iwm_alloc_wifi_cmd_seq(struct iwm_priv *iwm);
  192. void iwm_udma_wifi_hdr_set_eop(struct iwm_priv *iwm, u8 *buf, u8 eop);
  193. void iwm_build_udma_wifi_hdr(struct iwm_priv *iwm,
  194. struct iwm_udma_out_wifi_hdr *hdr,
  195. struct iwm_udma_wifi_cmd *cmd);
  196. void iwm_build_umac_hdr(struct iwm_priv *iwm,
  197. struct iwm_umac_fw_cmd_hdr *hdr,
  198. struct iwm_umac_cmd *cmd);
  199. #endif /* _IWM_HAL_H_ */