blob: 6017f15c5d751047734cd1dbab5df3bb30d7e2f0 [file] [log] [blame]
Mark Brown0cdfcc02013-09-11 13:15:40 +01001/*
2 * internal.h -- Voltage/Current Regulator framework internal code
3 *
4 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
5 * Copyright 2008 SlimLogic Ltd.
6 *
7 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
8 *
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.
13 *
14 */
15
16#ifndef __REGULATOR_INTERNAL_H
17#define __REGULATOR_INTERNAL_H
18
Chunyan Zhangc360a6d2018-01-26 21:08:44 +080019#include <linux/suspend.h>
20
21#define REGULATOR_STATES_NUM (PM_SUSPEND_MAX + 1)
22
23struct regulator_voltage {
24 int min_uV;
25 int max_uV;
26};
27
Mark Brown0cdfcc02013-09-11 13:15:40 +010028/*
29 * struct regulator
30 *
31 * One for each consumer device.
Chunyan Zhangc360a6d2018-01-26 21:08:44 +080032 * @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
Mark Brown0cdfcc02013-09-11 13:15:40 +010038 */
39struct 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;
Douglas Anderson54517812018-11-20 09:52:53 -080045 unsigned int enable_count;
46 unsigned int deferred_disables;
Chunyan Zhangc360a6d2018-01-26 21:08:44 +080047 struct regulator_voltage voltage[REGULATOR_STATES_NUM];
Stephen Boyd0630b612017-03-16 18:07:14 -070048 const char *supply_name;
Mark Brown0cdfcc02013-09-11 13:15:40 +010049 struct device_attribute dev_attr;
50 struct regulator_dev *rdev;
51 struct dentry *debugfs;
52};
53
Maciej Purski148096a2018-01-22 15:30:06 +010054extern struct class regulator_class;
55
56static inline struct regulator_dev *dev_to_rdev(struct device *dev)
57{
58 return container_of(dev, struct regulator_dev, dev);
59}
60
Mark Brownef126a42014-09-10 15:17:01 +010061#ifdef CONFIG_OF
Changbin Du08813e02018-05-02 21:44:57 +080062struct regulator_dev *of_find_regulator_by_node(struct device_node *np);
Mark Browna0c7b162014-09-09 23:13:57 +010063struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
64 const struct regulator_desc *desc,
Krzysztof Kozlowskibfa21a02015-01-05 12:48:42 +010065 struct regulator_config *config,
Mark Browna0c7b162014-09-09 23:13:57 +010066 struct device_node **node);
Maciej Purskia085a312018-04-23 16:33:39 +020067
68struct regulator_dev *of_parse_coupled_regulator(struct regulator_dev *rdev,
69 int index);
70
71int of_get_n_coupled(struct regulator_dev *rdev);
72
73bool of_check_coupling_data(struct regulator_dev *rdev);
74
Mark Brownef126a42014-09-10 15:17:01 +010075#else
Changbin Du08813e02018-05-02 21:44:57 +080076static inline struct regulator_dev *
77of_find_regulator_by_node(struct device_node *np)
78{
79 return NULL;
80}
81
Mark Brownef126a42014-09-10 15:17:01 +010082static inline struct regulator_init_data *
83regulator_of_get_init_data(struct device *dev,
84 const struct regulator_desc *desc,
Krzysztof Kozlowskibfa21a02015-01-05 12:48:42 +010085 struct regulator_config *config,
Mark Brownef126a42014-09-10 15:17:01 +010086 struct device_node **node)
87{
88 return NULL;
89}
Mark Browna0c7b162014-09-09 23:13:57 +010090
Maciej Purskia085a312018-04-23 16:33:39 +020091static inline struct regulator_dev *
92of_parse_coupled_regulator(struct regulator_dev *rdev,
93 int index)
94{
95 return NULL;
96}
97
98static inline int of_get_n_coupled(struct regulator_dev *rdev)
99{
100 return 0;
101}
102
103static inline bool of_check_coupling_data(struct regulator_dev *rdev)
104{
105 return false;
106}
107
108#endif
Dmitry Torokhova8bd42a2017-02-03 13:56:02 -0800109enum regulator_get_type {
110 NORMAL_GET,
111 EXCLUSIVE_GET,
112 OPTIONAL_GET,
113 MAX_GET_TYPE
114};
115
116struct regulator *_regulator_get(struct device *dev, const char *id,
117 enum regulator_get_type get_type);
Mark Brown0cdfcc02013-09-11 13:15:40 +0100118#endif