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