Linux 5.1.15
[linux/fpc-iii.git] / drivers / regulator / internal.h
blob6017f15c5d751047734cd1dbab5df3bb30d7e2f0
1 /*
2 * internal.h -- Voltage/Current Regulator framework internal code
4 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
5 * Copyright 2008 SlimLogic Ltd.
7 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
16 #ifndef __REGULATOR_INTERNAL_H
17 #define __REGULATOR_INTERNAL_H
19 #include <linux/suspend.h>
21 #define REGULATOR_STATES_NUM (PM_SUSPEND_MAX + 1)
23 struct regulator_voltage {
24 int min_uV;
25 int max_uV;
29 * struct regulator
31 * One for each consumer device.
32 * @voltage - a voltage array for each state of runtime, i.e.:
33 * PM_SUSPEND_ON
34 * PM_SUSPEND_TO_IDLE
35 * PM_SUSPEND_STANDBY
36 * PM_SUSPEND_MEM
37 * PM_SUSPEND_MAX
39 struct regulator {
40 struct device *dev;
41 struct list_head list;
42 unsigned int always_on:1;
43 unsigned int bypass:1;
44 int uA_load;
45 unsigned int enable_count;
46 unsigned int deferred_disables;
47 struct regulator_voltage voltage[REGULATOR_STATES_NUM];
48 const char *supply_name;
49 struct device_attribute dev_attr;
50 struct regulator_dev *rdev;
51 struct dentry *debugfs;
54 extern struct class regulator_class;
56 static inline struct regulator_dev *dev_to_rdev(struct device *dev)
58 return container_of(dev, struct regulator_dev, dev);
61 #ifdef CONFIG_OF
62 struct regulator_dev *of_find_regulator_by_node(struct device_node *np);
63 struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
64 const struct regulator_desc *desc,
65 struct regulator_config *config,
66 struct device_node **node);
68 struct regulator_dev *of_parse_coupled_regulator(struct regulator_dev *rdev,
69 int index);
71 int of_get_n_coupled(struct regulator_dev *rdev);
73 bool of_check_coupling_data(struct regulator_dev *rdev);
75 #else
76 static inline struct regulator_dev *
77 of_find_regulator_by_node(struct device_node *np)
79 return NULL;
82 static inline struct regulator_init_data *
83 regulator_of_get_init_data(struct device *dev,
84 const struct regulator_desc *desc,
85 struct regulator_config *config,
86 struct device_node **node)
88 return NULL;
91 static inline struct regulator_dev *
92 of_parse_coupled_regulator(struct regulator_dev *rdev,
93 int index)
95 return NULL;
98 static inline int of_get_n_coupled(struct regulator_dev *rdev)
100 return 0;
103 static inline bool of_check_coupling_data(struct regulator_dev *rdev)
105 return false;
108 #endif
109 enum regulator_get_type {
110 NORMAL_GET,
111 EXCLUSIVE_GET,
112 OPTIONAL_GET,
113 MAX_GET_TYPE
116 struct regulator *_regulator_get(struct device *dev, const char *id,
117 enum regulator_get_type get_type);
118 #endif