Commit 3d138fcc authored by Mark Brown's avatar Mark Brown

regulator: wm831x-dcdc: Use generic regmap enable/disable operations

Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: default avatarLiam Girdwood <lrg@ti.com>
parent cd6dffb4
...@@ -60,41 +60,6 @@ struct wm831x_dcdc { ...@@ -60,41 +60,6 @@ struct wm831x_dcdc {
int dvs_vsel; int dvs_vsel;
}; };
static int wm831x_dcdc_is_enabled(struct regulator_dev *rdev)
{
struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
struct wm831x *wm831x = dcdc->wm831x;
int mask = 1 << rdev_get_id(rdev);
int reg;
reg = wm831x_reg_read(wm831x, WM831X_DCDC_ENABLE);
if (reg < 0)
return reg;
if (reg & mask)
return 1;
else
return 0;
}
static int wm831x_dcdc_enable(struct regulator_dev *rdev)
{
struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
struct wm831x *wm831x = dcdc->wm831x;
int mask = 1 << rdev_get_id(rdev);
return wm831x_set_bits(wm831x, WM831X_DCDC_ENABLE, mask, mask);
}
static int wm831x_dcdc_disable(struct regulator_dev *rdev)
{
struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
struct wm831x *wm831x = dcdc->wm831x;
int mask = 1 << rdev_get_id(rdev);
return wm831x_set_bits(wm831x, WM831X_DCDC_ENABLE, mask, 0);
}
static unsigned int wm831x_dcdc_get_mode(struct regulator_dev *rdev) static unsigned int wm831x_dcdc_get_mode(struct regulator_dev *rdev)
{ {
...@@ -414,9 +379,9 @@ static struct regulator_ops wm831x_buckv_ops = { ...@@ -414,9 +379,9 @@ static struct regulator_ops wm831x_buckv_ops = {
.set_current_limit = wm831x_buckv_set_current_limit, .set_current_limit = wm831x_buckv_set_current_limit,
.get_current_limit = wm831x_buckv_get_current_limit, .get_current_limit = wm831x_buckv_get_current_limit,
.is_enabled = wm831x_dcdc_is_enabled, .is_enabled = regulator_is_enabled_regmap,
.enable = wm831x_dcdc_enable, .enable = regulator_enable_regmap,
.disable = wm831x_dcdc_disable, .disable = regulator_disable_regmap,
.get_status = wm831x_dcdc_get_status, .get_status = wm831x_dcdc_get_status,
.get_mode = wm831x_dcdc_get_mode, .get_mode = wm831x_dcdc_get_mode,
.set_mode = wm831x_dcdc_set_mode, .set_mode = wm831x_dcdc_set_mode,
...@@ -539,6 +504,8 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev) ...@@ -539,6 +504,8 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
dcdc->desc.n_voltages = WM831X_BUCKV_MAX_SELECTOR + 1; dcdc->desc.n_voltages = WM831X_BUCKV_MAX_SELECTOR + 1;
dcdc->desc.ops = &wm831x_buckv_ops; dcdc->desc.ops = &wm831x_buckv_ops;
dcdc->desc.owner = THIS_MODULE; dcdc->desc.owner = THIS_MODULE;
dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
dcdc->desc.enable_mask = 1 << id;
ret = wm831x_reg_read(wm831x, dcdc->base + WM831X_DCDC_ON_CONFIG); ret = wm831x_reg_read(wm831x, dcdc->base + WM831X_DCDC_ON_CONFIG);
if (ret < 0) { if (ret < 0) {
...@@ -560,6 +527,7 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev) ...@@ -560,6 +527,7 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
config.dev = pdev->dev.parent; config.dev = pdev->dev.parent;
config.init_data = pdata->dcdc[id]; config.init_data = pdata->dcdc[id];
config.driver_data = dcdc; config.driver_data = dcdc;
config.regmap = wm831x->regmap;
dcdc->regulator = regulator_register(&dcdc->desc, &config); dcdc->regulator = regulator_register(&dcdc->desc, &config);
if (IS_ERR(dcdc->regulator)) { if (IS_ERR(dcdc->regulator)) {
...@@ -685,9 +653,9 @@ static struct regulator_ops wm831x_buckp_ops = { ...@@ -685,9 +653,9 @@ static struct regulator_ops wm831x_buckp_ops = {
.list_voltage = wm831x_buckp_list_voltage, .list_voltage = wm831x_buckp_list_voltage,
.set_suspend_voltage = wm831x_buckp_set_suspend_voltage, .set_suspend_voltage = wm831x_buckp_set_suspend_voltage,
.is_enabled = wm831x_dcdc_is_enabled, .is_enabled = regulator_is_enabled_regmap,
.enable = wm831x_dcdc_enable, .enable = regulator_enable_regmap,
.disable = wm831x_dcdc_disable, .disable = regulator_disable_regmap,
.get_status = wm831x_dcdc_get_status, .get_status = wm831x_dcdc_get_status,
.get_mode = wm831x_dcdc_get_mode, .get_mode = wm831x_dcdc_get_mode,
.set_mode = wm831x_dcdc_set_mode, .set_mode = wm831x_dcdc_set_mode,
...@@ -741,6 +709,8 @@ static __devinit int wm831x_buckp_probe(struct platform_device *pdev) ...@@ -741,6 +709,8 @@ static __devinit int wm831x_buckp_probe(struct platform_device *pdev)
dcdc->desc.owner = THIS_MODULE; dcdc->desc.owner = THIS_MODULE;
dcdc->desc.vsel_reg = dcdc->base + WM831X_DCDC_ON_CONFIG; dcdc->desc.vsel_reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
dcdc->desc.vsel_mask = WM831X_DC3_ON_VSEL_MASK; dcdc->desc.vsel_mask = WM831X_DC3_ON_VSEL_MASK;
dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
dcdc->desc.enable_mask = 1 << id;
config.dev = pdev->dev.parent; config.dev = pdev->dev.parent;
config.init_data = pdata->dcdc[id]; config.init_data = pdata->dcdc[id];
...@@ -829,9 +799,9 @@ static int wm831x_boostp_get_status(struct regulator_dev *rdev) ...@@ -829,9 +799,9 @@ static int wm831x_boostp_get_status(struct regulator_dev *rdev)
static struct regulator_ops wm831x_boostp_ops = { static struct regulator_ops wm831x_boostp_ops = {
.get_status = wm831x_boostp_get_status, .get_status = wm831x_boostp_get_status,
.is_enabled = wm831x_dcdc_is_enabled, .is_enabled = regulator_is_enabled_regmap,
.enable = wm831x_dcdc_enable, .enable = regulator_enable_regmap,
.disable = wm831x_dcdc_disable, .disable = regulator_disable_regmap,
}; };
static __devinit int wm831x_boostp_probe(struct platform_device *pdev) static __devinit int wm831x_boostp_probe(struct platform_device *pdev)
...@@ -871,10 +841,13 @@ static __devinit int wm831x_boostp_probe(struct platform_device *pdev) ...@@ -871,10 +841,13 @@ static __devinit int wm831x_boostp_probe(struct platform_device *pdev)
dcdc->desc.type = REGULATOR_VOLTAGE; dcdc->desc.type = REGULATOR_VOLTAGE;
dcdc->desc.ops = &wm831x_boostp_ops; dcdc->desc.ops = &wm831x_boostp_ops;
dcdc->desc.owner = THIS_MODULE; dcdc->desc.owner = THIS_MODULE;
dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
dcdc->desc.enable_mask = 1 << id;
config.dev = pdev->dev.parent; config.dev = pdev->dev.parent;
config.init_data = pdata->dcdc[id]; config.init_data = pdata->dcdc[id];
config.driver_data = dcdc; config.driver_data = dcdc;
config.regmap = wm831x->regmap;
dcdc->regulator = regulator_register(&dcdc->desc, &config); dcdc->regulator = regulator_register(&dcdc->desc, &config);
if (IS_ERR(dcdc->regulator)) { if (IS_ERR(dcdc->regulator)) {
...@@ -935,9 +908,9 @@ static struct platform_driver wm831x_boostp_driver = { ...@@ -935,9 +908,9 @@ static struct platform_driver wm831x_boostp_driver = {
#define WM831X_EPE_BASE 6 #define WM831X_EPE_BASE 6
static struct regulator_ops wm831x_epe_ops = { static struct regulator_ops wm831x_epe_ops = {
.is_enabled = wm831x_dcdc_is_enabled, .is_enabled = regulator_is_enabled_regmap,
.enable = wm831x_dcdc_enable, .enable = regulator_enable_regmap,
.disable = wm831x_dcdc_disable, .disable = regulator_disable_regmap,
.get_status = wm831x_dcdc_get_status, .get_status = wm831x_dcdc_get_status,
}; };
...@@ -972,10 +945,13 @@ static __devinit int wm831x_epe_probe(struct platform_device *pdev) ...@@ -972,10 +945,13 @@ static __devinit int wm831x_epe_probe(struct platform_device *pdev)
dcdc->desc.ops = &wm831x_epe_ops; dcdc->desc.ops = &wm831x_epe_ops;
dcdc->desc.type = REGULATOR_VOLTAGE; dcdc->desc.type = REGULATOR_VOLTAGE;
dcdc->desc.owner = THIS_MODULE; dcdc->desc.owner = THIS_MODULE;
dcdc->desc.enable_reg = WM831X_DCDC_ENABLE;
dcdc->desc.enable_mask = 1 << dcdc->desc.id;
config.dev = pdev->dev.parent; config.dev = pdev->dev.parent;
config.init_data = pdata->epe[id]; config.init_data = pdata->epe[id];
config.driver_data = dcdc; config.driver_data = dcdc;
config.regmap = wm831x->regmap;
dcdc->regulator = regulator_register(&dcdc->desc, &config); dcdc->regulator = regulator_register(&dcdc->desc, &config);
if (IS_ERR(dcdc->regulator)) { if (IS_ERR(dcdc->regulator)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment