blob: 68d9a7b6e1f73e3fbb395d0e58892a02f19126f3 [file] [log] [blame]
David Brownellfa16a5c2009-02-08 10:37:06 -08001/*
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01002 * twl-regulator.c -- support regulators in twl4030/twl6030 family chips
David Brownellfa16a5c2009-02-08 10:37:06 -08003 *
4 * Copyright (C) 2008 David Brownell
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/err.h>
Juha Keski-Saari53b8a9d2009-12-16 14:55:26 +020015#include <linux/delay.h>
David Brownellfa16a5c2009-02-08 10:37:06 -080016#include <linux/platform_device.h>
Rajendra Nayak2098e952012-02-28 15:09:11 +053017#include <linux/of.h>
18#include <linux/of_device.h>
David Brownellfa16a5c2009-02-08 10:37:06 -080019#include <linux/regulator/driver.h>
20#include <linux/regulator/machine.h>
Rajendra Nayak2098e952012-02-28 15:09:11 +053021#include <linux/regulator/of_regulator.h>
Santosh Shilimkarb07682b2009-12-13 20:05:51 +010022#include <linux/i2c/twl.h>
David Brownellfa16a5c2009-02-08 10:37:06 -080023
24
25/*
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +010026 * The TWL4030/TW5030/TPS659x0/TWL6030 family chips include power management, a
David Brownellfa16a5c2009-02-08 10:37:06 -080027 * USB OTG transceiver, an RTC, ADC, PWM, and lots more. Some versions
28 * include an audio codec, battery charger, and more voltage regulators.
29 * These chips are often used in OMAP-based systems.
30 *
31 * This driver implements software-based resource control for various
32 * voltage regulators. This is usually augmented with state machine
33 * based control.
34 */
35
36struct twlreg_info {
37 /* start of regulator's PM_RECEIVER control register bank */
38 u8 base;
39
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +010040 /* twl resource ID, for resource control state machine */
David Brownellfa16a5c2009-02-08 10:37:06 -080041 u8 id;
42
43 /* voltage in mV = table[VSEL]; table_len must be a power-of-two */
44 u8 table_len;
45 const u16 *table;
46
Juha Keski-Saari045f9722009-12-16 14:49:52 +020047 /* regulator specific turn-on delay */
48 u16 delay;
49
50 /* State REMAP default configuration */
51 u8 remap;
52
David Brownellfa16a5c2009-02-08 10:37:06 -080053 /* chip constraints on regulator behavior */
54 u16 min_mV;
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +053055 u16 max_mV;
David Brownellfa16a5c2009-02-08 10:37:06 -080056
Graeme Gregory4d94aee2011-05-22 21:21:23 +010057 u8 flags;
58
David Brownellfa16a5c2009-02-08 10:37:06 -080059 /* used by regulator core */
60 struct regulator_desc desc;
Graeme Gregory4d94aee2011-05-22 21:21:23 +010061
62 /* chip specific features */
63 unsigned long features;
Tero Kristo63bfff42012-02-16 12:27:52 +020064
65 /*
66 * optional override functions for voltage set/get
67 * these are currently only used for SMPS regulators
68 */
69 int (*get_voltage)(void *data);
70 int (*set_voltage)(void *data, int target_uV);
71
72 /* data passed from board for external get/set voltage */
73 void *data;
David Brownellfa16a5c2009-02-08 10:37:06 -080074};
75
76
77/* LDO control registers ... offset is from the base of its register bank.
78 * The first three registers of all power resource banks help hardware to
79 * manage the various resource groups.
80 */
Rajendra Nayak441a4502009-12-13 22:19:23 +010081/* Common offset in TWL4030/6030 */
David Brownellfa16a5c2009-02-08 10:37:06 -080082#define VREG_GRP 0
Rajendra Nayak441a4502009-12-13 22:19:23 +010083/* TWL4030 register offsets */
David Brownellfa16a5c2009-02-08 10:37:06 -080084#define VREG_TYPE 1
85#define VREG_REMAP 2
86#define VREG_DEDICATED 3 /* LDO control */
Tero Kristoba305e32011-11-28 16:53:19 +020087#define VREG_VOLTAGE_SMPS_4030 9
Rajendra Nayak441a4502009-12-13 22:19:23 +010088/* TWL6030 register offsets */
89#define VREG_TRANS 1
90#define VREG_STATE 2
91#define VREG_VOLTAGE 3
Graeme Gregory4d94aee2011-05-22 21:21:23 +010092#define VREG_VOLTAGE_SMPS 4
Rajendra Nayak441a4502009-12-13 22:19:23 +010093/* TWL6030 Misc register offsets */
94#define VREG_BC_ALL 1
95#define VREG_BC_REF 2
96#define VREG_BC_PROC 3
97#define VREG_BC_CLK_RST 4
David Brownellfa16a5c2009-02-08 10:37:06 -080098
Saquib Herman21657ebf2011-04-01 10:22:42 +053099/* TWL6030 LDO register values for CFG_STATE */
100#define TWL6030_CFG_STATE_OFF 0x00
101#define TWL6030_CFG_STATE_ON 0x01
Saquib Herman9a0244a2011-04-01 10:22:45 +0530102#define TWL6030_CFG_STATE_OFF2 0x02
103#define TWL6030_CFG_STATE_SLEEP 0x03
Saquib Herman21657ebf2011-04-01 10:22:42 +0530104#define TWL6030_CFG_STATE_GRP_SHIFT 5
Saquib Hermanb2456772011-04-01 10:22:44 +0530105#define TWL6030_CFG_STATE_APP_SHIFT 2
106#define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT)
107#define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\
108 TWL6030_CFG_STATE_APP_SHIFT)
Saquib Herman21657ebf2011-04-01 10:22:42 +0530109
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100110/* Flags for SMPS Voltage reading */
111#define SMPS_OFFSET_EN BIT(0)
112#define SMPS_EXTENDED_EN BIT(1)
113
114/* twl6025 SMPS EPROM values */
115#define TWL6030_SMPS_OFFSET 0xB0
116#define TWL6030_SMPS_MULT 0xB3
117#define SMPS_MULTOFFSET_SMPS4 BIT(0)
118#define SMPS_MULTOFFSET_VIO BIT(1)
119#define SMPS_MULTOFFSET_SMPS3 BIT(6)
120
David Brownellfa16a5c2009-02-08 10:37:06 -0800121static inline int
Rajendra Nayak441a4502009-12-13 22:19:23 +0100122twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset)
David Brownellfa16a5c2009-02-08 10:37:06 -0800123{
124 u8 value;
125 int status;
126
Rajendra Nayak441a4502009-12-13 22:19:23 +0100127 status = twl_i2c_read_u8(slave_subgp,
David Brownellfa16a5c2009-02-08 10:37:06 -0800128 &value, info->base + offset);
129 return (status < 0) ? status : value;
130}
131
132static inline int
Rajendra Nayak441a4502009-12-13 22:19:23 +0100133twlreg_write(struct twlreg_info *info, unsigned slave_subgp, unsigned offset,
134 u8 value)
David Brownellfa16a5c2009-02-08 10:37:06 -0800135{
Rajendra Nayak441a4502009-12-13 22:19:23 +0100136 return twl_i2c_write_u8(slave_subgp,
David Brownellfa16a5c2009-02-08 10:37:06 -0800137 value, info->base + offset);
138}
139
140/*----------------------------------------------------------------------*/
141
142/* generic power resource operations, which work on all regulators */
143
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100144static int twlreg_grp(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800145{
Rajendra Nayak441a4502009-12-13 22:19:23 +0100146 return twlreg_read(rdev_get_drvdata(rdev), TWL_MODULE_PM_RECEIVER,
147 VREG_GRP);
David Brownellfa16a5c2009-02-08 10:37:06 -0800148}
149
150/*
151 * Enable/disable regulators by joining/leaving the P1 (processor) group.
152 * We assume nobody else is updating the DEV_GRP registers.
153 */
Rajendra Nayak441a4502009-12-13 22:19:23 +0100154/* definition for 4030 family */
155#define P3_GRP_4030 BIT(7) /* "peripherals" */
156#define P2_GRP_4030 BIT(6) /* secondary processor, modem, etc */
157#define P1_GRP_4030 BIT(5) /* CPU/Linux */
158/* definition for 6030 family */
159#define P3_GRP_6030 BIT(2) /* secondary processor, modem, etc */
160#define P2_GRP_6030 BIT(1) /* "peripherals" */
161#define P1_GRP_6030 BIT(0) /* CPU/Linux */
David Brownellfa16a5c2009-02-08 10:37:06 -0800162
Saquib Hermanb2456772011-04-01 10:22:44 +0530163static int twl4030reg_is_enabled(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800164{
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100165 int state = twlreg_grp(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800166
167 if (state < 0)
168 return state;
169
Saquib Hermanb2456772011-04-01 10:22:44 +0530170 return state & P1_GRP_4030;
171}
172
173static int twl6030reg_is_enabled(struct regulator_dev *rdev)
174{
175 struct twlreg_info *info = rdev_get_drvdata(rdev);
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100176 int grp = 0, val;
Saquib Hermanb2456772011-04-01 10:22:44 +0530177
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100178 if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
179 grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
Saquib Hermanb2456772011-04-01 10:22:44 +0530180 if (grp < 0)
181 return grp;
182
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100183 if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
184 grp &= P1_GRP_6030;
185 else
186 grp = 1;
Saquib Hermanb2456772011-04-01 10:22:44 +0530187
188 val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
189 val = TWL6030_CFG_STATE_APP(val);
190
191 return grp && (val == TWL6030_CFG_STATE_ON);
David Brownellfa16a5c2009-02-08 10:37:06 -0800192}
193
Balaji T Kf8c29402011-05-20 19:03:51 +0530194static int twl4030reg_enable(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800195{
196 struct twlreg_info *info = rdev_get_drvdata(rdev);
197 int grp;
Juha Keski-Saari53b8a9d2009-12-16 14:55:26 +0200198 int ret;
David Brownellfa16a5c2009-02-08 10:37:06 -0800199
Rajendra Nayak441a4502009-12-13 22:19:23 +0100200 grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
David Brownellfa16a5c2009-02-08 10:37:06 -0800201 if (grp < 0)
202 return grp;
203
Balaji T Kf8c29402011-05-20 19:03:51 +0530204 grp |= P1_GRP_4030;
Rajendra Nayak441a4502009-12-13 22:19:23 +0100205
Juha Keski-Saari53b8a9d2009-12-16 14:55:26 +0200206 ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
207
Balaji T Kf8c29402011-05-20 19:03:51 +0530208 udelay(info->delay);
209
210 return ret;
211}
212
213static int twl6030reg_enable(struct regulator_dev *rdev)
214{
215 struct twlreg_info *info = rdev_get_drvdata(rdev);
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100216 int grp = 0;
Balaji T Kf8c29402011-05-20 19:03:51 +0530217 int ret;
218
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100219 if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
220 grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
Balaji T Kf8c29402011-05-20 19:03:51 +0530221 if (grp < 0)
222 return grp;
223
224 ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE,
225 grp << TWL6030_CFG_STATE_GRP_SHIFT |
226 TWL6030_CFG_STATE_ON);
Saquib Herman21657ebf2011-04-01 10:22:42 +0530227
Juha Keski-Saari53b8a9d2009-12-16 14:55:26 +0200228 udelay(info->delay);
229
230 return ret;
David Brownellfa16a5c2009-02-08 10:37:06 -0800231}
232
Balaji T K0ff38972011-05-20 19:03:52 +0530233static int twl4030reg_disable(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800234{
235 struct twlreg_info *info = rdev_get_drvdata(rdev);
236 int grp;
Saquib Herman21657ebf2011-04-01 10:22:42 +0530237 int ret;
David Brownellfa16a5c2009-02-08 10:37:06 -0800238
Rajendra Nayak441a4502009-12-13 22:19:23 +0100239 grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
David Brownellfa16a5c2009-02-08 10:37:06 -0800240 if (grp < 0)
241 return grp;
242
Balaji T K0ff38972011-05-20 19:03:52 +0530243 grp &= ~(P1_GRP_4030 | P2_GRP_4030 | P3_GRP_4030);
Rajendra Nayak441a4502009-12-13 22:19:23 +0100244
Saquib Herman21657ebf2011-04-01 10:22:42 +0530245 ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
246
Balaji T K0ff38972011-05-20 19:03:52 +0530247 return ret;
248}
249
250static int twl6030reg_disable(struct regulator_dev *rdev)
251{
252 struct twlreg_info *info = rdev_get_drvdata(rdev);
253 int grp = 0;
254 int ret;
255
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100256 if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
257 grp = P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030;
Balaji T K0ff38972011-05-20 19:03:52 +0530258
259 /* For 6030, set the off state for all grps enabled */
260 ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE,
261 (grp) << TWL6030_CFG_STATE_GRP_SHIFT |
262 TWL6030_CFG_STATE_OFF);
Saquib Herman21657ebf2011-04-01 10:22:42 +0530263
264 return ret;
David Brownellfa16a5c2009-02-08 10:37:06 -0800265}
266
Saquib Herman9a0244a2011-04-01 10:22:45 +0530267static int twl4030reg_get_status(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800268{
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100269 int state = twlreg_grp(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800270
271 if (state < 0)
272 return state;
273 state &= 0x0f;
274
275 /* assume state != WARM_RESET; we'd not be running... */
276 if (!state)
277 return REGULATOR_STATUS_OFF;
278 return (state & BIT(3))
279 ? REGULATOR_STATUS_NORMAL
280 : REGULATOR_STATUS_STANDBY;
281}
282
Saquib Herman9a0244a2011-04-01 10:22:45 +0530283static int twl6030reg_get_status(struct regulator_dev *rdev)
284{
285 struct twlreg_info *info = rdev_get_drvdata(rdev);
286 int val;
287
288 val = twlreg_grp(rdev);
289 if (val < 0)
290 return val;
291
292 val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
293
294 switch (TWL6030_CFG_STATE_APP(val)) {
295 case TWL6030_CFG_STATE_ON:
296 return REGULATOR_STATUS_NORMAL;
297
298 case TWL6030_CFG_STATE_SLEEP:
299 return REGULATOR_STATUS_STANDBY;
300
301 case TWL6030_CFG_STATE_OFF:
302 case TWL6030_CFG_STATE_OFF2:
303 default:
304 break;
305 }
306
307 return REGULATOR_STATUS_OFF;
308}
309
Saquib Herman1a399622011-04-01 10:22:46 +0530310static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode)
David Brownellfa16a5c2009-02-08 10:37:06 -0800311{
312 struct twlreg_info *info = rdev_get_drvdata(rdev);
313 unsigned message;
314 int status;
315
316 /* We can only set the mode through state machine commands... */
317 switch (mode) {
318 case REGULATOR_MODE_NORMAL:
319 message = MSG_SINGULAR(DEV_GRP_P1, info->id, RES_STATE_ACTIVE);
320 break;
321 case REGULATOR_MODE_STANDBY:
322 message = MSG_SINGULAR(DEV_GRP_P1, info->id, RES_STATE_SLEEP);
323 break;
324 default:
325 return -EINVAL;
326 }
327
328 /* Ensure the resource is associated with some group */
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100329 status = twlreg_grp(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800330 if (status < 0)
331 return status;
Rajendra Nayak441a4502009-12-13 22:19:23 +0100332 if (!(status & (P3_GRP_4030 | P2_GRP_4030 | P1_GRP_4030)))
David Brownellfa16a5c2009-02-08 10:37:06 -0800333 return -EACCES;
334
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100335 status = twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
Axel Linb9e26bc2010-10-22 16:38:22 +0800336 message >> 8, TWL4030_PM_MASTER_PB_WORD_MSB);
337 if (status < 0)
David Brownellfa16a5c2009-02-08 10:37:06 -0800338 return status;
339
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100340 return twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
Axel Linb9e26bc2010-10-22 16:38:22 +0800341 message & 0xff, TWL4030_PM_MASTER_PB_WORD_LSB);
David Brownellfa16a5c2009-02-08 10:37:06 -0800342}
343
Saquib Herman1a399622011-04-01 10:22:46 +0530344static int twl6030reg_set_mode(struct regulator_dev *rdev, unsigned mode)
345{
346 struct twlreg_info *info = rdev_get_drvdata(rdev);
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100347 int grp = 0;
Saquib Herman1a399622011-04-01 10:22:46 +0530348 int val;
349
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100350 if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
351 grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
Saquib Herman1a399622011-04-01 10:22:46 +0530352
353 if (grp < 0)
354 return grp;
355
356 /* Compose the state register settings */
357 val = grp << TWL6030_CFG_STATE_GRP_SHIFT;
358 /* We can only set the mode through state machine commands... */
359 switch (mode) {
360 case REGULATOR_MODE_NORMAL:
361 val |= TWL6030_CFG_STATE_ON;
362 break;
363 case REGULATOR_MODE_STANDBY:
364 val |= TWL6030_CFG_STATE_SLEEP;
365 break;
366
367 default:
368 return -EINVAL;
369 }
370
371 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, val);
372}
373
David Brownellfa16a5c2009-02-08 10:37:06 -0800374/*----------------------------------------------------------------------*/
375
376/*
377 * Support for adjustable-voltage LDOs uses a four bit (or less) voltage
378 * select field in its control register. We use tables indexed by VSEL
379 * to record voltages in milliVolts. (Accuracy is about three percent.)
380 *
381 * Note that VSEL values for VAUX2 changed in twl5030 and newer silicon;
382 * currently handled by listing two slightly different VAUX2 regulators,
383 * only one of which will be configured.
384 *
385 * VSEL values documented as "TI cannot support these values" are flagged
386 * in these tables as UNSUP() values; we normally won't assign them.
Adrian Hunterd6bb69c2009-03-06 14:51:30 +0200387 *
388 * VAUX3 at 3V is incorrectly listed in some TI manuals as unsupported.
389 * TI are revising the twl5030/tps659x0 specs to support that 3.0V setting.
David Brownellfa16a5c2009-02-08 10:37:06 -0800390 */
391#ifdef CONFIG_TWL4030_ALLOW_UNSUPPORTED
392#define UNSUP_MASK 0x0000
393#else
394#define UNSUP_MASK 0x8000
395#endif
396
397#define UNSUP(x) (UNSUP_MASK | (x))
398#define IS_UNSUP(x) (UNSUP_MASK & (x))
399#define LDO_MV(x) (~UNSUP_MASK & (x))
400
401
402static const u16 VAUX1_VSEL_table[] = {
403 UNSUP(1500), UNSUP(1800), 2500, 2800,
404 3000, 3000, 3000, 3000,
405};
406static const u16 VAUX2_4030_VSEL_table[] = {
407 UNSUP(1000), UNSUP(1000), UNSUP(1200), 1300,
408 1500, 1800, UNSUP(1850), 2500,
409 UNSUP(2600), 2800, UNSUP(2850), UNSUP(3000),
410 UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
411};
412static const u16 VAUX2_VSEL_table[] = {
413 1700, 1700, 1900, 1300,
414 1500, 1800, 2000, 2500,
415 2100, 2800, 2200, 2300,
416 2400, 2400, 2400, 2400,
417};
418static const u16 VAUX3_VSEL_table[] = {
419 1500, 1800, 2500, 2800,
Adrian Hunterd6bb69c2009-03-06 14:51:30 +0200420 3000, 3000, 3000, 3000,
David Brownellfa16a5c2009-02-08 10:37:06 -0800421};
422static const u16 VAUX4_VSEL_table[] = {
423 700, 1000, 1200, UNSUP(1300),
424 1500, 1800, UNSUP(1850), 2500,
David Brownell1897e742009-03-10 11:51:15 -0800425 UNSUP(2600), 2800, UNSUP(2850), UNSUP(3000),
426 UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
David Brownellfa16a5c2009-02-08 10:37:06 -0800427};
428static const u16 VMMC1_VSEL_table[] = {
429 1850, 2850, 3000, 3150,
430};
431static const u16 VMMC2_VSEL_table[] = {
432 UNSUP(1000), UNSUP(1000), UNSUP(1200), UNSUP(1300),
433 UNSUP(1500), UNSUP(1800), 1850, UNSUP(2500),
434 2600, 2800, 2850, 3000,
435 3150, 3150, 3150, 3150,
436};
437static const u16 VPLL1_VSEL_table[] = {
438 1000, 1200, 1300, 1800,
439 UNSUP(2800), UNSUP(3000), UNSUP(3000), UNSUP(3000),
440};
441static const u16 VPLL2_VSEL_table[] = {
442 700, 1000, 1200, 1300,
443 UNSUP(1500), 1800, UNSUP(1850), UNSUP(2500),
444 UNSUP(2600), UNSUP(2800), UNSUP(2850), UNSUP(3000),
445 UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
446};
447static const u16 VSIM_VSEL_table[] = {
448 UNSUP(1000), UNSUP(1200), UNSUP(1300), 1800,
449 2800, 3000, 3000, 3000,
450};
451static const u16 VDAC_VSEL_table[] = {
452 1200, 1300, 1800, 1800,
453};
Juha Keski-Saari07fc4932009-12-16 15:27:55 +0200454static const u16 VDD1_VSEL_table[] = {
455 800, 1450,
456};
457static const u16 VDD2_VSEL_table[] = {
458 800, 1450, 1500,
459};
460static const u16 VIO_VSEL_table[] = {
461 1800, 1850,
462};
463static const u16 VINTANA2_VSEL_table[] = {
464 2500, 2750,
465};
David Brownellfa16a5c2009-02-08 10:37:06 -0800466
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530467static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
David Brownell66b659e2009-02-26 11:50:14 -0800468{
469 struct twlreg_info *info = rdev_get_drvdata(rdev);
470 int mV = info->table[index];
471
472 return IS_UNSUP(mV) ? 0 : (LDO_MV(mV) * 1000);
473}
474
David Brownellfa16a5c2009-02-08 10:37:06 -0800475static int
Axel Lindd16b1f2012-03-26 09:30:06 +0800476twl4030ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
David Brownellfa16a5c2009-02-08 10:37:06 -0800477{
478 struct twlreg_info *info = rdev_get_drvdata(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800479
Axel Lindd16b1f2012-03-26 09:30:06 +0800480 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE,
481 selector);
David Brownellfa16a5c2009-02-08 10:37:06 -0800482}
483
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530484static int twl4030ldo_get_voltage(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800485{
486 struct twlreg_info *info = rdev_get_drvdata(rdev);
Rajendra Nayak441a4502009-12-13 22:19:23 +0100487 int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
488 VREG_VOLTAGE);
David Brownellfa16a5c2009-02-08 10:37:06 -0800489
490 if (vsel < 0)
491 return vsel;
492
493 vsel &= info->table_len - 1;
494 return LDO_MV(info->table[vsel]) * 1000;
495}
496
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530497static struct regulator_ops twl4030ldo_ops = {
498 .list_voltage = twl4030ldo_list_voltage,
David Brownell66b659e2009-02-26 11:50:14 -0800499
Axel Lindd16b1f2012-03-26 09:30:06 +0800500 .set_voltage_sel = twl4030ldo_set_voltage_sel,
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530501 .get_voltage = twl4030ldo_get_voltage,
502
Balaji T Kf8c29402011-05-20 19:03:51 +0530503 .enable = twl4030reg_enable,
Balaji T K0ff38972011-05-20 19:03:52 +0530504 .disable = twl4030reg_disable,
Saquib Hermanb2456772011-04-01 10:22:44 +0530505 .is_enabled = twl4030reg_is_enabled,
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530506
Saquib Herman1a399622011-04-01 10:22:46 +0530507 .set_mode = twl4030reg_set_mode,
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530508
Saquib Herman9a0244a2011-04-01 10:22:45 +0530509 .get_status = twl4030reg_get_status,
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530510};
511
Tero Kristoba305e32011-11-28 16:53:19 +0200512static int
513twl4030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
514 unsigned *selector)
515{
516 struct twlreg_info *info = rdev_get_drvdata(rdev);
517 int vsel = DIV_ROUND_UP(min_uV - 600000, 12500);
518
Tero Kristo63bfff42012-02-16 12:27:52 +0200519 if (info->set_voltage) {
520 return info->set_voltage(info->data, min_uV);
521 } else {
522 twlreg_write(info, TWL_MODULE_PM_RECEIVER,
523 VREG_VOLTAGE_SMPS_4030, vsel);
524 }
525
Tero Kristoba305e32011-11-28 16:53:19 +0200526 return 0;
527}
528
529static int twl4030smps_get_voltage(struct regulator_dev *rdev)
530{
531 struct twlreg_info *info = rdev_get_drvdata(rdev);
Tero Kristo63bfff42012-02-16 12:27:52 +0200532 int vsel;
533
534 if (info->get_voltage)
535 return info->get_voltage(info->data);
536
537 vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
Tero Kristoba305e32011-11-28 16:53:19 +0200538 VREG_VOLTAGE_SMPS_4030);
539
540 return vsel * 12500 + 600000;
541}
542
543static struct regulator_ops twl4030smps_ops = {
544 .set_voltage = twl4030smps_set_voltage,
545 .get_voltage = twl4030smps_get_voltage,
546};
547
Tero Kristo34a38442012-02-28 15:09:10 +0530548static int twl6030coresmps_set_voltage(struct regulator_dev *rdev, int min_uV,
549 int max_uV, unsigned *selector)
550{
551 struct twlreg_info *info = rdev_get_drvdata(rdev);
552
553 if (info->set_voltage)
554 return info->set_voltage(info->data, min_uV);
555
556 return -ENODEV;
557}
558
559static int twl6030coresmps_get_voltage(struct regulator_dev *rdev)
560{
561 struct twlreg_info *info = rdev_get_drvdata(rdev);
562
563 if (info->get_voltage)
564 return info->get_voltage(info->data);
565
566 return -ENODEV;
567}
568
569static struct regulator_ops twl6030coresmps_ops = {
570 .set_voltage = twl6030coresmps_set_voltage,
571 .get_voltage = twl6030coresmps_get_voltage,
572};
573
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530574static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
575{
576 struct twlreg_info *info = rdev_get_drvdata(rdev);
577
578 return ((info->min_mV + (index * 100)) * 1000);
579}
580
581static int
Mark Brown3a93f2a2010-11-10 14:38:29 +0000582twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
583 unsigned *selector)
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530584{
585 struct twlreg_info *info = rdev_get_drvdata(rdev);
586 int vsel;
587
588 if ((min_uV/1000 < info->min_mV) || (max_uV/1000 > info->max_mV))
589 return -EDOM;
590
591 /*
592 * Use the below formula to calculate vsel
593 * mV = 1000mv + 100mv * (vsel - 1)
594 */
595 vsel = (min_uV/1000 - 1000)/100 + 1;
Mark Brown3a93f2a2010-11-10 14:38:29 +0000596 *selector = vsel;
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530597 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel);
598
599}
600
601static int twl6030ldo_get_voltage(struct regulator_dev *rdev)
602{
603 struct twlreg_info *info = rdev_get_drvdata(rdev);
604 int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
605 VREG_VOLTAGE);
606
607 if (vsel < 0)
608 return vsel;
609
610 /*
611 * Use the below formula to calculate vsel
612 * mV = 1000mv + 100mv * (vsel - 1)
613 */
614 return (1000 + (100 * (vsel - 1))) * 1000;
615}
616
617static struct regulator_ops twl6030ldo_ops = {
618 .list_voltage = twl6030ldo_list_voltage,
619
620 .set_voltage = twl6030ldo_set_voltage,
621 .get_voltage = twl6030ldo_get_voltage,
David Brownellfa16a5c2009-02-08 10:37:06 -0800622
Balaji T Kf8c29402011-05-20 19:03:51 +0530623 .enable = twl6030reg_enable,
Balaji T K0ff38972011-05-20 19:03:52 +0530624 .disable = twl6030reg_disable,
Saquib Hermanb2456772011-04-01 10:22:44 +0530625 .is_enabled = twl6030reg_is_enabled,
David Brownellfa16a5c2009-02-08 10:37:06 -0800626
Saquib Herman1a399622011-04-01 10:22:46 +0530627 .set_mode = twl6030reg_set_mode,
David Brownellfa16a5c2009-02-08 10:37:06 -0800628
Saquib Herman9a0244a2011-04-01 10:22:45 +0530629 .get_status = twl6030reg_get_status,
David Brownellfa16a5c2009-02-08 10:37:06 -0800630};
631
632/*----------------------------------------------------------------------*/
633
634/*
635 * Fixed voltage LDOs don't have a VSEL field to update.
636 */
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100637static int twlfixed_list_voltage(struct regulator_dev *rdev, unsigned index)
David Brownell66b659e2009-02-26 11:50:14 -0800638{
639 struct twlreg_info *info = rdev_get_drvdata(rdev);
640
641 return info->min_mV * 1000;
642}
643
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100644static int twlfixed_get_voltage(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800645{
646 struct twlreg_info *info = rdev_get_drvdata(rdev);
647
648 return info->min_mV * 1000;
649}
650
Saquib Hermanb2456772011-04-01 10:22:44 +0530651static struct regulator_ops twl4030fixed_ops = {
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100652 .list_voltage = twlfixed_list_voltage,
David Brownell66b659e2009-02-26 11:50:14 -0800653
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100654 .get_voltage = twlfixed_get_voltage,
David Brownellfa16a5c2009-02-08 10:37:06 -0800655
Balaji T Kf8c29402011-05-20 19:03:51 +0530656 .enable = twl4030reg_enable,
Balaji T K0ff38972011-05-20 19:03:52 +0530657 .disable = twl4030reg_disable,
Saquib Hermanb2456772011-04-01 10:22:44 +0530658 .is_enabled = twl4030reg_is_enabled,
659
Saquib Herman1a399622011-04-01 10:22:46 +0530660 .set_mode = twl4030reg_set_mode,
Saquib Hermanb2456772011-04-01 10:22:44 +0530661
Saquib Herman9a0244a2011-04-01 10:22:45 +0530662 .get_status = twl4030reg_get_status,
Saquib Hermanb2456772011-04-01 10:22:44 +0530663};
664
665static struct regulator_ops twl6030fixed_ops = {
666 .list_voltage = twlfixed_list_voltage,
667
668 .get_voltage = twlfixed_get_voltage,
669
Balaji T Kf8c29402011-05-20 19:03:51 +0530670 .enable = twl6030reg_enable,
Balaji T K0ff38972011-05-20 19:03:52 +0530671 .disable = twl6030reg_disable,
Saquib Hermanb2456772011-04-01 10:22:44 +0530672 .is_enabled = twl6030reg_is_enabled,
David Brownellfa16a5c2009-02-08 10:37:06 -0800673
Saquib Herman1a399622011-04-01 10:22:46 +0530674 .set_mode = twl6030reg_set_mode,
David Brownellfa16a5c2009-02-08 10:37:06 -0800675
Saquib Herman9a0244a2011-04-01 10:22:45 +0530676 .get_status = twl6030reg_get_status,
David Brownellfa16a5c2009-02-08 10:37:06 -0800677};
678
Balaji T K8e6de4a2011-02-10 18:44:50 +0530679static struct regulator_ops twl6030_fixed_resource = {
Balaji T Kf8c29402011-05-20 19:03:51 +0530680 .enable = twl6030reg_enable,
Balaji T K0ff38972011-05-20 19:03:52 +0530681 .disable = twl6030reg_disable,
Saquib Hermanb2456772011-04-01 10:22:44 +0530682 .is_enabled = twl6030reg_is_enabled,
Saquib Herman9a0244a2011-04-01 10:22:45 +0530683 .get_status = twl6030reg_get_status,
Balaji T K8e6de4a2011-02-10 18:44:50 +0530684};
685
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100686/*
687 * SMPS status and control
688 */
689
690static int twl6030smps_list_voltage(struct regulator_dev *rdev, unsigned index)
691{
692 struct twlreg_info *info = rdev_get_drvdata(rdev);
693
694 int voltage = 0;
695
696 switch (info->flags) {
697 case SMPS_OFFSET_EN:
698 voltage = 100000;
699 /* fall through */
700 case 0:
701 switch (index) {
702 case 0:
703 voltage = 0;
704 break;
705 case 58:
706 voltage = 1350 * 1000;
707 break;
708 case 59:
709 voltage = 1500 * 1000;
710 break;
711 case 60:
712 voltage = 1800 * 1000;
713 break;
714 case 61:
715 voltage = 1900 * 1000;
716 break;
717 case 62:
718 voltage = 2100 * 1000;
719 break;
720 default:
721 voltage += (600000 + (12500 * (index - 1)));
722 }
723 break;
724 case SMPS_EXTENDED_EN:
725 switch (index) {
726 case 0:
727 voltage = 0;
728 break;
729 case 58:
730 voltage = 2084 * 1000;
731 break;
732 case 59:
733 voltage = 2315 * 1000;
734 break;
735 case 60:
736 voltage = 2778 * 1000;
737 break;
738 case 61:
739 voltage = 2932 * 1000;
740 break;
741 case 62:
742 voltage = 3241 * 1000;
743 break;
744 default:
745 voltage = (1852000 + (38600 * (index - 1)));
746 }
747 break;
748 case SMPS_OFFSET_EN | SMPS_EXTENDED_EN:
749 switch (index) {
750 case 0:
751 voltage = 0;
752 break;
753 case 58:
754 voltage = 4167 * 1000;
755 break;
756 case 59:
757 voltage = 2315 * 1000;
758 break;
759 case 60:
760 voltage = 2778 * 1000;
761 break;
762 case 61:
763 voltage = 2932 * 1000;
764 break;
765 case 62:
766 voltage = 3241 * 1000;
767 break;
768 default:
769 voltage = (2161000 + (38600 * (index - 1)));
770 }
771 break;
772 }
773
774 return voltage;
775}
776
777static int
778twl6030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
779 unsigned int *selector)
780{
781 struct twlreg_info *info = rdev_get_drvdata(rdev);
782 int vsel = 0;
783
784 switch (info->flags) {
785 case 0:
786 if (min_uV == 0)
787 vsel = 0;
Laxman Dewangana33b6e52012-02-03 12:54:38 +0530788 else if ((min_uV >= 600000) && (min_uV <= 1300000)) {
789 int calc_uV;
Axel Lin268a1642012-04-09 23:35:10 +0800790 vsel = DIV_ROUND_UP(min_uV - 600000, 12500);
Axel Lin0cb2f122012-04-10 23:07:52 +0800791 vsel++;
Laxman Dewangana33b6e52012-02-03 12:54:38 +0530792 calc_uV = twl6030smps_list_voltage(rdev, vsel);
793 if (calc_uV > max_uV)
794 return -EINVAL;
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100795 }
796 /* Values 1..57 for vsel are linear and can be calculated
797 * values 58..62 are non linear.
798 */
799 else if ((min_uV > 1900000) && (max_uV >= 2100000))
800 vsel = 62;
801 else if ((min_uV > 1800000) && (max_uV >= 1900000))
802 vsel = 61;
803 else if ((min_uV > 1500000) && (max_uV >= 1800000))
804 vsel = 60;
805 else if ((min_uV > 1350000) && (max_uV >= 1500000))
806 vsel = 59;
807 else if ((min_uV > 1300000) && (max_uV >= 1350000))
808 vsel = 58;
809 else
810 return -EINVAL;
811 break;
812 case SMPS_OFFSET_EN:
813 if (min_uV == 0)
814 vsel = 0;
Laxman Dewangana33b6e52012-02-03 12:54:38 +0530815 else if ((min_uV >= 700000) && (min_uV <= 1420000)) {
816 int calc_uV;
Axel Lin268a1642012-04-09 23:35:10 +0800817 vsel = DIV_ROUND_UP(min_uV - 700000, 12500);
Axel Lin0cb2f122012-04-10 23:07:52 +0800818 vsel++;
Laxman Dewangana33b6e52012-02-03 12:54:38 +0530819 calc_uV = twl6030smps_list_voltage(rdev, vsel);
820 if (calc_uV > max_uV)
821 return -EINVAL;
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100822 }
823 /* Values 1..57 for vsel are linear and can be calculated
824 * values 58..62 are non linear.
825 */
826 else if ((min_uV > 1900000) && (max_uV >= 2100000))
827 vsel = 62;
828 else if ((min_uV > 1800000) && (max_uV >= 1900000))
829 vsel = 61;
830 else if ((min_uV > 1350000) && (max_uV >= 1800000))
831 vsel = 60;
832 else if ((min_uV > 1350000) && (max_uV >= 1500000))
833 vsel = 59;
834 else if ((min_uV > 1300000) && (max_uV >= 1350000))
835 vsel = 58;
836 else
837 return -EINVAL;
838 break;
839 case SMPS_EXTENDED_EN:
Axel Lin0cb2f122012-04-10 23:07:52 +0800840 if (min_uV == 0) {
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100841 vsel = 0;
Axel Lin0cb2f122012-04-10 23:07:52 +0800842 } else if ((min_uV >= 1852000) && (max_uV <= 4013600)) {
Axel Lin268a1642012-04-09 23:35:10 +0800843 vsel = DIV_ROUND_UP(min_uV - 1852000, 38600);
Axel Lin0cb2f122012-04-10 23:07:52 +0800844 vsel++;
845 }
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100846 break;
847 case SMPS_OFFSET_EN|SMPS_EXTENDED_EN:
Axel Lin0cb2f122012-04-10 23:07:52 +0800848 if (min_uV == 0) {
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100849 vsel = 0;
Axel Lin0cb2f122012-04-10 23:07:52 +0800850 } else if ((min_uV >= 2161000) && (max_uV <= 4321000)) {
Axel Lin268a1642012-04-09 23:35:10 +0800851 vsel = DIV_ROUND_UP(min_uV - 2161000, 38600);
Axel Lin0cb2f122012-04-10 23:07:52 +0800852 vsel++;
853 }
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100854 break;
855 }
856
857 *selector = vsel;
858
859 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS,
860 vsel);
861}
862
863static int twl6030smps_get_voltage_sel(struct regulator_dev *rdev)
864{
865 struct twlreg_info *info = rdev_get_drvdata(rdev);
866
867 return twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS);
868}
869
870static struct regulator_ops twlsmps_ops = {
871 .list_voltage = twl6030smps_list_voltage,
872
873 .set_voltage = twl6030smps_set_voltage,
874 .get_voltage_sel = twl6030smps_get_voltage_sel,
875
876 .enable = twl6030reg_enable,
877 .disable = twl6030reg_disable,
878 .is_enabled = twl6030reg_is_enabled,
879
880 .set_mode = twl6030reg_set_mode,
881
882 .get_status = twl6030reg_get_status,
883};
884
David Brownellfa16a5c2009-02-08 10:37:06 -0800885/*----------------------------------------------------------------------*/
886
Juha Keski-Saari045f9722009-12-16 14:49:52 +0200887#define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
888 remap_conf) \
889 TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
Saquib Hermanb2456772011-04-01 10:22:44 +0530890 remap_conf, TWL4030, twl4030fixed_ops)
Ambresh Kaf8b2442011-07-09 19:02:21 -0700891#define TWL6030_FIXED_LDO(label, offset, mVolts, turnon_delay) \
892 TWL_FIXED_LDO(label, offset, mVolts, 0x0, turnon_delay, \
Saquib Hermanb2456772011-04-01 10:22:44 +0530893 0x0, TWL6030, twl6030fixed_ops)
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100894
Rajendra Nayak2098e952012-02-28 15:09:11 +0530895#define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) \
896static struct twlreg_info TWL4030_INFO_##label = { \
David Brownellfa16a5c2009-02-08 10:37:06 -0800897 .base = offset, \
898 .id = num, \
899 .table_len = ARRAY_SIZE(label##_VSEL_table), \
900 .table = label##_VSEL_table, \
Juha Keski-Saari045f9722009-12-16 14:49:52 +0200901 .delay = turnon_delay, \
902 .remap = remap_conf, \
David Brownellfa16a5c2009-02-08 10:37:06 -0800903 .desc = { \
904 .name = #label, \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530905 .id = TWL4030_REG_##label, \
David Brownell66b659e2009-02-26 11:50:14 -0800906 .n_voltages = ARRAY_SIZE(label##_VSEL_table), \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530907 .ops = &twl4030ldo_ops, \
David Brownellfa16a5c2009-02-08 10:37:06 -0800908 .type = REGULATOR_VOLTAGE, \
909 .owner = THIS_MODULE, \
910 }, \
911 }
912
Tero Kristoba305e32011-11-28 16:53:19 +0200913#define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf) \
Rajendra Nayak2098e952012-02-28 15:09:11 +0530914static struct twlreg_info TWL4030_INFO_##label = { \
Tero Kristoba305e32011-11-28 16:53:19 +0200915 .base = offset, \
916 .id = num, \
917 .delay = turnon_delay, \
918 .remap = remap_conf, \
919 .desc = { \
920 .name = #label, \
921 .id = TWL4030_REG_##label, \
922 .ops = &twl4030smps_ops, \
923 .type = REGULATOR_VOLTAGE, \
924 .owner = THIS_MODULE, \
925 }, \
926 }
927
Rajendra Nayak2098e952012-02-28 15:09:11 +0530928#define TWL6030_ADJUSTABLE_SMPS(label) \
929static struct twlreg_info TWL6030_INFO_##label = { \
Tero Kristo34a38442012-02-28 15:09:10 +0530930 .desc = { \
931 .name = #label, \
932 .id = TWL6030_REG_##label, \
933 .ops = &twl6030coresmps_ops, \
934 .type = REGULATOR_VOLTAGE, \
935 .owner = THIS_MODULE, \
936 }, \
937 }
938
Rajendra Nayak2098e952012-02-28 15:09:11 +0530939#define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \
940static struct twlreg_info TWL6030_INFO_##label = { \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530941 .base = offset, \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530942 .min_mV = min_mVolts, \
943 .max_mV = max_mVolts, \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530944 .desc = { \
945 .name = #label, \
946 .id = TWL6030_REG_##label, \
Colin Cross7736f112011-05-27 12:25:27 -0700947 .n_voltages = (max_mVolts - min_mVolts)/100 + 1, \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530948 .ops = &twl6030ldo_ops, \
949 .type = REGULATOR_VOLTAGE, \
950 .owner = THIS_MODULE, \
951 }, \
952 }
953
Rajendra Nayak2098e952012-02-28 15:09:11 +0530954#define TWL6025_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \
955static struct twlreg_info TWL6025_INFO_##label = { \
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100956 .base = offset, \
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100957 .min_mV = min_mVolts, \
958 .max_mV = max_mVolts, \
959 .desc = { \
960 .name = #label, \
961 .id = TWL6025_REG_##label, \
962 .n_voltages = ((max_mVolts - min_mVolts)/100) + 1, \
963 .ops = &twl6030ldo_ops, \
964 .type = REGULATOR_VOLTAGE, \
965 .owner = THIS_MODULE, \
966 }, \
967 }
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530968
Juha Keski-Saari045f9722009-12-16 14:49:52 +0200969#define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \
Rajendra Nayak2098e952012-02-28 15:09:11 +0530970 family, operations) \
971static struct twlreg_info TWLFIXED_INFO_##label = { \
David Brownellfa16a5c2009-02-08 10:37:06 -0800972 .base = offset, \
973 .id = num, \
974 .min_mV = mVolts, \
Juha Keski-Saari045f9722009-12-16 14:49:52 +0200975 .delay = turnon_delay, \
976 .remap = remap_conf, \
David Brownellfa16a5c2009-02-08 10:37:06 -0800977 .desc = { \
978 .name = #label, \
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100979 .id = family##_REG_##label, \
David Brownell66b659e2009-02-26 11:50:14 -0800980 .n_voltages = 1, \
Saquib Hermanb2456772011-04-01 10:22:44 +0530981 .ops = &operations, \
David Brownellfa16a5c2009-02-08 10:37:06 -0800982 .type = REGULATOR_VOLTAGE, \
983 .owner = THIS_MODULE, \
984 }, \
985 }
986
Rajendra Nayak2098e952012-02-28 15:09:11 +0530987#define TWL6030_FIXED_RESOURCE(label, offset, turnon_delay) \
988static struct twlreg_info TWLRES_INFO_##label = { \
Balaji T K8e6de4a2011-02-10 18:44:50 +0530989 .base = offset, \
Balaji T K8e6de4a2011-02-10 18:44:50 +0530990 .delay = turnon_delay, \
Balaji T K8e6de4a2011-02-10 18:44:50 +0530991 .desc = { \
992 .name = #label, \
993 .id = TWL6030_REG_##label, \
994 .ops = &twl6030_fixed_resource, \
995 .type = REGULATOR_VOLTAGE, \
996 .owner = THIS_MODULE, \
997 }, \
998 }
999
Rajendra Nayak2098e952012-02-28 15:09:11 +05301000#define TWL6025_ADJUSTABLE_SMPS(label, offset) \
1001static struct twlreg_info TWLSMPS_INFO_##label = { \
Graeme Gregory4d94aee2011-05-22 21:21:23 +01001002 .base = offset, \
Graeme Gregory4d94aee2011-05-22 21:21:23 +01001003 .min_mV = 600, \
1004 .max_mV = 2100, \
1005 .desc = { \
1006 .name = #label, \
1007 .id = TWL6025_REG_##label, \
1008 .n_voltages = 63, \
1009 .ops = &twlsmps_ops, \
1010 .type = REGULATOR_VOLTAGE, \
1011 .owner = THIS_MODULE, \
1012 }, \
1013 }
1014
David Brownellfa16a5c2009-02-08 10:37:06 -08001015/*
1016 * We list regulators here if systems need some level of
1017 * software control over them after boot.
1018 */
Rajendra Nayak2098e952012-02-28 15:09:11 +05301019TWL4030_ADJUSTABLE_LDO(VAUX1, 0x17, 1, 100, 0x08);
1020TWL4030_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2, 100, 0x08);
1021TWL4030_ADJUSTABLE_LDO(VAUX2, 0x1b, 2, 100, 0x08);
1022TWL4030_ADJUSTABLE_LDO(VAUX3, 0x1f, 3, 100, 0x08);
1023TWL4030_ADJUSTABLE_LDO(VAUX4, 0x23, 4, 100, 0x08);
1024TWL4030_ADJUSTABLE_LDO(VMMC1, 0x27, 5, 100, 0x08);
1025TWL4030_ADJUSTABLE_LDO(VMMC2, 0x2b, 6, 100, 0x08);
1026TWL4030_ADJUSTABLE_LDO(VPLL1, 0x2f, 7, 100, 0x00);
1027TWL4030_ADJUSTABLE_LDO(VPLL2, 0x33, 8, 100, 0x08);
1028TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9, 100, 0x00);
1029TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10, 100, 0x08);
1030TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08);
1031TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08);
1032TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08);
1033TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08);
1034/* VUSBCP is managed *only* by the USB subchip */
1035/* 6030 REG with base as PMC Slave Misc : 0x0030 */
1036/* Turnon-delay and remap configuration values for 6030 are not
1037 verified since the specification is not public */
1038TWL6030_ADJUSTABLE_SMPS(VDD1);
1039TWL6030_ADJUSTABLE_SMPS(VDD2);
1040TWL6030_ADJUSTABLE_SMPS(VDD3);
1041TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300);
1042TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300);
1043TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300);
1044TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300);
1045TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300);
1046TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300);
1047/* 6025 are renamed compared to 6030 versions */
1048TWL6025_ADJUSTABLE_LDO(LDO2, 0x54, 1000, 3300);
1049TWL6025_ADJUSTABLE_LDO(LDO4, 0x58, 1000, 3300);
1050TWL6025_ADJUSTABLE_LDO(LDO3, 0x5c, 1000, 3300);
1051TWL6025_ADJUSTABLE_LDO(LDO5, 0x68, 1000, 3300);
1052TWL6025_ADJUSTABLE_LDO(LDO1, 0x6c, 1000, 3300);
1053TWL6025_ADJUSTABLE_LDO(LDO7, 0x74, 1000, 3300);
1054TWL6025_ADJUSTABLE_LDO(LDO6, 0x60, 1000, 3300);
1055TWL6025_ADJUSTABLE_LDO(LDOLN, 0x64, 1000, 3300);
1056TWL6025_ADJUSTABLE_LDO(LDOUSB, 0x70, 1000, 3300);
1057TWL4030_FIXED_LDO(VINTANA2, 0x3f, 1500, 11, 100, 0x08);
1058TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08);
1059TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08);
1060TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08);
1061TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08);
1062TWL6030_FIXED_LDO(VANA, 0x50, 2100, 0);
1063TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 0);
1064TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 0);
1065TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 0);
Peter Ujfalusie9d47fa2012-02-28 15:09:12 +05301066TWL6030_FIXED_LDO(V1V8, 0x16, 1800, 0);
1067TWL6030_FIXED_LDO(V2V1, 0x1c, 2100, 0);
Rajendra Nayak2098e952012-02-28 15:09:11 +05301068TWL6030_FIXED_RESOURCE(CLK32KG, 0x8C, 0);
1069TWL6025_ADJUSTABLE_SMPS(SMPS3, 0x34);
1070TWL6025_ADJUSTABLE_SMPS(SMPS4, 0x10);
1071TWL6025_ADJUSTABLE_SMPS(VIO, 0x16);
David Brownellfa16a5c2009-02-08 10:37:06 -08001072
Graeme Gregory4d94aee2011-05-22 21:21:23 +01001073static u8 twl_get_smps_offset(void)
1074{
1075 u8 value;
1076
1077 twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value,
1078 TWL6030_SMPS_OFFSET);
1079 return value;
1080}
1081
1082static u8 twl_get_smps_mult(void)
1083{
1084 u8 value;
1085
1086 twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value,
1087 TWL6030_SMPS_MULT);
1088 return value;
1089}
1090
Rajendra Nayak2098e952012-02-28 15:09:11 +05301091#define TWL_OF_MATCH(comp, family, label) \
1092 { \
1093 .compatible = comp, \
1094 .data = &family##_INFO_##label, \
1095 }
1096
1097#define TWL4030_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL4030, label)
1098#define TWL6030_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6030, label)
1099#define TWL6025_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6025, label)
1100#define TWLFIXED_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLFIXED, label)
1101#define TWLRES_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLRES, label)
1102#define TWLSMPS_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLSMPS, label)
1103
1104static const struct of_device_id twl_of_match[] __devinitconst = {
1105 TWL4030_OF_MATCH("ti,twl4030-vaux1", VAUX1),
1106 TWL4030_OF_MATCH("ti,twl4030-vaux2", VAUX2_4030),
1107 TWL4030_OF_MATCH("ti,twl5030-vaux2", VAUX2),
1108 TWL4030_OF_MATCH("ti,twl4030-vaux3", VAUX3),
1109 TWL4030_OF_MATCH("ti,twl4030-vaux4", VAUX4),
1110 TWL4030_OF_MATCH("ti,twl4030-vmmc1", VMMC1),
1111 TWL4030_OF_MATCH("ti,twl4030-vmmc2", VMMC2),
1112 TWL4030_OF_MATCH("ti,twl4030-vpll1", VPLL1),
1113 TWL4030_OF_MATCH("ti,twl4030-vpll2", VPLL2),
1114 TWL4030_OF_MATCH("ti,twl4030-vsim", VSIM),
1115 TWL4030_OF_MATCH("ti,twl4030-vdac", VDAC),
1116 TWL4030_OF_MATCH("ti,twl4030-vintana2", VINTANA2),
1117 TWL4030_OF_MATCH("ti,twl4030-vio", VIO),
1118 TWL4030_OF_MATCH("ti,twl4030-vdd1", VDD1),
1119 TWL4030_OF_MATCH("ti,twl4030-vdd2", VDD2),
1120 TWL6030_OF_MATCH("ti,twl6030-vdd1", VDD1),
1121 TWL6030_OF_MATCH("ti,twl6030-vdd2", VDD2),
1122 TWL6030_OF_MATCH("ti,twl6030-vdd3", VDD3),
1123 TWL6030_OF_MATCH("ti,twl6030-vaux1", VAUX1_6030),
1124 TWL6030_OF_MATCH("ti,twl6030-vaux2", VAUX2_6030),
1125 TWL6030_OF_MATCH("ti,twl6030-vaux3", VAUX3_6030),
1126 TWL6030_OF_MATCH("ti,twl6030-vmmc", VMMC),
1127 TWL6030_OF_MATCH("ti,twl6030-vpp", VPP),
1128 TWL6030_OF_MATCH("ti,twl6030-vusim", VUSIM),
1129 TWL6025_OF_MATCH("ti,twl6025-ldo2", LDO2),
1130 TWL6025_OF_MATCH("ti,twl6025-ldo4", LDO4),
1131 TWL6025_OF_MATCH("ti,twl6025-ldo3", LDO3),
1132 TWL6025_OF_MATCH("ti,twl6025-ldo5", LDO5),
1133 TWL6025_OF_MATCH("ti,twl6025-ldo1", LDO1),
1134 TWL6025_OF_MATCH("ti,twl6025-ldo7", LDO7),
1135 TWL6025_OF_MATCH("ti,twl6025-ldo6", LDO6),
1136 TWL6025_OF_MATCH("ti,twl6025-ldoln", LDOLN),
1137 TWL6025_OF_MATCH("ti,twl6025-ldousb", LDOUSB),
1138 TWLFIXED_OF_MATCH("ti,twl4030-vintana2", VINTANA2),
1139 TWLFIXED_OF_MATCH("ti,twl4030-vintdig", VINTDIG),
1140 TWLFIXED_OF_MATCH("ti,twl4030-vusb1v5", VUSB1V5),
1141 TWLFIXED_OF_MATCH("ti,twl4030-vusb1v8", VUSB1V8),
1142 TWLFIXED_OF_MATCH("ti,twl4030-vusb3v1", VUSB3V1),
1143 TWLFIXED_OF_MATCH("ti,twl6030-vana", VANA),
1144 TWLFIXED_OF_MATCH("ti,twl6030-vcxio", VCXIO),
1145 TWLFIXED_OF_MATCH("ti,twl6030-vdac", VDAC),
1146 TWLFIXED_OF_MATCH("ti,twl6030-vusb", VUSB),
Peter Ujfalusie9d47fa2012-02-28 15:09:12 +05301147 TWLFIXED_OF_MATCH("ti,twl6030-v1v8", V1V8),
1148 TWLFIXED_OF_MATCH("ti,twl6030-v2v1", V2V1),
Rajendra Nayak2098e952012-02-28 15:09:11 +05301149 TWLRES_OF_MATCH("ti,twl6030-clk32kg", CLK32KG),
1150 TWLSMPS_OF_MATCH("ti,twl6025-smps3", SMPS3),
1151 TWLSMPS_OF_MATCH("ti,twl6025-smps4", SMPS4),
1152 TWLSMPS_OF_MATCH("ti,twl6025-vio", VIO),
1153 {},
1154};
1155MODULE_DEVICE_TABLE(of, twl_of_match);
1156
Dmitry Torokhov24c29022010-02-23 23:38:01 -08001157static int __devinit twlreg_probe(struct platform_device *pdev)
David Brownellfa16a5c2009-02-08 10:37:06 -08001158{
Rajendra Nayak2098e952012-02-28 15:09:11 +05301159 int i, id;
David Brownellfa16a5c2009-02-08 10:37:06 -08001160 struct twlreg_info *info;
1161 struct regulator_init_data *initdata;
1162 struct regulation_constraints *c;
1163 struct regulator_dev *rdev;
Tero Kristo63bfff42012-02-16 12:27:52 +02001164 struct twl_regulator_driver_data *drvdata;
Rajendra Nayak2098e952012-02-28 15:09:11 +05301165 const struct of_device_id *match;
Mark Brownc1727082012-04-04 00:50:22 +01001166 struct regulator_config config = { };
David Brownellfa16a5c2009-02-08 10:37:06 -08001167
Rajendra Nayak2098e952012-02-28 15:09:11 +05301168 match = of_match_device(twl_of_match, &pdev->dev);
1169 if (match) {
1170 info = match->data;
1171 id = info->desc.id;
1172 initdata = of_get_regulator_init_data(&pdev->dev,
1173 pdev->dev.of_node);
1174 drvdata = NULL;
1175 } else {
1176 id = pdev->id;
1177 initdata = pdev->dev.platform_data;
1178 for (i = 0, info = NULL; i < ARRAY_SIZE(twl_of_match); i++) {
1179 info = twl_of_match[i].data;
Axel Lin5ade3932012-04-09 22:32:49 +08001180 if (info && info->desc.id == id)
1181 break;
Rajendra Nayak2098e952012-02-28 15:09:11 +05301182 }
Axel Lin5ade3932012-04-09 22:32:49 +08001183 if (i == ARRAY_SIZE(twl_of_match))
1184 return -ENODEV;
1185
Rajendra Nayak2098e952012-02-28 15:09:11 +05301186 drvdata = initdata->driver_data;
1187 if (!drvdata)
1188 return -EINVAL;
David Brownellfa16a5c2009-02-08 10:37:06 -08001189 }
Rajendra Nayak2098e952012-02-28 15:09:11 +05301190
David Brownellfa16a5c2009-02-08 10:37:06 -08001191 if (!info)
1192 return -ENODEV;
1193
David Brownellfa16a5c2009-02-08 10:37:06 -08001194 if (!initdata)
1195 return -EINVAL;
1196
Rajendra Nayak2098e952012-02-28 15:09:11 +05301197 if (drvdata) {
1198 /* copy the driver data into regulator data */
1199 info->features = drvdata->features;
1200 info->data = drvdata->data;
1201 info->set_voltage = drvdata->set_voltage;
1202 info->get_voltage = drvdata->get_voltage;
1203 }
Graeme Gregory4d94aee2011-05-22 21:21:23 +01001204
David Brownellfa16a5c2009-02-08 10:37:06 -08001205 /* Constrain board-specific capabilities according to what
1206 * this driver and the chip itself can actually do.
1207 */
1208 c = &initdata->constraints;
David Brownellfa16a5c2009-02-08 10:37:06 -08001209 c->valid_modes_mask &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_STANDBY;
1210 c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE
1211 | REGULATOR_CHANGE_MODE
1212 | REGULATOR_CHANGE_STATUS;
Rajendra Nayak2098e952012-02-28 15:09:11 +05301213 switch (id) {
Juha Keski-Saari205e5cd2009-12-16 15:27:56 +02001214 case TWL4030_REG_VIO:
1215 case TWL4030_REG_VDD1:
1216 case TWL4030_REG_VDD2:
1217 case TWL4030_REG_VPLL1:
1218 case TWL4030_REG_VINTANA1:
1219 case TWL4030_REG_VINTANA2:
1220 case TWL4030_REG_VINTDIG:
1221 c->always_on = true;
1222 break;
1223 default:
1224 break;
1225 }
David Brownellfa16a5c2009-02-08 10:37:06 -08001226
Rajendra Nayak2098e952012-02-28 15:09:11 +05301227 switch (id) {
Graeme Gregory4d94aee2011-05-22 21:21:23 +01001228 case TWL6025_REG_SMPS3:
1229 if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS3)
1230 info->flags |= SMPS_EXTENDED_EN;
1231 if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS3)
1232 info->flags |= SMPS_OFFSET_EN;
1233 break;
1234 case TWL6025_REG_SMPS4:
1235 if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS4)
1236 info->flags |= SMPS_EXTENDED_EN;
1237 if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS4)
1238 info->flags |= SMPS_OFFSET_EN;
1239 break;
1240 case TWL6025_REG_VIO:
1241 if (twl_get_smps_mult() & SMPS_MULTOFFSET_VIO)
1242 info->flags |= SMPS_EXTENDED_EN;
1243 if (twl_get_smps_offset() & SMPS_MULTOFFSET_VIO)
1244 info->flags |= SMPS_OFFSET_EN;
1245 break;
1246 }
1247
Mark Brownc1727082012-04-04 00:50:22 +01001248 config.dev = &pdev->dev;
1249 config.init_data = initdata;
1250 config.driver_data = info;
1251 config.of_node = pdev->dev.of_node;
1252
1253 rdev = regulator_register(&info->desc, &config);
David Brownellfa16a5c2009-02-08 10:37:06 -08001254 if (IS_ERR(rdev)) {
1255 dev_err(&pdev->dev, "can't register %s, %ld\n",
1256 info->desc.name, PTR_ERR(rdev));
1257 return PTR_ERR(rdev);
1258 }
1259 platform_set_drvdata(pdev, rdev);
1260
Saquib Herman776dc922011-04-01 10:22:43 +05301261 if (twl_class_is_4030())
1262 twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP,
Juha Keski-Saari30010fa2009-12-16 15:27:58 +02001263 info->remap);
1264
David Brownellfa16a5c2009-02-08 10:37:06 -08001265 /* NOTE: many regulators support short-circuit IRQs (presentable
1266 * as REGULATOR_OVER_CURRENT notifications?) configured via:
1267 * - SC_CONFIG
1268 * - SC_DETECT1 (vintana2, vmmc1/2, vaux1/2/3/4)
1269 * - SC_DETECT2 (vusb, vdac, vio, vdd1/2, vpll2)
1270 * - IT_CONFIG
1271 */
1272
1273 return 0;
1274}
1275
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001276static int __devexit twlreg_remove(struct platform_device *pdev)
David Brownellfa16a5c2009-02-08 10:37:06 -08001277{
1278 regulator_unregister(platform_get_drvdata(pdev));
1279 return 0;
1280}
1281
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001282MODULE_ALIAS("platform:twl_reg");
David Brownellfa16a5c2009-02-08 10:37:06 -08001283
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001284static struct platform_driver twlreg_driver = {
1285 .probe = twlreg_probe,
1286 .remove = __devexit_p(twlreg_remove),
David Brownellfa16a5c2009-02-08 10:37:06 -08001287 /* NOTE: short name, to work around driver model truncation of
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001288 * "twl_regulator.12" (and friends) to "twl_regulator.1".
David Brownellfa16a5c2009-02-08 10:37:06 -08001289 */
Rajendra Nayak2098e952012-02-28 15:09:11 +05301290 .driver = {
1291 .name = "twl_reg",
1292 .owner = THIS_MODULE,
1293 .of_match_table = of_match_ptr(twl_of_match),
1294 },
David Brownellfa16a5c2009-02-08 10:37:06 -08001295};
1296
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001297static int __init twlreg_init(void)
David Brownellfa16a5c2009-02-08 10:37:06 -08001298{
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001299 return platform_driver_register(&twlreg_driver);
David Brownellfa16a5c2009-02-08 10:37:06 -08001300}
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001301subsys_initcall(twlreg_init);
David Brownellfa16a5c2009-02-08 10:37:06 -08001302
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001303static void __exit twlreg_exit(void)
David Brownellfa16a5c2009-02-08 10:37:06 -08001304{
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001305 platform_driver_unregister(&twlreg_driver);
David Brownellfa16a5c2009-02-08 10:37:06 -08001306}
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001307module_exit(twlreg_exit)
David Brownellfa16a5c2009-02-08 10:37:06 -08001308
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001309MODULE_DESCRIPTION("TWL regulator driver");
David Brownellfa16a5c2009-02-08 10:37:06 -08001310MODULE_LICENSE("GPL");