Lines Matching +full:regulator +full:- +full:allow +full:- +full:set +full:- +full:load
1 // SPDX-License-Identifier: GPL-2.0
3 // bd71837-regulator.c ROHM BD71837MWV/BD71847MWV regulator driver
9 #include <linux/mfd/rohm-bd718x7.h>
13 #include <linux/regulator/driver.h>
14 #include <linux/regulator/machine.h>
15 #include <linux/regulator/of_regulator.h>
20 * controlled by software - or by PMIC internal HW state machine. Whether
21 * regulator should be under SW or HW control can be defined from device-tree.
65 dev_dbg(&rdev->dev, "Buck[%d] Set Ramp = %d\n", id + 1, in bd718xx_buck1234_set_ramp_delay()
82 dev_err(&rdev->dev, in bd718xx_buck1234_set_ramp_delay()
84 rdev->desc->name, ramp_delay); in bd718xx_buck1234_set_ramp_delay()
87 return regmap_update_bits(rdev->regmap, BD718XX_REG_BUCK1_CTRL + id, in bd718xx_buck1234_set_ramp_delay()
97 * Note for next hacker - these PMICs have a register where the HW state can be
98 * read. If assuming RUN appears to be false in your use-case - you can
117 ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val); in bd71837_get_buck34_enable_hwctrl()
127 * is changed. Hence we return -EBUSY for these if voltage is changed
131 * enabled. But if voltage is increased the LDO power-good monitoring
139 if (rdev->desc->ops->is_enabled(rdev)) in bd71837_set_voltage_sel_restricted()
140 return -EBUSY; in bd71837_set_voltage_sel_restricted()
152 * Let's allow scheduling as we use I2C anyways. We just need to in voltage_change_done()
153 * guarantee minimum of 1ms sleep - it shouldn't matter if we in voltage_change_done()
160 * when voltage is set. in voltage_change_done()
163 * aware of such use-cases so for the sake of the simplicity in voltage_change_done()
166 ret = regmap_update_bits(rdev->regmap, BD718XX_REG_MVRFLTMASK2, in voltage_change_done()
169 dev_err(&rdev->dev, in voltage_change_done()
170 "Failed to re-enable voltage monitoring (%d)\n", in voltage_change_done()
181 if (rdev->desc->ops->is_enabled(rdev)) { in voltage_change_prepare()
184 now = rdev->desc->ops->get_voltage_sel(rdev); in voltage_change_prepare()
188 now = rdev->desc->ops->list_voltage(rdev, now); in voltage_change_prepare()
192 new = rdev->desc->ops->list_voltage(rdev, sel); in voltage_change_prepare()
198 * disable the power-good detection until voltage has reached in voltage_change_prepare()
200 * it takes is 1000us. I assume that on systems with light load in voltage_change_prepare()
201 * this might be less - and we could probably use DT to give in voltage_change_prepare()
206 * 1ms sleep here (and allow scheduling). If this turns out to in voltage_change_prepare()
211 int ldo_offset = rdev->desc->id - BD718XX_LDO1; in voltage_change_prepare()
214 ret = regmap_update_bits(rdev->regmap, in voltage_change_prepare()
218 dev_err(&rdev->dev, in voltage_change_prepare()
263 if (rdev->desc->ops->is_enabled(rdev)) in bd71837_set_voltage_sel_pickable_restricted()
264 return -EBUSY; in bd71837_set_voltage_sel_pickable_restricted()
343 * bit [2] in CTRL register is used to indicate if regulator should be ON.
355 * OPS for all of the ICs - BD718(37/47/50)
543 * beginning of shut-down sequence. As bucks 6 and 7 are parent
544 * supplies for LDO5 and LDO6 - this causes LDO5/6 voltage
573 return rohm_regulator_set_dvs_levels(&data->dvs, np, desc, cfg->regmap); in buck_set_hw_dvs_levels()
1316 if (!of_node_name_eq(np, reg_data[i-1].desc.of_match)) in mark_hw_controlled()
1319 *info |= 1 << (i - 1); in mark_hw_controlled()
1320 dev_dbg(dev, "regulator %d runlevel controlled\n", i); in mark_hw_controlled()
1323 dev_warn(dev, "Bad regulator node\n"); in mark_hw_controlled()
1331 struct device_node *nproot = dev->of_node; in get_hw_controlled_regulators()
1332 const char *prop = "rohm,no-regulator-enable-control"; in get_hw_controlled_regulators()
1339 return -ENODEV; in get_hw_controlled_regulators()
1358 enum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data; in bd718xx_probe()
1361 mfd = dev_get_drvdata(pdev->dev.parent); in bd718xx_probe()
1363 dev_err(&pdev->dev, "No MFD driver data\n"); in bd718xx_probe()
1364 err = -EINVAL; in bd718xx_probe()
1382 dev_err(&pdev->dev, "Unsupported chip type\n"); in bd718xx_probe()
1383 err = -EINVAL; in bd718xx_probe()
1388 err = regmap_update_bits(mfd->chip.regmap, BD718XX_REG_REGLOCK, in bd718xx_probe()
1391 dev_err(&pdev->dev, "Failed to unlock PMIC (%d)\n", err); in bd718xx_probe()
1394 dev_dbg(&pdev->dev, "Unlocked lock register 0x%x\n", in bd718xx_probe()
1398 use_snvs = of_property_read_bool(pdev->dev.parent->of_node, in bd718xx_probe()
1399 "rohm,reset-snvs-powered"); in bd718xx_probe()
1407 err = regmap_update_bits(mfd->chip.regmap, in bd718xx_probe()
1415 dev_err(&pdev->dev, "Failed to change reset target\n"); in bd718xx_probe()
1418 dev_dbg(&pdev->dev, in bd718xx_probe()
1423 config.dev = pdev->dev.parent; in bd718xx_probe()
1424 config.regmap = mfd->chip.regmap; in bd718xx_probe()
1426 * There are cases when we want to leave the enable-control for in bd718xx_probe()
1429 * in order to set the system to SUSPEND state. in bd718xx_probe()
1431 * If regulator is taken under SW control the regulator state will not in bd718xx_probe()
1432 * be affected by PMIC state machine - Eg. regulator is likely to stay in bd718xx_probe()
1435 get_hw_controlled_regulators(pdev->dev.parent, reg_data, num_reg_data, in bd718xx_probe()
1446 desc = &r->desc; in bd718xx_probe()
1449 desc->ops = hwops[i]; in bd718xx_probe()
1451 desc->ops = swops[i]; in bd718xx_probe()
1453 rdev = devm_regulator_register(&pdev->dev, desc, &config); in bd718xx_probe()
1455 dev_err(&pdev->dev, in bd718xx_probe()
1456 "failed to register %s regulator\n", in bd718xx_probe()
1457 desc->name); in bd718xx_probe()
1463 * Regulator register gets the regulator constraints and in bd718xx_probe()
1471 * transition from POWEROFF is done to SNVS - then all power in bd718xx_probe()
1472 * rails controlled by SW (having SEL bit set) stay disabled in bd718xx_probe()
1479 !rdev->constraints->always_on || in bd718xx_probe()
1480 !rdev->constraints->boot_on)) { in bd718xx_probe()
1481 err = regmap_update_bits(mfd->chip.regmap, r->init.reg, in bd718xx_probe()
1482 r->init.mask, r->init.val); in bd718xx_probe()
1484 dev_err(&pdev->dev, in bd718xx_probe()
1486 desc->name); in bd718xx_probe()
1490 for (j = 0; j < r->additional_init_amnt; j++) { in bd718xx_probe()
1491 err = regmap_update_bits(mfd->chip.regmap, in bd718xx_probe()
1492 r->additional_inits[j].reg, in bd718xx_probe()
1493 r->additional_inits[j].mask, in bd718xx_probe()
1494 r->additional_inits[j].val); in bd718xx_probe()
1496 dev_err(&pdev->dev, in bd718xx_probe()
1498 desc->name); in bd718xx_probe()
1509 { "bd71837-pmic", ROHM_CHIP_TYPE_BD71837 },
1510 { "bd71847-pmic", ROHM_CHIP_TYPE_BD71847 },
1517 .name = "bd718xx-pmic",
1526 MODULE_DESCRIPTION("BD71837/BD71847 voltage regulator driver");
1528 MODULE_ALIAS("platform:bd718xx-pmic");