blob: de99b784c5da939f8d1e10207f75908fd3d63cc3 [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>
15#include <linux/platform_device.h>
Rajendra Nayak2098e952012-02-28 15:09:11 +053016#include <linux/of.h>
17#include <linux/of_device.h>
David Brownellfa16a5c2009-02-08 10:37:06 -080018#include <linux/regulator/driver.h>
19#include <linux/regulator/machine.h>
Rajendra Nayak2098e952012-02-28 15:09:11 +053020#include <linux/regulator/of_regulator.h>
Santosh Shilimkarb07682b2009-12-13 20:05:51 +010021#include <linux/i2c/twl.h>
David Brownellfa16a5c2009-02-08 10:37:06 -080022
23
24/*
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +010025 * The TWL4030/TW5030/TPS659x0/TWL6030 family chips include power management, a
David Brownellfa16a5c2009-02-08 10:37:06 -080026 * USB OTG transceiver, an RTC, ADC, PWM, and lots more. Some versions
27 * include an audio codec, battery charger, and more voltage regulators.
28 * These chips are often used in OMAP-based systems.
29 *
30 * This driver implements software-based resource control for various
31 * voltage regulators. This is usually augmented with state machine
32 * based control.
33 */
34
35struct twlreg_info {
36 /* start of regulator's PM_RECEIVER control register bank */
37 u8 base;
38
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +010039 /* twl resource ID, for resource control state machine */
David Brownellfa16a5c2009-02-08 10:37:06 -080040 u8 id;
41
42 /* voltage in mV = table[VSEL]; table_len must be a power-of-two */
43 u8 table_len;
44 const u16 *table;
45
Juha Keski-Saari045f9722009-12-16 14:49:52 +020046 /* State REMAP default configuration */
47 u8 remap;
48
David Brownellfa16a5c2009-02-08 10:37:06 -080049 /* chip constraints on regulator behavior */
50 u16 min_mV;
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +053051 u16 max_mV;
David Brownellfa16a5c2009-02-08 10:37:06 -080052
Graeme Gregory4d94aee2011-05-22 21:21:23 +010053 u8 flags;
54
David Brownellfa16a5c2009-02-08 10:37:06 -080055 /* used by regulator core */
56 struct regulator_desc desc;
Graeme Gregory4d94aee2011-05-22 21:21:23 +010057
58 /* chip specific features */
59 unsigned long features;
Tero Kristo63bfff42012-02-16 12:27:52 +020060
61 /*
62 * optional override functions for voltage set/get
63 * these are currently only used for SMPS regulators
64 */
65 int (*get_voltage)(void *data);
66 int (*set_voltage)(void *data, int target_uV);
67
68 /* data passed from board for external get/set voltage */
69 void *data;
David Brownellfa16a5c2009-02-08 10:37:06 -080070};
71
72
73/* LDO control registers ... offset is from the base of its register bank.
74 * The first three registers of all power resource banks help hardware to
75 * manage the various resource groups.
76 */
Rajendra Nayak441a4502009-12-13 22:19:23 +010077/* Common offset in TWL4030/6030 */
David Brownellfa16a5c2009-02-08 10:37:06 -080078#define VREG_GRP 0
Rajendra Nayak441a4502009-12-13 22:19:23 +010079/* TWL4030 register offsets */
David Brownellfa16a5c2009-02-08 10:37:06 -080080#define VREG_TYPE 1
81#define VREG_REMAP 2
82#define VREG_DEDICATED 3 /* LDO control */
Tero Kristoba305e32011-11-28 16:53:19 +020083#define VREG_VOLTAGE_SMPS_4030 9
Rajendra Nayak441a4502009-12-13 22:19:23 +010084/* TWL6030 register offsets */
85#define VREG_TRANS 1
86#define VREG_STATE 2
87#define VREG_VOLTAGE 3
Graeme Gregory4d94aee2011-05-22 21:21:23 +010088#define VREG_VOLTAGE_SMPS 4
Rajendra Nayak441a4502009-12-13 22:19:23 +010089/* TWL6030 Misc register offsets */
90#define VREG_BC_ALL 1
91#define VREG_BC_REF 2
92#define VREG_BC_PROC 3
93#define VREG_BC_CLK_RST 4
David Brownellfa16a5c2009-02-08 10:37:06 -080094
Saquib Herman21657ebf2011-04-01 10:22:42 +053095/* TWL6030 LDO register values for CFG_STATE */
96#define TWL6030_CFG_STATE_OFF 0x00
97#define TWL6030_CFG_STATE_ON 0x01
Saquib Herman9a0244a2011-04-01 10:22:45 +053098#define TWL6030_CFG_STATE_OFF2 0x02
99#define TWL6030_CFG_STATE_SLEEP 0x03
Saquib Herman21657ebf2011-04-01 10:22:42 +0530100#define TWL6030_CFG_STATE_GRP_SHIFT 5
Saquib Hermanb2456772011-04-01 10:22:44 +0530101#define TWL6030_CFG_STATE_APP_SHIFT 2
102#define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT)
103#define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\
104 TWL6030_CFG_STATE_APP_SHIFT)
Saquib Herman21657ebf2011-04-01 10:22:42 +0530105
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100106/* Flags for SMPS Voltage reading */
107#define SMPS_OFFSET_EN BIT(0)
108#define SMPS_EXTENDED_EN BIT(1)
109
110/* twl6025 SMPS EPROM values */
111#define TWL6030_SMPS_OFFSET 0xB0
112#define TWL6030_SMPS_MULT 0xB3
113#define SMPS_MULTOFFSET_SMPS4 BIT(0)
114#define SMPS_MULTOFFSET_VIO BIT(1)
115#define SMPS_MULTOFFSET_SMPS3 BIT(6)
116
David Brownellfa16a5c2009-02-08 10:37:06 -0800117static inline int
Rajendra Nayak441a4502009-12-13 22:19:23 +0100118twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset)
David Brownellfa16a5c2009-02-08 10:37:06 -0800119{
120 u8 value;
121 int status;
122
Rajendra Nayak441a4502009-12-13 22:19:23 +0100123 status = twl_i2c_read_u8(slave_subgp,
David Brownellfa16a5c2009-02-08 10:37:06 -0800124 &value, info->base + offset);
125 return (status < 0) ? status : value;
126}
127
128static inline int
Rajendra Nayak441a4502009-12-13 22:19:23 +0100129twlreg_write(struct twlreg_info *info, unsigned slave_subgp, unsigned offset,
130 u8 value)
David Brownellfa16a5c2009-02-08 10:37:06 -0800131{
Rajendra Nayak441a4502009-12-13 22:19:23 +0100132 return twl_i2c_write_u8(slave_subgp,
David Brownellfa16a5c2009-02-08 10:37:06 -0800133 value, info->base + offset);
134}
135
136/*----------------------------------------------------------------------*/
137
138/* generic power resource operations, which work on all regulators */
139
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100140static int twlreg_grp(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800141{
Rajendra Nayak441a4502009-12-13 22:19:23 +0100142 return twlreg_read(rdev_get_drvdata(rdev), TWL_MODULE_PM_RECEIVER,
143 VREG_GRP);
David Brownellfa16a5c2009-02-08 10:37:06 -0800144}
145
146/*
147 * Enable/disable regulators by joining/leaving the P1 (processor) group.
148 * We assume nobody else is updating the DEV_GRP registers.
149 */
Rajendra Nayak441a4502009-12-13 22:19:23 +0100150/* definition for 4030 family */
151#define P3_GRP_4030 BIT(7) /* "peripherals" */
152#define P2_GRP_4030 BIT(6) /* secondary processor, modem, etc */
153#define P1_GRP_4030 BIT(5) /* CPU/Linux */
154/* definition for 6030 family */
155#define P3_GRP_6030 BIT(2) /* secondary processor, modem, etc */
156#define P2_GRP_6030 BIT(1) /* "peripherals" */
157#define P1_GRP_6030 BIT(0) /* CPU/Linux */
David Brownellfa16a5c2009-02-08 10:37:06 -0800158
Saquib Hermanb2456772011-04-01 10:22:44 +0530159static int twl4030reg_is_enabled(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800160{
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100161 int state = twlreg_grp(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800162
163 if (state < 0)
164 return state;
165
Saquib Hermanb2456772011-04-01 10:22:44 +0530166 return state & P1_GRP_4030;
167}
168
169static int twl6030reg_is_enabled(struct regulator_dev *rdev)
170{
171 struct twlreg_info *info = rdev_get_drvdata(rdev);
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100172 int grp = 0, val;
Saquib Hermanb2456772011-04-01 10:22:44 +0530173
Axel Linb6f476c2012-04-11 11:07:17 +0800174 if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS))) {
175 grp = twlreg_grp(rdev);
176 if (grp < 0)
177 return grp;
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100178 grp &= P1_GRP_6030;
Axel Linb6f476c2012-04-11 11:07:17 +0800179 } else {
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100180 grp = 1;
Axel Linb6f476c2012-04-11 11:07:17 +0800181 }
Saquib Hermanb2456772011-04-01 10:22:44 +0530182
183 val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
184 val = TWL6030_CFG_STATE_APP(val);
185
186 return grp && (val == TWL6030_CFG_STATE_ON);
David Brownellfa16a5c2009-02-08 10:37:06 -0800187}
188
Balaji T Kf8c29402011-05-20 19:03:51 +0530189static int twl4030reg_enable(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800190{
191 struct twlreg_info *info = rdev_get_drvdata(rdev);
192 int grp;
Juha Keski-Saari53b8a9d2009-12-16 14:55:26 +0200193 int ret;
David Brownellfa16a5c2009-02-08 10:37:06 -0800194
Axel Linb6f476c2012-04-11 11:07:17 +0800195 grp = twlreg_grp(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800196 if (grp < 0)
197 return grp;
198
Balaji T Kf8c29402011-05-20 19:03:51 +0530199 grp |= P1_GRP_4030;
Rajendra Nayak441a4502009-12-13 22:19:23 +0100200
Juha Keski-Saari53b8a9d2009-12-16 14:55:26 +0200201 ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
202
Balaji T Kf8c29402011-05-20 19:03:51 +0530203 return ret;
204}
205
206static int twl6030reg_enable(struct regulator_dev *rdev)
207{
208 struct twlreg_info *info = rdev_get_drvdata(rdev);
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100209 int grp = 0;
Balaji T Kf8c29402011-05-20 19:03:51 +0530210 int ret;
211
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100212 if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
Axel Linb6f476c2012-04-11 11:07:17 +0800213 grp = twlreg_grp(rdev);
Balaji T Kf8c29402011-05-20 19:03:51 +0530214 if (grp < 0)
215 return grp;
216
217 ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE,
218 grp << TWL6030_CFG_STATE_GRP_SHIFT |
219 TWL6030_CFG_STATE_ON);
Juha Keski-Saari53b8a9d2009-12-16 14:55:26 +0200220 return ret;
David Brownellfa16a5c2009-02-08 10:37:06 -0800221}
222
Balaji T K0ff38972011-05-20 19:03:52 +0530223static int twl4030reg_disable(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800224{
225 struct twlreg_info *info = rdev_get_drvdata(rdev);
226 int grp;
Saquib Herman21657ebf2011-04-01 10:22:42 +0530227 int ret;
David Brownellfa16a5c2009-02-08 10:37:06 -0800228
Axel Linb6f476c2012-04-11 11:07:17 +0800229 grp = twlreg_grp(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800230 if (grp < 0)
231 return grp;
232
Balaji T K0ff38972011-05-20 19:03:52 +0530233 grp &= ~(P1_GRP_4030 | P2_GRP_4030 | P3_GRP_4030);
Rajendra Nayak441a4502009-12-13 22:19:23 +0100234
Saquib Herman21657ebf2011-04-01 10:22:42 +0530235 ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
236
Balaji T K0ff38972011-05-20 19:03:52 +0530237 return ret;
238}
239
240static int twl6030reg_disable(struct regulator_dev *rdev)
241{
242 struct twlreg_info *info = rdev_get_drvdata(rdev);
243 int grp = 0;
244 int ret;
245
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100246 if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
247 grp = P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030;
Balaji T K0ff38972011-05-20 19:03:52 +0530248
249 /* For 6030, set the off state for all grps enabled */
250 ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE,
251 (grp) << TWL6030_CFG_STATE_GRP_SHIFT |
252 TWL6030_CFG_STATE_OFF);
Saquib Herman21657ebf2011-04-01 10:22:42 +0530253
254 return ret;
David Brownellfa16a5c2009-02-08 10:37:06 -0800255}
256
Saquib Herman9a0244a2011-04-01 10:22:45 +0530257static int twl4030reg_get_status(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800258{
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100259 int state = twlreg_grp(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800260
261 if (state < 0)
262 return state;
263 state &= 0x0f;
264
265 /* assume state != WARM_RESET; we'd not be running... */
266 if (!state)
267 return REGULATOR_STATUS_OFF;
268 return (state & BIT(3))
269 ? REGULATOR_STATUS_NORMAL
270 : REGULATOR_STATUS_STANDBY;
271}
272
Saquib Herman9a0244a2011-04-01 10:22:45 +0530273static int twl6030reg_get_status(struct regulator_dev *rdev)
274{
275 struct twlreg_info *info = rdev_get_drvdata(rdev);
276 int val;
277
278 val = twlreg_grp(rdev);
279 if (val < 0)
280 return val;
281
282 val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
283
284 switch (TWL6030_CFG_STATE_APP(val)) {
285 case TWL6030_CFG_STATE_ON:
286 return REGULATOR_STATUS_NORMAL;
287
288 case TWL6030_CFG_STATE_SLEEP:
289 return REGULATOR_STATUS_STANDBY;
290
291 case TWL6030_CFG_STATE_OFF:
292 case TWL6030_CFG_STATE_OFF2:
293 default:
294 break;
295 }
296
297 return REGULATOR_STATUS_OFF;
298}
299
Saquib Herman1a399622011-04-01 10:22:46 +0530300static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode)
David Brownellfa16a5c2009-02-08 10:37:06 -0800301{
302 struct twlreg_info *info = rdev_get_drvdata(rdev);
303 unsigned message;
304 int status;
305
306 /* We can only set the mode through state machine commands... */
307 switch (mode) {
308 case REGULATOR_MODE_NORMAL:
309 message = MSG_SINGULAR(DEV_GRP_P1, info->id, RES_STATE_ACTIVE);
310 break;
311 case REGULATOR_MODE_STANDBY:
312 message = MSG_SINGULAR(DEV_GRP_P1, info->id, RES_STATE_SLEEP);
313 break;
314 default:
315 return -EINVAL;
316 }
317
318 /* Ensure the resource is associated with some group */
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100319 status = twlreg_grp(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800320 if (status < 0)
321 return status;
Rajendra Nayak441a4502009-12-13 22:19:23 +0100322 if (!(status & (P3_GRP_4030 | P2_GRP_4030 | P1_GRP_4030)))
David Brownellfa16a5c2009-02-08 10:37:06 -0800323 return -EACCES;
324
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100325 status = twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
Axel Linb9e26bc2010-10-22 16:38:22 +0800326 message >> 8, TWL4030_PM_MASTER_PB_WORD_MSB);
327 if (status < 0)
David Brownellfa16a5c2009-02-08 10:37:06 -0800328 return status;
329
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100330 return twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
Axel Linb9e26bc2010-10-22 16:38:22 +0800331 message & 0xff, TWL4030_PM_MASTER_PB_WORD_LSB);
David Brownellfa16a5c2009-02-08 10:37:06 -0800332}
333
Saquib Herman1a399622011-04-01 10:22:46 +0530334static int twl6030reg_set_mode(struct regulator_dev *rdev, unsigned mode)
335{
336 struct twlreg_info *info = rdev_get_drvdata(rdev);
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100337 int grp = 0;
Saquib Herman1a399622011-04-01 10:22:46 +0530338 int val;
339
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100340 if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
Axel Linb6f476c2012-04-11 11:07:17 +0800341 grp = twlreg_grp(rdev);
Saquib Herman1a399622011-04-01 10:22:46 +0530342
343 if (grp < 0)
344 return grp;
345
346 /* Compose the state register settings */
347 val = grp << TWL6030_CFG_STATE_GRP_SHIFT;
348 /* We can only set the mode through state machine commands... */
349 switch (mode) {
350 case REGULATOR_MODE_NORMAL:
351 val |= TWL6030_CFG_STATE_ON;
352 break;
353 case REGULATOR_MODE_STANDBY:
354 val |= TWL6030_CFG_STATE_SLEEP;
355 break;
356
357 default:
358 return -EINVAL;
359 }
360
361 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, val);
362}
363
David Brownellfa16a5c2009-02-08 10:37:06 -0800364/*----------------------------------------------------------------------*/
365
366/*
367 * Support for adjustable-voltage LDOs uses a four bit (or less) voltage
368 * select field in its control register. We use tables indexed by VSEL
369 * to record voltages in milliVolts. (Accuracy is about three percent.)
370 *
371 * Note that VSEL values for VAUX2 changed in twl5030 and newer silicon;
372 * currently handled by listing two slightly different VAUX2 regulators,
373 * only one of which will be configured.
374 *
375 * VSEL values documented as "TI cannot support these values" are flagged
376 * in these tables as UNSUP() values; we normally won't assign them.
Adrian Hunterd6bb69c2009-03-06 14:51:30 +0200377 *
378 * VAUX3 at 3V is incorrectly listed in some TI manuals as unsupported.
379 * TI are revising the twl5030/tps659x0 specs to support that 3.0V setting.
David Brownellfa16a5c2009-02-08 10:37:06 -0800380 */
David Brownellfa16a5c2009-02-08 10:37:06 -0800381#define UNSUP_MASK 0x8000
David Brownellfa16a5c2009-02-08 10:37:06 -0800382
383#define UNSUP(x) (UNSUP_MASK | (x))
NeilBrown411a2df2012-05-09 05:44:00 +1000384#define IS_UNSUP(info, x) \
385 ((UNSUP_MASK & (x)) && \
386 !((info)->features & TWL4030_ALLOW_UNSUPPORTED))
David Brownellfa16a5c2009-02-08 10:37:06 -0800387#define LDO_MV(x) (~UNSUP_MASK & (x))
388
389
390static const u16 VAUX1_VSEL_table[] = {
391 UNSUP(1500), UNSUP(1800), 2500, 2800,
392 3000, 3000, 3000, 3000,
393};
394static const u16 VAUX2_4030_VSEL_table[] = {
395 UNSUP(1000), UNSUP(1000), UNSUP(1200), 1300,
396 1500, 1800, UNSUP(1850), 2500,
397 UNSUP(2600), 2800, UNSUP(2850), UNSUP(3000),
398 UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
399};
400static const u16 VAUX2_VSEL_table[] = {
401 1700, 1700, 1900, 1300,
402 1500, 1800, 2000, 2500,
403 2100, 2800, 2200, 2300,
404 2400, 2400, 2400, 2400,
405};
406static const u16 VAUX3_VSEL_table[] = {
407 1500, 1800, 2500, 2800,
Adrian Hunterd6bb69c2009-03-06 14:51:30 +0200408 3000, 3000, 3000, 3000,
David Brownellfa16a5c2009-02-08 10:37:06 -0800409};
410static const u16 VAUX4_VSEL_table[] = {
411 700, 1000, 1200, UNSUP(1300),
412 1500, 1800, UNSUP(1850), 2500,
David Brownell1897e742009-03-10 11:51:15 -0800413 UNSUP(2600), 2800, UNSUP(2850), UNSUP(3000),
414 UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
David Brownellfa16a5c2009-02-08 10:37:06 -0800415};
416static const u16 VMMC1_VSEL_table[] = {
417 1850, 2850, 3000, 3150,
418};
419static const u16 VMMC2_VSEL_table[] = {
420 UNSUP(1000), UNSUP(1000), UNSUP(1200), UNSUP(1300),
421 UNSUP(1500), UNSUP(1800), 1850, UNSUP(2500),
422 2600, 2800, 2850, 3000,
423 3150, 3150, 3150, 3150,
424};
425static const u16 VPLL1_VSEL_table[] = {
426 1000, 1200, 1300, 1800,
427 UNSUP(2800), UNSUP(3000), UNSUP(3000), UNSUP(3000),
428};
429static const u16 VPLL2_VSEL_table[] = {
430 700, 1000, 1200, 1300,
431 UNSUP(1500), 1800, UNSUP(1850), UNSUP(2500),
432 UNSUP(2600), UNSUP(2800), UNSUP(2850), UNSUP(3000),
433 UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
434};
435static const u16 VSIM_VSEL_table[] = {
436 UNSUP(1000), UNSUP(1200), UNSUP(1300), 1800,
437 2800, 3000, 3000, 3000,
438};
439static const u16 VDAC_VSEL_table[] = {
440 1200, 1300, 1800, 1800,
441};
Juha Keski-Saari07fc4932009-12-16 15:27:55 +0200442static const u16 VDD1_VSEL_table[] = {
443 800, 1450,
444};
445static const u16 VDD2_VSEL_table[] = {
446 800, 1450, 1500,
447};
448static const u16 VIO_VSEL_table[] = {
449 1800, 1850,
450};
451static const u16 VINTANA2_VSEL_table[] = {
452 2500, 2750,
453};
David Brownellfa16a5c2009-02-08 10:37:06 -0800454
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530455static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
David Brownell66b659e2009-02-26 11:50:14 -0800456{
457 struct twlreg_info *info = rdev_get_drvdata(rdev);
458 int mV = info->table[index];
459
NeilBrown411a2df2012-05-09 05:44:00 +1000460 return IS_UNSUP(info, mV) ? 0 : (LDO_MV(mV) * 1000);
David Brownell66b659e2009-02-26 11:50:14 -0800461}
462
David Brownellfa16a5c2009-02-08 10:37:06 -0800463static int
Axel Lindd16b1f2012-03-26 09:30:06 +0800464twl4030ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
David Brownellfa16a5c2009-02-08 10:37:06 -0800465{
466 struct twlreg_info *info = rdev_get_drvdata(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800467
Axel Lindd16b1f2012-03-26 09:30:06 +0800468 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE,
469 selector);
David Brownellfa16a5c2009-02-08 10:37:06 -0800470}
471
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530472static int twl4030ldo_get_voltage(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800473{
474 struct twlreg_info *info = rdev_get_drvdata(rdev);
Rajendra Nayak441a4502009-12-13 22:19:23 +0100475 int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
476 VREG_VOLTAGE);
David Brownellfa16a5c2009-02-08 10:37:06 -0800477
478 if (vsel < 0)
479 return vsel;
480
481 vsel &= info->table_len - 1;
482 return LDO_MV(info->table[vsel]) * 1000;
483}
484
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530485static struct regulator_ops twl4030ldo_ops = {
486 .list_voltage = twl4030ldo_list_voltage,
David Brownell66b659e2009-02-26 11:50:14 -0800487
Axel Lindd16b1f2012-03-26 09:30:06 +0800488 .set_voltage_sel = twl4030ldo_set_voltage_sel,
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530489 .get_voltage = twl4030ldo_get_voltage,
490
Balaji T Kf8c29402011-05-20 19:03:51 +0530491 .enable = twl4030reg_enable,
Balaji T K0ff38972011-05-20 19:03:52 +0530492 .disable = twl4030reg_disable,
Saquib Hermanb2456772011-04-01 10:22:44 +0530493 .is_enabled = twl4030reg_is_enabled,
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530494
Saquib Herman1a399622011-04-01 10:22:46 +0530495 .set_mode = twl4030reg_set_mode,
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530496
Saquib Herman9a0244a2011-04-01 10:22:45 +0530497 .get_status = twl4030reg_get_status,
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530498};
499
Tero Kristoba305e32011-11-28 16:53:19 +0200500static int
501twl4030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
502 unsigned *selector)
503{
504 struct twlreg_info *info = rdev_get_drvdata(rdev);
505 int vsel = DIV_ROUND_UP(min_uV - 600000, 12500);
506
Tero Kristo63bfff42012-02-16 12:27:52 +0200507 if (info->set_voltage) {
508 return info->set_voltage(info->data, min_uV);
509 } else {
510 twlreg_write(info, TWL_MODULE_PM_RECEIVER,
511 VREG_VOLTAGE_SMPS_4030, vsel);
512 }
513
Tero Kristoba305e32011-11-28 16:53:19 +0200514 return 0;
515}
516
517static int twl4030smps_get_voltage(struct regulator_dev *rdev)
518{
519 struct twlreg_info *info = rdev_get_drvdata(rdev);
Tero Kristo63bfff42012-02-16 12:27:52 +0200520 int vsel;
521
522 if (info->get_voltage)
523 return info->get_voltage(info->data);
524
525 vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
Tero Kristoba305e32011-11-28 16:53:19 +0200526 VREG_VOLTAGE_SMPS_4030);
527
528 return vsel * 12500 + 600000;
529}
530
531static struct regulator_ops twl4030smps_ops = {
532 .set_voltage = twl4030smps_set_voltage,
533 .get_voltage = twl4030smps_get_voltage,
534};
535
Tero Kristo34a38442012-02-28 15:09:10 +0530536static int twl6030coresmps_set_voltage(struct regulator_dev *rdev, int min_uV,
537 int max_uV, unsigned *selector)
538{
539 struct twlreg_info *info = rdev_get_drvdata(rdev);
540
541 if (info->set_voltage)
542 return info->set_voltage(info->data, min_uV);
543
544 return -ENODEV;
545}
546
547static int twl6030coresmps_get_voltage(struct regulator_dev *rdev)
548{
549 struct twlreg_info *info = rdev_get_drvdata(rdev);
550
551 if (info->get_voltage)
552 return info->get_voltage(info->data);
553
554 return -ENODEV;
555}
556
557static struct regulator_ops twl6030coresmps_ops = {
558 .set_voltage = twl6030coresmps_set_voltage,
559 .get_voltage = twl6030coresmps_get_voltage,
560};
561
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530562static int
Axel Lin4bcb9f42012-07-09 11:26:28 +0800563twl6030ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530564{
565 struct twlreg_info *info = rdev_get_drvdata(rdev);
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530566
Axel Lin4bcb9f42012-07-09 11:26:28 +0800567 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE,
568 selector);
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530569}
570
Axel Lin4bcb9f42012-07-09 11:26:28 +0800571static int twl6030ldo_get_voltage_sel(struct regulator_dev *rdev)
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530572{
573 struct twlreg_info *info = rdev_get_drvdata(rdev);
Axel Lina3cb80f2012-07-09 11:22:31 +0800574 int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE);
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530575
Axel Lin4bcb9f42012-07-09 11:26:28 +0800576 return vsel;
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530577}
578
579static struct regulator_ops twl6030ldo_ops = {
Axel Linea7e3302012-06-04 12:44:15 +0800580 .list_voltage = regulator_list_voltage_linear,
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530581
Axel Lin4bcb9f42012-07-09 11:26:28 +0800582 .set_voltage_sel = twl6030ldo_set_voltage_sel,
583 .get_voltage_sel = twl6030ldo_get_voltage_sel,
David Brownellfa16a5c2009-02-08 10:37:06 -0800584
Balaji T Kf8c29402011-05-20 19:03:51 +0530585 .enable = twl6030reg_enable,
Balaji T K0ff38972011-05-20 19:03:52 +0530586 .disable = twl6030reg_disable,
Saquib Hermanb2456772011-04-01 10:22:44 +0530587 .is_enabled = twl6030reg_is_enabled,
David Brownellfa16a5c2009-02-08 10:37:06 -0800588
Saquib Herman1a399622011-04-01 10:22:46 +0530589 .set_mode = twl6030reg_set_mode,
David Brownellfa16a5c2009-02-08 10:37:06 -0800590
Saquib Herman9a0244a2011-04-01 10:22:45 +0530591 .get_status = twl6030reg_get_status,
David Brownellfa16a5c2009-02-08 10:37:06 -0800592};
593
594/*----------------------------------------------------------------------*/
595
596/*
597 * Fixed voltage LDOs don't have a VSEL field to update.
598 */
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100599static int twlfixed_list_voltage(struct regulator_dev *rdev, unsigned index)
David Brownell66b659e2009-02-26 11:50:14 -0800600{
601 struct twlreg_info *info = rdev_get_drvdata(rdev);
602
603 return info->min_mV * 1000;
604}
605
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100606static int twlfixed_get_voltage(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800607{
608 struct twlreg_info *info = rdev_get_drvdata(rdev);
609
610 return info->min_mV * 1000;
611}
612
Saquib Hermanb2456772011-04-01 10:22:44 +0530613static struct regulator_ops twl4030fixed_ops = {
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100614 .list_voltage = twlfixed_list_voltage,
David Brownell66b659e2009-02-26 11:50:14 -0800615
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100616 .get_voltage = twlfixed_get_voltage,
David Brownellfa16a5c2009-02-08 10:37:06 -0800617
Balaji T Kf8c29402011-05-20 19:03:51 +0530618 .enable = twl4030reg_enable,
Balaji T K0ff38972011-05-20 19:03:52 +0530619 .disable = twl4030reg_disable,
Saquib Hermanb2456772011-04-01 10:22:44 +0530620 .is_enabled = twl4030reg_is_enabled,
621
Saquib Herman1a399622011-04-01 10:22:46 +0530622 .set_mode = twl4030reg_set_mode,
Saquib Hermanb2456772011-04-01 10:22:44 +0530623
Saquib Herman9a0244a2011-04-01 10:22:45 +0530624 .get_status = twl4030reg_get_status,
Saquib Hermanb2456772011-04-01 10:22:44 +0530625};
626
627static struct regulator_ops twl6030fixed_ops = {
628 .list_voltage = twlfixed_list_voltage,
629
630 .get_voltage = twlfixed_get_voltage,
631
Balaji T Kf8c29402011-05-20 19:03:51 +0530632 .enable = twl6030reg_enable,
Balaji T K0ff38972011-05-20 19:03:52 +0530633 .disable = twl6030reg_disable,
Saquib Hermanb2456772011-04-01 10:22:44 +0530634 .is_enabled = twl6030reg_is_enabled,
David Brownellfa16a5c2009-02-08 10:37:06 -0800635
Saquib Herman1a399622011-04-01 10:22:46 +0530636 .set_mode = twl6030reg_set_mode,
David Brownellfa16a5c2009-02-08 10:37:06 -0800637
Saquib Herman9a0244a2011-04-01 10:22:45 +0530638 .get_status = twl6030reg_get_status,
David Brownellfa16a5c2009-02-08 10:37:06 -0800639};
640
Balaji T K8e6de4a2011-02-10 18:44:50 +0530641static struct regulator_ops twl6030_fixed_resource = {
Balaji T Kf8c29402011-05-20 19:03:51 +0530642 .enable = twl6030reg_enable,
Balaji T K0ff38972011-05-20 19:03:52 +0530643 .disable = twl6030reg_disable,
Saquib Hermanb2456772011-04-01 10:22:44 +0530644 .is_enabled = twl6030reg_is_enabled,
Saquib Herman9a0244a2011-04-01 10:22:45 +0530645 .get_status = twl6030reg_get_status,
Balaji T K8e6de4a2011-02-10 18:44:50 +0530646};
647
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100648/*
649 * SMPS status and control
650 */
651
652static int twl6030smps_list_voltage(struct regulator_dev *rdev, unsigned index)
653{
654 struct twlreg_info *info = rdev_get_drvdata(rdev);
655
656 int voltage = 0;
657
658 switch (info->flags) {
659 case SMPS_OFFSET_EN:
660 voltage = 100000;
661 /* fall through */
662 case 0:
663 switch (index) {
664 case 0:
665 voltage = 0;
666 break;
667 case 58:
668 voltage = 1350 * 1000;
669 break;
670 case 59:
671 voltage = 1500 * 1000;
672 break;
673 case 60:
674 voltage = 1800 * 1000;
675 break;
676 case 61:
677 voltage = 1900 * 1000;
678 break;
679 case 62:
680 voltage = 2100 * 1000;
681 break;
682 default:
683 voltage += (600000 + (12500 * (index - 1)));
684 }
685 break;
686 case SMPS_EXTENDED_EN:
687 switch (index) {
688 case 0:
689 voltage = 0;
690 break;
691 case 58:
692 voltage = 2084 * 1000;
693 break;
694 case 59:
695 voltage = 2315 * 1000;
696 break;
697 case 60:
698 voltage = 2778 * 1000;
699 break;
700 case 61:
701 voltage = 2932 * 1000;
702 break;
703 case 62:
704 voltage = 3241 * 1000;
705 break;
706 default:
707 voltage = (1852000 + (38600 * (index - 1)));
708 }
709 break;
710 case SMPS_OFFSET_EN | SMPS_EXTENDED_EN:
711 switch (index) {
712 case 0:
713 voltage = 0;
714 break;
715 case 58:
716 voltage = 4167 * 1000;
717 break;
718 case 59:
719 voltage = 2315 * 1000;
720 break;
721 case 60:
722 voltage = 2778 * 1000;
723 break;
724 case 61:
725 voltage = 2932 * 1000;
726 break;
727 case 62:
728 voltage = 3241 * 1000;
729 break;
730 default:
731 voltage = (2161000 + (38600 * (index - 1)));
732 }
733 break;
734 }
735
736 return voltage;
737}
738
739static int
740twl6030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
741 unsigned int *selector)
742{
743 struct twlreg_info *info = rdev_get_drvdata(rdev);
744 int vsel = 0;
745
746 switch (info->flags) {
747 case 0:
748 if (min_uV == 0)
749 vsel = 0;
Laxman Dewangana33b6e52012-02-03 12:54:38 +0530750 else if ((min_uV >= 600000) && (min_uV <= 1300000)) {
751 int calc_uV;
Axel Lin268a1642012-04-09 23:35:10 +0800752 vsel = DIV_ROUND_UP(min_uV - 600000, 12500);
Axel Lin0cb2f122012-04-10 23:07:52 +0800753 vsel++;
Laxman Dewangana33b6e52012-02-03 12:54:38 +0530754 calc_uV = twl6030smps_list_voltage(rdev, vsel);
755 if (calc_uV > max_uV)
756 return -EINVAL;
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100757 }
758 /* Values 1..57 for vsel are linear and can be calculated
759 * values 58..62 are non linear.
760 */
761 else if ((min_uV > 1900000) && (max_uV >= 2100000))
762 vsel = 62;
763 else if ((min_uV > 1800000) && (max_uV >= 1900000))
764 vsel = 61;
765 else if ((min_uV > 1500000) && (max_uV >= 1800000))
766 vsel = 60;
767 else if ((min_uV > 1350000) && (max_uV >= 1500000))
768 vsel = 59;
769 else if ((min_uV > 1300000) && (max_uV >= 1350000))
770 vsel = 58;
771 else
772 return -EINVAL;
773 break;
774 case SMPS_OFFSET_EN:
775 if (min_uV == 0)
776 vsel = 0;
Laxman Dewangana33b6e52012-02-03 12:54:38 +0530777 else if ((min_uV >= 700000) && (min_uV <= 1420000)) {
778 int calc_uV;
Axel Lin268a1642012-04-09 23:35:10 +0800779 vsel = DIV_ROUND_UP(min_uV - 700000, 12500);
Axel Lin0cb2f122012-04-10 23:07:52 +0800780 vsel++;
Laxman Dewangana33b6e52012-02-03 12:54:38 +0530781 calc_uV = twl6030smps_list_voltage(rdev, vsel);
782 if (calc_uV > max_uV)
783 return -EINVAL;
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100784 }
785 /* Values 1..57 for vsel are linear and can be calculated
786 * values 58..62 are non linear.
787 */
788 else if ((min_uV > 1900000) && (max_uV >= 2100000))
789 vsel = 62;
790 else if ((min_uV > 1800000) && (max_uV >= 1900000))
791 vsel = 61;
792 else if ((min_uV > 1350000) && (max_uV >= 1800000))
793 vsel = 60;
794 else if ((min_uV > 1350000) && (max_uV >= 1500000))
795 vsel = 59;
796 else if ((min_uV > 1300000) && (max_uV >= 1350000))
797 vsel = 58;
798 else
799 return -EINVAL;
800 break;
801 case SMPS_EXTENDED_EN:
Axel Lin0cb2f122012-04-10 23:07:52 +0800802 if (min_uV == 0) {
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100803 vsel = 0;
Axel Lin0cb2f122012-04-10 23:07:52 +0800804 } else if ((min_uV >= 1852000) && (max_uV <= 4013600)) {
Axel Lin268a1642012-04-09 23:35:10 +0800805 vsel = DIV_ROUND_UP(min_uV - 1852000, 38600);
Axel Lin0cb2f122012-04-10 23:07:52 +0800806 vsel++;
807 }
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100808 break;
809 case SMPS_OFFSET_EN|SMPS_EXTENDED_EN:
Axel Lin0cb2f122012-04-10 23:07:52 +0800810 if (min_uV == 0) {
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100811 vsel = 0;
Axel Lin0cb2f122012-04-10 23:07:52 +0800812 } else if ((min_uV >= 2161000) && (max_uV <= 4321000)) {
Axel Lin268a1642012-04-09 23:35:10 +0800813 vsel = DIV_ROUND_UP(min_uV - 2161000, 38600);
Axel Lin0cb2f122012-04-10 23:07:52 +0800814 vsel++;
815 }
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100816 break;
817 }
818
819 *selector = vsel;
820
821 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS,
822 vsel);
823}
824
825static int twl6030smps_get_voltage_sel(struct regulator_dev *rdev)
826{
827 struct twlreg_info *info = rdev_get_drvdata(rdev);
828
829 return twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS);
830}
831
832static struct regulator_ops twlsmps_ops = {
833 .list_voltage = twl6030smps_list_voltage,
834
835 .set_voltage = twl6030smps_set_voltage,
836 .get_voltage_sel = twl6030smps_get_voltage_sel,
837
838 .enable = twl6030reg_enable,
839 .disable = twl6030reg_disable,
840 .is_enabled = twl6030reg_is_enabled,
841
842 .set_mode = twl6030reg_set_mode,
843
844 .get_status = twl6030reg_get_status,
845};
846
David Brownellfa16a5c2009-02-08 10:37:06 -0800847/*----------------------------------------------------------------------*/
848
Juha Keski-Saari045f9722009-12-16 14:49:52 +0200849#define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
850 remap_conf) \
851 TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
Saquib Hermanb2456772011-04-01 10:22:44 +0530852 remap_conf, TWL4030, twl4030fixed_ops)
Ambresh Kaf8b2442011-07-09 19:02:21 -0700853#define TWL6030_FIXED_LDO(label, offset, mVolts, turnon_delay) \
854 TWL_FIXED_LDO(label, offset, mVolts, 0x0, turnon_delay, \
Saquib Hermanb2456772011-04-01 10:22:44 +0530855 0x0, TWL6030, twl6030fixed_ops)
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100856
Rajendra Nayak2098e952012-02-28 15:09:11 +0530857#define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) \
858static struct twlreg_info TWL4030_INFO_##label = { \
David Brownellfa16a5c2009-02-08 10:37:06 -0800859 .base = offset, \
860 .id = num, \
861 .table_len = ARRAY_SIZE(label##_VSEL_table), \
862 .table = label##_VSEL_table, \
Juha Keski-Saari045f9722009-12-16 14:49:52 +0200863 .remap = remap_conf, \
David Brownellfa16a5c2009-02-08 10:37:06 -0800864 .desc = { \
865 .name = #label, \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530866 .id = TWL4030_REG_##label, \
David Brownell66b659e2009-02-26 11:50:14 -0800867 .n_voltages = ARRAY_SIZE(label##_VSEL_table), \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530868 .ops = &twl4030ldo_ops, \
David Brownellfa16a5c2009-02-08 10:37:06 -0800869 .type = REGULATOR_VOLTAGE, \
870 .owner = THIS_MODULE, \
Axel Linfca53d82012-07-04 10:46:34 +0800871 .enable_time = turnon_delay, \
David Brownellfa16a5c2009-02-08 10:37:06 -0800872 }, \
873 }
874
Tero Kristoba305e32011-11-28 16:53:19 +0200875#define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf) \
Rajendra Nayak2098e952012-02-28 15:09:11 +0530876static struct twlreg_info TWL4030_INFO_##label = { \
Tero Kristoba305e32011-11-28 16:53:19 +0200877 .base = offset, \
878 .id = num, \
Tero Kristoba305e32011-11-28 16:53:19 +0200879 .remap = remap_conf, \
880 .desc = { \
881 .name = #label, \
882 .id = TWL4030_REG_##label, \
883 .ops = &twl4030smps_ops, \
884 .type = REGULATOR_VOLTAGE, \
885 .owner = THIS_MODULE, \
Axel Linfca53d82012-07-04 10:46:34 +0800886 .enable_time = turnon_delay, \
Tero Kristoba305e32011-11-28 16:53:19 +0200887 }, \
888 }
889
Rajendra Nayak2098e952012-02-28 15:09:11 +0530890#define TWL6030_ADJUSTABLE_SMPS(label) \
891static struct twlreg_info TWL6030_INFO_##label = { \
Tero Kristo34a38442012-02-28 15:09:10 +0530892 .desc = { \
893 .name = #label, \
894 .id = TWL6030_REG_##label, \
895 .ops = &twl6030coresmps_ops, \
896 .type = REGULATOR_VOLTAGE, \
897 .owner = THIS_MODULE, \
898 }, \
899 }
900
Rajendra Nayak2098e952012-02-28 15:09:11 +0530901#define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \
902static struct twlreg_info TWL6030_INFO_##label = { \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530903 .base = offset, \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530904 .min_mV = min_mVolts, \
905 .max_mV = max_mVolts, \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530906 .desc = { \
907 .name = #label, \
908 .id = TWL6030_REG_##label, \
Colin Cross7736f112011-05-27 12:25:27 -0700909 .n_voltages = (max_mVolts - min_mVolts)/100 + 1, \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530910 .ops = &twl6030ldo_ops, \
911 .type = REGULATOR_VOLTAGE, \
912 .owner = THIS_MODULE, \
Axel Linea7e3302012-06-04 12:44:15 +0800913 .min_uV = min_mVolts * 1000, \
914 .uV_step = 100 * 1000, \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530915 }, \
916 }
917
Rajendra Nayak2098e952012-02-28 15:09:11 +0530918#define TWL6025_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \
919static struct twlreg_info TWL6025_INFO_##label = { \
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100920 .base = offset, \
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100921 .min_mV = min_mVolts, \
922 .max_mV = max_mVolts, \
923 .desc = { \
924 .name = #label, \
925 .id = TWL6025_REG_##label, \
926 .n_voltages = ((max_mVolts - min_mVolts)/100) + 1, \
927 .ops = &twl6030ldo_ops, \
928 .type = REGULATOR_VOLTAGE, \
929 .owner = THIS_MODULE, \
Axel Linea7e3302012-06-04 12:44:15 +0800930 .min_uV = min_mVolts * 1000, \
931 .uV_step = 100 * 1000, \
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100932 }, \
933 }
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530934
Juha Keski-Saari045f9722009-12-16 14:49:52 +0200935#define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \
Rajendra Nayak2098e952012-02-28 15:09:11 +0530936 family, operations) \
937static struct twlreg_info TWLFIXED_INFO_##label = { \
David Brownellfa16a5c2009-02-08 10:37:06 -0800938 .base = offset, \
939 .id = num, \
940 .min_mV = mVolts, \
Juha Keski-Saari045f9722009-12-16 14:49:52 +0200941 .remap = remap_conf, \
David Brownellfa16a5c2009-02-08 10:37:06 -0800942 .desc = { \
943 .name = #label, \
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100944 .id = family##_REG_##label, \
David Brownell66b659e2009-02-26 11:50:14 -0800945 .n_voltages = 1, \
Saquib Hermanb2456772011-04-01 10:22:44 +0530946 .ops = &operations, \
David Brownellfa16a5c2009-02-08 10:37:06 -0800947 .type = REGULATOR_VOLTAGE, \
948 .owner = THIS_MODULE, \
Axel Linfca53d82012-07-04 10:46:34 +0800949 .enable_time = turnon_delay, \
David Brownellfa16a5c2009-02-08 10:37:06 -0800950 }, \
951 }
952
Rajendra Nayak2098e952012-02-28 15:09:11 +0530953#define TWL6030_FIXED_RESOURCE(label, offset, turnon_delay) \
954static struct twlreg_info TWLRES_INFO_##label = { \
Balaji T K8e6de4a2011-02-10 18:44:50 +0530955 .base = offset, \
Balaji T K8e6de4a2011-02-10 18:44:50 +0530956 .desc = { \
957 .name = #label, \
958 .id = TWL6030_REG_##label, \
959 .ops = &twl6030_fixed_resource, \
960 .type = REGULATOR_VOLTAGE, \
961 .owner = THIS_MODULE, \
Axel Linfca53d82012-07-04 10:46:34 +0800962 .enable_time = turnon_delay, \
Balaji T K8e6de4a2011-02-10 18:44:50 +0530963 }, \
964 }
965
Rajendra Nayak2098e952012-02-28 15:09:11 +0530966#define TWL6025_ADJUSTABLE_SMPS(label, offset) \
967static struct twlreg_info TWLSMPS_INFO_##label = { \
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100968 .base = offset, \
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100969 .min_mV = 600, \
970 .max_mV = 2100, \
971 .desc = { \
972 .name = #label, \
973 .id = TWL6025_REG_##label, \
974 .n_voltages = 63, \
975 .ops = &twlsmps_ops, \
976 .type = REGULATOR_VOLTAGE, \
977 .owner = THIS_MODULE, \
978 }, \
979 }
980
David Brownellfa16a5c2009-02-08 10:37:06 -0800981/*
982 * We list regulators here if systems need some level of
983 * software control over them after boot.
984 */
Rajendra Nayak2098e952012-02-28 15:09:11 +0530985TWL4030_ADJUSTABLE_LDO(VAUX1, 0x17, 1, 100, 0x08);
986TWL4030_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2, 100, 0x08);
987TWL4030_ADJUSTABLE_LDO(VAUX2, 0x1b, 2, 100, 0x08);
988TWL4030_ADJUSTABLE_LDO(VAUX3, 0x1f, 3, 100, 0x08);
989TWL4030_ADJUSTABLE_LDO(VAUX4, 0x23, 4, 100, 0x08);
990TWL4030_ADJUSTABLE_LDO(VMMC1, 0x27, 5, 100, 0x08);
991TWL4030_ADJUSTABLE_LDO(VMMC2, 0x2b, 6, 100, 0x08);
992TWL4030_ADJUSTABLE_LDO(VPLL1, 0x2f, 7, 100, 0x00);
993TWL4030_ADJUSTABLE_LDO(VPLL2, 0x33, 8, 100, 0x08);
994TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9, 100, 0x00);
995TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10, 100, 0x08);
996TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08);
997TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08);
998TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08);
999TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08);
1000/* VUSBCP is managed *only* by the USB subchip */
1001/* 6030 REG with base as PMC Slave Misc : 0x0030 */
1002/* Turnon-delay and remap configuration values for 6030 are not
1003 verified since the specification is not public */
1004TWL6030_ADJUSTABLE_SMPS(VDD1);
1005TWL6030_ADJUSTABLE_SMPS(VDD2);
1006TWL6030_ADJUSTABLE_SMPS(VDD3);
1007TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300);
1008TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300);
1009TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300);
1010TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300);
1011TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300);
1012TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300);
1013/* 6025 are renamed compared to 6030 versions */
1014TWL6025_ADJUSTABLE_LDO(LDO2, 0x54, 1000, 3300);
1015TWL6025_ADJUSTABLE_LDO(LDO4, 0x58, 1000, 3300);
1016TWL6025_ADJUSTABLE_LDO(LDO3, 0x5c, 1000, 3300);
1017TWL6025_ADJUSTABLE_LDO(LDO5, 0x68, 1000, 3300);
1018TWL6025_ADJUSTABLE_LDO(LDO1, 0x6c, 1000, 3300);
1019TWL6025_ADJUSTABLE_LDO(LDO7, 0x74, 1000, 3300);
1020TWL6025_ADJUSTABLE_LDO(LDO6, 0x60, 1000, 3300);
1021TWL6025_ADJUSTABLE_LDO(LDOLN, 0x64, 1000, 3300);
1022TWL6025_ADJUSTABLE_LDO(LDOUSB, 0x70, 1000, 3300);
1023TWL4030_FIXED_LDO(VINTANA2, 0x3f, 1500, 11, 100, 0x08);
1024TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08);
1025TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08);
1026TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08);
1027TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08);
1028TWL6030_FIXED_LDO(VANA, 0x50, 2100, 0);
1029TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 0);
1030TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 0);
1031TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 0);
Peter Ujfalusie9d47fa2012-02-28 15:09:12 +05301032TWL6030_FIXED_LDO(V1V8, 0x16, 1800, 0);
1033TWL6030_FIXED_LDO(V2V1, 0x1c, 2100, 0);
Rajendra Nayak2098e952012-02-28 15:09:11 +05301034TWL6030_FIXED_RESOURCE(CLK32KG, 0x8C, 0);
1035TWL6025_ADJUSTABLE_SMPS(SMPS3, 0x34);
1036TWL6025_ADJUSTABLE_SMPS(SMPS4, 0x10);
1037TWL6025_ADJUSTABLE_SMPS(VIO, 0x16);
David Brownellfa16a5c2009-02-08 10:37:06 -08001038
Graeme Gregory4d94aee2011-05-22 21:21:23 +01001039static u8 twl_get_smps_offset(void)
1040{
1041 u8 value;
1042
1043 twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value,
1044 TWL6030_SMPS_OFFSET);
1045 return value;
1046}
1047
1048static u8 twl_get_smps_mult(void)
1049{
1050 u8 value;
1051
1052 twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value,
1053 TWL6030_SMPS_MULT);
1054 return value;
1055}
1056
Rajendra Nayak2098e952012-02-28 15:09:11 +05301057#define TWL_OF_MATCH(comp, family, label) \
1058 { \
1059 .compatible = comp, \
1060 .data = &family##_INFO_##label, \
1061 }
1062
1063#define TWL4030_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL4030, label)
1064#define TWL6030_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6030, label)
1065#define TWL6025_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6025, label)
1066#define TWLFIXED_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLFIXED, label)
Rajendra Nayak2098e952012-02-28 15:09:11 +05301067#define TWLSMPS_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLSMPS, label)
1068
1069static const struct of_device_id twl_of_match[] __devinitconst = {
1070 TWL4030_OF_MATCH("ti,twl4030-vaux1", VAUX1),
1071 TWL4030_OF_MATCH("ti,twl4030-vaux2", VAUX2_4030),
1072 TWL4030_OF_MATCH("ti,twl5030-vaux2", VAUX2),
1073 TWL4030_OF_MATCH("ti,twl4030-vaux3", VAUX3),
1074 TWL4030_OF_MATCH("ti,twl4030-vaux4", VAUX4),
1075 TWL4030_OF_MATCH("ti,twl4030-vmmc1", VMMC1),
1076 TWL4030_OF_MATCH("ti,twl4030-vmmc2", VMMC2),
1077 TWL4030_OF_MATCH("ti,twl4030-vpll1", VPLL1),
1078 TWL4030_OF_MATCH("ti,twl4030-vpll2", VPLL2),
1079 TWL4030_OF_MATCH("ti,twl4030-vsim", VSIM),
1080 TWL4030_OF_MATCH("ti,twl4030-vdac", VDAC),
1081 TWL4030_OF_MATCH("ti,twl4030-vintana2", VINTANA2),
1082 TWL4030_OF_MATCH("ti,twl4030-vio", VIO),
1083 TWL4030_OF_MATCH("ti,twl4030-vdd1", VDD1),
1084 TWL4030_OF_MATCH("ti,twl4030-vdd2", VDD2),
1085 TWL6030_OF_MATCH("ti,twl6030-vdd1", VDD1),
1086 TWL6030_OF_MATCH("ti,twl6030-vdd2", VDD2),
1087 TWL6030_OF_MATCH("ti,twl6030-vdd3", VDD3),
1088 TWL6030_OF_MATCH("ti,twl6030-vaux1", VAUX1_6030),
1089 TWL6030_OF_MATCH("ti,twl6030-vaux2", VAUX2_6030),
1090 TWL6030_OF_MATCH("ti,twl6030-vaux3", VAUX3_6030),
1091 TWL6030_OF_MATCH("ti,twl6030-vmmc", VMMC),
1092 TWL6030_OF_MATCH("ti,twl6030-vpp", VPP),
1093 TWL6030_OF_MATCH("ti,twl6030-vusim", VUSIM),
1094 TWL6025_OF_MATCH("ti,twl6025-ldo2", LDO2),
1095 TWL6025_OF_MATCH("ti,twl6025-ldo4", LDO4),
1096 TWL6025_OF_MATCH("ti,twl6025-ldo3", LDO3),
1097 TWL6025_OF_MATCH("ti,twl6025-ldo5", LDO5),
1098 TWL6025_OF_MATCH("ti,twl6025-ldo1", LDO1),
1099 TWL6025_OF_MATCH("ti,twl6025-ldo7", LDO7),
1100 TWL6025_OF_MATCH("ti,twl6025-ldo6", LDO6),
1101 TWL6025_OF_MATCH("ti,twl6025-ldoln", LDOLN),
1102 TWL6025_OF_MATCH("ti,twl6025-ldousb", LDOUSB),
1103 TWLFIXED_OF_MATCH("ti,twl4030-vintana2", VINTANA2),
1104 TWLFIXED_OF_MATCH("ti,twl4030-vintdig", VINTDIG),
1105 TWLFIXED_OF_MATCH("ti,twl4030-vusb1v5", VUSB1V5),
1106 TWLFIXED_OF_MATCH("ti,twl4030-vusb1v8", VUSB1V8),
1107 TWLFIXED_OF_MATCH("ti,twl4030-vusb3v1", VUSB3V1),
1108 TWLFIXED_OF_MATCH("ti,twl6030-vana", VANA),
1109 TWLFIXED_OF_MATCH("ti,twl6030-vcxio", VCXIO),
1110 TWLFIXED_OF_MATCH("ti,twl6030-vdac", VDAC),
1111 TWLFIXED_OF_MATCH("ti,twl6030-vusb", VUSB),
Peter Ujfalusie9d47fa2012-02-28 15:09:12 +05301112 TWLFIXED_OF_MATCH("ti,twl6030-v1v8", V1V8),
1113 TWLFIXED_OF_MATCH("ti,twl6030-v2v1", V2V1),
Rajendra Nayak2098e952012-02-28 15:09:11 +05301114 TWLSMPS_OF_MATCH("ti,twl6025-smps3", SMPS3),
1115 TWLSMPS_OF_MATCH("ti,twl6025-smps4", SMPS4),
1116 TWLSMPS_OF_MATCH("ti,twl6025-vio", VIO),
1117 {},
1118};
1119MODULE_DEVICE_TABLE(of, twl_of_match);
1120
Dmitry Torokhov24c29022010-02-23 23:38:01 -08001121static int __devinit twlreg_probe(struct platform_device *pdev)
David Brownellfa16a5c2009-02-08 10:37:06 -08001122{
Rajendra Nayak2098e952012-02-28 15:09:11 +05301123 int i, id;
David Brownellfa16a5c2009-02-08 10:37:06 -08001124 struct twlreg_info *info;
1125 struct regulator_init_data *initdata;
1126 struct regulation_constraints *c;
1127 struct regulator_dev *rdev;
Tero Kristo63bfff42012-02-16 12:27:52 +02001128 struct twl_regulator_driver_data *drvdata;
Rajendra Nayak2098e952012-02-28 15:09:11 +05301129 const struct of_device_id *match;
Mark Brownc1727082012-04-04 00:50:22 +01001130 struct regulator_config config = { };
David Brownellfa16a5c2009-02-08 10:37:06 -08001131
Rajendra Nayak2098e952012-02-28 15:09:11 +05301132 match = of_match_device(twl_of_match, &pdev->dev);
1133 if (match) {
1134 info = match->data;
1135 id = info->desc.id;
1136 initdata = of_get_regulator_init_data(&pdev->dev,
1137 pdev->dev.of_node);
1138 drvdata = NULL;
1139 } else {
1140 id = pdev->id;
1141 initdata = pdev->dev.platform_data;
1142 for (i = 0, info = NULL; i < ARRAY_SIZE(twl_of_match); i++) {
1143 info = twl_of_match[i].data;
Axel Lin5ade3932012-04-09 22:32:49 +08001144 if (info && info->desc.id == id)
1145 break;
Rajendra Nayak2098e952012-02-28 15:09:11 +05301146 }
Axel Lin5ade3932012-04-09 22:32:49 +08001147 if (i == ARRAY_SIZE(twl_of_match))
1148 return -ENODEV;
1149
Rajendra Nayak2098e952012-02-28 15:09:11 +05301150 drvdata = initdata->driver_data;
1151 if (!drvdata)
1152 return -EINVAL;
David Brownellfa16a5c2009-02-08 10:37:06 -08001153 }
Rajendra Nayak2098e952012-02-28 15:09:11 +05301154
David Brownellfa16a5c2009-02-08 10:37:06 -08001155 if (!info)
1156 return -ENODEV;
1157
David Brownellfa16a5c2009-02-08 10:37:06 -08001158 if (!initdata)
1159 return -EINVAL;
1160
Rajendra Nayak2098e952012-02-28 15:09:11 +05301161 if (drvdata) {
1162 /* copy the driver data into regulator data */
1163 info->features = drvdata->features;
1164 info->data = drvdata->data;
1165 info->set_voltage = drvdata->set_voltage;
1166 info->get_voltage = drvdata->get_voltage;
1167 }
Graeme Gregory4d94aee2011-05-22 21:21:23 +01001168
David Brownellfa16a5c2009-02-08 10:37:06 -08001169 /* Constrain board-specific capabilities according to what
1170 * this driver and the chip itself can actually do.
1171 */
1172 c = &initdata->constraints;
David Brownellfa16a5c2009-02-08 10:37:06 -08001173 c->valid_modes_mask &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_STANDBY;
1174 c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE
1175 | REGULATOR_CHANGE_MODE
1176 | REGULATOR_CHANGE_STATUS;
Rajendra Nayak2098e952012-02-28 15:09:11 +05301177 switch (id) {
Juha Keski-Saari205e5cd2009-12-16 15:27:56 +02001178 case TWL4030_REG_VIO:
1179 case TWL4030_REG_VDD1:
1180 case TWL4030_REG_VDD2:
1181 case TWL4030_REG_VPLL1:
1182 case TWL4030_REG_VINTANA1:
1183 case TWL4030_REG_VINTANA2:
1184 case TWL4030_REG_VINTDIG:
1185 c->always_on = true;
1186 break;
1187 default:
1188 break;
1189 }
David Brownellfa16a5c2009-02-08 10:37:06 -08001190
Rajendra Nayak2098e952012-02-28 15:09:11 +05301191 switch (id) {
Graeme Gregory4d94aee2011-05-22 21:21:23 +01001192 case TWL6025_REG_SMPS3:
1193 if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS3)
1194 info->flags |= SMPS_EXTENDED_EN;
1195 if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS3)
1196 info->flags |= SMPS_OFFSET_EN;
1197 break;
1198 case TWL6025_REG_SMPS4:
1199 if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS4)
1200 info->flags |= SMPS_EXTENDED_EN;
1201 if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS4)
1202 info->flags |= SMPS_OFFSET_EN;
1203 break;
1204 case TWL6025_REG_VIO:
1205 if (twl_get_smps_mult() & SMPS_MULTOFFSET_VIO)
1206 info->flags |= SMPS_EXTENDED_EN;
1207 if (twl_get_smps_offset() & SMPS_MULTOFFSET_VIO)
1208 info->flags |= SMPS_OFFSET_EN;
1209 break;
1210 }
1211
Mark Brownc1727082012-04-04 00:50:22 +01001212 config.dev = &pdev->dev;
1213 config.init_data = initdata;
1214 config.driver_data = info;
1215 config.of_node = pdev->dev.of_node;
1216
1217 rdev = regulator_register(&info->desc, &config);
David Brownellfa16a5c2009-02-08 10:37:06 -08001218 if (IS_ERR(rdev)) {
1219 dev_err(&pdev->dev, "can't register %s, %ld\n",
1220 info->desc.name, PTR_ERR(rdev));
1221 return PTR_ERR(rdev);
1222 }
1223 platform_set_drvdata(pdev, rdev);
1224
Saquib Herman776dc922011-04-01 10:22:43 +05301225 if (twl_class_is_4030())
1226 twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP,
Juha Keski-Saari30010fa2009-12-16 15:27:58 +02001227 info->remap);
1228
David Brownellfa16a5c2009-02-08 10:37:06 -08001229 /* NOTE: many regulators support short-circuit IRQs (presentable
1230 * as REGULATOR_OVER_CURRENT notifications?) configured via:
1231 * - SC_CONFIG
1232 * - SC_DETECT1 (vintana2, vmmc1/2, vaux1/2/3/4)
1233 * - SC_DETECT2 (vusb, vdac, vio, vdd1/2, vpll2)
1234 * - IT_CONFIG
1235 */
1236
1237 return 0;
1238}
1239
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001240static int __devexit twlreg_remove(struct platform_device *pdev)
David Brownellfa16a5c2009-02-08 10:37:06 -08001241{
1242 regulator_unregister(platform_get_drvdata(pdev));
1243 return 0;
1244}
1245
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001246MODULE_ALIAS("platform:twl_reg");
David Brownellfa16a5c2009-02-08 10:37:06 -08001247
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001248static struct platform_driver twlreg_driver = {
1249 .probe = twlreg_probe,
1250 .remove = __devexit_p(twlreg_remove),
David Brownellfa16a5c2009-02-08 10:37:06 -08001251 /* NOTE: short name, to work around driver model truncation of
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001252 * "twl_regulator.12" (and friends) to "twl_regulator.1".
David Brownellfa16a5c2009-02-08 10:37:06 -08001253 */
Rajendra Nayak2098e952012-02-28 15:09:11 +05301254 .driver = {
1255 .name = "twl_reg",
1256 .owner = THIS_MODULE,
1257 .of_match_table = of_match_ptr(twl_of_match),
1258 },
David Brownellfa16a5c2009-02-08 10:37:06 -08001259};
1260
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001261static int __init twlreg_init(void)
David Brownellfa16a5c2009-02-08 10:37:06 -08001262{
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001263 return platform_driver_register(&twlreg_driver);
David Brownellfa16a5c2009-02-08 10:37:06 -08001264}
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001265subsys_initcall(twlreg_init);
David Brownellfa16a5c2009-02-08 10:37:06 -08001266
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001267static void __exit twlreg_exit(void)
David Brownellfa16a5c2009-02-08 10:37:06 -08001268{
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001269 platform_driver_unregister(&twlreg_driver);
David Brownellfa16a5c2009-02-08 10:37:06 -08001270}
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001271module_exit(twlreg_exit)
David Brownellfa16a5c2009-02-08 10:37:06 -08001272
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001273MODULE_DESCRIPTION("TWL regulator driver");
David Brownellfa16a5c2009-02-08 10:37:06 -08001274MODULE_LICENSE("GPL");