19312900fSEmmanuel Vadot.\" Copyright (c) 2018 Emmanuel Vadot <manu@freebsd.org> 29312900fSEmmanuel Vadot.\" 39312900fSEmmanuel Vadot.\" Redistribution and use in source and binary forms, with or without 49312900fSEmmanuel Vadot.\" modification, are permitted provided that the following conditions 59312900fSEmmanuel Vadot.\" are met: 69312900fSEmmanuel Vadot.\" 1. Redistributions of source code must retain the above copyright 79312900fSEmmanuel Vadot.\" notice, this list of conditions and the following disclaimer. 89312900fSEmmanuel Vadot.\" 2. Redistributions in binary form must reproduce the above copyright 99312900fSEmmanuel Vadot.\" notice, this list of conditions and the following disclaimer in the 109312900fSEmmanuel Vadot.\" documentation and/or other materials provided with the distribution. 119312900fSEmmanuel Vadot.\" 129312900fSEmmanuel Vadot.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 139312900fSEmmanuel Vadot.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 149312900fSEmmanuel Vadot.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 159312900fSEmmanuel Vadot.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 169312900fSEmmanuel Vadot.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 179312900fSEmmanuel Vadot.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 189312900fSEmmanuel Vadot.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 199312900fSEmmanuel Vadot.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 209312900fSEmmanuel Vadot.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 219312900fSEmmanuel Vadot.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 229312900fSEmmanuel Vadot.\" 239312900fSEmmanuel Vadot.\" $FreeBSD$ 249312900fSEmmanuel Vadot.\" 257202a380SIan Lepore.Dd June 21, 2019 269312900fSEmmanuel Vadot.Dt PWMBUS 9 279312900fSEmmanuel Vadot.Os 289312900fSEmmanuel Vadot.Sh NAME 299312900fSEmmanuel Vadot.Nm pwmbus , 309312900fSEmmanuel Vadot.Nm PWMBUS_CHANNEL_CONFIG , 31*1d90bbbbSIan Lepore.Nm PWMBUS_CHANNEL_COUNT , 329312900fSEmmanuel Vadot.Nm PWMBUS_CHANNEL_ENABLE , 33*1d90bbbbSIan Lepore.Nm PWMBUS_CHANNEL_GET_CONFIG , 34*1d90bbbbSIan Lepore.Nm PWMBUS_CHANNEL_GET_FLAGS , 359312900fSEmmanuel Vadot.Nm PWMBUS_CHANNEL_IS_ENABLED , 36*1d90bbbbSIan Lepore.Nm PWMBUS_CHANNEL_SET_FLAGS , 37*1d90bbbbSIan Lepore.Nm PWMBUS_GET_BUS 389312900fSEmmanuel Vadot.Nd PWMBUS methods 399312900fSEmmanuel Vadot.Sh SYNOPSIS 409312900fSEmmanuel Vadot.Cd "device pwm" 419312900fSEmmanuel Vadot.In "pwmbus_if.h" 429312900fSEmmanuel Vadot.Ft int 439312900fSEmmanuel Vadot.Fn PWMBUS_CHANNEL_CONFIG "device_t bus" "int channel" "uint64_t period" "uint64_t duty" 449312900fSEmmanuel Vadot.Ft int 45*1d90bbbbSIan Lepore.Fn PWMBUS_CHANNEL_COUNT "device_t bus" "int channel" "int *nchannel" 469312900fSEmmanuel Vadot.Ft int 479312900fSEmmanuel Vadot.Fn PWMBUS_CHANNEL_ENABLE "device_t bus" "int channel" "bool enable" 489312900fSEmmanuel Vadot.Ft int 49*1d90bbbbSIan Lepore.Fn PWMBUS_CHANNEL_GET_CONFIG "device_t bus" "int channel" "uint64_t *period" "uint64_t *duty" 50*1d90bbbbSIan Lepore.Ft int 51*1d90bbbbSIan Lepore.Fn PWMBUS_CHANNEL_GET_FLAGS "device_t bus" "int channel" "uint32_t *flags" 52*1d90bbbbSIan Lepore.Ft int 539312900fSEmmanuel Vadot.Fn PWMBUS_CHANNEL_IS_ENABLED "device_t bus" "int channel" "bool *enabled" 549312900fSEmmanuel Vadot.Ft int 55*1d90bbbbSIan Lepore.Fn PWMBUS_CHANNEL_SET_FLAGS "device_t bus" "int channel" "uint32_t flags" 569312900fSEmmanuel Vadot.Sh DESCRIPTION 57*1d90bbbbSIan LeporeThe PWMBUS (Pulse-Width Modulation) interface allows a device driver to 58*1d90bbbbSIan Leporeregister to a global bus so other devices in the kernel can use them in a 59*1d90bbbbSIan Leporegeneric way. 60*1d90bbbbSIan Lepore.Pp 61*1d90bbbbSIan LeporeFor all 62*1d90bbbbSIan Lepore.Nm 63*1d90bbbbSIan Leporemethods, the 64*1d90bbbbSIan Lepore.Va period 65*1d90bbbbSIan Leporeargument is the duration in nanoseconds of one complete on-off cycle, and the 66*1d90bbbbSIan Lepore.Va duty 67*1d90bbbbSIan Leporeargument is the duration in nanoseconds of the on portion of that cycle. 68*1d90bbbbSIan Lepore.Pp 69*1d90bbbbSIan LeporeSome PWM hardware is organized as a single controller with multiple channels. 70*1d90bbbbSIan LeporeChannel numbers count up from zero. 71*1d90bbbbSIan LeporeWhen multiple channels are present, they sometimes share a common clock or 72*1d90bbbbSIan Leporeother resources. 73*1d90bbbbSIan LeporeIn such cases, changing the period or duty cycle of any one channel may affect 74*1d90bbbbSIan Leporeother channels within the hardware which share the same resources. 75*1d90bbbbSIan LeporeConsult the documentation for the underlying PWM hardware device driver for 76*1d90bbbbSIan Leporedetails on channels that share resources. 779312900fSEmmanuel Vadot.Sh INTERFACE 789312900fSEmmanuel Vadot.Bl -tag -width indent 799312900fSEmmanuel Vadot.It Fn PWMBUS_CHANNEL_CONFIG "device_t bus" "int channel" "uint64_t period" "uint64_t duty" 80*1d90bbbbSIan LeporeConfigure the period and duty (in nanoseconds) in the PWM controller on the bus 81*1d90bbbbSIan Leporefor the specified channel. 829312900fSEmmanuel VadotReturns 0 on success or 839312900fSEmmanuel Vadot.Er EINVAL 847202a380SIan Leporeif the values are not supported by the controller or 859312900fSEmmanuel Vadot.Er EBUSY 86*1d90bbbbSIan Leporeif the PWMBUS controller is in use and does not support changing the value on 87*1d90bbbbSIan Leporethe fly. 88*1d90bbbbSIan Lepore.It Fn PWMBUS_CHANNEL_COUNT "device_t bus" "int *nchannel" 89*1d90bbbbSIan LeporeGet the number of channels supported by the controller. 90*1d90bbbbSIan Lepore.It Fn PWMBUS_CHANNEL_ENABLE "device_t bus" "int channel" "bool enable" 91*1d90bbbbSIan LeporeEnable the PWM channel. 929312900fSEmmanuel Vadot.It Fn PWMBUS_CHANNEL_GET_CONFIG "device_t bus" "int channel" "uint64_t *period" "uint64_t *duty" 939312900fSEmmanuel VadotGet the current configuration of the period and duty for the specified channel. 949312900fSEmmanuel Vadot.It Fn PWMBUS_CHANNEL_GET_FLAGS "device_t bus" "int channel" "uint32_t *flags" 957202a380SIan LeporeGet the current flags for the channel. 967202a380SIan LeporeIf the driver or controller 97*1d90bbbbSIan Leporedoes not support this, a default method returns a flags value of zero. 98*1d90bbbbSIan Lepore.It Fn PWMBUS_CHANNEL_IS_ENABLED "device_t bus" "int channel" "bool *enable" 99*1d90bbbbSIan LeporeTest whether the PWM channel is enabled. 100*1d90bbbbSIan Lepore.It Fn PWMBUS_CHANNEL_SET_FLAGS "device_t bus" "int channel" "uint32_t flags" 101*1d90bbbbSIan LeporeSet the flags of the channel (such as inverted polarity). 102*1d90bbbbSIan LeporeIf the driver or controller does not support this a do-nothing default method 103*1d90bbbbSIan Leporeis used. 1049312900fSEmmanuel Vadot.El 1059312900fSEmmanuel Vadot.Sh HISTORY 1069312900fSEmmanuel VadotThe 1079312900fSEmmanuel Vadot.Nm pwmbus 1089312900fSEmmanuel Vadotinterface first appear in 1099312900fSEmmanuel Vadot.Fx 13.0 . 1109312900fSEmmanuel VadotThe 1119312900fSEmmanuel Vadot.Nm pwmbus 1129312900fSEmmanuel Vadotinterface and manual page was written by 1139312900fSEmmanuel Vadot.An Emmanuel Vadot Aq Mt manu@FreeBSD.org . 114