blob: f841bd0db6aabe523d5c4c8089743c448c72138f [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>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090026#include <linux/slab.h>
Mark Brown90923352011-06-18 01:18:51 +010027#include <linux/regmap.h>
Anuj Aggarwal30e65992009-08-21 00:39:31 +053028
29/* Register definitions */
30#define TPS65023_REG_VERSION 0
31#define TPS65023_REG_PGOODZ 1
32#define TPS65023_REG_MASK 2
33#define TPS65023_REG_REG_CTRL 3
34#define TPS65023_REG_CON_CTRL 4
35#define TPS65023_REG_CON_CTRL2 5
36#define TPS65023_REG_DEF_CORE 6
37#define TPS65023_REG_DEFSLEW 7
38#define TPS65023_REG_LDO_CTRL 8
39
40/* PGOODZ bitfields */
41#define TPS65023_PGOODZ_PWRFAILZ BIT(7)
42#define TPS65023_PGOODZ_LOWBATTZ BIT(6)
43#define TPS65023_PGOODZ_VDCDC1 BIT(5)
44#define TPS65023_PGOODZ_VDCDC2 BIT(4)
45#define TPS65023_PGOODZ_VDCDC3 BIT(3)
46#define TPS65023_PGOODZ_LDO2 BIT(2)
47#define TPS65023_PGOODZ_LDO1 BIT(1)
48
49/* MASK bitfields */
50#define TPS65023_MASK_PWRFAILZ BIT(7)
51#define TPS65023_MASK_LOWBATTZ BIT(6)
52#define TPS65023_MASK_VDCDC1 BIT(5)
53#define TPS65023_MASK_VDCDC2 BIT(4)
54#define TPS65023_MASK_VDCDC3 BIT(3)
55#define TPS65023_MASK_LDO2 BIT(2)
56#define TPS65023_MASK_LDO1 BIT(1)
57
58/* REG_CTRL bitfields */
59#define TPS65023_REG_CTRL_VDCDC1_EN BIT(5)
60#define TPS65023_REG_CTRL_VDCDC2_EN BIT(4)
61#define TPS65023_REG_CTRL_VDCDC3_EN BIT(3)
62#define TPS65023_REG_CTRL_LDO2_EN BIT(2)
63#define TPS65023_REG_CTRL_LDO1_EN BIT(1)
64
Marcus Folkessonfc999b82011-08-04 13:33:49 +020065/* REG_CTRL2 bitfields */
66#define TPS65023_REG_CTRL2_GO BIT(7)
67#define TPS65023_REG_CTRL2_CORE_ADJ BIT(6)
68#define TPS65023_REG_CTRL2_DCDC2 BIT(2)
Marcus Folkessonf068ad82011-08-08 20:29:32 +020069#define TPS65023_REG_CTRL2_DCDC1 BIT(1)
70#define TPS65023_REG_CTRL2_DCDC3 BIT(0)
71
Anuj Aggarwal30e65992009-08-21 00:39:31 +053072/* LDO_CTRL bitfields */
73#define TPS65023_LDO_CTRL_LDOx_SHIFT(ldo_id) ((ldo_id)*4)
Axel Lin70618732012-03-26 13:46:44 +080074#define TPS65023_LDO_CTRL_LDOx_MASK(ldo_id) (0x0F << ((ldo_id)*4))
Anuj Aggarwal30e65992009-08-21 00:39:31 +053075
76/* Number of step-down converters available */
77#define TPS65023_NUM_DCDC 3
78/* Number of LDO voltage regulators available */
79#define TPS65023_NUM_LDO 2
80/* Number of total regulators available */
81#define TPS65023_NUM_REGULATOR (TPS65023_NUM_DCDC + TPS65023_NUM_LDO)
82
83/* DCDCs */
84#define TPS65023_DCDC_1 0
85#define TPS65023_DCDC_2 1
86#define TPS65023_DCDC_3 2
87/* LDOs */
88#define TPS65023_LDO_1 3
89#define TPS65023_LDO_2 4
90
91#define TPS65023_MAX_REG_ID TPS65023_LDO_2
92
93/* Supported voltage values for regulators */
Marcus Folkesson1c3ede02011-08-08 20:29:34 +020094static const u16 VCORE_VSEL_table[] = {
Anuj Aggarwal30e65992009-08-21 00:39:31 +053095 800, 825, 850, 875,
96 900, 925, 950, 975,
97 1000, 1025, 1050, 1075,
98 1100, 1125, 1150, 1175,
99 1200, 1225, 1250, 1275,
100 1300, 1325, 1350, 1375,
101 1400, 1425, 1450, 1475,
102 1500, 1525, 1550, 1600,
103};
104
Marcus Folkesson437afd22011-08-08 20:29:35 +0200105/* Supported voltage values for LDO regulators for tps65020 */
106static const u16 TPS65020_LDO1_VSEL_table[] = {
107 1000, 1050, 1100, 1300,
108 1800, 2500, 3000, 3300,
109};
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200110
Marcus Folkesson437afd22011-08-08 20:29:35 +0200111static const u16 TPS65020_LDO2_VSEL_table[] = {
112 1000, 1050, 1100, 1300,
113 1800, 2500, 3000, 3300,
114};
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200115
116/* Supported voltage values for LDO regulators
117 * for tps65021 and tps65023 */
118static const u16 TPS65023_LDO1_VSEL_table[] = {
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530119 1000, 1100, 1300, 1800,
120 2200, 2600, 2800, 3150,
121};
122
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200123static const u16 TPS65023_LDO2_VSEL_table[] = {
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530124 1050, 1200, 1300, 1800,
125 2500, 2800, 3000, 3300,
126};
127
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530128/* Regulator specific details */
129struct tps_info {
130 const char *name;
131 unsigned min_uV;
132 unsigned max_uV;
133 bool fixed;
134 u8 table_len;
135 const u16 *table;
136};
137
138/* PMIC details */
139struct tps_pmic {
140 struct regulator_desc desc[TPS65023_NUM_REGULATOR];
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530141 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;
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200144 u8 core_regulator;
145};
146
147/* Struct passed as driver data */
148struct tps_driver_data {
149 const struct tps_info *info;
150 u8 core_regulator;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530151};
152
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530153static int tps65023_dcdc_get_voltage(struct regulator_dev *dev)
154{
155 struct tps_pmic *tps = rdev_get_drvdata(dev);
Jonghwan Choi43530b62011-11-07 08:16:04 +0900156 int ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530157 int data, dcdc = rdev_get_id(dev);
158
159 if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
160 return -EINVAL;
161
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200162 if (dcdc == tps->core_regulator) {
Jonghwan Choi43530b62011-11-07 08:16:04 +0900163 ret = regmap_read(tps->regmap, TPS65023_REG_DEF_CORE, &data);
164 if (ret != 0)
165 return ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530166 data &= (tps->info[dcdc]->table_len - 1);
167 return tps->info[dcdc]->table[data] * 1000;
168 } else
169 return tps->info[dcdc]->min_uV;
170}
171
Axel Lin70618732012-03-26 13:46:44 +0800172static int tps65023_dcdc_set_voltage_sel(struct regulator_dev *dev,
173 unsigned selector)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530174{
175 struct tps_pmic *tps = rdev_get_drvdata(dev);
176 int dcdc = rdev_get_id(dev);
Marcus Folkessoncc17ef32011-08-08 20:29:33 +0200177 int ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530178
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200179 if (dcdc != tps->core_regulator)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530180 return -EINVAL;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530181
Axel Lin70618732012-03-26 13:46:44 +0800182 ret = regmap_write(tps->regmap, TPS65023_REG_DEF_CORE, selector);
183 if (ret)
184 goto out;
Marcus Folkessoncc17ef32011-08-08 20:29:33 +0200185
186 /* Tell the chip that we have changed the value in DEFCORE
187 * and its time to update the core voltage
188 */
Axel Lin70618732012-03-26 13:46:44 +0800189 ret = regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2,
190 TPS65023_REG_CTRL2_GO, TPS65023_REG_CTRL2_GO);
Marcus Folkessoncc17ef32011-08-08 20:29:33 +0200191
Axel Lin70618732012-03-26 13:46:44 +0800192out:
Marcus Folkessoncc17ef32011-08-08 20:29:33 +0200193 return ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530194}
195
196static int tps65023_ldo_get_voltage(struct regulator_dev *dev)
197{
198 struct tps_pmic *tps = rdev_get_drvdata(dev);
199 int data, ldo = rdev_get_id(dev);
Jonghwan Choi43530b62011-11-07 08:16:04 +0900200 int ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530201
202 if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
203 return -EINVAL;
204
Jonghwan Choi43530b62011-11-07 08:16:04 +0900205 ret = regmap_read(tps->regmap, TPS65023_REG_LDO_CTRL, &data);
206 if (ret != 0)
207 return ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530208
209 data >>= (TPS65023_LDO_CTRL_LDOx_SHIFT(ldo - TPS65023_LDO_1));
210 data &= (tps->info[ldo]->table_len - 1);
211 return tps->info[ldo]->table[data] * 1000;
212}
213
Axel Lin70618732012-03-26 13:46:44 +0800214static int tps65023_ldo_set_voltage_sel(struct regulator_dev *dev,
215 unsigned selector)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530216{
217 struct tps_pmic *tps = rdev_get_drvdata(dev);
Axel Lin70618732012-03-26 13:46:44 +0800218 int ldo_index = rdev_get_id(dev) - TPS65023_LDO_1;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530219
Axel Lin70618732012-03-26 13:46:44 +0800220 return regmap_update_bits(tps->regmap, TPS65023_REG_LDO_CTRL,
221 TPS65023_LDO_CTRL_LDOx_MASK(ldo_index),
222 selector << TPS65023_LDO_CTRL_LDOx_SHIFT(ldo_index));
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530223}
224
225static int tps65023_dcdc_list_voltage(struct regulator_dev *dev,
226 unsigned selector)
227{
228 struct tps_pmic *tps = rdev_get_drvdata(dev);
229 int dcdc = rdev_get_id(dev);
230
231 if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
232 return -EINVAL;
233
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200234 if (dcdc == tps->core_regulator) {
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530235 if (selector >= tps->info[dcdc]->table_len)
236 return -EINVAL;
237 else
238 return tps->info[dcdc]->table[selector] * 1000;
239 } else
240 return tps->info[dcdc]->min_uV;
241}
242
243static int tps65023_ldo_list_voltage(struct regulator_dev *dev,
244 unsigned selector)
245{
246 struct tps_pmic *tps = rdev_get_drvdata(dev);
247 int ldo = rdev_get_id(dev);
248
249 if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
250 return -EINVAL;
251
252 if (selector >= tps->info[ldo]->table_len)
253 return -EINVAL;
254 else
255 return tps->info[ldo]->table[selector] * 1000;
256}
257
258/* Operations permitted on VDCDCx */
259static struct regulator_ops tps65023_dcdc_ops = {
Axel Linee7b1912012-04-16 19:03:09 +0800260 .is_enabled = regulator_is_enabled_regmap,
261 .enable = regulator_enable_regmap,
262 .disable = regulator_disable_regmap,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530263 .get_voltage = tps65023_dcdc_get_voltage,
Axel Lin70618732012-03-26 13:46:44 +0800264 .set_voltage_sel = tps65023_dcdc_set_voltage_sel,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530265 .list_voltage = tps65023_dcdc_list_voltage,
266};
267
268/* Operations permitted on LDOx */
269static struct regulator_ops tps65023_ldo_ops = {
Axel Linee7b1912012-04-16 19:03:09 +0800270 .is_enabled = regulator_is_enabled_regmap,
271 .enable = regulator_enable_regmap,
272 .disable = regulator_disable_regmap,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530273 .get_voltage = tps65023_ldo_get_voltage,
Axel Lin70618732012-03-26 13:46:44 +0800274 .set_voltage_sel = tps65023_ldo_set_voltage_sel,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530275 .list_voltage = tps65023_ldo_list_voltage,
276};
277
Mark Brown90923352011-06-18 01:18:51 +0100278static struct regmap_config tps65023_regmap_config = {
279 .reg_bits = 8,
280 .val_bits = 8,
281};
282
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800283static int __devinit tps_65023_probe(struct i2c_client *client,
284 const struct i2c_device_id *id)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530285{
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200286 const struct tps_driver_data *drv_data = (void *)id->driver_data;
287 const struct tps_info *info = drv_data->info;
Mark Brownc1727082012-04-04 00:50:22 +0100288 struct regulator_config config = { };
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530289 struct regulator_init_data *init_data;
290 struct regulator_dev *rdev;
291 struct tps_pmic *tps;
292 int i;
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800293 int error;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530294
295 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
296 return -EIO;
297
298 /**
299 * init_data points to array of regulator_init structures
300 * coming from the board-evm file.
301 */
302 init_data = client->dev.platform_data;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530303 if (!init_data)
304 return -EIO;
305
Axel Lin19a8da22012-04-07 23:31:44 +0800306 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530307 if (!tps)
308 return -ENOMEM;
309
Axel Lin19a8da22012-04-07 23:31:44 +0800310 tps->regmap = devm_regmap_init_i2c(client, &tps65023_regmap_config);
Mark Brown90923352011-06-18 01:18:51 +0100311 if (IS_ERR(tps->regmap)) {
312 error = PTR_ERR(tps->regmap);
313 dev_err(&client->dev, "Failed to allocate register map: %d\n",
314 error);
Axel Lin19a8da22012-04-07 23:31:44 +0800315 return error;
Mark Brown90923352011-06-18 01:18:51 +0100316 }
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530317
318 /* common for all regulators */
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200319 tps->core_regulator = drv_data->core_regulator;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530320
321 for (i = 0; i < TPS65023_NUM_REGULATOR; i++, info++, init_data++) {
322 /* Store regulator specific information */
323 tps->info[i] = info;
324
325 tps->desc[i].name = info->name;
Axel Lin77fa44d2011-05-12 13:47:50 +0800326 tps->desc[i].id = i;
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200327 tps->desc[i].n_voltages = info->table_len;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530328 tps->desc[i].ops = (i > TPS65023_DCDC_3 ?
329 &tps65023_ldo_ops : &tps65023_dcdc_ops);
330 tps->desc[i].type = REGULATOR_VOLTAGE;
331 tps->desc[i].owner = THIS_MODULE;
332
Axel Linee7b1912012-04-16 19:03:09 +0800333 tps->desc[i].enable_reg = TPS65023_REG_REG_CTRL;
334 if (i == TPS65023_LDO_1)
335 tps->desc[i].enable_mask = 1 << 1;
336 else if (i == TPS65023_LDO_2)
337 tps->desc[i].enable_mask = 1 << 2;
338 else /* DCDCx */
339 tps->desc[i].enable_mask =
340 1 << (TPS65023_NUM_REGULATOR - i);
341
Mark Brownc1727082012-04-04 00:50:22 +0100342 config.dev = &client->dev;
343 config.init_data = init_data;
344 config.driver_data = tps;
Axel Linee7b1912012-04-16 19:03:09 +0800345 config.regmap = tps->regmap;
Mark Brownc1727082012-04-04 00:50:22 +0100346
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530347 /* Register the regulators */
Mark Brownc1727082012-04-04 00:50:22 +0100348 rdev = regulator_register(&tps->desc[i], &config);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530349 if (IS_ERR(rdev)) {
350 dev_err(&client->dev, "failed to register %s\n",
351 id->name);
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800352 error = PTR_ERR(rdev);
353 goto fail;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530354 }
355
356 /* Save regulator for cleanup */
357 tps->rdev[i] = rdev;
358 }
359
360 i2c_set_clientdata(client, tps);
361
Marcus Folkessonfc999b82011-08-04 13:33:49 +0200362 /* Enable setting output voltage by I2C */
Jonghwan Choi43530b62011-11-07 08:16:04 +0900363 regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2,
364 TPS65023_REG_CTRL2_CORE_ADJ, TPS65023_REG_CTRL2_CORE_ADJ);
Marcus Folkessonfc999b82011-08-04 13:33:49 +0200365
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530366 return 0;
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800367
368 fail:
369 while (--i >= 0)
370 regulator_unregister(tps->rdev[i]);
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800371 return error;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530372}
373
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530374static int __devexit tps_65023_remove(struct i2c_client *client)
375{
376 struct tps_pmic *tps = i2c_get_clientdata(client);
377 int i;
378
379 for (i = 0; i < TPS65023_NUM_REGULATOR; i++)
380 regulator_unregister(tps->rdev[i]);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530381 return 0;
382}
383
Marcus Folkesson437afd22011-08-08 20:29:35 +0200384static const struct tps_info tps65020_regs[] = {
385 {
386 .name = "VDCDC1",
387 .min_uV = 3300000,
388 .max_uV = 3300000,
389 .fixed = 1,
390 },
391 {
392 .name = "VDCDC2",
393 .min_uV = 1800000,
394 .max_uV = 1800000,
395 .fixed = 1,
396 },
397 {
398 .name = "VDCDC3",
399 .min_uV = 800000,
400 .max_uV = 1600000,
401 .table_len = ARRAY_SIZE(VCORE_VSEL_table),
402 .table = VCORE_VSEL_table,
403 },
404
405 {
406 .name = "LDO1",
407 .min_uV = 1000000,
408 .max_uV = 3150000,
409 .table_len = ARRAY_SIZE(TPS65020_LDO1_VSEL_table),
410 .table = TPS65020_LDO1_VSEL_table,
411 },
412 {
413 .name = "LDO2",
414 .min_uV = 1050000,
415 .max_uV = 3300000,
416 .table_len = ARRAY_SIZE(TPS65020_LDO2_VSEL_table),
417 .table = TPS65020_LDO2_VSEL_table,
418 },
419};
420
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200421static const struct tps_info tps65021_regs[] = {
422 {
423 .name = "VDCDC1",
424 .min_uV = 3300000,
425 .max_uV = 3300000,
426 .fixed = 1,
427 },
428 {
429 .name = "VDCDC2",
430 .min_uV = 1800000,
431 .max_uV = 1800000,
432 .fixed = 1,
433 },
434 {
435 .name = "VDCDC3",
436 .min_uV = 800000,
437 .max_uV = 1600000,
438 .table_len = ARRAY_SIZE(VCORE_VSEL_table),
439 .table = VCORE_VSEL_table,
440 },
441 {
442 .name = "LDO1",
443 .min_uV = 1000000,
444 .max_uV = 3150000,
445 .table_len = ARRAY_SIZE(TPS65023_LDO1_VSEL_table),
446 .table = TPS65023_LDO1_VSEL_table,
447 },
448 {
449 .name = "LDO2",
450 .min_uV = 1050000,
451 .max_uV = 3300000,
452 .table_len = ARRAY_SIZE(TPS65023_LDO2_VSEL_table),
453 .table = TPS65023_LDO2_VSEL_table,
454 },
455};
456
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530457static const struct tps_info tps65023_regs[] = {
458 {
459 .name = "VDCDC1",
460 .min_uV = 800000,
461 .max_uV = 1600000,
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200462 .table_len = ARRAY_SIZE(VCORE_VSEL_table),
463 .table = VCORE_VSEL_table,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530464 },
465 {
466 .name = "VDCDC2",
467 .min_uV = 3300000,
468 .max_uV = 3300000,
469 .fixed = 1,
470 },
471 {
472 .name = "VDCDC3",
473 .min_uV = 1800000,
474 .max_uV = 1800000,
475 .fixed = 1,
476 },
477 {
478 .name = "LDO1",
479 .min_uV = 1000000,
480 .max_uV = 3150000,
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200481 .table_len = ARRAY_SIZE(TPS65023_LDO1_VSEL_table),
482 .table = TPS65023_LDO1_VSEL_table,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530483 },
484 {
485 .name = "LDO2",
486 .min_uV = 1050000,
487 .max_uV = 3300000,
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200488 .table_len = ARRAY_SIZE(TPS65023_LDO2_VSEL_table),
489 .table = TPS65023_LDO2_VSEL_table,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530490 },
491};
492
Marcus Folkesson437afd22011-08-08 20:29:35 +0200493static struct tps_driver_data tps65020_drv_data = {
494 .info = tps65020_regs,
495 .core_regulator = TPS65023_DCDC_3,
496};
497
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200498static struct tps_driver_data tps65021_drv_data = {
Axel Lin70618732012-03-26 13:46:44 +0800499 .info = tps65021_regs,
500 .core_regulator = TPS65023_DCDC_3,
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200501};
502
503static struct tps_driver_data tps65023_drv_data = {
Axel Lin70618732012-03-26 13:46:44 +0800504 .info = tps65023_regs,
505 .core_regulator = TPS65023_DCDC_1,
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200506};
507
Liam Girdwood9e108d32009-08-24 10:31:34 +0100508static const struct i2c_device_id tps_65023_id[] = {
509 {.name = "tps65023",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200510 .driver_data = (unsigned long) &tps65023_drv_data},
Marek Vasut1880a2f2010-06-24 15:49:49 +0200511 {.name = "tps65021",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200512 .driver_data = (unsigned long) &tps65021_drv_data,},
Marcus Folkesson437afd22011-08-08 20:29:35 +0200513 {.name = "tps65020",
514 .driver_data = (unsigned long) &tps65020_drv_data},
Liam Girdwood9e108d32009-08-24 10:31:34 +0100515 { },
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530516};
517
518MODULE_DEVICE_TABLE(i2c, tps_65023_id);
519
520static struct i2c_driver tps_65023_i2c_driver = {
521 .driver = {
522 .name = "tps65023",
523 .owner = THIS_MODULE,
524 },
525 .probe = tps_65023_probe,
526 .remove = __devexit_p(tps_65023_remove),
Liam Girdwood9e108d32009-08-24 10:31:34 +0100527 .id_table = tps_65023_id,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530528};
529
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530530static int __init tps_65023_init(void)
531{
532 return i2c_add_driver(&tps_65023_i2c_driver);
533}
534subsys_initcall(tps_65023_init);
535
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530536static void __exit tps_65023_cleanup(void)
537{
538 i2c_del_driver(&tps_65023_i2c_driver);
539}
540module_exit(tps_65023_cleanup);
541
542MODULE_AUTHOR("Texas Instruments");
543MODULE_DESCRIPTION("TPS65023 voltage regulator driver");
Liam Girdwood9e108d32009-08-24 10:31:34 +0100544MODULE_LICENSE("GPL v2");