diff --git a/luna/gateware/usb/usb2/device.py b/luna/gateware/usb/usb2/device.py index e73b0f522..d0301a5e9 100644 --- a/luna/gateware/usb/usb2/device.py +++ b/luna/gateware/usb/usb2/device.py @@ -150,6 +150,7 @@ def __init__(self, *, bus, handle_clocking=True): # Internals. # self._endpoints = [] + self._bus_name = bus.name def add_endpoint(self, endpoint): @@ -202,6 +203,12 @@ def add_standard_control_endpoint(self, descriptors: DeviceDescriptorCollection, def elaborate(self, platform): m = Module() + # Call any hooks registered for the bus in the platform definition. + if hasattr(platform, "usb_device_hooks"): + hook = platform.usb_device_hooks.get(self._bus_name) + if hook is not None: + hook(self, m) + # If we have a bus translator, include it in our submodules. if self.translator: m.submodules.translator = self.translator