summaryrefslogtreecommitdiff
path: root/drivers/char/rio/rio_linux.h
blob: 4ce77fb1fae5f9befb1e9a794de4c422e1a25f66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*
 *  rio_linux.h
 *
 *  Copyright (C) 1998,1999,2000 R.E.Wolff@BitWizard.nl
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  RIO serial driver.
 *
 *  Version 1.0 -- July, 1999. 
 * 
 */
#include <linux/config.h>

#define RIO_NBOARDS        4
#define RIO_PORTSPERBOARD 128
#define RIO_NPORTS        (RIO_NBOARDS * RIO_PORTSPERBOARD)

#define MODEM_SUPPORT

#ifdef __KERNEL__

#define RIO_MAGIC 0x12345678


struct vpd_prom {
	unsigned short id;
	char hwrev;
	char hwass;
	int uniqid;
	char myear;
	char mweek;
	char hw_feature[5];
	char oem_id;
	char identifier[16];
};


#define RIO_DEBUG_ALL           0xffffffff

#define O_OTHER(tty)    \
      ((O_OLCUC(tty))  ||\
      (O_ONLCR(tty))   ||\
      (O_OCRNL(tty))   ||\
      (O_ONOCR(tty))   ||\
      (O_ONLRET(tty))  ||\
      (O_OFILL(tty))   ||\
      (O_OFDEL(tty))   ||\
      (O_NLDLY(tty))   ||\
      (O_CRDLY(tty))   ||\
      (O_TABDLY(tty))  ||\
      (O_BSDLY(tty))   ||\
      (O_VTDLY(tty))   ||\
      (O_FFDLY(tty)))

/* Same for input. */
#define I_OTHER(tty)    \
      ((I_INLCR(tty))  ||\
      (I_IGNCR(tty))   ||\
      (I_ICRNL(tty))   ||\
      (I_IUCLC(tty))   ||\
      (L_ISIG(tty)))


#endif				/* __KERNEL__ */


#define RIO_BOARD_INTR_LOCK  1


#ifndef RIOCTL_MISC_MINOR
/* Allow others to gather this into "major.h" or something like that */
#define RIOCTL_MISC_MINOR    169
#endif


/* Allow us to debug "in the field" without requiring clients to
   recompile.... */
#if 1
#define rio_spin_lock_irqsave(sem, flags) do { \
	rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlockirqsave: %p %s:%d\n", \
	                                sem, __FILE__, __LINE__);\
	spin_lock_irqsave(sem, flags);\
	} while (0)

#define rio_spin_unlock_irqrestore(sem, flags) do { \
	rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlockirqrestore: %p %s:%d\n",\
	                                sem, __FILE__, __LINE__);\
	spin_unlock_irqrestore(sem, flags);\
	} while (0)

#define rio_spin_lock(sem) do { \
	rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlock: %p %s:%d\n",\
	                                sem, __FILE__, __LINE__);\
	spin_lock(sem);\
	} while (0)

#define rio_spin_unlock(sem) do { \
	rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlock: %p %s:%d\n",\
	                                sem, __FILE__, __LINE__);\
	spin_unlock(sem);\
	} while (0)
#else
#define rio_spin_lock_irqsave(sem, flags) \
            spin_lock_irqsave(sem, flags)

#define rio_spin_unlock_irqrestore(sem, flags) \
            spin_unlock_irqrestore(sem, flags)

#define rio_spin_lock(sem) \
            spin_lock(sem)

#define rio_spin_unlock(sem) \
            spin_unlock(sem)

#endif



#ifdef CONFIG_RIO_OLDPCI
static inline void *rio_memcpy_toio(void *dummy, void *dest, void *source, int n)
{
	char *dst = dest;
	char *src = source;

	while (n--) {
		writeb(*src++, dst++);
		(void) readb(dummy);
	}

	return dest;
}


static inline void *rio_memcpy_fromio(void *dest, void *source, int n)
{
	char *dst = dest;
	char *src = source;

	while (n--)
		*dst++ = readb(src++);

	return dest;
}

#else
#define rio_memcpy_toio(dummy,dest,source,n)   memcpy_toio(dest, source, n)
#define rio_memcpy_fromio                      memcpy_fromio
#endif

#define DEBUG 1


/* 
   This driver can spew a whole lot of debugging output at you. If you
   need maximum performance, you should disable the DEBUG define. To
   aid in debugging in the field, I'm leaving the compile-time debug
   features enabled, and disable them "runtime". That allows me to
   instruct people with problems to enable debugging without requiring
   them to recompile... 
*/

#ifdef DEBUG
#define rio_dprintk(f, str...) do { if (rio_debug & f) printk (str);} while (0)
#define func_enter() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s\n", __FUNCTION__)
#define func_exit()  rio_dprintk (RIO_DEBUG_FLOW, "rio: exit  %s\n", __FUNCTION__)
#define func_enter2() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s (port %d)\n",__FUNCTION__, port->line)
#else
#define rio_dprintk(f, str...)	/* nothing */
#define func_enter()
#define func_exit()
#define func_enter2()
#endif