blob: 318b9631155c145dc413b1c53f7c70dad63029f9 [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
38#define WM831X_DCDC_MAX_NAME 6
39
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];
53 struct regulator_desc desc;
54 int base;
55 struct wm831x *wm831x;
56 struct regulator_dev *regulator;
Mark Browne24a04c2009-09-22 08:47:11 -070057 int dvs_gpio;
58 int dvs_gpio_state;
59 int on_vsel;
60 int dvs_vsel;
Mark Browne4ee8312009-07-28 15:21:49 +010061};
62
Mark Browne4ee8312009-07-28 15:21:49 +010063static unsigned int wm831x_dcdc_get_mode(struct regulator_dev *rdev)
64
65{
66 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
67 struct wm831x *wm831x = dcdc->wm831x;
68 u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
69 int val;
70
71 val = wm831x_reg_read(wm831x, reg);
72 if (val < 0)
73 return val;
74
75 val = (val & WM831X_DC1_ON_MODE_MASK) >> WM831X_DC1_ON_MODE_SHIFT;
76
77 switch (val) {
78 case WM831X_DCDC_MODE_FAST:
79 return REGULATOR_MODE_FAST;
80 case WM831X_DCDC_MODE_NORMAL:
81 return REGULATOR_MODE_NORMAL;
82 case WM831X_DCDC_MODE_STANDBY:
83 return REGULATOR_MODE_STANDBY;
84 case WM831X_DCDC_MODE_IDLE:
85 return REGULATOR_MODE_IDLE;
86 default:
87 BUG();
Mark Brown9ee291a2011-02-02 20:17:22 +000088 return -EINVAL;
Mark Browne4ee8312009-07-28 15:21:49 +010089 }
90}
91
92static int wm831x_dcdc_set_mode_int(struct wm831x *wm831x, int reg,
93 unsigned int mode)
94{
95 int val;
96
97 switch (mode) {
98 case REGULATOR_MODE_FAST:
99 val = WM831X_DCDC_MODE_FAST;
100 break;
101 case REGULATOR_MODE_NORMAL:
102 val = WM831X_DCDC_MODE_NORMAL;
103 break;
104 case REGULATOR_MODE_STANDBY:
105 val = WM831X_DCDC_MODE_STANDBY;
106 break;
107 case REGULATOR_MODE_IDLE:
108 val = WM831X_DCDC_MODE_IDLE;
109 break;
110 default:
111 return -EINVAL;
112 }
113
114 return wm831x_set_bits(wm831x, reg, WM831X_DC1_ON_MODE_MASK,
115 val << WM831X_DC1_ON_MODE_SHIFT);
116}
117
118static int wm831x_dcdc_set_mode(struct regulator_dev *rdev, unsigned int mode)
119{
120 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
121 struct wm831x *wm831x = dcdc->wm831x;
122 u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
123
124 return wm831x_dcdc_set_mode_int(wm831x, reg, mode);
125}
126
127static int wm831x_dcdc_set_suspend_mode(struct regulator_dev *rdev,
128 unsigned int mode)
129{
130 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
131 struct wm831x *wm831x = dcdc->wm831x;
132 u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL;
133
134 return wm831x_dcdc_set_mode_int(wm831x, reg, mode);
135}
136
137static int wm831x_dcdc_get_status(struct regulator_dev *rdev)
138{
139 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
140 struct wm831x *wm831x = dcdc->wm831x;
141 int ret;
142
143 /* First, check for errors */
144 ret = wm831x_reg_read(wm831x, WM831X_DCDC_UV_STATUS);
145 if (ret < 0)
146 return ret;
147
148 if (ret & (1 << rdev_get_id(rdev))) {
149 dev_dbg(wm831x->dev, "DCDC%d under voltage\n",
150 rdev_get_id(rdev) + 1);
151 return REGULATOR_STATUS_ERROR;
152 }
153
154 /* DCDC1 and DCDC2 can additionally detect high voltage/current */
155 if (rdev_get_id(rdev) < 2) {
156 if (ret & (WM831X_DC1_OV_STS << rdev_get_id(rdev))) {
157 dev_dbg(wm831x->dev, "DCDC%d over voltage\n",
158 rdev_get_id(rdev) + 1);
159 return REGULATOR_STATUS_ERROR;
160 }
161
162 if (ret & (WM831X_DC1_HC_STS << rdev_get_id(rdev))) {
163 dev_dbg(wm831x->dev, "DCDC%d over current\n",
164 rdev_get_id(rdev) + 1);
165 return REGULATOR_STATUS_ERROR;
166 }
167 }
168
169 /* Is the regulator on? */
170 ret = wm831x_reg_read(wm831x, WM831X_DCDC_STATUS);
171 if (ret < 0)
172 return ret;
173 if (!(ret & (1 << rdev_get_id(rdev))))
174 return REGULATOR_STATUS_OFF;
175
176 /* TODO: When we handle hardware control modes so we can report the
177 * current mode. */
178 return REGULATOR_STATUS_ON;
179}
180
181static irqreturn_t wm831x_dcdc_uv_irq(int irq, void *data)
182{
183 struct wm831x_dcdc *dcdc = data;
184
185 regulator_notifier_call_chain(dcdc->regulator,
186 REGULATOR_EVENT_UNDER_VOLTAGE,
187 NULL);
188
189 return IRQ_HANDLED;
190}
191
192static irqreturn_t wm831x_dcdc_oc_irq(int irq, void *data)
193{
194 struct wm831x_dcdc *dcdc = data;
195
196 regulator_notifier_call_chain(dcdc->regulator,
197 REGULATOR_EVENT_OVER_CURRENT,
198 NULL);
199
200 return IRQ_HANDLED;
201}
202
203/*
204 * BUCKV specifics
205 */
206
207static int wm831x_buckv_list_voltage(struct regulator_dev *rdev,
208 unsigned selector)
209{
210 if (selector <= 0x8)
211 return 600000;
212 if (selector <= WM831X_BUCKV_MAX_SELECTOR)
213 return 600000 + ((selector - 0x8) * 12500);
214 return -EINVAL;
215}
216
Mark Browne24a04c2009-09-22 08:47:11 -0700217static int wm831x_buckv_select_min_voltage(struct regulator_dev *rdev,
218 int min_uV, int max_uV)
Mark Browne4ee8312009-07-28 15:21:49 +0100219{
Mark Browne4ee8312009-07-28 15:21:49 +0100220 u16 vsel;
221
222 if (min_uV < 600000)
223 vsel = 0;
224 else if (min_uV <= 1800000)
225 vsel = ((min_uV - 600000) / 12500) + 8;
226 else
227 return -EINVAL;
228
229 if (wm831x_buckv_list_voltage(rdev, vsel) > max_uV)
230 return -EINVAL;
231
Mark Browne24a04c2009-09-22 08:47:11 -0700232 return vsel;
233}
234
Mark Browne24a04c2009-09-22 08:47:11 -0700235static int wm831x_buckv_set_dvs(struct regulator_dev *rdev, int state)
236{
237 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
238
239 if (state == dcdc->dvs_gpio_state)
240 return 0;
241
242 dcdc->dvs_gpio_state = state;
243 gpio_set_value(dcdc->dvs_gpio, state);
244
245 /* Should wait for DVS state change to be asserted if we have
246 * a GPIO for it, for now assume the device is configured
247 * for the fastest possible transition.
248 */
249
250 return 0;
Mark Browne4ee8312009-07-28 15:21:49 +0100251}
252
253static int wm831x_buckv_set_voltage(struct regulator_dev *rdev,
Mark Brown3a93f2a2010-11-10 14:38:29 +0000254 int min_uV, int max_uV, unsigned *selector)
Mark Browne4ee8312009-07-28 15:21:49 +0100255{
256 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
Mark Browne24a04c2009-09-22 08:47:11 -0700257 struct wm831x *wm831x = dcdc->wm831x;
258 int on_reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
259 int dvs_reg = dcdc->base + WM831X_DCDC_DVS_CONTROL;
260 int vsel, ret;
Mark Browne4ee8312009-07-28 15:21:49 +0100261
Mark Browne24a04c2009-09-22 08:47:11 -0700262 vsel = wm831x_buckv_select_min_voltage(rdev, min_uV, max_uV);
263 if (vsel < 0)
264 return vsel;
265
Mark Brown3a93f2a2010-11-10 14:38:29 +0000266 *selector = vsel;
267
Mark Browne24a04c2009-09-22 08:47:11 -0700268 /* If this value is already set then do a GPIO update if we can */
269 if (dcdc->dvs_gpio && dcdc->on_vsel == vsel)
270 return wm831x_buckv_set_dvs(rdev, 0);
271
272 if (dcdc->dvs_gpio && dcdc->dvs_vsel == vsel)
273 return wm831x_buckv_set_dvs(rdev, 1);
274
275 /* Always set the ON status to the minimum voltage */
276 ret = wm831x_set_bits(wm831x, on_reg, WM831X_DC1_ON_VSEL_MASK, vsel);
277 if (ret < 0)
278 return ret;
279 dcdc->on_vsel = vsel;
280
281 if (!dcdc->dvs_gpio)
282 return ret;
283
284 /* Kick the voltage transition now */
285 ret = wm831x_buckv_set_dvs(rdev, 0);
286 if (ret < 0)
287 return ret;
288
Mark Brown88cda602011-07-25 22:20:34 +0100289 /*
290 * If this VSEL is higher than the last one we've seen then
291 * remember it as the DVS VSEL. This is optimised for CPUfreq
292 * usage where we want to get to the highest voltage very
293 * quickly.
294 */
295 if (vsel > dcdc->dvs_vsel) {
296 ret = wm831x_set_bits(wm831x, dvs_reg,
297 WM831X_DC1_DVS_VSEL_MASK,
298 dcdc->dvs_vsel);
299 if (ret == 0)
300 dcdc->dvs_vsel = vsel;
301 else
302 dev_warn(wm831x->dev,
303 "Failed to set DCDC DVS VSEL: %d\n", ret);
Mark Browne24a04c2009-09-22 08:47:11 -0700304 }
305
Mark Browne24a04c2009-09-22 08:47:11 -0700306 return 0;
Mark Browne4ee8312009-07-28 15:21:49 +0100307}
308
309static int wm831x_buckv_set_suspend_voltage(struct regulator_dev *rdev,
Mark Browne24a04c2009-09-22 08:47:11 -0700310 int uV)
Mark Browne4ee8312009-07-28 15:21:49 +0100311{
312 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
Mark Browne24a04c2009-09-22 08:47:11 -0700313 struct wm831x *wm831x = dcdc->wm831x;
Mark Browne4ee8312009-07-28 15:21:49 +0100314 u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL;
Mark Browne24a04c2009-09-22 08:47:11 -0700315 int vsel;
Mark Browne4ee8312009-07-28 15:21:49 +0100316
Mark Browne24a04c2009-09-22 08:47:11 -0700317 vsel = wm831x_buckv_select_min_voltage(rdev, uV, uV);
318 if (vsel < 0)
319 return vsel;
320
321 return wm831x_set_bits(wm831x, reg, WM831X_DC1_SLP_VSEL_MASK, vsel);
Mark Browne4ee8312009-07-28 15:21:49 +0100322}
323
Mark Brownafb8bb82010-12-10 17:28:08 +0000324static int wm831x_buckv_get_voltage_sel(struct regulator_dev *rdev)
Mark Browne4ee8312009-07-28 15:21:49 +0100325{
326 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
Mark Browne4ee8312009-07-28 15:21:49 +0100327
Mark Browne24a04c2009-09-22 08:47:11 -0700328 if (dcdc->dvs_gpio && dcdc->dvs_gpio_state)
Mark Brownafb8bb82010-12-10 17:28:08 +0000329 return dcdc->dvs_vsel;
Mark Browne24a04c2009-09-22 08:47:11 -0700330 else
Mark Brownafb8bb82010-12-10 17:28:08 +0000331 return dcdc->on_vsel;
Mark Browne4ee8312009-07-28 15:21:49 +0100332}
333
334/* Current limit options */
335static u16 wm831x_dcdc_ilim[] = {
336 125, 250, 375, 500, 625, 750, 875, 1000
337};
338
339static int wm831x_buckv_set_current_limit(struct regulator_dev *rdev,
340 int min_uA, int max_uA)
341{
342 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
343 struct wm831x *wm831x = dcdc->wm831x;
344 u16 reg = dcdc->base + WM831X_DCDC_CONTROL_2;
345 int i;
346
347 for (i = 0; i < ARRAY_SIZE(wm831x_dcdc_ilim); i++) {
Axel Lina171e782012-03-27 15:17:26 +0800348 if ((min_uA <= wm831x_dcdc_ilim[i]) &&
349 (wm831x_dcdc_ilim[i] <= max_uA))
Mark Browne4ee8312009-07-28 15:21:49 +0100350 break;
351 }
352 if (i == ARRAY_SIZE(wm831x_dcdc_ilim))
353 return -EINVAL;
354
Axel Lin09bf14b2012-03-15 15:53:05 +0800355 return wm831x_set_bits(wm831x, reg, WM831X_DC1_HC_THR_MASK,
356 i << WM831X_DC1_HC_THR_SHIFT);
Mark Browne4ee8312009-07-28 15:21:49 +0100357}
358
359static int wm831x_buckv_get_current_limit(struct regulator_dev *rdev)
360{
361 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
362 struct wm831x *wm831x = dcdc->wm831x;
363 u16 reg = dcdc->base + WM831X_DCDC_CONTROL_2;
364 int val;
365
366 val = wm831x_reg_read(wm831x, reg);
367 if (val < 0)
368 return val;
369
Axel Lin09bf14b2012-03-15 15:53:05 +0800370 val = (val & WM831X_DC1_HC_THR_MASK) >> WM831X_DC1_HC_THR_SHIFT;
371 return wm831x_dcdc_ilim[val];
Mark Browne4ee8312009-07-28 15:21:49 +0100372}
373
374static struct regulator_ops wm831x_buckv_ops = {
375 .set_voltage = wm831x_buckv_set_voltage,
Mark Brownafb8bb82010-12-10 17:28:08 +0000376 .get_voltage_sel = wm831x_buckv_get_voltage_sel,
Mark Browne4ee8312009-07-28 15:21:49 +0100377 .list_voltage = wm831x_buckv_list_voltage,
378 .set_suspend_voltage = wm831x_buckv_set_suspend_voltage,
379 .set_current_limit = wm831x_buckv_set_current_limit,
380 .get_current_limit = wm831x_buckv_get_current_limit,
381
Mark Brown3d138fc2012-04-15 12:38:42 +0100382 .is_enabled = regulator_is_enabled_regmap,
383 .enable = regulator_enable_regmap,
384 .disable = regulator_disable_regmap,
Mark Browne4ee8312009-07-28 15:21:49 +0100385 .get_status = wm831x_dcdc_get_status,
386 .get_mode = wm831x_dcdc_get_mode,
387 .set_mode = wm831x_dcdc_set_mode,
388 .set_suspend_mode = wm831x_dcdc_set_suspend_mode,
389};
390
Mark Browne24a04c2009-09-22 08:47:11 -0700391/*
392 * Set up DVS control. We just log errors since we can still run
393 * (with reduced performance) if we fail.
394 */
395static __devinit void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc,
396 struct wm831x_buckv_pdata *pdata)
397{
398 struct wm831x *wm831x = dcdc->wm831x;
399 int ret;
400 u16 ctrl;
401
402 if (!pdata || !pdata->dvs_gpio)
403 return;
404
Mark Browne24a04c2009-09-22 08:47:11 -0700405 ret = gpio_request(pdata->dvs_gpio, "DCDC DVS");
406 if (ret < 0) {
407 dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %d\n",
408 dcdc->name, ret);
409 return;
410 }
411
412 /* gpiolib won't let us read the GPIO status so pick the higher
413 * of the two existing voltages so we take it as platform data.
414 */
415 dcdc->dvs_gpio_state = pdata->dvs_init_state;
416
417 ret = gpio_direction_output(pdata->dvs_gpio, dcdc->dvs_gpio_state);
418 if (ret < 0) {
419 dev_err(wm831x->dev, "Failed to enable %s DVS GPIO: %d\n",
420 dcdc->name, ret);
421 gpio_free(pdata->dvs_gpio);
422 return;
423 }
424
425 dcdc->dvs_gpio = pdata->dvs_gpio;
Mark Brownb47ba9fd2011-07-25 22:20:32 +0100426
427 switch (pdata->dvs_control_src) {
428 case 1:
429 ctrl = 2 << WM831X_DC1_DVS_SRC_SHIFT;
430 break;
431 case 2:
432 ctrl = 3 << WM831X_DC1_DVS_SRC_SHIFT;
433 break;
434 default:
435 dev_err(wm831x->dev, "Invalid DVS control source %d for %s\n",
436 pdata->dvs_control_src, dcdc->name);
437 return;
438 }
439
Mark Brownc439b8f2011-07-25 22:20:33 +0100440 /* If DVS_VSEL is set to the minimum value then raise it to ON_VSEL
441 * to make bootstrapping a bit smoother.
442 */
443 if (!dcdc->dvs_vsel) {
444 ret = wm831x_set_bits(wm831x,
445 dcdc->base + WM831X_DCDC_DVS_CONTROL,
446 WM831X_DC1_DVS_VSEL_MASK, dcdc->on_vsel);
447 if (ret == 0)
448 dcdc->dvs_vsel = dcdc->on_vsel;
449 else
450 dev_warn(wm831x->dev, "Failed to set DVS_VSEL: %d\n",
451 ret);
452 }
453
Mark Brownb47ba9fd2011-07-25 22:20:32 +0100454 ret = wm831x_set_bits(wm831x, dcdc->base + WM831X_DCDC_DVS_CONTROL,
455 WM831X_DC1_DVS_SRC_MASK, ctrl);
456 if (ret < 0) {
457 dev_err(wm831x->dev, "Failed to set %s DVS source: %d\n",
458 dcdc->name, ret);
459 }
Mark Browne24a04c2009-09-22 08:47:11 -0700460}
461
Mark Browne4ee8312009-07-28 15:21:49 +0100462static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
463{
464 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
465 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
Mark Brownc172708d2012-04-04 00:50:22 +0100466 struct regulator_config config = { };
Mark Brown137a6352011-07-25 22:20:29 +0100467 int id;
Mark Browne4ee8312009-07-28 15:21:49 +0100468 struct wm831x_dcdc *dcdc;
469 struct resource *res;
470 int ret, irq;
471
Mark Brown137a6352011-07-25 22:20:29 +0100472 if (pdata && pdata->wm831x_num)
473 id = (pdata->wm831x_num * 10) + 1;
474 else
475 id = 0;
476 id = pdev->id - id;
477
Mark Browne4ee8312009-07-28 15:21:49 +0100478 dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
479
Mark Brownfded2f42011-12-15 02:11:14 +0800480 dcdc = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_dcdc),
481 GFP_KERNEL);
Mark Browne4ee8312009-07-28 15:21:49 +0100482 if (dcdc == NULL) {
483 dev_err(&pdev->dev, "Unable to allocate private data\n");
484 return -ENOMEM;
485 }
486
487 dcdc->wm831x = wm831x;
488
489 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
490 if (res == NULL) {
491 dev_err(&pdev->dev, "No I/O resource\n");
492 ret = -EINVAL;
493 goto err;
494 }
495 dcdc->base = res->start;
496
497 snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1);
498 dcdc->desc.name = dcdc->name;
499 dcdc->desc.id = id;
500 dcdc->desc.type = REGULATOR_VOLTAGE;
501 dcdc->desc.n_voltages = WM831X_BUCKV_MAX_SELECTOR + 1;
502 dcdc->desc.ops = &wm831x_buckv_ops;
503 dcdc->desc.owner = THIS_MODULE;
Mark Brown3d138fc2012-04-15 12:38:42 +0100504 dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
505 dcdc->desc.enable_mask = 1 << id;
Mark Browne4ee8312009-07-28 15:21:49 +0100506
Mark Browne24a04c2009-09-22 08:47:11 -0700507 ret = wm831x_reg_read(wm831x, dcdc->base + WM831X_DCDC_ON_CONFIG);
508 if (ret < 0) {
509 dev_err(wm831x->dev, "Failed to read ON VSEL: %d\n", ret);
510 goto err;
511 }
512 dcdc->on_vsel = ret & WM831X_DC1_ON_VSEL_MASK;
513
Mark Browna1b81dd2011-07-25 22:20:30 +0100514 ret = wm831x_reg_read(wm831x, dcdc->base + WM831X_DCDC_DVS_CONTROL);
Mark Browne24a04c2009-09-22 08:47:11 -0700515 if (ret < 0) {
516 dev_err(wm831x->dev, "Failed to read DVS VSEL: %d\n", ret);
517 goto err;
518 }
519 dcdc->dvs_vsel = ret & WM831X_DC1_DVS_VSEL_MASK;
520
521 if (pdata->dcdc[id])
522 wm831x_buckv_dvs_init(dcdc, pdata->dcdc[id]->driver_data);
523
Mark Brownc172708d2012-04-04 00:50:22 +0100524 config.dev = pdev->dev.parent;
Mark Brownb7ca8782012-05-10 00:41:02 +0100525 if (pdata)
526 config.init_data = pdata->dcdc[id];
Mark Brownc172708d2012-04-04 00:50:22 +0100527 config.driver_data = dcdc;
Mark Brown3d138fc2012-04-15 12:38:42 +0100528 config.regmap = wm831x->regmap;
Mark Brownc172708d2012-04-04 00:50:22 +0100529
530 dcdc->regulator = regulator_register(&dcdc->desc, &config);
Mark Browne4ee8312009-07-28 15:21:49 +0100531 if (IS_ERR(dcdc->regulator)) {
532 ret = PTR_ERR(dcdc->regulator);
533 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n",
534 id + 1, ret);
535 goto err;
536 }
537
538 irq = platform_get_irq_byname(pdev, "UV");
Mark Browndfda9c22011-03-01 16:50:43 +0000539 ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq,
540 IRQF_TRIGGER_RISING, dcdc->name, dcdc);
Mark Browne4ee8312009-07-28 15:21:49 +0100541 if (ret != 0) {
542 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n",
543 irq, ret);
544 goto err_regulator;
545 }
546
547 irq = platform_get_irq_byname(pdev, "HC");
Mark Browndfda9c22011-03-01 16:50:43 +0000548 ret = request_threaded_irq(irq, NULL, wm831x_dcdc_oc_irq,
549 IRQF_TRIGGER_RISING, dcdc->name, dcdc);
Mark Browne4ee8312009-07-28 15:21:49 +0100550 if (ret != 0) {
551 dev_err(&pdev->dev, "Failed to request HC IRQ %d: %d\n",
552 irq, ret);
553 goto err_uv;
554 }
555
556 platform_set_drvdata(pdev, dcdc);
557
558 return 0;
559
560err_uv:
Mark Browndfda9c22011-03-01 16:50:43 +0000561 free_irq(platform_get_irq_byname(pdev, "UV"), dcdc);
Mark Browne4ee8312009-07-28 15:21:49 +0100562err_regulator:
563 regulator_unregister(dcdc->regulator);
564err:
Mark Browne24a04c2009-09-22 08:47:11 -0700565 if (dcdc->dvs_gpio)
566 gpio_free(dcdc->dvs_gpio);
Mark Browne4ee8312009-07-28 15:21:49 +0100567 return ret;
568}
569
570static __devexit int wm831x_buckv_remove(struct platform_device *pdev)
571{
572 struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
Mark Browne4ee8312009-07-28 15:21:49 +0100573
Dmitry Torokhoveb66d562010-02-23 23:38:39 -0800574 platform_set_drvdata(pdev, NULL);
575
Mark Brown69952362011-03-18 12:43:35 +0000576 free_irq(platform_get_irq_byname(pdev, "HC"), dcdc);
577 free_irq(platform_get_irq_byname(pdev, "UV"), dcdc);
Mark Browne4ee8312009-07-28 15:21:49 +0100578 regulator_unregister(dcdc->regulator);
Mark Browne24a04c2009-09-22 08:47:11 -0700579 if (dcdc->dvs_gpio)
580 gpio_free(dcdc->dvs_gpio);
Mark Browne4ee8312009-07-28 15:21:49 +0100581
582 return 0;
583}
584
585static struct platform_driver wm831x_buckv_driver = {
586 .probe = wm831x_buckv_probe,
587 .remove = __devexit_p(wm831x_buckv_remove),
588 .driver = {
589 .name = "wm831x-buckv",
Dmitry Torokhoveb66d562010-02-23 23:38:39 -0800590 .owner = THIS_MODULE,
Mark Browne4ee8312009-07-28 15:21:49 +0100591 },
592};
593
594/*
595 * BUCKP specifics
596 */
597
598static int wm831x_buckp_list_voltage(struct regulator_dev *rdev,
599 unsigned selector)
600{
601 if (selector <= WM831X_BUCKP_MAX_SELECTOR)
602 return 850000 + (selector * 25000);
603 else
604 return -EINVAL;
605}
606
607static int wm831x_buckp_set_voltage_int(struct regulator_dev *rdev, int reg,
Mark Brown3a93f2a2010-11-10 14:38:29 +0000608 int min_uV, int max_uV, int *selector)
Mark Browne4ee8312009-07-28 15:21:49 +0100609{
610 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
611 struct wm831x *wm831x = dcdc->wm831x;
612 u16 vsel;
613
614 if (min_uV <= 34000000)
615 vsel = (min_uV - 850000) / 25000;
616 else
617 return -EINVAL;
618
619 if (wm831x_buckp_list_voltage(rdev, vsel) > max_uV)
620 return -EINVAL;
621
Mark Brown3a93f2a2010-11-10 14:38:29 +0000622 *selector = vsel;
623
Mark Browne4ee8312009-07-28 15:21:49 +0100624 return wm831x_set_bits(wm831x, reg, WM831X_DC3_ON_VSEL_MASK, vsel);
625}
626
627static int wm831x_buckp_set_voltage(struct regulator_dev *rdev,
Mark Brown3a93f2a2010-11-10 14:38:29 +0000628 int min_uV, int max_uV,
629 unsigned *selector)
Mark Browne4ee8312009-07-28 15:21:49 +0100630{
631 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
632 u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
633
Mark Brown3a93f2a2010-11-10 14:38:29 +0000634 return wm831x_buckp_set_voltage_int(rdev, reg, min_uV, max_uV,
635 selector);
Mark Browne4ee8312009-07-28 15:21:49 +0100636}
637
638static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev,
639 int uV)
640{
641 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
642 u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL;
Mark Brown3a93f2a2010-11-10 14:38:29 +0000643 unsigned selector;
Mark Browne4ee8312009-07-28 15:21:49 +0100644
Mark Brown3a93f2a2010-11-10 14:38:29 +0000645 return wm831x_buckp_set_voltage_int(rdev, reg, uV, uV, &selector);
Mark Browne4ee8312009-07-28 15:21:49 +0100646}
647
Mark Browne4ee8312009-07-28 15:21:49 +0100648static struct regulator_ops wm831x_buckp_ops = {
649 .set_voltage = wm831x_buckp_set_voltage,
Mark Brown817436e2012-04-15 11:55:34 +0100650 .get_voltage_sel = regulator_get_voltage_sel_regmap,
Mark Browne4ee8312009-07-28 15:21:49 +0100651 .list_voltage = wm831x_buckp_list_voltage,
652 .set_suspend_voltage = wm831x_buckp_set_suspend_voltage,
653
Mark Brown3d138fc2012-04-15 12:38:42 +0100654 .is_enabled = regulator_is_enabled_regmap,
655 .enable = regulator_enable_regmap,
656 .disable = regulator_disable_regmap,
Mark Browne4ee8312009-07-28 15:21:49 +0100657 .get_status = wm831x_dcdc_get_status,
658 .get_mode = wm831x_dcdc_get_mode,
659 .set_mode = wm831x_dcdc_set_mode,
660 .set_suspend_mode = wm831x_dcdc_set_suspend_mode,
661};
662
663static __devinit int wm831x_buckp_probe(struct platform_device *pdev)
664{
665 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
666 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
Mark Brownc172708d2012-04-04 00:50:22 +0100667 struct regulator_config config = { };
Mark Brown137a6352011-07-25 22:20:29 +0100668 int id;
Mark Browne4ee8312009-07-28 15:21:49 +0100669 struct wm831x_dcdc *dcdc;
670 struct resource *res;
671 int ret, irq;
672
Mark Brown137a6352011-07-25 22:20:29 +0100673 if (pdata && pdata->wm831x_num)
674 id = (pdata->wm831x_num * 10) + 1;
675 else
676 id = 0;
677 id = pdev->id - id;
678
Mark Browne4ee8312009-07-28 15:21:49 +0100679 dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
680
Mark Brownfded2f42011-12-15 02:11:14 +0800681 dcdc = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_dcdc),
682 GFP_KERNEL);
Mark Browne4ee8312009-07-28 15:21:49 +0100683 if (dcdc == NULL) {
684 dev_err(&pdev->dev, "Unable to allocate private data\n");
685 return -ENOMEM;
686 }
687
688 dcdc->wm831x = wm831x;
689
690 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
691 if (res == NULL) {
692 dev_err(&pdev->dev, "No I/O resource\n");
693 ret = -EINVAL;
694 goto err;
695 }
696 dcdc->base = res->start;
697
698 snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1);
699 dcdc->desc.name = dcdc->name;
700 dcdc->desc.id = id;
701 dcdc->desc.type = REGULATOR_VOLTAGE;
702 dcdc->desc.n_voltages = WM831X_BUCKP_MAX_SELECTOR + 1;
703 dcdc->desc.ops = &wm831x_buckp_ops;
704 dcdc->desc.owner = THIS_MODULE;
Mark Brown817436e2012-04-15 11:55:34 +0100705 dcdc->desc.vsel_reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
706 dcdc->desc.vsel_mask = WM831X_DC3_ON_VSEL_MASK;
Mark Brown3d138fc2012-04-15 12:38:42 +0100707 dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
708 dcdc->desc.enable_mask = 1 << id;
Mark Browne4ee8312009-07-28 15:21:49 +0100709
Mark Brownc172708d2012-04-04 00:50:22 +0100710 config.dev = pdev->dev.parent;
Mark Brownb7ca8782012-05-10 00:41:02 +0100711 if (pdata)
712 config.init_data = pdata->dcdc[id];
Mark Brownc172708d2012-04-04 00:50:22 +0100713 config.driver_data = dcdc;
Mark Brown817436e2012-04-15 11:55:34 +0100714 config.regmap = wm831x->regmap;
Mark Brownc172708d2012-04-04 00:50:22 +0100715
716 dcdc->regulator = regulator_register(&dcdc->desc, &config);
Mark Browne4ee8312009-07-28 15:21:49 +0100717 if (IS_ERR(dcdc->regulator)) {
718 ret = PTR_ERR(dcdc->regulator);
719 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n",
720 id + 1, ret);
721 goto err;
722 }
723
724 irq = platform_get_irq_byname(pdev, "UV");
Mark Browndfda9c22011-03-01 16:50:43 +0000725 ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq,
726 IRQF_TRIGGER_RISING, dcdc->name, dcdc);
Mark Browne4ee8312009-07-28 15:21:49 +0100727 if (ret != 0) {
728 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n",
729 irq, ret);
730 goto err_regulator;
731 }
732
733 platform_set_drvdata(pdev, dcdc);
734
735 return 0;
736
737err_regulator:
738 regulator_unregister(dcdc->regulator);
739err:
Mark Browne4ee8312009-07-28 15:21:49 +0100740 return ret;
741}
742
743static __devexit int wm831x_buckp_remove(struct platform_device *pdev)
744{
745 struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
Mark Browne4ee8312009-07-28 15:21:49 +0100746
Dmitry Torokhoveb66d562010-02-23 23:38:39 -0800747 platform_set_drvdata(pdev, NULL);
748
Mark Brown69952362011-03-18 12:43:35 +0000749 free_irq(platform_get_irq_byname(pdev, "UV"), dcdc);
Mark Browne4ee8312009-07-28 15:21:49 +0100750 regulator_unregister(dcdc->regulator);
Mark Browne4ee8312009-07-28 15:21:49 +0100751
752 return 0;
753}
754
755static struct platform_driver wm831x_buckp_driver = {
756 .probe = wm831x_buckp_probe,
757 .remove = __devexit_p(wm831x_buckp_remove),
758 .driver = {
759 .name = "wm831x-buckp",
Dmitry Torokhoveb66d562010-02-23 23:38:39 -0800760 .owner = THIS_MODULE,
Mark Browne4ee8312009-07-28 15:21:49 +0100761 },
762};
763
Mark Brown8267a9b2009-07-28 15:22:23 +0100764/*
Mark Brown13048502009-07-28 15:23:16 +0100765 * DCDC boost convertors
766 */
767
768static int wm831x_boostp_get_status(struct regulator_dev *rdev)
769{
770 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
771 struct wm831x *wm831x = dcdc->wm831x;
772 int ret;
773
774 /* First, check for errors */
775 ret = wm831x_reg_read(wm831x, WM831X_DCDC_UV_STATUS);
776 if (ret < 0)
777 return ret;
778
779 if (ret & (1 << rdev_get_id(rdev))) {
780 dev_dbg(wm831x->dev, "DCDC%d under voltage\n",
781 rdev_get_id(rdev) + 1);
782 return REGULATOR_STATUS_ERROR;
783 }
784
785 /* Is the regulator on? */
786 ret = wm831x_reg_read(wm831x, WM831X_DCDC_STATUS);
787 if (ret < 0)
788 return ret;
789 if (ret & (1 << rdev_get_id(rdev)))
790 return REGULATOR_STATUS_ON;
791 else
792 return REGULATOR_STATUS_OFF;
793}
794
795static struct regulator_ops wm831x_boostp_ops = {
796 .get_status = wm831x_boostp_get_status,
797
Mark Brown3d138fc2012-04-15 12:38:42 +0100798 .is_enabled = regulator_is_enabled_regmap,
799 .enable = regulator_enable_regmap,
800 .disable = regulator_disable_regmap,
Mark Brown13048502009-07-28 15:23:16 +0100801};
802
803static __devinit int wm831x_boostp_probe(struct platform_device *pdev)
804{
805 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
806 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
Mark Brownc172708d2012-04-04 00:50:22 +0100807 struct regulator_config config = { };
Mark Brown13048502009-07-28 15:23:16 +0100808 int id = pdev->id % ARRAY_SIZE(pdata->dcdc);
809 struct wm831x_dcdc *dcdc;
810 struct resource *res;
811 int ret, irq;
812
813 dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
814
815 if (pdata == NULL || pdata->dcdc[id] == NULL)
816 return -ENODEV;
817
Axel Lin4c601652012-03-23 17:00:01 +0800818 dcdc = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_dcdc), GFP_KERNEL);
Mark Brown13048502009-07-28 15:23:16 +0100819 if (dcdc == NULL) {
820 dev_err(&pdev->dev, "Unable to allocate private data\n");
821 return -ENOMEM;
822 }
823
824 dcdc->wm831x = wm831x;
825
826 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
827 if (res == NULL) {
828 dev_err(&pdev->dev, "No I/O resource\n");
829 ret = -EINVAL;
830 goto err;
831 }
832 dcdc->base = res->start;
833
834 snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1);
835 dcdc->desc.name = dcdc->name;
836 dcdc->desc.id = id;
837 dcdc->desc.type = REGULATOR_VOLTAGE;
838 dcdc->desc.ops = &wm831x_boostp_ops;
839 dcdc->desc.owner = THIS_MODULE;
Mark Brown3d138fc2012-04-15 12:38:42 +0100840 dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
841 dcdc->desc.enable_mask = 1 << id;
Mark Brown13048502009-07-28 15:23:16 +0100842
Mark Brownc172708d2012-04-04 00:50:22 +0100843 config.dev = pdev->dev.parent;
844 config.init_data = pdata->dcdc[id];
845 config.driver_data = dcdc;
Mark Brown3d138fc2012-04-15 12:38:42 +0100846 config.regmap = wm831x->regmap;
Mark Brownc172708d2012-04-04 00:50:22 +0100847
848 dcdc->regulator = regulator_register(&dcdc->desc, &config);
Mark Brown13048502009-07-28 15:23:16 +0100849 if (IS_ERR(dcdc->regulator)) {
850 ret = PTR_ERR(dcdc->regulator);
851 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n",
852 id + 1, ret);
853 goto err;
854 }
855
856 irq = platform_get_irq_byname(pdev, "UV");
Mark Browndfda9c22011-03-01 16:50:43 +0000857 ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq,
858 IRQF_TRIGGER_RISING, dcdc->name,
859 dcdc);
Mark Brown13048502009-07-28 15:23:16 +0100860 if (ret != 0) {
861 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n",
862 irq, ret);
863 goto err_regulator;
864 }
865
866 platform_set_drvdata(pdev, dcdc);
867
868 return 0;
869
870err_regulator:
871 regulator_unregister(dcdc->regulator);
872err:
Mark Brown13048502009-07-28 15:23:16 +0100873 return ret;
874}
875
876static __devexit int wm831x_boostp_remove(struct platform_device *pdev)
877{
878 struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
Mark Brown13048502009-07-28 15:23:16 +0100879
Dmitry Torokhoveb66d562010-02-23 23:38:39 -0800880 platform_set_drvdata(pdev, NULL);
881
Mark Browndfda9c22011-03-01 16:50:43 +0000882 free_irq(platform_get_irq_byname(pdev, "UV"), dcdc);
Mark Brown13048502009-07-28 15:23:16 +0100883 regulator_unregister(dcdc->regulator);
Mark Brown13048502009-07-28 15:23:16 +0100884
885 return 0;
886}
887
888static struct platform_driver wm831x_boostp_driver = {
889 .probe = wm831x_boostp_probe,
890 .remove = __devexit_p(wm831x_boostp_remove),
891 .driver = {
892 .name = "wm831x-boostp",
Dmitry Torokhoveb66d562010-02-23 23:38:39 -0800893 .owner = THIS_MODULE,
Mark Brown13048502009-07-28 15:23:16 +0100894 },
895};
896
897/*
Mark Brown8267a9b2009-07-28 15:22:23 +0100898 * External Power Enable
899 *
900 * These aren't actually DCDCs but look like them in hardware so share
901 * code.
902 */
903
904#define WM831X_EPE_BASE 6
905
906static struct regulator_ops wm831x_epe_ops = {
Mark Brown3d138fc2012-04-15 12:38:42 +0100907 .is_enabled = regulator_is_enabled_regmap,
908 .enable = regulator_enable_regmap,
909 .disable = regulator_disable_regmap,
Mark Brown8267a9b2009-07-28 15:22:23 +0100910 .get_status = wm831x_dcdc_get_status,
911};
912
913static __devinit int wm831x_epe_probe(struct platform_device *pdev)
914{
915 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
916 struct wm831x_pdata *pdata = wm831x->dev->platform_data;
Mark Brownc172708d2012-04-04 00:50:22 +0100917 struct regulator_config config = { };
Mark Brown8267a9b2009-07-28 15:22:23 +0100918 int id = pdev->id % ARRAY_SIZE(pdata->epe);
919 struct wm831x_dcdc *dcdc;
920 int ret;
921
922 dev_dbg(&pdev->dev, "Probing EPE%d\n", id + 1);
923
Axel Lin4c601652012-03-23 17:00:01 +0800924 dcdc = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_dcdc), GFP_KERNEL);
Mark Brown8267a9b2009-07-28 15:22:23 +0100925 if (dcdc == NULL) {
926 dev_err(&pdev->dev, "Unable to allocate private data\n");
927 return -ENOMEM;
928 }
929
930 dcdc->wm831x = wm831x;
931
932 /* For current parts this is correct; probably need to revisit
933 * in future.
934 */
935 snprintf(dcdc->name, sizeof(dcdc->name), "EPE%d", id + 1);
936 dcdc->desc.name = dcdc->name;
937 dcdc->desc.id = id + WM831X_EPE_BASE; /* Offset in DCDC registers */
938 dcdc->desc.ops = &wm831x_epe_ops;
939 dcdc->desc.type = REGULATOR_VOLTAGE;
940 dcdc->desc.owner = THIS_MODULE;
Mark Brown3d138fc2012-04-15 12:38:42 +0100941 dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
942 dcdc->desc.enable_mask = 1 << dcdc->desc.id;
Mark Brown8267a9b2009-07-28 15:22:23 +0100943
Mark Brownc172708d2012-04-04 00:50:22 +0100944 config.dev = pdev->dev.parent;
Mark Brownb7ca8782012-05-10 00:41:02 +0100945 if (pdata)
946 config.init_data = pdata->epe[id];
Mark Brownc172708d2012-04-04 00:50:22 +0100947 config.driver_data = dcdc;
Mark Brown3d138fc2012-04-15 12:38:42 +0100948 config.regmap = wm831x->regmap;
Mark Brownc172708d2012-04-04 00:50:22 +0100949
950 dcdc->regulator = regulator_register(&dcdc->desc, &config);
Mark Brown8267a9b2009-07-28 15:22:23 +0100951 if (IS_ERR(dcdc->regulator)) {
952 ret = PTR_ERR(dcdc->regulator);
953 dev_err(wm831x->dev, "Failed to register EPE%d: %d\n",
954 id + 1, ret);
955 goto err;
956 }
957
958 platform_set_drvdata(pdev, dcdc);
959
960 return 0;
961
962err:
Mark Brown8267a9b2009-07-28 15:22:23 +0100963 return ret;
964}
965
966static __devexit int wm831x_epe_remove(struct platform_device *pdev)
967{
968 struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev);
969
Dmitry Torokhoveb66d562010-02-23 23:38:39 -0800970 platform_set_drvdata(pdev, NULL);
Mark Brown8267a9b2009-07-28 15:22:23 +0100971 regulator_unregister(dcdc->regulator);
Mark Brown8267a9b2009-07-28 15:22:23 +0100972
973 return 0;
974}
975
976static struct platform_driver wm831x_epe_driver = {
977 .probe = wm831x_epe_probe,
978 .remove = __devexit_p(wm831x_epe_remove),
979 .driver = {
980 .name = "wm831x-epe",
Dmitry Torokhoveb66d562010-02-23 23:38:39 -0800981 .owner = THIS_MODULE,
Mark Brown8267a9b2009-07-28 15:22:23 +0100982 },
983};
984
Mark Browne4ee8312009-07-28 15:21:49 +0100985static int __init wm831x_dcdc_init(void)
986{
987 int ret;
988 ret = platform_driver_register(&wm831x_buckv_driver);
989 if (ret != 0)
990 pr_err("Failed to register WM831x BUCKV driver: %d\n", ret);
991
992 ret = platform_driver_register(&wm831x_buckp_driver);
993 if (ret != 0)
994 pr_err("Failed to register WM831x BUCKP driver: %d\n", ret);
995
Mark Brown13048502009-07-28 15:23:16 +0100996 ret = platform_driver_register(&wm831x_boostp_driver);
997 if (ret != 0)
998 pr_err("Failed to register WM831x BOOST driver: %d\n", ret);
999
Mark Brown8267a9b2009-07-28 15:22:23 +01001000 ret = platform_driver_register(&wm831x_epe_driver);
1001 if (ret != 0)
1002 pr_err("Failed to register WM831x EPE driver: %d\n", ret);
1003
Mark Browne4ee8312009-07-28 15:21:49 +01001004 return 0;
1005}
1006subsys_initcall(wm831x_dcdc_init);
1007
1008static void __exit wm831x_dcdc_exit(void)
1009{
Mark Brown8267a9b2009-07-28 15:22:23 +01001010 platform_driver_unregister(&wm831x_epe_driver);
Mark Brown13048502009-07-28 15:23:16 +01001011 platform_driver_unregister(&wm831x_boostp_driver);
Mark Browne4ee8312009-07-28 15:21:49 +01001012 platform_driver_unregister(&wm831x_buckp_driver);
1013 platform_driver_unregister(&wm831x_buckv_driver);
1014}
1015module_exit(wm831x_dcdc_exit);
1016
1017/* Module information */
1018MODULE_AUTHOR("Mark Brown");
1019MODULE_DESCRIPTION("WM831x DC-DC convertor driver");
1020MODULE_LICENSE("GPL");
1021MODULE_ALIAS("platform:wm831x-buckv");
1022MODULE_ALIAS("platform:wm831x-buckp");
Mark Brown24b43152011-07-25 22:20:31 +01001023MODULE_ALIAS("platform:wm831x-epe");