drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/mt76x02_phy.c- Extension
.c- Size
- 5164 bytes
- Lines
- 205
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hmt76x02.hmt76x02_phy.h
Detected Declarations
function Copyrightfunction mt76x02_phy_set_txdacfunction mt76x02_tx_power_maskfunction mt76x02_get_max_rate_powerfunction mt76x02_limit_rate_powerfunction mt76x02_add_rate_power_offsetfunction mt76x02_phy_set_txpowerfunction mt76x02_phy_set_bwfunction mt76x02_phy_set_bandfunction mt76x02_phy_adjust_vga_gainfunction mt76x02_init_agc_gainexport mt76x02_phy_set_rxpathexport mt76x02_phy_set_txdacexport mt76x02_get_max_rate_powerexport mt76x02_limit_rate_powerexport mt76x02_add_rate_power_offsetexport mt76x02_phy_set_txpowerexport mt76x02_phy_set_bwexport mt76x02_phy_set_bandexport mt76x02_phy_adjust_vga_gainexport mt76x02_init_agc_gain
Annotated Snippet
// SPDX-License-Identifier: BSD-3-Clause-Clear
/*
* Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
* Copyright (C) 2018 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
*/
#include <linux/kernel.h>
#include "mt76x02.h"
#include "mt76x02_phy.h"
void mt76x02_phy_set_rxpath(struct mt76x02_dev *dev)
{
u32 val;
val = mt76_rr(dev, MT_BBP(AGC, 0));
val &= ~BIT(4);
switch (dev->mphy.chainmask & 0xf) {
case 2:
val |= BIT(3);
break;
default:
val &= ~BIT(3);
break;
}
mt76_wr(dev, MT_BBP(AGC, 0), val);
mb();
val = mt76_rr(dev, MT_BBP(AGC, 0));
}
EXPORT_SYMBOL_GPL(mt76x02_phy_set_rxpath);
void mt76x02_phy_set_txdac(struct mt76x02_dev *dev)
{
int txpath;
txpath = (dev->mphy.chainmask >> 8) & 0xf;
switch (txpath) {
case 2:
mt76_set(dev, MT_BBP(TXBE, 5), 0x3);
break;
default:
mt76_clear(dev, MT_BBP(TXBE, 5), 0x3);
break;
}
}
EXPORT_SYMBOL_GPL(mt76x02_phy_set_txdac);
static u32
mt76x02_tx_power_mask(u8 v1, u8 v2, u8 v3, u8 v4)
{
u32 val = 0;
val |= (v1 & (BIT(6) - 1)) << 0;
val |= (v2 & (BIT(6) - 1)) << 8;
val |= (v3 & (BIT(6) - 1)) << 16;
val |= (v4 & (BIT(6) - 1)) << 24;
return val;
}
int mt76x02_get_max_rate_power(struct mt76x02_rate_power *r)
{
s8 ret = 0;
int i;
for (i = 0; i < sizeof(r->all); i++)
ret = max(ret, r->all[i]);
return ret;
}
EXPORT_SYMBOL_GPL(mt76x02_get_max_rate_power);
void mt76x02_limit_rate_power(struct mt76x02_rate_power *r, int limit)
{
int i;
for (i = 0; i < sizeof(r->all); i++)
if (r->all[i] > limit)
r->all[i] = limit;
}
EXPORT_SYMBOL_GPL(mt76x02_limit_rate_power);
void mt76x02_add_rate_power_offset(struct mt76x02_rate_power *r, int offset)
{
int i;
for (i = 0; i < sizeof(r->all); i++)
r->all[i] += offset;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `mt76x02.h`, `mt76x02_phy.h`.
- Detected declarations: `function Copyright`, `function mt76x02_phy_set_txdac`, `function mt76x02_tx_power_mask`, `function mt76x02_get_max_rate_power`, `function mt76x02_limit_rate_power`, `function mt76x02_add_rate_power_offset`, `function mt76x02_phy_set_txpower`, `function mt76x02_phy_set_bw`, `function mt76x02_phy_set_band`, `function mt76x02_phy_adjust_vga_gain`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
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.