regulator: palma: Disable smps10 boost during suspend
[linux-2.6.git] / drivers / regulator / tps80031-regulator.c
1 /*
2  * driver/regulator/tps80031-regulator.c
3  *
4  * Regulator driver for TI TPS80031
5  *
6  * Copyright (C) 2011 NVIDIA Corporation
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16  * more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21  *
22  */
23
24 #include <linux/kernel.h>
25 #include <linux/delay.h>
26 #include <linux/init.h>
27 #include <linux/err.h>
28 #include <linux/slab.h>
29 #include <linux/platform_device.h>
30 #include <linux/regulator/driver.h>
31 #include <linux/regulator/machine.h>
32 #include <linux/regulator/tps80031-regulator.h>
33 #include <linux/mfd/tps80031.h>
34 #include <linux/module.h>
35
36 /* Flags for DCDC Voltage reading */
37 #define DCDC_OFFSET_EN          BIT(0)
38 #define DCDC_EXTENDED_EN        BIT(1)
39 #define TRACK_MODE_ENABLE       BIT(2)
40
41 #define SMPS_MULTOFFSET_VIO     BIT(1)
42 #define SMPS_MULTOFFSET_SMPS1   BIT(3)
43 #define SMPS_MULTOFFSET_SMPS2   BIT(4)
44 #define SMPS_MULTOFFSET_SMPS3   BIT(6)
45 #define SMPS_MULTOFFSET_SMPS4   BIT(0)
46
47 #define PMC_SMPS_OFFSET_ADD     0xE0
48 #define PMC_SMPS_MULT_ADD       0xE3
49
50 #define STATE_OFF               0x00
51 #define STATE_ON                0x01
52 #define STATE_MASK              0x03
53
54 #define TRANS_SLEEP_OFF         0x00
55 #define TRANS_SLEEP_ON          0x04
56 #define TRANS_SLEEP_MASK        0x0C
57
58 #define SMPS_CMD_MASK           0xC0
59 #define SMPS_VSEL_MASK          0x3F
60 #define LDO_VSEL_MASK           0x1F
61
62 #define TPS80031_MISC2_ADD      0xE5
63 #define MISC2_LDOUSB_IN_VSYS    0x10
64 #define MISC2_LDOUSB_IN_PMID    0x08
65 #define MISC2_LDOUSB_IN_MASK    0x18
66
67 #define MISC2_LDO3_SEL_VIB_VAL  BIT(0)
68 #define MISC2_LDO3_SEL_VIB_MASK 0x1
69
70 #define CHARGERUSB_CTRL3_ADD    0xEA
71 #define BOOST_HW_PWR_EN         BIT(5)
72 #define BOOST_HW_PWR_EN_MASK    BIT(5)
73
74 #define CHARGERUSB_CTRL1_ADD    0xE8
75 #define OPA_MODE_EN             BIT(6)
76 #define OPA_MODE_EN_MASK        BIT(6)
77
78 #define USB_VBUS_CTRL_SET       0x04
79 #define USB_VBUS_CTRL_CLR       0x05
80 #define VBUS_DISCHRG            0x20
81
82 #define EXT_PWR_REQ (PWR_REQ_INPUT_PREQ1 | PWR_REQ_INPUT_PREQ2 | \
83                         PWR_REQ_INPUT_PREQ3)
84
85 struct tps80031_regulator_info {
86         /* Regulator register address.*/
87         u8              trans_reg;
88         u8              state_reg;
89         u8              force_reg;
90         u8              volt_reg;
91         u8              volt_id;
92
93         /* chip constraints on regulator behavior */
94         u16                     min_mV;
95         u16                     max_mV;
96
97         /* regulator specific turn-on delay as per datasheet*/
98         int                     delay;
99
100         /* used by regulator core */
101         struct regulator_desc   desc;
102
103         /*Power request bits */
104         int preq_bit;
105 };
106
107 struct tps80031_regulator {
108         struct device                   *dev;
109         struct regulator_dev            *rdev;
110         struct tps80031_regulator_info  *rinfo;
111         unsigned int                    tolerance_uv;
112
113         /* Regulator specific turn-on delay if board file provided */
114         int                             delay;
115
116         u8                              flags;
117         unsigned int                    platform_flags;
118         unsigned int                    ext_ctrl_flag;
119
120         /* Cached register */
121         uint8_t         trans_reg_cache;
122         uint8_t         state_reg_cache;
123         uint8_t         force_reg_cache;
124         uint8_t         volt_reg_cache;
125 };
126
127 static inline struct device *to_tps80031_dev(struct regulator_dev *rdev)
128 {
129         return rdev_get_dev(rdev)->parent->parent;
130 }
131
132 static int tps80031_regulator_enable_time(struct regulator_dev *rdev)
133 {
134         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
135
136         return ri->delay;
137 }
138
139 static u8 tps80031_get_smps_offset(struct device *parent)
140 {
141         u8 value;
142         int ret;
143
144         ret = tps80031_read(parent, SLAVE_ID1, PMC_SMPS_OFFSET_ADD, &value);
145         if (ret < 0) {
146                 dev_err(parent, "Error in reading smps offset register\n");
147                 return 0;
148         }
149         return value;
150 }
151
152 static u8 tps80031_get_smps_mult(struct device *parent)
153 {
154         u8 value;
155         int ret;
156
157         ret = tps80031_read(parent, SLAVE_ID1, PMC_SMPS_MULT_ADD, &value);
158         if (ret < 0) {
159                 dev_err(parent, "Error in reading smps mult register\n");
160                 return 0;
161         }
162         return value;
163 }
164
165 static int tps80031_reg_is_enabled(struct regulator_dev *rdev)
166 {
167         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
168
169         if (ri->ext_ctrl_flag & EXT_PWR_REQ)
170                 return true;
171         return ((ri->state_reg_cache & STATE_MASK) == STATE_ON);
172 }
173
174 static int tps80031_reg_enable(struct regulator_dev *rdev)
175 {
176         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
177         struct device *parent = to_tps80031_dev(rdev);
178         int ret;
179         uint8_t reg_val;
180
181         if (ri->ext_ctrl_flag & EXT_PWR_REQ)
182                 return 0;
183
184         reg_val = (ri->state_reg_cache & ~STATE_MASK) |
185                                         (STATE_ON & STATE_MASK);
186         ret = tps80031_write(parent, SLAVE_ID1, ri->rinfo->state_reg, reg_val);
187         if (ret < 0) {
188                 dev_err(&rdev->dev, "Error in writing the STATE register\n");
189                 return ret;
190         }
191         ri->state_reg_cache = reg_val;
192         udelay(ri->delay);
193         return ret;
194 }
195
196 static int tps80031_reg_disable(struct regulator_dev *rdev)
197 {
198         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
199         struct device *parent = to_tps80031_dev(rdev);
200         int ret;
201         uint8_t reg_val;
202
203         if (ri->ext_ctrl_flag & EXT_PWR_REQ)
204                 return 0;
205
206         reg_val = (ri->state_reg_cache & ~STATE_MASK) |
207                                         (STATE_OFF & STATE_MASK);
208         ret = tps80031_write(parent, SLAVE_ID1, ri->rinfo->state_reg, reg_val);
209         if (ret < 0)
210                 dev_err(&rdev->dev, "Error in writing the STATE register\n");
211         else
212                 ri->state_reg_cache = reg_val;
213         return ret;
214 }
215
216 /*
217  * DCDC status and control
218  */
219 static int tps80031dcdc_list_voltage(struct regulator_dev *rdev, unsigned index)
220 {
221         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
222         int voltage = 0;
223
224         switch (ri->flags) {
225         case 0:
226                 if (index == 0)
227                         voltage = 0;
228                 else if (index < 58)
229                         voltage = (607700 + (12660 * (index - 1)));
230                 else if (index == 58)
231                         voltage = 1350 * 1000;
232                 else if (index == 59)
233                         voltage = 1500 * 1000;
234                 else if (index == 60)
235                         voltage = 1800 * 1000;
236                 else if (index == 61)
237                         voltage = 1900 * 1000;
238                 else if (index == 62)
239                         voltage = 2100 * 1000;
240                 break;
241
242         case DCDC_OFFSET_EN:
243                 if (index == 0)
244                         voltage = 0;
245                 else if (index < 58)
246                         voltage = (700000 + (12500 * (index - 1)));
247                 else if (index == 58)
248                         voltage = 1350 * 1000;
249                 else if (index == 59)
250                         voltage = 1500 * 1000;
251                 else if (index == 60)
252                         voltage = 1800 * 1000;
253                 else if (index == 61)
254                         voltage = 1900 * 1000;
255                 else if (index == 62)
256                         voltage = 2100 * 1000;
257                 break;
258
259         case DCDC_EXTENDED_EN:
260                 if (index == 0)
261                         voltage = 0;
262                 else if (index < 58)
263                         voltage = (1852000 + (38600 * (index - 1)));
264                 else if (index == 58)
265                         voltage = 2084 * 1000;
266                 else if (index == 59)
267                         voltage = 2315 * 1000;
268                 else if (index == 60)
269                         voltage = 2778 * 1000;
270                 else if (index == 61)
271                         voltage = 2932 * 1000;
272                 else if (index == 62)
273                         voltage = 3241 * 1000;
274                 break;
275
276         case DCDC_OFFSET_EN|DCDC_EXTENDED_EN:
277                 if (index == 0)
278                         voltage = 0;
279                 else if (index < 58)
280                         voltage = (2161000 + (38600 * (index - 1)));
281                 else if (index == 58)
282                         voltage = 4167 * 1000;
283                 else if (index == 59)
284                         voltage = 2315 * 1000;
285                 else if (index == 60)
286                         voltage = 2778 * 1000;
287                 else if (index == 61)
288                         voltage = 2932 * 1000;
289                 else if (index == 62)
290                         voltage = 3241 * 1000;
291                 break;
292         }
293
294         return voltage;
295 }
296
297 static int __tps80031_dcdc_set_voltage(struct device *parent,
298                                        struct tps80031_regulator *ri,
299                                        int min_uV, int max_uV,
300                                        unsigned *selector)
301 {
302         int vsel = 0;
303         int ret;
304
305         switch (ri->flags) {
306         case 0:
307                 if (min_uV >= (607700 + ri->tolerance_uv))
308                         min_uV = min_uV - ri->tolerance_uv;
309
310                 if (min_uV == 0)
311                         vsel = 0;
312                 else if ((min_uV >= 607700) && (min_uV <= 1300000)) {
313                         int cal_volt;
314                         vsel = (10 * (min_uV - 607700)) / 1266;
315                         if (vsel % 100)
316                                 vsel += 100;
317                         vsel /= 100;
318                         vsel++;
319                         cal_volt = (607700 + (12660 * (vsel - 1)));
320                         if (cal_volt > max_uV)
321                                 return -EINVAL;
322                 } else if ((min_uV > 1900000) && (max_uV >= 2100000))
323                         vsel = 62;
324                 else if ((min_uV > 1800000) && (max_uV >= 1900000))
325                         vsel = 61;
326                 else if ((min_uV > 1500000) && (max_uV >= 1800000))
327                         vsel = 60;
328                 else if ((min_uV > 1350000) && (max_uV >= 1500000))
329                         vsel = 59;
330                 else if ((min_uV > 1300000) && (max_uV >= 1350000))
331                         vsel = 58;
332                 else
333                         return -EINVAL;
334                 break;
335
336         case DCDC_OFFSET_EN:
337                 if (min_uV >= (700000 + ri->tolerance_uv))
338                         min_uV = min_uV - ri->tolerance_uv;
339                 if (min_uV == 0)
340                         vsel = 0;
341                 else if ((min_uV >= 700000) && (min_uV <= 1420000)) {
342                         int cal_volt;
343                         vsel = (min_uV - 700000) / 125;
344                         if (vsel % 100)
345                                 vsel += 100;
346                         vsel /= 100;
347                         vsel++;
348                         cal_volt = (700000 + (12500 * (vsel - 1)));
349                         if (cal_volt > max_uV)
350                                 return -EINVAL;
351                 } else if ((min_uV > 1900000) && (max_uV >= 2100000))
352                         vsel = 62;
353                 else if ((min_uV > 1800000) && (max_uV >= 1900000))
354                         vsel = 61;
355                 else if ((min_uV > 1500000) && (max_uV >= 1800000))
356                         vsel = 60;
357                 else if ((min_uV > 1350000) && (max_uV >= 1500000))
358                         vsel = 59;
359                 else if ((min_uV > 1300000) && (max_uV >= 1350000))
360                         vsel = 58;
361                 else
362                         return -EINVAL;
363                 break;
364
365         case DCDC_EXTENDED_EN:
366                 if (min_uV >= (1852000 + ri->tolerance_uv))
367                         min_uV = min_uV - ri->tolerance_uv;
368                 if (min_uV == 0)
369                         vsel = 0;
370                 else if ((min_uV >= 1852000) && (max_uV <= 4013600)) {
371                         vsel = (min_uV - 1852000) / 386;
372                         if (vsel % 100)
373                                 vsel += 100;
374                         vsel++;
375                 }
376                 break;
377
378         case DCDC_OFFSET_EN|DCDC_EXTENDED_EN:
379                 if (min_uV >= (2161000 + ri->tolerance_uv))
380                         min_uV = min_uV - ri->tolerance_uv;
381                 if (min_uV == 0)
382                         vsel = 0;
383                 else if ((min_uV >= 2161000) && (max_uV <= 4321000)) {
384                         vsel = (min_uV - 2161000) / 386;
385                         if (vsel % 100)
386                                 vsel += 100;
387                         vsel /= 100;
388                         vsel++;
389                 }
390                 break;
391         }
392
393         if (selector)
394                 *selector = vsel;
395
396         if (ri->rinfo->force_reg) {
397                 if (((ri->force_reg_cache >> 6) & 0x3) == 0) {
398                         ret = tps80031_write(parent, ri->rinfo->volt_id,
399                                                 ri->rinfo->force_reg, vsel);
400                         if (ret < 0)
401                                 dev_err(ri->dev, "Error in writing the "
402                                                 "force register\n");
403                         else
404                                 ri->force_reg_cache = vsel;
405                         return ret;
406                 }
407         }
408         ret = tps80031_write(parent, ri->rinfo->volt_id,
409                                         ri->rinfo->volt_reg, vsel);
410         if (ret < 0)
411                 dev_err(ri->dev, "Error in writing the Voltage register\n");
412         else
413                 ri->volt_reg_cache = vsel;
414         return ret;
415 }
416
417 static int tps80031dcdc_set_voltage(struct regulator_dev *rdev,
418                         int min_uV, int max_uV, unsigned *selector)
419 {
420         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
421         struct device *parent = to_tps80031_dev(rdev);
422         return __tps80031_dcdc_set_voltage(parent, ri, min_uV, max_uV,
423                                            selector);
424 }
425
426 static int tps80031dcdc_get_voltage(struct regulator_dev *rdev)
427 {
428         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
429         uint8_t vsel = 0;
430         int voltage = 0;
431
432         if (ri->rinfo->force_reg) {
433                 vsel  = ri->force_reg_cache;
434                 if ((vsel & SMPS_CMD_MASK) == 0)
435                         goto decode;
436         }
437
438         vsel =  ri->volt_reg_cache;
439
440 decode:
441         vsel &= SMPS_VSEL_MASK;
442
443         switch (ri->flags) {
444         case 0:
445                 if (vsel == 0)
446                         voltage = 0;
447                 else if (vsel < 58)
448                         voltage = (607700 + (12660 * (vsel - 1)));
449                 else if (vsel == 58)
450                         voltage = 1350 * 1000;
451                 else if (vsel == 59)
452                         voltage = 1500 * 1000;
453                 else if (vsel == 60)
454                         voltage = 1800 * 1000;
455                 else if (vsel == 61)
456                         voltage = 1900 * 1000;
457                 else if (vsel == 62)
458                         voltage = 2100 * 1000;
459                 break;
460
461         case DCDC_OFFSET_EN:
462                 if (vsel == 0)
463                         voltage = 0;
464                 else if (vsel < 58)
465                         voltage = (700000 + (12500 * (vsel - 1)));
466                 else if (vsel == 58)
467                         voltage = 1350 * 1000;
468                 else if (vsel == 59)
469                         voltage = 1500 * 1000;
470                 else if (vsel == 60)
471                         voltage = 1800 * 1000;
472                 else if (vsel == 61)
473                         voltage = 1900 * 1000;
474                 else if (vsel == 62)
475                         voltage = 2100 * 1000;
476                 break;
477
478         case DCDC_EXTENDED_EN:
479                 if (vsel == 0)
480                         voltage = 0;
481                 else if (vsel < 58)
482                         voltage = (1852000 + (38600 * (vsel - 1)));
483                 else if (vsel == 58)
484                         voltage = 2084 * 1000;
485                 else if (vsel == 59)
486                         voltage = 2315 * 1000;
487                 else if (vsel == 60)
488                         voltage = 2778 * 1000;
489                 else if (vsel == 61)
490                         voltage = 2932 * 1000;
491                 else if (vsel == 62)
492                         voltage = 3241 * 1000;
493                 break;
494
495         case DCDC_EXTENDED_EN|DCDC_OFFSET_EN:
496                 if (vsel == 0)
497                         voltage = 0;
498                 else if (vsel < 58)
499                         voltage = (2161000 + (38600 * (vsel - 1)));
500                 else if (vsel == 58)
501                         voltage = 4167 * 1000;
502                 else if (vsel == 59)
503                         voltage = 2315 * 1000;
504                 else if (vsel == 60)
505                         voltage = 2778 * 1000;
506                 else if (vsel == 61)
507                         voltage = 2932 * 1000;
508                 else if (vsel == 62)
509                         voltage = 3241 * 1000;
510                 break;
511         }
512
513         return voltage;
514 }
515
516 static int tps80031ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
517 {
518         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
519
520         if (index == 0)
521                 return 0;
522
523         if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) &&
524                         (ri->flags &  TRACK_MODE_ENABLE))
525                 return (ri->rinfo->min_mV + (((index - 1) * 125))/10) * 1000;
526
527         return (ri->rinfo->min_mV + ((index - 1) * 100)) * 1000;
528 }
529
530 static int __tps80031_ldo2_set_voltage_track_mode(struct device *parent,
531                 struct tps80031_regulator *ri, int min_uV, int max_uV)
532 {
533         int vsel = 0;
534         int ret;
535         int nvsel;
536
537         if (min_uV < 600000) {
538                 vsel = 0;
539         } else if ((min_uV >= 600000) && (max_uV <= 1300000)) {
540                 vsel = (min_uV - 600000) / 125;
541                 if (vsel % 100)
542                         vsel += 100;
543                 vsel /= 100;
544                 vsel++;
545         } else {
546                 return -EINVAL;
547         }
548
549         /* Check for valid setting for TPS80031 or TPS80032-ES1.0 */
550         if ((tps80031_get_chip_info(parent) == TPS80031) ||
551                 ((tps80031_get_chip_info(parent) == TPS80032) &&
552                 (tps80031_get_pmu_version(parent) == 0x0))) {
553                 nvsel = vsel & 0x1F;
554                 if ((nvsel == 0x0) || (nvsel >= 0x19 && nvsel <= 0x1F)) {
555                         dev_err(ri->dev, "Invalid value for track mode LDO2 "
556                                 "configuration for TPS8003x PMU\n");
557                         return -EINVAL;
558                 }
559         }
560
561         ret = tps80031_write(parent, ri->rinfo->volt_id,
562                                 ri->rinfo->volt_reg, vsel);
563         if (ret < 0)
564                 dev_err(ri->dev, "Error in writing the Voltage register\n");
565         else
566                 ri->volt_reg_cache = vsel;
567         return ret;
568 }
569
570
571 static int __tps80031_ldo_set_voltage(struct device *parent,
572                                       struct tps80031_regulator *ri,
573                                       int min_uV, int max_uV,
574                                       unsigned *selector)
575 {
576         int vsel;
577         int ret;
578
579         if ((min_uV/1000 < ri->rinfo->min_mV) ||
580                         (max_uV/1000 > ri->rinfo->max_mV))
581                 return -EDOM;
582
583         if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) &&
584                         (ri->flags &  TRACK_MODE_ENABLE))
585                 return __tps80031_ldo2_set_voltage_track_mode(parent, ri,
586                                 min_uV, max_uV);
587
588         /*
589          * Use the below formula to calculate vsel
590          * mV = 1000mv + 100mv * (vsel - 1)
591          */
592         vsel = (min_uV/1000 - 1000)/100 + 1;
593         if (selector)
594                 *selector = vsel;
595         ret = tps80031_write(parent, ri->rinfo->volt_id,
596                                 ri->rinfo->volt_reg, vsel);
597         if (ret < 0)
598                 dev_err(ri->dev, "Error in writing the Voltage register\n");
599         else
600                 ri->volt_reg_cache = vsel;
601         return ret;
602 }
603
604 static int tps80031ldo_set_voltage(struct regulator_dev *rdev,
605                 int min_uV, int max_uV, unsigned *selector)
606 {
607         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
608         struct device *parent = to_tps80031_dev(rdev);
609
610         return __tps80031_ldo_set_voltage(parent, ri, min_uV, max_uV,
611                                           selector);
612 }
613
614 static int tps80031ldo_get_voltage(struct regulator_dev *rdev)
615 {
616         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
617         uint8_t vsel;
618
619
620         if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) &&
621                         (ri->flags &  TRACK_MODE_ENABLE)) {
622                 vsel = ri->volt_reg_cache & 0x3F;
623                 return (ri->rinfo->min_mV + (((vsel - 1) * 125))/10) * 1000;
624         }
625
626         vsel = ri->volt_reg_cache & LDO_VSEL_MASK;
627         /*
628          * Use the below formula to calculate vsel
629          * mV = 1000mv + 100mv * (vsel - 1)
630          */
631         return (1000 + (100 * (vsel - 1))) * 1000;
632 }
633
634 /* VBUS */
635 static int tps80031_vbus_enable_time(struct regulator_dev *rdev)
636 {
637         /* Enable and settling time for vbus is 3ms */
638         return 3000;
639 }
640 static int tps80031_vbus_is_enabled(struct regulator_dev *rdev)
641 {
642         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
643         struct device *parent = to_tps80031_dev(rdev);
644         uint8_t ctrl1, ctrl3;
645         int ret;
646
647         if (ri->platform_flags & VBUS_SW_ONLY) {
648                 ret = tps80031_read(parent, SLAVE_ID2,
649                                 CHARGERUSB_CTRL1_ADD, &ctrl1);
650                 if (!ret)
651                         ret = tps80031_read(parent, SLAVE_ID2,
652                                         CHARGERUSB_CTRL3_ADD, &ctrl3);
653                 if (ret < 0) {
654                         dev_err(&rdev->dev, "Error in reading control reg\n");
655                         return ret;
656                 }
657                 if ((ctrl1 & OPA_MODE_EN) && (ctrl3 & BOOST_HW_PWR_EN))
658                         return 1;
659                 return 0;
660         } else {
661                 return -EIO;
662         }
663 }
664
665 static int tps80031_vbus_enable(struct regulator_dev *rdev)
666 {
667         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
668         struct device *parent = to_tps80031_dev(rdev);
669         int ret;
670
671         if (ri->platform_flags & VBUS_SW_ONLY) {
672                 ret = tps80031_set_bits(parent, SLAVE_ID2,
673                                 CHARGERUSB_CTRL1_ADD,  OPA_MODE_EN);
674                 if (!ret)
675                         ret = tps80031_set_bits(parent, SLAVE_ID2,
676                                         CHARGERUSB_CTRL3_ADD, BOOST_HW_PWR_EN);
677                 if (ret < 0) {
678                         dev_err(&rdev->dev, "Error in reading control reg\n");
679                         return ret;
680                 }
681                 udelay(ri->delay);
682                 return ret;
683         }
684         dev_err(&rdev->dev, "%s() is not supported with flag 0x%08x\n",
685                  __func__, ri->platform_flags);
686         return -EIO;
687 }
688
689 static int tps80031_vbus_disable(struct regulator_dev *rdev)
690 {
691         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
692         struct device *parent = to_tps80031_dev(rdev);
693         int ret = 0;
694
695         if (ri->platform_flags & VBUS_SW_ONLY) {
696
697                 if (ri->platform_flags & VBUS_DISCHRG_EN_PDN)
698                         ret = tps80031_write(parent, SLAVE_ID2,
699                                 USB_VBUS_CTRL_SET, VBUS_DISCHRG);
700                 if (!ret)
701                         ret = tps80031_clr_bits(parent, SLAVE_ID2,
702                                 CHARGERUSB_CTRL1_ADD,  OPA_MODE_EN);
703                 if (!ret)
704                         ret = tps80031_clr_bits(parent, SLAVE_ID2,
705                                         CHARGERUSB_CTRL3_ADD, BOOST_HW_PWR_EN);
706                 if (!ret)
707                         mdelay((ri->delay + 999)/1000);
708
709                 if (ri->platform_flags & VBUS_DISCHRG_EN_PDN)
710                         tps80031_write(parent, SLAVE_ID2,
711                                 USB_VBUS_CTRL_CLR, VBUS_DISCHRG);
712
713                 if (ret < 0)
714                         dev_err(&rdev->dev, "Error in reading control reg\n");
715                 return ret;
716         }
717         dev_err(&rdev->dev, "%s() is not supported with flag 0x%08x\n",
718                  __func__, ri->platform_flags);
719         return -EIO;
720 }
721
722 static int tps80031vbus_get_voltage(struct regulator_dev *rdev)
723 {
724         int ret;
725         ret = tps80031_vbus_is_enabled(rdev);
726         if (ret > 0)
727                 return 5000000;
728         return ret;
729 }
730
731 static int tps80031_extreg_enable_time(struct regulator_dev *rdev)
732 {
733         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
734         return ri->delay;
735 }
736
737 static int tps80031_extreg_get_voltage(struct regulator_dev *rdev)
738 {
739         struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
740         int ret;
741         ret = tps80031_reg_is_enabled(rdev);
742         if (ret > 0)
743                 return ri->rinfo->max_mV * 1000;
744         return 0;
745 }
746
747 static struct regulator_ops tps80031dcdc_ops = {
748         .list_voltage   = tps80031dcdc_list_voltage,
749         .set_voltage    = tps80031dcdc_set_voltage,
750         .get_voltage    = tps80031dcdc_get_voltage,
751         .enable         = tps80031_reg_enable,
752         .disable        = tps80031_reg_disable,
753         .is_enabled     = tps80031_reg_is_enabled,
754         .enable_time    = tps80031_regulator_enable_time,
755 };
756
757 static struct regulator_ops tps80031ldo_ops = {
758         .list_voltage   = tps80031ldo_list_voltage,
759         .set_voltage    = tps80031ldo_set_voltage,
760         .get_voltage    = tps80031ldo_get_voltage,
761         .enable         = tps80031_reg_enable,
762         .disable        = tps80031_reg_disable,
763         .is_enabled     = tps80031_reg_is_enabled,
764         .enable_time    = tps80031_regulator_enable_time,
765 };
766
767 static struct regulator_ops tps80031vbus_ops = {
768         .get_voltage    = tps80031vbus_get_voltage,
769         .enable         = tps80031_vbus_enable,
770         .disable        = tps80031_vbus_disable,
771         .is_enabled     = tps80031_vbus_is_enabled,
772         .enable_time    = tps80031_vbus_enable_time,
773 };
774
775 static struct regulator_ops tps80031_ext_reg_ops = {
776         .enable         = tps80031_reg_enable,
777         .disable        = tps80031_reg_disable,
778         .is_enabled     = tps80031_reg_is_enabled,
779         .enable_time    = tps80031_extreg_enable_time,
780         .get_voltage    = tps80031_extreg_get_voltage,
781 };
782
783
784
785 #define TPS80031_REG(_id, _trans_reg, _state_reg, _force_reg, _volt_reg, \
786                 _volt_id, min_mVolts, max_mVolts, _ops, _n_volt, _delay, \
787                 _preq_bit)                                               \
788 {                                                               \
789         .trans_reg = _trans_reg,                                \
790         .state_reg = _state_reg,                                \
791         .force_reg = _force_reg,                                \
792         .volt_reg = _volt_reg,                                  \
793         .volt_id = _volt_id,                                    \
794         .min_mV = min_mVolts,                                   \
795         .max_mV = max_mVolts,                                   \
796         .desc = {                                               \
797                 .name = tps80031_rails(_id),                    \
798                 .id = TPS80031_REGULATOR_##_id,                 \
799                 .n_voltages = _n_volt,                          \
800                 .ops = &_ops,                                   \
801                 .type = REGULATOR_VOLTAGE,                      \
802                 .owner = THIS_MODULE,                           \
803         },                                                      \
804         .delay = _delay,                                        \
805         .preq_bit = _preq_bit,                                  \
806 }
807
808 static struct tps80031_regulator_info tps80031_regulator_info[] = {
809         TPS80031_REG(VIO,   0x47, 0x48, 0x49, 0x4A, SLAVE_ID0, 600, 2100,
810                                 tps80031dcdc_ops, 63, 500, 4),
811         TPS80031_REG(SMPS1, 0x53, 0x54, 0x55, 0x56, SLAVE_ID0, 600, 2100,
812                                 tps80031dcdc_ops, 63, 500, 0),
813         TPS80031_REG(SMPS2, 0x59, 0x5A, 0x5B, 0x5C, SLAVE_ID0, 600, 2100,
814                                 tps80031dcdc_ops, 63, 500, 1),
815         TPS80031_REG(SMPS3, 0x65, 0x66, 0x00, 0x68, SLAVE_ID1, 600, 2100,
816                                 tps80031dcdc_ops, 63, 500, 2),
817         TPS80031_REG(SMPS4, 0x41, 0x42, 0x00, 0x44, SLAVE_ID1, 600, 2100,
818                                 tps80031dcdc_ops, 63, 500, 3),
819
820         TPS80031_REG(LDO1,   0x9D, 0x9E, 0x00, 0x9F, SLAVE_ID1, 1000, 3300,
821                                 tps80031ldo_ops, 25, 500, 8),
822         TPS80031_REG(LDO2,   0x85, 0x86, 0x00, 0x87, SLAVE_ID1, 1000, 3300,
823                                 tps80031ldo_ops, 25, 500, 9),
824         TPS80031_REG(LDO3,   0x8D, 0x8E, 0x00, 0x8F, SLAVE_ID1, 1000, 3300,
825                                 tps80031ldo_ops, 25, 500, 10),
826         TPS80031_REG(LDO4,   0x89, 0x8A, 0x00, 0x8B, SLAVE_ID1, 1000, 3300,
827                                 tps80031ldo_ops, 25, 500, 11),
828         TPS80031_REG(LDO5,   0x99, 0x9A, 0x00, 0x9B, SLAVE_ID1, 1000, 3300,
829                                 tps80031ldo_ops, 25, 500, 12),
830         TPS80031_REG(LDO6,   0x91, 0x92, 0x00, 0x93, SLAVE_ID1, 1000, 3300,
831                                 tps80031ldo_ops, 25, 500, 13),
832         TPS80031_REG(LDO7,   0xA5, 0xA6, 0x00, 0xA7, SLAVE_ID1, 1000, 3300,
833                                 tps80031ldo_ops, 25, 500, 14),
834         TPS80031_REG(LDOUSB, 0xA1, 0xA2, 0x00, 0xA3, SLAVE_ID1, 1000, 3300,
835                                 tps80031ldo_ops, 25, 500, 5),
836         TPS80031_REG(LDOLN,  0x95, 0x96, 0x00, 0x97, SLAVE_ID1, 1000, 3300,
837                                 tps80031ldo_ops, 25, 500, 15),
838         TPS80031_REG(VANA,   0x81, 0x82, 0x00, 0x83, SLAVE_ID1, 1000, 3300,
839                                 tps80031ldo_ops, 25, 500, -1),
840         TPS80031_REG(VBUS,   0x0,  0x0,  0x00, 0x0,  SLAVE_ID1, 0,    5000,
841                                 tps80031vbus_ops, 2, 200000, -1),
842         TPS80031_REG(REGEN1, 0xAE,  0xAF,  0x00, 0x0,  SLAVE_ID1, 0,    3300,
843                                 tps80031_ext_reg_ops, 2, 500, 16),
844         TPS80031_REG(REGEN2, 0xB1,  0xB2,  0x00, 0x0,  SLAVE_ID1, 0,    3300,
845                                 tps80031_ext_reg_ops, 2, 500, 17),
846         TPS80031_REG(SYSEN,  0xB4,  0xB5,  0x00, 0x0,  SLAVE_ID1, 0,    3300,
847                                 tps80031_ext_reg_ops, 2, 500, 18),
848 };
849
850 static int tps80031_power_req_config(struct device *parent,
851                 struct tps80031_regulator *ri,
852                 struct tps80031_regulator_platform_data *tps80031_pdata)
853 {
854         int ret = 0;
855         uint8_t reg_val;
856
857         if (ri->rinfo->preq_bit < 0)
858                 goto skip_pwr_req_config;
859
860         ret = tps80031_ext_power_req_config(parent, ri->ext_ctrl_flag,
861                         ri->rinfo->preq_bit, ri->rinfo->state_reg,
862                         ri->rinfo->trans_reg);
863         if (!ret)
864                 ret = tps80031_read(parent, SLAVE_ID1, ri->rinfo->trans_reg,
865                         &ri->trans_reg_cache);
866
867         if (!ret && ri->rinfo->state_reg)
868                 ret = tps80031_read(parent, SLAVE_ID1, ri->rinfo->state_reg,
869                         &ri->state_reg_cache);
870         if (ret < 0) {
871                 dev_err(ri->dev, "%s() fails\n", __func__);
872                 return ret;
873         }
874
875 skip_pwr_req_config:
876         if (tps80031_pdata->ext_ctrl_flag &
877                         (PWR_OFF_ON_SLEEP | PWR_ON_ON_SLEEP)) {
878                 reg_val = (ri->trans_reg_cache & ~0xC);
879                 if (tps80031_pdata->ext_ctrl_flag & PWR_ON_ON_SLEEP)
880                         reg_val |= 0x4;
881
882                 ret = tps80031_write(parent, SLAVE_ID1, ri->rinfo->trans_reg,
883                         reg_val);
884                 if (ret < 0)
885                         dev_err(ri->dev, "Not able to write reg 0x%02x\n",
886                                 ri->rinfo->trans_reg);
887                 else
888                         ri->trans_reg_cache = reg_val;
889         }
890         return ret;
891 }
892
893 static int tps80031_regulator_preinit(struct device *parent,
894                 struct tps80031_regulator *ri,
895                 struct tps80031_regulator_platform_data *tps80031_pdata)
896 {
897         int ret = 0;
898         uint8_t reg_val;
899
900         if (ri->rinfo->desc.id == TPS80031_REGULATOR_LDOUSB) {
901                 if (ri->platform_flags & USBLDO_INPUT_VSYS)
902                         ret = tps80031_update(parent, SLAVE_ID1,
903                                 TPS80031_MISC2_ADD,
904                                 MISC2_LDOUSB_IN_VSYS, MISC2_LDOUSB_IN_MASK);
905                 if (ri->platform_flags & USBLDO_INPUT_PMID)
906                         ret = tps80031_update(parent, SLAVE_ID1,
907                                 TPS80031_MISC2_ADD,
908                                 MISC2_LDOUSB_IN_PMID, MISC2_LDOUSB_IN_MASK);
909                 if (ret < 0) {
910                         dev_err(ri->dev, "Not able to configure the rail "
911                                 "LDOUSB as per platform data error %d\n", ret);
912                         return ret;
913                 }
914         }
915
916         if (ri->rinfo->desc.id == TPS80031_REGULATOR_LDO3) {
917                 if (ri->platform_flags & LDO3_OUTPUT_VIB)
918                         ret = tps80031_update(parent, SLAVE_ID1,
919                                 TPS80031_MISC2_ADD,
920                                 MISC2_LDO3_SEL_VIB_VAL,
921                                 MISC2_LDO3_SEL_VIB_MASK);
922                 if (ret < 0) {
923                         dev_err(ri->dev, "Not able to configure the rail "
924                                 "LDO3 as per platform data error %d\n", ret);
925                         return ret;
926                 }
927         }
928
929         switch (ri->rinfo->desc.id) {
930         case TPS80031_REGULATOR_REGEN1:
931         case TPS80031_REGULATOR_REGEN2:
932         case TPS80031_REGULATOR_SYSEN:
933                 if (tps80031_pdata->reg_init_data->constraints.always_on ||
934                         tps80031_pdata->reg_init_data->constraints.boot_on)
935                         ret = tps80031_update(parent, SLAVE_ID1,
936                                 ri->rinfo->state_reg, STATE_ON, STATE_MASK);
937                 else
938                         ret = tps80031_update(parent, SLAVE_ID1,
939                                 ri->rinfo->state_reg, STATE_OFF, STATE_MASK);
940                 if (ret < 0) {
941                         dev_err(ri->dev,
942                                 "state reg update failed, e %d\n", ret);
943                         return ret;
944                 }
945                 ret = tps80031_update(parent, SLAVE_ID1,
946                                         ri->rinfo->trans_reg, 1, 0x3);
947                 if (ret < 0) {
948                         dev_err(ri->dev,
949                                 "trans reg update failed, e %d\n", ret);
950                         return ret;
951                 }
952                 break;
953         default:
954                 break;
955         }
956
957         if (!tps80031_pdata->init_apply)
958                 return 0;
959
960         if (tps80031_pdata->init_uV >= 0) {
961                 switch (ri->rinfo->desc.id) {
962                 case TPS80031_REGULATOR_VIO:
963                 case TPS80031_REGULATOR_SMPS1:
964                 case TPS80031_REGULATOR_SMPS2:
965                 case TPS80031_REGULATOR_SMPS3:
966                 case TPS80031_REGULATOR_SMPS4:
967                         ret = __tps80031_dcdc_set_voltage(parent, ri,
968                                         tps80031_pdata->init_uV,
969                                         tps80031_pdata->init_uV, 0);
970                         break;
971
972                 case TPS80031_REGULATOR_LDO1:
973                 case TPS80031_REGULATOR_LDO2:
974                 case TPS80031_REGULATOR_LDO3:
975                 case TPS80031_REGULATOR_LDO4:
976                 case TPS80031_REGULATOR_LDO5:
977                 case TPS80031_REGULATOR_LDO6:
978                 case TPS80031_REGULATOR_LDO7:
979                 case TPS80031_REGULATOR_LDOUSB:
980                 case TPS80031_REGULATOR_LDOLN:
981                 case TPS80031_REGULATOR_VANA:
982                         ret = __tps80031_ldo_set_voltage(parent, ri,
983                                         tps80031_pdata->init_uV,
984                                         tps80031_pdata->init_uV, 0);
985                         break;
986                 default:
987                         ret = -EINVAL;
988                         break;
989                 }
990
991                 if (ret < 0) {
992                         dev_err(ri->dev, "Not able to initialize voltage %d "
993                                 "for rail %d err %d\n", tps80031_pdata->init_uV,
994                                 ri->rinfo->desc.id, ret);
995                         return ret;
996                 }
997         }
998
999         if (tps80031_pdata->init_enable)
1000                 reg_val = (ri->state_reg_cache & ~STATE_MASK) |
1001                                 (STATE_ON & STATE_MASK);
1002         else
1003                 reg_val = (ri->state_reg_cache & ~STATE_MASK) |
1004                                 (STATE_OFF & STATE_MASK);
1005
1006         ret = tps80031_write(parent, SLAVE_ID1, ri->rinfo->state_reg, reg_val);
1007         if (ret < 0)
1008                 dev_err(ri->dev, "Not able to %s rail %d err %d\n",
1009                         (tps80031_pdata->init_enable) ? "enable" : "disable",
1010                         ri->rinfo->desc.id, ret);
1011         else
1012                 ri->state_reg_cache = reg_val;
1013         return ret;
1014 }
1015
1016 static inline struct tps80031_regulator_info *find_regulator_info(int id)
1017 {
1018         struct tps80031_regulator_info *rinfo;
1019         int i;
1020
1021         for (i = 0; i < ARRAY_SIZE(tps80031_regulator_info); i++) {
1022                 rinfo = &tps80031_regulator_info[i];
1023                 if (rinfo->desc.id == id)
1024                         return rinfo;
1025         }
1026         return NULL;
1027 }
1028 static void check_smps_mode_mult(struct device *parent,
1029         struct tps80031_regulator *ri)
1030 {
1031         int mult_offset;
1032         switch (ri->rinfo->desc.id) {
1033         case TPS80031_REGULATOR_VIO:
1034                 mult_offset = SMPS_MULTOFFSET_VIO;
1035                 break;
1036         case TPS80031_REGULATOR_SMPS1:
1037                 mult_offset = SMPS_MULTOFFSET_SMPS1;
1038                 break;
1039         case TPS80031_REGULATOR_SMPS2:
1040                 mult_offset = SMPS_MULTOFFSET_SMPS2;
1041                 break;
1042         case TPS80031_REGULATOR_SMPS3:
1043                 mult_offset = SMPS_MULTOFFSET_SMPS3;
1044                 break;
1045         case TPS80031_REGULATOR_SMPS4:
1046                 mult_offset = SMPS_MULTOFFSET_SMPS4;
1047                 break;
1048         case TPS80031_REGULATOR_LDO2:
1049                 ri->flags = (tps80031_get_smps_mult(parent) & (1 << 5)) ?
1050                                                 TRACK_MODE_ENABLE : 0;
1051                 /* TRACK mode the ldo2 varies from 600mV to 1300mV */
1052                 if (ri->flags & TRACK_MODE_ENABLE) {
1053                         ri->rinfo->min_mV = 600;
1054                         ri->rinfo->max_mV = 1300;
1055                         ri->rinfo->desc.n_voltages = 57;
1056                 }
1057                 return;
1058         default:
1059                 return;
1060         }
1061
1062         ri->flags = (tps80031_get_smps_offset(parent) & mult_offset) ?
1063                                                 DCDC_OFFSET_EN : 0;
1064         ri->flags |= (tps80031_get_smps_mult(parent) & mult_offset) ?
1065                                                 DCDC_EXTENDED_EN : 0;
1066         return;
1067 }
1068
1069 static inline int tps80031_cache_regulator_register(struct device *parent,
1070         struct tps80031_regulator *ri)
1071 {
1072         int ret;
1073
1074         ret = tps80031_read(parent, SLAVE_ID1, ri->rinfo->trans_reg,
1075                         &ri->trans_reg_cache);
1076         if (!ret && ri->rinfo->state_reg)
1077                 ret = tps80031_read(parent, SLAVE_ID1, ri->rinfo->state_reg,
1078                         &ri->state_reg_cache);
1079         if (!ret && ri->rinfo->force_reg)
1080                 ret = tps80031_read(parent, ri->rinfo->volt_id,
1081                                 ri->rinfo->force_reg, &ri->force_reg_cache);
1082         if (!ret && ri->rinfo->volt_reg)
1083                 ret = tps80031_read(parent, ri->rinfo->volt_id,
1084                                 ri->rinfo->volt_reg, &ri->volt_reg_cache);
1085         return ret;
1086 }
1087
1088 static int __devinit tps80031_regulator_probe(struct platform_device *pdev)
1089 {
1090         struct tps80031_platform_data *pdata = dev_get_platdata(pdev->dev.parent);
1091         struct tps80031_regulator_platform_data *tps_pdata;
1092         struct tps80031_regulator_info *rinfo;
1093         struct tps80031_regulator *ri;
1094         struct tps80031_regulator *pmic;
1095         struct regulator_dev *rdev;
1096         int id;
1097         int ret;
1098         int num;
1099
1100         if (!pdata || !pdata->num_regulator_pdata) {
1101                 dev_err(&pdev->dev, "Number of regulator is 0\n");
1102                 return -EINVAL;
1103         }
1104
1105         pmic = devm_kzalloc(&pdev->dev,
1106                         pdata->num_regulator_pdata * sizeof(*pmic), GFP_KERNEL);
1107         if (!pmic) {
1108                 dev_err(&pdev->dev, "mem alloc for pmic failed\n");
1109                 return -ENOMEM;
1110         }
1111
1112         for (num = 0; num < pdata->num_regulator_pdata; ++num) {
1113                 tps_pdata = pdata->regulator_pdata[num];
1114                 if (!tps_pdata->reg_init_data) {
1115                         dev_err(&pdev->dev,
1116                                 "No regulator init data for index %d\n", num);
1117                         ret = -EINVAL;
1118                         goto fail;
1119                 }
1120
1121                 id = tps_pdata->regulator_id;
1122                 rinfo = find_regulator_info(id);
1123                 if (!rinfo) {
1124                         dev_err(&pdev->dev, "invalid regulator ID specified\n");
1125                         ret = -EINVAL;
1126                         goto fail;
1127                 }
1128
1129                 ri = &pmic[num];
1130                 ri->rinfo = rinfo;
1131                 ri->dev = &pdev->dev;
1132                 if (tps_pdata->delay_us)
1133                         ri->delay = tps_pdata->delay_us;
1134                 else
1135                         ri->delay = rinfo->delay;
1136                 ri->tolerance_uv = tps_pdata->tolerance_uv;
1137
1138                 check_smps_mode_mult(pdev->dev.parent, ri);
1139                 ri->platform_flags = tps_pdata->flags;
1140                 ri->ext_ctrl_flag = tps_pdata->ext_ctrl_flag;
1141
1142                 ret = tps80031_cache_regulator_register(pdev->dev.parent, ri);
1143                 if (ret < 0) {
1144                         dev_err(&pdev->dev,
1145                                 "Register cache failed, err %d\n", ret);
1146                         goto fail;
1147                 }
1148                 ret = tps80031_regulator_preinit(pdev->dev.parent, ri, tps_pdata);
1149                 if (ret < 0) {
1150                         dev_err(&pdev->dev,
1151                                 "regulator preinit failed, err %d\n", ret);
1152                         goto fail;
1153                 }
1154
1155                 ret = tps80031_power_req_config(pdev->dev.parent, ri, tps_pdata);
1156                 if (ret < 0) {
1157                         dev_err(&pdev->dev,
1158                                 "power req config failed, err %d\n", ret);
1159                         goto fail;
1160                 }
1161
1162                 rdev = regulator_register(&ri->rinfo->desc, &pdev->dev,
1163                                 tps_pdata->reg_init_data, ri, NULL);
1164                 if (IS_ERR_OR_NULL(rdev)) {
1165                         dev_err(&pdev->dev,
1166                                 "register regulator failed %s\n",
1167                                         ri->rinfo->desc.name);
1168                         ret = PTR_ERR(rdev);
1169                         goto fail;
1170                 }
1171                 ri->rdev = rdev;
1172         }
1173
1174         platform_set_drvdata(pdev, pmic);
1175         return 0;
1176 fail:
1177         while(--num >= 0) {
1178                 ri = &pmic[num];
1179                 regulator_unregister(ri->rdev);
1180         }
1181         return ret;
1182 }
1183
1184 static int __devexit tps80031_regulator_remove(struct platform_device *pdev)
1185 {
1186         struct tps80031_platform_data *pdata = pdev->dev.parent->platform_data;
1187         struct tps80031_regulator *pmic = platform_get_drvdata(pdev);
1188         struct tps80031_regulator *ri = NULL;
1189         int num;
1190
1191         if (!pdata || !pdata->num_regulator_pdata)
1192                 return 0;
1193
1194         for (num = 0; num < pdata->num_regulator_pdata; ++num) {
1195                 ri = &pmic[num];
1196                 regulator_unregister(ri->rdev);
1197         }
1198         return 0;
1199 }
1200
1201 static struct platform_driver tps80031_regulator_driver = {
1202         .driver = {
1203                 .name   = "tps80031-regulators",
1204                 .owner  = THIS_MODULE,
1205         },
1206         .probe          = tps80031_regulator_probe,
1207         .remove         = __devexit_p(tps80031_regulator_remove),
1208 };
1209
1210 static int __init tps80031_regulator_init(void)
1211 {
1212         return platform_driver_register(&tps80031_regulator_driver);
1213 }
1214 subsys_initcall(tps80031_regulator_init);
1215
1216 static void __exit tps80031_regulator_exit(void)
1217 {
1218         platform_driver_unregister(&tps80031_regulator_driver);
1219 }
1220 module_exit(tps80031_regulator_exit);
1221
1222 MODULE_LICENSE("GPL");
1223 MODULE_DESCRIPTION("Regulator Driver for TI TPS80031 PMIC");
1224 MODULE_ALIAS("platform:tps80031-regulator");