1 1.1 matt /* $NetBSD: qvareg.h,v 1.1 2015/07/05 03:07:21 matt Exp $ */ 2 1.1 matt 3 1.1 matt /* 4 1.1 matt * Copyright (c) 2015 Charles H. Dickman. All rights reserved. 5 1.1 matt * Derived from sgimips port 6 1.1 matt * Copyright (c) 1996, 1997 Philip L. Budne. 7 1.1 matt * Copyright (c) 1993 Philip A. Nelson. 8 1.1 matt * All rights reserved. 9 1.1 matt * 10 1.1 matt * Redistribution and use in source and binary forms, with or without 11 1.1 matt * modification, are permitted provided that the following conditions 12 1.1 matt * are met: 13 1.1 matt * 1. Redistributions of source code must retain the above copyright 14 1.1 matt * notice, this list of conditions and the following disclaimer. 15 1.1 matt * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 matt * notice, this list of conditions and the following disclaimer in the 17 1.1 matt * documentation and/or other materials provided with the distribution. 18 1.1 matt * 3. All advertising materials mentioning features or use of this software 19 1.1 matt * must display the following acknowledgement: 20 1.1 matt * This product includes software developed by Philip A. Nelson. 21 1.1 matt * 4. The name of Philip A. Nelson may not be used to endorse or promote 22 1.1 matt * products derived from this software without specific prior written 23 1.1 matt * permission. 24 1.1 matt * 25 1.1 matt * THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``AS IS'' AND ANY EXPRESS OR 26 1.1 matt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27 1.1 matt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 28 1.1 matt * IN NO EVENT SHALL PHILIP NELSON BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 1.1 matt * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 30 1.1 matt * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 31 1.1 matt * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 32 1.1 matt * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 33 1.1 matt * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 34 1.1 matt * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 1.1 matt * 36 1.1 matt * scnreg.h: definitions for qvss scn2681 DUART 37 1.1 matt */ 38 1.1 matt 39 1.1 matt /* 40 1.1 matt * register offsets 41 1.1 matt */ 42 1.1 matt 43 1.1 matt /* per-channel regs (channel B's at SCN_REG(8-11)) */ 44 1.1 matt #define CH_MR(x) SCN_REG(0 + 8*(x)) /* rw mode register */ 45 1.1 matt #define CH_SR(x) SCN_REG(1 + 8*(x)) /* ro status register */ 46 1.1 matt #define CH_CSR(x) SCN_REG(1 + 8*(x)) /* wo clock select reg */ 47 1.1 matt #define CH_CR(x) SCN_REG(2 + 8*(x)) /* wo command reg */ 48 1.1 matt #define CH_DAT(x) SCN_REG(3 + 8*(x)) /* rw data reg */ 49 1.1 matt 50 1.1 matt /* duart-wide regs */ 51 1.1 matt #define DU_IPCR SCN_REG(4) /* ro input port change reg */ 52 1.1 matt #define DU_ACR SCN_REG(4) /* wo aux control reg */ 53 1.1 matt #define DU_ISR SCN_REG(5) /* ro interrupt stat reg */ 54 1.1 matt #define DU_IMR SCN_REG(5) /* wo interrupt mask reg */ 55 1.1 matt #define DU_CTUR SCN_REG(6) /* rw counter timer upper reg */ 56 1.1 matt #define DU_CTLR SCN_REG(7) /* rw counter timer lower reg */ 57 1.1 matt /* SCN_REG(8-11) channel b (see above) */ 58 1.1 matt /* SCN_REG(12): reserved */ 59 1.1 matt #define DU_IP SCN_REG(13) /* ro input port */ 60 1.1 matt #define DU_OPCR SCN_REG(13) /* wo output port cfg reg */ 61 1.1 matt #define DU_CSTRT SCN_REG(14) /* ro start C/T cmd */ 62 1.1 matt #define DU_OPSET SCN_REG(14) /* wo output port set */ 63 1.1 matt #define DU_CSTOP SCN_REG(15) /* ro stop C/T cmd */ 64 1.1 matt #define DU_OPCLR SCN_REG(15) /* wo output port reset */ 65 1.1 matt 66 1.1 matt 67 1.1 matt 68 1.1 matt struct qvaux_ch_regs { 69 1.1 matt bus_addr_t qr_mr; 70 1.1 matt bus_addr_t qr_sr; 71 1.1 matt bus_addr_t qr_csr; 72 1.1 matt bus_addr_t qr_cr; 73 1.1 matt bus_addr_t qr_dat; 74 1.1 matt }; 75 1.1 matt 76 1.1 matt struct qvaux_regs { 77 1.1 matt bus_addr_t qr_ipcr; 78 1.1 matt bus_addr_t qr_acr; 79 1.1 matt bus_addr_t qr_isr; 80 1.1 matt bus_addr_t qr_imr; 81 1.1 matt bus_addr_t qr_ctur; 82 1.1 matt bus_addr_t qr_ctlr; 83 1.1 matt bus_addr_t qr_ip; 84 1.1 matt bus_addr_t qr_opcr; 85 1.1 matt bus_addr_t qr_cstrt; 86 1.1 matt bus_addr_t qr_opset; 87 1.1 matt bus_addr_t qr_cstop; 88 1.1 matt bus_addr_t qr_opclr; 89 1.1 matt struct qvaux_ch_regs qr_ch_regs[2]; 90 1.1 matt 91 1.1 matt bus_addr_t qr_firstreg; 92 1.1 matt bus_addr_t qr_winsize; 93 1.1 matt }; 94 1.1 matt 95 1.1 matt /* 96 1.1 matt * Data Values 97 1.1 matt */ 98 1.1 matt 99 1.1 matt /* 100 1.1 matt * MR (mode register) -- per channel 101 1.1 matt */ 102 1.1 matt 103 1.1 matt /* MR0 (scn26c92 only) need to use CR_CMD_MR0 before access */ 104 1.1 matt #define MR0_MODE 0x07 /* extended baud rate mode (MR0A only) */ 105 1.1 matt #define MR0_TXINT 0x30 /* Tx int threshold */ 106 1.1 matt #define MR0_RXINT 0x40 /* Rx int threshold (along with MR1_FFULL) */ 107 1.1 matt #define MR0_RXWD 0x80 /* Rx watchdog (8 byte-times after last rx) */ 108 1.1 matt 109 1.1 matt #define MR0_MODE_0 0x00 /* Normal mode */ 110 1.1 matt #define MR0_MODE_1 0x01 /* Extended mode 1 */ 111 1.1 matt #define MR0_MODE_2 0x04 /* Extended mode 2 */ 112 1.1 matt 113 1.1 matt #define MR0_TXINT_EMPTY 0x00 /* TxInt when 8 FIFO bytes empty (default) */ 114 1.1 matt #define MR0_TXINT_4 0x10 /* TxInt when 4 or more FIFO bytes empty */ 115 1.1 matt #define MR0_TXINT_6 0x20 /* TxInt when 6 or more FIFO bytes empty */ 116 1.1 matt #define MR0_TXINT_TXRDY 0x30 /* TxInt when 1 or more FIFO bytes empty */ 117 1.1 matt 118 1.1 matt /* MR1 (need to use CR_CMD_MR1 before each access) */ 119 1.1 matt #define MR1_CS5 0x00 120 1.1 matt #define MR1_CS6 0x01 121 1.1 matt #define MR1_CS7 0x02 122 1.1 matt #define MR1_CS8 0x03 123 1.1 matt 124 1.1 matt #define MR1_PEVEN 0x00 125 1.1 matt #define MR1_PODD 0x04 126 1.1 matt #define MR1_PNONE 0x10 127 1.1 matt 128 1.1 matt #define MR1_RXBLK 0x20 /* "block" error mode */ 129 1.1 matt #define MR1_FFULL 0x40 /* wait until FIFO full for rxint (cf MR0) */ 130 1.1 matt #define MR1_RXRTS 0x80 /* auto RTS input flow ctrl */ 131 1.1 matt 132 1.1 matt /* MR2 (any access to MR after MR1) */ 133 1.1 matt #define MR2_STOP 0x0f /* mask for stop bits */ 134 1.1 matt #define MR2_STOP1 0x07 135 1.1 matt #define MR2_STOP2 0x0f 136 1.1 matt 137 1.1 matt #define MR2_TXCTS 0x10 /* transmitter follows CTS */ 138 1.1 matt #define MR2_TXRTS 0x20 /* RTS follows transmitter */ 139 1.1 matt #define MR2_MODE 0xc0 /* mode mask */ 140 1.1 matt 141 1.1 matt /* 142 1.1 matt * IP (input port) 143 1.1 matt */ 144 1.1 matt #define IP_IP0 0x01 145 1.1 matt #define IP_IP1 0x02 146 1.1 matt #define IP_IP2 0x04 147 1.1 matt #define IP_IP3 0x08 148 1.1 matt #define IP_IP4 0x10 149 1.1 matt #define IP_IP5 0x20 150 1.1 matt #define IP_IP6 0x40 151 1.1 matt /* D7 is always 1 */ 152 1.1 matt 153 1.1 matt /* 154 1.1 matt * ACR (Aux Control Register) 155 1.1 matt */ 156 1.1 matt 157 1.1 matt #define ACR_DELTA_IP0 0x01 /* enable IP0 delta interrupt */ 158 1.1 matt #define ACR_DELTA_IP1 0x02 /* enable IP1 delta interrupt */ 159 1.1 matt #define ACR_DELTA_IP2 0x04 /* enable IP2 delta interrupt */ 160 1.1 matt #define ACR_DELTA_IP3 0x08 /* enable IP3 delta interrupt */ 161 1.1 matt #define ACR_CT 0x70 /* counter/timer mode (ACT_CT_xxx) */ 162 1.1 matt #define ACR_BRG 0x80 /* baud rate generator speed set */ 163 1.1 matt 164 1.1 matt /* counter/timer mode */ 165 1.1 matt #define ACR_CT_CEXT 0x00 /* counter: external (IP2) */ 166 1.1 matt #define ACR_CT_CTXA 0x10 /* counter: TxCA x 1 */ 167 1.1 matt #define ACR_CT_CTXB 0x20 /* counter: TxCB x 1 */ 168 1.1 matt #define ACR_CT_CCLK 0x30 /* counter: X1/CLK div 16 */ 169 1.1 matt #define ACR_CT_TEXT1 0x40 /* timer: external (IP2) */ 170 1.1 matt #define ACR_CT_TEXT16 0x50 /* timer: external (IP2) div 16 */ 171 1.1 matt #define ACR_CT_TCLK1 0x60 /* timer: X1/CLK */ 172 1.1 matt #define ACR_CT_TCLK16 0x70 /* timer: X1/CLK div 16 */ 173 1.1 matt 174 1.1 matt /* 175 1.1 matt * IPCR (Input Port Change Register) -- per channel 176 1.1 matt */ 177 1.1 matt #define IPCR_IP0 0x01 178 1.1 matt #define IPCR_IP1 0x02 179 1.1 matt #define IPCR_IP2 0x04 180 1.1 matt #define IPCR_IP3 0x08 181 1.1 matt #define IPCR_DELTA_IP0 0x10 182 1.1 matt #define IPCR_DELTA_IP1 0x20 183 1.1 matt #define IPCR_DELTA_IP2 0x40 184 1.1 matt #define IPCR_DELTA_IP3 0x80 185 1.1 matt 186 1.1 matt /* 187 1.1 matt * output port config register 188 1.1 matt * if bit(s) clear OP line follows OP register OPn bit 189 1.1 matt */ 190 1.1 matt 191 1.1 matt #define OPCR_OP7_TXRDYB 0x80 /* OP7: TxRDYB */ 192 1.1 matt #define OPCR_OP6_TXRDYA 0x40 /* OP6: TxRDYA */ 193 1.1 matt #define OPCR_OP5_RXRDYB 0x20 /* OP5: ch B RxRDY/FFULL */ 194 1.1 matt #define OPCR_OP4_RXRDYA 0x10 /* OP4: ch A RxRDY/FFULL */ 195 1.1 matt 196 1.1 matt #define OPCR_OP3 0xC0 /* OP3: mask */ 197 1.1 matt #define OPCR_OP2 0x03 /* OP2: mask */ 198 1.1 matt 199 1.1 matt /* 200 1.1 matt * output port 201 1.1 matt */ 202 1.1 matt #define OP_OP0 0x01 203 1.1 matt #define OP_OP1 0x02 204 1.1 matt #define OP_OP2 0x04 205 1.1 matt #define OP_OP3 0x08 206 1.1 matt #define OP_OP4 0x10 207 1.1 matt #define OP_OP5 0x20 208 1.1 matt #define OP_OP6 0x40 209 1.1 matt #define OP_OP7 0x80 210 1.1 matt 211 1.1 matt /* 212 1.1 matt * CR (command register) -- per channel 213 1.1 matt */ 214 1.1 matt 215 1.1 matt /* bits (may be or'ed together, with a command) */ 216 1.1 matt #define CR_ENA_RX 0x01 217 1.1 matt #define CR_DIS_RX 0x02 218 1.1 matt #define CR_ENA_TX 0x04 219 1.1 matt #define CR_DIS_TX 0x08 220 1.1 matt 221 1.1 matt /* commands */ 222 1.1 matt #define CR_CMD_NOP 0x00 223 1.1 matt #define CR_CMD_MR1 0x10 224 1.1 matt #define CR_CMD_RESET_RX 0x20 225 1.1 matt #define CR_CMD_RESET_TX 0x30 226 1.1 matt #define CR_CMD_RESET_ERR 0x40 227 1.1 matt #define CR_CMD_RESET_BRK 0x50 228 1.1 matt #define CR_CMD_START_BRK 0x60 229 1.1 matt #define CR_CMD_STOP_BRK 0x70 230 1.1 matt 231 1.1 matt /* 2692-only commands */ 232 1.1 matt #define CR_CMD_RTS_ON 0x80 /* raise RTS */ 233 1.1 matt #define CR_CMD_RTS_OFF 0x90 /* lower RTS */ 234 1.1 matt #define CR_CMD_TIM_ON 0xa0 /* enable timeout mode */ 235 1.1 matt #define CR_CMD_TIM_OFF 0xc0 /* reset timeout mode */ 236 1.1 matt #define CR_CMD_PDN_ON 0xe0 /* power down mode on */ 237 1.1 matt #define CR_CMD_PDN_RUN 0xf0 /* power down mode off (normal run) */ 238 1.1 matt 239 1.1 matt /* 26C92-only commands */ 240 1.1 matt #define CR_CMD_MR0 0xb0 /* MR0 select */ 241 1.1 matt 242 1.1 matt /* 243 1.1 matt * CSR (clock select register) -- per channel 244 1.1 matt */ 245 1.1 matt #define CSR_B75 0x0 246 1.1 matt #define CSR_B110 0x1 247 1.1 matt #define CSR_B134 0x2 248 1.1 matt #define CSR_B150 0x3 249 1.1 matt #define CSR_B300 0x4 250 1.1 matt #define CSR_B600 0x5 251 1.1 matt #define CSR_B1200 0x6 252 1.1 matt #define CSR_B2000 0x7 253 1.1 matt #define CSR_B2400 0x8 254 1.1 matt #define CSR_B4800 0x9 255 1.1 matt #define CSR_B7200 0xa 256 1.1 matt #define CSR_B9600 0xb 257 1.1 matt #define CSR_B19200 0xc 258 1.1 matt 259 1.1 matt /* 260 1.1 matt * SR (status register) -- per channel 261 1.1 matt */ 262 1.1 matt #define SR_RX_RDY 0x01 263 1.1 matt #define SR_RX_FFULL 0x02 /* rx fifo full */ 264 1.1 matt #define SR_TX_RDY 0x04 /* tx room for more */ 265 1.1 matt #define SR_TX_EMPTY 0x08 /* tx dry */ 266 1.1 matt 267 1.1 matt #define SR_OVERRUN 0x10 268 1.1 matt 269 1.1 matt /* bits cleared by reset error (see MR1 error mode bit) */ 270 1.1 matt #define SR_PARITY 0x20 /* received parity error */ 271 1.1 matt #define SR_FRAME 0x40 /* received framing error */ 272 1.1 matt #define SR_BREAK 0x80 /* received break */ 273 1.1 matt 274 1.1 matt /* 275 1.1 matt * Interrupt Mask Register (IMR) and ISR (Interrupt Status Register) 276 1.1 matt */ 277 1.1 matt #define INT_TXA 0x01 /* Tx Ready A */ 278 1.1 matt #define INT_RXA 0x02 /* Rx Ready/FIFO Full A */ 279 1.1 matt #define INT_BRKA 0x04 /* Delta Break A */ 280 1.1 matt #define INT_CTR 0x08 /* counter ready */ 281 1.1 matt #define INT_TXB 0x10 /* Tx Ready B */ 282 1.1 matt #define INT_RXB 0x20 /* Rx Ready/FIFO Full B */ 283 1.1 matt #define INT_BRKB 0x40 /* Delta Break B */ 284 1.1 matt #define INT_IP 0x80 /* input port change */ 285