Annotation of sys/arch/sparc/dev/magmareg.h, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: magmareg.h,v 1.9 2004/11/02 21:16:10 miod Exp $ */
! 2:
! 3: /* magmareg.h
! 4: *
! 5: * Copyright (c) 1998 Iain Hibbert
! 6: * All rights reserved.
! 7: *
! 8: * Redistribution and use in source and binary forms, with or without
! 9: * modification, are permitted provided that the following conditions
! 10: * are met:
! 11: * 1. Redistributions of source code must retain the above copyright
! 12: * notice, this list of conditions and the following disclaimer.
! 13: * 2. Redistributions in binary form must reproduce the above copyright
! 14: * notice, this list of conditions and the following disclaimer in the
! 15: * documentation and/or other materials provided with the distribution.
! 16: * 3. All advertising materials mentioning features or use of this software
! 17: * must display the following acknowledgement:
! 18: * This product includes software developed by Iain Hibbert
! 19: * 4. The name of the author may not be used to endorse or promote products
! 20: * derived from this software without specific prior written permission.
! 21: *
! 22: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 23: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 24: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 25: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 26: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 27: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 28: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 29: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 30: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 31: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 32: *
! 33: */
! 34:
! 35: /* The mapping of minor device number -> card and port is done as
! 36: * follows by default:
! 37: *
! 38: * +---+---+---+---+---+---+---+---+
! 39: * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
! 40: * +---+---+---+---+---+---+---+---+
! 41: * | | | | | | | |
! 42: * | | | | +---+---+---+---> port number
! 43: * | | | |
! 44: * | | | +-------------------> dialout (on tty ports)
! 45: * | | |
! 46: * | | +-----------------------> unused
! 47: * | |
! 48: * +---+---------------------------> card number
! 49: *
! 50: */
! 51:
! 52: #define MAGMA_MAX_CARDS 4
! 53: #define MAGMA_MAX_TTY 16
! 54: #define MAGMA_MAX_BPP 2
! 55: #define MAGMA_MAX_CD1400 4
! 56: #define MAGMA_MAX_CD1190 2
! 57:
! 58: #define MAGMA_CARD(x) ((minor(x) >> 6) & 0x03)
! 59: #define MAGMA_PORT(x) (minor(x) & 0x0f)
! 60:
! 61: #define MTTY_DIALOUT(x) (minor(x) & 0x10)
! 62:
! 63: /*
! 64: * Supported Card Types
! 65: */
! 66: struct magma_board_info {
! 67: const char *mb_sbusname; /* sbus name */
! 68: const char *mb_name; /* cardname to match against */
! 69: const char *mb_realname; /* english card name */
! 70: int mb_nser; /* number of serial ports */
! 71: int mb_npar; /* number of parallel ports */
! 72: int mb_ncd1400; /* number of CD1400 chips */
! 73: int mb_svcackr; /* svcackr offset */
! 74: int mb_svcackt; /* svcackt offset */
! 75: int mb_svcackm; /* svcackm offset */
! 76: int mb_cd1400[MAGMA_MAX_CD1400];/* cd1400 chip register offsets */
! 77: int mb_ncd1190; /* number of CD1190 chips */
! 78: int mb_cd1190[MAGMA_MAX_CD1190];/* cd1190 chip register offsets */
! 79: };
! 80:
! 81: /*
! 82: * cd1400 chip data
! 83: */
! 84: struct cd1400 {
! 85: __volatile u_char *cd_reg; /* chip registers */
! 86: int cd_chiprev; /* chip revision */
! 87: int cd_clock; /* clock speed in MHz */
! 88: int cd_parmode; /* parallel mode operation */
! 89: };
! 90:
! 91: /*
! 92: * cd1190 chip data
! 93: */
! 94: struct cd1190 {
! 95: __volatile u_char *cd_reg; /* chip registers */
! 96: int cd_chiprev; /* chip revision */
! 97: };
! 98:
! 99: /* software state for each card */
! 100: struct magma_softc {
! 101: struct device ms_dev; /* required. must be first in softc */
! 102:
! 103: /* cd1400 chip info */
! 104: int ms_ncd1400;
! 105: struct cd1400 ms_cd1400[MAGMA_MAX_CD1400];
! 106: __volatile u_char *ms_svcackr; /* CD1400 service acknowledge receive */
! 107: __volatile u_char *ms_svcackt; /* CD1400 service acknowledge transmit */
! 108: __volatile u_char *ms_svcackm; /* CD1400 service acknowledge modem */
! 109:
! 110: /* cd1190 chip info */
! 111: int ms_ncd1190;
! 112: struct cd1190 ms_cd1190[MAGMA_MAX_CD1190];
! 113:
! 114: const struct magma_board_info *ms_board; /* what am I? */
! 115:
! 116: struct mtty_softc *ms_mtty;
! 117: struct mbpp_softc *ms_mbpp;
! 118:
! 119: struct intrhand ms_hardint; /* hard interrupt handler */
! 120: struct intrhand ms_softint; /* soft interrupt handler */
! 121: };
! 122:
! 123: #define MTTY_RBUF_SIZE (2 * 512)
! 124: #define MTTY_RX_FIFO_THRESHOLD 6
! 125: #define MTTY_RX_DTR_THRESHOLD 9
! 126:
! 127: struct mtty_port {
! 128: struct cd1400 *mp_cd1400; /* ptr to chip */
! 129: int mp_channel; /* and channel */
! 130: struct tty *mp_tty;
! 131:
! 132: int mp_openflags; /* default tty flags */
! 133: int mp_flags; /* port flags */
! 134: int mp_carrier; /* state of carrier */
! 135:
! 136: u_char *mp_rbuf; /* ring buffer start */
! 137: u_char *mp_rend; /* ring buffer end */
! 138: u_char *mp_rget; /* ring buffer read pointer */
! 139: u_char *mp_rput; /* ring buffer write pointer */
! 140:
! 141: u_char *mp_txp; /* transmit character pointer */
! 142: int mp_txc; /* transmit character counter */
! 143: };
! 144:
! 145: #define MTTYF_CARRIER_CHANGED (1<<0)
! 146: #define MTTYF_SET_BREAK (1<<1)
! 147: #define MTTYF_CLR_BREAK (1<<2)
! 148: #define MTTYF_DONE (1<<3)
! 149: #define MTTYF_STOP (1<<4)
! 150: #define MTTYF_RING_OVERFLOW (1<<5)
! 151:
! 152: struct mtty_softc {
! 153: struct device ms_dev; /* device info */
! 154: int ms_nports; /* tty ports */
! 155: struct mtty_port ms_port[MAGMA_MAX_TTY];
! 156: };
! 157:
! 158: #define MBPP_RX_FIFO_THRESHOLD 25
! 159:
! 160: struct mbpp_port {
! 161: struct cd1400 *mp_cd1400; /* for LC2+1Sp card */
! 162: struct cd1190 *mp_cd1190; /* all the others */
! 163:
! 164: int mp_flags;
! 165:
! 166: struct bpp_param mp_param;
! 167: #define mp_burst mp_param.bp_burst
! 168: #define mp_timeout mp_param.bp_timeout
! 169: #define mp_delay mp_param.bp_delay
! 170:
! 171: u_char *mp_ptr; /* pointer to io data */
! 172: int mp_cnt; /* count of io chars */
! 173:
! 174: struct timeout mp_timeout_tmo; /* for mbpp_timeout() */
! 175: struct timeout mp_start_tmo; /* for mbpp_start() */
! 176: };
! 177:
! 178: #define MBPPF_OPEN (1<<0)
! 179: #define MBPPF_TIMEOUT (1<<1)
! 180: #define MBPPF_UIO (1<<2)
! 181: #define MBPPF_DELAY (1<<3)
! 182: #define MBPPF_WAKEUP (1<<4)
! 183:
! 184: struct mbpp_softc {
! 185: struct device ms_dev; /* device info */
! 186: int ms_nports; /* parallel ports */
! 187: struct mbpp_port ms_port[MAGMA_MAX_BPP];
! 188: };
! 189:
! 190: /* internal function prototypes */
! 191:
! 192: int cd1400_compute_baud(speed_t, int, int *, int *);
! 193: __inline void cd1400_write_ccr(struct cd1400 *, u_char);
! 194: __inline u_char cd1400_read_reg(struct cd1400 *, int);
! 195: __inline void cd1400_write_reg(struct cd1400 *, int, u_char);
! 196: void cd1400_enable_transmitter(struct cd1400 *, int);
! 197:
! 198: int magma_match(struct device *, void *, void *);
! 199: void magma_attach(struct device *, struct device *, void *);
! 200: int magma_hard(void *);
! 201: int magma_soft(void *);
! 202:
! 203: int mtty_match(struct device *, void *, void *);
! 204: void mtty_attach(struct device *, struct device *, void *);
! 205: int mtty_modem_control(struct mtty_port *, int, int);
! 206: int mtty_param(struct tty *, struct termios *);
! 207: void mtty_start(struct tty *);
! 208:
! 209: int mbpp_match(struct device *, void *, void *);
! 210: void mbpp_attach(struct device *, struct device *, void *);
! 211: int mbpp_rw(dev_t, struct uio *);
! 212: void mbpp_timeout(void *);
! 213: void mbpp_start(void *);
! 214: int mbpp_send(struct mbpp_port *, caddr_t, int);
! 215: int mbpp_recv(struct mbpp_port *, caddr_t, int);
! 216: int mbpp_hztoms(int);
! 217: int mbpp_mstohz(int);
CVSweb