xref: /netbsd-src/sys/arch/arm/ep93xx/epcomvar.h (revision 9d134cf530d1d1b584326aeb2bbdec2203215173)
1*9d134cf5Sskrll /*      $NetBSD: epcomvar.h,v 1.9 2021/11/21 08:44:28 skrll Exp $        */
24e771f5dSjoff /*-
34e771f5dSjoff  * Copyright (c) 2004 Jesse Off
44e771f5dSjoff  *
54e771f5dSjoff  * Redistribution and use in source and binary forms, with or without
64e771f5dSjoff  * modification, are permitted provided that the following conditions
74e771f5dSjoff  * are met:
84e771f5dSjoff  * 1. Redistributions of source code must retain the above copyright
94e771f5dSjoff  *    notice, this list of conditions and the following disclaimer.
104e771f5dSjoff  * 2. Redistributions in binary form must reproduce the above copyright
114e771f5dSjoff  *    notice, this list of conditions and the following disclaimer in the
124e771f5dSjoff  *    documentation and/or other materials provided with the distribution.
137e82f68cSsnj  *
144e771f5dSjoff  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
154e771f5dSjoff  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
164e771f5dSjoff  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
174e771f5dSjoff  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
184e771f5dSjoff  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
194e771f5dSjoff  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
204e771f5dSjoff  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
214e771f5dSjoff  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
224e771f5dSjoff  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
234e771f5dSjoff  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
244e771f5dSjoff  * SUCH DAMAGE.
254e771f5dSjoff  *
264e771f5dSjoff  */
274e771f5dSjoff 
284e771f5dSjoff #ifndef _EPCOMVAR_H_
294e771f5dSjoff #define _EPCOMVAR_H_
304e771f5dSjoff 
3156d32429Sriastradh #ifdef RND_COM
3256d32429Sriastradh #include <sys/rndsource.h>
3356d32429Sriastradh #endif
3456d32429Sriastradh 
354e771f5dSjoff /* Hardware flag masks */
364e771f5dSjoff #define COM_HW_NOIEN		0x01
374e771f5dSjoff #define COM_HW_DEV_OK		0x20
384e771f5dSjoff #define COM_HW_CONSOLE		0x40
394e771f5dSjoff #define COM_HW_KGDB		0x80
404e771f5dSjoff 
414e771f5dSjoff #define RX_TTY_BLOCKED		0x01
424e771f5dSjoff #define RX_TTY_OVERFLOWED	0x02
434e771f5dSjoff #define RX_IBUF_BLOCKED		0x04
444e771f5dSjoff #define RX_IBUF_OVERFLOWED	0x08
454e771f5dSjoff #define RX_ANY_BLOCK		0x0f
464e771f5dSjoff 
474e771f5dSjoff #define EPCOM_RING_SIZE	2048
484e771f5dSjoff 
494e771f5dSjoff struct epcom_softc {
50cbab9cadSchs 	device_t		sc_dev;
514e771f5dSjoff 	bus_addr_t		sc_hwbase;
524e771f5dSjoff 	bus_space_tag_t		sc_iot;
534e771f5dSjoff 	bus_space_handle_t 	sc_ioh;
544e771f5dSjoff 
554e771f5dSjoff 	void			*sc_si;
564e771f5dSjoff 
574e771f5dSjoff 	struct tty		*sc_tty;
584e771f5dSjoff 
594e771f5dSjoff 	u_char			*sc_rbuf, *sc_ebuf;
604e771f5dSjoff 
614e771f5dSjoff  	u_char			*sc_tba;
625beb7d30Sjoff  	u_int			sc_tbc;
634e771f5dSjoff 
644e771f5dSjoff 	u_char			*volatile sc_rbget,
654e771f5dSjoff 				*volatile sc_rbput;
664e771f5dSjoff  	volatile u_int		sc_rbavail;
674e771f5dSjoff 
684e771f5dSjoff 	/* status flags */
694e771f5dSjoff 	int			sc_hwflags, sc_swflags;
704e771f5dSjoff 
714e771f5dSjoff 	volatile u_int		sc_rx_flags,
724e771f5dSjoff 				sc_tx_busy,
734e771f5dSjoff 				sc_tx_done,
744e771f5dSjoff 				sc_tx_stopped,
754e771f5dSjoff 				sc_st_check,
764e771f5dSjoff 				sc_rx_ready;
774e771f5dSjoff 
784e771f5dSjoff 	/* control registers */
794e771f5dSjoff 	u_int			sc_lcrlo;
804e771f5dSjoff 	u_int			sc_lcrmid;
814e771f5dSjoff 	u_int			sc_lcrhi;
824e771f5dSjoff 	u_int			sc_ctrl;
834e771f5dSjoff 
844e771f5dSjoff 	/* power management hooks */
854e771f5dSjoff 	int			(*enable)(struct epcom_softc *);
864e771f5dSjoff 	int			(*disable)(struct epcom_softc *);
874e771f5dSjoff 
884e771f5dSjoff 	int			enabled;
897b0b7dedStls #ifdef RND_COM
903afd44cfStls 	krndsource_t  rnd_source;
914e771f5dSjoff #endif
924e771f5dSjoff };
934e771f5dSjoff 
944e771f5dSjoff void	epcom_attach_subr(struct epcom_softc *);
954e771f5dSjoff 
964e771f5dSjoff int	epcomintr(void* arg);
974e771f5dSjoff int	epcomcnattach(bus_space_tag_t, bus_addr_t, bus_space_handle_t,
984e771f5dSjoff 		       int, tcflag_t);
99*9d134cf5Sskrll int	epcom_kgdb_attach(bus_space_tag_t, bus_addr_t, int, tcflag_t);
1004e771f5dSjoff 
1014e771f5dSjoff #endif /* _EPCOMVAR_H_ */
102