[PATCH V3 03/14] genirq: Generic chip: Allow irqchip drivers to override irq_reg_{readl,writel}

2014-11-01 Thread Kevin Cernekee
Currently, these I/O accessors always assume little endian 32-bit
registers (readl/writel).  On some systems the IRQ registers need to be
accessed in BE mode or using 16-bit loads/stores, so we will provide a
way to override the default behavior.

Signed-off-by: Kevin Cernekee 
---
 include/linux/irq.h | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index 0743743..a514ef7 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -709,6 +710,8 @@ struct irq_chip_type {
 struct irq_chip_generic {
raw_spinlock_t  lock;
void __iomem*reg_base;
+   u32 (*reg_readl)(void __iomem *addr);
+   void(*reg_writel)(u32 val, void __iomem *addr);
unsigned intirq_base;
unsigned intirq_cnt;
u32 mask_cache;
@@ -817,13 +820,19 @@ static inline void irq_gc_unlock(struct irq_chip_generic 
*gc) { }
 static inline void irq_reg_writel(struct irq_chip_generic *gc,
  u32 val, int reg_offset)
 {
-   writel(val, gc->reg_base + reg_offset);
+   if (gc->reg_writel)
+   gc->reg_writel(val, gc->reg_base + reg_offset);
+   else
+   writel(val, gc->reg_base + reg_offset);
 }
 
 static inline u32 irq_reg_readl(struct irq_chip_generic *gc,
int reg_offset)
 {
-   return readl(gc->reg_base + reg_offset);
+   if (gc->reg_readl)
+   return gc->reg_readl(gc->reg_base + reg_offset);
+   else
+   return readl(gc->reg_base + reg_offset);
 }
 
 #endif /* _LINUX_IRQ_H */
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V3 03/14] genirq: Generic chip: Allow irqchip drivers to override irq_reg_{readl,writel}

2014-11-01 Thread Kevin Cernekee
Currently, these I/O accessors always assume little endian 32-bit
registers (readl/writel).  On some systems the IRQ registers need to be
accessed in BE mode or using 16-bit loads/stores, so we will provide a
way to override the default behavior.

Signed-off-by: Kevin Cernekee cerne...@gmail.com
---
 include/linux/irq.h | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index 0743743..a514ef7 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -20,6 +20,7 @@
 #include linux/errno.h
 #include linux/topology.h
 #include linux/wait.h
+#include linux/io.h
 
 #include asm/irq.h
 #include asm/ptrace.h
@@ -709,6 +710,8 @@ struct irq_chip_type {
 struct irq_chip_generic {
raw_spinlock_t  lock;
void __iomem*reg_base;
+   u32 (*reg_readl)(void __iomem *addr);
+   void(*reg_writel)(u32 val, void __iomem *addr);
unsigned intirq_base;
unsigned intirq_cnt;
u32 mask_cache;
@@ -817,13 +820,19 @@ static inline void irq_gc_unlock(struct irq_chip_generic 
*gc) { }
 static inline void irq_reg_writel(struct irq_chip_generic *gc,
  u32 val, int reg_offset)
 {
-   writel(val, gc-reg_base + reg_offset);
+   if (gc-reg_writel)
+   gc-reg_writel(val, gc-reg_base + reg_offset);
+   else
+   writel(val, gc-reg_base + reg_offset);
 }
 
 static inline u32 irq_reg_readl(struct irq_chip_generic *gc,
int reg_offset)
 {
-   return readl(gc-reg_base + reg_offset);
+   if (gc-reg_readl)
+   return gc-reg_readl(gc-reg_base + reg_offset);
+   else
+   return readl(gc-reg_base + reg_offset);
 }
 
 #endif /* _LINUX_IRQ_H */
-- 
2.1.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/