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