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)
402 return regulator_disable(stmfx->vdd);
411 struct stmfx *stmfx;
414 stmfx = devm_kzalloc(dev, sizeof(*stmfx), GFP_KERNEL);
415 if (!stmfx)
418 i2c_set_clientdata(client, stmfx);
420 stmfx->dev = dev;
422 stmfx->map = devm_regmap_init_i2c(client, &stmfx_regmap_config);
423 if (IS_ERR(stmfx->map)) {
424 ret = PTR_ERR(stmfx->map);
429 mutex_init(&stmfx->lock);
450 0, stmfx->irq_domain);
474 struct stmfx *stmfx = dev_get_drvdata(dev);
477 ret = regmap_raw_read(stmfx->map, STMFX_REG_SYS_CTRL,
478 &stmfx->bkp_sysctrl, sizeof(stmfx->bkp_sysctrl));
482 ret = regmap_raw_read(stmfx->map, STMFX_REG_IRQ_OUT_PIN,
483 &stmfx->bkp_irqoutpin,
484 sizeof(stmfx->bkp_irqoutpin));
488 disable_irq(stmfx->irq);
490 if (stmfx->vdd)
491 return regulator_disable(stmfx->vdd);
498 struct stmfx *stmfx = dev_get_drvdata(dev);
501 if (stmfx->vdd) {
502 ret = regulator_enable(stmfx->vdd);
504 dev_err(stmfx->dev,
511 ret = stmfx_chip_reset(stmfx);
513 dev_err(stmfx->dev, "Failed to reset chip: %d\n", ret);
517 ret = regmap_raw_write(stmfx->map, STMFX_REG_SYS_CTRL,
518 &stmfx->bkp_sysctrl, sizeof(stmfx->bkp_sysctrl));
522 ret = regmap_raw_write(stmfx->map, STMFX_REG_IRQ_OUT_PIN,
523 &stmfx->bkp_irqoutpin,
524 sizeof(stmfx->bkp_irqoutpin));
528 ret = regmap_raw_write(stmfx->map, STMFX_REG_IRQ_SRC_EN,
529 &stmfx->irq_src, sizeof(stmfx->irq_src));
533 enable_irq(stmfx->irq);
542 { .compatible = "st,stmfx-0300", },
549 .name = "stmfx-core",