]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - drivers/regulator/internal.h
Merge tag 'omap-for-v5.8/dt-missed-signed' of git://git.kernel.org/pub/scm/linux...
[mirror_ubuntu-hirsute-kernel.git] / drivers / regulator / internal.h
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
0cdfcc0f
MB
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>
0cdfcc0f
MB
9 */
10
11#ifndef __REGULATOR_INTERNAL_H
12#define __REGULATOR_INTERNAL_H
13
c360a6df
CZ
14#include <linux/suspend.h>
15
16#define REGULATOR_STATES_NUM (PM_SUSPEND_MAX + 1)
17
18struct regulator_voltage {
19 int min_uV;
20 int max_uV;
21};
22
0cdfcc0f
MB
23/*
24 * struct regulator
25 *
26 * One for each consumer device.
c360a6df
CZ
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
0cdfcc0f
MB
33 */
34struct regulator {
35 struct device *dev;
36 struct list_head list;
37 unsigned int always_on:1;
38 unsigned int bypass:1;
b59b6544 39 unsigned int device_link:1;
0cdfcc0f 40 int uA_load;
5451781d
DA
41 unsigned int enable_count;
42 unsigned int deferred_disables;
c360a6df 43 struct regulator_voltage voltage[REGULATOR_STATES_NUM];
0630b614 44 const char *supply_name;
0cdfcc0f
MB
45 struct device_attribute dev_attr;
46 struct regulator_dev *rdev;
47 struct dentry *debugfs;
48};
49
148096af
MP
50extern struct class regulator_class;
51
52static inline struct regulator_dev *dev_to_rdev(struct device *dev)
53{
54 return container_of(dev, struct regulator_dev, dev);
55}
56
ef126a4a 57#ifdef CONFIG_OF
08813e0e 58struct regulator_dev *of_find_regulator_by_node(struct device_node *np);
a0c7b164
MB
59struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
60 const struct regulator_desc *desc,
bfa21a0d 61 struct regulator_config *config,
a0c7b164 62 struct device_node **node);
a085a31a
MP
63
64struct regulator_dev *of_parse_coupled_regulator(struct regulator_dev *rdev,
65 int index);
66
67int of_get_n_coupled(struct regulator_dev *rdev);
68
69bool of_check_coupling_data(struct regulator_dev *rdev);
70
ef126a4a 71#else
08813e0e
CD
72static inline struct regulator_dev *
73of_find_regulator_by_node(struct device_node *np)
74{
75 return NULL;
76}
77
ef126a4a
MB
78static inline struct regulator_init_data *
79regulator_of_get_init_data(struct device *dev,
80 const struct regulator_desc *desc,
bfa21a0d 81 struct regulator_config *config,
ef126a4a
MB
82 struct device_node **node)
83{
84 return NULL;
85}
a0c7b164 86
a085a31a
MP
87static inline struct regulator_dev *
88of_parse_coupled_regulator(struct regulator_dev *rdev,
89 int index)
90{
91 return NULL;
92}
93
94static inline int of_get_n_coupled(struct regulator_dev *rdev)
95{
96 return 0;
97}
98
99static inline bool of_check_coupling_data(struct regulator_dev *rdev)
100{
101 return false;
102}
103
104#endif
a8bd42a9
DT
105enum regulator_get_type {
106 NORMAL_GET,
107 EXCLUSIVE_GET,
108 OPTIONAL_GET,
109 MAX_GET_TYPE
110};
111
112struct regulator *_regulator_get(struct device *dev, const char *id,
113 enum regulator_get_type get_type);
0cdfcc0f 114#endif