source: rtems/c/src/lib/libbsp/powerpc/score603e/irq/FPGA.c @ 50f93fb

4.104.114.84.9
Last change on this file since 50f93fb was 50f93fb, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 17, 2007 at 2:09:43 PM

2007-09-17 Joel Sherrill <joel.sherrill@…>

  • PCI_bus/universe.c, console/console.c, include/bsp.h, irq/FPGA.c, startup/bspstart.c, startup/genpvec.c, startup/spurious.c: Eliminate DEBUG_puts.
  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*  FPGA.c -- Bridge for second and subsequent generations
2 *
3 *  COPYRIGHT (c) 1989-2001.
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
8 *  http://www.rtems.com/license/LICENSE.
9 *
10 *  $Id:
11 */
12
13#include <bsp.h>
14#include <string.h>
15#include <fcntl.h>
16#include <assert.h>
17
18#include <rtems/libio.h>
19#include <rtems/libcsupport.h>
20#include <rtems/bspIo.h>
21
22/*
23 *  initialize FPGA
24 */
25void initialize_PCI_bridge ()
26{
27#if (!SCORE603E_USE_DINK)
28  uint16_t         mask, shift, data;
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
44void set_irq_mask(
45  uint16_t         value
46)
47{
48  uint16_t          *loc;
49
50  loc = (uint16_t*)SCORE603E_FPGA_MASK_DATA;
51
52  *loc = value;
53}
54
55uint16_t         get_irq_mask()
56{
57  uint16_t          *loc;
58  uint16_t          value;
59
60  loc =  (uint16_t*)SCORE603E_FPGA_MASK_DATA;
61
62  value = *loc;
63
64  return value;
65}
66
67void unmask_irq(
68  uint16_t         irq_idx
69)
70{
71  uint16_t         value;
72  uint32_t         mask_idx = irq_idx;
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
89  value &= (~(0x1 << mask_idx));
90  set_irq_mask( value );
91}
92
93void init_irq_data_register()
94{
95  uint32_t         index;
96  uint32_t         i;
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
112uint16_t         read_and_clear_PMC_irq(
113  uint16_t            irq
114)
115{
116  uint16_t            status_word = irq;
117
118  status_word = (*BSP_PMC_STATUS_ADDRESS);
119
120  return status_word;
121}
122
123rtems_boolean Is_PMC_IRQ(
124  uint32_t           pmc_irq,
125  uint16_t           status_word
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
151uint16_t         read_and_clear_irq()
152{
153  uint16_t            irq;
154
155  irq = (*SCORE603E_FPGA_VECT_DATA);
156
157  if ((irq & 0xffff0) != 0x10) {
158    printk( "ERROR:: no irq data\n");
159    return (irq | 0x80);
160  }
161
162  irq &=0xf;
163
164  return irq;
165}
Note: See TracBrowser for help on using the repository browser.