aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorStefan Agner <stefan@agner.ch>2013-12-06 07:51:46 -0500
committerLee Jones <lee.jones@linaro.org>2014-01-21 03:28:01 -0500
commit844a4f0d8a5ae075e06b6a673bbc0596510046df (patch)
tree5a02a6de3bd27ced52e31b049d45e4068c63dd91 /drivers
parente0a3da80c65dc427c30829eb3e361507f843778f (diff)
regulator: tps6586x: Add and use correct voltage table
Depending on the regulator version, the voltage table might be different. Use version specific regulator tables in order to select correct voltage table. For the following regulator versions different voltage tables are now used: * TPS658623: Use correct voltage table for SM2 * TPS658643: New voltage table for SM2 Both versions are in use on the Colibri T20 module. Make use of the correct tables by requesting the correct SM2 voltage of 1.8V. This change is not backward compatible since an old driver is not able to correctly set that value. The value 1.8V is out of range for the old driver and will refuse to probe the device. The regulator starts with default settings and the driver shows appropriate error messages. On Colibri T20, the old value used to work with TPS658623 since the driver applied a wrong voltage table too. However, the TPS658643 used on V1.2 devices uses yet another voltage table and those broke that pseudo-compatibility. The regulator driver now has the correct voltage table for both regulator versions and those the correct voltage can be used in the device tree. Signed-off-by: Stefan Agner <stefan@agner.ch> Reviewed-by: Thierry Reding <treding@nvidia.com> Acked-by: Mark Brown <broonie@linaro.org> Acked-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/tps6586x-regulator.c93
1 files changed, 74 insertions, 19 deletions
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index e8e3a8afd3e2..0485d47f0d8a 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -93,6 +93,8 @@ static const unsigned int tps6586x_ldo4_voltages[] = {
93 2300000, 2325000, 2350000, 2375000, 2400000, 2425000, 2450000, 2475000, 93 2300000, 2325000, 2350000, 2375000, 2400000, 2425000, 2450000, 2475000,
94}; 94};
95 95
96#define tps658623_sm2_voltages tps6586x_ldo4_voltages
97
96static const unsigned int tps6586x_ldo_voltages[] = { 98static const unsigned int tps6586x_ldo_voltages[] = {
97 1250000, 1500000, 1800000, 2500000, 2700000, 2850000, 3100000, 3300000, 99 1250000, 1500000, 1800000, 2500000, 2700000, 2850000, 3100000, 3300000,
98}; 100};
@@ -104,6 +106,13 @@ static const unsigned int tps6586x_sm2_voltages[] = {
104 4200000, 4250000, 4300000, 4350000, 4400000, 4450000, 4500000, 4550000, 106 4200000, 4250000, 4300000, 4350000, 4400000, 4450000, 4500000, 4550000,
105}; 107};
106 108
109static const unsigned int tps658643_sm2_voltages[] = {
110 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000,
111 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000,
112 1425000, 1450000, 1475000, 1500000, 1525000, 1550000, 1575000, 1600000,
113 1625000, 1650000, 1675000, 1700000, 1725000, 1750000, 1775000, 1800000,
114};
115
107static const unsigned int tps6586x_dvm_voltages[] = { 116static const unsigned int tps6586x_dvm_voltages[] = {
108 725000, 750000, 775000, 800000, 825000, 850000, 875000, 900000, 117 725000, 750000, 775000, 800000, 825000, 850000, 875000, 900000,
109 925000, 950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000, 118 925000, 950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000,
@@ -119,8 +128,8 @@ static const unsigned int tps6586x_dvm_voltages[] = {
119 .ops = &tps6586x_regulator_ops, \ 128 .ops = &tps6586x_regulator_ops, \
120 .type = REGULATOR_VOLTAGE, \ 129 .type = REGULATOR_VOLTAGE, \
121 .id = TPS6586X_ID_##_id, \ 130 .id = TPS6586X_ID_##_id, \
122 .n_voltages = ARRAY_SIZE(tps6586x_##vdata##_voltages), \ 131 .n_voltages = ARRAY_SIZE(vdata##_voltages), \
123 .volt_table = tps6586x_##vdata##_voltages, \ 132 .volt_table = vdata##_voltages, \
124 .owner = THIS_MODULE, \ 133 .owner = THIS_MODULE, \
125 .enable_reg = TPS6586X_SUPPLY##ereg0, \ 134 .enable_reg = TPS6586X_SUPPLY##ereg0, \
126 .enable_mask = 1 << (ebit0), \ 135 .enable_mask = 1 << (ebit0), \
@@ -162,27 +171,47 @@ static const unsigned int tps6586x_dvm_voltages[] = {
162 171
163static struct tps6586x_regulator tps6586x_regulator[] = { 172static struct tps6586x_regulator tps6586x_regulator[] = {
164 TPS6586X_SYS_REGULATOR(), 173 TPS6586X_SYS_REGULATOR(),
165 TPS6586X_LDO(LDO_0, "vinldo01", ldo0, SUPPLYV1, 5, 3, ENC, 0, END, 0), 174 TPS6586X_LDO(LDO_0, "vinldo01", tps6586x_ldo0, SUPPLYV1, 5, 3, ENC, 0,
166 TPS6586X_LDO(LDO_3, "vinldo23", ldo, SUPPLYV4, 0, 3, ENC, 2, END, 2), 175 END, 0),
167 TPS6586X_LDO(LDO_5, "REG-SYS", ldo, SUPPLYV6, 0, 3, ENE, 6, ENE, 6), 176 TPS6586X_LDO(LDO_3, "vinldo23", tps6586x_ldo, SUPPLYV4, 0, 3, ENC, 2,
168 TPS6586X_LDO(LDO_6, "vinldo678", ldo, SUPPLYV3, 0, 3, ENC, 4, END, 4), 177 END, 2),
169 TPS6586X_LDO(LDO_7, "vinldo678", ldo, SUPPLYV3, 3, 3, ENC, 5, END, 5), 178 TPS6586X_LDO(LDO_5, "REG-SYS", tps6586x_ldo, SUPPLYV6, 0, 3, ENE, 6,
170 TPS6586X_LDO(LDO_8, "vinldo678", ldo, SUPPLYV2, 5, 3, ENC, 6, END, 6), 179 ENE, 6),
171 TPS6586X_LDO(LDO_9, "vinldo9", ldo, SUPPLYV6, 3, 3, ENE, 7, ENE, 7), 180 TPS6586X_LDO(LDO_6, "vinldo678", tps6586x_ldo, SUPPLYV3, 0, 3, ENC, 4,
172 TPS6586X_LDO(LDO_RTC, "REG-SYS", ldo, SUPPLYV4, 3, 3, V4, 7, V4, 7), 181 END, 4),
173 TPS6586X_LDO(LDO_1, "vinldo01", dvm, SUPPLYV1, 0, 5, ENC, 1, END, 1), 182 TPS6586X_LDO(LDO_7, "vinldo678", tps6586x_ldo, SUPPLYV3, 3, 3, ENC, 5,
174 TPS6586X_LDO(SM_2, "vin-sm2", sm2, SUPPLYV2, 0, 5, ENC, 7, END, 7), 183 END, 5),
175 184 TPS6586X_LDO(LDO_8, "vinldo678", tps6586x_ldo, SUPPLYV2, 5, 3, ENC, 6,
176 TPS6586X_DVM(LDO_2, "vinldo23", dvm, LDO2BV1, 0, 5, ENA, 3, 185 END, 6),
186 TPS6586X_LDO(LDO_9, "vinldo9", tps6586x_ldo, SUPPLYV6, 3, 3, ENE, 7,
187 ENE, 7),
188 TPS6586X_LDO(LDO_RTC, "REG-SYS", tps6586x_ldo, SUPPLYV4, 3, 3, V4, 7,
189 V4, 7),
190 TPS6586X_LDO(LDO_1, "vinldo01", tps6586x_dvm, SUPPLYV1, 0, 5, ENC, 1,
191 END, 1),
192 TPS6586X_LDO(SM_2, "vin-sm2", tps6586x_sm2, SUPPLYV2, 0, 5, ENC, 7,
193 END, 7),
194
195 TPS6586X_DVM(LDO_2, "vinldo23", tps6586x_dvm, LDO2BV1, 0, 5, ENA, 3,
177 ENB, 3, TPS6586X_VCC2, BIT(6)), 196 ENB, 3, TPS6586X_VCC2, BIT(6)),
178 TPS6586X_DVM(LDO_4, "vinldo4", ldo4, LDO4V1, 0, 5, ENC, 3, 197 TPS6586X_DVM(LDO_4, "vinldo4", tps6586x_ldo4, LDO4V1, 0, 5, ENC, 3,
179 END, 3, TPS6586X_VCC1, BIT(6)), 198 END, 3, TPS6586X_VCC1, BIT(6)),
180 TPS6586X_DVM(SM_0, "vin-sm0", dvm, SM0V1, 0, 5, ENA, 1, 199 TPS6586X_DVM(SM_0, "vin-sm0", tps6586x_dvm, SM0V1, 0, 5, ENA, 1,
181 ENB, 1, TPS6586X_VCC1, BIT(2)), 200 ENB, 1, TPS6586X_VCC1, BIT(2)),
182 TPS6586X_DVM(SM_1, "vin-sm1", dvm, SM1V1, 0, 5, ENA, 0, 201 TPS6586X_DVM(SM_1, "vin-sm1", tps6586x_dvm, SM1V1, 0, 5, ENA, 0,
183 ENB, 0, TPS6586X_VCC1, BIT(0)), 202 ENB, 0, TPS6586X_VCC1, BIT(0)),
184}; 203};
185 204
205static struct tps6586x_regulator tps658623_regulator[] = {
206 TPS6586X_LDO(SM_2, "vin-sm2", tps658623_sm2, SUPPLYV2, 0, 5, ENC, 7,
207 END, 7),
208};
209
210static struct tps6586x_regulator tps658643_regulator[] = {
211 TPS6586X_LDO(SM_2, "vin-sm2", tps658643_sm2, SUPPLYV2, 0, 5, ENC, 7,
212 END, 7),
213};
214
186/* 215/*
187 * TPS6586X has 2 enable bits that are OR'ed to determine the actual 216 * TPS6586X has 2 enable bits that are OR'ed to determine the actual
188 * regulator state. Clearing one of this bits allows switching 217 * regulator state. Clearing one of this bits allows switching
@@ -254,11 +283,33 @@ static int tps6586x_regulator_set_slew_rate(struct platform_device *pdev,
254 setting->slew_rate & TPS6586X_SLEW_RATE_MASK); 283 setting->slew_rate & TPS6586X_SLEW_RATE_MASK);
255} 284}
256 285
257static inline struct tps6586x_regulator *find_regulator_info(int id) 286static struct tps6586x_regulator *find_regulator_info(int id, int version)
258{ 287{
259 struct tps6586x_regulator *ri; 288 struct tps6586x_regulator *ri;
289 struct tps6586x_regulator *table = NULL;
290 int num;
260 int i; 291 int i;
261 292
293 switch (version) {
294 case TPS658623:
295 table = tps658623_regulator;
296 num = ARRAY_SIZE(tps658623_regulator);
297 break;
298 case TPS658643:
299 table = tps658643_regulator;
300 num = ARRAY_SIZE(tps658643_regulator);
301 break;
302 }
303
304 /* Search version specific table first */
305 if (table) {
306 for (i = 0; i < num; i++) {
307 ri = &table[i];
308 if (ri->desc.id == id)
309 return ri;
310 }
311 }
312
262 for (i = 0; i < ARRAY_SIZE(tps6586x_regulator); i++) { 313 for (i = 0; i < ARRAY_SIZE(tps6586x_regulator); i++) {
263 ri = &tps6586x_regulator[i]; 314 ri = &tps6586x_regulator[i];
264 if (ri->desc.id == id) 315 if (ri->desc.id == id)
@@ -351,6 +402,7 @@ static int tps6586x_regulator_probe(struct platform_device *pdev)
351 struct regulator_init_data *reg_data; 402 struct regulator_init_data *reg_data;
352 struct tps6586x_platform_data *pdata; 403 struct tps6586x_platform_data *pdata;
353 struct of_regulator_match *tps6586x_reg_matches = NULL; 404 struct of_regulator_match *tps6586x_reg_matches = NULL;
405 int version;
354 int id; 406 int id;
355 int err; 407 int err;
356 408
@@ -373,10 +425,13 @@ static int tps6586x_regulator_probe(struct platform_device *pdev)
373 return -ENOMEM; 425 return -ENOMEM;
374 } 426 }
375 427
428 version = tps6586x_get_version(pdev->dev.parent);
429
376 for (id = 0; id < TPS6586X_ID_MAX_REGULATOR; ++id) { 430 for (id = 0; id < TPS6586X_ID_MAX_REGULATOR; ++id) {
377 reg_data = pdata->reg_init_data[id]; 431 reg_data = pdata->reg_init_data[id];
378 432
379 ri = find_regulator_info(id); 433 ri = find_regulator_info(id, version);
434
380 if (!ri) { 435 if (!ri) {
381 dev_err(&pdev->dev, "invalid regulator ID specified\n"); 436 dev_err(&pdev->dev, "invalid regulator ID specified\n");
382 return -EINVAL; 437 return -EINVAL;