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