From: Guo Ren <[email protected]>
C-SKY dh7k SOC use simple APB interrupt controller and most of driver's
implementation codes could be reused in csky-apb-intc.c. So merge them
together.
Signed-off-by: Guo Ren <[email protected]>
---
drivers/irqchip/irq-csky-apb-intc.c | 95 +++++++++++++++++++++++++++++++++----
1 file changed, 85 insertions(+), 10 deletions(-)
diff --git a/drivers/irqchip/irq-csky-apb-intc.c b/drivers/irqchip/irq-csky-apb-intc.c
index 5a2ec43..fcc5444 100644
--- a/drivers/irqchip/irq-csky-apb-intc.c
+++ b/drivers/irqchip/irq-csky-apb-intc.c
@@ -12,6 +12,7 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <asm/irq.h>
+#include <asm/traps.h>
#define INTC_IRQS 64
@@ -31,6 +32,17 @@
#define GX_INTC_NMASK63_32 0x54
#define GX_INTC_SOURCE 0x60
+#define DH_INTC_CLR 0x10
+#define DH_INTC_INIT 0x34
+#define DH_INTC_NMASK31_00 0x08
+#define DH_INTC_NMASK63_32 0x68
+#define DH_INTC_SOURCE31_00 0x14
+#define DH_INTC_SOURCE63_32 0x6c
+#define DH_INTC_EDGE31_00 0x00
+#define DH_INTC_EDGE63_32 0x60
+#define DH_INTC_POLL31_00 0x04
+#define DH_INTC_POLL63_32 0x64
+
static void __iomem *reg_base;
static struct irq_domain *root_domain;
@@ -58,15 +70,21 @@ static void irq_ck_mask_set_bit(struct irq_data *d)
}
static void __init ck_set_gc(struct device_node *node, void __iomem *reg_base,
- u32 mask_reg, u32 irq_base)
+ u32 en_off, u32 mask_off, u32 irq_base)
{
struct irq_chip_generic *gc;
gc = irq_get_domain_generic_chip(root_domain, irq_base);
gc->reg_base = reg_base;
- gc->chip_types[0].regs.mask = mask_reg;
- gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit;
- gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit;
+ if (en_off) {
+ gc->chip_types[0].regs.mask = en_off;
+ gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit;
+ gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit;
+ } else if (mask_off) {
+ gc->chip_types[0].regs.mask = mask_off;
+ gc->chip_types[0].chip.irq_mask = irq_gc_mask_set_bit;
+ gc->chip_types[0].chip.irq_unmask = irq_gc_mask_clr_bit;
+ }
if (of_find_property(node, "csky,support-pulse-signal", NULL))
gc->chip_types[0].chip.irq_unmask = irq_ck_mask_set_bit;
@@ -183,8 +201,8 @@ gx_intc_init(struct device_node *node, struct device_node *parent)
setup_irq_channel(0x03020100, reg_base + GX_INTC_SOURCE);
- ck_set_gc(node, reg_base, GX_INTC_NEN31_00, 0);
- ck_set_gc(node, reg_base, GX_INTC_NEN63_32, 32);
+ ck_set_gc(node, reg_base, GX_INTC_NEN31_00, 0, 0);
+ ck_set_gc(node, reg_base, GX_INTC_NEN63_32, 0, 32);
set_handle_irq(gx_irq_handler);
@@ -192,6 +210,63 @@ gx_intc_init(struct device_node *node, struct device_node *parent)
}
IRQCHIP_DECLARE(csky_gx6605s_intc, "csky,gx6605s-intc", gx_intc_init);
+static void dh_irq_handler(struct pt_regs *regs)
+{
+ u32 tmp;
+ unsigned long vector = (mfcr("psr") >> 16) & 0xff;
+
+ tmp = readl(reg_base + DH_INTC_CLR);
+ tmp |= BIT(2);
+ writel(tmp, reg_base + DH_INTC_CLR);
+
+ handle_domain_irq(root_domain, vector - 32, regs);
+}
+
+extern void csky_irq(void);
+
+static int __init
+dh_intc_init(struct device_node *node, struct device_node *parent)
+{
+ int ret, i;
+
+ ret = ck_intc_init_comm(node, parent);
+ if (ret)
+ return ret;
+
+ /* set default mode */
+ writel(0xffffffff, reg_base + DH_INTC_EDGE31_00);
+ writel(0xffffffff, reg_base + DH_INTC_EDGE63_32);
+ writel(0xffffffff, reg_base + DH_INTC_POLL31_00);
+ writel(0xffffffff, reg_base + DH_INTC_POLL63_32);
+
+ writel(BIT(1) | BIT(6), reg_base + DH_INTC_INIT);
+
+ /* Setup 0-31 channel slots */
+ for (i = 0; i < INTC_IRQS/2; i += 4)
+ writel(build_channel_val(i, 0x03020100) + 0x40404040,
+ reg_base + DH_INTC_SOURCE31_00 + i);
+
+ /* Setup 32-63 channel slots */
+ for (i = 0; i < INTC_IRQS/2; i += 4)
+ writel(build_channel_val(i, 0x03020100) + 0x40404040,
+ reg_base + DH_INTC_SOURCE63_32 + i);
+
+ /* mask all interrrupts */
+ writel(0xffffffff, reg_base + DH_INTC_NMASK31_00);
+ writel(0xffffffff, reg_base + DH_INTC_NMASK63_32);
+
+ ck_set_gc(node, reg_base, 0, DH_INTC_NMASK31_00, 0);
+ ck_set_gc(node, reg_base, 0, DH_INTC_NMASK63_32, 32);
+
+ for (i = 32; i < 128; i++)
+ VEC_INIT(i, csky_irq);
+
+ set_handle_irq(dh_irq_handler);
+
+ return 0;
+}
+IRQCHIP_DECLARE(csky_dh7k_intc, "csky,dh7k-intc", dh_intc_init);
+
/*
* C-SKY simple 64 irqs interrupt controller, dual-together could support 128
* irqs.
@@ -243,8 +318,8 @@ ck_intc_init(struct device_node *node, struct device_node *parent)
/* Enable irq intc */
writel(BIT(31), reg_base + CK_INTC_ICR);
- ck_set_gc(node, reg_base, CK_INTC_NEN31_00, 0);
- ck_set_gc(node, reg_base, CK_INTC_NEN63_32, 32);
+ ck_set_gc(node, reg_base, CK_INTC_NEN31_00, 0, 0);
+ ck_set_gc(node, reg_base, CK_INTC_NEN63_32, 0, 32);
setup_irq_channel(0x00010203, reg_base + CK_INTC_SOURCE);
@@ -270,8 +345,8 @@ ck_dual_intc_init(struct device_node *node, struct device_node *parent)
writel(0, reg_base + CK_INTC_NEN31_00 + CK_INTC_DUAL_BASE);
writel(0, reg_base + CK_INTC_NEN63_32 + CK_INTC_DUAL_BASE);
- ck_set_gc(node, reg_base + CK_INTC_DUAL_BASE, CK_INTC_NEN31_00, 64);
- ck_set_gc(node, reg_base + CK_INTC_DUAL_BASE, CK_INTC_NEN63_32, 96);
+ ck_set_gc(node, reg_base + CK_INTC_DUAL_BASE, CK_INTC_NEN31_00, 0, 64);
+ ck_set_gc(node, reg_base + CK_INTC_DUAL_BASE, CK_INTC_NEN63_32, 0, 96);
setup_irq_channel(0x00010203,
reg_base + CK_INTC_SOURCE + CK_INTC_DUAL_BASE);
--
2.7.4
From: Guo Ren <[email protected]>
Add C-SKY dh7k SOC description.
Signed-off-by: Guo Ren <[email protected]>
---
Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt b/Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt
index 44286dc..63bc9dc 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt
+++ b/Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt
@@ -23,6 +23,7 @@ intc node bindings definition
Definition: must be "csky,apb-intc"
"csky,dual-apb-intc"
"csky,gx6605s-intc"
+ "csky,dh7k-intc"
- #interrupt-cells
Usage: required
Value type: <u32>
--
2.7.4
From: Guo Ren <[email protected]>
C-SKY CPU 8xx's _PAGE_GLOBAL is BIT(0), but 610's _PAGE_GLOBAL is
BIT(6). Use _PAGE_GLOBAL macro instead of bad magic number.
Signed-off-by: Guo Ren <[email protected]>
---
arch/csky/include/asm/pgtable.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/csky/include/asm/pgtable.h b/arch/csky/include/asm/pgtable.h
index edfcbb2..af7a7fa 100644
--- a/arch/csky/include/asm/pgtable.h
+++ b/arch/csky/include/asm/pgtable.h
@@ -45,8 +45,8 @@
((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset_t(address))
#define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
#define pte_clear(mm, addr, ptep) set_pte((ptep), \
- (((unsigned int)addr&0x80000000)?__pte(1):__pte(0)))
-#define pte_none(pte) (!(pte_val(pte)&0xfffffffe))
+ (((unsigned int) addr & PAGE_OFFSET) ? __pte(_PAGE_GLOBAL) : __pte(0)))
+#define pte_none(pte) (!(pte_val(pte) & ~_PAGE_GLOBAL))
#define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
#define pte_pfn(x) ((unsigned long)((x).pte_low >> PAGE_SHIFT))
#define pfn_pte(pfn, prot) __pte(((unsigned long long)(pfn) << PAGE_SHIFT) \
--
2.7.4
From: Guo Ren <[email protected]>
Here is the previous interrupt processing flow:
while (pending) {
^^^^^^^^^^^^^^^ It's unnecessary!
get irq
handle_level/fasteoi_irq {
mask irq
driver irq handler
unmask irq
}
irq_exit {
preempt_count_sub(HARDIRQ_OFFSET);
if (!in_interrupt() && local_softirq_pending())
invoke_softirq();
Because: ^^^^^^^^^^^^^^^^ linux enable irq Here!
}
}
Because linux enable the irq in irq_exit() before ret, we needn't loop
read pending register again for next irq which is done during irq_exit().
Signed-off-by: Guo Ren <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-csky-apb-intc.c | 36 ++++++++++++++++++------------------
drivers/irqchip/irq-csky-mpintc.c | 8 ++------
2 files changed, 20 insertions(+), 24 deletions(-)
diff --git a/drivers/irqchip/irq-csky-apb-intc.c b/drivers/irqchip/irq-csky-apb-intc.c
index fcc5444..ae4c59b 100644
--- a/drivers/irqchip/irq-csky-apb-intc.c
+++ b/drivers/irqchip/irq-csky-apb-intc.c
@@ -150,7 +150,7 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent)
return 0;
}
-static inline bool handle_irq_perbit(struct pt_regs *regs, u32 hwirq,
+static inline bool handle_irq_onebit(struct pt_regs *regs, u32 hwirq,
u32 irq_base)
{
if (hwirq == 0)
@@ -166,16 +166,15 @@ static void gx_irq_handler(struct pt_regs *regs)
{
bool ret;
-retry:
- ret = handle_irq_perbit(regs,
+ ret = handle_irq_onebit(regs,
readl(reg_base + GX_INTC_PEN63_32), 32);
if (ret)
- goto retry;
+ return;
- ret = handle_irq_perbit(regs,
+ ret = handle_irq_onebit(regs,
readl(reg_base + GX_INTC_PEN31_00), 0);
- if (ret)
- goto retry;
+ if (!ret)
+ pr_err("%s: none irq pending!\n", __func__);
}
static int __init
@@ -277,29 +276,30 @@ static void ck_irq_handler(struct pt_regs *regs)
void __iomem *reg_pen_lo = reg_base + CK_INTC_PEN31_00;
void __iomem *reg_pen_hi = reg_base + CK_INTC_PEN63_32;
-retry:
/* handle 0 - 63 irqs */
- ret = handle_irq_perbit(regs, readl(reg_pen_hi), 32);
+ ret = handle_irq_onebit(regs, readl(reg_pen_hi), 32);
if (ret)
- goto retry;
+ return;
- ret = handle_irq_perbit(regs, readl(reg_pen_lo), 0);
+ ret = handle_irq_onebit(regs, readl(reg_pen_lo), 0);
if (ret)
- goto retry;
+ return;
- if (nr_irq == INTC_IRQS)
+ if (nr_irq == INTC_IRQS) {
+ pr_err("%s: none irq pending!\n", __func__);
return;
+ }
/* handle 64 - 127 irqs */
- ret = handle_irq_perbit(regs,
+ ret = handle_irq_onebit(regs,
readl(reg_pen_hi + CK_INTC_DUAL_BASE), 96);
if (ret)
- goto retry;
+ return;
- ret = handle_irq_perbit(regs,
+ ret = handle_irq_onebit(regs,
readl(reg_pen_lo + CK_INTC_DUAL_BASE), 64);
- if (ret)
- goto retry;
+ if (!ret)
+ pr_err("%s: none irq pending!\n", __func__);
}
static int __init
diff --git a/drivers/irqchip/irq-csky-mpintc.c b/drivers/irqchip/irq-csky-mpintc.c
index c67c961..99d3f3f 100644
--- a/drivers/irqchip/irq-csky-mpintc.c
+++ b/drivers/irqchip/irq-csky-mpintc.c
@@ -33,7 +33,6 @@ static void __iomem *INTCL_base;
#define INTCL_PICTLR 0x0
#define INTCL_SIGR 0x60
-#define INTCL_HPPIR 0x68
#define INTCL_RDYIR 0x6c
#define INTCL_SENR 0xa0
#define INTCL_CENR 0xa4
@@ -45,11 +44,8 @@ static void csky_mpintc_handler(struct pt_regs *regs)
{
void __iomem *reg_base = this_cpu_read(intcl_reg);
- do {
- handle_domain_irq(root_domain,
- readl_relaxed(reg_base + INTCL_RDYIR),
- regs);
- } while (readl_relaxed(reg_base + INTCL_HPPIR) & BIT(31));
+ handle_domain_irq(root_domain,
+ readl_relaxed(reg_base + INTCL_RDYIR), regs);
}
static void csky_mpintc_enable(struct irq_data *d)
--
2.7.4
From: Guo Ren <[email protected]>
Support 4 triger types:
- IRQ_TYPE_LEVEL_HIGH
- IRQ_TYPE_LEVEL_LOW
- IRQ_TYPE_EDGE_RISING
- IRQ_TYPE_EDGE_FALLING
Support 0-255 priority setting for each irq.
Changelog:
- Fixup this_cpu_read() preempted problem.
- Optimize the coding style.
Signed-off-by: Guo Ren <[email protected]>
Cc: Marc Zyngier <[email protected]>
---
drivers/irqchip/irq-csky-mpintc.c | 105 +++++++++++++++++++++++++++++++++++++-
1 file changed, 104 insertions(+), 1 deletion(-)
diff --git a/drivers/irqchip/irq-csky-mpintc.c b/drivers/irqchip/irq-csky-mpintc.c
index 99d3f3f..07a3752 100644
--- a/drivers/irqchip/irq-csky-mpintc.c
+++ b/drivers/irqchip/irq-csky-mpintc.c
@@ -17,6 +17,7 @@
#include <asm/reg_ops.h>
static struct irq_domain *root_domain;
+
static void __iomem *INTCG_base;
static void __iomem *INTCL_base;
@@ -29,9 +30,12 @@ static void __iomem *INTCL_base;
#define INTCG_ICTLR 0x0
#define INTCG_CICFGR 0x100
+#define INTCG_CIPRTR 0x200
#define INTCG_CIDSTR 0x1000
#define INTCL_PICTLR 0x0
+#define INTCL_CFGR 0x14
+#define INTCL_PRTR 0x20
#define INTCL_SIGR 0x60
#define INTCL_RDYIR 0x6c
#define INTCL_SENR 0xa0
@@ -40,6 +44,51 @@ static void __iomem *INTCL_base;
static DEFINE_PER_CPU(void __iomem *, intcl_reg);
+static unsigned long *__trigger;
+static unsigned long *__priority;
+
+#define IRQ_OFFSET(irq) ((irq < COMM_IRQ_BASE) ? irq : (irq - COMM_IRQ_BASE))
+
+#define TRIG_BYTE_OFFSET(i) ((((i) * 2) / 32) * 4)
+#define TRIG_BIT_OFFSET(i) (((i) * 2) % 32)
+
+#define PRI_BYTE_OFFSET(i) ((((i) * 8) / 32) * 4)
+#define PRI_BIT_OFFSET(i) (((i) * 8) % 32)
+
+#define TRIG_VAL(trigger, irq) (trigger << TRIG_BIT_OFFSET(IRQ_OFFSET(irq)))
+#define TRIG_VAL_MSK(irq) (~(3 << TRIG_BIT_OFFSET(IRQ_OFFSET(irq))))
+#define PRI_VAL(priority, irq) (priority << PRI_BIT_OFFSET(IRQ_OFFSET(irq)))
+#define PRI_VAL_MSK(irq) (~(0xff << PRI_BIT_OFFSET(IRQ_OFFSET(irq))))
+
+#define TRIG_BASE(irq) \
+ (TRIG_BYTE_OFFSET(IRQ_OFFSET(irq)) + ((irq < COMM_IRQ_BASE) ? \
+ (this_cpu_read(intcl_reg) + INTCL_CFGR) : (INTCG_base + INTCG_CICFGR)))
+
+#define PRI_BASE(irq) \
+ (PRI_BYTE_OFFSET(IRQ_OFFSET(irq)) + ((irq < COMM_IRQ_BASE) ? \
+ (this_cpu_read(intcl_reg) + INTCL_PRTR) : (INTCG_base + INTCG_CIPRTR)))
+
+static DEFINE_SPINLOCK(setup_lock);
+static void setup_trigger_priority(unsigned long irq, unsigned long trigger,
+ unsigned long priority)
+{
+ unsigned int tmp;
+
+ spin_lock(&setup_lock);
+
+ /* setup trigger */
+ tmp = readl_relaxed(TRIG_BASE(irq)) & TRIG_VAL_MSK(irq);
+
+ writel_relaxed(tmp | TRIG_VAL(trigger, irq), TRIG_BASE(irq));
+
+ /* setup priority */
+ tmp = readl_relaxed(PRI_BASE(irq)) & PRI_VAL_MSK(irq);
+
+ writel_relaxed(tmp | PRI_VAL(priority, irq), PRI_BASE(irq));
+
+ spin_unlock(&setup_lock);
+}
+
static void csky_mpintc_handler(struct pt_regs *regs)
{
void __iomem *reg_base = this_cpu_read(intcl_reg);
@@ -52,6 +101,9 @@ static void csky_mpintc_enable(struct irq_data *d)
{
void __iomem *reg_base = this_cpu_read(intcl_reg);
+ setup_trigger_priority(d->hwirq, __trigger[d->hwirq],
+ __priority[d->hwirq]);
+
writel_relaxed(d->hwirq, reg_base + INTCL_SENR);
}
@@ -69,6 +121,28 @@ static void csky_mpintc_eoi(struct irq_data *d)
writel_relaxed(d->hwirq, reg_base + INTCL_CACR);
}
+static int csky_mpintc_set_type(struct irq_data *d, unsigned int type)
+{
+ switch (type & IRQ_TYPE_SENSE_MASK) {
+ case IRQ_TYPE_LEVEL_HIGH:
+ __trigger[d->hwirq] = 0;
+ break;
+ case IRQ_TYPE_LEVEL_LOW:
+ __trigger[d->hwirq] = 1;
+ break;
+ case IRQ_TYPE_EDGE_RISING:
+ __trigger[d->hwirq] = 2;
+ break;
+ case IRQ_TYPE_EDGE_FALLING:
+ __trigger[d->hwirq] = 3;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
#ifdef CONFIG_SMP
static int csky_irq_set_affinity(struct irq_data *d,
const struct cpumask *mask_val,
@@ -101,6 +175,7 @@ static struct irq_chip csky_irq_chip = {
.irq_eoi = csky_mpintc_eoi,
.irq_enable = csky_mpintc_enable,
.irq_disable = csky_mpintc_disable,
+ .irq_set_type = csky_mpintc_set_type,
#ifdef CONFIG_SMP
.irq_set_affinity = csky_irq_set_affinity,
#endif
@@ -121,9 +196,29 @@ static int csky_irqdomain_map(struct irq_domain *d, unsigned int irq,
return 0;
}
+static int csky_irq_domain_xlate_cells(struct irq_domain *d,
+ struct device_node *ctrlr, const u32 *intspec,
+ unsigned int intsize, unsigned long *out_hwirq,
+ unsigned int *out_type)
+{
+ if (WARN_ON(intsize < 1))
+ return -EINVAL;
+
+ *out_hwirq = intspec[0];
+ if (intsize > 1)
+ *out_type = intspec[1] & IRQ_TYPE_SENSE_MASK;
+ else
+ *out_type = IRQ_TYPE_NONE;
+
+ if (intsize > 2)
+ __priority[*out_hwirq] = intspec[2];
+
+ return 0;
+}
+
static const struct irq_domain_ops csky_irqdomain_ops = {
.map = csky_irqdomain_map,
- .xlate = irq_domain_xlate_onecell,
+ .xlate = csky_irq_domain_xlate_cells,
};
#ifdef CONFIG_SMP
@@ -157,6 +252,14 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent)
if (ret < 0)
nr_irq = INTC_IRQS;
+ __priority = kcalloc(nr_irq, sizeof(unsigned long), GFP_KERNEL);
+ if (__priority == NULL)
+ return -ENXIO;
+
+ __trigger = kcalloc(nr_irq, sizeof(unsigned long), GFP_KERNEL);
+ if (__trigger == NULL)
+ return -ENXIO;
+
if (INTCG_base == NULL) {
INTCG_base = ioremap(mfcr("cr<31, 14>"),
INTCL_SIZE*nr_cpu_ids + INTCG_SIZE);
--
2.7.4
From: Guo Ren <[email protected]>
Add trigger type and priority setting for csky,mpintc.
Changelog:
- change #interrupt-cells to <3>
Signed-off-by: Guo Ren <[email protected]>
Cc: Rob Herring <[email protected]>
---
.../bindings/interrupt-controller/csky,mpintc.txt | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt b/Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt
index ab921f1..dccd913 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt
+++ b/Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt
@@ -6,11 +6,18 @@ C-SKY Multi-processors Interrupt Controller is designed for ck807/ck810/ck860
SMP soc, and it also could be used in non-SMP system.
Interrupt number definition:
-
0-15 : software irq, and we use 15 as our IPI_IRQ.
16-31 : private irq, and we use 16 as the co-processor timer.
31-1024: common irq for soc ip.
+Interrupt triger mode:
+ IRQ_TYPE_LEVEL_HIGH (default)
+ IRQ_TYPE_LEVEL_LOW
+ IRQ_TYPE_EDGE_RISING
+ IRQ_TYPE_EDGE_FALLING
+
+Interrupt priority range: 0-255
+
=============================
intc node bindings definition
=============================
@@ -26,15 +33,21 @@ intc node bindings definition
- #interrupt-cells
Usage: required
Value type: <u32>
- Definition: must be <1>
+ Definition: <3>
- interrupt-controller:
Usage: required
-Examples:
+Examples: ("interrupts = <irq_num IRQ_TYPE_XXX priority>")
---------
intc: interrupt-controller {
compatible = "csky,mpintc";
- #interrupt-cells = <1>;
+ #interrupt-cells = <3>;
interrupt-controller;
};
+
+ device: device-example {
+ ...
+ interrupts = <34 IRQ_TYPE_EDGE_RISING 254>;
+ interrupt-parent = <&intc>;
+ };
--
2.7.4
From: Guo Ren <[email protected]>
The bug is from commit 2054f4af1957 ("csky: bugfix gdb coredump error.")
We change the ELF_NGREG to ELF_NGREG - 2 to fit gdb&gcc define, but forgot
modify ptrace regset.
Now coredump use ELF_NRGEG to parse GPRs and ptrace use pt_regs_regset, so
there are two different reg_sets for userspace.
Signed-off-by: Guo Ren <[email protected]>
---
arch/csky/kernel/ptrace.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/csky/kernel/ptrace.c b/arch/csky/kernel/ptrace.c
index 57f1afe..f2f12ff 100644
--- a/arch/csky/kernel/ptrace.c
+++ b/arch/csky/kernel/ptrace.c
@@ -8,6 +8,7 @@
#include <linux/ptrace.h>
#include <linux/regset.h>
#include <linux/sched.h>
+#include <linux/sched/task_stack.h>
#include <linux/signal.h>
#include <linux/smp.h>
#include <linux/uaccess.h>
@@ -159,7 +160,7 @@ static int fpr_set(struct task_struct *target,
static const struct user_regset csky_regsets[] = {
[REGSET_GPR] = {
.core_note_type = NT_PRSTATUS,
- .n = ELF_NGREG,
+ .n = sizeof(struct pt_regs) / sizeof(u32),
.size = sizeof(u32),
.align = sizeof(u32),
.get = &gpr_get,
--
2.7.4
From: Guo Ren <[email protected]>
Add csky,support-vector-irq for irq-csky-apb-intc.
Signed-off-by: Guo Ren <[email protected]>
---
.../devicetree/bindings/interrupt-controller/csky,apb-intc.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt b/Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt
index 63bc9dc..0f9fa88 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt
+++ b/Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt
@@ -37,6 +37,9 @@ intc node bindings definition
- csky,support-pulse-signal:
Usage: select
Description: to support pulse signal flag
+ - csky,support-vector-irq:
+ Usage: select
+ Description: to support vector irq mode
Examples:
---------
--
2.7.4
From: Guo Ren <[email protected]>
Use task_stack_page instead of p->stack to get stack. Follow the coding
convention style. Also for init_stack, the same with other archs.
Signed-off-by: Guo Ren <[email protected]>
---
arch/csky/include/asm/processor.h | 4 ++--
arch/csky/kernel/smp.c | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/csky/include/asm/processor.h b/arch/csky/include/asm/processor.h
index 8f45481..21e0bd5 100644
--- a/arch/csky/include/asm/processor.h
+++ b/arch/csky/include/asm/processor.h
@@ -49,7 +49,7 @@ struct thread_struct {
};
#define INIT_THREAD { \
- .ksp = (unsigned long) init_thread_union.stack + THREAD_SIZE, \
+ .ksp = sizeof(init_stack) + (unsigned long) &init_stack, \
.sr = DEFAULT_PSR_VALUE, \
}
@@ -95,7 +95,7 @@ unsigned long get_wchan(struct task_struct *p);
#define KSTK_ESP(tsk) (task_pt_regs(tsk)->usp)
#define task_pt_regs(p) \
- ((struct pt_regs *)(THREAD_SIZE + p->stack) - 1)
+ ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
#define cpu_relax() barrier()
diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c
index ddc4dd7..b07a534 100644
--- a/arch/csky/kernel/smp.c
+++ b/arch/csky/kernel/smp.c
@@ -160,7 +160,8 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
{
unsigned long mask = 1 << cpu;
- secondary_stack = (unsigned int)tidle->stack + THREAD_SIZE - 8;
+ secondary_stack =
+ (unsigned int) task_stack_page(tidle) + THREAD_SIZE - 8;
secondary_hint = mfcr("cr31");
secondary_ccr = mfcr("cr18");
--
2.7.4
From: Guo Ren <[email protected]>
Some socs don't provide pending registers, so we must make the interrupt
controller working at vector mode. Add csky,support-vector-irq to
support this mode in dts.
Signed-off-by: Guo Ren <[email protected]>
---
drivers/irqchip/irq-csky-apb-intc.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/irqchip/irq-csky-apb-intc.c b/drivers/irqchip/irq-csky-apb-intc.c
index ae4c59b..14ef206 100644
--- a/drivers/irqchip/irq-csky-apb-intc.c
+++ b/drivers/irqchip/irq-csky-apb-intc.c
@@ -302,10 +302,17 @@ static void ck_irq_handler(struct pt_regs *regs)
pr_err("%s: none irq pending!\n", __func__);
}
+static void ck_vec_irq_handler(struct pt_regs *regs)
+{
+ unsigned long vector = (mfcr("psr") >> 16) & 0xff;
+
+ handle_domain_irq(root_domain, vector - 32, regs);
+}
+
static int __init
ck_intc_init(struct device_node *node, struct device_node *parent)
{
- int ret;
+ int ret, i;
ret = ck_intc_init_comm(node, parent);
if (ret)
@@ -323,7 +330,16 @@ ck_intc_init(struct device_node *node, struct device_node *parent)
setup_irq_channel(0x00010203, reg_base + CK_INTC_SOURCE);
- set_handle_irq(ck_irq_handler);
+ if (of_find_property(node, "csky,support-vector-irq", NULL)) {
+ set_handle_irq(ck_vec_irq_handler);
+
+ for (i = 32; i < 128; i++)
+ VEC_INIT(i, csky_irq);
+
+ writel(0, reg_base + CK_INTC_ICR);
+ } else {
+ set_handle_irq(ck_irq_handler);
+ }
return 0;
}
--
2.7.4
On Tue, 29 Jan 2019 12:24:20 +0000,
[email protected] wrote:
>
> From: Guo Ren <[email protected]>
>
> C-SKY dh7k SOC use simple APB interrupt controller and most of driver's
> implementation codes could be reused in csky-apb-intc.c. So merge them
> together.
>
> Signed-off-by: Guo Ren <[email protected]>
> ---
> drivers/irqchip/irq-csky-apb-intc.c | 95 +++++++++++++++++++++++++++++++++----
> 1 file changed, 85 insertions(+), 10 deletions(-)
>
So this patch series seems to contain both core c-sky stuff as well as
irqchip updates.
Please send an irqchip series that I can take standalone. If there are
dependencies, please state so in the cover letter, and we'll work out
something. Please make sure that everybody gets at least the cover
letter (I didn't receive one for this series).
Thanks,
M.
--
Jazz is not dead, it just smell funny.
On Thu, Feb 14, 2019 at 02:03:52PM +0000, Marc Zyngier wrote:
> On Tue, 29 Jan 2019 12:24:20 +0000,
> [email protected] wrote:
> >
> > From: Guo Ren <[email protected]>
> >
> > C-SKY dh7k SOC use simple APB interrupt controller and most of driver's
> > implementation codes could be reused in csky-apb-intc.c. So merge them
> > together.
> >
> > Signed-off-by: Guo Ren <[email protected]>
> > ---
> > drivers/irqchip/irq-csky-apb-intc.c | 95 +++++++++++++++++++++++++++++++++----
> > 1 file changed, 85 insertions(+), 10 deletions(-)
> >
>
> So this patch series seems to contain both core c-sky stuff as well as
> irqchip updates.
There are no dependencies on core-csky stuff and irqchip in this patch
series.
>
> Please send an irqchip series that I can take standalone.
Ok, I'll send a standalone irqchip series later.
> If there are
> dependencies, please state so in the cover letter, and we'll work out
> something. Please make sure that everybody gets at least the cover
> letter (I didn't receive one for this series).
I guess you are worried about:
+#include <asm/traps.h>
...
+
+ for (i = 32; i < 128; i++)
+ VEC_INIT(i, csky_irq);
+
In arch/csky, 32 - 127 trap entries are reserved for vector irqs. But
the mode of vector irq need irq controller to support, or csky cpu will
use trap 10 for all interrupts and get irq-num from interrupt controller.
Some interrupt controllers don't support trap 10, so they need working
at vector mode and get irq-num by mfcr("psr").
Here we just use csky_irq instead of csky_trap which initiated by arch/csky.
Best Regards
Guo Ren