source: rtems/c/src/lib/libbsp/powerpc/mvme3100/irq/irq_init.c @ b599faa

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