Skip to content

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

Open
Josbleuet wants to merge 3 commits into
LinuxCNC:masterfrom
Josbleuet:opto_ac5-uspace
Open

Josbleuet wants to merge 3 commits into
LinuxCNC:masterfrom
Josbleuet:opto_ac5-uspace

Conversation

@Josbleuet

Copy link
Copy Markdown

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.

  • First commit: the driver, docs, man page and component-list row come back. 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() is updated to the current signature.
  • Second commit: whitespace only, spaces instead of tabs and 4 spaces per level (git diff -w is empty).
  • Third commit: BsAtHome's suggestion from the issue, each HAL pin and the invert param are read once per cycle. The output test ends up as val == inv, same truth table as before.
  • The uspace rtapi_pci matches subvendor/subdevice exactly, so the id table lists 148a:ac05 as the card reports it.

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. Squash the commits if you prefer it as one.

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.

Only 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.  Pins, parameters,
functions and the read/write logic are unchanged.

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).

The driver is built like hal_gm, for uspace and RTAI.  Its docs, man
page and component-list row are restored.
Whitespace only, no code change (git diff -w is empty).  Tabs are
expanded and the old functions are reindented to 4 spaces per level
as asked in review.
As suggested in review: digital-read computes the input state once and
writes it to the pin and the -not pin, and digital-write reads the
output pin and its invert parameter once each.  Same behaviour, the
output test is now simply val == inv.
Comment on lines +52 to +54
* 'opto_ac5.[BOARDNUMBER].port[PORTNUMBER].in-[PINNUMBER] OUT bit' -

* 'opto_ac5.[BOARDNUMBER].port[PORTNUMBER].in-[PINNUMBER]-not OUT bit' -

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.

The HAL types have been renamed and bit is now called bool (several more instances below).

IIRC, the only pins this driver makes are bools.

Comment on lines +38 to +41
**opto_ac5.**_BOARDNUMBER_**.port.**_PORTNUMBER_**.in-**_PINNUMBER_ OUT bit::
+

**opto_ac5.**_BOARDNUMBER_**.port.**_PORTNUMBER_**.in-**_PINNUMBER_**-not** OUT bit::

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.

Same issue: bit --> bool
(must be done everywhere appropriate)

Comment on lines +7 to +8
*PCI AC5 ADAPTER CARD / HAL DRIVER*

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.

The file is called opto22.adoc whereas the card is called PCI AC5. The driver file is called opto_ac5.*. This is rather confusing. Was that always the case? The Opto22 is the manufacturer. Are there other cards from that manufacturer? Maybe use opto_ac5.adoc?

Comment on lines +260 to +261
int msgLevel, error=0;

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.

There are some stray tabs here.

Comment on lines +289 to +290
int halError=0, channel,mask,portnum=0;

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.

Some more tabs here too.

Comment on lines +410 to +411
// Read digital I/O register.
pins= ac5_read(pboard, offset);

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.

Stray tab or just misplaced space at pins=

Comment on lines +442 to +446
board_data_t *pboard = (board_data_t *)arg;
DigitalPinsParams *pDigital;
int portnum=0;
unsigned int i,j;
unsigned long pins, offset=DATA_WRITE_OFFSET_0,mask;

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.

Are there tabs here or just many spaces?
And then, the spaces around = and , are inconsistent.

@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.

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.

2 participants