155f4fa4eSRobert Jarzmik /*
255f4fa4eSRobert Jarzmik  * max1586.h  --  Voltage regulation for the Maxim 1586
355f4fa4eSRobert Jarzmik  *
455f4fa4eSRobert Jarzmik  * Copyright (C) 2008 Robert Jarzmik
555f4fa4eSRobert Jarzmik  *
655f4fa4eSRobert Jarzmik  * This program is free software; you can redistribute it and/or modify
755f4fa4eSRobert Jarzmik  * it under the terms of the GNU General Public License as published by
855f4fa4eSRobert Jarzmik  * the Free Software Foundation; either version 2 of the License, or
955f4fa4eSRobert Jarzmik  * (at your option) any later version.
1055f4fa4eSRobert Jarzmik  *
1155f4fa4eSRobert Jarzmik  * This program is distributed in the hope that it will be useful,
1255f4fa4eSRobert Jarzmik  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1355f4fa4eSRobert Jarzmik  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1455f4fa4eSRobert Jarzmik  * GNU General Public License for more details.
1555f4fa4eSRobert Jarzmik  *
1655f4fa4eSRobert Jarzmik  * You should have received a copy of the GNU General Public License
1755f4fa4eSRobert Jarzmik  * along with this program; if not, write to the Free Software
1855f4fa4eSRobert Jarzmik  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1955f4fa4eSRobert Jarzmik  */
2055f4fa4eSRobert Jarzmik 
2155f4fa4eSRobert Jarzmik #ifndef REGULATOR_MAX1586
2255f4fa4eSRobert Jarzmik #define REGULATOR_MAX1586
2355f4fa4eSRobert Jarzmik 
2455f4fa4eSRobert Jarzmik #include <linux/regulator/machine.h>
2555f4fa4eSRobert Jarzmik 
2655f4fa4eSRobert Jarzmik #define MAX1586_V3 0
2755f4fa4eSRobert Jarzmik #define MAX1586_V6 1
2855f4fa4eSRobert Jarzmik 
29b110a8fbSPhilipp Zabel /* precalculated values for v3_gain */
30b110a8fbSPhilipp Zabel #define MAX1586_GAIN_NO_R24   1000000  /* 700000 .. 1475000 mV */
31b110a8fbSPhilipp Zabel #define MAX1586_GAIN_R24_3k32 1051098  /* 735768 .. 1550369 mV */
32b110a8fbSPhilipp Zabel #define MAX1586_GAIN_R24_5k11 1078648  /* 755053 .. 1591005 mV */
33b110a8fbSPhilipp Zabel #define MAX1586_GAIN_R24_7k5  1115432  /* 780802 .. 1645262 mV */
34b110a8fbSPhilipp Zabel 
3555f4fa4eSRobert Jarzmik /**
3655f4fa4eSRobert Jarzmik  * max1586_subdev_data - regulator data
3755f4fa4eSRobert Jarzmik  * @id: regulator Id (either MAX1586_V3 or MAX1586_V6)
3855f4fa4eSRobert Jarzmik  * @name: regulator cute name (example for V3: "vcc_core")
392e7e65ceSWolfram Sang  * @platform_data: regulator init data (constraints, supplies, ...)
4055f4fa4eSRobert Jarzmik  */
4155f4fa4eSRobert Jarzmik struct max1586_subdev_data {
4255f4fa4eSRobert Jarzmik 	int				id;
434e005179SRobert Jarzmik 	const char			*name;
4455f4fa4eSRobert Jarzmik 	struct regulator_init_data	*platform_data;
4555f4fa4eSRobert Jarzmik };
4655f4fa4eSRobert Jarzmik 
4755f4fa4eSRobert Jarzmik /**
4855f4fa4eSRobert Jarzmik  * max1586_platform_data - platform data for max1586
492e7e65ceSWolfram Sang  * @num_subdevs: number of regulators used (may be 1 or 2)
5055f4fa4eSRobert Jarzmik  * @subdevs: regulator used
5155f4fa4eSRobert Jarzmik  *           At most, there will be a regulator for V3 and one for V6 voltages.
52b110a8fbSPhilipp Zabel  * @v3_gain: gain on the V3 voltage output multiplied by 1e6.
53b110a8fbSPhilipp Zabel  *           This can be calculated as ((1 + R24/R25 + R24/185.5kOhm) * 1e6)
54b110a8fbSPhilipp Zabel  *           for an external resistor configuration as described in the
55b110a8fbSPhilipp Zabel  *           data sheet (R25=100kOhm).
5655f4fa4eSRobert Jarzmik  */
5755f4fa4eSRobert Jarzmik struct max1586_platform_data {
5855f4fa4eSRobert Jarzmik 	int num_subdevs;
5955f4fa4eSRobert Jarzmik 	struct max1586_subdev_data *subdevs;
60b110a8fbSPhilipp Zabel 	int v3_gain;
6155f4fa4eSRobert Jarzmik };
6255f4fa4eSRobert Jarzmik 
6355f4fa4eSRobert Jarzmik #endif
64