drivers/usb/gadget/udc/lpc32xx_udc.c
Source file repositories/reference/linux-study-clean/drivers/usb/gadget/udc/lpc32xx_udc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/gadget/udc/lpc32xx_udc.c- Extension
.c- Size
- 83227 bytes
- Lines
- 3277
- 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/clk.hlinux/delay.hlinux/dma-mapping.hlinux/dmapool.hlinux/i2c.hlinux/interrupt.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/prefetch.hlinux/proc_fs.hlinux/slab.hlinux/usb/ch9.hlinux/usb/gadget.hlinux/usb/isp1301.hlinux/debugfs.hlinux/seq_file.h
Detected Declarations
struct lpc32xx_usbd_cfgstruct lpc32xx_usbd_dd_gadstruct lpc32xx_epstruct lpc32xx_udcstruct lpc32xx_requeststruct lpc32xx_usbd_ddenum atx_typefunction proc_ep_showfunction list_for_each_entryfunction udc_showfunction create_debug_filefunction remove_debug_filefunction create_debug_filefunction isp1301_pullup_setfunction pullup_workfunction isp1301_pullup_enablefunction isp1301_set_powerstatefunction power_workfunction udc_protocol_cmd_wfunction udc_protocol_cmd_data_wfunction udc_protocol_cmd_rfunction uda_enable_devintfunction uda_disable_devintfunction uda_clear_devintfunction uda_enable_hwepintfunction uda_disable_hwepintfunction uda_clear_hwepintfunction udc_ep_dma_enablefunction udc_ep_dma_disablefunction interruptfunction udc_unrealize_hwepfunction udc_selep_clrintfunction udc_disable_hwepfunction udc_stall_hwepfunction udc_clrstall_hwepfunction udc_select_hwepfunction udc_clr_buffer_hwepfunction udc_val_buffer_hwepfunction udc_clearep_getstsfunction udc_dd_freefunction udc_clk_setfunction udc_set_addressfunction udc_ep_in_req_dmafunction udc_ep_out_req_dmafunction udc_disablefunction udc_enablefunction uda_power_eventfunction uda_resm_susp_event
Annotated Snippet
struct lpc32xx_usbd_cfg {
int vbus_drv_pol; /* 0=active low drive for VBUS via ISP1301 */
usc_chg_event conn_chgb; /* Connection change event (optional) */
usc_chg_event susp_chgb; /* Suspend/resume event (optional) */
usc_chg_event rmwk_chgb; /* Enable/disable remote wakeup */
};
/*
* controller driver data structures
*/
/* 16 endpoints (not to be confused with 32 hardware endpoints) */
#define NUM_ENDPOINTS 16
/*
* IRQ indices make reading the code a little easier
*/
#define IRQ_USB_LP 0
#define IRQ_USB_HP 1
#define IRQ_USB_DEVDMA 2
#define IRQ_USB_ATX 3
#define EP_OUT 0 /* RX (from host) */
#define EP_IN 1 /* TX (to host) */
/* Returns the interrupt mask for the selected hardware endpoint */
#define EP_MASK_SEL(ep, dir) (1 << (((ep) * 2) + dir))
#define EP_INT_TYPE 0
#define EP_ISO_TYPE 1
#define EP_BLK_TYPE 2
#define EP_CTL_TYPE 3
/* EP0 states */
#define WAIT_FOR_SETUP 0 /* Wait for setup packet */
#define DATA_IN 1 /* Expect dev->host transfer */
#define DATA_OUT 2 /* Expect host->dev transfer */
/* DD (DMA Descriptor) structure, requires word alignment, this is already
* defined in the LPC32XX USB device header file, but this version is slightly
* modified to tag some work data with each DMA descriptor. */
struct lpc32xx_usbd_dd_gad {
u32 dd_next_phy;
u32 dd_setup;
u32 dd_buffer_addr;
u32 dd_status;
u32 dd_iso_ps_mem_addr;
u32 this_dma;
u32 iso_status[6]; /* 5 spare */
u32 dd_next_v;
};
/*
* Logical endpoint structure
*/
struct lpc32xx_ep {
struct usb_ep ep;
struct list_head queue;
struct lpc32xx_udc *udc;
u32 hwep_num_base; /* Physical hardware EP */
u32 hwep_num; /* Maps to hardware endpoint */
u32 maxpacket;
u32 lep;
bool is_in;
bool req_pending;
u32 eptype;
u32 totalints;
bool wedge;
};
enum atx_type {
ISP1301,
STOTG04,
};
/*
* Common UDC structure
*/
struct lpc32xx_udc {
struct usb_gadget gadget;
struct usb_gadget_driver *driver;
struct platform_device *pdev;
struct device *dev;
spinlock_t lock;
struct i2c_client *isp1301_i2c_client;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/dmapool.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct lpc32xx_usbd_cfg`, `struct lpc32xx_usbd_dd_gad`, `struct lpc32xx_ep`, `struct lpc32xx_udc`, `struct lpc32xx_request`, `struct lpc32xx_usbd_dd`, `enum atx_type`, `function proc_ep_show`, `function list_for_each_entry`, `function udc_show`.
- 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.