1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// io/serial/mips/atlas/atlas_serial.h
|
4 |
|
|
//
|
5 |
|
|
// MIPS Atlas Serial I/O definitions.
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
16 |
|
|
// version.
|
17 |
|
|
//
|
18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
19 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
20 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
21 |
|
|
// for more details.
|
22 |
|
|
//
|
23 |
|
|
// You should have received a copy of the GNU General Public License
|
24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
26 |
|
|
//
|
27 |
|
|
// As a special exception, if other files instantiate templates or use
|
28 |
|
|
// macros or inline functions from this file, or you compile this file
|
29 |
|
|
// and link it with other works to produce a work based on this file,
|
30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
31 |
|
|
// the GNU General Public License. However the source code for this file
|
32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
33 |
|
|
// General Public License v2.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
36 |
|
|
// on this file might be covered by the GNU General Public License.
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
//==========================================================================
|
40 |
|
|
//#####DESCRIPTIONBEGIN####
|
41 |
|
|
//
|
42 |
|
|
// Author(s): dmoseley, based on PowerPC driver by jskov
|
43 |
|
|
// Contributors:gthomas, jskov, dmoseley
|
44 |
|
|
// Date: 2000-06-23
|
45 |
|
|
// Purpose: Atlas Serial definitions
|
46 |
|
|
//####DESCRIPTIONEND####
|
47 |
|
|
//==========================================================================
|
48 |
|
|
|
49 |
|
|
// Description of serial ports on Atlas board
|
50 |
|
|
|
51 |
|
|
// Interrupt Enable Register
|
52 |
|
|
#define IER_RCV 0x01
|
53 |
|
|
#define IER_XMT 0x02
|
54 |
|
|
#define IER_LS 0x04
|
55 |
|
|
#define IER_MS 0x08
|
56 |
|
|
|
57 |
|
|
// Line Control Register
|
58 |
|
|
#define LCR_WL5 0x00 // Word length
|
59 |
|
|
#define LCR_WL6 0x01
|
60 |
|
|
#define LCR_WL7 0x02
|
61 |
|
|
#define LCR_WL8 0x03
|
62 |
|
|
#define LCR_SB1 0x00 // Number of stop bits
|
63 |
|
|
#define LCR_SB1_5 0x04 // 1.5 -> only valid with 5 bit words
|
64 |
|
|
#define LCR_SB2 0x04
|
65 |
|
|
#define LCR_PN 0x00 // Parity mode - none
|
66 |
|
|
#define LCR_PE 0x0C // Parity mode - even
|
67 |
|
|
#define LCR_PO 0x08 // Parity mode - odd
|
68 |
|
|
#define LCR_PM 0x28 // Forced "mark" parity
|
69 |
|
|
#define LCR_PS 0x38 // Forced "space" parity
|
70 |
|
|
#define LCR_DL 0x80 // Enable baud rate latch
|
71 |
|
|
|
72 |
|
|
// Line Status Register
|
73 |
|
|
#define LSR_RSR 0x01
|
74 |
|
|
#define LSR_THE 0x20
|
75 |
|
|
|
76 |
|
|
// Modem Control Register
|
77 |
|
|
#define MCR_DTR 0x01
|
78 |
|
|
#define MCR_RTS 0x02
|
79 |
|
|
#define MCR_INT 0x08 // Enable interrupts
|
80 |
|
|
|
81 |
|
|
// Interrupt status register
|
82 |
|
|
#define ISR_None 0x01
|
83 |
|
|
#define ISR_Rx_Line_Status 0x06
|
84 |
|
|
#define ISR_Rx_Avail 0x04
|
85 |
|
|
#define ISR_Rx_Char_Timeout 0x0C
|
86 |
|
|
#define ISR_Tx_Empty 0x02
|
87 |
|
|
#define IRS_Modem_Status 0x00
|
88 |
|
|
|
89 |
|
|
// FIFO control register
|
90 |
|
|
#define FCR_ENABLE 0x01
|
91 |
|
|
#define FCR_CLEAR_RCVR 0x02
|
92 |
|
|
#define FCR_CLEAR_XMIT 0x04
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
////////////////////////////////////////////////////////////
|
96 |
|
|
// Clean this up.
|
97 |
|
|
|
98 |
|
|
#define ATLAS_SER_16550_BASE_A 0xBF000900
|
99 |
|
|
#define SER_16550_BASE ATLAS_SER_16550_BASE_A
|
100 |
|
|
|
101 |
|
|
//-----------------------------------------------------------------------------
|
102 |
|
|
// Define the serial registers. The Atlas board is equipped with a 16550C
|
103 |
|
|
// serial chip.
|
104 |
|
|
#define SER_16550_RBR 0x00 // receiver buffer register, read, dlab = 0
|
105 |
|
|
#define SER_16550_THR 0x00 // transmitter holding register, write, dlab = 0
|
106 |
|
|
#define SER_16550_DLL 0x00 // divisor latch (LS), read/write, dlab = 1
|
107 |
|
|
#define SER_16550_IER 0x08 // interrupt enable register, read/write, dlab = 0
|
108 |
|
|
#define SER_16550_DLM 0x08 // divisor latch (MS), read/write, dlab = 1
|
109 |
|
|
#define SER_16550_IIR 0x10 // interrupt identification reg, read, dlab = 0
|
110 |
|
|
#define SER_16550_FCR 0x10 // fifo control register, write, dlab = 0
|
111 |
|
|
#define SER_16550_AFR 0x10 // alternate function reg, read/write, dlab = 1
|
112 |
|
|
#define SER_16550_LCR 0x18 // line control register, read/write
|
113 |
|
|
#define SER_16550_MCR 0x20 // modem control register, read/write
|
114 |
|
|
#define SER_16550_LSR 0x28 // line status register, read
|
115 |
|
|
#define SER_16550_MSR 0x30 // modem status register, read
|
116 |
|
|
#define SER_16550_SCR 0x38 // scratch pad register
|
117 |
|
|
|
118 |
|
|
// The interrupt enable register bits.
|
119 |
|
|
#define SIO_IER_ERDAI 0x01 // enable received data available irq
|
120 |
|
|
#define SIO_IER_ETHREI 0x02 // enable THR empty interrupt
|
121 |
|
|
#define SIO_IER_ELSI 0x04 // enable receiver line status irq
|
122 |
|
|
#define SIO_IER_EMSI 0x08 // enable modem status interrupt
|
123 |
|
|
|
124 |
|
|
// The interrupt identification register bits.
|
125 |
|
|
#define SIO_IIR_IP 0x01 // 0 if interrupt pending
|
126 |
|
|
#define SIO_IIR_ID_MASK 0x0e // mask for interrupt ID bits
|
127 |
|
|
|
128 |
|
|
// The line status register bits.
|
129 |
|
|
#define SIO_LSR_DR 0x01 // data ready
|
130 |
|
|
#define SIO_LSR_OE 0x02 // overrun error
|
131 |
|
|
#define SIO_LSR_PE 0x04 // parity error
|
132 |
|
|
#define SIO_LSR_FE 0x08 // framing error
|
133 |
|
|
#define SIO_LSR_BI 0x10 // break interrupt
|
134 |
|
|
#define SIO_LSR_THRE 0x20 // transmitter holding register empty
|
135 |
|
|
#define SIO_LSR_TEMT 0x40 // transmitter register empty
|
136 |
|
|
#define SIO_LSR_ERR 0x80 // any error condition
|
137 |
|
|
|
138 |
|
|
// The modem status register bits.
|
139 |
|
|
#define SIO_MSR_DCTS 0x01 // delta clear to send
|
140 |
|
|
#define SIO_MSR_DDSR 0x02 // delta data set ready
|
141 |
|
|
#define SIO_MSR_TERI 0x04 // trailing edge ring indicator
|
142 |
|
|
#define SIO_MSR_DDCD 0x08 // delta data carrier detect
|
143 |
|
|
#define SIO_MSR_CTS 0x10 // clear to send
|
144 |
|
|
#define SIO_MSR_DSR 0x20 // data set ready
|
145 |
|
|
#define SIO_MSR_RI 0x40 // ring indicator
|
146 |
|
|
#define SIO_MSR_DCD 0x80 // data carrier detect
|
147 |
|
|
|
148 |
|
|
// The line control register bits.
|
149 |
|
|
#define SIO_LCR_WLS0 0x01 // word length select bit 0
|
150 |
|
|
#define SIO_LCR_WLS1 0x02 // word length select bit 1
|
151 |
|
|
#define SIO_LCR_STB 0x04 // number of stop bits
|
152 |
|
|
#define SIO_LCR_PEN 0x08 // parity enable
|
153 |
|
|
#define SIO_LCR_EPS 0x10 // even parity select
|
154 |
|
|
#define SIO_LCR_SP 0x20 // stick parity
|
155 |
|
|
#define SIO_LCR_SB 0x40 // set break
|
156 |
|
|
#define SIO_LCR_DLAB 0x80 // divisor latch access bit
|
157 |
|
|
|
158 |
|
|
// The FIFO control register
|
159 |
|
|
#define SIO_FCR_FCR0 0x01 // enable xmit and rcvr fifos
|
160 |
|
|
#define SIO_FCR_FCR1 0x02 // clear RCVR FIFO
|
161 |
|
|
#define SIO_FCR_FCR2 0x04 // clear XMIT FIFO
|
162 |
|
|
/////////////////////////////////////////
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
static unsigned char select_word_length[] = {
|
166 |
|
|
LCR_WL5, // 5 bits / word (char)
|
167 |
|
|
LCR_WL6,
|
168 |
|
|
LCR_WL7,
|
169 |
|
|
LCR_WL8
|
170 |
|
|
};
|
171 |
|
|
|
172 |
|
|
static unsigned char select_stop_bits[] = {
|
173 |
|
|
0,
|
174 |
|
|
LCR_SB1, // 1 stop bit
|
175 |
|
|
LCR_SB1_5, // 1.5 stop bit
|
176 |
|
|
LCR_SB2 // 2 stop bits
|
177 |
|
|
};
|
178 |
|
|
|
179 |
|
|
static unsigned char select_parity[] = {
|
180 |
|
|
LCR_PN, // No parity
|
181 |
|
|
LCR_PE, // Even parity
|
182 |
|
|
LCR_PO, // Odd parity
|
183 |
|
|
LCR_PM, // Mark parity
|
184 |
|
|
LCR_PS, // Space parity
|
185 |
|
|
};
|
186 |
|
|
|
187 |
|
|
// FIXME: calc all properly
|
188 |
|
|
// The Atlas board has a 3.6864 MHz crystal
|
189 |
|
|
static unsigned short select_baud[] = {
|
190 |
|
|
0, // Unused
|
191 |
|
|
0, // 50
|
192 |
|
|
0, // 75
|
193 |
|
|
2094, // 110
|
194 |
|
|
0, // 134.5
|
195 |
|
|
1536, // 150
|
196 |
|
|
0, // 200
|
197 |
|
|
768, // 300
|
198 |
|
|
384, // 600
|
199 |
|
|
192, // 1200
|
200 |
|
|
0, // 1800
|
201 |
|
|
96, // 2400
|
202 |
|
|
0, // 3600
|
203 |
|
|
48, // 4800
|
204 |
|
|
32, // 7200
|
205 |
|
|
24, // 9600
|
206 |
|
|
16, // 14400
|
207 |
|
|
12, // 19200
|
208 |
|
|
6, // 38400
|
209 |
|
|
4, // 57600
|
210 |
|
|
2, // 115200
|
211 |
|
|
1, // 230400
|
212 |
|
|
};
|
213 |
|
|
|