Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 38 | struct vpd_prom { |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 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]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 77 | #endif /* __KERNEL__ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | |
| 79 | |
| 80 | #define RIO_BOARD_INTR_LOCK 1 |
| 81 | |
| 82 | |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 83 | #ifndef RIOCTL_MISC_MINOR |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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) \ |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 123 | spin_lock(sem) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
| 125 | #define rio_spin_unlock(sem) \ |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 126 | spin_unlock(sem) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | |
| 128 | #endif |
| 129 | |
| 130 | |
| 131 | |
| 132 | #ifdef CONFIG_RIO_OLDPCI |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame] | 133 | static inline void __iomem *rio_memcpy_toio(void __iomem *dummy, void __iomem *dest, void *source, int n) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | { |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame] | 135 | char __iomem *dst = dest; |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 136 | char *src = source; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 138 | while (n--) { |
| 139 | writeb(*src++, dst++); |
Al Viro | ae5b28a | 2006-05-27 01:48:08 -0400 | [diff] [blame] | 140 | (void) readb(dummy); |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 141 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 143 | return dest; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Al Viro | ae5b28a | 2006-05-27 01:48:08 -0400 | [diff] [blame] | 146 | static 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame] | 158 | static inline void *rio_memcpy_fromio(void *dest, void __iomem *source, int n) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | { |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 160 | char *dst = dest; |
Al Viro | d886cb5 | 2006-05-27 00:08:25 -0400 | [diff] [blame] | 161 | char __iomem *src = source; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 163 | while (n--) |
| 164 | *dst++ = readb(src++); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 166 | return dest; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | #else |
| 170 | #define rio_memcpy_toio(dummy,dest,source,n) memcpy_toio(dest, source, n) |
Al Viro | ae5b28a | 2006-05-27 01:48:08 -0400 | [diff] [blame] | 171 | #define rio_copy_toio memcpy_toio |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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) |
Harvey Harrison | bf9d892 | 2008-04-30 00:55:10 -0700 | [diff] [blame] | 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) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | #else |
Andrew Morton | 8d8706e | 2006-01-11 12:17:49 -0800 | [diff] [blame] | 193 | #define rio_dprintk(f, str...) /* nothing */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | #define func_enter() |
| 195 | #define func_exit() |
| 196 | #define func_enter2() |
| 197 | #endif |