Lines Matching +full:mt6315 +full:- +full:regulator
1 // SPDX-License-Identifier: GPL-2.0
8 #include <linux/regulator/driver.h>
9 #include <linux/regulator/machine.h>
10 #include <linux/regulator/mt6315-regulator.h>
11 #include <linux/regulator/of_regulator.h>
83 info = container_of(rdev->desc, struct mt6315_regulator_info, desc); in mt6315_regulator_get_mode()
84 modeset_mask = init->modeset_mask[rdev_get_id(rdev)]; in mt6315_regulator_get_mode()
85 ret = regmap_read(rdev->regmap, MT6315_BUCK_TOP_4PHASE_ANA_CON42, ®val); in mt6315_regulator_get_mode()
87 dev_err(&rdev->dev, "Failed to get mode: %d\n", ret); in mt6315_regulator_get_mode()
94 ret = regmap_read(rdev->regmap, MT6315_BUCK_TOP_CON1, ®val); in mt6315_regulator_get_mode()
96 dev_err(&rdev->dev, "Failed to get lp mode: %d\n", ret); in mt6315_regulator_get_mode()
100 if (regval & info->lp_mode_mask) in mt6315_regulator_get_mode()
114 info = container_of(rdev->desc, struct mt6315_regulator_info, desc); in mt6315_regulator_set_mode()
115 modeset_mask = init->modeset_mask[rdev_get_id(rdev)]; in mt6315_regulator_set_mode()
119 ret = regmap_update_bits(rdev->regmap, in mt6315_regulator_set_mode()
126 ret = regmap_update_bits(rdev->regmap, in mt6315_regulator_set_mode()
131 ret = regmap_update_bits(rdev->regmap, in mt6315_regulator_set_mode()
133 info->lp_mode_mask, in mt6315_regulator_set_mode()
137 ret = -EINVAL; in mt6315_regulator_set_mode()
142 val <<= info->lp_mode_shift; in mt6315_regulator_set_mode()
143 ret = regmap_update_bits(rdev->regmap, in mt6315_regulator_set_mode()
145 info->lp_mode_mask, in mt6315_regulator_set_mode()
149 ret = -EINVAL; in mt6315_regulator_set_mode()
150 dev_err(&rdev->dev, "Unsupported mode: %d\n", mode); in mt6315_regulator_set_mode()
155 dev_err(&rdev->dev, "Failed to set mode: %d\n", ret); in mt6315_regulator_set_mode()
168 info = container_of(rdev->desc, struct mt6315_regulator_info, desc); in mt6315_get_status()
169 ret = regmap_read(rdev->regmap, info->status_reg, ®val); in mt6315_get_status()
171 dev_err(&rdev->dev, "Failed to get enable reg: %d\n", ret); in mt6315_get_status()
208 .compatible = "mediatek,mt6315-regulator",
217 struct device *dev = &pdev->dev; in mt6315_regulator_probe()
231 return -ENOMEM; in mt6315_regulator_probe()
235 return -ENOMEM; in mt6315_regulator_probe()
237 switch (pdev->usid) { in mt6315_regulator_probe()
239 init_data->modeset_mask[MT6315_VBUCK1] = BIT(MT6315_VBUCK1) | BIT(MT6315_VBUCK2) | in mt6315_regulator_probe()
244 init_data->modeset_mask[MT6315_VBUCK1] = BIT(MT6315_VBUCK1) | BIT(MT6315_VBUCK2); in mt6315_regulator_probe()
247 init_data->modeset_mask[MT6315_VBUCK1] = BIT(MT6315_VBUCK1); in mt6315_regulator_probe()
251 init_data->modeset_mask[i] = BIT(i); in mt6315_regulator_probe()
253 chip->dev = dev; in mt6315_regulator_probe()
254 chip->regmap = regmap; in mt6315_regulator_probe()
274 struct mt6315_chip *chip = dev_get_drvdata(&pdev->dev); in mt6315_regulator_shutdown()
277 ret |= regmap_write(chip->regmap, MT6315_TOP_TMA_KEY_H, PROTECTION_KEY_H); in mt6315_regulator_shutdown()
278 ret |= regmap_write(chip->regmap, MT6315_TOP_TMA_KEY, PROTECTION_KEY); in mt6315_regulator_shutdown()
279 ret |= regmap_update_bits(chip->regmap, MT6315_TOP2_ELR7, 1, 1); in mt6315_regulator_shutdown()
280 ret |= regmap_write(chip->regmap, MT6315_TOP_TMA_KEY, 0); in mt6315_regulator_shutdown()
281 ret |= regmap_write(chip->regmap, MT6315_TOP_TMA_KEY_H, 0); in mt6315_regulator_shutdown()
283 dev_err(&pdev->dev, "[%#x] Failed to enable power off sequence. %d\n", in mt6315_regulator_shutdown()
284 pdev->usid, ret); in mt6315_regulator_shutdown()
289 .name = "mt6315-regulator",
299 MODULE_AUTHOR("Hsin-Hsiung Wang <hsin-hsiung.wang@mediatek.com>");
300 MODULE_DESCRIPTION("Regulator Driver for MediaTek MT6315 PMIC");