blob: 6823e6f2b88aa13fde26a00e75b5d4ed8a2ce2ea [file] [log] [blame]
Mark Browne4ee8312009-07-28 15:21:49 +01001/*
2 * wm831x-dcdc.c -- DC-DC buck convertor driver for the WM831x series
3 *
4 * Copyright 2009 Wolfson Microelectronics PLC.
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
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.
12 */
13
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>
Mark Browne24a04c2009-09-22 08:47:11 -070022#include <linux/regulator/machine.h>
23#include <linux/gpio.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090024#include <linux/slab.h>
Mark Browne4ee8312009-07-28 15:21:49 +010025
26#include <linux/mfd/wm831x/core.h>
27#include <linux/mfd/wm831x/regulator.h>
28#include <linux/mfd/wm831x/pdata.h>
29
30#define WM831X_BUCKV_MAX_SELECTOR 0x68
31#define WM831X_BUCKP_MAX_SELECTOR 0x66
32
33#define WM831X_DCDC_MODE_FAST 0
34#define WM831X_DCDC_MODE_NORMAL 1
35#define WM831X_DCDC_MODE_IDLE 2
36#define WM831X_DCDC_MODE_STANDBY 3
37
Mark Brown82caa972012-03-28 21:40:42 +010038#define WM831X_DCDC_MAX_NAME 9
Mark Browne4ee8312009-07-28 15:21:49 +010039
40/* Register offsets in control block */
41#define WM831X_DCDC_CONTROL_1 0
42#define WM831X_DCDC_CONTROL_2 1
43#define WM831X_DCDC_ON_CONFIG 2
44#define WM831X_DCDC_SLEEP_CONTROL 3
Mark Browne24a04c2009-09-22 08:47:11 -070045#define WM831X_DCDC_DVS_CONTROL 4
Mark Browne4ee8312009-07-28 15:21:49 +010046
47/*
48 * Shared
49 */
50
51struct wm831x_dcdc {
52 char name[WM831X_DCDC_MAX_NAME];
Mark Brown82caa972012-03-28 21:40:42 +010053 char supply_name[WM831X_DCDC_MAX_NAME];
Mark Browne4ee8312009-07-28 15:21:49 +010054 struct regulator_desc desc;
55 int base;
56 struct wm831x *wm831x;
57 struct regulator_dev *regulator;
Mark Browne24a04c2009-09-22 08:47:11 -070058 int dvs_gpio;
59 int dvs_gpio_state;
60 int on_vsel;
61 int dvs_vsel;
Mark Browne4ee8312009-07-28 15:21:49 +010062};
63
Mark Browne4ee8312009-07-28 15:21:49 +010064static unsigned int wm831x_dcdc_get_mode(struct regulator_dev *rdev)
65
66{
67 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
68 struct wm831x *wm831x = dcdc->wm831x;
69 u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
70 int val;
71
72 val = wm831x_reg_read(wm831x, reg);
73 if (val < 0)
74 return val;
75
76 val = (val & WM831X_DC1_ON_MODE_MASK) >> WM831X_DC1_ON_MODE_SHIFT;
77
78 switch (val) {
79 case WM831X_DCDC_MODE_FAST:
80 return REGULATOR_MODE_FAST;
81 case WM831X_DCDC_MODE_NORMAL:
82 return REGULATOR_MODE_NORMAL;
83 case WM831X_DCDC_MODE_STANDBY:
84 return REGULATOR_MODE_STANDBY;
85 case WM831X_DCDC_MODE_IDLE:
86 return REGULATOR_MODE_IDLE;
87 default:
88 BUG();
Mark Brown9ee291a2011-02-02 20:17:22 +000089 return -EINVAL;
Mark Browne4ee8312009-07-28 15:21:49 +010090 }
91}
92
93static int wm831x_dcdc_set_mode_int(struct wm831x *wm831x, int reg,
94 unsigned int mode)
95{
96 int val;
97
98 switch (mode) {
99 case REGULATOR_MODE_FAST:
100 val = WM831X_DCDC_MODE_FAST;
101 break;
102 case REGULATOR_MODE_NORMAL:
103 val = WM831X_DCDC_MODE_NORMAL;
104 break;
105 case REGULATOR_MODE_STANDBY:
106 val = WM831X_DCDC_MODE_STANDBY;
107 break;
108 case REGULATOR_MODE_IDLE:
109 val = WM831X_DCDC_MODE_IDLE;
110 break;
111 default:
112 return -EINVAL;
113 }
114
115 return wm831x_set_bits(wm831x, reg, WM831X_DC1_ON_MODE_MASK,
116 val << WM831X_DC1_ON_MODE_SHIFT);
117}
118
119static int wm831x_dcdc_set_mode(struct regulator_dev *rdev, unsigned int mode)
120{
121 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
122 struct wm831x *wm831x = dcdc->wm831x;
123 u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
124
125 return wm831x_dcdc_set_mode_int(wm831x, reg, mode);
126}
127
128static int wm831x_dcdc_set_suspend_mode(struct regulator_dev *rdev,
129 unsigned int mode)
130{
131 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
132 struct wm831x *wm831x = dcdc->wm831x;
133 u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL;
134
135 return wm831x_dcdc_set_mode_int(wm831x, reg, mode);
136}
137
138static int wm831x_dcdc_get_status(struct regulator_dev *rdev)
139{
140 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
141 struct wm831x *wm831x = dcdc->wm831x;
142 int ret;
143
144 /* First, check for errors */
145 ret = wm831x_reg_read(wm831x, WM831X_DCDC_UV_STATUS);
146 if (ret < 0)
147 return ret;
148
149 if (ret & (1 << rdev_get_id(rdev))) {
150 dev_dbg(wm831x->dev, "DCDC%d under voltage\n",
151 rdev_get_id(rdev) + 1);
152 return REGULATOR_STATUS_ERROR;
153 }
154
155 /* DCDC1 and DCDC2 can additionally detect high voltage/current */
156 if (rdev_get_id(rdev) < 2) {
157 if (ret & (WM831X_DC1_OV_STS << rdev_get_id(rdev))) {
158 dev_dbg(wm831x->dev, "DCDC%d over voltage\n",
159 rdev_get_id(rdev) + 1);
160 return REGULATOR_STATUS_ERROR;
161 }
162
163 if (ret & (WM831X_DC1_HC_STS << rdev_get_id(rdev))) {
164 dev_dbg(wm831x->dev, "DCDC%d over current\n",
165 rdev_get_id(rdev) + 1);
166 return REGULATOR_STATUS_ERROR;
167 }
168 }
169
170 /* Is the regulator on? */
171 ret = wm831x_reg_read(wm831x, WM831X_DCDC_STATUS);
172 if (ret < 0)
173 return ret;
174 if (!(ret & (1 << rdev_get_id(rdev))))
175 return REGULATOR_STATUS_OFF;
176
177 /* TODO: When we handle hardware control modes so we can report the
178 * current mode. */
179 return REGULATOR_STATUS_ON;
180}
181
182static irqreturn_t wm831x_dcdc_uv_irq(int irq, void *data)
183{
184 struct wm831x_dcdc *dcdc = data;
185
186 regulator_notifier_call_chain(dcdc->regulator,
187 REGULATOR_EVENT_UNDER_VOLTAGE,
188 NULL);
189
190 return IRQ_HANDLED;
191}
192
193static irqreturn_t wm831x_dcdc_oc_irq(int irq, void *data)
194{
195 struct wm831x_dcdc *dcdc = data;
196
197 regulator_notifier_call_chain(dcdc->regulator,
198 REGULATOR_EVENT_OVER_CURRENT,
199 NULL);
200
201 return IRQ_HANDLED;
202}
203
204/*
205 * BUCKV specifics
206 */
207
208static int wm831x_buckv_list_voltage(struct regulator_dev *rdev,
209 unsigned selector)
210{
211 if (selector <= 0x8)
212 return 600000;
213 if (selector <= WM831X_BUCKV_MAX_SELECTOR)
214 return 600000 + ((selector - 0x8) * 12500);
215 return -EINVAL;
216}
217
Axel Linb5fb77e2012-06-13 20:29:17 +0800218static int wm831x_buckv_map_voltage(struct regulator_dev *rdev,
219 int min_uV, int max_uV)
Mark Browne4ee8312009-07-28 15:21:49 +0100220{
Mark Browne4ee8312009-07-28 15:21:49 +0100221 u16 vsel;
222
223 if (min_uV < 600000)
224 vsel = 0;
225 else if (min_uV <= 1800000)
Axel Lin1a679932012-11-30 13:19:33 +0800226 vsel = DIV_ROUND_UP(min_uV - 600000, 12500) + 8;
Mark Browne4ee8312009-07-28 15:21:49 +0100227 else
228 return -EINVAL;
229
230 if (wm831x_buckv_list_voltage(rdev, vsel) > max_uV)
231 return -EINVAL;
232
Mark Browne24a04c2009-09-22 08:47:11 -0700233 return vsel;
234}
235
Mark Browne24a04c2009-09-22 08:47:11 -0700236static int wm831x_buckv_set_dvs(struct regulator_dev *rdev, int state)
237{
238 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
239
240 if (state == dcdc->dvs_gpio_state)
241 return 0;
242
243 dcdc->dvs_gpio_state = state;
244 gpio_set_value(dcdc->dvs_gpio, state);
245
246 /* Should wait for DVS state change to be asserted if we have
247 * a GPIO for it, for now assume the device is configured
248 * for the fastest possible transition.
249 */
250
251 return 0;
Mark Browne4ee8312009-07-28 15:21:49 +0100252}
253
Axel Linb5fb77e2012-06-13 20:29:17 +0800254static int wm831x_buckv_set_voltage_sel(struct regulator_dev *rdev,
255 unsigned vsel)
Mark Browne4ee8312009-07-28 15:21:49 +0100256{
257 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
Mark Browne24a04c2009-09-22 08:47:11 -0700258 struct wm831x *wm831x = dcdc->wm831x;
259 int on_reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
260 int dvs_reg = dcdc->base + WM831X_DCDC_DVS_CONTROL;
Axel Linb5fb77e2012-06-13 20:29:17 +0800261 int ret;
Mark Brown3a93f2a2010-11-10 14:38:29 +0000262
Mark Browne24a04c2009-09-22 08:47:11 -0700263 /* If this value is already set then do a GPIO update if we can */
264 if (dcdc->dvs_gpio && dcdc->on_vsel == vsel)
265 return wm831x_buckv_set_dvs(rdev, 0);
266
267 if (dcdc->dvs_gpio && dcdc->dvs_vsel == vsel)
268 return wm831x_buckv_set_dvs(rdev, 1);
269
270 /* Always set the ON status to the minimum voltage */
271 ret = wm831x_set_bits(wm831x, on_reg, WM831X_DC1_ON_VSEL_MASK, vsel);
272 if (ret < 0)
273 return ret;
274 dcdc->on_vsel = vsel;
275
276 if (!dcdc->dvs_gpio)
277 return ret;
278
279 /* Kick the voltage transition now */
280 ret = wm831x_buckv_set_dvs(rdev, 0);
281 if (ret < 0)
282 return ret;
283
Mark Brown88cda602011-07-25 22:20:34 +0100284 /*
285 * If this VSEL is higher than the last one we've seen then
286 * remember it as the DVS VSEL. This is optimised for CPUfreq
287 * usage where we want to get to the highest voltage very
288 * quickly.
289 */
290 if (vsel > dcdc->dvs_vsel) {
291 ret = wm831x_set_bits(wm831x, dvs_reg,
292 WM831X_DC1_DVS_VSEL_MASK,
Mark Brown13ae6332012-11-20 10:02:06 +0900293 vsel);
Mark Brown88cda602011-07-25 22:20:34 +0100294 if (ret == 0)
295 dcdc->dvs_vsel = vsel;
296 else
297 dev_warn(wm831x->dev,
298 "Failed to set DCDC DVS VSEL: %d\n", ret);
Mark Browne24a04c2009-09-22 08:47:11 -0700299 }
300
Mark Browne24a04c2009-09-22 08:47:11 -0700301 return 0;
Mark Browne4ee8312009-07-28 15:21:49 +0100302}
303
304static int wm831x_buckv_set_suspend_voltage(struct regulator_dev *rdev,
Mark Browne24a04c2009-09-22 08:47:11 -0700305 int uV)
Mark Browne4ee8312009-07-28 15:21:49 +0100306{
307 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
Mark Browne24a04c2009-09-22 08:47:11 -0700308 struct wm831x *wm831x = dcdc->wm831x;
Mark Browne4ee8312009-07-28 15:21:49 +0100309 u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL;
Mark Browne24a04c2009-09-22 08:47:11 -0700310 int vsel;
Mark Browne4ee8312009-07-28 15:21:49 +0100311
Axel Linb5fb77e2012-06-13 20:29:17 +0800312 vsel = wm831x_buckv_map_voltage(rdev, uV, uV);
Mark Browne24a04c2009-09-22 08:47:11 -0700313 if (vsel < 0)
314 return vsel;
315
316 return wm831x_set_bits(wm831x, reg, WM831X_DC1_SLP_VSEL_MASK, vsel);
Mark Browne4ee8312009-07-28 15:21:49 +0100317}
318
Mark Brownafb8bb82010-12-10 17:28:08 +0000319static int wm831x_buckv_get_voltage_sel(struct regulator_dev *rdev)
Mark Browne4ee8312009-07-28 15:21:49 +0100320{
321 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
Mark Browne4ee8312009-07-28 15:21:49 +0100322
Mark Browne24a04c2009-09-22 08:47:11 -0700323 if (dcdc->dvs_gpio && dcdc->dvs_gpio_state)
Mark Brownafb8bb82010-12-10 17:28:08 +0000324 return dcdc->dvs_vsel;
Mark Browne24a04c2009-09-22 08:47:11 -0700325 else
Mark Brownafb8bb82010-12-10 17:28:08 +0000326 return dcdc->on_vsel;
Mark Browne4ee8312009-07-28 15:21:49 +0100327}
328
329/* Current limit options */
330static u16 wm831x_dcdc_ilim[] = {
331 125, 250, 375, 500, 625, 750, 875, 1000
332};
333
334static int wm831x_buckv_set_current_limit(struct regulator_dev *rdev,
335 int min_uA, int max_uA)
336{
337 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
338 struct wm831x *wm831x = dcdc->wm831x;
339 u16 reg = dcdc->base + WM831X_DCDC_CONTROL_2;
340 int i;
341
Axel Lin422294d2012-08-08 20:20:29 +0800342 for (i = ARRAY_SIZE(wm831x_dcdc_ilim) - 1; i >= 0; i--) {
Axel Lina171e782012-03-27 15:17:26 +0800343 if ((min_uA <= wm831x_dcdc_ilim[i]) &&
344 (wm831x_dcdc_ilim[i] <= max_uA))
Axel Lin422294d2012-08-08 20:20:29 +0800345 return wm831x_set_bits(wm831x, reg,
346 WM831X_DC1_HC_THR_MASK,
347 i << WM831X_DC1_HC_THR_SHIFT);
Mark Browne4ee8312009-07-28 15:21:49 +0100348 }
Mark Browne4ee8312009-07-28 15:21:49 +0100349
Axel Lin422294d2012-08-08 20:20:29 +0800350 return -EINVAL;
Mark Browne4ee8312009-07-28 15:21:49 +0100351}
352
353static int wm831x_buckv_get_current_limit(struct regulator_dev *rdev)
354{
355 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
356 struct wm831x *wm831x = dcdc->wm831x;
357 u16 reg = dcdc->base + WM831X_DCDC_CONTROL_2;
358 int val;
359
360 val = wm831x_reg_read(wm831x, reg);
361 if (val < 0)
362 return val;
363
Axel Lin09bf14b2012-03-15 15:53:05 +0800364 val = (val & WM831X_DC1_HC_THR_MASK) >> WM831X_DC1_HC_THR_SHIFT;
365 return wm831x_dcdc_ilim[val];
Mark Browne4ee8312009-07-28 15:21:49 +0100366}
367
368static struct regulator_ops wm831x_buckv_ops = {
Axel Linb5fb77e2012-06-13 20:29:17 +0800369 .set_voltage_sel = wm831x_buckv_set_voltage_sel,
Mark Brownafb8bb82010-12-10 17:28:08 +0000370 .get_voltage_sel = wm831x_buckv_get_voltage_sel,
Mark Browne4ee8312009-07-28 15:21:49 +0100371 .list_voltage = wm831x_buckv_list_voltage,
Axel Linb5fb77e2012-06-13 20:29:17 +0800372 .map_voltage = wm831x_buckv_map_voltage,
Mark Browne4ee8312009-07-28 15:21:49 +0100373 .set_suspend_voltage = wm831x_buckv_set_suspend_voltage,
374 .set_current_limit = wm831x_buckv_set_current_limit,
375 .get_current_limit = wm831x_buckv_get_current_limit,
376
Mark Brown3d138fc2012-04-15 12:38:42 +0100377 .is_enabled = regulator_is_enabled_regmap,
378 .enable = regulator_enable_regmap,
379 .disable = regulator_disable_regmap,
Mark Browne4ee8312009-07-28 15:21:49 +0100380 .get_status = wm831x_dcdc_get_status,
381 .get_mode = wm831x_dcdc_get_mode,
382 .set_mode = wm831x_dcdc_set_mode,
383 .set_suspend_mode = wm831x_dcdc_set_suspend_mode,
384};
385
Mark Browne24a04c2009-09-22 08:47:11 -0700386/*
387 * Set up DVS control. We just log errors since we can still run
388 * (with reduced performance) if we fail.
389 */
Mark Brown1aa20d22013-08-31 11:42:46 +0100390static void wm831x_buckv_dvs_init(struct platform_device *pdev,
391 struct wm831x_dcdc *dcdc,
392 struct wm831x_buckv_pdata *pdata)
Mark Browne24a04c2009-09-22 08:47:11 -0700393{
394 struct wm831x *wm831x = dcdc->wm831x;
395 int ret;
396 u16 ctrl;
397
398 if (!pdata || !pdata->dvs_gpio)
399 return;
400
Mark Browne24a04c2009-09-22 08:47:11 -0700401 /* gpiolib won't let us read the GPIO status so pick the higher
402 * of the two existing voltages so we take it as platform data.
403 */
404 dcdc->dvs_gpio_state = pdata->dvs_init_state;
405
Mark Brown1aa20d22013-08-31 11:42:46 +0100406 ret = devm_gpio_request_one(&pdev->dev, pdata->dvs_gpio,
407 dcdc->dvs_gpio_state ? GPIOF_INIT_HIGH : 0,
408 "DCDC DVS");
Mark Browne24a04c2009-09-22 08:47:11 -0700409 if (ret < 0) {
Mark Brown053fa1b2012-05-07 18:19:08 +0100410 dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %d\n",
Mark Browne24a04c2009-09-22 08:47:11 -0700411 dcdc->name, ret);
Mark Browne24a04c2009-09-22 08:47:11 -0700412 return;
413 }
414
415 dcdc->dvs_gpio = pdata->dvs_gpio;
Mark Brownb47ba9fd2011-07-25 22:20:32 +0100416
417 switch (pdata->dvs_control_src) {
418 case 1:
419 ctrl = 2 << WM831X_DC1_DVS_SRC_SHIFT;
420 break;
421 case 2:
422 ctrl = 3 << WM831X_DC1_DVS_SRC_SHIFT;
423 break;
424 default:
425 dev_err(wm831x->dev, "Invalid DVS control source %d for %s\n",
426 pdata->dvs_control_src, dcdc->name);
427 return;
428 }
429
Mark Brownc439b8f2011-07-25 22:20:33 +0100430 /* If DVS_VSEL is set to the minimum value then raise it to ON_VSEL
431 * to make bootstrapping a bit smoother.
432 */
433 if (!dcdc->dvs_vsel) {
434 ret = wm831x_set_bits(wm831x,
435 dcdc->base + WM831X_DCDC_DVS_CONTROL,
436 WM831X_DC1_DVS_VSEL_MASK, dcdc->on_vsel);
437 if (ret == 0)
438 dcdc->dvs_vsel = dcdc->on_vsel;
439 else
440 dev_warn(wm831x->dev, "Failed to set DVS_VSEL: %d\n",
441 ret);
442 }
443
Mark Brownb47ba9fd2011-07-25 22:20:32 +0100444 ret = wm831x_set_bits(wm831x, dcdc->base + WM831X_DCDC_DVS_CONTROL,
445 WM831X_DC1_DVS_SRC_MASK, ctrl);
446 if (ret < 0) {
447 dev_err(wm831x->dev, "Failed to set %s DVS source: %d\n",
448 dcdc->name, ret);
449 }
Mark Browne24a04c2009-09-22 08:47:11 -0700450}
451
Bill Pembertona5023572012-11-19 13:22:22 -0500452static int wm831x_buckv_probe(struct platform_device *pdev)
Mark Browne4ee8312009-07-28 15:21:49 +0100453{
454 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
Jingoo Handff91d02013-07-30 17:20:47 +0900455 struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
Mark Brownc1727082012-04-04 00:50:22 +0100456 struct regulator_config config = { };
Mark Brown137a6352011-07-25 22:20:29 +0100457 int id;
Mark Browne4ee8312009-07-28 15:21:49 +0100458 struct wm831x_dcdc *dcdc;
459 struct resource *res;
460 int ret, irq;
461
Mark Brown137a6352011-07-25 22:20:29 +0100462 if (pdata && pdata->wm831x_num)
463 id = (pdata->wm831x_num * 10) + 1;
464 else
465 id = 0;
466 id = pdev->id - id;
467
Mark Browne4ee8312009-07-28 15:21:49 +0100468 dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
469
Mark Brownfded2f42011-12-15 02:11:14 +0800470 dcdc = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_dcdc),
471 GFP_KERNEL);
Mark Browne4ee8312009-07-28 15:21:49 +0100472 if (dcdc == NULL) {
473 dev_err(&pdev->dev, "Unable to allocate private data\n");
474 return -ENOMEM;
475 }
476
477 dcdc->wm831x = wm831x;
478
Mark Brown56560982012-08-07 19:42:47 +0100479 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
Mark Browne4ee8312009-07-28 15:21:49 +0100480 if (res == NULL) {
Mark Brown56560982012-08-07 19:42:47 +0100481 dev_err(&pdev->dev, "No REG resource\n");
Mark Browne4ee8312009-07-28 15:21:49 +0100482 ret = -EINVAL;
483 goto err;
484 }
485 dcdc->base = res->start;
486
487 snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1);
488 dcdc->desc.name = dcdc->name;
Mark Brown82caa972012-03-28 21:40:42 +0100489
490 snprintf(dcdc->supply_name, sizeof(dcdc->supply_name),
491 "DC%dVDD", id + 1);
492 dcdc->desc.supply_name = dcdc->supply_name;
493
Mark Browne4ee8312009-07-28 15:21:49 +0100494 dcdc->desc.id = id;
495 dcdc->desc.type = REGULATOR_VOLTAGE;
496 dcdc->desc.n_voltages = WM831X_BUCKV_MAX_SELECTOR + 1;
497 dcdc->desc.ops = &wm831x_buckv_ops;
498 dcdc->desc.owner = THIS_MODULE;
Mark Brown3d138fc2012-04-15 12:38:42 +0100499 dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
500 dcdc->desc.enable_mask = 1 << id;
Mark Browne4ee8312009-07-28 15:21:49 +0100501
Mark Browne24a04c2009-09-22 08:47:11 -0700502 ret = wm831x_reg_read(wm831x, dcdc->base + WM831X_DCDC_ON_CONFIG);
503 if (ret < 0) {
504 dev_err(wm831x->dev, "Failed to read ON VSEL: %d\n", ret);
505 goto err;
506 }
507 dcdc->on_vsel = ret & WM831X_DC1_ON_VSEL_MASK;
508
Mark Browna1b81dd2011-07-25 22:20:30 +0100509 ret = wm831x_reg_read(wm831x, dcdc->base + WM831X_DCDC_DVS_CONTROL);
Mark Browne24a04c2009-09-22 08:47:11 -0700510 if (ret < 0) {
511 dev_err(wm831x->dev, "Failed to read DVS VSEL: %d\n", ret);
512 goto err;
513 }
514 dcdc->dvs_vsel = ret & WM831X_DC1_DVS_VSEL_MASK;
515
Mark Brownf0b067d2012-05-14 11:37:09 +0100516 if (pdata && pdata->dcdc[id])
Mark Brown1aa20d22013-08-31 11:42:46 +0100517 wm831x_buckv_dvs_init(pdev, dcdc,
518 pdata->dcdc[id]->driver_data);
Mark Browne24a04c2009-09-22 08:47:11 -0700519
Mark Brownc1727082012-04-04 00:50:22 +0100520 config.dev = pdev->dev.parent;
Mark Brownb7ca8782012-05-10 00:41:02 +0100521 if (pdata)
522 config.init_data = pdata->dcdc[id];
Mark Brownc1727082012-04-04 00:50:22 +0100523 config.driver_data = dcdc;
Mark Brown3d138fc2012-04-15 12:38:42 +0100524 config.regmap = wm831x->regmap;
Mark Brownc1727082012-04-04 00:50:22 +0100525
Mark Brownd73b4cb2013-08-31 11:58:40 +0100526 dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc,
527 &config);
Mark Browne4ee8312009-07-28 15:21:49 +0100528 if (IS_ERR(dcdc->regulator)) {
529 ret = PTR_ERR(dcdc->regulator);
530 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n",
531 id + 1, ret);
532 goto err;
533 }
534
Mark Browncd997582012-05-14 23:14:24 +0200535 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV"));
Mark Brownb0c4c0c2013-08-31 11:47:39 +0100536 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
537 wm831x_dcdc_uv_irq,
538 IRQF_TRIGGER_RISING, dcdc->name, dcdc);
Mark Browne4ee8312009-07-28 15:21:49 +0100539 if (ret != 0) {
540 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n",
541 irq, ret);
Mark Brownd73b4cb2013-08-31 11:58:40 +0100542 goto err;
Mark Browne4ee8312009-07-28 15:21:49 +0100543 }
544
Mark Browncd997582012-05-14 23:14:24 +0200545 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC"));
Mark Brownb0c4c0c2013-08-31 11:47:39 +0100546 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
547 wm831x_dcdc_oc_irq,
548 IRQF_TRIGGER_RISING, dcdc->name, dcdc);
Mark Browne4ee8312009-07-28 15:21:49 +0100549 if (ret != 0) {
550 dev_err(&pdev->dev, "Failed to request HC IRQ %d: %d\n",
551 irq, ret);
Mark Brownd73b4cb2013-08-31 11:58:40 +0100552 goto err;
Mark Browne4ee8312009-07-28 15:21:49 +0100553 }
554
555 platform_set_drvdata(pdev, dcdc);
556
557 return 0;
558
Mark Browne4ee8312009-07-28 15:21:49 +0100559err:
Mark Browne4ee8312009-07-28 15:21:49 +0100560 return ret;
561}
562
Mark Browne4ee8312009-07-28 15:21:49 +0100563static struct platform_driver wm831x_buckv_driver = {
564 .probe = wm831x_buckv_probe,
Mark Browne4ee8312009-07-28 15:21:49 +0100565 .driver = {
566 .name = "wm831x-buckv",
Dmitry Torokhoveb66d562010-02-23 23:38:39 -0800567 .owner = THIS_MODULE,
Mark Browne4ee8312009-07-28 15:21:49 +0100568 },
569};
570
571/*
572 * BUCKP specifics
573 */
574
Axel Lind580cb52012-06-13 20:27:58 +0800575static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev, int uV)
Mark Browne4ee8312009-07-28 15:21:49 +0100576{
577 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
578 struct wm831x *wm831x = dcdc->wm831x;
Mark Browne4ee8312009-07-28 15:21:49 +0100579 u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL;
Axel Lind580cb52012-06-13 20:27:58 +0800580 int sel;
Mark Browne4ee8312009-07-28 15:21:49 +0100581
Axel Lind580cb52012-06-13 20:27:58 +0800582 sel = regulator_map_voltage_linear(rdev, uV, uV);
583 if (sel < 0)
584 return sel;
585
586 return wm831x_set_bits(wm831x, reg, WM831X_DC3_ON_VSEL_MASK, sel);
Mark Browne4ee8312009-07-28 15:21:49 +0100587}
588
Mark Browne4ee8312009-07-28 15:21:49 +0100589static struct regulator_ops wm831x_buckp_ops = {
Axel Lind580cb52012-06-13 20:27:58 +0800590 .set_voltage_sel = regulator_set_voltage_sel_regmap,
Mark Brown817436e2012-04-15 11:55:34 +0100591 .get_voltage_sel = regulator_get_voltage_sel_regmap,
Axel Linc70ad9d2012-06-13 20:27:14 +0800592 .list_voltage = regulator_list_voltage_linear,
Axel Lind580cb52012-06-13 20:27:58 +0800593 .map_voltage = regulator_map_voltage_linear,
Mark Browne4ee8312009-07-28 15:21:49 +0100594 .set_suspend_voltage = wm831x_buckp_set_suspend_voltage,
595
Mark Brown3d138fc2012-04-15 12:38:42 +0100596 .is_enabled = regulator_is_enabled_regmap,
597 .enable = regulator_enable_regmap,
598 .disable = regulator_disable_regmap,
Mark Browne4ee8312009-07-28 15:21:49 +0100599 .get_status = wm831x_dcdc_get_status,
600 .get_mode = wm831x_dcdc_get_mode,
601 .set_mode = wm831x_dcdc_set_mode,
602 .set_suspend_mode = wm831x_dcdc_set_suspend_mode,
603};
604
Bill Pembertona5023572012-11-19 13:22:22 -0500605static int wm831x_buckp_probe(struct platform_device *pdev)
Mark Browne4ee8312009-07-28 15:21:49 +0100606{
607 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
Jingoo Handff91d02013-07-30 17:20:47 +0900608 struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
Mark Brownc1727082012-04-04 00:50:22 +0100609 struct regulator_config config = { };
Mark Brown137a6352011-07-25 22:20:29 +0100610 int id;
Mark Browne4ee8312009-07-28 15:21:49 +0100611 struct wm831x_dcdc *dcdc;
612 struct resource *res;
613 int ret, irq;
614
Mark Brown137a6352011-07-25 22:20:29 +0100615 if (pdata && pdata->wm831x_num)
616 id = (pdata->wm831x_num * 10) + 1;
617 else
618 id = 0;
619 id = pdev->id - id;
620
Mark Browne4ee8312009-07-28 15:21:49 +0100621 dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
622
Mark Brownfded2f42011-12-15 02:11:14 +0800623 dcdc = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_dcdc),
624 GFP_KERNEL);
Mark Browne4ee8312009-07-28 15:21:49 +0100625 if (dcdc == NULL) {
626 dev_err(&pdev->dev, "Unable to allocate private data\n");
627 return -ENOMEM;
628 }
629
630 dcdc->wm831x = wm831x;
631
Mark Brown56560982012-08-07 19:42:47 +0100632 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
Mark Browne4ee8312009-07-28 15:21:49 +0100633 if (res == NULL) {
Mark Brown56560982012-08-07 19:42:47 +0100634 dev_err(&pdev->dev, "No REG resource\n");
Mark Browne4ee8312009-07-28 15:21:49 +0100635 ret = -EINVAL;
636 goto err;
637 }
638 dcdc->base = res->start;
639
640 snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1);
641 dcdc->desc.name = dcdc->name;
Mark Brown82caa972012-03-28 21:40:42 +0100642
643 snprintf(dcdc->supply_name, sizeof(dcdc->supply_name),
644 "DC%dVDD", id + 1);
645 dcdc->desc.supply_name = dcdc->supply_name;
646
Mark Browne4ee8312009-07-28 15:21:49 +0100647 dcdc->desc.id = id;
648 dcdc->desc.type = REGULATOR_VOLTAGE;
649 dcdc->desc.n_voltages = WM831X_BUCKP_MAX_SELECTOR + 1;
650 dcdc->desc.ops = &wm831x_buckp_ops;
651 dcdc->desc.owner = THIS_MODULE;
Mark Brown817436e2012-04-15 11:55:34 +0100652 dcdc->desc.vsel_reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
653 dcdc->desc.vsel_mask = WM831X_DC3_ON_VSEL_MASK;
Mark Brown3d138fc2012-04-15 12:38:42 +0100654 dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
655 dcdc->desc.enable_mask = 1 << id;
Axel Linc70ad9d2012-06-13 20:27:14 +0800656 dcdc->desc.min_uV = 850000;
657 dcdc->desc.uV_step = 25000;
Mark Browne4ee8312009-07-28 15:21:49 +0100658
Mark Brownc1727082012-04-04 00:50:22 +0100659 config.dev = pdev->dev.parent;
Mark Brownb7ca8782012-05-10 00:41:02 +0100660 if (pdata)
661 config.init_data = pdata->dcdc[id];
Mark Brownc1727082012-04-04 00:50:22 +0100662 config.driver_data = dcdc;
Mark Brown817436e2012-04-15 11:55:34 +0100663 config.regmap = wm831x->regmap;
Mark Brownc1727082012-04-04 00:50:22 +0100664
Mark Brownd73b4cb2013-08-31 11:58:40 +0100665 dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc,
666 &config);
Mark Browne4ee8312009-07-28 15:21:49 +0100667 if (IS_ERR(dcdc->regulator)) {
668 ret = PTR_ERR(dcdc->regulator);
669 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n",
670 id + 1, ret);
671 goto err;
672 }
673
Mark Browncd997582012-05-14 23:14:24 +0200674 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV"));
Mark Brownb0c4c0c2013-08-31 11:47:39 +0100675 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
676 wm831x_dcdc_uv_irq,
677 IRQF_TRIGGER_RISING, dcdc->name, dcdc);
Mark Browne4ee8312009-07-28 15:21:49 +0100678 if (ret != 0) {
679 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n",
680 irq, ret);
Mark Brownd73b4cb2013-08-31 11:58:40 +0100681 goto err;
Mark Browne4ee8312009-07-28 15:21:49 +0100682 }
683
684 platform_set_drvdata(pdev, dcdc);
685
686 return 0;
687
Mark Browne4ee8312009-07-28 15:21:49 +0100688err:
Mark Browne4ee8312009-07-28 15:21:49 +0100689 return ret;
690}
691
Mark Browne4ee8312009-07-28 15:21:49 +0100692static struct platform_driver wm831x_buckp_driver = {
693 .probe = wm831x_buckp_probe,
Mark Browne4ee8312009-07-28 15:21:49 +0100694 .driver = {
695 .name = "wm831x-buckp",
Dmitry Torokhoveb66d562010-02-23 23:38:39 -0800696 .owner = THIS_MODULE,
Mark Browne4ee8312009-07-28 15:21:49 +0100697 },
698};
699
Mark Brown8267a9b2009-07-28 15:22:23 +0100700/*
Mark Brown13048502009-07-28 15:23:16 +0100701 * DCDC boost convertors
702 */
703
704static int wm831x_boostp_get_status(struct regulator_dev *rdev)
705{
706 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
707 struct wm831x *wm831x = dcdc->wm831x;
708 int ret;
709
710 /* First, check for errors */
711 ret = wm831x_reg_read(wm831x, WM831X_DCDC_UV_STATUS);
712 if (ret < 0)
713 return ret;
714
715 if (ret & (1 << rdev_get_id(rdev))) {
716 dev_dbg(wm831x->dev, "DCDC%d under voltage\n",
717 rdev_get_id(rdev) + 1);
718 return REGULATOR_STATUS_ERROR;
719 }
720
721 /* Is the regulator on? */
722 ret = wm831x_reg_read(wm831x, WM831X_DCDC_STATUS);
723 if (ret < 0)
724 return ret;
725 if (ret & (1 << rdev_get_id(rdev)))
726 return REGULATOR_STATUS_ON;
727 else
728 return REGULATOR_STATUS_OFF;
729}
730
731static struct regulator_ops wm831x_boostp_ops = {
732 .get_status = wm831x_boostp_get_status,
733
Mark Brown3d138fc2012-04-15 12:38:42 +0100734 .is_enabled = regulator_is_enabled_regmap,
735 .enable = regulator_enable_regmap,
736 .disable = regulator_disable_regmap,
Mark Brown13048502009-07-28 15:23:16 +0100737};
738
Bill Pembertona5023572012-11-19 13:22:22 -0500739static int wm831x_boostp_probe(struct platform_device *pdev)
Mark Brown13048502009-07-28 15:23:16 +0100740{
741 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
Jingoo Handff91d02013-07-30 17:20:47 +0900742 struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
Mark Brownc1727082012-04-04 00:50:22 +0100743 struct regulator_config config = { };
Mark Brown13048502009-07-28 15:23:16 +0100744 int id = pdev->id % ARRAY_SIZE(pdata->dcdc);
745 struct wm831x_dcdc *dcdc;
746 struct resource *res;
747 int ret, irq;
748
749 dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
750
751 if (pdata == NULL || pdata->dcdc[id] == NULL)
752 return -ENODEV;
753
Axel Lin4c601652012-03-23 17:00:01 +0800754 dcdc = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_dcdc), GFP_KERNEL);
Mark Brown13048502009-07-28 15:23:16 +0100755 if (dcdc == NULL) {
756 dev_err(&pdev->dev, "Unable to allocate private data\n");
757 return -ENOMEM;
758 }
759
760 dcdc->wm831x = wm831x;
761
Mark Brown56560982012-08-07 19:42:47 +0100762 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
Mark Brown13048502009-07-28 15:23:16 +0100763 if (res == NULL) {
Mark Brown56560982012-08-07 19:42:47 +0100764 dev_err(&pdev->dev, "No REG resource\n");
Mark Brown13048502009-07-28 15:23:16 +0100765 ret = -EINVAL;
766 goto err;
767 }
768 dcdc->base = res->start;
769
770 snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1);
771 dcdc->desc.name = dcdc->name;
772 dcdc->desc.id = id;
773 dcdc->desc.type = REGULATOR_VOLTAGE;
774 dcdc->desc.ops = &wm831x_boostp_ops;
775 dcdc->desc.owner = THIS_MODULE;
Mark Brown3d138fc2012-04-15 12:38:42 +0100776 dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
777 dcdc->desc.enable_mask = 1 << id;
Mark Brown13048502009-07-28 15:23:16 +0100778
Mark Brownc1727082012-04-04 00:50:22 +0100779 config.dev = pdev->dev.parent;
Mark Brownf0b067d2012-05-14 11:37:09 +0100780 if (pdata)
781 config.init_data = pdata->dcdc[id];
Mark Brownc1727082012-04-04 00:50:22 +0100782 config.driver_data = dcdc;
Mark Brown3d138fc2012-04-15 12:38:42 +0100783 config.regmap = wm831x->regmap;
Mark Brownc1727082012-04-04 00:50:22 +0100784
Mark Brownd73b4cb2013-08-31 11:58:40 +0100785 dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc,
786 &config);
Mark Brown13048502009-07-28 15:23:16 +0100787 if (IS_ERR(dcdc->regulator)) {
788 ret = PTR_ERR(dcdc->regulator);
789 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n",
790 id + 1, ret);
791 goto err;
792 }
793
Mark Browncd997582012-05-14 23:14:24 +0200794 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV"));
Mark Brownb0c4c0c2013-08-31 11:47:39 +0100795 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
796 wm831x_dcdc_uv_irq,
797 IRQF_TRIGGER_RISING, dcdc->name,
798 dcdc);
Mark Brown13048502009-07-28 15:23:16 +0100799 if (ret != 0) {
800 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n",
801 irq, ret);
Mark Brownd73b4cb2013-08-31 11:58:40 +0100802 goto err;
Mark Brown13048502009-07-28 15:23:16 +0100803 }
804
805 platform_set_drvdata(pdev, dcdc);
806
807 return 0;
808
Mark Brown13048502009-07-28 15:23:16 +0100809err:
Mark Brown13048502009-07-28 15:23:16 +0100810 return ret;
811}
812
Mark Brown13048502009-07-28 15:23:16 +0100813static struct platform_driver wm831x_boostp_driver = {
814 .probe = wm831x_boostp_probe,
Mark Brown13048502009-07-28 15:23:16 +0100815 .driver = {
816 .name = "wm831x-boostp",
Dmitry Torokhoveb66d562010-02-23 23:38:39 -0800817 .owner = THIS_MODULE,
Mark Brown13048502009-07-28 15:23:16 +0100818 },
819};
820
821/*
Mark Brown8267a9b2009-07-28 15:22:23 +0100822 * External Power Enable
823 *
824 * These aren't actually DCDCs but look like them in hardware so share
825 * code.
826 */
827
828#define WM831X_EPE_BASE 6
829
830static struct regulator_ops wm831x_epe_ops = {
Mark Brown3d138fc2012-04-15 12:38:42 +0100831 .is_enabled = regulator_is_enabled_regmap,
832 .enable = regulator_enable_regmap,
833 .disable = regulator_disable_regmap,
Mark Brown8267a9b2009-07-28 15:22:23 +0100834 .get_status = wm831x_dcdc_get_status,
835};
836
Bill Pembertona5023572012-11-19 13:22:22 -0500837static int wm831x_epe_probe(struct platform_device *pdev)
Mark Brown8267a9b2009-07-28 15:22:23 +0100838{
839 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
Jingoo Handff91d02013-07-30 17:20:47 +0900840 struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
Mark Brownc1727082012-04-04 00:50:22 +0100841 struct regulator_config config = { };
Mark Brown8267a9b2009-07-28 15:22:23 +0100842 int id = pdev->id % ARRAY_SIZE(pdata->epe);
843 struct wm831x_dcdc *dcdc;
844 int ret;
845
846 dev_dbg(&pdev->dev, "Probing EPE%d\n", id + 1);
847
Axel Lin4c601652012-03-23 17:00:01 +0800848 dcdc = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_dcdc), GFP_KERNEL);
Mark Brown8267a9b2009-07-28 15:22:23 +0100849 if (dcdc == NULL) {
850 dev_err(&pdev->dev, "Unable to allocate private data\n");
851 return -ENOMEM;
852 }
853
854 dcdc->wm831x = wm831x;
855
856 /* For current parts this is correct; probably need to revisit
857 * in future.
858 */
859 snprintf(dcdc->name, sizeof(dcdc->name), "EPE%d", id + 1);
860 dcdc->desc.name = dcdc->name;
861 dcdc->desc.id = id + WM831X_EPE_BASE; /* Offset in DCDC registers */
862 dcdc->desc.ops = &wm831x_epe_ops;
863 dcdc->desc.type = REGULATOR_VOLTAGE;
864 dcdc->desc.owner = THIS_MODULE;
Mark Brown3d138fc2012-04-15 12:38:42 +0100865 dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
866 dcdc->desc.enable_mask = 1 << dcdc->desc.id;
Mark Brown8267a9b2009-07-28 15:22:23 +0100867
Mark Brownc1727082012-04-04 00:50:22 +0100868 config.dev = pdev->dev.parent;
Mark Brownb7ca8782012-05-10 00:41:02 +0100869 if (pdata)
870 config.init_data = pdata->epe[id];
Mark Brownc1727082012-04-04 00:50:22 +0100871 config.driver_data = dcdc;
Mark Brown3d138fc2012-04-15 12:38:42 +0100872 config.regmap = wm831x->regmap;
Mark Brownc1727082012-04-04 00:50:22 +0100873
Mark Brownd73b4cb2013-08-31 11:58:40 +0100874 dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc,
875 &config);
Mark Brown8267a9b2009-07-28 15:22:23 +0100876 if (IS_ERR(dcdc->regulator)) {
877 ret = PTR_ERR(dcdc->regulator);
878 dev_err(wm831x->dev, "Failed to register EPE%d: %d\n",
879 id + 1, ret);
880 goto err;
881 }
882
883 platform_set_drvdata(pdev, dcdc);
884
885 return 0;
886
887err:
Mark Brown8267a9b2009-07-28 15:22:23 +0100888 return ret;
889}
890
Mark Brown8267a9b2009-07-28 15:22:23 +0100891static struct platform_driver wm831x_epe_driver = {
892 .probe = wm831x_epe_probe,
Mark Brown8267a9b2009-07-28 15:22:23 +0100893 .driver = {
894 .name = "wm831x-epe",
Dmitry Torokhoveb66d562010-02-23 23:38:39 -0800895 .owner = THIS_MODULE,
Mark Brown8267a9b2009-07-28 15:22:23 +0100896 },
897};
898
Mark Browne4ee8312009-07-28 15:21:49 +0100899static int __init wm831x_dcdc_init(void)
900{
901 int ret;
902 ret = platform_driver_register(&wm831x_buckv_driver);
903 if (ret != 0)
904 pr_err("Failed to register WM831x BUCKV driver: %d\n", ret);
905
906 ret = platform_driver_register(&wm831x_buckp_driver);
907 if (ret != 0)
908 pr_err("Failed to register WM831x BUCKP driver: %d\n", ret);
909
Mark Brown13048502009-07-28 15:23:16 +0100910 ret = platform_driver_register(&wm831x_boostp_driver);
911 if (ret != 0)
912 pr_err("Failed to register WM831x BOOST driver: %d\n", ret);
913
Mark Brown8267a9b2009-07-28 15:22:23 +0100914 ret = platform_driver_register(&wm831x_epe_driver);
915 if (ret != 0)
916 pr_err("Failed to register WM831x EPE driver: %d\n", ret);
917
Mark Browne4ee8312009-07-28 15:21:49 +0100918 return 0;
919}
920subsys_initcall(wm831x_dcdc_init);
921
922static void __exit wm831x_dcdc_exit(void)
923{
Mark Brown8267a9b2009-07-28 15:22:23 +0100924 platform_driver_unregister(&wm831x_epe_driver);
Mark Brown13048502009-07-28 15:23:16 +0100925 platform_driver_unregister(&wm831x_boostp_driver);
Mark Browne4ee8312009-07-28 15:21:49 +0100926 platform_driver_unregister(&wm831x_buckp_driver);
927 platform_driver_unregister(&wm831x_buckv_driver);
928}
929module_exit(wm831x_dcdc_exit);
930
931/* Module information */
932MODULE_AUTHOR("Mark Brown");
933MODULE_DESCRIPTION("WM831x DC-DC convertor driver");
934MODULE_LICENSE("GPL");
935MODULE_ALIAS("platform:wm831x-buckv");
936MODULE_ALIAS("platform:wm831x-buckp");
Axel Lin43f1f212012-11-30 20:39:53 +0800937MODULE_ALIAS("platform:wm831x-boostp");
Mark Brown24b43152011-07-25 22:20:31 +0100938MODULE_ALIAS("platform:wm831x-epe");