OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_49/] [or1ksim/] [peripheral/] [16450.h] - Blame information for rev 186

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 31 lampret
/* 16450.h -- Definition of types and structures for 8250/16450 serial UART
2
   Copyright (C) 2000 Damjan Lampret, lampret@opencores.org
3
 
4
This file is part of OpenRISC 1000 Architectural Simulator.
5
 
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
 
20
/* Prototypes */
21 186 chris
void uart_write(unsigned long addr, unsigned int value);
22
unsigned int uart_read(unsigned long addr);
23 31 lampret
void uart_reset();
24
void uart_clock();
25
 
26
/* Registers */
27
 
28
struct dev_16450 {
29
        struct {
30
                unsigned char txbuf;
31
                unsigned char rxbuf;
32
                unsigned char dll;
33
                unsigned char dlh;
34
                unsigned char ier;
35
                unsigned char iir;
36
                unsigned char lcr;
37
                unsigned char mcr;
38
                unsigned char lsr;
39
                unsigned char msr;
40
                unsigned char scr;
41
        } regs;         /* Visible registers */
42
        struct {
43
                unsigned char txser;
44
                unsigned char rxser;
45
                unsigned char loopback;
46
        } iregs;        /* Internal registers */
47
        struct {
48
                unsigned char txser;
49
                unsigned char rxser;
50
                unsigned char txbuf;
51
                unsigned char rxbuf;
52
                unsigned long txser_clks;
53
                unsigned long rxser_clks;
54
        } istat;        /* Internal status */
55
        unsigned long char_clks;
56 186 chris
        int    rxfd;    /* Changed by CZ for non blocking I/O */
57
        int    txfd;    /* Changed by CZ for non blocking I/O */
58 31 lampret
        unsigned long baseaddr;
59
};
60
 
61
/* Definitions */
62
#define FULL            1
63
#define EMPTY           0
64
#define UART_ADDR_SPACE 8       /* UART memory address space size in bytes */
65
 
66
/*
67
 * Addresses of visible registers
68
 *
69
 */
70
#define UART_RXBUF      0        /* R: Rx buffer, DLAB=0 */
71
#define UART_TXBUF      0        /* W: Tx buffer, DLAB=0 */
72
#define UART_DLL        0        /* R/W: Divisor Latch Low, DLAB=1 */
73
#define UART_DLH        1       /* R/W: Divisor Latch High, DLAB=1 */
74
#define UART_IER        1       /* R/W: Interrupt Enable Register */
75
#define UART_IIR        2       /* R: Interrupt ID Register */
76
#define UART_LCR        3       /* R/W: Line Control Register */
77
#define UART_MCR        4       /* R/W: Modem Control Register */
78
#define UART_LSR        5       /* R: Line Status Register */
79
#define UART_MSR        6       /* R: Modem Status Register */
80
#define UART_SCR        7       /* R/W: Scratch Register */
81
 
82
/*
83
 * R/W masks for valid bits in 8250/16450 (mask out 16550 and later bits)
84
 *
85
 */
86
#define UART_VALID_LCR  0xff
87
#define UART_VALID_LSR  0x7f
88
#define UART_VALID_IIR  0x07
89
#define UART_VALID_IER  0x0f
90
#define UART_VALID_MCR  0x1f
91
#define UART_VALID_MSR  0xff
92
 
93
/*
94
 * Bit definitions for the Line Control Register
95
 *
96
 */
97
#define UART_LCR_DLAB   0x80    /* Divisor latch access bit */
98
#define UART_LCR_SBC    0x40    /* Set break control */
99
#define UART_LCR_SPAR   0x20    /* Stick parity (?) */
100
#define UART_LCR_EPAR   0x10    /* Even parity select */
101
#define UART_LCR_PARITY 0x08    /* Parity Enable */
102
#define UART_LCR_STOP   0x04    /* Stop bits: 0=1 stop bit, 1= 2 stop bits */
103
#define UART_LCR_WLEN5  0x00    /* Wordlength: 5 bits */
104
#define UART_LCR_WLEN6  0x01    /* Wordlength: 6 bits */
105
#define UART_LCR_WLEN7  0x02    /* Wordlength: 7 bits */
106
#define UART_LCR_WLEN8  0x03    /* Wordlength: 8 bits */
107
 
108
/*
109
 * Bit definitions for the Line Status Register
110
 */
111
#define UART_LSR_TXSERE 0x40    /* Transmitter serial register empty */
112
#define UART_LSR_TXBUFE 0x20    /* Transmitter buffer register empty */
113
#define UART_LSR_BREAK  0x10    /* Break interrupt indicator */
114
#define UART_LSR_FRAME  0x08    /* Frame error indicator */
115
#define UART_LSR_PARITY 0x04    /* Parity error indicator */
116
#define UART_LSR_OVRRUN 0x02    /* Overrun error indicator */
117
#define UART_LSR_RDRDY  0x01    /* Receiver data ready */
118
 
119
/*
120
 * Bit definitions for the Interrupt Identification Register
121
 */
122
#define UART_IIR_NO_INT 0x01    /* No interrupts pending */
123
#define UART_IIR_ID     0x06    /* Mask for the interrupt ID */
124
 
125
#define UART_IIR_MSI    0x00    /* Modem status interrupt (Low priority) */
126
#define UART_IIR_THRI   0x02    /* Transmitter holding register empty */
127
#define UART_IIR_RDI    0x04    /* Receiver data interrupt */
128
#define UART_IIR_RLSI   0x06    /* Receiver line status interrupt (High p.) */
129
 
130
/*
131
 * Bit definitions for the Interrupt Enable Register
132
 */
133
#define UART_IER_MSI    0x08    /* Enable Modem status interrupt */
134
#define UART_IER_RLSI   0x04    /* Enable receiver line status interrupt */
135
#define UART_IER_THRI   0x02    /* Enable Transmitter holding register int. */
136
#define UART_IER_RDI    0x01    /* Enable receiver data interrupt */
137
 
138
/*
139
 * Bit definitions for the Modem Control Register
140
 */
141
#define UART_MCR_LOOP   0x10    /* Enable loopback mode */
142
#define UART_MCR_AUX2   0x08    /* Auxilary 2  */
143
#define UART_MCR_AUX1   0x04    /* Auxilary 1 */
144
#define UART_MCR_RTS    0x02    /* Force RTS */
145
#define UART_MCR_DTR    0x01    /* Force DTR */
146
 
147
/*
148
 * Bit definitions for the Modem Status Register
149
 */
150
#define UART_MSR_DCD    0x80    /* Data Carrier Detect */
151
#define UART_MSR_RI     0x40    /* Ring Indicator */
152
#define UART_MSR_DSR    0x20    /* Data Set Ready */
153
#define UART_MSR_CTS    0x10    /* Clear to Send */
154
#define UART_MSR_DDCD   0x08    /* Delta DCD */
155
#define UART_MSR_TERI   0x04    /* Trailing edge ring indicator */
156
#define UART_MSR_DDSR   0x02    /* Delta DSR */
157
#define UART_MSR_DCTS   0x01    /* Delta CTS */
158
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.