STRUCT MUSB_PLATFORM_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

struct musb_platform_ops(9) πŸ’…

okay so this is the Kernel API Manual page for struct musb_platform_ops, and bestie, it's literally the handshake between the MUSB core and whatever hardware glue layer you're dealing with. Think of it as the group chat where musb_core and your platform-specific code agree on how things get done. 🫢


✨ NAME ✨

struct musb_platform_ops β€” Operations passed to musb_core by the HW glue layer. that's the whole vibe. the core gets handed this struct and goes "cool, this is how I talk to your weird little hardware." πŸŽ€


🌸 SYNOPSIS 🌸

struct musb_platform_ops {
  #define MUSB_G_NO_SKB_RESERVE   BIT(9);
  #define MUSB_DA8XX              BIT(8);
  #define MUSB_PRESERVE_SESSION   BIT(7);
  #define MUSB_DMA_UX500          BIT(6);
  #define MUSB_DMA_CPPI41         BIT(5);
  #define MUSB_DMA_CPPI           BIT(4);
  #define MUSB_DMA_TUSB_OMAP      BIT(3);
  #define MUSB_DMA_INVENTRA       BIT(2);
  #define MUSB_IN_TUSB            BIT(1);
  #define MUSB_INDEXED_EP         BIT(0);
    u32 quirks;
    int (*init)(struct musb *musb);
    int (*exit)(struct musb *musb);
    void (*enable)(struct musb *musb);
    void (*disable)(struct musb *musb);
    u32 (*ep_offset)(u8 epnum, u16 offset);
    void (*ep_select)(void __iomem *mbase, u8 epnum);
    u16 fifo_mode;
    u32 (*fifo_offset)(u8 epnum);
    u32 (*busctl_offset)(u8 epnum, u16 offset);
    u8 (*readb)(void __iomem *addr, u32 offset);
    void (*writeb)(void __iomem *addr, u32 offset, u8 data);
    u8 (*clearb)(void __iomem *addr, u32 offset);
    u16 (*readw)(void __iomem *addr, u32 offset);
    void (*writew)(void __iomem *addr, u32 offset, u16 data);
    u16 (*clearw)(void __iomem *addr, u32 offset);
    void (*read_fifo)(struct musb_hw_ep *hw_ep, u16 len, u8 *buf);
    void (*write_fifo)(struct musb_hw_ep *hw_ep, u16 len, const u8 *buf);
    u16 (*get_toggle)(struct musb_qh *qh, int is_out);
    u16 (*set_toggle)(struct musb_qh *qh, int is_out, struct urb *urb);
    struct dma_controller * (*dma_init) (struct musb *musb, void __iomem *base);
    void (*dma_exit)(struct dma_controller *c);
    int (*set_mode)(struct musb *musb, u8 mode);
    void (*try_idle)(struct musb *musb, unsigned long timeout);
    int (*recover)(struct musb *musb);
    int (*vbus_status)(struct musb *musb);
    void (*set_vbus)(struct musb *musb, int on);
    void (*pre_root_reset_end)(struct musb *musb);
    void (*post_root_reset_end)(struct musb *musb);
    int (*phy_callback)(enum musb_vbus_id_status status);
    void (*clear_ep_rxintr)(struct musb *musb, int epnum);
};

like, that's a lot of function pointers, and every single one is about to get explained. buckle up. πŸ’–


πŸ‘‘ Members πŸ‘‘

okay so these are all the members, and I'm giving you the tea on each one, in order, no skipping:

  • quirks β€” flags for platform specific quirks. yes, the field is literally called "quirks." iconic. πŸ”₯
  • init β€” turns on clocks, sets up platform-specific registers, etc. the "wake up babe we're going in" function.
  • exit β€” undoes init. the "ok we're done here, put it all back" function. πŸ¦‹
  • enable β€” enable device.
  • disable β€” disable device. (they're a matching set, your honor.)
  • ep_offset β€” returns the end point offset.
  • ep_select β€” selects the specified end point.
  • fifo_mode β€” sets the fifo mode.
  • fifo_offset β€” returns the fifo offset. no cap, it does exactly what it says.
  • busctl_offset β€” ngl, this one is in the struct but the original page doesn't describe it. mystery member energy πŸ™ˆ it's between fifo_offset and readb and that's all we're told.
  • readb β€” read 8 bits.
  • writeb β€” write 8 bits.
  • clearb β€” could be clear-on-readb or W1C.
  • readw β€” read 16 bits.
  • writew β€” write 16 bits.
  • clearw β€” could be clear-on-readw or W1C. (notice the pattern? yes, the b/w pair does the same thing at different widths. slay.)
  • read_fifo β€” reads the fifo.
  • write_fifo β€” writes to fifo.
  • get_toggle β€” platform specific get toggle function.
  • set_toggle β€” platform specific set toggle function.
  • dma_init β€” platform specific dma init function.
  • dma_exit β€” platform specific dma exit function.
  • set_mode β€” forcefully changes operating mode. forcefully, bestie. it's not asking. πŸ’…
  • try_idle β€” tries to idle the IP. "tries" is doing a lot of work in that sentence, but that's what it says.
  • recover β€” platform-specific babble recovery. babble!! as in the USB babble condition. this is the "ok calm down" function. 😭
  • vbus_status β€” returns vbus status if possible. if possible. conditional queen.
  • set_vbus β€” forces vbus status.
  • pre_root_reset_end β€” called before the root usb port reset flag gets cleared.
  • post_root_reset_end β€” called after the root usb port reset flag gets cleared. (before/after duo, we love a matched pair 🫢)
  • phy_callback β€” optional callback function for the phy to call. optional! so if you don't need it, don't stress.
  • clear_ep_rxintr β€” this one's also in the struct with no description on this page. another mystery member, but at least the name is self-explanatory-ish. πŸ™ˆ

🌈 SEE ALSO 🌈

  • Kernel file ./drivers/usb/musb/musb_core.h β€” go read it, it's the whole context, iykyk πŸ’œ

and that's the page, bestie! this one came out of ./drivers/usb/musb and it's dated October 2026, so mark your calendar πŸ—“οΈβœ¨ go forth and implement your platform ops, you're gonna ate πŸ’…πŸŽ€

πŸ“¦ where this page comes from