Lines Matching +full:pre +full:- +full:configurable

1 // SPDX-License-Identifier: GPL-2.0
3 * PFSM (Pre-configurable Finite State Machine) driver for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs
5 * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/
35 #define TPS6594_FILE_TO_PFSM(f) container_of((f)->private_data, struct tps6594_pfsm, miscdev)
38 * struct tps6594_pfsm - device private data structure
60 return -EINVAL; in tps6594_pfsm_read()
63 if (count > TPS6594_PMIC_MAX_POS - pos) in tps6594_pfsm_read()
64 count = TPS6594_PMIC_MAX_POS - pos; in tps6594_pfsm_read()
67 ret = regmap_read(pfsm->regmap, pos + i, &val); in tps6594_pfsm_read()
72 return -EFAULT; in tps6594_pfsm_read()
90 return -EINVAL; in tps6594_pfsm_write()
93 if (count > TPS6594_PMIC_MAX_POS - pos) in tps6594_pfsm_write()
94 count = TPS6594_PMIC_MAX_POS - pos; in tps6594_pfsm_write()
98 return -EFAULT; in tps6594_pfsm_write()
100 ret = regmap_write(pfsm->regmap, pos + i, val); in tps6594_pfsm_write()
139 int ret = -ENOIOCTLCMD; in tps6594_pfsm_ioctl()
144 if (pfsm->chip_id != TPS65224) { in tps6594_pfsm_ioctl()
145 ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_RTC_CTRL_2, in tps6594_pfsm_ioctl()
153 ret = regmap_write_bits(pfsm->regmap, TPS6594_REG_FSM_I2C_TRIGGERS, in tps6594_pfsm_ioctl()
158 if (pfsm->chip_id == TPS65224) in tps6594_pfsm_ioctl()
162 ret = regmap_set_bits(pfsm->regmap, TPS6594_REG_RTC_CTRL_2, in tps6594_pfsm_ioctl()
168 ret = regmap_write_bits(pfsm->regmap, TPS6594_REG_FSM_I2C_TRIGGERS, in tps6594_pfsm_ioctl()
173 ret = regmap_write_bits(pfsm->regmap, TPS6594_REG_FSM_I2C_TRIGGERS, in tps6594_pfsm_ioctl()
177 /* Modify NSLEEP1-2 bits */ in tps6594_pfsm_ioctl()
178 ret = regmap_set_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS, in tps6594_pfsm_ioctl()
183 if (pfsm->chip_id == TPS65224) in tps6594_pfsm_ioctl()
187 return -EFAULT; in tps6594_pfsm_ioctl()
190 ret = tps6594_pfsm_configure_ret_trig(pfsm->regmap, state_opt.gpio_retention, in tps6594_pfsm_ioctl()
195 /* Modify NSLEEP1-2 bits */ in tps6594_pfsm_ioctl()
196 ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS, in tps6594_pfsm_ioctl()
201 ret = regmap_set_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS, in tps6594_pfsm_ioctl()
206 return -EFAULT; in tps6594_pfsm_ioctl()
208 /* Configure wake-up destination */ in tps6594_pfsm_ioctl()
209 if (pfsm->chip_id == TPS65224) { in tps6594_pfsm_ioctl()
218 ret = regmap_write_bits(pfsm->regmap, regmap_reg, in tps6594_pfsm_ioctl()
221 ret = regmap_write_bits(pfsm->regmap, regmap_reg, in tps6594_pfsm_ioctl()
227 ret = tps6594_pfsm_configure_ret_trig(pfsm->regmap, state_opt.gpio_retention, in tps6594_pfsm_ioctl()
232 /* Modify NSLEEP1-2 bits */ in tps6594_pfsm_ioctl()
233 ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS, in tps6594_pfsm_ioctl()
234 pfsm->chip_id == TPS65224 ? in tps6594_pfsm_ioctl()
256 for (i = 0 ; i < pdev->num_resources ; i++) { in tps6594_pfsm_isr()
257 if (irq == platform_get_irq_byname(pdev, pdev->resource[i].name)) { in tps6594_pfsm_isr()
258 dev_err(pdev->dev.parent, "%s event detected\n", pdev->resource[i].name); in tps6594_pfsm_isr()
269 struct tps6594 *tps = dev_get_drvdata(pdev->dev.parent); in tps6594_pfsm_probe()
270 struct device *dev = &pdev->dev; in tps6594_pfsm_probe()
277 return -ENOMEM; in tps6594_pfsm_probe()
279 pfsm->regmap = tps->regmap; in tps6594_pfsm_probe()
281 pfsm->miscdev.minor = MISC_DYNAMIC_MINOR; in tps6594_pfsm_probe()
282 pfsm->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "pfsm-%ld-0x%02x", in tps6594_pfsm_probe()
283 tps->chip_id, tps->reg); in tps6594_pfsm_probe()
284 pfsm->miscdev.fops = &tps6594_pfsm_fops; in tps6594_pfsm_probe()
285 pfsm->miscdev.parent = dev->parent; in tps6594_pfsm_probe()
286 pfsm->chip_id = tps->chip_id; in tps6594_pfsm_probe()
288 for (i = 0 ; i < pdev->num_resources ; i++) { in tps6594_pfsm_probe()
289 irq = platform_get_irq_byname(pdev, pdev->resource[i].name); in tps6594_pfsm_probe()
295 pdev->resource[i].name, pdev); in tps6594_pfsm_probe()
302 return misc_register(&pfsm->miscdev); in tps6594_pfsm_probe()
309 misc_deregister(&pfsm->miscdev); in tps6594_pfsm_remove()
314 .name = "tps6594-pfsm",
322 MODULE_ALIAS("platform:tps6594-pfsm");
324 MODULE_DESCRIPTION("TPS6594 Pre-configurable Finite State Machine Driver");