blob: fffacb4837adbd9258fd4e175929179a2b328973 [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 /* regulator specific turn-on delay */
47 u16 delay;
48
49 /* State REMAP default configuration */
50 u8 remap;
51
David Brownellfa16a5c2009-02-08 10:37:06 -080052 /* chip constraints on regulator behavior */
53 u16 min_mV;
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +053054 u16 max_mV;
David Brownellfa16a5c2009-02-08 10:37:06 -080055
Graeme Gregory4d94aee2011-05-22 21:21:23 +010056 u8 flags;
57
David Brownellfa16a5c2009-02-08 10:37:06 -080058 /* used by regulator core */
59 struct regulator_desc desc;
Graeme Gregory4d94aee2011-05-22 21:21:23 +010060
61 /* chip specific features */
62 unsigned long features;
Tero Kristo63bfff42012-02-16 12:27:52 +020063
64 /*
65 * optional override functions for voltage set/get
66 * these are currently only used for SMPS regulators
67 */
68 int (*get_voltage)(void *data);
69 int (*set_voltage)(void *data, int target_uV);
70
71 /* data passed from board for external get/set voltage */
72 void *data;
David Brownellfa16a5c2009-02-08 10:37:06 -080073};
74
75
76/* LDO control registers ... offset is from the base of its register bank.
77 * The first three registers of all power resource banks help hardware to
78 * manage the various resource groups.
79 */
Rajendra Nayak441a4502009-12-13 22:19:23 +010080/* Common offset in TWL4030/6030 */
David Brownellfa16a5c2009-02-08 10:37:06 -080081#define VREG_GRP 0
Rajendra Nayak441a4502009-12-13 22:19:23 +010082/* TWL4030 register offsets */
David Brownellfa16a5c2009-02-08 10:37:06 -080083#define VREG_TYPE 1
84#define VREG_REMAP 2
85#define VREG_DEDICATED 3 /* LDO control */
Tero Kristoba305e32011-11-28 16:53:19 +020086#define VREG_VOLTAGE_SMPS_4030 9
Rajendra Nayak441a4502009-12-13 22:19:23 +010087/* TWL6030 register offsets */
88#define VREG_TRANS 1
89#define VREG_STATE 2
90#define VREG_VOLTAGE 3
Graeme Gregory4d94aee2011-05-22 21:21:23 +010091#define VREG_VOLTAGE_SMPS 4
Rajendra Nayak441a4502009-12-13 22:19:23 +010092/* TWL6030 Misc register offsets */
93#define VREG_BC_ALL 1
94#define VREG_BC_REF 2
95#define VREG_BC_PROC 3
96#define VREG_BC_CLK_RST 4
David Brownellfa16a5c2009-02-08 10:37:06 -080097
Saquib Herman21657ebf2011-04-01 10:22:42 +053098/* TWL6030 LDO register values for CFG_STATE */
99#define TWL6030_CFG_STATE_OFF 0x00
100#define TWL6030_CFG_STATE_ON 0x01
Saquib Herman9a0244a2011-04-01 10:22:45 +0530101#define TWL6030_CFG_STATE_OFF2 0x02
102#define TWL6030_CFG_STATE_SLEEP 0x03
Saquib Herman21657ebf2011-04-01 10:22:42 +0530103#define TWL6030_CFG_STATE_GRP_SHIFT 5
Saquib Hermanb2456772011-04-01 10:22:44 +0530104#define TWL6030_CFG_STATE_APP_SHIFT 2
105#define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT)
106#define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\
107 TWL6030_CFG_STATE_APP_SHIFT)
Saquib Herman21657ebf2011-04-01 10:22:42 +0530108
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100109/* Flags for SMPS Voltage reading */
110#define SMPS_OFFSET_EN BIT(0)
111#define SMPS_EXTENDED_EN BIT(1)
112
113/* twl6025 SMPS EPROM values */
114#define TWL6030_SMPS_OFFSET 0xB0
115#define TWL6030_SMPS_MULT 0xB3
116#define SMPS_MULTOFFSET_SMPS4 BIT(0)
117#define SMPS_MULTOFFSET_VIO BIT(1)
118#define SMPS_MULTOFFSET_SMPS3 BIT(6)
119
David Brownellfa16a5c2009-02-08 10:37:06 -0800120static inline int
Rajendra Nayak441a4502009-12-13 22:19:23 +0100121twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset)
David Brownellfa16a5c2009-02-08 10:37:06 -0800122{
123 u8 value;
124 int status;
125
Rajendra Nayak441a4502009-12-13 22:19:23 +0100126 status = twl_i2c_read_u8(slave_subgp,
David Brownellfa16a5c2009-02-08 10:37:06 -0800127 &value, info->base + offset);
128 return (status < 0) ? status : value;
129}
130
131static inline int
Rajendra Nayak441a4502009-12-13 22:19:23 +0100132twlreg_write(struct twlreg_info *info, unsigned slave_subgp, unsigned offset,
133 u8 value)
David Brownellfa16a5c2009-02-08 10:37:06 -0800134{
Rajendra Nayak441a4502009-12-13 22:19:23 +0100135 return twl_i2c_write_u8(slave_subgp,
David Brownellfa16a5c2009-02-08 10:37:06 -0800136 value, info->base + offset);
137}
138
139/*----------------------------------------------------------------------*/
140
141/* generic power resource operations, which work on all regulators */
142
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100143static int twlreg_grp(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800144{
Rajendra Nayak441a4502009-12-13 22:19:23 +0100145 return twlreg_read(rdev_get_drvdata(rdev), TWL_MODULE_PM_RECEIVER,
146 VREG_GRP);
David Brownellfa16a5c2009-02-08 10:37:06 -0800147}
148
149/*
150 * Enable/disable regulators by joining/leaving the P1 (processor) group.
151 * We assume nobody else is updating the DEV_GRP registers.
152 */
Rajendra Nayak441a4502009-12-13 22:19:23 +0100153/* definition for 4030 family */
154#define P3_GRP_4030 BIT(7) /* "peripherals" */
155#define P2_GRP_4030 BIT(6) /* secondary processor, modem, etc */
156#define P1_GRP_4030 BIT(5) /* CPU/Linux */
157/* definition for 6030 family */
158#define P3_GRP_6030 BIT(2) /* secondary processor, modem, etc */
159#define P2_GRP_6030 BIT(1) /* "peripherals" */
160#define P1_GRP_6030 BIT(0) /* CPU/Linux */
David Brownellfa16a5c2009-02-08 10:37:06 -0800161
Saquib Hermanb2456772011-04-01 10:22:44 +0530162static int twl4030reg_is_enabled(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800163{
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100164 int state = twlreg_grp(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800165
166 if (state < 0)
167 return state;
168
Saquib Hermanb2456772011-04-01 10:22:44 +0530169 return state & P1_GRP_4030;
170}
171
172static int twl6030reg_is_enabled(struct regulator_dev *rdev)
173{
174 struct twlreg_info *info = rdev_get_drvdata(rdev);
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100175 int grp = 0, val;
Saquib Hermanb2456772011-04-01 10:22:44 +0530176
Axel Linb6f476c2012-04-11 11:07:17 +0800177 if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS))) {
178 grp = twlreg_grp(rdev);
179 if (grp < 0)
180 return grp;
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100181 grp &= P1_GRP_6030;
Axel Linb6f476c2012-04-11 11:07:17 +0800182 } else {
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100183 grp = 1;
Axel Linb6f476c2012-04-11 11:07:17 +0800184 }
Saquib Hermanb2456772011-04-01 10:22:44 +0530185
186 val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
187 val = TWL6030_CFG_STATE_APP(val);
188
189 return grp && (val == TWL6030_CFG_STATE_ON);
David Brownellfa16a5c2009-02-08 10:37:06 -0800190}
191
Balaji T Kf8c29402011-05-20 19:03:51 +0530192static int twl4030reg_enable(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800193{
194 struct twlreg_info *info = rdev_get_drvdata(rdev);
195 int grp;
Juha Keski-Saari53b8a9d2009-12-16 14:55:26 +0200196 int ret;
David Brownellfa16a5c2009-02-08 10:37:06 -0800197
Axel Linb6f476c2012-04-11 11:07:17 +0800198 grp = twlreg_grp(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800199 if (grp < 0)
200 return grp;
201
Balaji T Kf8c29402011-05-20 19:03:51 +0530202 grp |= P1_GRP_4030;
Rajendra Nayak441a4502009-12-13 22:19:23 +0100203
Juha Keski-Saari53b8a9d2009-12-16 14:55:26 +0200204 ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
205
Balaji T Kf8c29402011-05-20 19:03:51 +0530206 return ret;
207}
208
209static int twl6030reg_enable(struct regulator_dev *rdev)
210{
211 struct twlreg_info *info = rdev_get_drvdata(rdev);
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100212 int grp = 0;
Balaji T Kf8c29402011-05-20 19:03:51 +0530213 int ret;
214
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100215 if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
Axel Linb6f476c2012-04-11 11:07:17 +0800216 grp = twlreg_grp(rdev);
Balaji T Kf8c29402011-05-20 19:03:51 +0530217 if (grp < 0)
218 return grp;
219
220 ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE,
221 grp << TWL6030_CFG_STATE_GRP_SHIFT |
222 TWL6030_CFG_STATE_ON);
Juha Keski-Saari53b8a9d2009-12-16 14:55:26 +0200223 return ret;
David Brownellfa16a5c2009-02-08 10:37:06 -0800224}
225
Axel Lin48c936d2012-04-11 11:05:57 +0800226static int twl4030reg_enable_time(struct regulator_dev *rdev)
227{
228 struct twlreg_info *info = rdev_get_drvdata(rdev);
229
230 return info->delay;
231}
232
233static int twl6030reg_enable_time(struct regulator_dev *rdev)
234{
235 struct twlreg_info *info = rdev_get_drvdata(rdev);
236
237 return info->delay;
238}
239
Balaji T K0ff38972011-05-20 19:03:52 +0530240static int twl4030reg_disable(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800241{
242 struct twlreg_info *info = rdev_get_drvdata(rdev);
243 int grp;
Saquib Herman21657ebf2011-04-01 10:22:42 +0530244 int ret;
David Brownellfa16a5c2009-02-08 10:37:06 -0800245
Axel Linb6f476c2012-04-11 11:07:17 +0800246 grp = twlreg_grp(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800247 if (grp < 0)
248 return grp;
249
Balaji T K0ff38972011-05-20 19:03:52 +0530250 grp &= ~(P1_GRP_4030 | P2_GRP_4030 | P3_GRP_4030);
Rajendra Nayak441a4502009-12-13 22:19:23 +0100251
Saquib Herman21657ebf2011-04-01 10:22:42 +0530252 ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
253
Balaji T K0ff38972011-05-20 19:03:52 +0530254 return ret;
255}
256
257static int twl6030reg_disable(struct regulator_dev *rdev)
258{
259 struct twlreg_info *info = rdev_get_drvdata(rdev);
260 int grp = 0;
261 int ret;
262
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100263 if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
264 grp = P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030;
Balaji T K0ff38972011-05-20 19:03:52 +0530265
266 /* For 6030, set the off state for all grps enabled */
267 ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE,
268 (grp) << TWL6030_CFG_STATE_GRP_SHIFT |
269 TWL6030_CFG_STATE_OFF);
Saquib Herman21657ebf2011-04-01 10:22:42 +0530270
271 return ret;
David Brownellfa16a5c2009-02-08 10:37:06 -0800272}
273
Saquib Herman9a0244a2011-04-01 10:22:45 +0530274static int twl4030reg_get_status(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800275{
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100276 int state = twlreg_grp(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800277
278 if (state < 0)
279 return state;
280 state &= 0x0f;
281
282 /* assume state != WARM_RESET; we'd not be running... */
283 if (!state)
284 return REGULATOR_STATUS_OFF;
285 return (state & BIT(3))
286 ? REGULATOR_STATUS_NORMAL
287 : REGULATOR_STATUS_STANDBY;
288}
289
Saquib Herman9a0244a2011-04-01 10:22:45 +0530290static int twl6030reg_get_status(struct regulator_dev *rdev)
291{
292 struct twlreg_info *info = rdev_get_drvdata(rdev);
293 int val;
294
295 val = twlreg_grp(rdev);
296 if (val < 0)
297 return val;
298
299 val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
300
301 switch (TWL6030_CFG_STATE_APP(val)) {
302 case TWL6030_CFG_STATE_ON:
303 return REGULATOR_STATUS_NORMAL;
304
305 case TWL6030_CFG_STATE_SLEEP:
306 return REGULATOR_STATUS_STANDBY;
307
308 case TWL6030_CFG_STATE_OFF:
309 case TWL6030_CFG_STATE_OFF2:
310 default:
311 break;
312 }
313
314 return REGULATOR_STATUS_OFF;
315}
316
Saquib Herman1a399622011-04-01 10:22:46 +0530317static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode)
David Brownellfa16a5c2009-02-08 10:37:06 -0800318{
319 struct twlreg_info *info = rdev_get_drvdata(rdev);
320 unsigned message;
321 int status;
322
323 /* We can only set the mode through state machine commands... */
324 switch (mode) {
325 case REGULATOR_MODE_NORMAL:
326 message = MSG_SINGULAR(DEV_GRP_P1, info->id, RES_STATE_ACTIVE);
327 break;
328 case REGULATOR_MODE_STANDBY:
329 message = MSG_SINGULAR(DEV_GRP_P1, info->id, RES_STATE_SLEEP);
330 break;
331 default:
332 return -EINVAL;
333 }
334
335 /* Ensure the resource is associated with some group */
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100336 status = twlreg_grp(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800337 if (status < 0)
338 return status;
Rajendra Nayak441a4502009-12-13 22:19:23 +0100339 if (!(status & (P3_GRP_4030 | P2_GRP_4030 | P1_GRP_4030)))
David Brownellfa16a5c2009-02-08 10:37:06 -0800340 return -EACCES;
341
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100342 status = twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
Axel Linb9e26bc2010-10-22 16:38:22 +0800343 message >> 8, TWL4030_PM_MASTER_PB_WORD_MSB);
344 if (status < 0)
David Brownellfa16a5c2009-02-08 10:37:06 -0800345 return status;
346
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100347 return twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
Axel Linb9e26bc2010-10-22 16:38:22 +0800348 message & 0xff, TWL4030_PM_MASTER_PB_WORD_LSB);
David Brownellfa16a5c2009-02-08 10:37:06 -0800349}
350
Saquib Herman1a399622011-04-01 10:22:46 +0530351static int twl6030reg_set_mode(struct regulator_dev *rdev, unsigned mode)
352{
353 struct twlreg_info *info = rdev_get_drvdata(rdev);
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100354 int grp = 0;
Saquib Herman1a399622011-04-01 10:22:46 +0530355 int val;
356
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100357 if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS)))
Axel Linb6f476c2012-04-11 11:07:17 +0800358 grp = twlreg_grp(rdev);
Saquib Herman1a399622011-04-01 10:22:46 +0530359
360 if (grp < 0)
361 return grp;
362
363 /* Compose the state register settings */
364 val = grp << TWL6030_CFG_STATE_GRP_SHIFT;
365 /* We can only set the mode through state machine commands... */
366 switch (mode) {
367 case REGULATOR_MODE_NORMAL:
368 val |= TWL6030_CFG_STATE_ON;
369 break;
370 case REGULATOR_MODE_STANDBY:
371 val |= TWL6030_CFG_STATE_SLEEP;
372 break;
373
374 default:
375 return -EINVAL;
376 }
377
378 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, val);
379}
380
David Brownellfa16a5c2009-02-08 10:37:06 -0800381/*----------------------------------------------------------------------*/
382
383/*
384 * Support for adjustable-voltage LDOs uses a four bit (or less) voltage
385 * select field in its control register. We use tables indexed by VSEL
386 * to record voltages in milliVolts. (Accuracy is about three percent.)
387 *
388 * Note that VSEL values for VAUX2 changed in twl5030 and newer silicon;
389 * currently handled by listing two slightly different VAUX2 regulators,
390 * only one of which will be configured.
391 *
392 * VSEL values documented as "TI cannot support these values" are flagged
393 * in these tables as UNSUP() values; we normally won't assign them.
Adrian Hunterd6bb69c2009-03-06 14:51:30 +0200394 *
395 * VAUX3 at 3V is incorrectly listed in some TI manuals as unsupported.
396 * TI are revising the twl5030/tps659x0 specs to support that 3.0V setting.
David Brownellfa16a5c2009-02-08 10:37:06 -0800397 */
398#ifdef CONFIG_TWL4030_ALLOW_UNSUPPORTED
399#define UNSUP_MASK 0x0000
400#else
401#define UNSUP_MASK 0x8000
402#endif
403
404#define UNSUP(x) (UNSUP_MASK | (x))
405#define IS_UNSUP(x) (UNSUP_MASK & (x))
406#define LDO_MV(x) (~UNSUP_MASK & (x))
407
408
409static const u16 VAUX1_VSEL_table[] = {
410 UNSUP(1500), UNSUP(1800), 2500, 2800,
411 3000, 3000, 3000, 3000,
412};
413static const u16 VAUX2_4030_VSEL_table[] = {
414 UNSUP(1000), UNSUP(1000), UNSUP(1200), 1300,
415 1500, 1800, UNSUP(1850), 2500,
416 UNSUP(2600), 2800, UNSUP(2850), UNSUP(3000),
417 UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
418};
419static const u16 VAUX2_VSEL_table[] = {
420 1700, 1700, 1900, 1300,
421 1500, 1800, 2000, 2500,
422 2100, 2800, 2200, 2300,
423 2400, 2400, 2400, 2400,
424};
425static const u16 VAUX3_VSEL_table[] = {
426 1500, 1800, 2500, 2800,
Adrian Hunterd6bb69c2009-03-06 14:51:30 +0200427 3000, 3000, 3000, 3000,
David Brownellfa16a5c2009-02-08 10:37:06 -0800428};
429static const u16 VAUX4_VSEL_table[] = {
430 700, 1000, 1200, UNSUP(1300),
431 1500, 1800, UNSUP(1850), 2500,
David Brownell1897e742009-03-10 11:51:15 -0800432 UNSUP(2600), 2800, UNSUP(2850), UNSUP(3000),
433 UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
David Brownellfa16a5c2009-02-08 10:37:06 -0800434};
435static const u16 VMMC1_VSEL_table[] = {
436 1850, 2850, 3000, 3150,
437};
438static const u16 VMMC2_VSEL_table[] = {
439 UNSUP(1000), UNSUP(1000), UNSUP(1200), UNSUP(1300),
440 UNSUP(1500), UNSUP(1800), 1850, UNSUP(2500),
441 2600, 2800, 2850, 3000,
442 3150, 3150, 3150, 3150,
443};
444static const u16 VPLL1_VSEL_table[] = {
445 1000, 1200, 1300, 1800,
446 UNSUP(2800), UNSUP(3000), UNSUP(3000), UNSUP(3000),
447};
448static const u16 VPLL2_VSEL_table[] = {
449 700, 1000, 1200, 1300,
450 UNSUP(1500), 1800, UNSUP(1850), UNSUP(2500),
451 UNSUP(2600), UNSUP(2800), UNSUP(2850), UNSUP(3000),
452 UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
453};
454static const u16 VSIM_VSEL_table[] = {
455 UNSUP(1000), UNSUP(1200), UNSUP(1300), 1800,
456 2800, 3000, 3000, 3000,
457};
458static const u16 VDAC_VSEL_table[] = {
459 1200, 1300, 1800, 1800,
460};
Juha Keski-Saari07fc4932009-12-16 15:27:55 +0200461static const u16 VDD1_VSEL_table[] = {
462 800, 1450,
463};
464static const u16 VDD2_VSEL_table[] = {
465 800, 1450, 1500,
466};
467static const u16 VIO_VSEL_table[] = {
468 1800, 1850,
469};
470static const u16 VINTANA2_VSEL_table[] = {
471 2500, 2750,
472};
David Brownellfa16a5c2009-02-08 10:37:06 -0800473
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530474static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
David Brownell66b659e2009-02-26 11:50:14 -0800475{
476 struct twlreg_info *info = rdev_get_drvdata(rdev);
477 int mV = info->table[index];
478
479 return IS_UNSUP(mV) ? 0 : (LDO_MV(mV) * 1000);
480}
481
David Brownellfa16a5c2009-02-08 10:37:06 -0800482static int
Axel Lindd16b1f2012-03-26 09:30:06 +0800483twl4030ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
David Brownellfa16a5c2009-02-08 10:37:06 -0800484{
485 struct twlreg_info *info = rdev_get_drvdata(rdev);
David Brownellfa16a5c2009-02-08 10:37:06 -0800486
Axel Lindd16b1f2012-03-26 09:30:06 +0800487 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE,
488 selector);
David Brownellfa16a5c2009-02-08 10:37:06 -0800489}
490
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530491static int twl4030ldo_get_voltage(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800492{
493 struct twlreg_info *info = rdev_get_drvdata(rdev);
Rajendra Nayak441a4502009-12-13 22:19:23 +0100494 int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
495 VREG_VOLTAGE);
David Brownellfa16a5c2009-02-08 10:37:06 -0800496
497 if (vsel < 0)
498 return vsel;
499
500 vsel &= info->table_len - 1;
501 return LDO_MV(info->table[vsel]) * 1000;
502}
503
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530504static struct regulator_ops twl4030ldo_ops = {
505 .list_voltage = twl4030ldo_list_voltage,
David Brownell66b659e2009-02-26 11:50:14 -0800506
Axel Lindd16b1f2012-03-26 09:30:06 +0800507 .set_voltage_sel = twl4030ldo_set_voltage_sel,
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530508 .get_voltage = twl4030ldo_get_voltage,
509
Balaji T Kf8c29402011-05-20 19:03:51 +0530510 .enable = twl4030reg_enable,
Balaji T K0ff38972011-05-20 19:03:52 +0530511 .disable = twl4030reg_disable,
Saquib Hermanb2456772011-04-01 10:22:44 +0530512 .is_enabled = twl4030reg_is_enabled,
Axel Lin48c936d2012-04-11 11:05:57 +0800513 .enable_time = twl4030reg_enable_time,
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530514
Saquib Herman1a399622011-04-01 10:22:46 +0530515 .set_mode = twl4030reg_set_mode,
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530516
Saquib Herman9a0244a2011-04-01 10:22:45 +0530517 .get_status = twl4030reg_get_status,
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530518};
519
Tero Kristoba305e32011-11-28 16:53:19 +0200520static int
521twl4030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
522 unsigned *selector)
523{
524 struct twlreg_info *info = rdev_get_drvdata(rdev);
525 int vsel = DIV_ROUND_UP(min_uV - 600000, 12500);
526
Tero Kristo63bfff42012-02-16 12:27:52 +0200527 if (info->set_voltage) {
528 return info->set_voltage(info->data, min_uV);
529 } else {
530 twlreg_write(info, TWL_MODULE_PM_RECEIVER,
531 VREG_VOLTAGE_SMPS_4030, vsel);
532 }
533
Tero Kristoba305e32011-11-28 16:53:19 +0200534 return 0;
535}
536
537static int twl4030smps_get_voltage(struct regulator_dev *rdev)
538{
539 struct twlreg_info *info = rdev_get_drvdata(rdev);
Tero Kristo63bfff42012-02-16 12:27:52 +0200540 int vsel;
541
542 if (info->get_voltage)
543 return info->get_voltage(info->data);
544
545 vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
Tero Kristoba305e32011-11-28 16:53:19 +0200546 VREG_VOLTAGE_SMPS_4030);
547
548 return vsel * 12500 + 600000;
549}
550
551static struct regulator_ops twl4030smps_ops = {
552 .set_voltage = twl4030smps_set_voltage,
553 .get_voltage = twl4030smps_get_voltage,
554};
555
Tero Kristo34a38442012-02-28 15:09:10 +0530556static int twl6030coresmps_set_voltage(struct regulator_dev *rdev, int min_uV,
557 int max_uV, unsigned *selector)
558{
559 struct twlreg_info *info = rdev_get_drvdata(rdev);
560
561 if (info->set_voltage)
562 return info->set_voltage(info->data, min_uV);
563
564 return -ENODEV;
565}
566
567static int twl6030coresmps_get_voltage(struct regulator_dev *rdev)
568{
569 struct twlreg_info *info = rdev_get_drvdata(rdev);
570
571 if (info->get_voltage)
572 return info->get_voltage(info->data);
573
574 return -ENODEV;
575}
576
577static struct regulator_ops twl6030coresmps_ops = {
578 .set_voltage = twl6030coresmps_set_voltage,
579 .get_voltage = twl6030coresmps_get_voltage,
580};
581
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530582static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
583{
584 struct twlreg_info *info = rdev_get_drvdata(rdev);
585
586 return ((info->min_mV + (index * 100)) * 1000);
587}
588
589static int
Mark Brown3a93f2a2010-11-10 14:38:29 +0000590twl6030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
591 unsigned *selector)
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530592{
593 struct twlreg_info *info = rdev_get_drvdata(rdev);
594 int vsel;
595
596 if ((min_uV/1000 < info->min_mV) || (max_uV/1000 > info->max_mV))
597 return -EDOM;
598
599 /*
600 * Use the below formula to calculate vsel
601 * mV = 1000mv + 100mv * (vsel - 1)
602 */
603 vsel = (min_uV/1000 - 1000)/100 + 1;
Mark Brown3a93f2a2010-11-10 14:38:29 +0000604 *selector = vsel;
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530605 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, vsel);
606
607}
608
609static int twl6030ldo_get_voltage(struct regulator_dev *rdev)
610{
611 struct twlreg_info *info = rdev_get_drvdata(rdev);
612 int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER,
613 VREG_VOLTAGE);
614
615 if (vsel < 0)
616 return vsel;
617
618 /*
619 * Use the below formula to calculate vsel
620 * mV = 1000mv + 100mv * (vsel - 1)
621 */
622 return (1000 + (100 * (vsel - 1))) * 1000;
623}
624
625static struct regulator_ops twl6030ldo_ops = {
626 .list_voltage = twl6030ldo_list_voltage,
627
628 .set_voltage = twl6030ldo_set_voltage,
629 .get_voltage = twl6030ldo_get_voltage,
David Brownellfa16a5c2009-02-08 10:37:06 -0800630
Balaji T Kf8c29402011-05-20 19:03:51 +0530631 .enable = twl6030reg_enable,
Balaji T K0ff38972011-05-20 19:03:52 +0530632 .disable = twl6030reg_disable,
Saquib Hermanb2456772011-04-01 10:22:44 +0530633 .is_enabled = twl6030reg_is_enabled,
Axel Lin48c936d2012-04-11 11:05:57 +0800634 .enable_time = twl6030reg_enable_time,
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
641/*----------------------------------------------------------------------*/
642
643/*
644 * Fixed voltage LDOs don't have a VSEL field to update.
645 */
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100646static int twlfixed_list_voltage(struct regulator_dev *rdev, unsigned index)
David Brownell66b659e2009-02-26 11:50:14 -0800647{
648 struct twlreg_info *info = rdev_get_drvdata(rdev);
649
650 return info->min_mV * 1000;
651}
652
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100653static int twlfixed_get_voltage(struct regulator_dev *rdev)
David Brownellfa16a5c2009-02-08 10:37:06 -0800654{
655 struct twlreg_info *info = rdev_get_drvdata(rdev);
656
657 return info->min_mV * 1000;
658}
659
Saquib Hermanb2456772011-04-01 10:22:44 +0530660static struct regulator_ops twl4030fixed_ops = {
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100661 .list_voltage = twlfixed_list_voltage,
David Brownell66b659e2009-02-26 11:50:14 -0800662
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100663 .get_voltage = twlfixed_get_voltage,
David Brownellfa16a5c2009-02-08 10:37:06 -0800664
Balaji T Kf8c29402011-05-20 19:03:51 +0530665 .enable = twl4030reg_enable,
Balaji T K0ff38972011-05-20 19:03:52 +0530666 .disable = twl4030reg_disable,
Saquib Hermanb2456772011-04-01 10:22:44 +0530667 .is_enabled = twl4030reg_is_enabled,
Axel Lin48c936d2012-04-11 11:05:57 +0800668 .enable_time = twl4030reg_enable_time,
Saquib Hermanb2456772011-04-01 10:22:44 +0530669
Saquib Herman1a399622011-04-01 10:22:46 +0530670 .set_mode = twl4030reg_set_mode,
Saquib Hermanb2456772011-04-01 10:22:44 +0530671
Saquib Herman9a0244a2011-04-01 10:22:45 +0530672 .get_status = twl4030reg_get_status,
Saquib Hermanb2456772011-04-01 10:22:44 +0530673};
674
675static struct regulator_ops twl6030fixed_ops = {
676 .list_voltage = twlfixed_list_voltage,
677
678 .get_voltage = twlfixed_get_voltage,
679
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,
Axel Lin48c936d2012-04-11 11:05:57 +0800683 .enable_time = twl6030reg_enable_time,
David Brownellfa16a5c2009-02-08 10:37:06 -0800684
Saquib Herman1a399622011-04-01 10:22:46 +0530685 .set_mode = twl6030reg_set_mode,
David Brownellfa16a5c2009-02-08 10:37:06 -0800686
Saquib Herman9a0244a2011-04-01 10:22:45 +0530687 .get_status = twl6030reg_get_status,
David Brownellfa16a5c2009-02-08 10:37:06 -0800688};
689
Balaji T K8e6de4a2011-02-10 18:44:50 +0530690static struct regulator_ops twl6030_fixed_resource = {
Balaji T Kf8c29402011-05-20 19:03:51 +0530691 .enable = twl6030reg_enable,
Balaji T K0ff38972011-05-20 19:03:52 +0530692 .disable = twl6030reg_disable,
Saquib Hermanb2456772011-04-01 10:22:44 +0530693 .is_enabled = twl6030reg_is_enabled,
Axel Lin48c936d2012-04-11 11:05:57 +0800694 .enable_time = twl6030reg_enable_time,
Saquib Herman9a0244a2011-04-01 10:22:45 +0530695 .get_status = twl6030reg_get_status,
Balaji T K8e6de4a2011-02-10 18:44:50 +0530696};
697
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100698/*
699 * SMPS status and control
700 */
701
702static int twl6030smps_list_voltage(struct regulator_dev *rdev, unsigned index)
703{
704 struct twlreg_info *info = rdev_get_drvdata(rdev);
705
706 int voltage = 0;
707
708 switch (info->flags) {
709 case SMPS_OFFSET_EN:
710 voltage = 100000;
711 /* fall through */
712 case 0:
713 switch (index) {
714 case 0:
715 voltage = 0;
716 break;
717 case 58:
718 voltage = 1350 * 1000;
719 break;
720 case 59:
721 voltage = 1500 * 1000;
722 break;
723 case 60:
724 voltage = 1800 * 1000;
725 break;
726 case 61:
727 voltage = 1900 * 1000;
728 break;
729 case 62:
730 voltage = 2100 * 1000;
731 break;
732 default:
733 voltage += (600000 + (12500 * (index - 1)));
734 }
735 break;
736 case SMPS_EXTENDED_EN:
737 switch (index) {
738 case 0:
739 voltage = 0;
740 break;
741 case 58:
742 voltage = 2084 * 1000;
743 break;
744 case 59:
745 voltage = 2315 * 1000;
746 break;
747 case 60:
748 voltage = 2778 * 1000;
749 break;
750 case 61:
751 voltage = 2932 * 1000;
752 break;
753 case 62:
754 voltage = 3241 * 1000;
755 break;
756 default:
757 voltage = (1852000 + (38600 * (index - 1)));
758 }
759 break;
760 case SMPS_OFFSET_EN | SMPS_EXTENDED_EN:
761 switch (index) {
762 case 0:
763 voltage = 0;
764 break;
765 case 58:
766 voltage = 4167 * 1000;
767 break;
768 case 59:
769 voltage = 2315 * 1000;
770 break;
771 case 60:
772 voltage = 2778 * 1000;
773 break;
774 case 61:
775 voltage = 2932 * 1000;
776 break;
777 case 62:
778 voltage = 3241 * 1000;
779 break;
780 default:
781 voltage = (2161000 + (38600 * (index - 1)));
782 }
783 break;
784 }
785
786 return voltage;
787}
788
789static int
790twl6030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV,
791 unsigned int *selector)
792{
793 struct twlreg_info *info = rdev_get_drvdata(rdev);
794 int vsel = 0;
795
796 switch (info->flags) {
797 case 0:
798 if (min_uV == 0)
799 vsel = 0;
Laxman Dewangana33b6e52012-02-03 12:54:38 +0530800 else if ((min_uV >= 600000) && (min_uV <= 1300000)) {
801 int calc_uV;
Axel Lin268a1642012-04-09 23:35:10 +0800802 vsel = DIV_ROUND_UP(min_uV - 600000, 12500);
Axel Lin0cb2f122012-04-10 23:07:52 +0800803 vsel++;
Laxman Dewangana33b6e52012-02-03 12:54:38 +0530804 calc_uV = twl6030smps_list_voltage(rdev, vsel);
805 if (calc_uV > max_uV)
806 return -EINVAL;
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100807 }
808 /* Values 1..57 for vsel are linear and can be calculated
809 * values 58..62 are non linear.
810 */
811 else if ((min_uV > 1900000) && (max_uV >= 2100000))
812 vsel = 62;
813 else if ((min_uV > 1800000) && (max_uV >= 1900000))
814 vsel = 61;
815 else if ((min_uV > 1500000) && (max_uV >= 1800000))
816 vsel = 60;
817 else if ((min_uV > 1350000) && (max_uV >= 1500000))
818 vsel = 59;
819 else if ((min_uV > 1300000) && (max_uV >= 1350000))
820 vsel = 58;
821 else
822 return -EINVAL;
823 break;
824 case SMPS_OFFSET_EN:
825 if (min_uV == 0)
826 vsel = 0;
Laxman Dewangana33b6e52012-02-03 12:54:38 +0530827 else if ((min_uV >= 700000) && (min_uV <= 1420000)) {
828 int calc_uV;
Axel Lin268a1642012-04-09 23:35:10 +0800829 vsel = DIV_ROUND_UP(min_uV - 700000, 12500);
Axel Lin0cb2f122012-04-10 23:07:52 +0800830 vsel++;
Laxman Dewangana33b6e52012-02-03 12:54:38 +0530831 calc_uV = twl6030smps_list_voltage(rdev, vsel);
832 if (calc_uV > max_uV)
833 return -EINVAL;
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100834 }
835 /* Values 1..57 for vsel are linear and can be calculated
836 * values 58..62 are non linear.
837 */
838 else if ((min_uV > 1900000) && (max_uV >= 2100000))
839 vsel = 62;
840 else if ((min_uV > 1800000) && (max_uV >= 1900000))
841 vsel = 61;
842 else if ((min_uV > 1350000) && (max_uV >= 1800000))
843 vsel = 60;
844 else if ((min_uV > 1350000) && (max_uV >= 1500000))
845 vsel = 59;
846 else if ((min_uV > 1300000) && (max_uV >= 1350000))
847 vsel = 58;
848 else
849 return -EINVAL;
850 break;
851 case SMPS_EXTENDED_EN:
Axel Lin0cb2f122012-04-10 23:07:52 +0800852 if (min_uV == 0) {
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100853 vsel = 0;
Axel Lin0cb2f122012-04-10 23:07:52 +0800854 } else if ((min_uV >= 1852000) && (max_uV <= 4013600)) {
Axel Lin268a1642012-04-09 23:35:10 +0800855 vsel = DIV_ROUND_UP(min_uV - 1852000, 38600);
Axel Lin0cb2f122012-04-10 23:07:52 +0800856 vsel++;
857 }
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100858 break;
859 case SMPS_OFFSET_EN|SMPS_EXTENDED_EN:
Axel Lin0cb2f122012-04-10 23:07:52 +0800860 if (min_uV == 0) {
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100861 vsel = 0;
Axel Lin0cb2f122012-04-10 23:07:52 +0800862 } else if ((min_uV >= 2161000) && (max_uV <= 4321000)) {
Axel Lin268a1642012-04-09 23:35:10 +0800863 vsel = DIV_ROUND_UP(min_uV - 2161000, 38600);
Axel Lin0cb2f122012-04-10 23:07:52 +0800864 vsel++;
865 }
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100866 break;
867 }
868
869 *selector = vsel;
870
871 return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS,
872 vsel);
873}
874
875static int twl6030smps_get_voltage_sel(struct regulator_dev *rdev)
876{
877 struct twlreg_info *info = rdev_get_drvdata(rdev);
878
879 return twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS);
880}
881
882static struct regulator_ops twlsmps_ops = {
883 .list_voltage = twl6030smps_list_voltage,
884
885 .set_voltage = twl6030smps_set_voltage,
886 .get_voltage_sel = twl6030smps_get_voltage_sel,
887
888 .enable = twl6030reg_enable,
889 .disable = twl6030reg_disable,
890 .is_enabled = twl6030reg_is_enabled,
Axel Lin48c936d2012-04-11 11:05:57 +0800891 .enable_time = twl6030reg_enable_time,
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100892
893 .set_mode = twl6030reg_set_mode,
894
895 .get_status = twl6030reg_get_status,
896};
897
David Brownellfa16a5c2009-02-08 10:37:06 -0800898/*----------------------------------------------------------------------*/
899
Juha Keski-Saari045f9722009-12-16 14:49:52 +0200900#define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
901 remap_conf) \
902 TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
Saquib Hermanb2456772011-04-01 10:22:44 +0530903 remap_conf, TWL4030, twl4030fixed_ops)
Ambresh Kaf8b2442011-07-09 19:02:21 -0700904#define TWL6030_FIXED_LDO(label, offset, mVolts, turnon_delay) \
905 TWL_FIXED_LDO(label, offset, mVolts, 0x0, turnon_delay, \
Saquib Hermanb2456772011-04-01 10:22:44 +0530906 0x0, TWL6030, twl6030fixed_ops)
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100907
Rajendra Nayak2098e952012-02-28 15:09:11 +0530908#define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) \
909static struct twlreg_info TWL4030_INFO_##label = { \
David Brownellfa16a5c2009-02-08 10:37:06 -0800910 .base = offset, \
911 .id = num, \
912 .table_len = ARRAY_SIZE(label##_VSEL_table), \
913 .table = label##_VSEL_table, \
Juha Keski-Saari045f9722009-12-16 14:49:52 +0200914 .delay = turnon_delay, \
915 .remap = remap_conf, \
David Brownellfa16a5c2009-02-08 10:37:06 -0800916 .desc = { \
917 .name = #label, \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530918 .id = TWL4030_REG_##label, \
David Brownell66b659e2009-02-26 11:50:14 -0800919 .n_voltages = ARRAY_SIZE(label##_VSEL_table), \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530920 .ops = &twl4030ldo_ops, \
David Brownellfa16a5c2009-02-08 10:37:06 -0800921 .type = REGULATOR_VOLTAGE, \
922 .owner = THIS_MODULE, \
923 }, \
924 }
925
Tero Kristoba305e32011-11-28 16:53:19 +0200926#define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf) \
Rajendra Nayak2098e952012-02-28 15:09:11 +0530927static struct twlreg_info TWL4030_INFO_##label = { \
Tero Kristoba305e32011-11-28 16:53:19 +0200928 .base = offset, \
929 .id = num, \
930 .delay = turnon_delay, \
931 .remap = remap_conf, \
932 .desc = { \
933 .name = #label, \
934 .id = TWL4030_REG_##label, \
935 .ops = &twl4030smps_ops, \
936 .type = REGULATOR_VOLTAGE, \
937 .owner = THIS_MODULE, \
938 }, \
939 }
940
Rajendra Nayak2098e952012-02-28 15:09:11 +0530941#define TWL6030_ADJUSTABLE_SMPS(label) \
942static struct twlreg_info TWL6030_INFO_##label = { \
Tero Kristo34a38442012-02-28 15:09:10 +0530943 .desc = { \
944 .name = #label, \
945 .id = TWL6030_REG_##label, \
946 .ops = &twl6030coresmps_ops, \
947 .type = REGULATOR_VOLTAGE, \
948 .owner = THIS_MODULE, \
949 }, \
950 }
951
Rajendra Nayak2098e952012-02-28 15:09:11 +0530952#define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \
953static struct twlreg_info TWL6030_INFO_##label = { \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530954 .base = offset, \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530955 .min_mV = min_mVolts, \
956 .max_mV = max_mVolts, \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530957 .desc = { \
958 .name = #label, \
959 .id = TWL6030_REG_##label, \
Colin Cross7736f112011-05-27 12:25:27 -0700960 .n_voltages = (max_mVolts - min_mVolts)/100 + 1, \
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530961 .ops = &twl6030ldo_ops, \
962 .type = REGULATOR_VOLTAGE, \
963 .owner = THIS_MODULE, \
964 }, \
965 }
966
Rajendra Nayak2098e952012-02-28 15:09:11 +0530967#define TWL6025_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \
968static struct twlreg_info TWL6025_INFO_##label = { \
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100969 .base = offset, \
Graeme Gregory4d94aee2011-05-22 21:21:23 +0100970 .min_mV = min_mVolts, \
971 .max_mV = max_mVolts, \
972 .desc = { \
973 .name = #label, \
974 .id = TWL6025_REG_##label, \
975 .n_voltages = ((max_mVolts - min_mVolts)/100) + 1, \
976 .ops = &twl6030ldo_ops, \
977 .type = REGULATOR_VOLTAGE, \
978 .owner = THIS_MODULE, \
979 }, \
980 }
Rajendra Nayak3e3d3be2010-04-22 14:18:32 +0530981
Juha Keski-Saari045f9722009-12-16 14:49:52 +0200982#define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \
Rajendra Nayak2098e952012-02-28 15:09:11 +0530983 family, operations) \
984static struct twlreg_info TWLFIXED_INFO_##label = { \
David Brownellfa16a5c2009-02-08 10:37:06 -0800985 .base = offset, \
986 .id = num, \
987 .min_mV = mVolts, \
Juha Keski-Saari045f9722009-12-16 14:49:52 +0200988 .delay = turnon_delay, \
989 .remap = remap_conf, \
David Brownellfa16a5c2009-02-08 10:37:06 -0800990 .desc = { \
991 .name = #label, \
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +0100992 .id = family##_REG_##label, \
David Brownell66b659e2009-02-26 11:50:14 -0800993 .n_voltages = 1, \
Saquib Hermanb2456772011-04-01 10:22:44 +0530994 .ops = &operations, \
David Brownellfa16a5c2009-02-08 10:37:06 -0800995 .type = REGULATOR_VOLTAGE, \
996 .owner = THIS_MODULE, \
997 }, \
998 }
999
Rajendra Nayak2098e952012-02-28 15:09:11 +05301000#define TWL6030_FIXED_RESOURCE(label, offset, turnon_delay) \
1001static struct twlreg_info TWLRES_INFO_##label = { \
Balaji T K8e6de4a2011-02-10 18:44:50 +05301002 .base = offset, \
Balaji T K8e6de4a2011-02-10 18:44:50 +05301003 .delay = turnon_delay, \
Balaji T K8e6de4a2011-02-10 18:44:50 +05301004 .desc = { \
1005 .name = #label, \
1006 .id = TWL6030_REG_##label, \
1007 .ops = &twl6030_fixed_resource, \
1008 .type = REGULATOR_VOLTAGE, \
1009 .owner = THIS_MODULE, \
1010 }, \
1011 }
1012
Rajendra Nayak2098e952012-02-28 15:09:11 +05301013#define TWL6025_ADJUSTABLE_SMPS(label, offset) \
1014static struct twlreg_info TWLSMPS_INFO_##label = { \
Graeme Gregory4d94aee2011-05-22 21:21:23 +01001015 .base = offset, \
Graeme Gregory4d94aee2011-05-22 21:21:23 +01001016 .min_mV = 600, \
1017 .max_mV = 2100, \
1018 .desc = { \
1019 .name = #label, \
1020 .id = TWL6025_REG_##label, \
1021 .n_voltages = 63, \
1022 .ops = &twlsmps_ops, \
1023 .type = REGULATOR_VOLTAGE, \
1024 .owner = THIS_MODULE, \
1025 }, \
1026 }
1027
David Brownellfa16a5c2009-02-08 10:37:06 -08001028/*
1029 * We list regulators here if systems need some level of
1030 * software control over them after boot.
1031 */
Rajendra Nayak2098e952012-02-28 15:09:11 +05301032TWL4030_ADJUSTABLE_LDO(VAUX1, 0x17, 1, 100, 0x08);
1033TWL4030_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2, 100, 0x08);
1034TWL4030_ADJUSTABLE_LDO(VAUX2, 0x1b, 2, 100, 0x08);
1035TWL4030_ADJUSTABLE_LDO(VAUX3, 0x1f, 3, 100, 0x08);
1036TWL4030_ADJUSTABLE_LDO(VAUX4, 0x23, 4, 100, 0x08);
1037TWL4030_ADJUSTABLE_LDO(VMMC1, 0x27, 5, 100, 0x08);
1038TWL4030_ADJUSTABLE_LDO(VMMC2, 0x2b, 6, 100, 0x08);
1039TWL4030_ADJUSTABLE_LDO(VPLL1, 0x2f, 7, 100, 0x00);
1040TWL4030_ADJUSTABLE_LDO(VPLL2, 0x33, 8, 100, 0x08);
1041TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9, 100, 0x00);
1042TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10, 100, 0x08);
1043TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08);
1044TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08);
1045TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08);
1046TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08);
1047/* VUSBCP is managed *only* by the USB subchip */
1048/* 6030 REG with base as PMC Slave Misc : 0x0030 */
1049/* Turnon-delay and remap configuration values for 6030 are not
1050 verified since the specification is not public */
1051TWL6030_ADJUSTABLE_SMPS(VDD1);
1052TWL6030_ADJUSTABLE_SMPS(VDD2);
1053TWL6030_ADJUSTABLE_SMPS(VDD3);
1054TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300);
1055TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300);
1056TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300);
1057TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300);
1058TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300);
1059TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300);
1060/* 6025 are renamed compared to 6030 versions */
1061TWL6025_ADJUSTABLE_LDO(LDO2, 0x54, 1000, 3300);
1062TWL6025_ADJUSTABLE_LDO(LDO4, 0x58, 1000, 3300);
1063TWL6025_ADJUSTABLE_LDO(LDO3, 0x5c, 1000, 3300);
1064TWL6025_ADJUSTABLE_LDO(LDO5, 0x68, 1000, 3300);
1065TWL6025_ADJUSTABLE_LDO(LDO1, 0x6c, 1000, 3300);
1066TWL6025_ADJUSTABLE_LDO(LDO7, 0x74, 1000, 3300);
1067TWL6025_ADJUSTABLE_LDO(LDO6, 0x60, 1000, 3300);
1068TWL6025_ADJUSTABLE_LDO(LDOLN, 0x64, 1000, 3300);
1069TWL6025_ADJUSTABLE_LDO(LDOUSB, 0x70, 1000, 3300);
1070TWL4030_FIXED_LDO(VINTANA2, 0x3f, 1500, 11, 100, 0x08);
1071TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08);
1072TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08);
1073TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08);
1074TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08);
1075TWL6030_FIXED_LDO(VANA, 0x50, 2100, 0);
1076TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 0);
1077TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 0);
1078TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 0);
Peter Ujfalusie9d47fa2012-02-28 15:09:12 +05301079TWL6030_FIXED_LDO(V1V8, 0x16, 1800, 0);
1080TWL6030_FIXED_LDO(V2V1, 0x1c, 2100, 0);
Rajendra Nayak2098e952012-02-28 15:09:11 +05301081TWL6030_FIXED_RESOURCE(CLK32KG, 0x8C, 0);
1082TWL6025_ADJUSTABLE_SMPS(SMPS3, 0x34);
1083TWL6025_ADJUSTABLE_SMPS(SMPS4, 0x10);
1084TWL6025_ADJUSTABLE_SMPS(VIO, 0x16);
David Brownellfa16a5c2009-02-08 10:37:06 -08001085
Graeme Gregory4d94aee2011-05-22 21:21:23 +01001086static u8 twl_get_smps_offset(void)
1087{
1088 u8 value;
1089
1090 twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value,
1091 TWL6030_SMPS_OFFSET);
1092 return value;
1093}
1094
1095static u8 twl_get_smps_mult(void)
1096{
1097 u8 value;
1098
1099 twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value,
1100 TWL6030_SMPS_MULT);
1101 return value;
1102}
1103
Rajendra Nayak2098e952012-02-28 15:09:11 +05301104#define TWL_OF_MATCH(comp, family, label) \
1105 { \
1106 .compatible = comp, \
1107 .data = &family##_INFO_##label, \
1108 }
1109
1110#define TWL4030_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL4030, label)
1111#define TWL6030_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6030, label)
1112#define TWL6025_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWL6025, label)
1113#define TWLFIXED_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLFIXED, label)
1114#define TWLRES_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLRES, label)
1115#define TWLSMPS_OF_MATCH(comp, label) TWL_OF_MATCH(comp, TWLSMPS, label)
1116
1117static const struct of_device_id twl_of_match[] __devinitconst = {
1118 TWL4030_OF_MATCH("ti,twl4030-vaux1", VAUX1),
1119 TWL4030_OF_MATCH("ti,twl4030-vaux2", VAUX2_4030),
1120 TWL4030_OF_MATCH("ti,twl5030-vaux2", VAUX2),
1121 TWL4030_OF_MATCH("ti,twl4030-vaux3", VAUX3),
1122 TWL4030_OF_MATCH("ti,twl4030-vaux4", VAUX4),
1123 TWL4030_OF_MATCH("ti,twl4030-vmmc1", VMMC1),
1124 TWL4030_OF_MATCH("ti,twl4030-vmmc2", VMMC2),
1125 TWL4030_OF_MATCH("ti,twl4030-vpll1", VPLL1),
1126 TWL4030_OF_MATCH("ti,twl4030-vpll2", VPLL2),
1127 TWL4030_OF_MATCH("ti,twl4030-vsim", VSIM),
1128 TWL4030_OF_MATCH("ti,twl4030-vdac", VDAC),
1129 TWL4030_OF_MATCH("ti,twl4030-vintana2", VINTANA2),
1130 TWL4030_OF_MATCH("ti,twl4030-vio", VIO),
1131 TWL4030_OF_MATCH("ti,twl4030-vdd1", VDD1),
1132 TWL4030_OF_MATCH("ti,twl4030-vdd2", VDD2),
1133 TWL6030_OF_MATCH("ti,twl6030-vdd1", VDD1),
1134 TWL6030_OF_MATCH("ti,twl6030-vdd2", VDD2),
1135 TWL6030_OF_MATCH("ti,twl6030-vdd3", VDD3),
1136 TWL6030_OF_MATCH("ti,twl6030-vaux1", VAUX1_6030),
1137 TWL6030_OF_MATCH("ti,twl6030-vaux2", VAUX2_6030),
1138 TWL6030_OF_MATCH("ti,twl6030-vaux3", VAUX3_6030),
1139 TWL6030_OF_MATCH("ti,twl6030-vmmc", VMMC),
1140 TWL6030_OF_MATCH("ti,twl6030-vpp", VPP),
1141 TWL6030_OF_MATCH("ti,twl6030-vusim", VUSIM),
1142 TWL6025_OF_MATCH("ti,twl6025-ldo2", LDO2),
1143 TWL6025_OF_MATCH("ti,twl6025-ldo4", LDO4),
1144 TWL6025_OF_MATCH("ti,twl6025-ldo3", LDO3),
1145 TWL6025_OF_MATCH("ti,twl6025-ldo5", LDO5),
1146 TWL6025_OF_MATCH("ti,twl6025-ldo1", LDO1),
1147 TWL6025_OF_MATCH("ti,twl6025-ldo7", LDO7),
1148 TWL6025_OF_MATCH("ti,twl6025-ldo6", LDO6),
1149 TWL6025_OF_MATCH("ti,twl6025-ldoln", LDOLN),
1150 TWL6025_OF_MATCH("ti,twl6025-ldousb", LDOUSB),
1151 TWLFIXED_OF_MATCH("ti,twl4030-vintana2", VINTANA2),
1152 TWLFIXED_OF_MATCH("ti,twl4030-vintdig", VINTDIG),
1153 TWLFIXED_OF_MATCH("ti,twl4030-vusb1v5", VUSB1V5),
1154 TWLFIXED_OF_MATCH("ti,twl4030-vusb1v8", VUSB1V8),
1155 TWLFIXED_OF_MATCH("ti,twl4030-vusb3v1", VUSB3V1),
1156 TWLFIXED_OF_MATCH("ti,twl6030-vana", VANA),
1157 TWLFIXED_OF_MATCH("ti,twl6030-vcxio", VCXIO),
1158 TWLFIXED_OF_MATCH("ti,twl6030-vdac", VDAC),
1159 TWLFIXED_OF_MATCH("ti,twl6030-vusb", VUSB),
Peter Ujfalusie9d47fa2012-02-28 15:09:12 +05301160 TWLFIXED_OF_MATCH("ti,twl6030-v1v8", V1V8),
1161 TWLFIXED_OF_MATCH("ti,twl6030-v2v1", V2V1),
Rajendra Nayak2098e952012-02-28 15:09:11 +05301162 TWLRES_OF_MATCH("ti,twl6030-clk32kg", CLK32KG),
1163 TWLSMPS_OF_MATCH("ti,twl6025-smps3", SMPS3),
1164 TWLSMPS_OF_MATCH("ti,twl6025-smps4", SMPS4),
1165 TWLSMPS_OF_MATCH("ti,twl6025-vio", VIO),
1166 {},
1167};
1168MODULE_DEVICE_TABLE(of, twl_of_match);
1169
Dmitry Torokhov24c29022010-02-23 23:38:01 -08001170static int __devinit twlreg_probe(struct platform_device *pdev)
David Brownellfa16a5c2009-02-08 10:37:06 -08001171{
Rajendra Nayak2098e952012-02-28 15:09:11 +05301172 int i, id;
David Brownellfa16a5c2009-02-08 10:37:06 -08001173 struct twlreg_info *info;
1174 struct regulator_init_data *initdata;
1175 struct regulation_constraints *c;
1176 struct regulator_dev *rdev;
Tero Kristo63bfff42012-02-16 12:27:52 +02001177 struct twl_regulator_driver_data *drvdata;
Rajendra Nayak2098e952012-02-28 15:09:11 +05301178 const struct of_device_id *match;
Mark Brownc1727082012-04-04 00:50:22 +01001179 struct regulator_config config = { };
David Brownellfa16a5c2009-02-08 10:37:06 -08001180
Rajendra Nayak2098e952012-02-28 15:09:11 +05301181 match = of_match_device(twl_of_match, &pdev->dev);
1182 if (match) {
1183 info = match->data;
1184 id = info->desc.id;
1185 initdata = of_get_regulator_init_data(&pdev->dev,
1186 pdev->dev.of_node);
1187 drvdata = NULL;
1188 } else {
1189 id = pdev->id;
1190 initdata = pdev->dev.platform_data;
1191 for (i = 0, info = NULL; i < ARRAY_SIZE(twl_of_match); i++) {
1192 info = twl_of_match[i].data;
Axel Lin5ade3932012-04-09 22:32:49 +08001193 if (info && info->desc.id == id)
1194 break;
Rajendra Nayak2098e952012-02-28 15:09:11 +05301195 }
Axel Lin5ade3932012-04-09 22:32:49 +08001196 if (i == ARRAY_SIZE(twl_of_match))
1197 return -ENODEV;
1198
Rajendra Nayak2098e952012-02-28 15:09:11 +05301199 drvdata = initdata->driver_data;
1200 if (!drvdata)
1201 return -EINVAL;
David Brownellfa16a5c2009-02-08 10:37:06 -08001202 }
Rajendra Nayak2098e952012-02-28 15:09:11 +05301203
David Brownellfa16a5c2009-02-08 10:37:06 -08001204 if (!info)
1205 return -ENODEV;
1206
David Brownellfa16a5c2009-02-08 10:37:06 -08001207 if (!initdata)
1208 return -EINVAL;
1209
Rajendra Nayak2098e952012-02-28 15:09:11 +05301210 if (drvdata) {
1211 /* copy the driver data into regulator data */
1212 info->features = drvdata->features;
1213 info->data = drvdata->data;
1214 info->set_voltage = drvdata->set_voltage;
1215 info->get_voltage = drvdata->get_voltage;
1216 }
Graeme Gregory4d94aee2011-05-22 21:21:23 +01001217
David Brownellfa16a5c2009-02-08 10:37:06 -08001218 /* Constrain board-specific capabilities according to what
1219 * this driver and the chip itself can actually do.
1220 */
1221 c = &initdata->constraints;
David Brownellfa16a5c2009-02-08 10:37:06 -08001222 c->valid_modes_mask &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_STANDBY;
1223 c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE
1224 | REGULATOR_CHANGE_MODE
1225 | REGULATOR_CHANGE_STATUS;
Rajendra Nayak2098e952012-02-28 15:09:11 +05301226 switch (id) {
Juha Keski-Saari205e5cd2009-12-16 15:27:56 +02001227 case TWL4030_REG_VIO:
1228 case TWL4030_REG_VDD1:
1229 case TWL4030_REG_VDD2:
1230 case TWL4030_REG_VPLL1:
1231 case TWL4030_REG_VINTANA1:
1232 case TWL4030_REG_VINTANA2:
1233 case TWL4030_REG_VINTDIG:
1234 c->always_on = true;
1235 break;
1236 default:
1237 break;
1238 }
David Brownellfa16a5c2009-02-08 10:37:06 -08001239
Rajendra Nayak2098e952012-02-28 15:09:11 +05301240 switch (id) {
Graeme Gregory4d94aee2011-05-22 21:21:23 +01001241 case TWL6025_REG_SMPS3:
1242 if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS3)
1243 info->flags |= SMPS_EXTENDED_EN;
1244 if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS3)
1245 info->flags |= SMPS_OFFSET_EN;
1246 break;
1247 case TWL6025_REG_SMPS4:
1248 if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS4)
1249 info->flags |= SMPS_EXTENDED_EN;
1250 if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS4)
1251 info->flags |= SMPS_OFFSET_EN;
1252 break;
1253 case TWL6025_REG_VIO:
1254 if (twl_get_smps_mult() & SMPS_MULTOFFSET_VIO)
1255 info->flags |= SMPS_EXTENDED_EN;
1256 if (twl_get_smps_offset() & SMPS_MULTOFFSET_VIO)
1257 info->flags |= SMPS_OFFSET_EN;
1258 break;
1259 }
1260
Mark Brownc1727082012-04-04 00:50:22 +01001261 config.dev = &pdev->dev;
1262 config.init_data = initdata;
1263 config.driver_data = info;
1264 config.of_node = pdev->dev.of_node;
1265
1266 rdev = regulator_register(&info->desc, &config);
David Brownellfa16a5c2009-02-08 10:37:06 -08001267 if (IS_ERR(rdev)) {
1268 dev_err(&pdev->dev, "can't register %s, %ld\n",
1269 info->desc.name, PTR_ERR(rdev));
1270 return PTR_ERR(rdev);
1271 }
1272 platform_set_drvdata(pdev, rdev);
1273
Saquib Herman776dc922011-04-01 10:22:43 +05301274 if (twl_class_is_4030())
1275 twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP,
Juha Keski-Saari30010fa2009-12-16 15:27:58 +02001276 info->remap);
1277
David Brownellfa16a5c2009-02-08 10:37:06 -08001278 /* NOTE: many regulators support short-circuit IRQs (presentable
1279 * as REGULATOR_OVER_CURRENT notifications?) configured via:
1280 * - SC_CONFIG
1281 * - SC_DETECT1 (vintana2, vmmc1/2, vaux1/2/3/4)
1282 * - SC_DETECT2 (vusb, vdac, vio, vdd1/2, vpll2)
1283 * - IT_CONFIG
1284 */
1285
1286 return 0;
1287}
1288
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001289static int __devexit twlreg_remove(struct platform_device *pdev)
David Brownellfa16a5c2009-02-08 10:37:06 -08001290{
1291 regulator_unregister(platform_get_drvdata(pdev));
1292 return 0;
1293}
1294
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001295MODULE_ALIAS("platform:twl_reg");
David Brownellfa16a5c2009-02-08 10:37:06 -08001296
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001297static struct platform_driver twlreg_driver = {
1298 .probe = twlreg_probe,
1299 .remove = __devexit_p(twlreg_remove),
David Brownellfa16a5c2009-02-08 10:37:06 -08001300 /* NOTE: short name, to work around driver model truncation of
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001301 * "twl_regulator.12" (and friends) to "twl_regulator.1".
David Brownellfa16a5c2009-02-08 10:37:06 -08001302 */
Rajendra Nayak2098e952012-02-28 15:09:11 +05301303 .driver = {
1304 .name = "twl_reg",
1305 .owner = THIS_MODULE,
1306 .of_match_table = of_match_ptr(twl_of_match),
1307 },
David Brownellfa16a5c2009-02-08 10:37:06 -08001308};
1309
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001310static int __init twlreg_init(void)
David Brownellfa16a5c2009-02-08 10:37:06 -08001311{
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001312 return platform_driver_register(&twlreg_driver);
David Brownellfa16a5c2009-02-08 10:37:06 -08001313}
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001314subsys_initcall(twlreg_init);
David Brownellfa16a5c2009-02-08 10:37:06 -08001315
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001316static void __exit twlreg_exit(void)
David Brownellfa16a5c2009-02-08 10:37:06 -08001317{
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001318 platform_driver_unregister(&twlreg_driver);
David Brownellfa16a5c2009-02-08 10:37:06 -08001319}
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001320module_exit(twlreg_exit)
David Brownellfa16a5c2009-02-08 10:37:06 -08001321
Rajendra Nayakc4aa6f32009-12-13 21:36:49 +01001322MODULE_DESCRIPTION("TWL regulator driver");
David Brownellfa16a5c2009-02-08 10:37:06 -08001323MODULE_LICENSE("GPL");