Lines Matching +full:bd71837 +full:- +full:pmic
1 // SPDX-License-Identifier: GPL-2.0
3 // bd71837-regulator.c ROHM BD71837MWV/BD71847MWV regulator driver
10 #include <linux/mfd/rohm-bd718x7.h>
51 * controlled by software - or by PMIC internal HW state machine. Whether
52 * regulator should be under SW or HW control can be defined from device-tree.
98 * We assume PMIC is in RUN state because SW running and able to query the
100 * them we just return a constant. BD71837 BUCK3 and BUCK4 are exceptions as
103 * Note for next hacker - these PMICs have a register where the HW state can be
104 * read. If assuming RUN appears to be false in your use-case - you can
123 ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val); in bd71837_get_buck34_enable_hwctrl()
142 * might be less - and we could probably use DT to give in voltage_change_done()
153 ret = regmap_clear_bits(rdev->regmap, BD718XX_REG_MVRFLTMASK2, in voltage_change_done()
156 dev_err(&rdev->dev, in voltage_change_done()
157 "Failed to re-enable voltage monitoring (%d)\n", in voltage_change_done()
168 if (rdev->desc->ops->is_enabled(rdev)) { in voltage_change_prepare()
171 now = rdev->desc->ops->get_voltage_sel(rdev); in voltage_change_prepare()
175 now = rdev->desc->ops->list_voltage(rdev, now); in voltage_change_prepare()
179 new = rdev->desc->ops->list_voltage(rdev, sel); in voltage_change_prepare()
185 * disable the power-good detection until voltage has reached in voltage_change_prepare()
191 int ldo_offset = rdev->desc->id - BD718XX_LDO1; in voltage_change_prepare()
194 ret = regmap_read(rdev->regmap, BD718XX_REG_MVRFLTMASK2, in voltage_change_prepare()
197 dev_err(&rdev->dev, in voltage_change_prepare()
204 ret = regmap_set_bits(rdev->regmap, in voltage_change_prepare()
207 /* ...and we also want to re-enable it */ in voltage_change_prepare()
211 dev_err(&rdev->dev, in voltage_change_prepare()
256 if (rdev->desc->ops->is_enabled(rdev)) in bd71837_set_voltage_sel_pickable_restricted()
257 return -EBUSY; in bd71837_set_voltage_sel_pickable_restricted()
263 * BD71837 BUCK1/2/3/4
273 * BD71837 BUCK5
333 * BD71837 BUCK7
392 * LDO5 for BD71837
400 * LDO5 for BD71837
443 * BD71837/47/50 ... (ICs supported by this driver) do not provide in bd718x7_xvp_sanity_check()
447 dev_err(&rdev->dev, in bd718x7_xvp_sanity_check()
449 return -EINVAL; in bd718x7_xvp_sanity_check()
457 return -EINVAL; in bd718x7_xvp_sanity_check()
465 int ldo_offset = rdev->desc->id - BD718XX_LDO1; in bd718x7_set_ldo_uvp()
475 return regmap_clear_bits(rdev->regmap, BD718XX_REG_MVRFLTMASK2, in bd718x7_set_ldo_uvp()
478 return regmap_set_bits(rdev->regmap, BD718XX_REG_MVRFLTMASK2, in bd718x7_set_ldo_uvp()
487 return -EINVAL; in bd718x7_get_buck_prot_reg()
533 ret = bd718x7_get_buck_uvp_info(rdev->desc->id, ®, &bit); in bd718x7_set_buck_uvp()
538 return regmap_clear_bits(rdev->regmap, reg, bit); in bd718x7_set_buck_uvp()
540 return regmap_set_bits(rdev->regmap, reg, bit); in bd718x7_set_buck_uvp()
554 ret = bd718x7_get_buck_ovp_info(rdev->desc->id, ®, &bit); in bd718x7_set_buck_ovp()
559 return regmap_clear_bits(rdev->regmap, reg, bit); in bd718x7_set_buck_ovp()
561 return regmap_set_bits(rdev->regmap, reg, bit); in bd718x7_set_buck_ovp()
610 * OPS for BD71837
645 * BD71837 bucks 3 and 4 support defining their enable/disable state also
661 * OPS for all of the ICs - BD718(37/47/50)
672 * There is a HW quirk in BD71837. The shutdown sequence timings for
674 * At PMIC poweroff the voltage for BUCK6/7 is cut immediately at the
675 * beginning of shut-down sequence. As bucks 6 and 7 are parent
676 * supplies for LDO5 and LDO6 - this causes LDO5/6 voltage
677 * monitoring to errorneously detect under voltage and force PMIC to
705 return rohm_regulator_set_dvs_levels(&data->dvs, np, desc, cfg->regmap); in buck_set_hw_dvs_levels()
1499 if (!of_node_name_eq(np, reg_data[i-1].desc.of_match)) in mark_hw_controlled()
1502 *info |= 1 << (i - 1); in mark_hw_controlled()
1512 * to feedback-pin (over suitable resistors) is getting popular amongst users
1513 * of BD71837. (This allows for example scaling down the buck8 voltages to suit
1517 * - hence I keep the DVS disabled for non DVS bucks by default. I don't want
1523 * |------------|
1524 * | buck 8 |-------+----->Vout
1526 * |------------| |
1529 * +-------+--R2---+
1533 * V FB-pull-up
1537 * Vout_o = Vo - (Vpu - Vo)*R2/R1
1543 * Vpu is the pull-up voltage V FB-pull-up in the picture
1547 * VLDO = 1.6V (used as FB-pull-up)
1562 * one PMIC is controlled from same processor. I don't see such use-case in setup_feedback_loop()
1563 * for BD718x7 now - so we spare some bits. in setup_feedback_loop()
1565 * If this will point out to be a problem - then we can allocate new in setup_feedback_loop()
1570 * that means allocating new array for each PMIC - and currently I see in setup_feedback_loop()
1578 if (!of_node_name_eq(np, desc->of_match)) in setup_feedback_loop()
1582 if (desc->id >= BD718XX_LDO1) in setup_feedback_loop()
1583 return -EINVAL; in setup_feedback_loop()
1585 ret = of_property_read_u32(np, "rohm,feedback-pull-up-r1-ohms", in setup_feedback_loop()
1591 return -EINVAL; in setup_feedback_loop()
1593 ret = of_property_read_u32(np, "rohm,feedback-pull-up-r2-ohms", in setup_feedback_loop()
1598 if (desc->n_linear_ranges && desc->linear_ranges) { in setup_feedback_loop()
1601 new = devm_kzalloc(dev, desc->n_linear_ranges * in setup_feedback_loop()
1605 return -ENOMEM; in setup_feedback_loop()
1607 for (j = 0; j < desc->n_linear_ranges; j++) { in setup_feedback_loop()
1608 int min = desc->linear_ranges[j].min; in setup_feedback_loop()
1609 int step = desc->linear_ranges[j].step; in setup_feedback_loop()
1611 min -= (fb_uv - min)*r2/r1; in setup_feedback_loop()
1619 desc->name, desc->linear_ranges[j].min, in setup_feedback_loop()
1620 desc->linear_ranges[j].step); in setup_feedback_loop()
1624 desc->linear_ranges = new; in setup_feedback_loop()
1626 dev_dbg(dev, "regulator '%s' has FB pull-up configured\n", in setup_feedback_loop()
1627 desc->name); in setup_feedback_loop()
1632 return -ENODEV; in setup_feedback_loop()
1644 struct device_node *nproot __free(device_node) = of_get_child_by_name(dev->of_node, in get_special_regulators()
1648 return -ENODEV; in get_special_regulators()
1651 if (of_property_read_bool(np, "rohm,no-regulator-enable-control")) in get_special_regulators()
1654 ret = of_property_read_u32(np, "rohm,fb-pull-up-microvolt", in get_special_regulators()
1657 if (ret == -EINVAL) in get_special_regulators()
1679 enum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data; in bd718xx_probe()
1682 regmap = dev_get_regmap(pdev->dev.parent, NULL); in bd718xx_probe()
1684 dev_err(&pdev->dev, "No MFD driver data\n"); in bd718xx_probe()
1685 return -EINVAL; in bd718xx_probe()
1702 dev_err(&pdev->dev, "Unsupported chip type\n"); in bd718xx_probe()
1703 return -EINVAL; in bd718xx_probe()
1710 return dev_err_probe(&pdev->dev, err, "Failed to unlock PMIC\n"); in bd718xx_probe()
1712 dev_dbg(&pdev->dev, "Unlocked lock register 0x%x\n", in bd718xx_probe()
1715 use_snvs = of_property_read_bool(pdev->dev.parent->of_node, in bd718xx_probe()
1716 "rohm,reset-snvs-powered"); in bd718xx_probe()
1731 return dev_err_probe(&pdev->dev, err, in bd718xx_probe()
1734 dev_dbg(&pdev->dev, "Changed all resets from SVNS to READY\n"); in bd718xx_probe()
1737 config.dev = pdev->dev.parent; in bd718xx_probe()
1740 * There are cases when we want to leave the enable-control for in bd718xx_probe()
1742 * One special case is when we use PMIC_STBY_REQ line from SoC to PMIC in bd718xx_probe()
1746 * be affected by PMIC state machine - Eg. regulator is likely to stay in bd718xx_probe()
1749 err = get_special_regulators(pdev->dev.parent, reg_data, num_reg_data, in bd718xx_probe()
1762 desc = &r->desc; in bd718xx_probe()
1765 desc->ops = hwops[i]; in bd718xx_probe()
1767 desc->ops = swops[i]; in bd718xx_probe()
1769 rdev = devm_regulator_register(&pdev->dev, desc, &config); in bd718xx_probe()
1771 return dev_err_probe(&pdev->dev, PTR_ERR(rdev), in bd718xx_probe()
1773 desc->name); in bd718xx_probe()
1779 * can now switch the control from PMIC state machine to the in bd718xx_probe()
1782 * At poweroff transition PMIC HW disables EN bit for in bd718xx_probe()
1784 * transition from POWEROFF is done to SNVS - then all power in bd718xx_probe()
1792 !rdev->constraints->always_on || in bd718xx_probe()
1793 !rdev->constraints->boot_on)) { in bd718xx_probe()
1794 err = regmap_update_bits(regmap, r->init.reg, in bd718xx_probe()
1795 r->init.mask, r->init.val); in bd718xx_probe()
1797 return dev_err_probe(&pdev->dev, err, in bd718xx_probe()
1799 desc->name); in bd718xx_probe()
1801 for (j = 0; j < r->additional_init_amnt; j++) { in bd718xx_probe()
1803 r->additional_inits[j].reg, in bd718xx_probe()
1804 r->additional_inits[j].mask, in bd718xx_probe()
1805 r->additional_inits[j].val); in bd718xx_probe()
1807 return dev_err_probe(&pdev->dev, err, in bd718xx_probe()
1809 desc->name); in bd718xx_probe()
1817 { "bd71837-pmic", ROHM_CHIP_TYPE_BD71837 },
1818 { "bd71847-pmic", ROHM_CHIP_TYPE_BD71847 },
1825 .name = "bd718xx-pmic",
1835 MODULE_DESCRIPTION("BD71837/BD71847 voltage regulator driver");
1837 MODULE_ALIAS("platform:bd718xx-pmic");