Lines Matching +full:primary +full:- +full:pmic
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Motorola CPCAP PMIC regulator driver
5 * Based on cpcap-regulator.c from Motorola Linux kernel tree
6 * Copyright (C) 2009-2011 Motorola, Inc.
20 #include <linux/mfd/motorola-cpcap.h>
27 /* CPCAP_REG_ASSIGN2 bits - Resource Assignment 2 */
38 /* CPCAP_REG_ASSIGN3 bits - Resource Assignment 3 */
56 /* CPCAP_REG_ASSIGN4 bits - Resource Assignment 4 */
80 * primary when the regulator is turned on.
88 * The assign_reg and assign_mask seem to allow toggling between primary
170 if (rdev->desc->enable_val & CPCAP_REG_OFF_MODE_SEC) { in cpcap_regulator_enable()
171 error = regmap_update_bits(rdev->regmap, regulator->assign_reg, in cpcap_regulator_enable()
172 regulator->assign_mask, in cpcap_regulator_enable()
173 regulator->assign_mask); in cpcap_regulator_enable()
190 if (rdev->desc->enable_val & CPCAP_REG_OFF_MODE_SEC) { in cpcap_regulator_disable()
191 error = regmap_update_bits(rdev->regmap, regulator->assign_reg, in cpcap_regulator_disable()
192 regulator->assign_mask, 0); in cpcap_regulator_disable()
198 if (error && (rdev->desc->enable_val & CPCAP_REG_OFF_MODE_SEC)) { in cpcap_regulator_disable()
199 regmap_update_bits(rdev->regmap, regulator->assign_reg, in cpcap_regulator_disable()
200 regulator->assign_mask, in cpcap_regulator_disable()
201 regulator->assign_mask); in cpcap_regulator_disable()
223 regmap_read(rdev->regmap, rdev->desc->enable_reg, &value); in cpcap_regulator_get_mode()
244 return -EINVAL; in cpcap_regulator_set_mode()
247 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, in cpcap_regulator_set_mode()
483 .compatible = "motorola,cpcap-regulator",
486 .compatible = "motorola,mapphone-cpcap-regulator",
490 .compatible = "motorola,xoom-cpcap-regulator",
504 match_data = of_device_get_match_data(&pdev->dev); in cpcap_regulator_probe()
506 dev_err(&pdev->dev, "no configuration data found\n"); in cpcap_regulator_probe()
508 return -ENODEV; in cpcap_regulator_probe()
511 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); in cpcap_regulator_probe()
513 return -ENOMEM; in cpcap_regulator_probe()
515 ddata->reg = dev_get_regmap(pdev->dev.parent, NULL); in cpcap_regulator_probe()
516 if (!ddata->reg) in cpcap_regulator_probe()
517 return -ENODEV; in cpcap_regulator_probe()
519 ddata->dev = &pdev->dev; in cpcap_regulator_probe()
520 ddata->soc = match_data; in cpcap_regulator_probe()
524 config.dev = &pdev->dev; in cpcap_regulator_probe()
525 config.regmap = ddata->reg; in cpcap_regulator_probe()
528 const struct cpcap_regulator *regulator = &ddata->soc[i]; in cpcap_regulator_probe()
531 if (!regulator->rdesc.name) in cpcap_regulator_probe()
534 if (regulator->rdesc.volt_table == unknown_val_tbl) in cpcap_regulator_probe()
538 rdev = devm_regulator_register(&pdev->dev, in cpcap_regulator_probe()
539 ®ulator->rdesc, in cpcap_regulator_probe()
542 dev_err(&pdev->dev, "failed to register regulator %s\n", in cpcap_regulator_probe()
543 regulator->rdesc.name); in cpcap_regulator_probe()
555 .name = "cpcap-regulator",
563 MODULE_ALIAS("platform:cpcap-regulator");