mt76x02_mcu.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* SPDX-License-Identifier: ISC */
  2. /*
  3. * Copyright (C) 2018 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
  4. */
  5. #ifndef __MT76x02_MCU_H
  6. #define __MT76x02_MCU_H
  7. #include "mt76x02.h"
  8. #define MT_MCU_RESET_CTL 0x070C
  9. #define MT_MCU_INT_LEVEL 0x0718
  10. #define MT_MCU_COM_REG0 0x0730
  11. #define MT_MCU_COM_REG1 0x0734
  12. #define MT_MCU_COM_REG2 0x0738
  13. #define MT_MCU_COM_REG3 0x073C
  14. #define MT_INBAND_PACKET_MAX_LEN 192
  15. #define MT_MCU_MEMMAP_WLAN 0x410000
  16. #define MT_MCU_PCIE_REMAP_BASE4 0x074C
  17. #define MT_MCU_SEMAPHORE_00 0x07B0
  18. #define MT_MCU_SEMAPHORE_01 0x07B4
  19. #define MT_MCU_SEMAPHORE_02 0x07B8
  20. #define MT_MCU_SEMAPHORE_03 0x07BC
  21. #define MT_MCU_ILM_ADDR 0x80000
  22. enum mcu_cmd {
  23. CMD_FUN_SET_OP = 1,
  24. CMD_LOAD_CR = 2,
  25. CMD_INIT_GAIN_OP = 3,
  26. CMD_DYNC_VGA_OP = 6,
  27. CMD_TDLS_CH_SW = 7,
  28. CMD_BURST_WRITE = 8,
  29. CMD_READ_MODIFY_WRITE = 9,
  30. CMD_RANDOM_READ = 10,
  31. CMD_BURST_READ = 11,
  32. CMD_RANDOM_WRITE = 12,
  33. CMD_LED_MODE_OP = 16,
  34. CMD_POWER_SAVING_OP = 20,
  35. CMD_WOW_CONFIG = 21,
  36. CMD_WOW_QUERY = 22,
  37. CMD_WOW_FEATURE = 24,
  38. CMD_CARRIER_DETECT_OP = 28,
  39. CMD_RADOR_DETECT_OP = 29,
  40. CMD_SWITCH_CHANNEL_OP = 30,
  41. CMD_CALIBRATION_OP = 31,
  42. CMD_BEACON_OP = 32,
  43. CMD_ANTENNA_OP = 33,
  44. };
  45. enum mcu_power_mode {
  46. RADIO_OFF = 0x30,
  47. RADIO_ON = 0x31,
  48. RADIO_OFF_AUTO_WAKEUP = 0x32,
  49. RADIO_OFF_ADVANCE = 0x33,
  50. RADIO_ON_ADVANCE = 0x34,
  51. };
  52. enum mcu_function {
  53. Q_SELECT = 1,
  54. BW_SETTING = 2,
  55. USB2_SW_DISCONNECT = 2,
  56. USB3_SW_DISCONNECT = 3,
  57. LOG_FW_DEBUG_MSG = 4,
  58. GET_FW_VERSION = 5,
  59. };
  60. struct mt76x02_fw_header {
  61. __le32 ilm_len;
  62. __le32 dlm_len;
  63. __le16 build_ver;
  64. __le16 fw_ver;
  65. u8 pad[4];
  66. char build_time[16];
  67. };
  68. struct mt76x02_patch_header {
  69. char build_time[16];
  70. char platform[4];
  71. char hw_version[4];
  72. char patch_version[4];
  73. u8 pad[2];
  74. };
  75. int mt76x02_mcu_cleanup(struct mt76x02_dev *dev);
  76. int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type, u32 param);
  77. int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
  78. int len, bool wait_resp);
  79. int mt76x02_mcu_parse_response(struct mt76_dev *mdev, int cmd,
  80. struct sk_buff *skb, int seq);
  81. int mt76x02_mcu_function_select(struct mt76x02_dev *dev, enum mcu_function func,
  82. u32 val);
  83. int mt76x02_mcu_set_radio_state(struct mt76x02_dev *dev, bool on);
  84. void mt76x02_set_ethtool_fwver(struct mt76x02_dev *dev,
  85. const struct mt76x02_fw_header *h);
  86. #endif /* __MT76x02_MCU_H */