2018-12-12 20:56:56 +00:00
|
|
|
.\" Copyright (c) 2018 Emmanuel Vadot <manu@freebsd.org>
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2021-03-11 08:53:26 +00:00
|
|
|
.Dd March 9, 2021
|
2018-12-12 20:56:56 +00:00
|
|
|
.Dt PWMBUS 9
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm pwmbus ,
|
|
|
|
.Nm PWMBUS_CHANNEL_CONFIG ,
|
2019-06-21 15:12:17 +00:00
|
|
|
.Nm PWMBUS_CHANNEL_COUNT ,
|
|
|
|
.Nm PWMBUS_CHANNEL_ENABLE ,
|
2018-12-12 20:56:56 +00:00
|
|
|
.Nm PWMBUS_CHANNEL_GET_CONFIG ,
|
|
|
|
.Nm PWMBUS_CHANNEL_GET_FLAGS ,
|
|
|
|
.Nm PWMBUS_CHANNEL_IS_ENABLED ,
|
2019-06-21 15:12:17 +00:00
|
|
|
.Nm PWMBUS_CHANNEL_SET_FLAGS ,
|
|
|
|
.Nm PWMBUS_GET_BUS
|
2018-12-12 20:56:56 +00:00
|
|
|
.Nd PWMBUS methods
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Cd "device pwm"
|
|
|
|
.In "pwmbus_if.h"
|
|
|
|
.Ft int
|
2021-03-11 08:53:26 +00:00
|
|
|
.Fn PWMBUS_CHANNEL_CONFIG "device_t bus" "u_int channel" "u_int period" "u_int duty"
|
2018-12-12 20:56:56 +00:00
|
|
|
.Ft int
|
2021-03-11 08:53:26 +00:00
|
|
|
.Fn PWMBUS_CHANNEL_COUNT "device_t bus" "u_int *nchannel"
|
2018-12-12 20:56:56 +00:00
|
|
|
.Ft int
|
2021-03-11 08:53:26 +00:00
|
|
|
.Fn PWMBUS_CHANNEL_ENABLE "device_t bus" "u_int channel" "bool enable"
|
2018-12-12 20:56:56 +00:00
|
|
|
.Ft int
|
2021-03-11 08:53:26 +00:00
|
|
|
.Fn PWMBUS_CHANNEL_GET_CONFIG "device_t bus" "u_int channel" "u_int *period" "u_int *duty"
|
2018-12-12 20:56:56 +00:00
|
|
|
.Ft int
|
2021-03-11 08:53:26 +00:00
|
|
|
.Fn PWMBUS_CHANNEL_GET_FLAGS "device_t bus" "u_int channel" "uint32_t *flags"
|
2018-12-12 20:56:56 +00:00
|
|
|
.Ft int
|
2021-03-11 08:53:26 +00:00
|
|
|
.Fn PWMBUS_CHANNEL_IS_ENABLED "device_t bus" "u_int channel" "bool *enabled"
|
2018-12-12 20:56:56 +00:00
|
|
|
.Ft int
|
2021-03-11 08:53:26 +00:00
|
|
|
.Fn PWMBUS_CHANNEL_SET_FLAGS "device_t bus" "u_int channel" "uint32_t flags"
|
2018-12-12 20:56:56 +00:00
|
|
|
.Sh DESCRIPTION
|
2019-06-21 15:12:17 +00:00
|
|
|
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
|
|
|
|
generic way.
|
|
|
|
.Pp
|
|
|
|
For all
|
|
|
|
.Nm
|
|
|
|
methods, the
|
|
|
|
.Va period
|
|
|
|
argument is the duration in nanoseconds of one complete on-off cycle, and the
|
|
|
|
.Va duty
|
|
|
|
argument is the duration in nanoseconds of the on portion of that cycle.
|
|
|
|
.Pp
|
|
|
|
Some PWM hardware is organized as a single controller with multiple channels.
|
|
|
|
Channel numbers count up from zero.
|
2020-09-17 20:55:42 +00:00
|
|
|
When multiple channels are present, they sometimes share a common clock or
|
2019-06-21 15:12:17 +00:00
|
|
|
other resources.
|
2020-09-17 20:55:42 +00:00
|
|
|
In such cases, changing the period or duty cycle of any one channel may affect
|
2019-06-21 15:12:17 +00:00
|
|
|
other channels within the hardware which share the same resources.
|
2020-09-17 20:55:42 +00:00
|
|
|
Consult the documentation for the underlying PWM hardware device driver for
|
2019-06-21 15:12:17 +00:00
|
|
|
details on channels that share resources.
|
2018-12-12 20:56:56 +00:00
|
|
|
.Sh INTERFACE
|
|
|
|
.Bl -tag -width indent
|
2021-03-11 08:53:26 +00:00
|
|
|
.It Fn PWMBUS_CHANNEL_CONFIG "device_t bus" "u_int channel" "u_int period" "u_int duty"
|
2019-06-21 15:12:17 +00:00
|
|
|
Configure the period and duty (in nanoseconds) in the PWM controller on the bus
|
|
|
|
for the specified channel.
|
2018-12-12 20:56:56 +00:00
|
|
|
Returns 0 on success or
|
|
|
|
.Er EINVAL
|
2019-06-21 14:46:43 +00:00
|
|
|
if the values are not supported by the controller or
|
2018-12-12 20:56:56 +00:00
|
|
|
.Er EBUSY
|
2019-06-21 15:12:17 +00:00
|
|
|
if the PWMBUS controller is in use and does not support changing the value on
|
|
|
|
the fly.
|
2021-03-11 08:53:26 +00:00
|
|
|
.It Fn PWMBUS_CHANNEL_COUNT "device_t bus" "u_int *nchannel"
|
2019-06-21 15:12:17 +00:00
|
|
|
Get the number of channels supported by the controller.
|
2021-03-11 08:53:26 +00:00
|
|
|
.It Fn PWMBUS_CHANNEL_ENABLE "device_t bus" "u_int channel" "bool enable"
|
2019-06-21 15:12:17 +00:00
|
|
|
Enable the PWM channel.
|
2021-03-11 08:53:26 +00:00
|
|
|
.It Fn PWMBUS_CHANNEL_GET_CONFIG "device_t bus" "u_int channel" "u_int *period" "u_int *duty"
|
2018-12-12 20:56:56 +00:00
|
|
|
Get the current configuration of the period and duty for the specified channel.
|
2021-03-11 08:53:26 +00:00
|
|
|
.It Fn PWMBUS_CHANNEL_GET_FLAGS "device_t bus" "u_int channel" "uint32_t *flags"
|
2019-06-21 14:46:43 +00:00
|
|
|
Get the current flags for the channel.
|
|
|
|
If the driver or controller
|
2019-06-21 15:12:17 +00:00
|
|
|
does not support this, a default method returns a flags value of zero.
|
2021-03-11 08:53:26 +00:00
|
|
|
.It Fn PWMBUS_CHANNEL_IS_ENABLED "device_t bus" "u_int channel" "bool *enable"
|
2019-06-21 15:12:17 +00:00
|
|
|
Test whether the PWM channel is enabled.
|
2021-03-11 08:53:26 +00:00
|
|
|
.It Fn PWMBUS_CHANNEL_SET_FLAGS "device_t bus" "u_int channel" "uint32_t flags"
|
2019-06-21 15:12:17 +00:00
|
|
|
Set the flags of the channel (such as inverted polarity).
|
|
|
|
If the driver or controller does not support this a do-nothing default method
|
|
|
|
is used.
|
2018-12-12 20:56:56 +00:00
|
|
|
.El
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm pwmbus
|
|
|
|
interface first appear in
|
|
|
|
.Fx 13.0 .
|
|
|
|
The
|
|
|
|
.Nm pwmbus
|
|
|
|
interface and manual page was written by
|
|
|
|
.An Emmanuel Vadot Aq Mt manu@FreeBSD.org .
|