| 1 | /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ |
| 2 | |
| 3 | #ifndef _UAPI_PWM_H_ |
| 4 | #define _UAPI_PWM_H_ |
| 5 | |
| 6 | #include <linux/ioctl.h> |
| 7 | #include <linux/types.h> |
| 8 | |
| 9 | /** |
| 10 | * struct pwmchip_waveform - Describe a PWM waveform for a pwm_chip's PWM channel |
| 11 | * @hwpwm: per-chip relative index of the PWM device |
| 12 | * @__pad: padding, must be zero |
| 13 | * @period_length_ns: duration of the repeating period. |
| 14 | * A value of 0 represents a disabled PWM. |
| 15 | * @duty_length_ns: duration of the active part in each period |
| 16 | * @duty_offset_ns: offset of the rising edge from a period's start |
| 17 | */ |
| 18 | struct pwmchip_waveform { |
| 19 | __u32 hwpwm; |
| 20 | __u32 __pad; |
| 21 | __u64 period_length_ns; |
| 22 | __u64 duty_length_ns; |
| 23 | __u64 duty_offset_ns; |
| 24 | }; |
| 25 | |
| 26 | /* Reserves the passed hwpwm for exclusive control. */ |
| 27 | #define PWM_IOCTL_REQUEST _IO(0x75, 1) |
| 28 | |
| 29 | /* counter part to PWM_IOCTL_REQUEST */ |
| 30 | #define PWM_IOCTL_FREE _IO(0x75, 2) |
| 31 | |
| 32 | /* |
| 33 | * Modifies the passed wf according to hardware constraints. All parameters are |
| 34 | * rounded down to the next possible value, unless there is no such value, then |
| 35 | * values are rounded up. Note that zero isn't considered for rounding down |
| 36 | * period_length_ns. |
| 37 | */ |
| 38 | #define PWM_IOCTL_ROUNDWF _IOWR(0x75, 3, struct pwmchip_waveform) |
| 39 | |
| 40 | /* Get the currently implemented waveform */ |
| 41 | #define PWM_IOCTL_GETWF _IOWR(0x75, 4, struct pwmchip_waveform) |
| 42 | |
| 43 | /* Like PWM_IOCTL_ROUNDWF + PWM_IOCTL_SETEXACTWF in one go. */ |
| 44 | #define PWM_IOCTL_SETROUNDEDWF _IOW(0x75, 5, struct pwmchip_waveform) |
| 45 | |
| 46 | /* |
| 47 | * Program the PWM to emit exactly the passed waveform, subject only to rounding |
| 48 | * down each value less than 1 ns. Returns 0 on success, -EDOM if the waveform |
| 49 | * cannot be implemented exactly, or other negative error codes. |
| 50 | */ |
| 51 | #define PWM_IOCTL_SETEXACTWF _IOW(0x75, 6, struct pwmchip_waveform) |
| 52 | |
| 53 | #endif /* _UAPI_PWM_H_ */ |
| 54 | |