1 | /* irq_init.c |
---|
2 | * |
---|
3 | * This file contains the implementation of rtems initialization |
---|
4 | * related to interrupt handling. |
---|
5 | * |
---|
6 | * CopyRight (C) 1999 valette@crf.canon.fr |
---|
7 | * |
---|
8 | * Modified and added support for the MVME5500. |
---|
9 | * Copyright 2003, 2004, 2005, Brookhaven National Laboratory and |
---|
10 | * Shuchen Kate Feng <feng1@bnl.gov> |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE |
---|
15 | * |
---|
16 | */ |
---|
17 | #include <libcpu/io.h> |
---|
18 | #include <libcpu/spr.h> |
---|
19 | #include <bsp/irq.h> |
---|
20 | #include <bsp.h> |
---|
21 | #include <libcpu/raw_exception.h> /* ASM_EXT_VECTOR, ASM_DEC_VECTOR ... */ |
---|
22 | /*#define TRACE_IRQ_INIT*/ |
---|
23 | |
---|
24 | /* |
---|
25 | * default on/off function |
---|
26 | */ |
---|
27 | static void nop_func(void){} |
---|
28 | /* |
---|
29 | * default isOn function |
---|
30 | */ |
---|
31 | static int not_connected(void) {return 0;} |
---|
32 | /* |
---|
33 | * default possible isOn function |
---|
34 | */ |
---|
35 | static int connected(void) {return 1;} |
---|
36 | |
---|
37 | static rtems_irq_connect_data rtemsIrq[BSP_IRQ_NUMBER]; |
---|
38 | static rtems_irq_global_settings initial_config; |
---|
39 | static rtems_irq_connect_data defaultIrq = { |
---|
40 | /* vectorIdex, hdl , handle , on , off , isOn */ |
---|
41 | 0, nop_func , NULL , nop_func , nop_func , not_connected |
---|
42 | }; |
---|
43 | |
---|
44 | rtems_irq_prio BSPirqPrioTable[BSP_PIC_IRQ_NUMBER]={ |
---|
45 | /* |
---|
46 | * This table is where the developers can change the levels of priority |
---|
47 | * based on the need of their applications. |
---|
48 | * |
---|
49 | * actual priorities for CPU MAIN and GPP interrupts (0-95) |
---|
50 | * |
---|
51 | * 0 means that only current interrupt is masked (lowest priority) |
---|
52 | * 255 is only used by bits 24, 25, 26 and 27 of the CPU high |
---|
53 | * interrupt Mask: (e.g. GPP7_0, GPP15_8, GPP23_16, GPP31_24). |
---|
54 | * The IRQs of those four bits are always enabled. When it's used, |
---|
55 | * the IRQ number is never listed in the dynamic picIsrTable[96]. |
---|
56 | * |
---|
57 | * The priorities of GPP interrupts were decided by their own |
---|
58 | * value set at BSPirqPrioTable. |
---|
59 | * |
---|
60 | */ |
---|
61 | /* CPU Main cause low interrupt */ |
---|
62 | /* 0-15 */ |
---|
63 | 0, 0, 0, 0, 0, 0, 0, 0, 64/*Timer*/, 0, 0, 0, 0, 0, 0, 0, |
---|
64 | /* 16-31 */ |
---|
65 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
66 | /* CPU Main cause high interrupt */ |
---|
67 | /* 32-47 */ |
---|
68 | 2/*10/100MHZ*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
69 | /* 48-63 */ |
---|
70 | 0, 0, 0, 0, 0, 0, 0, 0, |
---|
71 | 255 /*GPP0-7*/, 255/*GPP8-15*/, 255/*GPP16-23*/, 255/*GPP24-31*/, 0, 0, 0, 0, |
---|
72 | /* GPP interrupts */ |
---|
73 | /* GPP0-7 */ |
---|
74 | 1/*serial*/,0, 0, 0, 0, 0, 0, 0, |
---|
75 | /* GPP8-15 */ |
---|
76 | 47/*PMC1A*/,46/*PMC1B*/,45/*PMC1C*/,44/*PMC1D*/,30/*VME0*/, 29/*VME1*/,3,1, |
---|
77 | /* GPP16-23 */ |
---|
78 | 37/*PMC2A*/,36/*PMC2B*/,35/*PMC2C*/,34/*PMC2D*/,23/*1GHZ*/, 0,0,0, |
---|
79 | /* GPP24-31 */ |
---|
80 | 7/*watchdog*/, 0,0,0,0,0,0,0 |
---|
81 | }; |
---|
82 | |
---|
83 | /* |
---|
84 | * This code assumes the exceptions management setup has already |
---|
85 | * been done. We just need to replace the exceptions that will |
---|
86 | * be handled like interrupt. On MPC7455 and many PPC processors |
---|
87 | * this means the decrementer exception and the external exception. |
---|
88 | */ |
---|
89 | void BSP_rtems_irq_mng_init(unsigned cpuId) |
---|
90 | { |
---|
91 | int i; |
---|
92 | rtems_interrupt_level l; |
---|
93 | |
---|
94 | /* |
---|
95 | * First initialize the Interrupt management hardware |
---|
96 | */ |
---|
97 | #ifdef TRACE_IRQ_INIT |
---|
98 | printk("Initializing the interrupt controller of the GT64260\n"); |
---|
99 | #endif |
---|
100 | |
---|
101 | #ifdef TRACE_IRQ_INIT |
---|
102 | printk("Going to re-initialize the rtemsIrq table %d\n",BSP_IRQ_NUMBER); |
---|
103 | #endif |
---|
104 | /* |
---|
105 | * Initialize Rtems management interrupt table |
---|
106 | */ |
---|
107 | /* |
---|
108 | * re-init the rtemsIrq table |
---|
109 | */ |
---|
110 | for (i = 0; i < BSP_IRQ_NUMBER; i++) { |
---|
111 | rtemsIrq[i] = defaultIrq; |
---|
112 | rtemsIrq[i].name = i; |
---|
113 | } |
---|
114 | |
---|
115 | /* |
---|
116 | * Init initial Interrupt management config |
---|
117 | */ |
---|
118 | initial_config.irqNb = BSP_IRQ_NUMBER; |
---|
119 | initial_config.defaultEntry = defaultIrq; |
---|
120 | initial_config.irqHdlTbl = rtemsIrq; |
---|
121 | initial_config.irqBase = BSP_LOWEST_OFFSET; |
---|
122 | initial_config.irqPrioTbl = BSPirqPrioTable; |
---|
123 | |
---|
124 | #ifdef TRACE_IRQ_INIT |
---|
125 | printk("Going to setup irq mngt configuration\n"); |
---|
126 | #endif |
---|
127 | |
---|
128 | rtems_interrupt_disable(l); |
---|
129 | if (!BSP_rtems_irq_mngt_set(&initial_config)) { |
---|
130 | /* |
---|
131 | * put something here that will show the failure... |
---|
132 | */ |
---|
133 | BSP_panic("Unable to initialize RTEMS interrupt Management!!! System locked\n"); |
---|
134 | } |
---|
135 | #ifdef TRACE_IRQ_INIT |
---|
136 | printk("Done setup irq mngt configuration\n"); |
---|
137 | #endif |
---|
138 | |
---|
139 | /* I don't really understand why all sources are enable here... (T.S) */ |
---|
140 | for (i= BSP_MAIN_GPP7_0_IRQ; i <= BSP_MAIN_GPP31_24_IRQ; i++) |
---|
141 | BSP_enable_pic_irq(i); |
---|
142 | |
---|
143 | rtems_interrupt_enable(l); |
---|
144 | |
---|
145 | #ifdef TRACE_IRQ_INIT |
---|
146 | printk("RTEMS IRQ management is now operationnal\n"); |
---|
147 | #endif |
---|
148 | } |
---|