Skip to content

Commit 1a6ebcc

Browse files
bijudasKAGA-KOKO
authored andcommitted
irqchip/renesas-rzv2h: Add field_width to struct rzv2h_hw_info
On RZ/G3E the field width for TSSR register for a TINT is 16 compared to 8 on the RZ/V2H. Add field_width to struct rzv2h_hw_info and replace the macros ICU_TSSR_K and ICU_TSSR_TSSEL_N by a runtime evaluation: (32 / field_width) provides the number of tints in the TSSR register. Signed-off-by: Biju Das <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent eb23d23 commit 1a6ebcc

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

drivers/irqchip/irq-renesas-rzv2h.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@
6464
#define ICU_TINT_LEVEL_HIGH 2
6565
#define ICU_TINT_LEVEL_LOW 3
6666

67-
#define ICU_TSSR_K(tint_nr) ((tint_nr) / 4)
68-
#define ICU_TSSR_TSSEL_N(tint_nr) ((tint_nr) % 4)
6967
#define ICU_TSSR_TSSEL_PREP(tssel, n) ((tssel) << ((n) * 8))
7068
#define ICU_TSSR_TSSEL_MASK(n) ICU_TSSR_TSSEL_PREP(0x7F, n)
7169
#define ICU_TSSR_TIEN(n) (BIT(7) << ((n) * 8))
@@ -84,10 +82,12 @@
8482
* struct rzv2h_hw_info - Interrupt Control Unit controller hardware info structure.
8583
* @t_offs: TINT offset
8684
* @max_tssel: TSSEL max value
85+
* @field_width: TSSR field width
8786
*/
8887
struct rzv2h_hw_info {
8988
u16 t_offs;
9089
u8 max_tssel;
90+
u8 field_width;
9191
};
9292

9393
/**
@@ -140,13 +140,15 @@ static void rzv2h_tint_irq_endisable(struct irq_data *d, bool enable)
140140
struct rzv2h_icu_priv *priv = irq_data_to_priv(d);
141141
unsigned int hw_irq = irqd_to_hwirq(d);
142142
u32 tint_nr, tssel_n, k, tssr;
143+
u8 nr_tint;
143144

144145
if (hw_irq < ICU_TINT_START)
145146
return;
146147

147148
tint_nr = hw_irq - ICU_TINT_START;
148-
k = ICU_TSSR_K(tint_nr);
149-
tssel_n = ICU_TSSR_TSSEL_N(tint_nr);
149+
nr_tint = 32 / priv->info->field_width;
150+
k = tint_nr / nr_tint;
151+
tssel_n = tint_nr % nr_tint;
150152

151153
guard(raw_spinlock)(&priv->lock);
152154
tssr = readl_relaxed(priv->base + priv->info->t_offs + ICU_TSSR(k));
@@ -278,6 +280,7 @@ static int rzv2h_tint_set_type(struct irq_data *d, unsigned int type)
278280
unsigned int hwirq;
279281
u32 tint, sense;
280282
int tint_nr;
283+
u8 nr_tint;
281284

282285
switch (type & IRQ_TYPE_SENSE_MASK) {
283286
case IRQ_TYPE_LEVEL_LOW:
@@ -308,8 +311,9 @@ static int rzv2h_tint_set_type(struct irq_data *d, unsigned int type)
308311
hwirq = irqd_to_hwirq(d);
309312
tint_nr = hwirq - ICU_TINT_START;
310313

311-
tssr_k = ICU_TSSR_K(tint_nr);
312-
tssel_n = ICU_TSSR_TSSEL_N(tint_nr);
314+
nr_tint = 32 / priv->info->field_width;
315+
tssr_k = tint_nr / nr_tint;
316+
tssel_n = tint_nr % nr_tint;
313317
tien = ICU_TSSR_TIEN(tssel_n);
314318

315319
titsr_k = ICU_TITSR_K(tint_nr);
@@ -519,6 +523,7 @@ static int rzv2h_icu_init_common(struct device_node *node, struct device_node *p
519523
static const struct rzv2h_hw_info rzv2h_hw_params = {
520524
.t_offs = 0,
521525
.max_tssel = ICU_RZV2H_TSSEL_MAX_VAL,
526+
.field_width = 8,
522527
};
523528

524529
static int rzv2h_icu_init(struct device_node *node, struct device_node *parent)

0 commit comments

Comments
 (0)