STRUCT CDNS2_DEVICE(9)
Hi bestie π welcome to struct cdns2_device(9) from the Kernel API Manual. We're about to vibe-check a USB device struct together, and no cap, every member is getting its moment.
β¨ NAME β¨
struct cdns2_device β literally the struct that represents a USB device. Main character energy fr fr. π
πΈ SYNOPSIS πΈ
struct cdns2_device {
struct device *dev;
struct usb_gadget gadget;
struct usb_gadget_driver *gadget_driver;
spinlock_t lock;
int irq;
void __iomem *regs;
struct cdns2_usb_regs __iomem *usb_regs;
struct cdns2_ep0_regs __iomem *ep0_regs;
struct cdns2_epx_regs __iomem *epx_regs;
struct cdns2_interrupt_regs __iomem *interrupt_regs;
struct cdns2_adma_regs __iomem *adma_regs;
struct dma_pool *eps_dma_pool;
struct usb_ctrlrequest setup;
struct cdns2_request ep0_preq;
u8 ep0_stage;
void *zlp_buf;
u8 dev_address;
struct cdns2_endpoint eps[CDNS2_ENDPOINTS_NUM];
u32 selected_ep;
bool is_selfpowered;
bool may_wakeup;
bool status_completion_no_call;
bool in_lpm;
struct work_struct pending_status_wq;
struct usb_request *pending_status_request;
u32 eps_supported;
u8 burst_opt[MAX_ISO_SIZE + 1];
u16 onchip_tx_buf;
u16 onchip_rx_buf;
};
Like, that's the whole squad right there. Obsessed with how tidy it is. π«Ά
π Members π
devβ pointer to thedevicestructure associated with this controller. The home base, basically.gadgetβ device-side representation of the peripheral controller. Slay.gadget_driverβ pointer to the gadget driver. The driver bestie in question.lockβ for synchronizing. Gotta keep things from getting chaotic.irqβ interrupt line number. The interrupt's little address, iykyk.regsβ base address for registers.usb_regsβ base address for common USB registers.ep0_regsβ base address for endpoint 0 related registers.epx_regsβ base address for all non-control endpoint registers.interrupt_regsβ base address for interrupt handling related registers.adma_regsβ base address for ADMA registers.eps_dma_poolβ endpoint Transfer Ring pool. Cute little pool for the eps.setupβ used while processing usb control requests. Very on-the-job.ep0_preqβ private request used while handling EP0. Private means private, bestie.ep0_stageβ ep0 stage during enumeration process. The lore of the enumeration era.zlp_bufβ zlp buffer. Short, sweet, iconic.dev_addressβ device address assigned by host. The host said "this is your address now" and that's periodt.epsβ array of objects describing endpoints. The whole endpoint ensemble.selected_epβ actually selected endpoint. It's used only to improve performance by limiting access todma_ep_selregister. Highkey a performance flex.is_selfpoweredβ device is self powered. Independent queen behavior.may_wakeupβ allows device to remote wakeup the host. Consent to wake the host: granted.status_completion_no_callβ indicate that driver is waiting for status stage completion. It's used in deferredSET_CONFIGURATIONrequest. The waiting-for-you energy is real.in_lpmβ indicate the controller is in low power mode. Resting, but make it low power.pending_status_wqβ workqueue handling status stage for deferred requests. Handling the to-do list, no cap.pending_status_requestβ request for which status stage was deferred. The request in the waiting room.eps_supportedβ endpoints supported by controller in form:bit: 0 - ep0, 1 - epOut1, 2 - epIn1, 3 - epOut2 ...A whole bit-map situation. πburst_optβ array with the best burst size value for different TRB size. Best burst size behavior only.onchip_tx_bufβ size of transmit on-chip buffer in KB. TX buffer, but make it on-chip.onchip_rx_bufβ size of receive on-chip buffer in KB. And the RX twin. Matching set π
π¦ SEE ALSO π¦
Kernel file ./drivers/usb/gadget/udc/cdns2/cdns2-gadget.h β and the whole friend group is here too: struct cdns2_ep0_regs(9), struct cdns2_epx_base(9), struct cdns2_epx_regs(9), struct cdns2_interrupt_regs(9), struct cdns2_usb_regs(9), struct cdns2_adma_regs(9), struct cdns2_trb(9), struct cdns2_ring(9), struct cdns2_endpoint(9), struct cdns2_request(9).
Go read those too, bestie. It's giving required reading. π
And that's the page, mwah π this comes from ./drivers/usb/gadget/udc/cdns2, dated October 2026 β iconic source directory, iconic date, no notes. πβ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms