162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */ 262306a36Sopenharmony_ci/************************************************************************ 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * 16654.H Definitions for 16C654 UART used on EdgePorts 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright (C) 1998 Inside Out Networks, Inc. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci ************************************************************************/ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#if !defined(_16654_H) 1162306a36Sopenharmony_ci#define _16654_H 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci/************************************************************************ 1462306a36Sopenharmony_ci * 1562306a36Sopenharmony_ci * D e f i n e s / T y p e d e f s 1662306a36Sopenharmony_ci * 1762306a36Sopenharmony_ci ************************************************************************/ 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci // 2062306a36Sopenharmony_ci // UART register numbers 2162306a36Sopenharmony_ci // Numbers 0-7 are passed to the Edgeport directly. Numbers 8 and 2262306a36Sopenharmony_ci // above are used internally to indicate that we must enable access 2362306a36Sopenharmony_ci // to them via LCR bit 0x80 or LCR = 0xBF. 2462306a36Sopenharmony_ci // The register number sent to the Edgeport is then (x & 0x7). 2562306a36Sopenharmony_ci // 2662306a36Sopenharmony_ci // Driver must not access registers that affect operation of the 2762306a36Sopenharmony_ci // the EdgePort firmware -- that includes THR, RHR, IER, FCR. 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define THR 0 // ! Transmit Holding Register (Write) 3162306a36Sopenharmony_ci#define RDR 0 // ! Receive Holding Register (Read) 3262306a36Sopenharmony_ci#define IER 1 // ! Interrupt Enable Register 3362306a36Sopenharmony_ci#define FCR 2 // ! Fifo Control Register (Write) 3462306a36Sopenharmony_ci#define ISR 2 // Interrupt Status Register (Read) 3562306a36Sopenharmony_ci#define LCR 3 // Line Control Register 3662306a36Sopenharmony_ci#define MCR 4 // Modem Control Register 3762306a36Sopenharmony_ci#define LSR 5 // Line Status Register 3862306a36Sopenharmony_ci#define MSR 6 // Modem Status Register 3962306a36Sopenharmony_ci#define SPR 7 // ScratchPad Register 4062306a36Sopenharmony_ci#define DLL 8 // Bank2[ 0 ] Divisor Latch LSB 4162306a36Sopenharmony_ci#define DLM 9 // Bank2[ 1 ] Divisor Latch MSB 4262306a36Sopenharmony_ci#define EFR 10 // Bank2[ 2 ] Extended Function Register 4362306a36Sopenharmony_ci//efine unused 11 // Bank2[ 3 ] 4462306a36Sopenharmony_ci#define XON1 12 // Bank2[ 4 ] Xon-1 4562306a36Sopenharmony_ci#define XON2 13 // Bank2[ 5 ] Xon-2 4662306a36Sopenharmony_ci#define XOFF1 14 // Bank2[ 6 ] Xoff-1 4762306a36Sopenharmony_ci#define XOFF2 15 // Bank2[ 7 ] Xoff-2 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci#define NUM_16654_REGS 16 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#define IS_REG_2ND_BANK(x) ((x) >= 8) 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci // 5462306a36Sopenharmony_ci // Bit definitions for each register 5562306a36Sopenharmony_ci // 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci#define IER_RX 0x01 // Enable receive interrupt 5862306a36Sopenharmony_ci#define IER_TX 0x02 // Enable transmit interrupt 5962306a36Sopenharmony_ci#define IER_RXS 0x04 // Enable receive status interrupt 6062306a36Sopenharmony_ci#define IER_MDM 0x08 // Enable modem status interrupt 6162306a36Sopenharmony_ci#define IER_SLEEP 0x10 // Enable sleep mode 6262306a36Sopenharmony_ci#define IER_XOFF 0x20 // Enable s/w flow control (XOFF) interrupt 6362306a36Sopenharmony_ci#define IER_RTS 0x40 // Enable RTS interrupt 6462306a36Sopenharmony_ci#define IER_CTS 0x80 // Enable CTS interrupt 6562306a36Sopenharmony_ci#define IER_ENABLE_ALL 0xFF // Enable all ints 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci#define FCR_FIFO_EN 0x01 // Enable FIFOs 6962306a36Sopenharmony_ci#define FCR_RXCLR 0x02 // Reset Rx FIFO 7062306a36Sopenharmony_ci#define FCR_TXCLR 0x04 // Reset Tx FIFO 7162306a36Sopenharmony_ci#define FCR_DMA_BLK 0x08 // Enable DMA block mode 7262306a36Sopenharmony_ci#define FCR_TX_LEVEL_MASK 0x30 // Mask for Tx FIFO Level 7362306a36Sopenharmony_ci#define FCR_TX_LEVEL_8 0x00 // Tx FIFO Level = 8 bytes 7462306a36Sopenharmony_ci#define FCR_TX_LEVEL_16 0x10 // Tx FIFO Level = 16 bytes 7562306a36Sopenharmony_ci#define FCR_TX_LEVEL_32 0x20 // Tx FIFO Level = 32 bytes 7662306a36Sopenharmony_ci#define FCR_TX_LEVEL_56 0x30 // Tx FIFO Level = 56 bytes 7762306a36Sopenharmony_ci#define FCR_RX_LEVEL_MASK 0xC0 // Mask for Rx FIFO Level 7862306a36Sopenharmony_ci#define FCR_RX_LEVEL_8 0x00 // Rx FIFO Level = 8 bytes 7962306a36Sopenharmony_ci#define FCR_RX_LEVEL_16 0x40 // Rx FIFO Level = 16 bytes 8062306a36Sopenharmony_ci#define FCR_RX_LEVEL_56 0x80 // Rx FIFO Level = 56 bytes 8162306a36Sopenharmony_ci#define FCR_RX_LEVEL_60 0xC0 // Rx FIFO Level = 60 bytes 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci#define ISR_INT_MDM_STATUS 0x00 // Modem status int pending 8562306a36Sopenharmony_ci#define ISR_INT_NONE 0x01 // No interrupt pending 8662306a36Sopenharmony_ci#define ISR_INT_TXRDY 0x02 // Tx ready int pending 8762306a36Sopenharmony_ci#define ISR_INT_RXRDY 0x04 // Rx ready int pending 8862306a36Sopenharmony_ci#define ISR_INT_LINE_STATUS 0x06 // Line status int pending 8962306a36Sopenharmony_ci#define ISR_INT_RX_TIMEOUT 0x0C // Rx timeout int pending 9062306a36Sopenharmony_ci#define ISR_INT_RX_XOFF 0x10 // Rx Xoff int pending 9162306a36Sopenharmony_ci#define ISR_INT_RTS_CTS 0x20 // RTS/CTS change int pending 9262306a36Sopenharmony_ci#define ISR_FIFO_ENABLED 0xC0 // Bits set if FIFOs enabled 9362306a36Sopenharmony_ci#define ISR_INT_BITS_MASK 0x3E // Mask to isolate valid int causes 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci#define LCR_BITS_5 0x00 // 5 bits/char 9762306a36Sopenharmony_ci#define LCR_BITS_6 0x01 // 6 bits/char 9862306a36Sopenharmony_ci#define LCR_BITS_7 0x02 // 7 bits/char 9962306a36Sopenharmony_ci#define LCR_BITS_8 0x03 // 8 bits/char 10062306a36Sopenharmony_ci#define LCR_BITS_MASK 0x03 // Mask for bits/char field 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci#define LCR_STOP_1 0x00 // 1 stop bit 10362306a36Sopenharmony_ci#define LCR_STOP_1_5 0x04 // 1.5 stop bits (if 5 bits/char) 10462306a36Sopenharmony_ci#define LCR_STOP_2 0x04 // 2 stop bits (if 6-8 bits/char) 10562306a36Sopenharmony_ci#define LCR_STOP_MASK 0x04 // Mask for stop bits field 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci#define LCR_PAR_NONE 0x00 // No parity 10862306a36Sopenharmony_ci#define LCR_PAR_ODD 0x08 // Odd parity 10962306a36Sopenharmony_ci#define LCR_PAR_EVEN 0x18 // Even parity 11062306a36Sopenharmony_ci#define LCR_PAR_MARK 0x28 // Force parity bit to 1 11162306a36Sopenharmony_ci#define LCR_PAR_SPACE 0x38 // Force parity bit to 0 11262306a36Sopenharmony_ci#define LCR_PAR_MASK 0x38 // Mask for parity field 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci#define LCR_SET_BREAK 0x40 // Set Break condition 11562306a36Sopenharmony_ci#define LCR_DL_ENABLE 0x80 // Enable access to divisor latch 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci#define LCR_ACCESS_EFR 0xBF // Load this value to access DLL,DLM, 11862306a36Sopenharmony_ci // and also the '654-only registers 11962306a36Sopenharmony_ci // EFR, XON1, XON2, XOFF1, XOFF2 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci#define MCR_DTR 0x01 // Assert DTR 12362306a36Sopenharmony_ci#define MCR_RTS 0x02 // Assert RTS 12462306a36Sopenharmony_ci#define MCR_OUT1 0x04 // Loopback only: Sets state of RI 12562306a36Sopenharmony_ci#define MCR_MASTER_IE 0x08 // Enable interrupt outputs 12662306a36Sopenharmony_ci#define MCR_LOOPBACK 0x10 // Set internal (digital) loopback mode 12762306a36Sopenharmony_ci#define MCR_XON_ANY 0x20 // Enable any char to exit XOFF mode 12862306a36Sopenharmony_ci#define MCR_IR_ENABLE 0x40 // Enable IrDA functions 12962306a36Sopenharmony_ci#define MCR_BRG_DIV_4 0x80 // Divide baud rate clk by /4 instead of /1 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci#define LSR_RX_AVAIL 0x01 // Rx data available 13362306a36Sopenharmony_ci#define LSR_OVER_ERR 0x02 // Rx overrun 13462306a36Sopenharmony_ci#define LSR_PAR_ERR 0x04 // Rx parity error 13562306a36Sopenharmony_ci#define LSR_FRM_ERR 0x08 // Rx framing error 13662306a36Sopenharmony_ci#define LSR_BREAK 0x10 // Rx break condition detected 13762306a36Sopenharmony_ci#define LSR_TX_EMPTY 0x20 // Tx Fifo empty 13862306a36Sopenharmony_ci#define LSR_TX_ALL_EMPTY 0x40 // Tx Fifo and shift register empty 13962306a36Sopenharmony_ci#define LSR_FIFO_ERR 0x80 // Rx Fifo contains at least 1 erred char 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci#define EDGEPORT_MSR_DELTA_CTS 0x01 // CTS changed from last read 14362306a36Sopenharmony_ci#define EDGEPORT_MSR_DELTA_DSR 0x02 // DSR changed from last read 14462306a36Sopenharmony_ci#define EDGEPORT_MSR_DELTA_RI 0x04 // RI changed from 0 -> 1 14562306a36Sopenharmony_ci#define EDGEPORT_MSR_DELTA_CD 0x08 // CD changed from last read 14662306a36Sopenharmony_ci#define EDGEPORT_MSR_CTS 0x10 // Current state of CTS 14762306a36Sopenharmony_ci#define EDGEPORT_MSR_DSR 0x20 // Current state of DSR 14862306a36Sopenharmony_ci#define EDGEPORT_MSR_RI 0x40 // Current state of RI 14962306a36Sopenharmony_ci#define EDGEPORT_MSR_CD 0x80 // Current state of CD 15062306a36Sopenharmony_ci 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci // Tx Rx 15462306a36Sopenharmony_ci //------------------------------- 15562306a36Sopenharmony_ci#define EFR_SWFC_NONE 0x00 // None None 15662306a36Sopenharmony_ci#define EFR_SWFC_RX1 0x02 // None XOFF1 15762306a36Sopenharmony_ci#define EFR_SWFC_RX2 0x01 // None XOFF2 15862306a36Sopenharmony_ci#define EFR_SWFC_RX12 0x03 // None XOFF1 & XOFF2 15962306a36Sopenharmony_ci#define EFR_SWFC_TX1 0x08 // XOFF1 None 16062306a36Sopenharmony_ci#define EFR_SWFC_TX1_RX1 0x0a // XOFF1 XOFF1 16162306a36Sopenharmony_ci#define EFR_SWFC_TX1_RX2 0x09 // XOFF1 XOFF2 16262306a36Sopenharmony_ci#define EFR_SWFC_TX1_RX12 0x0b // XOFF1 XOFF1 & XOFF2 16362306a36Sopenharmony_ci#define EFR_SWFC_TX2 0x04 // XOFF2 None 16462306a36Sopenharmony_ci#define EFR_SWFC_TX2_RX1 0x06 // XOFF2 XOFF1 16562306a36Sopenharmony_ci#define EFR_SWFC_TX2_RX2 0x05 // XOFF2 XOFF2 16662306a36Sopenharmony_ci#define EFR_SWFC_TX2_RX12 0x07 // XOFF2 XOFF1 & XOFF2 16762306a36Sopenharmony_ci#define EFR_SWFC_TX12 0x0c // XOFF1 & XOFF2 None 16862306a36Sopenharmony_ci#define EFR_SWFC_TX12_RX1 0x0e // XOFF1 & XOFF2 XOFF1 16962306a36Sopenharmony_ci#define EFR_SWFC_TX12_RX2 0x0d // XOFF1 & XOFF2 XOFF2 17062306a36Sopenharmony_ci#define EFR_SWFC_TX12_RX12 0x0f // XOFF1 & XOFF2 XOFF1 & XOFF2 17162306a36Sopenharmony_ci 17262306a36Sopenharmony_ci#define EFR_TX_FC_MASK 0x0c // Mask to isolate Rx flow control 17362306a36Sopenharmony_ci#define EFR_TX_FC_NONE 0x00 // No Tx Xon/Xoff flow control 17462306a36Sopenharmony_ci#define EFR_TX_FC_X1 0x08 // Transmit Xon1/Xoff1 17562306a36Sopenharmony_ci#define EFR_TX_FC_X2 0x04 // Transmit Xon2/Xoff2 17662306a36Sopenharmony_ci#define EFR_TX_FC_X1_2 0x0c // Transmit Xon1&2/Xoff1&2 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ci#define EFR_RX_FC_MASK 0x03 // Mask to isolate Rx flow control 17962306a36Sopenharmony_ci#define EFR_RX_FC_NONE 0x00 // No Rx Xon/Xoff flow control 18062306a36Sopenharmony_ci#define EFR_RX_FC_X1 0x02 // Receiver compares Xon1/Xoff1 18162306a36Sopenharmony_ci#define EFR_RX_FC_X2 0x01 // Receiver compares Xon2/Xoff2 18262306a36Sopenharmony_ci#define EFR_RX_FC_X1_2 0x03 // Receiver compares Xon1&2/Xoff1&2 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci#define EFR_SWFC_MASK 0x0F // Mask for software flow control field 18662306a36Sopenharmony_ci#define EFR_ENABLE_16654 0x10 // Enable 16C654 features 18762306a36Sopenharmony_ci#define EFR_SPEC_DETECT 0x20 // Enable special character detect interrupt 18862306a36Sopenharmony_ci#define EFR_AUTO_RTS 0x40 // Use RTS for Rx flow control 18962306a36Sopenharmony_ci#define EFR_AUTO_CTS 0x80 // Use CTS for Tx flow control 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci#endif // if !defined(_16654_H) 19262306a36Sopenharmony_ci 193