diff options
Diffstat (limited to 'drivers/regulator/arizona-micsupp.c')
-rw-r--r-- | drivers/regulator/arizona-micsupp.c | 52 |
1 files changed, 11 insertions, 41 deletions
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c index fd3154d86901..034ece707083 100644 --- a/drivers/regulator/arizona-micsupp.c +++ b/drivers/regulator/arizona-micsupp.c | |||
@@ -28,8 +28,6 @@ | |||
28 | #include <linux/mfd/arizona/pdata.h> | 28 | #include <linux/mfd/arizona/pdata.h> |
29 | #include <linux/mfd/arizona/registers.h> | 29 | #include <linux/mfd/arizona/registers.h> |
30 | 30 | ||
31 | #define ARIZONA_MICSUPP_MAX_SELECTOR 0x1f | ||
32 | |||
33 | struct arizona_micsupp { | 31 | struct arizona_micsupp { |
34 | struct regulator_dev *regulator; | 32 | struct regulator_dev *regulator; |
35 | struct arizona *arizona; | 33 | struct arizona *arizona; |
@@ -40,42 +38,6 @@ struct arizona_micsupp { | |||
40 | struct work_struct check_cp_work; | 38 | struct work_struct check_cp_work; |
41 | }; | 39 | }; |
42 | 40 | ||
43 | static int arizona_micsupp_list_voltage(struct regulator_dev *rdev, | ||
44 | unsigned int selector) | ||
45 | { | ||
46 | if (selector > ARIZONA_MICSUPP_MAX_SELECTOR) | ||
47 | return -EINVAL; | ||
48 | |||
49 | if (selector == ARIZONA_MICSUPP_MAX_SELECTOR) | ||
50 | return 3300000; | ||
51 | else | ||
52 | return (selector * 50000) + 1700000; | ||
53 | } | ||
54 | |||
55 | static int arizona_micsupp_map_voltage(struct regulator_dev *rdev, | ||
56 | int min_uV, int max_uV) | ||
57 | { | ||
58 | unsigned int voltage; | ||
59 | int selector; | ||
60 | |||
61 | if (min_uV < 1700000) | ||
62 | min_uV = 1700000; | ||
63 | |||
64 | if (min_uV > 3200000) | ||
65 | selector = ARIZONA_MICSUPP_MAX_SELECTOR; | ||
66 | else | ||
67 | selector = DIV_ROUND_UP(min_uV - 1700000, 50000); | ||
68 | |||
69 | if (selector < 0) | ||
70 | return -EINVAL; | ||
71 | |||
72 | voltage = arizona_micsupp_list_voltage(rdev, selector); | ||
73 | if (voltage < min_uV || voltage > max_uV) | ||
74 | return -EINVAL; | ||
75 | |||
76 | return selector; | ||
77 | } | ||
78 | |||
79 | static void arizona_micsupp_check_cp(struct work_struct *work) | 41 | static void arizona_micsupp_check_cp(struct work_struct *work) |
80 | { | 42 | { |
81 | struct arizona_micsupp *micsupp = | 43 | struct arizona_micsupp *micsupp = |
@@ -145,8 +107,8 @@ static struct regulator_ops arizona_micsupp_ops = { | |||
145 | .disable = arizona_micsupp_disable, | 107 | .disable = arizona_micsupp_disable, |
146 | .is_enabled = regulator_is_enabled_regmap, | 108 | .is_enabled = regulator_is_enabled_regmap, |
147 | 109 | ||
148 | .list_voltage = arizona_micsupp_list_voltage, | 110 | .list_voltage = regulator_list_voltage_linear_range, |
149 | .map_voltage = arizona_micsupp_map_voltage, | 111 | .map_voltage = regulator_map_voltage_linear_range, |
150 | 112 | ||
151 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | 113 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
152 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | 114 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
@@ -155,11 +117,16 @@ static struct regulator_ops arizona_micsupp_ops = { | |||
155 | .set_bypass = arizona_micsupp_set_bypass, | 117 | .set_bypass = arizona_micsupp_set_bypass, |
156 | }; | 118 | }; |
157 | 119 | ||
120 | static const struct regulator_linear_range arizona_micsupp_ranges[] = { | ||
121 | REGULATOR_LINEAR_RANGE(1700000, 0, 0x1e, 50000), | ||
122 | REGULATOR_LINEAR_RANGE(3300000, 0x1f, 0x1f, 0), | ||
123 | }; | ||
124 | |||
158 | static const struct regulator_desc arizona_micsupp = { | 125 | static const struct regulator_desc arizona_micsupp = { |
159 | .name = "MICVDD", | 126 | .name = "MICVDD", |
160 | .supply_name = "CPVDD", | 127 | .supply_name = "CPVDD", |
161 | .type = REGULATOR_VOLTAGE, | 128 | .type = REGULATOR_VOLTAGE, |
162 | .n_voltages = ARIZONA_MICSUPP_MAX_SELECTOR + 1, | 129 | .n_voltages = 32, |
163 | .ops = &arizona_micsupp_ops, | 130 | .ops = &arizona_micsupp_ops, |
164 | 131 | ||
165 | .vsel_reg = ARIZONA_LDO2_CONTROL_1, | 132 | .vsel_reg = ARIZONA_LDO2_CONTROL_1, |
@@ -169,6 +136,9 @@ static const struct regulator_desc arizona_micsupp = { | |||
169 | .bypass_reg = ARIZONA_MIC_CHARGE_PUMP_1, | 136 | .bypass_reg = ARIZONA_MIC_CHARGE_PUMP_1, |
170 | .bypass_mask = ARIZONA_CPMIC_BYPASS, | 137 | .bypass_mask = ARIZONA_CPMIC_BYPASS, |
171 | 138 | ||
139 | .linear_ranges = arizona_micsupp_ranges, | ||
140 | .n_linear_ranges = ARRAY_SIZE(arizona_micsupp_ranges), | ||
141 | |||
172 | .enable_time = 3000, | 142 | .enable_time = 3000, |
173 | 143 | ||
174 | .owner = THIS_MODULE, | 144 | .owner = THIS_MODULE, |