FreeBSD/Linux Kernel Cross Reference
sys/dev/uart/uart.h
1 /*-
2 * Copyright (c) 2003 Marcel Moolenaar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * $FreeBSD$
27 */
28
29 #ifndef _DEV_UART_H_
30 #define _DEV_UART_H_
31
32 /*
33 * Bus access structure. This structure holds the minimum information needed
34 * to access the UART. The rclk field, although not important to actually
35 * access the UART, is important for baudrate programming, delay loops and
36 * other timing related computations.
37 */
38 struct uart_bas {
39 bus_space_tag_t bst;
40 bus_space_handle_t bsh;
41 u_int chan;
42 u_int rclk;
43 u_int regshft;
44 };
45
46 #define uart_regofs(bas, reg) ((reg) << (bas)->regshft)
47
48 #define uart_getreg(bas, reg) \
49 bus_space_read_1((bas)->bst, (bas)->bsh, uart_regofs(bas, reg))
50 #define uart_setreg(bas, reg, value) \
51 bus_space_write_1((bas)->bst, (bas)->bsh, uart_regofs(bas, reg), value)
52
53 /* 16-bit I/O (e.g. to divisor latch) */
54 #define uart_getdreg(bas, reg) \
55 bus_space_read_2((bas)->bst, (bas)->bsh, uart_regofs(bas, reg))
56 #define uart_setdreg(bas, reg, value) \
57 bus_space_write_2((bas)->bst, (bas)->bsh, uart_regofs(bas, reg), value)
58
59 /*
60 * XXX we don't know the length of the bus space address range in use by
61 * the UART. Since barriers don't use the length field currently, we put
62 * a zero there for now.
63 */
64 #define uart_barrier(bas) \
65 bus_space_barrier((bas)->bst, (bas)->bsh, 0, 0, \
66 BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE)
67
68 /*
69 * Device flags.
70 */
71 #define UART_FLAGS_CONSOLE(f) ((f) & 0x10)
72 #define UART_FLAGS_DBGPORT(f) ((f) & 0x80)
73
74 /*
75 * Data parity values (magical numbers related to ns8250).
76 */
77 #define UART_PARITY_NONE 0
78 #define UART_PARITY_ODD 1
79 #define UART_PARITY_EVEN 3
80 #define UART_PARITY_MARK 5
81 #define UART_PARITY_SPACE 7
82
83 #endif /* _DEV_UART_H_ */
Cache object: 10010fbe4ac315d18c0d2ed835e3cfd8
|