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

regulator: Implement list_voltage() for WM8400 DCDCs and LDOs

All DCDCs and LDOs are identical.

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
216765d9 5c13941a

+30 -4
+30 -4
drivers/regulator/wm8400-regulator.c
··· 43 43 WM8400_LDO1_ENA, 0); 44 44 } 45 45 46 + static int wm8400_ldo_list_voltage(struct regulator_dev *dev, 47 + unsigned selector) 48 + { 49 + if (selector > WM8400_LDO1_VSEL_MASK) 50 + return -EINVAL; 51 + 52 + if (selector < 15) 53 + return 900000 + (selector * 50000); 54 + else 55 + return 1600000 + ((selector - 14) * 100000); 56 + } 57 + 46 58 static int wm8400_ldo_get_voltage(struct regulator_dev *dev) 47 59 { 48 60 struct wm8400 *wm8400 = rdev_get_drvdata(dev); ··· 63 51 val = wm8400_reg_read(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev)); 64 52 val &= WM8400_LDO1_VSEL_MASK; 65 53 66 - if (val < 15) 67 - return 900000 + (val * 50000); 68 - else 69 - return 1600000 + ((val - 14) * 100000); 54 + return wm8400_ldo_list_voltage(dev, val); 70 55 } 71 56 72 57 static int wm8400_ldo_set_voltage(struct regulator_dev *dev, ··· 101 92 .is_enabled = wm8400_ldo_is_enabled, 102 93 .enable = wm8400_ldo_enable, 103 94 .disable = wm8400_ldo_disable, 95 + .list_voltage = wm8400_ldo_list_voltage, 104 96 .get_voltage = wm8400_ldo_get_voltage, 105 97 .set_voltage = wm8400_ldo_set_voltage, 106 98 }; ··· 132 122 133 123 return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset, 134 124 WM8400_DC1_ENA, 0); 125 + } 126 + 127 + static int wm8400_dcdc_list_voltage(struct regulator_dev *dev, 128 + unsigned selector) 129 + { 130 + if (selector > WM8400_DC1_VSEL_MASK) 131 + return -EINVAL; 132 + 133 + return 850000 + (selector * 25000); 135 134 } 136 135 137 136 static int wm8400_dcdc_get_voltage(struct regulator_dev *dev) ··· 256 237 .is_enabled = wm8400_dcdc_is_enabled, 257 238 .enable = wm8400_dcdc_enable, 258 239 .disable = wm8400_dcdc_disable, 240 + .list_voltage = wm8400_dcdc_list_voltage, 259 241 .get_voltage = wm8400_dcdc_get_voltage, 260 242 .set_voltage = wm8400_dcdc_set_voltage, 261 243 .get_mode = wm8400_dcdc_get_mode, ··· 269 249 .name = "LDO1", 270 250 .id = WM8400_LDO1, 271 251 .ops = &wm8400_ldo_ops, 252 + .n_voltages = WM8400_LDO1_VSEL_MASK + 1, 272 253 .type = REGULATOR_VOLTAGE, 273 254 .owner = THIS_MODULE, 274 255 }, ··· 277 256 .name = "LDO2", 278 257 .id = WM8400_LDO2, 279 258 .ops = &wm8400_ldo_ops, 259 + .n_voltages = WM8400_LDO2_VSEL_MASK + 1, 280 260 .type = REGULATOR_VOLTAGE, 281 261 .owner = THIS_MODULE, 282 262 }, ··· 285 263 .name = "LDO3", 286 264 .id = WM8400_LDO3, 287 265 .ops = &wm8400_ldo_ops, 266 + .n_voltages = WM8400_LDO3_VSEL_MASK + 1, 288 267 .type = REGULATOR_VOLTAGE, 289 268 .owner = THIS_MODULE, 290 269 }, ··· 293 270 .name = "LDO4", 294 271 .id = WM8400_LDO4, 295 272 .ops = &wm8400_ldo_ops, 273 + .n_voltages = WM8400_LDO4_VSEL_MASK + 1, 296 274 .type = REGULATOR_VOLTAGE, 297 275 .owner = THIS_MODULE, 298 276 }, ··· 301 277 .name = "DCDC1", 302 278 .id = WM8400_DCDC1, 303 279 .ops = &wm8400_dcdc_ops, 280 + .n_voltages = WM8400_DC1_VSEL_MASK + 1, 304 281 .type = REGULATOR_VOLTAGE, 305 282 .owner = THIS_MODULE, 306 283 }, ··· 309 284 .name = "DCDC2", 310 285 .id = WM8400_DCDC2, 311 286 .ops = &wm8400_dcdc_ops, 287 + .n_voltages = WM8400_DC2_VSEL_MASK + 1, 312 288 .type = REGULATOR_VOLTAGE, 313 289 .owner = THIS_MODULE, 314 290 },