aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/wm8994-regulator.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-15 06:25:36 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-16 14:52:29 -0400
commit633b6fcd5a70bacbb770136f2938a8be855bbea8 (patch)
treee1d5213702dbdf42e83fe4cc2a41578e05fc7c1c /drivers/regulator/wm8994-regulator.c
parentac663b472c6c04e3257c60816e01a05c2a02d0d3 (diff)
regulator: wm8994: Use core voltage selector operations
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
Diffstat (limited to 'drivers/regulator/wm8994-regulator.c')
-rw-r--r--drivers/regulator/wm8994-regulator.c59
1 files changed, 9 insertions, 50 deletions
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c
index 0ee81e1b6463..e07972fbf44f 100644
--- a/drivers/regulator/wm8994-regulator.c
+++ b/drivers/regulator/wm8994-regulator.c
@@ -86,29 +86,6 @@ static int wm8994_ldo1_list_voltage(struct regulator_dev *rdev,
86 return (selector * 100000) + 2400000; 86 return (selector * 100000) + 2400000;
87} 87}
88 88
89static int wm8994_ldo1_get_voltage_sel(struct regulator_dev *rdev)
90{
91 struct wm8994_ldo *ldo = rdev_get_drvdata(rdev);
92 int val;
93
94 val = wm8994_reg_read(ldo->wm8994, WM8994_LDO_1);
95 if (val < 0)
96 return val;
97
98 return (val & WM8994_LDO1_VSEL_MASK) >> WM8994_LDO1_VSEL_SHIFT;
99}
100
101static int wm8994_ldo1_set_voltage_sel(struct regulator_dev *rdev,
102 unsigned selector)
103{
104 struct wm8994_ldo *ldo = rdev_get_drvdata(rdev);
105
106 selector <<= WM8994_LDO1_VSEL_SHIFT;
107
108 return wm8994_set_bits(ldo->wm8994, WM8994_LDO_1,
109 WM8994_LDO1_VSEL_MASK, selector);
110}
111
112static struct regulator_ops wm8994_ldo1_ops = { 89static struct regulator_ops wm8994_ldo1_ops = {
113 .enable = wm8994_ldo_enable, 90 .enable = wm8994_ldo_enable,
114 .disable = wm8994_ldo_disable, 91 .disable = wm8994_ldo_disable,
@@ -116,8 +93,8 @@ static struct regulator_ops wm8994_ldo1_ops = {
116 .enable_time = wm8994_ldo_enable_time, 93 .enable_time = wm8994_ldo_enable_time,
117 94
118 .list_voltage = wm8994_ldo1_list_voltage, 95 .list_voltage = wm8994_ldo1_list_voltage,
119 .get_voltage_sel = wm8994_ldo1_get_voltage_sel, 96 .get_voltage_sel = regulator_get_voltage_sel_regmap,
120 .set_voltage_sel = wm8994_ldo1_set_voltage_sel, 97 .set_voltage_sel = regulator_set_voltage_sel_regmap,
121}; 98};
122 99
123static int wm8994_ldo2_list_voltage(struct regulator_dev *rdev, 100static int wm8994_ldo2_list_voltage(struct regulator_dev *rdev,
@@ -146,29 +123,6 @@ static int wm8994_ldo2_list_voltage(struct regulator_dev *rdev,
146 } 123 }
147} 124}
148 125
149static int wm8994_ldo2_get_voltage_sel(struct regulator_dev *rdev)
150{
151 struct wm8994_ldo *ldo = rdev_get_drvdata(rdev);
152 int val;
153
154 val = wm8994_reg_read(ldo->wm8994, WM8994_LDO_2);
155 if (val < 0)
156 return val;
157
158 return (val & WM8994_LDO2_VSEL_MASK) >> WM8994_LDO2_VSEL_SHIFT;
159}
160
161static int wm8994_ldo2_set_voltage_sel(struct regulator_dev *rdev,
162 unsigned selector)
163{
164 struct wm8994_ldo *ldo = rdev_get_drvdata(rdev);
165
166 selector <<= WM8994_LDO2_VSEL_SHIFT;
167
168 return wm8994_set_bits(ldo->wm8994, WM8994_LDO_2,
169 WM8994_LDO2_VSEL_MASK, selector);
170}
171
172static struct regulator_ops wm8994_ldo2_ops = { 126static struct regulator_ops wm8994_ldo2_ops = {
173 .enable = wm8994_ldo_enable, 127 .enable = wm8994_ldo_enable,
174 .disable = wm8994_ldo_disable, 128 .disable = wm8994_ldo_disable,
@@ -176,8 +130,8 @@ static struct regulator_ops wm8994_ldo2_ops = {
176 .enable_time = wm8994_ldo_enable_time, 130 .enable_time = wm8994_ldo_enable_time,
177 131
178 .list_voltage = wm8994_ldo2_list_voltage, 132 .list_voltage = wm8994_ldo2_list_voltage,
179 .get_voltage_sel = wm8994_ldo2_get_voltage_sel, 133 .get_voltage_sel = regulator_get_voltage_sel_regmap,
180 .set_voltage_sel = wm8994_ldo2_set_voltage_sel, 134 .set_voltage_sel = regulator_set_voltage_sel_regmap,
181}; 135};
182 136
183static const struct regulator_desc wm8994_ldo_desc[] = { 137static const struct regulator_desc wm8994_ldo_desc[] = {
@@ -186,6 +140,8 @@ static const struct regulator_desc wm8994_ldo_desc[] = {
186 .id = 1, 140 .id = 1,
187 .type = REGULATOR_VOLTAGE, 141 .type = REGULATOR_VOLTAGE,
188 .n_voltages = WM8994_LDO1_MAX_SELECTOR + 1, 142 .n_voltages = WM8994_LDO1_MAX_SELECTOR + 1,
143 .vsel_reg = WM8994_LDO_1,
144 .vsel_mask = WM8994_LDO1_VSEL_MASK,
189 .ops = &wm8994_ldo1_ops, 145 .ops = &wm8994_ldo1_ops,
190 .owner = THIS_MODULE, 146 .owner = THIS_MODULE,
191 }, 147 },
@@ -194,6 +150,8 @@ static const struct regulator_desc wm8994_ldo_desc[] = {
194 .id = 2, 150 .id = 2,
195 .type = REGULATOR_VOLTAGE, 151 .type = REGULATOR_VOLTAGE,
196 .n_voltages = WM8994_LDO2_MAX_SELECTOR + 1, 152 .n_voltages = WM8994_LDO2_MAX_SELECTOR + 1,
153 .vsel_reg = WM8994_LDO_2,
154 .vsel_mask = WM8994_LDO2_VSEL_MASK,
197 .ops = &wm8994_ldo2_ops, 155 .ops = &wm8994_ldo2_ops,
198 .owner = THIS_MODULE, 156 .owner = THIS_MODULE,
199 }, 157 },
@@ -243,6 +201,7 @@ static __devinit int wm8994_ldo_probe(struct platform_device *pdev)
243 config.dev = &pdev->dev; 201 config.dev = &pdev->dev;
244 config.init_data = pdata->ldo[id].init_data; 202 config.init_data = pdata->ldo[id].init_data;
245 config.driver_data = ldo; 203 config.driver_data = ldo;
204 config.regmap = wm8994->regmap;
246 205
247 ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config); 206 ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config);
248 if (IS_ERR(ldo->regulator)) { 207 if (IS_ERR(ldo->regulator)) {