include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[linux-2.6.git] / drivers / regulator / tps6507x-regulator.c
1 /*
2  * tps6507x-regulator.c
3  *
4  * Regulator driver for TPS65073 PMIC
5  *
6  * Copyright (C) 2009 Texas Instrument Incorporated - http://www.ti.com/
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation version 2.
11  *
12  * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
13  * whether express or implied; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  */
17
18 #include <linux/kernel.h>
19 #include <linux/module.h>
20 #include <linux/init.h>
21 #include <linux/err.h>
22 #include <linux/platform_device.h>
23 #include <linux/regulator/driver.h>
24 #include <linux/regulator/machine.h>
25 #include <linux/i2c.h>
26 #include <linux/delay.h>
27 #include <linux/slab.h>
28
29 /* Register definitions */
30 #define TPS6507X_REG_PPATH1                             0X01
31 #define TPS6507X_REG_INT                                0X02
32 #define TPS6507X_REG_CHGCONFIG0                         0X03
33 #define TPS6507X_REG_CHGCONFIG1                         0X04
34 #define TPS6507X_REG_CHGCONFIG2                         0X05
35 #define TPS6507X_REG_CHGCONFIG3                         0X06
36 #define TPS6507X_REG_REG_ADCONFIG                       0X07
37 #define TPS6507X_REG_TSCMODE                            0X08
38 #define TPS6507X_REG_ADRESULT_1                         0X09
39 #define TPS6507X_REG_ADRESULT_2                         0X0A
40 #define TPS6507X_REG_PGOOD                              0X0B
41 #define TPS6507X_REG_PGOODMASK                          0X0C
42 #define TPS6507X_REG_CON_CTRL1                          0X0D
43 #define TPS6507X_REG_CON_CTRL2                          0X0E
44 #define TPS6507X_REG_CON_CTRL3                          0X0F
45 #define TPS6507X_REG_DEFDCDC1                           0X10
46 #define TPS6507X_REG_DEFDCDC2_LOW                       0X11
47 #define TPS6507X_REG_DEFDCDC2_HIGH                      0X12
48 #define TPS6507X_REG_DEFDCDC3_LOW                       0X13
49 #define TPS6507X_REG_DEFDCDC3_HIGH                      0X14
50 #define TPS6507X_REG_DEFSLEW                            0X15
51 #define TPS6507X_REG_LDO_CTRL1                          0X16
52 #define TPS6507X_REG_DEFLDO2                            0X17
53 #define TPS6507X_REG_WLED_CTRL1                         0X18
54 #define TPS6507X_REG_WLED_CTRL2                         0X19
55
56 /* CON_CTRL1 bitfields */
57 #define TPS6507X_CON_CTRL1_DCDC1_ENABLE         BIT(4)
58 #define TPS6507X_CON_CTRL1_DCDC2_ENABLE         BIT(3)
59 #define TPS6507X_CON_CTRL1_DCDC3_ENABLE         BIT(2)
60 #define TPS6507X_CON_CTRL1_LDO1_ENABLE          BIT(1)
61 #define TPS6507X_CON_CTRL1_LDO2_ENABLE          BIT(0)
62
63 /* DEFDCDC1 bitfields */
64 #define TPS6507X_DEFDCDC1_DCDC1_EXT_ADJ_EN      BIT(7)
65 #define TPS6507X_DEFDCDC1_DCDC1_MASK            0X3F
66
67 /* DEFDCDC2_LOW bitfields */
68 #define TPS6507X_DEFDCDC2_LOW_DCDC2_MASK        0X3F
69
70 /* DEFDCDC2_HIGH bitfields */
71 #define TPS6507X_DEFDCDC2_HIGH_DCDC2_MASK       0X3F
72
73 /* DEFDCDC3_LOW bitfields */
74 #define TPS6507X_DEFDCDC3_LOW_DCDC3_MASK        0X3F
75
76 /* DEFDCDC3_HIGH bitfields */
77 #define TPS6507X_DEFDCDC3_HIGH_DCDC3_MASK       0X3F
78
79 /* TPS6507X_REG_LDO_CTRL1 bitfields */
80 #define TPS6507X_REG_LDO_CTRL1_LDO1_MASK        0X0F
81
82 /* TPS6507X_REG_DEFLDO2 bitfields */
83 #define TPS6507X_REG_DEFLDO2_LDO2_MASK          0X3F
84
85 /* VDCDC MASK */
86 #define TPS6507X_DEFDCDCX_DCDC_MASK             0X3F
87
88 /* DCDC's */
89 #define TPS6507X_DCDC_1                         0
90 #define TPS6507X_DCDC_2                         1
91 #define TPS6507X_DCDC_3                         2
92 /* LDOs */
93 #define TPS6507X_LDO_1                          3
94 #define TPS6507X_LDO_2                          4
95
96 #define TPS6507X_MAX_REG_ID                     TPS6507X_LDO_2
97
98 /* Number of step-down converters available */
99 #define TPS6507X_NUM_DCDC                       3
100 /* Number of LDO voltage regulators  available */
101 #define TPS6507X_NUM_LDO                        2
102 /* Number of total regulators available */
103 #define TPS6507X_NUM_REGULATOR          (TPS6507X_NUM_DCDC + TPS6507X_NUM_LDO)
104
105 /* Supported voltage values for regulators (in milliVolts) */
106 static const u16 VDCDCx_VSEL_table[] = {
107         725, 750, 775, 800,
108         825, 850, 875, 900,
109         925, 950, 975, 1000,
110         1025, 1050, 1075, 1100,
111         1125, 1150, 1175, 1200,
112         1225, 1250, 1275, 1300,
113         1325, 1350, 1375, 1400,
114         1425, 1450, 1475, 1500,
115         1550, 1600, 1650, 1700,
116         1750, 1800, 1850, 1900,
117         1950, 2000, 2050, 2100,
118         2150, 2200, 2250, 2300,
119         2350, 2400, 2450, 2500,
120         2550, 2600, 2650, 2700,
121         2750, 2800, 2850, 2900,
122         3000, 3100, 3200, 3300,
123 };
124
125 static const u16 LDO1_VSEL_table[] = {
126         1000, 1100, 1200, 1250,
127         1300, 1350, 1400, 1500,
128         1600, 1800, 2500, 2750,
129         2800, 3000, 3100, 3300,
130 };
131
132 static const u16 LDO2_VSEL_table[] = {
133         725, 750, 775, 800,
134         825, 850, 875, 900,
135         925, 950, 975, 1000,
136         1025, 1050, 1075, 1100,
137         1125, 1150, 1175, 1200,
138         1225, 1250, 1275, 1300,
139         1325, 1350, 1375, 1400,
140         1425, 1450, 1475, 1500,
141         1550, 1600, 1650, 1700,
142         1750, 1800, 1850, 1900,
143         1950, 2000, 2050, 2100,
144         2150, 2200, 2250, 2300,
145         2350, 2400, 2450, 2500,
146         2550, 2600, 2650, 2700,
147         2750, 2800, 2850, 2900,
148         3000, 3100, 3200, 3300,
149 };
150
151 static unsigned int num_voltages[] = {ARRAY_SIZE(VDCDCx_VSEL_table),
152                                 ARRAY_SIZE(VDCDCx_VSEL_table),
153                                 ARRAY_SIZE(VDCDCx_VSEL_table),
154                                 ARRAY_SIZE(LDO1_VSEL_table),
155                                 ARRAY_SIZE(LDO2_VSEL_table)};
156
157 struct tps_info {
158         const char *name;
159         unsigned min_uV;
160         unsigned max_uV;
161         u8 table_len;
162         const u16 *table;
163 };
164
165 struct tps_pmic {
166         struct regulator_desc desc[TPS6507X_NUM_REGULATOR];
167         struct i2c_client *client;
168         struct regulator_dev *rdev[TPS6507X_NUM_REGULATOR];
169         const struct tps_info *info[TPS6507X_NUM_REGULATOR];
170         struct mutex io_lock;
171 };
172
173 static inline int tps_6507x_read(struct tps_pmic *tps, u8 reg)
174 {
175         return i2c_smbus_read_byte_data(tps->client, reg);
176 }
177
178 static inline int tps_6507x_write(struct tps_pmic *tps, u8 reg, u8 val)
179 {
180         return i2c_smbus_write_byte_data(tps->client, reg, val);
181 }
182
183 static int tps_6507x_set_bits(struct tps_pmic *tps, u8 reg, u8 mask)
184 {
185         int err, data;
186
187         mutex_lock(&tps->io_lock);
188
189         data = tps_6507x_read(tps, reg);
190         if (data < 0) {
191                 dev_err(&tps->client->dev, "Read from reg 0x%x failed\n", reg);
192                 err = data;
193                 goto out;
194         }
195
196         data |= mask;
197         err = tps_6507x_write(tps, reg, data);
198         if (err)
199                 dev_err(&tps->client->dev, "Write for reg 0x%x failed\n", reg);
200
201 out:
202         mutex_unlock(&tps->io_lock);
203         return err;
204 }
205
206 static int tps_6507x_clear_bits(struct tps_pmic *tps, u8 reg, u8 mask)
207 {
208         int err, data;
209
210         mutex_lock(&tps->io_lock);
211
212         data = tps_6507x_read(tps, reg);
213         if (data < 0) {
214                 dev_err(&tps->client->dev, "Read from reg 0x%x failed\n", reg);
215                 err = data;
216                 goto out;
217         }
218
219         data &= ~mask;
220         err = tps_6507x_write(tps, reg, data);
221         if (err)
222                 dev_err(&tps->client->dev, "Write for reg 0x%x failed\n", reg);
223
224 out:
225         mutex_unlock(&tps->io_lock);
226         return err;
227 }
228
229 static int tps_6507x_reg_read(struct tps_pmic *tps, u8 reg)
230 {
231         int data;
232
233         mutex_lock(&tps->io_lock);
234
235         data = tps_6507x_read(tps, reg);
236         if (data < 0)
237                 dev_err(&tps->client->dev, "Read from reg 0x%x failed\n", reg);
238
239         mutex_unlock(&tps->io_lock);
240         return data;
241 }
242
243 static int tps_6507x_reg_write(struct tps_pmic *tps, u8 reg, u8 val)
244 {
245         int err;
246
247         mutex_lock(&tps->io_lock);
248
249         err = tps_6507x_write(tps, reg, val);
250         if (err < 0)
251                 dev_err(&tps->client->dev, "Write for reg 0x%x failed\n", reg);
252
253         mutex_unlock(&tps->io_lock);
254         return err;
255 }
256
257 static int tps6507x_dcdc_is_enabled(struct regulator_dev *dev)
258 {
259         struct tps_pmic *tps = rdev_get_drvdata(dev);
260         int data, dcdc = rdev_get_id(dev);
261         u8 shift;
262
263         if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3)
264                 return -EINVAL;
265
266         shift = TPS6507X_MAX_REG_ID - dcdc;
267         data = tps_6507x_reg_read(tps, TPS6507X_REG_CON_CTRL1);
268
269         if (data < 0)
270                 return data;
271         else
272                 return (data & 1<<shift) ? 1 : 0;
273 }
274
275 static int tps6507x_ldo_is_enabled(struct regulator_dev *dev)
276 {
277         struct tps_pmic *tps = rdev_get_drvdata(dev);
278         int data, ldo = rdev_get_id(dev);
279         u8 shift;
280
281         if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2)
282                 return -EINVAL;
283
284         shift = TPS6507X_MAX_REG_ID - ldo;
285         data = tps_6507x_reg_read(tps, TPS6507X_REG_CON_CTRL1);
286
287         if (data < 0)
288                 return data;
289         else
290                 return (data & 1<<shift) ? 1 : 0;
291 }
292
293 static int tps6507x_dcdc_enable(struct regulator_dev *dev)
294 {
295         struct tps_pmic *tps = rdev_get_drvdata(dev);
296         int dcdc = rdev_get_id(dev);
297         u8 shift;
298
299         if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3)
300                 return -EINVAL;
301
302         shift = TPS6507X_MAX_REG_ID - dcdc;
303         return tps_6507x_set_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift);
304 }
305
306 static int tps6507x_dcdc_disable(struct regulator_dev *dev)
307 {
308         struct tps_pmic *tps = rdev_get_drvdata(dev);
309         int dcdc = rdev_get_id(dev);
310         u8 shift;
311
312         if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3)
313                 return -EINVAL;
314
315         shift = TPS6507X_MAX_REG_ID - dcdc;
316         return tps_6507x_clear_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift);
317 }
318
319 static int tps6507x_ldo_enable(struct regulator_dev *dev)
320 {
321         struct tps_pmic *tps = rdev_get_drvdata(dev);
322         int ldo = rdev_get_id(dev);
323         u8 shift;
324
325         if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2)
326                 return -EINVAL;
327
328         shift = TPS6507X_MAX_REG_ID - ldo;
329         return tps_6507x_set_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift);
330 }
331
332 static int tps6507x_ldo_disable(struct regulator_dev *dev)
333 {
334         struct tps_pmic *tps = rdev_get_drvdata(dev);
335         int ldo = rdev_get_id(dev);
336         u8 shift;
337
338         if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2)
339                 return -EINVAL;
340
341         shift = TPS6507X_MAX_REG_ID - ldo;
342         return tps_6507x_clear_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift);
343 }
344
345 static int tps6507x_dcdc_get_voltage(struct regulator_dev *dev)
346 {
347         struct tps_pmic *tps = rdev_get_drvdata(dev);
348         int data, dcdc = rdev_get_id(dev);
349         u8 reg;
350
351         switch (dcdc) {
352         case TPS6507X_DCDC_1:
353                 reg = TPS6507X_REG_DEFDCDC1;
354                 break;
355         case TPS6507X_DCDC_2:
356                 reg = TPS6507X_REG_DEFDCDC2_LOW;
357                 break;
358         case TPS6507X_DCDC_3:
359                 reg = TPS6507X_REG_DEFDCDC3_LOW;
360                 break;
361         default:
362                 return -EINVAL;
363         }
364
365         data = tps_6507x_reg_read(tps, reg);
366         if (data < 0)
367                 return data;
368
369         data &= TPS6507X_DEFDCDCX_DCDC_MASK;
370         return tps->info[dcdc]->table[data] * 1000;
371 }
372
373 static int tps6507x_dcdc_set_voltage(struct regulator_dev *dev,
374                                 int min_uV, int max_uV)
375 {
376         struct tps_pmic *tps = rdev_get_drvdata(dev);
377         int data, vsel, dcdc = rdev_get_id(dev);
378         u8 reg;
379
380         switch (dcdc) {
381         case TPS6507X_DCDC_1:
382                 reg = TPS6507X_REG_DEFDCDC1;
383                 break;
384         case TPS6507X_DCDC_2:
385                 reg = TPS6507X_REG_DEFDCDC2_LOW;
386                 break;
387         case TPS6507X_DCDC_3:
388                 reg = TPS6507X_REG_DEFDCDC3_LOW;
389                 break;
390         default:
391                 return -EINVAL;
392         }
393
394         if (min_uV < tps->info[dcdc]->min_uV
395                 || min_uV > tps->info[dcdc]->max_uV)
396                 return -EINVAL;
397         if (max_uV < tps->info[dcdc]->min_uV
398                 || max_uV > tps->info[dcdc]->max_uV)
399                 return -EINVAL;
400
401         for (vsel = 0; vsel < tps->info[dcdc]->table_len; vsel++) {
402                 int mV = tps->info[dcdc]->table[vsel];
403                 int uV = mV * 1000;
404
405                 /* Break at the first in-range value */
406                 if (min_uV <= uV && uV <= max_uV)
407                         break;
408         }
409
410         /* write to the register in case we found a match */
411         if (vsel == tps->info[dcdc]->table_len)
412                 return -EINVAL;
413
414         data = tps_6507x_reg_read(tps, reg);
415         if (data < 0)
416                 return data;
417
418         data &= ~TPS6507X_DEFDCDCX_DCDC_MASK;
419         data |= vsel;
420
421         return tps_6507x_reg_write(tps, reg, data);
422 }
423
424 static int tps6507x_ldo_get_voltage(struct regulator_dev *dev)
425 {
426         struct tps_pmic *tps = rdev_get_drvdata(dev);
427         int data, ldo = rdev_get_id(dev);
428         u8 reg, mask;
429
430         if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2)
431                 return -EINVAL;
432         else {
433                 reg = (ldo == TPS6507X_LDO_1 ?
434                         TPS6507X_REG_LDO_CTRL1 : TPS6507X_REG_DEFLDO2);
435                 mask = (ldo == TPS6507X_LDO_1 ?
436                         TPS6507X_REG_LDO_CTRL1_LDO1_MASK :
437                                 TPS6507X_REG_DEFLDO2_LDO2_MASK);
438         }
439
440         data = tps_6507x_reg_read(tps, reg);
441         if (data < 0)
442                 return data;
443
444         data &= mask;
445         return tps->info[ldo]->table[data] * 1000;
446 }
447
448 static int tps6507x_ldo_set_voltage(struct regulator_dev *dev,
449                                 int min_uV, int max_uV)
450 {
451         struct tps_pmic *tps = rdev_get_drvdata(dev);
452         int data, vsel, ldo = rdev_get_id(dev);
453         u8 reg, mask;
454
455         if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2)
456                 return -EINVAL;
457         else {
458                 reg = (ldo == TPS6507X_LDO_1 ?
459                         TPS6507X_REG_LDO_CTRL1 : TPS6507X_REG_DEFLDO2);
460                 mask = (ldo == TPS6507X_LDO_1 ?
461                         TPS6507X_REG_LDO_CTRL1_LDO1_MASK :
462                                 TPS6507X_REG_DEFLDO2_LDO2_MASK);
463         }
464
465         if (min_uV < tps->info[ldo]->min_uV || min_uV > tps->info[ldo]->max_uV)
466                 return -EINVAL;
467         if (max_uV < tps->info[ldo]->min_uV || max_uV > tps->info[ldo]->max_uV)
468                 return -EINVAL;
469
470         for (vsel = 0; vsel < tps->info[ldo]->table_len; vsel++) {
471                 int mV = tps->info[ldo]->table[vsel];
472                 int uV = mV * 1000;
473
474                 /* Break at the first in-range value */
475                 if (min_uV <= uV && uV <= max_uV)
476                         break;
477         }
478
479         if (vsel == tps->info[ldo]->table_len)
480                 return -EINVAL;
481
482         data = tps_6507x_reg_read(tps, reg);
483         if (data < 0)
484                 return data;
485
486         data &= ~mask;
487         data |= vsel;
488
489         return tps_6507x_reg_write(tps, reg, data);
490 }
491
492 static int tps6507x_dcdc_list_voltage(struct regulator_dev *dev,
493                                         unsigned selector)
494 {
495         struct tps_pmic *tps = rdev_get_drvdata(dev);
496         int dcdc = rdev_get_id(dev);
497
498         if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3)
499                 return -EINVAL;
500
501         if (selector >= tps->info[dcdc]->table_len)
502                 return -EINVAL;
503         else
504                 return tps->info[dcdc]->table[selector] * 1000;
505 }
506
507 static int tps6507x_ldo_list_voltage(struct regulator_dev *dev,
508                                         unsigned selector)
509 {
510         struct tps_pmic *tps = rdev_get_drvdata(dev);
511         int ldo = rdev_get_id(dev);
512
513         if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2)
514                 return -EINVAL;
515
516         if (selector >= tps->info[ldo]->table_len)
517                 return -EINVAL;
518         else
519                 return tps->info[ldo]->table[selector] * 1000;
520 }
521
522 /* Operations permitted on VDCDCx */
523 static struct regulator_ops tps6507x_dcdc_ops = {
524         .is_enabled = tps6507x_dcdc_is_enabled,
525         .enable = tps6507x_dcdc_enable,
526         .disable = tps6507x_dcdc_disable,
527         .get_voltage = tps6507x_dcdc_get_voltage,
528         .set_voltage = tps6507x_dcdc_set_voltage,
529         .list_voltage = tps6507x_dcdc_list_voltage,
530 };
531
532 /* Operations permitted on LDOx */
533 static struct regulator_ops tps6507x_ldo_ops = {
534         .is_enabled = tps6507x_ldo_is_enabled,
535         .enable = tps6507x_ldo_enable,
536         .disable = tps6507x_ldo_disable,
537         .get_voltage = tps6507x_ldo_get_voltage,
538         .set_voltage = tps6507x_ldo_set_voltage,
539         .list_voltage = tps6507x_ldo_list_voltage,
540 };
541
542 static int __devinit tps_6507x_probe(struct i2c_client *client,
543                                      const struct i2c_device_id *id)
544 {
545         static int desc_id;
546         const struct tps_info *info = (void *)id->driver_data;
547         struct regulator_init_data *init_data;
548         struct regulator_dev *rdev;
549         struct tps_pmic *tps;
550         int i;
551         int error;
552
553         if (!i2c_check_functionality(client->adapter,
554                                 I2C_FUNC_SMBUS_BYTE_DATA))
555                 return -EIO;
556
557         /**
558          * init_data points to array of regulator_init structures
559          * coming from the board-evm file.
560          */
561         init_data = client->dev.platform_data;
562         if (!init_data)
563                 return -EIO;
564
565         tps = kzalloc(sizeof(*tps), GFP_KERNEL);
566         if (!tps)
567                 return -ENOMEM;
568
569         mutex_init(&tps->io_lock);
570
571         /* common for all regulators */
572         tps->client = client;
573
574         for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) {
575                 /* Register the regulators */
576                 tps->info[i] = info;
577                 tps->desc[i].name = info->name;
578                 tps->desc[i].id = desc_id++;
579                 tps->desc[i].n_voltages = num_voltages[i];
580                 tps->desc[i].ops = (i > TPS6507X_DCDC_3 ?
581                                 &tps6507x_ldo_ops : &tps6507x_dcdc_ops);
582                 tps->desc[i].type = REGULATOR_VOLTAGE;
583                 tps->desc[i].owner = THIS_MODULE;
584
585                 rdev = regulator_register(&tps->desc[i],
586                                         &client->dev, init_data, tps);
587                 if (IS_ERR(rdev)) {
588                         dev_err(&client->dev, "failed to register %s\n",
589                                 id->name);
590                         error = PTR_ERR(rdev);
591                         goto fail;
592                 }
593
594                 /* Save regulator for cleanup */
595                 tps->rdev[i] = rdev;
596         }
597
598         i2c_set_clientdata(client, tps);
599
600         return 0;
601
602 fail:
603         while (--i >= 0)
604                 regulator_unregister(tps->rdev[i]);
605
606         kfree(tps);
607         return error;
608 }
609
610 /**
611  * tps_6507x_remove - TPS6507x driver i2c remove handler
612  * @client: i2c driver client device structure
613  *
614  * Unregister TPS driver as an i2c client device driver
615  */
616 static int __devexit tps_6507x_remove(struct i2c_client *client)
617 {
618         struct tps_pmic *tps = i2c_get_clientdata(client);
619         int i;
620
621         /* clear the client data in i2c */
622         i2c_set_clientdata(client, NULL);
623
624         for (i = 0; i < TPS6507X_NUM_REGULATOR; i++)
625                 regulator_unregister(tps->rdev[i]);
626
627         kfree(tps);
628
629         return 0;
630 }
631
632 static const struct tps_info tps6507x_regs[] = {
633         {
634                 .name = "VDCDC1",
635                 .min_uV = 725000,
636                 .max_uV = 3300000,
637                 .table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
638                 .table = VDCDCx_VSEL_table,
639         },
640         {
641                 .name = "VDCDC2",
642                 .min_uV = 725000,
643                 .max_uV = 3300000,
644                 .table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
645                 .table = VDCDCx_VSEL_table,
646         },
647         {
648                 .name = "VDCDC3",
649                 .min_uV = 725000,
650                 .max_uV = 3300000,
651                 .table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
652                 .table = VDCDCx_VSEL_table,
653         },
654         {
655                 .name = "LDO1",
656                 .min_uV = 1000000,
657                 .max_uV = 3300000,
658                 .table_len = ARRAY_SIZE(LDO1_VSEL_table),
659                 .table = LDO1_VSEL_table,
660         },
661         {
662                 .name = "LDO2",
663                 .min_uV = 725000,
664                 .max_uV = 3300000,
665                 .table_len = ARRAY_SIZE(LDO2_VSEL_table),
666                 .table = LDO2_VSEL_table,
667         },
668 };
669
670 static const struct i2c_device_id tps_6507x_id[] = {
671         {.name = "tps6507x",
672         .driver_data = (unsigned long) tps6507x_regs,},
673         { },
674 };
675 MODULE_DEVICE_TABLE(i2c, tps_6507x_id);
676
677 static struct i2c_driver tps_6507x_i2c_driver = {
678         .driver = {
679                 .name = "tps6507x",
680                 .owner = THIS_MODULE,
681         },
682         .probe = tps_6507x_probe,
683         .remove = __devexit_p(tps_6507x_remove),
684         .id_table = tps_6507x_id,
685 };
686
687 /**
688  * tps_6507x_init
689  *
690  * Module init function
691  */
692 static int __init tps_6507x_init(void)
693 {
694         return i2c_add_driver(&tps_6507x_i2c_driver);
695 }
696 subsys_initcall(tps_6507x_init);
697
698 /**
699  * tps_6507x_cleanup
700  *
701  * Module exit function
702  */
703 static void __exit tps_6507x_cleanup(void)
704 {
705         i2c_del_driver(&tps_6507x_i2c_driver);
706 }
707 module_exit(tps_6507x_cleanup);
708
709 MODULE_AUTHOR("Texas Instruments");
710 MODULE_DESCRIPTION("TPS6507x voltage regulator driver");
711 MODULE_LICENSE("GPL v2");