drivers/dma/sh/usb-dmac.c
Source file repositories/reference/linux-study-clean/drivers/dma/sh/usb-dmac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma/sh/usb-dmac.c- Extension
.c- Size
- 23435 bytes
- Lines
- 908
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/delay.hlinux/dma-mapping.hlinux/dmaengine.hlinux/interrupt.hlinux/list.hlinux/module.hlinux/of.hlinux/of_dma.hlinux/of_platform.hlinux/platform_device.hlinux/pm_runtime.hlinux/slab.hlinux/spinlock.h../dmaengine.h../virt-dma.h
Detected Declarations
struct usb_dmac_sgstruct usb_dmac_descstruct usb_dmac_chanstruct usb_dmacfunction usb_dmac_writefunction usb_dmac_readfunction usb_dmac_chan_readfunction usb_dmac_chan_writefunction usb_dmac_chan_is_busyfunction usb_dmac_calc_tendfunction usb_dmac_chan_start_sgfunction usb_dmac_chan_start_descfunction usb_dmac_initfunction usb_dmac_desc_allocfunction usb_dmac_desc_freefunction list_for_each_entry_safefunction usb_dmac_desc_putfunction usb_dmac_soft_resetfunction usb_dmac_chan_haltfunction usb_dmac_stopfunction usb_dmac_alloc_chan_resourcesfunction usb_dmac_free_chan_resourcesfunction usb_dmac_prep_slave_sgfunction usb_dmac_chan_terminate_allfunction usb_dmac_get_current_residuefunction usb_dmac_chan_get_residue_if_completefunction list_for_each_entry_reversefunction usb_dmac_chan_get_residuefunction usb_dmac_tx_statusfunction usb_dmac_issue_pendingfunction usb_dmac_virt_desc_freefunction usb_dmac_isr_transfer_endfunction usb_dmac_isr_channelfunction usb_dmac_chan_filterfunction usb_dmac_runtime_suspendfunction usb_dmac_runtime_resumefunction usb_dmac_chan_probefunction usb_dmac_parse_offunction usb_dmac_probefunction usb_dmac_chan_removefunction usb_dmac_removefunction usb_dmac_shutdown
Annotated Snippet
struct usb_dmac_sg {
dma_addr_t mem_addr;
u32 size;
};
/*
* struct usb_dmac_desc - USB DMA Transfer Descriptor
* @vd: base virtual channel DMA transaction descriptor
* @direction: direction of the DMA transfer
* @sg_allocated_len: length of allocated sg
* @sg_len: length of sg
* @sg_index: index of sg
* @residue: residue after the DMAC completed a transfer
* @node: node for desc_got and desc_freed
* @done_cookie: cookie after the DMAC completed a transfer
* @sg: information for the transfer
*/
struct usb_dmac_desc {
struct virt_dma_desc vd;
enum dma_transfer_direction direction;
unsigned int sg_allocated_len;
unsigned int sg_len;
unsigned int sg_index;
u32 residue;
struct list_head node;
dma_cookie_t done_cookie;
struct usb_dmac_sg sg[] __counted_by(sg_allocated_len);
};
#define to_usb_dmac_desc(vd) container_of(vd, struct usb_dmac_desc, vd)
/*
* struct usb_dmac_chan - USB DMA Controller Channel
* @vc: base virtual DMA channel object
* @iomem: channel I/O memory base
* @index: index of this channel in the controller
* @irq: irq number of this channel
* @desc: the current descriptor
* @descs_allocated: number of descriptors allocated
* @desc_got: got descriptors
* @desc_freed: freed descriptors after the DMAC completed a transfer
*/
struct usb_dmac_chan {
struct virt_dma_chan vc;
void __iomem *iomem;
unsigned int index;
int irq;
struct usb_dmac_desc *desc;
int descs_allocated;
struct list_head desc_got;
struct list_head desc_freed;
};
#define to_usb_dmac_chan(c) container_of(c, struct usb_dmac_chan, vc.chan)
/*
* struct usb_dmac - USB DMA Controller
* @engine: base DMA engine object
* @dev: the hardware device
* @iomem: remapped I/O memory base
* @n_channels: number of available channels
* @channels: array of DMAC channels
*/
struct usb_dmac {
struct dma_device engine;
struct device *dev;
void __iomem *iomem;
unsigned int n_channels;
struct usb_dmac_chan *channels;
};
#define to_usb_dmac(d) container_of(d, struct usb_dmac, engine)
/* -----------------------------------------------------------------------------
* Registers
*/
#define USB_DMAC_CHAN_OFFSET(i) (0x20 + 0x20 * (i))
#define USB_DMASWR 0x0008
#define USB_DMASWR_SWR (1 << 0)
#define USB_DMAOR 0x0060
#define USB_DMAOR_AE (1 << 1)
#define USB_DMAOR_DME (1 << 0)
#define USB_DMASAR 0x0000
#define USB_DMADAR 0x0004
#define USB_DMATCR 0x0008
#define USB_DMATCR_MASK 0x00ffffff
Annotation
- Immediate include surface: `linux/delay.h`, `linux/dma-mapping.h`, `linux/dmaengine.h`, `linux/interrupt.h`, `linux/list.h`, `linux/module.h`, `linux/of.h`, `linux/of_dma.h`.
- Detected declarations: `struct usb_dmac_sg`, `struct usb_dmac_desc`, `struct usb_dmac_chan`, `struct usb_dmac`, `function usb_dmac_write`, `function usb_dmac_read`, `function usb_dmac_chan_read`, `function usb_dmac_chan_write`, `function usb_dmac_chan_is_busy`, `function usb_dmac_calc_tend`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.