Skip to content

opto_ac5: bring the driver back, ported to uspace - #4883

Merged
BsAtHome merged 1 commit into
LinuxCNC:masterfrom
Josbleuet:opto_ac5-uspace
Nov 23, 2026
Merged

BsAtHome merged 1 commit into
LinuxCNC:masterfrom
Josbleuet:opto_ac5-uspace

Conversation

@Josbleuet

@Josbleuet Josbleuet commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #4880.

The Opto22 PCI-AC5 driver was removed in #4513 because nobody was known to use or test it. I use one on my milling machine, so this brings it back, ported to rtapi_pci so it builds and runs on uspace.

  • The PCI part becomes a rtapi_pci driver (probe/remove, rtapi_pci_ioremap_bar) and register access goes through ac5_read()/ac5_write(). hal_export_functf() follows the current signature.
  • The uspace rtapi_pci matches subvendor/subdevice exactly, so the id table lists 148a:ac05 as the card reports it.
  • From review: each HAL pin and the invert param are read once per cycle, and the sources use spaces only, with the style guide spacing and braces.
  • Docs, man page, component-list row and index entry are back. The doc page is now opto_ac5.adoc, and both docs give the real pin names, bool types, IN for the LED pins, RW for invert and the actual meaning of -not and -invert.

Tested on Debian 13, 6.12 PREEMPT_RT, i7-2600, base thread at 90 us, master run-in-place with my full machine config: e-stop, home all on X/Y/Z/A, jog on every axis, spindle CW/CCW and speed changes. in/in-not checked in halrun on all port 1 inputs. For the invert param itself I have nothing to look at on the hardware, none of my outputs use it.

I can keep testing on the machine during the review.

Comment thread docs/src/drivers/opto22.adoc Resolved
Comment thread docs/src/man/man9/opto_ac5.9.adoc Resolved
Comment thread docs/src/drivers/opto_ac5.adoc Resolved
Comment thread src/hal/drivers/opto_ac5.c Resolved
Comment thread src/hal/drivers/opto_ac5.c Resolved
Comment thread src/hal/drivers/opto_ac5.c Resolved
Comment thread src/hal/drivers/opto_ac5.c Resolved
@BsAtHome

Copy link
Copy Markdown
Contributor

I can keep testing on the machine during the review.

Yes, please do. Also, if we need this driver tested in the future, may we ask you again?

Squash the commits if you prefer it as one.

Yes, please do.

The Opto22 PCI-AC5 driver was removed in dd394d9 because it only
built for RTAI kernels and nobody was known to use or be able to test
it.  It is in daily use on a milling machine here, so port it instead.

The PCI discovery and mapping change: pci_get_device() /
ioremap_nocache() become a rtapi_pci driver (probe/remove,
rtapi_pci_ioremap_bar), and readl()/writel() go through ac5_read() /
ac5_write(), which keep readl()/writel() in a kernel build and do a
volatile 32 bit access on the mapped BAR in uspace.  hal_export_functf()
follows the current signature.

The uspace rtapi_pci matches subvendor/subdevice exactly (no
PCI_ANY_ID), so the id table lists the subsystem IDs the card reports
(148a:ac05).

From review: each HAL pin and the invert parameter are read once per
cycle, and the sources use spaces only with consistent spacing.

The driver is built like hal_gm, for uspace and RTAI.  Its docs, man
page, component-list row and index entry are restored.  The doc page
is renamed opto_ac5.adoc to match the driver, and both docs now give
the real pin names (opto-ac5.N.portP...), bool types, IN for the LED
pins, RW for the invert parameter and the actual meaning of -not and
-invert.
@Josbleuet

Copy link
Copy Markdown
Contributor Author

Yes, sure, I can test it anytime. I have been using LinuxCNC for free for 16 years now, it's a wonderful project and I'm very proud of my small contribution to it.

Squashed and force-pushed, with your review in:

  • bit -> bool in both docs. While at it I checked them against the code: the pin names were wrong too (opto_ac5.N.port.P instead of opto-ac5.N.portP), the LED pins are IN, invert is RW, and the descriptions of -not and -invert were reversed. Fixed.
  • opto22.adoc is renamed opto_ac5.adoc. It has been called opto22.adoc since the old docs as far as I can tell, and this is the only Opto22 driver in the tree. The index entry that went away with the removal is back too.
  • The "tabs" were the old column alignment done with spaces. Declarations now use a single space, spacing around operators and commas is consistent, and the braces follow the style guide. Ignoring comments and whitespace, the code is the same as what I tested.

Rebuilt and retested on the machine.

@grandixximo grandixximo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for porting and testing this on your machine. The docs now match the pins the driver creates. Looks good to me.

@BsAtHome
BsAtHome merged commit 65f7467 into LinuxCNC:master Nov 23, 2026
19 checks passed
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.

3 participants