Skip to content

Commit 0a9d6ef

Browse files
bijudasKAGA-KOKO
authored andcommitted
irqchip/renesas-rzv2h: Add struct rzv2h_hw_info with t_offs variable
The ICU block on the RZ/G3E SoC is almost identical to the one found on the RZ/V2H SoC, with the following differences: - The TINT register base offset is 0x800 instead of zero. - The number of GPIO interrupts for TINT selection is 141 instead of 86. - The pin index and TINT selection index are not in the 1:1 map - The number of TSSR registers is 16 instead of 8 - Each TSSR register can program 2 TINTs instead of 4 TINTs Introduce struct rzv2h_hw_info to describe the SoC properties and refactor the code by moving rzv2h_icu_init() into rzv2h_icu_init_common() and pass the variable containing hw difference to support both these SoCs. As a first step add t_offs to the new struct and replace the hardcoded constants in the code. Signed-off-by: Biju Das <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Fabrizio Castro <[email protected]> Reviewed-by: Tommaso Merciai <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 5ec8cab commit 0a9d6ef

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

drivers/irqchip/irq-renesas-rzv2h.c

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,26 @@
8080
#define ICU_TINT_EXTRACT_GPIOINT(x) FIELD_GET(GENMASK(31, 16), (x))
8181
#define ICU_PB5_TINT 0x55
8282

83+
/**
84+
* struct rzv2h_hw_info - Interrupt Control Unit controller hardware info structure.
85+
* @t_offs: TINT offset
86+
*/
87+
struct rzv2h_hw_info {
88+
u16 t_offs;
89+
};
90+
8391
/**
8492
* struct rzv2h_icu_priv - Interrupt Control Unit controller private data structure.
8593
* @base: Controller's base address
8694
* @fwspec: IRQ firmware specific data
8795
* @lock: Lock to serialize access to hardware registers
96+
* @info: Pointer to struct rzv2h_hw_info
8897
*/
8998
struct rzv2h_icu_priv {
9099
void __iomem *base;
91100
struct irq_fwspec fwspec[ICU_NUM_IRQ];
92101
raw_spinlock_t lock;
102+
const struct rzv2h_hw_info *info;
93103
};
94104

95105
static inline struct rzv2h_icu_priv *irq_data_to_priv(struct irq_data *data)
@@ -109,7 +119,7 @@ static void rzv2h_icu_eoi(struct irq_data *d)
109119
tintirq_nr = hw_irq - ICU_TINT_START;
110120
bit = BIT(tintirq_nr);
111121
if (!irqd_is_level_type(d))
112-
writel_relaxed(bit, priv->base + ICU_TSCLR);
122+
writel_relaxed(bit, priv->base + priv->info->t_offs + ICU_TSCLR);
113123
} else if (hw_irq >= ICU_IRQ_START) {
114124
tintirq_nr = hw_irq - ICU_IRQ_START;
115125
bit = BIT(tintirq_nr);
@@ -137,12 +147,12 @@ static void rzv2h_tint_irq_endisable(struct irq_data *d, bool enable)
137147
tssel_n = ICU_TSSR_TSSEL_N(tint_nr);
138148

139149
guard(raw_spinlock)(&priv->lock);
140-
tssr = readl_relaxed(priv->base + ICU_TSSR(k));
150+
tssr = readl_relaxed(priv->base + priv->info->t_offs + ICU_TSSR(k));
141151
if (enable)
142152
tssr |= ICU_TSSR_TIEN(tssel_n);
143153
else
144154
tssr &= ~ICU_TSSR_TIEN(tssel_n);
145-
writel_relaxed(tssr, priv->base + ICU_TSSR(k));
155+
writel_relaxed(tssr, priv->base + priv->info->t_offs + ICU_TSSR(k));
146156
}
147157

