156817Sralph /*- 2*63207Sbostic * Copyright (c) 1992, 1993 3*63207Sbostic * The Regents of the University of California. All rights reserved. 456817Sralph * 556817Sralph * This code is derived from software contributed to Berkeley by 656817Sralph * Ralph Campbell and Rick Macklem. 756817Sralph * 856817Sralph * %sccs.include.redist.c% 956817Sralph * 10*63207Sbostic * @(#)sccreg.h 8.1 (Berkeley) 06/10/93 1156817Sralph */ 1256817Sralph 1356817Sralph /* 1456817Sralph * Mach Operating System 1556817Sralph * Copyright (c) 1991,1990,1989 Carnegie Mellon University 1656817Sralph * All Rights Reserved. 1756817Sralph * 1856817Sralph * Permission to use, copy, modify and distribute this software and its 1956817Sralph * documentation is hereby granted, provided that both the copyright 2056817Sralph * notice and this permission notice appear in all copies of the 2156817Sralph * software, derivative works or modified versions, and any portions 2256817Sralph * thereof, and that both notices appear in supporting documentation. 2356817Sralph * 2456817Sralph * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 2556817Sralph * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 2656817Sralph * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 2756817Sralph * 2856817Sralph * Carnegie Mellon requests users of this software to return to 2956817Sralph * 3056817Sralph * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 3156817Sralph * School of Computer Science 3256817Sralph * Carnegie Mellon University 3356817Sralph * Pittsburgh PA 15213-3890 3456817Sralph * 3556817Sralph * any improvements or extensions that they make and grant Carnegie Mellon 3656817Sralph * the rights to redistribute these changes. 3756817Sralph */ 3856817Sralph /* 3956817Sralph * Definitions for Intel 82530 serial communications chip. 4056817Sralph * Each chip is a dual uart with the A channels used for the keyboard and 4156817Sralph * mouse with the B channel(s) for comm ports with modem control. Since 4256817Sralph * some registers are used for the other channel, the following macros 4356817Sralph * are used to access the register ports. 4456817Sralph */ 4556817Sralph typedef struct { 4656817Sralph /* Channel B is first, then A */ 4756817Sralph struct { 4856817Sralph char scc_pad0; 4956817Sralph volatile u_char scc_command; /* reg select */ 5056817Sralph char scc_pad1[3]; 5156817Sralph volatile u_char scc_data; /* Rx/Tx buffer */ 5256817Sralph char scc_pad3[2]; 5356817Sralph } scc_channel[2]; 5456817Sralph } scc_regmap_t; 5556817Sralph 5656817Sralph #define SCC_CHANNEL_A 1 5756817Sralph #define SCC_CHANNEL_B 0 5856817Sralph 5956817Sralph #define SCC_INIT_REG(scc,chan) { \ 6056817Sralph char tmp; \ 6156817Sralph tmp = (scc)->scc_channel[(chan)].scc_command; \ 6256817Sralph tmp = (scc)->scc_channel[(chan)].scc_command; \ 6356817Sralph } 6456817Sralph 6556817Sralph #define SCC_READ_REG(scc,chan,reg,val) { \ 6656817Sralph (scc)->scc_channel[(chan)].scc_command = (reg); \ 6756817Sralph (val) = (scc)->scc_channel[(chan)].scc_command; \ 6856817Sralph } 6956817Sralph 7056817Sralph #define SCC_READ_REG_ZERO(scc,chan,val) { \ 7156817Sralph (val) = (scc)->scc_channel[(chan)].scc_command; \ 7256817Sralph } 7356817Sralph 7456817Sralph #define SCC_WRITE_REG(scc,chan,reg,val) { \ 7556817Sralph (scc)->scc_channel[(chan)].scc_command = (reg); \ 7656817Sralph (scc)->scc_channel[(chan)].scc_command = (val); \ 7756817Sralph } 7856817Sralph 7956817Sralph #define SCC_WRITE_REG_ZERO(scc,chan,val) { \ 8056817Sralph (scc)->scc_channel[(chan)].scc_command = (val); \ 8156817Sralph } 8256817Sralph 8356817Sralph #define SCC_READ_DATA(scc,chan,val) { \ 8456817Sralph (val) = (scc)->scc_channel[(chan)].scc_data; \ 8556817Sralph } 8656817Sralph 8756817Sralph #define SCC_WRITE_DATA(scc,chan,val) { \ 8856817Sralph (scc)->scc_channel[(chan)].scc_data = (val); \ 8956817Sralph } 9056817Sralph 9156817Sralph #define SCC_RR0 0 /* status register */ 9256817Sralph #define SCC_RR1 1 /* special receive conditions */ 9356817Sralph #define SCC_RR2 2 /* (modified) interrupt vector */ 9456817Sralph #define SCC_RR3 3 /* interrupts pending (cha A only) */ 9556817Sralph #define SCC_RR8 8 /* recv buffer (alias for data) */ 9656817Sralph #define SCC_RR10 10 /* sdlc status */ 9756817Sralph #define SCC_RR12 12 /* BRG constant, low part */ 9856817Sralph #define SCC_RR13 13 /* BRG constant, high part */ 9956817Sralph #define SCC_RR15 15 /* interrupts currently enabled */ 10056817Sralph 10156817Sralph #define SCC_WR0 0 /* reg select, and commands */ 10256817Sralph #define SCC_WR1 1 /* interrupt and DMA enables */ 10356817Sralph #define SCC_WR2 2 /* interrupt vector */ 10456817Sralph #define SCC_WR3 3 /* receiver params and enables */ 10556817Sralph #define SCC_WR4 4 /* clock/char/parity params */ 10656817Sralph #define SCC_WR5 5 /* xmit params and enables */ 10756817Sralph #define SCC_WR6 6 /* synchr SYNCH/address */ 10856817Sralph #define SCC_WR7 7 /* synchr SYNCH/flag */ 10956817Sralph #define SCC_WR8 8 /* xmit buffer (alias for data) */ 11056817Sralph #define SCC_WR9 9 /* vectoring and resets */ 11156817Sralph #define SCC_WR10 10 /* synchr params */ 11256817Sralph #define SCC_WR11 11 /* clocking definitions */ 11356817Sralph #define SCC_WR12 12 /* BRG constant, low part */ 11456817Sralph #define SCC_WR13 13 /* BRG constant, high part */ 11556817Sralph #define SCC_WR14 14 /* BRG enables and commands */ 11656817Sralph #define SCC_WR15 15 /* interrupt enables */ 11756817Sralph 11856817Sralph /* 11956817Sralph * Read registers defines 12056817Sralph */ 12156817Sralph #define SCC_RR0_BREAK 0x80 /* break detected (rings twice), or */ 12256817Sralph #define SCC_RR0_ABORT 0x80 /* abort (synchr) */ 12356817Sralph #define SCC_RR0_TX_UNDERRUN 0x40 /* xmit buffer empty/end of message */ 12456817Sralph #define SCC_RR0_CTS 0x20 /* clear-to-send pin active (sampled 12556817Sralph only on intr and after RESI cmd */ 12656817Sralph #define SCC_RR0_SYNCH 0x10 /* SYNCH found/still hunting */ 12756817Sralph #define SCC_RR0_DCD 0x08 /* carrier-detect (same as CTS) */ 12856817Sralph #define SCC_RR0_TX_EMPTY 0x04 /* xmit buffer empty */ 12956817Sralph #define SCC_RR0_ZERO_COUNT 0x02 /* ? */ 13056817Sralph #define SCC_RR0_RX_AVAIL 0x01 /* recv fifo not empty */ 13156817Sralph 13256817Sralph #define SCC_RR1_EOF 0x80 /* end-of-frame, SDLC mode */ 13356817Sralph #define SCC_RR1_CRC_ERR 0x40 /* incorrect CRC or.. */ 13456817Sralph #define SCC_RR1_FRAME_ERR 0x40 /* ..bad frame */ 13556817Sralph #define SCC_RR1_RX_OVERRUN 0x20 /* rcv fifo overflow */ 13656817Sralph #define SCC_RR1_PARITY_ERR 0x10 /* incorrect parity in data */ 13756817Sralph #define SCC_RR1_RESIDUE0 0x08 13856817Sralph #define SCC_RR1_RESIDUE1 0x04 13956817Sralph #define SCC_RR1_RESIDUE2 0x02 14056817Sralph #define SCC_RR1_ALL_SENT 0x01 14156817Sralph 14256817Sralph /* RR2 contains the interrupt vector unmodified (channel A) or 14356817Sralph modified as follows (channel B, if vector-include-status) */ 14456817Sralph 14556817Sralph #define SCC_RR2_STATUS(val) ((val)&0xf) 14656817Sralph 14756817Sralph #define SCC_RR2_B_XMIT_DONE 0x0 14856817Sralph #define SCC_RR2_B_EXT_STATUS 0x2 14956817Sralph #define SCC_RR2_B_RECV_DONE 0x4 15056817Sralph #define SCC_RR2_B_RECV_SPECIAL 0x6 15156817Sralph #define SCC_RR2_A_XMIT_DONE 0x8 15256817Sralph #define SCC_RR2_A_EXT_STATUS 0xa 15356817Sralph #define SCC_RR2_A_RECV_DONE 0xc 15456817Sralph #define SCC_RR2_A_RECV_SPECIAL 0xe 15556817Sralph 15656817Sralph /* Interrupts pending, to be read from channel A only (B raz) */ 15756817Sralph #define SCC_RR3_zero 0xc0 15856817Sralph #define SCC_RR3_RX_IP_A 0x20 15956817Sralph #define SCC_RR3_TX_IP_A 0x10 16056817Sralph #define SCC_RR3_EXT_IP_A 0x08 16156817Sralph #define SCC_RR3_RX_IP_B 0x04 16256817Sralph #define SCC_RR3_TX_IP_B 0x02 16356817Sralph #define SCC_RR3_EXT_IP_B 0x01 16456817Sralph 16556817Sralph /* RR8 is the receive data buffer, a 3 deep FIFO */ 16656817Sralph #define SCC_RECV_BUFFER SCC_RR8 16756817Sralph #define SCC_RECV_FIFO_DEEP 3 16856817Sralph 16956817Sralph #define SCC_RR10_1CLKS 0x80 17056817Sralph #define SCC_RR10_2CLKS 0x40 17156817Sralph #define SCC_RR10_zero 0x2d 17256817Sralph #define SCC_RR10_LOOP_SND 0x10 17356817Sralph #define SCC_RR10_ON_LOOP 0x02 17456817Sralph 17556817Sralph /* RR12/RR13 hold the timing base, upper byte in RR13 */ 17656817Sralph 17756817Sralph #define SCC_GET_TIMING_BASE(scc,chan,val) { \ 17856817Sralph register char tmp; \ 17956817Sralph SCC_READ_REG(scc,chan,SCC_RR12,val);\ 18056817Sralph SCC_READ_REG(scc,chan,SCC_RR13,tmp);\ 18156817Sralph (val) = ((val)<<8)|(tmp&0xff);\ 18256817Sralph } 18356817Sralph 18456817Sralph #define SCC_RR15_BREAK_IE 0x80 18556817Sralph #define SCC_RR15_TX_UNDERRUN_IE 0x40 18656817Sralph #define SCC_RR15_CTS_IE 0x20 18756817Sralph #define SCC_RR15_SYNCH_IE 0x10 18856817Sralph #define SCC_RR15_DCD_IE 0x08 18956817Sralph #define SCC_RR15_zero 0x05 19056817Sralph #define SCC_RR15_ZERO_COUNT_IE 0x02 19156817Sralph 19256817Sralph /* 19356817Sralph * Write registers defines 19456817Sralph */ 19556817Sralph /* WR0 is used for commands too */ 19656817Sralph #define SCC_RESET_TXURUN_LATCH 0xc0 19756817Sralph #define SCC_RESET_TX_CRC 0x80 19856817Sralph #define SCC_RESET_RX_CRC 0x40 19956817Sralph #define SCC_RESET_HIGHEST_IUS 0x38 /* channel A only */ 20056817Sralph #define SCC_RESET_ERROR 0x30 20156817Sralph #define SCC_RESET_TX_IP 0x28 20256817Sralph #define SCC_IE_NEXT_CHAR 0x20 20356817Sralph #define SCC_SEND_SDLC_ABORT 0x18 20456817Sralph #define SCC_RESET_EXT_IP 0x10 20556817Sralph 20656817Sralph #define SCC_WR1_DMA_ENABLE 0x80 /* dma control */ 20756817Sralph #define SCC_WR1_DMA_MODE 0x40 /* drive ~req for DMA controller */ 20856817Sralph #define SCC_WR1_DMA_RECV_DATA 0x20 /* from wire to host memory */ 20956817Sralph /* interrupt enable/conditions */ 21056817Sralph #define SCC_WR1_RXI_SPECIAL_O 0x18 /* on special only */ 21156817Sralph #define SCC_WR1_RXI_ALL_CHAR 0x10 /* on each char, or special */ 21256817Sralph #define SCC_WR1_RXI_FIRST_CHAR 0x08 /* on first char, or special */ 21356817Sralph #define SCC_WR1_RXI_DISABLE 0x00 /* never on recv */ 21456817Sralph #define SCC_WR1_PARITY_IE 0x04 /* on parity errors */ 21556817Sralph #define SCC_WR1_TX_IE 0x02 21656817Sralph #define SCC_WR1_EXT_IE 0x01 21756817Sralph 21856817Sralph /* WR2 is common and contains the interrupt vector (high nibble) */ 21956817Sralph 22056817Sralph #define SCC_WR3_RX_8_BITS 0xc0 22156817Sralph #define SCC_WR3_RX_6_BITS 0x80 22256817Sralph #define SCC_WR3_RX_7_BITS 0x40 22356817Sralph #define SCC_WR3_RX_5_BITS 0x00 22456817Sralph #define SCC_WR3_AUTO_ENABLE 0x20 22556817Sralph #define SCC_WR3_HUNT_MODE 0x10 22656817Sralph #define SCC_WR3_RX_CRC_ENABLE 0x08 22756817Sralph #define SCC_WR3_SDLC_SRCH 0x04 22856817Sralph #define SCC_WR3_INHIBIT_SYNCH 0x02 22956817Sralph #define SCC_WR3_RX_ENABLE 0x01 23056817Sralph 23156817Sralph /* Should be re-written after reset */ 23256817Sralph #define SCC_WR4_CLK_x64 0xc0 /* clock divide factor */ 23356817Sralph #define SCC_WR4_CLK_x32 0x80 23456817Sralph #define SCC_WR4_CLK_x16 0x40 23556817Sralph #define SCC_WR4_CLK_x1 0x00 23656817Sralph #define SCC_WR4_EXT_SYNCH_MODE 0x30 /* synch modes */ 23756817Sralph #define SCC_WR4_SDLC_MODE 0x20 23856817Sralph #define SCC_WR4_16BIT_SYNCH 0x10 23956817Sralph #define SCC_WR4_8BIT_SYNCH 0x00 24056817Sralph #define SCC_WR4_2_STOP 0x0c /* asynch modes */ 24156817Sralph #define SCC_WR4_1_5_STOP 0x08 24256817Sralph #define SCC_WR4_1_STOP 0x04 24356817Sralph #define SCC_WR4_SYNCH_MODE 0x00 24456817Sralph #define SCC_WR4_EVEN_PARITY 0x02 24556817Sralph #define SCC_WR4_PARITY_ENABLE 0x01 24656817Sralph 24756817Sralph #define SCC_WR5_DTR 0x80 /* drive DTR pin */ 24856817Sralph #define SCC_WR5_TX_8_BITS 0x60 24956817Sralph #define SCC_WR5_TX_6_BITS 0x40 25056817Sralph #define SCC_WR5_TX_7_BITS 0x20 25156817Sralph #define SCC_WR5_TX_5_BITS 0x00 25256817Sralph #define SCC_WR5_SEND_BREAK 0x10 25356817Sralph #define SCC_WR5_TX_ENABLE 0x08 25456817Sralph #define SCC_WR5_CRC_16 0x04 /* CRC if non zero, .. */ 25556817Sralph #define SCC_WR5_SDLC 0x00 /* ..SDLC otherwise */ 25656817Sralph #define SCC_WR5_RTS 0x02 /* drive RTS pin */ 25756817Sralph #define SCC_WR5_TX_CRC_ENABLE 0x01 25856817Sralph 25956817Sralph /* Registers WR6 and WR7 are for synch modes data, with among other things: */ 26056817Sralph 26156817Sralph #define SCC_WR6_BISYNCH_12 0x0f 26256817Sralph #define SCC_WR6_SDLC_RANGE_MASK 0x0f 26356817Sralph #define SCC_WR7_SDLC_FLAG 0x7e 26456817Sralph 26556817Sralph /* WR8 is the transmit data buffer (no FIFO) */ 26656817Sralph #define SCC_XMT_BUFFER SCC_WR8 26756817Sralph 26856817Sralph #define SCC_WR9_HW_RESET 0xc0 /* force hardware reset */ 26956817Sralph #define SCC_WR9_RESET_CHA_A 0x80 27056817Sralph #define SCC_WR9_RESET_CHA_B 0x40 27156817Sralph #define SCC_WR9_NON_VECTORED 0x20 /* mbz for Zilog chip */ 27256817Sralph #define SCC_WR9_STATUS_HIGH 0x10 27356817Sralph #define SCC_WR9_MASTER_IE 0x08 27456817Sralph #define SCC_WR9_DLC 0x04 /* disable-lower-chain */ 27556817Sralph #define SCC_WR9_NV 0x02 /* no vector */ 27656817Sralph #define SCC_WR9_VIS 0x01 /* vector-includes-status */ 27756817Sralph 27856817Sralph #define SCC_WR10_CRC_PRESET 0x80 27956817Sralph #define SCC_WR10_FM0 0x60 28056817Sralph #define SCC_WR10_FM1 0x40 28156817Sralph #define SCC_WR10_NRZI 0x20 28256817Sralph #define SCC_WR10_NRZ 0x00 28356817Sralph #define SCC_WR10_ACTIVE_ON_POLL 0x10 28456817Sralph #define SCC_WR10_MARK_IDLE 0x08 /* flag if zero */ 28556817Sralph #define SCC_WR10_ABORT_ON_URUN 0x04 /* flag if zero */ 28656817Sralph #define SCC_WR10_LOOP_MODE 0x02 28756817Sralph #define SCC_WR10_6BIT_SYNCH 0x01 28856817Sralph #define SCC_WR10_8BIT_SYNCH 0x00 28956817Sralph 29056817Sralph #define SCC_WR11_RTxC_XTAL 0x80 /* RTxC pin is input (ext oscill) */ 29156817Sralph #define SCC_WR11_RCLK_DPLL 0x60 /* clock received data on dpll */ 29256817Sralph #define SCC_WR11_RCLK_BAUDR 0x40 /* .. on BRG */ 29356817Sralph #define SCC_WR11_RCLK_TRc_PIN 0x20 /* .. on TRxC pin */ 29456817Sralph #define SCC_WR11_RCLK_RTc_PIN 0x00 /* .. on RTxC pin */ 29556817Sralph #define SCC_WR11_XTLK_DPLL 0x18 29656817Sralph #define SCC_WR11_XTLK_BAUDR 0x10 29756817Sralph #define SCC_WR11_XTLK_TRc_PIN 0x08 29856817Sralph #define SCC_WR11_XTLK_RTc_PIN 0x00 29956817Sralph #define SCC_WR11_TRc_OUT 0x04 /* drive TRxC pin as output from..*/ 30056817Sralph #define SCC_WR11_TRcOUT_DPLL 0x03 /* .. the dpll */ 30156817Sralph #define SCC_WR11_TRcOUT_BAUDR 0x02 /* .. the BRG */ 30256817Sralph #define SCC_WR11_TRcOUT_XMTCLK 0x01 /* .. the xmit clock */ 30356817Sralph #define SCC_WR11_TRcOUT_XTAL 0x00 /* .. the external oscillator */ 30456817Sralph 30556817Sralph /* WR12/WR13 are for timing base preset */ 30656817Sralph #define SCC_SET_TIMING_BASE(scc,chan,val) { \ 30756817Sralph SCC_WRITE_REG(scc,chan,SCC_RR12,val);\ 30856817Sralph SCC_WRITE_REG(scc,chan,SCC_RR13,(val)>>8);\ 30956817Sralph } 31056817Sralph 31156817Sralph /* More commands in this register */ 31256817Sralph #define SCC_WR14_NRZI_MODE 0xe0 /* synch modulations */ 31356817Sralph #define SCC_WR14_FM_MODE 0xc0 31456817Sralph #define SCC_WR14_RTc_SOURCE 0xa0 /* clock is from pin .. */ 31556817Sralph #define SCC_WR14_BAUDR_SOURCE 0x80 /* .. or internal BRG */ 31656817Sralph #define SCC_WR14_DISABLE_DPLL 0x60 31756817Sralph #define SCC_WR14_RESET_CLKMISS 0x40 31856817Sralph #define SCC_WR14_SEARCH_MODE 0x20 31956817Sralph /* ..and more bitsy */ 32056817Sralph #define SCC_WR14_LOCAL_LOOPB 0x10 32156817Sralph #define SCC_WR14_AUTO_ECHO 0x08 32256817Sralph #define SCC_WR14_DTR_REQUEST 0x04 32356817Sralph #define SCC_WR14_BAUDR_SRC 0x02 32456817Sralph #define SCC_WR14_BAUDR_ENABLE 0x01 32556817Sralph 32656817Sralph #define SCC_WR15_BREAK_IE 0x80 32756817Sralph #define SCC_WR15_TX_UNDERRUN_IE 0x40 32856817Sralph #define SCC_WR15_CTS_IE 0x20 32956817Sralph #define SCC_WR15_SYNCHUNT_IE 0x10 33056817Sralph #define SCC_WR15_DCD_IE 0x08 33156817Sralph #define SCC_WR15_zero 0x05 33256817Sralph #define SCC_WR15_ZERO_COUNT_IE 0x02 33356817Sralph 33456817Sralph /* bits in dm lsr, copied from dmreg.h */ 33556817Sralph #define DML_DSR 0000400 /* data set ready, not a real DM bit */ 33656817Sralph #define DML_RNG 0000200 /* ring */ 33756817Sralph #define DML_CAR 0000100 /* carrier detect */ 33856817Sralph #define DML_CTS 0000040 /* clear to send */ 33956817Sralph #define DML_SR 0000020 /* secondary receive */ 34056817Sralph #define DML_ST 0000010 /* secondary transmit */ 34156817Sralph #define DML_RTS 0000004 /* request to send */ 34256817Sralph #define DML_DTR 0000002 /* data terminal ready */ 34356817Sralph #define DML_LE 0000001 /* line enable */ 34456817Sralph 34556817Sralph /* 34656817Sralph * Minor device numbers for scc. Weird because B channel comes 34756817Sralph * first and the A channels are wired for keyboard/mouse and the 34856817Sralph * B channels for the comm port(s). 34956817Sralph */ 35056817Sralph #define SCCCOMM2_PORT 0x0 35157234Sralph #define SCCMOUSE_PORT 0x1 35256817Sralph #define SCCCOMM3_PORT 0x2 35357234Sralph #define SCCKBD_PORT 0x3 354