efuse.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 __RTL_EFUSE_H_
  26. #define __RTL_EFUSE_H_
  27. #define EFUSE_IC_ID_OFFSET 506
  28. #define EFUSE_MAX_WORD_UNIT 4
  29. #define EFUSE_INIT_MAP 0
  30. #define EFUSE_MODIFY_MAP 1
  31. #define PG_STATE_HEADER 0x01
  32. #define PG_STATE_WORD_0 0x02
  33. #define PG_STATE_WORD_1 0x04
  34. #define PG_STATE_WORD_2 0x08
  35. #define PG_STATE_WORD_3 0x10
  36. #define PG_STATE_DATA 0x20
  37. #define EFUSE_REPEAT_THRESHOLD_ 3
  38. #define EFUSE_ERROE_HANDLE 1
  39. struct efuse_map {
  40. u8 offset;
  41. u8 word_start;
  42. u8 byte_start;
  43. u8 byte_cnts;
  44. };
  45. struct pgpkt_struct {
  46. u8 offset;
  47. u8 word_en;
  48. u8 data[8];
  49. };
  50. enum efuse_data_item {
  51. EFUSE_CHIP_ID = 0,
  52. EFUSE_LDO_SETTING,
  53. EFUSE_CLK_SETTING,
  54. EFUSE_SDIO_SETTING,
  55. EFUSE_CCCR,
  56. EFUSE_SDIO_MODE,
  57. EFUSE_OCR,
  58. EFUSE_F0CIS,
  59. EFUSE_F1CIS,
  60. EFUSE_MAC_ADDR,
  61. EFUSE_EEPROM_VER,
  62. EFUSE_CHAN_PLAN,
  63. EFUSE_TXPW_TAB
  64. };
  65. enum {
  66. VOLTAGE_V25 = 0x03,
  67. LDOE25_SHIFT = 28,
  68. };
  69. struct efuse_priv {
  70. u8 id[2];
  71. u8 ldo_setting[2];
  72. u8 clk_setting[2];
  73. u8 cccr;
  74. u8 sdio_mode;
  75. u8 ocr[3];
  76. u8 cis0[17];
  77. u8 cis1[48];
  78. u8 mac_addr[6];
  79. u8 eeprom_verno;
  80. u8 channel_plan;
  81. u8 tx_power_b[14];
  82. u8 tx_power_g[14];
  83. };
  84. void read_efuse_byte(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf);
  85. void efuse_initialize(struct ieee80211_hw *hw);
  86. u8 efuse_read_1byte(struct ieee80211_hw *hw, u16 address);
  87. int efuse_one_byte_read(struct ieee80211_hw *hw, u16 addr, u8 *data);
  88. void efuse_write_1byte(struct ieee80211_hw *hw, u16 address, u8 value);
  89. void read_efuse(struct ieee80211_hw *hw, u16 _offset,
  90. u16 _size_byte, u8 *pbuf);
  91. void efuse_shadow_read(struct ieee80211_hw *hw, u8 type,
  92. u16 offset, u32 *value);
  93. void efuse_shadow_write(struct ieee80211_hw *hw, u8 type,
  94. u16 offset, u32 value);
  95. bool efuse_shadow_update(struct ieee80211_hw *hw);
  96. bool efuse_shadow_update_chk(struct ieee80211_hw *hw);
  97. void rtl_efuse_shadow_map_update(struct ieee80211_hw *hw);
  98. void efuse_force_write_vendor_Id(struct ieee80211_hw *hw);
  99. void efuse_re_pg_section(struct ieee80211_hw *hw, u8 section_idx);
  100. void efuse_power_switch(struct ieee80211_hw *hw, u8 write, u8 pwrstate);
  101. int rtl_get_hwinfo(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv,
  102. int max_size, u8 *hwinfo, int *params);
  103. void rtl_fill_dummy(u8 *pfwbuf, u32 *pfwlen);
  104. void rtl_fw_page_write(struct ieee80211_hw *hw, u32 page, const u8 *buffer,
  105. u32 size);
  106. void rtl_fw_block_write(struct ieee80211_hw *hw, const u8 *buffer, u32 size);
  107. void rtl_efuse_ops_init(struct ieee80211_hw *hw);
  108. #endif