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.\" 23*7d4a5de8SOskar Holmund.Dd March 9, 2021 249312900fSEmmanuel Vadot.Dt PWMBUS 9 259312900fSEmmanuel Vadot.Os 269312900fSEmmanuel Vadot.Sh NAME 279312900fSEmmanuel Vadot.Nm pwmbus , 289312900fSEmmanuel Vadot.Nm PWMBUS_CHANNEL_CONFIG , 291d90bbbbSIan Lepore.Nm PWMBUS_CHANNEL_COUNT , 309312900fSEmmanuel Vadot.Nm PWMBUS_CHANNEL_ENABLE , 311d90bbbbSIan Lepore.Nm PWMBUS_CHANNEL_GET_CONFIG , 321d90bbbbSIan Lepore.Nm PWMBUS_CHANNEL_GET_FLAGS , 339312900fSEmmanuel Vadot.Nm PWMBUS_CHANNEL_IS_ENABLED , 341d90bbbbSIan Lepore.Nm PWMBUS_CHANNEL_SET_FLAGS , 351d90bbbbSIan Lepore.Nm PWMBUS_GET_BUS 369312900fSEmmanuel Vadot.Nd PWMBUS methods 379312900fSEmmanuel Vadot.Sh SYNOPSIS 389312900fSEmmanuel Vadot.Cd "device pwm" 399312900fSEmmanuel Vadot.In "pwmbus_if.h" 409312900fSEmmanuel Vadot.Ft int 41*7d4a5de8SOskar Holmund.Fn PWMBUS_CHANNEL_CONFIG "device_t bus" "u_int channel" "u_int period" "u_int duty" 429312900fSEmmanuel Vadot.Ft int 43*7d4a5de8SOskar Holmund.Fn PWMBUS_CHANNEL_COUNT "device_t bus" "u_int *nchannel" 449312900fSEmmanuel Vadot.Ft int 45*7d4a5de8SOskar Holmund.Fn PWMBUS_CHANNEL_ENABLE "device_t bus" "u_int channel" "bool enable" 469312900fSEmmanuel Vadot.Ft int 47*7d4a5de8SOskar Holmund.Fn PWMBUS_CHANNEL_GET_CONFIG "device_t bus" "u_int channel" "u_int *period" "u_int *duty" 481d90bbbbSIan Lepore.Ft int 49*7d4a5de8SOskar Holmund.Fn PWMBUS_CHANNEL_GET_FLAGS "device_t bus" "u_int channel" "uint32_t *flags" 501d90bbbbSIan Lepore.Ft int 51*7d4a5de8SOskar Holmund.Fn PWMBUS_CHANNEL_IS_ENABLED "device_t bus" "u_int channel" "bool *enabled" 529312900fSEmmanuel Vadot.Ft int 53*7d4a5de8SOskar Holmund.Fn PWMBUS_CHANNEL_SET_FLAGS "device_t bus" "u_int channel" "uint32_t flags" 549312900fSEmmanuel Vadot.Sh DESCRIPTION 551d90bbbbSIan LeporeThe PWMBUS (Pulse-Width Modulation) interface allows a device driver to 561d90bbbbSIan Leporeregister to a global bus so other devices in the kernel can use them in a 571d90bbbbSIan Leporegeneric way. 581d90bbbbSIan Lepore.Pp 591d90bbbbSIan LeporeFor all 601d90bbbbSIan Lepore.Nm 611d90bbbbSIan Leporemethods, the 621d90bbbbSIan Lepore.Va period 631d90bbbbSIan Leporeargument is the duration in nanoseconds of one complete on-off cycle, and the 641d90bbbbSIan Lepore.Va duty 651d90bbbbSIan Leporeargument is the duration in nanoseconds of the on portion of that cycle. 661d90bbbbSIan Lepore.Pp 671d90bbbbSIan LeporeSome PWM hardware is organized as a single controller with multiple channels. 681d90bbbbSIan LeporeChannel numbers count up from zero. 691d90bbbbSIan LeporeWhen multiple channels are present, they sometimes share a common clock or 701d90bbbbSIan Leporeother resources. 711d90bbbbSIan LeporeIn such cases, changing the period or duty cycle of any one channel may affect 721d90bbbbSIan Leporeother channels within the hardware which share the same resources. 731d90bbbbSIan LeporeConsult the documentation for the underlying PWM hardware device driver for 741d90bbbbSIan Leporedetails on channels that share resources. 759312900fSEmmanuel Vadot.Sh INTERFACE 769312900fSEmmanuel Vadot.Bl -tag -width indent 77*7d4a5de8SOskar Holmund.It Fn PWMBUS_CHANNEL_CONFIG "device_t bus" "u_int channel" "u_int period" "u_int duty" 781d90bbbbSIan LeporeConfigure the period and duty (in nanoseconds) in the PWM controller on the bus 791d90bbbbSIan Leporefor the specified channel. 809312900fSEmmanuel VadotReturns 0 on success or 819312900fSEmmanuel Vadot.Er EINVAL 827202a380SIan Leporeif the values are not supported by the controller or 839312900fSEmmanuel Vadot.Er EBUSY 841d90bbbbSIan Leporeif the PWMBUS controller is in use and does not support changing the value on 851d90bbbbSIan Leporethe fly. 86*7d4a5de8SOskar Holmund.It Fn PWMBUS_CHANNEL_COUNT "device_t bus" "u_int *nchannel" 871d90bbbbSIan LeporeGet the number of channels supported by the controller. 88*7d4a5de8SOskar Holmund.It Fn PWMBUS_CHANNEL_ENABLE "device_t bus" "u_int channel" "bool enable" 891d90bbbbSIan LeporeEnable the PWM channel. 90*7d4a5de8SOskar Holmund.It Fn PWMBUS_CHANNEL_GET_CONFIG "device_t bus" "u_int channel" "u_int *period" "u_int *duty" 919312900fSEmmanuel VadotGet the current configuration of the period and duty for the specified channel. 92*7d4a5de8SOskar Holmund.It Fn PWMBUS_CHANNEL_GET_FLAGS "device_t bus" "u_int channel" "uint32_t *flags" 937202a380SIan LeporeGet the current flags for the channel. 947202a380SIan LeporeIf the driver or controller 951d90bbbbSIan Leporedoes not support this, a default method returns a flags value of zero. 96*7d4a5de8SOskar Holmund.It Fn PWMBUS_CHANNEL_IS_ENABLED "device_t bus" "u_int channel" "bool *enable" 971d90bbbbSIan LeporeTest whether the PWM channel is enabled. 98*7d4a5de8SOskar Holmund.It Fn PWMBUS_CHANNEL_SET_FLAGS "device_t bus" "u_int channel" "uint32_t flags" 991d90bbbbSIan LeporeSet the flags of the channel (such as inverted polarity). 1001d90bbbbSIan LeporeIf the driver or controller does not support this a do-nothing default method 1011d90bbbbSIan Leporeis used. 1029312900fSEmmanuel Vadot.El 1039312900fSEmmanuel Vadot.Sh HISTORY 1049312900fSEmmanuel VadotThe 1059312900fSEmmanuel Vadot.Nm pwmbus 1069312900fSEmmanuel Vadotinterface first appear in 1079312900fSEmmanuel Vadot.Fx 13.0 . 1089312900fSEmmanuel VadotThe 1099312900fSEmmanuel Vadot.Nm pwmbus 1109312900fSEmmanuel Vadotinterface and manual page was written by 1119312900fSEmmanuel Vadot.An Emmanuel Vadot Aq Mt manu@FreeBSD.org . 112