2 * wm831x-ldo.c -- LDO driver for the WM831x series
4 * Copyright 2009 Wolfson Microelectronics PLC.
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
14 #include <linux/module.h>
15 #include <linux/moduleparam.h>
16 #include <linux/init.h>
17 #include <linux/bitops.h>
18 #include <linux/err.h>
19 #include <linux/i2c.h>
20 #include <linux/platform_device.h>
21 #include <linux/regulator/driver.h>
22 #include <linux/slab.h>
24 #include <linux/mfd/wm831x/core.h>
25 #include <linux/mfd/wm831x/regulator.h>
26 #include <linux/mfd/wm831x/pdata.h>
28 #define WM831X_LDO_MAX_NAME 9
30 #define WM831X_LDO_CONTROL 0
31 #define WM831X_LDO_ON_CONTROL 1
32 #define WM831X_LDO_SLEEP_CONTROL 2
34 #define WM831X_ALIVE_LDO_ON_CONTROL 0
35 #define WM831X_ALIVE_LDO_SLEEP_CONTROL 1
38 char name
[WM831X_LDO_MAX_NAME
];
39 char supply_name
[WM831X_LDO_MAX_NAME
];
40 struct regulator_desc desc
;
42 struct wm831x
*wm831x
;
43 struct regulator_dev
*regulator
;
50 static irqreturn_t
wm831x_ldo_uv_irq(int irq
, void *data
)
52 struct wm831x_ldo
*ldo
= data
;
54 regulator_notifier_call_chain(ldo
->regulator
,
55 REGULATOR_EVENT_UNDER_VOLTAGE
,
62 * General purpose LDOs
65 #define WM831X_GP_LDO_SELECTOR_LOW 0xe
66 #define WM831X_GP_LDO_MAX_SELECTOR 0x1f
68 static int wm831x_gp_ldo_list_voltage(struct regulator_dev
*rdev
,
69 unsigned int selector
)
71 /* 0.9-1.6V in 50mV steps */
72 if (selector
<= WM831X_GP_LDO_SELECTOR_LOW
)
73 return 900000 + (selector
* 50000);
74 /* 1.7-3.3V in 100mV steps */
75 if (selector
<= WM831X_GP_LDO_MAX_SELECTOR
)
76 return 1600000 + ((selector
- WM831X_GP_LDO_SELECTOR_LOW
)
81 static int wm831x_gp_ldo_set_voltage_int(struct regulator_dev
*rdev
, int reg
,
82 int min_uV
, int max_uV
,
85 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
86 struct wm831x
*wm831x
= ldo
->wm831x
;
91 else if (min_uV
< 1700000)
92 vsel
= ((min_uV
- 900000) / 50000);
94 vsel
= ((min_uV
- 1700000) / 100000)
95 + WM831X_GP_LDO_SELECTOR_LOW
+ 1;
97 ret
= wm831x_gp_ldo_list_voltage(rdev
, vsel
);
100 if (ret
< min_uV
|| ret
> max_uV
)
105 return wm831x_set_bits(wm831x
, reg
, WM831X_LDO1_ON_VSEL_MASK
, vsel
);
108 static int wm831x_gp_ldo_set_voltage(struct regulator_dev
*rdev
,
109 int min_uV
, int max_uV
,
112 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
113 int reg
= ldo
->base
+ WM831X_LDO_ON_CONTROL
;
115 return wm831x_gp_ldo_set_voltage_int(rdev
, reg
, min_uV
, max_uV
,
119 static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev
*rdev
,
122 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
123 int reg
= ldo
->base
+ WM831X_LDO_SLEEP_CONTROL
;
124 unsigned int selector
;
126 return wm831x_gp_ldo_set_voltage_int(rdev
, reg
, uV
, uV
, &selector
);
129 static unsigned int wm831x_gp_ldo_get_mode(struct regulator_dev
*rdev
)
131 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
132 struct wm831x
*wm831x
= ldo
->wm831x
;
133 int ctrl_reg
= ldo
->base
+ WM831X_LDO_CONTROL
;
134 int on_reg
= ldo
->base
+ WM831X_LDO_ON_CONTROL
;
137 ret
= wm831x_reg_read(wm831x
, on_reg
);
141 if (!(ret
& WM831X_LDO1_ON_MODE
))
142 return REGULATOR_MODE_NORMAL
;
144 ret
= wm831x_reg_read(wm831x
, ctrl_reg
);
148 if (ret
& WM831X_LDO1_LP_MODE
)
149 return REGULATOR_MODE_STANDBY
;
151 return REGULATOR_MODE_IDLE
;
154 static int wm831x_gp_ldo_set_mode(struct regulator_dev
*rdev
,
157 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
158 struct wm831x
*wm831x
= ldo
->wm831x
;
159 int ctrl_reg
= ldo
->base
+ WM831X_LDO_CONTROL
;
160 int on_reg
= ldo
->base
+ WM831X_LDO_ON_CONTROL
;
165 case REGULATOR_MODE_NORMAL
:
166 ret
= wm831x_set_bits(wm831x
, on_reg
,
167 WM831X_LDO1_ON_MODE
, 0);
172 case REGULATOR_MODE_IDLE
:
173 ret
= wm831x_set_bits(wm831x
, ctrl_reg
,
174 WM831X_LDO1_LP_MODE
, 0);
178 ret
= wm831x_set_bits(wm831x
, on_reg
,
180 WM831X_LDO1_ON_MODE
);
185 case REGULATOR_MODE_STANDBY
:
186 ret
= wm831x_set_bits(wm831x
, ctrl_reg
,
188 WM831X_LDO1_LP_MODE
);
192 ret
= wm831x_set_bits(wm831x
, on_reg
,
194 WM831X_LDO1_ON_MODE
);
206 static int wm831x_gp_ldo_get_status(struct regulator_dev
*rdev
)
208 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
209 struct wm831x
*wm831x
= ldo
->wm831x
;
210 int mask
= 1 << rdev_get_id(rdev
);
213 /* Is the regulator on? */
214 ret
= wm831x_reg_read(wm831x
, WM831X_LDO_STATUS
);
218 return REGULATOR_STATUS_OFF
;
220 /* Is it reporting under voltage? */
221 ret
= wm831x_reg_read(wm831x
, WM831X_LDO_UV_STATUS
);
223 return REGULATOR_STATUS_ERROR
;
225 ret
= wm831x_gp_ldo_get_mode(rdev
);
229 return regulator_mode_to_status(ret
);
232 static unsigned int wm831x_gp_ldo_get_optimum_mode(struct regulator_dev
*rdev
,
234 int output_uV
, int load_uA
)
237 return REGULATOR_MODE_STANDBY
;
239 return REGULATOR_MODE_IDLE
;
240 return REGULATOR_MODE_NORMAL
;
244 static struct regulator_ops wm831x_gp_ldo_ops
= {
245 .list_voltage
= wm831x_gp_ldo_list_voltage
,
246 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
247 .set_voltage
= wm831x_gp_ldo_set_voltage
,
248 .set_suspend_voltage
= wm831x_gp_ldo_set_suspend_voltage
,
249 .get_mode
= wm831x_gp_ldo_get_mode
,
250 .set_mode
= wm831x_gp_ldo_set_mode
,
251 .get_status
= wm831x_gp_ldo_get_status
,
252 .get_optimum_mode
= wm831x_gp_ldo_get_optimum_mode
,
254 .is_enabled
= regulator_is_enabled_regmap
,
255 .enable
= regulator_enable_regmap
,
256 .disable
= regulator_disable_regmap
,
259 static __devinit
int wm831x_gp_ldo_probe(struct platform_device
*pdev
)
261 struct wm831x
*wm831x
= dev_get_drvdata(pdev
->dev
.parent
);
262 struct wm831x_pdata
*pdata
= wm831x
->dev
->platform_data
;
263 struct regulator_config config
= { };
265 struct wm831x_ldo
*ldo
;
266 struct resource
*res
;
269 if (pdata
&& pdata
->wm831x_num
)
270 id
= (pdata
->wm831x_num
* 10) + 1;
275 dev_dbg(&pdev
->dev
, "Probing LDO%d\n", id
+ 1);
277 ldo
= devm_kzalloc(&pdev
->dev
, sizeof(struct wm831x_ldo
), GFP_KERNEL
);
279 dev_err(&pdev
->dev
, "Unable to allocate private data\n");
283 ldo
->wm831x
= wm831x
;
285 res
= platform_get_resource(pdev
, IORESOURCE_IO
, 0);
287 dev_err(&pdev
->dev
, "No I/O resource\n");
291 ldo
->base
= res
->start
;
293 snprintf(ldo
->name
, sizeof(ldo
->name
), "LDO%d", id
+ 1);
294 ldo
->desc
.name
= ldo
->name
;
296 snprintf(ldo
->supply_name
, sizeof(ldo
->supply_name
),
298 ldo
->desc
.supply_name
= ldo
->supply_name
;
301 ldo
->desc
.type
= REGULATOR_VOLTAGE
;
302 ldo
->desc
.n_voltages
= WM831X_GP_LDO_MAX_SELECTOR
+ 1;
303 ldo
->desc
.ops
= &wm831x_gp_ldo_ops
;
304 ldo
->desc
.owner
= THIS_MODULE
;
305 ldo
->desc
.vsel_reg
= ldo
->base
+ WM831X_LDO_ON_CONTROL
;
306 ldo
->desc
.vsel_mask
= WM831X_LDO1_ON_VSEL_MASK
;
307 ldo
->desc
.enable_reg
= WM831X_LDO_ENABLE
;
308 ldo
->desc
.enable_mask
= 1 << id
;
310 config
.dev
= pdev
->dev
.parent
;
312 config
.init_data
= pdata
->ldo
[id
];
313 config
.driver_data
= ldo
;
314 config
.regmap
= wm831x
->regmap
;
316 ldo
->regulator
= regulator_register(&ldo
->desc
, &config
);
317 if (IS_ERR(ldo
->regulator
)) {
318 ret
= PTR_ERR(ldo
->regulator
);
319 dev_err(wm831x
->dev
, "Failed to register LDO%d: %d\n",
324 irq
= wm831x_irq(wm831x
, platform_get_irq_byname(pdev
, "UV"));
325 ret
= request_threaded_irq(irq
, NULL
, wm831x_ldo_uv_irq
,
326 IRQF_TRIGGER_RISING
, ldo
->name
,
329 dev_err(&pdev
->dev
, "Failed to request UV IRQ %d: %d\n",
334 platform_set_drvdata(pdev
, ldo
);
339 regulator_unregister(ldo
->regulator
);
344 static __devexit
int wm831x_gp_ldo_remove(struct platform_device
*pdev
)
346 struct wm831x_ldo
*ldo
= platform_get_drvdata(pdev
);
348 platform_set_drvdata(pdev
, NULL
);
350 free_irq(wm831x_irq(ldo
->wm831x
,
351 platform_get_irq_byname(pdev
, "UV")), ldo
);
352 regulator_unregister(ldo
->regulator
);
357 static struct platform_driver wm831x_gp_ldo_driver
= {
358 .probe
= wm831x_gp_ldo_probe
,
359 .remove
= __devexit_p(wm831x_gp_ldo_remove
),
361 .name
= "wm831x-ldo",
362 .owner
= THIS_MODULE
,
371 #define WM831X_ALDO_SELECTOR_LOW 0xc
372 #define WM831X_ALDO_MAX_SELECTOR 0x1f
374 static int wm831x_aldo_list_voltage(struct regulator_dev
*rdev
,
375 unsigned int selector
)
377 /* 1-1.6V in 50mV steps */
378 if (selector
<= WM831X_ALDO_SELECTOR_LOW
)
379 return 1000000 + (selector
* 50000);
380 /* 1.7-3.5V in 100mV steps */
381 if (selector
<= WM831X_ALDO_MAX_SELECTOR
)
382 return 1600000 + ((selector
- WM831X_ALDO_SELECTOR_LOW
)
387 static int wm831x_aldo_set_voltage_int(struct regulator_dev
*rdev
, int reg
,
388 int min_uV
, int max_uV
,
391 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
392 struct wm831x
*wm831x
= ldo
->wm831x
;
395 if (min_uV
< 1000000)
397 else if (min_uV
< 1700000)
398 vsel
= ((min_uV
- 1000000) / 50000);
400 vsel
= ((min_uV
- 1700000) / 100000)
401 + WM831X_ALDO_SELECTOR_LOW
+ 1;
403 ret
= wm831x_aldo_list_voltage(rdev
, vsel
);
406 if (ret
< min_uV
|| ret
> max_uV
)
411 return wm831x_set_bits(wm831x
, reg
, WM831X_LDO7_ON_VSEL_MASK
, vsel
);
414 static int wm831x_aldo_set_voltage(struct regulator_dev
*rdev
,
415 int min_uV
, int max_uV
, unsigned *selector
)
417 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
418 int reg
= ldo
->base
+ WM831X_LDO_ON_CONTROL
;
420 return wm831x_aldo_set_voltage_int(rdev
, reg
, min_uV
, max_uV
,
424 static int wm831x_aldo_set_suspend_voltage(struct regulator_dev
*rdev
,
427 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
428 int reg
= ldo
->base
+ WM831X_LDO_SLEEP_CONTROL
;
429 unsigned int selector
;
431 return wm831x_aldo_set_voltage_int(rdev
, reg
, uV
, uV
, &selector
);
434 static unsigned int wm831x_aldo_get_mode(struct regulator_dev
*rdev
)
436 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
437 struct wm831x
*wm831x
= ldo
->wm831x
;
438 int on_reg
= ldo
->base
+ WM831X_LDO_ON_CONTROL
;
441 ret
= wm831x_reg_read(wm831x
, on_reg
);
445 if (ret
& WM831X_LDO7_ON_MODE
)
446 return REGULATOR_MODE_IDLE
;
448 return REGULATOR_MODE_NORMAL
;
451 static int wm831x_aldo_set_mode(struct regulator_dev
*rdev
,
454 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
455 struct wm831x
*wm831x
= ldo
->wm831x
;
456 int on_reg
= ldo
->base
+ WM831X_LDO_ON_CONTROL
;
461 case REGULATOR_MODE_NORMAL
:
462 ret
= wm831x_set_bits(wm831x
, on_reg
, WM831X_LDO7_ON_MODE
, 0);
467 case REGULATOR_MODE_IDLE
:
468 ret
= wm831x_set_bits(wm831x
, on_reg
, WM831X_LDO7_ON_MODE
,
469 WM831X_LDO7_ON_MODE
);
481 static int wm831x_aldo_get_status(struct regulator_dev
*rdev
)
483 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
484 struct wm831x
*wm831x
= ldo
->wm831x
;
485 int mask
= 1 << rdev_get_id(rdev
);
488 /* Is the regulator on? */
489 ret
= wm831x_reg_read(wm831x
, WM831X_LDO_STATUS
);
493 return REGULATOR_STATUS_OFF
;
495 /* Is it reporting under voltage? */
496 ret
= wm831x_reg_read(wm831x
, WM831X_LDO_UV_STATUS
);
498 return REGULATOR_STATUS_ERROR
;
500 ret
= wm831x_aldo_get_mode(rdev
);
504 return regulator_mode_to_status(ret
);
507 static struct regulator_ops wm831x_aldo_ops
= {
508 .list_voltage
= wm831x_aldo_list_voltage
,
509 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
510 .set_voltage
= wm831x_aldo_set_voltage
,
511 .set_suspend_voltage
= wm831x_aldo_set_suspend_voltage
,
512 .get_mode
= wm831x_aldo_get_mode
,
513 .set_mode
= wm831x_aldo_set_mode
,
514 .get_status
= wm831x_aldo_get_status
,
516 .is_enabled
= regulator_is_enabled_regmap
,
517 .enable
= regulator_enable_regmap
,
518 .disable
= regulator_disable_regmap
,
521 static __devinit
int wm831x_aldo_probe(struct platform_device
*pdev
)
523 struct wm831x
*wm831x
= dev_get_drvdata(pdev
->dev
.parent
);
524 struct wm831x_pdata
*pdata
= wm831x
->dev
->platform_data
;
525 struct regulator_config config
= { };
527 struct wm831x_ldo
*ldo
;
528 struct resource
*res
;
531 if (pdata
&& pdata
->wm831x_num
)
532 id
= (pdata
->wm831x_num
* 10) + 1;
537 dev_dbg(&pdev
->dev
, "Probing LDO%d\n", id
+ 1);
539 ldo
= devm_kzalloc(&pdev
->dev
, sizeof(struct wm831x_ldo
), GFP_KERNEL
);
541 dev_err(&pdev
->dev
, "Unable to allocate private data\n");
545 ldo
->wm831x
= wm831x
;
547 res
= platform_get_resource(pdev
, IORESOURCE_IO
, 0);
549 dev_err(&pdev
->dev
, "No I/O resource\n");
553 ldo
->base
= res
->start
;
555 snprintf(ldo
->name
, sizeof(ldo
->name
), "LDO%d", id
+ 1);
556 ldo
->desc
.name
= ldo
->name
;
558 snprintf(ldo
->supply_name
, sizeof(ldo
->supply_name
),
560 ldo
->desc
.supply_name
= ldo
->supply_name
;
563 ldo
->desc
.type
= REGULATOR_VOLTAGE
;
564 ldo
->desc
.n_voltages
= WM831X_ALDO_MAX_SELECTOR
+ 1;
565 ldo
->desc
.ops
= &wm831x_aldo_ops
;
566 ldo
->desc
.owner
= THIS_MODULE
;
567 ldo
->desc
.vsel_reg
= ldo
->base
+ WM831X_LDO_ON_CONTROL
;
568 ldo
->desc
.vsel_mask
= WM831X_LDO7_ON_VSEL_MASK
;
569 ldo
->desc
.enable_reg
= WM831X_LDO_ENABLE
;
570 ldo
->desc
.enable_mask
= 1 << id
;
572 config
.dev
= pdev
->dev
.parent
;
574 config
.init_data
= pdata
->ldo
[id
];
575 config
.driver_data
= ldo
;
576 config
.regmap
= wm831x
->regmap
;
578 ldo
->regulator
= regulator_register(&ldo
->desc
, &config
);
579 if (IS_ERR(ldo
->regulator
)) {
580 ret
= PTR_ERR(ldo
->regulator
);
581 dev_err(wm831x
->dev
, "Failed to register LDO%d: %d\n",
586 irq
= wm831x_irq(wm831x
, platform_get_irq_byname(pdev
, "UV"));
587 ret
= request_threaded_irq(irq
, NULL
, wm831x_ldo_uv_irq
,
588 IRQF_TRIGGER_RISING
, ldo
->name
, ldo
);
590 dev_err(&pdev
->dev
, "Failed to request UV IRQ %d: %d\n",
595 platform_set_drvdata(pdev
, ldo
);
600 regulator_unregister(ldo
->regulator
);
605 static __devexit
int wm831x_aldo_remove(struct platform_device
*pdev
)
607 struct wm831x_ldo
*ldo
= platform_get_drvdata(pdev
);
609 free_irq(wm831x_irq(ldo
->wm831x
, platform_get_irq_byname(pdev
, "UV")),
611 regulator_unregister(ldo
->regulator
);
616 static struct platform_driver wm831x_aldo_driver
= {
617 .probe
= wm831x_aldo_probe
,
618 .remove
= __devexit_p(wm831x_aldo_remove
),
620 .name
= "wm831x-aldo",
621 .owner
= THIS_MODULE
,
629 #define WM831X_ALIVE_LDO_MAX_SELECTOR 0xf
631 static int wm831x_alive_ldo_set_voltage_int(struct regulator_dev
*rdev
,
633 int min_uV
, int max_uV
,
636 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
637 struct wm831x
*wm831x
= ldo
->wm831x
;
640 vsel
= (min_uV
- 800000) / 50000;
642 ret
= regulator_list_voltage_linear(rdev
, vsel
);
645 if (ret
< min_uV
|| ret
> max_uV
)
650 return wm831x_set_bits(wm831x
, reg
, WM831X_LDO11_ON_VSEL_MASK
, vsel
);
653 static int wm831x_alive_ldo_set_voltage(struct regulator_dev
*rdev
,
654 int min_uV
, int max_uV
,
657 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
658 int reg
= ldo
->base
+ WM831X_ALIVE_LDO_ON_CONTROL
;
660 return wm831x_alive_ldo_set_voltage_int(rdev
, reg
, min_uV
, max_uV
,
664 static int wm831x_alive_ldo_set_suspend_voltage(struct regulator_dev
*rdev
,
667 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
668 int reg
= ldo
->base
+ WM831X_ALIVE_LDO_SLEEP_CONTROL
;
671 return wm831x_alive_ldo_set_voltage_int(rdev
, reg
, uV
, uV
, &selector
);
674 static int wm831x_alive_ldo_get_status(struct regulator_dev
*rdev
)
676 struct wm831x_ldo
*ldo
= rdev_get_drvdata(rdev
);
677 struct wm831x
*wm831x
= ldo
->wm831x
;
678 int mask
= 1 << rdev_get_id(rdev
);
681 /* Is the regulator on? */
682 ret
= wm831x_reg_read(wm831x
, WM831X_LDO_STATUS
);
686 return REGULATOR_STATUS_ON
;
688 return REGULATOR_STATUS_OFF
;
691 static struct regulator_ops wm831x_alive_ldo_ops
= {
692 .list_voltage
= regulator_list_voltage_linear
,
693 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
694 .set_voltage
= wm831x_alive_ldo_set_voltage
,
695 .set_suspend_voltage
= wm831x_alive_ldo_set_suspend_voltage
,
696 .get_status
= wm831x_alive_ldo_get_status
,
698 .is_enabled
= regulator_is_enabled_regmap
,
699 .enable
= regulator_enable_regmap
,
700 .disable
= regulator_disable_regmap
,
703 static __devinit
int wm831x_alive_ldo_probe(struct platform_device
*pdev
)
705 struct wm831x
*wm831x
= dev_get_drvdata(pdev
->dev
.parent
);
706 struct wm831x_pdata
*pdata
= wm831x
->dev
->platform_data
;
707 struct regulator_config config
= { };
709 struct wm831x_ldo
*ldo
;
710 struct resource
*res
;
713 if (pdata
&& pdata
->wm831x_num
)
714 id
= (pdata
->wm831x_num
* 10) + 1;
720 dev_dbg(&pdev
->dev
, "Probing LDO%d\n", id
+ 1);
722 ldo
= devm_kzalloc(&pdev
->dev
, sizeof(struct wm831x_ldo
), GFP_KERNEL
);
724 dev_err(&pdev
->dev
, "Unable to allocate private data\n");
728 ldo
->wm831x
= wm831x
;
730 res
= platform_get_resource(pdev
, IORESOURCE_IO
, 0);
732 dev_err(&pdev
->dev
, "No I/O resource\n");
736 ldo
->base
= res
->start
;
738 snprintf(ldo
->name
, sizeof(ldo
->name
), "LDO%d", id
+ 1);
739 ldo
->desc
.name
= ldo
->name
;
741 snprintf(ldo
->supply_name
, sizeof(ldo
->supply_name
),
743 ldo
->desc
.supply_name
= ldo
->supply_name
;
746 ldo
->desc
.type
= REGULATOR_VOLTAGE
;
747 ldo
->desc
.n_voltages
= WM831X_ALIVE_LDO_MAX_SELECTOR
+ 1;
748 ldo
->desc
.ops
= &wm831x_alive_ldo_ops
;
749 ldo
->desc
.owner
= THIS_MODULE
;
750 ldo
->desc
.vsel_reg
= ldo
->base
+ WM831X_ALIVE_LDO_ON_CONTROL
;
751 ldo
->desc
.vsel_mask
= WM831X_LDO11_ON_VSEL_MASK
;
752 ldo
->desc
.enable_reg
= WM831X_LDO_ENABLE
;
753 ldo
->desc
.enable_mask
= 1 << id
;
754 ldo
->desc
.min_uV
= 800000;
755 ldo
->desc
.uV_step
= 50000;
757 config
.dev
= pdev
->dev
.parent
;
759 config
.init_data
= pdata
->ldo
[id
];
760 config
.driver_data
= ldo
;
761 config
.regmap
= wm831x
->regmap
;
763 ldo
->regulator
= regulator_register(&ldo
->desc
, &config
);
764 if (IS_ERR(ldo
->regulator
)) {
765 ret
= PTR_ERR(ldo
->regulator
);
766 dev_err(wm831x
->dev
, "Failed to register LDO%d: %d\n",
771 platform_set_drvdata(pdev
, ldo
);
779 static __devexit
int wm831x_alive_ldo_remove(struct platform_device
*pdev
)
781 struct wm831x_ldo
*ldo
= platform_get_drvdata(pdev
);
783 regulator_unregister(ldo
->regulator
);
788 static struct platform_driver wm831x_alive_ldo_driver
= {
789 .probe
= wm831x_alive_ldo_probe
,
790 .remove
= __devexit_p(wm831x_alive_ldo_remove
),
792 .name
= "wm831x-alive-ldo",
793 .owner
= THIS_MODULE
,
797 static int __init
wm831x_ldo_init(void)
801 ret
= platform_driver_register(&wm831x_gp_ldo_driver
);
803 pr_err("Failed to register WM831x GP LDO driver: %d\n", ret
);
805 ret
= platform_driver_register(&wm831x_aldo_driver
);
807 pr_err("Failed to register WM831x ALDO driver: %d\n", ret
);
809 ret
= platform_driver_register(&wm831x_alive_ldo_driver
);
811 pr_err("Failed to register WM831x alive LDO driver: %d\n",
816 subsys_initcall(wm831x_ldo_init
);
818 static void __exit
wm831x_ldo_exit(void)
820 platform_driver_unregister(&wm831x_alive_ldo_driver
);
821 platform_driver_unregister(&wm831x_aldo_driver
);
822 platform_driver_unregister(&wm831x_gp_ldo_driver
);
824 module_exit(wm831x_ldo_exit
);
826 /* Module information */
827 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
828 MODULE_DESCRIPTION("WM831x LDO driver");
829 MODULE_LICENSE("GPL");
830 MODULE_ALIAS("platform:wm831x-ldo");
831 MODULE_ALIAS("platform:wm831x-aldo");
832 MODULE_ALIAS("platform:wm831x-aliveldo");