blob: dc3f005614a36d5cefbc9df333a1fa09aab8546a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
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 {
Andrew Morton8d8706e2006-01-11 12:17:49 -080039 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];
Linus Torvalds1da177e2005-04-16 15:20:36 -070048};
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
Andrew Morton8d8706e2006-01-11 12:17:49 -080077#endif /* __KERNEL__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79
80#define RIO_BOARD_INTR_LOCK 1
81
82
Andrew Morton8d8706e2006-01-11 12:17:49 -080083#ifndef RIOCTL_MISC_MINOR
Linus Torvalds1da177e2005-04-16 15:20:36 -070084/* 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) \
Andrew Morton8d8706e2006-01-11 12:17:49 -0800123 spin_lock(sem)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124
125#define rio_spin_unlock(sem) \
Andrew Morton8d8706e2006-01-11 12:17:49 -0800126 spin_unlock(sem)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128#endif
129
130
131
132#ifdef CONFIG_RIO_OLDPCI
Al Virod886cb52006-05-27 00:08:25 -0400133static inline void __iomem *rio_memcpy_toio(void __iomem *dummy, void __iomem *dest, void *source, int n)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134{
Al Virod886cb52006-05-27 00:08:25 -0400135 char __iomem *dst = dest;
Andrew Morton8d8706e2006-01-11 12:17:49 -0800136 char *src = source;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
Andrew Morton8d8706e2006-01-11 12:17:49 -0800138 while (n--) {
139 writeb(*src++, dst++);
Al Viroae5b28a2006-05-27 01:48:08 -0400140 (void) readb(dummy);
Andrew Morton8d8706e2006-01-11 12:17:49 -0800141 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
Andrew Morton8d8706e2006-01-11 12:17:49 -0800143 return dest;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144}
145
Al Viroae5b28a2006-05-27 01:48:08 -0400146static 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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157
Al Virod886cb52006-05-27 00:08:25 -0400158static inline void *rio_memcpy_fromio(void *dest, void __iomem *source, int n)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800160 char *dst = dest;
Al Virod886cb52006-05-27 00:08:25 -0400161 char __iomem *src = source;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
Andrew Morton8d8706e2006-01-11 12:17:49 -0800163 while (n--)
164 *dst++ = readb(src++);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165
Andrew Morton8d8706e2006-01-11 12:17:49 -0800166 return dest;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167}
168
169#else
170#define rio_memcpy_toio(dummy,dest,source,n) memcpy_toio(dest, source, n)
Al Viroae5b28a2006-05-27 01:48:08 -0400171#define rio_copy_toio memcpy_toio
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172#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)
189#define func_enter() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s\n", __FUNCTION__)
190#define func_exit() rio_dprintk (RIO_DEBUG_FLOW, "rio: exit %s\n", __FUNCTION__)
191#define func_enter2() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s (port %d)\n",__FUNCTION__, port->line)
192#else
Andrew Morton8d8706e2006-01-11 12:17:49 -0800193#define rio_dprintk(f, str...) /* nothing */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194#define func_enter()
195#define func_exit()
196#define func_enter2()
197#endif