drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c- Extension
.c- Size
- 64202 bytes
- Lines
- 2614
- 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/firmware.hmt7615.hmcu.hmac.heeprom.h
Detected Declarations
struct mt7615_patch_hdrstruct mt7615_fw_trailerstruct mt7663_fw_bufstruct req_hdrstruct req_tlvstruct reqstruct req_hdrstruct bcn_content_tlvstruct req_datastruct dbdc_entryfunction mt7615_mcu_fill_msgfunction mt7615_mcu_parse_responsefunction mt7615_mcu_send_messagefunction mt7615_rf_rrfunction mt7615_rf_wrfunction mt7622_trigger_hif_intfunction mt7615_mcu_drv_pmctrlfunction mt7615_mcu_lp_drv_pmctrlfunction mt7615_mcu_fw_pmctrlfunction mt7615_mcu_csa_finishfunction mt7615_mcu_rx_csa_notifyfunction mt7615_mcu_rx_radar_detectedfunction mt7615_mcu_rx_log_messagefunction mt7615_mcu_rx_ext_eventfunction mt7615_mcu_scan_eventfunction mt7615_mcu_roc_eventfunction mt7615_mcu_beacon_loss_eventfunction mt7615_mcu_bss_eventfunction mt7615_mcu_rx_unsolicited_eventfunction mt7615_mcu_rx_eventfunction mt7615_mcu_muar_configfunction mt7615_mcu_add_devfunction mt7615_mcu_add_beacon_offloadfunction mt7615_mcu_ctrl_pm_statefunction mt7615_mcu_add_bssfunction mt7615_mcu_wtbl_tx_bafunction mt7615_mcu_wtbl_rx_bafunction mt7615_mcu_wtbl_sta_addfunction mt7615_mcu_wtbl_update_hdr_transfunction mt7615_mcu_sta_bafunction mt7615_mcu_sta_tx_bafunction mt7615_mcu_sta_rx_bafunction __mt7615_mcu_add_stafunction mt7615_mcu_add_stafunction mt7615_mcu_sta_update_hdr_transfunction mt7615_mcu_uni_ctrl_pm_statefunction mt7615_mcu_uni_add_beacon_offloadfunction mt7615_mcu_uni_add_dev
Annotated Snippet
struct mt7615_patch_hdr {
char build_date[16];
char platform[4];
__be32 hw_sw_ver;
__be32 patch_ver;
__be16 checksum;
} __packed;
struct mt7615_fw_trailer {
__le32 addr;
u8 chip_id;
u8 feature_set;
u8 eco_code;
char fw_ver[10];
char build_date[15];
__le32 len;
} __packed;
#define FW_V3_COMMON_TAILER_SIZE 36
#define FW_V3_REGION_TAILER_SIZE 40
#define FW_START_OVERRIDE BIT(0)
#define FW_START_DLYCAL BIT(1)
#define FW_START_WORKING_PDA_CR4 BIT(2)
struct mt7663_fw_buf {
__le32 crc;
__le32 d_img_size;
__le32 block_size;
u8 rsv[4];
__le32 img_dest_addr;
__le32 img_size;
u8 feature_set;
};
#define MT7615_PATCH_ADDRESS 0x80000
#define MT7622_PATCH_ADDRESS 0x9c000
#define MT7663_PATCH_ADDRESS 0xdc000
#define N9_REGION_NUM 2
#define CR4_REGION_NUM 1
#define IMG_CRC_LEN 4
void mt7615_mcu_fill_msg(struct mt7615_dev *dev, struct sk_buff *skb,
int cmd, int *wait_seq)
{
int txd_len, mcu_cmd = FIELD_GET(__MCU_CMD_FIELD_ID, cmd);
struct mt7615_uni_txd *uni_txd;
struct mt7615_mcu_txd *mcu_txd;
u8 seq, q_idx, pkt_fmt;
__le32 *txd;
u32 val;
/* TODO: make dynamic based on msg type */
dev->mt76.mcu.timeout = 20 * HZ;
seq = ++dev->mt76.mcu.msg_seq & 0xf;
if (!seq)
seq = ++dev->mt76.mcu.msg_seq & 0xf;
if (wait_seq)
*wait_seq = seq;
txd_len = cmd & __MCU_CMD_FIELD_UNI ? sizeof(*uni_txd) : sizeof(*mcu_txd);
txd = (__le32 *)skb_push(skb, txd_len);
if (cmd != MCU_CMD(FW_SCATTER)) {
q_idx = MT_TX_MCU_PORT_RX_Q0;
pkt_fmt = MT_TX_TYPE_CMD;
} else {
q_idx = MT_TX_MCU_PORT_RX_FWDL;
pkt_fmt = MT_TX_TYPE_FW;
}
val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len) |
FIELD_PREP(MT_TXD0_P_IDX, MT_TX_PORT_IDX_MCU) |
FIELD_PREP(MT_TXD0_Q_IDX, q_idx);
txd[0] = cpu_to_le32(val);
val = MT_TXD1_LONG_FORMAT |
FIELD_PREP(MT_TXD1_HDR_FORMAT, MT_HDR_FORMAT_CMD) |
FIELD_PREP(MT_TXD1_PKT_FMT, pkt_fmt);
txd[1] = cpu_to_le32(val);
if (cmd & __MCU_CMD_FIELD_UNI) {
uni_txd = (struct mt7615_uni_txd *)txd;
uni_txd->len = cpu_to_le16(skb->len - sizeof(uni_txd->txd));
uni_txd->option = MCU_CMD_UNI_EXT_ACK;
uni_txd->cid = cpu_to_le16(mcu_cmd);
uni_txd->s2d_index = MCU_S2D_H2N;
uni_txd->pkt_type = MCU_PKT_ID;
Annotation
- Immediate include surface: `linux/firmware.h`, `mt7615.h`, `mcu.h`, `mac.h`, `eeprom.h`.
- Detected declarations: `struct mt7615_patch_hdr`, `struct mt7615_fw_trailer`, `struct mt7663_fw_buf`, `struct req_hdr`, `struct req_tlv`, `struct req`, `struct req_hdr`, `struct bcn_content_tlv`, `struct req_data`, `struct dbdc_entry`.
- 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.