/* GT64260Int.c - GT64260 Interrupt controller support functions * * Copyright 2003, 2004, Brookhaven National Laboratory and * Shuchen Kate Feng * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution. * */ #include #include /* for printk */ #include "bsp/gtreg.h" #include "bsp/irq.h" extern rtems_irq_prio BSPirqPrioTable[BSP_MAIN_IRQ_NUMBER]; rtems_GTirq_masks GT_GPPirq_cache=0; rtems_GTirq_masks GT_MAINirqLO_cache=0, GT_MAINirqHI_cache=0; void BSP_GT64260INT_init() { /* Page 401, Table 598: * Comm Unit Arbiter Control register : * bit 10:GPP interrupts as level sensitive(1) or edge sensitive(0). * We set the GPP interrupts to be edge sensitive. * MOTload default is set as level sensitive(1). */ outl((inl(GT_CommUnitArb_Ctrl)& (~(1<<10))), GT_CommUnitArb_Ctrl); /* Initialize the interrupt related GT64260 registers */ outl( 0, GT_CPU_INT_MASK_LO); outl( 0, GT_CPU_INT_MASK_HI); outl( 0, GT_PCI0_INT_MASK_LO); outl( 0, GT_PCI0_INT_MASK_HI); outl( 0, GT_PCI1_INT_MASK_LO); outl( 0, GT_PCI1_INT_MASK_HI); outl( 0, GT_CPU_INT0_MASK); outl( 0, GT_CPU_INT1_MASK); outl( 0, GT_CPU_INT2_MASK); outl( 0, GT_CPU_INT3_MASK); outl(0, GT_GPP_Interrupt_Mask); outl( 0, GT_GPP_Value); outl( 0, GT_GPP_Interrupt_Cause); #if 0 printk("watchdog timer 0x%x\n",inl(0xb410)); #endif } static void UpdateMainIrqTbl(int irqNum) { int i=0, j, shifted=0; #ifdef SHOW_MORE_INIT_SETTINGS unsigned long val2, val1; val2 = (MainIrqInTbl>>32) & 0xffffffff; val1 = MainIrqInTbl&0xffffffff; printk("irqNum %d, MainIrqInTbl 0x%x%x\n", irqNum, val2, val1); printMainIrqTbl(); #endif /* If entry not in table*/ if ( !((unsigned long long)(1LLU << irqNum) & MainIrqInTbl)) { while ( mainIrqTbl[i]!=-1) { if (BSPirqPrioTable[irqNum]>BSPirqPrioTable[mainIrqTbl[i]]) { /* all other lower priority entries shifted right */ for (j=MainIrqTblPtr;j>i; j--) mainIrqTbl[j]=mainIrqTbl[j-1]; mainIrqTbl[i]=irqNum; shifted=1; break; } i++; } if (!shifted) mainIrqTbl[MainIrqTblPtr]=irqNum; MainIrqInTbl |= (unsigned long long)(1LLU << irqNum); MainIrqTblPtr++; } } static void CleanMainIrqTbl(int irqNum) { int i, j; if (((1LLU << irqNum) & MainIrqInTbl)) { /* If entry in table*/ for (i=0; i<64; i++) { if (mainIrqTbl[i]==irqNum) {/*remove it from the entry */ /* all other lower priority entries shifted left */ for (j=i;j