Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / char / rio / rio_linux.h
CommitLineData
1da177e4
LT
1
2/*
3 * rio_linux.h
4 *
5 * Copyright (C) 1998,1999,2000 R.E.Wolff@BitWizard.nl
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * RIO serial driver.
22 *
23 * Version 1.0 -- July, 1999.
24 *
25 */
1da177e4
LT
26
27#define RIO_NBOARDS 4
28#define RIO_PORTSPERBOARD 128
29#define RIO_NPORTS (RIO_NBOARDS * RIO_PORTSPERBOARD)
30
31#define MODEM_SUPPORT
32
33#ifdef __KERNEL__
34
35#define RIO_MAGIC 0x12345678
36
37
38struct vpd_prom {
8d8706e2
AM
39 unsigned short id;
40 char hwrev;
41 char hwass;
42 int uniqid;
43 char myear;
44 char mweek;
45 char hw_feature[5];
46 char oem_id;
47 char identifier[16];
1da177e4
LT
48};
49
50
51#define RIO_DEBUG_ALL 0xffffffff
52
53#define O_OTHER(tty) \
54 ((O_OLCUC(tty)) ||\
55 (O_ONLCR(tty)) ||\
56 (O_OCRNL(tty)) ||\
57 (O_ONOCR(tty)) ||\
58 (O_ONLRET(tty)) ||\
59 (O_OFILL(tty)) ||\
60 (O_OFDEL(tty)) ||\
61 (O_NLDLY(tty)) ||\
62 (O_CRDLY(tty)) ||\
63 (O_TABDLY(tty)) ||\
64 (O_BSDLY(tty)) ||\
65 (O_VTDLY(tty)) ||\
66 (O_FFDLY(tty)))
67
68/* Same for input. */
69#define I_OTHER(tty) \
70 ((I_INLCR(tty)) ||\
71 (I_IGNCR(tty)) ||\
72 (I_ICRNL(tty)) ||\
73 (I_IUCLC(tty)) ||\
74 (L_ISIG(tty)))
75
76
8d8706e2 77#endif /* __KERNEL__ */
1da177e4
LT
78
79
80#define RIO_BOARD_INTR_LOCK 1
81
82
8d8706e2 83#ifndef RIOCTL_MISC_MINOR
1da177e4
LT
84/* Allow others to gather this into "major.h" or something like that */
85#define RIOCTL_MISC_MINOR 169
86#endif
87
88
89/* Allow us to debug "in the field" without requiring clients to
90 recompile.... */
91#if 1
92#define rio_spin_lock_irqsave(sem, flags) do { \
93 rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlockirqsave: %p %s:%d\n", \
94 sem, __FILE__, __LINE__);\
95 spin_lock_irqsave(sem, flags);\
96 } while (0)
97
98#define rio_spin_unlock_irqrestore(sem, flags) do { \
99 rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlockirqrestore: %p %s:%d\n",\
100 sem, __FILE__, __LINE__);\
101 spin_unlock_irqrestore(sem, flags);\
102 } while (0)
103
104#define rio_spin_lock(sem) do { \
105 rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlock: %p %s:%d\n",\
106 sem, __FILE__, __LINE__);\
107 spin_lock(sem);\
108 } while (0)
109
110#define rio_spin_unlock(sem) do { \
111 rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlock: %p %s:%d\n",\
112 sem, __FILE__, __LINE__);\
113 spin_unlock(sem);\
114 } while (0)
115#else
116#define rio_spin_lock_irqsave(sem, flags) \
117 spin_lock_irqsave(sem, flags)
118
119#define rio_spin_unlock_irqrestore(sem, flags) \
120 spin_unlock_irqrestore(sem, flags)
121
122#define rio_spin_lock(sem) \
8d8706e2 123 spin_lock(sem)
1da177e4
LT
124
125#define rio_spin_unlock(sem) \
8d8706e2 126 spin_unlock(sem)
1da177e4
LT
127
128#endif
129
130
131
132#ifdef CONFIG_RIO_OLDPCI
d886cb58 133static inline void __iomem *rio_memcpy_toio(void __iomem *dummy, void __iomem *dest, void *source, int n)
1da177e4 134{
d886cb58 135 char __iomem *dst = dest;
8d8706e2 136 char *src = source;
1da177e4 137
8d8706e2
AM
138 while (n--) {
139 writeb(*src++, dst++);
ae5b28a5 140 (void) readb(dummy);
8d8706e2 141 }
1da177e4 142
8d8706e2 143 return dest;
1da177e4
LT
144}
145
ae5b28a5
AV
146static inline void __iomem *rio_copy_toio(void __iomem *dest, void *source, int n)
147{
148 char __iomem *dst = dest;
149 char *src = source;
150
151 while (n--)
152 writeb(*src++, dst++);
153
154 return dest;
155}
156
1da177e4 157
d886cb58 158static inline void *rio_memcpy_fromio(void *dest, void __iomem *source, int n)
1da177e4 159{
8d8706e2 160 char *dst = dest;
d886cb58 161 char __iomem *src = source;
1da177e4 162
8d8706e2
AM
163 while (n--)
164 *dst++ = readb(src++);
1da177e4 165
8d8706e2 166 return dest;
1da177e4
LT
167}
168
169#else
170#define rio_memcpy_toio(dummy,dest,source,n) memcpy_toio(dest, source, n)
ae5b28a5 171#define rio_copy_toio memcpy_toio
1da177e4
LT
172#define rio_memcpy_fromio memcpy_fromio
173#endif
174
175#define DEBUG 1
176
177
178/*
179 This driver can spew a whole lot of debugging output at you. If you
180 need maximum performance, you should disable the DEBUG define. To
181 aid in debugging in the field, I'm leaving the compile-time debug
182 features enabled, and disable them "runtime". That allows me to
183 instruct people with problems to enable debugging without requiring
184 them to recompile...
185*/
186
187#ifdef DEBUG
188#define rio_dprintk(f, str...) do { if (rio_debug & f) printk (str);} while (0)
bf9d8929
HH
189#define func_enter() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s\n", __func__)
190#define func_exit() rio_dprintk (RIO_DEBUG_FLOW, "rio: exit %s\n", __func__)
191#define func_enter2() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s (port %d)\n",__func__, port->line)
1da177e4 192#else
8d8706e2 193#define rio_dprintk(f, str...) /* nothing */
1da177e4
LT
194#define func_enter()
195#define func_exit()
196#define func_enter2()
197#endif