diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-06-04 08:44:03 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-06-06 06:16:08 -0400 |
commit | 2628b10070c5a934a977f20831d97778034b39af (patch) | |
tree | 9aa82559470bc12ba11ce7dda747f149909b3223 | |
parent | 978371cbabb4cb7a47751049d72f06dc8348cab2 (diff) |
regulator: tps6586x: Use regulator_list_voltage_linear for dvm/ldo4/sw2
The voltage tables for dvm/ldo4/sw2 are actually linear mapping.
Thus convert dvm/ldo4/sw2 to use regulator_list_voltage_linear.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/regulator/tps6586x-regulator.c | 129 |
1 files changed, 68 insertions, 61 deletions
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index 0a3bb3aecd97..ccbb9f150b4e 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c | |||
@@ -74,6 +74,16 @@ static struct regulator_ops tps6586x_rw_regulator_ops = { | |||
74 | .disable = regulator_disable_regmap, | 74 | .disable = regulator_disable_regmap, |
75 | }; | 75 | }; |
76 | 76 | ||
77 | static struct regulator_ops tps6586x_rw_linear_regulator_ops = { | ||
78 | .list_voltage = regulator_list_voltage_linear, | ||
79 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
80 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
81 | |||
82 | .is_enabled = regulator_is_enabled_regmap, | ||
83 | .enable = regulator_enable_regmap, | ||
84 | .disable = regulator_disable_regmap, | ||
85 | }; | ||
86 | |||
77 | static struct regulator_ops tps6586x_ro_regulator_ops = { | 87 | static struct regulator_ops tps6586x_ro_regulator_ops = { |
78 | .list_voltage = regulator_list_voltage_table, | 88 | .list_voltage = regulator_list_voltage_table, |
79 | .map_voltage = regulator_map_voltage_ascend, | 89 | .map_voltage = regulator_map_voltage_ascend, |
@@ -91,48 +101,11 @@ static const unsigned int tps6586x_ldo0_voltages[] = { | |||
91 | 1200000, 1500000, 1800000, 2500000, 2700000, 2850000, 3100000, 3300000, | 101 | 1200000, 1500000, 1800000, 2500000, 2700000, 2850000, 3100000, 3300000, |
92 | }; | 102 | }; |
93 | 103 | ||
94 | static const unsigned int tps6586x_ldo4_voltages[] = { | ||
95 | 1700000, 1725000, 1750000, 1775000, 1800000, 1825000, 1850000, 1875000, | ||
96 | 1900000, 1925000, 1950000, 1975000, 2000000, 2025000, 2050000, 2075000, | ||
97 | 2100000, 2125000, 2150000, 2175000, 2200000, 2225000, 2250000, 2275000, | ||
98 | 2300000, 2325000, 2350000, 2375000, 2400000, 2425000, 2450000, 2475000, | ||
99 | }; | ||
100 | |||
101 | #define tps658623_sm2_voltages tps6586x_ldo4_voltages | ||
102 | |||
103 | static const unsigned int tps6586x_ldo_voltages[] = { | 104 | static const unsigned int tps6586x_ldo_voltages[] = { |
104 | 1250000, 1500000, 1800000, 2500000, 2700000, 2850000, 3100000, 3300000, | 105 | 1250000, 1500000, 1800000, 2500000, 2700000, 2850000, 3100000, 3300000, |
105 | }; | 106 | }; |
106 | 107 | ||
107 | static const unsigned int tps6586x_sm2_voltages[] = { | 108 | static const unsigned int tps658640_rtc_voltages[] = { |
108 | 3000000, 3050000, 3100000, 3150000, 3200000, 3250000, 3300000, 3350000, | ||
109 | 3400000, 3450000, 3500000, 3550000, 3600000, 3650000, 3700000, 3750000, | ||
110 | 3800000, 3850000, 3900000, 3950000, 4000000, 4050000, 4100000, 4150000, | ||
111 | 4200000, 4250000, 4300000, 4350000, 4400000, 4450000, 4500000, 4550000, | ||
112 | }; | ||
113 | |||
114 | static int tps658640_sm2_voltages[] = { | ||
115 | 2150000, 2200000, 2250000, 2300000, 2350000, 2400000, 2450000, 2500000, | ||
116 | 2550000, 2600000, 2650000, 2700000, 2750000, 2800000, 2850000, 2900000, | ||
117 | 2950000, 3000000, 3050000, 3100000, 3150000, 3200000, 3250000, 3300000, | ||
118 | 3350000, 3400000, 3450000, 3500000, 3550000, 3600000, 3650000, 3700000, | ||
119 | }; | ||
120 | |||
121 | static const unsigned int tps658643_sm2_voltages[] = { | ||
122 | 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, | ||
123 | 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000, | ||
124 | 1425000, 1450000, 1475000, 1500000, 1525000, 1550000, 1575000, 1600000, | ||
125 | 1625000, 1650000, 1675000, 1700000, 1725000, 1750000, 1775000, 1800000, | ||
126 | }; | ||
127 | |||
128 | static const unsigned int tps6586x_dvm_voltages[] = { | ||
129 | 725000, 750000, 775000, 800000, 825000, 850000, 875000, 900000, | ||
130 | 925000, 950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000, | ||
131 | 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, | ||
132 | 1325000, 1350000, 1375000, 1400000, 1425000, 1450000, 1475000, 1500000, | ||
133 | }; | ||
134 | |||
135 | static int tps658640_rtc_voltages[] = { | ||
136 | 2500000, 2850000, 3100000, 3300000, | 109 | 2500000, 2850000, 3100000, 3300000, |
137 | }; | 110 | }; |
138 | 111 | ||
@@ -159,6 +132,31 @@ static int tps658640_rtc_voltages[] = { | |||
159 | .enable_reg[1] = TPS6586X_SUPPLY##ereg1, \ | 132 | .enable_reg[1] = TPS6586X_SUPPLY##ereg1, \ |
160 | .enable_bit[1] = (ebit1), | 133 | .enable_bit[1] = (ebit1), |
161 | 134 | ||
135 | #define TPS6586X_REGULATOR_LINEAR(_id, _ops, _pin_name, n_volt, min_uv, \ | ||
136 | uv_step, vreg, shift, nbits, ereg0, \ | ||
137 | ebit0, ereg1, ebit1, goreg, gobit) \ | ||
138 | .desc = { \ | ||
139 | .supply_name = _pin_name, \ | ||
140 | .name = "REG-" #_id, \ | ||
141 | .ops = &tps6586x_## _ops ## _regulator_ops, \ | ||
142 | .type = REGULATOR_VOLTAGE, \ | ||
143 | .id = TPS6586X_ID_##_id, \ | ||
144 | .n_voltages = n_volt, \ | ||
145 | .min_uV = min_uv, \ | ||
146 | .uV_step = uv_step, \ | ||
147 | .owner = THIS_MODULE, \ | ||
148 | .enable_reg = TPS6586X_SUPPLY##ereg0, \ | ||
149 | .enable_mask = 1 << (ebit0), \ | ||
150 | .vsel_reg = TPS6586X_##vreg, \ | ||
151 | .vsel_mask = ((1 << (nbits)) - 1) << (shift), \ | ||
152 | .apply_reg = (goreg), \ | ||
153 | .apply_bit = (gobit), \ | ||
154 | }, \ | ||
155 | .enable_reg[0] = TPS6586X_SUPPLY##ereg0, \ | ||
156 | .enable_bit[0] = (ebit0), \ | ||
157 | .enable_reg[1] = TPS6586X_SUPPLY##ereg1, \ | ||
158 | .enable_bit[1] = (ebit1), | ||
159 | |||
162 | #define TPS6586X_LDO(_id, _pname, vdata, vreg, shift, nbits, \ | 160 | #define TPS6586X_LDO(_id, _pname, vdata, vreg, shift, nbits, \ |
163 | ereg0, ebit0, ereg1, ebit1) \ | 161 | ereg0, ebit0, ereg1, ebit1) \ |
164 | { \ | 162 | { \ |
@@ -166,6 +164,14 @@ static int tps658640_rtc_voltages[] = { | |||
166 | ereg0, ebit0, ereg1, ebit1, 0, 0) \ | 164 | ereg0, ebit0, ereg1, ebit1, 0, 0) \ |
167 | } | 165 | } |
168 | 166 | ||
167 | #define TPS6586X_LDO_LINEAR(_id, _pname, n_volt, min_uv, uv_step, vreg, \ | ||
168 | shift, nbits, ereg0, ebit0, ereg1, ebit1) \ | ||
169 | { \ | ||
170 | TPS6586X_REGULATOR_LINEAR(_id, rw_linear, _pname, n_volt, \ | ||
171 | min_uv, uv_step, vreg, shift, nbits, \ | ||
172 | ereg0, ebit0, ereg1, ebit1, 0, 0) \ | ||
173 | } | ||
174 | |||
169 | #define TPS6586X_FIXED_LDO(_id, _pname, vdata, vreg, shift, nbits, \ | 175 | #define TPS6586X_FIXED_LDO(_id, _pname, vdata, vreg, shift, nbits, \ |
170 | ereg0, ebit0, ereg1, ebit1) \ | 176 | ereg0, ebit0, ereg1, ebit1) \ |
171 | { \ | 177 | { \ |
@@ -173,11 +179,13 @@ static int tps658640_rtc_voltages[] = { | |||
173 | ereg0, ebit0, ereg1, ebit1, 0, 0) \ | 179 | ereg0, ebit0, ereg1, ebit1, 0, 0) \ |
174 | } | 180 | } |
175 | 181 | ||
176 | #define TPS6586X_DVM(_id, _pname, vdata, vreg, shift, nbits, \ | 182 | #define TPS6586X_DVM(_id, _pname, n_volt, min_uv, uv_step, vreg, shift, \ |
177 | ereg0, ebit0, ereg1, ebit1, goreg, gobit) \ | 183 | nbits, ereg0, ebit0, ereg1, ebit1, goreg, gobit) \ |
178 | { \ | 184 | { \ |
179 | TPS6586X_REGULATOR(_id, rw, _pname, vdata, vreg, shift, nbits, \ | 185 | TPS6586X_REGULATOR_LINEAR(_id, rw_linear, _pname, n_volt, \ |
180 | ereg0, ebit0, ereg1, ebit1, goreg, gobit) \ | 186 | min_uv, uv_step, vreg, shift, nbits, \ |
187 | ereg0, ebit0, ereg1, ebit1, goreg, \ | ||
188 | gobit) \ | ||
181 | } | 189 | } |
182 | 190 | ||
183 | #define TPS6586X_SYS_REGULATOR() \ | 191 | #define TPS6586X_SYS_REGULATOR() \ |
@@ -210,24 +218,23 @@ static struct tps6586x_regulator tps6586x_regulator[] = { | |||
210 | ENE, 7), | 218 | ENE, 7), |
211 | TPS6586X_LDO(LDO_RTC, "REG-SYS", tps6586x_ldo, SUPPLYV4, 3, 3, V4, 7, | 219 | TPS6586X_LDO(LDO_RTC, "REG-SYS", tps6586x_ldo, SUPPLYV4, 3, 3, V4, 7, |
212 | V4, 7), | 220 | V4, 7), |
213 | TPS6586X_LDO(LDO_1, "vinldo01", tps6586x_dvm, SUPPLYV1, 0, 5, ENC, 1, | 221 | TPS6586X_LDO_LINEAR(LDO_1, "vinldo01", 32, 725000, 25000, SUPPLYV1, |
214 | END, 1), | 222 | 0, 5, ENC, 1, END, 1), |
215 | TPS6586X_LDO(SM_2, "vin-sm2", tps6586x_sm2, SUPPLYV2, 0, 5, ENC, 7, | 223 | TPS6586X_LDO_LINEAR(SM_2, "vin-sm2", 32, 3000000, 50000, SUPPLYV2, |
216 | END, 7), | 224 | 0, 5, ENC, 7, END, 7), |
217 | 225 | TPS6586X_DVM(LDO_2, "vinldo23", 32, 725000, 25000, LDO2BV1, 0, 5, | |
218 | TPS6586X_DVM(LDO_2, "vinldo23", tps6586x_dvm, LDO2BV1, 0, 5, ENA, 3, | 226 | ENA, 3, ENB, 3, TPS6586X_VCC2, BIT(6)), |
219 | ENB, 3, TPS6586X_VCC2, BIT(6)), | 227 | TPS6586X_DVM(LDO_4, "vinldo4", 32, 1700000, 25000, LDO4V1, 0, 5, |
220 | TPS6586X_DVM(LDO_4, "vinldo4", tps6586x_ldo4, LDO4V1, 0, 5, ENC, 3, | 228 | ENC, 3, END, 3, TPS6586X_VCC1, BIT(6)), |
221 | END, 3, TPS6586X_VCC1, BIT(6)), | 229 | TPS6586X_DVM(SM_0, "vin-sm0", 32, 725000, 25000, SM0V1, 0, 5, |
222 | TPS6586X_DVM(SM_0, "vin-sm0", tps6586x_dvm, SM0V1, 0, 5, ENA, 1, | 230 | ENA, 1, ENB, 1, TPS6586X_VCC1, BIT(2)), |
223 | ENB, 1, TPS6586X_VCC1, BIT(2)), | 231 | TPS6586X_DVM(SM_1, "vin-sm1", 32, 725000, 25000, SM1V1, 0, 5, |
224 | TPS6586X_DVM(SM_1, "vin-sm1", tps6586x_dvm, SM1V1, 0, 5, ENA, 0, | 232 | ENA, 0, ENB, 0, TPS6586X_VCC1, BIT(0)), |
225 | ENB, 0, TPS6586X_VCC1, BIT(0)), | ||
226 | }; | 233 | }; |
227 | 234 | ||
228 | static struct tps6586x_regulator tps658623_regulator[] = { | 235 | static struct tps6586x_regulator tps658623_regulator[] = { |
229 | TPS6586X_LDO(SM_2, "vin-sm2", tps658623_sm2, SUPPLYV2, 0, 5, ENC, 7, | 236 | TPS6586X_LDO_LINEAR(SM_2, "vin-sm2", 32, 1700000, 25000, SUPPLYV2, |
230 | END, 7), | 237 | 0, 5, ENC, 7, END, 7), |
231 | }; | 238 | }; |
232 | 239 | ||
233 | static struct tps6586x_regulator tps658640_regulator[] = { | 240 | static struct tps6586x_regulator tps658640_regulator[] = { |
@@ -243,16 +250,16 @@ static struct tps6586x_regulator tps658640_regulator[] = { | |||
243 | ENC, 6, END, 6), | 250 | ENC, 6, END, 6), |
244 | TPS6586X_LDO(LDO_9, "vinldo9", tps6586x_ldo0, SUPPLYV6, 3, 3, | 251 | TPS6586X_LDO(LDO_9, "vinldo9", tps6586x_ldo0, SUPPLYV6, 3, 3, |
245 | ENE, 7, ENE, 7), | 252 | ENE, 7, ENE, 7), |
246 | TPS6586X_LDO(SM_2, "vin-sm2", tps658640_sm2, SUPPLYV2, 0, 5, | 253 | TPS6586X_LDO_LINEAR(SM_2, "vin-sm2", 32, 2150000, 50000, SUPPLYV2, |
247 | ENC, 7, END, 7), | 254 | 0, 5, ENC, 7, END, 7), |
248 | 255 | ||
249 | TPS6586X_FIXED_LDO(LDO_RTC, "REG-SYS", tps658640_rtc, SUPPLYV4, 3, 2, | 256 | TPS6586X_FIXED_LDO(LDO_RTC, "REG-SYS", tps658640_rtc, SUPPLYV4, 3, 2, |
250 | V4, 7, V4, 7), | 257 | V4, 7, V4, 7), |
251 | }; | 258 | }; |
252 | 259 | ||
253 | static struct tps6586x_regulator tps658643_regulator[] = { | 260 | static struct tps6586x_regulator tps658643_regulator[] = { |
254 | TPS6586X_LDO(SM_2, "vin-sm2", tps658643_sm2, SUPPLYV2, 0, 5, ENC, 7, | 261 | TPS6586X_LDO_LINEAR(SM_2, "vin-sm2", 32, 1025000, 25000, SUPPLYV2, |
255 | END, 7), | 262 | 0, 5, ENC, 7, END, 7), |
256 | }; | 263 | }; |
257 | 264 | ||
258 | /* | 265 | /* |