diff options
author | Yong Shen <yong.shen@linaro.org> | 2010-12-14 01:00:54 -0500 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2011-01-12 09:33:03 -0500 |
commit | 167e3d8af98a111994c4d6b3c5cbc589aedbbc2a (patch) | |
tree | 16b54e06e33b949a0ca98542131610926d483bae /drivers/regulator/mc13xxx.h | |
parent | 57c78e359a35c69eca4c88f107500f74ef7f0acf (diff) |
make mc13783 regulator code generic
move some common functions and micros of mc13783 regulaor driver to
a seperate file, which makes it possible for mc13892 to share code.
Signed-off-by: Yong Shen <yong.shen@linaro.org>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator/mc13xxx.h')
-rw-r--r-- | drivers/regulator/mc13xxx.h | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/drivers/regulator/mc13xxx.h b/drivers/regulator/mc13xxx.h new file mode 100644 index 000000000000..27758267e122 --- /dev/null +++ b/drivers/regulator/mc13xxx.h | |||
@@ -0,0 +1,101 @@ | |||
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 | ||