rtw_efuse.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 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 __RTW_EFUSE_H__
  21. #define __RTW_EFUSE_H__
  22. #define EFUSE_ERROE_HANDLE 1
  23. #define PG_STATE_HEADER 0x01
  24. #define PG_STATE_WORD_0 0x02
  25. #define PG_STATE_WORD_1 0x04
  26. #define PG_STATE_WORD_2 0x08
  27. #define PG_STATE_WORD_3 0x10
  28. #define PG_STATE_DATA 0x20
  29. #define PG_SWBYTE_H 0x01
  30. #define PG_SWBYTE_L 0x02
  31. #define PGPKT_DATA_SIZE 8
  32. #define EFUSE_WIFI 0
  33. #define EFUSE_BT 1
  34. enum _EFUSE_DEF_TYPE {
  35. TYPE_EFUSE_MAX_SECTION = 0,
  36. TYPE_EFUSE_REAL_CONTENT_LEN = 1,
  37. TYPE_AVAILABLE_EFUSE_BYTES_BANK = 2,
  38. TYPE_AVAILABLE_EFUSE_BYTES_TOTAL = 3,
  39. TYPE_EFUSE_MAP_LEN = 4,
  40. TYPE_EFUSE_PROTECT_BYTES_BANK = 5,
  41. TYPE_EFUSE_CONTENT_LEN_BANK = 6,
  42. };
  43. #define EFUSE_MAX_MAP_LEN 256
  44. #define EFUSE_MAX_HW_SIZE 512
  45. #define EFUSE_MAX_SECTION_BASE 16
  46. #define EXT_HEADER(header) ((header & 0x1F ) == 0x0F)
  47. #define ALL_WORDS_DISABLED(wde) ((wde & 0x0F) == 0x0F)
  48. #define GET_HDR_OFFSET_2_0(header) ( (header & 0xE0) >> 5)
  49. #define EFUSE_REPEAT_THRESHOLD_ 3
  50. //=============================================
  51. // The following is for BT Efuse definition
  52. //=============================================
  53. #define EFUSE_BT_MAX_MAP_LEN 1024
  54. #define EFUSE_MAX_BANK 4
  55. #define EFUSE_MAX_BT_BANK (EFUSE_MAX_BANK-1)
  56. //=============================================
  57. /*--------------------------Define Parameters-------------------------------*/
  58. #define EFUSE_MAX_WORD_UNIT 4
  59. /*------------------------------Define structure----------------------------*/
  60. typedef struct PG_PKT_STRUCT_A{
  61. u8 offset;
  62. u8 word_en;
  63. u8 data[8];
  64. u8 word_cnts;
  65. }PGPKT_STRUCT,*PPGPKT_STRUCT;
  66. /*------------------------------Define structure----------------------------*/
  67. typedef struct _EFUSE_HAL{
  68. u8 fakeEfuseBank;
  69. u32 fakeEfuseUsedBytes;
  70. u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE];
  71. u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN];
  72. u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN];
  73. u16 BTEfuseUsedBytes;
  74. u8 BTEfuseUsedPercentage;
  75. u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
  76. u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN];
  77. u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN];
  78. u16 fakeBTEfuseUsedBytes;
  79. u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
  80. u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN];
  81. u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN];
  82. }EFUSE_HAL, *PEFUSE_HAL;
  83. /*------------------------Export global variable----------------------------*/
  84. extern u8 fakeEfuseBank;
  85. extern u32 fakeEfuseUsedBytes;
  86. extern u8 fakeEfuseContent[];
  87. extern u8 fakeEfuseInitMap[];
  88. extern u8 fakeEfuseModifiedMap[];
  89. extern u32 BTEfuseUsedBytes;
  90. extern u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
  91. extern u8 BTEfuseInitMap[];
  92. extern u8 BTEfuseModifiedMap[];
  93. extern u32 fakeBTEfuseUsedBytes;
  94. extern u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE];
  95. extern u8 fakeBTEfuseInitMap[];
  96. extern u8 fakeBTEfuseModifiedMap[];
  97. /*------------------------Export global variable----------------------------*/
  98. u8 efuse_GetCurrentSize(PADAPTER padapter, u16 *size);
  99. u16 efuse_GetMaxSize(PADAPTER padapter);
  100. u8 rtw_efuse_access(PADAPTER padapter, u8 bRead, u16 start_addr, u16 cnts, u8 *data);
  101. u8 rtw_efuse_map_read(PADAPTER padapter, u16 addr, u16 cnts, u8 *data);
  102. u8 rtw_efuse_map_write(PADAPTER padapter, u16 addr, u16 cnts, u8 *data);
  103. u8 rtw_BT_efuse_map_read(PADAPTER padapter, u16 addr, u16 cnts, u8 *data);
  104. u8 rtw_BT_efuse_map_write(PADAPTER padapter, u16 addr, u16 cnts, u8 *data);
  105. u16 Efuse_GetCurrentSize(PADAPTER pAdapter, u8 efuseType, BOOLEAN bPseudoTest);
  106. u8 Efuse_CalculateWordCnts(u8 word_en);
  107. void ReadEFuseByte(PADAPTER Adapter, u16 _offset, u8 *pbuf, BOOLEAN bPseudoTest) ;
  108. void EFUSE_GetEfuseDefinition(PADAPTER pAdapter, u8 efuseType, u8 type, void *pOut, BOOLEAN bPseudoTest);
  109. u8 efuse_OneByteRead(PADAPTER pAdapter, u16 addr, u8 *data, BOOLEAN bPseudoTest);
  110. u8 efuse_OneByteWrite(PADAPTER pAdapter, u16 addr, u8 data, BOOLEAN bPseudoTest);
  111. void Efuse_PowerSwitch(PADAPTER pAdapter,u8 bWrite,u8 PwrState);
  112. int Efuse_PgPacketRead(PADAPTER pAdapter, u8 offset, u8 *data, BOOLEAN bPseudoTest);
  113. int Efuse_PgPacketWrite(PADAPTER pAdapter, u8 offset, u8 word_en, u8 *data, BOOLEAN bPseudoTest);
  114. void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata);
  115. u8 Efuse_WordEnableDataWrite(PADAPTER pAdapter, u16 efuse_addr, u8 word_en, u8 *data, BOOLEAN bPseudoTest);
  116. u8 EFUSE_Read1Byte(PADAPTER pAdapter, u16 Address);
  117. void EFUSE_ShadowMapUpdate(PADAPTER pAdapter, u8 efuseType, BOOLEAN bPseudoTest);
  118. void EFUSE_ShadowRead(PADAPTER pAdapter, u8 Type, u16 Offset, u32 *Value);
  119. #endif