blob: 8d21cf3385e44bc661a586b518c3ae30b53f629f [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/* Number of step-down converters available */
73#define TPS65023_NUM_DCDC 3
74/* Number of LDO voltage regulators available */
75#define TPS65023_NUM_LDO 2
76/* Number of total regulators available */
77#define TPS65023_NUM_REGULATOR (TPS65023_NUM_DCDC + TPS65023_NUM_LDO)
78
79/* DCDCs */
80#define TPS65023_DCDC_1 0
81#define TPS65023_DCDC_2 1
82#define TPS65023_DCDC_3 2
83/* LDOs */
84#define TPS65023_LDO_1 3
85#define TPS65023_LDO_2 4
86
87#define TPS65023_MAX_REG_ID TPS65023_LDO_2
88
89/* Supported voltage values for regulators */
Axel Linba3bd8a2012-06-19 17:12:18 +080090static const unsigned int VCORE_VSEL_table[] = {
91 800000, 825000, 850000, 875000,
92 900000, 925000, 950000, 975000,
93 1000000, 1025000, 1050000, 1075000,
94 1100000, 1125000, 1150000, 1175000,
95 1200000, 1225000, 1250000, 1275000,
96 1300000, 1325000, 1350000, 1375000,
97 1400000, 1425000, 1450000, 1475000,
98 1500000, 1525000, 1550000, 1600000,
99};
100
101static const unsigned int DCDC_FIXED_3300000_VSEL_table[] = {
102 3300000,
103};
104
105static const unsigned int DCDC_FIXED_1800000_VSEL_table[] = {
106 1800000,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530107};
108
Marcus Folkesson437afd22011-08-08 20:29:35 +0200109/* Supported voltage values for LDO regulators for tps65020 */
Axel Lin20405412013-04-25 11:31:42 +0800110static const unsigned int TPS65020_LDO_VSEL_table[] = {
Axel Linba3bd8a2012-06-19 17:12:18 +0800111 1000000, 1050000, 1100000, 1300000,
112 1800000, 2500000, 3000000, 3300000,
Marcus Folkesson437afd22011-08-08 20:29:35 +0200113};
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200114
115/* Supported voltage values for LDO regulators
116 * for tps65021 and tps65023 */
Axel Linba3bd8a2012-06-19 17:12:18 +0800117static const unsigned int TPS65023_LDO1_VSEL_table[] = {
118 1000000, 1100000, 1300000, 1800000,
119 2200000, 2600000, 2800000, 3150000,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530120};
121
Axel Linba3bd8a2012-06-19 17:12:18 +0800122static const unsigned int TPS65023_LDO2_VSEL_table[] = {
123 1050000, 1200000, 1300000, 1800000,
124 2500000, 2800000, 3000000, 3300000,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530125};
126
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530127/* Regulator specific details */
128struct tps_info {
129 const char *name;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530130 u8 table_len;
Axel Linba3bd8a2012-06-19 17:12:18 +0800131 const unsigned int *table;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530132};
133
134/* PMIC details */
135struct tps_pmic {
136 struct regulator_desc desc[TPS65023_NUM_REGULATOR];
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530137 struct regulator_dev *rdev[TPS65023_NUM_REGULATOR];
138 const struct tps_info *info[TPS65023_NUM_REGULATOR];
Mark Brown90923352011-06-18 01:18:51 +0100139 struct regmap *regmap;
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200140 u8 core_regulator;
141};
142
143/* Struct passed as driver data */
144struct tps_driver_data {
145 const struct tps_info *info;
146 u8 core_regulator;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530147};
148
Axel Lina1338292012-06-19 17:13:13 +0800149static int tps65023_dcdc_get_voltage_sel(struct regulator_dev *dev)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530150{
151 struct tps_pmic *tps = rdev_get_drvdata(dev);
Jonghwan Choi43530b62011-11-07 08:16:04 +0900152 int ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530153 int data, dcdc = rdev_get_id(dev);
154
155 if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
156 return -EINVAL;
157
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200158 if (dcdc == tps->core_regulator) {
Jonghwan Choi43530b62011-11-07 08:16:04 +0900159 ret = regmap_read(tps->regmap, TPS65023_REG_DEF_CORE, &data);
160 if (ret != 0)
161 return ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530162 data &= (tps->info[dcdc]->table_len - 1);
Axel Lina1338292012-06-19 17:13:13 +0800163 return data;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530164 } else
Axel Lina1338292012-06-19 17:13:13 +0800165 return 0;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530166}
167
Axel Lin70618732012-03-26 13:46:44 +0800168static int tps65023_dcdc_set_voltage_sel(struct regulator_dev *dev,
169 unsigned selector)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530170{
171 struct tps_pmic *tps = rdev_get_drvdata(dev);
172 int dcdc = rdev_get_id(dev);
Marcus Folkessoncc17ef32011-08-08 20:29:33 +0200173 int ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530174
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200175 if (dcdc != tps->core_regulator)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530176 return -EINVAL;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530177
Axel Lin70618732012-03-26 13:46:44 +0800178 ret = regmap_write(tps->regmap, TPS65023_REG_DEF_CORE, selector);
179 if (ret)
180 goto out;
Marcus Folkessoncc17ef32011-08-08 20:29:33 +0200181
182 /* Tell the chip that we have changed the value in DEFCORE
183 * and its time to update the core voltage
184 */
Axel Lin70618732012-03-26 13:46:44 +0800185 ret = regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2,
186 TPS65023_REG_CTRL2_GO, TPS65023_REG_CTRL2_GO);
Marcus Folkessoncc17ef32011-08-08 20:29:33 +0200187
Axel Lin70618732012-03-26 13:46:44 +0800188out:
Marcus Folkessoncc17ef32011-08-08 20:29:33 +0200189 return ret;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530190}
191
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530192/* Operations permitted on VDCDCx */
193static struct regulator_ops tps65023_dcdc_ops = {
Axel Linee7b1912012-04-16 19:03:09 +0800194 .is_enabled = regulator_is_enabled_regmap,
195 .enable = regulator_enable_regmap,
196 .disable = regulator_disable_regmap,
Axel Lina1338292012-06-19 17:13:13 +0800197 .get_voltage_sel = tps65023_dcdc_get_voltage_sel,
Axel Lin70618732012-03-26 13:46:44 +0800198 .set_voltage_sel = tps65023_dcdc_set_voltage_sel,
Axel Linba3bd8a2012-06-19 17:12:18 +0800199 .list_voltage = regulator_list_voltage_table,
Axel Linc4bbfbd2013-04-25 11:32:40 +0800200 .map_voltage = regulator_map_voltage_ascend,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530201};
202
203/* Operations permitted on LDOx */
204static struct regulator_ops tps65023_ldo_ops = {
Axel Linee7b1912012-04-16 19:03:09 +0800205 .is_enabled = regulator_is_enabled_regmap,
206 .enable = regulator_enable_regmap,
207 .disable = regulator_disable_regmap,
Axel Line90a8442012-06-19 17:14:31 +0800208 .get_voltage_sel = regulator_get_voltage_sel_regmap,
209 .set_voltage_sel = regulator_set_voltage_sel_regmap,
Axel Linba3bd8a2012-06-19 17:12:18 +0800210 .list_voltage = regulator_list_voltage_table,
Axel Linc4bbfbd2013-04-25 11:32:40 +0800211 .map_voltage = regulator_map_voltage_ascend,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530212};
213
Mark Brown90923352011-06-18 01:18:51 +0100214static struct regmap_config tps65023_regmap_config = {
215 .reg_bits = 8,
216 .val_bits = 8,
217};
218
Bill Pembertona5023572012-11-19 13:22:22 -0500219static int tps_65023_probe(struct i2c_client *client,
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800220 const struct i2c_device_id *id)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530221{
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200222 const struct tps_driver_data *drv_data = (void *)id->driver_data;
223 const struct tps_info *info = drv_data->info;
Mark Brownc1727082012-04-04 00:50:22 +0100224 struct regulator_config config = { };
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530225 struct regulator_init_data *init_data;
226 struct regulator_dev *rdev;
227 struct tps_pmic *tps;
228 int i;
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800229 int error;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530230
231 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
232 return -EIO;
233
234 /**
235 * init_data points to array of regulator_init structures
236 * coming from the board-evm file.
237 */
238 init_data = client->dev.platform_data;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530239 if (!init_data)
240 return -EIO;
241
Axel Lin19a8da22012-04-07 23:31:44 +0800242 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530243 if (!tps)
244 return -ENOMEM;
245
Axel Lin19a8da22012-04-07 23:31:44 +0800246 tps->regmap = devm_regmap_init_i2c(client, &tps65023_regmap_config);
Mark Brown90923352011-06-18 01:18:51 +0100247 if (IS_ERR(tps->regmap)) {
248 error = PTR_ERR(tps->regmap);
249 dev_err(&client->dev, "Failed to allocate register map: %d\n",
250 error);
Axel Lin19a8da22012-04-07 23:31:44 +0800251 return error;
Mark Brown90923352011-06-18 01:18:51 +0100252 }
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530253
254 /* common for all regulators */
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200255 tps->core_regulator = drv_data->core_regulator;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530256
257 for (i = 0; i < TPS65023_NUM_REGULATOR; i++, info++, init_data++) {
258 /* Store regulator specific information */
259 tps->info[i] = info;
260
261 tps->desc[i].name = info->name;
Axel Lin77fa44d2011-05-12 13:47:50 +0800262 tps->desc[i].id = i;
Axel Linba3bd8a2012-06-19 17:12:18 +0800263 tps->desc[i].n_voltages = info->table_len;
264 tps->desc[i].volt_table = info->table;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530265 tps->desc[i].ops = (i > TPS65023_DCDC_3 ?
266 &tps65023_ldo_ops : &tps65023_dcdc_ops);
267 tps->desc[i].type = REGULATOR_VOLTAGE;
268 tps->desc[i].owner = THIS_MODULE;
269
Axel Linee7b1912012-04-16 19:03:09 +0800270 tps->desc[i].enable_reg = TPS65023_REG_REG_CTRL;
Axel Line90a8442012-06-19 17:14:31 +0800271 switch (i) {
272 case TPS65023_LDO_1:
273 tps->desc[i].vsel_reg = TPS65023_REG_LDO_CTRL;
274 tps->desc[i].vsel_mask = 0x07;
Axel Linee7b1912012-04-16 19:03:09 +0800275 tps->desc[i].enable_mask = 1 << 1;
Axel Line90a8442012-06-19 17:14:31 +0800276 break;
277 case TPS65023_LDO_2:
278 tps->desc[i].vsel_reg = TPS65023_REG_LDO_CTRL;
279 tps->desc[i].vsel_mask = 0x70;
Axel Linee7b1912012-04-16 19:03:09 +0800280 tps->desc[i].enable_mask = 1 << 2;
Axel Line90a8442012-06-19 17:14:31 +0800281 break;
282 default: /* DCDCx */
Axel Linee7b1912012-04-16 19:03:09 +0800283 tps->desc[i].enable_mask =
284 1 << (TPS65023_NUM_REGULATOR - i);
Axel Line90a8442012-06-19 17:14:31 +0800285 }
Axel Linee7b1912012-04-16 19:03:09 +0800286
Mark Brownc1727082012-04-04 00:50:22 +0100287 config.dev = &client->dev;
288 config.init_data = init_data;
289 config.driver_data = tps;
Axel Linee7b1912012-04-16 19:03:09 +0800290 config.regmap = tps->regmap;
Mark Brownc1727082012-04-04 00:50:22 +0100291
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530292 /* Register the regulators */
Mark Brownc1727082012-04-04 00:50:22 +0100293 rdev = regulator_register(&tps->desc[i], &config);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530294 if (IS_ERR(rdev)) {
295 dev_err(&client->dev, "failed to register %s\n",
296 id->name);
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800297 error = PTR_ERR(rdev);
298 goto fail;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530299 }
300
301 /* Save regulator for cleanup */
302 tps->rdev[i] = rdev;
303 }
304
305 i2c_set_clientdata(client, tps);
306
Marcus Folkessonfc999b82011-08-04 13:33:49 +0200307 /* Enable setting output voltage by I2C */
Jonghwan Choi43530b62011-11-07 08:16:04 +0900308 regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2,
309 TPS65023_REG_CTRL2_CORE_ADJ, TPS65023_REG_CTRL2_CORE_ADJ);
Marcus Folkessonfc999b82011-08-04 13:33:49 +0200310
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530311 return 0;
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800312
313 fail:
314 while (--i >= 0)
315 regulator_unregister(tps->rdev[i]);
Dmitry Torokhov54d13ab2010-02-23 23:38:06 -0800316 return error;
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530317}
318
Bill Pemberton8dc995f2012-11-19 13:26:10 -0500319static int tps_65023_remove(struct i2c_client *client)
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530320{
321 struct tps_pmic *tps = i2c_get_clientdata(client);
322 int i;
323
324 for (i = 0; i < TPS65023_NUM_REGULATOR; i++)
325 regulator_unregister(tps->rdev[i]);
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530326 return 0;
327}
328
Marcus Folkesson437afd22011-08-08 20:29:35 +0200329static const struct tps_info tps65020_regs[] = {
330 {
331 .name = "VDCDC1",
Axel Linba3bd8a2012-06-19 17:12:18 +0800332 .table_len = ARRAY_SIZE(DCDC_FIXED_3300000_VSEL_table),
333 .table = DCDC_FIXED_3300000_VSEL_table,
Marcus Folkesson437afd22011-08-08 20:29:35 +0200334 },
335 {
336 .name = "VDCDC2",
Axel Linba3bd8a2012-06-19 17:12:18 +0800337 .table_len = ARRAY_SIZE(DCDC_FIXED_1800000_VSEL_table),
338 .table = DCDC_FIXED_1800000_VSEL_table,
Marcus Folkesson437afd22011-08-08 20:29:35 +0200339 },
340 {
341 .name = "VDCDC3",
Marcus Folkesson437afd22011-08-08 20:29:35 +0200342 .table_len = ARRAY_SIZE(VCORE_VSEL_table),
343 .table = VCORE_VSEL_table,
344 },
Marcus Folkesson437afd22011-08-08 20:29:35 +0200345 {
346 .name = "LDO1",
Axel Lin20405412013-04-25 11:31:42 +0800347 .table_len = ARRAY_SIZE(TPS65020_LDO_VSEL_table),
348 .table = TPS65020_LDO_VSEL_table,
Marcus Folkesson437afd22011-08-08 20:29:35 +0200349 },
350 {
351 .name = "LDO2",
Axel Lin20405412013-04-25 11:31:42 +0800352 .table_len = ARRAY_SIZE(TPS65020_LDO_VSEL_table),
353 .table = TPS65020_LDO_VSEL_table,
Marcus Folkesson437afd22011-08-08 20:29:35 +0200354 },
355};
356
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200357static const struct tps_info tps65021_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 Folkesson1c3ede02011-08-08 20:29:34 +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 Folkesson1c3ede02011-08-08 20:29:34 +0200367 },
368 {
369 .name = "VDCDC3",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200370 .table_len = ARRAY_SIZE(VCORE_VSEL_table),
371 .table = VCORE_VSEL_table,
372 },
373 {
374 .name = "LDO1",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200375 .table_len = ARRAY_SIZE(TPS65023_LDO1_VSEL_table),
376 .table = TPS65023_LDO1_VSEL_table,
377 },
378 {
379 .name = "LDO2",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200380 .table_len = ARRAY_SIZE(TPS65023_LDO2_VSEL_table),
381 .table = TPS65023_LDO2_VSEL_table,
382 },
383};
384
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530385static const struct tps_info tps65023_regs[] = {
386 {
387 .name = "VDCDC1",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200388 .table_len = ARRAY_SIZE(VCORE_VSEL_table),
389 .table = VCORE_VSEL_table,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530390 },
391 {
392 .name = "VDCDC2",
Axel Linba3bd8a2012-06-19 17:12:18 +0800393 .table_len = ARRAY_SIZE(DCDC_FIXED_3300000_VSEL_table),
394 .table = DCDC_FIXED_3300000_VSEL_table,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530395 },
396 {
397 .name = "VDCDC3",
Axel Linba3bd8a2012-06-19 17:12:18 +0800398 .table_len = ARRAY_SIZE(DCDC_FIXED_1800000_VSEL_table),
399 .table = DCDC_FIXED_1800000_VSEL_table,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530400 },
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,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530405 },
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,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530410 },
411};
412
Marcus Folkesson437afd22011-08-08 20:29:35 +0200413static struct tps_driver_data tps65020_drv_data = {
414 .info = tps65020_regs,
415 .core_regulator = TPS65023_DCDC_3,
416};
417
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200418static struct tps_driver_data tps65021_drv_data = {
Axel Lin70618732012-03-26 13:46:44 +0800419 .info = tps65021_regs,
420 .core_regulator = TPS65023_DCDC_3,
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200421};
422
423static struct tps_driver_data tps65023_drv_data = {
Axel Lin70618732012-03-26 13:46:44 +0800424 .info = tps65023_regs,
425 .core_regulator = TPS65023_DCDC_1,
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200426};
427
Liam Girdwood9e108d32009-08-24 10:31:34 +0100428static const struct i2c_device_id tps_65023_id[] = {
429 {.name = "tps65023",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200430 .driver_data = (unsigned long) &tps65023_drv_data},
Marek Vasut1880a2f2010-06-24 15:49:49 +0200431 {.name = "tps65021",
Marcus Folkesson1c3ede02011-08-08 20:29:34 +0200432 .driver_data = (unsigned long) &tps65021_drv_data,},
Marcus Folkesson437afd22011-08-08 20:29:35 +0200433 {.name = "tps65020",
434 .driver_data = (unsigned long) &tps65020_drv_data},
Liam Girdwood9e108d32009-08-24 10:31:34 +0100435 { },
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530436};
437
438MODULE_DEVICE_TABLE(i2c, tps_65023_id);
439
440static struct i2c_driver tps_65023_i2c_driver = {
441 .driver = {
442 .name = "tps65023",
443 .owner = THIS_MODULE,
444 },
445 .probe = tps_65023_probe,
Bill Pemberton5eb9f2b2012-11-19 13:20:42 -0500446 .remove = tps_65023_remove,
Liam Girdwood9e108d32009-08-24 10:31:34 +0100447 .id_table = tps_65023_id,
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530448};
449
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530450static int __init tps_65023_init(void)
451{
452 return i2c_add_driver(&tps_65023_i2c_driver);
453}
454subsys_initcall(tps_65023_init);
455
Anuj Aggarwal30e65992009-08-21 00:39:31 +0530456static void __exit tps_65023_cleanup(void)
457{
458 i2c_del_driver(&tps_65023_i2c_driver);
459}
460module_exit(tps_65023_cleanup);
461
462MODULE_AUTHOR("Texas Instruments");
463MODULE_DESCRIPTION("TPS65023 voltage regulator driver");
Liam Girdwood9e108d32009-08-24 10:31:34 +0100464MODULE_LICENSE("GPL v2");