drivers/dma/ti/dma-crossbar.c
Source file repositories/reference/linux-study-clean/drivers/dma/ti/dma-crossbar.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/ti/dma-crossbar.c- Extension
.c- Size
- 11873 bytes
- Lines
- 484
- Domain
- Driver Families
- Bucket
- drivers/dma
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/platform_device.hlinux/slab.hlinux/err.hlinux/init.hlinux/list.hlinux/io.hlinux/of.hlinux/of_dma.hlinux/of_platform.h
Detected Declarations
struct ti_am335x_xbar_datastruct ti_am335x_xbar_mapstruct ti_dra7_xbar_datastruct ti_dra7_xbar_mapfunction ti_am335x_xbar_writefunction ti_am335x_xbar_freefunction ti_am335x_xbar_probefunction ti_dra7_xbar_writefunction ti_dra7_xbar_freefunction ti_dra7_xbar_reservefunction ti_dra7_xbar_probefunction ti_dma_xbar_probefunction omap_dmaxbar_init
Annotated Snippet
struct ti_am335x_xbar_data {
void __iomem *iomem;
struct dma_router dmarouter;
u32 xbar_events; /* maximum number of events to select in xbar */
u32 dma_requests; /* number of DMA requests on eDMA */
};
struct ti_am335x_xbar_map {
u16 dma_line;
u8 mux_val;
};
static inline void ti_am335x_xbar_write(void __iomem *iomem, int event, u8 val)
{
/*
* TPCC_EVT_MUX_60_63 register layout is different than the
* rest, in the sense, that event 63 is mapped to lowest byte
* and event 60 is mapped to highest, handle it separately.
*/
if (event >= 60 && event <= 63)
writeb_relaxed(val, iomem + (63 - event % 4));
else
writeb_relaxed(val, iomem + event);
}
static void ti_am335x_xbar_free(struct device *dev, void *route_data)
{
struct ti_am335x_xbar_data *xbar = dev_get_drvdata(dev);
struct ti_am335x_xbar_map *map = route_data;
dev_dbg(dev, "Unmapping XBAR event %u on channel %u\n",
map->mux_val, map->dma_line);
ti_am335x_xbar_write(xbar->iomem, map->dma_line, 0);
kfree(map);
}
static void *ti_am335x_xbar_route_allocate(struct of_phandle_args *dma_spec,
struct of_dma *ofdma)
{
struct platform_device *pdev = of_find_device_by_node(ofdma->of_node);
struct ti_am335x_xbar_data *xbar = platform_get_drvdata(pdev);
struct ti_am335x_xbar_map *map = ERR_PTR(-EINVAL);
if (dma_spec->args_count != 3)
goto out_put_pdev;
if (dma_spec->args[2] >= xbar->xbar_events) {
dev_err(&pdev->dev, "Invalid XBAR event number: %d\n",
dma_spec->args[2]);
goto out_put_pdev;
}
if (dma_spec->args[0] >= xbar->dma_requests) {
dev_err(&pdev->dev, "Invalid DMA request line number: %d\n",
dma_spec->args[0]);
goto out_put_pdev;
}
/* The of_node_put() will be done in the core for the node */
dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
if (!dma_spec->np) {
dev_err(&pdev->dev, "Can't get DMA master\n");
goto out_put_pdev;
}
map = kzalloc_obj(*map);
if (!map) {
of_node_put(dma_spec->np);
map = ERR_PTR(-ENOMEM);
goto out_put_pdev;
}
map->dma_line = (u16)dma_spec->args[0];
map->mux_val = (u8)dma_spec->args[2];
dma_spec->args[2] = 0;
dma_spec->args_count = 2;
dev_dbg(&pdev->dev, "Mapping XBAR event%u to DMA%u\n",
map->mux_val, map->dma_line);
ti_am335x_xbar_write(xbar->iomem, map->dma_line, map->mux_val);
out_put_pdev:
put_device(&pdev->dev);
return map;
Annotation
- Immediate include surface: `linux/platform_device.h`, `linux/slab.h`, `linux/err.h`, `linux/init.h`, `linux/list.h`, `linux/io.h`, `linux/of.h`, `linux/of_dma.h`.
- Detected declarations: `struct ti_am335x_xbar_data`, `struct ti_am335x_xbar_map`, `struct ti_dra7_xbar_data`, `struct ti_dra7_xbar_map`, `function ti_am335x_xbar_write`, `function ti_am335x_xbar_free`, `function ti_am335x_xbar_probe`, `function ti_dra7_xbar_write`, `function ti_dra7_xbar_free`, `function ti_dra7_xbar_reserve`.
- Atlas domain: Driver Families / drivers/dma.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.