summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/dmv177/scv64/scv64.c
blob: f1c2e1200de0dfe820807c658a9ed4db2b88f0f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*  scv64.c
 *
 *  This set of routines control the scv64 chip on the DMV177 board.
 *
 *
 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994, 1997.
 *  On-Line Applications Research Corporation (OAR).
 *  All rights assigned to U.S. Government, 1994.
 *
 *  $Id$
 */

#include <rtems.h>
#include <bsp.h>

typedef struct {
  /* DARF Registers */
  volatile rtems_unsigned32  DMALAR;             /* 0x00 */       
  volatile rtems_unsigned32  DMAVAR;             /* 0x04 */       
  volatile rtems_unsigned32  DMATC;              /* 0x08 */      
  volatile rtems_unsigned32  DCSR;               /* 0x0c */     
  volatile rtems_unsigned32  VMEBAR;             /* 0x10 */       
  volatile rtems_unsigned32  RXDATA;             /* 0x14 */       
  volatile rtems_unsigned32  RXADDR;             /* 0x18 */                           
  volatile rtems_unsigned32  RXCTL;              /* 0x1c */      
  volatile rtems_unsigned32  BUSSEL;             /* 0x20 */       
  volatile rtems_unsigned32  IVECT;              /* 0x24 */      
  volatile rtems_unsigned32  APBR;               /* 0x28 */     
  volatile rtems_unsigned32  TXDATA;             /* 0x2c */       
  volatile rtems_unsigned32  TXADDR;             /* 0x30 */       
  volatile rtems_unsigned32  TXCTL;              /* 0x34 */      
  volatile rtems_unsigned32  LMFIFO;             /* 0x38 */       
  volatile rtems_unsigned32  MODE;               /* 0x3c */     
  volatile rtems_unsigned32  SA64BAR;            /* 0x40 */        
  volatile rtems_unsigned32  MA64BAR;            /* 0x44 */
  volatile rtems_unsigned32  LAG;                /* 0x48 */
  volatile rtems_unsigned32  DMAVTC;             /* 0x4c */

  /* Reserved */
  volatile rtems_unsigned32  reserved_50_7F[12];

  /* ACC Registers */
  volatile rtems_unsigned8   STAT0_pad[3];       /* 0x80 */       
  volatile rtems_unsigned8   STAT0;                        
  volatile rtems_unsigned8   STAT1_pad[3];       /* 0x84 */       
  volatile rtems_unsigned8   STAT1;                        
  volatile rtems_unsigned8   GENCTL_pad[3];      /* 0x88 */        
  volatile rtems_unsigned8   GENCTL;                        
  volatile rtems_unsigned8   VINT_pad[3];        /* 0x8c */      
  volatile rtems_unsigned8   VINT;                        
  volatile rtems_unsigned8   VREQ_pad[3];        /* 0x90 */      
  volatile rtems_unsigned8   VREQ;                        
  volatile rtems_unsigned8   VARB_pad[3];        /* 0x94 */      
  volatile rtems_unsigned8   VARB;                        
  volatile rtems_unsigned8   ID_pad[3];          /* 0x98 */    
  volatile rtems_unsigned8   ID;                        
  volatile rtems_unsigned8   NA_pad[3];          /* 0x9c */    
  volatile rtems_unsigned8   NA;                        
  volatile rtems_unsigned8   _7IS_pad[3];        /* 0xa0 */      
  volatile rtems_unsigned8   _7IS;                        
  volatile rtems_unsigned8   LIS_pad[3];         /* 0xa4 */     
  volatile rtems_unsigned8   LIS;                        
  volatile rtems_unsigned8   UIE_pad[3];         /* 0xa8 */     
  volatile rtems_unsigned8   UIE;                        
  volatile rtems_unsigned8   LIE_pad[3];         /* 0xac */     
  volatile rtems_unsigned8   LIE;                        
  volatile rtems_unsigned8   VIE_pad[3];         /* 0xb0 */     
  volatile rtems_unsigned8   VIE;                        
  volatile rtems_unsigned8   IC10_pad[3];        /* 0xb4 */      
  volatile rtems_unsigned8   IC10;                        
  volatile rtems_unsigned8   IC32_pad[3];        /* 0xb8 */      
  volatile rtems_unsigned8   IC32;                        
  volatile rtems_unsigned8   IC54_pad[3];        /* 0xbc */      
  volatile rtems_unsigned8   IC54;                        
  /* Utility Registers */
  volatile rtems_unsigned32  MISC;
  volatile rtems_unsigned32  delay_line[3];
  volatile rtems_unsigned32  MBOX0;
  volatile rtems_unsigned32  MBOX1;
  volatile rtems_unsigned32  MBOX2;
  volatile rtems_unsigned32  MBOX3;
} SCV64_Registers;

/*
 * LIE Register
 */
#define LOCAL_INTERRUPT_ENABLE_0  0x01
#define LOCAL_INTERRUPT_ENABLE_1  0x02
#define LOCAL_INTERRUPT_ENABLE_2  0x04
#define LOCAL_INTERRUPT_ENABLE_3  0x08
#define LOCAL_INTERRUPT_ENABLE_4  0x10
#define LOCAL_INTERRUPT_ENABLE_5  0x20

/* 
 * IC54 Register
 */
#define AUTOVECTOR_5  0x80


/*
 * Set the registers pointer to the base address of the SCV64
 */
SCV64_Registers *SCV64 =  (void *)DMV170_SCV64_BASE_ADDRESS;

/*
 *  SCV64_Initialize
 *
 *  This routine initializes the SCV64.
 */
void SCV64_Initialize() {
  SCV64->LIE = 0;
}
  
/*
 *  SCV64_Generate_DUART_Interrupts
 *
 *  This sets the SCV64 to generate duart interrupts for
 *  the DMV177 board.
 */
void SCV64_Generate_DUART_Interrupts() {

  rtems_unsigned8 data;
 
  /*
   * Set Local Interrupt 5 enable
   */
  data = SCV64->LIE;
  data |= LOCAL_INTERRUPT_ENABLE_5;
  SCV64->LIE = data;

  /*
   * Set Autovector.
   */
  data = SCV64->IC54;
  data |= AUTOVECTOR_5;
  SCV64->IC54 = data;
}

/*
 *  SCV64_Get_Interrupt
 *
 *  This routine returns the SCV64 status register.
 */
rtems_unsigned32 SCV64_Get_Interrupt()
{
  rtems_unsigned8 data;
 
  /*
   * Put the LIS data into the lower byte of the result
   */
  data = SCV64->LIS;

  return data;
}

/*
 * SCV64_Get_Interrupt_Enable
 *
 * This routine returns the interrupt enable mask.
 */
rtems_unsigned32 SCV64_Get_Interrupt_Enable()
{
  /*
   * Return the set of interrupts enabled.
   */
  return SCV64->LIE;
}