Skip to content

Commit

Permalink
regmap-irq: Introduce inverted status registers support
Browse files Browse the repository at this point in the history
Some interrupt controllers have inverted status register:
cleared bits is active interrupts and set bits is inactive interrupts,
so add inverted status support to the framework.

Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
  • Loading branch information
fidomax authored and intel-lab-lkp committed May 24, 2021
1 parent dfde31c commit 0592cd0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/base/regmap/regmap-irq.c
Expand Up @@ -531,6 +531,10 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
}
}

if (chip->status_invert)
for (i = 0; i < data->chip->num_regs; i++)
data->status_buf[i] = ~data->status_buf[i];

/*
* Ignore masked IRQs and ack if we need to; we ack early so
* there is no race between handling and acknowleding the
Expand Down Expand Up @@ -800,6 +804,9 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
goto err_alloc;
}

if (chip->status_invert)
data->status_buf[i] = ~data->status_buf[i];

if (d->status_buf[i] && (chip->ack_base || chip->use_ack)) {
reg = sub_irq_reg(d, d->chip->ack_base, i);
if (chip->ack_invert)
Expand Down
2 changes: 2 additions & 0 deletions include/linux/regmap.h
Expand Up @@ -1449,6 +1449,7 @@ struct regmap_irq_sub_irq_map {
* @not_fixed_stride: Used when chip peripherals are not laid out with fixed
* stride. Must be used with sub_reg_offsets containing the
* offsets to each peripheral.
* @status_invert: Inverted status register: cleared bits are active interrupts.
* @runtime_pm: Hold a runtime PM lock on the device when accessing it.
*
* @num_regs: Number of registers in each control bank.
Expand Down Expand Up @@ -1501,6 +1502,7 @@ struct regmap_irq_chip {
bool type_in_mask:1;
bool clear_on_unmask:1;
bool not_fixed_stride:1;
bool status_invert:1;

int num_regs;

Expand Down

0 comments on commit 0592cd0

Please sign in to comment.