Repository navigation
phy: add debounced link_up/connect/disconnect events - #48
Merged
Merged
Conversation
Software could only poll the PHY ready bit, and the LiteX IRQ for SATA has no connect/disconnect source (issue #21). Add LiteSATAPHYLinkMonitor: link_up rises with ready (which already carries the controller's 5 ms stability time) and falls only once ready has stayed low for link_down_timeout (100 ms by default), so the controller's own re-initializations on misalignment or idle do not generate events while a device unplug does. connect/disconnect are single-cycle pulses, directly usable as EventSourcePulse triggers. - LiteSATAPHY: link_down_timeout kwarg (appended), link_up / connect_irq / disconnect_irq attributes, link_up field appended to the status CSR. - gen: link_up, connect and disconnect output pads on both flavours. - tests: link monitor behaviour (short drop ignored, long drop reported) and the generator pads. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #45 (adds pads to its generator); GitHub will retarget as the stack merges. First half of issue #21: the DMA-done IRQs already exist in LiteX's
add_sata, the missing part was a connect/disconnect source.LiteSATAPHYLinkMonitor(inphy/ctrl.py):link_uprises withready(which already includes the controller's 5 ms stability time) and falls only oncereadyhas stayed low forlink_down_timeout(default 100 ms). The controller's own re-initializations on misalignment or idle retries are far shorter, so they never produce events; a device unplug does.connect/disconnectare single-cycle pulses, directly usable asEventSourcePulsetriggers.LiteSATAPHY:link_down_timeoutkwarg (appended, positional order preserved),link_up/connect_irq/disconnect_irqattributes,link_upfield appended to the status CSR (existing bits unchanged).link_up,connect,disconnectoutput pads on both flavours.The LiteX-side change (two
EventSourcePulseinadd_satatriggered byphy.connect_irq/phy.disconnect_irq, guarded withhasattr) is a separate PR on the LiteX repository.Verification
python3 -m pytest test/test_phy_ctrl.py test/test_phy.py test/test_gen.py: 16 passed. The monitor test checks: ready → one connect; an 8-cycle drop with a 16-cycle timeout → no event; a 32-cycle drop → one disconnect; ready again → one connect.🤖 Generated with Claude Code