xref: /openbmc/linux/arch/mips/generic/irq.c (revision eed0eabd12ef061821cbfa20d903476e07645320)
1*eed0eabdSPaul Burton /*
2*eed0eabdSPaul Burton  * Copyright (C) 2016 Imagination Technologies
3*eed0eabdSPaul Burton  * Author: Paul Burton <paul.burton@imgtec.com>
4*eed0eabdSPaul Burton  *
5*eed0eabdSPaul Burton  * This program is free software; you can redistribute it and/or modify it
6*eed0eabdSPaul Burton  * under the terms of the GNU General Public License as published by the
7*eed0eabdSPaul Burton  * Free Software Foundation; either version 2 of the License, or (at your
8*eed0eabdSPaul Burton  * option) any later version.
9*eed0eabdSPaul Burton  */
10*eed0eabdSPaul Burton 
11*eed0eabdSPaul Burton #include <linux/clk.h>
12*eed0eabdSPaul Burton #include <linux/clk-provider.h>
13*eed0eabdSPaul Burton #include <linux/clocksource.h>
14*eed0eabdSPaul Burton #include <linux/init.h>
15*eed0eabdSPaul Burton #include <linux/irqchip/mips-gic.h>
16*eed0eabdSPaul Burton #include <linux/types.h>
17*eed0eabdSPaul Burton 
18*eed0eabdSPaul Burton #include <asm/irq.h>
19*eed0eabdSPaul Burton 
20*eed0eabdSPaul Burton int get_c0_fdc_int(void)
21*eed0eabdSPaul Burton {
22*eed0eabdSPaul Burton 	int mips_cpu_fdc_irq;
23*eed0eabdSPaul Burton 
24*eed0eabdSPaul Burton 	if (cpu_has_veic)
25*eed0eabdSPaul Burton 		panic("Unimplemented!");
26*eed0eabdSPaul Burton 	else if (gic_present)
27*eed0eabdSPaul Burton 		mips_cpu_fdc_irq = gic_get_c0_fdc_int();
28*eed0eabdSPaul Burton 	else if (cp0_fdc_irq >= 0)
29*eed0eabdSPaul Burton 		mips_cpu_fdc_irq = MIPS_CPU_IRQ_BASE + cp0_fdc_irq;
30*eed0eabdSPaul Burton 	else
31*eed0eabdSPaul Burton 		mips_cpu_fdc_irq = -1;
32*eed0eabdSPaul Burton 
33*eed0eabdSPaul Burton 	return mips_cpu_fdc_irq;
34*eed0eabdSPaul Burton }
35*eed0eabdSPaul Burton 
36*eed0eabdSPaul Burton int get_c0_perfcount_int(void)
37*eed0eabdSPaul Burton {
38*eed0eabdSPaul Burton 	int mips_cpu_perf_irq;
39*eed0eabdSPaul Burton 
40*eed0eabdSPaul Burton 	if (cpu_has_veic)
41*eed0eabdSPaul Burton 		panic("Unimplemented!");
42*eed0eabdSPaul Burton 	else if (gic_present)
43*eed0eabdSPaul Burton 		mips_cpu_perf_irq = gic_get_c0_perfcount_int();
44*eed0eabdSPaul Burton 	else if (cp0_perfcount_irq >= 0)
45*eed0eabdSPaul Burton 		mips_cpu_perf_irq = MIPS_CPU_IRQ_BASE + cp0_perfcount_irq;
46*eed0eabdSPaul Burton 	else
47*eed0eabdSPaul Burton 		mips_cpu_perf_irq = -1;
48*eed0eabdSPaul Burton 
49*eed0eabdSPaul Burton 	return mips_cpu_perf_irq;
50*eed0eabdSPaul Burton }
51*eed0eabdSPaul Burton 
52*eed0eabdSPaul Burton unsigned int get_c0_compare_int(void)
53*eed0eabdSPaul Burton {
54*eed0eabdSPaul Burton 	int mips_cpu_timer_irq;
55*eed0eabdSPaul Burton 
56*eed0eabdSPaul Burton 	if (cpu_has_veic)
57*eed0eabdSPaul Burton 		panic("Unimplemented!");
58*eed0eabdSPaul Burton 	else if (gic_present)
59*eed0eabdSPaul Burton 		mips_cpu_timer_irq = gic_get_c0_compare_int();
60*eed0eabdSPaul Burton 	else
61*eed0eabdSPaul Burton 		mips_cpu_timer_irq = MIPS_CPU_IRQ_BASE + cp0_compare_irq;
62*eed0eabdSPaul Burton 
63*eed0eabdSPaul Burton 	return mips_cpu_timer_irq;
64*eed0eabdSPaul Burton }
65