148158
static void rzv2h_icu_irq_disable(struct irq_data *d)
@@ -245,8 +255,8 @@ static void rzv2h_clear_tint_int(struct rzv2h_icu_priv *priv, unsigned int hwirq
245255
u32 bit = BIT(tint_nr);
246256
int k = tint_nr / 16;
247257

248-
tsctr = readl_relaxed(priv->base + ICU_TSCTR);
249-
titsr = readl_relaxed(priv->base + ICU_TITSR(k));
258+
tsctr = readl_relaxed(priv->base + priv->info->t_offs + ICU_TSCTR);
259+
titsr = readl_relaxed(priv->base + priv->info->t_offs + ICU_TITSR(k));
250260
titsel = ICU_TITSR_TITSEL_GET(titsr, titsel_n);
251261

252262
/*
@@ -255,7 +265,7 @@ static void rzv2h_clear_tint_int(struct rzv2h_icu_priv *priv, unsigned int hwirq
255265
*/
256266
if ((tsctr & bit) && ((titsel == ICU_TINT_EDGE_RISING) ||
257267
(titsel == ICU_TINT_EDGE_FALLING)))
258-
writel_relaxed(bit, priv->base + ICU_TSCLR);
268+
writel_relaxed(bit, priv->base + priv->info->t_offs + ICU_TSCLR);
259269
}
260270

261271
static int rzv2h_tint_set_type(struct irq_data *d, unsigned int type)
@@ -306,21 +316,21 @@ static int rzv2h_tint_set_type(struct irq_data *d, unsigned int type)
306316

307317
guard(raw_spinlock)(&priv->lock);
308318

309-
tssr = readl_relaxed(priv->base + ICU_TSSR(tssr_k));
319+
tssr = readl_relaxed(priv->base + priv->info->t_offs + ICU_TSSR(tssr_k));
310320
tssr &= ~(ICU_TSSR_TSSEL_MASK(tssel_n) | tien);
311321
tssr |= ICU_TSSR_TSSEL_PREP(tint, tssel_n);
312322

313-
writel_relaxed(tssr, priv->base + ICU_TSSR(tssr_k));
323+
writel_relaxed(tssr, priv->base + priv->info->t_offs + ICU_TSSR(tssr_k));
314324

315-
titsr = readl_relaxed(priv->base + ICU_TITSR(titsr_k));
325+
titsr = readl_relaxed(priv->base + priv->info->t_offs + ICU_TITSR(titsr_k));
316326
titsr &= ~ICU_TITSR_TITSEL_MASK(titsel_n);
317327
titsr |= ICU_TITSR_TITSEL_PREP(sense, titsel_n);
318328

319-
writel_relaxed(titsr, priv->base + ICU_TITSR(titsr_k));
329+
writel_relaxed(titsr, priv->base + priv->info->t_offs + ICU_TITSR(titsr_k));
320330

321331
rzv2h_clear_tint_int(priv, hwirq);
322332

323-
writel_relaxed(tssr | tien, priv->base + ICU_TSSR(tssr_k));
333+
writel_relaxed(tssr | tien, priv->base + priv->info->t_offs + ICU_TSSR(tssr_k));
324334

325335
return 0;
326336
}
@@ -424,7 +434,8 @@ static void rzv2h_icu_put_device(void *data)
424434
put_device(data);
425435
}
426436

427-
static int rzv2h_icu_init(struct device_node *node, struct device_node *parent)
437+
static int rzv2h_icu_init_common(struct device_node *node, struct device_node *parent,
438+
const struct rzv2h_hw_info *hw_info)
428439
{
429440
struct irq_domain *irq_domain, *parent_domain;
430441
struct rzv2h_icu_priv *rzv2h_icu_data;
@@ -490,6 +501,8 @@ static int rzv2h_icu_init(struct device_node *node, struct device_node *parent)
490501
goto pm_put;
491502
}
492503

504+
rzv2h_icu_data->info = hw_info;
505+
493506
/*
494507
* coccicheck complains about a missing put_device call before returning, but it's a false
495508
* positive. We still need &pdev->dev after successfully returning from this function.
@@ -502,6 +515,15 @@ static int rzv2h_icu_init(struct device_node *node, struct device_node *parent)
502515
return ret;
503516
}
504517

518+
static const struct rzv2h_hw_info rzv2h_hw_params = {
519+
.t_offs = 0,
520+
};
521+
522+
static int rzv2h_icu_init(struct device_node *node, struct device_node *parent)
523+
{
524+
return rzv2h_icu_init_common(node, parent, &rzv2h_hw_params);
525+
}
526+
505527
IRQCHIP_PLATFORM_DRIVER_BEGIN(rzv2h_icu)
506528
IRQCHIP_MATCH("renesas,r9a09g057-icu", rzv2h_icu_init)
507529
IRQCHIP_PLATFORM_DRIVER_END(rzv2h_icu)

0 commit comments

Comments
 (0)