blob: 96b569abb46cfe055a50cdf35a4c362a15ba0a3a [file] [log] [blame]
Ashish Jangam08bf1c02011-12-09 19:48:20 +05301/*
2* da9052-regulator.c: Regulator driver for DA9052
3*
4* Copyright(c) 2011 Dialog Semiconductor Ltd.
5*
6* Author: David Dajun Chen <dchen@diasemi.com>
7*
8* This program is free software; you can redistribute it and/or modify
9* it under the terms of the GNU General Public License as published by
10* the Free Software Foundation; either version 2 of the License, or
11* (at your option) any later version.
12*
13*/
14
15#include <linux/module.h>
16#include <linux/moduleparam.h>
17#include <linux/init.h>
18#include <linux/err.h>
19#include <linux/platform_device.h>
20#include <linux/regulator/driver.h>
21#include <linux/regulator/machine.h>
Ying-Chun Liu (PaulLiu)88c84c12012-04-13 21:37:41 +080022#ifdef CONFIG_OF
Mark Browncd22a962012-04-16 09:54:24 +010023#include <linux/of.h>
Ying-Chun Liu (PaulLiu)88c84c12012-04-13 21:37:41 +080024#include <linux/regulator/of_regulator.h>
25#endif
Ashish Jangam08bf1c02011-12-09 19:48:20 +053026
27#include <linux/mfd/da9052/da9052.h>
28#include <linux/mfd/da9052/reg.h>
29#include <linux/mfd/da9052/pdata.h>
30
31/* Buck step size */
32#define DA9052_BUCK_PERI_3uV_STEP 100000
33#define DA9052_BUCK_PERI_REG_MAP_UPTO_3uV 24
34#define DA9052_CONST_3uV 3000000
35
36#define DA9052_MIN_UA 0
37#define DA9052_MAX_UA 3
38#define DA9052_CURRENT_RANGE 4
39
40/* Bit masks */
41#define DA9052_BUCK_ILIM_MASK_EVEN 0x0c
42#define DA9052_BUCK_ILIM_MASK_ODD 0xc0
43
Axel Lin9210f052012-03-15 19:58:39 +080044/* DA9052 REGULATOR IDs */
45#define DA9052_ID_BUCK1 0
46#define DA9052_ID_BUCK2 1
47#define DA9052_ID_BUCK3 2
48#define DA9052_ID_BUCK4 3
49#define DA9052_ID_LDO1 4
50#define DA9052_ID_LDO2 5
51#define DA9052_ID_LDO3 6
52#define DA9052_ID_LDO4 7
53#define DA9052_ID_LDO5 8
54#define DA9052_ID_LDO6 9
55#define DA9052_ID_LDO7 10
56#define DA9052_ID_LDO8 11
57#define DA9052_ID_LDO9 12
58#define DA9052_ID_LDO10 13
59
Ashish Jangam08bf1c02011-12-09 19:48:20 +053060static const u32 da9052_current_limits[3][4] = {
61 {700000, 800000, 1000000, 1200000}, /* DA9052-BC BUCKs */
62 {1600000, 2000000, 2400000, 3000000}, /* DA9053-AA/Bx BUCK-CORE */
63 {800000, 1000000, 1200000, 1500000}, /* DA9053-AA/Bx BUCK-PRO,
64 * BUCK-MEM and BUCK-PERI
65 */
66};
67
68struct da9052_regulator_info {
69 struct regulator_desc reg_desc;
70 int step_uV;
71 int min_uV;
72 int max_uV;
Ashish Jangam08bf1c02011-12-09 19:48:20 +053073};
74
75struct da9052_regulator {
76 struct da9052 *da9052;
77 struct da9052_regulator_info *info;
78 struct regulator_dev *rdev;
79};
80
81static int verify_range(struct da9052_regulator_info *info,
82 int min_uV, int max_uV)
83{
84 if (min_uV > info->max_uV || max_uV < info->min_uV)
85 return -EINVAL;
86
87 return 0;
88}
89
Ashish Jangam08bf1c02011-12-09 19:48:20 +053090static int da9052_dcdc_get_current_limit(struct regulator_dev *rdev)
91{
92 struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
93 int offset = rdev_get_id(rdev);
94 int ret, row = 2;
95
96 ret = da9052_reg_read(regulator->da9052, DA9052_BUCKA_REG + offset/2);
97 if (ret < 0)
98 return ret;
99
100 /* Determine the even or odd position of the buck current limit
101 * register field
102 */
103 if (offset % 2 == 0)
104 ret = (ret & DA9052_BUCK_ILIM_MASK_EVEN) >> 2;
105 else
106 ret = (ret & DA9052_BUCK_ILIM_MASK_ODD) >> 6;
107
108 /* Select the appropriate current limit range */
109 if (regulator->da9052->chip_id == DA9052)
110 row = 0;
111 else if (offset == 0)
112 row = 1;
113
114 return da9052_current_limits[row][ret];
115}
116
117static int da9052_dcdc_set_current_limit(struct regulator_dev *rdev, int min_uA,
118 int max_uA)
119{
120 struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
121 int offset = rdev_get_id(rdev);
122 int reg_val = 0;
123 int i, row = 2;
124
125 /* Select the appropriate current limit range */
126 if (regulator->da9052->chip_id == DA9052)
127 row = 0;
128 else if (offset == 0)
129 row = 1;
130
Axel Lin19d23c22012-08-08 20:23:54 +0800131 for (i = DA9052_CURRENT_RANGE - 1; i >= 0; i--) {
Axel Lin1e369bc2012-11-26 15:23:38 +0800132 if ((min_uA <= da9052_current_limits[row][i]) &&
133 (da9052_current_limits[row][i] <= max_uA)) {
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530134 reg_val = i;
135 break;
136 }
137 }
138
Axel Lin1e369bc2012-11-26 15:23:38 +0800139 if (i < 0)
140 return -EINVAL;
141
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530142 /* Determine the even or odd position of the buck current limit
143 * register field
144 */
145 if (offset % 2 == 0)
146 return da9052_reg_update(regulator->da9052,
147 DA9052_BUCKA_REG + offset/2,
148 DA9052_BUCK_ILIM_MASK_EVEN,
149 reg_val << 2);
150 else
151 return da9052_reg_update(regulator->da9052,
152 DA9052_BUCKA_REG + offset/2,
153 DA9052_BUCK_ILIM_MASK_ODD,
154 reg_val << 6);
155}
156
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530157static int da9052_list_voltage(struct regulator_dev *rdev,
158 unsigned int selector)
159{
160 struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
161 struct da9052_regulator_info *info = regulator->info;
Axel Lin0ec446e2012-03-15 20:00:07 +0800162 int id = rdev_get_id(rdev);
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530163 int volt_uV;
164
Axel Lin0ec446e2012-03-15 20:00:07 +0800165 if ((id == DA9052_ID_BUCK4) && (regulator->da9052->chip_id == DA9052)
166 && (selector >= DA9052_BUCK_PERI_REG_MAP_UPTO_3uV)) {
167 volt_uV = ((DA9052_BUCK_PERI_REG_MAP_UPTO_3uV * info->step_uV)
168 + info->min_uV);
169 volt_uV += (selector - DA9052_BUCK_PERI_REG_MAP_UPTO_3uV)
170 * (DA9052_BUCK_PERI_3uV_STEP);
171 } else {
172 volt_uV = (selector * info->step_uV) + info->min_uV;
173 }
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530174
175 if (volt_uV > info->max_uV)
176 return -EINVAL;
177
178 return volt_uV;
179}
180
Axel Lin4923b48b2012-05-16 13:12:35 +0800181static int da9052_map_voltage(struct regulator_dev *rdev,
182 int min_uV, int max_uV)
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530183{
184 struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
185 struct da9052_regulator_info *info = regulator->info;
Axel Lin0ec446e2012-03-15 20:00:07 +0800186 int id = rdev_get_id(rdev);
Axel Lin4923b48b2012-05-16 13:12:35 +0800187 int ret, sel;
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530188
189 ret = verify_range(info, min_uV, max_uV);
190 if (ret < 0)
191 return ret;
192
193 if (min_uV < info->min_uV)
194 min_uV = info->min_uV;
195
Axel Lin0ec446e2012-03-15 20:00:07 +0800196 if ((id == DA9052_ID_BUCK4) && (regulator->da9052->chip_id == DA9052)
197 && (min_uV >= DA9052_CONST_3uV)) {
Axel Lin4923b48b2012-05-16 13:12:35 +0800198 sel = DA9052_BUCK_PERI_REG_MAP_UPTO_3uV +
199 DIV_ROUND_UP(min_uV - DA9052_CONST_3uV,
200 DA9052_BUCK_PERI_3uV_STEP);
Axel Lin0ec446e2012-03-15 20:00:07 +0800201 } else {
Axel Lin4923b48b2012-05-16 13:12:35 +0800202 sel = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
Axel Lin0ec446e2012-03-15 20:00:07 +0800203 }
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530204
Axel Lin4923b48b2012-05-16 13:12:35 +0800205 ret = da9052_list_voltage(rdev, sel);
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530206 if (ret < 0)
207 return ret;
208
Axel Lin4923b48b2012-05-16 13:12:35 +0800209 return sel;
210}
211
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530212static struct regulator_ops da9052_dcdc_ops = {
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530213 .get_current_limit = da9052_dcdc_get_current_limit,
214 .set_current_limit = da9052_dcdc_set_current_limit,
215
216 .list_voltage = da9052_list_voltage,
Axel Lin4923b48b2012-05-16 13:12:35 +0800217 .map_voltage = da9052_map_voltage,
Axel Lin09812bc2012-04-24 09:54:38 +0800218 .get_voltage_sel = regulator_get_voltage_sel_regmap,
Axel Lin68f75062012-12-18 09:32:52 +0800219 .set_voltage_sel = regulator_set_voltage_sel_regmap,
Axel Lin0d481f72012-04-17 11:34:32 +0800220 .is_enabled = regulator_is_enabled_regmap,
221 .enable = regulator_enable_regmap,
222 .disable = regulator_disable_regmap,
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530223};
224
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530225static struct regulator_ops da9052_ldo_ops = {
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530226 .list_voltage = da9052_list_voltage,
Axel Lin4923b48b2012-05-16 13:12:35 +0800227 .map_voltage = da9052_map_voltage,
Axel Lin09812bc2012-04-24 09:54:38 +0800228 .get_voltage_sel = regulator_get_voltage_sel_regmap,
Axel Lin68f75062012-12-18 09:32:52 +0800229 .set_voltage_sel = regulator_set_voltage_sel_regmap,
Axel Lin0d481f72012-04-17 11:34:32 +0800230 .is_enabled = regulator_is_enabled_regmap,
231 .enable = regulator_enable_regmap,
232 .disable = regulator_disable_regmap,
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530233};
234
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530235#define DA9052_LDO(_id, step, min, max, sbits, ebits, abits) \
236{\
237 .reg_desc = {\
Axel Lin9210f052012-03-15 19:58:39 +0800238 .name = #_id,\
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530239 .ops = &da9052_ldo_ops,\
240 .type = REGULATOR_VOLTAGE,\
Axel Lin9210f052012-03-15 19:58:39 +0800241 .id = DA9052_ID_##_id,\
Axel Lin7b957652012-03-05 20:04:32 +0800242 .n_voltages = (max - min) / step + 1, \
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530243 .owner = THIS_MODULE,\
Axel Lin09812bc2012-04-24 09:54:38 +0800244 .vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \
245 .vsel_mask = (1 << (sbits)) - 1,\
Axel Lin68f75062012-12-18 09:32:52 +0800246 .apply_reg = DA9052_SUPPLY_REG, \
247 .apply_bit = (abits), \
Axel Lin0d481f72012-04-17 11:34:32 +0800248 .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \
249 .enable_mask = 1 << (ebits),\
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530250 },\
251 .min_uV = (min) * 1000,\
252 .max_uV = (max) * 1000,\
253 .step_uV = (step) * 1000,\
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530254}
255
256#define DA9052_DCDC(_id, step, min, max, sbits, ebits, abits) \
257{\
258 .reg_desc = {\
Axel Lin9210f052012-03-15 19:58:39 +0800259 .name = #_id,\
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530260 .ops = &da9052_dcdc_ops,\
261 .type = REGULATOR_VOLTAGE,\
Axel Lin9210f052012-03-15 19:58:39 +0800262 .id = DA9052_ID_##_id,\
Axel Lin7b957652012-03-05 20:04:32 +0800263 .n_voltages = (max - min) / step + 1, \
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530264 .owner = THIS_MODULE,\
Axel Lin09812bc2012-04-24 09:54:38 +0800265 .vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \
266 .vsel_mask = (1 << (sbits)) - 1,\
Axel Lin68f75062012-12-18 09:32:52 +0800267 .apply_reg = DA9052_SUPPLY_REG, \
268 .apply_bit = (abits), \
Axel Lin0d481f72012-04-17 11:34:32 +0800269 .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \
270 .enable_mask = 1 << (ebits),\
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530271 },\
272 .min_uV = (min) * 1000,\
273 .max_uV = (max) * 1000,\
274 .step_uV = (step) * 1000,\
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530275}
276
Axel Lin6242eae2011-12-20 17:12:00 +0800277static struct da9052_regulator_info da9052_regulator_info[] = {
Axel Lin9210f052012-03-15 19:58:39 +0800278 DA9052_DCDC(BUCK1, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBCOREGO),
279 DA9052_DCDC(BUCK2, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBPROGO),
280 DA9052_DCDC(BUCK3, 25, 925, 2500, 6, 6, DA9052_SUPPLY_VBMEMGO),
Axel Lin0ec446e2012-03-15 20:00:07 +0800281 DA9052_DCDC(BUCK4, 50, 1800, 3600, 5, 6, 0),
Axel Lin9210f052012-03-15 19:58:39 +0800282 DA9052_LDO(LDO1, 50, 600, 1800, 5, 6, 0),
Axel Lin0ec446e2012-03-15 20:00:07 +0800283 DA9052_LDO(LDO2, 25, 600, 1800, 6, 6, DA9052_SUPPLY_VLDO2GO),
284 DA9052_LDO(LDO3, 25, 1725, 3300, 6, 6, DA9052_SUPPLY_VLDO3GO),
Axel Lin9210f052012-03-15 19:58:39 +0800285 DA9052_LDO(LDO4, 25, 1725, 3300, 6, 6, 0),
286 DA9052_LDO(LDO5, 50, 1200, 3600, 6, 6, 0),
287 DA9052_LDO(LDO6, 50, 1200, 3600, 6, 6, 0),
288 DA9052_LDO(LDO7, 50, 1200, 3600, 6, 6, 0),
289 DA9052_LDO(LDO8, 50, 1200, 3600, 6, 6, 0),
290 DA9052_LDO(LDO9, 50, 1250, 3650, 6, 6, 0),
291 DA9052_LDO(LDO10, 50, 1200, 3600, 6, 6, 0),
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530292};
293
Axel Lin6242eae2011-12-20 17:12:00 +0800294static struct da9052_regulator_info da9053_regulator_info[] = {
Axel Lin9210f052012-03-15 19:58:39 +0800295 DA9052_DCDC(BUCK1, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBCOREGO),
296 DA9052_DCDC(BUCK2, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBPROGO),
297 DA9052_DCDC(BUCK3, 25, 925, 2500, 6, 6, DA9052_SUPPLY_VBMEMGO),
Axel Lin0ec446e2012-03-15 20:00:07 +0800298 DA9052_DCDC(BUCK4, 25, 925, 2500, 6, 6, 0),
Axel Lin9210f052012-03-15 19:58:39 +0800299 DA9052_LDO(LDO1, 50, 600, 1800, 5, 6, 0),
Axel Lin0ec446e2012-03-15 20:00:07 +0800300 DA9052_LDO(LDO2, 25, 600, 1800, 6, 6, DA9052_SUPPLY_VLDO2GO),
301 DA9052_LDO(LDO3, 25, 1725, 3300, 6, 6, DA9052_SUPPLY_VLDO3GO),
Axel Lin9210f052012-03-15 19:58:39 +0800302 DA9052_LDO(LDO4, 25, 1725, 3300, 6, 6, 0),
303 DA9052_LDO(LDO5, 50, 1200, 3600, 6, 6, 0),
304 DA9052_LDO(LDO6, 50, 1200, 3600, 6, 6, 0),
305 DA9052_LDO(LDO7, 50, 1200, 3600, 6, 6, 0),
306 DA9052_LDO(LDO8, 50, 1200, 3600, 6, 6, 0),
307 DA9052_LDO(LDO9, 50, 1250, 3650, 6, 6, 0),
308 DA9052_LDO(LDO10, 50, 1200, 3600, 6, 6, 0),
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530309};
310
311static inline struct da9052_regulator_info *find_regulator_info(u8 chip_id,
312 int id)
313{
314 struct da9052_regulator_info *info;
315 int i;
316
Ashish Jangam984b5a62011-12-15 18:59:53 +0530317 switch (chip_id) {
318 case DA9052:
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530319 for (i = 0; i < ARRAY_SIZE(da9052_regulator_info); i++) {
320 info = &da9052_regulator_info[i];
321 if (info->reg_desc.id == id)
322 return info;
323 }
Ashish Jangam984b5a62011-12-15 18:59:53 +0530324 break;
325 case DA9053_AA:
326 case DA9053_BA:
327 case DA9053_BB:
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530328 for (i = 0; i < ARRAY_SIZE(da9053_regulator_info); i++) {
329 info = &da9053_regulator_info[i];
330 if (info->reg_desc.id == id)
331 return info;
332 }
Ashish Jangam984b5a62011-12-15 18:59:53 +0530333 break;
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530334 }
335
336 return NULL;
337}
338
Bill Pembertona5023572012-11-19 13:22:22 -0500339static int da9052_regulator_probe(struct platform_device *pdev)
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530340{
Mark Brownc1727082012-04-04 00:50:22 +0100341 struct regulator_config config = { };
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530342 struct da9052_regulator *regulator;
343 struct da9052 *da9052;
344 struct da9052_pdata *pdata;
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530345
Ashish Jangam984b5a62011-12-15 18:59:53 +0530346 regulator = devm_kzalloc(&pdev->dev, sizeof(struct da9052_regulator),
347 GFP_KERNEL);
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530348 if (!regulator)
349 return -ENOMEM;
350
351 da9052 = dev_get_drvdata(pdev->dev.parent);
352 pdata = da9052->dev->platform_data;
353 regulator->da9052 = da9052;
354
355 regulator->info = find_regulator_info(regulator->da9052->chip_id,
356 pdev->id);
357 if (regulator->info == NULL) {
358 dev_err(&pdev->dev, "invalid regulator ID specified\n");
Axel Lin7eb64442012-04-05 12:08:58 +0800359 return -EINVAL;
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530360 }
Mark Brownc1727082012-04-04 00:50:22 +0100361
362 config.dev = &pdev->dev;
Mark Brownc1727082012-04-04 00:50:22 +0100363 config.driver_data = regulator;
Axel Lin0d481f72012-04-17 11:34:32 +0800364 config.regmap = da9052->regmap;
Ying-Chun Liu (PaulLiu)88c84c12012-04-13 21:37:41 +0800365 if (pdata && pdata->regulators) {
366 config.init_data = pdata->regulators[pdev->id];
367 } else {
368#ifdef CONFIG_OF
Axel Linc92f5dd2013-01-27 21:16:56 +0800369 struct device_node *nproot, *np;
Ying-Chun Liu (PaulLiu)88c84c12012-04-13 21:37:41 +0800370
Axel Linc92f5dd2013-01-27 21:16:56 +0800371 nproot = of_node_get(da9052->dev->of_node);
Ying-Chun Liu (PaulLiu)88c84c12012-04-13 21:37:41 +0800372 if (!nproot)
373 return -ENODEV;
374
375 nproot = of_find_node_by_name(nproot, "regulators");
376 if (!nproot)
377 return -ENODEV;
378
Axel Linb86bbdd2012-07-07 09:46:45 +0800379 for_each_child_of_node(nproot, np) {
Ying-Chun Liu (PaulLiu)88c84c12012-04-13 21:37:41 +0800380 if (!of_node_cmp(np->name,
381 regulator->info->reg_desc.name)) {
382 config.init_data = of_get_regulator_init_data(
383 &pdev->dev, np);
Axel Line76b9cc2012-07-12 22:23:25 +0800384 config.of_node = np;
Ying-Chun Liu (PaulLiu)88c84c12012-04-13 21:37:41 +0800385 break;
386 }
387 }
Axel Linc92f5dd2013-01-27 21:16:56 +0800388 of_node_put(nproot);
Ying-Chun Liu (PaulLiu)88c84c12012-04-13 21:37:41 +0800389#endif
390 }
Mark Brownc1727082012-04-04 00:50:22 +0100391
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530392 regulator->rdev = regulator_register(&regulator->info->reg_desc,
Mark Brownc1727082012-04-04 00:50:22 +0100393 &config);
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530394 if (IS_ERR(regulator->rdev)) {
395 dev_err(&pdev->dev, "failed to register regulator %s\n",
396 regulator->info->reg_desc.name);
Axel Lin7eb64442012-04-05 12:08:58 +0800397 return PTR_ERR(regulator->rdev);
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530398 }
399
400 platform_set_drvdata(pdev, regulator);
401
402 return 0;
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530403}
404
Bill Pemberton8dc995f2012-11-19 13:26:10 -0500405static int da9052_regulator_remove(struct platform_device *pdev)
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530406{
407 struct da9052_regulator *regulator = platform_get_drvdata(pdev);
408
409 regulator_unregister(regulator->rdev);
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530410 return 0;
411}
412
413static struct platform_driver da9052_regulator_driver = {
414 .probe = da9052_regulator_probe,
Bill Pemberton5eb9f2b2012-11-19 13:20:42 -0500415 .remove = da9052_regulator_remove,
Ashish Jangam08bf1c02011-12-09 19:48:20 +0530416 .driver = {
417 .name = "da9052-regulator",
418 .owner = THIS_MODULE,
419 },
420};
421
422static int __init da9052_regulator_init(void)
423{
424 return platform_driver_register(&da9052_regulator_driver);
425}
426subsys_initcall(da9052_regulator_init);
427
428static void __exit da9052_regulator_exit(void)
429{
430 platform_driver_unregister(&da9052_regulator_driver);
431}
432module_exit(da9052_regulator_exit);
433
434MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>");
435MODULE_DESCRIPTION("Power Regulator driver for Dialog DA9052 PMIC");
436MODULE_LICENSE("GPL");
437MODULE_ALIAS("platform:da9052-regulator");