Skip to content

pwm: add support for PWMIOC_FAULTS_FETCH_AND_CLEAR ioctl - #15912

Merged
acassis merged 2 commits into
apache:masterfrom
michallenc:pwm-fault-clear-ioctl
Feb 27, 2025
Merged

acassis merged 2 commits into
apache:masterfrom
michallenc:pwm-fault-clear-ioctl

Conversation

@michallenc

Copy link
Copy Markdown
Contributor

Summary

This ioctl clears the active fault inputs. Some faults can be latched (still active even if the source is not active anymore), so they have to be cleared from the software. The argument is a pointer to unsigned long bitmask variable. This bitmask specifies which faults are to be cleared.

The ioctl also can fetch the faults active prior to the clear. These faults are saved to the argument specifying which faults are to be
cleared. Therefore passing zero bitmask means the driver will only return active faults and clear none. Passing NULL pointer means the driver will clear all active and return none.

The other commit implements the ioctl to samv7 PWM driver.

Impact

None to current implementations as this is a new ioctl call. Documentation updated with a proper description. Drivers not implementing the ioctl will returns -ENOTTY as usual.

Testing

Tested on SAMv7 custom board. The ioctl successfully reads currently active faults and the value is changed if the fault becomes active (and remains active if the fault is latched). All cases (passing NULL to clear all, 0 to read only and specific bitmask to clear some) tested.

The PWM becomes active again once the faults are cleared.

This ioctl clears the active fault inputs. Some faults can be latched
(still active even if the source is not active anymore), so they have
to be cleared from the software. The argument is a pointer to unsigned
long bitmask variable. This bitmask specifies which faults are to be
cleared.

The ioctl also can fetch the faults active prior to the clear. These
faults are saved to the argument specifying which faults are to be
cleared. Therefore passing zero bitmask means the driver will only return
active faults and clear none. Passing NULL pointer means the driver
will clear all active and return none.

The implementation of this ioctl is per driver.

Signed-off-by: Michal Lenc <[email protected]>
This ioctl fetches and clears PWM faults.

Signed-off-by: Michal Lenc <[email protected]>
@github-actions github-actions Bot added Area: Documentation Improvements or additions to documentation Arch: arm Issues related to ARM (32-bit) architecture Area: Drivers Drivers issues Size: S The size of the change in this PR is small labels Feb 26, 2025
@michallenc

Copy link
Copy Markdown
Contributor Author

@raiden00pl Hi, what do you think? I know it may not be the best time for it because of possible future PWM API rewrite, but it is completely separated from characteristics set, so it should not cause any troubles in the future.

Also ping to @ppisa

@ppisa

ppisa commented Feb 26, 2025

Copy link
Copy Markdown
Contributor

I agree with implementation. Thank for the enhancement. I ping @zdebanos , he would have use for IOCTL as well on SaMoCon.

@acassis
acassis merged commit 4e70cc1 into apache:master Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Area: Documentation Improvements or additions to documentation Area: Drivers Drivers issues Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants