18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: ISC 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 48c2ecf20Sopenharmony_ci#include "mt7603.h" 58c2ecf20Sopenharmony_ci#include "mac.h" 68c2ecf20Sopenharmony_ci#include "eeprom.h" 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ciconst struct mt76_driver_ops mt7603_drv_ops = { 98c2ecf20Sopenharmony_ci .txwi_size = MT_TXD_SIZE, 108c2ecf20Sopenharmony_ci .drv_flags = MT_DRV_SW_RX_AIRTIME, 118c2ecf20Sopenharmony_ci .survey_flags = SURVEY_INFO_TIME_TX, 128c2ecf20Sopenharmony_ci .tx_prepare_skb = mt7603_tx_prepare_skb, 138c2ecf20Sopenharmony_ci .tx_complete_skb = mt7603_tx_complete_skb, 148c2ecf20Sopenharmony_ci .rx_skb = mt7603_queue_rx_skb, 158c2ecf20Sopenharmony_ci .rx_poll_complete = mt7603_rx_poll_complete, 168c2ecf20Sopenharmony_ci .sta_ps = mt7603_sta_ps, 178c2ecf20Sopenharmony_ci .sta_add = mt7603_sta_add, 188c2ecf20Sopenharmony_ci .sta_assoc = mt7603_sta_assoc, 198c2ecf20Sopenharmony_ci .sta_remove = mt7603_sta_remove, 208c2ecf20Sopenharmony_ci .update_survey = mt7603_update_channel, 218c2ecf20Sopenharmony_ci}; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistatic void 248c2ecf20Sopenharmony_cimt7603_set_tmac_template(struct mt7603_dev *dev) 258c2ecf20Sopenharmony_ci{ 268c2ecf20Sopenharmony_ci u32 desc[5] = { 278c2ecf20Sopenharmony_ci [1] = FIELD_PREP(MT_TXD3_REM_TX_COUNT, 0xf), 288c2ecf20Sopenharmony_ci [3] = MT_TXD5_SW_POWER_MGMT 298c2ecf20Sopenharmony_ci }; 308c2ecf20Sopenharmony_ci u32 addr; 318c2ecf20Sopenharmony_ci int i; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci addr = mt7603_reg_map(dev, MT_CLIENT_BASE_PHYS_ADDR); 348c2ecf20Sopenharmony_ci addr += MT_CLIENT_TMAC_INFO_TEMPLATE; 358c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(desc); i++) 368c2ecf20Sopenharmony_ci mt76_wr(dev, addr + 4 * i, desc[i]); 378c2ecf20Sopenharmony_ci} 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_cistatic void 408c2ecf20Sopenharmony_cimt7603_dma_sched_init(struct mt7603_dev *dev) 418c2ecf20Sopenharmony_ci{ 428c2ecf20Sopenharmony_ci int page_size = 128; 438c2ecf20Sopenharmony_ci int page_count; 448c2ecf20Sopenharmony_ci int max_len = 1792; 458c2ecf20Sopenharmony_ci int max_amsdu_pages = 4096 / page_size; 468c2ecf20Sopenharmony_ci int max_mcu_len = 4096; 478c2ecf20Sopenharmony_ci int max_beacon_len = 512 * 4 + max_len; 488c2ecf20Sopenharmony_ci int max_mcast_pages = 4 * max_len / page_size; 498c2ecf20Sopenharmony_ci int reserved_count = 0; 508c2ecf20Sopenharmony_ci int beacon_pages; 518c2ecf20Sopenharmony_ci int mcu_pages; 528c2ecf20Sopenharmony_ci int i; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci page_count = mt76_get_field(dev, MT_PSE_FC_P0, 558c2ecf20Sopenharmony_ci MT_PSE_FC_P0_MAX_QUOTA); 568c2ecf20Sopenharmony_ci beacon_pages = 4 * (max_beacon_len / page_size); 578c2ecf20Sopenharmony_ci mcu_pages = max_mcu_len / page_size; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci mt76_wr(dev, MT_PSE_FRP, 608c2ecf20Sopenharmony_ci FIELD_PREP(MT_PSE_FRP_P0, 7) | 618c2ecf20Sopenharmony_ci FIELD_PREP(MT_PSE_FRP_P1, 6) | 628c2ecf20Sopenharmony_ci FIELD_PREP(MT_PSE_FRP_P2_RQ2, 4)); 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci mt76_wr(dev, MT_HIGH_PRIORITY_1, 0x55555553); 658c2ecf20Sopenharmony_ci mt76_wr(dev, MT_HIGH_PRIORITY_2, 0x78555555); 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci mt76_wr(dev, MT_QUEUE_PRIORITY_1, 0x2b1a096e); 688c2ecf20Sopenharmony_ci mt76_wr(dev, MT_QUEUE_PRIORITY_2, 0x785f4d3c); 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci mt76_wr(dev, MT_PRIORITY_MASK, 0xffffffff); 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci mt76_wr(dev, MT_SCH_1, page_count | (2 << 28)); 738c2ecf20Sopenharmony_ci mt76_wr(dev, MT_SCH_2, max_amsdu_pages); 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci for (i = 0; i <= 4; i++) 768c2ecf20Sopenharmony_ci mt76_wr(dev, MT_PAGE_COUNT(i), max_amsdu_pages); 778c2ecf20Sopenharmony_ci reserved_count += 5 * max_amsdu_pages; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci mt76_wr(dev, MT_PAGE_COUNT(5), mcu_pages); 808c2ecf20Sopenharmony_ci reserved_count += mcu_pages; 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci mt76_wr(dev, MT_PAGE_COUNT(7), beacon_pages); 838c2ecf20Sopenharmony_ci reserved_count += beacon_pages; 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci mt76_wr(dev, MT_PAGE_COUNT(8), max_mcast_pages); 868c2ecf20Sopenharmony_ci reserved_count += max_mcast_pages; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci if (is_mt7603(dev)) 898c2ecf20Sopenharmony_ci reserved_count = 0; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci mt76_wr(dev, MT_RSV_MAX_THRESH, page_count - reserved_count); 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci if (is_mt7603(dev) && mt76xx_rev(dev) >= MT7603_REV_E2) { 948c2ecf20Sopenharmony_ci mt76_wr(dev, MT_GROUP_THRESH(0), 958c2ecf20Sopenharmony_ci page_count - beacon_pages - mcu_pages); 968c2ecf20Sopenharmony_ci mt76_wr(dev, MT_GROUP_THRESH(1), beacon_pages); 978c2ecf20Sopenharmony_ci mt76_wr(dev, MT_BMAP_0, 0x0080ff5f); 988c2ecf20Sopenharmony_ci mt76_wr(dev, MT_GROUP_THRESH(2), mcu_pages); 998c2ecf20Sopenharmony_ci mt76_wr(dev, MT_BMAP_1, 0x00000020); 1008c2ecf20Sopenharmony_ci } else { 1018c2ecf20Sopenharmony_ci mt76_wr(dev, MT_GROUP_THRESH(0), page_count); 1028c2ecf20Sopenharmony_ci mt76_wr(dev, MT_BMAP_0, 0xffff); 1038c2ecf20Sopenharmony_ci } 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci mt76_wr(dev, MT_SCH_4, 0); 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci for (i = 0; i <= 15; i++) 1088c2ecf20Sopenharmony_ci mt76_wr(dev, MT_TXTIME_THRESH(i), 0xfffff); 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci mt76_set(dev, MT_SCH_4, BIT(6)); 1118c2ecf20Sopenharmony_ci} 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_cistatic void 1148c2ecf20Sopenharmony_cimt7603_phy_init(struct mt7603_dev *dev) 1158c2ecf20Sopenharmony_ci{ 1168c2ecf20Sopenharmony_ci int rx_chains = dev->mphy.antenna_mask; 1178c2ecf20Sopenharmony_ci int tx_chains = hweight8(rx_chains) - 1; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci mt76_rmw(dev, MT_WF_RMAC_RMCR, 1208c2ecf20Sopenharmony_ci (MT_WF_RMAC_RMCR_SMPS_MODE | 1218c2ecf20Sopenharmony_ci MT_WF_RMAC_RMCR_RX_STREAMS), 1228c2ecf20Sopenharmony_ci (FIELD_PREP(MT_WF_RMAC_RMCR_SMPS_MODE, 3) | 1238c2ecf20Sopenharmony_ci FIELD_PREP(MT_WF_RMAC_RMCR_RX_STREAMS, rx_chains))); 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci mt76_rmw_field(dev, MT_TMAC_TCR, MT_TMAC_TCR_TX_STREAMS, 1268c2ecf20Sopenharmony_ci tx_chains); 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci dev->agc0 = mt76_rr(dev, MT_AGC(0)); 1298c2ecf20Sopenharmony_ci dev->agc3 = mt76_rr(dev, MT_AGC(3)); 1308c2ecf20Sopenharmony_ci} 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_cistatic void 1338c2ecf20Sopenharmony_cimt7603_mac_init(struct mt7603_dev *dev) 1348c2ecf20Sopenharmony_ci{ 1358c2ecf20Sopenharmony_ci u8 bc_addr[ETH_ALEN]; 1368c2ecf20Sopenharmony_ci u32 addr; 1378c2ecf20Sopenharmony_ci int i; 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci mt76_wr(dev, MT_AGG_BA_SIZE_LIMIT_0, 1408c2ecf20Sopenharmony_ci (MT_AGG_SIZE_LIMIT(0) << 0 * MT_AGG_BA_SIZE_LIMIT_SHIFT) | 1418c2ecf20Sopenharmony_ci (MT_AGG_SIZE_LIMIT(1) << 1 * MT_AGG_BA_SIZE_LIMIT_SHIFT) | 1428c2ecf20Sopenharmony_ci (MT_AGG_SIZE_LIMIT(2) << 2 * MT_AGG_BA_SIZE_LIMIT_SHIFT) | 1438c2ecf20Sopenharmony_ci (MT_AGG_SIZE_LIMIT(3) << 3 * MT_AGG_BA_SIZE_LIMIT_SHIFT)); 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci mt76_wr(dev, MT_AGG_BA_SIZE_LIMIT_1, 1468c2ecf20Sopenharmony_ci (MT_AGG_SIZE_LIMIT(4) << 0 * MT_AGG_BA_SIZE_LIMIT_SHIFT) | 1478c2ecf20Sopenharmony_ci (MT_AGG_SIZE_LIMIT(5) << 1 * MT_AGG_BA_SIZE_LIMIT_SHIFT) | 1488c2ecf20Sopenharmony_ci (MT_AGG_SIZE_LIMIT(6) << 2 * MT_AGG_BA_SIZE_LIMIT_SHIFT) | 1498c2ecf20Sopenharmony_ci (MT_AGG_SIZE_LIMIT(7) << 3 * MT_AGG_BA_SIZE_LIMIT_SHIFT)); 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci mt76_wr(dev, MT_AGG_LIMIT, 1528c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_LIMIT_AC(0), 24) | 1538c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_LIMIT_AC(1), 24) | 1548c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_LIMIT_AC(2), 24) | 1558c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_LIMIT_AC(3), 24)); 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci mt76_wr(dev, MT_AGG_LIMIT_1, 1588c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_LIMIT_AC(0), 24) | 1598c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_LIMIT_AC(1), 24) | 1608c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_LIMIT_AC(2), 24) | 1618c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_LIMIT_AC(3), 24)); 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci mt76_wr(dev, MT_AGG_CONTROL, 1648c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_CONTROL_BAR_RATE, 0x4b) | 1658c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_CONTROL_CFEND_RATE, 0x69) | 1668c2ecf20Sopenharmony_ci MT_AGG_CONTROL_NO_BA_AR_RULE); 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci mt76_wr(dev, MT_AGG_RETRY_CONTROL, 1698c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_RETRY_CONTROL_BAR_LIMIT, 1) | 1708c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_RETRY_CONTROL_RTS_LIMIT, 15)); 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci mt76_wr(dev, MT_DMA_DCR0, MT_DMA_DCR0_RX_VEC_DROP | 1738c2ecf20Sopenharmony_ci FIELD_PREP(MT_DMA_DCR0_MAX_RX_LEN, 4096)); 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci mt76_rmw(dev, MT_DMA_VCFR0, BIT(0), BIT(13)); 1768c2ecf20Sopenharmony_ci mt76_rmw(dev, MT_DMA_TMCFR0, BIT(0) | BIT(1), BIT(13)); 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci mt76_clear(dev, MT_WF_RMAC_TMR_PA, BIT(31)); 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci mt76_set(dev, MT_WF_RMACDR, MT_WF_RMACDR_MAXLEN_20BIT); 1818c2ecf20Sopenharmony_ci mt76_rmw(dev, MT_WF_RMAC_MAXMINLEN, 0xffffff, 0x19000); 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci mt76_wr(dev, MT_WF_RFCR1, 0); 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci mt76_set(dev, MT_TMAC_TCR, MT_TMAC_TCR_RX_RIFS_MODE); 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci mt7603_set_tmac_template(dev); 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci /* Enable RX group to HIF */ 1908c2ecf20Sopenharmony_ci addr = mt7603_reg_map(dev, MT_CLIENT_BASE_PHYS_ADDR); 1918c2ecf20Sopenharmony_ci mt76_set(dev, addr + MT_CLIENT_RXINF, MT_CLIENT_RXINF_RXSH_GROUPS); 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci /* Enable RX group to MCU */ 1948c2ecf20Sopenharmony_ci mt76_set(dev, MT_DMA_DCR1, GENMASK(13, 11)); 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci mt76_rmw_field(dev, MT_AGG_PCR_RTS, MT_AGG_PCR_RTS_PKT_THR, 3); 1978c2ecf20Sopenharmony_ci mt76_set(dev, MT_TMAC_PCR, MT_TMAC_PCR_SPE_EN); 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci /* include preamble detection in CCA trigger signal */ 2008c2ecf20Sopenharmony_ci mt76_rmw_field(dev, MT_TXREQ, MT_TXREQ_CCA_SRC_SEL, 2); 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci mt76_wr(dev, MT_RXREQ, 4); 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci /* Configure all rx packets to HIF */ 2058c2ecf20Sopenharmony_ci mt76_wr(dev, MT_DMA_RCFR0, 0xc0000000); 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci /* Configure MCU txs selection with aggregation */ 2088c2ecf20Sopenharmony_ci mt76_wr(dev, MT_DMA_TCFR0, 2098c2ecf20Sopenharmony_ci FIELD_PREP(MT_DMA_TCFR_TXS_AGGR_TIMEOUT, 1) | /* 32 us */ 2108c2ecf20Sopenharmony_ci MT_DMA_TCFR_TXS_AGGR_COUNT); 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci /* Configure HIF txs selection with aggregation */ 2138c2ecf20Sopenharmony_ci mt76_wr(dev, MT_DMA_TCFR1, 2148c2ecf20Sopenharmony_ci FIELD_PREP(MT_DMA_TCFR_TXS_AGGR_TIMEOUT, 1) | /* 32 us */ 2158c2ecf20Sopenharmony_ci MT_DMA_TCFR_TXS_AGGR_COUNT | /* Maximum count */ 2168c2ecf20Sopenharmony_ci MT_DMA_TCFR_TXS_BIT_MAP); 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci mt76_wr(dev, MT_MCU_PCIE_REMAP_1, MT_PSE_WTBL_2_PHYS_ADDR); 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci for (i = 0; i < MT7603_WTBL_SIZE; i++) 2218c2ecf20Sopenharmony_ci mt7603_wtbl_clear(dev, i); 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci eth_broadcast_addr(bc_addr); 2248c2ecf20Sopenharmony_ci mt7603_wtbl_init(dev, MT7603_WTBL_RESERVED, -1, bc_addr); 2258c2ecf20Sopenharmony_ci dev->global_sta.wcid.idx = MT7603_WTBL_RESERVED; 2268c2ecf20Sopenharmony_ci rcu_assign_pointer(dev->mt76.wcid[MT7603_WTBL_RESERVED], 2278c2ecf20Sopenharmony_ci &dev->global_sta.wcid); 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci mt76_rmw_field(dev, MT_LPON_BTEIR, MT_LPON_BTEIR_MBSS_MODE, 2); 2308c2ecf20Sopenharmony_ci mt76_rmw_field(dev, MT_WF_RMACDR, MT_WF_RMACDR_MBSSID_MASK, 2); 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci mt76_wr(dev, MT_AGG_ARUCR, 2338c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(0), 7) | 2348c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(1), 2) | 2358c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(2), 2) | 2368c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(3), 2) | 2378c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(4), 1) | 2388c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(5), 1) | 2398c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(6), 1) | 2408c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(7), 1)); 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci mt76_wr(dev, MT_AGG_ARDCR, 2438c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(0), MT7603_RATE_RETRY - 1) | 2448c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(1), MT7603_RATE_RETRY - 1) | 2458c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(2), MT7603_RATE_RETRY - 1) | 2468c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(3), MT7603_RATE_RETRY - 1) | 2478c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(4), MT7603_RATE_RETRY - 1) | 2488c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(5), MT7603_RATE_RETRY - 1) | 2498c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(6), MT7603_RATE_RETRY - 1) | 2508c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARxCR_LIMIT(7), MT7603_RATE_RETRY - 1)); 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci mt76_wr(dev, MT_AGG_ARCR, 2538c2ecf20Sopenharmony_ci (FIELD_PREP(MT_AGG_ARCR_RTS_RATE_THR, 2) | 2548c2ecf20Sopenharmony_ci MT_AGG_ARCR_RATE_DOWN_RATIO_EN | 2558c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARCR_RATE_DOWN_RATIO, 1) | 2568c2ecf20Sopenharmony_ci FIELD_PREP(MT_AGG_ARCR_RATE_UP_EXTRA_TH, 4))); 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci mt76_set(dev, MT_WTBL_RMVTCR, MT_WTBL_RMVTCR_RX_MV_MODE); 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci mt76_clear(dev, MT_SEC_SCR, MT_SEC_SCR_MASK_ORDER); 2618c2ecf20Sopenharmony_ci mt76_clear(dev, MT_SEC_SCR, BIT(18)); 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci /* Set secondary beacon time offsets */ 2648c2ecf20Sopenharmony_ci for (i = 0; i <= 4; i++) 2658c2ecf20Sopenharmony_ci mt76_rmw_field(dev, MT_LPON_SBTOR(i), MT_LPON_SBTOR_TIME_OFFSET, 2668c2ecf20Sopenharmony_ci (i + 1) * (20 + 4096)); 2678c2ecf20Sopenharmony_ci} 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_cistatic int 2708c2ecf20Sopenharmony_cimt7603_init_hardware(struct mt7603_dev *dev) 2718c2ecf20Sopenharmony_ci{ 2728c2ecf20Sopenharmony_ci int i, ret; 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci mt76_wr(dev, MT_INT_SOURCE_CSR, ~0); 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci ret = mt7603_eeprom_init(dev); 2778c2ecf20Sopenharmony_ci if (ret < 0) 2788c2ecf20Sopenharmony_ci return ret; 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci ret = mt7603_dma_init(dev); 2818c2ecf20Sopenharmony_ci if (ret) 2828c2ecf20Sopenharmony_ci return ret; 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci mt76_wr(dev, MT_WPDMA_GLO_CFG, 0x52000850); 2858c2ecf20Sopenharmony_ci mt7603_mac_dma_start(dev); 2868c2ecf20Sopenharmony_ci dev->rxfilter = mt76_rr(dev, MT_WF_RFCR); 2878c2ecf20Sopenharmony_ci set_bit(MT76_STATE_INITIALIZED, &dev->mphy.state); 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci for (i = 0; i < MT7603_WTBL_SIZE; i++) { 2908c2ecf20Sopenharmony_ci mt76_wr(dev, MT_PSE_RTA, MT_PSE_RTA_BUSY | MT_PSE_RTA_WRITE | 2918c2ecf20Sopenharmony_ci FIELD_PREP(MT_PSE_RTA_TAG_ID, i)); 2928c2ecf20Sopenharmony_ci mt76_poll(dev, MT_PSE_RTA, MT_PSE_RTA_BUSY, 0, 5000); 2938c2ecf20Sopenharmony_ci } 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci ret = mt7603_mcu_init(dev); 2968c2ecf20Sopenharmony_ci if (ret) 2978c2ecf20Sopenharmony_ci return ret; 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci mt7603_dma_sched_init(dev); 3008c2ecf20Sopenharmony_ci mt7603_mcu_set_eeprom(dev); 3018c2ecf20Sopenharmony_ci mt7603_phy_init(dev); 3028c2ecf20Sopenharmony_ci mt7603_mac_init(dev); 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci return 0; 3058c2ecf20Sopenharmony_ci} 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ci#define CCK_RATE(_idx, _rate) { \ 3088c2ecf20Sopenharmony_ci .bitrate = _rate, \ 3098c2ecf20Sopenharmony_ci .flags = IEEE80211_RATE_SHORT_PREAMBLE, \ 3108c2ecf20Sopenharmony_ci .hw_value = (MT_PHY_TYPE_CCK << 8) | (_idx), \ 3118c2ecf20Sopenharmony_ci .hw_value_short = (MT_PHY_TYPE_CCK << 8) | (4 + _idx), \ 3128c2ecf20Sopenharmony_ci} 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci#define OFDM_RATE(_idx, _rate) { \ 3158c2ecf20Sopenharmony_ci .bitrate = _rate, \ 3168c2ecf20Sopenharmony_ci .hw_value = (MT_PHY_TYPE_OFDM << 8) | (_idx), \ 3178c2ecf20Sopenharmony_ci .hw_value_short = (MT_PHY_TYPE_OFDM << 8) | (_idx), \ 3188c2ecf20Sopenharmony_ci} 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_cistatic struct ieee80211_rate mt7603_rates[] = { 3218c2ecf20Sopenharmony_ci CCK_RATE(0, 10), 3228c2ecf20Sopenharmony_ci CCK_RATE(1, 20), 3238c2ecf20Sopenharmony_ci CCK_RATE(2, 55), 3248c2ecf20Sopenharmony_ci CCK_RATE(3, 110), 3258c2ecf20Sopenharmony_ci OFDM_RATE(11, 60), 3268c2ecf20Sopenharmony_ci OFDM_RATE(15, 90), 3278c2ecf20Sopenharmony_ci OFDM_RATE(10, 120), 3288c2ecf20Sopenharmony_ci OFDM_RATE(14, 180), 3298c2ecf20Sopenharmony_ci OFDM_RATE(9, 240), 3308c2ecf20Sopenharmony_ci OFDM_RATE(13, 360), 3318c2ecf20Sopenharmony_ci OFDM_RATE(8, 480), 3328c2ecf20Sopenharmony_ci OFDM_RATE(12, 540), 3338c2ecf20Sopenharmony_ci}; 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_cistatic const struct ieee80211_iface_limit if_limits[] = { 3368c2ecf20Sopenharmony_ci { 3378c2ecf20Sopenharmony_ci .max = 1, 3388c2ecf20Sopenharmony_ci .types = BIT(NL80211_IFTYPE_ADHOC) 3398c2ecf20Sopenharmony_ci }, { 3408c2ecf20Sopenharmony_ci .max = MT7603_MAX_INTERFACES, 3418c2ecf20Sopenharmony_ci .types = BIT(NL80211_IFTYPE_STATION) | 3428c2ecf20Sopenharmony_ci#ifdef CONFIG_MAC80211_MESH 3438c2ecf20Sopenharmony_ci BIT(NL80211_IFTYPE_MESH_POINT) | 3448c2ecf20Sopenharmony_ci#endif 3458c2ecf20Sopenharmony_ci BIT(NL80211_IFTYPE_P2P_CLIENT) | 3468c2ecf20Sopenharmony_ci BIT(NL80211_IFTYPE_P2P_GO) | 3478c2ecf20Sopenharmony_ci BIT(NL80211_IFTYPE_AP) 3488c2ecf20Sopenharmony_ci }, 3498c2ecf20Sopenharmony_ci}; 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_cistatic const struct ieee80211_iface_combination if_comb[] = { 3528c2ecf20Sopenharmony_ci { 3538c2ecf20Sopenharmony_ci .limits = if_limits, 3548c2ecf20Sopenharmony_ci .n_limits = ARRAY_SIZE(if_limits), 3558c2ecf20Sopenharmony_ci .max_interfaces = 4, 3568c2ecf20Sopenharmony_ci .num_different_channels = 1, 3578c2ecf20Sopenharmony_ci .beacon_int_infra_match = true, 3588c2ecf20Sopenharmony_ci } 3598c2ecf20Sopenharmony_ci}; 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_cistatic void mt7603_led_set_config(struct mt76_dev *mt76, u8 delay_on, 3628c2ecf20Sopenharmony_ci u8 delay_off) 3638c2ecf20Sopenharmony_ci{ 3648c2ecf20Sopenharmony_ci struct mt7603_dev *dev = container_of(mt76, struct mt7603_dev, 3658c2ecf20Sopenharmony_ci mt76); 3668c2ecf20Sopenharmony_ci u32 val, addr; 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci val = FIELD_PREP(MT_LED_STATUS_DURATION, 0xffff) | 3698c2ecf20Sopenharmony_ci FIELD_PREP(MT_LED_STATUS_OFF, delay_off) | 3708c2ecf20Sopenharmony_ci FIELD_PREP(MT_LED_STATUS_ON, delay_on); 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci addr = mt7603_reg_map(dev, MT_LED_STATUS_0(mt76->led_pin)); 3738c2ecf20Sopenharmony_ci mt76_wr(dev, addr, val); 3748c2ecf20Sopenharmony_ci addr = mt7603_reg_map(dev, MT_LED_STATUS_1(mt76->led_pin)); 3758c2ecf20Sopenharmony_ci mt76_wr(dev, addr, val); 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci val = MT_LED_CTRL_REPLAY(mt76->led_pin) | 3788c2ecf20Sopenharmony_ci MT_LED_CTRL_KICK(mt76->led_pin); 3798c2ecf20Sopenharmony_ci if (mt76->led_al) 3808c2ecf20Sopenharmony_ci val |= MT_LED_CTRL_POLARITY(mt76->led_pin); 3818c2ecf20Sopenharmony_ci addr = mt7603_reg_map(dev, MT_LED_CTRL); 3828c2ecf20Sopenharmony_ci mt76_wr(dev, addr, val); 3838c2ecf20Sopenharmony_ci} 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_cistatic int mt7603_led_set_blink(struct led_classdev *led_cdev, 3868c2ecf20Sopenharmony_ci unsigned long *delay_on, 3878c2ecf20Sopenharmony_ci unsigned long *delay_off) 3888c2ecf20Sopenharmony_ci{ 3898c2ecf20Sopenharmony_ci struct mt76_dev *mt76 = container_of(led_cdev, struct mt76_dev, 3908c2ecf20Sopenharmony_ci led_cdev); 3918c2ecf20Sopenharmony_ci u8 delta_on, delta_off; 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_ci delta_off = max_t(u8, *delay_off / 10, 1); 3948c2ecf20Sopenharmony_ci delta_on = max_t(u8, *delay_on / 10, 1); 3958c2ecf20Sopenharmony_ci 3968c2ecf20Sopenharmony_ci mt7603_led_set_config(mt76, delta_on, delta_off); 3978c2ecf20Sopenharmony_ci return 0; 3988c2ecf20Sopenharmony_ci} 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_cistatic void mt7603_led_set_brightness(struct led_classdev *led_cdev, 4018c2ecf20Sopenharmony_ci enum led_brightness brightness) 4028c2ecf20Sopenharmony_ci{ 4038c2ecf20Sopenharmony_ci struct mt76_dev *mt76 = container_of(led_cdev, struct mt76_dev, 4048c2ecf20Sopenharmony_ci led_cdev); 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci if (!brightness) 4078c2ecf20Sopenharmony_ci mt7603_led_set_config(mt76, 0, 0xff); 4088c2ecf20Sopenharmony_ci else 4098c2ecf20Sopenharmony_ci mt7603_led_set_config(mt76, 0xff, 0); 4108c2ecf20Sopenharmony_ci} 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_cistatic u32 __mt7603_reg_addr(struct mt7603_dev *dev, u32 addr) 4138c2ecf20Sopenharmony_ci{ 4148c2ecf20Sopenharmony_ci if (addr < 0x100000) 4158c2ecf20Sopenharmony_ci return addr; 4168c2ecf20Sopenharmony_ci 4178c2ecf20Sopenharmony_ci return mt7603_reg_map(dev, addr); 4188c2ecf20Sopenharmony_ci} 4198c2ecf20Sopenharmony_ci 4208c2ecf20Sopenharmony_cistatic u32 mt7603_rr(struct mt76_dev *mdev, u32 offset) 4218c2ecf20Sopenharmony_ci{ 4228c2ecf20Sopenharmony_ci struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76); 4238c2ecf20Sopenharmony_ci u32 addr = __mt7603_reg_addr(dev, offset); 4248c2ecf20Sopenharmony_ci 4258c2ecf20Sopenharmony_ci return dev->bus_ops->rr(mdev, addr); 4268c2ecf20Sopenharmony_ci} 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_cistatic void mt7603_wr(struct mt76_dev *mdev, u32 offset, u32 val) 4298c2ecf20Sopenharmony_ci{ 4308c2ecf20Sopenharmony_ci struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76); 4318c2ecf20Sopenharmony_ci u32 addr = __mt7603_reg_addr(dev, offset); 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_ci dev->bus_ops->wr(mdev, addr, val); 4348c2ecf20Sopenharmony_ci} 4358c2ecf20Sopenharmony_ci 4368c2ecf20Sopenharmony_cistatic u32 mt7603_rmw(struct mt76_dev *mdev, u32 offset, u32 mask, u32 val) 4378c2ecf20Sopenharmony_ci{ 4388c2ecf20Sopenharmony_ci struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76); 4398c2ecf20Sopenharmony_ci u32 addr = __mt7603_reg_addr(dev, offset); 4408c2ecf20Sopenharmony_ci 4418c2ecf20Sopenharmony_ci return dev->bus_ops->rmw(mdev, addr, mask, val); 4428c2ecf20Sopenharmony_ci} 4438c2ecf20Sopenharmony_ci 4448c2ecf20Sopenharmony_cistatic void 4458c2ecf20Sopenharmony_cimt7603_regd_notifier(struct wiphy *wiphy, 4468c2ecf20Sopenharmony_ci struct regulatory_request *request) 4478c2ecf20Sopenharmony_ci{ 4488c2ecf20Sopenharmony_ci struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); 4498c2ecf20Sopenharmony_ci struct mt7603_dev *dev = hw->priv; 4508c2ecf20Sopenharmony_ci 4518c2ecf20Sopenharmony_ci dev->mt76.region = request->dfs_region; 4528c2ecf20Sopenharmony_ci dev->ed_monitor = dev->ed_monitor_enabled && 4538c2ecf20Sopenharmony_ci dev->mt76.region == NL80211_DFS_ETSI; 4548c2ecf20Sopenharmony_ci} 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_cistatic int 4578c2ecf20Sopenharmony_cimt7603_txpower_signed(int val) 4588c2ecf20Sopenharmony_ci{ 4598c2ecf20Sopenharmony_ci bool sign = val & BIT(6); 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_ci if (!(val & BIT(7))) 4628c2ecf20Sopenharmony_ci return 0; 4638c2ecf20Sopenharmony_ci 4648c2ecf20Sopenharmony_ci val &= GENMASK(5, 0); 4658c2ecf20Sopenharmony_ci if (!sign) 4668c2ecf20Sopenharmony_ci val = -val; 4678c2ecf20Sopenharmony_ci 4688c2ecf20Sopenharmony_ci return val; 4698c2ecf20Sopenharmony_ci} 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_cistatic void 4728c2ecf20Sopenharmony_cimt7603_init_txpower(struct mt7603_dev *dev, 4738c2ecf20Sopenharmony_ci struct ieee80211_supported_band *sband) 4748c2ecf20Sopenharmony_ci{ 4758c2ecf20Sopenharmony_ci struct ieee80211_channel *chan; 4768c2ecf20Sopenharmony_ci u8 *eeprom = (u8 *)dev->mt76.eeprom.data; 4778c2ecf20Sopenharmony_ci int target_power = eeprom[MT_EE_TX_POWER_0_START_2G + 2] & ~BIT(7); 4788c2ecf20Sopenharmony_ci u8 *rate_power = &eeprom[MT_EE_TX_POWER_CCK]; 4798c2ecf20Sopenharmony_ci bool ext_pa = eeprom[MT_EE_NIC_CONF_0 + 1] & BIT(1); 4808c2ecf20Sopenharmony_ci int max_offset, cur_offset; 4818c2ecf20Sopenharmony_ci int i; 4828c2ecf20Sopenharmony_ci 4838c2ecf20Sopenharmony_ci if (ext_pa && is_mt7603(dev)) 4848c2ecf20Sopenharmony_ci target_power = eeprom[MT_EE_TX_POWER_TSSI_OFF] & ~BIT(7); 4858c2ecf20Sopenharmony_ci 4868c2ecf20Sopenharmony_ci if (target_power & BIT(6)) 4878c2ecf20Sopenharmony_ci target_power = -(target_power & GENMASK(5, 0)); 4888c2ecf20Sopenharmony_ci 4898c2ecf20Sopenharmony_ci max_offset = 0; 4908c2ecf20Sopenharmony_ci for (i = 0; i < 14; i++) { 4918c2ecf20Sopenharmony_ci cur_offset = mt7603_txpower_signed(rate_power[i]); 4928c2ecf20Sopenharmony_ci max_offset = max(max_offset, cur_offset); 4938c2ecf20Sopenharmony_ci } 4948c2ecf20Sopenharmony_ci 4958c2ecf20Sopenharmony_ci target_power += max_offset; 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ci dev->tx_power_limit = target_power; 4988c2ecf20Sopenharmony_ci dev->mphy.txpower_cur = target_power; 4998c2ecf20Sopenharmony_ci 5008c2ecf20Sopenharmony_ci target_power = DIV_ROUND_UP(target_power, 2); 5018c2ecf20Sopenharmony_ci 5028c2ecf20Sopenharmony_ci /* add 3 dBm for 2SS devices (combined output) */ 5038c2ecf20Sopenharmony_ci if (dev->mphy.antenna_mask & BIT(1)) 5048c2ecf20Sopenharmony_ci target_power += 3; 5058c2ecf20Sopenharmony_ci 5068c2ecf20Sopenharmony_ci for (i = 0; i < sband->n_channels; i++) { 5078c2ecf20Sopenharmony_ci chan = &sband->channels[i]; 5088c2ecf20Sopenharmony_ci chan->max_power = min_t(int, chan->max_reg_power, target_power); 5098c2ecf20Sopenharmony_ci chan->orig_mpwr = target_power; 5108c2ecf20Sopenharmony_ci } 5118c2ecf20Sopenharmony_ci} 5128c2ecf20Sopenharmony_ci 5138c2ecf20Sopenharmony_ciint mt7603_register_device(struct mt7603_dev *dev) 5148c2ecf20Sopenharmony_ci{ 5158c2ecf20Sopenharmony_ci struct mt76_bus_ops *bus_ops; 5168c2ecf20Sopenharmony_ci struct ieee80211_hw *hw = mt76_hw(dev); 5178c2ecf20Sopenharmony_ci struct wiphy *wiphy = hw->wiphy; 5188c2ecf20Sopenharmony_ci int ret; 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci dev->bus_ops = dev->mt76.bus; 5218c2ecf20Sopenharmony_ci bus_ops = devm_kmemdup(dev->mt76.dev, dev->bus_ops, sizeof(*bus_ops), 5228c2ecf20Sopenharmony_ci GFP_KERNEL); 5238c2ecf20Sopenharmony_ci if (!bus_ops) 5248c2ecf20Sopenharmony_ci return -ENOMEM; 5258c2ecf20Sopenharmony_ci 5268c2ecf20Sopenharmony_ci bus_ops->rr = mt7603_rr; 5278c2ecf20Sopenharmony_ci bus_ops->wr = mt7603_wr; 5288c2ecf20Sopenharmony_ci bus_ops->rmw = mt7603_rmw; 5298c2ecf20Sopenharmony_ci dev->mt76.bus = bus_ops; 5308c2ecf20Sopenharmony_ci 5318c2ecf20Sopenharmony_ci INIT_LIST_HEAD(&dev->sta_poll_list); 5328c2ecf20Sopenharmony_ci spin_lock_init(&dev->sta_poll_lock); 5338c2ecf20Sopenharmony_ci spin_lock_init(&dev->ps_lock); 5348c2ecf20Sopenharmony_ci 5358c2ecf20Sopenharmony_ci INIT_DELAYED_WORK(&dev->mt76.mac_work, mt7603_mac_work); 5368c2ecf20Sopenharmony_ci tasklet_init(&dev->mt76.pre_tbtt_tasklet, mt7603_pre_tbtt_tasklet, 5378c2ecf20Sopenharmony_ci (unsigned long)dev); 5388c2ecf20Sopenharmony_ci 5398c2ecf20Sopenharmony_ci dev->slottime = 9; 5408c2ecf20Sopenharmony_ci dev->sensitivity_limit = 28; 5418c2ecf20Sopenharmony_ci dev->dynamic_sensitivity = true; 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_ci ret = mt7603_init_hardware(dev); 5448c2ecf20Sopenharmony_ci if (ret) 5458c2ecf20Sopenharmony_ci return ret; 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ci hw->queues = 4; 5488c2ecf20Sopenharmony_ci hw->max_rates = 3; 5498c2ecf20Sopenharmony_ci hw->max_report_rates = 7; 5508c2ecf20Sopenharmony_ci hw->max_rate_tries = 11; 5518c2ecf20Sopenharmony_ci 5528c2ecf20Sopenharmony_ci hw->sta_data_size = sizeof(struct mt7603_sta); 5538c2ecf20Sopenharmony_ci hw->vif_data_size = sizeof(struct mt7603_vif); 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_ci wiphy->iface_combinations = if_comb; 5568c2ecf20Sopenharmony_ci wiphy->n_iface_combinations = ARRAY_SIZE(if_comb); 5578c2ecf20Sopenharmony_ci 5588c2ecf20Sopenharmony_ci ieee80211_hw_set(hw, TX_STATUS_NO_AMPDU_LEN); 5598c2ecf20Sopenharmony_ci ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING); 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_ci /* init led callbacks */ 5628c2ecf20Sopenharmony_ci if (IS_ENABLED(CONFIG_MT76_LEDS)) { 5638c2ecf20Sopenharmony_ci dev->mt76.led_cdev.brightness_set = mt7603_led_set_brightness; 5648c2ecf20Sopenharmony_ci dev->mt76.led_cdev.blink_set = mt7603_led_set_blink; 5658c2ecf20Sopenharmony_ci } 5668c2ecf20Sopenharmony_ci 5678c2ecf20Sopenharmony_ci wiphy->reg_notifier = mt7603_regd_notifier; 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ci ret = mt76_register_device(&dev->mt76, true, mt7603_rates, 5708c2ecf20Sopenharmony_ci ARRAY_SIZE(mt7603_rates)); 5718c2ecf20Sopenharmony_ci if (ret) 5728c2ecf20Sopenharmony_ci return ret; 5738c2ecf20Sopenharmony_ci 5748c2ecf20Sopenharmony_ci mt7603_init_debugfs(dev); 5758c2ecf20Sopenharmony_ci mt7603_init_txpower(dev, &dev->mphy.sband_2g.sband); 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_ci return 0; 5788c2ecf20Sopenharmony_ci} 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_civoid mt7603_unregister_device(struct mt7603_dev *dev) 5818c2ecf20Sopenharmony_ci{ 5828c2ecf20Sopenharmony_ci tasklet_disable(&dev->mt76.pre_tbtt_tasklet); 5838c2ecf20Sopenharmony_ci mt76_unregister_device(&dev->mt76); 5848c2ecf20Sopenharmony_ci mt7603_mcu_exit(dev); 5858c2ecf20Sopenharmony_ci mt7603_dma_cleanup(dev); 5868c2ecf20Sopenharmony_ci mt76_free_device(&dev->mt76); 5878c2ecf20Sopenharmony_ci} 588