0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <linux/interrupt.h>
0014 #include <linux/irqchip.h>
0015 #include <linux/of.h>
0016
0017 #include <asm/irq_cpu.h>
0018 #include <asm/mach-ath79/ath79.h>
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 static unsigned irq_wb_chan[8] = {
0031 -1, -1, -1, -1, -1, -1, -1, -1,
0032 };
0033
0034 asmlinkage void plat_irq_dispatch(void)
0035 {
0036 unsigned long pending;
0037 int irq;
0038
0039 pending = read_c0_status() & read_c0_cause() & ST0_IM;
0040
0041 if (!pending) {
0042 spurious_interrupt();
0043 return;
0044 }
0045
0046 pending >>= CAUSEB_IP;
0047 while (pending) {
0048 irq = fls(pending) - 1;
0049 if (irq < ARRAY_SIZE(irq_wb_chan) && irq_wb_chan[irq] != -1)
0050 ath79_ddr_wb_flush(irq_wb_chan[irq]);
0051 do_IRQ(MIPS_CPU_IRQ_BASE + irq);
0052 pending &= ~BIT(irq);
0053 }
0054 }
0055
0056 static int __init ar79_cpu_intc_of_init(
0057 struct device_node *node, struct device_node *parent)
0058 {
0059 int err, i, count;
0060
0061
0062 count = of_count_phandle_with_args(
0063 node, "qca,ddr-wb-channels", "#qca,ddr-wb-channel-cells");
0064
0065 for (i = 0; i < count; i++) {
0066 struct of_phandle_args args;
0067 u32 irq = i;
0068
0069 of_property_read_u32_index(
0070 node, "qca,ddr-wb-channel-interrupts", i, &irq);
0071 if (irq >= ARRAY_SIZE(irq_wb_chan))
0072 continue;
0073
0074 err = of_parse_phandle_with_args(
0075 node, "qca,ddr-wb-channels",
0076 "#qca,ddr-wb-channel-cells",
0077 i, &args);
0078 if (err)
0079 return err;
0080
0081 irq_wb_chan[irq] = args.args[0];
0082 }
0083
0084 return mips_cpu_irq_of_init(node, parent);
0085 }
0086 IRQCHIP_DECLARE(ar79_cpu_intc, "qca,ar7100-cpu-intc",
0087 ar79_cpu_intc_of_init);
0088
0089 void __init ath79_cpu_irq_init(unsigned irq_wb_chan2, unsigned irq_wb_chan3)
0090 {
0091 irq_wb_chan[2] = irq_wb_chan2;
0092 irq_wb_chan[3] = irq_wb_chan3;
0093 mips_cpu_irq_init();
0094 }