1/*
2 * Private header file for the (dumb) serial driver
3 *
4 * Copyright (C) 1997 by Theodore Ts'o.
5 *
6 * Redistribution of this file is permitted under the terms of the GNU
7 * Public License (GPL)
8 */
9
10#ifndef _LINUX_SERIALP_H
11#define _LINUX_SERIALP_H
12
13/*
14 * This is our internal structure for each serial port's state.
15 *
16 * Many fields are paralleled by the structure used by the serial_struct
17 * structure.
18 *
19 * For definitions of the flags field, see tty.h
20 */
21
22#include <linux/config.h>
23#include <linux/termios.h>
24#include <linux/tqueue.h>
25#include <linux/circ_buf.h>
26#include <linux/wait.h>
27#if (LINUX_VERSION_CODE < 0x020300)
28/* Unfortunate, but Linux 2.2 needs async_icount defined here and
29 * it got moved in 2.3 */
30#include <linux/serial.h>
31#endif
32
33struct serial_state {
34	int	magic;
35	int	baud_base;
36	unsigned long	port;
37	int	irq;
38	int	flags;
39	int	hub6;
40	int	type;
41	int	line;
42	int	revision;	/* Chip revision (950) */
43	int	xmit_fifo_size;
44	int	custom_divisor;
45	int	count;
46	u8	*iomem_base;
47	u16	iomem_reg_shift;
48	unsigned short	close_delay;
49	unsigned short	closing_wait; /* time to wait before closing */
50	struct async_icount	icount;
51	struct termios		normal_termios;
52	struct termios		callout_termios;
53	int	io_type;
54	struct async_struct *info;
55	struct pci_dev	*dev;
56};
57
58struct async_struct {
59	int			magic;
60	unsigned long		port;
61	int			hub6;
62	int			flags;
63	int			xmit_fifo_size;
64	struct serial_state	*state;
65	struct tty_struct 	*tty;
66	int			read_status_mask;
67	int			ignore_status_mask;
68	int			timeout;
69	int			quot;
70	int			x_char;	/* xon/xoff character */
71	int			close_delay;
72	unsigned short		closing_wait;
73	unsigned short		closing_wait2;
74	int			IER; 	/* Interrupt Enable Register */
75	int			MCR; 	/* Modem control register */
76	int			LCR; 	/* Line control register */
77	int			ACR;	 /* 16950 Additional Control Reg. */
78	unsigned long		event;
79	unsigned long		last_active;
80	int			line;
81	int			blocked_open; /* # of blocked opens */
82	long			session; /* Session of opening process */
83	long			pgrp; /* pgrp of opening process */
84 	struct circ_buf		xmit;
85 	spinlock_t		xmit_lock;
86	u8			*iomem_base;
87	u16			iomem_reg_shift;
88	int			io_type;
89	struct tq_struct	tqueue;
90#ifdef DECLARE_WAITQUEUE
91	wait_queue_head_t	open_wait;
92	wait_queue_head_t	close_wait;
93	wait_queue_head_t	delta_msr_wait;
94#else
95	struct wait_queue	*open_wait;
96	struct wait_queue	*close_wait;
97	struct wait_queue	*delta_msr_wait;
98#endif
99	struct async_struct	*next_port; /* For the linked list */
100	struct async_struct	*prev_port;
101};
102
103#define CONFIGURED_SERIAL_PORT(info) ((info)->port || ((info)->iomem_base))
104
105#define SERIAL_MAGIC 0x5301
106#define SSTATE_MAGIC 0x5302
107
108/*
109 * Events are used to schedule things to happen at timer-interrupt
110 * time, instead of at rs interrupt time.
111 */
112#define RS_EVENT_WRITE_WAKEUP	0
113
114/*
115 * Multiport serial configuration structure --- internal structure
116 */
117struct rs_multiport_struct {
118	int		port1;
119	unsigned char	mask1, match1;
120	int		port2;
121	unsigned char	mask2, match2;
122	int		port3;
123	unsigned char	mask3, match3;
124	int		port4;
125	unsigned char	mask4, match4;
126	int		port_monitor;
127};
128
129#if defined(__alpha__) && !defined(CONFIG_PCI)
130/*
131 * Digital did something really horribly wrong with the OUT1 and OUT2
132 * lines on at least some ALPHA's.  The failure mode is that if either
133 * is cleared, the machine locks up with endless interrupts.
134 */
135#define ALPHA_KLUDGE_MCR  (UART_MCR_OUT2 | UART_MCR_OUT1)
136#else
137#define ALPHA_KLUDGE_MCR 0
138#endif
139
140/*
141 * Structures and definitions for PCI support
142 */
143struct pci_dev;
144struct pci_board {
145	int flags;
146	int num_ports;
147	int base_baud;
148	int uart_offset;
149	int reg_shift;
150	int (*init_fn)(struct pci_dev *dev, struct pci_board *board,
151			int enable);
152	int first_uart_offset;
153};
154
155struct pci_board_inst {
156	struct pci_board	board;
157	struct pci_dev		*dev;
158};
159
160extern int pci_siig10x_fn(struct pci_dev *dev, struct pci_board *board, int enable);
161extern int pci_siig20x_fn(struct pci_dev *dev, struct pci_board *board, int enable);
162
163#ifndef PCI_ANY_ID
164#define PCI_ANY_ID (~0)
165#endif
166
167#define SPCI_FL_BASE_MASK	0x0007
168#define SPCI_FL_BASE0	0x0000
169#define SPCI_FL_BASE1	0x0001
170#define SPCI_FL_BASE2	0x0002
171#define SPCI_FL_BASE3	0x0003
172#define SPCI_FL_BASE4	0x0004
173#define SPCI_FL_GET_BASE(x)	(x & SPCI_FL_BASE_MASK)
174
175#define SPCI_FL_IRQ_MASK       (0x0007 << 4)
176#define SPCI_FL_IRQBASE0       (0x0000 << 4)
177#define SPCI_FL_IRQBASE1       (0x0001 << 4)
178#define SPCI_FL_IRQBASE2       (0x0002 << 4)
179#define SPCI_FL_IRQBASE3       (0x0003 << 4)
180#define SPCI_FL_IRQBASE4       (0x0004 << 4)
181#define SPCI_FL_GET_IRQBASE(x)        ((x & SPCI_FL_IRQ_MASK) >> 4)
182
183/* Use successive BARs (PCI base address registers),
184   else use offset into some specified BAR */
185#define SPCI_FL_BASE_TABLE	0x0100
186
187/* Use successive entries in the irq resource table */
188#define SPCI_FL_IRQ_TABLE	0x0200
189
190/* Use the irq resource table instead of dev->irq */
191#define SPCI_FL_IRQRESOURCE	0x0400
192
193/* Use the Base address register size to cap number of ports */
194#define SPCI_FL_REGION_SZ_CAP	0x0800
195
196/* Do not use irq sharing for this device */
197#define SPCI_FL_NO_SHIRQ	0x1000
198
199/* This is a PNP device */
200#define SPCI_FL_ISPNP		0x2000
201
202#define SPCI_FL_PNPDEFAULT	(SPCI_FL_IRQRESOURCE|SPCI_FL_ISPNP)
203
204#endif /* _LINUX_SERIAL_H */
205