lkml.org 
[lkml]   [2018]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] regmap: irq: handle HW using separate mask bits for edges
Date
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Some interrupt controllers use separate bits for controlling rising
and falling edge interrupts in the mask register.

Let's reuse the existing type fields in struct regmap_irq to make
regmap_irq_chip available to such HW.

If the type_base and mask_base offsets are the same - assume there
are separate bits for falling and rising edge interrupts and use
the value previously written to the type buffer by the set_type()
callback instead of the entire mask specified for this interrupt
so that we only enable the requested edge interrupts.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/base/regmap/regmap-irq.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 429ca8ed7e51..109ae353c526 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -194,8 +194,24 @@ static void regmap_irq_enable(struct irq_data *data)
struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data);
struct regmap *map = d->map;
const struct regmap_irq *irq_data = irq_to_regmap_irq(d, data->hwirq);
+ unsigned int mask;

- d->mask_buf[irq_data->reg_offset / map->reg_stride] &= ~irq_data->mask;
+ /*
+ * If the type_base and mask_base addresses are the same, then
+ * the underlying hardware uses separate mask bits for rising and
+ * falling edge interrupts, but we want to make them into a single
+ * virtual interrupt with configurable edge.
+ *
+ * Instead of using the regular mask bits for this interrupt, use
+ * the value previously written to the type buffer at the
+ * corresponding offset in regmap_irq_set_type().
+ */
+ if (unlikely(d->chip->type_base == d->chip->mask_base))
+ mask = d->type_buf[irq_data->reg_offset / map->reg_stride];
+ else
+ mask = irq_data->mask;
+
+ d->mask_buf[irq_data->reg_offset / map->reg_stride] &= ~mask;
}

static void regmap_irq_disable(struct irq_data *data)
--
2.19.1
\
 
 \ /
  Last update: 2018-12-04 19:16    [W:0.197 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site