1*395d907eSEmmanuel Vadot.\" Copyright (c) 2021 Emmanuel Vadot <manu@freebsd.org> 2*395d907eSEmmanuel Vadot.\" 3*395d907eSEmmanuel Vadot.\" Redistribution and use in source and binary forms, with or without 4*395d907eSEmmanuel Vadot.\" modification, are permitted provided that the following conditions 5*395d907eSEmmanuel Vadot.\" are met: 6*395d907eSEmmanuel Vadot.\" 1. Redistributions of source code must retain the above copyright 7*395d907eSEmmanuel Vadot.\" notice, this list of conditions and the following disclaimer. 8*395d907eSEmmanuel Vadot.\" 2. Redistributions in binary form must reproduce the above copyright 9*395d907eSEmmanuel Vadot.\" notice, this list of conditions and the following disclaimer in the 10*395d907eSEmmanuel Vadot.\" documentation and/or other materials provided with the distribution. 11*395d907eSEmmanuel Vadot.\" 12*395d907eSEmmanuel Vadot.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 13*395d907eSEmmanuel Vadot.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 14*395d907eSEmmanuel Vadot.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 15*395d907eSEmmanuel Vadot.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 16*395d907eSEmmanuel Vadot.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 17*395d907eSEmmanuel Vadot.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 18*395d907eSEmmanuel Vadot.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 19*395d907eSEmmanuel Vadot.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20*395d907eSEmmanuel Vadot.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 21*395d907eSEmmanuel Vadot.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22*395d907eSEmmanuel Vadot.\" 23*395d907eSEmmanuel Vadot.Dd June 14, 2021 24*395d907eSEmmanuel Vadot.Dt REGULATOR 9 25*395d907eSEmmanuel Vadot.Os 26*395d907eSEmmanuel Vadot.Sh NAME 27*395d907eSEmmanuel Vadot.Nm regulator , 28*395d907eSEmmanuel Vadot.Nm regulator_get_by_name , 29*395d907eSEmmanuel Vadot.Nm regulator_get_by_id , 30*395d907eSEmmanuel Vadot.Nm regulator_release , 31*395d907eSEmmanuel Vadot.Nm regulator_get_name , 32*395d907eSEmmanuel Vadot.Nm regulator_enable , 33*395d907eSEmmanuel Vadot.Nm regulator_disable , 34*395d907eSEmmanuel Vadot.Nm regulator_stop , 35*395d907eSEmmanuel Vadot.Nm regulator_status , 36*395d907eSEmmanuel Vadot.Nm regulator_get_voltage , 37*395d907eSEmmanuel Vadot.Nm regulator_set_voltage , 38*395d907eSEmmanuel Vadot.Nm regulator_check_voltage , 39*395d907eSEmmanuel Vadot.Nm regulator_get_by_ofw_property 40*395d907eSEmmanuel Vadot.Nd regulator methods 41*395d907eSEmmanuel Vadot.Sh SYNOPSIS 42*395d907eSEmmanuel Vadot.Cd "device regulator" 43*395d907eSEmmanuel Vadot.In "dev/extres/regulator/regulator.h" 44*395d907eSEmmanuel Vadot.Ft int 45*395d907eSEmmanuel Vadot.Fn regulator_get_by_name "device_t cdev" "const char *name" "regulator_t *regulator" 46*395d907eSEmmanuel Vadot.Ft int 47*395d907eSEmmanuel Vadot.Fn regulator_get_by_id "device_t cdev" "device_t pdev" "intptr_t id" "regulator_t *regulator" 48*395d907eSEmmanuel Vadot.Ft int 49*395d907eSEmmanuel Vadot.Fn regulator_release "regulator_t regulator" 50*395d907eSEmmanuel Vadot.Ft int 51*395d907eSEmmanuel Vadot.Fn regulator_get_name "regulator_t regulator" 52*395d907eSEmmanuel Vadot.Ft int 53*395d907eSEmmanuel Vadot.Fn regulator_enable "regulator_t reg" 54*395d907eSEmmanuel Vadot.Ft int 55*395d907eSEmmanuel Vadot.Fn regulator_disable "regulator_t reg" 56*395d907eSEmmanuel Vadot.Ft int 57*395d907eSEmmanuel Vadot.Fn regulator_stop "regulator_t reg" 58*395d907eSEmmanuel Vadot.Ft int 59*395d907eSEmmanuel Vadot.Fn regulator_status "regulator_t reg" "int *status" 60*395d907eSEmmanuel Vadot.Ft int 61*395d907eSEmmanuel Vadot.Fn regulator_get_voltage "regulator_t reg" "int *uvolt" 62*395d907eSEmmanuel Vadot.Ft int 63*395d907eSEmmanuel Vadot.Fn regulator_set_voltage "regulator_t reg" "int min_uvolt" "int max_uvolt" 64*395d907eSEmmanuel Vadot.Ft int 65*395d907eSEmmanuel Vadot.Fn regulator_check_voltage "regulator_t reg" "int uvolt" 66*395d907eSEmmanuel Vadot.Ft int 67*395d907eSEmmanuel Vadot.Fn regulator_get_by_ofw_property "device_t dev" "phandle_t node" "char *name" "regulator_t *reg" 68*395d907eSEmmanuel Vadot.Sh DESCRIPTION 69*395d907eSEmmanuel VadotThe regulator framework allow drivers to enable, disable and change regulator voltage. 70*395d907eSEmmanuel Vadot.Sh RETURN VALUES 71*395d907eSEmmanuel VadotAll functions returns 0 on success or 72*395d907eSEmmanuel Vadot.Er ENODEV 73*395d907eSEmmanuel Vadotif the regulator or one of its parent was not found. 74*395d907eSEmmanuel Vadot.Sh INTERFACE 75*395d907eSEmmanuel Vadot.Bl -tag -width indent 76*395d907eSEmmanuel Vadot.It Fn regulator_get_by_name "device_t cdev" "const char *name" "regulator_t *regulator" 77*395d907eSEmmanuel VadotResolve a regulator based on its name. 78*395d907eSEmmanuel VadotAll regulators names are unique. 79*395d907eSEmmanuel VadotThis will also increment the refcount on the regulator. 80*395d907eSEmmanuel Vadot.It Fn regulator_get_by_id "device_t cdev" "device_t pdev" "intptr_t id" "regulator_t *regulator" 81*395d907eSEmmanuel VadotResolve a regulator based on its id. 82*395d907eSEmmanuel VadotAll regulators ids are unique. 83*395d907eSEmmanuel VadotThis will also increment the refcount on the regulator. 84*395d907eSEmmanuel Vadot.It Fn regulator_get_by_ofw_property "device_t dev" "phandle_t node" "char *name" "regulator_t *reg" 85*395d907eSEmmanuel VadotResolve a regulator based on the fdt property named name. 86*395d907eSEmmanuel VadotIf node is 0 then the function will get the ofw node itself. 87*395d907eSEmmanuel VadotThis will also increment the refcount on the regulator. 88*395d907eSEmmanuel VadotReturns 0 on success or 89*395d907eSEmmanuel Vadot.Er ENOENT 90*395d907eSEmmanuel Vadotif the ofw property does not exists. 91*395d907eSEmmanuel Vadot.It Fn regulator_release "regulator_t regulator" 92*395d907eSEmmanuel VadotThis disables the regulator, decrements the refcount on it and frees the regulator variable passed. 93*395d907eSEmmanuel Vadot.It Fn regulator_get_name "regulator_t regulator" 94*395d907eSEmmanuel VadotReturns the name of the regulator. 95*395d907eSEmmanuel VadotAll regulator names are unique. 96*395d907eSEmmanuel Vadot.It Fn regulator_enable "regulator_t reg" 97*395d907eSEmmanuel VadotEnable the regulator. 98*395d907eSEmmanuel VadotIf the regulator supports a voltage range, the one configured in the hardware will be the output voltage. 99*395d907eSEmmanuel VadotIf the regulator was already enabled by another driver this simply increments the enable counter. 100*395d907eSEmmanuel Vadot.It Fn regulator_disable "regulator_t reg" 101*395d907eSEmmanuel VadotDisable the regulator. 102*395d907eSEmmanuel VadotIf the regulator was also enabled by another driver this simply decrements the enable counter. 103*395d907eSEmmanuel VadotIf the regulator was not previously enabled we will kassert. 104*395d907eSEmmanuel Vadot.It Fn regulator_stop "regulator_t reg" 105*395d907eSEmmanuel VadotDisable the regulator in hardware. 106*395d907eSEmmanuel VadotThis ensures the regulator is disabled even if it was enabled by bootloader. 107*395d907eSEmmanuel VadotThis should not be called on regulator that has previously been enabled by a driver. 108*395d907eSEmmanuel VadotReturns 0 on success or 109*395d907eSEmmanuel Vadot.Er EBUSY 110*395d907eSEmmanuel Vadotif another consumer enabled it. 111*395d907eSEmmanuel Vadot.It Fn regulator_status "regulator_t reg" "int *status" 112*395d907eSEmmanuel VadotGet the hardware status of the regulator. 113*395d907eSEmmanuel Vadotstatus will contain a bit mask with 114*395d907eSEmmanuel Vadotthoses possible value : 115*395d907eSEmmanuel Vadot.Bl -tag -width indent 116*395d907eSEmmanuel Vadot.It REGULATOR_STATUS_ENABLED 117*395d907eSEmmanuel VadotThe regulator is enabled. 118*395d907eSEmmanuel Vadot.It REGULATOR_STATUS_OVERCURRENT 119*395d907eSEmmanuel VadotThe hardware reports that too much current is being drawn. 120*395d907eSEmmanuel Vadot.El 121*395d907eSEmmanuel Vadot.It Fn regulator_get_voltage "regulator_t reg" "int *uvolt" 122*395d907eSEmmanuel VadotGet the current voltage set for the regulator in microvolts. 123*395d907eSEmmanuel Vadot.It Fn regulator_set_voltage "regulator_t reg" "int min_uvolt" "int max_uvolt" 124*395d907eSEmmanuel VadotChange the voltage for the regulator. 125*395d907eSEmmanuel VadotIf a range is acceptable by the hardware or driver different values can be provided as min and max. 126*395d907eSEmmanuel VadotReturns 0 on success or 127*395d907eSEmmanuel Vadot.Er ERANGE 128*395d907eSEmmanuel Vadotif the regulator doesn't support this voltage range. 129*395d907eSEmmanuel Vadot.It Fn regulator_check_voltage "regulator_t reg" "int uvolt" 130*395d907eSEmmanuel VadotChecks if the regulator support the given voltage. 131*395d907eSEmmanuel VadotReturns 0 on success or 132*395d907eSEmmanuel Vadot.Er ERANGE 133*395d907eSEmmanuel Vadotif the regulator doesn't support this voltage range. 134*395d907eSEmmanuel Vadot.El 135*395d907eSEmmanuel Vadot.Sh HISTORY 136*395d907eSEmmanuel VadotThe 137*395d907eSEmmanuel Vadot.Nm regulator 138*395d907eSEmmanuel Vadotframework first appear in 139*395d907eSEmmanuel Vadot.Fx 12.0 . 140*395d907eSEmmanuel VadotThe 141*395d907eSEmmanuel Vadot.Nm regulator 142*395d907eSEmmanuel Vadotframework was written by 143*395d907eSEmmanuel Vadot.An Michal Meloun Aq Mt mmel@FreeBSD.org . 144*395d907eSEmmanuel VadotThe 145*395d907eSEmmanuel Vadot.Nm regulator 146*395d907eSEmmanuel Vadotmanual page was written by 147*395d907eSEmmanuel Vadot.An Emmanuel Vadot Aq Mt manu@FreeBSD.org . 148