arch/powerpc/platforms/pseries/ibmebus.c

Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/pseries/ibmebus.c

File Facts

System
Linux kernel
Corpus path
arch/powerpc/platforms/pseries/ibmebus.c
Extension
.c
Size
11513 bytes
Lines
482
Domain
Architecture Layer
Bucket
arch/powerpc
Inferred role
Architecture Layer: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

const struct bus_type ibmebus_bus_type;

/* These devices will automatically be added to the bus during init */
static const struct of_device_id ibmebus_matches[] __initconst = {
	{ .compatible = "IBM,lhca" },
	{ .compatible = "IBM,lhea" },
	{},
};

static void *ibmebus_alloc_coherent(struct device *dev,
				    size_t size,
				    dma_addr_t *dma_handle,
				    gfp_t flag,
				    unsigned long attrs)
{
	void *mem;

	mem = kmalloc(size, flag);
	*dma_handle = (dma_addr_t)mem;

	return mem;
}

static void ibmebus_free_coherent(struct device *dev,
				  size_t size, void *vaddr,
				  dma_addr_t dma_handle,
				  unsigned long attrs)
{
	kfree(vaddr);
}

static dma_addr_t ibmebus_map_phys(struct device *dev, phys_addr_t phys,
				   size_t size,
				   enum dma_data_direction direction,
				   unsigned long attrs)
{
	if (attrs & DMA_ATTR_MMIO)
		return DMA_MAPPING_ERROR;

	return (dma_addr_t)(phys_to_virt(phys));
}

static void ibmebus_unmap_phys(struct device *dev,
			       dma_addr_t dma_addr,
			       size_t size,
			       enum dma_data_direction direction,
			       unsigned long attrs)
{
	return;
}

static int ibmebus_map_sg(struct device *dev,
			  struct scatterlist *sgl,
			  int nents, enum dma_data_direction direction,
			  unsigned long attrs)
{
	struct scatterlist *sg;
	int i;

	for_each_sg(sgl, sg, nents, i) {
		sg->dma_address = (dma_addr_t) sg_virt(sg);
		sg->dma_length = sg->length;
	}

	return nents;
}

static void ibmebus_unmap_sg(struct device *dev,
			     struct scatterlist *sg,
			     int nents, enum dma_data_direction direction,
			     unsigned long attrs)
{
	return;
}

static int ibmebus_dma_supported(struct device *dev, u64 mask)
{
	return mask == DMA_BIT_MASK(64);
}

static u64 ibmebus_dma_get_required_mask(struct device *dev)
{
	return DMA_BIT_MASK(64);
}

static const struct dma_map_ops ibmebus_dma_ops = {
	.alloc              = ibmebus_alloc_coherent,
	.free               = ibmebus_free_coherent,
	.map_sg             = ibmebus_map_sg,
	.unmap_sg           = ibmebus_unmap_sg,

Annotation

Implementation Notes