blob: ad2203d11a8804cb3c6b2c4917fa95e1ba781028 [file] [log] [blame]
Axel Lin3cad5fc2019-04-17 22:16:30 +08001// SPDX-License-Identifier: GPL-2.0+
2//
3// wm831x-dcdc.c -- DC-DC buck converter driver for the WM831x series
4//
5// Copyright 2009 Wolfson Microelectronics PLC.
6//
7// Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
Mark Browne4ee8312009-07-28 15:21:49 +01008
9#include <linux/module.h>
10#include <linux/moduleparam.h>
11#include <linux/init.h>
12#include <linux/bitops.h>
13#include <linux/err.h>
14#include <linux/i2c.h>
15#include <linux/platform_device.h>
16#include <linux/regulator/driver.h>
Mark Browne24a04c2009-09-22 08:47:11 -070017#include <linux/regulator/machine.h>
Linus Walleij9a5ed0b2019-06-12 09:42:22 +020018#include <linux/gpio/consumer.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090019#include <linux/slab.h>
Mark Browne4ee8312009-07-28 15:21:49 +010020
21#include <linux/mfd/wm831x/core.h>
22#include <linux/mfd/wm831x/regulator.h>
23#include <linux/mfd/wm831x/pdata.h>
24
25#define WM831X_BUCKV_MAX_SELECTOR 0x68
26#define WM831X_BUCKP_MAX_SELECTOR 0x66
27
28#define WM831X_DCDC_MODE_FAST 0
29#define WM831X_DCDC_MODE_NORMAL 1
30#define WM831X_DCDC_MODE_IDLE 2
31#define WM831X_DCDC_MODE_STANDBY 3
32
Mark Brown82caa972012-03-28 21:40:42 +010033#define WM831X_DCDC_MAX_NAME 9
Mark Browne4ee8312009-07-28 15:21:49 +010034
35/* Register offsets in control block */
36#define WM831X_DCDC_CONTROL_1 0
37#define WM831X_DCDC_CONTROL_2 1
38#define WM831X_DCDC_ON_CONFIG 2
39#define WM831X_DCDC_SLEEP_CONTROL 3
Mark Browne24a04c2009-09-22 08:47:11 -070040#define WM831X_DCDC_DVS_CONTROL 4
Mark Browne4ee8312009-07-28 15:21:49 +010041
42/*
43 * Shared
44 */
45
46struct wm831x_dcdc {
47 char name[WM831X_DCDC_MAX_NAME];
Mark Brown82caa972012-03-28 21:40:42 +010048 char supply_name[WM831X_DCDC_MAX_NAME];
Mark Browne4ee8312009-07-28 15:21:49 +010049 struct regulator_desc desc;
50 int base;
51 struct wm831x *wm831x;
52 struct regulator_dev *regulator;
Linus Walleij9a5ed0b2019-06-12 09:42:22 +020053 struct gpio_desc *dvs_gpiod;
Mark Browne24a04c2009-09-22 08:47:11 -070054 int dvs_gpio_state;
55 int on_vsel;
56 int dvs_vsel;
Mark Browne4ee8312009-07-28 15:21:49 +010057};
58
Mark Browne4ee8312009-07-28 15:21:49 +010059static unsigned int wm831x_dcdc_get_mode(struct regulator_dev *rdev)
60
61{
62 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
63 struct wm831x *wm831x = dcdc->wm831x;
64 u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
65 int val;
66
67 val = wm831x_reg_read(wm831x, reg);
68 if (val < 0)
69 return val;
70
71 val = (val & WM831X_DC1_ON_MODE_MASK) >> WM831X_DC1_ON_MODE_SHIFT;
72
73 switch (val) {
74 case WM831X_DCDC_MODE_FAST:
75 return REGULATOR_MODE_FAST;
76 case WM831X_DCDC_MODE_NORMAL:
77 return REGULATOR_MODE_NORMAL;
78 case WM831X_DCDC_MODE_STANDBY:
79 return REGULATOR_MODE_STANDBY;
80 case WM831X_DCDC_MODE_IDLE:
81 return REGULATOR_MODE_IDLE;
82 default:
83 BUG();
Mark Brown9ee291a2011-02-02 20:17:22 +000084 return -EINVAL;
Mark Browne4ee8312009-07-28 15:21:49 +010085 }
86}
87
88static int wm831x_dcdc_set_mode_int(struct wm831x *wm831x, int reg,
89 unsigned int mode)
90{
91 int val;
92
93 switch (mode) {
94 case REGULATOR_MODE_FAST:
95 val = WM831X_DCDC_MODE_FAST;
96 break;
97 case REGULATOR_MODE_NORMAL:
98 val = WM831X_DCDC_MODE_NORMAL;
99 break;
100 case REGULATOR_MODE_STANDBY:
101 val = WM831X_DCDC_MODE_STANDBY;
102 break;
103 case REGULATOR_MODE_IDLE:
104 val = WM831X_DCDC_MODE_IDLE;
105 break;
106 default:
107 return -EINVAL;
108 }
109
110 return wm831x_set_bits(wm831x, reg, WM831X_DC1_ON_MODE_MASK,
111 val << WM831X_DC1_ON_MODE_SHIFT);
112}
113
114static int wm831x_dcdc_set_mode(struct regulator_dev *rdev, unsigned int mode)
115{
116 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
117 struct wm831x *wm831x = dcdc->wm831x;
118 u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
119
120 return wm831x_dcdc_set_mode_int(wm831x, reg, mode);
121}
122
123static int wm831x_dcdc_set_suspend_mode(struct regulator_dev *rdev,
124 unsigned int mode)
125{
126 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
127 struct wm831x *wm831x = dcdc->wm831x;
128 u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL;
129
130 return wm831x_dcdc_set_mode_int(wm831x, reg, mode);
131}
132
133static int wm831x_dcdc_get_status(struct regulator_dev *rdev)
134{
135 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
136 struct wm831x *wm831x = dcdc->wm831x;
137 int ret;
138
139 /* First, check for errors */
140 ret = wm831x_reg_read(wm831x, WM831X_DCDC_UV_STATUS);
141 if (ret < 0)
142 return ret;
143
144 if (ret & (1 << rdev_get_id(rdev))) {
145 dev_dbg(wm831x->dev, "DCDC%d under voltage\n",
146 rdev_get_id(rdev) + 1);
147 return REGULATOR_STATUS_ERROR;
148 }
149
150 /* DCDC1 and DCDC2 can additionally detect high voltage/current */
151 if (rdev_get_id(rdev) < 2) {
152 if (ret & (WM831X_DC1_OV_STS << rdev_get_id(rdev))) {
153 dev_dbg(wm831x->dev, "DCDC%d over voltage\n",
154 rdev_get_id(rdev) + 1);
155 return REGULATOR_STATUS_ERROR;
156 }
157
158 if (ret & (WM831X_DC1_HC_STS << rdev_get_id(rdev))) {
159 dev_dbg(wm831x->dev, "DCDC%d over current\n",
160 rdev_get_id(rdev) + 1);
161 return REGULATOR_STATUS_ERROR;
162 }
163 }
164
165 /* Is the regulator on? */
166 ret = wm831x_reg_read(wm831x, WM831X_DCDC_STATUS);
167 if (ret < 0)
168 return ret;
169 if (!(ret & (1 << rdev_get_id(rdev))))
170 return REGULATOR_STATUS_OFF;
171
172 /* TODO: When we handle hardware control modes so we can report the
173 * current mode. */
174 return REGULATOR_STATUS_ON;
175}
176
177static irqreturn_t wm831x_dcdc_uv_irq(int irq, void *data)
178{
179 struct wm831x_dcdc *dcdc = data;
180
Steve Twiss119c4f52019-02-26 15:48:46 +0000181 regulator_lock(dcdc->regulator);
Mark Browne4ee8312009-07-28 15:21:49 +0100182 regulator_notifier_call_chain(dcdc->regulator,
183 REGULATOR_EVENT_UNDER_VOLTAGE,
184 NULL);
Steve Twiss119c4f52019-02-26 15:48:46 +0000185 regulator_unlock(dcdc->regulator);
Mark Browne4ee8312009-07-28 15:21:49 +0100186
187 return IRQ_HANDLED;
188}
189
190static irqreturn_t wm831x_dcdc_oc_irq(int irq, void *data)
191{
192 struct wm831x_dcdc *dcdc = data;
193
Steve Twiss119c4f52019-02-26 15:48:46 +0000194 regulator_lock(dcdc->regulator);
Mark Browne4ee8312009-07-28 15:21:49 +0100195 regulator_notifier_call_chain(dcdc->regulator,
196 REGULATOR_EVENT_OVER_CURRENT,
197 NULL);
Steve Twiss119c4f52019-02-26 15:48:46 +0000198 regulator_unlock(dcdc->regulator);
Mark Browne4ee8312009-07-28 15:21:49 +0100199
200 return IRQ_HANDLED;
201}
202
203/*
204 * BUCKV specifics
205 */
206
Matti Vaittinen60ab7f42020-05-08 18:43:36 +0300207static const struct linear_range wm831x_buckv_ranges[] = {
Axel Linccffcb82019-01-20 15:33:56 +0800208 REGULATOR_LINEAR_RANGE(600000, 0, 0x7, 0),
209 REGULATOR_LINEAR_RANGE(600000, 0x8, 0x68, 12500),
210};
Mark Browne24a04c2009-09-22 08:47:11 -0700211
Mark Browne24a04c2009-09-22 08:47:11 -0700212static int wm831x_buckv_set_dvs(struct regulator_dev *rdev, int state)
213{
214 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
215
216 if (state == dcdc->dvs_gpio_state)
217 return 0;
218
219 dcdc->dvs_gpio_state = state;
Linus Walleij9a5ed0b2019-06-12 09:42:22 +0200220 gpiod_set_value(dcdc->dvs_gpiod, state);
Mark Browne24a04c2009-09-22 08:47:11 -0700221
222 /* Should wait for DVS state change to be asserted if we have
223 * a GPIO for it, for now assume the device is configured
224 * for the fastest possible transition.
225 */
226
227 return 0;
Mark Browne4ee8312009-07-28 15:21:49 +0100228}
229
Axel Linb5fb77e2012-06-13 20:29:17 +0800230static int wm831x_buckv_set_voltage_sel(struct regulator_dev *rdev,
231 unsigned vsel)
Mark Browne4ee8312009-07-28 15:21:49 +0100232{
233 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
Mark Browne24a04c2009-09-22 08:47:11 -0700234 struct wm831x *wm831x = dcdc->wm831x;
235 int on_reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
236 int dvs_reg = dcdc->base + WM831X_DCDC_DVS_CONTROL;
Axel Linb5fb77e2012-06-13 20:29:17 +0800237 int ret;
Mark Brown3a93f2a2010-11-10 14:38:29 +0000238
Mark Browne24a04c2009-09-22 08:47:11 -0700239 /* If this value is already set then do a GPIO update if we can */
Linus Walleij9a5ed0b2019-06-12 09:42:22 +0200240 if (dcdc->dvs_gpiod && dcdc->on_vsel == vsel)
Mark Browne24a04c2009-09-22 08:47:11 -0700241 return wm831x_buckv_set_dvs(rdev, 0);
242
Linus Walleij9a5ed0b2019-06-12 09:42:22 +0200243 if (dcdc->dvs_gpiod && dcdc->dvs_vsel == vsel)
Mark Browne24a04c2009-09-22 08:47:11 -0700244 return wm831x_buckv_set_dvs(rdev, 1);
245
246 /* Always set the ON status to the minimum voltage */
247 ret = wm831x_set_bits(wm831x, on_reg, WM831X_DC1_ON_VSEL_MASK, vsel);
248 if (ret < 0)
249 return ret;
250 dcdc->on_vsel = vsel;
251
Linus Walleij9a5ed0b2019-06-12 09:42:22 +0200252 if (!dcdc->dvs_gpiod)
Mark Browne24a04c2009-09-22 08:47:11 -0700253 return ret;
254
255 /* Kick the voltage transition now */
256 ret = wm831x_buckv_set_dvs(rdev, 0);
257 if (ret < 0)
258 return ret;
259
Mark Brown88cda602011-07-25 22:20:34 +0100260 /*
261 * If this VSEL is higher than the last one we've seen then
262 * remember it as the DVS VSEL. This is optimised for CPUfreq
263 * usage where we want to get to the highest voltage very
264 * quickly.
265 */
266 if (vsel > dcdc->dvs_vsel) {
267 ret = wm831x_set_bits(wm831x, dvs_reg,
268 WM831X_DC1_DVS_VSEL_MASK,
Mark Brown13ae6332012-11-20 10:02:06 +0900269 vsel);
Mark Brown88cda602011-07-25 22:20:34 +0100270 if (ret == 0)
271 dcdc->dvs_vsel = vsel;
272 else
273 dev_warn(wm831x->dev,
274 "Failed to set DCDC DVS VSEL: %d\n", ret);
Mark Browne24a04c2009-09-22 08:47:11 -0700275 }
276
Mark Browne24a04c2009-09-22 08:47:11 -0700277 return 0;
Mark Browne4ee8312009-07-28 15:21:49 +0100278}
279
280static int wm831x_buckv_set_suspend_voltage(struct regulator_dev *rdev,
Mark Browne24a04c2009-09-22 08:47:11 -0700281 int uV)
Mark Browne4ee8312009-07-28 15:21:49 +0100282{
283 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
Mark Browne24a04c2009-09-22 08:47:11 -0700284 struct wm831x *wm831x = dcdc->wm831x;
Mark Browne4ee8312009-07-28 15:21:49 +0100285 u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL;
Mark Browne24a04c2009-09-22 08:47:11 -0700286 int vsel;
Mark Browne4ee8312009-07-28 15:21:49 +0100287
Axel Linccffcb82019-01-20 15:33:56 +0800288 vsel = regulator_map_voltage_linear_range(rdev, uV, uV);
Mark Browne24a04c2009-09-22 08:47:11 -0700289 if (vsel < 0)
290 return vsel;
291
292 return wm831x_set_bits(wm831x, reg, WM831X_DC1_SLP_VSEL_MASK, vsel);
Mark Browne4ee8312009-07-28 15:21:49 +0100293}
294
Mark Brownafb8bb82010-12-10 17:28:08 +0000295static int wm831x_buckv_get_voltage_sel(struct regulator_dev *rdev)
Mark Browne4ee8312009-07-28 15:21:49 +0100296{
297 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
Mark Browne4ee8312009-07-28 15:21:49 +0100298
Linus Walleij9a5ed0b2019-06-12 09:42:22 +0200299 if (dcdc->dvs_gpiod && dcdc->dvs_gpio_state)
Mark Brownafb8bb82010-12-10 17:28:08 +0000300 return dcdc->dvs_vsel;
Mark Browne24a04c2009-09-22 08:47:11 -0700301 else
Mark Brownafb8bb82010-12-10 17:28:08 +0000302 return dcdc->on_vsel;
Mark Browne4ee8312009-07-28 15:21:49 +0100303}
304
305/* Current limit options */
Axel Linc25d4782019-02-24 21:16:51 +0800306static const unsigned int wm831x_dcdc_ilim[] = {
307 125000, 250000, 375000, 500000, 625000, 750000, 875000, 1000000
Mark Browne4ee8312009-07-28 15:21:49 +0100308};
309
Julia Lawallb0d6dd32015-12-19 16:31:24 +0100310static const struct regulator_ops wm831x_buckv_ops = {
Axel Linb5fb77e2012-06-13 20:29:17 +0800311 .set_voltage_sel = wm831x_buckv_set_voltage_sel,
Mark Brownafb8bb82010-12-10 17:28:08 +0000312 .get_voltage_sel = wm831x_buckv_get_voltage_sel,
Axel Linccffcb82019-01-20 15:33:56 +0800313 .list_voltage = regulator_list_voltage_linear_range,
314 .map_voltage = regulator_map_voltage_linear_range,
Mark Browne4ee8312009-07-28 15:21:49 +0100315 .set_suspend_voltage = wm831x_buckv_set_suspend_voltage,
Axel Lin20eb6412019-02-28 21:40:22 +0800316 .set_current_limit = regulator_set_current_limit_regmap,
317 .get_current_limit = regulator_get_current_limit_regmap,
Mark Browne4ee8312009-07-28 15:21:49 +0100318
Mark Brown3d138fc2012-04-15 12:38:42 +0100319 .is_enabled = regulator_is_enabled_regmap,
320 .enable = regulator_enable_regmap,
321 .disable = regulator_disable_regmap,
Mark Browne4ee8312009-07-28 15:21:49 +0100322 .get_status = wm831x_dcdc_get_status,
323 .get_mode = wm831x_dcdc_get_mode,
324 .set_mode = wm831x_dcdc_set_mode,
325 .set_suspend_mode = wm831x_dcdc_set_suspend_mode,
326};
327
Mark Browne24a04c2009-09-22 08:47:11 -0700328/*
329 * Set up DVS control. We just log errors since we can still run
330 * (with reduced performance) if we fail.
331 */
Mark Brown1aa20d22013-08-31 11:42:46 +0100332static void wm831x_buckv_dvs_init(struct platform_device *pdev,
333 struct wm831x_dcdc *dcdc,
334 struct wm831x_buckv_pdata *pdata)
Mark Browne24a04c2009-09-22 08:47:11 -0700335{
336 struct wm831x *wm831x = dcdc->wm831x;
337 int ret;
338 u16 ctrl;
339
Linus Walleij9a5ed0b2019-06-12 09:42:22 +0200340 if (!pdata)
Mark Browne24a04c2009-09-22 08:47:11 -0700341 return;
342
Mark Browne24a04c2009-09-22 08:47:11 -0700343 /* gpiolib won't let us read the GPIO status so pick the higher
344 * of the two existing voltages so we take it as platform data.
345 */
346 dcdc->dvs_gpio_state = pdata->dvs_init_state;
347
Linus Walleij9a5ed0b2019-06-12 09:42:22 +0200348 dcdc->dvs_gpiod = devm_gpiod_get(&pdev->dev, "dvs",
349 dcdc->dvs_gpio_state ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW);
350 if (IS_ERR(dcdc->dvs_gpiod)) {
351 dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %ld\n",
352 dcdc->name, PTR_ERR(dcdc->dvs_gpiod));
Mark Browne24a04c2009-09-22 08:47:11 -0700353 return;
354 }
355
Mark Brownb47ba9fd2011-07-25 22:20:32 +0100356 switch (pdata->dvs_control_src) {
357 case 1:
358 ctrl = 2 << WM831X_DC1_DVS_SRC_SHIFT;
359 break;
360 case 2:
361 ctrl = 3 << WM831X_DC1_DVS_SRC_SHIFT;
362 break;
363 default:
364 dev_err(wm831x->dev, "Invalid DVS control source %d for %s\n",
365 pdata->dvs_control_src, dcdc->name);
366 return;
367 }
368
Mark Brownc439b8f2011-07-25 22:20:33 +0100369 /* If DVS_VSEL is set to the minimum value then raise it to ON_VSEL
370 * to make bootstrapping a bit smoother.
371 */
372 if (!dcdc->dvs_vsel) {
373 ret = wm831x_set_bits(wm831x,
374 dcdc->base + WM831X_DCDC_DVS_CONTROL,
375 WM831X_DC1_DVS_VSEL_MASK, dcdc->on_vsel);
376 if (ret == 0)
377 dcdc->dvs_vsel = dcdc->on_vsel;
378 else
379 dev_warn(wm831x->dev, "Failed to set DVS_VSEL: %d\n",
380 ret);
381 }
382
Mark Brownb47ba9fd2011-07-25 22:20:32 +0100383 ret = wm831x_set_bits(wm831x, dcdc->base + WM831X_DCDC_DVS_CONTROL,
384 WM831X_DC1_DVS_SRC_MASK, ctrl);
385 if (ret < 0) {
386 dev_err(wm831x->dev, "Failed to set %s DVS source: %d\n",
387 dcdc->name, ret);
388 }
Mark Browne24a04c2009-09-22 08:47:11 -0700389}
390
Bill Pembertona5023572012-11-19 13:22:22 -0500391static int wm831x_buckv_probe(struct platform_device *pdev)
Mark Browne4ee8312009-07-28 15:21:49 +0100392{
393 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
Jingoo Handff91d02013-07-30 17:20:47 +0900394 struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
Mark Brownc172708d2012-04-04 00:50:22 +0100395 struct regulator_config config = { };
Mark Brown137a6352011-07-25 22:20:29 +0100396 int id;
Mark Browne4ee8312009-07-28 15:21:49 +0100397 struct wm831x_dcdc *dcdc;
398 struct resource *res;
399 int ret, irq;
400
Mark Brown137a6352011-07-25 22:20:29 +0100401 if (pdata && pdata->wm831x_num)
402 id = (pdata->wm831x_num * 10) + 1;
403 else
404 id = 0;
405 id = pdev->id - id;
406
Mark Browne4ee8312009-07-28 15:21:49 +0100407 dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
408
Mark Brownfded2f42011-12-15 02:11:14 +0800409 dcdc = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_dcdc),
410 GFP_KERNEL);
Sachin Kamat5730aa52014-02-20 14:23:20 +0530411 if (!dcdc)
Mark Browne4ee8312009-07-28 15:21:49 +0100412 return -ENOMEM;
Mark Browne4ee8312009-07-28 15:21:49 +0100413
414 dcdc->wm831x = wm831x;
415
Mark Brown56560982012-08-07 19:42:47 +0100416 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
Mark Browne4ee8312009-07-28 15:21:49 +0100417 if (res == NULL) {
Mark Brown56560982012-08-07 19:42:47 +0100418 dev_err(&pdev->dev, "No REG resource\n");
Mark Browne4ee8312009-07-28 15:21:49 +0100419 ret = -EINVAL;
420 goto err;
421 }
422 dcdc->base = res->start;
423
424 snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1);
425 dcdc->desc.name = dcdc->name;
Mark Brown82caa972012-03-28 21:40:42 +0100426
427 snprintf(dcdc->supply_name, sizeof(dcdc->supply_name),
428 "DC%dVDD", id + 1);
429 dcdc->desc.supply_name = dcdc->supply_name;
430
Mark Browne4ee8312009-07-28 15:21:49 +0100431 dcdc->desc.id = id;
432 dcdc->desc.type = REGULATOR_VOLTAGE;
433 dcdc->desc.n_voltages = WM831X_BUCKV_MAX_SELECTOR + 1;
Axel Linccffcb82019-01-20 15:33:56 +0800434 dcdc->desc.linear_ranges = wm831x_buckv_ranges;
435 dcdc->desc.n_linear_ranges = ARRAY_SIZE(wm831x_buckv_ranges);
Mark Browne4ee8312009-07-28 15:21:49 +0100436 dcdc->desc.ops = &wm831x_buckv_ops;
437 dcdc->desc.owner = THIS_MODULE;
Mark Brown3d138fc2012-04-15 12:38:42 +0100438 dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
439 dcdc->desc.enable_mask = 1 << id;
Axel Lin20eb6412019-02-28 21:40:22 +0800440 dcdc->desc.csel_reg = dcdc->base + WM831X_DCDC_CONTROL_2;
441 dcdc->desc.csel_mask = WM831X_DC1_HC_THR_MASK;
442 dcdc->desc.n_current_limits = ARRAY_SIZE(wm831x_dcdc_ilim);
443 dcdc->desc.curr_table = wm831x_dcdc_ilim;
Mark Browne4ee8312009-07-28 15:21:49 +0100444
Mark Browne24a04c2009-09-22 08:47:11 -0700445 ret = wm831x_reg_read(wm831x, dcdc->base + WM831X_DCDC_ON_CONFIG);
446 if (ret < 0) {
447 dev_err(wm831x->dev, "Failed to read ON VSEL: %d\n", ret);
448 goto err;
449 }
450 dcdc->on_vsel = ret & WM831X_DC1_ON_VSEL_MASK;
451
Mark Browna1b81dd2011-07-25 22:20:30 +0100452 ret = wm831x_reg_read(wm831x, dcdc->base + WM831X_DCDC_DVS_CONTROL);
Mark Browne24a04c2009-09-22 08:47:11 -0700453 if (ret < 0) {
454 dev_err(wm831x->dev, "Failed to read DVS VSEL: %d\n", ret);
455 goto err;
456 }
457 dcdc->dvs_vsel = ret & WM831X_DC1_DVS_VSEL_MASK;
458
Mark Brownf0b067d2012-05-14 11:37:09 +0100459 if (pdata && pdata->dcdc[id])
Mark Brown1aa20d22013-08-31 11:42:46 +0100460 wm831x_buckv_dvs_init(pdev, dcdc,
461 pdata->dcdc[id]->driver_data);
Mark Browne24a04c2009-09-22 08:47:11 -0700462
Mark Brownc172708d2012-04-04 00:50:22 +0100463 config.dev = pdev->dev.parent;
Mark Brownb7ca8782012-05-10 00:41:02 +0100464 if (pdata)
465 config.init_data = pdata->dcdc[id];
Mark Brownc172708d2012-04-04 00:50:22 +0100466 config.driver_data = dcdc;
Mark Brown3d138fc2012-04-15 12:38:42 +0100467 config.regmap = wm831x->regmap;
Mark Brownc172708d2012-04-04 00:50:22 +0100468
Mark Brownd73b4cb2013-08-31 11:58:40 +0100469 dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc,
470 &config);
Mark Browne4ee8312009-07-28 15:21:49 +0100471 if (IS_ERR(dcdc->regulator)) {
472 ret = PTR_ERR(dcdc->regulator);
473 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n",
474 id + 1, ret);
475 goto err;
476 }
477
Mark Browncd997582012-05-14 23:14:24 +0200478 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV"));
Mark Brownb0c4c0c2013-08-31 11:47:39 +0100479 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
480 wm831x_dcdc_uv_irq,
Fabio Estevam29454732015-06-01 22:33:53 -0300481 IRQF_TRIGGER_RISING | IRQF_ONESHOT,
482 dcdc->name, dcdc);
Mark Browne4ee8312009-07-28 15:21:49 +0100483 if (ret != 0) {
484 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n",
485 irq, ret);
Mark Brownd73b4cb2013-08-31 11:58:40 +0100486 goto err;
Mark Browne4ee8312009-07-28 15:21:49 +0100487 }
488
Mark Browncd997582012-05-14 23:14:24 +0200489 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC"));
Mark Brownb0c4c0c2013-08-31 11:47:39 +0100490 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
491 wm831x_dcdc_oc_irq,
Fabio Estevam29454732015-06-01 22:33:53 -0300492 IRQF_TRIGGER_RISING | IRQF_ONESHOT,
493 dcdc->name, dcdc);
Mark Browne4ee8312009-07-28 15:21:49 +0100494 if (ret != 0) {
495 dev_err(&pdev->dev, "Failed to request HC IRQ %d: %d\n",
496 irq, ret);
Mark Brownd73b4cb2013-08-31 11:58:40 +0100497 goto err;
Mark Browne4ee8312009-07-28 15:21:49 +0100498 }
499
500 platform_set_drvdata(pdev, dcdc);
501
502 return 0;
503
Mark Browne4ee8312009-07-28 15:21:49 +0100504err:
Mark Browne4ee8312009-07-28 15:21:49 +0100505 return ret;
506}
507
Mark Browne4ee8312009-07-28 15:21:49 +0100508static struct platform_driver wm831x_buckv_driver = {
509 .probe = wm831x_buckv_probe,
Mark Browne4ee8312009-07-28 15:21:49 +0100510 .driver = {
511 .name = "wm831x-buckv",
512 },
513};
514
515/*
516 * BUCKP specifics
517 */
518
Axel Lind580cb52012-06-13 20:27:58 +0800519static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev, int uV)
Mark Browne4ee8312009-07-28 15:21:49 +0100520{
521 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
522 struct wm831x *wm831x = dcdc->wm831x;
Mark Browne4ee8312009-07-28 15:21:49 +0100523 u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL;
Axel Lind580cb52012-06-13 20:27:58 +0800524 int sel;
Mark Browne4ee8312009-07-28 15:21:49 +0100525
Axel Lind580cb52012-06-13 20:27:58 +0800526 sel = regulator_map_voltage_linear(rdev, uV, uV);
527 if (sel < 0)
528 return sel;
529
530 return wm831x_set_bits(wm831x, reg, WM831X_DC3_ON_VSEL_MASK, sel);
Mark Browne4ee8312009-07-28 15:21:49 +0100531}
532
Julia Lawallb0d6dd32015-12-19 16:31:24 +0100533static const struct regulator_ops wm831x_buckp_ops = {
Axel Lind580cb52012-06-13 20:27:58 +0800534 .set_voltage_sel = regulator_set_voltage_sel_regmap,
Mark Brown817436e2012-04-15 11:55:34 +0100535 .get_voltage_sel = regulator_get_voltage_sel_regmap,
Axel Linc70ad9d2012-06-13 20:27:14 +0800536 .list_voltage = regulator_list_voltage_linear,
Axel Lind580cb52012-06-13 20:27:58 +0800537 .map_voltage = regulator_map_voltage_linear,
Mark Browne4ee8312009-07-28 15:21:49 +0100538 .set_suspend_voltage = wm831x_buckp_set_suspend_voltage,
539
Mark Brown3d138fc2012-04-15 12:38:42 +0100540 .is_enabled = regulator_is_enabled_regmap,
541 .enable = regulator_enable_regmap,
542 .disable = regulator_disable_regmap,
Mark Browne4ee8312009-07-28 15:21:49 +0100543 .get_status = wm831x_dcdc_get_status,
544 .get_mode = wm831x_dcdc_get_mode,
545 .set_mode = wm831x_dcdc_set_mode,
546 .set_suspend_mode = wm831x_dcdc_set_suspend_mode,
547};
548
Bill Pembertona5023572012-11-19 13:22:22 -0500549static int wm831x_buckp_probe(struct platform_device *pdev)
Mark Browne4ee8312009-07-28 15:21:49 +0100550{
551 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
Jingoo Handff91d02013-07-30 17:20:47 +0900552 struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
Mark Brownc172708d2012-04-04 00:50:22 +0100553 struct regulator_config config = { };
Mark Brown137a6352011-07-25 22:20:29 +0100554 int id;
Mark Browne4ee8312009-07-28 15:21:49 +0100555 struct wm831x_dcdc *dcdc;
556 struct resource *res;
557 int ret, irq;
558
Mark Brown137a6352011-07-25 22:20:29 +0100559 if (pdata && pdata->wm831x_num)
560 id = (pdata->wm831x_num * 10) + 1;
561 else
562 id = 0;
563 id = pdev->id - id;
564
Mark Browne4ee8312009-07-28 15:21:49 +0100565 dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
566
Mark Brownfded2f42011-12-15 02:11:14 +0800567 dcdc = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_dcdc),
568 GFP_KERNEL);
Sachin Kamat5730aa52014-02-20 14:23:20 +0530569 if (!dcdc)
Mark Browne4ee8312009-07-28 15:21:49 +0100570 return -ENOMEM;
Mark Browne4ee8312009-07-28 15:21:49 +0100571
572 dcdc->wm831x = wm831x;
573
Mark Brown56560982012-08-07 19:42:47 +0100574 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
Mark Browne4ee8312009-07-28 15:21:49 +0100575 if (res == NULL) {
Mark Brown56560982012-08-07 19:42:47 +0100576 dev_err(&pdev->dev, "No REG resource\n");
Mark Browne4ee8312009-07-28 15:21:49 +0100577 ret = -EINVAL;
578 goto err;
579 }
580 dcdc->base = res->start;
581
582 snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1);
583 dcdc->desc.name = dcdc->name;
Mark Brown82caa972012-03-28 21:40:42 +0100584
585 snprintf(dcdc->supply_name, sizeof(dcdc->supply_name),
586 "DC%dVDD", id + 1);
587 dcdc->desc.supply_name = dcdc->supply_name;
588
Mark Browne4ee8312009-07-28 15:21:49 +0100589 dcdc->desc.id = id;
590 dcdc->desc.type = REGULATOR_VOLTAGE;
591 dcdc->desc.n_voltages = WM831X_BUCKP_MAX_SELECTOR + 1;
592 dcdc->desc.ops = &wm831x_buckp_ops;
593 dcdc->desc.owner = THIS_MODULE;
Mark Brown817436e2012-04-15 11:55:34 +0100594 dcdc->desc.vsel_reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
595 dcdc->desc.vsel_mask = WM831X_DC3_ON_VSEL_MASK;
Mark Brown3d138fc2012-04-15 12:38:42 +0100596 dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
597 dcdc->desc.enable_mask = 1 << id;
Axel Linc70ad9d2012-06-13 20:27:14 +0800598 dcdc->desc.min_uV = 850000;
599 dcdc->desc.uV_step = 25000;
Mark Browne4ee8312009-07-28 15:21:49 +0100600
Mark Brownc172708d2012-04-04 00:50:22 +0100601 config.dev = pdev->dev.parent;
Mark Brownb7ca8782012-05-10 00:41:02 +0100602 if (pdata)
603 config.init_data = pdata->dcdc[id];
Mark Brownc172708d2012-04-04 00:50:22 +0100604 config.driver_data = dcdc;
Mark Brown817436e2012-04-15 11:55:34 +0100605 config.regmap = wm831x->regmap;
Mark Brownc172708d2012-04-04 00:50:22 +0100606
Mark Brownd73b4cb2013-08-31 11:58:40 +0100607 dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc,
608 &config);
Mark Browne4ee8312009-07-28 15:21:49 +0100609 if (IS_ERR(dcdc->regulator)) {
610 ret = PTR_ERR(dcdc->regulator);
611 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n",
612 id + 1, ret);
613 goto err;
614 }
615
Mark Browncd997582012-05-14 23:14:24 +0200616 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV"));
Mark Brownb0c4c0c2013-08-31 11:47:39 +0100617 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
618 wm831x_dcdc_uv_irq,
Fabio Estevam29454732015-06-01 22:33:53 -0300619 IRQF_TRIGGER_RISING | IRQF_ONESHOT,
620 dcdc->name, dcdc);
Mark Browne4ee8312009-07-28 15:21:49 +0100621 if (ret != 0) {
622 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n",
623 irq, ret);
Mark Brownd73b4cb2013-08-31 11:58:40 +0100624 goto err;
Mark Browne4ee8312009-07-28 15:21:49 +0100625 }
626
627 platform_set_drvdata(pdev, dcdc);
628
629 return 0;
630
Mark Browne4ee8312009-07-28 15:21:49 +0100631err:
Mark Browne4ee8312009-07-28 15:21:49 +0100632 return ret;
633}
634
Mark Browne4ee8312009-07-28 15:21:49 +0100635static struct platform_driver wm831x_buckp_driver = {
636 .probe = wm831x_buckp_probe,
Mark Browne4ee8312009-07-28 15:21:49 +0100637 .driver = {
638 .name = "wm831x-buckp",
639 },
640};
641
Mark Brown8267a9b2009-07-28 15:22:23 +0100642/*
Mark Brown13048502009-07-28 15:23:16 +0100643 * DCDC boost convertors
644 */
645
646static int wm831x_boostp_get_status(struct regulator_dev *rdev)
647{
648 struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
649 struct wm831x *wm831x = dcdc->wm831x;
650 int ret;
651
652 /* First, check for errors */
653 ret = wm831x_reg_read(wm831x, WM831X_DCDC_UV_STATUS);
654 if (ret < 0)
655 return ret;
656
657 if (ret & (1 << rdev_get_id(rdev))) {
658 dev_dbg(wm831x->dev, "DCDC%d under voltage\n",
659 rdev_get_id(rdev) + 1);
660 return REGULATOR_STATUS_ERROR;
661 }
662
663 /* Is the regulator on? */
664 ret = wm831x_reg_read(wm831x, WM831X_DCDC_STATUS);
665 if (ret < 0)
666 return ret;
667 if (ret & (1 << rdev_get_id(rdev)))
668 return REGULATOR_STATUS_ON;
669 else
670 return REGULATOR_STATUS_OFF;
671}
672
Julia Lawallb0d6dd32015-12-19 16:31:24 +0100673static const struct regulator_ops wm831x_boostp_ops = {
Mark Brown13048502009-07-28 15:23:16 +0100674 .get_status = wm831x_boostp_get_status,
675
Mark Brown3d138fc2012-04-15 12:38:42 +0100676 .is_enabled = regulator_is_enabled_regmap,
677 .enable = regulator_enable_regmap,
678 .disable = regulator_disable_regmap,
Mark Brown13048502009-07-28 15:23:16 +0100679};
680
Bill Pembertona5023572012-11-19 13:22:22 -0500681static int wm831x_boostp_probe(struct platform_device *pdev)
Mark Brown13048502009-07-28 15:23:16 +0100682{
683 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
Jingoo Handff91d02013-07-30 17:20:47 +0900684 struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
Mark Brownc172708d2012-04-04 00:50:22 +0100685 struct regulator_config config = { };
Mark Brown13048502009-07-28 15:23:16 +0100686 int id = pdev->id % ARRAY_SIZE(pdata->dcdc);
687 struct wm831x_dcdc *dcdc;
688 struct resource *res;
689 int ret, irq;
690
691 dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
692
693 if (pdata == NULL || pdata->dcdc[id] == NULL)
694 return -ENODEV;
695
Axel Lin4c60165d2012-03-23 17:00:01 +0800696 dcdc = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_dcdc), GFP_KERNEL);
Sachin Kamat5730aa52014-02-20 14:23:20 +0530697 if (!dcdc)
Mark Brown13048502009-07-28 15:23:16 +0100698 return -ENOMEM;
Mark Brown13048502009-07-28 15:23:16 +0100699
700 dcdc->wm831x = wm831x;
701
Mark Brown56560982012-08-07 19:42:47 +0100702 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
Mark Brown13048502009-07-28 15:23:16 +0100703 if (res == NULL) {
Mark Brown56560982012-08-07 19:42:47 +0100704 dev_err(&pdev->dev, "No REG resource\n");
Fabio Estevam477b2ba2013-12-30 18:03:24 -0200705 return -EINVAL;
Mark Brown13048502009-07-28 15:23:16 +0100706 }
707 dcdc->base = res->start;
708
709 snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1);
710 dcdc->desc.name = dcdc->name;
711 dcdc->desc.id = id;
712 dcdc->desc.type = REGULATOR_VOLTAGE;
713 dcdc->desc.ops = &wm831x_boostp_ops;
714 dcdc->desc.owner = THIS_MODULE;
Mark Brown3d138fc2012-04-15 12:38:42 +0100715 dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
716 dcdc->desc.enable_mask = 1 << id;
Mark Brown13048502009-07-28 15:23:16 +0100717
Mark Brownc172708d2012-04-04 00:50:22 +0100718 config.dev = pdev->dev.parent;
Mark Brownf0b067d2012-05-14 11:37:09 +0100719 if (pdata)
720 config.init_data = pdata->dcdc[id];
Mark Brownc172708d2012-04-04 00:50:22 +0100721 config.driver_data = dcdc;
Mark Brown3d138fc2012-04-15 12:38:42 +0100722 config.regmap = wm831x->regmap;
Mark Brownc172708d2012-04-04 00:50:22 +0100723
Mark Brownd73b4cb2013-08-31 11:58:40 +0100724 dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc,
725 &config);
Mark Brown13048502009-07-28 15:23:16 +0100726 if (IS_ERR(dcdc->regulator)) {
727 ret = PTR_ERR(dcdc->regulator);
728 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n",
729 id + 1, ret);
Fabio Estevam477b2ba2013-12-30 18:03:24 -0200730 return ret;
Mark Brown13048502009-07-28 15:23:16 +0100731 }
732
Mark Browncd997582012-05-14 23:14:24 +0200733 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV"));
Mark Brownb0c4c0c2013-08-31 11:47:39 +0100734 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
735 wm831x_dcdc_uv_irq,
Fabio Estevam29454732015-06-01 22:33:53 -0300736 IRQF_TRIGGER_RISING | IRQF_ONESHOT,
737 dcdc->name,
Mark Brownb0c4c0c2013-08-31 11:47:39 +0100738 dcdc);
Mark Brown13048502009-07-28 15:23:16 +0100739 if (ret != 0) {
740 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n",
741 irq, ret);
Fabio Estevam477b2ba2013-12-30 18:03:24 -0200742 return ret;
Mark Brown13048502009-07-28 15:23:16 +0100743 }
744
745 platform_set_drvdata(pdev, dcdc);
746
747 return 0;
Mark Brown13048502009-07-28 15:23:16 +0100748}
749
Mark Brown13048502009-07-28 15:23:16 +0100750static struct platform_driver wm831x_boostp_driver = {
751 .probe = wm831x_boostp_probe,
Mark Brown13048502009-07-28 15:23:16 +0100752 .driver = {
753 .name = "wm831x-boostp",
754 },
755};
756
757/*
Mark Brown8267a9b2009-07-28 15:22:23 +0100758 * External Power Enable
759 *
760 * These aren't actually DCDCs but look like them in hardware so share
761 * code.
762 */
763
764#define WM831X_EPE_BASE 6
765
Julia Lawallb0d6dd32015-12-19 16:31:24 +0100766static const struct regulator_ops wm831x_epe_ops = {
Mark Brown3d138fc2012-04-15 12:38:42 +0100767 .is_enabled = regulator_is_enabled_regmap,
768 .enable = regulator_enable_regmap,
769 .disable = regulator_disable_regmap,
Mark Brown8267a9b2009-07-28 15:22:23 +0100770 .get_status = wm831x_dcdc_get_status,
771};
772
Bill Pembertona5023572012-11-19 13:22:22 -0500773static int wm831x_epe_probe(struct platform_device *pdev)
Mark Brown8267a9b2009-07-28 15:22:23 +0100774{
775 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
Jingoo Handff91d02013-07-30 17:20:47 +0900776 struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
Mark Brownc172708d2012-04-04 00:50:22 +0100777 struct regulator_config config = { };
Mark Brown8267a9b2009-07-28 15:22:23 +0100778 int id = pdev->id % ARRAY_SIZE(pdata->epe);
779 struct wm831x_dcdc *dcdc;
780 int ret;
781
782 dev_dbg(&pdev->dev, "Probing EPE%d\n", id + 1);
783
Axel Lin4c60165d2012-03-23 17:00:01 +0800784 dcdc = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_dcdc), GFP_KERNEL);
Sachin Kamat5730aa52014-02-20 14:23:20 +0530785 if (!dcdc)
Mark Brown8267a9b2009-07-28 15:22:23 +0100786 return -ENOMEM;
Mark Brown8267a9b2009-07-28 15:22:23 +0100787
788 dcdc->wm831x = wm831x;
789
790 /* For current parts this is correct; probably need to revisit
791 * in future.
792 */
793 snprintf(dcdc->name, sizeof(dcdc->name), "EPE%d", id + 1);
794 dcdc->desc.name = dcdc->name;
795 dcdc->desc.id = id + WM831X_EPE_BASE; /* Offset in DCDC registers */
796 dcdc->desc.ops = &wm831x_epe_ops;
797 dcdc->desc.type = REGULATOR_VOLTAGE;
798 dcdc->desc.owner = THIS_MODULE;
Mark Brown3d138fc2012-04-15 12:38:42 +0100799 dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
800 dcdc->desc.enable_mask = 1 << dcdc->desc.id;
Mark Brown8267a9b2009-07-28 15:22:23 +0100801
Mark Brownc172708d2012-04-04 00:50:22 +0100802 config.dev = pdev->dev.parent;
Mark Brownb7ca8782012-05-10 00:41:02 +0100803 if (pdata)
804 config.init_data = pdata->epe[id];
Mark Brownc172708d2012-04-04 00:50:22 +0100805 config.driver_data = dcdc;
Mark Brown3d138fc2012-04-15 12:38:42 +0100806 config.regmap = wm831x->regmap;
Mark Brownc172708d2012-04-04 00:50:22 +0100807
Mark Brownd73b4cb2013-08-31 11:58:40 +0100808 dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc,
809 &config);
Mark Brown8267a9b2009-07-28 15:22:23 +0100810 if (IS_ERR(dcdc->regulator)) {
811 ret = PTR_ERR(dcdc->regulator);
812 dev_err(wm831x->dev, "Failed to register EPE%d: %d\n",
813 id + 1, ret);
814 goto err;
815 }
816
817 platform_set_drvdata(pdev, dcdc);
818
819 return 0;
820
821err:
Mark Brown8267a9b2009-07-28 15:22:23 +0100822 return ret;
823}
824
Mark Brown8267a9b2009-07-28 15:22:23 +0100825static struct platform_driver wm831x_epe_driver = {
826 .probe = wm831x_epe_probe,
Mark Brown8267a9b2009-07-28 15:22:23 +0100827 .driver = {
828 .name = "wm831x-epe",
829 },
830};
831
Thierry Reding55e03e9c2015-12-02 17:32:52 +0100832static struct platform_driver * const drivers[] = {
833 &wm831x_buckv_driver,
834 &wm831x_buckp_driver,
835 &wm831x_boostp_driver,
836 &wm831x_epe_driver,
837};
838
Mark Browne4ee8312009-07-28 15:21:49 +0100839static int __init wm831x_dcdc_init(void)
840{
Thierry Reding55e03e9c2015-12-02 17:32:52 +0100841 return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
Mark Browne4ee8312009-07-28 15:21:49 +0100842}
843subsys_initcall(wm831x_dcdc_init);
844
845static void __exit wm831x_dcdc_exit(void)
846{
Thierry Reding55e03e9c2015-12-02 17:32:52 +0100847 platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
Mark Browne4ee8312009-07-28 15:21:49 +0100848}
849module_exit(wm831x_dcdc_exit);
850
851/* Module information */
852MODULE_AUTHOR("Mark Brown");
853MODULE_DESCRIPTION("WM831x DC-DC convertor driver");
854MODULE_LICENSE("GPL");
855MODULE_ALIAS("platform:wm831x-buckv");
856MODULE_ALIAS("platform:wm831x-buckp");
Axel Lin43f1f212012-11-30 20:39:53 +0800857MODULE_ALIAS("platform:wm831x-boostp");
Mark Brown24b43152011-07-25 22:20:31 +0100858MODULE_ALIAS("platform:wm831x-epe");