Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Mark Brown and committed by
Liam Girdwood
221a7c7c 1897e742

+29
+29
drivers/regulator/wm8350-regulator.c
··· 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, ··· 386 383 /* all DCDCs have same mV bits */ 387 384 val = wm8350_reg_read(wm8350, volt_reg) & WM8350_DC1_VSEL_MASK; 388 385 return wm8350_dcdc_val_to_mvolts(val) * 1000; 386 + } 387 + 388 + static int wm8350_dcdc_list_voltage(struct regulator_dev *rdev, 389 + unsigned selector) 390 + { 391 + if (selector > WM8350_DCDC_MAX_VSEL) 392 + return -EINVAL; 393 + return wm8350_dcdc_val_to_mvolts(selector) * 1000; 389 394 } 390 395 391 396 static int wm8350_dcdc_set_suspend_voltage(struct regulator_dev *rdev, int uV) ··· 786 775 return wm8350_ldo_val_to_mvolts(val) * 1000; 787 776 } 788 777 778 + static int wm8350_ldo_list_voltage(struct regulator_dev *rdev, 779 + unsigned selector) 780 + { 781 + if (selector > WM8350_LDO1_VSEL_MASK) 782 + return -EINVAL; 783 + return wm8350_ldo_val_to_mvolts(selector) * 1000; 784 + } 785 + 789 786 int wm8350_dcdc_set_slot(struct wm8350 *wm8350, int dcdc, u16 start, 790 787 u16 stop, u16 fault) 791 788 { ··· 1181 1162 static struct regulator_ops wm8350_dcdc_ops = { 1182 1163 .set_voltage = wm8350_dcdc_set_voltage, 1183 1164 .get_voltage = wm8350_dcdc_get_voltage, 1165 + .list_voltage = wm8350_dcdc_list_voltage, 1184 1166 .enable = wm8350_dcdc_enable, 1185 1167 .disable = wm8350_dcdc_disable, 1186 1168 .get_mode = wm8350_dcdc_get_mode, ··· 1205 1185 static struct regulator_ops wm8350_ldo_ops = { 1206 1186 .set_voltage = wm8350_ldo_set_voltage, 1207 1187 .get_voltage = wm8350_ldo_get_voltage, 1188 + .list_voltage = wm8350_ldo_list_voltage, 1208 1189 .enable = wm8350_ldo_enable, 1209 1190 .disable = wm8350_ldo_disable, 1210 1191 .is_enabled = wm8350_ldo_is_enabled, ··· 1230 1209 .ops = &wm8350_dcdc_ops, 1231 1210 .irq = WM8350_IRQ_UV_DC1, 1232 1211 .type = REGULATOR_VOLTAGE, 1212 + .n_voltages = WM8350_DCDC_MAX_VSEL + 1, 1233 1213 .owner = THIS_MODULE, 1234 1214 }, 1235 1215 { ··· 1247 1225 .ops = &wm8350_dcdc_ops, 1248 1226 .irq = WM8350_IRQ_UV_DC3, 1249 1227 .type = REGULATOR_VOLTAGE, 1228 + .n_voltages = WM8350_DCDC_MAX_VSEL + 1, 1250 1229 .owner = THIS_MODULE, 1251 1230 }, 1252 1231 { ··· 1256 1233 .ops = &wm8350_dcdc_ops, 1257 1234 .irq = WM8350_IRQ_UV_DC4, 1258 1235 .type = REGULATOR_VOLTAGE, 1236 + .n_voltages = WM8350_DCDC_MAX_VSEL + 1, 1259 1237 .owner = THIS_MODULE, 1260 1238 }, 1261 1239 { ··· 1273 1249 .ops = &wm8350_dcdc_ops, 1274 1250 .irq = WM8350_IRQ_UV_DC6, 1275 1251 .type = REGULATOR_VOLTAGE, 1252 + .n_voltages = WM8350_DCDC_MAX_VSEL + 1, 1276 1253 .owner = THIS_MODULE, 1277 1254 }, 1278 1255 { ··· 1282 1257 .ops = &wm8350_ldo_ops, 1283 1258 .irq = WM8350_IRQ_UV_LDO1, 1284 1259 .type = REGULATOR_VOLTAGE, 1260 + .n_voltages = WM8350_LDO1_VSEL_MASK + 1, 1285 1261 .owner = THIS_MODULE, 1286 1262 }, 1287 1263 { ··· 1291 1265 .ops = &wm8350_ldo_ops, 1292 1266 .irq = WM8350_IRQ_UV_LDO2, 1293 1267 .type = REGULATOR_VOLTAGE, 1268 + .n_voltages = WM8350_LDO2_VSEL_MASK + 1, 1294 1269 .owner = THIS_MODULE, 1295 1270 }, 1296 1271 { ··· 1300 1273 .ops = &wm8350_ldo_ops, 1301 1274 .irq = WM8350_IRQ_UV_LDO3, 1302 1275 .type = REGULATOR_VOLTAGE, 1276 + .n_voltages = WM8350_LDO3_VSEL_MASK + 1, 1303 1277 .owner = THIS_MODULE, 1304 1278 }, 1305 1279 { ··· 1309 1281 .ops = &wm8350_ldo_ops, 1310 1282 .irq = WM8350_IRQ_UV_LDO4, 1311 1283 .type = REGULATOR_VOLTAGE, 1284 + .n_voltages = WM8350_LDO4_VSEL_MASK + 1, 1312 1285 .owner = THIS_MODULE, 1313 1286 }, 1314 1287 {