1*445478ceSriastradh /* $NetBSD: sbscnvar.h,v 1.8 2015/04/13 21:18:42 riastradh Exp $ */ 21b5ddfe4Ssimonb 31b5ddfe4Ssimonb /* 41b5ddfe4Ssimonb * Copyright 2000, 2001 51b5ddfe4Ssimonb * Broadcom Corporation. All rights reserved. 61b5ddfe4Ssimonb * 71b5ddfe4Ssimonb * This software is furnished under license and may be used and copied only 81b5ddfe4Ssimonb * in accordance with the following terms and conditions. Subject to these 91b5ddfe4Ssimonb * conditions, you may download, copy, install, use, modify and distribute 101b5ddfe4Ssimonb * modified or unmodified copies of this software in source and/or binary 111b5ddfe4Ssimonb * form. No title or ownership is transferred hereby. 121b5ddfe4Ssimonb * 131b5ddfe4Ssimonb * 1) Any source code used, modified or distributed must reproduce and 141b5ddfe4Ssimonb * retain this copyright notice and list of conditions as they appear in 151b5ddfe4Ssimonb * the source file. 161b5ddfe4Ssimonb * 171b5ddfe4Ssimonb * 2) No right is granted to use any trade name, trademark, or logo of 188a6b8c3bScgd * Broadcom Corporation. The "Broadcom Corporation" name may not be 198a6b8c3bScgd * used to endorse or promote products derived from this software 208a6b8c3bScgd * without the prior written permission of Broadcom Corporation. 211b5ddfe4Ssimonb * 221b5ddfe4Ssimonb * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED 231b5ddfe4Ssimonb * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF 241b5ddfe4Ssimonb * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 251b5ddfe4Ssimonb * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE 261b5ddfe4Ssimonb * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE 271b5ddfe4Ssimonb * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 281b5ddfe4Ssimonb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 291b5ddfe4Ssimonb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 301b5ddfe4Ssimonb * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 311b5ddfe4Ssimonb * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 321b5ddfe4Ssimonb * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 331b5ddfe4Ssimonb */ 341b5ddfe4Ssimonb 351b5ddfe4Ssimonb /* from: $NetBSD: comvar.h,v 1.32 2000/03/23 07:01:30 thorpej Exp */ 361b5ddfe4Ssimonb 371b5ddfe4Ssimonb /* 381b5ddfe4Ssimonb * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 391b5ddfe4Ssimonb * 401b5ddfe4Ssimonb * Redistribution and use in source and binary forms, with or without 411b5ddfe4Ssimonb * modification, are permitted provided that the following conditions 421b5ddfe4Ssimonb * are met: 431b5ddfe4Ssimonb * 1. Redistributions of source code must retain the above copyright 441b5ddfe4Ssimonb * notice, this list of conditions and the following disclaimer. 451b5ddfe4Ssimonb * 2. Redistributions in binary form must reproduce the above copyright 461b5ddfe4Ssimonb * notice, this list of conditions and the following disclaimer in the 471b5ddfe4Ssimonb * documentation and/or other materials provided with the distribution. 481b5ddfe4Ssimonb * 3. All advertising materials mentioning features or use of this software 491b5ddfe4Ssimonb * must display the following acknowledgement: 501b5ddfe4Ssimonb * This product includes software developed by Christopher G. Demetriou 511b5ddfe4Ssimonb * for the NetBSD Project. 521b5ddfe4Ssimonb * 4. The name of the author may not be used to endorse or promote products 531b5ddfe4Ssimonb * derived from this software without specific prior written permission 541b5ddfe4Ssimonb * 551b5ddfe4Ssimonb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 561b5ddfe4Ssimonb * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 571b5ddfe4Ssimonb * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 581b5ddfe4Ssimonb * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 591b5ddfe4Ssimonb * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 601b5ddfe4Ssimonb * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 611b5ddfe4Ssimonb * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 621b5ddfe4Ssimonb * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 631b5ddfe4Ssimonb * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 641b5ddfe4Ssimonb * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 651b5ddfe4Ssimonb */ 661b5ddfe4Ssimonb 677b0b7dedStls #ifdef RND_SBSCN 68*445478ceSriastradh #include <sys/rndsource.h> 691b5ddfe4Ssimonb #endif 701b5ddfe4Ssimonb 711b5ddfe4Ssimonb #include <sys/callout.h> 721b5ddfe4Ssimonb 73a0a6c85fSchristos #define SBSCN_CHAN(x) (TTUNIT(x) & 1) 74a0a6c85fSchristos #define SBSCN_UNIT(x) (TTUNIT(x) >> 1) 75a0a6c85fSchristos #define SBSCN_DIALOUT(x) TTDIALOUT(x) 761b5ddfe4Ssimonb 771b5ddfe4Ssimonb #define SBSCN_TOLERANCE 30 /* baud rate tolerance, in 0.1% units */ 781b5ddfe4Ssimonb 791b5ddfe4Ssimonb int sbscn_cnattach(u_long addr, int chan, int rate, 801b5ddfe4Ssimonb tcflag_t cflag); 811b5ddfe4Ssimonb #ifdef KGDB 821b5ddfe4Ssimonb int sbscn_kgdb_attach(u_long addr, int chan, int rate, 831b5ddfe4Ssimonb tcflag_t cflag); 841b5ddfe4Ssimonb #endif 851b5ddfe4Ssimonb int sbscn_is_console(u_long addr, int chan); 861b5ddfe4Ssimonb 871b5ddfe4Ssimonb /* Hardware flag masks */ 881b5ddfe4Ssimonb #define SBSCN_HW_CONSOLE 0x01 891b5ddfe4Ssimonb #define SBSCN_HW_KGDB 0x02 901b5ddfe4Ssimonb #define SBSCN_HW_DEV_OK 0x04 911b5ddfe4Ssimonb 921b5ddfe4Ssimonb /* Buffer size for character buffer */ 931b5ddfe4Ssimonb #define SBSCN_RING_SIZE 2048 941b5ddfe4Ssimonb 951b5ddfe4Ssimonb struct sbscn_channel { 961b5ddfe4Ssimonb int ch_num; 971b5ddfe4Ssimonb struct sbscn_softc *ch_sc; 981b5ddfe4Ssimonb struct tty *ch_tty; /* tty struct */ 991b5ddfe4Ssimonb void *ch_intrhand; /* interrupt registration handle */ 1001b5ddfe4Ssimonb void *ch_si; /* softintr cookie */ 1011b5ddfe4Ssimonb struct callout ch_diag_callout; /* callout for diagnostic msgs */ 1021b5ddfe4Ssimonb 1031b5ddfe4Ssimonb volatile char *ch_base; /* kseg1 addr of channel regs */ 1041b5ddfe4Ssimonb volatile char *ch_isr_base; /* kseg1 addr of channel ISR */ 1051b5ddfe4Ssimonb volatile char *ch_imr_base; /* kseg1 addr of channel IMR */ 1061b5ddfe4Ssimonb #ifdef XXXCGDnotyet 1071b5ddfe4Ssimonb volatile char *ch_inchg_base; /* kseg1 addr of channel inport-chg */ 1081b5ddfe4Ssimonb #endif 1091b5ddfe4Ssimonb 1101b5ddfe4Ssimonb u_int ch_overflows; 1111b5ddfe4Ssimonb u_int ch_floods; 1121b5ddfe4Ssimonb u_int ch_errors; 1131b5ddfe4Ssimonb 1141b5ddfe4Ssimonb u_int ch_hwflags; 1151b5ddfe4Ssimonb u_int ch_swflags; 1161b5ddfe4Ssimonb 1171b5ddfe4Ssimonb u_int ch_r_hiwat; 1181b5ddfe4Ssimonb u_int ch_r_lowat; 1191b5ddfe4Ssimonb 1201b5ddfe4Ssimonb /* receive ring buffer management */ 1211b5ddfe4Ssimonb u_char *volatile ch_rbget; 1221b5ddfe4Ssimonb u_char *volatile ch_rbput; 1231b5ddfe4Ssimonb volatile u_int ch_rbavail; 1241b5ddfe4Ssimonb u_char *ch_rbuf; 1251b5ddfe4Ssimonb u_char *ch_ebuf; 1261b5ddfe4Ssimonb 1271b5ddfe4Ssimonb /* transmit buffer management */ 1281b5ddfe4Ssimonb u_char *ch_tba; 1291b5ddfe4Ssimonb u_int ch_tbc; 1301b5ddfe4Ssimonb u_int ch_heldtbc; 1311b5ddfe4Ssimonb 1321b5ddfe4Ssimonb volatile u_int ch_rx_flags; 1331b5ddfe4Ssimonb #define RX_TTY_BLOCKED 0x01 1341b5ddfe4Ssimonb #define RX_TTY_OVERFLOWED 0x02 1351b5ddfe4Ssimonb #define RX_IBUF_BLOCKED 0x04 1361b5ddfe4Ssimonb #define RX_IBUF_OVERFLOWED 0x08 1371b5ddfe4Ssimonb #define RX_ANY_BLOCK 0x0f 1381b5ddfe4Ssimonb volatile u_int ch_tx_busy; 1391b5ddfe4Ssimonb volatile u_int ch_tx_done; 1401b5ddfe4Ssimonb volatile u_int ch_tx_stopped; 1411b5ddfe4Ssimonb volatile u_int ch_st_check; 1421b5ddfe4Ssimonb volatile u_int ch_rx_ready; 1431b5ddfe4Ssimonb 1441b5ddfe4Ssimonb volatile u_char ch_heldchange; 1451b5ddfe4Ssimonb 1461b5ddfe4Ssimonb volatile u_int ch_brc; 1471b5ddfe4Ssimonb volatile u_char ch_imr; 1481b5ddfe4Ssimonb volatile u_char ch_iports, ch_iports_delta; 1491b5ddfe4Ssimonb volatile u_char ch_oports, ch_oports_active; 1501b5ddfe4Ssimonb volatile u_char ch_mode1, ch_mode2; 1511b5ddfe4Ssimonb 1521b5ddfe4Ssimonb u_char ch_i_dcd, ch_i_cts, ch_i_dsr, ch_i_ri, ch_i_mask; 1531b5ddfe4Ssimonb u_char ch_o_dtr, ch_o_rts, ch_o_mask; 1541b5ddfe4Ssimonb 1551b5ddfe4Ssimonb u_char ch_i_dcd_pin, ch_i_cts_pin, ch_i_dsr_pin, ch_i_ri_pin; 1561b5ddfe4Ssimonb u_char ch_o_dtr_pin, ch_o_rts_pin; 1571b5ddfe4Ssimonb 1587b0b7dedStls #ifdef RND_SBSCN 1593afd44cfStls krndsource_t ch_rnd_source; 1601b5ddfe4Ssimonb #endif 1611b5ddfe4Ssimonb }; 1621b5ddfe4Ssimonb 1631b5ddfe4Ssimonb struct sbscn_softc { 164916ee5b6Smatt device_t sc_dev; /* base device */ 1651b5ddfe4Ssimonb 1661b5ddfe4Ssimonb /* shared data structures */ 1671b5ddfe4Ssimonb u_long sc_addr; /* phys addr of DUART XXX bus_space */ 1681b5ddfe4Ssimonb 1691b5ddfe4Ssimonb struct sbscn_channel sc_channels[2]; 1701b5ddfe4Ssimonb }; 171