drivers/net/wireless/ath/ath12k/mhi.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/ath/ath12k/mhi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/ath/ath12k/mhi.c- Extension
.c- Size
- 13468 bytes
- Lines
- 530
- 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 user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/msi.hlinux/pci.hlinux/firmware.hcore.hdebug.hmhi.hpci.h
Detected Declarations
function Copyrightfunction ath12k_mhi_reset_txvecdbfunction ath12k_mhi_reset_txvecstatusfunction ath12k_mhi_reset_rxvecdbfunction ath12k_mhi_reset_rxvecstatusfunction ath12k_mhi_clear_vectorfunction ath12k_mhi_get_msifunction ath12k_mhi_op_runtime_getfunction ath12k_mhi_op_runtime_putfunction ath12k_mhi_op_status_cbfunction ath12k_mhi_op_read_regfunction ath12k_mhi_op_write_regfunction ath12k_mhi_registerfunction ath12k_mhi_unregisterfunction ath12k_mhi_set_state_bitfunction ath12k_mhi_check_state_bitfunction ath12k_mhi_set_statefunction ath12k_mhi_startfunction ath12k_mhi_stopfunction ath12k_mhi_suspendfunction ath12k_mhi_resumefunction ath12k_mhi_coredump
Annotated Snippet
if (ab_pci->mhi_pre_cb == MHI_CB_EE_RDDM) {
ath12k_dbg(ab, ATH12K_DBG_BOOT,
"do not queue again for consecutive RDDM event\n");
break;
}
if (!(test_bit(ATH12K_FLAG_UNREGISTERING, &ab->dev_flags))) {
set_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags);
set_bit(ATH12K_FLAG_RECOVERY, &ab->dev_flags);
queue_work(ab->workqueue_aux, &ab->reset_work);
}
break;
default:
break;
}
ab_pci->mhi_pre_cb = cb;
}
static int ath12k_mhi_op_read_reg(struct mhi_controller *mhi_cntrl,
void __iomem *addr,
u32 *out)
{
*out = readl(addr);
return 0;
}
static void ath12k_mhi_op_write_reg(struct mhi_controller *mhi_cntrl,
void __iomem *addr,
u32 val)
{
writel(val, addr);
}
int ath12k_mhi_register(struct ath12k_pci *ab_pci)
{
struct ath12k_base *ab = ab_pci->ab;
struct mhi_controller *mhi_ctrl;
unsigned int board_id;
int ret;
bool dualmac = false;
mhi_ctrl = mhi_alloc_controller();
if (!mhi_ctrl)
return -ENOMEM;
ab_pci->mhi_pre_cb = MHI_CB_INVALID;
ab_pci->mhi_ctrl = mhi_ctrl;
mhi_ctrl->cntrl_dev = ab->dev;
mhi_ctrl->regs = ab->mem;
mhi_ctrl->reg_len = ab->mem_len;
mhi_ctrl->rddm_size = ab->hw_params->rddm_size;
if (ab->hw_params->otp_board_id_register) {
board_id =
ath12k_pci_read32(ab, ab->hw_params->otp_board_id_register);
board_id = u32_get_bits(board_id, OTP_BOARD_ID_MASK);
if (!board_id || (board_id == OTP_INVALID_BOARD_ID)) {
ath12k_dbg(ab, ATH12K_DBG_BOOT,
"failed to read board id\n");
} else if (board_id & OTP_VALID_DUALMAC_BOARD_ID_MASK) {
dualmac = true;
ath12k_dbg(ab, ATH12K_DBG_BOOT,
"dualmac fw selected for board id: %x\n", board_id);
}
}
if (dualmac) {
if (ab->fw.amss_dualmac_data && ab->fw.amss_dualmac_len > 0) {
/* use MHI firmware file from firmware-N.bin */
mhi_ctrl->fw_data = ab->fw.amss_dualmac_data;
mhi_ctrl->fw_sz = ab->fw.amss_dualmac_len;
} else {
ath12k_warn(ab, "dualmac firmware IE not present in firmware-N.bin\n");
ret = -ENOENT;
goto free_controller;
}
} else {
if (ab->fw.amss_data && ab->fw.amss_len > 0) {
/* use MHI firmware file from firmware-N.bin */
mhi_ctrl->fw_data = ab->fw.amss_data;
mhi_ctrl->fw_sz = ab->fw.amss_len;
} else {
/* use the old separate mhi.bin MHI firmware file */
ath12k_core_create_firmware_path(ab, ATH12K_AMSS_FILE,
ab_pci->amss_path,
sizeof(ab_pci->amss_path));
mhi_ctrl->fw_image = ab_pci->amss_path;
Annotation
- Immediate include surface: `linux/msi.h`, `linux/pci.h`, `linux/firmware.h`, `core.h`, `debug.h`, `mhi.h`, `pci.h`.
- Detected declarations: `function Copyright`, `function ath12k_mhi_reset_txvecdb`, `function ath12k_mhi_reset_txvecstatus`, `function ath12k_mhi_reset_rxvecdb`, `function ath12k_mhi_reset_rxvecstatus`, `function ath12k_mhi_clear_vector`, `function ath12k_mhi_get_msi`, `function ath12k_mhi_op_runtime_get`, `function ath12k_mhi_op_runtime_put`, `function ath12k_mhi_op_status_cb`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.