Lines Matching +full:mt6360 +full:- +full:regulator

1 // SPDX-License-Identifier: GPL-2.0-only
13 #include <linux/regulator/driver.h>
14 #include <linux/regulator/machine.h>
16 #include <dt-bindings/regulator/mediatek,mt6360-regulator.h>
223 const struct mt6360_regulator_desc *rdesc = (struct mt6360_regulator_desc *)rdev->desc; in mt6360_regulator_set_mode()
225 int shift = ffs(rdesc->mode_mask) - 1; in mt6360_regulator_set_mode()
240 return -EINVAL; in mt6360_regulator_set_mode()
243 ret = regmap_update_bits(regmap, rdesc->mode_reg, rdesc->mode_mask, val << shift); in mt6360_regulator_set_mode()
245 dev_err(&rdev->dev, "%s: fail (%d)\n", __func__, ret); in mt6360_regulator_set_mode()
254 const struct mt6360_regulator_desc *rdesc = (struct mt6360_regulator_desc *)rdev->desc; in mt6360_regulator_get_mode()
256 int shift = ffs(rdesc->mode_mask) - 1; in mt6360_regulator_get_mode()
260 ret = regmap_read(regmap, rdesc->mode_reg, &val); in mt6360_regulator_get_mode()
264 val &= rdesc->mode_mask; in mt6360_regulator_get_mode()
275 return -EINVAL; in mt6360_regulator_get_mode()
281 const struct mt6360_regulator_desc *rdesc = (struct mt6360_regulator_desc *)rdev->desc; in mt6360_regulator_get_status()
286 ret = regmap_read(regmap, rdesc->state_reg, &val); in mt6360_regulator_get_status()
290 if (val & rdesc->state_mask) in mt6360_regulator_get_status()
331 .regulators_node = of_match_ptr("regulator"), \
382 irq = platform_get_irq_byname(pdev, irq_desc->name); in mt6360_regulator_irq_register()
386 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, irq_desc->handler, 0, in mt6360_regulator_irq_register()
387 irq_desc->name, rdev); in mt6360_regulator_irq_register()
389 dev_err(&pdev->dev, "Fail to request %s irq\n", irq_desc->name); in mt6360_regulator_irq_register()
403 mrd = devm_kzalloc(&pdev->dev, sizeof(*mrd), GFP_KERNEL); in mt6360_regulator_probe()
405 return -ENOMEM; in mt6360_regulator_probe()
407 mrd->dev = &pdev->dev; in mt6360_regulator_probe()
409 mrd->regmap = dev_get_regmap(pdev->dev.parent, NULL); in mt6360_regulator_probe()
410 if (!mrd->regmap) { in mt6360_regulator_probe()
411 dev_err(&pdev->dev, "Failed to get parent regmap\n"); in mt6360_regulator_probe()
412 return -ENODEV; in mt6360_regulator_probe()
415 config.dev = pdev->dev.parent; in mt6360_regulator_probe()
417 config.regmap = mrd->regmap; in mt6360_regulator_probe()
423 rdev = devm_regulator_register(&pdev->dev, &rdesc->desc, &config); in mt6360_regulator_probe()
425 dev_err(&pdev->dev, "Failed to register %d regulator\n", i); in mt6360_regulator_probe()
429 ret = mt6360_regulator_irq_register(pdev, rdev, rdesc->irq_tables, in mt6360_regulator_probe()
430 rdesc->irq_table_size); in mt6360_regulator_probe()
432 dev_err(&pdev->dev, "Failed to register %d regulator irqs\n", i); in mt6360_regulator_probe()
441 { "mt6360-regulator", 0 },
448 .name = "mt6360-regulator",
456 MODULE_DESCRIPTION("MT6360 Regulator Driver");