plcomvar.h revision 1.18 1 /* $NetBSD: plcomvar.h,v 1.18 2021/10/17 22:34:17 jmcneill Exp $ */
2
3 /*
4 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
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 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Christopher G. Demetriou
17 * for the NetBSD Project.
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
20 *
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
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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
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
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #include "opt_multiprocessor.h"
34 #include "opt_lockdebug.h"
35 #include "opt_plcom.h"
36 #include "opt_kgdb.h"
37
38 #ifdef RND_COM
39 #include <sys/rndsource.h>
40 #endif
41
42 #include <sys/callout.h>
43 #include <sys/timepps.h>
44
45 struct plcom_instance;
46
47 int plcomcnattach (struct plcom_instance *, int, int, tcflag_t, int);
48 void plcomcndetach (void);
49
50 #ifdef KGDB
51 int plcom_kgdb_attach (struct plcom_instance *, int, int, tcflag_t, int);
52 #endif
53
54 int plcom_is_console (bus_space_tag_t, bus_addr_t, bus_space_handle_t *);
55
56 /* Hardware flag masks */
57 #define PLCOM_HW_NOIEN 0x01
58 #define PLCOM_HW_FIFO 0x02
59 #define PLCOM_HW_HAYESP 0x04
60 #define PLCOM_HW_FLOW 0x08
61 #define PLCOM_HW_DEV_OK 0x20
62 #define PLCOM_HW_CONSOLE 0x40
63 #define PLCOM_HW_KGDB 0x80
64 #define PLCOM_HW_TXFIFO_DISABLE 0x100
65
66 /* Buffer size for character buffer */
67 #define PLCOM_RING_SIZE 2048
68
69 struct plcom_instance {
70 u_int pi_type;
71 #define PLCOM_TYPE_PL010 0
72 #define PLCOM_TYPE_PL011 1
73
74 uint32_t pi_flags; /* flags for this PLCOM */
75 #define PLC_FLAG_USE_DMA 0x0001
76 #define PLC_FLAG_32BIT_ACCESS 0x0002
77
78 void *pi_cookie;
79
80 bus_space_tag_t pi_iot;
81 bus_space_handle_t pi_ioh;
82 bus_addr_t pi_iobase;
83 bus_addr_t pi_size;
84 struct plcom_registers *pi_regs;
85 };
86
87 struct plcom_softc {
88 device_t sc_dev;
89
90 struct tty *sc_tty;
91 void *sc_si;
92
93 struct callout sc_diag_callout;
94
95 int sc_frequency;
96
97 struct plcom_instance sc_pi;
98
99 u_int sc_overflows,
100 sc_floods,
101 sc_errors;
102
103 int sc_hwflags,
104 sc_swflags;
105 u_int sc_fifolen;
106
107 struct timeval sc_hup_pending;
108
109 u_int sc_r_hiwat,
110 sc_r_lowat;
111 u_char *volatile sc_rbget,
112 *volatile sc_rbput;
113 volatile u_int sc_rbavail;
114 u_char *sc_rbuf,
115 *sc_ebuf;
116
117 u_char *sc_tba;
118 u_int sc_tbc,
119 sc_heldtbc;
120
121 volatile u_char sc_rx_flags,
122 #define RX_TTY_BLOCKED 0x01
123 #define RX_TTY_OVERFLOWED 0x02
124 #define RX_IBUF_BLOCKED 0x04
125 #define RX_IBUF_OVERFLOWED 0x08
126 #define RX_ANY_BLOCK 0x0f
127 sc_tx_busy,
128 sc_tx_done,
129 sc_tx_stopped,
130 sc_st_check,
131 sc_rx_ready;
132
133 volatile u_char sc_heldchange;
134 volatile u_int sc_cr, sc_ratel, sc_rateh, sc_imsc;
135 volatile u_int sc_msr, sc_msr_delta, sc_msr_mask;
136 volatile u_char sc_mcr, sc_mcr_active, sc_lcr;
137 u_char sc_mcr_dtr, sc_mcr_rts, sc_msr_cts, sc_msr_dcd;
138 u_int sc_fifo;
139
140 /* Support routine to program mcr lines for PL010, if present. */
141 void (*sc_set_mcr)(void *, int, u_int);
142 void *sc_set_mcr_arg;
143
144 /* power management hooks */
145 int (*enable) (struct plcom_softc *);
146 void (*disable) (struct plcom_softc *);
147 int enabled;
148
149 /* PPS signal on DCD, with or without inkernel clock disciplining */
150 u_char sc_ppsmask; /* pps signal mask */
151 u_char sc_ppsassert; /* pps leading edge */
152 u_char sc_ppsclear; /* pps trailing edge */
153 pps_info_t ppsinfo;
154 pps_params_t ppsparam;
155
156 #ifdef RND_COM
157 krndsource_t rnd_source;
158 #endif
159 kmutex_t sc_lock;
160 };
161
162 #if 0
163 int plcomprobe1 (bus_space_tag_t, bus_space_handle_t);
164 #endif
165 int plcomintr (void *);
166 void plcom_attach_subr (struct plcom_softc *);
167 int plcom_detach (device_t, int);
168 int plcom_activate (device_t, enum devact);
169
170