10 #include <linux/kernel.h>
13 #include <linux/module.h>
23 static
void __dispatch_internal_64(
void) __maybe_unused;
24 static
void __internal_irq_mask_32(
unsigned int irq) __maybe_unused;
25 static
void __internal_irq_mask_64(
unsigned int irq) __maybe_unused;
26 static
void __internal_irq_unmask_32(
unsigned int irq) __maybe_unused;
27 static
void __internal_irq_unmask_64(
unsigned int irq) __maybe_unused;
29 #ifndef BCMCPU_RUNTIME_DETECT
30 #ifdef CONFIG_BCM63XX_CPU_6328
31 #define irq_stat_reg PERF_IRQSTAT_6328_REG
32 #define irq_mask_reg PERF_IRQMASK_6328_REG
34 #define is_ext_irq_cascaded 1
35 #define ext_irq_start (BCM_6328_EXT_IRQ0 - IRQ_INTERNAL_BASE)
36 #define ext_irq_end (BCM_6328_EXT_IRQ3 - IRQ_INTERNAL_BASE)
37 #define ext_irq_count 4
38 #define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6328
39 #define ext_irq_cfg_reg2 0
41 #ifdef CONFIG_BCM63XX_CPU_6338
42 #define irq_stat_reg PERF_IRQSTAT_6338_REG
43 #define irq_mask_reg PERF_IRQMASK_6338_REG
45 #define is_ext_irq_cascaded 0
46 #define ext_irq_start 0
48 #define ext_irq_count 4
49 #define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6338
50 #define ext_irq_cfg_reg2 0
52 #ifdef CONFIG_BCM63XX_CPU_6345
53 #define irq_stat_reg PERF_IRQSTAT_6345_REG
54 #define irq_mask_reg PERF_IRQMASK_6345_REG
56 #define is_ext_irq_cascaded 0
57 #define ext_irq_start 0
59 #define ext_irq_count 4
60 #define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6345
61 #define ext_irq_cfg_reg2 0
63 #ifdef CONFIG_BCM63XX_CPU_6348
64 #define irq_stat_reg PERF_IRQSTAT_6348_REG
65 #define irq_mask_reg PERF_IRQMASK_6348_REG
67 #define is_ext_irq_cascaded 0
68 #define ext_irq_start 0
70 #define ext_irq_count 4
71 #define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6348
72 #define ext_irq_cfg_reg2 0
74 #ifdef CONFIG_BCM63XX_CPU_6358
75 #define irq_stat_reg PERF_IRQSTAT_6358_REG
76 #define irq_mask_reg PERF_IRQMASK_6358_REG
78 #define is_ext_irq_cascaded 1
79 #define ext_irq_start (BCM_6358_EXT_IRQ0 - IRQ_INTERNAL_BASE)
80 #define ext_irq_end (BCM_6358_EXT_IRQ3 - IRQ_INTERNAL_BASE)
81 #define ext_irq_count 4
82 #define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6358
83 #define ext_irq_cfg_reg2 0
85 #ifdef CONFIG_BCM63XX_CPU_6368
86 #define irq_stat_reg PERF_IRQSTAT_6368_REG
87 #define irq_mask_reg PERF_IRQMASK_6368_REG
89 #define is_ext_irq_cascaded 1
90 #define ext_irq_start (BCM_6368_EXT_IRQ0 - IRQ_INTERNAL_BASE)
91 #define ext_irq_end (BCM_6368_EXT_IRQ5 - IRQ_INTERNAL_BASE)
92 #define ext_irq_count 6
93 #define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6368
94 #define ext_irq_cfg_reg2 PERF_EXTIRQ_CFG_REG2_6368
98 #define dispatch_internal __dispatch_internal
99 #define internal_irq_mask __internal_irq_mask_32
100 #define internal_irq_unmask __internal_irq_unmask_32
102 #define dispatch_internal __dispatch_internal_64
103 #define internal_irq_mask __internal_irq_mask_64
104 #define internal_irq_unmask __internal_irq_unmask_64
107 #define irq_stat_addr (bcm63xx_regset_address(RSET_PERF) + irq_stat_reg)
108 #define irq_mask_addr (bcm63xx_regset_address(RSET_PERF) + irq_mask_reg)
110 static inline void bcm63xx_init_irq(
void)
116 static void (*dispatch_internal)(
void);
117 static int is_ext_irq_cascaded;
118 static unsigned int ext_irq_count;
119 static unsigned int ext_irq_start, ext_irq_end;
120 static unsigned int ext_irq_cfg_reg1, ext_irq_cfg_reg2;
121 static void (*internal_irq_mask)(
unsigned int irq);
122 static void (*internal_irq_unmask)(
unsigned int irq);
124 static void bcm63xx_init_irq(
void)
128 irq_stat_addr = bcm63xx_regset_address(
RSET_PERF);
129 irq_mask_addr = bcm63xx_regset_address(
RSET_PERF);
131 switch (bcm63xx_get_cpu_id()) {
137 is_ext_irq_cascaded = 1;
168 is_ext_irq_cascaded = 1;
178 is_ext_irq_cascaded = 1;
188 if (irq_bits == 32) {
200 static inline u32 get_ext_irq_perf_reg(
int irq)
203 return ext_irq_cfg_reg1;
204 return ext_irq_cfg_reg2;
207 static inline void handle_internal(
int intbit)
209 if (is_ext_irq_cascaded &&
210 intbit >= ext_irq_start && intbit <= ext_irq_end)
222 static void __dispatch_internal(
void)
236 if (pending & (1 << to_call)) {
237 handle_internal(to_call);
243 static void __dispatch_internal_64(
void)
257 if (pending & (1ull << to_call)) {
258 handle_internal(to_call);
278 if (!is_ext_irq_cascaded) {
295 static void __internal_irq_mask_32(
unsigned int irq)
304 static void __internal_irq_mask_64(
unsigned int irq)
309 mask &= ~(1ull << irq);
313 static void __internal_irq_unmask_32(
unsigned int irq)
322 static void __internal_irq_unmask_64(
unsigned int irq)
327 mask |= (1ull << irq);
331 static void bcm63xx_internal_irq_mask(
struct irq_data *
d)
336 static void bcm63xx_internal_irq_unmask(
struct irq_data *
d)
345 static void bcm63xx_external_irq_mask(
struct irq_data *
d)
350 regaddr = get_ext_irq_perf_reg(irq);
359 if (is_ext_irq_cascaded)
363 static void bcm63xx_external_irq_unmask(
struct irq_data *d)
368 regaddr = get_ext_irq_perf_reg(irq);
378 if (is_ext_irq_cascaded)
382 static void bcm63xx_external_irq_clear(
struct irq_data *d)
387 regaddr = get_ext_irq_perf_reg(irq);
398 static int bcm63xx_external_irq_set_type(
struct irq_data *d,
399 unsigned int flow_type)
403 int levelsense,
sense, bothedge;
410 levelsense = sense = bothedge = 0;
437 regaddr = get_ext_irq_perf_reg(irq);
441 switch (bcm63xx_get_cpu_id()) {
481 irqd_set_trigger_type(d, flow_type);
490 static struct irq_chip bcm63xx_internal_irq_chip = {
491 .name =
"bcm63xx_ipic",
492 .irq_mask = bcm63xx_internal_irq_mask,
493 .irq_unmask = bcm63xx_internal_irq_unmask,
496 static struct irq_chip bcm63xx_external_irq_chip = {
497 .name =
"bcm63xx_epic",
498 .irq_ack = bcm63xx_external_irq_clear,
500 .irq_mask = bcm63xx_external_irq_mask,
501 .irq_unmask = bcm63xx_external_irq_unmask,
503 .irq_set_type = bcm63xx_external_irq_set_type,
506 static struct irqaction cpu_ip2_cascade_action = {
508 .name =
"cascade_ip2",
512 static struct irqaction cpu_ext_cascade_action = {
514 .name =
"cascade_extirq",
525 irq_set_chip_and_handler(i, &bcm63xx_internal_irq_chip,
529 irq_set_chip_and_handler(i, &bcm63xx_external_irq_chip,
532 if (!is_ext_irq_cascaded) {
533 for (i = 3; i < 3 + ext_irq_count; ++
i)