blob: 2391b565ef11f34f616850e8cdc8a5b3a78c9f8c [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Mark Brown0cdfcc02013-09-11 13:15:40 +01002/*
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>
Mark Brown0cdfcc02013-09-11 13:15:40 +01009 */
10
11#ifndef __REGULATOR_INTERNAL_H
12#define __REGULATOR_INTERNAL_H
13
Chunyan Zhangc360a6d2018-01-26 21:08:44 +080014#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
Mark Brown0cdfcc02013-09-11 13:15:40 +010023/*
24 * struct regulator
25 *
26 * One for each consumer device.
Chunyan Zhangc360a6d2018-01-26 21:08:44 +080027 * @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
Mark Brown0cdfcc02013-09-11 13:15:40 +010033 */
34struct regulator {
35 struct device *dev;
36 struct list_head list;
37 unsigned int always_on:1;
38 unsigned int bypass:1;
Saravana Kannanb59b6542019-11-14 16:04:38 -080039 unsigned int device_link:1;
Mark Brown0cdfcc02013-09-11 13:15:40 +010040 int uA_load;
Douglas Anderson54517812018-11-20 09:52:53 -080041 unsigned int enable_count;
42 unsigned int deferred_disables;
Chunyan Zhangc360a6d2018-01-26 21:08:44 +080043 struct regulator_voltage voltage[REGULATOR_STATES_NUM];
Stephen Boyd0630b612017-03-16 18:07:14 -070044 const char *supply_name;
Mark Brown0cdfcc02013-09-11 13:15:40 +010045 struct device_attribute dev_attr;
46 struct regulator_dev *rdev;
47 struct dentry *debugfs;
48};
49
Maciej Purski148096a2018-01-22 15:30:06 +010050extern 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
Mark Brownef126a42014-09-10 15:17:01 +010057#ifdef CONFIG_OF
Changbin Du08813e02018-05-02 21:44:57 +080058struct regulator_dev *of_find_regulator_by_node(struct device_node *np);
Mark Browna0c7b162014-09-09 23:13:57 +010059struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
60 const struct regulator_desc *desc,
Krzysztof Kozlowskibfa21a02015-01-05 12:48:42 +010061 struct regulator_config *config,
Mark Browna0c7b162014-09-09 23:13:57 +010062 struct device_node **node);
Maciej Purskia085a312018-04-23 16:33:39 +020063
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
Mark Brownef126a42014-09-10 15:17:01 +010071#else
Changbin Du08813e02018-05-02 21:44:57 +080072static inline struct regulator_dev *
73of_find_regulator_by_node(struct device_node *np)
74{
75 return NULL;
76}
77
Mark Brownef126a42014-09-10 15:17:01 +010078static inline struct regulator_init_data *
79regulator_of_get_init_data(struct device *dev,
80 const struct regulator_desc *desc,
Krzysztof Kozlowskibfa21a02015-01-05 12:48:42 +010081 struct regulator_config *config,
Mark Brownef126a42014-09-10 15:17:01 +010082 struct device_node **node)
83{
84 return NULL;
85}
Mark Browna0c7b162014-09-09 23:13:57 +010086
Maciej Purskia085a312018-04-23 16:33:39 +020087static 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
Dmitry Torokhova8bd42a2017-02-03 13:56:02 -0800105enum 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);
Mark Brown0cdfcc02013-09-11 13:15:40 +0100114#endif