2 * Copyright (C) ST-Ericsson SA 2010
4 * License Terms: GNU General Public License v2
6 * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson
7 * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
9 * AB8500 peripheral regulators
11 * AB8500 supports the following regulators:
12 * VAUX1/2/3, VINTCORE, VTVOUT, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/module.h>
17 #include <linux/err.h>
18 #include <linux/platform_device.h>
19 #include <linux/mfd/abx500.h>
20 #include <linux/mfd/abx500/ab8500.h>
22 #include <linux/regulator/of_regulator.h>
23 #include <linux/regulator/driver.h>
24 #include <linux/regulator/machine.h>
25 #include <linux/regulator/ab8500.h>
26 #include <linux/slab.h>
29 * struct ab8500_regulator_info - ab8500 regulator information
30 * @dev: device pointer
31 * @desc: regulator description
32 * @regulator_dev: regulator device
33 * @max_uV: maximum voltage (for variable voltage supplies)
34 * @min_uV: minimum voltage (for variable voltage supplies)
35 * @fixed_uV: typical voltage (for fixed voltage supplies)
36 * @update_bank: bank to control on/off
37 * @update_reg: register to control on/off
38 * @update_mask: mask to enable/disable regulator
39 * @update_val_enable: bits to enable the regulator in normal (high power) mode
40 * @voltage_bank: bank to control regulator voltage
41 * @voltage_reg: register to control regulator voltage
42 * @voltage_mask: mask to control regulator voltage
43 * @voltages: supported voltage table
44 * @voltages_len: number of supported voltages for the regulator
45 * @delay: startup/set voltage delay in us
47 struct ab8500_regulator_info
{
49 struct regulator_desc desc
;
50 struct regulator_dev
*regulator
;
66 /* voltage tables for the vauxn/vintcore supplies */
67 static const int ldo_vauxn_voltages
[] = {
86 static const int ldo_vaux3_voltages
[] = {
97 static const int ldo_vintcore_voltages
[] = {
107 static int ab8500_regulator_enable(struct regulator_dev
*rdev
)
110 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
113 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
117 ret
= abx500_mask_and_set_register_interruptible(info
->dev
,
118 info
->update_bank
, info
->update_reg
,
119 info
->update_mask
, info
->update_val_enable
);
121 dev_err(rdev_get_dev(rdev
),
122 "couldn't set enable bits for regulator\n");
124 dev_vdbg(rdev_get_dev(rdev
),
125 "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
126 info
->desc
.name
, info
->update_bank
, info
->update_reg
,
127 info
->update_mask
, info
->update_val_enable
);
132 static int ab8500_regulator_disable(struct regulator_dev
*rdev
)
135 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
138 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
142 ret
= abx500_mask_and_set_register_interruptible(info
->dev
,
143 info
->update_bank
, info
->update_reg
,
144 info
->update_mask
, 0x0);
146 dev_err(rdev_get_dev(rdev
),
147 "couldn't set disable bits for regulator\n");
149 dev_vdbg(rdev_get_dev(rdev
),
150 "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
151 info
->desc
.name
, info
->update_bank
, info
->update_reg
,
152 info
->update_mask
, 0x0);
157 static int ab8500_regulator_is_enabled(struct regulator_dev
*rdev
)
160 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
164 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
168 ret
= abx500_get_register_interruptible(info
->dev
,
169 info
->update_bank
, info
->update_reg
, ®val
);
171 dev_err(rdev_get_dev(rdev
),
172 "couldn't read 0x%x register\n", info
->update_reg
);
176 dev_vdbg(rdev_get_dev(rdev
),
177 "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
179 info
->desc
.name
, info
->update_bank
, info
->update_reg
,
180 info
->update_mask
, regval
);
182 if (regval
& info
->update_mask
)
188 static int ab8500_list_voltage(struct regulator_dev
*rdev
, unsigned selector
)
190 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
193 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
197 /* return the uV for the fixed regulators */
199 return info
->fixed_uV
;
201 if (selector
>= info
->voltages_len
)
204 return info
->voltages
[selector
];
207 static int ab8500_regulator_get_voltage_sel(struct regulator_dev
*rdev
)
210 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
214 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
218 ret
= abx500_get_register_interruptible(info
->dev
,
219 info
->voltage_bank
, info
->voltage_reg
, ®val
);
221 dev_err(rdev_get_dev(rdev
),
222 "couldn't read voltage reg for regulator\n");
226 dev_vdbg(rdev_get_dev(rdev
),
227 "%s-get_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
229 info
->desc
.name
, info
->voltage_bank
, info
->voltage_reg
,
230 info
->voltage_mask
, regval
);
232 /* vintcore has a different layout */
233 val
= regval
& info
->voltage_mask
;
234 if (info
->desc
.id
== AB8500_LDO_INTCORE
)
240 static int ab8500_regulator_set_voltage_sel(struct regulator_dev
*rdev
,
244 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
248 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
252 /* set the registers for the request */
253 regval
= (u8
)selector
;
254 ret
= abx500_mask_and_set_register_interruptible(info
->dev
,
255 info
->voltage_bank
, info
->voltage_reg
,
256 info
->voltage_mask
, regval
);
258 dev_err(rdev_get_dev(rdev
),
259 "couldn't set voltage reg for regulator\n");
261 dev_vdbg(rdev_get_dev(rdev
),
262 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
264 info
->desc
.name
, info
->voltage_bank
, info
->voltage_reg
,
265 info
->voltage_mask
, regval
);
270 static int ab8500_regulator_enable_time(struct regulator_dev
*rdev
)
272 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
277 static int ab8500_regulator_set_voltage_time_sel(struct regulator_dev
*rdev
,
278 unsigned int old_sel
,
279 unsigned int new_sel
)
281 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
284 /* If the regulator isn't on, it won't take time here */
285 ret
= ab8500_regulator_is_enabled(rdev
);
293 static struct regulator_ops ab8500_regulator_ops
= {
294 .enable
= ab8500_regulator_enable
,
295 .disable
= ab8500_regulator_disable
,
296 .is_enabled
= ab8500_regulator_is_enabled
,
297 .get_voltage_sel
= ab8500_regulator_get_voltage_sel
,
298 .set_voltage_sel
= ab8500_regulator_set_voltage_sel
,
299 .list_voltage
= ab8500_list_voltage
,
300 .enable_time
= ab8500_regulator_enable_time
,
301 .set_voltage_time_sel
= ab8500_regulator_set_voltage_time_sel
,
304 static int ab8500_fixed_get_voltage(struct regulator_dev
*rdev
)
306 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
309 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
313 return info
->fixed_uV
;
316 static struct regulator_ops ab8500_regulator_fixed_ops
= {
317 .enable
= ab8500_regulator_enable
,
318 .disable
= ab8500_regulator_disable
,
319 .is_enabled
= ab8500_regulator_is_enabled
,
320 .get_voltage
= ab8500_fixed_get_voltage
,
321 .list_voltage
= ab8500_list_voltage
,
322 .enable_time
= ab8500_regulator_enable_time
,
323 .set_voltage_time_sel
= ab8500_regulator_set_voltage_time_sel
,
326 static struct ab8500_regulator_info
327 ab8500_regulator_info
[AB8500_NUM_REGULATORS
] = {
329 * Variable Voltage Regulators
330 * name, min mV, max mV,
331 * update bank, reg, mask, enable val
332 * volt bank, reg, mask, table, table length
334 [AB8500_LDO_AUX1
] = {
337 .ops
= &ab8500_regulator_ops
,
338 .type
= REGULATOR_VOLTAGE
,
339 .id
= AB8500_LDO_AUX1
,
340 .owner
= THIS_MODULE
,
341 .n_voltages
= ARRAY_SIZE(ldo_vauxn_voltages
),
348 .update_val_enable
= 0x01,
349 .voltage_bank
= 0x04,
351 .voltage_mask
= 0x0f,
352 .voltages
= ldo_vauxn_voltages
,
353 .voltages_len
= ARRAY_SIZE(ldo_vauxn_voltages
),
355 [AB8500_LDO_AUX2
] = {
358 .ops
= &ab8500_regulator_ops
,
359 .type
= REGULATOR_VOLTAGE
,
360 .id
= AB8500_LDO_AUX2
,
361 .owner
= THIS_MODULE
,
362 .n_voltages
= ARRAY_SIZE(ldo_vauxn_voltages
),
369 .update_val_enable
= 0x04,
370 .voltage_bank
= 0x04,
372 .voltage_mask
= 0x0f,
373 .voltages
= ldo_vauxn_voltages
,
374 .voltages_len
= ARRAY_SIZE(ldo_vauxn_voltages
),
376 [AB8500_LDO_AUX3
] = {
379 .ops
= &ab8500_regulator_ops
,
380 .type
= REGULATOR_VOLTAGE
,
381 .id
= AB8500_LDO_AUX3
,
382 .owner
= THIS_MODULE
,
383 .n_voltages
= ARRAY_SIZE(ldo_vaux3_voltages
),
390 .update_val_enable
= 0x01,
391 .voltage_bank
= 0x04,
393 .voltage_mask
= 0x07,
394 .voltages
= ldo_vaux3_voltages
,
395 .voltages_len
= ARRAY_SIZE(ldo_vaux3_voltages
),
397 [AB8500_LDO_INTCORE
] = {
399 .name
= "LDO-INTCORE",
400 .ops
= &ab8500_regulator_ops
,
401 .type
= REGULATOR_VOLTAGE
,
402 .id
= AB8500_LDO_INTCORE
,
403 .owner
= THIS_MODULE
,
404 .n_voltages
= ARRAY_SIZE(ldo_vintcore_voltages
),
411 .update_val_enable
= 0x04,
412 .voltage_bank
= 0x03,
414 .voltage_mask
= 0x38,
415 .voltages
= ldo_vintcore_voltages
,
416 .voltages_len
= ARRAY_SIZE(ldo_vintcore_voltages
),
420 * Fixed Voltage Regulators
422 * update bank, reg, mask, enable val
424 [AB8500_LDO_TVOUT
] = {
427 .ops
= &ab8500_regulator_fixed_ops
,
428 .type
= REGULATOR_VOLTAGE
,
429 .id
= AB8500_LDO_TVOUT
,
430 .owner
= THIS_MODULE
,
438 .update_val_enable
= 0x02,
443 .ops
= &ab8500_regulator_fixed_ops
,
444 .type
= REGULATOR_VOLTAGE
,
445 .id
= AB8500_LDO_USB
,
446 .owner
= THIS_MODULE
,
453 .update_val_enable
= 0x01,
455 [AB8500_LDO_AUDIO
] = {
458 .ops
= &ab8500_regulator_fixed_ops
,
459 .type
= REGULATOR_VOLTAGE
,
460 .id
= AB8500_LDO_AUDIO
,
461 .owner
= THIS_MODULE
,
468 .update_val_enable
= 0x02,
470 [AB8500_LDO_ANAMIC1
] = {
472 .name
= "LDO-ANAMIC1",
473 .ops
= &ab8500_regulator_fixed_ops
,
474 .type
= REGULATOR_VOLTAGE
,
475 .id
= AB8500_LDO_ANAMIC1
,
476 .owner
= THIS_MODULE
,
483 .update_val_enable
= 0x08,
485 [AB8500_LDO_ANAMIC2
] = {
487 .name
= "LDO-ANAMIC2",
488 .ops
= &ab8500_regulator_fixed_ops
,
489 .type
= REGULATOR_VOLTAGE
,
490 .id
= AB8500_LDO_ANAMIC2
,
491 .owner
= THIS_MODULE
,
498 .update_val_enable
= 0x10,
500 [AB8500_LDO_DMIC
] = {
503 .ops
= &ab8500_regulator_fixed_ops
,
504 .type
= REGULATOR_VOLTAGE
,
505 .id
= AB8500_LDO_DMIC
,
506 .owner
= THIS_MODULE
,
513 .update_val_enable
= 0x04,
518 .ops
= &ab8500_regulator_fixed_ops
,
519 .type
= REGULATOR_VOLTAGE
,
520 .id
= AB8500_LDO_ANA
,
521 .owner
= THIS_MODULE
,
528 .update_val_enable
= 0x04,
534 struct ab8500_reg_init
{
540 #define REG_INIT(_id, _bank, _addr, _mask) \
547 static struct ab8500_reg_init ab8500_reg_init
[] = {
549 * 0x30, VanaRequestCtrl
550 * 0x0C, VpllRequestCtrl
551 * 0xc0, VextSupply1RequestCtrl
553 REG_INIT(AB8500_REGUREQUESTCTRL2
, 0x03, 0x04, 0xfc),
555 * 0x03, VextSupply2RequestCtrl
556 * 0x0c, VextSupply3RequestCtrl
557 * 0x30, Vaux1RequestCtrl
558 * 0xc0, Vaux2RequestCtrl
560 REG_INIT(AB8500_REGUREQUESTCTRL3
, 0x03, 0x05, 0xff),
562 * 0x03, Vaux3RequestCtrl
565 REG_INIT(AB8500_REGUREQUESTCTRL4
, 0x03, 0x06, 0x07),
567 * 0x08, VanaSysClkReq1HPValid
568 * 0x20, Vaux1SysClkReq1HPValid
569 * 0x40, Vaux2SysClkReq1HPValid
570 * 0x80, Vaux3SysClkReq1HPValid
572 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID1
, 0x03, 0x07, 0xe8),
574 * 0x10, VextSupply1SysClkReq1HPValid
575 * 0x20, VextSupply2SysClkReq1HPValid
576 * 0x40, VextSupply3SysClkReq1HPValid
578 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID2
, 0x03, 0x08, 0x70),
580 * 0x08, VanaHwHPReq1Valid
581 * 0x20, Vaux1HwHPReq1Valid
582 * 0x40, Vaux2HwHPReq1Valid
583 * 0x80, Vaux3HwHPReq1Valid
585 REG_INIT(AB8500_REGUHWHPREQ1VALID1
, 0x03, 0x09, 0xe8),
587 * 0x01, VextSupply1HwHPReq1Valid
588 * 0x02, VextSupply2HwHPReq1Valid
589 * 0x04, VextSupply3HwHPReq1Valid
591 REG_INIT(AB8500_REGUHWHPREQ1VALID2
, 0x03, 0x0a, 0x07),
593 * 0x08, VanaHwHPReq2Valid
594 * 0x20, Vaux1HwHPReq2Valid
595 * 0x40, Vaux2HwHPReq2Valid
596 * 0x80, Vaux3HwHPReq2Valid
598 REG_INIT(AB8500_REGUHWHPREQ2VALID1
, 0x03, 0x0b, 0xe8),
600 * 0x01, VextSupply1HwHPReq2Valid
601 * 0x02, VextSupply2HwHPReq2Valid
602 * 0x04, VextSupply3HwHPReq2Valid
604 REG_INIT(AB8500_REGUHWHPREQ2VALID2
, 0x03, 0x0c, 0x07),
606 * 0x20, VanaSwHPReqValid
607 * 0x80, Vaux1SwHPReqValid
609 REG_INIT(AB8500_REGUSWHPREQVALID1
, 0x03, 0x0d, 0xa0),
611 * 0x01, Vaux2SwHPReqValid
612 * 0x02, Vaux3SwHPReqValid
613 * 0x04, VextSupply1SwHPReqValid
614 * 0x08, VextSupply2SwHPReqValid
615 * 0x10, VextSupply3SwHPReqValid
617 REG_INIT(AB8500_REGUSWHPREQVALID2
, 0x03, 0x0e, 0x1f),
619 * 0x02, SysClkReq2Valid1
621 * 0x80, SysClkReq8Valid1
623 REG_INIT(AB8500_REGUSYSCLKREQVALID1
, 0x03, 0x0f, 0xfe),
625 * 0x02, SysClkReq2Valid2
627 * 0x80, SysClkReq8Valid2
629 REG_INIT(AB8500_REGUSYSCLKREQVALID2
, 0x03, 0x10, 0xfe),
632 * 0x04, Vintcore12Ena
633 * 0x38, Vintcore12Sel
637 REG_INIT(AB8500_REGUMISC1
, 0x03, 0x80, 0xfe),
644 REG_INIT(AB8500_VAUDIOSUPPLY
, 0x03, 0x83, 0x1e),
649 REG_INIT(AB8500_REGUCTRL1VAMIC
, 0x03, 0x84, 0x03),
654 REG_INIT(AB8500_VPLLVANAREGU
, 0x04, 0x06, 0x0f),
657 * 0x02, VrefDDRSleepMode
659 REG_INIT(AB8500_VREFDDR
, 0x04, 0x07, 0x03),
661 * 0x03, VextSupply1Regu
662 * 0x0c, VextSupply2Regu
663 * 0x30, VextSupply3Regu
664 * 0x40, ExtSupply2Bypass
665 * 0x80, ExtSupply3Bypass
667 REG_INIT(AB8500_EXTSUPPLYREGU
, 0x04, 0x08, 0xff),
672 REG_INIT(AB8500_VAUX12REGU
, 0x04, 0x09, 0x0f),
676 REG_INIT(AB8500_VRF1VAUX3REGU
, 0x04, 0x0a, 0x03),
680 REG_INIT(AB8500_VSMPS1SEL1
, 0x04, 0x13, 0x3f),
684 REG_INIT(AB8500_VAUX1SEL
, 0x04, 0x1f, 0x0f),
688 REG_INIT(AB8500_VAUX2SEL
, 0x04, 0x20, 0x0f),
692 REG_INIT(AB8500_VRF1VAUX3SEL
, 0x04, 0x21, 0x07),
694 * 0x01, VextSupply12LP
696 REG_INIT(AB8500_REGUCTRL2SPARE
, 0x04, 0x22, 0x01),
701 * 0x20, Vintcore12Disch
705 REG_INIT(AB8500_REGUCTRLDISCH
, 0x04, 0x43, 0xfc),
708 * 0x04, VdmicPullDownEna
711 REG_INIT(AB8500_REGUCTRLDISCH2
, 0x04, 0x44, 0x16),
715 ab8500_regulator_init_registers(struct platform_device
*pdev
, int id
, int value
)
719 if (value
& ~ab8500_reg_init
[id
].mask
) {
721 "Configuration error: value outside mask.\n");
725 err
= abx500_mask_and_set_register_interruptible(
727 ab8500_reg_init
[id
].bank
,
728 ab8500_reg_init
[id
].addr
,
729 ab8500_reg_init
[id
].mask
,
733 "Failed to initialize 0x%02x, 0x%02x.\n",
734 ab8500_reg_init
[id
].bank
,
735 ab8500_reg_init
[id
].addr
);
740 "init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
741 ab8500_reg_init
[id
].bank
,
742 ab8500_reg_init
[id
].addr
,
743 ab8500_reg_init
[id
].mask
,
749 static __devinit
int ab8500_regulator_register(struct platform_device
*pdev
,
750 struct regulator_init_data
*init_data
,
752 struct device_node
*np
)
754 struct ab8500_regulator_info
*info
= NULL
;
755 struct regulator_config config
= { };
758 /* assign per-regulator data */
759 info
= &ab8500_regulator_info
[id
];
760 info
->dev
= &pdev
->dev
;
762 config
.dev
= &pdev
->dev
;
763 config
.init_data
= init_data
;
764 config
.driver_data
= info
;
767 /* fix for hardware before ab8500v2.0 */
768 if (abx500_get_chip_id(info
->dev
) < 0x20) {
769 if (info
->desc
.id
== AB8500_LDO_AUX3
) {
770 info
->desc
.n_voltages
=
771 ARRAY_SIZE(ldo_vauxn_voltages
);
772 info
->voltages
= ldo_vauxn_voltages
;
774 ARRAY_SIZE(ldo_vauxn_voltages
);
775 info
->voltage_mask
= 0xf;
779 /* register regulator with framework */
780 info
->regulator
= regulator_register(&info
->desc
, &config
);
781 if (IS_ERR(info
->regulator
)) {
782 err
= PTR_ERR(info
->regulator
);
783 dev_err(&pdev
->dev
, "failed to register regulator %s\n",
785 /* when we fail, un-register all earlier regulators */
787 info
= &ab8500_regulator_info
[id
];
788 regulator_unregister(info
->regulator
);
796 static struct of_regulator_match ab8500_regulator_matches
[] = {
797 { .name
= "ab8500_ldo_aux1", .driver_data
= (void *) AB8500_LDO_AUX1
, },
798 { .name
= "ab8500_ldo_aux2", .driver_data
= (void *) AB8500_LDO_AUX2
, },
799 { .name
= "ab8500_ldo_aux3", .driver_data
= (void *) AB8500_LDO_AUX3
, },
800 { .name
= "ab8500_ldo_intcore", .driver_data
= (void *) AB8500_LDO_INTCORE
, },
801 { .name
= "ab8500_ldo_tvout", .driver_data
= (void *) AB8500_LDO_TVOUT
, },
802 { .name
= "ab8500_ldo_usb", .driver_data
= (void *) AB8500_LDO_USB
, },
803 { .name
= "ab8500_ldo_audio", .driver_data
= (void *) AB8500_LDO_AUDIO
, },
804 { .name
= "ab8500_ldo_anamic1", .driver_data
= (void *) AB8500_LDO_ANAMIC1
, },
805 { .name
= "ab8500_ldo_amamic2", .driver_data
= (void *) AB8500_LDO_ANAMIC2
, },
806 { .name
= "ab8500_ldo_dmic", .driver_data
= (void *) AB8500_LDO_DMIC
, },
807 { .name
= "ab8500_ldo_ana", .driver_data
= (void *) AB8500_LDO_ANA
, },
811 ab8500_regulator_of_probe(struct platform_device
*pdev
, struct device_node
*np
)
815 for (i
= 0; i
< ARRAY_SIZE(ab8500_regulator_info
); i
++) {
816 err
= ab8500_regulator_register(
817 pdev
, ab8500_regulator_matches
[i
].init_data
,
818 i
, ab8500_regulator_matches
[i
].of_node
);
826 static __devinit
int ab8500_regulator_probe(struct platform_device
*pdev
)
828 struct ab8500
*ab8500
= dev_get_drvdata(pdev
->dev
.parent
);
829 struct ab8500_platform_data
*pdata
;
830 struct device_node
*np
= pdev
->dev
.of_node
;
834 err
= of_regulator_match(&pdev
->dev
, np
,
835 ab8500_regulator_matches
,
836 ARRAY_SIZE(ab8500_regulator_matches
));
839 "Error parsing regulator init data: %d\n", err
);
843 err
= ab8500_regulator_of_probe(pdev
, np
);
848 dev_err(&pdev
->dev
, "null mfd parent\n");
851 pdata
= dev_get_platdata(ab8500
->dev
);
853 dev_err(&pdev
->dev
, "null pdata\n");
857 /* make sure the platform data has the correct size */
858 if (pdata
->num_regulator
!= ARRAY_SIZE(ab8500_regulator_info
)) {
859 dev_err(&pdev
->dev
, "Configuration error: size mismatch.\n");
863 /* initialize registers */
864 for (i
= 0; i
< pdata
->num_regulator_reg_init
; i
++) {
867 id
= pdata
->regulator_reg_init
[i
].id
;
868 value
= pdata
->regulator_reg_init
[i
].value
;
870 /* check for configuration errors */
871 if (id
>= AB8500_NUM_REGULATOR_REGISTERS
) {
873 "Configuration error: id outside range.\n");
877 err
= ab8500_regulator_init_registers(pdev
, id
, value
);
882 /* register all regulators */
883 for (i
= 0; i
< ARRAY_SIZE(ab8500_regulator_info
); i
++) {
884 err
= ab8500_regulator_register(pdev
, &pdata
->regulator
[i
], i
, NULL
);
892 static __devexit
int ab8500_regulator_remove(struct platform_device
*pdev
)
896 for (i
= 0; i
< ARRAY_SIZE(ab8500_regulator_info
); i
++) {
897 struct ab8500_regulator_info
*info
= NULL
;
898 info
= &ab8500_regulator_info
[i
];
900 dev_vdbg(rdev_get_dev(info
->regulator
),
901 "%s-remove\n", info
->desc
.name
);
903 regulator_unregister(info
->regulator
);
909 static const struct of_device_id ab8500_regulator_match
[] = {
910 { .compatible
= "stericsson,ab8500-regulator", },
914 static struct platform_driver ab8500_regulator_driver
= {
915 .probe
= ab8500_regulator_probe
,
916 .remove
= __devexit_p(ab8500_regulator_remove
),
918 .name
= "ab8500-regulator",
919 .owner
= THIS_MODULE
,
920 .of_match_table
= ab8500_regulator_match
,
924 static int __init
ab8500_regulator_init(void)
928 ret
= platform_driver_register(&ab8500_regulator_driver
);
930 pr_err("Failed to register ab8500 regulator: %d\n", ret
);
934 subsys_initcall(ab8500_regulator_init
);
936 static void __exit
ab8500_regulator_exit(void)
938 platform_driver_unregister(&ab8500_regulator_driver
);
940 module_exit(ab8500_regulator_exit
);
942 MODULE_LICENSE("GPL v2");
943 MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");
944 MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC");
945 MODULE_ALIAS("platform:ab8500-regulator");