• Home
  • Raw
  • Download

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

1 // SPDX-License-Identifier: GPL-2.0
3 * PFSM (Pre-configurable Finite State Machine) driver for TI 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
58 return -EINVAL; in tps6594_pfsm_read()
61 if (count > TPS6594_PMIC_MAX_POS - pos) in tps6594_pfsm_read()
62 count = TPS6594_PMIC_MAX_POS - pos; in tps6594_pfsm_read()
65 ret = regmap_read(pfsm->regmap, pos + i, &val); in tps6594_pfsm_read()
70 return -EFAULT; in tps6594_pfsm_read()
88 return -EINVAL; in tps6594_pfsm_write()
91 if (count > TPS6594_PMIC_MAX_POS - pos) in tps6594_pfsm_write()
92 count = TPS6594_PMIC_MAX_POS - pos; in tps6594_pfsm_write()
96 return -EFAULT; in tps6594_pfsm_write()
98 ret = regmap_write(pfsm->regmap, pos + i, val); in tps6594_pfsm_write()
136 int ret = -ENOIOCTLCMD; in tps6594_pfsm_ioctl()
141 ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_RTC_CTRL_2, in tps6594_pfsm_ioctl()
147 ret = regmap_write_bits(pfsm->regmap, TPS6594_REG_FSM_I2C_TRIGGERS, in tps6594_pfsm_ioctl()
152 ret = regmap_set_bits(pfsm->regmap, TPS6594_REG_RTC_CTRL_2, in tps6594_pfsm_ioctl()
158 ret = regmap_write_bits(pfsm->regmap, TPS6594_REG_FSM_I2C_TRIGGERS, in tps6594_pfsm_ioctl()
163 ret = regmap_write_bits(pfsm->regmap, TPS6594_REG_FSM_I2C_TRIGGERS, in tps6594_pfsm_ioctl()
167 /* Modify NSLEEP1-2 bits */ in tps6594_pfsm_ioctl()
168 ret = regmap_set_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS, in tps6594_pfsm_ioctl()
173 return -EFAULT; in tps6594_pfsm_ioctl()
176 ret = tps6594_pfsm_configure_ret_trig(pfsm->regmap, state_opt.gpio_retention, in tps6594_pfsm_ioctl()
181 /* Modify NSLEEP1-2 bits */ in tps6594_pfsm_ioctl()
182 ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS, in tps6594_pfsm_ioctl()
187 ret = regmap_set_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS, in tps6594_pfsm_ioctl()
192 return -EFAULT; in tps6594_pfsm_ioctl()
194 /* Configure wake-up destination */ in tps6594_pfsm_ioctl()
196 ret = regmap_write_bits(pfsm->regmap, TPS6594_REG_RTC_CTRL_2, in tps6594_pfsm_ioctl()
200 ret = regmap_write_bits(pfsm->regmap, TPS6594_REG_RTC_CTRL_2, in tps6594_pfsm_ioctl()
207 ret = tps6594_pfsm_configure_ret_trig(pfsm->regmap, state_opt.gpio_retention, in tps6594_pfsm_ioctl()
212 /* Modify NSLEEP1-2 bits */ in tps6594_pfsm_ioctl()
213 ret = regmap_clear_bits(pfsm->regmap, TPS6594_REG_FSM_NSLEEP_TRIGGERS, in tps6594_pfsm_ioctl()
235 for (i = 0 ; i < pdev->num_resources ; i++) { in tps6594_pfsm_isr()
236 if (irq == platform_get_irq_byname(pdev, pdev->resource[i].name)) { in tps6594_pfsm_isr()
237 dev_err(pdev->dev.parent, "%s event detected\n", pdev->resource[i].name); in tps6594_pfsm_isr()
248 struct tps6594 *tps = dev_get_drvdata(pdev->dev.parent); in tps6594_pfsm_probe()
249 struct device *dev = &pdev->dev; in tps6594_pfsm_probe()
256 return -ENOMEM; in tps6594_pfsm_probe()
258 pfsm->regmap = tps->regmap; in tps6594_pfsm_probe()
260 pfsm->miscdev.minor = MISC_DYNAMIC_MINOR; in tps6594_pfsm_probe()
261 pfsm->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "pfsm-%ld-0x%02x", in tps6594_pfsm_probe()
262 tps->chip_id, tps->reg); in tps6594_pfsm_probe()
263 if (!pfsm->miscdev.name) in tps6594_pfsm_probe()
264 return -ENOMEM; in tps6594_pfsm_probe()
266 pfsm->miscdev.fops = &tps6594_pfsm_fops; in tps6594_pfsm_probe()
267 pfsm->miscdev.parent = dev->parent; in tps6594_pfsm_probe()
269 for (i = 0 ; i < pdev->num_resources ; i++) { in tps6594_pfsm_probe()
270 irq = platform_get_irq_byname(pdev, pdev->resource[i].name); in tps6594_pfsm_probe()
276 pdev->resource[i].name, pdev); in tps6594_pfsm_probe()
283 return misc_register(&pfsm->miscdev); in tps6594_pfsm_probe()
290 misc_deregister(&pfsm->miscdev); in tps6594_pfsm_remove()
295 .name = "tps6594-pfsm",
303 MODULE_ALIAS("platform:tps6594-pfsm");
305 MODULE_DESCRIPTION("TPS6594 Pre-configurable Finite State Machine Driver");