Skip to content

Commit e5f8153

Browse files
apmswJason Cooper
authored andcommitted
irqchip: gic: Replace hex numbers with defines.
This is to cleanup some hex numbers used in the code and replace them with defines to make the code cleaner. Signed-off-by: Feng Kan <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Jason Cooper <[email protected]>
1 parent 7d1311b commit e5f8153

File tree

3 files changed

+37
-18
lines changed

3 files changed

+37
-18
lines changed

drivers/irqchip/irq-gic-common.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,22 @@ void __init gic_dist_config(void __iomem *base, int gic_irqs,
7474
* Set all global interrupts to be level triggered, active low.
7575
*/
7676
for (i = 32; i < gic_irqs; i += 16)
77-
writel_relaxed(0, base + GIC_DIST_CONFIG + i / 4);
77+
writel_relaxed(GICD_INT_ACTLOW_LVLTRIG,
78+
base + GIC_DIST_CONFIG + i / 4);
7879

7980
/*
8081
* Set priority on all global interrupts.
8182
*/
8283
for (i = 32; i < gic_irqs; i += 4)
83-
writel_relaxed(0xa0a0a0a0, base + GIC_DIST_PRI + i);
84+
writel_relaxed(GICD_INT_DEF_PRI_X4, base + GIC_DIST_PRI + i);
8485

8586
/*
8687
* Disable all interrupts. Leave the PPI and SGIs alone
8788
* as they are enabled by redistributor registers.
8889
*/
8990
for (i = 32; i < gic_irqs; i += 32)
90-
writel_relaxed(0xffffffff, base + GIC_DIST_ENABLE_CLEAR + i / 8);
91+
writel_relaxed(GICD_INT_EN_CLR_X32,
92+
base + GIC_DIST_ENABLE_CLEAR + i / 8);
9193

9294
if (sync_access)
9395
sync_access();
@@ -101,14 +103,15 @@ void gic_cpu_config(void __iomem *base, void (*sync_access)(void))
101103
* Deal with the banked PPI and SGI interrupts - disable all
102104
* PPI interrupts, ensure all SGI interrupts are enabled.
103105
*/
104-
writel_relaxed(0xffff0000, base + GIC_DIST_ENABLE_CLEAR);
105-
writel_relaxed(0x0000ffff, base + GIC_DIST_ENABLE_SET);
106+
writel_relaxed(GICD_INT_EN_CLR_PPI, base + GIC_DIST_ENABLE_CLEAR);
107+
writel_relaxed(GICD_INT_EN_SET_SGI, base + GIC_DIST_ENABLE_SET);
106108

107109
/*
108110
* Set priority on PPI and SGI interrupts
109111
*/
110112
for (i = 0; i < 32; i += 4)
111-
writel_relaxed(0xa0a0a0a0, base + GIC_DIST_PRI + i * 4 / 4);
113+
writel_relaxed(GICD_INT_DEF_PRI_X4,
114+
base + GIC_DIST_PRI + i * 4 / 4);
112115

113116
if (sync_access)
114117
sync_access();

drivers/irqchip/irq-gic.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
298298
status = readl_relaxed(gic_data_cpu_base(chip_data) + GIC_CPU_INTACK);
299299
raw_spin_unlock(&irq_controller_lock);
300300

301-
gic_irq = (status & 0x3ff);
302-
if (gic_irq == 1023)
301+
gic_irq = (status & GICC_IAR_INT_ID_MASK);
302+
if (gic_irq == GICC_INT_SPURIOUS)
303303
goto out;
304304

305305
cascade_irq = irq_find_mapping(chip_data->domain, gic_irq);
@@ -360,7 +360,7 @@ static void __init gic_dist_init(struct gic_chip_data *gic)
360360
unsigned int gic_irqs = gic->gic_irqs;
361361
void __iomem *base = gic_data_dist_base(gic);
362362

363-
writel_relaxed(0, base + GIC_DIST_CTRL);
363+
writel_relaxed(GICD_DISABLE, base + GIC_DIST_CTRL);
364364

365365
/*
366366
* Set all global interrupts to this CPU only.
@@ -373,7 +373,7 @@ static void __init gic_dist_init(struct gic_chip_data *gic)
373373

374374
gic_dist_config(base, gic_irqs, NULL);
375375

376-
writel_relaxed(1, base + GIC_DIST_CTRL);
376+
writel_relaxed(GICD_ENABLE, base + GIC_DIST_CTRL);
377377
}
378378

379379
static void gic_cpu_init(struct gic_chip_data *gic)
@@ -400,8 +400,8 @@ static void gic_cpu_init(struct gic_chip_data *gic)
400400

401401
gic_cpu_config(dist_base, NULL);
402402

403-
writel_relaxed(0xf0, base + GIC_CPU_PRIMASK);
404-
writel_relaxed(1, base + GIC_CPU_CTRL);
403+
writel_relaxed(GICC_INT_PRI_THRESHOLD, base + GIC_CPU_PRIMASK);
404+
writel_relaxed(GICC_ENABLE, base + GIC_CPU_CTRL);
405405
}
406406

407407
void gic_cpu_if_down(void)
@@ -467,14 +467,14 @@ static void gic_dist_restore(unsigned int gic_nr)
467467
if (!dist_base)
468468
return;
469469

470-
writel_relaxed(0, dist_base + GIC_DIST_CTRL);
470+
writel_relaxed(GICD_DISABLE, dist_base + GIC_DIST_CTRL);
471471

472472
for (i = 0; i < DIV_ROUND_UP(gic_irqs, 16); i++)
473473
writel_relaxed(gic_data[gic_nr].saved_spi_conf[i],
474474
dist_base + GIC_DIST_CONFIG + i * 4);
475475

476476
for (i = 0; i < DIV_ROUND_UP(gic_irqs, 4); i++)
477-
writel_relaxed(0xa0a0a0a0,
477+
writel_relaxed(GICD_INT_DEF_PRI_X4,
478478
dist_base + GIC_DIST_PRI + i * 4);
479479

480480
for (i = 0; i < DIV_ROUND_UP(gic_irqs, 4); i++)
@@ -485,7 +485,7 @@ static void gic_dist_restore(unsigned int gic_nr)
485485
writel_relaxed(gic_data[gic_nr].saved_spi_enable[i],
486486
dist_base + GIC_DIST_ENABLE_SET + i * 4);
487487

488-
writel_relaxed(1, dist_base + GIC_DIST_CTRL);
488+
writel_relaxed(GICD_ENABLE, dist_base + GIC_DIST_CTRL);
489489
}
490490

491491
static void gic_cpu_save(unsigned int gic_nr)
@@ -539,10 +539,11 @@ static void gic_cpu_restore(unsigned int gic_nr)
539539
writel_relaxed(ptr[i], dist_base + GIC_DIST_CONFIG + i * 4);
540540

541541
for (i = 0; i < DIV_ROUND_UP(32, 4); i++)
542-
writel_relaxed(0xa0a0a0a0, dist_base + GIC_DIST_PRI + i * 4);
542+
writel_relaxed(GICD_INT_DEF_PRI_X4,
543+
dist_base + GIC_DIST_PRI + i * 4);
543544

544-
writel_relaxed(0xf0, cpu_base + GIC_CPU_PRIMASK);
545-
writel_relaxed(1, cpu_base + GIC_CPU_CTRL);
545+
writel_relaxed(GICC_INT_PRI_THRESHOLD, cpu_base + GIC_CPU_PRIMASK);
546+
writel_relaxed(GICC_ENABLE, cpu_base + GIC_CPU_CTRL);
546547
}
547548

548549
static int gic_notifier(struct notifier_block *self, unsigned long cmd, void *v)

include/linux/irqchip/arm-gic.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
#define GIC_CPU_ACTIVEPRIO 0xd0
2222
#define GIC_CPU_IDENT 0xfc
2323

24+
#define GICC_ENABLE 0x1
25+
#define GICC_INT_PRI_THRESHOLD 0xf0
2426
#define GICC_IAR_INT_ID_MASK 0x3ff
27+
#define GICC_INT_SPURIOUS 1023
2528

2629
#define GIC_DIST_CTRL 0x000
2730
#define GIC_DIST_CTR 0x004
@@ -39,6 +42,18 @@
3942
#define GIC_DIST_SGI_PENDING_CLEAR 0xf10
4043
#define GIC_DIST_SGI_PENDING_SET 0xf20
4144

45+
#define GICD_ENABLE 0x1
46+
#define GICD_DISABLE 0x0
47+
#define GICD_INT_ACTLOW_LVLTRIG 0x0
48+
#define GICD_INT_EN_CLR_X32 0xffffffff
49+
#define GICD_INT_EN_SET_SGI 0x0000ffff
50+
#define GICD_INT_EN_CLR_PPI 0xffff0000
51+
#define GICD_INT_DEF_PRI 0xa0
52+
#define GICD_INT_DEF_PRI_X4 ((GICD_INT_DEF_PRI << 24) |\
53+
(GICD_INT_DEF_PRI << 16) |\
54+
(GICD_INT_DEF_PRI << 8) |\
55+
GICD_INT_DEF_PRI)
56+
4257
#define GICH_HCR 0x0
4358
#define GICH_VTR 0x4
4459
#define GICH_VMCR 0x8

0 commit comments

Comments
 (0)