drivers/usb/musb/tusb6010_omap.c
Source file repositories/reference/linux-study-clean/drivers/usb/musb/tusb6010_omap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/musb/tusb6010_omap.c- Extension
.c- Size
- 16666 bytes
- Lines
- 643
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/module.hlinux/kernel.hlinux/errno.hlinux/usb.hlinux/platform_device.hlinux/dma-mapping.hlinux/slab.hlinux/dmaengine.hmusb_core.htusb6010.h
Detected Declarations
struct tusb_dma_datastruct tusb_omap_dma_chstruct tusb_omap_dmafunction tusb_omap_use_shared_dmareqfunction tusb_omap_free_shared_dmareqfunction tusb_omap_dma_cbfunction tusb_omap_dma_programfunction tusb_omap_dma_abortfunction tusb_omap_dma_allocate_dmareqfunction tusb_omap_dma_free_dmareqfunction tusb_omap_dma_allocatefunction tusb_omap_dma_releasefunction tusb_dma_controller_destroyfunction tusb_omap_allocate_dma_poolfunction tusb_dma_controller_createexport tusb_dma_controller_destroyexport tusb_dma_controller_create
Annotated Snippet
struct tusb_dma_data {
s8 dmareq;
struct dma_chan *chan;
};
struct tusb_omap_dma_ch {
struct musb *musb;
void __iomem *tbase;
unsigned long phys_offset;
int epnum;
u8 tx;
struct musb_hw_ep *hw_ep;
struct tusb_dma_data *dma_data;
struct tusb_omap_dma *tusb_dma;
dma_addr_t dma_addr;
u32 len;
u16 packet_sz;
u16 transfer_packet_sz;
u32 transfer_len;
u32 completed_len;
};
struct tusb_omap_dma {
struct dma_controller controller;
void __iomem *tbase;
struct tusb_dma_data dma_pool[MAX_DMAREQ];
unsigned multichannel:1;
};
/*
* Allocate dmareq0 to the current channel unless it's already taken
*/
static inline int tusb_omap_use_shared_dmareq(struct tusb_omap_dma_ch *chdat)
{
u32 reg = musb_readl(chdat->tbase, TUSB_DMA_EP_MAP);
if (reg != 0) {
dev_dbg(chdat->musb->controller, "ep%i dmareq0 is busy for ep%i\n",
chdat->epnum, reg & 0xf);
return -EAGAIN;
}
if (chdat->tx)
reg = (1 << 4) | chdat->epnum;
else
reg = chdat->epnum;
musb_writel(chdat->tbase, TUSB_DMA_EP_MAP, reg);
return 0;
}
static inline void tusb_omap_free_shared_dmareq(struct tusb_omap_dma_ch *chdat)
{
u32 reg = musb_readl(chdat->tbase, TUSB_DMA_EP_MAP);
if ((reg & 0xf) != chdat->epnum) {
printk(KERN_ERR "ep%i trying to release dmareq0 for ep%i\n",
chdat->epnum, reg & 0xf);
return;
}
musb_writel(chdat->tbase, TUSB_DMA_EP_MAP, 0);
}
/*
* See also musb_dma_completion in plat_uds.c and musb_g_[tx|rx]() in
* musb_gadget.c.
*/
static void tusb_omap_dma_cb(void *data)
{
struct dma_channel *channel = (struct dma_channel *)data;
struct tusb_omap_dma_ch *chdat = to_chdat(channel);
struct tusb_omap_dma *tusb_dma = chdat->tusb_dma;
struct musb *musb = chdat->musb;
struct device *dev = musb->controller;
struct musb_hw_ep *hw_ep = chdat->hw_ep;
void __iomem *ep_conf = hw_ep->conf;
void __iomem *mbase = musb->mregs;
unsigned long remaining, flags, pio;
spin_lock_irqsave(&musb->lock, flags);
dev_dbg(musb->controller, "ep%i %s dma callback\n",
chdat->epnum, chdat->tx ? "tx" : "rx");
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/errno.h`, `linux/usb.h`, `linux/platform_device.h`, `linux/dma-mapping.h`, `linux/slab.h`, `linux/dmaengine.h`.
- Detected declarations: `struct tusb_dma_data`, `struct tusb_omap_dma_ch`, `struct tusb_omap_dma`, `function tusb_omap_use_shared_dmareq`, `function tusb_omap_free_shared_dmareq`, `function tusb_omap_dma_cb`, `function tusb_omap_dma_program`, `function tusb_omap_dma_abort`, `function tusb_omap_dma_allocate_dmareq`, `function tusb_omap_dma_free_dmareq`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: integration 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.