Lines Matching +full:buck +full:- +full:c
1 // SPDX-License-Identifier: GPL-2.0
3 // Copyright (c) 2014 MediaTek Inc.
14 #include <linux/regulator/mt6397-regulator.h>
16 #include <dt-bindings/regulator/mediatek,mt6397-regulator.h>
24 * @vselctrl_reg: Register for controlling the buck control mode.
25 * @vselctrl_mask: Mask for query buck's voltage control mode.
48 .n_voltages = (max - min)/step + 1, \
172 ret = -EINVAL; in mt6397_regulator_set_mode()
176 dev_dbg(&rdev->dev, "mt6397 buck set_mode %#x, %#x, %#x\n", in mt6397_regulator_set_mode()
177 info->modeset_reg, info->modeset_mask, val); in mt6397_regulator_set_mode()
179 val <<= ffs(info->modeset_mask) - 1; in mt6397_regulator_set_mode()
181 ret = regmap_update_bits(rdev->regmap, info->modeset_reg, in mt6397_regulator_set_mode()
182 info->modeset_mask, val); in mt6397_regulator_set_mode()
185 dev_err(&rdev->dev, in mt6397_regulator_set_mode()
186 "Failed to set mt6397 buck mode: %d\n", ret); in mt6397_regulator_set_mode()
198 ret = regmap_read(rdev->regmap, info->modeset_reg, ®val); in mt6397_regulator_get_mode()
200 dev_err(&rdev->dev, in mt6397_regulator_get_mode()
201 "Failed to get mt6397 buck mode: %d\n", ret); in mt6397_regulator_get_mode()
205 regval &= info->modeset_mask; in mt6397_regulator_get_mode()
206 regval >>= ffs(info->modeset_mask) - 1; in mt6397_regulator_get_mode()
214 return -EINVAL; in mt6397_regulator_get_mode()
224 ret = regmap_read(rdev->regmap, info->desc.enable_reg, ®val); in mt6397_get_status()
226 dev_err(&rdev->dev, "Failed to get enable reg: %d\n", ret); in mt6397_get_status()
230 return (regval & info->qi) ? REGULATOR_STATUS_ON : REGULATOR_STATUS_OFF; in mt6397_get_status()
325 struct mt6397_chip *mt6397 = dev_get_drvdata(pdev->dev.parent); in mt6397_set_buck_vosel_reg()
331 if (regmap_read(mt6397->regmap, in mt6397_set_buck_vosel_reg()
334 dev_err(&pdev->dev, in mt6397_set_buck_vosel_reg()
335 "Failed to read buck ctrl\n"); in mt6397_set_buck_vosel_reg()
336 return -EIO; in mt6397_set_buck_vosel_reg()
351 struct mt6397_chip *mt6397 = dev_get_drvdata(pdev->dev.parent); in mt6397_regulator_probe()
357 /* Query buck controller to select activated voltage register part */ in mt6397_regulator_probe()
359 return -EIO; in mt6397_regulator_probe()
362 if (regmap_read(mt6397->regmap, MT6397_CID, ®_value) < 0) { in mt6397_regulator_probe()
363 dev_err(&pdev->dev, "Failed to read Chip ID\n"); in mt6397_regulator_probe()
364 return -EIO; in mt6397_regulator_probe()
366 dev_info(&pdev->dev, "Chip ID = 0x%x\n", reg_value); in mt6397_regulator_probe()
379 config.dev = &pdev->dev; in mt6397_regulator_probe()
381 config.regmap = mt6397->regmap; in mt6397_regulator_probe()
382 rdev = devm_regulator_register(&pdev->dev, in mt6397_regulator_probe()
385 dev_err(&pdev->dev, "failed to register %s\n", in mt6397_regulator_probe()
395 {"mt6397-regulator", 0},
401 { .compatible = "mediatek,mt6397-regulator", },
408 .name = "mt6397-regulator",