stmfx
int stmfx_function_enable(struct stmfx *stmfx, u32 func)
ret = regmap_read(stmfx->map, STMFX_REG_SYS_CTRL, &sys_ctrl);
dev_err(stmfx->dev, "ALTGPIO function already enabled\n");
dev_err(stmfx->dev, "TS in use, aGPIO[3:0] unavailable\n");
dev_err(stmfx->dev, "IDD in use, aGPIO[7:4] unavailable\n");
return regmap_update_bits(stmfx->map, STMFX_REG_SYS_CTRL, mask, mask);
int stmfx_function_disable(struct stmfx *stmfx, u32 func)
return regmap_update_bits(stmfx->map, STMFX_REG_SYS_CTRL, mask, 0);
struct stmfx *stmfx = irq_data_get_irq_chip_data(data);
mutex_lock(&stmfx->lock);
struct stmfx *stmfx = irq_data_get_irq_chip_data(data);
regmap_write(stmfx->map, STMFX_REG_IRQ_SRC_EN, stmfx->irq_src);
mutex_unlock(&stmfx->lock);
struct stmfx *stmfx = irq_data_get_irq_chip_data(data);
stmfx->irq_src &= ~BIT(data->hwirq % 8);
struct stmfx *stmfx = irq_data_get_irq_chip_data(data);
stmfx->irq_src |= BIT(data->hwirq % 8);
struct stmfx *stmfx = data;
ret = regmap_read(stmfx->map, STMFX_REG_IRQ_PENDING, &pending);
ret = regmap_write(stmfx->map, STMFX_REG_IRQ_ACK, ack);
handle_nested_irq(irq_find_mapping(stmfx->irq_domain, n));
struct stmfx *stmfx = i2c_get_clientdata(client);
irq_dispose_mapping(irq_find_mapping(stmfx->irq_domain, hwirq));
irq_domain_remove(stmfx->irq_domain);
struct stmfx *stmfx = i2c_get_clientdata(client);
stmfx->irq_domain = irq_domain_create_simple(dev_fwnode(stmfx->dev), STMFX_REG_IRQ_SRC_MAX,
0, &stmfx_irq_ops, stmfx);
if (!stmfx->irq_domain) {
dev_err(stmfx->dev, "Failed to create IRQ domain\n");
if (!of_property_read_bool(stmfx->dev->of_node, "drive-open-drain"))
ret = regmap_write(stmfx->map, STMFX_REG_IRQ_OUT_PIN, irqoutpin);
ret = devm_request_threaded_irq(stmfx->dev, client->irq,
"stmfx", stmfx);
stmfx->irq = client->irq;
static int stmfx_chip_reset(struct stmfx *stmfx)
ret = regmap_write(stmfx->map, STMFX_REG_SYS_CTRL,
struct stmfx *stmfx = i2c_get_clientdata(client);
stmfx->vdd = devm_regulator_get_optional(&client->dev, "vdd");
ret = PTR_ERR_OR_ZERO(stmfx->vdd);
stmfx->vdd = NULL;
if (stmfx->vdd) {
ret = regulator_enable(stmfx->vdd);
ret = regmap_read(stmfx->map, STMFX_REG_CHIP_ID, &id);
ret = regmap_bulk_read(stmfx->map, STMFX_REG_FW_VERSION_MSB,
ret = stmfx_chip_reset(stmfx);
if (stmfx->vdd)
regulator_disable(stmfx->vdd);
struct stmfx *stmfx = i2c_get_clientdata(client);
regmap_write(stmfx->map, STMFX_REG_IRQ_SRC_EN, 0);
regmap_write(stmfx->map, STMFX_REG_SYS_CTRL, 0);
if (stmfx->vdd) {
ret = regulator_disable(stmfx->vdd);
struct stmfx *stmfx;
stmfx = devm_kzalloc(dev, sizeof(*stmfx), GFP_KERNEL);
if (!stmfx)
i2c_set_clientdata(client, stmfx);
stmfx->dev = dev;
stmfx->map = devm_regmap_init_i2c(client, &stmfx_regmap_config);
if (IS_ERR(stmfx->map)) {
ret = PTR_ERR(stmfx->map);
mutex_init(&stmfx->lock);
0, stmfx->irq_domain);
struct stmfx *stmfx = dev_get_drvdata(dev);
ret = regmap_raw_read(stmfx->map, STMFX_REG_SYS_CTRL,
&stmfx->bkp_sysctrl, sizeof(stmfx->bkp_sysctrl));
ret = regmap_raw_read(stmfx->map, STMFX_REG_IRQ_OUT_PIN,
&stmfx->bkp_irqoutpin,
sizeof(stmfx->bkp_irqoutpin));
disable_irq(stmfx->irq);
if (stmfx->vdd)
return regulator_disable(stmfx->vdd);
struct stmfx *stmfx = dev_get_drvdata(dev);
if (stmfx->vdd) {
ret = regulator_enable(stmfx->vdd);
dev_err(stmfx->dev,
ret = stmfx_chip_reset(stmfx);
dev_err(stmfx->dev, "Failed to reset chip: %d\n", ret);
ret = regmap_raw_write(stmfx->map, STMFX_REG_SYS_CTRL,
&stmfx->bkp_sysctrl, sizeof(stmfx->bkp_sysctrl));
ret = regmap_raw_write(stmfx->map, STMFX_REG_IRQ_OUT_PIN,
&stmfx->bkp_irqoutpin,
sizeof(stmfx->bkp_irqoutpin));
ret = regmap_raw_write(stmfx->map, STMFX_REG_IRQ_SRC_EN,
&stmfx->irq_src, sizeof(stmfx->irq_src));
enable_irq(stmfx->irq);
ret = regmap_read(pctl->stmfx->map, reg, &value);
return regmap_write_bits(pctl->stmfx->map, reg + get_reg(offset),
ret = regmap_read(pctl->stmfx->map, reg, &val);
return regmap_write_bits(pctl->stmfx->map, reg, mask, 0);
return regmap_write_bits(pctl->stmfx->map, reg, mask, mask);
ret = regmap_read(pctl->stmfx->map, reg, &pupd);
return regmap_write_bits(pctl->stmfx->map, reg, mask, pupd ? mask : 0);
ret = regmap_read(pctl->stmfx->map, reg, &type);
return regmap_write_bits(pctl->stmfx->map, reg, mask, type ? mask : 0);
regmap_bulk_write(pctl->stmfx->map, STMFX_REG_IRQ_GPI_EVT,
regmap_bulk_write(pctl->stmfx->map, STMFX_REG_IRQ_GPI_TYPE,
regmap_bulk_write(pctl->stmfx->map, STMFX_REG_IRQ_GPI_SRC,
regmap_write_bits(pctl->stmfx->map,
regmap_write_bits(pctl->stmfx->map,
ret = regmap_bulk_read(pctl->stmfx->map, STMFX_REG_IRQ_GPI_PENDING,
regmap_bulk_write(pctl->stmfx->map, STMFX_REG_IRQ_GPI_SRC,
regmap_bulk_write(pctl->stmfx->map, STMFX_REG_IRQ_GPI_SRC,
return stmfx_function_enable(pctl->stmfx, func);
struct stmfx *stmfx = dev_get_drvdata(pdev->dev.parent);
pctl = devm_kzalloc(stmfx->dev, sizeof(*pctl), GFP_KERNEL);
pctl->stmfx = stmfx;
struct stmfx *stmfx = dev_get_drvdata(pdev->dev.parent);
ret = stmfx_function_disable(stmfx,
ret = regmap_bulk_read(pctl->stmfx->map, STMFX_REG_GPIO_STATE,
ret = regmap_bulk_read(pctl->stmfx->map, STMFX_REG_GPIO_DIR,
ret = regmap_bulk_read(pctl->stmfx->map, STMFX_REG_GPIO_TYPE,
ret = regmap_bulk_read(pctl->stmfx->map, STMFX_REG_GPIO_PUPD,
ret = regmap_bulk_write(pctl->stmfx->map, STMFX_REG_GPIO_DIR,
ret = regmap_bulk_write(pctl->stmfx->map, STMFX_REG_GPIO_TYPE,
ret = regmap_bulk_write(pctl->stmfx->map, STMFX_REG_GPIO_PUPD,
ret = regmap_bulk_write(pctl->stmfx->map, STMFX_REG_GPO_SET,
ret = regmap_bulk_write(pctl->stmfx->map, STMFX_REG_IRQ_GPI_EVT,
ret = regmap_bulk_write(pctl->stmfx->map, STMFX_REG_IRQ_GPI_TYPE,
ret = regmap_bulk_write(pctl->stmfx->map, STMFX_REG_IRQ_GPI_SRC,
struct stmfx *stmfx;
int stmfx_function_enable(struct stmfx *stmfx, u32 func);
int stmfx_function_disable(struct stmfx *stmfx, u32 func);