drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c- Extension
.c- Size
- 7831 bytes
- Lines
- 357
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/of.hmt7615.heeprom.h
Detected Declarations
function mt7615_efuse_readfunction WARN_ON_ONCEfunction mt7615_efuse_initfunction mt7615_eeprom_loadfunction mt7615_check_eepromfunction mt7615_eeprom_parse_hw_band_capfunction mt7615_eeprom_parse_hw_capfunction mt7663_eeprom_get_target_power_indexfunction mt7615_eeprom_get_target_power_indexfunction mt7615_eeprom_get_power_delta_indexfunction mt7615_apply_cal_free_datafunction mt7622_apply_cal_free_datafunction mt7615_cal_free_datafunction mt7615_eeprom_initexport mt7615_eeprom_init
Annotated Snippet
WARN_ON_ONCE(!(val & MT_EFUSE_CTRL_VALID))) {
memset(data, 0x0, 16);
return 0;
}
for (i = 0; i < 4; i++) {
val = mt76_rr(dev, base + MT_EFUSE_RDATA(i));
put_unaligned_le32(val, data + 4 * i);
}
return 0;
}
static int mt7615_efuse_init(struct mt7615_dev *dev, u32 base)
{
int i, len = MT7615_EEPROM_SIZE;
void *buf;
u32 val;
if (is_mt7663(&dev->mt76))
len = MT7663_EEPROM_SIZE;
val = mt76_rr(dev, base + MT_EFUSE_BASE_CTRL);
if (val & MT_EFUSE_BASE_CTRL_EMPTY)
return 0;
dev->mt76.otp.data = devm_kzalloc(dev->mt76.dev, len, GFP_KERNEL);
dev->mt76.otp.size = len;
if (!dev->mt76.otp.data)
return -ENOMEM;
buf = dev->mt76.otp.data;
for (i = 0; i + 16 <= len; i += 16) {
int ret;
ret = mt7615_efuse_read(dev, base, i, buf + i);
if (ret)
return ret;
}
return 0;
}
static int mt7615_eeprom_load(struct mt7615_dev *dev, u32 addr)
{
int ret;
BUILD_BUG_ON(MT7615_EEPROM_FULL_SIZE < MT7663_EEPROM_SIZE);
ret = mt76_eeprom_init(&dev->mt76, MT7615_EEPROM_FULL_SIZE);
if (ret < 0)
return ret;
return mt7615_efuse_init(dev, addr);
}
static int mt7615_check_eeprom(struct mt76_dev *dev)
{
u16 val = get_unaligned_le16(dev->eeprom.data);
switch (val) {
case 0x7615:
case 0x7622:
case 0x7663:
return 0;
default:
return -EINVAL;
}
}
static void
mt7615_eeprom_parse_hw_band_cap(struct mt7615_dev *dev)
{
u8 val, *eeprom = dev->mt76.eeprom.data;
if (is_mt7663(&dev->mt76)) {
/* dual band */
dev->mphy.cap.has_2ghz = true;
dev->mphy.cap.has_5ghz = true;
return;
}
if (is_mt7622(&dev->mt76)) {
/* 2GHz only */
dev->mphy.cap.has_2ghz = true;
return;
}
if (is_mt7611(&dev->mt76)) {
/* 5GHz only */
Annotation
- Immediate include surface: `linux/of.h`, `mt7615.h`, `eeprom.h`.
- Detected declarations: `function mt7615_efuse_read`, `function WARN_ON_ONCE`, `function mt7615_efuse_init`, `function mt7615_eeprom_load`, `function mt7615_check_eeprom`, `function mt7615_eeprom_parse_hw_band_cap`, `function mt7615_eeprom_parse_hw_cap`, `function mt7663_eeprom_get_target_power_index`, `function mt7615_eeprom_get_target_power_index`, `function mt7615_eeprom_get_power_delta_index`.
- 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.