init.c (78562b2cafc61a0c08dc949eacb942ac756aae37) | init.c (975e122ddb7cd6f67bff974d2ea00c5568d2014c) |
---|---|
1// SPDX-License-Identifier: ISC 2/* Copyright (C) 2020 MediaTek Inc. */ 3 4#include <linux/etherdevice.h> 5#include <linux/hwmon.h> 6#include <linux/hwmon-sysfs.h> 7#include <linux/thermal.h> 8#include <linux/firmware.h> --- 47 unchanged lines hidden (view full) --- 56 57static ssize_t mt7921_thermal_temp_show(struct device *dev, 58 struct device_attribute *attr, 59 char *buf) 60{ 61 switch (to_sensor_dev_attr(attr)->index) { 62 case 0: { 63 struct mt792x_phy *phy = dev_get_drvdata(dev); | 1// SPDX-License-Identifier: ISC 2/* Copyright (C) 2020 MediaTek Inc. */ 3 4#include <linux/etherdevice.h> 5#include <linux/hwmon.h> 6#include <linux/hwmon-sysfs.h> 7#include <linux/thermal.h> 8#include <linux/firmware.h> --- 47 unchanged lines hidden (view full) --- 56 57static ssize_t mt7921_thermal_temp_show(struct device *dev, 58 struct device_attribute *attr, 59 char *buf) 60{ 61 switch (to_sensor_dev_attr(attr)->index) { 62 case 0: { 63 struct mt792x_phy *phy = dev_get_drvdata(dev); |
64 struct mt7921_dev *mdev = phy->dev; | 64 struct mt792x_dev *mdev = phy->dev; |
65 int temperature; 66 67 mt7921_mutex_acquire(mdev); 68 temperature = mt7921_mcu_get_temperature(phy); 69 mt7921_mutex_release(mdev); 70 71 if (temperature < 0) 72 return temperature; --- 32 unchanged lines hidden (view full) --- 105 return 0; 106} 107 108static void 109mt7921_regd_notifier(struct wiphy *wiphy, 110 struct regulatory_request *request) 111{ 112 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); | 65 int temperature; 66 67 mt7921_mutex_acquire(mdev); 68 temperature = mt7921_mcu_get_temperature(phy); 69 mt7921_mutex_release(mdev); 70 71 if (temperature < 0) 72 return temperature; --- 32 unchanged lines hidden (view full) --- 105 return 0; 106} 107 108static void 109mt7921_regd_notifier(struct wiphy *wiphy, 110 struct regulatory_request *request) 111{ 112 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
113 struct mt7921_dev *dev = mt7921_hw_dev(hw); | 113 struct mt792x_dev *dev = mt7921_hw_dev(hw); |
114 115 memcpy(dev->mt76.alpha2, request->alpha2, sizeof(dev->mt76.alpha2)); 116 dev->mt76.region = request->dfs_region; 117 dev->country_ie_env = request->country_ie_env; 118 119 mt7921_mutex_acquire(dev); 120 mt7921_mcu_set_clc(dev, request->alpha2, request->country_ie_env); 121 mt76_connac_mcu_set_channel_domain(hw->priv); 122 mt7921_set_tx_sar_pwr(hw, NULL); 123 mt7921_mutex_release(dev); 124} 125 126static int 127mt7921_init_wiphy(struct ieee80211_hw *hw) 128{ 129 struct mt792x_phy *phy = mt7921_hw_phy(hw); | 114 115 memcpy(dev->mt76.alpha2, request->alpha2, sizeof(dev->mt76.alpha2)); 116 dev->mt76.region = request->dfs_region; 117 dev->country_ie_env = request->country_ie_env; 118 119 mt7921_mutex_acquire(dev); 120 mt7921_mcu_set_clc(dev, request->alpha2, request->country_ie_env); 121 mt76_connac_mcu_set_channel_domain(hw->priv); 122 mt7921_set_tx_sar_pwr(hw, NULL); 123 mt7921_mutex_release(dev); 124} 125 126static int 127mt7921_init_wiphy(struct ieee80211_hw *hw) 128{ 129 struct mt792x_phy *phy = mt7921_hw_phy(hw); |
130 struct mt7921_dev *dev = phy->dev; | 130 struct mt792x_dev *dev = phy->dev; |
131 struct wiphy *wiphy = hw->wiphy; 132 133 hw->queues = 4; 134 hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HE; 135 hw->max_tx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HE; 136 hw->netdev_features = NETIF_F_RXCSUM; 137 138 hw->radiotap_timestamp.units_pos = --- 56 unchanged lines hidden (view full) --- 195 ieee80211_hw_set(hw, CONNECTION_MONITOR); 196 197 hw->max_tx_fragments = 4; 198 199 return 0; 200} 201 202static void | 131 struct wiphy *wiphy = hw->wiphy; 132 133 hw->queues = 4; 134 hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HE; 135 hw->max_tx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HE; 136 hw->netdev_features = NETIF_F_RXCSUM; 137 138 hw->radiotap_timestamp.units_pos = --- 56 unchanged lines hidden (view full) --- 195 ieee80211_hw_set(hw, CONNECTION_MONITOR); 196 197 hw->max_tx_fragments = 4; 198 199 return 0; 200} 201 202static void |
203mt7921_mac_init_band(struct mt7921_dev *dev, u8 band) | 203mt7921_mac_init_band(struct mt792x_dev *dev, u8 band) |
204{ 205 u32 mask, set; 206 207 mt76_rmw_field(dev, MT_TMAC_CTCR0(band), 208 MT_TMAC_CTCR0_INS_DDLMT_REFTIME, 0x3f); 209 mt76_set(dev, MT_TMAC_CTCR0(band), 210 MT_TMAC_CTCR0_INS_DDLMT_VHT_SMPDU_EN | 211 MT_TMAC_CTCR0_INS_DDLMT_EN); --- 92 unchanged lines hidden (view full) --- 304 ops->unassign_vif_chanctx = NULL; 305 ops->mgd_prepare_tx = NULL; 306 ops->mgd_complete_tx = NULL; 307 } 308 return ops; 309} 310EXPORT_SYMBOL_GPL(mt7921_get_mac80211_ops); 311 | 204{ 205 u32 mask, set; 206 207 mt76_rmw_field(dev, MT_TMAC_CTCR0(band), 208 MT_TMAC_CTCR0_INS_DDLMT_REFTIME, 0x3f); 209 mt76_set(dev, MT_TMAC_CTCR0(band), 210 MT_TMAC_CTCR0_INS_DDLMT_VHT_SMPDU_EN | 211 MT_TMAC_CTCR0_INS_DDLMT_EN); --- 92 unchanged lines hidden (view full) --- 304 ops->unassign_vif_chanctx = NULL; 305 ops->mgd_prepare_tx = NULL; 306 ops->mgd_complete_tx = NULL; 307 } 308 return ops; 309} 310EXPORT_SYMBOL_GPL(mt7921_get_mac80211_ops); 311 |
312int mt7921_mac_init(struct mt7921_dev *dev) | 312int mt7921_mac_init(struct mt792x_dev *dev) |
313{ 314 int i; 315 316 mt76_rmw_field(dev, MT_MDP_DCR1, MT_MDP_DCR1_MAX_RX_LEN, 1536); 317 /* enable hardware de-agg */ 318 mt76_set(dev, MT_MDP_DCR0, MT_MDP_DCR0_DAMSDU_EN); 319 /* enable hardware rx header translation */ 320 mt76_set(dev, MT_MDP_DCR0, MT_MDP_DCR0_RX_HDR_TRANS_EN); 321 322 for (i = 0; i < MT7921_WTBL_SIZE; i++) 323 mt7921_mac_wtbl_update(dev, i, 324 MT_WTBL_UPDATE_ADM_COUNT_CLEAR); 325 for (i = 0; i < 2; i++) 326 mt7921_mac_init_band(dev, i); 327 328 return mt76_connac_mcu_set_rts_thresh(&dev->mt76, 0x92b, 0); 329} 330EXPORT_SYMBOL_GPL(mt7921_mac_init); 331 | 313{ 314 int i; 315 316 mt76_rmw_field(dev, MT_MDP_DCR1, MT_MDP_DCR1_MAX_RX_LEN, 1536); 317 /* enable hardware de-agg */ 318 mt76_set(dev, MT_MDP_DCR0, MT_MDP_DCR0_DAMSDU_EN); 319 /* enable hardware rx header translation */ 320 mt76_set(dev, MT_MDP_DCR0, MT_MDP_DCR0_RX_HDR_TRANS_EN); 321 322 for (i = 0; i < MT7921_WTBL_SIZE; i++) 323 mt7921_mac_wtbl_update(dev, i, 324 MT_WTBL_UPDATE_ADM_COUNT_CLEAR); 325 for (i = 0; i < 2; i++) 326 mt7921_mac_init_band(dev, i); 327 328 return mt76_connac_mcu_set_rts_thresh(&dev->mt76, 0x92b, 0); 329} 330EXPORT_SYMBOL_GPL(mt7921_mac_init); 331 |
332static int __mt7921_init_hardware(struct mt7921_dev *dev) | 332static int __mt7921_init_hardware(struct mt792x_dev *dev) |
333{ 334 int ret; 335 336 /* force firmware operation mode into normal state, 337 * which should be set before firmware download stage. 338 */ 339 mt76_wr(dev, MT_SWDEF_MODE, MT_SWDEF_NORMAL_MODE); 340 ret = mt7921_mcu_init(dev); --- 6 unchanged lines hidden (view full) --- 347 if (ret) 348 goto out; 349 350 ret = mt7921_mac_init(dev); 351out: 352 return ret; 353} 354 | 333{ 334 int ret; 335 336 /* force firmware operation mode into normal state, 337 * which should be set before firmware download stage. 338 */ 339 mt76_wr(dev, MT_SWDEF_MODE, MT_SWDEF_NORMAL_MODE); 340 ret = mt7921_mcu_init(dev); --- 6 unchanged lines hidden (view full) --- 347 if (ret) 348 goto out; 349 350 ret = mt7921_mac_init(dev); 351out: 352 return ret; 353} 354 |
355static int mt7921_init_hardware(struct mt7921_dev *dev) | 355static int mt7921_init_hardware(struct mt792x_dev *dev) |
356{ 357 int ret, i; 358 359 set_bit(MT76_STATE_INITIALIZED, &dev->mphy.state); 360 361 for (i = 0; i < MT7921_MCU_INIT_RETRY_COUNT; i++) { 362 ret = __mt7921_init_hardware(dev); 363 if (!ret) --- 5 unchanged lines hidden (view full) --- 369 if (i == MT7921_MCU_INIT_RETRY_COUNT) { 370 dev_err(dev->mt76.dev, "hardware init failed\n"); 371 return ret; 372 } 373 374 return 0; 375} 376 | 356{ 357 int ret, i; 358 359 set_bit(MT76_STATE_INITIALIZED, &dev->mphy.state); 360 361 for (i = 0; i < MT7921_MCU_INIT_RETRY_COUNT; i++) { 362 ret = __mt7921_init_hardware(dev); 363 if (!ret) --- 5 unchanged lines hidden (view full) --- 369 if (i == MT7921_MCU_INIT_RETRY_COUNT) { 370 dev_err(dev->mt76.dev, "hardware init failed\n"); 371 return ret; 372 } 373 374 return 0; 375} 376 |
377static int mt7921_init_wcid(struct mt7921_dev *dev) | 377static int mt7921_init_wcid(struct mt792x_dev *dev) |
378{ 379 int idx; 380 381 /* Beacon and mgmt frames should occupy wcid 0 */ 382 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1); 383 if (idx) 384 return -ENOSPC; 385 386 dev->mt76.global_wcid.idx = idx; 387 dev->mt76.global_wcid.hw_key_idx = -1; 388 dev->mt76.global_wcid.tx_info |= MT_WCID_TX_INFO_SET; 389 rcu_assign_pointer(dev->mt76.wcid[idx], &dev->mt76.global_wcid); 390 391 return 0; 392} 393 394static void mt7921_init_work(struct work_struct *work) 395{ | 378{ 379 int idx; 380 381 /* Beacon and mgmt frames should occupy wcid 0 */ 382 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1); 383 if (idx) 384 return -ENOSPC; 385 386 dev->mt76.global_wcid.idx = idx; 387 dev->mt76.global_wcid.hw_key_idx = -1; 388 dev->mt76.global_wcid.tx_info |= MT_WCID_TX_INFO_SET; 389 rcu_assign_pointer(dev->mt76.wcid[idx], &dev->mt76.global_wcid); 390 391 return 0; 392} 393 394static void mt7921_init_work(struct work_struct *work) 395{ |
396 struct mt7921_dev *dev = container_of(work, struct mt7921_dev, | 396 struct mt792x_dev *dev = container_of(work, struct mt792x_dev, |
397 init_work); 398 int ret; 399 400 ret = mt7921_init_hardware(dev); 401 if (ret) 402 return; 403 404 mt76_set_stream_caps(&dev->mphy, true); --- 19 unchanged lines hidden (view full) --- 424 } 425 426 /* we support chip reset now */ 427 dev->hw_init_done = true; 428 429 mt76_connac_mcu_set_deep_sleep(&dev->mt76, dev->pm.ds_enable); 430} 431 | 397 init_work); 398 int ret; 399 400 ret = mt7921_init_hardware(dev); 401 if (ret) 402 return; 403 404 mt76_set_stream_caps(&dev->mphy, true); --- 19 unchanged lines hidden (view full) --- 424 } 425 426 /* we support chip reset now */ 427 dev->hw_init_done = true; 428 429 mt76_connac_mcu_set_deep_sleep(&dev->mt76, dev->pm.ds_enable); 430} 431 |
432int mt7921_register_device(struct mt7921_dev *dev) | 432int mt7921_register_device(struct mt792x_dev *dev) |
433{ 434 struct ieee80211_hw *hw = mt76_hw(dev); 435 int ret; 436 437 dev->phy.dev = dev; 438 dev->phy.mt76 = &dev->mt76.phy; 439 dev->mt76.phy.priv = &dev->phy; 440 dev->mt76.tx_worker.fn = mt7921_tx_worker; --- 74 unchanged lines hidden --- | 433{ 434 struct ieee80211_hw *hw = mt76_hw(dev); 435 int ret; 436 437 dev->phy.dev = dev; 438 dev->phy.mt76 = &dev->mt76.phy; 439 dev->mt76.phy.priv = &dev->phy; 440 dev->mt76.tx_worker.fn = mt7921_tx_worker; --- 74 unchanged lines hidden --- |