drivers/net/wireless/mediatek/mt76/mt7996/init.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/mt7996/init.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/mt7996/init.c- Extension
.c- Size
- 52315 bytes
- Lines
- 1818
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/etherdevice.hlinux/of.hlinux/hwmon.hlinux/hwmon-sysfs.hlinux/thermal.hmt7996.hmac.hmcu.hcoredump.heeprom.h
Detected Declarations
function mt7996_thermal_temp_showfunction mt7996_thermal_temp_storefunction mt7996_thermal_get_max_throttle_statefunction mt7996_thermal_get_cur_throttle_statefunction mt7996_thermal_set_cur_throttle_statefunction mt7996_unregister_thermalfunction mt7996_thermal_initfunction mt7996_led_set_configfunction mt7996_led_set_blinkfunction mt7996_led_set_brightnessfunction __mt7996_init_txpowerfunction mt7996_init_txpowerfunction mt7996_regd_notifierfunction mt7996_for_each_phyfunction mt7996_init_wiphy_bandfunction mt7996_init_wiphyfunction mt7996_mac_init_bandfunction mt7996_mac_init_basic_ratesfunction mt7996_mac_initfunction mt7996_txbf_initfunction mt7996_register_phyfunction mt7996_unregister_phyfunction mt7996_init_workfunction mt7996_wfsys_resetfunction mt7996_rro_hw_init_v3function mt7996_rro_hw_initfunction mt7996_wed_rro_initfunction mt7996_wed_rro_freefunction mt7996_wed_rro_workfunction mt7996_variant_type_initfunction mt7996_variant_fem_initfunction mt7996_init_hardwarefunction mt7996_set_stream_vht_txbf_capsfunction mt7996_set_stream_he_txbf_capsfunction mt7996_init_he_capsfunction mt7996_init_eht_capsfunction __mt7996_set_stream_he_eht_capsfunction mt7996_set_stream_he_eht_capsfunction mt7996_register_devicefunction mt7996_unregister_device
Annotated Snippet
mt7996_band_valid(dev, MT_BAND2)) {
ret = mt7996_mcu_set_txbf(dev, BF_MOD_EN_CTRL);
if (ret)
return ret;
}
/* trigger sounding packets */
ret = mt7996_mcu_set_txbf(dev, BF_SOUNDING_ON);
if (ret)
return ret;
/* enable eBF */
return mt7996_mcu_set_txbf(dev, BF_HW_EN_UPDATE);
}
static int mt7996_register_phy(struct mt7996_dev *dev, enum mt76_band_id band)
{
struct mt7996_phy *phy;
struct mt76_phy *mphy;
u32 mac_ofs, hif1_ofs = 0;
int ret;
struct mtk_wed_device *wed = &dev->mt76.mmio.wed;
if (!mt7996_band_valid(dev, band))
return 0;
if (dev->hif2 &&
((is_mt7992(&dev->mt76) && band == MT_BAND1) ||
(is_mt7996(&dev->mt76) && band == MT_BAND2 &&
!mt76_npu_device_active(&dev->mt76)))) {
hif1_ofs = MT_WFDMA0_PCIE1(0) - MT_WFDMA0(0);
wed = &dev->mt76.mmio.wed_hif2;
}
mphy = mt76_alloc_radio_phy(&dev->mt76, sizeof(*phy), band);
if (!mphy)
return -ENOMEM;
phy = mphy->priv;
phy->dev = dev;
phy->mt76 = mphy;
mphy->dev->phys[band] = mphy;
INIT_DELAYED_WORK(&mphy->mac_work, mt7996_mac_work);
ret = mt7996_eeprom_parse_hw_cap(dev, phy);
if (ret)
goto error;
mac_ofs = band == MT_BAND2 ? MT_EE_MAC_ADDR3 : MT_EE_MAC_ADDR2;
memcpy(mphy->macaddr, dev->mt76.eeprom.data + mac_ofs, ETH_ALEN);
/* Make the extra PHY MAC address local without overlapping with
* the usual MAC address allocation scheme on multiple virtual interfaces
*/
if (!is_valid_ether_addr(mphy->macaddr)) {
memcpy(mphy->macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR,
ETH_ALEN);
mphy->macaddr[0] |= 2;
mphy->macaddr[0] ^= BIT(7);
if (band == MT_BAND2)
mphy->macaddr[0] ^= BIT(6);
}
ret = mt76_eeprom_override(mphy);
if (ret)
goto error;
/* init wiphy according to mphy and phy */
mt7996_init_wiphy_band(mphy->hw, phy);
if (is_mt7996(&dev->mt76) &&
((band == MT_BAND1 && !dev->hif2) ||
(band == MT_BAND2 && mt76_npu_device_active(&dev->mt76)))) {
int i;
for (i = 0; i <= MT_TXQ_PSD; i++)
mphy->q_tx[i] = dev->mt76.phys[band - 1]->q_tx[0];
} else {
int size = is_mt7996(&dev->mt76) &&
mt76_npu_device_active(&dev->mt76)
? MT7996_NPU_TX_RING_SIZE / 2 : MT7996_TX_RING_SIZE;
ret = mt7996_init_tx_queues(mphy->priv, MT_TXQ_ID(band), size,
MT_TXQ_RING_BASE(band) + hif1_ofs,
wed);
if (ret)
goto error;
}
ret = mt76_register_phy(mphy, true, mt76_rates,
ARRAY_SIZE(mt76_rates));
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/of.h`, `linux/hwmon.h`, `linux/hwmon-sysfs.h`, `linux/thermal.h`, `mt7996.h`, `mac.h`, `mcu.h`.
- Detected declarations: `function mt7996_thermal_temp_show`, `function mt7996_thermal_temp_store`, `function mt7996_thermal_get_max_throttle_state`, `function mt7996_thermal_get_cur_throttle_state`, `function mt7996_thermal_set_cur_throttle_state`, `function mt7996_unregister_thermal`, `function mt7996_thermal_init`, `function mt7996_led_set_config`, `function mt7996_led_set_blink`, `function mt7996_led_set_brightness`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.