aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/Kconfig2
-rw-r--r--drivers/regulator/anatop-regulator.c31
2 files changed, 22 insertions, 11 deletions
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 4e932cc695e9..2ae1d97fac1e 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -112,7 +112,7 @@ config REGULATOR_DA9052
112 112
113config REGULATOR_ANATOP 113config REGULATOR_ANATOP
114 tristate "Freescale i.MX on-chip ANATOP LDO regulators" 114 tristate "Freescale i.MX on-chip ANATOP LDO regulators"
115 depends on MFD_ANATOP 115 depends on MFD_SYSCON
116 help 116 help
117 Say y here to support Freescale i.MX on-chip ANATOP LDOs 117 Say y here to support Freescale i.MX on-chip ANATOP LDOs
118 regulators. It is recommended that this option be 118 regulators. It is recommended that this option be
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index e9c2085f9dfb..596535dd917a 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -21,19 +21,20 @@
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/mfd/syscon.h>
24#include <linux/err.h> 25#include <linux/err.h>
25#include <linux/io.h> 26#include <linux/io.h>
26#include <linux/platform_device.h> 27#include <linux/platform_device.h>
27#include <linux/of.h> 28#include <linux/of.h>
28#include <linux/of_address.h> 29#include <linux/of_address.h>
29#include <linux/mfd/anatop.h> 30#include <linux/regmap.h>
30#include <linux/regulator/driver.h> 31#include <linux/regulator/driver.h>
31#include <linux/regulator/of_regulator.h> 32#include <linux/regulator/of_regulator.h>
32 33
33struct anatop_regulator { 34struct anatop_regulator {
34 const char *name; 35 const char *name;
35 u32 control_reg; 36 u32 control_reg;
36 struct anatop *mfd; 37 struct regmap *anatop;
37 int vol_bit_shift; 38 int vol_bit_shift;
38 int vol_bit_width; 39 int vol_bit_width;
39 int min_bit_val; 40 int min_bit_val;
@@ -43,7 +44,8 @@ struct anatop_regulator {
43 struct regulator_init_data *initdata; 44 struct regulator_init_data *initdata;
44}; 45};
45 46
46static int anatop_set_voltage_sel(struct regulator_dev *reg, unsigned selector) 47static int anatop_regmap_set_voltage_sel(struct regulator_dev *reg,
48 unsigned selector)
47{ 49{
48 struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); 50 struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
49 u32 val, mask; 51 u32 val, mask;
@@ -56,12 +58,13 @@ static int anatop_set_voltage_sel(struct regulator_dev *reg, unsigned selector)
56 mask = ((1 << anatop_reg->vol_bit_width) - 1) << 58 mask = ((1 << anatop_reg->vol_bit_width) - 1) <<
57 anatop_reg->vol_bit_shift; 59 anatop_reg->vol_bit_shift;
58 val <<= anatop_reg->vol_bit_shift; 60 val <<= anatop_reg->vol_bit_shift;
59 anatop_write_reg(anatop_reg->mfd, anatop_reg->control_reg, val, mask); 61 regmap_update_bits(anatop_reg->anatop, anatop_reg->control_reg,
62 mask, val);
60 63
61 return 0; 64 return 0;
62} 65}
63 66
64static int anatop_get_voltage_sel(struct regulator_dev *reg) 67static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg)
65{ 68{
66 struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); 69 struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
67 u32 val; 70 u32 val;
@@ -69,7 +72,7 @@ static int anatop_get_voltage_sel(struct regulator_dev *reg)
69 if (!anatop_reg->control_reg) 72 if (!anatop_reg->control_reg)
70 return -ENOTSUPP; 73 return -ENOTSUPP;
71 74
72 val = anatop_read_reg(anatop_reg->mfd, anatop_reg->control_reg); 75 regmap_read(anatop_reg->anatop, anatop_reg->control_reg, &val);
73 val = (val & ((1 << anatop_reg->vol_bit_width) - 1)) >> 76 val = (val & ((1 << anatop_reg->vol_bit_width) - 1)) >>
74 anatop_reg->vol_bit_shift; 77 anatop_reg->vol_bit_shift;
75 78
@@ -77,8 +80,8 @@ static int anatop_get_voltage_sel(struct regulator_dev *reg)
77} 80}
78 81
79static struct regulator_ops anatop_rops = { 82static struct regulator_ops anatop_rops = {
80 .set_voltage_sel = anatop_set_voltage_sel, 83 .set_voltage_sel = anatop_regmap_set_voltage_sel,
81 .get_voltage_sel = anatop_get_voltage_sel, 84 .get_voltage_sel = anatop_regmap_get_voltage_sel,
82 .list_voltage = regulator_list_voltage_linear, 85 .list_voltage = regulator_list_voltage_linear,
83 .map_voltage = regulator_map_voltage_linear, 86 .map_voltage = regulator_map_voltage_linear,
84}; 87};
@@ -87,11 +90,11 @@ static int __devinit anatop_regulator_probe(struct platform_device *pdev)
87{ 90{
88 struct device *dev = &pdev->dev; 91 struct device *dev = &pdev->dev;
89 struct device_node *np = dev->of_node; 92 struct device_node *np = dev->of_node;
93 struct device_node *anatop_np;
90 struct regulator_desc *rdesc; 94 struct regulator_desc *rdesc;
91 struct regulator_dev *rdev; 95 struct regulator_dev *rdev;
92 struct anatop_regulator *sreg; 96 struct anatop_regulator *sreg;
93 struct regulator_init_data *initdata; 97 struct regulator_init_data *initdata;
94 struct anatop *anatopmfd = dev_get_drvdata(pdev->dev.parent);
95 struct regulator_config config = { }; 98 struct regulator_config config = { };
96 int ret = 0; 99 int ret = 0;
97 100
@@ -108,7 +111,15 @@ static int __devinit anatop_regulator_probe(struct platform_device *pdev)
108 rdesc->ops = &anatop_rops; 111 rdesc->ops = &anatop_rops;
109 rdesc->type = REGULATOR_VOLTAGE; 112 rdesc->type = REGULATOR_VOLTAGE;
110 rdesc->owner = THIS_MODULE; 113 rdesc->owner = THIS_MODULE;
111 sreg->mfd = anatopmfd; 114
115 anatop_np = of_get_parent(np);
116 if (!anatop_np)
117 return -ENODEV;
118 sreg->anatop = syscon_node_to_regmap(anatop_np);
119 of_node_put(anatop_np);
120 if (IS_ERR(sreg->anatop))
121 return PTR_ERR(sreg->anatop);
122
112 ret = of_property_read_u32(np, "anatop-reg-offset", 123 ret = of_property_read_u32(np, "anatop-reg-offset",
113 &sreg->control_reg); 124 &sreg->control_reg);
114 if (ret) { 125 if (ret) {