xref: /freebsd/share/man/man9/pwmbus.9 (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1.\" Copyright (c) 2018 Emmanuel Vadot <manu@freebsd.org>
2.\"
3.\" Redistribution and use in source and binary forms, with or without
4.\" modification, are permitted provided that the following conditions
5.\" are met:
6.\" 1. Redistributions of source code must retain the above copyright
7.\"    notice, this list of conditions and the following disclaimer.
8.\" 2. Redistributions in binary form must reproduce the above copyright
9.\"    notice, this list of conditions and the following disclaimer in the
10.\"    documentation and/or other materials provided with the distribution.
11.\"
12.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
13.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
14.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
16.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
18.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
19.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22.\"
23.Dd March 9, 2021
24.Dt PWMBUS 9
25.Os
26.Sh NAME
27.Nm pwmbus ,
28.Nm PWMBUS_CHANNEL_CONFIG ,
29.Nm PWMBUS_CHANNEL_COUNT ,
30.Nm PWMBUS_CHANNEL_ENABLE ,
31.Nm PWMBUS_CHANNEL_GET_CONFIG ,
32.Nm PWMBUS_CHANNEL_GET_FLAGS ,
33.Nm PWMBUS_CHANNEL_IS_ENABLED ,
34.Nm PWMBUS_CHANNEL_SET_FLAGS ,
35.Nm PWMBUS_GET_BUS
36.Nd PWMBUS methods
37.Sh SYNOPSIS
38.Cd "device pwm"
39.In "pwmbus_if.h"
40.Ft int
41.Fn PWMBUS_CHANNEL_CONFIG "device_t bus" "u_int channel" "u_int period" "u_int duty"
42.Ft int
43.Fn PWMBUS_CHANNEL_COUNT "device_t bus" "u_int *nchannel"
44.Ft int
45.Fn PWMBUS_CHANNEL_ENABLE "device_t bus" "u_int channel" "bool enable"
46.Ft int
47.Fn PWMBUS_CHANNEL_GET_CONFIG "device_t bus" "u_int channel" "u_int *period" "u_int *duty"
48.Ft int
49.Fn PWMBUS_CHANNEL_GET_FLAGS "device_t bus" "u_int channel" "uint32_t *flags"
50.Ft int
51.Fn PWMBUS_CHANNEL_IS_ENABLED "device_t bus" "u_int channel" "bool *enabled"
52.Ft int
53.Fn PWMBUS_CHANNEL_SET_FLAGS "device_t bus" "u_int channel" "uint32_t flags"
54.Sh DESCRIPTION
55The PWMBUS (Pulse-Width Modulation) interface allows a device driver to
56register to a global bus so other devices in the kernel can use them in a
57generic way.
58.Pp
59For all
60.Nm
61methods, the
62.Va period
63argument is the duration in nanoseconds of one complete on-off cycle, and the
64.Va duty
65argument is the duration in nanoseconds of the on portion of that cycle.
66.Pp
67Some PWM hardware is organized as a single controller with multiple channels.
68Channel numbers count up from zero.
69When multiple channels are present, they sometimes share a common clock or
70other resources.
71In such cases, changing the period or duty cycle of any one channel may affect
72other channels within the hardware which share the same resources.
73Consult the documentation for the underlying PWM hardware device driver for
74details on channels that share resources.
75.Sh INTERFACE
76.Bl -tag -width indent
77.It Fn PWMBUS_CHANNEL_CONFIG "device_t bus" "u_int channel" "u_int period" "u_int duty"
78Configure the period and duty (in nanoseconds) in the PWM controller on the bus
79for the specified channel.
80Returns 0 on success or
81.Er EINVAL
82if the values are not supported by the controller or
83.Er EBUSY
84if the PWMBUS controller is in use and does not support changing the value on
85the fly.
86.It Fn PWMBUS_CHANNEL_COUNT "device_t bus" "u_int *nchannel"
87Get the number of channels supported by the controller.
88.It Fn PWMBUS_CHANNEL_ENABLE "device_t bus" "u_int channel" "bool enable"
89Enable the PWM channel.
90.It Fn PWMBUS_CHANNEL_GET_CONFIG "device_t bus" "u_int channel" "u_int *period" "u_int *duty"
91Get the current configuration of the period and duty for the specified channel.
92.It Fn PWMBUS_CHANNEL_GET_FLAGS "device_t bus" "u_int channel" "uint32_t *flags"
93Get the current flags for the channel.
94If the driver or controller
95does not support this, a default method returns a flags value of zero.
96.It Fn PWMBUS_CHANNEL_IS_ENABLED "device_t bus" "u_int channel" "bool *enable"
97Test whether the PWM channel is enabled.
98.It Fn PWMBUS_CHANNEL_SET_FLAGS "device_t bus" "u_int channel" "uint32_t flags"
99Set the flags of the channel (such as inverted polarity).
100If the driver or controller does not support this a do-nothing default method
101is used.
102.El
103.Sh HISTORY
104The
105.Nm pwmbus
106interface first appear in
107.Fx 13.0 .
108The
109.Nm pwmbus
110interface and manual page was written by
111.An Emmanuel Vadot Aq Mt manu@FreeBSD.org .
112