1*b2f0caf1SEmmanuel Vadot#- 2*b2f0caf1SEmmanuel Vadot# Copyright (c) 2016 Michal Meloun <mmel@FreeBSD.org> 3*b2f0caf1SEmmanuel Vadot# All rights reserved. 4*b2f0caf1SEmmanuel Vadot# 5*b2f0caf1SEmmanuel Vadot# Redistribution and use in source and binary forms, with or without 6*b2f0caf1SEmmanuel Vadot# modification, are permitted provided that the following conditions 7*b2f0caf1SEmmanuel Vadot# are met: 8*b2f0caf1SEmmanuel Vadot# 1. Redistributions of source code must retain the above copyright 9*b2f0caf1SEmmanuel Vadot# notice, this list of conditions and the following disclaimer. 10*b2f0caf1SEmmanuel Vadot# 2. Redistributions in binary form must reproduce the above copyright 11*b2f0caf1SEmmanuel Vadot# notice, this list of conditions and the following disclaimer in the 12*b2f0caf1SEmmanuel Vadot# documentation and/or other materials provided with the distribution. 13*b2f0caf1SEmmanuel Vadot# 14*b2f0caf1SEmmanuel Vadot# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*b2f0caf1SEmmanuel Vadot# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*b2f0caf1SEmmanuel Vadot# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*b2f0caf1SEmmanuel Vadot# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*b2f0caf1SEmmanuel Vadot# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*b2f0caf1SEmmanuel Vadot# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*b2f0caf1SEmmanuel Vadot# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*b2f0caf1SEmmanuel Vadot# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*b2f0caf1SEmmanuel Vadot# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*b2f0caf1SEmmanuel Vadot# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*b2f0caf1SEmmanuel Vadot# SUCH DAMAGE. 25*b2f0caf1SEmmanuel Vadot# 26*b2f0caf1SEmmanuel Vadot# 27*b2f0caf1SEmmanuel Vadot 28*b2f0caf1SEmmanuel VadotINTERFACE regnode; 29*b2f0caf1SEmmanuel VadotHEADER { 30*b2f0caf1SEmmanuel Vadot struct regnode; 31*b2f0caf1SEmmanuel Vadot} 32*b2f0caf1SEmmanuel Vadot 33*b2f0caf1SEmmanuel VadotCODE { 34*b2f0caf1SEmmanuel Vadot static int 35*b2f0caf1SEmmanuel Vadot regnode_default_stop(struct regnode *regnode, int *udelay) 36*b2f0caf1SEmmanuel Vadot { 37*b2f0caf1SEmmanuel Vadot 38*b2f0caf1SEmmanuel Vadot return(REGNODE_ENABLE(regnode, false, udelay)); 39*b2f0caf1SEmmanuel Vadot } 40*b2f0caf1SEmmanuel Vadot} 41*b2f0caf1SEmmanuel Vadot 42*b2f0caf1SEmmanuel Vadot# 43*b2f0caf1SEmmanuel Vadot# Initialize regulator 44*b2f0caf1SEmmanuel Vadot# Returns 0 on success or a standard errno value. 45*b2f0caf1SEmmanuel Vadot# 46*b2f0caf1SEmmanuel VadotMETHOD int init { 47*b2f0caf1SEmmanuel Vadot struct regnode *regnode; 48*b2f0caf1SEmmanuel Vadot}; 49*b2f0caf1SEmmanuel Vadot 50*b2f0caf1SEmmanuel Vadot# 51*b2f0caf1SEmmanuel Vadot# Enable/disable regulator 52*b2f0caf1SEmmanuel Vadot# Returns 0 on success or a standard errno value. 53*b2f0caf1SEmmanuel Vadot# - enable - input. 54*b2f0caf1SEmmanuel Vadot# - delay - output, delay needed to stabilize voltage (in us) 55*b2f0caf1SEmmanuel Vadot# 56*b2f0caf1SEmmanuel VadotMETHOD int enable { 57*b2f0caf1SEmmanuel Vadot struct regnode *regnode; 58*b2f0caf1SEmmanuel Vadot bool enable; 59*b2f0caf1SEmmanuel Vadot int *udelay; 60*b2f0caf1SEmmanuel Vadot}; 61*b2f0caf1SEmmanuel Vadot 62*b2f0caf1SEmmanuel Vadot# 63*b2f0caf1SEmmanuel Vadot# Get regulator status 64*b2f0caf1SEmmanuel Vadot# Returns 0 on success or a standard errno value. 65*b2f0caf1SEmmanuel Vadot# 66*b2f0caf1SEmmanuel VadotMETHOD int status { 67*b2f0caf1SEmmanuel Vadot struct regnode *regnode; 68*b2f0caf1SEmmanuel Vadot int *status; /* REGULATOR_STATUS_* */ 69*b2f0caf1SEmmanuel Vadot}; 70*b2f0caf1SEmmanuel Vadot 71*b2f0caf1SEmmanuel Vadot# 72*b2f0caf1SEmmanuel Vadot# Set regulator voltage 73*b2f0caf1SEmmanuel Vadot# Returns 0 on success or a standard errno value. 74*b2f0caf1SEmmanuel Vadot# - min_uvolt, max_uvolt - input, requested voltage range (in uV) 75*b2f0caf1SEmmanuel Vadot# - delay - output, delay needed to stabilize voltage (in us) 76*b2f0caf1SEmmanuel VadotMETHOD int set_voltage { 77*b2f0caf1SEmmanuel Vadot struct regnode *regnode; 78*b2f0caf1SEmmanuel Vadot int min_uvolt; 79*b2f0caf1SEmmanuel Vadot int max_uvolt; 80*b2f0caf1SEmmanuel Vadot int *udelay; 81*b2f0caf1SEmmanuel Vadot}; 82*b2f0caf1SEmmanuel Vadot 83*b2f0caf1SEmmanuel Vadot# 84*b2f0caf1SEmmanuel Vadot# Get regulator voltage 85*b2f0caf1SEmmanuel Vadot# Returns 0 on success or a standard errno value. 86*b2f0caf1SEmmanuel Vadot# 87*b2f0caf1SEmmanuel VadotMETHOD int get_voltage { 88*b2f0caf1SEmmanuel Vadot struct regnode *regnode; 89*b2f0caf1SEmmanuel Vadot int *uvolt; 90*b2f0caf1SEmmanuel Vadot}; 91*b2f0caf1SEmmanuel Vadot 92*b2f0caf1SEmmanuel Vadot# 93*b2f0caf1SEmmanuel Vadot# Check if a given voltage is supported by the regulator 94*b2f0caf1SEmmanuel Vadot# Returns 0 on success or a standard errno value. 95*b2f0caf1SEmmanuel Vadot# 96*b2f0caf1SEmmanuel VadotMETHOD int check_voltage { 97*b2f0caf1SEmmanuel Vadot struct regnode *regnode; 98*b2f0caf1SEmmanuel Vadot int uvolt; 99*b2f0caf1SEmmanuel Vadot}; 100*b2f0caf1SEmmanuel Vadot 101*b2f0caf1SEmmanuel Vadot# 102*b2f0caf1SEmmanuel Vadot# Stop (shutdown) regulator 103*b2f0caf1SEmmanuel Vadot# Returns 0 on success or a standard errno value. 104*b2f0caf1SEmmanuel Vadot# 105*b2f0caf1SEmmanuel VadotMETHOD int stop { 106*b2f0caf1SEmmanuel Vadot struct regnode *regnode; 107*b2f0caf1SEmmanuel Vadot int *udelay; 108*b2f0caf1SEmmanuel Vadot} DEFAULT regnode_default_stop; 109