drivers/bus/fsl-mc/fsl-mc-msi.c

Source file repositories/reference/linux-study-clean/drivers/bus/fsl-mc/fsl-mc-msi.c

File Facts

System
Linux kernel
Corpus path
drivers/bus/fsl-mc/fsl-mc-msi.c
Extension
.c
Size
3197 bytes
Lines
118
Domain
Driver Families
Bucket
drivers/bus
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 (error < 0) {
			dev_err(&owner_mc_dev->dev,
				"dprc_set_irq() failed: %d\n", error);
		}
	} else {
		/*
		 * IRQ is for for a child device of mc_bus_dev
		 */
		error = dprc_set_obj_irq(mc_bus_dev->mc_io,
					 MC_CMD_FLAG_INTR_DIS | MC_CMD_FLAG_PRI,
					 mc_bus_dev->mc_handle,
					 owner_mc_dev->obj_desc.type,
					 owner_mc_dev->obj_desc.id,
					 mc_dev_irq->dev_irq_index,
					 &irq_cfg);
		if (error < 0) {
			dev_err(&owner_mc_dev->dev,
				"dprc_obj_set_irq() failed: %d\n", error);
		}
	}
}

struct irq_domain *fsl_mc_get_msi_parent(struct device *dev)
{
	struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
	struct device *root_dprc_dev;
	struct device *bus_dev;

	fsl_mc_get_root_dprc(dev, &root_dprc_dev);
	bus_dev = root_dprc_dev->parent;

	return (bus_dev->of_node ?
		of_msi_get_domain(bus_dev, bus_dev->of_node, DOMAIN_BUS_NEXUS) :
		iort_get_device_domain(bus_dev, mc_dev->icid, DOMAIN_BUS_NEXUS));
}

int fsl_mc_msi_domain_alloc_irqs(struct device *dev,  unsigned int irq_count)
{
	int error = msi_setup_device_data(dev);
	if (error)
		return error;

	error = platform_device_msi_init_and_alloc_irqs(dev, irq_count, fsl_mc_write_msi_msg);
	if (error)
		dev_err(dev, "Failed to allocate IRQs\n");
	return error;
}

void fsl_mc_msi_domain_free_irqs(struct device *dev)
{
	msi_domain_free_irqs_all(dev, MSI_DEFAULT_DOMAIN);
}

u32 fsl_mc_get_msi_id(struct device *dev)
{
	struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
	struct device *root_dprc_dev;

	fsl_mc_get_root_dprc(dev, &root_dprc_dev);

	return (root_dprc_dev->parent->of_node ?
		of_msi_xlate(dev, NULL, mc_dev->icid) :
		iort_msi_map_id(dev, mc_dev->icid));
}

Annotation

Implementation Notes