2 .\" Copyright (c) 2019 Ian Lepore <ian@freebsd.org>
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 .Nd PWM (Pulse Width Modulation) control device driver
34 To compile this driver into the kernel,
35 place the following lines in your
36 kernel configuration file:
37 .Bd -ragged -offset indent
42 Alternatively, to load the driver as a
43 module at boot time, place the following line in
45 .Bd -literal -offset indent
51 driver provides device-control access to a channel of PWM hardware.
54 device is associated with a single PWM output channel.
56 Some PWM hardware is organized with multiple channels sharing a
57 common clock or other resources.
58 In such cases, a separate
60 instance will exist for each channel, but changing the period or
61 duty cycle of any one channel may affect other channels within the
62 hardware which share the same resources.
63 Consult the documentation for the underlying PWM hardware device driver
64 for details on channels that share resources.
68 creates a character device named
72 is a sequential number assigned to each PWM hardware controller
73 as it is discovered by the system, and
75 is the channel number within that hardware controller.
76 The driver can be configured to create aliases that point to the
78 entries, in effect creating named channels.
82 driver provides control of a PWM channel with the following
84 calls and data structures, defined in
86 .Bl -tag -width indent
87 .It Dv PWMGETSTATE Pq Vt "struct pwm_state"
88 Retrieve the current state of the channel.
89 .It Dv PWMSETSTATE Pq Vt "struct pwm_state"
90 Set the current state of the channel.
91 All parameters are updated on every call.
92 To change just one of the values, use
94 to get the current state and then submit the same data back with
95 just the appropriate value changed.
100 structure is defined as follows:
110 .Bl -tag -width period
112 The duration, in nanoseconds, of one complete on-off cycle.
114 The duration, in nanoseconds, of the on portion of one cycle.
116 Flags that affect the output signal can be bitwise-ORed together.
117 The following flags are currently defined:
119 .Bl -tag -width PWM_POLARITY_INVERTED -compact
120 .It Dv PWM_POLARITY_INVERTED
121 Invert the signal polarity.
125 False to disable the output signal or true to enable it.
127 .Sh HINTS CONFIGURATION
130 based system, such as
132 these values are configurable for
134 .Bl -tag -width indent
135 .It Va hint.pwmc.%d.at
136 The pwmbus instance the
138 instance is attached to.
139 .It Va hint.pwmc.%d.channel
140 The hardware channel number the instance is attached to.
141 Channel numbers count up from zero.
142 .It Va hint.pwmc.%d.label
143 If this optional hint is set, the driver creates an alias in
145 with the given name, which points to the instance.
147 .Sh FDT CONFIGURATION
152 device is described with a child node of the pwm hardware controller node.
153 When the hardware supports multiple channels within the controller, it is
154 not necessary to include a
156 child node for every channel the hardware supports.
157 Define only the channels you need to control.
159 The following properties are required for a
162 .Bl -tag -width indent
164 Must be the string "freebsd,pwmc".
166 The hardware channel number.
169 The following properties are optional for the
172 .Bl -tag -width indent
174 A string containing only characters legal in a file name.
175 The driver creates an alias with the given name in
177 which points to the instance's
182 Example of a PWM hardware node containing one
188 pinctrl-names = "default";
189 pinctrl-0 = <&ehrpwm0_AB_pins>;
192 compatible = "freebsd,pwmc";
199 .Bl -tag -width -compact
200 .It Pa /dev/pwm/pwmc*