drivers/usb/fotg210/fotg210-udc.c
Source file repositories/reference/linux-study-clean/drivers/usb/fotg210/fotg210-udc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/fotg210/fotg210-udc.c- Extension
.c- Size
- 32484 bytes
- Lines
- 1307
- 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/delay.hlinux/dma-mapping.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/platform_device.hlinux/usb/ch9.hlinux/usb/gadget.hlinux/usb/otg.hlinux/usb/phy.hfotg210.hfotg210-udc.h
Detected Declarations
function fotg210_ack_intfunction fotg210_disable_fifo_intfunction fotg210_enable_fifo_intfunction fotg210_set_cxdonefunction fotg210_donefunction fotg210_fifo_ep_mappingfunction fotg210_set_fifo_dirfunction fotg210_set_tfrtypefunction fotg210_set_mpsfunction fotg210_config_epfunction fotg210_ep_enablefunction fotg210_reset_tseqfunction fotg210_ep_releasefunction fotg210_ep_disablefunction fotg210_ep_free_requestfunction fotg210_enable_dmafunction fotg210_disable_dmafunction fotg210_wait_dma_donefunction fotg210_start_dmafunction fotg210_ep0_queuefunction fotg210_ep_queuefunction fotg210_ep_dequeuefunction fotg210_set_epnstallfunction fotg210_clear_epnstallfunction fotg210_set_halt_and_wedgefunction fotg210_ep_set_haltfunction fotg210_ep_set_wedgefunction fotg210_ep_fifo_flushfunction fotg210_clear_tx0bytefunction fotg210_clear_rx0bytefunction fotg210_rdsetuppfunction fotg210_set_configurationfunction fotg210_set_dev_addrfunction fotg210_set_cxstallfunction fotg210_request_errorfunction fotg210_set_addressfunction fotg210_set_featurefunction fotg210_clear_featurefunction fotg210_is_epnstallfunction fotg210_ep0_completefunction fotg210_get_statusfunction fotg210_setup_packetfunction fotg210_ep0outfunction fotg210_ep0infunction fotg210_in_fifo_handlerfunction fotg210_out_fifo_handlerfunction fotg210_irqfunction fotg210_disable_unplug
Annotated Snippet
if (ep->dir_in) {
buffer = req->req.buf;
length = req->req.length;
} else {
buffer = req->req.buf + req->req.actual;
length = ioread32(ep->fotg210->reg +
FOTG210_FIBCR(ep->epnum - 1)) & FIBCR_BCFX;
if (length > req->req.length - req->req.actual)
length = req->req.length - req->req.actual;
}
} else {
buffer = req->req.buf + req->req.actual;
if (req->req.length - req->req.actual > ep->ep.maxpacket)
length = ep->ep.maxpacket;
else
length = req->req.length - req->req.actual;
}
d = dma_map_single(dev, buffer, length,
ep->dir_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
if (dma_mapping_error(dev, d)) {
pr_err("dma_mapping_error\n");
return;
}
fotg210_enable_dma(ep, d, length);
/* check if dma is done */
fotg210_wait_dma_done(ep);
fotg210_disable_dma(ep);
/* update actual transfer length */
req->req.actual += length;
dma_unmap_single(dev, d, length, DMA_TO_DEVICE);
}
static void fotg210_ep0_queue(struct fotg210_ep *ep,
struct fotg210_request *req)
{
if (!req->req.length) {
fotg210_done(ep, req, 0);
return;
}
if (ep->dir_in) { /* if IN */
fotg210_start_dma(ep, req);
if (req->req.length == req->req.actual)
fotg210_done(ep, req, 0);
} else { /* OUT */
u32 value = ioread32(ep->fotg210->reg + FOTG210_DMISGR0);
value &= ~DMISGR0_MCX_OUT_INT;
iowrite32(value, ep->fotg210->reg + FOTG210_DMISGR0);
}
}
static int fotg210_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
gfp_t gfp_flags)
{
struct fotg210_ep *ep;
struct fotg210_request *req;
unsigned long flags;
int request = 0;
ep = container_of(_ep, struct fotg210_ep, ep);
req = container_of(_req, struct fotg210_request, req);
if (ep->fotg210->gadget.speed == USB_SPEED_UNKNOWN)
return -ESHUTDOWN;
spin_lock_irqsave(&ep->fotg210->lock, flags);
if (list_empty(&ep->queue))
request = 1;
list_add_tail(&req->queue, &ep->queue);
req->req.actual = 0;
req->req.status = -EINPROGRESS;
if (!ep->epnum) /* ep0 */
fotg210_ep0_queue(ep, req);
else if (request && !ep->stall)
fotg210_enable_fifo_int(ep);
spin_unlock_irqrestore(&ep->fotg210->lock, flags);
return 0;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/platform_device.h`, `linux/usb/ch9.h`.
- Detected declarations: `function fotg210_ack_int`, `function fotg210_disable_fifo_int`, `function fotg210_enable_fifo_int`, `function fotg210_set_cxdone`, `function fotg210_done`, `function fotg210_fifo_ep_mapping`, `function fotg210_set_fifo_dir`, `function fotg210_set_tfrtype`, `function fotg210_set_mps`, `function fotg210_config_ep`.
- 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.