xref: /netbsd-src/sys/arch/evbarm/dev/plcomvar.h (revision 82d56013d7b633d116a93943de88e08335357a7c)
1 /*	$NetBSD: plcomvar.h,v 1.17 2017/10/12 20:05:42 skrll 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 	u_int sc_r_hiwat,
108 	      sc_r_lowat;
109 	u_char *volatile sc_rbget,
110 	       *volatile sc_rbput;
111  	volatile u_int sc_rbavail;
112 	u_char *sc_rbuf,
113 	       *sc_ebuf;
114 
115  	u_char *sc_tba;
116  	u_int sc_tbc,
117 	      sc_heldtbc;
118 
119 	volatile u_char sc_rx_flags,
120 #define	RX_TTY_BLOCKED		0x01
121 #define	RX_TTY_OVERFLOWED	0x02
122 #define	RX_IBUF_BLOCKED		0x04
123 #define	RX_IBUF_OVERFLOWED	0x08
124 #define	RX_ANY_BLOCK		0x0f
125 			sc_tx_busy,
126 			sc_tx_done,
127 			sc_tx_stopped,
128 			sc_st_check,
129 			sc_rx_ready;
130 
131 	volatile u_char sc_heldchange;
132 	volatile u_int sc_cr, sc_ratel, sc_rateh, sc_imsc;
133 	volatile u_int sc_msr, sc_msr_delta, sc_msr_mask;
134 	volatile u_char sc_mcr, sc_mcr_active, sc_lcr;
135 	u_char sc_mcr_dtr, sc_mcr_rts, sc_msr_cts, sc_msr_dcd;
136 	u_int sc_fifo;
137 
138 	/* Support routine to program mcr lines for PL010, if present.  */
139 	void	(*sc_set_mcr)(void *, int, u_int);
140 	void	*sc_set_mcr_arg;
141 
142 	/* power management hooks */
143 	int (*enable) (struct plcom_softc *);
144 	void (*disable) (struct plcom_softc *);
145 	int enabled;
146 
147 	/* PPS signal on DCD, with or without inkernel clock disciplining */
148 	u_char	sc_ppsmask;			/* pps signal mask */
149 	u_char	sc_ppsassert;			/* pps leading edge */
150 	u_char	sc_ppsclear;			/* pps trailing edge */
151 	pps_info_t ppsinfo;
152 	pps_params_t ppsparam;
153 
154 #ifdef RND_COM
155 	krndsource_t  rnd_source;
156 #endif
157 	kmutex_t		sc_lock;
158 };
159 
160 #if 0
161 int  plcomprobe1	(bus_space_tag_t, bus_space_handle_t);
162 #endif
163 int  plcomintr		(void *);
164 void plcom_attach_subr	(struct plcom_softc *);
165 int  plcom_detach	(device_t, int);
166 int  plcom_activate	(device_t, enum devact);
167 
168