Merge branch 'for-2.6.40' of git://linux-nfs.org/~bfields/linux
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / regulator / mc13xxx.h
1 /*
2  * mc13xxx.h - regulators for the Freescale mc13xxx PMIC
3  *
4  *  Copyright (C) 2010 Yong Shen <yong.shen@linaro.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  */
11
12 #ifndef __LINUX_REGULATOR_MC13XXX_H
13 #define __LINUX_REGULATOR_MC13XXX_H
14
15 #include <linux/regulator/driver.h>
16
17 struct mc13xxx_regulator {
18         struct regulator_desc desc;
19         int reg;
20         int enable_bit;
21         int vsel_reg;
22         int vsel_shift;
23         int vsel_mask;
24         int hi_bit;
25         int const *voltages;
26 };
27
28 struct mc13xxx_regulator_priv {
29         struct mc13xxx *mc13xxx;
30         u32 powermisc_pwgt_state;
31         struct mc13xxx_regulator *mc13xxx_regulators;
32         struct regulator_dev *regulators[];
33 };
34
35 extern int mc13xxx_sw_regulator(struct regulator_dev *rdev);
36 extern int mc13xxx_sw_regulator_is_enabled(struct regulator_dev *rdev);
37 extern int mc13xxx_get_best_voltage_index(struct regulator_dev *rdev,
38                                                 int min_uV, int max_uV);
39 extern int mc13xxx_regulator_list_voltage(struct regulator_dev *rdev,
40                                                 unsigned selector);
41 extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev,
42                 int min_uV, int max_uV, unsigned *selector);
43 extern int mc13xxx_fixed_regulator_get_voltage(struct regulator_dev *rdev);
44
45 extern struct regulator_ops mc13xxx_regulator_ops;
46 extern struct regulator_ops mc13xxx_fixed_regulator_ops;
47
48 #define MC13xxx_DEFINE(prefix, _name, _reg, _vsel_reg, _voltages, _ops) \
49         [prefix ## _name] = {                           \
50                 .desc = {                                               \
51                         .name = #prefix "_" #_name,                     \
52                         .n_voltages = ARRAY_SIZE(_voltages),            \
53                         .ops = &_ops,                   \
54                         .type = REGULATOR_VOLTAGE,                      \
55                         .id = prefix ## _name,          \
56                         .owner = THIS_MODULE,                           \
57                 },                                                      \
58                 .reg = prefix ## _reg,                          \
59                 .enable_bit = prefix ## _reg ## _ ## _name ## EN,       \
60                 .vsel_reg = prefix ## _vsel_reg,                        \
61                 .vsel_shift = prefix ## _vsel_reg ## _ ## _name ## VSEL,\
62                 .vsel_mask = prefix ## _vsel_reg ## _ ## _name ## VSEL_M,\
63                 .voltages =  _voltages,                                 \
64         }
65
66 #define MC13xxx_FIXED_DEFINE(prefix, _name, _reg, _voltages, _ops)      \
67         [prefix ## _name] = {                           \
68                 .desc = {                                               \
69                         .name = #prefix "_" #_name,                     \
70                         .n_voltages = ARRAY_SIZE(_voltages),            \
71                         .ops = &_ops,           \
72                         .type = REGULATOR_VOLTAGE,                      \
73                         .id = prefix ## _name,          \
74                         .owner = THIS_MODULE,                           \
75                 },                                                      \
76                 .reg = prefix ## _reg,                          \
77                 .enable_bit = prefix ## _reg ## _ ## _name ## EN,       \
78                 .voltages =  _voltages,                                 \
79         }
80
81 #define MC13xxx_GPO_DEFINE(prefix, _name, _reg,  _voltages, _ops)       \
82         [prefix ## _name] = {                           \
83                 .desc = {                                               \
84                         .name = #prefix "_" #_name,                     \
85                         .n_voltages = ARRAY_SIZE(_voltages),            \
86                         .ops = &_ops,           \
87                         .type = REGULATOR_VOLTAGE,                      \
88                         .id = prefix ## _name,          \
89                         .owner = THIS_MODULE,                           \
90                 },                                                      \
91                 .reg = prefix ## _reg,                          \
92                 .enable_bit = prefix ## _reg ## _ ## _name ## EN,       \
93                 .voltages =  _voltages,                                 \
94         }
95
96 #define MC13xxx_DEFINE_SW(_name, _reg, _vsel_reg, _voltages, ops)       \
97         MC13xxx_DEFINE(SW, _name, _reg, _vsel_reg, _voltages, ops)
98 #define MC13xxx_DEFINE_REGU(_name, _reg, _vsel_reg, _voltages, ops)     \
99         MC13xxx_DEFINE(REGU, _name, _reg, _vsel_reg, _voltages, ops)
100
101 #endif