Skip to content

Commit

Permalink
gateware.usb2: add disconnect signal to USBResetSequencer
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinevg committed May 30, 2024
1 parent 41d8f9f commit 1ad6ef3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions luna/gateware/usb/usb2/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ def elaborate(self, platform):

reset_sequencer.vbus_connected .eq(~self.utmi.session_end),
reset_sequencer.line_state .eq(self.utmi.line_state),

reset_sequencer.disconnect .eq(~self.connect),
]


Expand Down
11 changes: 11 additions & 0 deletions luna/gateware/usb/usb2/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class USBResetSequencer(Elaboratable):
be held in perpetual bus reset, and reset handshaking will be disabled.
line_state: Signal(2), input
The UTMI linestate signals; used to read the current state of the USB D+ and D- lines.
disconnect: Signal(), input
If set, the device will be switched into non-driving operating mode to force a host disconnect.
bus_reset: Signal(), output
Strobe; pulses high for one cycle when a bus reset is detected. This signal indicates that the
Expand Down Expand Up @@ -123,6 +125,8 @@ def __init__(self):
self.vbus_connected = Signal()
self.line_state = Signal(2)

self.disconnect = Signal()

self.bus_reset = Signal()
self.suspended = Signal()

Expand Down Expand Up @@ -173,6 +177,13 @@ def elaborate(self, platform):
with m.Else():
m.d.comb += bus_idle.eq(self.line_state == self._LINE_STATE_LS_J)

# Switch to non-driving operating mode when we're not
# connected and we're not seeing an SE0.
with m.If(self.disconnect & (self.line_state != self._LINE_STATE_SE0)):
m.d.usb += [
self.operating_mode.eq(UTMIOperatingMode.NON_DRIVING),
timer.eq(0),
]

#
# Core reset sequences.
Expand Down

0 comments on commit 1ad6ef3

Please sign in to comment.