blob: 55b9c97e8477c59fb3b39d924d9b51ba1a83ab68 [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 */
26#include <linux/config.h>
27
28#define RIO_NBOARDS 4
29#define RIO_PORTSPERBOARD 128
30#define RIO_NPORTS (RIO_NBOARDS * RIO_PORTSPERBOARD)
31
32#define MODEM_SUPPORT
33
34#ifdef __KERNEL__
35
36#define RIO_MAGIC 0x12345678
37
38
39struct vpd_prom {
Andrew Morton8d8706e2006-01-11 12:17:49 -080040 unsigned short id;
41 char hwrev;
42 char hwass;
43 int uniqid;
44 char myear;
45 char mweek;
46 char hw_feature[5];
47 char oem_id;
48 char identifier[16];
Linus Torvalds1da177e2005-04-16 15:20:36 -070049};
50
51
52#define RIO_DEBUG_ALL 0xffffffff
53
54#define O_OTHER(tty) \
55 ((O_OLCUC(tty)) ||\
56 (O_ONLCR(tty)) ||\
57 (O_OCRNL(tty)) ||\
58 (O_ONOCR(tty)) ||\
59 (O_ONLRET(tty)) ||\
60 (O_OFILL(tty)) ||\
61 (O_OFDEL(tty)) ||\
62 (O_NLDLY(tty)) ||\
63 (O_CRDLY(tty)) ||\
64 (O_TABDLY(tty)) ||\
65 (O_BSDLY(tty)) ||\
66 (O_VTDLY(tty)) ||\
67 (O_FFDLY(tty)))
68
69/* Same for input. */
70#define I_OTHER(tty) \
71 ((I_INLCR(tty)) ||\
72 (I_IGNCR(tty)) ||\
73 (I_ICRNL(tty)) ||\
74 (I_IUCLC(tty)) ||\
75 (L_ISIG(tty)))
76
77
Andrew Morton8d8706e2006-01-11 12:17:49 -080078#endif /* __KERNEL__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80
81#define RIO_BOARD_INTR_LOCK 1
82
83
Andrew Morton8d8706e2006-01-11 12:17:49 -080084#ifndef RIOCTL_MISC_MINOR
Linus Torvalds1da177e2005-04-16 15:20:36 -070085/* Allow others to gather this into "major.h" or something like that */
86#define RIOCTL_MISC_MINOR 169
87#endif
88
89
90/* Allow us to debug "in the field" without requiring clients to
91 recompile.... */
92#if 1
93#define rio_spin_lock_irqsave(sem, flags) do { \
94 rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlockirqsave: %p %s:%d\n", \
95 sem, __FILE__, __LINE__);\
96 spin_lock_irqsave(sem, flags);\
97 } while (0)
98
99#define rio_spin_unlock_irqrestore(sem, flags) do { \
100 rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlockirqrestore: %p %s:%d\n",\
101 sem, __FILE__, __LINE__);\
102 spin_unlock_irqrestore(sem, flags);\
103 } while (0)
104
105#define rio_spin_lock(sem) do { \
106 rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlock: %p %s:%d\n",\
107 sem, __FILE__, __LINE__);\
108 spin_lock(sem);\
109 } while (0)
110
111#define rio_spin_unlock(sem) do { \
112 rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlock: %p %s:%d\n",\
113 sem, __FILE__, __LINE__);\
114 spin_unlock(sem);\
115 } while (0)
116#else
117#define rio_spin_lock_irqsave(sem, flags) \
118 spin_lock_irqsave(sem, flags)
119
120#define rio_spin_unlock_irqrestore(sem, flags) \
121 spin_unlock_irqrestore(sem, flags)
122
123#define rio_spin_lock(sem) \
Andrew Morton8d8706e2006-01-11 12:17:49 -0800124 spin_lock(sem)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
126#define rio_spin_unlock(sem) \
Andrew Morton8d8706e2006-01-11 12:17:49 -0800127 spin_unlock(sem)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
129#endif
130
131
132
133#ifdef CONFIG_RIO_OLDPCI
Al Virod886cb52006-05-27 00:08:25 -0400134static inline void __iomem *rio_memcpy_toio(void __iomem *dummy, void __iomem *dest, void *source, int n)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135{
Al Virod886cb52006-05-27 00:08:25 -0400136 char __iomem *dst = dest;
Andrew Morton8d8706e2006-01-11 12:17:49 -0800137 char *src = source;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
Andrew Morton8d8706e2006-01-11 12:17:49 -0800139 while (n--) {
140 writeb(*src++, dst++);
Al Viroae5b28a2006-05-27 01:48:08 -0400141 (void) readb(dummy);
Andrew Morton8d8706e2006-01-11 12:17:49 -0800142 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
Andrew Morton8d8706e2006-01-11 12:17:49 -0800144 return dest;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145}
146
Al Viroae5b28a2006-05-27 01:48:08 -0400147static inline void __iomem *rio_copy_toio(void __iomem *dest, void *source, int n)
148{
149 char __iomem *dst = dest;
150 char *src = source;
151
152 while (n--)
153 writeb(*src++, dst++);
154
155 return dest;
156}
157
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158
Al Virod886cb52006-05-27 00:08:25 -0400159static inline void *rio_memcpy_fromio(void *dest, void __iomem *source, int n)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160{
Andrew Morton8d8706e2006-01-11 12:17:49 -0800161 char *dst = dest;
Al Virod886cb52006-05-27 00:08:25 -0400162 char __iomem *src = source;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
Andrew Morton8d8706e2006-01-11 12:17:49 -0800164 while (n--)
165 *dst++ = readb(src++);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166
Andrew Morton8d8706e2006-01-11 12:17:49 -0800167 return dest;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168}
169
170#else
171#define rio_memcpy_toio(dummy,dest,source,n) memcpy_toio(dest, source, n)
Al Viroae5b28a2006-05-27 01:48:08 -0400172#define rio_copy_toio memcpy_toio
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173#define rio_memcpy_fromio memcpy_fromio
174#endif
175
176#define DEBUG 1
177
178
179/*
180 This driver can spew a whole lot of debugging output at you. If you
181 need maximum performance, you should disable the DEBUG define. To
182 aid in debugging in the field, I'm leaving the compile-time debug
183 features enabled, and disable them "runtime". That allows me to
184 instruct people with problems to enable debugging without requiring
185 them to recompile...
186*/
187
188#ifdef DEBUG
189#define rio_dprintk(f, str...) do { if (rio_debug & f) printk (str);} while (0)
190#define func_enter() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s\n", __FUNCTION__)
191#define func_exit() rio_dprintk (RIO_DEBUG_FLOW, "rio: exit %s\n", __FUNCTION__)
192#define func_enter2() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s (port %d)\n",__FUNCTION__, port->line)
193#else
Andrew Morton8d8706e2006-01-11 12:17:49 -0800194#define rio_dprintk(f, str...) /* nothing */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195#define func_enter()
196#define func_exit()
197#define func_enter2()
198#endif