Skip to content

phy: add debounced link_up/connect/disconnect events - #48

Merged
enjoy-digital merged 1 commit into
gen/dma-corefrom
phy/link-events
Oct 19, 2026
Merged

enjoy-digital merged 1 commit into
gen/dma-corefrom
phy/link-events

Conversation

@enjoy-digital

Copy link
Copy Markdown
Owner

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 (in phy/ctrl.py): link_up rises with ready (which already includes the controller's 5 ms stability time) and falls only once ready has stayed low for link_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/disconnect are single-cycle pulses, directly usable as EventSourcePulse triggers.
  • LiteSATAPHY: link_down_timeout kwarg (appended, positional order preserved), link_up / connect_irq / disconnect_irq attributes, link_up field appended to the status CSR (existing bits unchanged).
  • Generator: link_up, connect, disconnect output pads on both flavours.

The LiteX-side change (two EventSourcePulse in add_sata triggered by phy.connect_irq / phy.disconnect_irq, guarded with hasattr) 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

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>
@enjoy-digital
enjoy-digital merged commit 697fa4e into gen/dma-core Oct 19, 2026
2 checks passed
enjoy-digital added a commit that referenced this pull request Oct 19, 2026
docs: move the generator details to doc/gen.md (and land #46/#48 on master)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant