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.\" $FreeBSD$ 24.\" 25.Dd November 12, 2018 26.Dt PWMBUS 9 27.Os 28.Sh NAME 29.Nm pwmbus , 30.Nm pwmbus_attach_bus , 31.Nm PWMBUS_GET_BUS , 32.Nm PWMBUS_CHANNEL_CONFIG , 33.Nm PWMBUS_CHANNEL_GET_CONFIG , 34.Nm PWMBUS_CHANNEL_SET_FLAGS , 35.Nm PWMBUS_CHANNEL_GET_FLAGS , 36.Nm PWMBUS_CHANNEL_ENABLE , 37.Nm PWMBUS_CHANNEL_IS_ENABLED , 38.Nm PWMBUS_CHANNEL_MAX 39.Nd PWMBUS methods 40.Sh SYNOPSIS 41.Cd "device pwm" 42.In "pwmbus_if.h" 43.Ft device_t 44.Fn pwmbus_attach_bus "device_t dev" 45.Ft int 46.Fn PWMBUS_CHANNEL_CONFIG "device_t bus" "int channel" "uint64_t period" "uint64_t duty" 47.Ft int 48.Fn PWMBUS_CHANNEL_GET_CONFIG "device_t bus" "int channel" "uint64_t *period" "uint64_t *duty" 49.Ft int 50.Fn PWMBUS_CHANNEL_SET_FLAGS "device_t bus" "int channel" "uint32_t flags" 51.Ft int 52.Fn PWMBUS_CHANNEL_GET_FLAGS "device_t bus" "int channel" "uint32_t *flags" 53.Ft int 54.Fn PWMBUS_CHANNEL_ENABLE "device_t bus" "int channel" "bool enable" 55.Ft int 56.Fn PWMBUS_CHANNEL_IS_ENABLED "device_t bus" "int channel" "bool *enabled" 57.Ft int 58.Fn PWMBUS_CHANNEL_MAX "device_t bus" "int channel" "int *nchannel" 59.Sh DESCRIPTION 60The PWMBUS (Pulse-Width Modulation) interface allows the device driver to register to a global 61bus so other devices in the kernel can use them in a generic way 62.Sh INTERFACE 63.Bl -tag -width indent 64.It Fn pwmbus_attach_bus "device_t dev" 65Attach the 66.Nm pwmbus 67to the device driver 68.It Fn PWMBUS_CHANNEL_CONFIG "device_t bus" "int channel" "uint64_t period" "uint64_t duty" 69Configure the period and duty (in nanoseconds) in the PWM controller on the bus for the specified channel. 70Returns 0 on success or 71.Er EINVAL 72is the values are not supported by the controller or 73.Er EBUSY 74is the PWMBUS controller is in use and doesn't support changing the value on the fly. 75.It Fn PWMBUS_CHANNEL_GET_CONFIG "device_t bus" "int channel" "uint64_t *period" "uint64_t *duty" 76Get the current configuration of the period and duty for the specified channel. 77.It Fn PWMBUS_CHANNEL_SET_FLAGS "device_t bus" "int channel" "uint32_t flags" 78Set the flags of the channel (like inverted polarity), if the driver or controller 79doesn't support this a default method is used. 80.It Fn PWMBUS_CHANNEL_GET_FLAGS "device_t bus" "int channel" "uint32_t *flags" 81Get the current flags for the channel, if the driver or controller 82doesn't support this, a default method is used. 83.It Fn PWMBUS_CHANNEL_ENABLE "device_t bus" "int channel" "bool enable" 84Enable the PWM channel. 85.It Fn PWMBUS_CHANNEL_ISENABLED "device_t bus" "int channel" "bool *enable" 86Test if the PWM channel is enabled. 87.It PWMBUS_CHANNEL_MAX "device_t bus" "int channel" "int *nchannel" 88Get the maximum number of channel supported by the controller. 89.El 90.Sh HISTORY 91The 92.Nm pwmbus 93interface first appear in 94.Fx 13.0 . 95The 96.Nm pwmbus 97interface and manual page was written by 98.An Emmanuel Vadot Aq Mt manu@FreeBSD.org . 99