fw.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009-2012 Realtek Corporation.
  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. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * wlanfae <wlanfae@realtek.com>
  23. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  24. * Hsinchu 300, Taiwan.
  25. *
  26. * Larry Finger <Larry.Finger@lwfinger.net>
  27. *
  28. *****************************************************************************/
  29. #ifndef __REALTEK_FIRMWARE92S_H__
  30. #define __REALTEK_FIRMWARE92S_H__
  31. #define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000
  32. #define RTL8190_MAX_RAW_FIRMWARE_CODE_SIZE 90000
  33. #define RTL8190_CPU_START_OFFSET 0x80
  34. /* Firmware Local buffer size. 64k */
  35. #define MAX_FIRMWARE_CODE_SIZE 0xFF00
  36. #define RT_8192S_FIRMWARE_HDR_SIZE 80
  37. #define RT_8192S_FIRMWARE_HDR_EXCLUDE_PRI_SIZE 32
  38. /* support till 64 bit bus width OS */
  39. #define MAX_DEV_ADDR_SIZE 8
  40. #define MAX_FIRMWARE_INFORMATION_SIZE 32
  41. #define MAX_802_11_HEADER_LENGTH (40 + \
  42. MAX_FIRMWARE_INFORMATION_SIZE)
  43. #define ENCRYPTION_MAX_OVERHEAD 128
  44. #define MAX_FRAGMENT_COUNT 8
  45. #define MAX_TRANSMIT_BUFFER_SIZE (1600 + \
  46. (MAX_802_11_HEADER_LENGTH + \
  47. ENCRYPTION_MAX_OVERHEAD) *\
  48. MAX_FRAGMENT_COUNT)
  49. #define H2C_TX_CMD_HDR_LEN 8
  50. /* The following DM control code are for Reg0x364, */
  51. #define FW_DIG_ENABLE_CTL BIT(0)
  52. #define FW_HIGH_PWR_ENABLE_CTL BIT(1)
  53. #define FW_SS_CTL BIT(2)
  54. #define FW_RA_INIT_CTL BIT(3)
  55. #define FW_RA_BG_CTL BIT(4)
  56. #define FW_RA_N_CTL BIT(5)
  57. #define FW_PWR_TRK_CTL BIT(6)
  58. #define FW_IQK_CTL BIT(7)
  59. #define FW_FA_CTL BIT(8)
  60. #define FW_DRIVER_CTRL_DM_CTL BIT(9)
  61. #define FW_PAPE_CTL_BY_SW_HW BIT(10)
  62. #define FW_DISABLE_ALL_DM 0
  63. #define FW_PWR_TRK_PARAM_CLR 0x0000ffff
  64. #define FW_RA_PARAM_CLR 0xffff0000
  65. enum desc_packet_type {
  66. DESC_PACKET_TYPE_INIT = 0,
  67. DESC_PACKET_TYPE_NORMAL = 1,
  68. };
  69. /* 8-bytes alignment required */
  70. struct fw_priv {
  71. /* --- long word 0 ---- */
  72. /* 0x12: CE product, 0x92: IT product */
  73. u8 signature_0;
  74. /* 0x87: CE product, 0x81: IT product */
  75. u8 signature_1;
  76. /* 0x81: PCI-AP, 01:PCIe, 02: 92S-U,
  77. * 0x82: USB-AP, 0x12: 72S-U, 03:SDIO */
  78. u8 hci_sel;
  79. /* the same value as reigster value */
  80. u8 chip_version;
  81. /* customer ID low byte */
  82. u8 customer_id_0;
  83. /* customer ID high byte */
  84. u8 customer_id_1;
  85. /* 0x11: 1T1R, 0x12: 1T2R,
  86. * 0x92: 1T2R turbo, 0x22: 2T2R */
  87. u8 rf_config;
  88. /* 4: 4EP, 6: 6EP, 11: 11EP */
  89. u8 usb_ep_num;
  90. /* --- long word 1 ---- */
  91. /* regulatory class bit map 0 */
  92. u8 regulatory_class_0;
  93. /* regulatory class bit map 1 */
  94. u8 regulatory_class_1;
  95. /* regulatory class bit map 2 */
  96. u8 regulatory_class_2;
  97. /* regulatory class bit map 3 */
  98. u8 regulatory_class_3;
  99. /* 0:SWSI, 1:HWSI, 2:HWPI */
  100. u8 rfintfs;
  101. u8 def_nettype;
  102. u8 rsvd010;
  103. u8 rsvd011;
  104. /* --- long word 2 ---- */
  105. /* 0x00: normal, 0x03: MACLBK, 0x01: PHYLBK */
  106. u8 lbk_mode;
  107. /* 1: for MP use, 0: for normal
  108. * driver (to be discussed) */
  109. u8 mp_mode;
  110. u8 rsvd020;
  111. u8 rsvd021;
  112. u8 rsvd022;
  113. u8 rsvd023;
  114. u8 rsvd024;
  115. u8 rsvd025;
  116. /* --- long word 3 ---- */
  117. /* QoS enable */
  118. u8 qos_en;
  119. /* 40MHz BW enable */
  120. /* 4181 convert AMSDU to AMPDU, 0: disable */
  121. u8 bw_40mhz_en;
  122. u8 amsdu2ampdu_en;
  123. /* 11n AMPDU enable */
  124. u8 ampdu_en;
  125. /* FW offloads, 0: driver handles */
  126. u8 rate_control_offload;
  127. /* FW offloads, 0: driver handles */
  128. u8 aggregation_offload;
  129. u8 rsvd030;
  130. u8 rsvd031;
  131. /* --- long word 4 ---- */
  132. /* 1. FW offloads, 0: driver handles */
  133. u8 beacon_offload;
  134. /* 2. FW offloads, 0: driver handles */
  135. u8 mlme_offload;
  136. /* 3. FW offloads, 0: driver handles */
  137. u8 hwpc_offload;
  138. /* 4. FW offloads, 0: driver handles */
  139. u8 tcp_checksum_offload;
  140. /* 5. FW offloads, 0: driver handles */
  141. u8 tcp_offload;
  142. /* 6. FW offloads, 0: driver handles */
  143. u8 ps_control_offload;
  144. /* 7. FW offloads, 0: driver handles */
  145. u8 wwlan_offload;
  146. u8 rsvd040;
  147. /* --- long word 5 ---- */
  148. /* tcp tx packet length low byte */
  149. u8 tcp_tx_frame_len_L;
  150. /* tcp tx packet length high byte */
  151. u8 tcp_tx_frame_len_H;
  152. /* tcp rx packet length low byte */
  153. u8 tcp_rx_frame_len_L;
  154. /* tcp rx packet length high byte */
  155. u8 tcp_rx_frame_len_H;
  156. u8 rsvd050;
  157. u8 rsvd051;
  158. u8 rsvd052;
  159. u8 rsvd053;
  160. };
  161. /* 8-byte alinment required */
  162. struct fw_hdr {
  163. /* --- LONG WORD 0 ---- */
  164. u16 signature;
  165. /* 0x8000 ~ 0x8FFF for FPGA version,
  166. * 0x0000 ~ 0x7FFF for ASIC version, */
  167. u16 version;
  168. /* define the size of boot loader */
  169. u32 dmem_size;
  170. /* --- LONG WORD 1 ---- */
  171. /* define the size of FW in IMEM */
  172. u32 img_imem_size;
  173. /* define the size of FW in SRAM */
  174. u32 img_sram_size;
  175. /* --- LONG WORD 2 ---- */
  176. /* define the size of DMEM variable */
  177. u32 fw_priv_size;
  178. u32 rsvd0;
  179. /* --- LONG WORD 3 ---- */
  180. u32 rsvd1;
  181. u32 rsvd2;
  182. struct fw_priv fwpriv;
  183. } ;
  184. enum fw_status {
  185. FW_STATUS_INIT = 0,
  186. FW_STATUS_LOAD_IMEM = 1,
  187. FW_STATUS_LOAD_EMEM = 2,
  188. FW_STATUS_LOAD_DMEM = 3,
  189. FW_STATUS_READY = 4,
  190. };
  191. struct rt_firmware {
  192. struct fw_hdr *pfwheader;
  193. enum fw_status fwstatus;
  194. u16 firmwareversion;
  195. u8 fw_imem[RTL8190_MAX_FIRMWARE_CODE_SIZE];
  196. u8 fw_emem[RTL8190_MAX_FIRMWARE_CODE_SIZE];
  197. u32 fw_imem_len;
  198. u32 fw_emem_len;
  199. u8 sz_fw_tmpbuffer[RTL8190_MAX_RAW_FIRMWARE_CODE_SIZE];
  200. u32 sz_fw_tmpbufferlen;
  201. u16 cmdpacket_fragthresold;
  202. };
  203. struct h2c_set_pwrmode_parm {
  204. u8 mode;
  205. u8 flag_low_traffic_en;
  206. u8 flag_lpnav_en;
  207. u8 flag_rf_low_snr_en;
  208. /* 1: dps, 0: 32k */
  209. u8 flag_dps_en;
  210. u8 bcn_rx_en;
  211. u8 bcn_pass_cnt;
  212. /* beacon TO (ms). ¡§=0¡¨ no limit. */
  213. u8 bcn_to;
  214. u16 bcn_itv;
  215. /* only for VOIP mode. */
  216. u8 app_itv;
  217. u8 awake_bcn_itvl;
  218. u8 smart_ps;
  219. /* unit: 100 ms */
  220. u8 bcn_pass_period;
  221. };
  222. struct h2c_joinbss_rpt_parm {
  223. u8 opmode;
  224. u8 ps_qos_info;
  225. u8 bssid[6];
  226. u16 bcnitv;
  227. u16 aid;
  228. } ;
  229. struct h2c_wpa_ptk {
  230. /* EAPOL-Key Key Confirmation Key (KCK) */
  231. u8 kck[16];
  232. /* EAPOL-Key Key Encryption Key (KEK) */
  233. u8 kek[16];
  234. /* Temporal Key 1 (TK1) */
  235. u8 tk1[16];
  236. union {
  237. /* Temporal Key 2 (TK2) */
  238. u8 tk2[16];
  239. struct {
  240. u8 tx_mic_key[8];
  241. u8 rx_mic_key[8];
  242. } athu;
  243. } u;
  244. };
  245. struct h2c_wpa_two_way_parm {
  246. /* algorithm TKIP or AES */
  247. u8 pairwise_en_alg;
  248. u8 group_en_alg;
  249. struct h2c_wpa_ptk wpa_ptk_value;
  250. } ;
  251. enum h2c_cmd {
  252. FW_H2C_SETPWRMODE = 0,
  253. FW_H2C_JOINBSSRPT = 1,
  254. FW_H2C_WOWLAN_UPDATE_GTK = 2,
  255. FW_H2C_WOWLAN_UPDATE_IV = 3,
  256. FW_H2C_WOWLAN_OFFLOAD = 4,
  257. };
  258. enum fw_h2c_cmd {
  259. H2C_READ_MACREG_CMD, /*0*/
  260. H2C_WRITE_MACREG_CMD,
  261. H2C_READBB_CMD,
  262. H2C_WRITEBB_CMD,
  263. H2C_READRF_CMD,
  264. H2C_WRITERF_CMD, /*5*/
  265. H2C_READ_EEPROM_CMD,
  266. H2C_WRITE_EEPROM_CMD,
  267. H2C_READ_EFUSE_CMD,
  268. H2C_WRITE_EFUSE_CMD,
  269. H2C_READ_CAM_CMD, /*10*/
  270. H2C_WRITE_CAM_CMD,
  271. H2C_SETBCNITV_CMD,
  272. H2C_SETMBIDCFG_CMD,
  273. H2C_JOINBSS_CMD,
  274. H2C_DISCONNECT_CMD, /*15*/
  275. H2C_CREATEBSS_CMD,
  276. H2C_SETOPMode_CMD,
  277. H2C_SITESURVEY_CMD,
  278. H2C_SETAUTH_CMD,
  279. H2C_SETKEY_CMD, /*20*/
  280. H2C_SETSTAKEY_CMD,
  281. H2C_SETASSOCSTA_CMD,
  282. H2C_DELASSOCSTA_CMD,
  283. H2C_SETSTAPWRSTATE_CMD,
  284. H2C_SETBASICRATE_CMD, /*25*/
  285. H2C_GETBASICRATE_CMD,
  286. H2C_SETDATARATE_CMD,
  287. H2C_GETDATARATE_CMD,
  288. H2C_SETPHYINFO_CMD,
  289. H2C_GETPHYINFO_CMD, /*30*/
  290. H2C_SETPHY_CMD,
  291. H2C_GETPHY_CMD,
  292. H2C_READRSSI_CMD,
  293. H2C_READGAIN_CMD,
  294. H2C_SETATIM_CMD, /*35*/
  295. H2C_SETPWRMODE_CMD,
  296. H2C_JOINBSSRPT_CMD,
  297. H2C_SETRATABLE_CMD,
  298. H2C_GETRATABLE_CMD,
  299. H2C_GETCCXREPORT_CMD, /*40*/
  300. H2C_GETDTMREPORT_CMD,
  301. H2C_GETTXRATESTATICS_CMD,
  302. H2C_SETUSBSUSPEND_CMD,
  303. H2C_SETH2CLBK_CMD,
  304. H2C_TMP1, /*45*/
  305. H2C_WOWLAN_UPDATE_GTK_CMD,
  306. H2C_WOWLAN_FW_OFFLOAD,
  307. H2C_TMP2,
  308. H2C_TMP3,
  309. H2C_WOWLAN_UPDATE_IV_CMD, /*50*/
  310. H2C_TMP4,
  311. };
  312. /* The following macros are used for FW
  313. * CMD map and parameter updated. */
  314. #define FW_CMD_IO_CLR(rtlpriv, _Bit) \
  315. do { \
  316. udelay(1000); \
  317. rtlpriv->rtlhal.fwcmd_iomap &= (~_Bit); \
  318. } while (0)
  319. #define FW_CMD_IO_UPDATE(rtlpriv, _val) \
  320. rtlpriv->rtlhal.fwcmd_iomap = _val;
  321. #define FW_CMD_IO_SET(rtlpriv, _val) \
  322. do { \
  323. rtl_write_word(rtlpriv, LBUS_MON_ADDR, (u16)_val); \
  324. FW_CMD_IO_UPDATE(rtlpriv, _val); \
  325. } while (0)
  326. #define FW_CMD_PARA_SET(rtlpriv, _val) \
  327. do { \
  328. rtl_write_dword(rtlpriv, LBUS_ADDR_MASK, _val); \
  329. rtlpriv->rtlhal.fwcmd_ioparam = _val; \
  330. } while (0)
  331. #define FW_CMD_IO_QUERY(rtlpriv) \
  332. (u16)(rtlpriv->rtlhal.fwcmd_iomap)
  333. #define FW_CMD_IO_PARA_QUERY(rtlpriv) \
  334. ((u32)(rtlpriv->rtlhal.fwcmd_ioparam))
  335. int rtl92s_download_fw(struct ieee80211_hw *hw);
  336. void rtl92s_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode);
  337. void rtl92s_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw,
  338. u8 mstatus, u8 ps_qosinfo);
  339. #endif