drivers/net/wireless/ath/ath11k/mhi.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/ath/ath11k/mhi.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/ath/ath11k/mhi.c
Extension
.c
Size
11725 bytes
Lines
505
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (ab_pci->mhi_pre_cb == MHI_CB_EE_RDDM) {
			ath11k_dbg(ab, ATH11K_DBG_BOOT,
				   "do not queue again for consecutive RDDM event\n");
			break;
		}

		spin_lock_bh(&ab->base_lock);
		if (!(test_bit(ATH11K_FLAG_UNREGISTERING, &ab->dev_flags)))
			queue_work(ab->workqueue_aux, &ab->reset_work);
		spin_unlock_bh(&ab->base_lock);

		break;
	default:
		break;
	}

	ab_pci->mhi_pre_cb = cb;
}

static int ath11k_mhi_op_read_reg(struct mhi_controller *mhi_cntrl,
				  void __iomem *addr,
				  u32 *out)
{
	*out = readl(addr);

	return 0;
}

static void ath11k_mhi_op_write_reg(struct mhi_controller *mhi_cntrl,
				    void __iomem *addr,
				    u32 val)
{
	writel(val, addr);
}

static int ath11k_mhi_read_addr_from_dt(struct mhi_controller *mhi_ctrl)
{
	struct device_node *np;
	struct resource res;
	int ret;

	np = of_find_node_by_type(NULL, "memory");
	if (!np)
		return -ENOENT;

	ret = of_address_to_resource(np, 0, &res);
	of_node_put(np);
	if (ret)
		return ret;

	mhi_ctrl->iova_start = res.start + 0x1000000;
	mhi_ctrl->iova_stop = res.end;

	return 0;
}

int ath11k_mhi_register(struct ath11k_pci *ab_pci)
{
	struct ath11k_base *ab = ab_pci->ab;
	struct mhi_controller *mhi_ctrl;
	const struct mhi_controller_config *ath11k_mhi_config;
	int ret;

	mhi_ctrl = mhi_alloc_controller();
	if (!mhi_ctrl)
		return -ENOMEM;

	ab_pci->mhi_ctrl = mhi_ctrl;
	mhi_ctrl->cntrl_dev = ab->dev;
	mhi_ctrl->regs = ab->mem;
	mhi_ctrl->reg_len = ab->mem_len;

	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 */
		ath11k_core_create_firmware_path(ab, ATH11K_AMSS_FILE,
						 ab_pci->amss_path,
						 sizeof(ab_pci->amss_path));
		mhi_ctrl->fw_image = ab_pci->amss_path;
	}

	ret = ath11k_mhi_get_msi(ab_pci);
	if (ret) {
		ath11k_err(ab, "failed to get msi for mhi\n");
		goto free_controller;
	}

Annotation

Implementation Notes