Home | History | Annotate | Line # | Download | only in sbus
spifreg.h revision 1.5.20.1
      1  1.5.20.1  christos /*	$NetBSD: spifreg.h,v 1.5.20.1 2019/06/10 22:07:32 christos Exp $	*/
      2       1.1       mrg /*	$OpenBSD: spifreg.h,v 1.5 2003/06/02 18:32:41 jason Exp $	*/
      3       1.1       mrg 
      4       1.1       mrg /*
      5       1.1       mrg  * Copyright (c) 1999-2002 Jason L. Wright (jason (at) thought.net)
      6       1.1       mrg  * All rights reserved.
      7       1.1       mrg  *
      8       1.1       mrg  * Redistribution and use in source and binary forms, with or without
      9       1.1       mrg  * modification, are permitted provided that the following conditions
     10       1.1       mrg  * are met:
     11       1.1       mrg  * 1. Redistributions of source code must retain the above copyright
     12       1.1       mrg  *    notice, this list of conditions and the following disclaimer.
     13       1.1       mrg  * 2. Redistributions in binary form must reproduce the above copyright
     14       1.1       mrg  *    notice, this list of conditions and the following disclaimer in the
     15       1.1       mrg  *    documentation and/or other materials provided with the distribution.
     16       1.1       mrg  *
     17       1.1       mrg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18       1.1       mrg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     19       1.1       mrg  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     20       1.1       mrg  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     21       1.1       mrg  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     22       1.1       mrg  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     23       1.1       mrg  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24       1.1       mrg  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     25       1.1       mrg  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     26       1.1       mrg  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27       1.1       mrg  * POSSIBILITY OF SUCH DAMAGE.
     28       1.1       mrg  *
     29       1.1       mrg  * Effort sponsored in part by the Defense Advanced Research Projects
     30       1.1       mrg  * Agency (DARPA) and Air Force Research Laboratory, Air Force
     31       1.1       mrg  * Materiel Command, USAF, under agreement number F30602-01-2-0537.
     32       1.1       mrg  *
     33       1.1       mrg  */
     34       1.1       mrg 
     35       1.1       mrg #define	PPC_IN_PDATA		0x000		/* input data */
     36       1.1       mrg #define	PPC_IN_PSTAT		0x001		/* input status */
     37       1.1       mrg #define	PPC_IN_CTRL		0x002		/* input control */
     38       1.1       mrg #define	PPC_IN_PWEIRD		0x003		/* input weird */
     39       1.1       mrg #define	PPC_OUT_PDATA		0x000		/* output data */
     40       1.1       mrg #define	PPC_OUT_PSTAT		0x001		/* output status */
     41       1.1       mrg #define	PPC_OUT_PCTRL		0x002		/* output control */
     42       1.1       mrg #define	PPC_OUT_PWEIRD		0x003		/* output weird */
     43       1.1       mrg #define	PPC_IACK_PDATA		0x1fc		/* iack data */
     44       1.1       mrg #define	PPC_IACK_PSTAT		0x1fd		/* iack status */
     45       1.1       mrg #define	PPC_IACK_PCTRL		0x1fe		/* iack control */
     46       1.1       mrg #define	PPC_IACK_PWEIRD		0x1ff		/* iack weird */
     47       1.1       mrg 
     48       1.1       mrg /* Parallel Status: read only */
     49       1.1       mrg #define	PPC_PSTAT_ERROR		0x08		/* error */
     50       1.1       mrg #define	PPC_PSTAT_SELECT	0x10		/* select */
     51       1.1       mrg #define	PPC_PSTAT_PAPER		0x20		/* paper out */
     52       1.1       mrg #define	PPC_PSTAT_ACK		0x40		/* ack */
     53       1.1       mrg #define	PPC_PSTAT_BUSY		0x80		/* busy */
     54       1.1       mrg 
     55       1.1       mrg /* Parallel Control: read/write */
     56       1.1       mrg #define	PPC_CTRL_STROBE		0x01		/* strobe, 1=drop strobe */
     57       1.1       mrg #define	PPC_CTRL_AFX		0x02		/* auto form-feed */
     58       1.1       mrg #define	PPC_CTRL_INIT		0x04		/* init, 1=enable printer */
     59       1.1       mrg #define	PPC_CTRL_SLCT		0x08		/* SLC, 1=select printer */
     60       1.1       mrg #define	PPC_CTRL_IRQE		0x10		/* IRQ, 1=enable intrs */
     61       1.1       mrg #define	PPC_CTRL_OUTPUT		0x20		/* direction: 1=ppc out */
     62       1.1       mrg 
     63       1.1       mrg /*
     64       1.1       mrg  * The 'stc' is a Cirrus Logic CL-CD180 (either revision B or revision C)
     65       1.1       mrg  */
     66       1.1       mrg #define	STC_CCR			0x01		/* channel command */
     67       1.1       mrg #define	STC_SRER		0x02		/* service request enable */
     68       1.1       mrg #define	STC_COR1		0x03		/* channel option 1 */
     69       1.1       mrg #define	STC_COR2		0x04		/* channel option 2 */
     70       1.1       mrg #define	STC_COR3		0x05		/* channel option 3 */
     71       1.1       mrg #define	STC_CCSR		0x06		/* channel control status */
     72       1.1       mrg #define	STC_RDCR		0x07		/* rx data count */
     73       1.1       mrg #define	STC_SCHR1		0x09		/* special character 1 */
     74       1.1       mrg #define	STC_SCHR2		0x0a		/* special character 2 */
     75       1.1       mrg #define	STC_SCHR3		0x0b		/* special character 3 */
     76       1.1       mrg #define	STC_SCHR4		0x0c		/* special character 4 */
     77       1.1       mrg #define	STC_MCOR1		0x10		/* modem change option 1 */
     78       1.1       mrg #define	STC_MCOR2		0x11		/* modem change option 2 */
     79       1.1       mrg #define	STC_MCR			0x12		/* modem change */
     80       1.1       mrg #define	STC_RTPR		0x18		/* rx timeout period */
     81       1.1       mrg #define	STC_MSVR		0x28		/* modem signal value */
     82       1.1       mrg #define	STC_MSVRTS		0x29		/* modem signal value rts */
     83       1.1       mrg #define	STC_MSVDTR		0x2a		/* modem signal value dtr */
     84       1.1       mrg #define	STC_RBPRH		0x31		/* rx bit rate period high */
     85       1.1       mrg #define	STC_RBPRL		0x32		/* rx bit rate period low */
     86       1.1       mrg #define	STC_RBR			0x33		/* rx bit */
     87       1.1       mrg #define	STC_TBPRH		0x39		/* tx bit rate period high */
     88       1.1       mrg #define	STC_TBPRL		0x3a		/* tx bit rate period low */
     89       1.1       mrg #define	STC_GSVR		0x40		/* global service vector */
     90       1.1       mrg #define	STC_GSCR1		0x41		/* global service channel 1 */
     91       1.1       mrg #define	STC_GSCR2		0x42		/* global service channel 2 */
     92       1.1       mrg #define	STC_GSCR3		0x43		/* global service channel 3 */
     93       1.1       mrg #define	STC_MSMR		0x61		/* modem service match */
     94       1.1       mrg #define	STC_TSMR		0x62		/* tx service match */
     95       1.1       mrg #define	STC_RSMR		0x63		/* rx service match */
     96       1.1       mrg #define	STC_CAR			0x64		/* channel access */
     97       1.1       mrg #define	STC_SRSR		0x65		/* service request status */
     98       1.1       mrg #define	STC_SRCR		0x66		/* service request config */
     99       1.1       mrg #define	STC_GFRCR		0x6b		/* global firmware rev code */
    100       1.1       mrg #define	STC_PPRH		0x70		/* prescalar period high */
    101       1.1       mrg #define	STC_PPRL		0x71		/* prescalar period low */
    102       1.1       mrg #define	STC_MRAR		0x75		/* modem request ack */
    103       1.1       mrg #define	STC_TRAR		0x76		/* tx request ack */
    104       1.1       mrg #define	STC_RRAR		0x77		/* rx request ack */
    105       1.1       mrg #define	STC_RDR			0x78		/* rx data */
    106       1.1       mrg #define	STC_RCSR		0x7a		/* rx character status */
    107       1.1       mrg #define	STC_TDR			0x7b		/* tx data */
    108       1.1       mrg #define	STC_EOSRR		0x7f		/* end of service */
    109       1.1       mrg 
    110       1.1       mrg #define	STC_REGMAPSIZE		0x80
    111       1.1       mrg 
    112       1.1       mrg /* Global Firmware Revision Code Register (rw) */
    113       1.1       mrg #define	CD180_GFRCR_REV_B	0x81		/* CL-CD180B */
    114       1.1       mrg #define	CD180_GFRCR_REV_C	0x82		/* CL-CD180C */
    115       1.1       mrg 
    116       1.1       mrg /* Service Request Configuration Register (rw) (CD180C or higher) */
    117       1.1       mrg #define	CD180_SRCR_PKGTYP		0x80	/* pkg type,0=PLCC,1=PQFP */
    118       1.1       mrg #define	CD180_SRCR_REGACKEN		0x40	/* register ack enable */
    119       1.1       mrg #define	CD180_SRCR_DAISYEN		0x20	/* daisy chain enable */
    120       1.1       mrg #define	CD180_SRCR_GLOBPRI		0x10	/* global priority */
    121       1.1       mrg #define	CD180_SRCR_UNFAIR		0x08	/* use unfair interrupts */
    122       1.1       mrg #define	CD180_SRCR_AUTOPRI		0x02	/* automatic priority */
    123       1.1       mrg #define	CD180_SRCR_PRISEL		0x01	/* select rx/tx as high pri */
    124       1.1       mrg 
    125       1.1       mrg /* Prescalar Period Register High (rw) */
    126       1.1       mrg #define	CD180_PPRH	0xf0		/* high byte */
    127       1.1       mrg #define	CD180_PPRL	0x00		/* low byte */
    128       1.1       mrg 
    129       1.1       mrg /* Global Service Vector Register (rw) */
    130       1.1       mrg /* Modem Request Acknowledgement Register (ro) (and IACK equivalent) */
    131       1.1       mrg /* Receive Request Acknowledgement Register (ro) (and IACK equivalent) */
    132       1.1       mrg /* Transmit Request Acknowledgement Register (ro) (and IACK equivalent) */
    133       1.1       mrg #define	CD180_GSVR_USERMASK		0xf8	/* user defined bits */
    134       1.1       mrg #define	CD180_GSVR_IMASK		0x07	/* interrupt type mask */
    135       1.1       mrg #define	CD180_GSVR_NOREQUEST		0x00	/* no request pending */
    136       1.1       mrg #define	CD180_GSVR_STATCHG		0x01	/* modem signal change */
    137       1.1       mrg #define	CD180_GSVR_TXDATA		0x02	/* tx service request */
    138       1.1       mrg #define	CD180_GSVR_RXGOOD		0x03	/* rx service request */
    139       1.1       mrg #define	CD180_GSVR_reserved1		0x04	/* reserved */
    140       1.1       mrg #define	CD180_GSVR_reserved2		0x05	/* reserved */
    141       1.1       mrg #define	CD180_GSVR_reserved3		0x06	/* reserved */
    142       1.1       mrg #define	CD180_GSVR_RXEXCEPTION		0x07	/* rx exception request */
    143       1.1       mrg 
    144       1.1       mrg /* Service Request Status Register (ro) (CD180C and higher) */
    145       1.1       mrg #define	CD180_SRSR_MREQINT		0x01	/* modem request internal */
    146       1.1       mrg #define	CD180_SRSR_MREQEXT		0x02	/* modem request external */
    147       1.1       mrg #define	CD180_SRSR_TREQINT		0x04	/* tx request internal */
    148       1.1       mrg #define	CD180_SRSR_TREQEXT		0x08	/* tx request external */
    149       1.1       mrg #define	CD180_SRSR_RREQINT		0x10	/* rx request internal */
    150       1.1       mrg #define	CD180_SRSR_RREQEXT		0x20	/* rx request external */
    151       1.1       mrg #define	CD180_SRSR_ILV_MASK		0xc0	/* internal service context */
    152       1.1       mrg #define	CD180_SRSR_ILV_NONE		0x00	/* not in service context */
    153       1.1       mrg #define	CD180_SRSR_ILV_RX		0xc0	/* in rx service context */
    154       1.1       mrg #define	CD180_SRSR_ILV_TX		0x80	/* in tx service context */
    155       1.1       mrg #define	CD180_SRSR_ILV_MODEM		0x40	/* in modem service context */
    156       1.1       mrg 
    157       1.1       mrg /* Global Service Channel Register 1,2,3 (rw) */
    158       1.1       mrg #define	CD180_GSCR_CHANNEL(gscr)	(((gscr) >> 2) & 7)
    159       1.1       mrg 
    160       1.1       mrg /* Receive Data Count Register (ro) */
    161       1.1       mrg #define	CD180_RDCR_MASK			0x0f	/* mask for fifo length */
    162       1.1       mrg 
    163       1.1       mrg /* Receive Character Status Register (ro) */
    164       1.1       mrg #define	CD180_RCSR_TO			0x80	/* time out */
    165       1.1       mrg #define	CD180_RCSR_SCD2			0x40	/* special char detect 2 */
    166       1.1       mrg #define	CD180_RCSR_SCD1			0x20	/* special char detect 1 */
    167       1.1       mrg #define	CD180_RCSR_SCD0			0x10	/* special char detect 0 */
    168       1.1       mrg #define	CD180_RCSR_BE			0x08	/* break exception */
    169       1.1       mrg #define	CD180_RCSR_PE			0x04	/* parity exception */
    170       1.1       mrg #define	CD180_RCSR_FE			0x02	/* framing exception */
    171       1.1       mrg #define	CD180_RCSR_OE			0x01	/* overrun exception */
    172       1.1       mrg 
    173       1.1       mrg /* Service Request Enable Register (rw) */
    174       1.1       mrg #define	CD180_SRER_DSR			0x80	/* DSR service request */
    175       1.1       mrg #define	CD180_SRER_CD			0x40	/* CD service request */
    176       1.1       mrg #define	CD180_SRER_CTS			0x20	/* CTS service request */
    177       1.1       mrg #define	CD180_SRER_RXD			0x10	/* RXD service request */
    178       1.1       mrg #define	CD180_SRER_RXSCD		0x08	/* RX special char request */
    179       1.1       mrg #define	CD180_SRER_TXD			0x04	/* TX ready service request */
    180       1.1       mrg #define	CD180_SRER_TXE			0x02	/* TX empty service request */
    181       1.1       mrg #define	CD180_SRER_NNDT			0x01	/* No new data timeout req */
    182       1.1       mrg 
    183       1.1       mrg /* Channel Command Register (rw) */
    184       1.1       mrg /* Reset Channel Command */
    185       1.1       mrg #define	CD180_CCR_CMD_RESET		0x80	/* chip/channel reset */
    186       1.1       mrg #define CD180_CCR_RESETALL		0x01	/* global reset */
    187       1.1       mrg #define	CD180_CCR_RESETCHAN		0x00	/* current channel reset */
    188       1.1       mrg /* Channel Option Register Command */
    189       1.1       mrg #define	CD180_CCR_CMD_COR		0x40	/* channel opt reg changed */
    190       1.1       mrg #define	CD180_CCR_CORCHG1		0x02	/* cor1 has changed */
    191       1.1       mrg #define	CD180_CCR_CORCHG2		0x04	/* cor2 has changed */
    192       1.1       mrg #define	CD180_CCR_CORCHG3		0x08	/* cor3 has changed */
    193       1.1       mrg /* Send Special Character Command */
    194       1.1       mrg #define	CD180_CCR_CMD_SPC		0x20	/* send special chars changed */
    195       1.1       mrg #define	CD180_CCR_SSPC0			0x01	/* send special char 0 change */
    196       1.1       mrg #define	CD180_CCR_SSPC1			0x02	/* send special char 1 change */
    197       1.1       mrg #define	CD180_CCR_SSPC2			0x04	/* send special char 2 change */
    198       1.1       mrg /* Channel Control Command */
    199       1.1       mrg #define	CD180_CCR_CMD_CHAN		0x10	/* channel control command */
    200       1.1       mrg #define	CD180_CCR_CHAN_TXEN		0x08	/* enable channel tx */
    201       1.1       mrg #define	CD180_CCR_CHAN_TXDIS		0x04	/* disable channel tx */
    202       1.1       mrg #define	CD180_CCR_CHAN_RXEN		0x02	/* enable channel rx */
    203       1.1       mrg #define	CD180_CCR_CHAN_RXDIS		0x01	/* disable channel rx */
    204       1.1       mrg 
    205       1.1       mrg /* Channel Option Register 1 (rw) */
    206       1.1       mrg #define	CD180_COR1_EVENPAR		0x00	/* even parity */
    207       1.1       mrg #define	CD180_COR1_ODDPAR		0x80	/* odd parity */
    208       1.1       mrg #define	CD180_COR1_PARMODE_NO		0x00	/* no parity */
    209       1.1       mrg #define	CD180_COR1_PARMODE_FORCE	0x20	/* force (odd=1, even=0) */
    210       1.1       mrg #define CD180_COR1_PARMODE_NORMAL	0x40	/* normal parity mode */
    211       1.1       mrg #define	CD180_COR1_PARMODE_NA		0x60	/* notused */
    212       1.1       mrg #define	CD180_COR1_IGNPAR		0x10	/* ignore parity */
    213       1.1       mrg #define	CD180_COR1_STOP1		0x00	/* 1 stop bit */
    214       1.1       mrg #define	CD180_COR1_STOP15		0x04	/* 1.5 stop bits */
    215       1.1       mrg #define	CD180_COR1_STOP2		0x08	/* 2 stop bits */
    216       1.1       mrg #define	CD180_COR1_STOP25		0x0c	/* 2.5 stop bits */
    217       1.1       mrg #define	CD180_COR1_CS5			0x00	/* 5 bit characters */
    218       1.1       mrg #define	CD180_COR1_CS6			0x01	/* 6 bit characters */
    219       1.1       mrg #define	CD180_COR1_CS7			0x02	/* 7 bit characters */
    220       1.1       mrg #define	CD180_COR1_CS8			0x03	/* 8 bit characters */
    221       1.1       mrg 
    222       1.1       mrg /* Channel Option Register 2 (rw) */
    223       1.1       mrg #define	CD180_COR2_IXM			0x80	/* implied xon mode */
    224       1.1       mrg #define	CD180_COR2_TXIBE		0x40	/* tx in-band flow control */
    225       1.1       mrg #define	CD180_COR2_ETC			0x20	/* embedded tx command enbl */
    226       1.1       mrg #define	CD180_COR2_LLM			0x10	/* local loopback mode */
    227       1.1       mrg #define	CD180_COR2_RLM			0x08	/* remote loopback mode */
    228       1.1       mrg #define	CD180_COR2_RTSAO		0x04	/* RTS automatic output enbl */
    229       1.1       mrg #define	CD180_COR2_CTSAE		0x02	/* CTS automatic enable */
    230       1.1       mrg #define	CD180_COR2_DSRAE		0x01	/* DSR automatic enable */
    231       1.1       mrg 
    232       1.1       mrg /* Channel Option Register 3 (rw) */
    233       1.1       mrg #define	CD180_COR3_XON2			0x80	/* XON char in spc1&3 */
    234       1.1       mrg #define	CD180_COR3_XON1			0x00	/* XON char in spc1 */
    235       1.1       mrg #define	CD180_COR3_XOFF2		0x40	/* XOFF char in spc2&4 */
    236       1.1       mrg #define	CD180_COR3_XOFF1		0x00	/* XOFF char in spc2 */
    237       1.1       mrg #define	CD180_COR3_FCT			0x20	/* flow control transparency */
    238       1.1       mrg #define	CD180_COR3_SCDE			0x10	/* special char recognition */
    239       1.1       mrg #define	CD180_COR3_RXFIFO_MASK		0x0f	/* rx fifo threshold */
    240       1.1       mrg 
    241       1.1       mrg /* Channel Control Status Register (ro) */
    242       1.1       mrg #define	CD180_CCSR_RXEN			0x80	/* rx is enabled */
    243       1.1       mrg #define	CD180_CCSR_RXFLOFF		0x40	/* rx flow-off */
    244       1.1       mrg #define	CD180_CCSR_RXFLON		0x20	/* rx flow-on */
    245       1.1       mrg #define	CD180_CCSR_TXEN			0x08	/* tx is enabled */
    246       1.1       mrg #define	CD180_CCSR_TXFLOFF		0x04	/* tx flow-off */
    247       1.1       mrg #define	CD180_CCSR_TXFLON		0x02	/* tx flow-on */
    248       1.1       mrg 
    249       1.1       mrg /* Receiver Bit Register (ro) */
    250       1.1       mrg #define	CD180_RBR_RXD			0x40	/* state of RxD pin */
    251       1.1       mrg #define	CD180_RBR_STARTHUNT		0x20	/* looking for start bit */
    252       1.1       mrg 
    253       1.1       mrg /* Modem Change Register (rw) */
    254       1.1       mrg #define	CD180_MCR_DSR			0x80	/* DSR changed */
    255       1.1       mrg #define	CD180_MCR_CD			0x40	/* CD changed */
    256       1.1       mrg #define	CD180_MCR_CTS			0x20	/* CTS changed */
    257       1.1       mrg 
    258       1.1       mrg /* Modem Change Option Register 1 (rw) */
    259       1.1       mrg #define	CD180_MCOR1_DSRZD		0x80	/* catch 0->1 DSR changes */
    260       1.1       mrg #define	CD180_MCOR1_CDZD		0x40	/* catch 0->1 CD changes */
    261       1.1       mrg #define	CD180_MCOR1_CTSZD		0x40	/* catch 0->1 CTS changes */
    262       1.1       mrg #define	CD180_MCOR1_DTRTHRESH		0x0f	/* DTR threshold mask */
    263       1.1       mrg 
    264       1.1       mrg /* Modem Change Option Register 2 (rw) */
    265       1.1       mrg #define	CD180_MCOR2_DSROD		0x80	/* catch 1->0 DSR changes */
    266       1.1       mrg #define	CD180_MCOR2_CDOD		0x40	/* catch 1->0 CD changes */
    267       1.1       mrg #define	CD180_MCOR2_CTSOD		0x20	/* catch 1->0 CTS changes */
    268       1.1       mrg 
    269       1.1       mrg /* Modem Signal Value Register (rw) */
    270       1.1       mrg #define	CD180_MSVR_DSR			0x80	/* DSR input state */
    271       1.1       mrg #define	CD180_MSVR_CD			0x40	/* CD input state */
    272       1.1       mrg #define	CD180_MSVR_CTS			0x20	/* CTS input state */
    273       1.1       mrg #define	CD180_MSVR_DTR			0x02	/* DTR output state */
    274       1.1       mrg #define	CD180_MSVR_RTS			0x01	/* RTS output state */
    275       1.1       mrg 
    276       1.1       mrg /* Modem Signal Value Register - Request To Send (w) (CD180C and higher) */
    277       1.1       mrg #define	CD180_MSVRTS_RTS		0x01	/* RTS signal value */
    278       1.1       mrg 
    279       1.1       mrg /* Modem Signal Value Register - Data Terminal Ready (w) (CD180C and higher) */
    280       1.1       mrg #define	CD180_MSVDTR_DTR		0x02	/* DTR signal value */
    281       1.1       mrg 
    282       1.1       mrg /*
    283       1.1       mrg  * The register map for the SUNW,spif looks something like:
    284       1.1       mrg  *    Offset:		Function:
    285       1.1       mrg  *	0000 - 03ff	Boot ROM
    286       1.1       mrg  *	0400 - 0407	dtr latches (one per port)
    287       1.1       mrg  *	0409 - 07ff	unused
    288       1.1       mrg  *	0800 - 087f	CD180 registers (normal mapping)
    289       1.1       mrg  *	0880 - 0bff	unused
    290       1.1       mrg  *	0c00 - 0c7f	CD180 registers (*iack mapping)
    291       1.1       mrg  *	0c80 - 0dff	unused
    292       1.1       mrg  *	0e00 - 1fff	PPC registers
    293       1.1       mrg  *
    294       1.1       mrg  * One note about the DTR latches:  The values stored there are reversed.
    295       1.1       mrg  * By writing a 1 to the latch, DTR is lowered, and by writing a 0, DTR
    296       1.1       mrg  * is raised.  The latches cannot be read, and no other value can be written
    297       1.1       mrg  * there or the system will crash due to "excessive bus loading (see
    298       1.1       mrg  * SBus loading and capacitance spec)"
    299       1.1       mrg  *
    300       1.1       mrg  * The *iack registers are read/written with the IACK bit set.  When
    301       1.1       mrg  * the interrupt routine starts, it reads the MRAR, TRAR, and RRAR registers
    302       1.1       mrg  * from this mapping.  This signals an interrupt acknowledgement cycle.
    303       1.1       mrg  * (NOTE: these are not really the MRAR, TRAR, and RRAR... They are copies
    304       1.1       mrg  * of the GSVR, I just mapped them to the same location as the mrar, trar,
    305       1.1       mrg  * and rrar because it seemed appropriate).
    306       1.1       mrg  */
    307       1.1       mrg #define	DTR_REG_OFFSET		0x400		/* DTR latches */
    308       1.1       mrg #define	DTR_REG_LEN		0x8
    309       1.1       mrg #define	STC_REG_OFFSET		0x800		/* normal cd180 access */
    310       1.1       mrg #define	STC_REG_LEN		0x80
    311       1.1       mrg #define	ISTC_REG_OFFSET		0xc00		/* IACK cd180 access */
    312       1.1       mrg #define	ISTC_REG_LEN		STC_REG_LEN
    313       1.1       mrg #define	PPC_REG_OFFSET		0xe00		/* PPC registers */
    314       1.1       mrg #define	PPC_REG_LEN		0x200
    315       1.1       mrg 
    316       1.1       mrg /*
    317       1.1       mrg  * The mapping of minor device number -> card and port is done as
    318       1.1       mrg  * follows by default:
    319       1.1       mrg  *
    320       1.1       mrg  *  +---+---+---+---+---+---+---+---+
    321       1.1       mrg  *  | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
    322       1.1       mrg  *  +---+---+---+---+---+---+---+---+
    323       1.1       mrg  *    |   |   |   |   |   |   |   |
    324       1.1       mrg  *    |   |   |   |   |   +---+---+---> port number
    325       1.1       mrg  *    |   |   |   |   |
    326       1.1       mrg  *    |   |   |   |   +---------------> unused
    327       1.1       mrg  *    |   |   |   |
    328       1.5  christos  *    |   |   |   +-------------------> unused
    329       1.1       mrg  *    |   |   |
    330       1.1       mrg  *    |   |   +-----------------------> unused
    331       1.1       mrg  *    |   |
    332       1.1       mrg  *    +---+---------------------------> card number
    333       1.1       mrg  *
    334       1.1       mrg  */
    335       1.1       mrg #define SPIF_MAX_CARDS		4
    336       1.1       mrg #define SPIF_MAX_TTY		8
    337       1.1       mrg #define SPIF_MAX_BPP		1
    338       1.1       mrg 
    339       1.1       mrg /*
    340       1.1       mrg  * device selectors
    341       1.1       mrg  */
    342       1.5  christos #define SPIF_CARD(x)	((TTUNIT(x) >> 6) & 0x03)
    343       1.5  christos #define SPIF_PORT(x)	(TTUNIT(x) & 0x07)
    344       1.5  christos #define STTY_DIALOUT(x) TTDIALOUT(x)
    345       1.1       mrg 
    346       1.1       mrg #define	STTY_RX_FIFO_THRESHOLD	4
    347       1.1       mrg #define	STTY_RX_DTR_THRESHOLD	7
    348       1.1       mrg #define	CD180_TX_FIFO_SIZE	8		/* 8 chars of fifo */
    349       1.1       mrg 
    350       1.1       mrg /*
    351       1.1       mrg  * These are the offsets of the MRAR, TRAR, and RRAR in *IACK space.
    352       1.1       mrg  * The high bit must be set as per specs for the MSMR, TSMR, and RSMR.
    353       1.1       mrg  */
    354       1.1       mrg #define	SPIF_MSMR	(0x80 | STC_MRAR)	/* offset of MRAR | 0x80 */
    355       1.1       mrg #define	SPIF_TSMR	(0x80 | STC_TRAR)	/* offset of TRAR | 0x80 */
    356       1.1       mrg #define	SPIF_RSMR	(0x80 | STC_RRAR)	/* offset of RRAR | 0x80 */
    357       1.1       mrg 
    358       1.1       mrg /*
    359       1.1       mrg  * "verosc" node tells which oscillator we have.
    360       1.1       mrg  */
    361       1.1       mrg #define	SPIF_OSC9	1		/* 9.8304 MHz */
    362       1.1       mrg #define	SPIF_OSC10	2		/* 10MHz */
    363       1.1       mrg 
    364       1.1       mrg /*
    365       1.1       mrg  * There are two interrupts, serial gets interrupt[0], and parallel
    366       1.1       mrg  * gets interrupt[1]
    367       1.1       mrg  */
    368       1.1       mrg #define	SERIAL_INTR	0
    369       1.1       mrg #define	PARALLEL_INTR	1
    370       1.1       mrg 
    371       1.1       mrg /*
    372       1.1       mrg  * spif tty flags
    373       1.1       mrg  */
    374       1.1       mrg #define	STTYF_CDCHG		0x01		/* carrier changed */
    375       1.1       mrg #define	STTYF_RING_OVERFLOW	0x02		/* ring buffer overflowed */
    376       1.1       mrg #define	STTYF_DONE		0x04		/* done... flush buffers */
    377       1.1       mrg #define	STTYF_SET_BREAK		0x08		/* set break signal */
    378       1.1       mrg #define	STTYF_CLR_BREAK		0x10		/* clear break signal */
    379       1.1       mrg #define	STTYF_STOP		0x20		/* stopped */
    380       1.1       mrg 
    381       1.1       mrg #define	STTY_RBUF_SIZE		(2 * 512)
    382       1.1       mrg 
    383       1.1       mrg /*
    384       1.1       mrg  * internal function prototypes
    385       1.1       mrg  */
    386       1.4    cegger int	spif_match(device_t, cfdata_t, void *);
    387       1.4    cegger void	spif_attach(device_t, device_t, void *);
    388       1.1       mrg 
    389       1.4    cegger int	stty_match(device_t, cfdata_t, void *);
    390       1.4    cegger void	stty_attach(device_t, device_t, void *);
    391       1.1       mrg 
    392       1.1       mrg int	spif_stcintr(void *);
    393       1.1       mrg int	spif_stcintr_mx(struct spif_softc *, int *);
    394       1.1       mrg int	spif_stcintr_tx(struct spif_softc *, int *);
    395       1.1       mrg int	spif_stcintr_rx(struct spif_softc *, int *);
    396       1.1       mrg int	spif_stcintr_rxexception(struct spif_softc *, int *);
    397       1.1       mrg void	spif_softintr(void *);
    398       1.1       mrg 
    399       1.1       mrg int	stty_param(struct tty *, struct termios *);
    400       1.1       mrg int	stty_modem_control(struct stty_port *, int, int);
    401       1.1       mrg void	stty_write_ccr(struct spif_softc *, u_int8_t);
    402       1.1       mrg int	stty_compute_baud(speed_t, int, u_int8_t *, u_int8_t *);
    403       1.1       mrg void	stty_start(struct tty *);
    404       1.1       mrg 
    405       1.4    cegger int	sbpp_match(device_t, cfdata_t, void *);
    406       1.4    cegger void	sbpp_attach(device_t, device_t, void *);
    407       1.1       mrg 
    408       1.1       mrg int	sbpp_rw(dev_t, struct uio *);
    409       1.1       mrg int	spif_ppcintr(void *);
    410