efuse.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /******************************************************************************
  3. *
  4. * Copyright(c) 2009-2012 Realtek Corporation.
  5. *
  6. * Contact Information:
  7. * wlanfae <wlanfae@realtek.com>
  8. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  9. * Hsinchu 300, Taiwan.
  10. *
  11. * Larry Finger <Larry.Finger@lwfinger.net>
  12. *
  13. *****************************************************************************/
  14. #ifndef __RTL_EFUSE_H_
  15. #define __RTL_EFUSE_H_
  16. #define EFUSE_IC_ID_OFFSET 506
  17. #define EFUSE_MAX_WORD_UNIT 4
  18. #define EFUSE_INIT_MAP 0
  19. #define EFUSE_MODIFY_MAP 1
  20. #define PG_STATE_HEADER 0x01
  21. #define PG_STATE_WORD_0 0x02
  22. #define PG_STATE_WORD_1 0x04
  23. #define PG_STATE_WORD_2 0x08
  24. #define PG_STATE_WORD_3 0x10
  25. #define PG_STATE_DATA 0x20
  26. #define EFUSE_REPEAT_THRESHOLD_ 3
  27. #define EFUSE_ERROE_HANDLE 1
  28. struct efuse_map {
  29. u8 offset;
  30. u8 word_start;
  31. u8 byte_start;
  32. u8 byte_cnts;
  33. };
  34. struct pgpkt_struct {
  35. u8 offset;
  36. u8 word_en;
  37. u8 data[8];
  38. };
  39. enum efuse_data_item {
  40. EFUSE_CHIP_ID = 0,
  41. EFUSE_LDO_SETTING,
  42. EFUSE_CLK_SETTING,
  43. EFUSE_SDIO_SETTING,
  44. EFUSE_CCCR,
  45. EFUSE_SDIO_MODE,
  46. EFUSE_OCR,
  47. EFUSE_F0CIS,
  48. EFUSE_F1CIS,
  49. EFUSE_MAC_ADDR,
  50. EFUSE_EEPROM_VER,
  51. EFUSE_CHAN_PLAN,
  52. EFUSE_TXPW_TAB
  53. };
  54. enum {
  55. VOLTAGE_V25 = 0x03,
  56. LDOE25_SHIFT = 28,
  57. };
  58. struct efuse_priv {
  59. u8 id[2];
  60. u8 ldo_setting[2];
  61. u8 clk_setting[2];
  62. u8 cccr;
  63. u8 sdio_mode;
  64. u8 ocr[3];
  65. u8 cis0[17];
  66. u8 cis1[48];
  67. u8 mac_addr[6];
  68. u8 eeprom_verno;
  69. u8 channel_plan;
  70. u8 tx_power_b[14];
  71. u8 tx_power_g[14];
  72. };
  73. void read_efuse_byte(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf);
  74. void efuse_initialize(struct ieee80211_hw *hw);
  75. u8 efuse_read_1byte(struct ieee80211_hw *hw, u16 address);
  76. int efuse_one_byte_read(struct ieee80211_hw *hw, u16 addr, u8 *data);
  77. void efuse_write_1byte(struct ieee80211_hw *hw, u16 address, u8 value);
  78. void read_efuse(struct ieee80211_hw *hw, u16 _offset,
  79. u16 _size_byte, u8 *pbuf);
  80. void efuse_shadow_read(struct ieee80211_hw *hw, u8 type,
  81. u16 offset, u32 *value);
  82. void efuse_shadow_write(struct ieee80211_hw *hw, u8 type,
  83. u16 offset, u32 value);
  84. bool efuse_shadow_update(struct ieee80211_hw *hw);
  85. bool efuse_shadow_update_chk(struct ieee80211_hw *hw);
  86. void rtl_efuse_shadow_map_update(struct ieee80211_hw *hw);
  87. void efuse_force_write_vendor_id(struct ieee80211_hw *hw);
  88. void efuse_re_pg_section(struct ieee80211_hw *hw, u8 section_idx);
  89. void efuse_power_switch(struct ieee80211_hw *hw, u8 write, u8 pwrstate);
  90. int rtl_get_hwinfo(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv,
  91. int max_size, u8 *hwinfo, int *params);
  92. void rtl_fill_dummy(u8 *pfwbuf, u32 *pfwlen);
  93. void rtl_fw_page_write(struct ieee80211_hw *hw, u32 page, const u8 *buffer,
  94. u32 size);
  95. void rtl_fw_block_write(struct ieee80211_hw *hw, const u8 *buffer, u32 size);
  96. #endif