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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_71/] [or1ksim/] [peripheral/] [16450.h] - Blame information for rev 221

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 221 markom
void uart_write(unsigned long addr, unsigned long value);
22
unsigned long 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 221 markom
                unsigned char thre_int;
53 31 lampret
                unsigned long txser_clks;
54
                unsigned long rxser_clks;
55
        } istat;        /* Internal status */
56
        unsigned long char_clks;
57 221 markom
        FILE * rxfs;
58
        FILE * txfs;
59 31 lampret
        unsigned long baseaddr;
60
};
61
 
62
/* Definitions */
63
#define FULL            1
64
#define EMPTY           0
65
#define UART_ADDR_SPACE 8       /* UART memory address space size in bytes */
66
 
67
/*
68
 * Addresses of visible registers
69
 *
70
 */
71
#define UART_RXBUF      0        /* R: Rx buffer, DLAB=0 */
72
#define UART_TXBUF      0        /* W: Tx buffer, DLAB=0 */
73
#define UART_DLL        0        /* R/W: Divisor Latch Low, DLAB=1 */
74
#define UART_DLH        1       /* R/W: Divisor Latch High, DLAB=1 */
75
#define UART_IER        1       /* R/W: Interrupt Enable Register */
76
#define UART_IIR        2       /* R: Interrupt ID Register */
77
#define UART_LCR        3       /* R/W: Line Control Register */
78
#define UART_MCR        4       /* R/W: Modem Control Register */
79
#define UART_LSR        5       /* R: Line Status Register */
80
#define UART_MSR        6       /* R: Modem Status Register */
81
#define UART_SCR        7       /* R/W: Scratch Register */
82
 
83
/*
84
 * R/W masks for valid bits in 8250/16450 (mask out 16550 and later bits)
85
 *
86
 */
87
#define UART_VALID_LCR  0xff
88
#define UART_VALID_LSR  0x7f
89
#define UART_VALID_IIR  0x07
90
#define UART_VALID_IER  0x0f
91
#define UART_VALID_MCR  0x1f
92
#define UART_VALID_MSR  0xff
93
 
94
/*
95
 * Bit definitions for the Line Control Register
96
 *
97
 */
98
#define UART_LCR_DLAB   0x80    /* Divisor latch access bit */
99
#define UART_LCR_SBC    0x40    /* Set break control */
100
#define UART_LCR_SPAR   0x20    /* Stick parity (?) */
101
#define UART_LCR_EPAR   0x10    /* Even parity select */
102
#define UART_LCR_PARITY 0x08    /* Parity Enable */
103
#define UART_LCR_STOP   0x04    /* Stop bits: 0=1 stop bit, 1= 2 stop bits */
104
#define UART_LCR_WLEN5  0x00    /* Wordlength: 5 bits */
105
#define UART_LCR_WLEN6  0x01    /* Wordlength: 6 bits */
106
#define UART_LCR_WLEN7  0x02    /* Wordlength: 7 bits */
107
#define UART_LCR_WLEN8  0x03    /* Wordlength: 8 bits */
108
 
109
/*
110
 * Bit definitions for the Line Status Register
111
 */
112
#define UART_LSR_TXSERE 0x40    /* Transmitter serial register empty */
113
#define UART_LSR_TXBUFE 0x20    /* Transmitter buffer register empty */
114
#define UART_LSR_BREAK  0x10    /* Break interrupt indicator */
115
#define UART_LSR_FRAME  0x08    /* Frame error indicator */
116
#define UART_LSR_PARITY 0x04    /* Parity error indicator */
117
#define UART_LSR_OVRRUN 0x02    /* Overrun error indicator */
118
#define UART_LSR_RDRDY  0x01    /* Receiver data ready */
119
 
120
/*
121
 * Bit definitions for the Interrupt Identification Register
122
 */
123
#define UART_IIR_NO_INT 0x01    /* No interrupts pending */
124
#define UART_IIR_ID     0x06    /* Mask for the interrupt ID */
125
 
126
#define UART_IIR_MSI    0x00    /* Modem status interrupt (Low priority) */
127
#define UART_IIR_THRI   0x02    /* Transmitter holding register empty */
128
#define UART_IIR_RDI    0x04    /* Receiver data interrupt */
129
#define UART_IIR_RLSI   0x06    /* Receiver line status interrupt (High p.) */
130
 
131
/*
132
 * Bit definitions for the Interrupt Enable Register
133
 */
134
#define UART_IER_MSI    0x08    /* Enable Modem status interrupt */
135
#define UART_IER_RLSI   0x04    /* Enable receiver line status interrupt */
136
#define UART_IER_THRI   0x02    /* Enable Transmitter holding register int. */
137
#define UART_IER_RDI    0x01    /* Enable receiver data interrupt */
138
 
139
/*
140
 * Bit definitions for the Modem Control Register
141
 */
142
#define UART_MCR_LOOP   0x10    /* Enable loopback mode */
143
#define UART_MCR_AUX2   0x08    /* Auxilary 2  */
144
#define UART_MCR_AUX1   0x04    /* Auxilary 1 */
145
#define UART_MCR_RTS    0x02    /* Force RTS */
146
#define UART_MCR_DTR    0x01    /* Force DTR */
147
 
148
/*
149
 * Bit definitions for the Modem Status Register
150
 */
151
#define UART_MSR_DCD    0x80    /* Data Carrier Detect */
152
#define UART_MSR_RI     0x40    /* Ring Indicator */
153
#define UART_MSR_DSR    0x20    /* Data Set Ready */
154
#define UART_MSR_CTS    0x10    /* Clear to Send */
155
#define UART_MSR_DDCD   0x08    /* Delta DCD */
156
#define UART_MSR_TERI   0x04    /* Trailing edge ring indicator */
157
#define UART_MSR_DDSR   0x02    /* Delta DSR */
158
#define UART_MSR_DCTS   0x01    /* Delta CTS */
159
 

powered by: WebSVN 2.1.0

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