blob: b912daae9fa0a0863d572b3449d4a41fee3906b3 [file] [log] [blame]
Anuj Aggarwal30e65992009-08-21 00:39:31 +05301/*
2 * tps65023-regulator.c
3 *
4 * Supports TPS65023 Regulator
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>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090027#include <linux/slab.h>
Mark Brown90923352011-06-18 01:18:51 +010028#include <linux/regmap.h>
Anuj Aggarwal30e65992009-08-21 00:39:31 +053029
30/* Register definitions */
31#define TPS65023_REG_VERSION 0
32#define TPS65023_REG_PGOODZ 1
33#define TPS65023_REG_MASK 2
34#define TPS65023_REG_REG_CTRL 3
35#define TPS65023_REG_CON_CTRL 4
36#define TPS65023_REG_CON_CTRL2 5
37#define TPS65023_REG_DEF_CORE 6
38#define TPS65023_REG_DEFSLEW 7
39#define TPS65023_REG_LDO_CTRL 8
40
41/* PGOODZ bitfields */
42#define TPS65023_PGOODZ_PWRFAILZ BIT(7)
43#define TPS65023_PGOODZ_LOWBATTZ BIT(6)
44#define TPS65023_PGOODZ_VDCDC1 BIT(5)
45#define TPS65023_PGOODZ_VDCDC2 BIT(4)
46#define TPS65023_PGOODZ_VDCDC3 BIT(3)
47#define TPS65023_PGOODZ_LDO2 BIT(2)
48#define TPS65023_PGOODZ_LDO1 BIT(1)
49
50/* MASK bitfields */
51#define TPS65023_MASK_PWRFAILZ BIT(7)
52#define TPS65023_MASK_LOWBATTZ BIT(6)
53#define TPS65023_MASK_VDCDC1 BIT(5)
54#define TPS65023_MASK_VDCDC2 BIT(4)
55#define TPS65023_MASK_VDCDC3 BIT(3)
56#define TPS65023_MASK_LDO2 BIT(2)
57#define TPS65023_MASK_LDO1 BIT(1)
58
59/* REG_CTRL bitfields */
60#define TPS65023_REG_CTRL_VDCDC1_EN BIT(5)
61#define TPS65023_REG_CTRL_VDCDC2_EN BIT(4)
62#define TPS65023_REG_CTRL_VDCDC3_EN BIT(3)
63#define TPS65023_REG_CTRL_LDO2_EN BIT(2)
64#define TPS65023_REG_CTRL_LDO1_EN BIT(1)
65
Marcus Folkessonfc999b82011-08-04 13:33:49 +020066/* REG_CTRL2 bitfields */
67#define TPS65023_REG_CTRL2_GO BIT(7)
68#define TPS65023_REG_CTRL2_CORE_ADJ BIT(6)
69#define TPS65023_REG_CTRL2_DCDC2 BIT(2)
70#define TPS65023_REG_CTRL2_DCDC1 BIT(2)
71#define TPS65023_REG_CTRL2_DCDC3 BIT(0)
72
Marcus Folkessonf068ad82011-08-08 20:29:32 +020073/* REG_CTRL2 bitfields */
74#define TPS65023_REG_CTRL2_GO BIT(7)
75#define TPS65023_REG_CTRL2_CORE_ADJ BIT(6)
76#define TPS65023_REG_CTRL2_DCDC2 BIT(2)
77#define TPS65023_REG_CTRL2_DCDC1 BIT(1)
78#define TPS65023_REG_CTRL2_DCDC3 BIT(0)
79
Anuj Aggarwal30e65992009-08-21 00:39:31 +053080/* LDO_CTRL bitfields */
81#define TPS65023_LDO_CTRL_LDOx_SHIFT(ldo_id) ((ldo_id)*4)
82#define TPS65023_LDO_CTRL_LDOx_MASK(ldo_id) (0xF0 >> ((ldo_id)*4))
83
84/* Number of step-down converters available */
85#define TPS65023_NUM_DCDC 3
86/* Number of LDO voltage regulators available */
87#define TPS65023_NUM_LDO 2
88/* Number of total regulators available */
89#define TPS65023_NUM_REGULATOR (TPS65023_NUM_DCDC + TPS65023_NUM_LDO)
90
91/* DCDCs */
92#define TPS65023_DCDC_1 0
93#define TPS65023_DCDC_2 1
94#define TPS65023_DCDC_3 2
95/* LDOs */
96#define TPS65023_LDO_1 3
97#define TPS65023_LDO_2 4
98
99#define TPS65023_MAX_REG_ID TPS65023_LDO_2
100
101/* Supported voltage values for regulators */
102static const u16 VDCDC1_VSEL_table[] = {
103 800, 825, 850, 875,
104 900, 925, 950, 975,
105 1000, 1025, 1050, 1075,
106 1100, 1125, 1150, 1175,
107 1200, 1225, 1250, 1275,
108 1300, 1325, 1350, 1375,
109 1400, 1425, 1450, 1475,
110 1500, 1525, 1550, 1600,
111};
112
113static const u16 LDO1_VSEL_table[] = {
114 1000, 1100, 1300, 1800,
115 2200, 2600, 2800, 3150,
116};
117
118static const u16 LDO2_VSEL_table[] = {
119 1050, 1200, 1300, 1800,
120 2500, 2800, 3000, 3300,
121};
122
123static unsigned int num_voltages[] = {ARRAY_SIZE(VDCDC1_VSEL_table),
124 0, 0, ARRAY_SIZE(LDO1_VSEL_table),
125 ARRAY_SIZE(LDO2_VSEL_table)};
126
127/* Regulator specific details */
128struct tps_info {
129 const char *name;
130 unsigned min_uV;
131 unsigned max_uV;
132 bool fixed;
133 u8 table_len;
134 const u16 *table;
135};
136
137/* PMIC details */
138struct tps_pmic {
139 struct regulator_desc desc[TPS65023_NUM_REGULATOR];
140 struct i2c_client *client;
141 struct regulator_dev *rdev[TPS65023_NUM_REGULATOR];
142 const struct tps_info *info[TPS65023_NUM_REGULATOR];
Mark Brown90923352011-06-18 01:18:51 +0100143 struct regmap *regmap;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530144};
145
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530146static int tps_65023_set_bits(struct tps_pmic *tps, u8 reg, u8 mask)
147{
Mark Brown90923352011-06-18 01:18:51 +0100148 return regmap_update_bits(tps->regmap, reg, mask, mask);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530149}
150
151static int tps_65023_clear_bits(struct tps_pmic *tps, u8 reg, u8 mask)
152{
Mark Brown90923352011-06-18 01:18:51 +0100153 return regmap_update_bits(tps->regmap, reg, mask, 0);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530154}
155
156static int tps_65023_reg_read(struct tps_pmic *tps, u8 reg)
157{
Mark Brown90923352011-06-18 01:18:51 +0100158 unsigned int val;
159 int ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530160
Mark Brown90923352011-06-18 01:18:51 +0100161 ret = regmap_read(tps->regmap, reg, &val);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530162
Mark Brown90923352011-06-18 01:18:51 +0100163 if (ret != 0)
164 return ret;
165 else
166 return val;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530167}
168
169static int tps_65023_reg_write(struct tps_pmic *tps, u8 reg, u8 val)
170{
Mark Brown90923352011-06-18 01:18:51 +0100171 return regmap_write(tps->regmap, reg, val);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530172}
173
174static int tps65023_dcdc_is_enabled(struct regulator_dev *dev)
175{
176 struct tps_pmic *tps = rdev_get_drvdata(dev);
177 int data, dcdc = rdev_get_id(dev);
178 u8 shift;
179
180 if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
181 return -EINVAL;
182
183 shift = TPS65023_NUM_REGULATOR - dcdc;
184 data = tps_65023_reg_read(tps, TPS65023_REG_REG_CTRL);
185
186 if (data < 0)
187 return data;
188 else
189 return (data & 1<<shift) ? 1 : 0;
190}
191
192static int tps65023_ldo_is_enabled(struct regulator_dev *dev)
193{
194 struct tps_pmic *tps = rdev_get_drvdata(dev);
195 int data, ldo = rdev_get_id(dev);
196 u8 shift;
197
198 if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
199 return -EINVAL;
200
201 shift = (ldo == TPS65023_LDO_1 ? 1 : 2);
202 data = tps_65023_reg_read(tps, TPS65023_REG_REG_CTRL);
203
204 if (data < 0)
205 return data;
206 else
207 return (data & 1<<shift) ? 1 : 0;
208}
209
210static int tps65023_dcdc_enable(struct regulator_dev *dev)
211{
212 struct tps_pmic *tps = rdev_get_drvdata(dev);
213 int dcdc = rdev_get_id(dev);
214 u8 shift;
215
216 if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
217 return -EINVAL;
218
219 shift = TPS65023_NUM_REGULATOR - dcdc;
220 return tps_65023_set_bits(tps, TPS65023_REG_REG_CTRL, 1 << shift);
221}
222
223static int tps65023_dcdc_disable(struct regulator_dev *dev)
224{
225 struct tps_pmic *tps = rdev_get_drvdata(dev);
226 int dcdc = rdev_get_id(dev);
227 u8 shift;
228
229 if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
230 return -EINVAL;
231
232 shift = TPS65023_NUM_REGULATOR - dcdc;
233 return tps_65023_clear_bits(tps, TPS65023_REG_REG_CTRL, 1 << shift);
234}
235
236static int tps65023_ldo_enable(struct regulator_dev *dev)
237{
238 struct tps_pmic *tps = rdev_get_drvdata(dev);
239 int ldo = rdev_get_id(dev);
240 u8 shift;
241
242 if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
243 return -EINVAL;
244
245 shift = (ldo == TPS65023_LDO_1 ? 1 : 2);
246 return tps_65023_set_bits(tps, TPS65023_REG_REG_CTRL, 1 << shift);
247}
248
249static int tps65023_ldo_disable(struct regulator_dev *dev)
250{
251 struct tps_pmic *tps = rdev_get_drvdata(dev);
252 int ldo = rdev_get_id(dev);
253 u8 shift;
254
255 if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
256 return -EINVAL;
257
258 shift = (ldo == TPS65023_LDO_1 ? 1 : 2);
259 return tps_65023_clear_bits(tps, TPS65023_REG_REG_CTRL, 1 << shift);
260}
261
262static int tps65023_dcdc_get_voltage(struct regulator_dev *dev)
263{
264 struct tps_pmic *tps = rdev_get_drvdata(dev);
265 int data, dcdc = rdev_get_id(dev);
266
267 if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
268 return -EINVAL;
269
270 if (dcdc == TPS65023_DCDC_1) {
271 data = tps_65023_reg_read(tps, TPS65023_REG_DEF_CORE);
272 if (data < 0)
273 return data;
274 data &= (tps->info[dcdc]->table_len - 1);
275 return tps->info[dcdc]->table[data] * 1000;
276 } else
277 return tps->info[dcdc]->min_uV;
278}
279
280static int tps65023_dcdc_set_voltage(struct regulator_dev *dev,
Mark Brown3a93f2a2010-11-10 14:38:29 +0000281 int min_uV, int max_uV,
282 unsigned *selector)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530283{
284 struct tps_pmic *tps = rdev_get_drvdata(dev);
285 int dcdc = rdev_get_id(dev);
286 int vsel;
287
288 if (dcdc != TPS65023_DCDC_1)
289 return -EINVAL;
290
291 if (min_uV < tps->info[dcdc]->min_uV
292 || min_uV > tps->info[dcdc]->max_uV)
293 return -EINVAL;
294 if (max_uV < tps->info[dcdc]->min_uV
295 || max_uV > tps->info[dcdc]->max_uV)
296 return -EINVAL;
297
298 for (vsel = 0; vsel < tps->info[dcdc]->table_len; vsel++) {
299 int mV = tps->info[dcdc]->table[vsel];
300 int uV = mV * 1000;
301
302 /* Break at the first in-range value */
303 if (min_uV <= uV && uV <= max_uV)
304 break;
305 }
306
Mark Brown3a93f2a2010-11-10 14:38:29 +0000307 *selector = vsel;
308
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530309 /* write to the register in case we found a match */
310 if (vsel == tps->info[dcdc]->table_len)
311 return -EINVAL;
312 else
313 return tps_65023_reg_write(tps, TPS65023_REG_DEF_CORE, vsel);
314}
315
316static int tps65023_ldo_get_voltage(struct regulator_dev *dev)
317{
318 struct tps_pmic *tps = rdev_get_drvdata(dev);
319 int data, ldo = rdev_get_id(dev);
320
321 if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
322 return -EINVAL;
323
324 data = tps_65023_reg_read(tps, TPS65023_REG_LDO_CTRL);
325 if (data < 0)
326 return data;
327
328 data >>= (TPS65023_LDO_CTRL_LDOx_SHIFT(ldo - TPS65023_LDO_1));
329 data &= (tps->info[ldo]->table_len - 1);
330 return tps->info[ldo]->table[data] * 1000;
331}
332
333static int tps65023_ldo_set_voltage(struct regulator_dev *dev,
Mark Brown3a93f2a2010-11-10 14:38:29 +0000334 int min_uV, int max_uV, unsigned *selector)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530335{
336 struct tps_pmic *tps = rdev_get_drvdata(dev);
337 int data, vsel, ldo = rdev_get_id(dev);
338
339 if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
340 return -EINVAL;
341
342 if (min_uV < tps->info[ldo]->min_uV || min_uV > tps->info[ldo]->max_uV)
343 return -EINVAL;
344 if (max_uV < tps->info[ldo]->min_uV || max_uV > tps->info[ldo]->max_uV)
345 return -EINVAL;
346
347 for (vsel = 0; vsel < tps->info[ldo]->table_len; vsel++) {
348 int mV = tps->info[ldo]->table[vsel];
349 int uV = mV * 1000;
350
351 /* Break at the first in-range value */
352 if (min_uV <= uV && uV <= max_uV)
353 break;
354 }
355
356 if (vsel == tps->info[ldo]->table_len)
357 return -EINVAL;
358
Mark Brown3a93f2a2010-11-10 14:38:29 +0000359 *selector = vsel;
360
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530361 data = tps_65023_reg_read(tps, TPS65023_REG_LDO_CTRL);
362 if (data < 0)
363 return data;
364
365 data &= TPS65023_LDO_CTRL_LDOx_MASK(ldo - TPS65023_LDO_1);
366 data |= (vsel << (TPS65023_LDO_CTRL_LDOx_SHIFT(ldo - TPS65023_LDO_1)));
367 return tps_65023_reg_write(tps, TPS65023_REG_LDO_CTRL, data);
368}
369
370static int tps65023_dcdc_list_voltage(struct regulator_dev *dev,
371 unsigned selector)
372{
373 struct tps_pmic *tps = rdev_get_drvdata(dev);
374 int dcdc = rdev_get_id(dev);
375
376 if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
377 return -EINVAL;
378
379 if (dcdc == TPS65023_DCDC_1) {
380 if (selector >= tps->info[dcdc]->table_len)
381 return -EINVAL;
382 else
383 return tps->info[dcdc]->table[selector] * 1000;
384 } else
385 return tps->info[dcdc]->min_uV;
386}
387
388static int tps65023_ldo_list_voltage(struct regulator_dev *dev,
389 unsigned selector)
390{
391 struct tps_pmic *tps = rdev_get_drvdata(dev);
392 int ldo = rdev_get_id(dev);
393
394 if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
395 return -EINVAL;
396
397 if (selector >= tps->info[ldo]->table_len)
398 return -EINVAL;
399 else
400 return tps->info[ldo]->table[selector] * 1000;
401}
402
403/* Operations permitted on VDCDCx */
404static struct regulator_ops tps65023_dcdc_ops = {
405 .is_enabled = tps65023_dcdc_is_enabled,
406 .enable = tps65023_dcdc_enable,
407 .disable = tps65023_dcdc_disable,
408 .get_voltage = tps65023_dcdc_get_voltage,
409 .set_voltage = tps65023_dcdc_set_voltage,
410 .list_voltage = tps65023_dcdc_list_voltage,
411};
412
413/* Operations permitted on LDOx */
414static struct regulator_ops tps65023_ldo_ops = {
415 .is_enabled = tps65023_ldo_is_enabled,
416 .enable = tps65023_ldo_enable,
417 .disable = tps65023_ldo_disable,
418 .get_voltage = tps65023_ldo_get_voltage,
419 .set_voltage = tps65023_ldo_set_voltage,
420 .list_voltage = tps65023_ldo_list_voltage,
421};
422
Mark Brown90923352011-06-18 01:18:51 +0100423static struct regmap_config tps65023_regmap_config = {
424 .reg_bits = 8,
425 .val_bits = 8,
426};
427
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800428static int __devinit tps_65023_probe(struct i2c_client *client,
429 const struct i2c_device_id *id)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530430{
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530431 const struct tps_info *info = (void *)id->driver_data;
432 struct regulator_init_data *init_data;
433 struct regulator_dev *rdev;
434 struct tps_pmic *tps;
435 int i;
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800436 int error;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530437
438 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
439 return -EIO;
440
441 /**
442 * init_data points to array of regulator_init structures
443 * coming from the board-evm file.
444 */
445 init_data = client->dev.platform_data;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530446 if (!init_data)
447 return -EIO;
448
449 tps = kzalloc(sizeof(*tps), GFP_KERNEL);
450 if (!tps)
451 return -ENOMEM;
452
Mark Brown90923352011-06-18 01:18:51 +0100453 tps->regmap = regmap_init_i2c(client, &tps65023_regmap_config);
454 if (IS_ERR(tps->regmap)) {
455 error = PTR_ERR(tps->regmap);
456 dev_err(&client->dev, "Failed to allocate register map: %d\n",
457 error);
458 goto fail_alloc;
459 }
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530460
461 /* common for all regulators */
462 tps->client = client;
463
464 for (i = 0; i < TPS65023_NUM_REGULATOR; i++, info++, init_data++) {
465 /* Store regulator specific information */
466 tps->info[i] = info;
467
468 tps->desc[i].name = info->name;
Axel Lin77fa44d2011-05-12 13:47:50 +0800469 tps->desc[i].id = i;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530470 tps->desc[i].n_voltages = num_voltages[i];
471 tps->desc[i].ops = (i > TPS65023_DCDC_3 ?
472 &tps65023_ldo_ops : &tps65023_dcdc_ops);
473 tps->desc[i].type = REGULATOR_VOLTAGE;
474 tps->desc[i].owner = THIS_MODULE;
475
476 /* Register the regulators */
477 rdev = regulator_register(&tps->desc[i], &client->dev,
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800478 init_data, tps);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530479 if (IS_ERR(rdev)) {
480 dev_err(&client->dev, "failed to register %s\n",
481 id->name);
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800482 error = PTR_ERR(rdev);
483 goto fail;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530484 }
485
486 /* Save regulator for cleanup */
487 tps->rdev[i] = rdev;
488 }
489
490 i2c_set_clientdata(client, tps);
491
Marcus Folkessonfc999b82011-08-04 13:33:49 +0200492 /* Enable setting output voltage by I2C */
493 tps_65023_clear_bits(tps, TPS65023_REG_CON_CTRL2,
494 TPS65023_REG_CTRL2_CORE_ADJ);
495
Marcus Folkessonf068ad82011-08-08 20:29:32 +0200496 /* Enable setting output voltage by I2C */
497 tps_65023_clear_bits(tps, TPS65023_REG_CON_CTRL2,
498 TPS65023_REG_CTRL2_CORE_ADJ);
499
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530500 return 0;
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800501
502 fail:
503 while (--i >= 0)
504 regulator_unregister(tps->rdev[i]);
505
Mark Brown90923352011-06-18 01:18:51 +0100506 regmap_exit(tps->regmap);
507 fail_alloc:
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800508 kfree(tps);
509 return error;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530510}
511
512/**
513 * tps_65023_remove - TPS65023 driver i2c remove handler
514 * @client: i2c driver client device structure
515 *
516 * Unregister TPS driver as an i2c client device driver
517 */
518static int __devexit tps_65023_remove(struct i2c_client *client)
519{
520 struct tps_pmic *tps = i2c_get_clientdata(client);
521 int i;
522
523 for (i = 0; i < TPS65023_NUM_REGULATOR; i++)
524 regulator_unregister(tps->rdev[i]);
525
Mark Brown90923352011-06-18 01:18:51 +0100526 regmap_exit(tps->regmap);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530527 kfree(tps);
528
529 return 0;
530}
531
532static const struct tps_info tps65023_regs[] = {
533 {
534 .name = "VDCDC1",
535 .min_uV = 800000,
536 .max_uV = 1600000,
537 .table_len = ARRAY_SIZE(VDCDC1_VSEL_table),
538 .table = VDCDC1_VSEL_table,
539 },
540 {
541 .name = "VDCDC2",
542 .min_uV = 3300000,
543 .max_uV = 3300000,
544 .fixed = 1,
545 },
546 {
547 .name = "VDCDC3",
548 .min_uV = 1800000,
549 .max_uV = 1800000,
550 .fixed = 1,
551 },
552 {
553 .name = "LDO1",
554 .min_uV = 1000000,
555 .max_uV = 3150000,
556 .table_len = ARRAY_SIZE(LDO1_VSEL_table),
557 .table = LDO1_VSEL_table,
558 },
559 {
560 .name = "LDO2",
561 .min_uV = 1050000,
562 .max_uV = 3300000,
563 .table_len = ARRAY_SIZE(LDO2_VSEL_table),
564 .table = LDO2_VSEL_table,
565 },
566};
567
Liam Girdwood9e108d32009-08-24 10:31:34 +0100568static const struct i2c_device_id tps_65023_id[] = {
569 {.name = "tps65023",
570 .driver_data = (unsigned long) tps65023_regs,},
Marek Vasut1880a2f2010-06-24 15:49:49 +0200571 {.name = "tps65021",
572 .driver_data = (unsigned long) tps65023_regs,},
Liam Girdwood9e108d32009-08-24 10:31:34 +0100573 { },
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530574};
575
576MODULE_DEVICE_TABLE(i2c, tps_65023_id);
577
578static struct i2c_driver tps_65023_i2c_driver = {
579 .driver = {
580 .name = "tps65023",
581 .owner = THIS_MODULE,
582 },
583 .probe = tps_65023_probe,
584 .remove = __devexit_p(tps_65023_remove),
Liam Girdwood9e108d32009-08-24 10:31:34 +0100585 .id_table = tps_65023_id,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530586};
587
588/**
589 * tps_65023_init
590 *
591 * Module init function
592 */
593static int __init tps_65023_init(void)
594{
595 return i2c_add_driver(&tps_65023_i2c_driver);
596}
597subsys_initcall(tps_65023_init);
598
599/**
600 * tps_65023_cleanup
601 *
602 * Module exit function
603 */
604static void __exit tps_65023_cleanup(void)
605{
606 i2c_del_driver(&tps_65023_i2c_driver);
607}
608module_exit(tps_65023_cleanup);
609
610MODULE_AUTHOR("Texas Instruments");
611MODULE_DESCRIPTION("TPS65023 voltage regulator driver");
Liam Girdwood9e108d32009-08-24 10:31:34 +0100612MODULE_LICENSE("GPL v2");