drivers/net/wireless/mediatek/mt76/mt792x_usb.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/mt792x_usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/mt792x_usb.c- Extension
.c- Size
- 10933 bytes
- Lines
- 428
- 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.
- 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/kernel.hlinux/module.hlinux/usb.hmt792x.hmt76_connac2_mac.h
Detected Declarations
struct mt792xu_wfsys_descfunction mt792xu_read32function mt792xu_reset_workfunction mt792xu_reset_work_initfunction mt792xu_reset_work_cleanupfunction mt792xu_check_busfunction mt792xu_reset_on_bus_errorfunction mt792xu_rrfunction mt792xu_wrfunction mt792xu_rmwfunction mt792xu_copyfunction mt792xu_mcu_power_onfunction mt792xu_cleanupfunction mt792xu_uhw_rrfunction mt792xu_uhw_wrfunction mt792xu_dma_prefetchfunction mt792xu_wfdma_initfunction mt792xu_dma_rx_evt_ep4function mt792xu_epctl_rst_optfunction mt792xu_dma_initfunction mt792xu_wfsys_resetfunction mt792xu_init_resetfunction mt792xu_stopfunction mt792xu_disconnectexport mt792xu_reset_work_initexport mt792xu_reset_work_cleanupexport mt792xu_check_busexport mt792xu_reset_on_bus_errorexport mt792xu_rrexport mt792xu_wrexport mt792xu_rmwexport mt792xu_copyexport mt792xu_mcu_power_onexport mt792xu_dma_initexport mt792xu_wfsys_resetexport mt792xu_init_resetexport mt792xu_stopexport mt792xu_disconnect
Annotated Snippet
struct mt792xu_wfsys_desc {
u32 rst_reg;
u32 done_reg;
u32 done_mask;
u32 done_val;
u32 delay_ms;
bool need_status_sel;
};
static const struct mt792xu_wfsys_desc mt7921_wfsys_desc = {
.rst_reg = MT_CBTOP_RGU_WF_SUBSYS_RST,
.done_reg = MT_UDMA_CONN_INFRA_STATUS,
.done_mask = MT_UDMA_CONN_WFSYS_INIT_DONE,
.done_val = MT_UDMA_CONN_WFSYS_INIT_DONE,
.delay_ms = 0,
.need_status_sel = true,
};
static const struct mt792xu_wfsys_desc mt7925_wfsys_desc = {
.rst_reg = MT7925_CBTOP_RGU_WF_SUBSYS_RST,
.done_reg = MT7925_WFSYS_INIT_DONE_ADDR,
.done_mask = U32_MAX,
.done_val = MT7925_WFSYS_INIT_DONE,
.delay_ms = 20,
.need_status_sel = false,
};
int mt792xu_dma_init(struct mt792x_dev *dev, bool resume)
{
int err;
mt792xu_wfdma_init(dev);
mt76_clear(dev, MT_UDMA_WLCFG_0, MT_WL_RX_FLUSH);
mt76_set(dev, MT_UDMA_WLCFG_0,
MT_WL_RX_EN | MT_WL_TX_EN |
MT_WL_RX_MPSZ_PAD0 | MT_TICK_1US_EN);
mt76_clear(dev, MT_UDMA_WLCFG_0,
MT_WL_RX_AGG_TO | MT_WL_RX_AGG_LMT);
mt76_clear(dev, MT_UDMA_WLCFG_1, MT_WL_RX_AGG_PKT_LMT);
if (resume)
return 0;
err = mt792xu_dma_rx_evt_ep4(dev);
if (err)
return err;
mt792xu_epctl_rst_opt(dev, false);
return 0;
}
EXPORT_SYMBOL_GPL(mt792xu_dma_init);
int mt792xu_wfsys_reset(struct mt792x_dev *dev)
{
const struct mt792xu_wfsys_desc *desc = is_connac3(&dev->mt76) ?
&mt7925_wfsys_desc :
&mt7921_wfsys_desc;
u32 val;
int i;
mt792xu_epctl_rst_opt(dev, false);
val = mt792xu_uhw_rr(&dev->mt76, desc->rst_reg);
val |= MT_CBTOP_RGU_WF_SUBSYS_RST_WF_WHOLE_PATH;
mt792xu_uhw_wr(&dev->mt76, desc->rst_reg, val);
if (desc->delay_ms)
msleep(desc->delay_ms);
else
usleep_range(10, 20);
val = mt792xu_uhw_rr(&dev->mt76, desc->rst_reg);
val &= ~MT_CBTOP_RGU_WF_SUBSYS_RST_WF_WHOLE_PATH;
mt792xu_uhw_wr(&dev->mt76, desc->rst_reg, val);
if (desc->need_status_sel)
mt792xu_uhw_wr(&dev->mt76, MT_UDMA_CONN_INFRA_STATUS_SEL, 0);
for (i = 0; i < MT792x_WFSYS_INIT_RETRY_COUNT; i++) {
val = mt792xu_uhw_rr(&dev->mt76, desc->done_reg);
if ((val & desc->done_mask) == desc->done_val)
break;
msleep(100);
}
if (i == MT792x_WFSYS_INIT_RETRY_COUNT)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/usb.h`, `mt792x.h`, `mt76_connac2_mac.h`.
- Detected declarations: `struct mt792xu_wfsys_desc`, `function mt792xu_read32`, `function mt792xu_reset_work`, `function mt792xu_reset_work_init`, `function mt792xu_reset_work_cleanup`, `function mt792xu_check_bus`, `function mt792xu_reset_on_bus_error`, `function mt792xu_rr`, `function mt792xu_wr`, `function mt792xu_rmw`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.