]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - drivers/regulator/internal.h
regulator: core: Add regulator_is_equal() helper
[mirror_ubuntu-focal-kernel.git] / drivers / regulator / internal.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * internal.h -- Voltage/Current Regulator framework internal code
4 *
5 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
6 * Copyright 2008 SlimLogic Ltd.
7 *
8 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
9 */
10
11 #ifndef __REGULATOR_INTERNAL_H
12 #define __REGULATOR_INTERNAL_H
13
14 #include <linux/suspend.h>
15
16 #define REGULATOR_STATES_NUM (PM_SUSPEND_MAX + 1)
17
18 struct regulator_voltage {
19 int min_uV;
20 int max_uV;
21 };
22
23 /*
24 * struct regulator
25 *
26 * One for each consumer device.
27 * @voltage - a voltage array for each state of runtime, i.e.:
28 * PM_SUSPEND_ON
29 * PM_SUSPEND_TO_IDLE
30 * PM_SUSPEND_STANDBY
31 * PM_SUSPEND_MEM
32 * PM_SUSPEND_MAX
33 */
34 struct regulator {
35 struct device *dev;
36 struct list_head list;
37 unsigned int always_on:1;
38 unsigned int bypass:1;
39 int uA_load;
40 unsigned int enable_count;
41 unsigned int deferred_disables;
42 struct regulator_voltage voltage[REGULATOR_STATES_NUM];
43 const char *supply_name;
44 struct device_attribute dev_attr;
45 struct regulator_dev *rdev;
46 struct dentry *debugfs;
47 };
48
49 extern struct class regulator_class;
50
51 static inline struct regulator_dev *dev_to_rdev(struct device *dev)
52 {
53 return container_of(dev, struct regulator_dev, dev);
54 }
55
56 #ifdef CONFIG_OF
57 struct regulator_dev *of_find_regulator_by_node(struct device_node *np);
58 struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
59 const struct regulator_desc *desc,
60 struct regulator_config *config,
61 struct device_node **node);
62
63 struct regulator_dev *of_parse_coupled_regulator(struct regulator_dev *rdev,
64 int index);
65
66 int of_get_n_coupled(struct regulator_dev *rdev);
67
68 bool of_check_coupling_data(struct regulator_dev *rdev);
69
70 #else
71 static inline struct regulator_dev *
72 of_find_regulator_by_node(struct device_node *np)
73 {
74 return NULL;
75 }
76
77 static inline struct regulator_init_data *
78 regulator_of_get_init_data(struct device *dev,
79 const struct regulator_desc *desc,
80 struct regulator_config *config,
81 struct device_node **node)
82 {
83 return NULL;
84 }
85
86 static inline struct regulator_dev *
87 of_parse_coupled_regulator(struct regulator_dev *rdev,
88 int index)
89 {
90 return NULL;
91 }
92
93 static inline int of_get_n_coupled(struct regulator_dev *rdev)
94 {
95 return 0;
96 }
97
98 static inline bool of_check_coupling_data(struct regulator_dev *rdev)
99 {
100 return false;
101 }
102
103 #endif
104 enum regulator_get_type {
105 NORMAL_GET,
106 EXCLUSIVE_GET,
107 OPTIONAL_GET,
108 MAX_GET_TYPE
109 };
110
111 struct regulator *_regulator_get(struct device *dev, const char *id,
112 enum regulator_get_type get_type);
113 #endif