regmap: irq: Add support to clear ack registers

For particular codec HWs have requirement to toggle interrupt clear
register twice 0->1->0. To accommodate it, need to add one more field
(clear_ack) in the regmap_irq struct and update regmap-irq driver to
support it.

Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
Link: https://lore.kernel.org/r/1601907440-13373-1-git-send-email-lkasam@codeaurora.org
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Laxminath Kasam 2020-10-05 19:47:19 +05:30 committed by Mark Brown
parent d05199af72
commit 3a6f0fb7b8
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
2 changed files with 34 additions and 1 deletions

View File

@ -168,6 +168,14 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
ret = regmap_write(map, reg, ~d->mask_buf[i]); ret = regmap_write(map, reg, ~d->mask_buf[i]);
else else
ret = regmap_write(map, reg, d->mask_buf[i]); ret = regmap_write(map, reg, d->mask_buf[i]);
if (d->chip->clear_ack) {
if (d->chip->ack_invert && !ret)
ret = regmap_write(map, reg,
d->mask_buf[i]);
else if (!ret)
ret = regmap_write(map, reg,
~d->mask_buf[i]);
}
if (ret != 0) if (ret != 0)
dev_err(d->map->dev, "Failed to ack 0x%x: %d\n", dev_err(d->map->dev, "Failed to ack 0x%x: %d\n",
reg, ret); reg, ret);
@ -493,7 +501,20 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
if (data->status_buf[i] && (chip->ack_base || chip->use_ack)) { if (data->status_buf[i] && (chip->ack_base || chip->use_ack)) {
reg = chip->ack_base + reg = chip->ack_base +
(i * map->reg_stride * data->irq_reg_stride); (i * map->reg_stride * data->irq_reg_stride);
ret = regmap_write(map, reg, data->status_buf[i]); if (chip->ack_invert)
ret = regmap_write(map, reg,
~data->status_buf[i]);
else
ret = regmap_write(map, reg,
data->status_buf[i]);
if (chip->clear_ack) {
if (chip->ack_invert && !ret)
ret = regmap_write(map, reg,
data->status_buf[i]);
else if (!ret)
ret = regmap_write(map, reg,
~data->status_buf[i]);
}
if (ret != 0) if (ret != 0)
dev_err(map->dev, "Failed to ack 0x%x: %d\n", dev_err(map->dev, "Failed to ack 0x%x: %d\n",
reg, ret); reg, ret);
@ -722,6 +743,16 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
else else
ret = regmap_write(map, reg, ret = regmap_write(map, reg,
d->status_buf[i] & d->mask_buf[i]); d->status_buf[i] & d->mask_buf[i]);
if (chip->clear_ack) {
if (chip->ack_invert && !ret)
ret = regmap_write(map, reg,
(d->status_buf[i] &
d->mask_buf[i]));
else if (!ret)
ret = regmap_write(map, reg,
~(d->status_buf[i] &
d->mask_buf[i]));
}
if (ret != 0) { if (ret != 0) {
dev_err(map->dev, "Failed to ack 0x%x: %d\n", dev_err(map->dev, "Failed to ack 0x%x: %d\n",
reg, ret); reg, ret);

View File

@ -1355,6 +1355,7 @@ struct regmap_irq_sub_irq_map {
* @mask_invert: Inverted mask register: cleared bits are masked out. * @mask_invert: Inverted mask register: cleared bits are masked out.
* @use_ack: Use @ack register even if it is zero. * @use_ack: Use @ack register even if it is zero.
* @ack_invert: Inverted ack register: cleared bits for ack. * @ack_invert: Inverted ack register: cleared bits for ack.
* @clear_ack: Use this to set 1 and 0 or vice-versa to clear interrupts.
* @wake_invert: Inverted wake register: cleared bits are wake enabled. * @wake_invert: Inverted wake register: cleared bits are wake enabled.
* @type_invert: Invert the type flags. * @type_invert: Invert the type flags.
* @type_in_mask: Use the mask registers for controlling irq type. For * @type_in_mask: Use the mask registers for controlling irq type. For
@ -1403,6 +1404,7 @@ struct regmap_irq_chip {
bool mask_invert:1; bool mask_invert:1;
bool use_ack:1; bool use_ack:1;
bool ack_invert:1; bool ack_invert:1;
bool clear_ack:1;
bool wake_invert:1; bool wake_invert:1;
bool runtime_pm:1; bool runtime_pm:1;
bool type_invert:1; bool type_invert:1;