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

4.11
Last change on this file since d4ab6611 was d4ab6611, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 15, 2014 at 7:21:20 PM

powerpc/score603e: Fix warnings

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * FPGA.c -- Bridge for second and subsequent generations
3 */
4
5/*
6 *  COPYRIGHT (c) 1989-2014.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.org/license/LICENSE.
12 */
13
14#include <bsp.h>
15#include <bsp/irq.h>
16#include <string.h>
17#include <fcntl.h>
18#include <assert.h>
19
20#include <rtems/libio.h>
21#include <rtems/libcsupport.h>
22#include <rtems/bspIo.h>
23
24/*
25 *  initialize FPGA
26 */
27void initialize_PCI_bridge (void)
28{
29  /* Note: Accept DINKs setup of the PCI Bridge and don't
30   *       change anything.
31   */
32}
33
34void set_irq_mask(
35  uint16_t         value
36)
37{
38  volatile uint16_t   *loc;
39
40  loc = (uint16_t*)SCORE603E_FPGA_MASK_DATA;
41
42  *loc = value;
43}
44
45uint16_t get_irq_mask( void )
46{
47  volatile uint16_t  *loc;
48  uint16_t            value;
49
50  loc =  (uint16_t*)SCORE603E_FPGA_MASK_DATA;
51
52  value = *loc;
53
54  return value;
55}
56
57void mask_irq(
58  uint16_t         irq_idx
59)
60{
61  uint16_t         value;
62  uint32_t         mask_idx = irq_idx;
63
64  value = get_irq_mask();
65
66#if (HAS_PMC_PSC8)
67  switch (irq_idx + Score_IRQ_First ) {
68    case SCORE603E_85C30_4_IRQ:
69    case SCORE603E_85C30_2_IRQ:
70    case SCORE603E_85C30_5_IRQ:
71    case SCORE603E_85C30_3_IRQ:
72      mask_idx = SCORE603E_PCI_IRQ_0 - Score_IRQ_First;
73      break;
74    default:
75      break;
76  }
77#endif
78
79  value |= (0x1 << mask_idx);
80  set_irq_mask( value );
81}
82
83void unmask_irq(
84  uint16_t         irq_idx
85)
86{
87  uint16_t         value;
88  uint32_t         mask_idx = irq_idx;
89
90  value = get_irq_mask();
91
92#if (HAS_PMC_PSC8)
93  switch (irq_idx + Score_IRQ_First ) {
94    case SCORE603E_85C30_4_IRQ:
95    case SCORE603E_85C30_2_IRQ:
96    case SCORE603E_85C30_5_IRQ:
97    case SCORE603E_85C30_3_IRQ:
98      mask_idx = SCORE603E_PCI_IRQ_0 - Score_IRQ_First;
99      break;
100    default:
101      break;
102  }
103#endif
104
105  value &= (~(0x1 << mask_idx));
106  set_irq_mask( value );
107}
108
109void init_irq_data_register(void)
110{
111  uint32_t         index;
112  uint32_t         i;
113
114  set_irq_mask( 0xffff );
115
116  /*
117   * Clear any existing interupts from the vector data register.
118   */
119  for (i=0; i<20; i++) {
120    index =  (*SCORE603E_FPGA_VECT_DATA);
121    if ( (index&0x10) != 0x10 )
122      break;
123  }
124}
125
126uint16_t read_and_clear_PMC_irq(
127  uint16_t            irq
128)
129{
130  uint16_t   status_word = irq;
131
132  status_word = (*BSP_PMC_STATUS_ADDRESS);
133
134  return status_word;
135}
136
137bool Is_PMC_IRQ(
138  uint32_t           pmc_irq,
139  uint16_t           status_word
140)
141{
142  bool result = false;
143
144  switch(pmc_irq) {
145    case SCORE603E_85C30_4_IRQ:
146      result = Is_PMC_85C30_4_IRQ( status_word ) ? true : false;
147      break;
148    case SCORE603E_85C30_2_IRQ:
149      result = Is_PMC_85C30_2_IRQ( status_word ) ? true : false;
150      break;
151    case SCORE603E_85C30_5_IRQ:
152      result = Is_PMC_85C30_5_IRQ( status_word ) ? true : false;
153      break;
154    case SCORE603E_85C30_3_IRQ:
155      result = Is_PMC_85C30_3_IRQ( status_word ) ? true : false;
156      break;
157    default:
158      assert( 0 );
159      break;
160  }
161
162  return result;
163}
164
165uint16_t         read_and_clear_irq(void)
166{
167  uint16_t            irq;
168
169
170  irq = (*SCORE603E_FPGA_VECT_DATA);
171  Processor_Synchronize();
172  if ((irq & 0xffff0) != 0x10) {
173    printk( "read_and_clear_irq:: ERROR==>no irq data 0x%x\n", irq);
174    return (irq | 0x80);
175  }
176
177  irq &=0xf;
178  irq += Score_IRQ_First;
179  return irq;
180}
Note: See TracBrowser for help on using the repository browser.