1 /* $NetBSD: plcomvar.h,v 1.19 2023/01/24 06:56:40 mlelstv 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 #define PLCOM_TYPE_GENERIC_UART 2 /* SBSA generic uart */ 74 75 uint32_t pi_flags; /* flags for this PLCOM */ 76 #define PLC_FLAG_USE_DMA 0x0001 77 #define PLC_FLAG_32BIT_ACCESS 0x0002 78 uint32_t pi_periphid; 79 80 void *pi_cookie; 81 82 bus_space_tag_t pi_iot; 83 bus_space_handle_t pi_ioh; 84 bus_addr_t pi_iobase; 85 bus_addr_t pi_size; 86 struct plcom_registers *pi_regs; 87 }; 88 89 struct plcom_softc { 90 device_t sc_dev; 91 92 struct tty *sc_tty; 93 void *sc_si; 94 95 struct callout sc_diag_callout; 96 97 int sc_frequency; 98 99 struct plcom_instance sc_pi; 100 101 u_int sc_overflows, 102 sc_floods, 103 sc_errors; 104 105 int sc_hwflags, 106 sc_swflags; 107 u_int sc_fifolen; 108 u_int sc_burstlen; 109 110 struct timeval sc_hup_pending; 111 112 u_int sc_r_hiwat, 113 sc_r_lowat; 114 u_char *volatile sc_rbget, 115 *volatile sc_rbput; 116 volatile u_int sc_rbavail; 117 u_char *sc_rbuf, 118 *sc_ebuf; 119 120 u_char *sc_tba; 121 u_int sc_tbc, 122 sc_heldtbc; 123 124 volatile u_char sc_rx_flags, 125 #define RX_TTY_BLOCKED 0x01 126 #define RX_TTY_OVERFLOWED 0x02 127 #define RX_IBUF_BLOCKED 0x04 128 #define RX_IBUF_OVERFLOWED 0x08 129 #define RX_ANY_BLOCK 0x0f 130 sc_tx_busy, 131 sc_tx_done, 132 sc_tx_stopped, 133 sc_st_check, 134 sc_rx_ready; 135 136 volatile u_char sc_heldchange; 137 volatile uint32_t sc_cr, sc_ratel, sc_rateh, sc_imsc; 138 volatile uint32_t sc_msr, sc_msr_delta, sc_msr_mask; 139 volatile uint32_t sc_lcr, sc_ifls; 140 volatile u_char sc_mcr, sc_mcr_active; 141 u_char sc_mcr_dtr, sc_mcr_rts, sc_msr_cts, sc_msr_dcd; 142 u_int sc_fifo; 143 144 /* Support routine to program mcr lines for PL010, if present. */ 145 void (*sc_set_mcr)(void *, int, u_int); 146 void *sc_set_mcr_arg; 147 148 /* power management hooks */ 149 int (*enable) (struct plcom_softc *); 150 void (*disable) (struct plcom_softc *); 151 int enabled; 152 153 /* PPS signal on DCD, with or without inkernel clock disciplining */ 154 u_char sc_ppsmask; /* pps signal mask */ 155 u_char sc_ppsassert; /* pps leading edge */ 156 u_char sc_ppsclear; /* pps trailing edge */ 157 pps_info_t ppsinfo; 158 pps_params_t ppsparam; 159 160 #ifdef RND_COM 161 krndsource_t rnd_source; 162 #endif 163 kmutex_t sc_lock; 164 }; 165 166 #if 0 167 int plcomprobe1 (bus_space_tag_t, bus_space_handle_t); 168 #endif 169 int plcomintr (void *); 170 void plcom_attach_subr (struct plcom_softc *); 171 int plcom_detach (device_t, int); 172 int plcom_activate (device_t, enum devact); 173 174