1*4f5f5887SNishad Kamdar /* SPDX-License-Identifier: GPL-2.0+ */ 2ab4382d2SGreg Kroah-Hartman /************************************************************************ 3ab4382d2SGreg Kroah-Hartman * Copyright 2003 Digi International (www.digi.com) 4ab4382d2SGreg Kroah-Hartman * 5ab4382d2SGreg Kroah-Hartman * Copyright (C) 2004 IBM Corporation. All rights reserved. 6ab4382d2SGreg Kroah-Hartman * 7ab4382d2SGreg Kroah-Hartman * Contact Information: 8ab4382d2SGreg Kroah-Hartman * Scott H Kilau <Scott_Kilau@digi.com> 9ab4382d2SGreg Kroah-Hartman * Wendy Xiong <wendyx@us.ibm.com> 10ab4382d2SGreg Kroah-Hartman * 11ab4382d2SGreg Kroah-Hartman ***********************************************************************/ 12ab4382d2SGreg Kroah-Hartman 13ab4382d2SGreg Kroah-Hartman #ifndef __JSM_DRIVER_H 14ab4382d2SGreg Kroah-Hartman #define __JSM_DRIVER_H 15ab4382d2SGreg Kroah-Hartman 16ab4382d2SGreg Kroah-Hartman #include <linux/kernel.h> 17ab4382d2SGreg Kroah-Hartman #include <linux/types.h> /* To pick up the varions Linux types */ 18ab4382d2SGreg Kroah-Hartman #include <linux/tty.h> 19ab4382d2SGreg Kroah-Hartman #include <linux/serial_core.h> 20ab4382d2SGreg Kroah-Hartman #include <linux/device.h> 21ab4382d2SGreg Kroah-Hartman 22ab4382d2SGreg Kroah-Hartman /* 23ab4382d2SGreg Kroah-Hartman * Debugging levels can be set using debug insmod variable 24ab4382d2SGreg Kroah-Hartman * They can also be compiled out completely. 25ab4382d2SGreg Kroah-Hartman */ 26ab4382d2SGreg Kroah-Hartman enum { 27ab4382d2SGreg Kroah-Hartman DBG_INIT = 0x01, 28ab4382d2SGreg Kroah-Hartman DBG_BASIC = 0x02, 29ab4382d2SGreg Kroah-Hartman DBG_CORE = 0x04, 30ab4382d2SGreg Kroah-Hartman DBG_OPEN = 0x08, 31ab4382d2SGreg Kroah-Hartman DBG_CLOSE = 0x10, 32ab4382d2SGreg Kroah-Hartman DBG_READ = 0x20, 33ab4382d2SGreg Kroah-Hartman DBG_WRITE = 0x40, 34ab4382d2SGreg Kroah-Hartman DBG_IOCTL = 0x80, 35ab4382d2SGreg Kroah-Hartman DBG_PROC = 0x100, 36ab4382d2SGreg Kroah-Hartman DBG_PARAM = 0x200, 37ab4382d2SGreg Kroah-Hartman DBG_PSCAN = 0x400, 38ab4382d2SGreg Kroah-Hartman DBG_EVENT = 0x800, 39ab4382d2SGreg Kroah-Hartman DBG_DRAIN = 0x1000, 40ab4382d2SGreg Kroah-Hartman DBG_MSIGS = 0x2000, 41ab4382d2SGreg Kroah-Hartman DBG_MGMT = 0x4000, 42ab4382d2SGreg Kroah-Hartman DBG_INTR = 0x8000, 43ab4382d2SGreg Kroah-Hartman DBG_CARR = 0x10000, 44ab4382d2SGreg Kroah-Hartman }; 45ab4382d2SGreg Kroah-Hartman 46669fef46SJoe Perches #define jsm_dbg(nlevel, pdev, fmt, ...) \ 47669fef46SJoe Perches do { \ 48669fef46SJoe Perches if (DBG_##nlevel & jsm_debug) \ 49669fef46SJoe Perches dev_dbg(pdev->dev, fmt, ##__VA_ARGS__); \ 50669fef46SJoe Perches } while (0) 51ab4382d2SGreg Kroah-Hartman 52ab4382d2SGreg Kroah-Hartman #define MAXLINES 256 53ab4382d2SGreg Kroah-Hartman #define MAXPORTS 8 54ab4382d2SGreg Kroah-Hartman #define MAX_STOPS_SENT 5 55ab4382d2SGreg Kroah-Hartman 56293b2265SBill Pemberton /* Board ids */ 5703a8482cSKonrad Zapalowicz #define PCI_DEVICE_ID_CLASSIC_4 0x0028 5803a8482cSKonrad Zapalowicz #define PCI_DEVICE_ID_CLASSIC_8 0x0029 5903a8482cSKonrad Zapalowicz #define PCI_DEVICE_ID_CLASSIC_4_422 0x00D0 6003a8482cSKonrad Zapalowicz #define PCI_DEVICE_ID_CLASSIC_8_422 0x00D1 61293b2265SBill Pemberton #define PCI_DEVICE_ID_NEO_4 0x00B0 62293b2265SBill Pemberton #define PCI_DEVICE_ID_NEO_1_422 0x00CC 63293b2265SBill Pemberton #define PCI_DEVICE_ID_NEO_1_422_485 0x00CD 64293b2265SBill Pemberton #define PCI_DEVICE_ID_NEO_2_422_485 0x00CE 65293b2265SBill Pemberton #define PCIE_DEVICE_ID_NEO_8 0x00F0 66293b2265SBill Pemberton #define PCIE_DEVICE_ID_NEO_4 0x00F1 67293b2265SBill Pemberton #define PCIE_DEVICE_ID_NEO_4RJ45 0x00F2 68293b2265SBill Pemberton #define PCIE_DEVICE_ID_NEO_8RJ45 0x00F3 69293b2265SBill Pemberton 70ab4382d2SGreg Kroah-Hartman /* Board type definitions */ 71ab4382d2SGreg Kroah-Hartman 72ab4382d2SGreg Kroah-Hartman #define T_NEO 0000 73ab4382d2SGreg Kroah-Hartman #define T_CLASSIC 0001 74ab4382d2SGreg Kroah-Hartman #define T_PCIBUS 0400 75ab4382d2SGreg Kroah-Hartman 76ab4382d2SGreg Kroah-Hartman /* Board State Definitions */ 77ab4382d2SGreg Kroah-Hartman 78ab4382d2SGreg Kroah-Hartman #define BD_RUNNING 0x0 79ab4382d2SGreg Kroah-Hartman #define BD_REASON 0x7f 80ab4382d2SGreg Kroah-Hartman #define BD_NOTFOUND 0x1 81ab4382d2SGreg Kroah-Hartman #define BD_NOIOPORT 0x2 82ab4382d2SGreg Kroah-Hartman #define BD_NOMEM 0x3 83ab4382d2SGreg Kroah-Hartman #define BD_NOBIOS 0x4 84ab4382d2SGreg Kroah-Hartman #define BD_NOFEP 0x5 85ab4382d2SGreg Kroah-Hartman #define BD_FAILED 0x6 86ab4382d2SGreg Kroah-Hartman #define BD_ALLOCATED 0x7 87ab4382d2SGreg Kroah-Hartman #define BD_TRIBOOT 0x8 88ab4382d2SGreg Kroah-Hartman #define BD_BADKME 0x80 89ab4382d2SGreg Kroah-Hartman 90ab4382d2SGreg Kroah-Hartman 91ab4382d2SGreg Kroah-Hartman /* 4 extra for alignment play space */ 92ab4382d2SGreg Kroah-Hartman #define WRITEBUFLEN ((4096) + 4) 93ab4382d2SGreg Kroah-Hartman 94ab4382d2SGreg Kroah-Hartman #define JSM_VERSION "jsm: 1.2-1-INKERNEL" 95ab4382d2SGreg Kroah-Hartman #define JSM_PARTNUM "40002438_A-INKERNEL" 96ab4382d2SGreg Kroah-Hartman 97ab4382d2SGreg Kroah-Hartman struct jsm_board; 98ab4382d2SGreg Kroah-Hartman struct jsm_channel; 99ab4382d2SGreg Kroah-Hartman 100ab4382d2SGreg Kroah-Hartman /************************************************************************ 101ab4382d2SGreg Kroah-Hartman * Per board operations structure * 102ab4382d2SGreg Kroah-Hartman ************************************************************************/ 103ab4382d2SGreg Kroah-Hartman struct board_ops { 104ab4382d2SGreg Kroah-Hartman irq_handler_t intr; 105ab4382d2SGreg Kroah-Hartman void (*uart_init)(struct jsm_channel *ch); 106ab4382d2SGreg Kroah-Hartman void (*uart_off)(struct jsm_channel *ch); 107ab4382d2SGreg Kroah-Hartman void (*param)(struct jsm_channel *ch); 108ab4382d2SGreg Kroah-Hartman void (*assert_modem_signals)(struct jsm_channel *ch); 109ab4382d2SGreg Kroah-Hartman void (*flush_uart_write)(struct jsm_channel *ch); 110ab4382d2SGreg Kroah-Hartman void (*flush_uart_read)(struct jsm_channel *ch); 111ab4382d2SGreg Kroah-Hartman void (*disable_receiver)(struct jsm_channel *ch); 112ab4382d2SGreg Kroah-Hartman void (*enable_receiver)(struct jsm_channel *ch); 113ab4382d2SGreg Kroah-Hartman void (*send_break)(struct jsm_channel *ch); 114333f4eb1SKonrad Zapalowicz void (*clear_break)(struct jsm_channel *ch); 115ab4382d2SGreg Kroah-Hartman void (*send_start_character)(struct jsm_channel *ch); 116ab4382d2SGreg Kroah-Hartman void (*send_stop_character)(struct jsm_channel *ch); 117ab4382d2SGreg Kroah-Hartman void (*copy_data_from_queue_to_uart)(struct jsm_channel *ch); 118ab4382d2SGreg Kroah-Hartman }; 119ab4382d2SGreg Kroah-Hartman 120ab4382d2SGreg Kroah-Hartman 121ab4382d2SGreg Kroah-Hartman /* 122ab4382d2SGreg Kroah-Hartman * Per-board information 123ab4382d2SGreg Kroah-Hartman */ 124ab4382d2SGreg Kroah-Hartman struct jsm_board 125ab4382d2SGreg Kroah-Hartman { 126ab4382d2SGreg Kroah-Hartman int boardnum; /* Board number: 0-32 */ 127ab4382d2SGreg Kroah-Hartman 128ab4382d2SGreg Kroah-Hartman u8 rev; /* PCI revision ID */ 129ab4382d2SGreg Kroah-Hartman struct pci_dev *pci_dev; 130ab4382d2SGreg Kroah-Hartman u32 maxports; /* MAX ports this board can handle */ 131ab4382d2SGreg Kroah-Hartman 132ab4382d2SGreg Kroah-Hartman spinlock_t bd_intr_lock; /* Used to protect the poller tasklet and 133ab4382d2SGreg Kroah-Hartman * the interrupt routine from each other. 134ab4382d2SGreg Kroah-Hartman */ 135ab4382d2SGreg Kroah-Hartman 136ab4382d2SGreg Kroah-Hartman u32 nasync; /* Number of ports on card */ 137ab4382d2SGreg Kroah-Hartman 138ab4382d2SGreg Kroah-Hartman u32 irq; /* Interrupt request number */ 139ab4382d2SGreg Kroah-Hartman 140ab4382d2SGreg Kroah-Hartman u64 membase; /* Start of base memory of the card */ 141ab4382d2SGreg Kroah-Hartman u64 membase_end; /* End of base memory of the card */ 142ab4382d2SGreg Kroah-Hartman 143ab4382d2SGreg Kroah-Hartman u8 __iomem *re_map_membase;/* Remapped memory of the card */ 144ab4382d2SGreg Kroah-Hartman 145ab4382d2SGreg Kroah-Hartman u64 iobase; /* Start of io base of the card */ 146ab4382d2SGreg Kroah-Hartman u64 iobase_end; /* End of io base of the card */ 147ab4382d2SGreg Kroah-Hartman 148ab4382d2SGreg Kroah-Hartman u32 bd_uart_offset; /* Space between each UART */ 149ab4382d2SGreg Kroah-Hartman 150ab4382d2SGreg Kroah-Hartman struct jsm_channel *channels[MAXPORTS]; /* array of pointers to our channels. */ 151ab4382d2SGreg Kroah-Hartman 152ab4382d2SGreg Kroah-Hartman u32 bd_dividend; /* Board/UARTs specific dividend */ 153ab4382d2SGreg Kroah-Hartman 154ab4382d2SGreg Kroah-Hartman struct board_ops *bd_ops; 155ab4382d2SGreg Kroah-Hartman }; 156ab4382d2SGreg Kroah-Hartman 157ab4382d2SGreg Kroah-Hartman /************************************************************************ 158ab4382d2SGreg Kroah-Hartman * Device flag definitions for ch_flags. 159ab4382d2SGreg Kroah-Hartman ************************************************************************/ 160ab4382d2SGreg Kroah-Hartman #define CH_PRON 0x0001 /* Printer on string */ 161ab4382d2SGreg Kroah-Hartman #define CH_STOP 0x0002 /* Output is stopped */ 162ab4382d2SGreg Kroah-Hartman #define CH_STOPI 0x0004 /* Input is stopped */ 163ab4382d2SGreg Kroah-Hartman #define CH_CD 0x0008 /* Carrier is present */ 164ab4382d2SGreg Kroah-Hartman #define CH_FCAR 0x0010 /* Carrier forced on */ 165ab4382d2SGreg Kroah-Hartman #define CH_HANGUP 0x0020 /* Hangup received */ 166ab4382d2SGreg Kroah-Hartman 167ab4382d2SGreg Kroah-Hartman #define CH_RECEIVER_OFF 0x0040 /* Receiver is off */ 168ab4382d2SGreg Kroah-Hartman #define CH_OPENING 0x0080 /* Port in fragile open state */ 169ab4382d2SGreg Kroah-Hartman #define CH_CLOSING 0x0100 /* Port in fragile close state */ 170ab4382d2SGreg Kroah-Hartman #define CH_FIFO_ENABLED 0x0200 /* Port has FIFOs enabled */ 171ab4382d2SGreg Kroah-Hartman #define CH_TX_FIFO_EMPTY 0x0400 /* TX Fifo is completely empty */ 172ab4382d2SGreg Kroah-Hartman #define CH_TX_FIFO_LWM 0x0800 /* TX Fifo is below Low Water */ 173ab4382d2SGreg Kroah-Hartman #define CH_BREAK_SENDING 0x1000 /* Break is being sent */ 174ab4382d2SGreg Kroah-Hartman #define CH_LOOPBACK 0x2000 /* Channel is in lookback mode */ 175ab4382d2SGreg Kroah-Hartman #define CH_BAUD0 0x08000 /* Used for checking B0 transitions */ 176ab4382d2SGreg Kroah-Hartman 17795db1ccbSKonrad Zapalowicz /* Our Read/Error queue sizes */ 178ab4382d2SGreg Kroah-Hartman #define RQUEUEMASK 0x1FFF /* 8 K - 1 */ 179ab4382d2SGreg Kroah-Hartman #define EQUEUEMASK 0x1FFF /* 8 K - 1 */ 180ab4382d2SGreg Kroah-Hartman #define RQUEUESIZE (RQUEUEMASK + 1) 181ab4382d2SGreg Kroah-Hartman #define EQUEUESIZE RQUEUESIZE 182ab4382d2SGreg Kroah-Hartman 183ab4382d2SGreg Kroah-Hartman 184ab4382d2SGreg Kroah-Hartman /************************************************************************ 185ab4382d2SGreg Kroah-Hartman * Channel information structure. 186ab4382d2SGreg Kroah-Hartman ************************************************************************/ 187ab4382d2SGreg Kroah-Hartman struct jsm_channel { 188ab4382d2SGreg Kroah-Hartman struct uart_port uart_port; 189ab4382d2SGreg Kroah-Hartman struct jsm_board *ch_bd; /* Board structure pointer */ 190ab4382d2SGreg Kroah-Hartman 191ab4382d2SGreg Kroah-Hartman spinlock_t ch_lock; /* provide for serialization */ 192ab4382d2SGreg Kroah-Hartman wait_queue_head_t ch_flags_wait; 193ab4382d2SGreg Kroah-Hartman 194ab4382d2SGreg Kroah-Hartman u32 ch_portnum; /* Port number, 0 offset. */ 195ab4382d2SGreg Kroah-Hartman u32 ch_open_count; /* open count */ 196ab4382d2SGreg Kroah-Hartman u32 ch_flags; /* Channel flags */ 197ab4382d2SGreg Kroah-Hartman 198ab4382d2SGreg Kroah-Hartman u64 ch_close_delay; /* How long we should drop RTS/DTR for */ 199ab4382d2SGreg Kroah-Hartman 200ab4382d2SGreg Kroah-Hartman tcflag_t ch_c_iflag; /* channel iflags */ 201ab4382d2SGreg Kroah-Hartman tcflag_t ch_c_cflag; /* channel cflags */ 202ab4382d2SGreg Kroah-Hartman tcflag_t ch_c_oflag; /* channel oflags */ 203ab4382d2SGreg Kroah-Hartman tcflag_t ch_c_lflag; /* channel lflags */ 204ab4382d2SGreg Kroah-Hartman u8 ch_stopc; /* Stop character */ 205ab4382d2SGreg Kroah-Hartman u8 ch_startc; /* Start character */ 206ab4382d2SGreg Kroah-Hartman 207ab4382d2SGreg Kroah-Hartman u8 ch_mostat; /* FEP output modem status */ 208ab4382d2SGreg Kroah-Hartman u8 ch_mistat; /* FEP input modem status */ 209ab4382d2SGreg Kroah-Hartman 210d7685ca7SKonrad Zapalowicz /* Pointers to the "mapped" UART structs */ 211d7685ca7SKonrad Zapalowicz struct neo_uart_struct __iomem *ch_neo_uart; /* NEO card */ 212d7685ca7SKonrad Zapalowicz struct cls_uart_struct __iomem *ch_cls_uart; /* Classic card */ 213d7685ca7SKonrad Zapalowicz 214ab4382d2SGreg Kroah-Hartman u8 ch_cached_lsr; /* Cached value of the LSR register */ 215ab4382d2SGreg Kroah-Hartman 216ab4382d2SGreg Kroah-Hartman u8 *ch_rqueue; /* Our read queue buffer - malloc'ed */ 217ab4382d2SGreg Kroah-Hartman u16 ch_r_head; /* Head location of the read queue */ 218ab4382d2SGreg Kroah-Hartman u16 ch_r_tail; /* Tail location of the read queue */ 219ab4382d2SGreg Kroah-Hartman 220ab4382d2SGreg Kroah-Hartman u8 *ch_equeue; /* Our error queue buffer - malloc'ed */ 221ab4382d2SGreg Kroah-Hartman u16 ch_e_head; /* Head location of the error queue */ 222ab4382d2SGreg Kroah-Hartman u16 ch_e_tail; /* Tail location of the error queue */ 223ab4382d2SGreg Kroah-Hartman 224ab4382d2SGreg Kroah-Hartman u64 ch_rxcount; /* total of data received so far */ 225ab4382d2SGreg Kroah-Hartman u64 ch_txcount; /* total of data transmitted so far */ 226ab4382d2SGreg Kroah-Hartman 227ab4382d2SGreg Kroah-Hartman u8 ch_r_tlevel; /* Receive Trigger level */ 228ab4382d2SGreg Kroah-Hartman u8 ch_t_tlevel; /* Transmit Trigger level */ 229ab4382d2SGreg Kroah-Hartman 230ab4382d2SGreg Kroah-Hartman u8 ch_r_watermark; /* Receive Watermark */ 231ab4382d2SGreg Kroah-Hartman 232ab4382d2SGreg Kroah-Hartman 233ab4382d2SGreg Kroah-Hartman u32 ch_stops_sent; /* How many times I have sent a stop character 234ab4382d2SGreg Kroah-Hartman * to try to stop the other guy sending. 235ab4382d2SGreg Kroah-Hartman */ 236ab4382d2SGreg Kroah-Hartman u64 ch_err_parity; /* Count of parity errors on channel */ 237ab4382d2SGreg Kroah-Hartman u64 ch_err_frame; /* Count of framing errors on channel */ 238ab4382d2SGreg Kroah-Hartman u64 ch_err_break; /* Count of breaks on channel */ 239ab4382d2SGreg Kroah-Hartman u64 ch_err_overrun; /* Count of overruns on channel */ 240ab4382d2SGreg Kroah-Hartman 241ab4382d2SGreg Kroah-Hartman u64 ch_xon_sends; /* Count of xons transmitted */ 242ab4382d2SGreg Kroah-Hartman u64 ch_xoff_sends; /* Count of xoffs transmitted */ 243ab4382d2SGreg Kroah-Hartman }; 244ab4382d2SGreg Kroah-Hartman 245d7685ca7SKonrad Zapalowicz /************************************************************************ 246d7685ca7SKonrad Zapalowicz * Per channel/port Classic UART structures * 247d7685ca7SKonrad Zapalowicz ************************************************************************ 248d7685ca7SKonrad Zapalowicz * Base Structure Entries Usage Meanings to Host * 249d7685ca7SKonrad Zapalowicz * * 250d7685ca7SKonrad Zapalowicz * W = read write R = read only * 251d7685ca7SKonrad Zapalowicz * U = Unused. * 252d7685ca7SKonrad Zapalowicz ************************************************************************/ 253d7685ca7SKonrad Zapalowicz 254d7685ca7SKonrad Zapalowicz struct cls_uart_struct { 255d7685ca7SKonrad Zapalowicz u8 txrx; /* WR RHR/THR - Holding Reg */ 256d7685ca7SKonrad Zapalowicz u8 ier; /* WR IER - Interrupt Enable Reg */ 257d7685ca7SKonrad Zapalowicz u8 isr_fcr; /* WR ISR/FCR - Interrupt Status Reg/Fifo Control Reg*/ 258d7685ca7SKonrad Zapalowicz u8 lcr; /* WR LCR - Line Control Reg */ 259d7685ca7SKonrad Zapalowicz u8 mcr; /* WR MCR - Modem Control Reg */ 260d7685ca7SKonrad Zapalowicz u8 lsr; /* WR LSR - Line Status Reg */ 261d7685ca7SKonrad Zapalowicz u8 msr; /* WR MSR - Modem Status Reg */ 262d7685ca7SKonrad Zapalowicz u8 spr; /* WR SPR - Scratch Pad Reg */ 263d7685ca7SKonrad Zapalowicz }; 264d7685ca7SKonrad Zapalowicz 265d7685ca7SKonrad Zapalowicz /* Where to read the interrupt register (8bits) */ 266d7685ca7SKonrad Zapalowicz #define UART_CLASSIC_POLL_ADDR_OFFSET 0x40 267d7685ca7SKonrad Zapalowicz 268d7685ca7SKonrad Zapalowicz #define UART_EXAR654_ENHANCED_REGISTER_SET 0xBF 269d7685ca7SKonrad Zapalowicz 270d7685ca7SKonrad Zapalowicz #define UART_16654_FCR_TXTRIGGER_8 0x0 271d7685ca7SKonrad Zapalowicz #define UART_16654_FCR_TXTRIGGER_16 0x10 272d7685ca7SKonrad Zapalowicz #define UART_16654_FCR_TXTRIGGER_32 0x20 273d7685ca7SKonrad Zapalowicz #define UART_16654_FCR_TXTRIGGER_56 0x30 274d7685ca7SKonrad Zapalowicz 275d7685ca7SKonrad Zapalowicz #define UART_16654_FCR_RXTRIGGER_8 0x0 276d7685ca7SKonrad Zapalowicz #define UART_16654_FCR_RXTRIGGER_16 0x40 277d7685ca7SKonrad Zapalowicz #define UART_16654_FCR_RXTRIGGER_56 0x80 278d7685ca7SKonrad Zapalowicz #define UART_16654_FCR_RXTRIGGER_60 0xC0 279d7685ca7SKonrad Zapalowicz 280d7685ca7SKonrad Zapalowicz #define UART_IIR_CTSRTS 0x20 /* Received CTS/RTS change of state */ 281d7685ca7SKonrad Zapalowicz #define UART_IIR_RDI_TIMEOUT 0x0C /* Receiver data TIMEOUT */ 282d7685ca7SKonrad Zapalowicz 283d7685ca7SKonrad Zapalowicz /* 284d7685ca7SKonrad Zapalowicz * These are the EXTENDED definitions for the Exar 654's Interrupt 285d7685ca7SKonrad Zapalowicz * Enable Register. 286d7685ca7SKonrad Zapalowicz */ 287d7685ca7SKonrad Zapalowicz #define UART_EXAR654_EFR_ECB 0x10 /* Enhanced control bit */ 288d7685ca7SKonrad Zapalowicz #define UART_EXAR654_EFR_IXON 0x2 /* Receiver compares Xon1/Xoff1 */ 289d7685ca7SKonrad Zapalowicz #define UART_EXAR654_EFR_IXOFF 0x8 /* Transmit Xon1/Xoff1 */ 290d7685ca7SKonrad Zapalowicz #define UART_EXAR654_EFR_RTSDTR 0x40 /* Auto RTS/DTR Flow Control Enable */ 291d7685ca7SKonrad Zapalowicz #define UART_EXAR654_EFR_CTSDSR 0x80 /* Auto CTS/DSR Flow COntrol Enable */ 292d7685ca7SKonrad Zapalowicz 293d7685ca7SKonrad Zapalowicz #define UART_EXAR654_XOFF_DETECT 0x1 /* Indicates whether chip saw an incoming XOFF char */ 294d7685ca7SKonrad Zapalowicz #define UART_EXAR654_XON_DETECT 0x2 /* Indicates whether chip saw an incoming XON char */ 295d7685ca7SKonrad Zapalowicz 296d7685ca7SKonrad Zapalowicz #define UART_EXAR654_IER_XOFF 0x20 /* Xoff Interrupt Enable */ 297d7685ca7SKonrad Zapalowicz #define UART_EXAR654_IER_RTSDTR 0x40 /* Output Interrupt Enable */ 298d7685ca7SKonrad Zapalowicz #define UART_EXAR654_IER_CTSDSR 0x80 /* Input Interrupt Enable */ 299ab4382d2SGreg Kroah-Hartman 300ab4382d2SGreg Kroah-Hartman /************************************************************************ 301ab4382d2SGreg Kroah-Hartman * Per channel/port NEO UART structure * 302ab4382d2SGreg Kroah-Hartman ************************************************************************ 303ab4382d2SGreg Kroah-Hartman * Base Structure Entries Usage Meanings to Host * 304ab4382d2SGreg Kroah-Hartman * * 305ab4382d2SGreg Kroah-Hartman * W = read write R = read only * 306ab4382d2SGreg Kroah-Hartman * U = Unused. * 307ab4382d2SGreg Kroah-Hartman ************************************************************************/ 308ab4382d2SGreg Kroah-Hartman 309ab4382d2SGreg Kroah-Hartman struct neo_uart_struct { 310ab4382d2SGreg Kroah-Hartman u8 txrx; /* WR RHR/THR - Holding Reg */ 311ab4382d2SGreg Kroah-Hartman u8 ier; /* WR IER - Interrupt Enable Reg */ 312ab4382d2SGreg Kroah-Hartman u8 isr_fcr; /* WR ISR/FCR - Interrupt Status Reg/Fifo Control Reg */ 313ab4382d2SGreg Kroah-Hartman u8 lcr; /* WR LCR - Line Control Reg */ 314ab4382d2SGreg Kroah-Hartman u8 mcr; /* WR MCR - Modem Control Reg */ 315ab4382d2SGreg Kroah-Hartman u8 lsr; /* WR LSR - Line Status Reg */ 316ab4382d2SGreg Kroah-Hartman u8 msr; /* WR MSR - Modem Status Reg */ 317ab4382d2SGreg Kroah-Hartman u8 spr; /* WR SPR - Scratch Pad Reg */ 318ab4382d2SGreg Kroah-Hartman u8 fctr; /* WR FCTR - Feature Control Reg */ 319ab4382d2SGreg Kroah-Hartman u8 efr; /* WR EFR - Enhanced Function Reg */ 320ab4382d2SGreg Kroah-Hartman u8 tfifo; /* WR TXCNT/TXTRG - Transmit FIFO Reg */ 32125985edcSLucas De Marchi u8 rfifo; /* WR RXCNT/RXTRG - Receive FIFO Reg */ 322ab4382d2SGreg Kroah-Hartman u8 xoffchar1; /* WR XOFF 1 - XOff Character 1 Reg */ 323ab4382d2SGreg Kroah-Hartman u8 xoffchar2; /* WR XOFF 2 - XOff Character 2 Reg */ 324ab4382d2SGreg Kroah-Hartman u8 xonchar1; /* WR XON 1 - Xon Character 1 Reg */ 325ab4382d2SGreg Kroah-Hartman u8 xonchar2; /* WR XON 2 - XOn Character 2 Reg */ 326ab4382d2SGreg Kroah-Hartman 327ab4382d2SGreg Kroah-Hartman u8 reserved1[0x2ff - 0x200]; /* U Reserved by Exar */ 328ab4382d2SGreg Kroah-Hartman u8 txrxburst[64]; /* RW 64 bytes of RX/TX FIFO Data */ 329ab4382d2SGreg Kroah-Hartman u8 reserved2[0x37f - 0x340]; /* U Reserved by Exar */ 330ab4382d2SGreg Kroah-Hartman u8 rxburst_with_errors[64]; /* R 64 bytes of RX FIFO Data + LSR */ 331ab4382d2SGreg Kroah-Hartman }; 332ab4382d2SGreg Kroah-Hartman 333ab4382d2SGreg Kroah-Hartman /* Where to read the extended interrupt register (32bits instead of 8bits) */ 334ab4382d2SGreg Kroah-Hartman #define UART_17158_POLL_ADDR_OFFSET 0x80 335ab4382d2SGreg Kroah-Hartman 336ab4382d2SGreg Kroah-Hartman /* 337ab4382d2SGreg Kroah-Hartman * These are the redefinitions for the FCTR on the XR17C158, since 338ab4382d2SGreg Kroah-Hartman * Exar made them different than their earlier design. (XR16C854) 339ab4382d2SGreg Kroah-Hartman */ 340ab4382d2SGreg Kroah-Hartman 341ab4382d2SGreg Kroah-Hartman /* These are only applicable when table D is selected */ 342ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_NODELAY 0x00 343ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_4DELAY 0x01 344ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_6DELAY 0x02 345ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_8DELAY 0x03 346ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_12DELAY 0x12 347ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_16DELAY 0x05 348ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_20DELAY 0x13 349ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_24DELAY 0x06 350ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_28DELAY 0x14 351ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_32DELAY 0x07 352ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_36DELAY 0x16 353ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_40DELAY 0x08 354ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_44DELAY 0x09 355ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_48DELAY 0x10 356ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_52DELAY 0x11 357ab4382d2SGreg Kroah-Hartman 358ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RTS_IRDA 0x10 359ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_RS485 0x20 360ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_TRGA 0x00 361ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_TRGB 0x40 362ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_TRGC 0x80 363ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_TRGD 0xC0 364ab4382d2SGreg Kroah-Hartman 365ab4382d2SGreg Kroah-Hartman /* 17158 trigger table selects.. */ 366ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_BIT6 0x40 367ab4382d2SGreg Kroah-Hartman #define UART_17158_FCTR_BIT7 0x80 368ab4382d2SGreg Kroah-Hartman 369ab4382d2SGreg Kroah-Hartman /* 17158 TX/RX memmapped buffer offsets */ 370ab4382d2SGreg Kroah-Hartman #define UART_17158_RX_FIFOSIZE 64 371ab4382d2SGreg Kroah-Hartman #define UART_17158_TX_FIFOSIZE 64 372ab4382d2SGreg Kroah-Hartman 373ab4382d2SGreg Kroah-Hartman /* 17158 Extended IIR's */ 374ab4382d2SGreg Kroah-Hartman #define UART_17158_IIR_RDI_TIMEOUT 0x0C /* Receiver data TIMEOUT */ 375ab4382d2SGreg Kroah-Hartman #define UART_17158_IIR_XONXOFF 0x10 /* Received an XON/XOFF char */ 376ab4382d2SGreg Kroah-Hartman #define UART_17158_IIR_HWFLOW_STATE_CHANGE 0x20 /* CTS/DSR or RTS/DTR state change */ 377ab4382d2SGreg Kroah-Hartman #define UART_17158_IIR_FIFO_ENABLED 0xC0 /* 16550 FIFOs are Enabled */ 378ab4382d2SGreg Kroah-Hartman 379ab4382d2SGreg Kroah-Hartman /* 380ab4382d2SGreg Kroah-Hartman * These are the extended interrupts that get sent 381ab4382d2SGreg Kroah-Hartman * back to us from the UART's 32bit interrupt register 382ab4382d2SGreg Kroah-Hartman */ 383ab4382d2SGreg Kroah-Hartman #define UART_17158_RX_LINE_STATUS 0x1 /* RX Ready */ 384ab4382d2SGreg Kroah-Hartman #define UART_17158_RXRDY_TIMEOUT 0x2 /* RX Ready Timeout */ 385ab4382d2SGreg Kroah-Hartman #define UART_17158_TXRDY 0x3 /* TX Ready */ 386ab4382d2SGreg Kroah-Hartman #define UART_17158_MSR 0x4 /* Modem State Change */ 387ab4382d2SGreg Kroah-Hartman #define UART_17158_TX_AND_FIFO_CLR 0x40 /* Transmitter Holding Reg Empty */ 388ab4382d2SGreg Kroah-Hartman #define UART_17158_RX_FIFO_DATA_ERROR 0x80 /* UART detected an RX FIFO Data error */ 389ab4382d2SGreg Kroah-Hartman 390ab4382d2SGreg Kroah-Hartman /* 391ab4382d2SGreg Kroah-Hartman * These are the EXTENDED definitions for the 17C158's Interrupt 392ab4382d2SGreg Kroah-Hartman * Enable Register. 393ab4382d2SGreg Kroah-Hartman */ 394ab4382d2SGreg Kroah-Hartman #define UART_17158_EFR_ECB 0x10 /* Enhanced control bit */ 395ab4382d2SGreg Kroah-Hartman #define UART_17158_EFR_IXON 0x2 /* Receiver compares Xon1/Xoff1 */ 396ab4382d2SGreg Kroah-Hartman #define UART_17158_EFR_IXOFF 0x8 /* Transmit Xon1/Xoff1 */ 397ab4382d2SGreg Kroah-Hartman #define UART_17158_EFR_RTSDTR 0x40 /* Auto RTS/DTR Flow Control Enable */ 398ab4382d2SGreg Kroah-Hartman #define UART_17158_EFR_CTSDSR 0x80 /* Auto CTS/DSR Flow COntrol Enable */ 399ab4382d2SGreg Kroah-Hartman 400ab4382d2SGreg Kroah-Hartman #define UART_17158_XOFF_DETECT 0x1 /* Indicates whether chip saw an incoming XOFF char */ 401ab4382d2SGreg Kroah-Hartman #define UART_17158_XON_DETECT 0x2 /* Indicates whether chip saw an incoming XON char */ 402ab4382d2SGreg Kroah-Hartman 403ab4382d2SGreg Kroah-Hartman #define UART_17158_IER_RSVD1 0x10 /* Reserved by Exar */ 404ab4382d2SGreg Kroah-Hartman #define UART_17158_IER_XOFF 0x20 /* Xoff Interrupt Enable */ 405ab4382d2SGreg Kroah-Hartman #define UART_17158_IER_RTSDTR 0x40 /* Output Interrupt Enable */ 406ab4382d2SGreg Kroah-Hartman #define UART_17158_IER_CTSDSR 0x80 /* Input Interrupt Enable */ 407ab4382d2SGreg Kroah-Hartman 408ab4382d2SGreg Kroah-Hartman #define PCI_DEVICE_NEO_2DB9_PCI_NAME "Neo 2 - DB9 Universal PCI" 409ab4382d2SGreg Kroah-Hartman #define PCI_DEVICE_NEO_2DB9PRI_PCI_NAME "Neo 2 - DB9 Universal PCI - Powered Ring Indicator" 410ab4382d2SGreg Kroah-Hartman #define PCI_DEVICE_NEO_2RJ45_PCI_NAME "Neo 2 - RJ45 Universal PCI" 411ab4382d2SGreg Kroah-Hartman #define PCI_DEVICE_NEO_2RJ45PRI_PCI_NAME "Neo 2 - RJ45 Universal PCI - Powered Ring Indicator" 412ab4382d2SGreg Kroah-Hartman #define PCIE_DEVICE_NEO_IBM_PCI_NAME "Neo 4 - PCI Express - IBM" 413ab4382d2SGreg Kroah-Hartman 414ab4382d2SGreg Kroah-Hartman /* 415ab4382d2SGreg Kroah-Hartman * Our Global Variables. 416ab4382d2SGreg Kroah-Hartman */ 417ab4382d2SGreg Kroah-Hartman extern struct uart_driver jsm_uart_driver; 418ab4382d2SGreg Kroah-Hartman extern struct board_ops jsm_neo_ops; 41995db1ccbSKonrad Zapalowicz extern struct board_ops jsm_cls_ops; 420ab4382d2SGreg Kroah-Hartman extern int jsm_debug; 421ab4382d2SGreg Kroah-Hartman 422ab4382d2SGreg Kroah-Hartman /************************************************************************* 423ab4382d2SGreg Kroah-Hartman * 424ab4382d2SGreg Kroah-Hartman * Prototypes for non-static functions used in more than one module 425ab4382d2SGreg Kroah-Hartman * 426ab4382d2SGreg Kroah-Hartman *************************************************************************/ 427ab4382d2SGreg Kroah-Hartman int jsm_tty_init(struct jsm_board *); 428ab4382d2SGreg Kroah-Hartman int jsm_uart_port_init(struct jsm_board *); 429ab4382d2SGreg Kroah-Hartman int jsm_remove_uart_port(struct jsm_board *); 430ab4382d2SGreg Kroah-Hartman void jsm_input(struct jsm_channel *ch); 431ab4382d2SGreg Kroah-Hartman void jsm_check_queue_flow_control(struct jsm_channel *ch); 432ab4382d2SGreg Kroah-Hartman 433ab4382d2SGreg Kroah-Hartman #endif 434