Hi Neil, > > +static int dwc3_meson_g12a_debugfs_init(struct dwc3_meson_g12a *priv) > > +{ > > + priv->root = debugfs_create_dir("dwc3-meson-g12a", NULL); > > + if (IS_ERR(priv->root)) > > + return PTR_ERR(priv->root); > > + > > + debugfs_create_file("mode_force", 0600, priv->root, priv, > > + &dwc3_meson_g12a_mode_force_fops); > > + > > + debugfs_create_file("otg_id", 0400, priv->root, priv, > > + &dwc3_meson_g12a_otg_id_fops); > > + > > + return 0; > > +} I just stumbled across the "USB role switch framework", see [0] it seems to provide a userspace API as well and two in-kernel drivers are using this framework already (drivers/usb/gadget/udc/renesas_usb3.c, drivers/usb/roles/intel-xhci-usb-role-switch.c) [0] https://elixir.bootlin.com/linux/v5.0-rc8/source/drivers/usb/roles/class.c#L246