gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / regulator / internal.h
blob2391b565ef11f34f616850e8cdc8a5b3a78c9f8c
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * internal.h -- Voltage/Current Regulator framework internal code
5 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
6 * Copyright 2008 SlimLogic Ltd.
8 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
9 */
11 #ifndef __REGULATOR_INTERNAL_H
12 #define __REGULATOR_INTERNAL_H
14 #include <linux/suspend.h>
16 #define REGULATOR_STATES_NUM (PM_SUSPEND_MAX + 1)
18 struct regulator_voltage {
19 int min_uV;
20 int max_uV;
24 * struct regulator
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
34 struct regulator {
35 struct device *dev;
36 struct list_head list;
37 unsigned int always_on:1;
38 unsigned int bypass:1;
39 unsigned int device_link:1;
40 int uA_load;
41 unsigned int enable_count;
42 unsigned int deferred_disables;
43 struct regulator_voltage voltage[REGULATOR_STATES_NUM];
44 const char *supply_name;
45 struct device_attribute dev_attr;
46 struct regulator_dev *rdev;
47 struct dentry *debugfs;
50 extern struct class regulator_class;
52 static inline struct regulator_dev *dev_to_rdev(struct device *dev)
54 return container_of(dev, struct regulator_dev, dev);
57 #ifdef CONFIG_OF
58 struct regulator_dev *of_find_regulator_by_node(struct device_node *np);
59 struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
60 const struct regulator_desc *desc,
61 struct regulator_config *config,
62 struct device_node **node);
64 struct regulator_dev *of_parse_coupled_regulator(struct regulator_dev *rdev,
65 int index);
67 int of_get_n_coupled(struct regulator_dev *rdev);
69 bool of_check_coupling_data(struct regulator_dev *rdev);
71 #else
72 static inline struct regulator_dev *
73 of_find_regulator_by_node(struct device_node *np)
75 return NULL;
78 static inline struct regulator_init_data *
79 regulator_of_get_init_data(struct device *dev,
80 const struct regulator_desc *desc,
81 struct regulator_config *config,
82 struct device_node **node)
84 return NULL;
87 static inline struct regulator_dev *
88 of_parse_coupled_regulator(struct regulator_dev *rdev,
89 int index)
91 return NULL;
94 static inline int of_get_n_coupled(struct regulator_dev *rdev)
96 return 0;
99 static inline bool of_check_coupling_data(struct regulator_dev *rdev)
101 return false;
104 #endif
105 enum regulator_get_type {
106 NORMAL_GET,
107 EXCLUSIVE_GET,
108 OPTIONAL_GET,
109 MAX_GET_TYPE
112 struct regulator *_regulator_get(struct device *dev, const char *id,
113 enum regulator_get_type get_type);
114 #endif