drivers/usb/gadget/udc/omap_udc.c
Source file repositories/reference/linux-study-clean/drivers/usb/gadget/udc/omap_udc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/gadget/udc/omap_udc.c- Extension
.c- Size
- 77190 bytes
- Lines
- 2993
- Domain
- Driver Families
- Bucket
- drivers/usb
- 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/module.hlinux/kernel.hlinux/ioport.hlinux/types.hlinux/errno.hlinux/delay.hlinux/slab.hlinux/string_choices.hlinux/timer.hlinux/list.hlinux/interrupt.hlinux/proc_fs.hlinux/mm.hlinux/moduleparam.hlinux/platform_device.hlinux/usb/ch9.hlinux/usb/gadget.hlinux/usb/otg.hlinux/dma-mapping.hlinux/clk.hlinux/err.hlinux/prefetch.hlinux/io.hasm/byteorder.hasm/irq.hlinux/unaligned.hasm/mach-types.hlinux/omap-dma.hlinux/platform_data/usb-omap1.hlinux/soc/ti/omap1-usb.hlinux/soc/ti/omap1-soc.hlinux/soc/ti/omap1-io.h
Detected Declarations
function use_epfunction deselect_epfunction omap_ep_enablefunction omap_ep_disablefunction omap_alloc_requestfunction omap_free_requestfunction donefunction write_packetfunction write_fifofunction read_packetfunction read_fifofunction dma_src_lenfunction dma_dest_lenfunction next_in_dmafunction finish_in_dmafunction next_out_dmafunction finish_out_dmafunction dma_irqfunction dma_errorfunction dma_channel_claimfunction dma_channel_releasefunction omap_ep_queuefunction omap_ep_dequeuefunction omap_ep_set_haltfunction omap_get_framefunction omap_wakeupfunction omap_set_selfpoweredfunction can_pullupfunction pullup_enablefunction pullup_disablefunction omap_udc_enable_clockfunction omap_vbus_sessionfunction omap_vbus_drawfunction omap_pullupfunction nukefunction udc_quiescefunction update_otgfunction ep0_irqfunction devstate_irqfunction omap_udc_irqfunction pio_out_timerfunction omap_udc_pio_irqfunction omap_udc_iso_irqfunction machine_without_vbus_sensefunction omap_udc_startfunction omap_udc_stopfunction proc_ep_showfunction list_for_each_entry
Annotated Snippet
while (max >= 2) {
omap_writew(*wp++, UDC_DATA);
max -= 2;
}
buf = (u8 *)wp;
}
while (max--)
omap_writeb(*buf++, UDC_DATA);
return len;
}
/* FIXME change r/w fifo calling convention */
/* return: 0 = still running, 1 = completed, negative = errno */
static int write_fifo(struct omap_ep *ep, struct omap_req *req)
{
u8 *buf;
unsigned count;
int is_last;
u16 ep_stat;
buf = req->req.buf + req->req.actual;
prefetch(buf);
/* PIO-IN isn't double buffered except for iso */
ep_stat = omap_readw(UDC_STAT_FLG);
if (ep_stat & UDC_FIFO_UNWRITABLE)
return 0;
count = ep->ep.maxpacket;
count = write_packet(buf, req, count);
omap_writew(UDC_SET_FIFO_EN, UDC_CTRL);
ep->ackwait = 1;
/* last packet is often short (sometimes a zlp) */
if (count != ep->ep.maxpacket)
is_last = 1;
else if (req->req.length == req->req.actual
&& !req->req.zero)
is_last = 1;
else
is_last = 0;
/* NOTE: requests complete when all IN data is in a
* FIFO (or sometimes later, if a zlp was needed).
* Use usb_ep_fifo_status() where needed.
*/
if (is_last)
done(ep, req, 0);
return is_last;
}
static inline int
read_packet(u8 *buf, struct omap_req *req, unsigned avail)
{
unsigned len;
u16 *wp;
len = min(req->req.length - req->req.actual, avail);
req->req.actual += len;
avail = len;
if (likely((((int)buf) & 1) == 0)) {
wp = (u16 *)buf;
while (avail >= 2) {
*wp++ = omap_readw(UDC_DATA);
avail -= 2;
}
buf = (u8 *)wp;
}
while (avail--)
*buf++ = omap_readb(UDC_DATA);
return len;
}
/* return: 0 = still running, 1 = queue empty, negative = errno */
static int read_fifo(struct omap_ep *ep, struct omap_req *req)
{
u8 *buf;
unsigned count, avail;
int is_last;
buf = req->req.buf + req->req.actual;
prefetchw(buf);
for (;;) {
u16 ep_stat = omap_readw(UDC_STAT_FLG);
is_last = 0;
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/ioport.h`, `linux/types.h`, `linux/errno.h`, `linux/delay.h`, `linux/slab.h`, `linux/string_choices.h`.
- Detected declarations: `function use_ep`, `function deselect_ep`, `function omap_ep_enable`, `function omap_ep_disable`, `function omap_alloc_request`, `function omap_free_request`, `function done`, `function write_packet`, `function write_fifo`, `function read_packet`.
- Atlas domain: Driver Families / drivers/usb.
- 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.