1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2021-2022, STMicroelectronics
4  */
5 
6 #ifndef __DRIVERS_STPMIC1_REGULATOR_H
7 #define __DRIVERS_STPMIC1_REGULATOR_H
8 
9 #include <stdint.h>
10 
11 /*
12  * Return true if @name refers to a knwon regulator, return false otherwise
13  */
14 bool stpmic1_regulator_is_valid(const char *name);
15 
16 /*
17  * Enable STPMIC1 regulator identified by @name.
18  * Return 0 on success and a non-0 value if failing
19  */
20 int stpmic1_regulator_enable(const char *name);
21 
22 /*
23  * Disable STPMIC1 regulator identified by @name.
24  * Return 0 on success and a non-0 value if failing
25  */
26 int stpmic1_regulator_disable(const char *name);
27 
28 /*
29  * Return true if regulator identified by @name is enabled and false otherwise.
30  * Return 0 on success and a non-0 value if failing
31  */
32 bool stpmic1_is_regulator_enabled(const char *name);
33 
34 /*
35  * Retrieve regulator levels array (in millivolts) and/or levels count
36  * @name: regulator identifier
37  * @levels: output reference for an arrays of the supported levels, or NULL
38  * @levels_count: output reference for number of supported levels, or NULL
39  */
40 void stpmic1_regulator_levels_mv(const char *name, const uint16_t **levels,
41 				 size_t *levels_count);
42 
43 /*
44  * Set voltage level @millivolt for target regulator @name
45  * @name: regulator identifier
46  * @millivot: target voltage level, in mV
47  */
48 int stpmic1_regulator_voltage_set(const char *name, uint16_t millivolts);
49 
50 /*
51  * Get current voltage level (in millivolt) for target regulator @name
52  * @name: regulator identifier
53  * Return a positive millivolt level on success or a negative value on error
54  */
55 int stpmic1_regulator_voltage_get(const char *name);
56 
57 #endif /*__DRIVERS_STPMIC1_REGULATOR_H*/
58