xref: /openbmc/u-boot/include/tps6586x.h (revision 1aa7e23e2ba41c94d61bcd9199afb23817400f3c)
1*1aa7e23eSSimon Glass /*
2*1aa7e23eSSimon Glass  *  (C) Copyright 2010,2011
3*1aa7e23eSSimon Glass  *  NVIDIA Corporation <www.nvidia.com>
4*1aa7e23eSSimon Glass  *
5*1aa7e23eSSimon Glass  * See file CREDITS for list of people who contributed to this
6*1aa7e23eSSimon Glass  * project.
7*1aa7e23eSSimon Glass  *
8*1aa7e23eSSimon Glass  * This program is free software; you can redistribute it and/or
9*1aa7e23eSSimon Glass  * modify it under the terms of the GNU General Public License as
10*1aa7e23eSSimon Glass  * published by the Free Software Foundation; either version 2 of
11*1aa7e23eSSimon Glass  * the License, or (at your option) any later version.
12*1aa7e23eSSimon Glass  *
13*1aa7e23eSSimon Glass  * This program is distributed in the hope that it will be useful,
14*1aa7e23eSSimon Glass  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15*1aa7e23eSSimon Glass  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16*1aa7e23eSSimon Glass  * GNU General Public License for more details.
17*1aa7e23eSSimon Glass  *
18*1aa7e23eSSimon Glass  * You should have received a copy of the GNU General Public License
19*1aa7e23eSSimon Glass  * along with this program; if not, write to the Free Software
20*1aa7e23eSSimon Glass  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21*1aa7e23eSSimon Glass  * MA 02111-1307 USA
22*1aa7e23eSSimon Glass  */
23*1aa7e23eSSimon Glass 
24*1aa7e23eSSimon Glass #ifndef __H_
25*1aa7e23eSSimon Glass #define _TPS6586X_H_
26*1aa7e23eSSimon Glass 
27*1aa7e23eSSimon Glass enum {
28*1aa7e23eSSimon Glass 	/* SM0-2 PWM/PFM Mode Selection */
29*1aa7e23eSSimon Glass 	TPS6586X_PWM_SM0	= 1 << 0,
30*1aa7e23eSSimon Glass 	TPS6586X_PWM_SM1	= 1 << 1,
31*1aa7e23eSSimon Glass 	TPS6586X_PWM_SM2	= 1 << 2,
32*1aa7e23eSSimon Glass };
33*1aa7e23eSSimon Glass 
34*1aa7e23eSSimon Glass /**
35*1aa7e23eSSimon Glass  * Enable PWM mode for selected SM0-2
36*1aa7e23eSSimon Glass  *
37*1aa7e23eSSimon Glass  * @param mask	Mask of synchronous converter to enable (TPS6586X_PWM_...)
38*1aa7e23eSSimon Glass  * @return 0 if ok, -1 on error
39*1aa7e23eSSimon Glass  */
40*1aa7e23eSSimon Glass int tps6586x_set_pwm_mode(int mask);
41*1aa7e23eSSimon Glass 
42*1aa7e23eSSimon Glass /**
43*1aa7e23eSSimon Glass  * Adjust SM0 and SM1 voltages to the given targets in incremental steps.
44*1aa7e23eSSimon Glass  *
45*1aa7e23eSSimon Glass  * @param sm0_target	Target voltage for SM0 in 25mW units, 0=725mV, 31=1.5V
46*1aa7e23eSSimon Glass  * @param sm1_target	Target voltage for SM1 in 25mW units, 0=725mV, 31=1.5V
47*1aa7e23eSSimon Glass  * @param step		Amount to change voltage in each step, in 25mW units
48*1aa7e23eSSimon Glass  * @param rate		Slew ratein mV/us: 0=instantly, 1=0.11, 2=0.22,
49*1aa7e23eSSimon Glass  *			3=0.44, 4=0.88, 5=1.76, 6=3.52, 7=7.04
50*1aa7e23eSSimon Glass  * @param min_sm0_over_sm1	Minimum amount by which sm0 must exceed sm1.
51*1aa7e23eSSimon Glass  *			If this condition is not met, no adjustment will be
52*1aa7e23eSSimon Glass  *			done and an error will be reported. Use -1 to skip
53*1aa7e23eSSimon Glass  *			this check.
54*1aa7e23eSSimon Glass  * @return 0 if ok, -1 on error
55*1aa7e23eSSimon Glass  */
56*1aa7e23eSSimon Glass int tps6586x_adjust_sm0_sm1(int sm0_target, int sm1_target, int step, int rate,
57*1aa7e23eSSimon Glass 			    int min_sm0_over_sm1);
58*1aa7e23eSSimon Glass 
59*1aa7e23eSSimon Glass /**
60*1aa7e23eSSimon Glass  * Set up the TPS6586X I2C bus number. This will be used for all operations
61*1aa7e23eSSimon Glass  * on the device. This function must be called before using other functions.
62*1aa7e23eSSimon Glass  *
63*1aa7e23eSSimon Glass  * @param bus	I2C bus number containing the TPS6586X chip
64*1aa7e23eSSimon Glass  * @return 0 (always succeeds)
65*1aa7e23eSSimon Glass  */
66*1aa7e23eSSimon Glass int tps6586x_init(int bus);
67*1aa7e23eSSimon Glass 
68*1aa7e23eSSimon Glass #endif	/* _TPS6586X_H_ */
69