11a59d1b8SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
255f4fa4eSRobert Jarzmik /*
355f4fa4eSRobert Jarzmik  * max1586.h  --  Voltage regulation for the Maxim 1586
455f4fa4eSRobert Jarzmik  *
555f4fa4eSRobert Jarzmik  * Copyright (C) 2008 Robert Jarzmik
655f4fa4eSRobert Jarzmik  */
755f4fa4eSRobert Jarzmik 
855f4fa4eSRobert Jarzmik #ifndef REGULATOR_MAX1586
955f4fa4eSRobert Jarzmik #define REGULATOR_MAX1586
1055f4fa4eSRobert Jarzmik 
1155f4fa4eSRobert Jarzmik #include <linux/regulator/machine.h>
1255f4fa4eSRobert Jarzmik 
1355f4fa4eSRobert Jarzmik #define MAX1586_V3 0
1455f4fa4eSRobert Jarzmik #define MAX1586_V6 1
1555f4fa4eSRobert Jarzmik 
16b110a8fbSPhilipp Zabel /* precalculated values for v3_gain */
17b110a8fbSPhilipp Zabel #define MAX1586_GAIN_NO_R24   1000000  /* 700000 .. 1475000 mV */
18b110a8fbSPhilipp Zabel #define MAX1586_GAIN_R24_3k32 1051098  /* 735768 .. 1550369 mV */
19b110a8fbSPhilipp Zabel #define MAX1586_GAIN_R24_5k11 1078648  /* 755053 .. 1591005 mV */
20b110a8fbSPhilipp Zabel #define MAX1586_GAIN_R24_7k5  1115432  /* 780802 .. 1645262 mV */
21b110a8fbSPhilipp Zabel 
2255f4fa4eSRobert Jarzmik /**
2355f4fa4eSRobert Jarzmik  * max1586_subdev_data - regulator data
2455f4fa4eSRobert Jarzmik  * @id: regulator Id (either MAX1586_V3 or MAX1586_V6)
2555f4fa4eSRobert Jarzmik  * @name: regulator cute name (example for V3: "vcc_core")
262e7e65ceSWolfram Sang  * @platform_data: regulator init data (constraints, supplies, ...)
2755f4fa4eSRobert Jarzmik  */
2855f4fa4eSRobert Jarzmik struct max1586_subdev_data {
2955f4fa4eSRobert Jarzmik 	int				id;
304e005179SRobert Jarzmik 	const char			*name;
3155f4fa4eSRobert Jarzmik 	struct regulator_init_data	*platform_data;
3255f4fa4eSRobert Jarzmik };
3355f4fa4eSRobert Jarzmik 
3455f4fa4eSRobert Jarzmik /**
3555f4fa4eSRobert Jarzmik  * max1586_platform_data - platform data for max1586
362e7e65ceSWolfram Sang  * @num_subdevs: number of regulators used (may be 1 or 2)
3755f4fa4eSRobert Jarzmik  * @subdevs: regulator used
3855f4fa4eSRobert Jarzmik  *           At most, there will be a regulator for V3 and one for V6 voltages.
39b110a8fbSPhilipp Zabel  * @v3_gain: gain on the V3 voltage output multiplied by 1e6.
40b110a8fbSPhilipp Zabel  *           This can be calculated as ((1 + R24/R25 + R24/185.5kOhm) * 1e6)
41b110a8fbSPhilipp Zabel  *           for an external resistor configuration as described in the
42b110a8fbSPhilipp Zabel  *           data sheet (R25=100kOhm).
4355f4fa4eSRobert Jarzmik  */
4455f4fa4eSRobert Jarzmik struct max1586_platform_data {
4555f4fa4eSRobert Jarzmik 	int num_subdevs;
4655f4fa4eSRobert Jarzmik 	struct max1586_subdev_data *subdevs;
47b110a8fbSPhilipp Zabel 	int v3_gain;
4855f4fa4eSRobert Jarzmik };
4955f4fa4eSRobert Jarzmik 
5055f4fa4eSRobert Jarzmik #endif
51