Commit 582e2b4a authored by Paul Burton's avatar Paul Burton Committed by Ralf Baechle

MIPS: GIC: Introduce asm/mips-gic.h with accessor functions

This patch introduces a new header providing accessor functions for the
MIPS Global Interrupt Controller (GIC) mirroring those provided for the
other 2 components of the MIPS Coherent Processing System (CPS) - the
Coherence Manager (CM) & Cluster Power Controller (CPC).

This header makes use of the new standardised CPS accessor macros where
possible, but does require some custom accessors for cases where we have
either a bit or a register per interrupt.

A major advantage of this over the existing
include/linux/irqchip/mips-gic.h definitions is that code performing
accesses can become much simpler, for example this:

  gic_update_bits(GIC_REG(SHARED, GIC_SH_SET_TRIGGER) +
                  GIC_INTR_OFS(intr), 1ul << GIC_INTR_BIT(intr),
                  (unsigned long)trig << GIC_INTR_BIT(intr));

...can become simply:

  change_gic_trig(intr, trig);

The accessors handle 32 vs 64 bit in the same way as for CM & CPC code,
which means that GIC code will also not need to worry about the access
size in most cases. They are also accessible outside of
drivers/irqchip/irq-mips-gic.c which will allow for simplification in
the use of the non-interrupt portions of the GIC (eg. counters) which
currently require the interrupt controller driver to expose helper
functions for access.

This patch doesn't change any existing code over to use the new
accessors yet, since a wholesale change would be invasive & difficult to
review. Instead follow-on patches will convert code piecemeal to use
this new header. The one change to existing code is to rename gic_base
to mips_gic_base & make it global, in order to fit in with the naming
expected by the standardised CPS accessor macros.
Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
Acked-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/17020/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent a0ffec3d
...@@ -107,6 +107,7 @@ static inline void clear_##unit##_##name(uint##sz##_t val) \ ...@@ -107,6 +107,7 @@ static inline void clear_##unit##_##name(uint##sz##_t val) \
#include <asm/mips-cm.h> #include <asm/mips-cm.h>
#include <asm/mips-cpc.h> #include <asm/mips-cpc.h>
#include <asm/mips-gic.h>
/** /**
* mips_cps_numclusters - return the number of clusters present in the system * mips_cps_numclusters - return the number of clusters present in the system
......
This diff is collapsed.
...@@ -24,14 +24,13 @@ ...@@ -24,14 +24,13 @@
#include <dt-bindings/interrupt-controller/mips-gic.h> #include <dt-bindings/interrupt-controller/mips-gic.h>
unsigned int gic_present; unsigned int gic_present;
void __iomem *mips_gic_base;
struct gic_pcpu_mask { struct gic_pcpu_mask {
DECLARE_BITMAP(pcpu_mask, GIC_MAX_INTRS); DECLARE_BITMAP(pcpu_mask, GIC_MAX_INTRS);
}; };
static unsigned long __gic_base_addr; static unsigned long __gic_base_addr;
static void __iomem *gic_base;
static struct gic_pcpu_mask pcpu_masks[NR_CPUS]; static struct gic_pcpu_mask pcpu_masks[NR_CPUS];
static DEFINE_SPINLOCK(gic_lock); static DEFINE_SPINLOCK(gic_lock);
static struct irq_domain *gic_irq_domain; static struct irq_domain *gic_irq_domain;
...@@ -48,12 +47,12 @@ static void __gic_irq_dispatch(void); ...@@ -48,12 +47,12 @@ static void __gic_irq_dispatch(void);
static inline u32 gic_read32(unsigned int reg) static inline u32 gic_read32(unsigned int reg)
{ {
return __raw_readl(gic_base + reg); return __raw_readl(mips_gic_base + reg);
} }
static inline u64 gic_read64(unsigned int reg) static inline u64 gic_read64(unsigned int reg)
{ {
return __raw_readq(gic_base + reg); return __raw_readq(mips_gic_base + reg);
} }
static inline unsigned long gic_read(unsigned int reg) static inline unsigned long gic_read(unsigned int reg)
...@@ -66,12 +65,12 @@ static inline unsigned long gic_read(unsigned int reg) ...@@ -66,12 +65,12 @@ static inline unsigned long gic_read(unsigned int reg)
static inline void gic_write32(unsigned int reg, u32 val) static inline void gic_write32(unsigned int reg, u32 val)
{ {
return __raw_writel(val, gic_base + reg); return __raw_writel(val, mips_gic_base + reg);
} }
static inline void gic_write64(unsigned int reg, u64 val) static inline void gic_write64(unsigned int reg, u64 val)
{ {
return __raw_writeq(val, gic_base + reg); return __raw_writeq(val, mips_gic_base + reg);
} }
static inline void gic_write(unsigned int reg, unsigned long val) static inline void gic_write(unsigned int reg, unsigned long val)
...@@ -891,7 +890,7 @@ static void __init __gic_init(unsigned long gic_base_addr, ...@@ -891,7 +890,7 @@ static void __init __gic_init(unsigned long gic_base_addr,
__gic_base_addr = gic_base_addr; __gic_base_addr = gic_base_addr;
gic_base = ioremap_nocache(gic_base_addr, gic_addrspace_size); mips_gic_base = ioremap_nocache(gic_base_addr, gic_addrspace_size);
gicconfig = gic_read(GIC_REG(SHARED, GIC_SH_CONFIG)); gicconfig = gic_read(GIC_REG(SHARED, GIC_SH_CONFIG));
gic_shared_intrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >> gic_shared_intrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >>
......
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