summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/dmv177/scv64/scv64.c
blob: e7e357d0d257556ff1a4c51591d78369cf35f456 (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
168
169
170
/*  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).
 *
 *  $Id$
 */

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

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

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

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

/*PAGE
 *
 *  SCV64_Initialize
 *
 *  This routine initializes the SCV64.
 */
void SCV64_Initialize() {
  SCV64->LIE = 0;
}

/*PAGE
 *
 *  SCV64_Generate_DUART_Interrupts
 *
 *  This sets the SCV64 to generate duart interrupts for
 *  the DMV177 board.
 */
void SCV64_Generate_DUART_Interrupts() {

  uint8_t   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;
}

/*PAGE
 *
 *  SCV64_Get_Interrupt
 *
 *  This routine returns the SCV64 status register.
 */
uint32_t   SCV64_Get_Interrupt()
{
  uint8_t   data;

  /*
   * Put the LIS data into the lower byte of the result
   */
  data = SCV64->LIS;

  return data;
}

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