source: rtems/c/src/libchip/serial/ns16550_p.h @ 0737710

4.104.114.84.95
Last change on this file since 0737710 was 0737710, checked in by Joel Sherrill <joel.sherrill@…>, on 06/13/98 at 15:48:25

Base code from ppcn_60x BSP

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*
2 *  COPYRIGHT (c) 1998 by Radstone Technology
3 *
4 *
5 * THIS FILE IS PROVIDED TO YOU, THE USER, "AS IS", WITHOUT WARRANTY OF ANY
6 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
7 * IMPLIED WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK
8 * AS TO THE QUALITY AND PERFORMANCE OF ALL CODE IN THIS FILE IS WITH YOU.
9 *
10 * You are hereby granted permission to use, copy, modify, and distribute
11 * this file, provided that this notice, plus the above copyright notice
12 * and disclaimer, appears in all copies. Radstone Technology will provide
13 * no support for this code.
14 *
15 */
16
17#ifndef _NS16550_P_H_
18#define _NS16550_P_H_
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23/*
24 * Define serial port read registers structure.
25 */
26
27typedef volatile struct _SP_READ_REGISTERS {
28    unsigned char ReceiveBuffer;
29    unsigned char InterruptEnable;
30    unsigned char InterruptId;
31    unsigned char LineControl;
32    unsigned char ModemControl;
33    unsigned char LineStatus;
34    unsigned char ModemStatus;
35    unsigned char ScratchPad;
36} SP_READ_REGISTERS, *PSP_READ_REGISTERS;
37
38
39#define NS16550_RECEIVE_BUFFER   0
40#define NS16550_INTERRUPT_ENABLE 1
41#define NS16550_INTERRUPT_ID     2
42#define NS16550_LINE_CONTROL     3
43#define NS16550_MODEM_CONTROL    4
44#define NS16550_LINE_STATUS      5
45#define NS16550_MODEM_STATUS     6
46#define NS16550_SCRATCH_PAD      7
47/*
48 * Define serial port write registers structure.
49 */
50
51typedef volatile struct _SP_WRITE_REGISTERS {
52    unsigned char TransmitBuffer;
53    unsigned char InterruptEnable;
54    unsigned char FifoControl;
55    unsigned char LineControl;
56    unsigned char ModemControl;
57    unsigned char Reserved1;
58    unsigned char ModemStatus;
59    unsigned char ScratchPad;
60} SP_WRITE_REGISTERS, *PSP_WRITE_REGISTERS;
61
62#define NS16550_TRANSMIT_BUFFER  0
63#define NS16550_FIFO_CONTROL     2
64
65/*
66 * Define serial port interrupt enable register structure.
67 */
68
69#define SP_INT_RX_ENABLE        0x01
70#define SP_INT_TX_ENABLE        0x02
71#define SP_INT_LS_ENABLE        0x04
72#define SP_INT_MS_ENABLE        0x08
73
74/*
75 * Define serial port interrupt id register structure.
76 */
77
78typedef struct _SP_INTERRUPT_ID {
79    unsigned char InterruptPending : 1;
80    unsigned char Identification : 3;
81    unsigned char Reserved1 : 2;
82    unsigned char FifoEnabled : 2;
83} SP_INTERRUPT_ID, *PSP_INTERRUPT_ID;
84
85/*
86 * Define serial port fifo control register structure.
87 */
88#define SP_FIFO_ENABLE  0x01
89#define SP_FIFO_RXRST   0x02
90#define SP_FIFO_TXRST   0x04
91#define SP_FIFO_DMA             0x08
92#define SP_FIFO_RXLEVEL 0xc0
93
94/*
95 * Define serial port line control register structure.
96 */
97#define SP_LINE_SIZE    0x03
98#define SP_LINE_STOP    0x04
99#define SP_LINE_PAR             0x08
100#define SP_LINE_ODD             0x10
101#define SP_LINE_STICK   0x20
102#define SP_LINE_BREAK   0x40
103#define SP_LINE_DLAB    0x80
104
105/*
106 * Line status register character size definitions.
107 */
108#define FIVE_BITS 0x0                   /* five bits per character */
109#define SIX_BITS 0x1                    /* six bits per character */
110#define SEVEN_BITS 0x2                  /* seven bits per character */
111#define EIGHT_BITS 0x3                  /* eight bits per character */
112
113/*
114 * Line speed divisor definition.
115 */
116#define NS16550_Baud(baud_rate) (115200/baud_rate)
117
118/*
119 * Define serial port modem control register structure.
120 */
121#define SP_MODEM_DTR    0x01
122#define SP_MODEM_RTS    0x02
123#define SP_MODEM_IRQ    0x08
124#define SP_MODEM_LOOP   0x10
125#define SP_MODEM_DIV4   0x80
126
127/*
128 * Define serial port line status register structure.
129 */
130#define SP_LSR_RDY              0x01
131#define SP_LSR_EOVRUN   0x02
132#define SP_LSR_EPAR             0x04
133#define SP_LSR_EFRAME   0x08
134#define SP_LSR_BREAK    0x10
135#define SP_LSR_THOLD    0x20
136#define SP_LSR_TX               0x40
137#define SP_LSR_EFIFO    0x80
138
139typedef struct _ns16550_context
140{
141        unsigned8       ucModemCtrl;
142} ns16550_context;
143
144/*
145 * Driver functions
146 */
147static boolean ns16550_probe(int minor);
148
149static void ns16550_init(int minor);
150
151static int ns16550_open(
152        int     major,
153        int     minor,
154        void    * arg
155);
156
157static int ns16550_close(
158        int     major,
159        int     minor,
160        void    * arg
161);
162
163static void ns16550_write_polled(
164        int   minor,
165        char  cChar
166);
167
168static int ns16550_assert_RTS(
169        int minor
170);
171
172static int ns16550_negate_RTS(
173        int minor
174);
175
176static int ns16550_assert_DTR(
177        int minor
178);
179
180static int ns16550_negate_DTR(
181        int minor
182);
183
184static void ns16550_initialize_interrupts(int minor);
185
186static int ns16550_flush(int major, int minor, void *arg);
187
188static int ns16550_write_support_int(
189        int   minor,
190        const char *buf,
191        int   len
192);
193
194static int ns16550_write_support_polled(
195        int   minor,
196        const char *buf,
197        int   len
198        );
199
200static int ns16550_inbyte_nonblocking_polled(
201        int minor
202);
203
204#ifdef __cplusplus
205}
206#endif
207
208#endif /* _NS16550_P_H_ */
Note: See TracBrowser for help on using the repository browser.