drivers/net/wireless/ralink/rt2x00/rt2800usb.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/ralink/rt2x00/rt2800usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/ralink/rt2x00/rt2800usb.c- Extension
.c- Size
- 35078 bytes
- Lines
- 1277
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/delay.hlinux/etherdevice.hlinux/kernel.hlinux/module.hlinux/usb.hrt2x00.hrt2x00usb.hrt2800lib.hrt2800.hrt2800usb.h
Detected Declarations
function rt2800usb_hwcrypt_disabledfunction rt2800usb_start_queuefunction rt2800usb_stop_queuefunction rt2800usb_tx_sta_fifo_read_completedfunction rt2800usb_async_read_tx_statusfunction rt2800usb_tx_dma_donefunction rt2800usb_tx_sta_fifo_timeoutfunction rt2800usb_autorun_detectfunction rt2800usb_write_firmwarefunction rt2x00_rtfunction rt2800usb_init_registersfunction rt2800usb_enable_radiofunction rt2800usb_disable_radiofunction rt2800usb_set_statefunction rt2800usb_set_device_statefunction rt2800usb_get_dma_donefunction rt2800usb_write_tx_descfunction rt2800usb_get_tx_data_lenfunction rt2800usb_work_txdonefunction rt2800usb_fill_rxdonefunction rt2800usb_efuse_detectfunction rt2800usb_read_eepromfunction rt2800usb_probe_hwfunction rt2800usb_queue_initfunction rt2800usb_probe
Annotated Snippet
rt2x00_rt(rt2x00dev, RT3070)) {
offset = 0;
length = 4096;
} else {
offset = 4096;
length = 4096;
}
/*
* Write firmware to device.
*/
retval = rt2800usb_autorun_detect(rt2x00dev);
if (retval < 0)
return retval;
if (retval) {
rt2x00_info(rt2x00dev,
"Firmware loading not required - NIC in AutoRun mode\n");
__clear_bit(REQUIRE_FIRMWARE, &rt2x00dev->cap_flags);
} else {
rt2x00usb_register_multiwrite(rt2x00dev, FIRMWARE_IMAGE_BASE,
data + offset, length);
}
rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
/*
* Send firmware request to device to load firmware,
* we need to specify a long timeout time.
*/
status = rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE,
0, USB_MODE_FIRMWARE,
REGISTER_TIMEOUT_FIRMWARE);
if (status < 0) {
rt2x00_err(rt2x00dev, "Failed to write Firmware to device\n");
return status;
}
msleep(10);
rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
return 0;
}
/*
* Device state switch handlers.
*/
static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev)
{
u32 reg;
/*
* Wait until BBP and RF are ready.
*/
if (rt2800_wait_csr_ready(rt2x00dev))
return -EBUSY;
reg = rt2x00usb_register_read(rt2x00dev, PBF_SYS_CTRL);
rt2x00usb_register_write(rt2x00dev, PBF_SYS_CTRL, reg & ~0x00002000);
reg = 0;
rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_CSR, 1);
rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_BBP, 1);
rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0,
USB_MODE_RESET, REGISTER_TIMEOUT);
rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000);
return 0;
}
static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev)
{
u32 reg = 0;
if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev)))
return -EIO;
rt2x00_set_field32(®, USB_DMA_CFG_PHY_CLEAR, 0);
rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_EN, 0);
rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_TIMEOUT, 128);
/*
* Total room for RX frames in kilobytes, PBF might still exceed
* this limit so reduce the number to prevent errors.
*/
rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_LIMIT,
((rt2x00dev->rx->limit * DATA_FRAME_SIZE)
/ 1024) - 3);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/etherdevice.h`, `linux/kernel.h`, `linux/module.h`, `linux/usb.h`, `rt2x00.h`, `rt2x00usb.h`, `rt2800lib.h`.
- Detected declarations: `function rt2800usb_hwcrypt_disabled`, `function rt2800usb_start_queue`, `function rt2800usb_stop_queue`, `function rt2800usb_tx_sta_fifo_read_completed`, `function rt2800usb_async_read_tx_status`, `function rt2800usb_tx_dma_done`, `function rt2800usb_tx_sta_fifo_timeout`, `function rt2800usb_autorun_detect`, `function rt2800usb_write_firmware`, `function rt2x00_rt`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.