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 | * Enhanced by Jay Kulpinski <jskulpin@eng01.gdds.com> |
---|
9 | * to make it valid for MVME2300 Motorola boards. |
---|
10 | * |
---|
11 | * Till Straumann <strauman@slac.stanford.edu>, 12/20/2001: |
---|
12 | * Use the new interface to openpic_init |
---|
13 | * |
---|
14 | * Adapted for the mvme3100 BSP by T. Straumann, 2007. |
---|
15 | * |
---|
16 | * The license and distribution terms for this file may be |
---|
17 | * found in the file LICENSE in this distribution or at |
---|
18 | * http://www.rtems.org/license/LICENSE. |
---|
19 | */ |
---|
20 | |
---|
21 | #include <libcpu/io.h> |
---|
22 | #include <bsp/pci.h> |
---|
23 | #include <bsp/openpic.h> |
---|
24 | #include <bsp/irq.h> |
---|
25 | #include <bsp.h> |
---|
26 | #include <bsp/vectors.h> |
---|
27 | #include <rtems/bspIo.h> |
---|
28 | |
---|
29 | static void nop_func(void *unused) |
---|
30 | { |
---|
31 | printk("Unhandled IRQ\n"); |
---|
32 | } |
---|
33 | |
---|
34 | static rtems_irq_connect_data rtemsIrq[BSP_IRQ_NUMBER]; |
---|
35 | static rtems_irq_global_settings initial_config; |
---|
36 | static rtems_irq_connect_data defaultIrq = { |
---|
37 | /* vectorIdex, hdl , handle , on , off , isOn */ |
---|
38 | 0, nop_func , NULL , 0 , 0 , 0 |
---|
39 | }; |
---|
40 | |
---|
41 | static rtems_irq_prio irqPrioTable[BSP_IRQ_NUMBER]={ |
---|
42 | /* |
---|
43 | * actual priorities for interrupt : |
---|
44 | * 0 means that only current interrupt is masked |
---|
45 | * 255 means all other interrupts are masked |
---|
46 | */ |
---|
47 | /* |
---|
48 | * PCI Interrupts |
---|
49 | */ |
---|
50 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, /* for raven prio 0 means unactive... */ |
---|
51 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, /* for raven prio 0 means unactive... */ |
---|
52 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, /* for raven prio 0 means unactive... */ |
---|
53 | /* |
---|
54 | * Processor exceptions handled as interrupts |
---|
55 | */ |
---|
56 | 0 |
---|
57 | }; |
---|
58 | |
---|
59 | /* |
---|
60 | * This code assumes the exceptions management setup has already |
---|
61 | * been done. We just need to replace the exceptions that will |
---|
62 | * be handled like interrupt. On mcp750/mpc750 and many PPC processors |
---|
63 | * this means the decrementer exception and the external exception. |
---|
64 | */ |
---|
65 | void BSP_rtems_irq_mng_init(unsigned cpuId) |
---|
66 | { |
---|
67 | /* We should really have a way to find the number of sources |
---|
68 | * the driver will use so that the size of the polarity-array |
---|
69 | * matches the driver's idea of it. |
---|
70 | */ |
---|
71 | unsigned char pol[56]; |
---|
72 | int i; |
---|
73 | |
---|
74 | /* Note: The openpic driver initializes only as many |
---|
75 | * 'pic-external' interrupt sources as reported |
---|
76 | * by the feature register. |
---|
77 | * The 8540's openpic supports 12 core-external |
---|
78 | * and 23 core-internal (both of these groups |
---|
79 | * are external to the PIC, i.e., 'pic-external') |
---|
80 | * interrupts but between the corresponding |
---|
81 | * banks of vector/priority registers there is |
---|
82 | * a gap leaving space for 4 (unsupported) irqs. |
---|
83 | * The driver, not knowing of this gap, would |
---|
84 | * initialize the 12 core-external sources |
---|
85 | * followed by 4 unsupported sources and 19 |
---|
86 | * core-internal sources thus leaving the last |
---|
87 | * four core-internal sources uninitialized. |
---|
88 | * Luckily, the feature register reports |
---|
89 | * too many sources: |
---|
90 | * - the 4 IPI plus 4 timer plus 4 messaging |
---|
91 | * sources are included with the count |
---|
92 | * - there are unused core-internal sources 24..32 |
---|
93 | * which are also supported by the pic |
---|
94 | * bringing the reported number of sources to |
---|
95 | * a count of 56 (12+32+4+4+4) which is enough |
---|
96 | * so that all pic-external sources are covered |
---|
97 | * and initialized. |
---|
98 | * |
---|
99 | * NOTE: All core-internal sources are active-high. |
---|
100 | * The manual says that setting the polarity |
---|
101 | * to 'low/0' will disable the interrupt but |
---|
102 | * I found this not to be true: on the device |
---|
103 | * I tested the interrupt was asserted hard. |
---|
104 | */ |
---|
105 | |
---|
106 | /* core-external sources on the mvme3100 are active-low, |
---|
107 | * core-internal sources are active high. |
---|
108 | */ |
---|
109 | for (i=0; i<BSP_EXT_IRQ_NUMBER; i++) |
---|
110 | pol[i]=0; |
---|
111 | for (i=BSP_EXT_IRQ_NUMBER; i< BSP_EXT_IRQ_NUMBER + BSP_CORE_IRQ_NUMBER; i++) |
---|
112 | pol[i]=1; |
---|
113 | |
---|
114 | openpic_init(1, pol, 0, 0, 0, 0); |
---|
115 | |
---|
116 | /* |
---|
117 | * re-init the rtemsIrq table |
---|
118 | */ |
---|
119 | for (i = 0; i < BSP_IRQ_NUMBER; i++) { |
---|
120 | rtemsIrq[i] = defaultIrq; |
---|
121 | rtemsIrq[i].name = i; |
---|
122 | } |
---|
123 | /* |
---|
124 | * Init initial Interrupt management config |
---|
125 | */ |
---|
126 | initial_config.irqNb = BSP_IRQ_NUMBER; |
---|
127 | initial_config.defaultEntry = defaultIrq; |
---|
128 | initial_config.irqHdlTbl = rtemsIrq; |
---|
129 | initial_config.irqBase = BSP_LOWEST_OFFSET; |
---|
130 | initial_config.irqPrioTbl = irqPrioTable; |
---|
131 | |
---|
132 | if (!BSP_rtems_irq_mngt_set(&initial_config)) { |
---|
133 | /* |
---|
134 | * put something here that will show the failure... |
---|
135 | */ |
---|
136 | rtems_panic("Unable to initialize RTEMS interrupt Management!!! System locked\n"); |
---|
137 | } |
---|
138 | } |
---|