Commit 221a7c7c9c88bf9d3ea4e191b35c7da709ca30b7

Authored by Mark Brown
Committed by Liam Girdwood
1 parent 1897e7423b

regulator: Implement list_voltage for WM835x LDOs and DCDCs

Implement the recently added voltage step listing API for the WM835x
DCDCs and LDOs. DCDCs can use values up to 0x66, LDOs can use the full
range of values in the mask. Both masks are the lower bits of the
register.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>

Showing 1 changed file with 29 additions and 0 deletions Side-by-side Diff

drivers/regulator/wm8350-regulator.c
... ... @@ -24,6 +24,9 @@
24 24 #include <linux/regulator/driver.h>
25 25 #include <linux/regulator/machine.h>
26 26  
  27 +/* Maximum value possible for VSEL */
  28 +#define WM8350_DCDC_MAX_VSEL 0x66
  29 +
27 30 /* Microamps */
28 31 static const int isink_cur[] = {
29 32 4,
... ... @@ -385,6 +388,14 @@
385 388 return wm8350_dcdc_val_to_mvolts(val) * 1000;
386 389 }
387 390  
  391 +static int wm8350_dcdc_list_voltage(struct regulator_dev *rdev,
  392 + unsigned selector)
  393 +{
  394 + if (selector > WM8350_DCDC_MAX_VSEL)
  395 + return -EINVAL;
  396 + return wm8350_dcdc_val_to_mvolts(selector) * 1000;
  397 +}
  398 +
388 399 static int wm8350_dcdc_set_suspend_voltage(struct regulator_dev *rdev, int uV)
389 400 {
390 401 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
... ... @@ -775,6 +786,14 @@
775 786 return wm8350_ldo_val_to_mvolts(val) * 1000;
776 787 }
777 788  
  789 +static int wm8350_ldo_list_voltage(struct regulator_dev *rdev,
  790 + unsigned selector)
  791 +{
  792 + if (selector > WM8350_LDO1_VSEL_MASK)
  793 + return -EINVAL;
  794 + return wm8350_ldo_val_to_mvolts(selector) * 1000;
  795 +}
  796 +
778 797 int wm8350_dcdc_set_slot(struct wm8350 *wm8350, int dcdc, u16 start,
779 798 u16 stop, u16 fault)
780 799 {
... ... @@ -1162,6 +1181,7 @@
1162 1181 static struct regulator_ops wm8350_dcdc_ops = {
1163 1182 .set_voltage = wm8350_dcdc_set_voltage,
1164 1183 .get_voltage = wm8350_dcdc_get_voltage,
  1184 + .list_voltage = wm8350_dcdc_list_voltage,
1165 1185 .enable = wm8350_dcdc_enable,
1166 1186 .disable = wm8350_dcdc_disable,
1167 1187 .get_mode = wm8350_dcdc_get_mode,
... ... @@ -1185,6 +1205,7 @@
1185 1205 static struct regulator_ops wm8350_ldo_ops = {
1186 1206 .set_voltage = wm8350_ldo_set_voltage,
1187 1207 .get_voltage = wm8350_ldo_get_voltage,
  1208 + .list_voltage = wm8350_ldo_list_voltage,
1188 1209 .enable = wm8350_ldo_enable,
1189 1210 .disable = wm8350_ldo_disable,
1190 1211 .is_enabled = wm8350_ldo_is_enabled,
... ... @@ -1209,6 +1230,7 @@
1209 1230 .ops = &wm8350_dcdc_ops,
1210 1231 .irq = WM8350_IRQ_UV_DC1,
1211 1232 .type = REGULATOR_VOLTAGE,
  1233 + .n_voltages = WM8350_DCDC_MAX_VSEL + 1,
1212 1234 .owner = THIS_MODULE,
1213 1235 },
1214 1236 {
... ... @@ -1225,6 +1247,7 @@
1225 1247 .ops = &wm8350_dcdc_ops,
1226 1248 .irq = WM8350_IRQ_UV_DC3,
1227 1249 .type = REGULATOR_VOLTAGE,
  1250 + .n_voltages = WM8350_DCDC_MAX_VSEL + 1,
1228 1251 .owner = THIS_MODULE,
1229 1252 },
1230 1253 {
... ... @@ -1233,6 +1256,7 @@
1233 1256 .ops = &wm8350_dcdc_ops,
1234 1257 .irq = WM8350_IRQ_UV_DC4,
1235 1258 .type = REGULATOR_VOLTAGE,
  1259 + .n_voltages = WM8350_DCDC_MAX_VSEL + 1,
1236 1260 .owner = THIS_MODULE,
1237 1261 },
1238 1262 {
... ... @@ -1249,6 +1273,7 @@
1249 1273 .ops = &wm8350_dcdc_ops,
1250 1274 .irq = WM8350_IRQ_UV_DC6,
1251 1275 .type = REGULATOR_VOLTAGE,
  1276 + .n_voltages = WM8350_DCDC_MAX_VSEL + 1,
1252 1277 .owner = THIS_MODULE,
1253 1278 },
1254 1279 {
... ... @@ -1257,6 +1282,7 @@
1257 1282 .ops = &wm8350_ldo_ops,
1258 1283 .irq = WM8350_IRQ_UV_LDO1,
1259 1284 .type = REGULATOR_VOLTAGE,
  1285 + .n_voltages = WM8350_LDO1_VSEL_MASK + 1,
1260 1286 .owner = THIS_MODULE,
1261 1287 },
1262 1288 {
... ... @@ -1265,6 +1291,7 @@
1265 1291 .ops = &wm8350_ldo_ops,
1266 1292 .irq = WM8350_IRQ_UV_LDO2,
1267 1293 .type = REGULATOR_VOLTAGE,
  1294 + .n_voltages = WM8350_LDO2_VSEL_MASK + 1,
1268 1295 .owner = THIS_MODULE,
1269 1296 },
1270 1297 {
... ... @@ -1273,6 +1300,7 @@
1273 1300 .ops = &wm8350_ldo_ops,
1274 1301 .irq = WM8350_IRQ_UV_LDO3,
1275 1302 .type = REGULATOR_VOLTAGE,
  1303 + .n_voltages = WM8350_LDO3_VSEL_MASK + 1,
1276 1304 .owner = THIS_MODULE,
1277 1305 },
1278 1306 {
... ... @@ -1281,6 +1309,7 @@
1281 1309 .ops = &wm8350_ldo_ops,
1282 1310 .irq = WM8350_IRQ_UV_LDO4,
1283 1311 .type = REGULATOR_VOLTAGE,
  1312 + .n_voltages = WM8350_LDO4_VSEL_MASK + 1,
1284 1313 .owner = THIS_MODULE,
1285 1314 },
1286 1315 {