Commit bd654fb6 authored by Andrey Smirnov's avatar Andrey Smirnov Committed by Marc Zyngier

irqchip/irq-imx-gpcv2: Share reg offset calculation code

Move identical offset calculation code into a small helper function
and make use of it in the rest of the code.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: cphealy@gmail.com
Cc: l.stach@pengutronix.de
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
Cc: linux-imx@nxp.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: default avatarAndrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
parent b87442b0
...@@ -28,6 +28,11 @@ struct gpcv2_irqchip_data { ...@@ -28,6 +28,11 @@ struct gpcv2_irqchip_data {
static struct gpcv2_irqchip_data *imx_gpcv2_instance; static struct gpcv2_irqchip_data *imx_gpcv2_instance;
static void __iomem *gpcv2_idx_to_reg(struct gpcv2_irqchip_data *cd, int i)
{
return cd->gpc_base + cd->cpu2wakeup + i * 4;
}
static int gpcv2_wakeup_source_save(void) static int gpcv2_wakeup_source_save(void)
{ {
struct gpcv2_irqchip_data *cd; struct gpcv2_irqchip_data *cd;
...@@ -39,7 +44,7 @@ static int gpcv2_wakeup_source_save(void) ...@@ -39,7 +44,7 @@ static int gpcv2_wakeup_source_save(void)
return 0; return 0;
for (i = 0; i < IMR_NUM; i++) { for (i = 0; i < IMR_NUM; i++) {
reg = cd->gpc_base + cd->cpu2wakeup + i * 4; reg = gpcv2_idx_to_reg(cd, i);
cd->saved_irq_mask[i] = readl_relaxed(reg); cd->saved_irq_mask[i] = readl_relaxed(reg);
writel_relaxed(cd->wakeup_sources[i], reg); writel_relaxed(cd->wakeup_sources[i], reg);
} }
...@@ -50,17 +55,14 @@ static int gpcv2_wakeup_source_save(void) ...@@ -50,17 +55,14 @@ static int gpcv2_wakeup_source_save(void)
static void gpcv2_wakeup_source_restore(void) static void gpcv2_wakeup_source_restore(void)
{ {
struct gpcv2_irqchip_data *cd; struct gpcv2_irqchip_data *cd;
void __iomem *reg;
int i; int i;
cd = imx_gpcv2_instance; cd = imx_gpcv2_instance;
if (!cd) if (!cd)
return; return;
for (i = 0; i < IMR_NUM; i++) { for (i = 0; i < IMR_NUM; i++)
reg = cd->gpc_base + cd->cpu2wakeup + i * 4; writel_relaxed(cd->saved_irq_mask[i], gpcv2_idx_to_reg(cd, i));
writel_relaxed(cd->saved_irq_mask[i], reg);
}
} }
static struct syscore_ops imx_gpcv2_syscore_ops = { static struct syscore_ops imx_gpcv2_syscore_ops = {
...@@ -97,7 +99,7 @@ static void imx_gpcv2_irq_unmask(struct irq_data *d) ...@@ -97,7 +99,7 @@ static void imx_gpcv2_irq_unmask(struct irq_data *d)
u32 val; u32 val;
raw_spin_lock(&cd->rlock); raw_spin_lock(&cd->rlock);
reg = cd->gpc_base + cd->cpu2wakeup + d->hwirq / 32 * 4; reg = gpcv2_idx_to_reg(cd, d->hwirq / 32);
val = readl_relaxed(reg); val = readl_relaxed(reg);
val &= ~(1 << d->hwirq % 32); val &= ~(1 << d->hwirq % 32);
writel_relaxed(val, reg); writel_relaxed(val, reg);
...@@ -113,7 +115,7 @@ static void imx_gpcv2_irq_mask(struct irq_data *d) ...@@ -113,7 +115,7 @@ static void imx_gpcv2_irq_mask(struct irq_data *d)
u32 val; u32 val;
raw_spin_lock(&cd->rlock); raw_spin_lock(&cd->rlock);
reg = cd->gpc_base + cd->cpu2wakeup + d->hwirq / 32 * 4; reg = gpcv2_idx_to_reg(cd, d->hwirq / 32);
val = readl_relaxed(reg); val = readl_relaxed(reg);
val |= 1 << (d->hwirq % 32); val |= 1 << (d->hwirq % 32);
writel_relaxed(val, reg); writel_relaxed(val, reg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment