Lines Matching +full:regulator +full:- +full:vd18

1 // SPDX-License-Identifier: GPL-2.0
3 * ROHM BD9571MWV-M and BD9574MWF-M regulator driver
12 #include <linux/mfd/rohm-generic.h>
16 #include <linux/regulator/driver.h>
24 u8 bkup_mode_cnt_keepon; /* from "rohm,ddr-backup-power" */
33 enum bd9571mwv_regulators { VD09, VD18, VD25, VD33, DVFS }; enumerator
57 ret = regmap_read(rdev->regmap, BD9571MWV_AVS_SET_MONI, &val); in bd9571mwv_avs_get_moni_state()
73 return regmap_write_bits(rdev->regmap, BD9571MWV_AVS_VD09_VID(ret), in bd9571mwv_avs_set_voltage_sel_regmap()
74 rdev->desc->vsel_mask, sel); in bd9571mwv_avs_set_voltage_sel_regmap()
86 ret = regmap_read(rdev->regmap, BD9571MWV_AVS_VD09_VID(ret), &val); in bd9571mwv_avs_get_voltage_sel_regmap()
90 val &= rdev->desc->vsel_mask; in bd9571mwv_avs_get_voltage_sel_regmap()
91 val >>= ffs(rdev->desc->vsel_mask) - 1; in bd9571mwv_avs_get_voltage_sel_regmap()
99 return regmap_write_bits(rdev->regmap, BD9571MWV_DVFS_SETVID, in bd9571mwv_reg_set_voltage_sel_regmap()
100 rdev->desc->vsel_mask, sel); in bd9571mwv_reg_set_voltage_sel_regmap()
103 /* Operations permitted on AVS voltage regulator */
129 BD9571MWV_REG("VD18", "vd18", VD18, vid_ops, BD9571MWV_VD18_VID, 0xf,
146 ret = regmap_read(bdreg->regmap, BD9571MWV_BKUP_MODE_CNT, mode); in bd9571mwv_bkup_mode_read()
148 dev_err(regmap_get_device(bdreg->regmap), in bd9571mwv_bkup_mode_read()
161 ret = regmap_write(bdreg->regmap, BD9571MWV_BKUP_MODE_CNT, mode); in bd9571mwv_bkup_mode_write()
163 dev_err(regmap_get_device(bdreg->regmap), in bd9571mwv_bkup_mode_write()
177 return sysfs_emit(buf, "%s\n", bdreg->bkup_mode_enabled ? "on" : "off"); in backup_mode_show()
191 ret = kstrtobool(buf, &bdreg->bkup_mode_enabled); in backup_mode_store()
195 if (!bdreg->rstbmode_level) in backup_mode_store()
200 * switch from a power switch to a wake-up switch, or vice versa in backup_mode_store()
207 if (bdreg->bkup_mode_enabled) in backup_mode_store()
208 mode |= bdreg->bkup_mode_cnt_keepon; in backup_mode_store()
225 if (!bdreg->bkup_mode_enabled) in bd9571mwv_suspend()
233 bdreg->bkup_mode_cnt_saved = mode; in bd9571mwv_suspend()
235 if (!bdreg->rstbmode_pulse) in bd9571mwv_suspend()
240 mode |= bdreg->bkup_mode_cnt_keepon; in bd9571mwv_suspend()
242 if (mode != bdreg->bkup_mode_cnt_saved) in bd9571mwv_suspend()
252 if (!bdreg->bkup_mode_enabled) in bd9571mwv_resume()
256 return bd9571mwv_bkup_mode_write(bdreg, bdreg->bkup_mode_cnt_saved); in bd9571mwv_resume()
265 device_remove_file(&pdev->dev, &dev_attr_backup_mode); in bd9571mwv_regulator_remove()
280 enum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data; in bd9571mwv_regulator_probe()
282 bdreg = devm_kzalloc(&pdev->dev, sizeof(*bdreg), GFP_KERNEL); in bd9571mwv_regulator_probe()
284 return -ENOMEM; in bd9571mwv_regulator_probe()
286 bdreg->regmap = dev_get_regmap(pdev->dev.parent, NULL); in bd9571mwv_regulator_probe()
290 config.dev = &pdev->dev; in bd9571mwv_regulator_probe()
291 config.dev->of_node = pdev->dev.parent->of_node; in bd9571mwv_regulator_probe()
293 config.regmap = bdreg->regmap; in bd9571mwv_regulator_probe()
299 rdev = devm_regulator_register(&pdev->dev, &regulators[i], in bd9571mwv_regulator_probe()
302 dev_err(&pdev->dev, "failed to register %s regulator\n", in bd9571mwv_regulator_probe()
309 of_property_read_u32(config.dev->of_node, "rohm,ddr-backup-power", &val); in bd9571mwv_regulator_probe()
311 dev_err(&pdev->dev, "invalid %s mode %u\n", in bd9571mwv_regulator_probe()
312 "rohm,ddr-backup-power", val); in bd9571mwv_regulator_probe()
313 return -EINVAL; in bd9571mwv_regulator_probe()
315 bdreg->bkup_mode_cnt_keepon = val; in bd9571mwv_regulator_probe()
317 bdreg->rstbmode_level = of_property_read_bool(config.dev->of_node, in bd9571mwv_regulator_probe()
318 "rohm,rstbmode-level"); in bd9571mwv_regulator_probe()
319 bdreg->rstbmode_pulse = of_property_read_bool(config.dev->of_node, in bd9571mwv_regulator_probe()
320 "rohm,rstbmode-pulse"); in bd9571mwv_regulator_probe()
321 if (bdreg->rstbmode_level && bdreg->rstbmode_pulse) { in bd9571mwv_regulator_probe()
322 dev_err(&pdev->dev, "only one rohm,rstbmode-* may be specified"); in bd9571mwv_regulator_probe()
323 return -EINVAL; in bd9571mwv_regulator_probe()
327 if (bdreg->bkup_mode_cnt_keepon) { in bd9571mwv_regulator_probe()
334 bdreg->bkup_mode_enabled = bdreg->rstbmode_pulse; in bd9571mwv_regulator_probe()
336 ret = device_create_file(&pdev->dev, &dev_attr_backup_mode); in bd9571mwv_regulator_probe()
346 { "bd9571mwv-regulator", ROHM_CHIP_TYPE_BD9571 },
347 { "bd9574mwf-regulator", ROHM_CHIP_TYPE_BD9574 },
354 .name = "bd9571mwv-regulator",
365 MODULE_DESCRIPTION("BD9571MWV Regulator driver");