2 * arizona-ldo1.c -- LDO1 supply for Arizona devices
4 * Copyright 2012 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/platform_device.h>
20 #include <linux/regulator/driver.h>
21 #include <linux/regulator/machine.h>
22 #include <linux/gpio.h>
23 #include <linux/slab.h>
25 #include <linux/mfd/arizona/core.h>
26 #include <linux/mfd/arizona/pdata.h>
27 #include <linux/mfd/arizona/registers.h>
30 struct regulator_dev
*regulator
;
31 struct arizona
*arizona
;
33 struct regulator_consumer_supply supply
;
34 struct regulator_init_data init_data
;
37 static struct regulator_ops arizona_ldo1_ops
= {
38 .list_voltage
= regulator_list_voltage_linear
,
39 .map_voltage
= regulator_map_voltage_linear
,
40 .get_voltage_sel
= regulator_get_voltage_sel_regmap
,
41 .set_voltage_sel
= regulator_set_voltage_sel_regmap
,
44 static const struct regulator_desc arizona_ldo1
= {
46 .supply_name
= "LDOVDD",
47 .type
= REGULATOR_VOLTAGE
,
48 .ops
= &arizona_ldo1_ops
,
50 .vsel_reg
= ARIZONA_LDO1_CONTROL_1
,
51 .vsel_mask
= ARIZONA_LDO1_VSEL_MASK
,
59 static const struct regulator_init_data arizona_ldo1_default
= {
61 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
63 .num_consumer_supplies
= 1,
66 static __devinit
int arizona_ldo1_probe(struct platform_device
*pdev
)
68 struct arizona
*arizona
= dev_get_drvdata(pdev
->dev
.parent
);
69 struct regulator_config config
= { };
70 struct arizona_ldo1
*ldo1
;
73 ldo1
= devm_kzalloc(&pdev
->dev
, sizeof(*ldo1
), GFP_KERNEL
);
75 dev_err(&pdev
->dev
, "Unable to allocate private data\n");
79 ldo1
->arizona
= arizona
;
82 * Since the chip usually supplies itself we provide some
83 * default init_data for it. This will be overridden with
84 * platform data if provided.
86 ldo1
->init_data
= arizona_ldo1_default
;
87 ldo1
->init_data
.consumer_supplies
= &ldo1
->supply
;
88 ldo1
->supply
.supply
= "DCVDD";
89 ldo1
->supply
.dev_name
= dev_name(arizona
->dev
);
91 config
.dev
= arizona
->dev
;
92 config
.driver_data
= ldo1
;
93 config
.regmap
= arizona
->regmap
;
94 config
.ena_gpio
= arizona
->pdata
.ldoena
;
96 if (arizona
->pdata
.ldo1
)
97 config
.init_data
= arizona
->pdata
.ldo1
;
99 config
.init_data
= &ldo1
->init_data
;
101 ldo1
->regulator
= regulator_register(&arizona_ldo1
, &config
);
102 if (IS_ERR(ldo1
->regulator
)) {
103 ret
= PTR_ERR(ldo1
->regulator
);
104 dev_err(arizona
->dev
, "Failed to register LDO1 supply: %d\n",
109 platform_set_drvdata(pdev
, ldo1
);
114 static __devexit
int arizona_ldo1_remove(struct platform_device
*pdev
)
116 struct arizona_ldo1
*ldo1
= platform_get_drvdata(pdev
);
118 regulator_unregister(ldo1
->regulator
);
123 static struct platform_driver arizona_ldo1_driver
= {
124 .probe
= arizona_ldo1_probe
,
125 .remove
= __devexit_p(arizona_ldo1_remove
),
127 .name
= "arizona-ldo1",
128 .owner
= THIS_MODULE
,
132 module_platform_driver(arizona_ldo1_driver
);
134 /* Module information */
135 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
136 MODULE_DESCRIPTION("Arizona LDO1 driver");
137 MODULE_LICENSE("GPL");
138 MODULE_ALIAS("platform:arizona-ldo1");