xref: /linux/drivers/regulator/wm8400-regulator.c (revision c172708d38a401b2f3f841dfcd862b469fa0b670)
142fad570SMark Brown /*
242fad570SMark Brown  * Regulator support for WM8400
342fad570SMark Brown  *
442fad570SMark Brown  * Copyright 2008 Wolfson Microelectronics PLC.
542fad570SMark Brown  *
642fad570SMark Brown  * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
742fad570SMark Brown  *
842fad570SMark Brown  * This program is free software; you can redistribute it and/or
942fad570SMark Brown  * modify it under the terms of the GNU General Public License as
1042fad570SMark Brown  * published by the Free Software Foundation; either version 2 of the
1142fad570SMark Brown  * License, or (at your option) any later version.
1242fad570SMark Brown  *
1342fad570SMark Brown  */
1442fad570SMark Brown 
1542fad570SMark Brown #include <linux/bug.h>
1642fad570SMark Brown #include <linux/err.h>
1742fad570SMark Brown #include <linux/kernel.h>
1865602c32SPaul Gortmaker #include <linux/module.h>
1942fad570SMark Brown #include <linux/regulator/driver.h>
2042fad570SMark Brown #include <linux/mfd/wm8400-private.h>
2142fad570SMark Brown 
2242fad570SMark Brown static int wm8400_ldo_is_enabled(struct regulator_dev *dev)
2342fad570SMark Brown {
2442fad570SMark Brown 	struct wm8400 *wm8400 = rdev_get_drvdata(dev);
2542fad570SMark Brown 	u16 val;
2642fad570SMark Brown 
2742fad570SMark Brown 	val = wm8400_reg_read(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev));
2842fad570SMark Brown 	return (val & WM8400_LDO1_ENA) != 0;
2942fad570SMark Brown }
3042fad570SMark Brown 
3142fad570SMark Brown static int wm8400_ldo_enable(struct regulator_dev *dev)
3242fad570SMark Brown {
3342fad570SMark Brown 	struct wm8400 *wm8400 = rdev_get_drvdata(dev);
3442fad570SMark Brown 
3542fad570SMark Brown 	return wm8400_set_bits(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev),
3642fad570SMark Brown 			       WM8400_LDO1_ENA, WM8400_LDO1_ENA);
3742fad570SMark Brown }
3842fad570SMark Brown 
3942fad570SMark Brown static int wm8400_ldo_disable(struct regulator_dev *dev)
4042fad570SMark Brown {
4142fad570SMark Brown 	struct wm8400 *wm8400 = rdev_get_drvdata(dev);
4242fad570SMark Brown 
4342fad570SMark Brown 	return wm8400_set_bits(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev),
4442fad570SMark Brown 			       WM8400_LDO1_ENA, 0);
4542fad570SMark Brown }
4642fad570SMark Brown 
47216765d9SMark Brown static int wm8400_ldo_list_voltage(struct regulator_dev *dev,
48216765d9SMark Brown 				   unsigned selector)
49216765d9SMark Brown {
50216765d9SMark Brown 	if (selector > WM8400_LDO1_VSEL_MASK)
51216765d9SMark Brown 		return -EINVAL;
52216765d9SMark Brown 
53216765d9SMark Brown 	if (selector < 15)
54216765d9SMark Brown 		return 900000 + (selector * 50000);
55216765d9SMark Brown 	else
56216765d9SMark Brown 		return 1600000 + ((selector - 14) * 100000);
57216765d9SMark Brown }
58216765d9SMark Brown 
597ce8a2a0SMark Brown static int wm8400_ldo_get_voltage_sel(struct regulator_dev *dev)
6042fad570SMark Brown {
6142fad570SMark Brown 	struct wm8400 *wm8400 = rdev_get_drvdata(dev);
6242fad570SMark Brown 	u16 val;
6342fad570SMark Brown 
6442fad570SMark Brown 	val = wm8400_reg_read(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev));
6542fad570SMark Brown 	val &= WM8400_LDO1_VSEL_MASK;
6642fad570SMark Brown 
677ce8a2a0SMark Brown 	return val;
6842fad570SMark Brown }
6942fad570SMark Brown 
7042fad570SMark Brown static int wm8400_ldo_set_voltage(struct regulator_dev *dev,
713a93f2a9SMark Brown 				  int min_uV, int max_uV, unsigned *selector)
7242fad570SMark Brown {
7342fad570SMark Brown 	struct wm8400 *wm8400 = rdev_get_drvdata(dev);
7442fad570SMark Brown 	u16 val;
7542fad570SMark Brown 
7642fad570SMark Brown 	if (min_uV < 900000 || min_uV > 3300000)
7742fad570SMark Brown 		return -EINVAL;
7842fad570SMark Brown 
7942fad570SMark Brown 	if (min_uV < 1700000) {
8042fad570SMark Brown 		/* Steps of 50mV from 900mV;  */
81e9a15c8cSAxel Lin 		val = DIV_ROUND_UP(min_uV - 900000, 50000);
8242fad570SMark Brown 
8342fad570SMark Brown 		if ((val * 50000) + 900000 > max_uV)
8442fad570SMark Brown 			return -EINVAL;
8542fad570SMark Brown 		BUG_ON((val * 50000) + 900000 < min_uV);
8642fad570SMark Brown 	} else {
8742fad570SMark Brown 		/* Steps of 100mV from 1700mV */
88e9a15c8cSAxel Lin 		val = DIV_ROUND_UP(min_uV - 1700000, 100000);
8942fad570SMark Brown 
9042fad570SMark Brown 		if ((val * 100000) + 1700000 > max_uV)
9142fad570SMark Brown 			return -EINVAL;
9242fad570SMark Brown 		BUG_ON((val * 100000) + 1700000 < min_uV);
9342fad570SMark Brown 
9442fad570SMark Brown 		val += 0xf;
9542fad570SMark Brown 	}
9642fad570SMark Brown 
973a93f2a9SMark Brown 	*selector = val;
983a93f2a9SMark Brown 
9942fad570SMark Brown 	return wm8400_set_bits(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev),
10042fad570SMark Brown 			       WM8400_LDO1_VSEL_MASK, val);
10142fad570SMark Brown }
10242fad570SMark Brown 
10342fad570SMark Brown static struct regulator_ops wm8400_ldo_ops = {
10442fad570SMark Brown 	.is_enabled = wm8400_ldo_is_enabled,
10542fad570SMark Brown 	.enable = wm8400_ldo_enable,
10642fad570SMark Brown 	.disable = wm8400_ldo_disable,
107216765d9SMark Brown 	.list_voltage = wm8400_ldo_list_voltage,
1087ce8a2a0SMark Brown 	.get_voltage_sel = wm8400_ldo_get_voltage_sel,
10942fad570SMark Brown 	.set_voltage = wm8400_ldo_set_voltage,
11042fad570SMark Brown };
11142fad570SMark Brown 
11242fad570SMark Brown static int wm8400_dcdc_is_enabled(struct regulator_dev *dev)
11342fad570SMark Brown {
11442fad570SMark Brown 	struct wm8400 *wm8400 = rdev_get_drvdata(dev);
11542fad570SMark Brown 	int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
11642fad570SMark Brown 	u16 val;
11742fad570SMark Brown 
11842fad570SMark Brown 	val = wm8400_reg_read(wm8400, WM8400_DCDC1_CONTROL_1 + offset);
11942fad570SMark Brown 	return (val & WM8400_DC1_ENA) != 0;
12042fad570SMark Brown }
12142fad570SMark Brown 
12242fad570SMark Brown static int wm8400_dcdc_enable(struct regulator_dev *dev)
12342fad570SMark Brown {
12442fad570SMark Brown 	struct wm8400 *wm8400 = rdev_get_drvdata(dev);
12542fad570SMark Brown 	int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
12642fad570SMark Brown 
12742fad570SMark Brown 	return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
12842fad570SMark Brown 			       WM8400_DC1_ENA, WM8400_DC1_ENA);
12942fad570SMark Brown }
13042fad570SMark Brown 
13142fad570SMark Brown static int wm8400_dcdc_disable(struct regulator_dev *dev)
13242fad570SMark Brown {
13342fad570SMark Brown 	struct wm8400 *wm8400 = rdev_get_drvdata(dev);
13442fad570SMark Brown 	int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
13542fad570SMark Brown 
13642fad570SMark Brown 	return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
13742fad570SMark Brown 			       WM8400_DC1_ENA, 0);
13842fad570SMark Brown }
13942fad570SMark Brown 
140216765d9SMark Brown static int wm8400_dcdc_list_voltage(struct regulator_dev *dev,
141216765d9SMark Brown 				    unsigned selector)
142216765d9SMark Brown {
143216765d9SMark Brown 	if (selector > WM8400_DC1_VSEL_MASK)
144216765d9SMark Brown 		return -EINVAL;
145216765d9SMark Brown 
146216765d9SMark Brown 	return 850000 + (selector * 25000);
147216765d9SMark Brown }
148216765d9SMark Brown 
1497ce8a2a0SMark Brown static int wm8400_dcdc_get_voltage_sel(struct regulator_dev *dev)
15042fad570SMark Brown {
15142fad570SMark Brown 	struct wm8400 *wm8400 = rdev_get_drvdata(dev);
15242fad570SMark Brown 	u16 val;
15342fad570SMark Brown 	int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
15442fad570SMark Brown 
15542fad570SMark Brown 	val = wm8400_reg_read(wm8400, WM8400_DCDC1_CONTROL_1 + offset);
15642fad570SMark Brown 	val &= WM8400_DC1_VSEL_MASK;
15742fad570SMark Brown 
1587ce8a2a0SMark Brown 	return val;
15942fad570SMark Brown }
16042fad570SMark Brown 
16142fad570SMark Brown static int wm8400_dcdc_set_voltage(struct regulator_dev *dev,
1623a93f2a9SMark Brown 				   int min_uV, int max_uV, unsigned *selector)
16342fad570SMark Brown {
16442fad570SMark Brown 	struct wm8400 *wm8400 = rdev_get_drvdata(dev);
16542fad570SMark Brown 	u16 val;
16642fad570SMark Brown 	int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
16742fad570SMark Brown 
16842fad570SMark Brown 	if (min_uV < 850000)
16942fad570SMark Brown 		return -EINVAL;
17042fad570SMark Brown 
171e9a15c8cSAxel Lin 	val = DIV_ROUND_UP(min_uV - 850000, 25000);
17242fad570SMark Brown 
17342fad570SMark Brown 	if (850000 + (25000 * val) > max_uV)
17442fad570SMark Brown 		return -EINVAL;
17542fad570SMark Brown 	BUG_ON(850000 + (25000 * val) < min_uV);
17642fad570SMark Brown 
1773a93f2a9SMark Brown 	*selector = val;
1783a93f2a9SMark Brown 
17942fad570SMark Brown 	return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
18042fad570SMark Brown 			       WM8400_DC1_VSEL_MASK, val);
18142fad570SMark Brown }
18242fad570SMark Brown 
18342fad570SMark Brown static unsigned int wm8400_dcdc_get_mode(struct regulator_dev *dev)
18442fad570SMark Brown {
18542fad570SMark Brown 	struct wm8400 *wm8400 = rdev_get_drvdata(dev);
18642fad570SMark Brown 	int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
18742fad570SMark Brown 	u16 data[2];
18842fad570SMark Brown 	int ret;
18942fad570SMark Brown 
19042fad570SMark Brown 	ret = wm8400_block_read(wm8400, WM8400_DCDC1_CONTROL_1 + offset, 2,
19142fad570SMark Brown 				data);
19242fad570SMark Brown 	if (ret != 0)
19342fad570SMark Brown 		return 0;
19442fad570SMark Brown 
19542fad570SMark Brown 	/* Datasheet: hibernate */
19642fad570SMark Brown 	if (data[0] & WM8400_DC1_SLEEP)
19742fad570SMark Brown 		return REGULATOR_MODE_STANDBY;
19842fad570SMark Brown 
19942fad570SMark Brown 	/* Datasheet: standby */
20042fad570SMark Brown 	if (!(data[0] & WM8400_DC1_ACTIVE))
20142fad570SMark Brown 		return REGULATOR_MODE_IDLE;
20242fad570SMark Brown 
20342fad570SMark Brown 	/* Datasheet: active with or without force PWM */
20442fad570SMark Brown 	if (data[1] & WM8400_DC1_FRC_PWM)
20542fad570SMark Brown 		return REGULATOR_MODE_FAST;
20642fad570SMark Brown 	else
20742fad570SMark Brown 		return REGULATOR_MODE_NORMAL;
20842fad570SMark Brown }
20942fad570SMark Brown 
21042fad570SMark Brown static int wm8400_dcdc_set_mode(struct regulator_dev *dev, unsigned int mode)
21142fad570SMark Brown {
21242fad570SMark Brown 	struct wm8400 *wm8400 = rdev_get_drvdata(dev);
21342fad570SMark Brown 	int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
21442fad570SMark Brown 	int ret;
21542fad570SMark Brown 
21642fad570SMark Brown 	switch (mode) {
21742fad570SMark Brown 	case REGULATOR_MODE_FAST:
21842fad570SMark Brown 		/* Datasheet: active with force PWM */
21942fad570SMark Brown 		ret = wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_2 + offset,
22042fad570SMark Brown 				      WM8400_DC1_FRC_PWM, WM8400_DC1_FRC_PWM);
22142fad570SMark Brown 		if (ret != 0)
22242fad570SMark Brown 			return ret;
22342fad570SMark Brown 
22442fad570SMark Brown 		return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
22542fad570SMark Brown 				       WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP,
22642fad570SMark Brown 				       WM8400_DC1_ACTIVE);
22742fad570SMark Brown 
22842fad570SMark Brown 	case REGULATOR_MODE_NORMAL:
22942fad570SMark Brown 		/* Datasheet: active */
23042fad570SMark Brown 		ret = wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_2 + offset,
23142fad570SMark Brown 				      WM8400_DC1_FRC_PWM, 0);
23242fad570SMark Brown 		if (ret != 0)
23342fad570SMark Brown 			return ret;
23442fad570SMark Brown 
23542fad570SMark Brown 		return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
23642fad570SMark Brown 				       WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP,
23742fad570SMark Brown 				       WM8400_DC1_ACTIVE);
23842fad570SMark Brown 
23942fad570SMark Brown 	case REGULATOR_MODE_IDLE:
24042fad570SMark Brown 		/* Datasheet: standby */
24142fad570SMark Brown 		ret = wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
24242fad570SMark Brown 				      WM8400_DC1_ACTIVE, 0);
24342fad570SMark Brown 		if (ret != 0)
24442fad570SMark Brown 			return ret;
24542fad570SMark Brown 		return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
24642fad570SMark Brown 				       WM8400_DC1_SLEEP, 0);
24742fad570SMark Brown 
24842fad570SMark Brown 	default:
24942fad570SMark Brown 		return -EINVAL;
25042fad570SMark Brown 	}
25142fad570SMark Brown }
25242fad570SMark Brown 
25342fad570SMark Brown static unsigned int wm8400_dcdc_get_optimum_mode(struct regulator_dev *dev,
25442fad570SMark Brown 						 int input_uV, int output_uV,
25542fad570SMark Brown 						 int load_uA)
25642fad570SMark Brown {
25742fad570SMark Brown 	return REGULATOR_MODE_NORMAL;
25842fad570SMark Brown }
25942fad570SMark Brown 
26042fad570SMark Brown static struct regulator_ops wm8400_dcdc_ops = {
26142fad570SMark Brown 	.is_enabled = wm8400_dcdc_is_enabled,
26242fad570SMark Brown 	.enable = wm8400_dcdc_enable,
26342fad570SMark Brown 	.disable = wm8400_dcdc_disable,
264216765d9SMark Brown 	.list_voltage = wm8400_dcdc_list_voltage,
2657ce8a2a0SMark Brown 	.get_voltage_sel = wm8400_dcdc_get_voltage_sel,
26642fad570SMark Brown 	.set_voltage = wm8400_dcdc_set_voltage,
26742fad570SMark Brown 	.get_mode = wm8400_dcdc_get_mode,
26842fad570SMark Brown 	.set_mode = wm8400_dcdc_set_mode,
26942fad570SMark Brown 	.get_optimum_mode = wm8400_dcdc_get_optimum_mode,
27042fad570SMark Brown };
27142fad570SMark Brown 
27242fad570SMark Brown static struct regulator_desc regulators[] = {
27342fad570SMark Brown 	{
27442fad570SMark Brown 		.name = "LDO1",
27542fad570SMark Brown 		.id = WM8400_LDO1,
27642fad570SMark Brown 		.ops = &wm8400_ldo_ops,
277216765d9SMark Brown 		.n_voltages = WM8400_LDO1_VSEL_MASK + 1,
27842fad570SMark Brown 		.type = REGULATOR_VOLTAGE,
27942fad570SMark Brown 		.owner = THIS_MODULE,
28042fad570SMark Brown 	},
28142fad570SMark Brown 	{
28242fad570SMark Brown 		.name = "LDO2",
28342fad570SMark Brown 		.id = WM8400_LDO2,
28442fad570SMark Brown 		.ops = &wm8400_ldo_ops,
285216765d9SMark Brown 		.n_voltages = WM8400_LDO2_VSEL_MASK + 1,
28642fad570SMark Brown 		.type = REGULATOR_VOLTAGE,
28742fad570SMark Brown 		.owner = THIS_MODULE,
28842fad570SMark Brown 	},
28942fad570SMark Brown 	{
29042fad570SMark Brown 		.name = "LDO3",
29142fad570SMark Brown 		.id = WM8400_LDO3,
29242fad570SMark Brown 		.ops = &wm8400_ldo_ops,
293216765d9SMark Brown 		.n_voltages = WM8400_LDO3_VSEL_MASK + 1,
29442fad570SMark Brown 		.type = REGULATOR_VOLTAGE,
29542fad570SMark Brown 		.owner = THIS_MODULE,
29642fad570SMark Brown 	},
29742fad570SMark Brown 	{
29842fad570SMark Brown 		.name = "LDO4",
29942fad570SMark Brown 		.id = WM8400_LDO4,
30042fad570SMark Brown 		.ops = &wm8400_ldo_ops,
301216765d9SMark Brown 		.n_voltages = WM8400_LDO4_VSEL_MASK + 1,
30242fad570SMark Brown 		.type = REGULATOR_VOLTAGE,
30342fad570SMark Brown 		.owner = THIS_MODULE,
30442fad570SMark Brown 	},
30542fad570SMark Brown 	{
30642fad570SMark Brown 		.name = "DCDC1",
30742fad570SMark Brown 		.id = WM8400_DCDC1,
30842fad570SMark Brown 		.ops = &wm8400_dcdc_ops,
309216765d9SMark Brown 		.n_voltages = WM8400_DC1_VSEL_MASK + 1,
31042fad570SMark Brown 		.type = REGULATOR_VOLTAGE,
31142fad570SMark Brown 		.owner = THIS_MODULE,
31242fad570SMark Brown 	},
31342fad570SMark Brown 	{
31442fad570SMark Brown 		.name = "DCDC2",
31542fad570SMark Brown 		.id = WM8400_DCDC2,
31642fad570SMark Brown 		.ops = &wm8400_dcdc_ops,
317216765d9SMark Brown 		.n_voltages = WM8400_DC2_VSEL_MASK + 1,
31842fad570SMark Brown 		.type = REGULATOR_VOLTAGE,
31942fad570SMark Brown 		.owner = THIS_MODULE,
32042fad570SMark Brown 	},
32142fad570SMark Brown };
32242fad570SMark Brown 
3235dbdf735SUwe Kleine-König static int __devinit wm8400_regulator_probe(struct platform_device *pdev)
32442fad570SMark Brown {
3251ad02bbcSDmitry Torokhov 	struct wm8400 *wm8400 = container_of(pdev, struct wm8400, regulators[pdev->id]);
326*c172708dSMark Brown 	struct regulator_config config = { };
32742fad570SMark Brown 	struct regulator_dev *rdev;
32842fad570SMark Brown 
329*c172708dSMark Brown 	config.dev = &pdev->dev;
330*c172708dSMark Brown 	config.init_data = pdev->dev.platform_data;
331*c172708dSMark Brown 	config.driver_data = wm8400;
33242fad570SMark Brown 
333*c172708dSMark Brown 	rdev = regulator_register(&regulators[pdev->id], &config);
33442fad570SMark Brown 	if (IS_ERR(rdev))
33542fad570SMark Brown 		return PTR_ERR(rdev);
33642fad570SMark Brown 
3371ad02bbcSDmitry Torokhov 	platform_set_drvdata(pdev, rdev);
3381ad02bbcSDmitry Torokhov 
33942fad570SMark Brown 	return 0;
34042fad570SMark Brown }
34142fad570SMark Brown 
34242fad570SMark Brown static int __devexit wm8400_regulator_remove(struct platform_device *pdev)
34342fad570SMark Brown {
34442fad570SMark Brown 	struct regulator_dev *rdev = platform_get_drvdata(pdev);
34542fad570SMark Brown 
3461ad02bbcSDmitry Torokhov 	platform_set_drvdata(pdev, NULL);
34742fad570SMark Brown 	regulator_unregister(rdev);
34842fad570SMark Brown 
34942fad570SMark Brown 	return 0;
35042fad570SMark Brown }
35142fad570SMark Brown 
35242fad570SMark Brown static struct platform_driver wm8400_regulator_driver = {
35342fad570SMark Brown 	.driver = {
35442fad570SMark Brown 		.name = "wm8400-regulator",
35542fad570SMark Brown 	},
35642fad570SMark Brown 	.probe = wm8400_regulator_probe,
35742fad570SMark Brown 	.remove = __devexit_p(wm8400_regulator_remove),
35842fad570SMark Brown };
35942fad570SMark Brown 
36042fad570SMark Brown /**
36142fad570SMark Brown  * wm8400_register_regulator - enable software control of a WM8400 regulator
36242fad570SMark Brown  *
36342fad570SMark Brown  * This function enables software control of a WM8400 regulator via
36442fad570SMark Brown  * the regulator API.  It is intended to be called from the
36542fad570SMark Brown  * platform_init() callback of the WM8400 MFD driver.
36642fad570SMark Brown  *
36742fad570SMark Brown  * @param dev      The WM8400 device to operate on.
36842fad570SMark Brown  * @param reg      The regulator to control.
36942fad570SMark Brown  * @param initdata Regulator initdata for the regulator.
37042fad570SMark Brown  */
37142fad570SMark Brown int wm8400_register_regulator(struct device *dev, int reg,
37242fad570SMark Brown 			      struct regulator_init_data *initdata)
37342fad570SMark Brown {
3741909e2f6SGreg Kroah-Hartman 	struct wm8400 *wm8400 = dev_get_drvdata(dev);
37542fad570SMark Brown 
37642fad570SMark Brown 	if (wm8400->regulators[reg].name)
37742fad570SMark Brown 		return -EBUSY;
37842fad570SMark Brown 
37942fad570SMark Brown 	initdata->driver_data = wm8400;
38042fad570SMark Brown 
38142fad570SMark Brown 	wm8400->regulators[reg].name = "wm8400-regulator";
38242fad570SMark Brown 	wm8400->regulators[reg].id = reg;
38342fad570SMark Brown 	wm8400->regulators[reg].dev.parent = dev;
38442fad570SMark Brown 	wm8400->regulators[reg].dev.platform_data = initdata;
38542fad570SMark Brown 
38642fad570SMark Brown 	return platform_device_register(&wm8400->regulators[reg]);
38742fad570SMark Brown }
38842fad570SMark Brown EXPORT_SYMBOL_GPL(wm8400_register_regulator);
38942fad570SMark Brown 
39042fad570SMark Brown static int __init wm8400_regulator_init(void)
39142fad570SMark Brown {
39242fad570SMark Brown 	return platform_driver_register(&wm8400_regulator_driver);
39342fad570SMark Brown }
3945a1b22beSMark Brown subsys_initcall(wm8400_regulator_init);
39542fad570SMark Brown 
39642fad570SMark Brown static void __exit wm8400_regulator_exit(void)
39742fad570SMark Brown {
39842fad570SMark Brown 	platform_driver_unregister(&wm8400_regulator_driver);
39942fad570SMark Brown }
40042fad570SMark Brown module_exit(wm8400_regulator_exit);
40142fad570SMark Brown 
40242fad570SMark Brown MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
40342fad570SMark Brown MODULE_DESCRIPTION("WM8400 regulator driver");
40442fad570SMark Brown MODULE_LICENSE("GPL");
40542fad570SMark Brown MODULE_ALIAS("platform:wm8400-regulator");
406