blob: 4b6f1b2b9481a8cb9da8498bbf18b8e18cdf0486 [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 */
Axel Linba3bd8a2012-06-19 17:12:18 +080094static const unsigned int VCORE_VSEL_table[] = {
95 800000, 825000, 850000, 875000,
96 900000, 925000, 950000, 975000,
97 1000000, 1025000, 1050000, 1075000,
98 1100000, 1125000, 1150000, 1175000,
99 1200000, 1225000, 1250000, 1275000,
100 1300000, 1325000, 1350000, 1375000,
101 1400000, 1425000, 1450000, 1475000,
102 1500000, 1525000, 1550000, 1600000,
103};
104
105static const unsigned int DCDC_FIXED_3300000_VSEL_table[] = {
106 3300000,
107};
108
109static const unsigned int DCDC_FIXED_1800000_VSEL_table[] = {
110 1800000,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530111};
112
Marcus Folkesson437afd22011-08-08 20:29:35 +0200113/* Supported voltage values for LDO regulators for tps65020 */
Axel Linba3bd8a2012-06-19 17:12:18 +0800114static const unsigned int TPS65020_LDO1_VSEL_table[] = {
115 1000000, 1050000, 1100000, 1300000,
116 1800000, 2500000, 3000000, 3300000,
Marcus Folkesson437afd22011-08-08 20:29:35 +0200117};
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200118
Axel Linba3bd8a2012-06-19 17:12:18 +0800119static const unsigned int TPS65020_LDO2_VSEL_table[] = {
120 1000000, 1050000, 1100000, 1300000,
121 1800000, 2500000, 3000000, 3300000,
Marcus Folkesson437afd22011-08-08 20:29:35 +0200122};
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200123
124/* Supported voltage values for LDO regulators
125 * for tps65021 and tps65023 */
Axel Linba3bd8a2012-06-19 17:12:18 +0800126static const unsigned int TPS65023_LDO1_VSEL_table[] = {
127 1000000, 1100000, 1300000, 1800000,
128 2200000, 2600000, 2800000, 3150000,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530129};
130
Axel Linba3bd8a2012-06-19 17:12:18 +0800131static const unsigned int TPS65023_LDO2_VSEL_table[] = {
132 1050000, 1200000, 1300000, 1800000,
133 2500000, 2800000, 3000000, 3300000,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530134};
135
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530136/* Regulator specific details */
137struct tps_info {
138 const char *name;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530139 u8 table_len;
Axel Linba3bd8a2012-06-19 17:12:18 +0800140 const unsigned int *table;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530141};
142
143/* PMIC details */
144struct tps_pmic {
145 struct regulator_desc desc[TPS65023_NUM_REGULATOR];
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530146 struct regulator_dev *rdev[TPS65023_NUM_REGULATOR];
147 const struct tps_info *info[TPS65023_NUM_REGULATOR];
Mark Brown90923352011-06-18 01:18:51 +0100148 struct regmap *regmap;
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200149 u8 core_regulator;
150};
151
152/* Struct passed as driver data */
153struct tps_driver_data {
154 const struct tps_info *info;
155 u8 core_regulator;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530156};
157
Axel Lina1338292012-06-19 17:13:13 +0800158static int tps65023_dcdc_get_voltage_sel(struct regulator_dev *dev)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530159{
160 struct tps_pmic *tps = rdev_get_drvdata(dev);
Jonghwan Choi43530b62011-11-07 08:16:04 +0900161 int ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530162 int data, dcdc = rdev_get_id(dev);
163
164 if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
165 return -EINVAL;
166
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200167 if (dcdc == tps->core_regulator) {
Jonghwan Choi43530b62011-11-07 08:16:04 +0900168 ret = regmap_read(tps->regmap, TPS65023_REG_DEF_CORE, &data);
169 if (ret != 0)
170 return ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530171 data &= (tps->info[dcdc]->table_len - 1);
Axel Lina1338292012-06-19 17:13:13 +0800172 return data;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530173 } else
Axel Lina1338292012-06-19 17:13:13 +0800174 return 0;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530175}
176
Axel Lin70618732012-03-26 13:46:44 +0800177static int tps65023_dcdc_set_voltage_sel(struct regulator_dev *dev,
178 unsigned selector)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530179{
180 struct tps_pmic *tps = rdev_get_drvdata(dev);
181 int dcdc = rdev_get_id(dev);
Marcus Folkessoncc17ef32011-08-08 20:29:33 +0200182 int ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530183
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200184 if (dcdc != tps->core_regulator)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530185 return -EINVAL;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530186
Axel Lin70618732012-03-26 13:46:44 +0800187 ret = regmap_write(tps->regmap, TPS65023_REG_DEF_CORE, selector);
188 if (ret)
189 goto out;
Marcus Folkessoncc17ef32011-08-08 20:29:33 +0200190
191 /* Tell the chip that we have changed the value in DEFCORE
192 * and its time to update the core voltage
193 */
Axel Lin70618732012-03-26 13:46:44 +0800194 ret = regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2,
195 TPS65023_REG_CTRL2_GO, TPS65023_REG_CTRL2_GO);
Marcus Folkessoncc17ef32011-08-08 20:29:33 +0200196
Axel Lin70618732012-03-26 13:46:44 +0800197out:
Marcus Folkessoncc17ef32011-08-08 20:29:33 +0200198 return ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530199}
200
Axel Lina1338292012-06-19 17:13:13 +0800201static int tps65023_ldo_get_voltage_sel(struct regulator_dev *dev)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530202{
203 struct tps_pmic *tps = rdev_get_drvdata(dev);
204 int data, ldo = rdev_get_id(dev);
Jonghwan Choi43530b62011-11-07 08:16:04 +0900205 int ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530206
207 if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
208 return -EINVAL;
209
Jonghwan Choi43530b62011-11-07 08:16:04 +0900210 ret = regmap_read(tps->regmap, TPS65023_REG_LDO_CTRL, &data);
211 if (ret != 0)
212 return ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530213
214 data >>= (TPS65023_LDO_CTRL_LDOx_SHIFT(ldo - TPS65023_LDO_1));
215 data &= (tps->info[ldo]->table_len - 1);
Axel Lina1338292012-06-19 17:13:13 +0800216 return data;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530217}
218
Axel Lin70618732012-03-26 13:46:44 +0800219static int tps65023_ldo_set_voltage_sel(struct regulator_dev *dev,
220 unsigned selector)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530221{
222 struct tps_pmic *tps = rdev_get_drvdata(dev);
Axel Lin70618732012-03-26 13:46:44 +0800223 int ldo_index = rdev_get_id(dev) - TPS65023_LDO_1;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530224
Axel Lin70618732012-03-26 13:46:44 +0800225 return regmap_update_bits(tps->regmap, TPS65023_REG_LDO_CTRL,
226 TPS65023_LDO_CTRL_LDOx_MASK(ldo_index),
227 selector << TPS65023_LDO_CTRL_LDOx_SHIFT(ldo_index));
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530228}
229
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530230/* Operations permitted on VDCDCx */
231static struct regulator_ops tps65023_dcdc_ops = {
Axel Linee7b1912012-04-16 19:03:09 +0800232 .is_enabled = regulator_is_enabled_regmap,
233 .enable = regulator_enable_regmap,
234 .disable = regulator_disable_regmap,
Axel Lina1338292012-06-19 17:13:13 +0800235 .get_voltage_sel = tps65023_dcdc_get_voltage_sel,
Axel Lin70618732012-03-26 13:46:44 +0800236 .set_voltage_sel = tps65023_dcdc_set_voltage_sel,
Axel Linba3bd8a2012-06-19 17:12:18 +0800237 .list_voltage = regulator_list_voltage_table,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530238};
239
240/* Operations permitted on LDOx */
241static struct regulator_ops tps65023_ldo_ops = {
Axel Linee7b1912012-04-16 19:03:09 +0800242 .is_enabled = regulator_is_enabled_regmap,
243 .enable = regulator_enable_regmap,
244 .disable = regulator_disable_regmap,
Axel Lina1338292012-06-19 17:13:13 +0800245 .get_voltage_sel = tps65023_ldo_get_voltage_sel,
Axel Lin70618732012-03-26 13:46:44 +0800246 .set_voltage_sel = tps65023_ldo_set_voltage_sel,
Axel Linba3bd8a2012-06-19 17:12:18 +0800247 .list_voltage = regulator_list_voltage_table,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530248};
249
Mark Brown90923352011-06-18 01:18:51 +0100250static struct regmap_config tps65023_regmap_config = {
251 .reg_bits = 8,
252 .val_bits = 8,
253};
254
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800255static int __devinit tps_65023_probe(struct i2c_client *client,
256 const struct i2c_device_id *id)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530257{
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200258 const struct tps_driver_data *drv_data = (void *)id->driver_data;
259 const struct tps_info *info = drv_data->info;
Mark Brownc1727082012-04-04 00:50:22 +0100260 struct regulator_config config = { };
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530261 struct regulator_init_data *init_data;
262 struct regulator_dev *rdev;
263 struct tps_pmic *tps;
264 int i;
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800265 int error;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530266
267 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
268 return -EIO;
269
270 /**
271 * init_data points to array of regulator_init structures
272 * coming from the board-evm file.
273 */
274 init_data = client->dev.platform_data;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530275 if (!init_data)
276 return -EIO;
277
Axel Lin19a8da22012-04-07 23:31:44 +0800278 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530279 if (!tps)
280 return -ENOMEM;
281
Axel Lin19a8da22012-04-07 23:31:44 +0800282 tps->regmap = devm_regmap_init_i2c(client, &tps65023_regmap_config);
Mark Brown90923352011-06-18 01:18:51 +0100283 if (IS_ERR(tps->regmap)) {
284 error = PTR_ERR(tps->regmap);
285 dev_err(&client->dev, "Failed to allocate register map: %d\n",
286 error);
Axel Lin19a8da22012-04-07 23:31:44 +0800287 return error;
Mark Brown90923352011-06-18 01:18:51 +0100288 }
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530289
290 /* common for all regulators */
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200291 tps->core_regulator = drv_data->core_regulator;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530292
293 for (i = 0; i < TPS65023_NUM_REGULATOR; i++, info++, init_data++) {
294 /* Store regulator specific information */
295 tps->info[i] = info;
296
297 tps->desc[i].name = info->name;
Axel Lin77fa44d2011-05-12 13:47:50 +0800298 tps->desc[i].id = i;
Axel Linba3bd8a2012-06-19 17:12:18 +0800299 tps->desc[i].n_voltages = info->table_len;
300 tps->desc[i].volt_table = info->table;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530301 tps->desc[i].ops = (i > TPS65023_DCDC_3 ?
302 &tps65023_ldo_ops : &tps65023_dcdc_ops);
303 tps->desc[i].type = REGULATOR_VOLTAGE;
304 tps->desc[i].owner = THIS_MODULE;
305
Axel Linee7b1912012-04-16 19:03:09 +0800306 tps->desc[i].enable_reg = TPS65023_REG_REG_CTRL;
307 if (i == TPS65023_LDO_1)
308 tps->desc[i].enable_mask = 1 << 1;
309 else if (i == TPS65023_LDO_2)
310 tps->desc[i].enable_mask = 1 << 2;
311 else /* DCDCx */
312 tps->desc[i].enable_mask =
313 1 << (TPS65023_NUM_REGULATOR - i);
314
Mark Brownc1727082012-04-04 00:50:22 +0100315 config.dev = &client->dev;
316 config.init_data = init_data;
317 config.driver_data = tps;
Axel Linee7b1912012-04-16 19:03:09 +0800318 config.regmap = tps->regmap;
Mark Brownc1727082012-04-04 00:50:22 +0100319
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530320 /* Register the regulators */
Mark Brownc1727082012-04-04 00:50:22 +0100321 rdev = regulator_register(&tps->desc[i], &config);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530322 if (IS_ERR(rdev)) {
323 dev_err(&client->dev, "failed to register %s\n",
324 id->name);
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800325 error = PTR_ERR(rdev);
326 goto fail;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530327 }
328
329 /* Save regulator for cleanup */
330 tps->rdev[i] = rdev;
331 }
332
333 i2c_set_clientdata(client, tps);
334
Marcus Folkessonfc999b82011-08-04 13:33:49 +0200335 /* Enable setting output voltage by I2C */
Jonghwan Choi43530b62011-11-07 08:16:04 +0900336 regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2,
337 TPS65023_REG_CTRL2_CORE_ADJ, TPS65023_REG_CTRL2_CORE_ADJ);
Marcus Folkessonfc999b82011-08-04 13:33:49 +0200338
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530339 return 0;
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800340
341 fail:
342 while (--i >= 0)
343 regulator_unregister(tps->rdev[i]);
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800344 return error;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530345}
346
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530347static int __devexit tps_65023_remove(struct i2c_client *client)
348{
349 struct tps_pmic *tps = i2c_get_clientdata(client);
350 int i;
351
352 for (i = 0; i < TPS65023_NUM_REGULATOR; i++)
353 regulator_unregister(tps->rdev[i]);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530354 return 0;
355}
356
Marcus Folkesson437afd22011-08-08 20:29:35 +0200357static const struct tps_info tps65020_regs[] = {
358 {
359 .name = "VDCDC1",
Axel Linba3bd8a2012-06-19 17:12:18 +0800360 .table_len = ARRAY_SIZE(DCDC_FIXED_3300000_VSEL_table),
361 .table = DCDC_FIXED_3300000_VSEL_table,
Marcus Folkesson437afd22011-08-08 20:29:35 +0200362 },
363 {
364 .name = "VDCDC2",
Axel Linba3bd8a2012-06-19 17:12:18 +0800365 .table_len = ARRAY_SIZE(DCDC_FIXED_1800000_VSEL_table),
366 .table = DCDC_FIXED_1800000_VSEL_table,
Marcus Folkesson437afd22011-08-08 20:29:35 +0200367 },
368 {
369 .name = "VDCDC3",
Marcus Folkesson437afd22011-08-08 20:29:35 +0200370 .table_len = ARRAY_SIZE(VCORE_VSEL_table),
371 .table = VCORE_VSEL_table,
372 },
Marcus Folkesson437afd22011-08-08 20:29:35 +0200373 {
374 .name = "LDO1",
Marcus Folkesson437afd22011-08-08 20:29:35 +0200375 .table_len = ARRAY_SIZE(TPS65020_LDO1_VSEL_table),
376 .table = TPS65020_LDO1_VSEL_table,
377 },
378 {
379 .name = "LDO2",
Marcus Folkesson437afd22011-08-08 20:29:35 +0200380 .table_len = ARRAY_SIZE(TPS65020_LDO2_VSEL_table),
381 .table = TPS65020_LDO2_VSEL_table,
382 },
383};
384
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200385static const struct tps_info tps65021_regs[] = {
386 {
387 .name = "VDCDC1",
Axel Linba3bd8a2012-06-19 17:12:18 +0800388 .table_len = ARRAY_SIZE(DCDC_FIXED_3300000_VSEL_table),
389 .table = DCDC_FIXED_3300000_VSEL_table,
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200390 },
391 {
392 .name = "VDCDC2",
Axel Linba3bd8a2012-06-19 17:12:18 +0800393 .table_len = ARRAY_SIZE(DCDC_FIXED_1800000_VSEL_table),
394 .table = DCDC_FIXED_1800000_VSEL_table,
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200395 },
396 {
397 .name = "VDCDC3",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200398 .table_len = ARRAY_SIZE(VCORE_VSEL_table),
399 .table = VCORE_VSEL_table,
400 },
401 {
402 .name = "LDO1",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200403 .table_len = ARRAY_SIZE(TPS65023_LDO1_VSEL_table),
404 .table = TPS65023_LDO1_VSEL_table,
405 },
406 {
407 .name = "LDO2",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200408 .table_len = ARRAY_SIZE(TPS65023_LDO2_VSEL_table),
409 .table = TPS65023_LDO2_VSEL_table,
410 },
411};
412
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530413static const struct tps_info tps65023_regs[] = {
414 {
415 .name = "VDCDC1",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200416 .table_len = ARRAY_SIZE(VCORE_VSEL_table),
417 .table = VCORE_VSEL_table,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530418 },
419 {
420 .name = "VDCDC2",
Axel Linba3bd8a2012-06-19 17:12:18 +0800421 .table_len = ARRAY_SIZE(DCDC_FIXED_3300000_VSEL_table),
422 .table = DCDC_FIXED_3300000_VSEL_table,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530423 },
424 {
425 .name = "VDCDC3",
Axel Linba3bd8a2012-06-19 17:12:18 +0800426 .table_len = ARRAY_SIZE(DCDC_FIXED_1800000_VSEL_table),
427 .table = DCDC_FIXED_1800000_VSEL_table,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530428 },
429 {
430 .name = "LDO1",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200431 .table_len = ARRAY_SIZE(TPS65023_LDO1_VSEL_table),
432 .table = TPS65023_LDO1_VSEL_table,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530433 },
434 {
435 .name = "LDO2",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200436 .table_len = ARRAY_SIZE(TPS65023_LDO2_VSEL_table),
437 .table = TPS65023_LDO2_VSEL_table,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530438 },
439};
440
Marcus Folkesson437afd22011-08-08 20:29:35 +0200441static struct tps_driver_data tps65020_drv_data = {
442 .info = tps65020_regs,
443 .core_regulator = TPS65023_DCDC_3,
444};
445
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200446static struct tps_driver_data tps65021_drv_data = {
Axel Lin70618732012-03-26 13:46:44 +0800447 .info = tps65021_regs,
448 .core_regulator = TPS65023_DCDC_3,
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200449};
450
451static struct tps_driver_data tps65023_drv_data = {
Axel Lin70618732012-03-26 13:46:44 +0800452 .info = tps65023_regs,
453 .core_regulator = TPS65023_DCDC_1,
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200454};
455
Liam Girdwood9e108d32009-08-24 10:31:34 +0100456static const struct i2c_device_id tps_65023_id[] = {
457 {.name = "tps65023",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200458 .driver_data = (unsigned long) &tps65023_drv_data},
Marek Vasut1880a2fc2010-06-24 15:49:49 +0200459 {.name = "tps65021",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200460 .driver_data = (unsigned long) &tps65021_drv_data,},
Marcus Folkesson437afd22011-08-08 20:29:35 +0200461 {.name = "tps65020",
462 .driver_data = (unsigned long) &tps65020_drv_data},
Liam Girdwood9e108d32009-08-24 10:31:34 +0100463 { },
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530464};
465
466MODULE_DEVICE_TABLE(i2c, tps_65023_id);
467
468static struct i2c_driver tps_65023_i2c_driver = {
469 .driver = {
470 .name = "tps65023",
471 .owner = THIS_MODULE,
472 },
473 .probe = tps_65023_probe,
474 .remove = __devexit_p(tps_65023_remove),
Liam Girdwood9e108d32009-08-24 10:31:34 +0100475 .id_table = tps_65023_id,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530476};
477
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530478static int __init tps_65023_init(void)
479{
480 return i2c_add_driver(&tps_65023_i2c_driver);
481}
482subsys_initcall(tps_65023_init);
483
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530484static void __exit tps_65023_cleanup(void)
485{
486 i2c_del_driver(&tps_65023_i2c_driver);
487}
488module_exit(tps_65023_cleanup);
489
490MODULE_AUTHOR("Texas Instruments");
491MODULE_DESCRIPTION("TPS65023 voltage regulator driver");
Liam Girdwood9e108d32009-08-24 10:31:34 +0100492MODULE_LICENSE("GPL v2");