summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/dmv177/console/conscfg.c
blob: 1f5bae0da2176800e6150a9577902945e1c3a4e4 (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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
/*
 *  This file contains the TTY driver table for the DY-4 DMV177.
 *
 *  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 <bsp.h>

#include <libchip/serial.h>
#include <libchip/mc68681.h>
#include <libchip/z85c30.h>

/*
 * Configuration specific probe routines
 *
 *
 * NOTE:  There are no DMV177 specific configuration routines.  These
 *        routines could be written to dynamically determine which serial
 *        ports are on a board.  Debugging this would require access to
 *        multiple board models.
 */

/* NONE CURRENTLY PROVIDED */

/*
 * The following table configures the console drivers used in this BSP.
 *
 * The first entry which, when probed, is available, will be named /dev/console,
 * all others being given the name indicated.
 */

mc68681_baud_t 
  dmv177_mc68681_baud_table[4][RTEMS_TERMIOS_NUMBER_BAUD_RATES] = {
  { /* ACR[7] = 0, X = 0 */
    MC68681_BAUD_NOT_VALID,    /* B0 */
    MC68681_BAUD_NOT_VALID,    /* B50 */
    0x01,                      /* B75 */
    MC68681_BAUD_NOT_VALID,    /* B110 */
    0x03,                      /* B134 */
    MC68681_BAUD_NOT_VALID,    /* B150 */
    0x04,                      /* B200 */
    MC68681_BAUD_NOT_VALID,    /* B300 */
    MC68681_BAUD_NOT_VALID,    /* B600 */
    MC68681_BAUD_NOT_VALID,    /* B1200 */
    MC68681_BAUD_NOT_VALID,    /* B1800 */
    MC68681_BAUD_NOT_VALID,    /* B2400 */
    0x0A,                      /* B4800 */
    MC68681_BAUD_NOT_VALID,    /* B9600 */
    MC68681_BAUD_NOT_VALID,    /* B19200 */
    MC68681_BAUD_NOT_VALID,    /* B38400 */
    MC68681_BAUD_NOT_VALID,    /* B57600 */
    MC68681_BAUD_NOT_VALID,    /* B115200 */
    MC68681_BAUD_NOT_VALID,    /* B230400 */
    MC68681_BAUD_NOT_VALID     /* B460800 */
  },
  { /* ACR[7] = 1, X = 0 */
    MC68681_BAUD_NOT_VALID,    /* B0 */
    0x00,                      /* B50 */
    0x01,                      /* B75 */
    MC68681_BAUD_NOT_VALID,    /* B110 */
    MC68681_BAUD_NOT_VALID,    /* B134 */
    MC68681_BAUD_NOT_VALID,    /* B150 */
    0x04,                      /* B200 */
    MC68681_BAUD_NOT_VALID,    /* B300 */
    MC68681_BAUD_NOT_VALID,    /* B600 */
    0x0A,                      /* B1200 */
    MC68681_BAUD_NOT_VALID,    /* B1800 */
    MC68681_BAUD_NOT_VALID,    /* B2400 */
    MC68681_BAUD_NOT_VALID,    /* B4800 */
    MC68681_BAUD_NOT_VALID,    /* B9600 */
    MC68681_BAUD_NOT_VALID,    /* B19200 */
    MC68681_BAUD_NOT_VALID,    /* B38400 */
    MC68681_BAUD_NOT_VALID,    /* B57600 */
    MC68681_BAUD_NOT_VALID,    /* B115200 */
    MC68681_BAUD_NOT_VALID,    /* B230400 */
    MC68681_BAUD_NOT_VALID     /* B460800 */
  },
  { /* ACR[7] = 0, X = 1 */
    MC68681_BAUD_NOT_VALID,    /* B0 */
    0x00,                      /* B50 */
    0x01,                      /* B75 */
    MC68681_BAUD_NOT_VALID,    /* B110 */
    MC68681_BAUD_NOT_VALID,    /* B134 */
    MC68681_BAUD_NOT_VALID,    /* B150 */
    MC68681_BAUD_NOT_VALID,    /* B200 */
    MC68681_BAUD_NOT_VALID,    /* B300 */
    MC68681_BAUD_NOT_VALID,    /* B600 */
    MC68681_BAUD_NOT_VALID,    /* B1200 */
    MC68681_BAUD_NOT_VALID,    /* B1800 */
    0x04,                      /* B2400 */
    MC68681_BAUD_NOT_VALID,    /* B4800 */
    0x05,                      /* B9600 */
    0x06,                      /* B19200 */
    0x07,                      /* B38400 */
    MC68681_BAUD_NOT_VALID,    /* B57600 */
    MC68681_BAUD_NOT_VALID,    /* B115200 */
    MC68681_BAUD_NOT_VALID,    /* B230400 */
    MC68681_BAUD_NOT_VALID     /* B460800 */
  },
  { /* ACR[7] = 1, X = 1 */
    MC68681_BAUD_NOT_VALID,    /* B0 */
    MC68681_BAUD_NOT_VALID,    /* B50 */
    0x01,                      /* B75 */
    MC68681_BAUD_NOT_VALID,    /* B110 */
    0x03,                      /* B134 */
    MC68681_BAUD_NOT_VALID,    /* B150 */
    MC68681_BAUD_NOT_VALID,    /* B200 */
    MC68681_BAUD_NOT_VALID,    /* B300 */
    MC68681_BAUD_NOT_VALID,    /* B600 */
    MC68681_BAUD_NOT_VALID,    /* B1200 */
    MC68681_BAUD_NOT_VALID,    /* B1800 */
    0x04,                      /* B2400 */
    0x0A,                      /* B4800 */
    0x05,                      /* B9600 */
    0x06,                      /* B19200 */
    0x07,                      /* B38400 */
    MC68681_BAUD_NOT_VALID,    /* B57600 */
    MC68681_BAUD_NOT_VALID,    /* B115200 */
    MC68681_BAUD_NOT_VALID,    /* B230400 */
    MC68681_BAUD_NOT_VALID     /* B460800 */
  },
};

#define MC68681_PORT_CONFIG  \
  (MC68681_DATA_BAUD_RATE_SET_1|MC68681_XBRG_ENABLED) 

/*
 *  Based on BSP configuration information decide whether to do polling IO
 *  or interrupt driven IO.
 */

#if (CONSOLE_USE_INTERRUPTS)
#define MC68681_FUNCTIONS &mc68681_fns
#define Z85C30_FUNCTIONS  &z85c30_fns
#else
#define MC68681_FUNCTIONS &mc68681_fns_polled
#define Z85C30_FUNCTIONS  &z85c30_fns_polled
#endif

boolean dmv177_z85c30_probe(int minor);

console_tbl	Console_Port_Tbl[] = {
#if (0)
#endif
	{
		"/dev/com0",			/* sDeviceName */
                SERIAL_MC68681,                 /* deviceType */
		MC68681_FUNCTIONS,		/* pDeviceFns */
		NULL,				/* deviceProbe */
		NULL,				/* pDeviceFlow */
		16,				/* ulMargin */
		8,				/* ulHysteresis */
		(void *)9600,	/* baud rate */	/* pDeviceParams */
		MC68681_ADDR,			/* ulCtrlPort1 */
		MC68681_PORT1_ADDR,		/* ulCtrlPort2 */
		MC68681_PORT_CONFIG,		/* ulDataPort */
		mc68681_get_register_8,         /* getRegister */
		mc68681_set_register_8,		/* setRegister */
		NULL, /* unused */		/* getData */
		NULL, /* unused */		/* setData */
                (unsigned32)dmv177_mc68681_baud_table, /* ulClock */
		DMV170_DUART_IRQ		/* ulIntVector */
	},
	{
		"/dev/com1",			/* sDeviceName */
                SERIAL_MC68681,                 /* deviceType */
		MC68681_FUNCTIONS,		/* pDeviceFns */
		NULL,				/* deviceProbe */
		NULL,				/* pDeviceFlow */
		16,				/* ulMargin */
		8,				/* ulHysteresis */
		(void *)9600,	/* baud rate */	/* pDeviceParams */
		MC68681_ADDR,			/* ulCtrlPort1 */
		MC68681_PORT2_ADDR,		/* ulCtrlPort2 */
		MC68681_PORT_CONFIG,		/* ulDataPort */
		mc68681_get_register_8,         /* getRegister */
		mc68681_set_register_8,		/* setRegister */
		NULL, /* unused */		/* getData */
		NULL, /* unused */		/* setData */
                (unsigned32)dmv177_mc68681_baud_table, /* ulClock */
		DMV170_DUART_IRQ		/* ulIntVector */
	},
	{
		"/dev/com3",			/* sDeviceName */
                SERIAL_Z85C30,                  /* deviceType */
		Z85C30_FUNCTIONS,		/* pDeviceFns */
		dmv177_z85c30_probe,		/* deviceProbe */
		NULL,				/* pDeviceFlow */
		16,				/* ulMargin */
		8,				/* ulHysteresis */
		(void *)9600,	/* baud rate */	/* pDeviceParams */
		Z85C30_CTRL_A,			/* ulCtrlPort1 */
		Z85C30_CTRL_A,			/* ulCtrlPort2 */
		0,				/* ulDataPort */
		z85c30_get_register,		/* getRegister */
		z85c30_set_register,		/* setRegister */
		NULL,				/* getData */
		NULL,				/* setData */
                0, /* filled in by probe */     /* ulClock */
		DMV170_SCC_IRQ			/* ulIntVector */
	},
	{
		"/dev/com4",			/* sDeviceName */
                SERIAL_Z85C30,                  /* deviceType */
		Z85C30_FUNCTIONS,		/* pDeviceFns */
		dmv177_z85c30_probe,		/* deviceProbe */
		NULL,				/* pDeviceFlow */
		16,				/* ulMargin */
		8,				/* ulHysteresis */
		(void *)9600,	/* baud rate */	/* pDeviceParams */
		Z85C30_CTRL_B,			/* ulCtrlPort1 */
		Z85C30_CTRL_A,			/* ulCtrlPort2 */
		0,				/* ulDataPort */
		z85c30_get_register,		/* getRegister */
		z85c30_set_register,		/* setRegister */
		NULL,				/* getData */
		NULL,				/* setData */
                0, /* filled in by probe */     /* ulClock */
		DMV170_SCC_IRQ			/* ulIntVector */
	}
};

/*
 *  Declare some information used by the console driver
 */

#define NUM_CONSOLE_PORTS (sizeof(Console_Port_Tbl)/sizeof(console_tbl))

unsigned long  Console_Port_Count = NUM_CONSOLE_PORTS;

console_data  Console_Port_Data[NUM_CONSOLE_PORTS];

rtems_device_minor_number  Console_Port_Minor;

boolean dmv177_z85c30_probe(int minor)
{
  volatile unsigned32 *dma_control_status_reg;

  /*
   *  Figure out the clock speed of the Z85C30 SCC
   */

  dma_control_status_reg = DMV170_DMA_CONTROL_STATUS_REG;

  if ( *dma_control_status_reg & DMV170_SCC_10MHZ )
    Console_Port_Tbl[minor].ulClock = Z85C30_CLOCK_10;
  else
    Console_Port_Tbl[minor].ulClock = Z85C30_CLOCK_2;

  return TRUE;
}