| @@ -1,177 +1,176 @@ | | | @@ -1,177 +1,176 @@ |
1 | /* $NetBSD: plcomvar.h,v 1.14 2013/05/01 07:33:24 mlelstv Exp $ */ | | 1 | /* $NetBSD: plcomvar.h,v 1.15 2014/02/21 16:08:19 skrll Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. | | 4 | * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * 3. All advertising materials mentioning features or use of this software | | 14 | * 3. All advertising materials mentioning features or use of this software |
15 | * must display the following acknowledgement: | | 15 | * must display the following acknowledgement: |
16 | * This product includes software developed by Christopher G. Demetriou | | 16 | * This product includes software developed by Christopher G. Demetriou |
17 | * for the NetBSD Project. | | 17 | * for the NetBSD Project. |
18 | * 4. The name of the author may not be used to endorse or promote products | | 18 | * 4. The name of the author may not be used to endorse or promote products |
19 | * derived from this software without specific prior written permission | | 19 | * derived from this software without specific prior written permission |
20 | * | | 20 | * |
21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #include "rnd.h" | | 33 | #include "rnd.h" |
34 | #include "opt_multiprocessor.h" | | 34 | #include "opt_multiprocessor.h" |
35 | #include "opt_lockdebug.h" | | 35 | #include "opt_lockdebug.h" |
36 | #include "opt_plcom.h" | | 36 | #include "opt_plcom.h" |
37 | #include "opt_kgdb.h" | | 37 | #include "opt_kgdb.h" |
38 | | | 38 | |
39 | #ifdef RND_COM | | 39 | #ifdef RND_COM |
40 | #include <sys/rnd.h> | | 40 | #include <sys/rnd.h> |
41 | #endif | | 41 | #endif |
42 | | | 42 | |
43 | #include <sys/callout.h> | | 43 | #include <sys/callout.h> |
44 | #include <sys/timepps.h> | | 44 | #include <sys/timepps.h> |
45 | #include <sys/simplelock.h> | | | |
46 | | | 45 | |
47 | struct plcom_instance; | | 46 | struct plcom_instance; |
48 | | | 47 | |
49 | int plcomcnattach (struct plcom_instance *, int, int, tcflag_t, int); | | 48 | int plcomcnattach (struct plcom_instance *, int, int, tcflag_t, int); |
50 | void plcomcndetach (void); | | 49 | void plcomcndetach (void); |
51 | | | 50 | |
52 | #ifdef KGDB | | 51 | #ifdef KGDB |
53 | int plcom_kgdb_attach (struct plcom_instance *, int, int, tcflag_t, int); | | 52 | int plcom_kgdb_attach (struct plcom_instance *, int, int, tcflag_t, int); |
54 | #endif | | 53 | #endif |
55 | | | 54 | |
56 | int plcom_is_console (bus_space_tag_t, bus_addr_t, bus_space_handle_t *); | | 55 | int plcom_is_console (bus_space_tag_t, bus_addr_t, bus_space_handle_t *); |
57 | | | 56 | |
58 | /* Hardware flag masks */ | | 57 | /* Hardware flag masks */ |
59 | #define PLCOM_HW_NOIEN 0x01 | | 58 | #define PLCOM_HW_NOIEN 0x01 |
60 | #define PLCOM_HW_FIFO 0x02 | | 59 | #define PLCOM_HW_FIFO 0x02 |
61 | #define PLCOM_HW_HAYESP 0x04 | | 60 | #define PLCOM_HW_HAYESP 0x04 |
62 | #define PLCOM_HW_FLOW 0x08 | | 61 | #define PLCOM_HW_FLOW 0x08 |
63 | #define PLCOM_HW_DEV_OK 0x20 | | 62 | #define PLCOM_HW_DEV_OK 0x20 |
64 | #define PLCOM_HW_CONSOLE 0x40 | | 63 | #define PLCOM_HW_CONSOLE 0x40 |
65 | #define PLCOM_HW_KGDB 0x80 | | 64 | #define PLCOM_HW_KGDB 0x80 |
66 | #define PLCOM_HW_TXFIFO_DISABLE 0x100 | | 65 | #define PLCOM_HW_TXFIFO_DISABLE 0x100 |
67 | | | 66 | |
68 | /* Buffer size for character buffer */ | | 67 | /* Buffer size for character buffer */ |
69 | #define PLCOM_RING_SIZE 2048 | | 68 | #define PLCOM_RING_SIZE 2048 |
70 | | | 69 | |
71 | struct plcom_instance { | | 70 | struct plcom_instance { |
72 | u_int pi_type; | | 71 | u_int pi_type; |
73 | #define PLCOM_TYPE_PL010 0 | | 72 | #define PLCOM_TYPE_PL010 0 |
74 | #define PLCOM_TYPE_PL011 1 | | 73 | #define PLCOM_TYPE_PL011 1 |
75 | | | 74 | |
76 | uint32_t pi_flags; /* flags for this PLCOM */ | | 75 | uint32_t pi_flags; /* flags for this PLCOM */ |
77 | #define PLC_FLAG_USE_DMA 0x0001 | | 76 | #define PLC_FLAG_USE_DMA 0x0001 |
78 | #define PLC_FLAG_32BIT_ACCESS 0x0002 | | 77 | #define PLC_FLAG_32BIT_ACCESS 0x0002 |
79 | | | 78 | |
80 | void *pi_cookie; | | 79 | void *pi_cookie; |
81 | | | 80 | |
82 | bus_space_tag_t pi_iot; | | 81 | bus_space_tag_t pi_iot; |
83 | bus_space_handle_t pi_ioh; | | 82 | bus_space_handle_t pi_ioh; |
84 | bus_addr_t pi_iobase; | | 83 | bus_addr_t pi_iobase; |
85 | bus_addr_t pi_size; | | 84 | bus_addr_t pi_size; |
86 | struct plcom_registers *pi_regs; | | 85 | struct plcom_registers *pi_regs; |
87 | }; | | 86 | }; |
88 | | | 87 | |
89 | struct plcomcons_info { | | 88 | struct plcomcons_info { |
90 | int rate; | | 89 | int rate; |
91 | int frequency; | | 90 | int frequency; |
92 | int type; | | 91 | int type; |
93 | | | 92 | |
94 | tcflag_t cflag; | | 93 | tcflag_t cflag; |
95 | }; | | 94 | }; |
96 | | | 95 | |
97 | struct plcom_softc { | | 96 | struct plcom_softc { |
98 | device_t sc_dev; | | 97 | device_t sc_dev; |
99 | | | 98 | |
100 | struct tty *sc_tty; | | 99 | struct tty *sc_tty; |
101 | void *sc_si; | | 100 | void *sc_si; |
102 | | | 101 | |
103 | struct callout sc_diag_callout; | | 102 | struct callout sc_diag_callout; |
104 | | | 103 | |
105 | int sc_frequency; | | 104 | int sc_frequency; |
106 | | | 105 | |
107 | struct plcom_instance sc_pi; | | 106 | struct plcom_instance sc_pi; |
108 | | | 107 | |
109 | u_int sc_overflows, | | 108 | u_int sc_overflows, |
110 | sc_floods, | | 109 | sc_floods, |
111 | sc_errors; | | 110 | sc_errors; |
112 | | | 111 | |
113 | int sc_hwflags, | | 112 | int sc_hwflags, |
114 | sc_swflags; | | 113 | sc_swflags; |
115 | u_int sc_fifolen; | | 114 | u_int sc_fifolen; |
116 | | | 115 | |
117 | u_int sc_r_hiwat, | | 116 | u_int sc_r_hiwat, |
118 | sc_r_lowat; | | 117 | sc_r_lowat; |
119 | u_char *volatile sc_rbget, | | 118 | u_char *volatile sc_rbget, |
120 | *volatile sc_rbput; | | 119 | *volatile sc_rbput; |
121 | volatile u_int sc_rbavail; | | 120 | volatile u_int sc_rbavail; |
122 | u_char *sc_rbuf, | | 121 | u_char *sc_rbuf, |
123 | *sc_ebuf; | | 122 | *sc_ebuf; |
124 | | | 123 | |
125 | u_char *sc_tba; | | 124 | u_char *sc_tba; |
126 | u_int sc_tbc, | | 125 | u_int sc_tbc, |
127 | sc_heldtbc; | | 126 | sc_heldtbc; |
128 | | | 127 | |
129 | volatile u_char sc_rx_flags, | | 128 | volatile u_char sc_rx_flags, |
130 | #define RX_TTY_BLOCKED 0x01 | | 129 | #define RX_TTY_BLOCKED 0x01 |
131 | #define RX_TTY_OVERFLOWED 0x02 | | 130 | #define RX_TTY_OVERFLOWED 0x02 |
132 | #define RX_IBUF_BLOCKED 0x04 | | 131 | #define RX_IBUF_BLOCKED 0x04 |
133 | #define RX_IBUF_OVERFLOWED 0x08 | | 132 | #define RX_IBUF_OVERFLOWED 0x08 |
134 | #define RX_ANY_BLOCK 0x0f | | 133 | #define RX_ANY_BLOCK 0x0f |
135 | sc_tx_busy, | | 134 | sc_tx_busy, |
136 | sc_tx_done, | | 135 | sc_tx_done, |
137 | sc_tx_stopped, | | 136 | sc_tx_stopped, |
138 | sc_st_check, | | 137 | sc_st_check, |
139 | sc_rx_ready; | | 138 | sc_rx_ready; |
140 | | | 139 | |
141 | volatile u_char sc_heldchange; | | 140 | volatile u_char sc_heldchange; |
142 | volatile u_int sc_cr, sc_ratel, sc_rateh, sc_imsc; | | 141 | volatile u_int sc_cr, sc_ratel, sc_rateh, sc_imsc; |
143 | volatile u_int sc_msr, sc_msr_delta, sc_msr_mask; | | 142 | volatile u_int sc_msr, sc_msr_delta, sc_msr_mask; |
144 | volatile u_char sc_mcr, sc_mcr_active, sc_lcr; | | 143 | volatile u_char sc_mcr, sc_mcr_active, sc_lcr; |
145 | u_char sc_mcr_dtr, sc_mcr_rts, sc_msr_cts, sc_msr_dcd; | | 144 | u_char sc_mcr_dtr, sc_mcr_rts, sc_msr_cts, sc_msr_dcd; |
146 | u_int sc_fifo; | | 145 | u_int sc_fifo; |
147 | | | 146 | |
148 | /* Support routine to program mcr lines for PL010, if present. */ | | 147 | /* Support routine to program mcr lines for PL010, if present. */ |
149 | void (*sc_set_mcr)(void *, int, u_int); | | 148 | void (*sc_set_mcr)(void *, int, u_int); |
150 | void *sc_set_mcr_arg; | | 149 | void *sc_set_mcr_arg; |
151 | | | 150 | |
152 | /* power management hooks */ | | 151 | /* power management hooks */ |
153 | int (*enable) (struct plcom_softc *); | | 152 | int (*enable) (struct plcom_softc *); |
154 | void (*disable) (struct plcom_softc *); | | 153 | void (*disable) (struct plcom_softc *); |
155 | int enabled; | | 154 | int enabled; |
156 | | | 155 | |
157 | /* PPS signal on DCD, with or without inkernel clock disciplining */ | | 156 | /* PPS signal on DCD, with or without inkernel clock disciplining */ |
158 | u_char sc_ppsmask; /* pps signal mask */ | | 157 | u_char sc_ppsmask; /* pps signal mask */ |
159 | u_char sc_ppsassert; /* pps leading edge */ | | 158 | u_char sc_ppsassert; /* pps leading edge */ |
160 | u_char sc_ppsclear; /* pps trailing edge */ | | 159 | u_char sc_ppsclear; /* pps trailing edge */ |
161 | pps_info_t ppsinfo; | | 160 | pps_info_t ppsinfo; |
162 | pps_params_t ppsparam; | | 161 | pps_params_t ppsparam; |
163 | | | 162 | |
164 | #ifdef RND_COM | | 163 | #ifdef RND_COM |
165 | krndsource_t rnd_source; | | 164 | krndsource_t rnd_source; |
166 | #endif | | 165 | #endif |
167 | kmutex_t sc_lock; | | 166 | kmutex_t sc_lock; |
168 | }; | | 167 | }; |
169 | | | 168 | |
170 | #if 0 | | 169 | #if 0 |
171 | int plcomprobe1 (bus_space_tag_t, bus_space_handle_t); | | 170 | int plcomprobe1 (bus_space_tag_t, bus_space_handle_t); |
172 | #endif | | 171 | #endif |
173 | int plcomintr (void *); | | 172 | int plcomintr (void *); |
174 | void plcom_attach_subr (struct plcom_softc *); | | 173 | void plcom_attach_subr (struct plcom_softc *); |
175 | int plcom_detach (device_t, int); | | 174 | int plcom_detach (device_t, int); |
176 | int plcom_activate (device_t, enum devact); | | 175 | int plcom_activate (device_t, enum devact); |
177 | | | 176 | |