STRUCT CDNS2_DEVICE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

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 the device structure 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 to dma_ep_sel register. 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 deferred SET_CONFIGURATION request. 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