drivers/soc/qcom/qcom_aoss.c

Source file repositories/reference/linux-study-clean/drivers/soc/qcom/qcom_aoss.c

File Facts

System
Linux kernel
Corpus path
drivers/soc/qcom/qcom_aoss.c
Extension
.c
Size
16085 bytes
Lines
674
Domain
Driver Families
Bucket
drivers/soc
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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

static const struct file_operations qmp_debugfs_fops = {
	.open = simple_open,
	.write = qmp_debugfs_write,
};

static void qmp_debugfs_create(struct qmp *qmp)
{
	const struct qmp_debugfs_entry *entry;
	int i;

	qmp->debugfs_root = debugfs_create_dir("qcom_aoss", NULL);

	for (i = 0; i < ARRAY_SIZE(qmp->debugfs_files); i++) {
		entry = &qmp_debugfs_entries[i];

		qmp->debugfs_files[i] = debugfs_create_file(entry->name, 0200,
							    qmp->debugfs_root,
							    qmp,
							    &qmp_debugfs_fops);
	}
}

static int qmp_probe(struct platform_device *pdev)
{
	struct qmp *qmp;
	int irq;
	int ret;

	qmp = devm_kzalloc(&pdev->dev, sizeof(*qmp), GFP_KERNEL);
	if (!qmp)
		return -ENOMEM;

	qmp->dev = &pdev->dev;
	init_waitqueue_head(&qmp->event);
	mutex_init(&qmp->tx_lock);

	qmp->msgram = devm_platform_ioremap_resource(pdev, 0);
	if (IS_ERR(qmp->msgram))
		return PTR_ERR(qmp->msgram);

	qmp->mbox_client.dev = &pdev->dev;
	qmp->mbox_client.knows_txdone = true;
	qmp->mbox_chan = mbox_request_channel(&qmp->mbox_client, 0);
	if (IS_ERR(qmp->mbox_chan)) {
		dev_err(&pdev->dev, "failed to acquire ipc mailbox\n");
		return PTR_ERR(qmp->mbox_chan);
	}

	irq = platform_get_irq(pdev, 0);
	ret = devm_request_irq(&pdev->dev, irq, qmp_intr, 0,
			       "aoss-qmp", qmp);
	if (ret < 0) {
		dev_err(&pdev->dev, "failed to request interrupt\n");
		goto err_free_mbox;
	}

	ret = qmp_open(qmp);
	if (ret < 0)
		goto err_free_mbox;

	ret = qmp_qdss_clk_add(qmp);
	if (ret)
		goto err_close_qmp;

	ret = qmp_cooling_devices_register(qmp);
	if (ret)
		dev_err(&pdev->dev, "failed to register aoss cooling devices\n");

	platform_set_drvdata(pdev, qmp);

	qmp_debugfs_create(qmp);

	return 0;

err_close_qmp:
	qmp_close(qmp);
err_free_mbox:
	mbox_free_channel(qmp->mbox_chan);

	return ret;
}

static void qmp_remove(struct platform_device *pdev)
{
	struct qmp *qmp = platform_get_drvdata(pdev);

	debugfs_remove_recursive(qmp->debugfs_root);

	qmp_qdss_clk_remove(qmp);
	qmp_cooling_devices_remove(qmp);

Annotation

Implementation Notes