]>
Commit | Line | Data |
---|---|---|
167e3d8a YS |
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; | |
93bcb23b | 32 | int num_regulators; |
167e3d8a YS |
33 | struct regulator_dev *regulators[]; |
34 | }; | |
35 | ||
36 | extern int mc13xxx_sw_regulator(struct regulator_dev *rdev); | |
37 | extern int mc13xxx_sw_regulator_is_enabled(struct regulator_dev *rdev); | |
167e3d8a YS |
38 | extern int mc13xxx_regulator_list_voltage(struct regulator_dev *rdev, |
39 | unsigned selector); | |
40 | extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev, | |
41 | int min_uV, int max_uV, unsigned *selector); | |
42 | extern int mc13xxx_fixed_regulator_get_voltage(struct regulator_dev *rdev); | |
43 | ||
93bcb23b SG |
44 | #ifdef CONFIG_OF |
45 | extern int mc13xxx_get_num_regulators_dt(struct platform_device *pdev); | |
46 | extern struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( | |
47 | struct platform_device *pdev, struct mc13xxx_regulator *regulators, | |
48 | int num_regulators); | |
49 | #else | |
50 | static inline int mc13xxx_get_num_regulators_dt(struct platform_device *pdev) | |
51 | { | |
52 | return -ENODEV; | |
53 | } | |
54 | ||
55 | static inline struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( | |
56 | struct platform_device *pdev, struct mc13xxx_regulator *regulators, | |
57 | int num_regulators) | |
58 | { | |
59 | return NULL; | |
60 | } | |
61 | #endif | |
62 | ||
167e3d8a YS |
63 | extern struct regulator_ops mc13xxx_regulator_ops; |
64 | extern struct regulator_ops mc13xxx_fixed_regulator_ops; | |
65 | ||
66 | #define MC13xxx_DEFINE(prefix, _name, _reg, _vsel_reg, _voltages, _ops) \ | |
67 | [prefix ## _name] = { \ | |
68 | .desc = { \ | |
3a5d0315 | 69 | .name = #_name, \ |
167e3d8a YS |
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 | .vsel_reg = prefix ## _vsel_reg, \ | |
79 | .vsel_shift = prefix ## _vsel_reg ## _ ## _name ## VSEL,\ | |
80 | .vsel_mask = prefix ## _vsel_reg ## _ ## _name ## VSEL_M,\ | |
81 | .voltages = _voltages, \ | |
82 | } | |
83 | ||
84 | #define MC13xxx_FIXED_DEFINE(prefix, _name, _reg, _voltages, _ops) \ | |
85 | [prefix ## _name] = { \ | |
86 | .desc = { \ | |
3a5d0315 | 87 | .name = #_name, \ |
167e3d8a YS |
88 | .n_voltages = ARRAY_SIZE(_voltages), \ |
89 | .ops = &_ops, \ | |
90 | .type = REGULATOR_VOLTAGE, \ | |
91 | .id = prefix ## _name, \ | |
92 | .owner = THIS_MODULE, \ | |
93 | }, \ | |
94 | .reg = prefix ## _reg, \ | |
95 | .enable_bit = prefix ## _reg ## _ ## _name ## EN, \ | |
96 | .voltages = _voltages, \ | |
97 | } | |
98 | ||
99 | #define MC13xxx_GPO_DEFINE(prefix, _name, _reg, _voltages, _ops) \ | |
100 | [prefix ## _name] = { \ | |
101 | .desc = { \ | |
3a5d0315 | 102 | .name = #_name, \ |
167e3d8a YS |
103 | .n_voltages = ARRAY_SIZE(_voltages), \ |
104 | .ops = &_ops, \ | |
105 | .type = REGULATOR_VOLTAGE, \ | |
106 | .id = prefix ## _name, \ | |
107 | .owner = THIS_MODULE, \ | |
108 | }, \ | |
109 | .reg = prefix ## _reg, \ | |
110 | .enable_bit = prefix ## _reg ## _ ## _name ## EN, \ | |
111 | .voltages = _voltages, \ | |
112 | } | |
113 | ||
114 | #define MC13xxx_DEFINE_SW(_name, _reg, _vsel_reg, _voltages, ops) \ | |
115 | MC13xxx_DEFINE(SW, _name, _reg, _vsel_reg, _voltages, ops) | |
116 | #define MC13xxx_DEFINE_REGU(_name, _reg, _vsel_reg, _voltages, ops) \ | |
117 | MC13xxx_DEFINE(REGU, _name, _reg, _vsel_reg, _voltages, ops) | |
118 | ||
119 | #endif |