fw.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. * The full GNU General Public License is included in this distribution in the
  15. * file called LICENSE.
  16. *
  17. * Contact Information:
  18. * wlanfae <wlanfae@realtek.com>
  19. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  20. * Hsinchu 300, Taiwan.
  21. *
  22. * Larry Finger <Larry.Finger@lwfinger.net>
  23. *
  24. *****************************************************************************/
  25. #ifndef __RTL92D__FW__H__
  26. #define __RTL92D__FW__H__
  27. #define FW_8192D_START_ADDRESS 0x1000
  28. #define FW_8192D_PAGE_SIZE 4096
  29. #define FW_8192D_POLLING_TIMEOUT_COUNT 1000
  30. #define IS_FW_HEADER_EXIST(_pfwhdr) \
  31. ((GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFF0) == 0x92C0 || \
  32. (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFF0) == 0x88C0 || \
  33. (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D0 || \
  34. (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D1 || \
  35. (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D2 || \
  36. (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D3)
  37. /* Define a macro that takes an le32 word, converts it to host ordering,
  38. * right shifts by a specified count, creates a mask of the specified
  39. * bit count, and extracts that number of bits.
  40. */
  41. #define SHIFT_AND_MASK_LE(__pdesc, __shift, __mask) \
  42. ((le32_to_cpu(*(((__le32 *)(__pdesc)))) >> (__shift)) & \
  43. BIT_LEN_MASK_32(__mask))
  44. /* Firmware Header(8-byte alinment required) */
  45. /* --- LONG WORD 0 ---- */
  46. #define GET_FIRMWARE_HDR_SIGNATURE(__fwhdr) \
  47. SHIFT_AND_MASK_LE(__fwhdr, 0, 16)
  48. #define GET_FIRMWARE_HDR_CATEGORY(__fwhdr) \
  49. SHIFT_AND_MASK_LE(__fwhdr, 16, 8)
  50. #define GET_FIRMWARE_HDR_FUNCTION(__fwhdr) \
  51. SHIFT_AND_MASK_LE(__fwhdr, 24, 8)
  52. #define GET_FIRMWARE_HDR_VERSION(__fwhdr) \
  53. SHIFT_AND_MASK_LE(__fwhdr + 4, 0, 16)
  54. #define GET_FIRMWARE_HDR_SUB_VER(__fwhdr) \
  55. SHIFT_AND_MASK_LE(__fwhdr + 4, 16, 8)
  56. #define GET_FIRMWARE_HDR_RSVD1(__fwhdr) \
  57. SHIFT_AND_MASK_LE(__fwhdr + 4, 24, 8)
  58. /* --- LONG WORD 1 ---- */
  59. #define GET_FIRMWARE_HDR_MONTH(__fwhdr) \
  60. SHIFT_AND_MASK_LE(__fwhdr + 8, 0, 8)
  61. #define GET_FIRMWARE_HDR_DATE(__fwhdr) \
  62. SHIFT_AND_MASK_LE(__fwhdr + 8, 8, 8)
  63. #define GET_FIRMWARE_HDR_HOUR(__fwhdr) \
  64. SHIFT_AND_MASK_LE(__fwhdr + 8, 16, 8)
  65. #define GET_FIRMWARE_HDR_MINUTE(__fwhdr) \
  66. SHIFT_AND_MASK_LE(__fwhdr + 8, 24, 8)
  67. #define GET_FIRMWARE_HDR_ROMCODE_SIZE(__fwhdr) \
  68. SHIFT_AND_MASK_LE(__fwhdr + 12, 0, 16)
  69. #define GET_FIRMWARE_HDR_RSVD2(__fwhdr) \
  70. SHIFT_AND_MASK_LE(__fwhdr + 12, 16, 16)
  71. /* --- LONG WORD 2 ---- */
  72. #define GET_FIRMWARE_HDR_SVN_IDX(__fwhdr) \
  73. SHIFT_AND_MASK_LE(__fwhdr + 16, 0, 32)
  74. #define GET_FIRMWARE_HDR_RSVD3(__fwhdr) \
  75. SHIFT_AND_MASK_LE(__fwhdr + 20, 0, 32)
  76. /* --- LONG WORD 3 ---- */
  77. #define GET_FIRMWARE_HDR_RSVD4(__fwhdr) \
  78. SHIFT_AND_MASK_LE(__fwhdr + 24, 0, 32)
  79. #define GET_FIRMWARE_HDR_RSVD5(__fwhdr) \
  80. SHIFT_AND_MASK_LE(__fwhdr + 28, 0, 32)
  81. #define pagenum_128(_len) \
  82. (u32)(((_len) >> 7) + ((_len) & 0x7F ? 1 : 0))
  83. #define SET_H2CCMD_PWRMODE_PARM_MODE(__ph2ccmd, __val) \
  84. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
  85. #define SET_H2CCMD_PWRMODE_PARM_SMART_PS(__ph2ccmd, __val) \
  86. SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 1, 0, 8, __val)
  87. #define SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(__ph2ccmd, __val) \
  88. SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 2, 0, 8, __val)
  89. #define SET_H2CCMD_JOINBSSRPT_PARM_OPMODE(__ph2ccmd, __val) \
  90. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
  91. #define SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__ph2ccmd, __val) \
  92. SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
  93. #define SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(__ph2ccmd, __val) \
  94. SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 1, 0, 8, __val)
  95. #define SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__ph2ccmd, __val) \
  96. SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 2, 0, 8, __val)
  97. int rtl92d_download_fw(struct ieee80211_hw *hw);
  98. void rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id,
  99. u32 cmd_len, u8 *p_cmdbuffer);
  100. void rtl92d_firmware_selfreset(struct ieee80211_hw *hw);
  101. void rtl92d_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished);
  102. void rtl92d_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus);
  103. #endif