drivers/net/wireless/mediatek/mt7601u/phy.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt7601u/phy.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt7601u/phy.c- Extension
.c- Size
- 31052 bytes
- Lines
- 1259
- 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
mt7601u.hmcu.heeprom.htrace.hinitvals_phy.hlinux/etherdevice.h
Detected Declarations
function mt7601u_rf_wrfunction mt7601u_rf_rrfunction FIELD_GETfunction mt7601u_rf_rmwfunction mt7601u_rf_setfunction mt7601u_rf_clearfunction mt7601u_bbp_wrfunction mt7601u_bbp_rrfunction mt7601u_bbp_rmwfunction mt7601u_bbp_rmcfunction mt7601u_wait_bbp_readyfunction mt7601u_bbp_set_ctrlchfunction mt7601u_phy_get_rssifunction mt7601u_vco_calfunction mt7601u_set_bw_filterfunction mt7601u_load_bbp_temp_table_bwfunction mt7601u_bbp_tempfunction mt7601u_apply_ch14_fixupfunction __mt7601u_phy_set_channelfunction mt7601u_phy_set_channelfunction mt7601u_bbp_r47_getfunction mt7601u_read_bootup_tempfunction mt7601u_read_tempfunction mt7601u_rxdc_calfunction mt7601u_phy_recalibrate_after_assocfunction lin2dBdfunction mt7601u_set_initial_tssifunction mt7601u_tssi_dc_gain_calfunction mt7601u_temp_compfunction mt7601u_current_tx_powerfunction mt7601u_use_hvgafunction mt7601u_phy_rf_pa_mode_valfunction mt7601u_tssi_params_getfunction mt7601u_tssi_read_readyfunction mt7601u_tssi_calfunction mt7601u_agc_defaultfunction mt7601u_agc_resetfunction mt7601u_agc_savefunction mt7601u_agc_restorefunction mt7601u_agc_tunefunction mt7601u_phy_calibratefunction __mt7601u_phy_freq_calfunction mt7601u_phy_freq_calfunction mt7601u_phy_con_cal_onofffunction mt7601u_init_calfunction mt7601u_bbp_set_bwfunction mt7601u_set_rx_pathfunction mt7601u_set_tx_dac
Annotated Snippet
FIELD_GET(MT_RF_CSR_CFG_REG_BANK, val) == bank) {
ret = FIELD_GET(MT_RF_CSR_CFG_DATA, val);
trace_rf_read(dev, bank, offset, ret);
}
out:
mutex_unlock(&dev->reg_atomic_mutex);
if (ret < 0)
dev_err(dev->dev, "Error: RF read %02hhx:%02hhx failed:%d!!\n",
bank, offset, ret);
return ret;
}
static int
mt7601u_rf_rmw(struct mt7601u_dev *dev, u8 bank, u8 offset, u8 mask, u8 val)
{
int ret;
ret = mt7601u_rf_rr(dev, bank, offset);
if (ret < 0)
return ret;
val |= ret & ~mask;
ret = mt7601u_rf_wr(dev, bank, offset, val);
if (ret)
return ret;
return val;
}
static int
mt7601u_rf_set(struct mt7601u_dev *dev, u8 bank, u8 offset, u8 val)
{
return mt7601u_rf_rmw(dev, bank, offset, 0, val);
}
static int
mt7601u_rf_clear(struct mt7601u_dev *dev, u8 bank, u8 offset, u8 mask)
{
return mt7601u_rf_rmw(dev, bank, offset, mask, 0);
}
static void mt7601u_bbp_wr(struct mt7601u_dev *dev, u8 offset, u8 val)
{
if (WARN_ON(!test_bit(MT7601U_STATE_WLAN_RUNNING, &dev->state)) ||
test_bit(MT7601U_STATE_REMOVED, &dev->state))
return;
mutex_lock(&dev->reg_atomic_mutex);
if (!mt76_poll(dev, MT_BBP_CSR_CFG, MT_BBP_CSR_CFG_BUSY, 0, 1000)) {
dev_err(dev->dev, "Error: BBP write %02hhx failed!!\n", offset);
goto out;
}
mt7601u_wr(dev, MT_BBP_CSR_CFG,
FIELD_PREP(MT_BBP_CSR_CFG_VAL, val) |
FIELD_PREP(MT_BBP_CSR_CFG_REG_NUM, offset) |
MT_BBP_CSR_CFG_RW_MODE | MT_BBP_CSR_CFG_BUSY);
trace_bbp_write(dev, offset, val);
out:
mutex_unlock(&dev->reg_atomic_mutex);
}
static int mt7601u_bbp_rr(struct mt7601u_dev *dev, u8 offset)
{
u32 val;
int ret = -ETIMEDOUT;
if (WARN_ON(!test_bit(MT7601U_STATE_WLAN_RUNNING, &dev->state)))
return -EINVAL;
if (test_bit(MT7601U_STATE_REMOVED, &dev->state))
return 0xff;
mutex_lock(&dev->reg_atomic_mutex);
if (!mt76_poll(dev, MT_BBP_CSR_CFG, MT_BBP_CSR_CFG_BUSY, 0, 1000))
goto out;
mt7601u_wr(dev, MT_BBP_CSR_CFG,
FIELD_PREP(MT_BBP_CSR_CFG_REG_NUM, offset) |
MT_BBP_CSR_CFG_RW_MODE | MT_BBP_CSR_CFG_BUSY |
MT_BBP_CSR_CFG_READ);
if (!mt76_poll(dev, MT_BBP_CSR_CFG, MT_BBP_CSR_CFG_BUSY, 0, 1000))
goto out;
val = mt7601u_rr(dev, MT_BBP_CSR_CFG);
if (FIELD_GET(MT_BBP_CSR_CFG_REG_NUM, val) == offset) {
ret = FIELD_GET(MT_BBP_CSR_CFG_VAL, val);
Annotation
- Immediate include surface: `mt7601u.h`, `mcu.h`, `eeprom.h`, `trace.h`, `initvals_phy.h`, `linux/etherdevice.h`.
- Detected declarations: `function mt7601u_rf_wr`, `function mt7601u_rf_rr`, `function FIELD_GET`, `function mt7601u_rf_rmw`, `function mt7601u_rf_set`, `function mt7601u_rf_clear`, `function mt7601u_bbp_wr`, `function mt7601u_bbp_rr`, `function mt7601u_bbp_rmw`, `function mt7601u_bbp_rmc`.
- 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.