drivers/usb/gadget/udc/r8a66597-udc.c
Source file repositories/reference/linux-study-clean/drivers/usb/gadget/udc/r8a66597-udc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/gadget/udc/r8a66597-udc.c- Extension
.c- Size
- 49388 bytes
- Lines
- 1980
- 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/interrupt.hlinux/delay.hlinux/io.hlinux/platform_device.hlinux/clk.hlinux/err.hlinux/slab.hlinux/dma-mapping.hlinux/usb/ch9.hlinux/usb/gadget.hr8a66597-udc.h
Detected Declarations
function get_usb_speedfunction enable_pipe_irqfunction disable_pipe_irqfunction r8a66597_usb_connectfunction r8a66597_usb_disconnectfunction control_reg_get_pidfunction control_reg_set_pidfunction pipe_startfunction pipe_stopfunction pipe_stallfunction control_reg_getfunction control_reg_sqclrfunction control_reg_sqsetfunction control_reg_sqmonfunction save_usb_togglefunction restore_usb_togglefunction get_buffer_sizefunction mbw_valuefunction r8a66597_change_curpipefunction pipe_changefunction pipe_buffer_settingfunction pipe_buffer_releasefunction pipe_initializefunction r8a66597_ep_settingfunction r8a66597_ep_releasefunction alloc_pipe_configfunction free_pipe_configfunction pipe_irq_enablefunction pipe_irq_disablefunction control_endfunction start_ep0_writefunction disable_fifoselfunction change_bfre_modefunction sudmac_alloc_channelfunction sudmac_free_channelfunction sudmac_startfunction start_packet_writefunction start_packet_readfunction start_packetfunction start_ep0function init_controllerfunction disable_controllerfunction r8a66597_start_xclockfunction transfer_completefunction irq_ep0_writefunction irq_packet_writefunction irq_packet_readfunction irq_pipe_ready
Annotated Snippet
if ((tmp & R8A66597_CNTMD) != 0) {
tmp = r8a66597_read(r8a66597, PIPEBUF);
size = ((tmp >> 10) + 1) * 64;
} else {
tmp = r8a66597_read(r8a66597, PIPEMAXP);
size = tmp & MXPS;
}
}
return size;
}
static inline unsigned short mbw_value(struct r8a66597 *r8a66597)
{
if (r8a66597->pdata->on_chip)
return MBW_32;
else
return MBW_16;
}
static void r8a66597_change_curpipe(struct r8a66597 *r8a66597, u16 pipenum,
u16 isel, u16 fifosel)
{
u16 tmp, mask, loop;
int i = 0;
if (!pipenum) {
mask = ISEL | CURPIPE;
loop = isel;
} else {
mask = CURPIPE;
loop = pipenum;
}
r8a66597_mdfy(r8a66597, loop, mask, fifosel);
do {
tmp = r8a66597_read(r8a66597, fifosel);
if (i++ > 1000000) {
dev_err(r8a66597_to_dev(r8a66597),
"r8a66597: register%x, loop %x "
"is timeout\n", fifosel, loop);
break;
}
ndelay(1);
} while ((tmp & mask) != loop);
}
static void pipe_change(struct r8a66597 *r8a66597, u16 pipenum)
{
struct r8a66597_ep *ep = r8a66597->pipenum2ep[pipenum];
if (ep->use_dma)
r8a66597_bclr(r8a66597, DREQE, ep->fifosel);
r8a66597_mdfy(r8a66597, pipenum, CURPIPE, ep->fifosel);
ndelay(450);
if (r8a66597_is_sudmac(r8a66597) && ep->use_dma)
r8a66597_bclr(r8a66597, mbw_value(r8a66597), ep->fifosel);
else
r8a66597_bset(r8a66597, mbw_value(r8a66597), ep->fifosel);
if (ep->use_dma)
r8a66597_bset(r8a66597, DREQE, ep->fifosel);
}
static int pipe_buffer_setting(struct r8a66597 *r8a66597,
struct r8a66597_pipe_info *info)
{
u16 bufnum = 0, buf_bsize = 0;
u16 pipecfg = 0;
if (info->pipe == 0)
return -EINVAL;
r8a66597_write(r8a66597, info->pipe, PIPESEL);
if (info->dir_in)
pipecfg |= R8A66597_DIR;
pipecfg |= info->type;
pipecfg |= info->epnum;
switch (info->type) {
case R8A66597_INT:
bufnum = 4 + (info->pipe - R8A66597_BASE_PIPENUM_INT);
buf_bsize = 0;
break;
case R8A66597_BULK:
/* isochronous pipes may be used as bulk pipes */
if (info->pipe >= R8A66597_BASE_PIPENUM_BULK)
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/io.h`, `linux/platform_device.h`, `linux/clk.h`, `linux/err.h`, `linux/slab.h`.
- Detected declarations: `function get_usb_speed`, `function enable_pipe_irq`, `function disable_pipe_irq`, `function r8a66597_usb_connect`, `function r8a66597_usb_disconnect`, `function control_reg_get_pid`, `function control_reg_set_pid`, `function pipe_start`, `function pipe_stop`, `function pipe_stall`.
- 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.