Merge tag 'for-4.16-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
[linux-2.6-block.git] / drivers / regulator / internal.h
CommitLineData
0cdfcc0f
MB
1/*
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
c360a6df
CZ
19#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
0cdfcc0f
MB
28/*
29 * struct regulator
30 *
31 * One for each consumer device.
c360a6df
CZ
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
0cdfcc0f
MB
38 */
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;
c360a6df 45 struct regulator_voltage voltage[REGULATOR_STATES_NUM];
0630b614 46 const char *supply_name;
0cdfcc0f
MB
47 struct device_attribute dev_attr;
48 struct regulator_dev *rdev;
49 struct dentry *debugfs;
50};
51
148096af
MP
52extern struct class regulator_class;
53
54static inline struct regulator_dev *dev_to_rdev(struct device *dev)
55{
56 return container_of(dev, struct regulator_dev, dev);
57}
58
59struct regulator_dev *of_find_regulator_by_node(struct device_node *np);
60
ef126a4a 61#ifdef CONFIG_OF
a0c7b164
MB
62struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
63 const struct regulator_desc *desc,
bfa21a0d 64 struct regulator_config *config,
a0c7b164 65 struct device_node **node);
ef126a4a
MB
66#else
67static inline struct regulator_init_data *
68regulator_of_get_init_data(struct device *dev,
69 const struct regulator_desc *desc,
bfa21a0d 70 struct regulator_config *config,
ef126a4a
MB
71 struct device_node **node)
72{
73 return NULL;
74}
75#endif
a0c7b164 76
a8bd42a9
DT
77enum regulator_get_type {
78 NORMAL_GET,
79 EXCLUSIVE_GET,
80 OPTIONAL_GET,
81 MAX_GET_TYPE
82};
83
84struct regulator *_regulator_get(struct device *dev, const char *id,
85 enum regulator_get_type get_type);
86
0cdfcc0f 87#endif