xref: /kernel/linux/linux-6.6/drivers/tty/serial/jsm/jsm.h (revision 62306a36)
162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */
262306a36Sopenharmony_ci/************************************************************************
362306a36Sopenharmony_ci * Copyright 2003 Digi International (www.digi.com)
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2004 IBM Corporation. All rights reserved.
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Contact Information:
862306a36Sopenharmony_ci * Scott H Kilau <Scott_Kilau@digi.com>
962306a36Sopenharmony_ci * Wendy Xiong   <wendyx@us.ibm.com>
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci ***********************************************************************/
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#ifndef __JSM_DRIVER_H
1462306a36Sopenharmony_ci#define __JSM_DRIVER_H
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#include <linux/kernel.h>
1762306a36Sopenharmony_ci#include <linux/types.h>	/* To pick up the varions Linux types */
1862306a36Sopenharmony_ci#include <linux/tty.h>
1962306a36Sopenharmony_ci#include <linux/serial_core.h>
2062306a36Sopenharmony_ci#include <linux/device.h>
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci/*
2362306a36Sopenharmony_ci * Debugging levels can be set using debug insmod variable
2462306a36Sopenharmony_ci * They can also be compiled out completely.
2562306a36Sopenharmony_ci */
2662306a36Sopenharmony_cienum {
2762306a36Sopenharmony_ci	DBG_INIT	= 0x01,
2862306a36Sopenharmony_ci	DBG_BASIC	= 0x02,
2962306a36Sopenharmony_ci	DBG_CORE	= 0x04,
3062306a36Sopenharmony_ci	DBG_OPEN	= 0x08,
3162306a36Sopenharmony_ci	DBG_CLOSE	= 0x10,
3262306a36Sopenharmony_ci	DBG_READ	= 0x20,
3362306a36Sopenharmony_ci	DBG_WRITE	= 0x40,
3462306a36Sopenharmony_ci	DBG_IOCTL	= 0x80,
3562306a36Sopenharmony_ci	DBG_PROC	= 0x100,
3662306a36Sopenharmony_ci	DBG_PARAM	= 0x200,
3762306a36Sopenharmony_ci	DBG_PSCAN	= 0x400,
3862306a36Sopenharmony_ci	DBG_EVENT	= 0x800,
3962306a36Sopenharmony_ci	DBG_DRAIN	= 0x1000,
4062306a36Sopenharmony_ci	DBG_MSIGS	= 0x2000,
4162306a36Sopenharmony_ci	DBG_MGMT	= 0x4000,
4262306a36Sopenharmony_ci	DBG_INTR	= 0x8000,
4362306a36Sopenharmony_ci	DBG_CARR	= 0x10000,
4462306a36Sopenharmony_ci};
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci#define jsm_dbg(nlevel, pdev, fmt, ...)				\
4762306a36Sopenharmony_cido {								\
4862306a36Sopenharmony_ci	if (DBG_##nlevel & jsm_debug)				\
4962306a36Sopenharmony_ci		dev_dbg(pdev->dev, fmt, ##__VA_ARGS__);		\
5062306a36Sopenharmony_ci} while (0)
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#define	MAXLINES	256
5362306a36Sopenharmony_ci#define MAXPORTS	8
5462306a36Sopenharmony_ci#define MAX_STOPS_SENT	5
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* Board ids */
5762306a36Sopenharmony_ci#define PCI_DEVICE_ID_CLASSIC_4		0x0028
5862306a36Sopenharmony_ci#define PCI_DEVICE_ID_CLASSIC_8		0x0029
5962306a36Sopenharmony_ci#define PCI_DEVICE_ID_CLASSIC_4_422	0x00D0
6062306a36Sopenharmony_ci#define PCI_DEVICE_ID_CLASSIC_8_422	0x00D1
6162306a36Sopenharmony_ci#define PCI_DEVICE_ID_NEO_4             0x00B0
6262306a36Sopenharmony_ci#define PCI_DEVICE_ID_NEO_1_422         0x00CC
6362306a36Sopenharmony_ci#define PCI_DEVICE_ID_NEO_1_422_485     0x00CD
6462306a36Sopenharmony_ci#define PCI_DEVICE_ID_NEO_2_422_485     0x00CE
6562306a36Sopenharmony_ci#define PCIE_DEVICE_ID_NEO_8            0x00F0
6662306a36Sopenharmony_ci#define PCIE_DEVICE_ID_NEO_4            0x00F1
6762306a36Sopenharmony_ci#define PCIE_DEVICE_ID_NEO_4RJ45        0x00F2
6862306a36Sopenharmony_ci#define PCIE_DEVICE_ID_NEO_8RJ45        0x00F3
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci/* Board type definitions */
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci#define T_NEO		0000
7362306a36Sopenharmony_ci#define T_CLASSIC	0001
7462306a36Sopenharmony_ci#define T_PCIBUS	0400
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/* Board State Definitions */
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci#define BD_RUNNING	0x0
7962306a36Sopenharmony_ci#define BD_REASON	0x7f
8062306a36Sopenharmony_ci#define BD_NOTFOUND	0x1
8162306a36Sopenharmony_ci#define BD_NOIOPORT	0x2
8262306a36Sopenharmony_ci#define BD_NOMEM	0x3
8362306a36Sopenharmony_ci#define BD_NOBIOS	0x4
8462306a36Sopenharmony_ci#define BD_NOFEP	0x5
8562306a36Sopenharmony_ci#define BD_FAILED	0x6
8662306a36Sopenharmony_ci#define BD_ALLOCATED	0x7
8762306a36Sopenharmony_ci#define BD_TRIBOOT	0x8
8862306a36Sopenharmony_ci#define BD_BADKME	0x80
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci/* 4 extra for alignment play space */
9262306a36Sopenharmony_ci#define WRITEBUFLEN	((4096) + 4)
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci#define JSM_VERSION	"jsm: 1.2-1-INKERNEL"
9562306a36Sopenharmony_ci#define JSM_PARTNUM	"40002438_A-INKERNEL"
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_cistruct jsm_board;
9862306a36Sopenharmony_cistruct jsm_channel;
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci/************************************************************************
10162306a36Sopenharmony_ci * Per board operations structure					*
10262306a36Sopenharmony_ci ************************************************************************/
10362306a36Sopenharmony_cistruct board_ops {
10462306a36Sopenharmony_ci	irq_handler_t intr;
10562306a36Sopenharmony_ci	void (*uart_init)(struct jsm_channel *ch);
10662306a36Sopenharmony_ci	void (*uart_off)(struct jsm_channel *ch);
10762306a36Sopenharmony_ci	void (*param)(struct jsm_channel *ch);
10862306a36Sopenharmony_ci	void (*assert_modem_signals)(struct jsm_channel *ch);
10962306a36Sopenharmony_ci	void (*flush_uart_write)(struct jsm_channel *ch);
11062306a36Sopenharmony_ci	void (*flush_uart_read)(struct jsm_channel *ch);
11162306a36Sopenharmony_ci	void (*disable_receiver)(struct jsm_channel *ch);
11262306a36Sopenharmony_ci	void (*enable_receiver)(struct jsm_channel *ch);
11362306a36Sopenharmony_ci	void (*send_break)(struct jsm_channel *ch);
11462306a36Sopenharmony_ci	void (*clear_break)(struct jsm_channel *ch);
11562306a36Sopenharmony_ci	void (*send_start_character)(struct jsm_channel *ch);
11662306a36Sopenharmony_ci	void (*send_stop_character)(struct jsm_channel *ch);
11762306a36Sopenharmony_ci	void (*copy_data_from_queue_to_uart)(struct jsm_channel *ch);
11862306a36Sopenharmony_ci	u32 (*get_uart_bytes_left)(struct jsm_channel *ch);
11962306a36Sopenharmony_ci	void (*send_immediate_char)(struct jsm_channel *ch, unsigned char);
12062306a36Sopenharmony_ci};
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci/*
12462306a36Sopenharmony_ci *	Per-board information
12562306a36Sopenharmony_ci */
12662306a36Sopenharmony_cistruct jsm_board
12762306a36Sopenharmony_ci{
12862306a36Sopenharmony_ci	int		boardnum;	/* Board number: 0-32 */
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci	int		type;		/* Type of board */
13162306a36Sopenharmony_ci	u8		rev;		/* PCI revision ID */
13262306a36Sopenharmony_ci	struct pci_dev	*pci_dev;
13362306a36Sopenharmony_ci	u32		maxports;	/* MAX ports this board can handle */
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci	spinlock_t	bd_intr_lock;	/* Used to protect the poller tasklet and
13662306a36Sopenharmony_ci					 * the interrupt routine from each other.
13762306a36Sopenharmony_ci					 */
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci	u32		nasync;		/* Number of ports on card */
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci	u32		irq;		/* Interrupt request number */
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci	u64		membase;	/* Start of base memory of the card */
14462306a36Sopenharmony_ci	u64		membase_end;	/* End of base memory of the card */
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci	u8	__iomem *re_map_membase;/* Remapped memory of the card */
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci	u64		iobase;		/* Start of io base of the card */
14962306a36Sopenharmony_ci	u64		iobase_end;	/* End of io base of the card */
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci	u32		bd_uart_offset;	/* Space between each UART */
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci	struct jsm_channel *channels[MAXPORTS]; /* array of pointers to our channels. */
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci	u32		bd_dividend;	/* Board/UARTs specific dividend */
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci	struct board_ops *bd_ops;
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci	struct list_head jsm_board_entry;
16062306a36Sopenharmony_ci};
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci/************************************************************************
16362306a36Sopenharmony_ci * Device flag definitions for ch_flags.
16462306a36Sopenharmony_ci ************************************************************************/
16562306a36Sopenharmony_ci#define CH_PRON		0x0001		/* Printer on string		*/
16662306a36Sopenharmony_ci#define CH_STOP		0x0002		/* Output is stopped		*/
16762306a36Sopenharmony_ci#define CH_STOPI	0x0004		/* Input is stopped		*/
16862306a36Sopenharmony_ci#define CH_CD		0x0008		/* Carrier is present		*/
16962306a36Sopenharmony_ci#define CH_FCAR		0x0010		/* Carrier forced on		*/
17062306a36Sopenharmony_ci#define CH_HANGUP	0x0020		/* Hangup received		*/
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci#define CH_RECEIVER_OFF	0x0040		/* Receiver is off		*/
17362306a36Sopenharmony_ci#define CH_OPENING	0x0080		/* Port in fragile open state	*/
17462306a36Sopenharmony_ci#define CH_CLOSING	0x0100		/* Port in fragile close state	*/
17562306a36Sopenharmony_ci#define CH_FIFO_ENABLED 0x0200		/* Port has FIFOs enabled	*/
17662306a36Sopenharmony_ci#define CH_TX_FIFO_EMPTY 0x0400		/* TX Fifo is completely empty	*/
17762306a36Sopenharmony_ci#define CH_TX_FIFO_LWM	0x0800		/* TX Fifo is below Low Water	*/
17862306a36Sopenharmony_ci#define CH_BREAK_SENDING 0x1000		/* Break is being sent		*/
17962306a36Sopenharmony_ci#define CH_LOOPBACK 0x2000		/* Channel is in lookback mode	*/
18062306a36Sopenharmony_ci#define CH_BAUD0	0x08000		/* Used for checking B0 transitions */
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci/* Our Read/Error queue sizes */
18362306a36Sopenharmony_ci#define RQUEUEMASK	0x1FFF		/* 8 K - 1 */
18462306a36Sopenharmony_ci#define EQUEUEMASK	0x1FFF		/* 8 K - 1 */
18562306a36Sopenharmony_ci#define RQUEUESIZE	(RQUEUEMASK + 1)
18662306a36Sopenharmony_ci#define EQUEUESIZE	RQUEUESIZE
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_ci
18962306a36Sopenharmony_ci/************************************************************************
19062306a36Sopenharmony_ci * Channel information structure.
19162306a36Sopenharmony_ci ************************************************************************/
19262306a36Sopenharmony_cistruct jsm_channel {
19362306a36Sopenharmony_ci	struct uart_port uart_port;
19462306a36Sopenharmony_ci	struct jsm_board	*ch_bd;		/* Board structure pointer	*/
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ci	spinlock_t	ch_lock;	/* provide for serialization */
19762306a36Sopenharmony_ci	wait_queue_head_t ch_flags_wait;
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ci	u32		ch_portnum;	/* Port number, 0 offset.	*/
20062306a36Sopenharmony_ci	u32		ch_open_count;	/* open count			*/
20162306a36Sopenharmony_ci	u32		ch_flags;	/* Channel flags		*/
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ci	u64		ch_close_delay;	/* How long we should drop RTS/DTR for */
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ci	tcflag_t	ch_c_iflag;	/* channel iflags		*/
20662306a36Sopenharmony_ci	tcflag_t	ch_c_cflag;	/* channel cflags		*/
20762306a36Sopenharmony_ci	tcflag_t	ch_c_oflag;	/* channel oflags		*/
20862306a36Sopenharmony_ci	tcflag_t	ch_c_lflag;	/* channel lflags		*/
20962306a36Sopenharmony_ci	u8		ch_stopc;	/* Stop character		*/
21062306a36Sopenharmony_ci	u8		ch_startc;	/* Start character		*/
21162306a36Sopenharmony_ci
21262306a36Sopenharmony_ci	u8		ch_mostat;	/* FEP output modem status	*/
21362306a36Sopenharmony_ci	u8		ch_mistat;	/* FEP input modem status	*/
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ci	/* Pointers to the "mapped" UART structs */
21662306a36Sopenharmony_ci	struct neo_uart_struct __iomem *ch_neo_uart; /* NEO card */
21762306a36Sopenharmony_ci	struct cls_uart_struct __iomem *ch_cls_uart; /* Classic card */
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_ci	u8		ch_cached_lsr;	/* Cached value of the LSR register */
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_ci	u8		*ch_rqueue;	/* Our read queue buffer - malloc'ed */
22262306a36Sopenharmony_ci	u16		ch_r_head;	/* Head location of the read queue */
22362306a36Sopenharmony_ci	u16		ch_r_tail;	/* Tail location of the read queue */
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_ci	u8		*ch_equeue;	/* Our error queue buffer - malloc'ed */
22662306a36Sopenharmony_ci	u16		ch_e_head;	/* Head location of the error queue */
22762306a36Sopenharmony_ci	u16		ch_e_tail;	/* Tail location of the error queue */
22862306a36Sopenharmony_ci
22962306a36Sopenharmony_ci	u64		ch_rxcount;	/* total of data received so far */
23062306a36Sopenharmony_ci	u64		ch_txcount;	/* total of data transmitted so far */
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci	u8		ch_r_tlevel;	/* Receive Trigger level */
23362306a36Sopenharmony_ci	u8		ch_t_tlevel;	/* Transmit Trigger level */
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_ci	u8		ch_r_watermark;	/* Receive Watermark */
23662306a36Sopenharmony_ci
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ci	u32		ch_stops_sent;	/* How many times I have sent a stop character
23962306a36Sopenharmony_ci					 * to try to stop the other guy sending.
24062306a36Sopenharmony_ci					 */
24162306a36Sopenharmony_ci	u64		ch_err_parity;	/* Count of parity errors on channel */
24262306a36Sopenharmony_ci	u64		ch_err_frame;	/* Count of framing errors on channel */
24362306a36Sopenharmony_ci	u64		ch_err_break;	/* Count of breaks on channel */
24462306a36Sopenharmony_ci	u64		ch_err_overrun; /* Count of overruns on channel */
24562306a36Sopenharmony_ci
24662306a36Sopenharmony_ci	u64		ch_xon_sends;	/* Count of xons transmitted */
24762306a36Sopenharmony_ci	u64		ch_xoff_sends;	/* Count of xoffs transmitted */
24862306a36Sopenharmony_ci};
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_ci/************************************************************************
25162306a36Sopenharmony_ci * Per channel/port Classic UART structures				*
25262306a36Sopenharmony_ci ************************************************************************
25362306a36Sopenharmony_ci *		Base Structure Entries Usage Meanings to Host		*
25462306a36Sopenharmony_ci *									*
25562306a36Sopenharmony_ci *	W = read write		R = read only				*
25662306a36Sopenharmony_ci *			U = Unused.					*
25762306a36Sopenharmony_ci ************************************************************************/
25862306a36Sopenharmony_ci
25962306a36Sopenharmony_cistruct cls_uart_struct {
26062306a36Sopenharmony_ci	u8 txrx;	/* WR  RHR/THR - Holding Reg */
26162306a36Sopenharmony_ci	u8 ier;		/* WR  IER - Interrupt Enable Reg */
26262306a36Sopenharmony_ci	u8 isr_fcr;	/* WR  ISR/FCR - Interrupt Status Reg/Fifo Control Reg*/
26362306a36Sopenharmony_ci	u8 lcr;		/* WR  LCR - Line Control Reg */
26462306a36Sopenharmony_ci	u8 mcr;		/* WR  MCR - Modem Control Reg */
26562306a36Sopenharmony_ci	u8 lsr;		/* WR  LSR - Line Status Reg */
26662306a36Sopenharmony_ci	u8 msr;		/* WR  MSR - Modem Status Reg */
26762306a36Sopenharmony_ci	u8 spr;		/* WR  SPR - Scratch Pad Reg */
26862306a36Sopenharmony_ci};
26962306a36Sopenharmony_ci
27062306a36Sopenharmony_ci/* Where to read the interrupt register (8bits) */
27162306a36Sopenharmony_ci#define UART_CLASSIC_POLL_ADDR_OFFSET	0x40
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ci#define UART_EXAR654_ENHANCED_REGISTER_SET 0xBF
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_ci#define UART_16654_FCR_TXTRIGGER_8	0x0
27662306a36Sopenharmony_ci#define UART_16654_FCR_TXTRIGGER_16	0x10
27762306a36Sopenharmony_ci#define UART_16654_FCR_TXTRIGGER_32	0x20
27862306a36Sopenharmony_ci#define UART_16654_FCR_TXTRIGGER_56	0x30
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci#define UART_16654_FCR_RXTRIGGER_8	0x0
28162306a36Sopenharmony_ci#define UART_16654_FCR_RXTRIGGER_16	0x40
28262306a36Sopenharmony_ci#define UART_16654_FCR_RXTRIGGER_56	0x80
28362306a36Sopenharmony_ci#define UART_16654_FCR_RXTRIGGER_60	0xC0
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ci#define UART_IIR_CTSRTS			0x20	/* Received CTS/RTS change of state */
28662306a36Sopenharmony_ci#define UART_IIR_RDI_TIMEOUT		0x0C    /* Receiver data TIMEOUT */
28762306a36Sopenharmony_ci
28862306a36Sopenharmony_ci/*
28962306a36Sopenharmony_ci * These are the EXTENDED definitions for the Exar 654's Interrupt
29062306a36Sopenharmony_ci * Enable Register.
29162306a36Sopenharmony_ci */
29262306a36Sopenharmony_ci#define UART_EXAR654_EFR_ECB      0x10    /* Enhanced control bit */
29362306a36Sopenharmony_ci#define UART_EXAR654_EFR_IXON     0x2     /* Receiver compares Xon1/Xoff1 */
29462306a36Sopenharmony_ci#define UART_EXAR654_EFR_IXOFF    0x8     /* Transmit Xon1/Xoff1 */
29562306a36Sopenharmony_ci#define UART_EXAR654_EFR_RTSDTR   0x40    /* Auto RTS/DTR Flow Control Enable */
29662306a36Sopenharmony_ci#define UART_EXAR654_EFR_CTSDSR   0x80    /* Auto CTS/DSR Flow COntrol Enable */
29762306a36Sopenharmony_ci
29862306a36Sopenharmony_ci#define UART_EXAR654_XOFF_DETECT  0x1     /* Indicates whether chip saw an incoming XOFF char  */
29962306a36Sopenharmony_ci#define UART_EXAR654_XON_DETECT   0x2     /* Indicates whether chip saw an incoming XON char */
30062306a36Sopenharmony_ci
30162306a36Sopenharmony_ci#define UART_EXAR654_IER_XOFF     0x20    /* Xoff Interrupt Enable */
30262306a36Sopenharmony_ci#define UART_EXAR654_IER_RTSDTR   0x40    /* Output Interrupt Enable */
30362306a36Sopenharmony_ci#define UART_EXAR654_IER_CTSDSR   0x80    /* Input Interrupt Enable */
30462306a36Sopenharmony_ci
30562306a36Sopenharmony_ci/************************************************************************
30662306a36Sopenharmony_ci * Per channel/port NEO UART structure					*
30762306a36Sopenharmony_ci ************************************************************************
30862306a36Sopenharmony_ci *		Base Structure Entries Usage Meanings to Host		*
30962306a36Sopenharmony_ci *									*
31062306a36Sopenharmony_ci *	W = read write		R = read only				*
31162306a36Sopenharmony_ci *			U = Unused.					*
31262306a36Sopenharmony_ci ************************************************************************/
31362306a36Sopenharmony_ci
31462306a36Sopenharmony_cistruct neo_uart_struct {
31562306a36Sopenharmony_ci	 u8 txrx;		/* WR	RHR/THR - Holding Reg */
31662306a36Sopenharmony_ci	 u8 ier;		/* WR	IER - Interrupt Enable Reg */
31762306a36Sopenharmony_ci	 u8 isr_fcr;		/* WR	ISR/FCR - Interrupt Status Reg/Fifo Control Reg */
31862306a36Sopenharmony_ci	 u8 lcr;		/* WR	LCR - Line Control Reg */
31962306a36Sopenharmony_ci	 u8 mcr;		/* WR	MCR - Modem Control Reg */
32062306a36Sopenharmony_ci	 u8 lsr;		/* WR	LSR - Line Status Reg */
32162306a36Sopenharmony_ci	 u8 msr;		/* WR	MSR - Modem Status Reg */
32262306a36Sopenharmony_ci	 u8 spr;		/* WR	SPR - Scratch Pad Reg */
32362306a36Sopenharmony_ci	 u8 fctr;		/* WR	FCTR - Feature Control Reg */
32462306a36Sopenharmony_ci	 u8 efr;		/* WR	EFR - Enhanced Function Reg */
32562306a36Sopenharmony_ci	 u8 tfifo;		/* WR	TXCNT/TXTRG - Transmit FIFO Reg */
32662306a36Sopenharmony_ci	 u8 rfifo;		/* WR	RXCNT/RXTRG - Receive FIFO Reg */
32762306a36Sopenharmony_ci	 u8 xoffchar1;	/* WR	XOFF 1 - XOff Character 1 Reg */
32862306a36Sopenharmony_ci	 u8 xoffchar2;	/* WR	XOFF 2 - XOff Character 2 Reg */
32962306a36Sopenharmony_ci	 u8 xonchar1;	/* WR	XON 1 - Xon Character 1 Reg */
33062306a36Sopenharmony_ci	 u8 xonchar2;	/* WR	XON 2 - XOn Character 2 Reg */
33162306a36Sopenharmony_ci
33262306a36Sopenharmony_ci	 u8 reserved1[0x2ff - 0x200]; /* U	Reserved by Exar */
33362306a36Sopenharmony_ci	 u8 txrxburst[64];	/* RW	64 bytes of RX/TX FIFO Data */
33462306a36Sopenharmony_ci	 u8 reserved2[0x37f - 0x340]; /* U	Reserved by Exar */
33562306a36Sopenharmony_ci	 u8 rxburst_with_errors[64];	/* R	64 bytes of RX FIFO Data + LSR */
33662306a36Sopenharmony_ci};
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_ci/* Where to read the extended interrupt register (32bits instead of 8bits) */
33962306a36Sopenharmony_ci#define	UART_17158_POLL_ADDR_OFFSET	0x80
34062306a36Sopenharmony_ci
34162306a36Sopenharmony_ci/*
34262306a36Sopenharmony_ci * These are the redefinitions for the FCTR on the XR17C158, since
34362306a36Sopenharmony_ci * Exar made them different than their earlier design. (XR16C854)
34462306a36Sopenharmony_ci */
34562306a36Sopenharmony_ci
34662306a36Sopenharmony_ci/* These are only applicable when table D is selected */
34762306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_NODELAY	0x00
34862306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_4DELAY	0x01
34962306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_6DELAY	0x02
35062306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_8DELAY	0x03
35162306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_12DELAY	0x12
35262306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_16DELAY	0x05
35362306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_20DELAY	0x13
35462306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_24DELAY	0x06
35562306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_28DELAY	0x14
35662306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_32DELAY	0x07
35762306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_36DELAY	0x16
35862306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_40DELAY	0x08
35962306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_44DELAY	0x09
36062306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_48DELAY	0x10
36162306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_52DELAY	0x11
36262306a36Sopenharmony_ci
36362306a36Sopenharmony_ci#define UART_17158_FCTR_RTS_IRDA	0x10
36462306a36Sopenharmony_ci#define UART_17158_FCTR_RS485		0x20
36562306a36Sopenharmony_ci#define UART_17158_FCTR_TRGA		0x00
36662306a36Sopenharmony_ci#define UART_17158_FCTR_TRGB		0x40
36762306a36Sopenharmony_ci#define UART_17158_FCTR_TRGC		0x80
36862306a36Sopenharmony_ci#define UART_17158_FCTR_TRGD		0xC0
36962306a36Sopenharmony_ci
37062306a36Sopenharmony_ci/* 17158 trigger table selects.. */
37162306a36Sopenharmony_ci#define UART_17158_FCTR_BIT6		0x40
37262306a36Sopenharmony_ci#define UART_17158_FCTR_BIT7		0x80
37362306a36Sopenharmony_ci
37462306a36Sopenharmony_ci/* 17158 TX/RX memmapped buffer offsets */
37562306a36Sopenharmony_ci#define UART_17158_RX_FIFOSIZE		64
37662306a36Sopenharmony_ci#define UART_17158_TX_FIFOSIZE		64
37762306a36Sopenharmony_ci
37862306a36Sopenharmony_ci/* 17158 Extended IIR's */
37962306a36Sopenharmony_ci#define UART_17158_IIR_RDI_TIMEOUT	0x0C	/* Receiver data TIMEOUT */
38062306a36Sopenharmony_ci#define UART_17158_IIR_XONXOFF		0x10	/* Received an XON/XOFF char */
38162306a36Sopenharmony_ci#define UART_17158_IIR_HWFLOW_STATE_CHANGE 0x20	/* CTS/DSR or RTS/DTR state change */
38262306a36Sopenharmony_ci#define UART_17158_IIR_FIFO_ENABLED	0xC0	/* 16550 FIFOs are Enabled */
38362306a36Sopenharmony_ci
38462306a36Sopenharmony_ci/*
38562306a36Sopenharmony_ci * These are the extended interrupts that get sent
38662306a36Sopenharmony_ci * back to us from the UART's 32bit interrupt register
38762306a36Sopenharmony_ci */
38862306a36Sopenharmony_ci#define UART_17158_RX_LINE_STATUS	0x1	/* RX Ready */
38962306a36Sopenharmony_ci#define UART_17158_RXRDY_TIMEOUT	0x2	/* RX Ready Timeout */
39062306a36Sopenharmony_ci#define UART_17158_TXRDY		0x3	/* TX Ready */
39162306a36Sopenharmony_ci#define UART_17158_MSR			0x4	/* Modem State Change */
39262306a36Sopenharmony_ci#define UART_17158_TX_AND_FIFO_CLR	0x40	/* Transmitter Holding Reg Empty */
39362306a36Sopenharmony_ci#define UART_17158_RX_FIFO_DATA_ERROR	0x80	/* UART detected an RX FIFO Data error */
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_ci/*
39662306a36Sopenharmony_ci * These are the EXTENDED definitions for the 17C158's Interrupt
39762306a36Sopenharmony_ci * Enable Register.
39862306a36Sopenharmony_ci */
39962306a36Sopenharmony_ci#define UART_17158_EFR_ECB	0x10	/* Enhanced control bit */
40062306a36Sopenharmony_ci#define UART_17158_EFR_IXON	0x2	/* Receiver compares Xon1/Xoff1 */
40162306a36Sopenharmony_ci#define UART_17158_EFR_IXOFF	0x8	/* Transmit Xon1/Xoff1 */
40262306a36Sopenharmony_ci#define UART_17158_EFR_RTSDTR	0x40	/* Auto RTS/DTR Flow Control Enable */
40362306a36Sopenharmony_ci#define UART_17158_EFR_CTSDSR	0x80	/* Auto CTS/DSR Flow COntrol Enable */
40462306a36Sopenharmony_ci
40562306a36Sopenharmony_ci#define UART_17158_XOFF_DETECT	0x1	/* Indicates whether chip saw an incoming XOFF char */
40662306a36Sopenharmony_ci#define UART_17158_XON_DETECT	0x2	/* Indicates whether chip saw an incoming XON char */
40762306a36Sopenharmony_ci
40862306a36Sopenharmony_ci#define UART_17158_IER_RSVD1	0x10	/* Reserved by Exar */
40962306a36Sopenharmony_ci#define UART_17158_IER_XOFF	0x20	/* Xoff Interrupt Enable */
41062306a36Sopenharmony_ci#define UART_17158_IER_RTSDTR	0x40	/* Output Interrupt Enable */
41162306a36Sopenharmony_ci#define UART_17158_IER_CTSDSR	0x80	/* Input Interrupt Enable */
41262306a36Sopenharmony_ci
41362306a36Sopenharmony_ci#define PCI_DEVICE_NEO_2DB9_PCI_NAME		"Neo 2 - DB9 Universal PCI"
41462306a36Sopenharmony_ci#define PCI_DEVICE_NEO_2DB9PRI_PCI_NAME		"Neo 2 - DB9 Universal PCI - Powered Ring Indicator"
41562306a36Sopenharmony_ci#define PCI_DEVICE_NEO_2RJ45_PCI_NAME		"Neo 2 - RJ45 Universal PCI"
41662306a36Sopenharmony_ci#define PCI_DEVICE_NEO_2RJ45PRI_PCI_NAME	"Neo 2 - RJ45 Universal PCI - Powered Ring Indicator"
41762306a36Sopenharmony_ci#define PCIE_DEVICE_NEO_IBM_PCI_NAME		"Neo 4 - PCI Express - IBM"
41862306a36Sopenharmony_ci
41962306a36Sopenharmony_ci/*
42062306a36Sopenharmony_ci * Our Global Variables.
42162306a36Sopenharmony_ci */
42262306a36Sopenharmony_ciextern struct	uart_driver jsm_uart_driver;
42362306a36Sopenharmony_ciextern struct	board_ops jsm_neo_ops;
42462306a36Sopenharmony_ciextern struct	board_ops jsm_cls_ops;
42562306a36Sopenharmony_ciextern int	jsm_debug;
42662306a36Sopenharmony_ci
42762306a36Sopenharmony_ci/*************************************************************************
42862306a36Sopenharmony_ci *
42962306a36Sopenharmony_ci * Prototypes for non-static functions used in more than one module
43062306a36Sopenharmony_ci *
43162306a36Sopenharmony_ci *************************************************************************/
43262306a36Sopenharmony_ciint jsm_tty_init(struct jsm_board *);
43362306a36Sopenharmony_ciint jsm_uart_port_init(struct jsm_board *);
43462306a36Sopenharmony_ciint jsm_remove_uart_port(struct jsm_board *);
43562306a36Sopenharmony_civoid jsm_input(struct jsm_channel *ch);
43662306a36Sopenharmony_civoid jsm_check_queue_flow_control(struct jsm_channel *ch);
43762306a36Sopenharmony_ci
43862306a36Sopenharmony_ci#endif
439