Changeset View
Changeset View
Standalone View
Standalone View
share/man/man9/pwmbus.9
Show All 16 Lines | |||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd June 21, 2019 | .Dd March 9, 2021 | ||||
.Dt PWMBUS 9 | .Dt PWMBUS 9 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm pwmbus , | .Nm pwmbus , | ||||
.Nm PWMBUS_CHANNEL_CONFIG , | .Nm PWMBUS_CHANNEL_CONFIG , | ||||
.Nm PWMBUS_CHANNEL_COUNT , | .Nm PWMBUS_CHANNEL_COUNT , | ||||
.Nm PWMBUS_CHANNEL_ENABLE , | .Nm PWMBUS_CHANNEL_ENABLE , | ||||
.Nm PWMBUS_CHANNEL_GET_CONFIG , | .Nm PWMBUS_CHANNEL_GET_CONFIG , | ||||
.Nm PWMBUS_CHANNEL_GET_FLAGS , | .Nm PWMBUS_CHANNEL_GET_FLAGS , | ||||
.Nm PWMBUS_CHANNEL_IS_ENABLED , | .Nm PWMBUS_CHANNEL_IS_ENABLED , | ||||
.Nm PWMBUS_CHANNEL_SET_FLAGS , | .Nm PWMBUS_CHANNEL_SET_FLAGS , | ||||
.Nm PWMBUS_GET_BUS | .Nm PWMBUS_GET_BUS | ||||
.Nd PWMBUS methods | .Nd PWMBUS methods | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
.Cd "device pwm" | .Cd "device pwm" | ||||
.In "pwmbus_if.h" | .In "pwmbus_if.h" | ||||
.Ft int | .Ft int | ||||
.Fn PWMBUS_CHANNEL_CONFIG "device_t bus" "int channel" "uint64_t period" "uint64_t duty" | .Fn PWMBUS_CHANNEL_CONFIG "device_t bus" "u_int channel" "u_int period" "u_int duty" | ||||
rpokala: The code in `pwmbus.c` has `u_int` for `channel` for all of these... | |||||
.Ft int | .Ft int | ||||
.Fn PWMBUS_CHANNEL_COUNT "device_t bus" "int channel" "int *nchannel" | .Fn PWMBUS_CHANNEL_COUNT "device_t bus" "u_int *nchannel" | ||||
Done Inline Actionschannel isn't an argument for this function. rpokala: `channel` isn't an argument for this function. | |||||
.Ft int | .Ft int | ||||
.Fn PWMBUS_CHANNEL_ENABLE "device_t bus" "int channel" "bool enable" | .Fn PWMBUS_CHANNEL_ENABLE "device_t bus" "u_int channel" "bool enable" | ||||
.Ft int | .Ft int | ||||
.Fn PWMBUS_CHANNEL_GET_CONFIG "device_t bus" "int channel" "uint64_t *period" "uint64_t *duty" | .Fn PWMBUS_CHANNEL_GET_CONFIG "device_t bus" "u_int channel" "u_int *period" "u_int *duty" | ||||
.Ft int | .Ft int | ||||
.Fn PWMBUS_CHANNEL_GET_FLAGS "device_t bus" "int channel" "uint32_t *flags" | .Fn PWMBUS_CHANNEL_GET_FLAGS "device_t bus" "u_int channel" "uint32_t *flags" | ||||
.Ft int | .Ft int | ||||
.Fn PWMBUS_CHANNEL_IS_ENABLED "device_t bus" "int channel" "bool *enabled" | .Fn PWMBUS_CHANNEL_IS_ENABLED "device_t bus" "u_int channel" "bool *enabled" | ||||
.Ft int | .Ft int | ||||
.Fn PWMBUS_CHANNEL_SET_FLAGS "device_t bus" "int channel" "uint32_t flags" | .Fn PWMBUS_CHANNEL_SET_FLAGS "device_t bus" "u_int channel" "uint32_t flags" | ||||
.Sh DESCRIPTION | .Sh DESCRIPTION | ||||
The PWMBUS (Pulse-Width Modulation) interface allows a device driver to | The PWMBUS (Pulse-Width Modulation) interface allows a device driver to | ||||
register to a global bus so other devices in the kernel can use them in a | register to a global bus so other devices in the kernel can use them in a | ||||
generic way. | generic way. | ||||
.Pp | .Pp | ||||
For all | For all | ||||
.Nm | .Nm | ||||
methods, the | methods, the | ||||
.Va period | .Va period | ||||
argument is the duration in nanoseconds of one complete on-off cycle, and the | argument is the duration in nanoseconds of one complete on-off cycle, and the | ||||
.Va duty | .Va duty | ||||
argument is the duration in nanoseconds of the on portion of that cycle. | argument is the duration in nanoseconds of the on portion of that cycle. | ||||
.Pp | .Pp | ||||
Some PWM hardware is organized as a single controller with multiple channels. | Some PWM hardware is organized as a single controller with multiple channels. | ||||
Channel numbers count up from zero. | Channel numbers count up from zero. | ||||
When multiple channels are present, they sometimes share a common clock or | When multiple channels are present, they sometimes share a common clock or | ||||
other resources. | other resources. | ||||
In such cases, changing the period or duty cycle of any one channel may affect | In such cases, changing the period or duty cycle of any one channel may affect | ||||
other channels within the hardware which share the same resources. | other channels within the hardware which share the same resources. | ||||
Consult the documentation for the underlying PWM hardware device driver for | Consult the documentation for the underlying PWM hardware device driver for | ||||
details on channels that share resources. | details on channels that share resources. | ||||
.Sh INTERFACE | .Sh INTERFACE | ||||
.Bl -tag -width indent | .Bl -tag -width indent | ||||
.It Fn PWMBUS_CHANNEL_CONFIG "device_t bus" "int channel" "uint64_t period" "uint64_t duty" | .It Fn PWMBUS_CHANNEL_CONFIG "device_t bus" "u_int channel" "u_int period" "u_int duty" | ||||
Configure the period and duty (in nanoseconds) in the PWM controller on the bus | Configure the period and duty (in nanoseconds) in the PWM controller on the bus | ||||
for the specified channel. | for the specified channel. | ||||
Returns 0 on success or | Returns 0 on success or | ||||
.Er EINVAL | .Er EINVAL | ||||
if the values are not supported by the controller or | if the values are not supported by the controller or | ||||
.Er EBUSY | .Er EBUSY | ||||
if the PWMBUS controller is in use and does not support changing the value on | if the PWMBUS controller is in use and does not support changing the value on | ||||
the fly. | the fly. | ||||
.It Fn PWMBUS_CHANNEL_COUNT "device_t bus" "int *nchannel" | .It Fn PWMBUS_CHANNEL_COUNT "device_t bus" "u_int *nchannel" | ||||
Get the number of channels supported by the controller. | Get the number of channels supported by the controller. | ||||
.It Fn PWMBUS_CHANNEL_ENABLE "device_t bus" "int channel" "bool enable" | .It Fn PWMBUS_CHANNEL_ENABLE "device_t bus" "u_int channel" "bool enable" | ||||
Enable the PWM channel. | Enable the PWM channel. | ||||
.It Fn PWMBUS_CHANNEL_GET_CONFIG "device_t bus" "int channel" "uint64_t *period" "uint64_t *duty" | .It Fn PWMBUS_CHANNEL_GET_CONFIG "device_t bus" "u_int channel" "u_int *period" "u_int *duty" | ||||
Get the current configuration of the period and duty for the specified channel. | Get the current configuration of the period and duty for the specified channel. | ||||
.It Fn PWMBUS_CHANNEL_GET_FLAGS "device_t bus" "int channel" "uint32_t *flags" | .It Fn PWMBUS_CHANNEL_GET_FLAGS "device_t bus" "u_int channel" "uint32_t *flags" | ||||
Get the current flags for the channel. | Get the current flags for the channel. | ||||
If the driver or controller | If the driver or controller | ||||
does not support this, a default method returns a flags value of zero. | does not support this, a default method returns a flags value of zero. | ||||
.It Fn PWMBUS_CHANNEL_IS_ENABLED "device_t bus" "int channel" "bool *enable" | .It Fn PWMBUS_CHANNEL_IS_ENABLED "device_t bus" "u_int channel" "bool *enable" | ||||
Test whether the PWM channel is enabled. | Test whether the PWM channel is enabled. | ||||
.It Fn PWMBUS_CHANNEL_SET_FLAGS "device_t bus" "int channel" "uint32_t flags" | .It Fn PWMBUS_CHANNEL_SET_FLAGS "device_t bus" "u_int channel" "uint32_t flags" | ||||
Set the flags of the channel (such as inverted polarity). | Set the flags of the channel (such as inverted polarity). | ||||
If the driver or controller does not support this a do-nothing default method | If the driver or controller does not support this a do-nothing default method | ||||
is used. | is used. | ||||
.El | .El | ||||
.Sh HISTORY | .Sh HISTORY | ||||
The | The | ||||
.Nm pwmbus | .Nm pwmbus | ||||
interface first appear in | interface first appear in | ||||
.Fx 13.0 . | .Fx 13.0 . | ||||
The | The | ||||
.Nm pwmbus | .Nm pwmbus | ||||
interface and manual page was written by | interface and manual page was written by | ||||
.An Emmanuel Vadot Aq Mt manu@FreeBSD.org . | .An Emmanuel Vadot Aq Mt manu@FreeBSD.org . |
The code in pwmbus.c has u_int for channel for all of these...