OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [char/] [dz.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * dz.h: Serial port driver for DECStations equiped
3
 *       with the DZ chipset.
4
 *
5
 * Copyright (C) 1998 Olivier A. D. Lebaillif
6
 *
7
 * Email: olivier.lebaillif@ifrsys.com
8
 *
9
 */
10
#ifndef DZ_SERIAL_H
11
#define DZ_SERIAL_H
12
 
13
#define SERIAL_MAGIC 0x5301
14
 
15
/*
16
 * Definitions for the Control and Status Received.
17
 */
18
#define DZ_TRDY        0x8000                 /* Transmitter empty */
19
#define DZ_TIE         0x4000                 /* Transmitter Interrupt Enable */
20
#define DZ_RDONE       0x0080                 /* Receiver data ready */
21
#define DZ_RIE         0x0040                 /* Receive Interrupt Enable */
22
#define DZ_MSE         0x0020                 /* Master Scan Enable */
23
#define DZ_CLR         0x0010                 /* Master reset */
24
#define DZ_MAINT       0x0008                 /* Loop Back Mode */
25
 
26
/*
27
 * Definitions for the Received buffer.
28
 */
29
#define DZ_RBUF_MASK   0x00FF                 /* Data Mask in the Receive Buffer */
30
#define DZ_LINE_MASK   0x0300                 /* Line Mask in the Receive Buffer */
31
#define DZ_DVAL        0x8000                 /* Valid Data indicator */
32
#define DZ_OERR        0x4000                 /* Overrun error indicator */
33
#define DZ_FERR        0x2000                 /* Frame error indicator */
34
#define DZ_PERR        0x1000                 /* Parity error indicator */
35
 
36
#define LINE(x) (x & DZ_LINE_MASK) >> 8       /* Get the line number from the input buffer */
37
#define UCHAR(x) (unsigned char)(x & DZ_RBUF_MASK)
38
 
39
/*
40
 * Definitions for the Transmit Register.
41
 */
42
#define DZ_LINE_KEYBOARD 0x0001
43
#define DZ_LINE_MOUSE    0x0002
44
#define DZ_LINE_MODEM    0x0004
45
#define DZ_LINE_PRINTER  0x0008
46
 
47
#define DZ_MODEM_DTR     0x0400               /* DTR for the modem line (2) */
48
 
49
/*
50
 * Definitions for the Modem Status Register.
51
 */
52
#define DZ_MODEM_DSR     0x0200               /* DSR for the modem line (2) */
53
 
54
/*
55
 * Definitions for the Transmit Data Register.
56
 */
57
#define DZ_BRK0          0x0100               /* Break assertion for line 0 */
58
#define DZ_BRK1          0x0200               /* Break assertion for line 1 */
59
#define DZ_BRK2          0x0400               /* Break assertion for line 2 */
60
#define DZ_BRK3          0x0800               /* Break assertion for line 3 */
61
 
62
/*
63
 * Definitions for the Line Parameter Register.
64
 */
65
#define DZ_KEYBOARD      0x0000               /* line 0 = keyboard */
66
#define DZ_MOUSE         0x0001               /* line 1 = mouse */
67
#define DZ_MODEM         0x0002               /* line 2 = modem */
68
#define DZ_PRINTER       0x0003               /* line 3 = printer */
69
 
70
#define DZ_CSIZE         0x0018               /* Number of bits per byte (mask) */
71
#define DZ_CS5           0x0000               /* 5 bits per byte */
72
#define DZ_CS6           0x0008               /* 6 bits per byte */
73
#define DZ_CS7           0x0010               /* 7 bits per byte */
74
#define DZ_CS8           0x0018               /* 8 bits per byte */
75
 
76
#define DZ_CSTOPB        0x0020               /* 2 stop bits instead of one */ 
77
 
78
#define DZ_PARENB        0x0040               /* Parity enable */
79
#define DZ_PARODD        0x0080               /* Odd parity instead of even */
80
 
81
#define DZ_CBAUD         0x0E00               /* Baud Rate (mask) */
82
#define DZ_B50           0x0000
83
#define DZ_B75           0x0100
84
#define DZ_B110          0x0200
85
#define DZ_B134          0x0300
86
#define DZ_B150          0x0400
87
#define DZ_B300          0x0500
88
#define DZ_B600          0x0600
89
#define DZ_B1200         0x0700 
90
#define DZ_B1800         0x0800
91
#define DZ_B2000         0x0900
92
#define DZ_B2400         0x0A00
93
#define DZ_B3600         0x0B00
94
#define DZ_B4800         0x0C00
95
#define DZ_B7200         0x0D00
96
#define DZ_B9600         0x0E00
97
 
98
#define DZ_CREAD         0x1000               /* Enable receiver */
99
#define DZ_RXENAB        0x1000               /* enable receive char */
100
/*
101
 * Addresses for the DZ registers
102
 */
103
#define DZ_CSR       0x00            /* Control and Status Register */
104
#define DZ_RBUF      0x08            /* Receive Buffer */
105
#define DZ_LPR       0x08            /* Line Parameters Register */
106
#define DZ_TCR       0x10            /* Transmitter Control Register */
107
#define DZ_MSR       0x18            /* Modem Status Register */
108
#define DZ_TDR       0x18            /* Transmit Data Register */
109
 
110
 
111
#define DZ_NB_PORT 4
112
 
113
#define DZ_XMIT_SIZE   4096                 /* buffer size */
114
#define WAKEUP_CHARS   DZ_XMIT_SIZE/4
115
 
116
#define DZ_EVENT_WRITE_WAKEUP   0
117
 
118
#ifndef MIN
119
#define MIN(a,b)        ((a) < (b) ? (a) : (b))
120
 
121
#define DZ_INITIALIZED       0x80000000 /* Serial port was initialized */
122
#define DZ_CALLOUT_ACTIVE    0x40000000 /* Call out device is active */
123
#define DZ_NORMAL_ACTIVE     0x20000000 /* Normal device is active */
124
#define DZ_BOOT_AUTOCONF     0x10000000 /* Autoconfigure port on bootup */
125
#define DZ_CLOSING           0x08000000 /* Serial port is closing */
126
#define DZ_CTS_FLOW          0x04000000 /* Do CTS flow control */
127
#define DZ_CHECK_CD          0x02000000 /* i.e., CLOCAL */
128
 
129
#define DZ_CLOSING_WAIT_INF  0
130
#define DZ_CLOSING_WAIT_NONE 65535
131
 
132
#define DZ_SPLIT_TERMIOS   0x0008 /* Separate termios for dialin/callout */
133
#define DZ_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */
134
#define DZ_PGRP_LOCKOUT    0x0200 /* Lock out cua opens based on pgrp */
135
 
136
struct dz_serial {
137
  unsigned                port;                /* base address for the port */
138
  int                     type;
139
  int                     flags;
140
  int                     baud_base;
141
  int                     blocked_open;
142
  unsigned short          close_delay;
143
  unsigned short          closing_wait;
144
  unsigned short          line;                /* port/line number */
145
  unsigned short          cflags;              /* line configuration flag */
146
  unsigned short          x_char;              /* xon/xoff character */
147
  unsigned short          read_status_mask;    /* mask for read condition */
148
  unsigned short          ignore_status_mask;  /* mask for ignore condition */
149
  unsigned long           event;               /* mask used in BH */
150
  unsigned char           *xmit_buf;           /* Transmit buffer */
151
  int                     xmit_head;           /* Position of the head */
152
  int                     xmit_tail;           /* Position of the tail */
153
  int                     xmit_cnt;            /* Count of the chars in the buffer */
154
  int                     count;               /* indicates how many times it has been opened */
155
  int                     magic;
156
 
157
  struct async_icount     icount;              /* keep track of things ... */
158
  struct tty_struct       *tty;                /* tty associated */
159
  struct tq_struct        tqueue;              /* Queue for BH */
160
  struct tq_struct        tqueue_hangup;
161
  struct termios          normal_termios;
162
  struct termios          callout_termios;
163
  wait_queue_head_t       open_wait;
164
  wait_queue_head_t       close_wait;
165
 
166
  long                    session;             /* Session of opening process */
167
  long                    pgrp;                /* pgrp of opening process */
168
 
169
  unsigned char           is_console;          /* flag indicating a serial console */
170
  unsigned char           is_initialized;
171
};
172
 
173
static struct dz_serial multi[DZ_NB_PORT];    /* Four serial lines in the DZ chip */
174
static struct dz_serial *dz_console;
175
static struct tty_driver serial_driver, callout_driver;
176
 
177
static struct tty_struct *serial_table[DZ_NB_PORT];
178
static struct termios *serial_termios[DZ_NB_PORT];
179
static struct termios *serial_termios_locked[DZ_NB_PORT];
180
 
181
static int serial_refcount;
182
 
183
/*
184
 * tmp_buf is used as a temporary buffer by serial_write.  We need to
185
 * lock it in case the copy_from_user blocks while swapping in a page,
186
 * and some other program tries to do a serial write at the same time.
187
 * Since the lock will only come under contention when the system is
188
 * swapping and available memory is low, it makes sense to share one
189
 * buffer across all the serial ports, since it significantly saves
190
 * memory if large numbers of serial ports are open.
191
 */
192
static unsigned char *tmp_buf;
193
static DECLARE_MUTEX(tmp_buf_sem);
194
 
195
static char *dz_name = "DECstation DZ serial driver version ";
196
static char *dz_version = "1.02";
197
 
198
static inline unsigned short dz_in (struct dz_serial *, unsigned);
199
static inline void dz_out (struct dz_serial *, unsigned, unsigned short);
200
 
201
static inline void dz_sched_event (struct dz_serial *, int);
202
static inline void receive_chars (struct dz_serial *);
203
static inline void transmit_chars (struct dz_serial *);
204
static inline void check_modem_status (struct dz_serial *);
205
 
206
static void dz_stop (struct tty_struct *);
207
static void dz_start (struct tty_struct *);
208
static void dz_interrupt (int, void *, struct pt_regs *);
209
static void do_serial_bh (void);
210
static void do_softint (void *);
211
static void do_serial_hangup (void *);
212
static void change_speed (struct dz_serial *);
213
static void dz_flush_chars (struct tty_struct *);
214
static void dz_console_print (struct console *, const char *, unsigned int);
215
static void dz_flush_buffer (struct tty_struct *);
216
static void dz_throttle (struct tty_struct *);
217
static void dz_unthrottle (struct tty_struct *);
218
static void dz_send_xchar (struct tty_struct *, char);
219
static void shutdown (struct dz_serial *);
220
static void send_break (struct dz_serial *, int);
221
static void dz_set_termios (struct tty_struct *, struct termios *);
222
static void dz_close (struct tty_struct *, struct file *);
223
static void dz_hangup (struct tty_struct *);
224
static void show_serial_version (void);
225
 
226
static int dz_write (struct tty_struct *, int, const unsigned char *, int);
227
static int dz_write_room (struct tty_struct *);
228
static int dz_chars_in_buffer (struct tty_struct *);
229
static int startup (struct dz_serial *);
230
static int get_serial_info (struct dz_serial *, struct serial_struct *);
231
static int set_serial_info (struct dz_serial *, struct serial_struct *);
232
static int get_lsr_info (struct dz_serial *, unsigned int *);
233
static int dz_ioctl (struct tty_struct *, struct file *, unsigned int, unsigned long);
234
static int block_til_ready (struct tty_struct *, struct file *, struct dz_serial *);
235
static int dz_open (struct tty_struct *, struct file *);
236
 
237
#ifdef MODULE
238
int init_module (void)
239
void cleanup_module (void)
240
#endif
241
 
242
#endif
243
 
244
#endif /* DZ_SERIAL_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.