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 */ 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 { 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]; 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 77#endif /* __KERNEL__ */ 78 79 80#define RIO_BOARD_INTR_LOCK 1 81 82 83#ifndef RIOCTL_MISC_MINOR 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#define rio_spin_lock_irqsave(sem, flags) do { \ 92 rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlockirqsave: %p %s:%d\n", \ 93 sem, __FILE__, __LINE__);\ 94 spin_lock_irqsave(sem, flags);\ 95 } while (0) 96 97#define rio_spin_unlock_irqrestore(sem, flags) do { \ 98 rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlockirqrestore: %p %s:%d\n",\ 99 sem, __FILE__, __LINE__);\ 100 spin_unlock_irqrestore(sem, flags);\ 101 } while (0) 102 103#define rio_spin_lock(sem) do { \ 104 rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlock: %p %s:%d\n",\ 105 sem, __FILE__, __LINE__);\ 106 spin_lock(sem);\ 107 } while (0) 108 109#define rio_spin_unlock(sem) do { \ 110 rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlock: %p %s:%d\n",\ 111 sem, __FILE__, __LINE__);\ 112 spin_unlock(sem);\ 113 } while (0) 114 115 116 117#ifdef CONFIG_RIO_OLDPCI 118static inline void __iomem *rio_memcpy_toio(void __iomem *dummy, void __iomem *dest, void *source, int n) 119{ 120 char __iomem *dst = dest; 121 char *src = source; 122 123 while (n--) { 124 writeb(*src++, dst++); 125 (void) readb(dummy); 126 } 127 128 return dest; 129} 130 131static inline void __iomem *rio_copy_toio(void __iomem *dest, void *source, int n) 132{ 133 char __iomem *dst = dest; 134 char *src = source; 135 136 while (n--) 137 writeb(*src++, dst++); 138 139 return dest; 140} 141 142 143static inline void *rio_memcpy_fromio(void *dest, void __iomem *source, int n) 144{ 145 char *dst = dest; 146 char __iomem *src = source; 147 148 while (n--) 149 *dst++ = readb(src++); 150 151 return dest; 152} 153 154#else 155#define rio_memcpy_toio(dummy,dest,source,n) memcpy_toio(dest, source, n) 156#define rio_copy_toio memcpy_toio 157#define rio_memcpy_fromio memcpy_fromio 158#endif 159 160#define DEBUG 1 161 162 163/* 164 This driver can spew a whole lot of debugging output at you. If you 165 need maximum performance, you should disable the DEBUG define. To 166 aid in debugging in the field, I'm leaving the compile-time debug 167 features enabled, and disable them "runtime". That allows me to 168 instruct people with problems to enable debugging without requiring 169 them to recompile... 170*/ 171 172#ifdef DEBUG 173#define rio_dprintk(f, str...) do { if (rio_debug & f) printk (str);} while (0) 174#define func_enter() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s\n", __FUNCTION__) 175#define func_exit() rio_dprintk (RIO_DEBUG_FLOW, "rio: exit %s\n", __FUNCTION__) 176#define func_enter2() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s (port %d)\n",__FUNCTION__, port->line) 177#else 178#define rio_dprintk(f, str...) /* nothing */ 179#define func_enter() 180#define func_exit() 181#define func_enter2() 182#endif 183