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

regulator: max77686: Convert to use regulator_set_ramp_delay_regmap

Use regulator_set_ramp_delay_regmap instead of open-coded.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Link: https://lore.kernel.org/r/20210605013424.1298773-1-axel.lin@ingics.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Axel Lin and committed by
Mark Brown
3c37d899 4388daa8

+9 -33
+9 -33
drivers/regulator/max77686-regulator.c
··· 67 67 #define MAX77686_REGULATORS MAX77686_REG_MAX 68 68 #define MAX77686_LDOS 26 69 69 70 - enum max77686_ramp_rate { 71 - RAMP_RATE_13P75MV, 72 - RAMP_RATE_27P5MV, 73 - RAMP_RATE_55MV, 74 - RAMP_RATE_NO_CTRL, /* 100mV/us */ 75 - }; 76 - 77 70 struct max77686_data { 78 71 struct device *dev; 79 72 DECLARE_BITMAP(gpio_enabled, MAX77686_REGULATORS); ··· 213 220 max77686->opmode[id] << shift); 214 221 } 215 222 216 - static int max77686_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) 217 - { 218 - unsigned int ramp_value = RAMP_RATE_NO_CTRL; 219 - 220 - switch (ramp_delay) { 221 - case 1 ... 13750: 222 - ramp_value = RAMP_RATE_13P75MV; 223 - break; 224 - case 13751 ... 27500: 225 - ramp_value = RAMP_RATE_27P5MV; 226 - break; 227 - case 27501 ... 55000: 228 - ramp_value = RAMP_RATE_55MV; 229 - break; 230 - case 55001 ... 100000: 231 - break; 232 - default: 233 - pr_warn("%s: ramp_delay: %d not supported, setting 100000\n", 234 - rdev->desc->name, ramp_delay); 235 - } 236 - 237 - return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, 238 - MAX77686_RAMP_RATE_MASK, ramp_value << 6); 239 - } 240 - 241 223 static int max77686_of_parse_cb(struct device_node *np, 242 224 const struct regulator_desc *desc, 243 225 struct regulator_config *config) ··· 251 283 252 284 return 0; 253 285 } 286 + 287 + static const unsigned int max77686_buck_dvs_ramp_table[] = { 288 + 13750, 27500, 55000, 100000 289 + }; 254 290 255 291 static const struct regulator_ops max77686_ops = { 256 292 .list_voltage = regulator_list_voltage_linear, ··· 302 330 .get_voltage_sel = regulator_get_voltage_sel_regmap, 303 331 .set_voltage_sel = regulator_set_voltage_sel_regmap, 304 332 .set_voltage_time_sel = regulator_set_voltage_time_sel, 305 - .set_ramp_delay = max77686_set_ramp_delay, 333 + .set_ramp_delay = regulator_set_ramp_delay_regmap, 306 334 .set_suspend_disable = max77686_set_suspend_disable, 307 335 }; 308 336 ··· 434 462 .enable_reg = MAX77686_REG_BUCK2CTRL1 + (num - 2) * 10, \ 435 463 .enable_mask = MAX77686_OPMODE_MASK \ 436 464 << MAX77686_OPMODE_BUCK234_SHIFT, \ 465 + .ramp_reg = MAX77686_REG_BUCK2CTRL1 + (num - 2) * 10, \ 466 + .ramp_mask = MAX77686_RAMP_RATE_MASK, \ 467 + .ramp_delay_table = max77686_buck_dvs_ramp_table, \ 468 + .n_ramp_values = ARRAY_SIZE(max77686_buck_dvs_ramp_table), \ 437 469 } 438 470 439 471 static const struct regulator_desc regulators[] = {