Lines Matching defs:stmfx
13 #include <linux/mfd/stmfx.h>
78 .of_compatible = "st,stmfx-0300-pinctrl",
79 .name = "stmfx-pinctrl",
84 .of_compatible = "st,stmfx-0300-idd",
85 .name = "stmfx-idd",
90 .of_compatible = "st,stmfx-0300-ts",
91 .name = "stmfx-ts",
116 int stmfx_function_enable(struct stmfx *stmfx, u32 func)
122 ret = regmap_read(stmfx->map, STMFX_REG_SYS_CTRL, &sys_ctrl);
134 dev_err(stmfx->dev, "ALTGPIO function already enabled\n");
141 dev_err(stmfx->dev, "TS in use, aGPIO[3:0] unavailable\n");
148 dev_err(stmfx->dev, "IDD in use, aGPIO[7:4] unavailable\n");
154 return regmap_update_bits(stmfx->map, STMFX_REG_SYS_CTRL, mask, mask);
158 int stmfx_function_disable(struct stmfx *stmfx, u32 func)
162 return regmap_update_bits(stmfx->map, STMFX_REG_SYS_CTRL, mask, 0);
168 struct stmfx *stmfx = irq_data_get_irq_chip_data(data);
170 mutex_lock(&stmfx->lock);
175 struct stmfx *stmfx = irq_data_get_irq_chip_data(data);
177 regmap_write(stmfx->map, STMFX_REG_IRQ_SRC_EN, stmfx->irq_src);
179 mutex_unlock(&stmfx->lock);
184 struct stmfx *stmfx = irq_data_get_irq_chip_data(data);
186 stmfx->irq_src &= ~BIT(data->hwirq % 8);
191 struct stmfx *stmfx = irq_data_get_irq_chip_data(data);
193 stmfx->irq_src |= BIT(data->hwirq % 8);
197 .name = "stmfx-core",
206 struct stmfx *stmfx = data;
211 ret = regmap_read(stmfx->map, STMFX_REG_IRQ_PENDING, &pending);
221 ret = regmap_write(stmfx->map, STMFX_REG_IRQ_ACK, ack);
228 handle_nested_irq(irq_find_mapping(stmfx->irq_domain, n));
257 struct stmfx *stmfx = i2c_get_clientdata(client);
261 irq_dispose_mapping(irq_find_mapping(stmfx->irq_domain, hwirq));
263 irq_domain_remove(stmfx->irq_domain);
268 struct stmfx *stmfx = i2c_get_clientdata(client);
272 stmfx->irq_domain = irq_domain_add_simple(stmfx->dev->of_node,
274 &stmfx_irq_ops, stmfx);
275 if (!stmfx->irq_domain) {
276 dev_err(stmfx->dev, "Failed to create IRQ domain\n");
280 if (!of_property_read_bool(stmfx->dev->of_node, "drive-open-drain"))
288 ret = regmap_write(stmfx->map, STMFX_REG_IRQ_OUT_PIN, irqoutpin);
292 ret = devm_request_threaded_irq(stmfx->dev, client->irq,
295 "stmfx", stmfx);
299 stmfx->irq = client->irq;
309 static int stmfx_chip_reset(struct stmfx *stmfx)
313 ret = regmap_write(stmfx->map, STMFX_REG_SYS_CTRL,
325 struct stmfx *stmfx = i2c_get_clientdata(client);
330 stmfx->vdd = devm_regulator_get_optional(&client->dev, "vdd");
331 ret = PTR_ERR_OR_ZERO(stmfx->vdd);
333 stmfx->vdd = NULL;
338 if (stmfx->vdd) {
339 ret = regulator_enable(stmfx->vdd);
346 ret = regmap_read(stmfx->map, STMFX_REG_CHIP_ID, &id);
369 ret = regmap_bulk_read(stmfx->map, STMFX_REG_FW_VERSION_MSB,
379 ret = stmfx_chip_reset(stmfx);
388 if (stmfx->vdd)
389 regulator_disable(stmfx->vdd);
396 struct stmfx *stmfx = i2c_get_clientdata(client);
398 regmap_write(stmfx->map, STMFX_REG_IRQ_SRC_EN, 0);
399 regmap_write(stmfx->map, STMFX_REG_SYS_CTRL, 0);
401 if (stmfx->vdd) {
404 ret = regulator_disable(stmfx->vdd);
415 struct stmfx *stmfx;
418 stmfx = devm_kzalloc(dev, sizeof(*stmfx), GFP_KERNEL);
419 if (!stmfx)
422 i2c_set_clientdata(client, stmfx);
424 stmfx->dev = dev;
426 stmfx->map = devm_regmap_init_i2c(client, &stmfx_regmap_config);
427 if (IS_ERR(stmfx->map)) {
428 ret = PTR_ERR(stmfx->map);
433 mutex_init(&stmfx->lock);
454 0, stmfx->irq_domain);
477 struct stmfx *stmfx = dev_get_drvdata(dev);
480 ret = regmap_raw_read(stmfx->map, STMFX_REG_SYS_CTRL,
481 &stmfx->bkp_sysctrl, sizeof(stmfx->bkp_sysctrl));
485 ret = regmap_raw_read(stmfx->map, STMFX_REG_IRQ_OUT_PIN,
486 &stmfx->bkp_irqoutpin,
487 sizeof(stmfx->bkp_irqoutpin));
491 disable_irq(stmfx->irq);
493 if (stmfx->vdd)
494 return regulator_disable(stmfx->vdd);
501 struct stmfx *stmfx = dev_get_drvdata(dev);
504 if (stmfx->vdd) {
505 ret = regulator_enable(stmfx->vdd);
507 dev_err(stmfx->dev,
514 ret = stmfx_chip_reset(stmfx);
516 dev_err(stmfx->dev, "Failed to reset chip: %d\n", ret);
520 ret = regmap_raw_write(stmfx->map, STMFX_REG_SYS_CTRL,
521 &stmfx->bkp_sysctrl, sizeof(stmfx->bkp_sysctrl));
525 ret = regmap_raw_write(stmfx->map, STMFX_REG_IRQ_OUT_PIN,
526 &stmfx->bkp_irqoutpin,
527 sizeof(stmfx->bkp_irqoutpin));
531 ret = regmap_raw_write(stmfx->map, STMFX_REG_IRQ_SRC_EN,
532 &stmfx->irq_src, sizeof(stmfx->irq_src));
536 enable_irq(stmfx->irq);
544 { .compatible = "st,stmfx-0300", },
551 .name = "stmfx-core",