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