[f5e7b4c3] | 1 | /* FPGA.c -- Bridge for second and subsequent generations |
---|
[9c448e1] | 2 | * |
---|
[f5e7b4c3] | 3 | * COPYRIGHT (c) 1989-2001. |
---|
[9c448e1] | 4 | * On-Line Applications Research Corporation (OAR). |
---|
| 5 | * |
---|
| 6 | * The license and distribution terms for this file may in |
---|
| 7 | * the file LICENSE in this distribution or at |
---|
[b14e2f2] | 8 | * http://www.rtems.com/license/LICENSE. |
---|
[9c448e1] | 9 | * |
---|
[6128a4a] | 10 | * $Id: |
---|
[9c448e1] | 11 | */ |
---|
[9396d1e4] | 12 | |
---|
[9c448e1] | 13 | #include <bsp.h> |
---|
| 14 | #include <string.h> |
---|
| 15 | #include <fcntl.h> |
---|
| 16 | #include <assert.h> |
---|
| 17 | |
---|
[1ae05bf] | 18 | #include <rtems/libio.h> |
---|
| 19 | #include <rtems/libcsupport.h> |
---|
[50f93fb] | 20 | #include <rtems/bspIo.h> |
---|
[1ae05bf] | 21 | |
---|
[9c448e1] | 22 | /* |
---|
| 23 | * initialize FPGA |
---|
| 24 | */ |
---|
| 25 | void initialize_PCI_bridge () |
---|
| 26 | { |
---|
| 27 | #if (!SCORE603E_USE_DINK) |
---|
[dac4208] | 28 | uint16_t mask, shift, data; |
---|
[9c448e1] | 29 | |
---|
| 30 | shift = SCORE603E_85C30_0_IRQ - Score_IRQ_First; |
---|
| 31 | mask = 1 << shift; |
---|
| 32 | |
---|
| 33 | shift = SCORE603E_85C30_1_IRQ - Score_IRQ_First; |
---|
| 34 | mask = mask & (1 << shift); |
---|
| 35 | |
---|
| 36 | data = *SCORE603E_FPGA_MASK_DATA; |
---|
| 37 | data = ~mask; |
---|
| 38 | |
---|
| 39 | *SCORE603E_FPGA_MASK_DATA = data; |
---|
| 40 | #endif |
---|
| 41 | |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | void set_irq_mask( |
---|
[dac4208] | 45 | uint16_t value |
---|
[9c448e1] | 46 | ) |
---|
| 47 | { |
---|
[dac4208] | 48 | uint16_t *loc; |
---|
[9c448e1] | 49 | |
---|
[dac4208] | 50 | loc = (uint16_t*)SCORE603E_FPGA_MASK_DATA; |
---|
[9c448e1] | 51 | |
---|
| 52 | *loc = value; |
---|
| 53 | } |
---|
| 54 | |
---|
[dac4208] | 55 | uint16_t get_irq_mask() |
---|
[9c448e1] | 56 | { |
---|
[dac4208] | 57 | uint16_t *loc; |
---|
| 58 | uint16_t value; |
---|
[9c448e1] | 59 | |
---|
[dac4208] | 60 | loc = (uint16_t*)SCORE603E_FPGA_MASK_DATA; |
---|
[9c448e1] | 61 | |
---|
| 62 | value = *loc; |
---|
| 63 | |
---|
| 64 | return value; |
---|
| 65 | } |
---|
| 66 | |
---|
[6128a4a] | 67 | void unmask_irq( |
---|
[dac4208] | 68 | uint16_t irq_idx |
---|
[9c448e1] | 69 | ) |
---|
| 70 | { |
---|
[dac4208] | 71 | uint16_t value; |
---|
| 72 | uint32_t mask_idx = irq_idx; |
---|
[9c448e1] | 73 | |
---|
| 74 | value = get_irq_mask(); |
---|
| 75 | |
---|
| 76 | #if (HAS_PMC_PSC8) |
---|
| 77 | switch (irq_idx + Score_IRQ_First ) { |
---|
| 78 | case SCORE603E_85C30_4_IRQ: |
---|
| 79 | case SCORE603E_85C30_2_IRQ: |
---|
| 80 | case SCORE603E_85C30_5_IRQ: |
---|
| 81 | case SCORE603E_85C30_3_IRQ: |
---|
| 82 | mask_idx = SCORE603E_PCI_IRQ_0 - Score_IRQ_First; |
---|
| 83 | break; |
---|
| 84 | default: |
---|
| 85 | break; |
---|
| 86 | } |
---|
| 87 | #endif |
---|
| 88 | |
---|
[6128a4a] | 89 | value &= (~(0x1 << mask_idx)); |
---|
[9c448e1] | 90 | set_irq_mask( value ); |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | void init_irq_data_register() |
---|
| 94 | { |
---|
[dac4208] | 95 | uint32_t index; |
---|
| 96 | uint32_t i; |
---|
[9c448e1] | 97 | |
---|
| 98 | #if (SCORE603E_USE_DINK) |
---|
| 99 | set_irq_mask( 0xffff ); |
---|
| 100 | #endif |
---|
| 101 | |
---|
| 102 | /* |
---|
| 103 | * Clear any existing interupts from the vector data register. |
---|
| 104 | */ |
---|
| 105 | for (i=0; i<20; i++) { |
---|
| 106 | index = (*SCORE603E_FPGA_VECT_DATA); |
---|
| 107 | if ( (index&0x10) != 0x10 ) |
---|
| 108 | break; |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | |
---|
[dac4208] | 112 | uint16_t read_and_clear_PMC_irq( |
---|
| 113 | uint16_t irq |
---|
[6128a4a] | 114 | ) |
---|
[9c448e1] | 115 | { |
---|
[dac4208] | 116 | uint16_t status_word = irq; |
---|
[9c448e1] | 117 | |
---|
[f309cda] | 118 | status_word = (*BSP_PMC_STATUS_ADDRESS); |
---|
[9c448e1] | 119 | |
---|
| 120 | return status_word; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | rtems_boolean Is_PMC_IRQ( |
---|
[dac4208] | 124 | uint32_t pmc_irq, |
---|
| 125 | uint16_t status_word |
---|
[9c448e1] | 126 | ) |
---|
| 127 | { |
---|
| 128 | rtems_boolean result= FALSE; |
---|
| 129 | |
---|
| 130 | switch(pmc_irq) { |
---|
| 131 | case SCORE603E_85C30_4_IRQ: |
---|
| 132 | result = Is_PMC_85C30_4_IRQ( status_word ); |
---|
| 133 | break; |
---|
| 134 | case SCORE603E_85C30_2_IRQ: |
---|
| 135 | result = Is_PMC_85C30_2_IRQ( status_word ); |
---|
| 136 | break; |
---|
| 137 | case SCORE603E_85C30_5_IRQ: |
---|
| 138 | result = Is_PMC_85C30_5_IRQ( status_word ); |
---|
| 139 | break; |
---|
| 140 | case SCORE603E_85C30_3_IRQ: |
---|
| 141 | result = Is_PMC_85C30_3_IRQ( status_word ); |
---|
| 142 | break; |
---|
| 143 | default: |
---|
| 144 | assert( 0 ); |
---|
| 145 | break; |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | return result; |
---|
| 149 | } |
---|
| 150 | |
---|
[dac4208] | 151 | uint16_t read_and_clear_irq() |
---|
[9c448e1] | 152 | { |
---|
[dac4208] | 153 | uint16_t irq; |
---|
[9c448e1] | 154 | |
---|
| 155 | irq = (*SCORE603E_FPGA_VECT_DATA); |
---|
| 156 | |
---|
| 157 | if ((irq & 0xffff0) != 0x10) { |
---|
[50f93fb] | 158 | printk( "ERROR:: no irq data\n"); |
---|
[9c448e1] | 159 | return (irq | 0x80); |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | irq &=0xf; |
---|
| 163 | |
---|
| 164 | return irq; |
---|
| 165 | } |
---|