1 /* 2 * Copyright (C) 2018 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #ifndef __MT76x02_MCU_H 18 #define __MT76x02_MCU_H 19 20 #include "mt76x02.h" 21 22 #define MT_MCU_RESET_CTL 0x070C 23 #define MT_MCU_INT_LEVEL 0x0718 24 #define MT_MCU_COM_REG0 0x0730 25 #define MT_MCU_COM_REG1 0x0734 26 #define MT_MCU_COM_REG2 0x0738 27 #define MT_MCU_COM_REG3 0x073C 28 29 #define MT_INBAND_PACKET_MAX_LEN 192 30 #define MT_MCU_MEMMAP_WLAN 0x410000 31 32 #define MT_MCU_PCIE_REMAP_BASE4 0x074C 33 34 #define MT_MCU_SEMAPHORE_00 0x07B0 35 #define MT_MCU_SEMAPHORE_01 0x07B4 36 #define MT_MCU_SEMAPHORE_02 0x07B8 37 #define MT_MCU_SEMAPHORE_03 0x07BC 38 39 #define MT_MCU_ILM_ADDR 0x80000 40 41 enum mcu_cmd { 42 CMD_FUN_SET_OP = 1, 43 CMD_LOAD_CR = 2, 44 CMD_INIT_GAIN_OP = 3, 45 CMD_DYNC_VGA_OP = 6, 46 CMD_TDLS_CH_SW = 7, 47 CMD_BURST_WRITE = 8, 48 CMD_READ_MODIFY_WRITE = 9, 49 CMD_RANDOM_READ = 10, 50 CMD_BURST_READ = 11, 51 CMD_RANDOM_WRITE = 12, 52 CMD_LED_MODE_OP = 16, 53 CMD_POWER_SAVING_OP = 20, 54 CMD_WOW_CONFIG = 21, 55 CMD_WOW_QUERY = 22, 56 CMD_WOW_FEATURE = 24, 57 CMD_CARRIER_DETECT_OP = 28, 58 CMD_RADOR_DETECT_OP = 29, 59 CMD_SWITCH_CHANNEL_OP = 30, 60 CMD_CALIBRATION_OP = 31, 61 CMD_BEACON_OP = 32, 62 CMD_ANTENNA_OP = 33, 63 }; 64 65 enum mcu_power_mode { 66 RADIO_OFF = 0x30, 67 RADIO_ON = 0x31, 68 RADIO_OFF_AUTO_WAKEUP = 0x32, 69 RADIO_OFF_ADVANCE = 0x33, 70 RADIO_ON_ADVANCE = 0x34, 71 }; 72 73 enum mcu_function { 74 Q_SELECT = 1, 75 BW_SETTING = 2, 76 USB2_SW_DISCONNECT = 2, 77 USB3_SW_DISCONNECT = 3, 78 LOG_FW_DEBUG_MSG = 4, 79 GET_FW_VERSION = 5, 80 }; 81 82 struct mt76x02_fw_header { 83 __le32 ilm_len; 84 __le32 dlm_len; 85 __le16 build_ver; 86 __le16 fw_ver; 87 u8 pad[4]; 88 char build_time[16]; 89 }; 90 91 struct mt76x02_patch_header { 92 char build_time[16]; 93 char platform[4]; 94 char hw_version[4]; 95 char patch_version[4]; 96 u8 pad[2]; 97 }; 98 99 static inline struct sk_buff * 100 mt76x02_mcu_msg_alloc(const void *data, int len) 101 { 102 return mt76_mcu_msg_alloc(data, 0, len, 0); 103 } 104 105 int mt76x02_mcu_cleanup(struct mt76x02_dev *dev); 106 int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type, u32 param); 107 int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data, 108 int len, bool wait_resp); 109 int mt76x02_mcu_function_select(struct mt76x02_dev *dev, enum mcu_function func, 110 u32 val); 111 int mt76x02_mcu_set_radio_state(struct mt76x02_dev *dev, bool on); 112 void mt76x02_set_ethtool_fwver(struct mt76x02_dev *dev, 113 const struct mt76x02_fw_header *h); 114 115 #endif /* __MT76x02_MCU_H */ 116