Lines Matching +full:mt6397 +full:- +full:regulator

1 // SPDX-License-Identifier: GPL-2.0
8 #include <linux/mfd/mt6397/core.h>
12 #include <linux/regulator/driver.h>
13 #include <linux/regulator/machine.h>
14 #include <linux/regulator/mt6359-regulator.h>
15 #include <linux/regulator/of_regulator.h>
25 * @desc: standard fields of regulator description.
56 .n_voltages = ((max) - (min)) / (step) + 1, \
84 .n_voltages = ((max) - (min)) / (step) + 1, \
256 ret = regmap_read(rdev->regmap, info->status_reg, &regval); in mt6359_get_status()
258 dev_err(&rdev->dev, "Failed to get enable reg: %d\n", ret); in mt6359_get_status()
262 if (regval & info->qi) in mt6359_get_status()
273 ret = regmap_read(rdev->regmap, info->modeset_reg, &regval); in mt6359_regulator_get_mode()
275 dev_err(&rdev->dev, in mt6359_regulator_get_mode()
280 regval &= info->modeset_mask; in mt6359_regulator_get_mode()
281 regval >>= ffs(info->modeset_mask) - 1; in mt6359_regulator_get_mode()
286 ret = regmap_read(rdev->regmap, info->lp_mode_reg, &regval); in mt6359_regulator_get_mode()
288 dev_err(&rdev->dev, in mt6359_regulator_get_mode()
293 if (regval & info->lp_mode_mask) in mt6359_regulator_get_mode()
310 val <<= ffs(info->modeset_mask) - 1; in mt6359_regulator_set_mode()
311 ret = regmap_update_bits(rdev->regmap, in mt6359_regulator_set_mode()
312 info->modeset_reg, in mt6359_regulator_set_mode()
313 info->modeset_mask, in mt6359_regulator_set_mode()
319 val <<= ffs(info->modeset_mask) - 1; in mt6359_regulator_set_mode()
320 ret = regmap_update_bits(rdev->regmap, in mt6359_regulator_set_mode()
321 info->modeset_reg, in mt6359_regulator_set_mode()
322 info->modeset_mask, in mt6359_regulator_set_mode()
326 val <<= ffs(info->lp_mode_mask) - 1; in mt6359_regulator_set_mode()
327 ret = regmap_update_bits(rdev->regmap, in mt6359_regulator_set_mode()
328 info->lp_mode_reg, in mt6359_regulator_set_mode()
329 info->lp_mode_mask, in mt6359_regulator_set_mode()
336 val <<= ffs(info->lp_mode_mask) - 1; in mt6359_regulator_set_mode()
337 ret = regmap_update_bits(rdev->regmap, in mt6359_regulator_set_mode()
338 info->lp_mode_reg, in mt6359_regulator_set_mode()
339 info->lp_mode_mask, in mt6359_regulator_set_mode()
343 return -EINVAL; in mt6359_regulator_set_mode()
347 dev_err(&rdev->dev, in mt6359_regulator_set_mode()
361 sel <<= ffs(info->desc.vsel_mask) - 1; in mt6359p_vemc_set_voltage_sel()
362 ret = regmap_write(rdev->regmap, MT6359P_TMA_KEY_ADDR, TMA_KEY); in mt6359p_vemc_set_voltage_sel()
366 ret = regmap_read(rdev->regmap, MT6359P_VM_MODE_ADDR, &val); in mt6359p_vemc_set_voltage_sel()
373 ret = regmap_update_bits(rdev->regmap, in mt6359p_vemc_set_voltage_sel()
374 info->desc.vsel_reg, in mt6359p_vemc_set_voltage_sel()
375 info->desc.vsel_mask, sel); in mt6359p_vemc_set_voltage_sel()
379 ret = regmap_update_bits(rdev->regmap, in mt6359p_vemc_set_voltage_sel()
380 info->desc.vsel_reg + 0x2, in mt6359p_vemc_set_voltage_sel()
381 info->desc.vsel_mask, sel); in mt6359p_vemc_set_voltage_sel()
384 return -EINVAL; in mt6359p_vemc_set_voltage_sel()
390 ret = regmap_write(rdev->regmap, MT6359P_TMA_KEY_ADDR, 0); in mt6359p_vemc_set_voltage_sel()
400 ret = regmap_read(rdev->regmap, MT6359P_VM_MODE_ADDR, &val); in mt6359p_vemc_get_voltage_sel()
406 ret = regmap_read(rdev->regmap, in mt6359p_vemc_get_voltage_sel()
407 info->desc.vsel_reg, &val); in mt6359p_vemc_get_voltage_sel()
411 ret = regmap_read(rdev->regmap, in mt6359p_vemc_get_voltage_sel()
412 info->desc.vsel_reg + 0x2, &val); in mt6359p_vemc_get_voltage_sel()
415 return -EINVAL; in mt6359p_vemc_get_voltage_sel()
420 val &= info->desc.vsel_mask; in mt6359p_vemc_get_voltage_sel()
421 val >>= ffs(info->desc.vsel_mask) - 1; in mt6359p_vemc_get_voltage_sel()
950 struct mt6397_chip *mt6397 = dev_get_drvdata(pdev->dev.parent); in mt6359_regulator_probe() local
956 ret = regmap_read(mt6397->regmap, MT6359P_HWCID, &hw_ver); in mt6359_regulator_probe()
965 config.dev = mt6397->dev; in mt6359_regulator_probe()
966 config.regmap = mt6397->regmap; in mt6359_regulator_probe()
969 rdev = devm_regulator_register(&pdev->dev, &mt6359_info->desc, &config); in mt6359_regulator_probe()
971 dev_err(&pdev->dev, "failed to register %s\n", mt6359_info->desc.name); in mt6359_regulator_probe()
980 {"mt6359-regulator", 0},
987 .name = "mt6359-regulator",
997 MODULE_DESCRIPTION("Regulator Driver for MediaTek MT6359 PMIC");