drivers/net/wireless/ralink/rt2x00/rt73usb.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/ralink/rt2x00/rt73usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/ralink/rt2x00/rt73usb.c- Extension
.c- Size
- 77326 bytes
- Lines
- 2544
- 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.
- 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/crc-itu-t.hlinux/delay.hlinux/etherdevice.hlinux/kernel.hlinux/module.hlinux/slab.hlinux/usb.hrt2x00.hrt2x00usb.hrt73usb.h
Detected Declarations
struct antenna_selfunction rt73usb_bbp_writefunction rt73usb_bbp_readfunction rt73usb_rf_writefunction rt73usb_rfkill_pollfunction rt73usb_brightness_setfunction rt73usb_blink_setfunction rt73usb_init_ledfunction rt73usb_config_shared_keyfunction rt73usb_config_pairwise_keyfunction rt73usb_config_filterfunction rt73usb_config_intffunction rt73usb_config_erpfunction rt73usb_config_antenna_5xfunction rt73usb_config_antenna_2xfunction rt73usb_config_antfunction rt73usb_config_lna_gainfunction rt73usb_config_channelfunction rt73usb_config_txpowerfunction rt73usb_config_retry_limitfunction rt73usb_config_psfunction rt73usb_configfunction rt73usb_link_statsfunction rt73usb_set_vgcfunction rt73usb_reset_tunerfunction rt73usb_link_tunerfunction rt73usb_start_queuefunction rt73usb_stop_queuefunction rt73usb_check_firmwarefunction rt73usb_load_firmwarefunction rt73usb_init_registersfunction rt73usb_wait_bbp_readyfunction rt73usb_init_bbpfunction rt73usb_enable_radiofunction rt73usb_disable_radiofunction rt73usb_set_statefunction rt73usb_set_device_statefunction rt73usb_write_tx_descfunction rt73usb_write_beaconfunction rt73usb_clear_beaconfunction rt73usb_get_tx_data_lenfunction rt73usb_agc_to_rssifunction rt73usb_fill_rxdonefunction rt73usb_validate_eepromfunction rt73usb_init_eepromfunction rt73usb_probe_hw_modefunction rt73usb_probe_hwfunction rt73usb_conf_tx
Annotated Snippet
struct antenna_sel {
u8 word;
/*
* value[0] -> non-LNA
* value[1] -> LNA
*/
u8 value[2];
};
static const struct antenna_sel antenna_sel_a[] = {
{ 96, { 0x58, 0x78 } },
{ 104, { 0x38, 0x48 } },
{ 75, { 0xfe, 0x80 } },
{ 86, { 0xfe, 0x80 } },
{ 88, { 0xfe, 0x80 } },
{ 35, { 0x60, 0x60 } },
{ 97, { 0x58, 0x58 } },
{ 98, { 0x58, 0x58 } },
};
static const struct antenna_sel antenna_sel_bg[] = {
{ 96, { 0x48, 0x68 } },
{ 104, { 0x2c, 0x3c } },
{ 75, { 0xfe, 0x80 } },
{ 86, { 0xfe, 0x80 } },
{ 88, { 0xfe, 0x80 } },
{ 35, { 0x50, 0x50 } },
{ 97, { 0x48, 0x48 } },
{ 98, { 0x48, 0x48 } },
};
static void rt73usb_config_ant(struct rt2x00_dev *rt2x00dev,
struct antenna_setup *ant)
{
const struct antenna_sel *sel;
unsigned int lna;
unsigned int i;
u32 reg;
/*
* We should never come here because rt2x00lib is supposed
* to catch this and send us the correct antenna explicitely.
*/
BUG_ON(ant->rx == ANTENNA_SW_DIVERSITY ||
ant->tx == ANTENNA_SW_DIVERSITY);
if (rt2x00dev->curr_band == NL80211_BAND_5GHZ) {
sel = antenna_sel_a;
lna = rt2x00_has_cap_external_lna_a(rt2x00dev);
} else {
sel = antenna_sel_bg;
lna = rt2x00_has_cap_external_lna_bg(rt2x00dev);
}
for (i = 0; i < ARRAY_SIZE(antenna_sel_a); i++)
rt73usb_bbp_write(rt2x00dev, sel[i].word, sel[i].value[lna]);
reg = rt2x00usb_register_read(rt2x00dev, PHY_CSR0);
rt2x00_set_field32(®, PHY_CSR0_PA_PE_BG,
(rt2x00dev->curr_band == NL80211_BAND_2GHZ));
rt2x00_set_field32(®, PHY_CSR0_PA_PE_A,
(rt2x00dev->curr_band == NL80211_BAND_5GHZ));
rt2x00usb_register_write(rt2x00dev, PHY_CSR0, reg);
if (rt2x00_rf(rt2x00dev, RF5226) || rt2x00_rf(rt2x00dev, RF5225))
rt73usb_config_antenna_5x(rt2x00dev, ant);
else if (rt2x00_rf(rt2x00dev, RF2528) || rt2x00_rf(rt2x00dev, RF2527))
rt73usb_config_antenna_2x(rt2x00dev, ant);
}
static void rt73usb_config_lna_gain(struct rt2x00_dev *rt2x00dev,
struct rt2x00lib_conf *libconf)
{
u16 eeprom;
short lna_gain = 0;
if (libconf->conf->chandef.chan->band == NL80211_BAND_2GHZ) {
if (rt2x00_has_cap_external_lna_bg(rt2x00dev))
lna_gain += 14;
eeprom = rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_BG);
lna_gain -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_BG_1);
} else {
eeprom = rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_A);
lna_gain -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_A_1);
}
rt2x00dev->lna_gain = lna_gain;
Annotation
- Immediate include surface: `linux/crc-itu-t.h`, `linux/delay.h`, `linux/etherdevice.h`, `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/usb.h`, `rt2x00.h`.
- Detected declarations: `struct antenna_sel`, `function rt73usb_bbp_write`, `function rt73usb_bbp_read`, `function rt73usb_rf_write`, `function rt73usb_rfkill_poll`, `function rt73usb_brightness_set`, `function rt73usb_blink_set`, `function rt73usb_init_led`, `function rt73usb_config_shared_key`, `function rt73usb_config_pairwise_key`.
- 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.
- 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.