developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 1 | /* Copyright (C) 2021-2022 Mediatek Inc. */ |
| 2 | #ifndef __ATENL_H |
| 3 | #define __ATENL_H |
| 4 | |
| 5 | #include <arpa/inet.h> |
| 6 | #include <errno.h> |
| 7 | #include <fcntl.h> |
| 8 | #include <limits.h> |
| 9 | #include <linux/nl80211.h> |
| 10 | #include <net/if.h> |
| 11 | #include <stdbool.h> |
| 12 | #include <stdio.h> |
| 13 | #include <stdlib.h> |
| 14 | #include <unistd.h> |
| 15 | |
| 16 | #include "nl.h" |
| 17 | #include "util.h" |
| 18 | #include "debug.h" |
| 19 | |
| 20 | #define BRIDGE_NAME_OPENWRT "br-lan" |
| 21 | #define BRIDGE_NAME_RDKB "brlan0" |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 22 | #define ETH_P_RACFG 0x2880 |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 23 | #define RACFG_PKT_MAX_SIZE 1600 |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 24 | #define RACFG_HLEN 12 |
| 25 | #define RACFG_MAGIC_NO 0x18142880 |
| 26 | #define PRE_CAL_INFO 16 |
developer | 963a66b | 2023-04-11 13:34:56 +0800 | [diff] [blame] | 27 | #define DPD_INFO_CH_SHIFT 30 |
| 28 | #define DPD_INFO_2G_SHIFT 20 |
| 29 | #define DPD_INFO_5G_SHIFT 10 |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 30 | #define DPD_INFO_6G_SHIFT 0 |
developer | 963a66b | 2023-04-11 13:34:56 +0800 | [diff] [blame] | 31 | #define DPD_INFO_MASK GENMASK(9, 0) |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 32 | #define MT_EE_CAL_UNIT 1024 |
| 33 | |
| 34 | #define RACFG_CMD_TYPE_MASK GENMASK(14, 0) |
| 35 | #define RACFG_CMD_TYPE_ETHREQ BIT(3) |
| 36 | #define RACFG_CMD_TYPE_PLATFORM_MODULE GENMASK(4, 3) |
| 37 | |
| 38 | #define set_band_val(_an, _band, _field, _val) \ |
| 39 | _an->anb[_band]._field = (_val) |
| 40 | #define get_band_val(_an, _band, _field) \ |
| 41 | (_an->anb[_band]._field) |
| 42 | |
| 43 | enum atenl_rf_mode { |
| 44 | ATENL_RF_MODE_NORMAL, |
| 45 | ATENL_RF_MODE_TEST, |
| 46 | ATENL_RF_MODE_ICAP, |
| 47 | ATENL_RF_MODE_ICAP_OVERLAP, |
| 48 | |
| 49 | __ATENL_RF_MODE_MAX, |
| 50 | }; |
| 51 | |
| 52 | struct atenl_rx_stat { |
| 53 | u64 total; |
| 54 | u64 ok_cnt; |
| 55 | u64 err_cnt; |
| 56 | u64 len_mismatch; |
| 57 | }; |
| 58 | |
| 59 | struct atenl_band { |
| 60 | bool valid; |
| 61 | u8 phy_idx; |
| 62 | u8 cap; |
| 63 | u8 chainmask; |
| 64 | |
| 65 | enum mt76_testmode_state cur_state; |
| 66 | s8 tx_power; |
| 67 | enum atenl_rf_mode rf_mode; |
| 68 | |
| 69 | bool use_tx_time; |
| 70 | u32 tx_time; |
| 71 | u32 tx_mpdu_len; |
| 72 | |
| 73 | bool reset_tx_cnt; |
| 74 | bool reset_rx_cnt; |
| 75 | |
| 76 | /* history */ |
| 77 | struct atenl_rx_stat rx_stat; |
| 78 | }; |
| 79 | |
| 80 | #define MAX_BAND_NUM 3 |
| 81 | |
| 82 | struct atenl { |
| 83 | struct atenl_band anb[MAX_BAND_NUM]; |
| 84 | u16 chip_id; |
| 85 | u16 adie_id; |
| 86 | u8 sub_chip_id; |
| 87 | u8 cur_band; |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 88 | u8 main_phy_idx; |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 89 | |
| 90 | u8 mac_addr[ETH_ALEN]; |
| 91 | char *bridge_name; |
| 92 | bool unicast; |
| 93 | int sock_eth; |
| 94 | |
| 95 | const char *mtd_part; |
| 96 | u32 mtd_offset; |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 97 | u8 band_idx; |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 98 | u8 *eeprom_data; |
| 99 | int eeprom_fd; |
| 100 | u16 eeprom_size; |
| 101 | u32 eeprom_prek_offs; |
| 102 | |
| 103 | u8 *cal; |
| 104 | u32 cal_info[5]; |
| 105 | |
| 106 | bool cmd_mode; |
| 107 | |
| 108 | /* intermediate data */ |
| 109 | u8 ibf_mcs; |
| 110 | u8 ibf_ant; |
| 111 | }; |
| 112 | |
| 113 | struct atenl_cmd_hdr { |
| 114 | __be32 magic_no; |
| 115 | __be16 cmd_type; |
| 116 | __be16 cmd_id; |
| 117 | __be16 len; |
| 118 | __be16 seq; |
| 119 | u8 data[2048]; |
| 120 | } __attribute__((packed)); |
| 121 | |
| 122 | enum atenl_cmd { |
| 123 | HQA_CMD_UNKNOWN, |
| 124 | HQA_CMD_LEGACY, /* legacy or deprecated */ |
| 125 | |
| 126 | HQA_CMD_OPEN_ADAPTER, |
| 127 | HQA_CMD_CLOSE_ADAPTER, |
| 128 | HQA_CMD_GET_CHIP_ID, |
| 129 | HQA_CMD_GET_SUB_CHIP_ID, |
| 130 | HQA_CMD_SET_TX_BW, |
| 131 | HQA_CMD_SET_TX_PKT_BW, |
| 132 | HQA_CMD_SET_TX_PRI_BW, |
| 133 | HQA_CMD_GET_TX_INFO, |
| 134 | HQA_CMD_SET_TX_PATH, |
| 135 | HQA_CMD_SET_TX_POWER, |
| 136 | HQA_CMD_SET_TX_POWER_MANUAL, |
| 137 | HQA_CMD_SET_RF_MODE, |
| 138 | HQA_CMD_SET_RX_PATH, |
| 139 | HQA_CMD_SET_RX_PKT_LEN, |
| 140 | HQA_CMD_SET_FREQ_OFFSET, |
| 141 | HQA_CMD_SET_TSSI, |
| 142 | HQA_CMD_SET_CFG, |
| 143 | HQA_CMD_SET_RU, |
| 144 | HQA_CMD_SET_BAND, |
| 145 | HQA_CMD_SET_EEPROM_TO_FW, |
| 146 | HQA_CMD_READ_MAC_BBP_REG, |
| 147 | HQA_CMD_READ_MAC_BBP_REG_QA, |
| 148 | HQA_CMD_READ_RF_REG, |
| 149 | HQA_CMD_READ_EEPROM_BULK, |
| 150 | HQA_CMD_READ_TEMPERATURE, |
| 151 | HQA_CMD_WRITE_MAC_BBP_REG, |
| 152 | HQA_CMD_WRITE_RF_REG, |
| 153 | HQA_CMD_WRITE_EEPROM_BULK, |
| 154 | HQA_CMD_WRITE_BUFFER_DONE, |
| 155 | HQA_CMD_GET_BAND, |
| 156 | HQA_CMD_GET_CFG, |
| 157 | HQA_CMD_GET_TX_POWER, |
| 158 | HQA_CMD_GET_TX_TONE_POWER, |
| 159 | HQA_CMD_GET_EFUSE_FREE_BLOCK, |
| 160 | HQA_CMD_GET_FREQ_OFFSET, |
| 161 | HQA_CMD_GET_FW_INFO, |
| 162 | HQA_CMD_GET_RX_INFO, |
| 163 | HQA_CMD_GET_RF_CAP, |
| 164 | HQA_CMD_CHECK_EFUSE_MODE, |
| 165 | HQA_CMD_CHECK_EFUSE_MODE_TYPE, |
| 166 | HQA_CMD_CHECK_EFUSE_MODE_NATIVE, |
| 167 | HQA_CMD_ANT_SWAP_CAP, |
| 168 | HQA_CMD_RESET_TX_RX_COUNTER, |
| 169 | HQA_CMD_CONTINUOUS_TX, |
| 170 | |
| 171 | HQA_CMD_EXT, |
| 172 | HQA_CMD_ERR, |
| 173 | |
| 174 | __HQA_CMD_MAX_NUM, |
| 175 | }; |
| 176 | |
| 177 | enum atenl_ext_cmd { |
| 178 | HQA_EXT_CMD_UNSPEC, |
| 179 | |
| 180 | HQA_EXT_CMD_SET_CHANNEL, |
| 181 | HQA_EXT_CMD_SET_TX, |
| 182 | HQA_EXT_CMD_START_TX, |
| 183 | HQA_EXT_CMD_START_RX, |
| 184 | HQA_EXT_CMD_STOP_TX, |
| 185 | HQA_EXT_CMD_STOP_RX, |
| 186 | HQA_EXT_CMD_SET_TX_TIME_OPT, |
| 187 | |
| 188 | HQA_EXT_CMD_OFF_CH_SCAN, |
| 189 | |
| 190 | HQA_EXT_CMD_IBF_SET_VAL, |
| 191 | HQA_EXT_CMD_IBF_GET_STATUS, |
| 192 | HQA_EXT_CMD_IBF_PROF_UPDATE_ALL, |
| 193 | |
| 194 | HQA_EXT_CMD_ERR, |
| 195 | |
| 196 | __HQA_EXT_CMD_MAX_NUM, |
| 197 | }; |
| 198 | |
| 199 | struct atenl_data { |
| 200 | u8 buf[RACFG_PKT_MAX_SIZE]; |
| 201 | int len; |
| 202 | u16 cmd_id; |
| 203 | u8 ext_id; |
| 204 | enum atenl_cmd cmd; |
| 205 | enum atenl_ext_cmd ext_cmd; |
| 206 | }; |
| 207 | |
| 208 | struct atenl_ops { |
| 209 | int (*ops)(struct atenl *an, struct atenl_data *data); |
| 210 | u8 cmd; |
| 211 | u8 flags; |
| 212 | u16 cmd_id; |
| 213 | u16 resp_len; |
| 214 | }; |
| 215 | |
| 216 | #define ATENL_OPS_FLAG_EXT_CMD BIT(0) |
| 217 | #define ATENL_OPS_FLAG_LEGACY BIT(1) |
| 218 | #define ATENL_OPS_FLAG_SKIP BIT(2) |
| 219 | |
| 220 | static inline struct atenl_cmd_hdr * atenl_hdr(struct atenl_data *data) |
| 221 | { |
| 222 | u8 *hqa_data = (u8 *)data->buf + ETH_HLEN; |
| 223 | |
| 224 | return (struct atenl_cmd_hdr *)hqa_data; |
| 225 | } |
| 226 | |
| 227 | enum atenl_phy_type { |
| 228 | ATENL_PHY_TYPE_CCK, |
| 229 | ATENL_PHY_TYPE_OFDM, |
| 230 | ATENL_PHY_TYPE_HT, |
| 231 | ATENL_PHY_TYPE_HT_GF, |
| 232 | ATENL_PHY_TYPE_VHT, |
| 233 | ATENL_PHY_TYPE_HE_SU = 8, |
| 234 | ATENL_PHY_TYPE_HE_EXT_SU, |
| 235 | ATENL_PHY_TYPE_HE_TB, |
| 236 | ATENL_PHY_TYPE_HE_MU, |
developer | 7af0f76 | 2023-05-22 15:16:16 +0800 | [diff] [blame] | 237 | ATENL_PHY_TYPE_EHT_SU = 13, |
| 238 | ATENL_PHY_TYPE_EHT_TRIG, |
| 239 | ATENL_PHY_TYPE_EHT_MU, |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 240 | }; |
| 241 | |
| 242 | enum atenl_e2p_mode { |
| 243 | E2P_EFUSE_MODE = 1, |
| 244 | E2P_FLASH_MODE, |
| 245 | E2P_EEPROM_MODE, |
| 246 | E2P_BIN_MODE, |
| 247 | }; |
| 248 | |
| 249 | enum atenl_band_type { |
| 250 | BAND_TYPE_UNUSE, |
| 251 | BAND_TYPE_2G, |
| 252 | BAND_TYPE_5G, |
| 253 | BAND_TYPE_2G_5G, |
| 254 | BAND_TYPE_6G, |
| 255 | BAND_TYPE_2G_6G, |
| 256 | BAND_TYPE_5G_6G, |
| 257 | BAND_TYPE_2G_5G_6G, |
| 258 | }; |
| 259 | |
| 260 | enum atenl_ch_band { |
| 261 | CH_BAND_2GHZ, |
| 262 | CH_BAND_5GHZ, |
| 263 | CH_BAND_6GHZ, |
| 264 | }; |
| 265 | |
| 266 | /* for mt7915 */ |
| 267 | enum { |
| 268 | MT_EE_BAND_SEL_DEFAULT, |
| 269 | MT_EE_BAND_SEL_5GHZ, |
| 270 | MT_EE_BAND_SEL_2GHZ, |
| 271 | MT_EE_BAND_SEL_DUAL, |
| 272 | }; |
| 273 | |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 274 | /* for mt7916/mt7981/mt7986 */ |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 275 | enum { |
| 276 | MT_EE_BAND_SEL_2G, |
| 277 | MT_EE_BAND_SEL_5G, |
| 278 | MT_EE_BAND_SEL_6G, |
| 279 | MT_EE_BAND_SEL_5G_6G, |
| 280 | }; |
| 281 | |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 282 | /* for mt7996 */ |
| 283 | enum { |
| 284 | MT_EE_EAGLE_BAND_SEL_DEFAULT, |
| 285 | MT_EE_EAGLE_BAND_SEL_2GHZ, |
| 286 | MT_EE_EAGLE_BAND_SEL_5GHZ, |
| 287 | MT_EE_EAGLE_BAND_SEL_6GHZ, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 288 | MT_EE_EAGLE_BAND_SEL_5GHZ_LOW, |
| 289 | MT_EE_EAGLE_BAND_SEL_5GHZ_HIGH, |
| 290 | MT_EE_EAGLE_BAND_SEL_6GHZ_LOW, |
| 291 | MT_EE_EAGLE_BAND_SEL_6GHZ_HIGH, |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 292 | }; |
| 293 | |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 294 | #define MT_EE_WIFI_CONF 0x190 |
| 295 | #define MT_EE_WIFI_CONF0_BAND_SEL GENMASK(7, 6) |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 296 | #define MT_EE_WIFI_EAGLE_CONF0_BAND_SEL GENMASK(2, 0) |
| 297 | #define MT_EE_WIFI_EAGLE_CONF1_BAND_SEL GENMASK(5, 3) |
| 298 | #define MT_EE_WIFI_EAGLE_CONF2_BAND_SEL GENMASK(2, 0) |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 299 | |
| 300 | enum { |
| 301 | MT7976_ONE_ADIE_DBDC = 0x7, |
| 302 | MT7975_ONE_ADIE_SINGLE_BAND = 0x8, /* AX7800 */ |
| 303 | MT7976_ONE_ADIE_SINGLE_BAND = 0xa, /* AX7800 */ |
| 304 | MT7975_DUAL_ADIE_DBDC = 0xd, /* AX6000 */ |
| 305 | MT7976_DUAL_ADIE_DBDC = 0xf, /* AX6000 */ |
| 306 | }; |
| 307 | |
| 308 | enum { |
| 309 | TEST_CBW_20MHZ, |
| 310 | TEST_CBW_40MHZ, |
| 311 | TEST_CBW_80MHZ, |
| 312 | TEST_CBW_10MHZ, |
| 313 | TEST_CBW_5MHZ, |
| 314 | TEST_CBW_160MHZ, |
| 315 | TEST_CBW_8080MHZ, |
developer | 7af0f76 | 2023-05-22 15:16:16 +0800 | [diff] [blame] | 316 | TEST_CBW_320MHZ = 12, |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 317 | |
developer | 7af0f76 | 2023-05-22 15:16:16 +0800 | [diff] [blame] | 318 | TEST_CBW_MAX = TEST_CBW_320MHZ, |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 319 | }; |
| 320 | |
| 321 | struct atenl_rx_info_hdr { |
| 322 | __be32 type; |
| 323 | __be32 ver; |
| 324 | __be32 val; |
| 325 | __be32 len; |
| 326 | } __attribute__((packed)); |
| 327 | |
| 328 | struct atenl_rx_info_band { |
| 329 | __be32 mac_rx_fcs_err_cnt; |
| 330 | __be32 mac_rx_mdrdy_cnt; |
| 331 | __be32 mac_rx_len_mismatch; |
| 332 | __be32 mac_rx_fcs_ok_cnt; |
| 333 | __be32 phy_rx_fcs_err_cnt_cck; |
| 334 | __be32 phy_rx_fcs_err_cnt_ofdm; |
| 335 | __be32 phy_rx_pd_cck; |
| 336 | __be32 phy_rx_pd_ofdm; |
| 337 | __be32 phy_rx_sig_err_cck; |
| 338 | __be32 phy_rx_sfd_err_cck; |
| 339 | __be32 phy_rx_sig_err_ofdm; |
| 340 | __be32 phy_rx_tag_err_ofdm; |
| 341 | __be32 phy_rx_mdrdy_cnt_cck; |
| 342 | __be32 phy_rx_mdrdy_cnt_ofdm; |
| 343 | } __attribute__((packed)); |
| 344 | |
| 345 | struct atenl_rx_info_path { |
| 346 | __be32 rcpi; |
| 347 | __be32 rssi; |
| 348 | __be32 fagc_ib_rssi; |
| 349 | __be32 fagc_wb_rssi; |
| 350 | __be32 inst_ib_rssi; |
| 351 | __be32 inst_wb_rssi; |
| 352 | } __attribute__((packed)); |
| 353 | |
| 354 | struct atenl_rx_info_user { |
| 355 | __be32 freq_offset; |
| 356 | __be32 snr; |
| 357 | __be32 fcs_error_cnt; |
| 358 | } __attribute__((packed)); |
| 359 | |
| 360 | struct atenl_rx_info_comm { |
| 361 | __be32 rx_fifo_full; |
| 362 | __be32 aci_hit_low; |
| 363 | __be32 aci_hit_high; |
| 364 | __be32 mu_pkt_count; |
| 365 | __be32 sig_mcs; |
| 366 | __be32 sinr; |
| 367 | __be32 driver_rx_count; |
| 368 | } __attribute__((packed)); |
| 369 | |
| 370 | enum atenl_ibf_action { |
| 371 | TXBF_ACT_INIT = 1, |
| 372 | TXBF_ACT_CHANNEL, |
| 373 | TXBF_ACT_MCS, |
| 374 | TXBF_ACT_POWER, |
| 375 | TXBF_ACT_TX_ANT, |
| 376 | TXBF_ACT_RX_START, |
| 377 | TXBF_ACT_RX_ANT, |
| 378 | TXBF_ACT_LNA_GAIN, |
| 379 | TXBF_ACT_IBF_PHASE_COMP, |
| 380 | TXBF_ACT_TX_PKT, |
| 381 | TXBF_ACT_IBF_PROF_UPDATE, |
| 382 | TXBF_ACT_EBF_PROF_UPDATE, |
| 383 | TXBF_ACT_IBF_PHASE_CAL, |
| 384 | TXBF_ACT_IBF_PHASE_E2P_UPDATE = 16, |
| 385 | }; |
| 386 | |
| 387 | enum prek_ops { |
| 388 | PREK_SYNC_ALL = 1, |
| 389 | PREK_SYNC_GROUP, |
| 390 | PREK_SYNC_DPD_2G, |
| 391 | PREK_SYNC_DPD_5G, |
| 392 | PREK_SYNC_DPD_6G, |
| 393 | PREK_CLEAN_GROUP, |
| 394 | PREK_CLEAN_DPD, |
| 395 | }; |
| 396 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 397 | #define MT7916_EEPROM_CHIP_ID 0x7916 |
| 398 | |
| 399 | /* Wi-Fi6 device id */ |
| 400 | #define MT7915_DEVICE_ID 0x7915 |
| 401 | #define MT7915_DEVICE_ID_2 0x7916 |
| 402 | #define MT7916_DEVICE_ID 0x7906 |
| 403 | #define MT7916_DEVICE_ID_2 0x790a |
| 404 | #define MT7981_DEVICE_ID 0x7981 |
| 405 | #define MT7986_DEVICE_ID 0x7986 |
| 406 | |
| 407 | /* Wi-Fi7 device id */ |
| 408 | #define MT7996_DEVICE_ID 0x7990 |
| 409 | #define MT7996_DEVICE_ID_2 0x7991 |
| 410 | #define MT7992_DEVICE_ID 0x7992 |
| 411 | #define MT7992_DEVICE_ID_2 0x799a |
| 412 | #define MT7990_DEVICE_ID 0x7993 |
| 413 | #define MT7990_DEVICE_ID_2 0x799b |
| 414 | |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 415 | static inline bool is_mt7915(struct atenl *an) |
| 416 | { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 417 | return an->chip_id == MT7915_DEVICE_ID; |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | static inline bool is_mt7916(struct atenl *an) |
| 421 | { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 422 | /* Merlin is special case: |
| 423 | * pcie id is 0x7906/0x790a but eeprom chip id use 0x7916, |
| 424 | * since 0x7916 is already used by the second pcie of Harrier. |
| 425 | */ |
| 426 | return (an->chip_id == MT7916_EEPROM_CHIP_ID) || |
| 427 | (an->chip_id == MT7916_DEVICE_ID); |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 428 | } |
| 429 | |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 430 | static inline bool is_mt7981(struct atenl *an) |
| 431 | { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 432 | return an->chip_id == MT7981_DEVICE_ID; |
developer | 70180b0 | 2023-11-14 17:01:47 +0800 | [diff] [blame] | 433 | } |
| 434 | |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 435 | static inline bool is_mt7986(struct atenl *an) |
| 436 | { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 437 | return an->chip_id == MT7986_DEVICE_ID; |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 438 | } |
| 439 | |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 440 | static inline bool is_mt7996(struct atenl *an) |
| 441 | { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 442 | return an->chip_id == MT7996_DEVICE_ID; |
developer | 13655da | 2023-01-10 19:53:25 +0800 | [diff] [blame] | 443 | } |
| 444 | |
developer | 2299de9 | 2023-10-27 15:40:47 +0800 | [diff] [blame] | 445 | static inline bool is_mt7992(struct atenl *an) |
| 446 | { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 447 | return an->chip_id == MT7992_DEVICE_ID; |
developer | 2299de9 | 2023-10-27 15:40:47 +0800 | [diff] [blame] | 448 | } |
| 449 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 450 | static inline bool is_mt7990(struct atenl *an) |
| 451 | { |
| 452 | return an->chip_id == MT7990_DEVICE_ID; |
| 453 | } |
| 454 | |
developer | 2299de9 | 2023-10-27 15:40:47 +0800 | [diff] [blame] | 455 | static inline bool is_connac3(struct atenl *an) |
| 456 | { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 457 | return is_mt7996(an) || is_mt7992(an) || is_mt7990(an); |
developer | 2299de9 | 2023-10-27 15:40:47 +0800 | [diff] [blame] | 458 | } |
| 459 | |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 460 | int atenl_eth_init(struct atenl *an); |
| 461 | int atenl_eth_recv(struct atenl *an, struct atenl_data *data); |
| 462 | int atenl_eth_send(struct atenl *an, struct atenl_data *data); |
| 463 | int atenl_hqa_proc_cmd(struct atenl *an); |
| 464 | int atenl_nl_process(struct atenl *an, struct atenl_data *data); |
| 465 | int atenl_nl_process_many(struct atenl *an, struct atenl_data *data); |
| 466 | int atenl_nl_check_mtd(struct atenl *an); |
| 467 | int atenl_nl_write_eeprom(struct atenl *an, u32 offset, u8 *val, int len); |
| 468 | int atenl_nl_write_efuse_all(struct atenl *an); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 469 | int atenl_nl_write_ext_eeprom_all(struct atenl *an); |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 470 | int atenl_nl_update_buffer_mode(struct atenl *an); |
| 471 | int atenl_nl_set_state(struct atenl *an, u8 band, |
| 472 | enum mt76_testmode_state state); |
| 473 | int atenl_nl_set_aid(struct atenl *an, u8 band, u8 aid); |
| 474 | int atenl_nl_precal_sync_from_driver(struct atenl *an, enum prek_ops ops); |
developer | f9b0021 | 2023-07-31 12:27:06 +0800 | [diff] [blame] | 475 | void atenl_get_ibf_cal_result(struct atenl *an); |
developer | b9b4cd1 | 2022-10-11 13:18:59 +0800 | [diff] [blame] | 476 | int atenl_eeprom_init(struct atenl *an, u8 phy_idx); |
| 477 | void atenl_eeprom_close(struct atenl *an); |
| 478 | int atenl_eeprom_write_mtd(struct atenl *an); |
| 479 | int atenl_eeprom_update_precal(struct atenl *an, int write_offs, int size); |
| 480 | int atenl_eeprom_read_from_driver(struct atenl *an, u32 offset, int len); |
| 481 | void atenl_eeprom_cmd_handler(struct atenl *an, u8 phy_idx, char *cmd); |
| 482 | u16 atenl_get_center_channel(u8 bw, u8 ch_band, u16 ctrl_ch); |
| 483 | int atenl_reg_read(struct atenl *an, u32 offset, u32 *res); |
| 484 | int atenl_reg_write(struct atenl *an, u32 offset, u32 val); |
| 485 | int atenl_rf_read(struct atenl *an, u32 wf_sel, u32 offset, u32 *res); |
| 486 | int atenl_rf_write(struct atenl *an, u32 wf_sel, u32 offset, u32 val); |
| 487 | |
| 488 | #endif |