Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: sedlbauer.c,v 1.34.2.6 2004/01/24 20:47:24 keil Exp $ |
| 2 | * |
| 3 | * low level stuff for Sedlbauer cards |
| 4 | * includes support for the Sedlbauer speed star (speed star II), |
| 5 | * support for the Sedlbauer speed fax+, |
| 6 | * support for the Sedlbauer ISDN-Controller PC/104 and |
| 7 | * support for the Sedlbauer speed pci |
| 8 | * derived from the original file asuscom.c from Karsten Keil |
| 9 | * |
| 10 | * Author Marcus Niemann |
| 11 | * Copyright by Marcus Niemann <niemann@www-bib.fh-bielefeld.de> |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 12 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * This software may be used and distributed according to the terms |
| 14 | * of the GNU General Public License, incorporated herein by reference. |
| 15 | * |
| 16 | * Thanks to Karsten Keil |
| 17 | * Sedlbauer AG for informations |
| 18 | * Edgar Toernig |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | /* Supported cards: |
| 23 | * Card: Chip: Configuration: Comment: |
| 24 | * --------------------------------------------------------------------- |
| 25 | * Speed Card ISAC_HSCX DIP-SWITCH |
| 26 | * Speed Win ISAC_HSCX ISAPNP |
| 27 | * Speed Fax+ ISAC_ISAR ISAPNP Full analog support |
| 28 | * Speed Star ISAC_HSCX CARDMGR |
| 29 | * Speed Win2 IPAC ISAPNP |
| 30 | * ISDN PC/104 IPAC DIP-SWITCH |
| 31 | * Speed Star2 IPAC CARDMGR |
| 32 | * Speed PCI IPAC PCI PNP |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 33 | * Speed Fax+ ISAC_ISAR PCI PNP Full analog support |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | * |
| 35 | * Important: |
| 36 | * For the sedlbauer speed fax+ to work properly you have to download |
| 37 | * the firmware onto the card. |
| 38 | * For example: hisaxctrl <DriverID> 9 ISAR.BIN |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 39 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
| 41 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include "hisax.h" |
| 43 | #include "isac.h" |
| 44 | #include "ipac.h" |
| 45 | #include "hscx.h" |
| 46 | #include "isar.h" |
| 47 | #include "isdnl1.h" |
| 48 | #include <linux/pci.h> |
| 49 | #include <linux/isapnp.h> |
| 50 | |
Adrian Bunk | 672c3fd | 2005-06-25 14:59:18 -0700 | [diff] [blame] | 51 | static const char *Sedlbauer_revision = "$Revision: 1.34.2.6 $"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Adrian Bunk | 672c3fd | 2005-06-25 14:59:18 -0700 | [diff] [blame] | 53 | static const char *Sedlbauer_Types[] = |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 54 | {"None", "speed card/win", "speed star", "speed fax+", |
| 55 | "speed win II / ISDN PC/104", "speed star II", "speed pci", |
| 56 | "speed fax+ pyramid", "speed fax+ pci", "HST Saphir III"}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
| 58 | #define PCI_SUBVENDOR_SPEEDFAX_PYRAMID 0x51 |
| 59 | #define PCI_SUBVENDOR_HST_SAPHIR3 0x52 |
| 60 | #define PCI_SUBVENDOR_SEDLBAUER_PCI 0x53 |
| 61 | #define PCI_SUBVENDOR_SPEEDFAX_PCI 0x54 |
| 62 | #define PCI_SUB_ID_SEDLBAUER 0x01 |
| 63 | |
| 64 | #define SEDL_SPEED_CARD_WIN 1 |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 65 | #define SEDL_SPEED_STAR 2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | #define SEDL_SPEED_FAX 3 |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 67 | #define SEDL_SPEED_WIN2_PC104 4 |
| 68 | #define SEDL_SPEED_STAR2 5 |
| 69 | #define SEDL_SPEED_PCI 6 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | #define SEDL_SPEEDFAX_PYRAMID 7 |
| 71 | #define SEDL_SPEEDFAX_PCI 8 |
| 72 | #define HST_SAPHIR3 9 |
| 73 | |
| 74 | #define SEDL_CHIP_TEST 0 |
| 75 | #define SEDL_CHIP_ISAC_HSCX 1 |
| 76 | #define SEDL_CHIP_ISAC_ISAR 2 |
| 77 | #define SEDL_CHIP_IPAC 3 |
| 78 | |
| 79 | #define SEDL_BUS_ISA 1 |
| 80 | #define SEDL_BUS_PCI 2 |
| 81 | #define SEDL_BUS_PCMCIA 3 |
| 82 | |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 83 | #define byteout(addr, val) outb(val, addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | #define bytein(addr) inb(addr) |
| 85 | |
| 86 | #define SEDL_HSCX_ISA_RESET_ON 0 |
| 87 | #define SEDL_HSCX_ISA_RESET_OFF 1 |
| 88 | #define SEDL_HSCX_ISA_ISAC 2 |
| 89 | #define SEDL_HSCX_ISA_HSCX 3 |
| 90 | #define SEDL_HSCX_ISA_ADR 4 |
| 91 | |
| 92 | #define SEDL_HSCX_PCMCIA_RESET 0 |
| 93 | #define SEDL_HSCX_PCMCIA_ISAC 1 |
| 94 | #define SEDL_HSCX_PCMCIA_HSCX 2 |
| 95 | #define SEDL_HSCX_PCMCIA_ADR 4 |
| 96 | |
| 97 | #define SEDL_ISAR_ISA_ISAC 4 |
| 98 | #define SEDL_ISAR_ISA_ISAR 6 |
| 99 | #define SEDL_ISAR_ISA_ADR 8 |
| 100 | #define SEDL_ISAR_ISA_ISAR_RESET_ON 10 |
| 101 | #define SEDL_ISAR_ISA_ISAR_RESET_OFF 12 |
| 102 | |
| 103 | #define SEDL_IPAC_ANY_ADR 0 |
| 104 | #define SEDL_IPAC_ANY_IPAC 2 |
| 105 | |
| 106 | #define SEDL_IPAC_PCI_BASE 0 |
| 107 | #define SEDL_IPAC_PCI_ADR 0xc0 |
| 108 | #define SEDL_IPAC_PCI_IPAC 0xc8 |
| 109 | #define SEDL_ISAR_PCI_ADR 0xc8 |
| 110 | #define SEDL_ISAR_PCI_ISAC 0xd0 |
| 111 | #define SEDL_ISAR_PCI_ISAR 0xe0 |
| 112 | #define SEDL_ISAR_PCI_ISAR_RESET_ON 0x01 |
| 113 | #define SEDL_ISAR_PCI_ISAR_RESET_OFF 0x18 |
| 114 | #define SEDL_ISAR_PCI_LED1 0x08 |
| 115 | #define SEDL_ISAR_PCI_LED2 0x10 |
| 116 | |
| 117 | #define SEDL_RESET 0x3 /* same as DOS driver */ |
| 118 | |
| 119 | static inline u_char |
| 120 | readreg(unsigned int ale, unsigned int adr, u_char off) |
| 121 | { |
| 122 | register u_char ret; |
| 123 | |
| 124 | byteout(ale, off); |
| 125 | ret = bytein(adr); |
| 126 | return (ret); |
| 127 | } |
| 128 | |
| 129 | static inline void |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 130 | readfifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | { |
| 132 | byteout(ale, off); |
| 133 | insb(adr, data, size); |
| 134 | } |
| 135 | |
| 136 | |
| 137 | static inline void |
| 138 | writereg(unsigned int ale, unsigned int adr, u_char off, u_char data) |
| 139 | { |
| 140 | byteout(ale, off); |
| 141 | byteout(adr, data); |
| 142 | } |
| 143 | |
| 144 | static inline void |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 145 | writefifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | { |
| 147 | byteout(ale, off); |
| 148 | outsb(adr, data, size); |
| 149 | } |
| 150 | |
| 151 | /* Interface functions */ |
| 152 | |
| 153 | static u_char |
| 154 | ReadISAC(struct IsdnCardState *cs, u_char offset) |
| 155 | { |
| 156 | return (readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset)); |
| 157 | } |
| 158 | |
| 159 | static void |
| 160 | WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) |
| 161 | { |
| 162 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset, value); |
| 163 | } |
| 164 | |
| 165 | static void |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 166 | ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | { |
| 168 | readfifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0, data, size); |
| 169 | } |
| 170 | |
| 171 | static void |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 172 | WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | { |
| 174 | writefifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0, data, size); |
| 175 | } |
| 176 | |
| 177 | static u_char |
| 178 | ReadISAC_IPAC(struct IsdnCardState *cs, u_char offset) |
| 179 | { |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 180 | return (readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset | 0x80)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | static void |
| 184 | WriteISAC_IPAC(struct IsdnCardState *cs, u_char offset, u_char value) |
| 185 | { |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 186 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset | 0x80, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | static void |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 190 | ReadISACfifo_IPAC(struct IsdnCardState *cs, u_char *data, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | { |
| 192 | readfifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0x80, data, size); |
| 193 | } |
| 194 | |
| 195 | static void |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 196 | WriteISACfifo_IPAC(struct IsdnCardState *cs, u_char *data, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | { |
| 198 | writefifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0x80, data, size); |
| 199 | } |
| 200 | |
| 201 | static u_char |
| 202 | ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset) |
| 203 | { |
| 204 | return (readreg(cs->hw.sedl.adr, |
| 205 | cs->hw.sedl.hscx, offset + (hscx ? 0x40 : 0))); |
| 206 | } |
| 207 | |
| 208 | static void |
| 209 | WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value) |
| 210 | { |
| 211 | writereg(cs->hw.sedl.adr, |
| 212 | cs->hw.sedl.hscx, offset + (hscx ? 0x40 : 0), value); |
| 213 | } |
| 214 | |
| 215 | /* ISAR access routines |
| 216 | * mode = 0 access with IRQ on |
| 217 | * mode = 1 access with IRQ off |
| 218 | * mode = 2 access with IRQ off and using last offset |
| 219 | */ |
| 220 | |
| 221 | static u_char |
| 222 | ReadISAR(struct IsdnCardState *cs, int mode, u_char offset) |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 223 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | if (mode == 0) |
| 225 | return (readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, offset)); |
| 226 | else if (mode == 1) |
| 227 | byteout(cs->hw.sedl.adr, offset); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 228 | return (bytein(cs->hw.sedl.hscx)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | static void |
| 232 | WriteISAR(struct IsdnCardState *cs, int mode, u_char offset, u_char value) |
| 233 | { |
| 234 | if (mode == 0) |
| 235 | writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, offset, value); |
| 236 | else { |
| 237 | if (mode == 1) |
| 238 | byteout(cs->hw.sedl.adr, offset); |
| 239 | byteout(cs->hw.sedl.hscx, value); |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | /* |
| 244 | * fast interrupt HSCX stuff goes here |
| 245 | */ |
| 246 | |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 247 | #define READHSCX(cs, nr, reg) readreg(cs->hw.sedl.adr, \ |
| 248 | cs->hw.sedl.hscx, reg + (nr ? 0x40 : 0)) |
| 249 | #define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.sedl.adr, \ |
| 250 | cs->hw.sedl.hscx, reg + (nr ? 0x40 : 0), data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 252 | #define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.sedl.adr, \ |
| 253 | cs->hw.sedl.hscx, (nr ? 0x40 : 0), ptr, cnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 255 | #define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.sedl.adr, \ |
| 256 | cs->hw.sedl.hscx, (nr ? 0x40 : 0), ptr, cnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | |
| 258 | #include "hscx_irq.c" |
| 259 | |
| 260 | static irqreturn_t |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 261 | sedlbauer_interrupt(int intno, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | { |
| 263 | struct IsdnCardState *cs = dev_id; |
| 264 | u_char val; |
| 265 | u_long flags; |
| 266 | |
| 267 | spin_lock_irqsave(&cs->lock, flags); |
| 268 | if ((cs->hw.sedl.bus == SEDL_BUS_PCMCIA) && (*cs->busy_flag == 1)) { |
| 269 | /* The card tends to generate interrupts while being removed |
| 270 | causing us to just crash the kernel. bad. */ |
| 271 | spin_unlock_irqrestore(&cs->lock, flags); |
| 272 | printk(KERN_WARNING "Sedlbauer: card not available!\n"); |
| 273 | return IRQ_NONE; |
| 274 | } |
| 275 | |
| 276 | val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_ISTA + 0x40); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 277 | Start_HSCX: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | if (val) |
| 279 | hscx_int_main(cs, val); |
| 280 | val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 281 | Start_ISAC: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | if (val) |
| 283 | isac_interrupt(cs, val); |
| 284 | val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_ISTA + 0x40); |
| 285 | if (val) { |
| 286 | if (cs->debug & L1_DEB_HSCX) |
| 287 | debugl1(cs, "HSCX IntStat after IntRoutine"); |
| 288 | goto Start_HSCX; |
| 289 | } |
| 290 | val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA); |
| 291 | if (val) { |
| 292 | if (cs->debug & L1_DEB_ISAC) |
| 293 | debugl1(cs, "ISAC IntStat after IntRoutine"); |
| 294 | goto Start_ISAC; |
| 295 | } |
| 296 | writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK, 0xFF); |
| 297 | writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK + 0x40, 0xFF); |
| 298 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_MASK, 0xFF); |
| 299 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_MASK, 0x0); |
| 300 | writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK, 0x0); |
| 301 | writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK + 0x40, 0x0); |
| 302 | spin_unlock_irqrestore(&cs->lock, flags); |
| 303 | return IRQ_HANDLED; |
| 304 | } |
| 305 | |
| 306 | static irqreturn_t |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 307 | sedlbauer_interrupt_ipac(int intno, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | { |
| 309 | struct IsdnCardState *cs = dev_id; |
| 310 | u_char ista, val, icnt = 5; |
| 311 | u_long flags; |
| 312 | |
| 313 | spin_lock_irqsave(&cs->lock, flags); |
| 314 | ista = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_ISTA); |
| 315 | Start_IPAC: |
| 316 | if (cs->debug & L1_DEB_IPAC) |
| 317 | debugl1(cs, "IPAC ISTA %02X", ista); |
| 318 | if (ista & 0x0f) { |
| 319 | val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_ISTA + 0x40); |
| 320 | if (ista & 0x01) |
| 321 | val |= 0x01; |
| 322 | if (ista & 0x04) |
| 323 | val |= 0x02; |
| 324 | if (ista & 0x08) |
| 325 | val |= 0x04; |
| 326 | if (val) |
| 327 | hscx_int_main(cs, val); |
| 328 | } |
| 329 | if (ista & 0x20) { |
| 330 | val = 0xfe & readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA | 0x80); |
| 331 | if (val) { |
| 332 | isac_interrupt(cs, val); |
| 333 | } |
| 334 | } |
| 335 | if (ista & 0x10) { |
| 336 | val = 0x01; |
| 337 | isac_interrupt(cs, val); |
| 338 | } |
| 339 | ista = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_ISTA); |
| 340 | if ((ista & 0x3f) && icnt) { |
| 341 | icnt--; |
| 342 | goto Start_IPAC; |
| 343 | } |
| 344 | if (!icnt) |
| 345 | if (cs->debug & L1_DEB_ISAC) |
| 346 | debugl1(cs, "Sedlbauer IRQ LOOP"); |
| 347 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_MASK, 0xFF); |
| 348 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_MASK, 0xC0); |
| 349 | spin_unlock_irqrestore(&cs->lock, flags); |
| 350 | return IRQ_HANDLED; |
| 351 | } |
| 352 | |
| 353 | static irqreturn_t |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 354 | sedlbauer_interrupt_isar(int intno, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | { |
| 356 | struct IsdnCardState *cs = dev_id; |
| 357 | u_char val; |
| 358 | int cnt = 5; |
| 359 | u_long flags; |
| 360 | |
| 361 | spin_lock_irqsave(&cs->lock, flags); |
| 362 | val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, ISAR_IRQBIT); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 363 | Start_ISAR: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | if (val & ISAR_IRQSTA) |
| 365 | isar_int_main(cs); |
| 366 | val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 367 | Start_ISAC: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | if (val) |
| 369 | isac_interrupt(cs, val); |
| 370 | val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, ISAR_IRQBIT); |
| 371 | if ((val & ISAR_IRQSTA) && --cnt) { |
| 372 | if (cs->debug & L1_DEB_HSCX) |
| 373 | debugl1(cs, "ISAR IntStat after IntRoutine"); |
| 374 | goto Start_ISAR; |
| 375 | } |
| 376 | val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA); |
| 377 | if (val && --cnt) { |
| 378 | if (cs->debug & L1_DEB_ISAC) |
| 379 | debugl1(cs, "ISAC IntStat after IntRoutine"); |
| 380 | goto Start_ISAC; |
| 381 | } |
| 382 | if (!cnt) |
| 383 | if (cs->debug & L1_DEB_ISAC) |
| 384 | debugl1(cs, "Sedlbauer IRQ LOOP"); |
| 385 | |
| 386 | writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, ISAR_IRQBIT, 0); |
| 387 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_MASK, 0xFF); |
| 388 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_MASK, 0x0); |
| 389 | writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, ISAR_IRQBIT, ISAR_IRQMSK); |
| 390 | spin_unlock_irqrestore(&cs->lock, flags); |
| 391 | return IRQ_HANDLED; |
| 392 | } |
| 393 | |
Adrian Bunk | 672c3fd | 2005-06-25 14:59:18 -0700 | [diff] [blame] | 394 | static void |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | release_io_sedlbauer(struct IsdnCardState *cs) |
| 396 | { |
| 397 | int bytecnt = 8; |
| 398 | |
| 399 | if (cs->subtyp == SEDL_SPEED_FAX) { |
| 400 | bytecnt = 16; |
| 401 | } else if (cs->hw.sedl.bus == SEDL_BUS_PCI) { |
| 402 | bytecnt = 256; |
| 403 | } |
| 404 | if (cs->hw.sedl.cfg_reg) |
| 405 | release_region(cs->hw.sedl.cfg_reg, bytecnt); |
| 406 | } |
| 407 | |
| 408 | static void |
| 409 | reset_sedlbauer(struct IsdnCardState *cs) |
| 410 | { |
| 411 | printk(KERN_INFO "Sedlbauer: resetting card\n"); |
| 412 | |
| 413 | if (!((cs->hw.sedl.bus == SEDL_BUS_PCMCIA) && |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 414 | (cs->hw.sedl.chip == SEDL_CHIP_ISAC_HSCX))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | if (cs->hw.sedl.chip == SEDL_CHIP_IPAC) { |
| 416 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_POTA2, 0x20); |
| 417 | mdelay(2); |
| 418 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_POTA2, 0x0); |
| 419 | mdelay(10); |
| 420 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_CONF, 0x0); |
| 421 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_ACFG, 0xff); |
| 422 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_AOE, 0x0); |
| 423 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_MASK, 0xc0); |
| 424 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_PCFG, 0x12); |
| 425 | } else if ((cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) && |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 426 | (cs->hw.sedl.bus == SEDL_BUS_PCI)) { |
| 427 | byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_on); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | mdelay(2); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 429 | byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | mdelay(10); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 431 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | byteout(cs->hw.sedl.reset_on, SEDL_RESET); /* Reset On */ |
| 433 | mdelay(2); |
| 434 | byteout(cs->hw.sedl.reset_off, 0); /* Reset Off */ |
| 435 | mdelay(10); |
| 436 | } |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | static int |
| 441 | Sedl_card_msg(struct IsdnCardState *cs, int mt, void *arg) |
| 442 | { |
| 443 | u_long flags; |
| 444 | |
| 445 | switch (mt) { |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 446 | case CARD_RESET: |
| 447 | spin_lock_irqsave(&cs->lock, flags); |
| 448 | reset_sedlbauer(cs); |
| 449 | spin_unlock_irqrestore(&cs->lock, flags); |
| 450 | return (0); |
| 451 | case CARD_RELEASE: |
| 452 | if (cs->hw.sedl.bus == SEDL_BUS_PCI) |
| 453 | /* disable all IRQ */ |
| 454 | byteout(cs->hw.sedl.cfg_reg + 5, 0); |
| 455 | if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | spin_lock_irqsave(&cs->lock, flags); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 457 | writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, |
| 458 | ISAR_IRQBIT, 0); |
| 459 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, |
| 460 | ISAC_MASK, 0xFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | reset_sedlbauer(cs); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 462 | writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, |
| 463 | ISAR_IRQBIT, 0); |
| 464 | writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, |
| 465 | ISAC_MASK, 0xFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | spin_unlock_irqrestore(&cs->lock, flags); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 467 | } |
| 468 | release_io_sedlbauer(cs); |
| 469 | return (0); |
| 470 | case CARD_INIT: |
| 471 | spin_lock_irqsave(&cs->lock, flags); |
| 472 | if (cs->hw.sedl.bus == SEDL_BUS_PCI) |
| 473 | /* enable all IRQ */ |
| 474 | byteout(cs->hw.sedl.cfg_reg + 5, 0x02); |
| 475 | reset_sedlbauer(cs); |
| 476 | if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) { |
| 477 | clear_pending_isac_ints(cs); |
| 478 | writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, |
| 479 | ISAR_IRQBIT, 0); |
| 480 | initisac(cs); |
| 481 | initisar(cs); |
| 482 | /* Reenable all IRQ */ |
| 483 | cs->writeisac(cs, ISAC_MASK, 0); |
| 484 | /* RESET Receiver and Transmitter */ |
| 485 | cs->writeisac(cs, ISAC_CMDR, 0x41); |
| 486 | } else { |
| 487 | inithscxisac(cs, 3); |
| 488 | } |
| 489 | spin_unlock_irqrestore(&cs->lock, flags); |
| 490 | return (0); |
| 491 | case CARD_TEST: |
| 492 | return (0); |
| 493 | case MDL_INFO_CONN: |
| 494 | if (cs->subtyp != SEDL_SPEEDFAX_PYRAMID) |
| 495 | return (0); |
| 496 | spin_lock_irqsave(&cs->lock, flags); |
| 497 | if ((long) arg) |
| 498 | cs->hw.sedl.reset_off &= ~SEDL_ISAR_PCI_LED2; |
| 499 | else |
| 500 | cs->hw.sedl.reset_off &= ~SEDL_ISAR_PCI_LED1; |
| 501 | byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off); |
| 502 | spin_unlock_irqrestore(&cs->lock, flags); |
| 503 | break; |
| 504 | case MDL_INFO_REL: |
| 505 | if (cs->subtyp != SEDL_SPEEDFAX_PYRAMID) |
| 506 | return (0); |
| 507 | spin_lock_irqsave(&cs->lock, flags); |
| 508 | if ((long) arg) |
| 509 | cs->hw.sedl.reset_off |= SEDL_ISAR_PCI_LED2; |
| 510 | else |
| 511 | cs->hw.sedl.reset_off |= SEDL_ISAR_PCI_LED1; |
| 512 | byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off); |
| 513 | spin_unlock_irqrestore(&cs->lock, flags); |
| 514 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | } |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 516 | return (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | } |
| 518 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | #ifdef __ISAPNP__ |
Greg Kroah-Hartman | ed5a84c | 2012-12-21 13:13:05 -0800 | [diff] [blame] | 520 | static struct isapnp_device_id sedl_ids[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | { ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x01), |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 522 | ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x01), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | (unsigned long) "Speed win" }, |
| 524 | { ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x02), |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 525 | ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x02), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | (unsigned long) "Speed Fax+" }, |
| 527 | { 0, } |
| 528 | }; |
| 529 | |
Greg Kroah-Hartman | ed5a84c | 2012-12-21 13:13:05 -0800 | [diff] [blame] | 530 | static struct isapnp_device_id *ipid = &sedl_ids[0]; |
| 531 | static struct pnp_card *pnp_c = NULL; |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 532 | |
Greg Kroah-Hartman | ed5a84c | 2012-12-21 13:13:05 -0800 | [diff] [blame] | 533 | static int setup_sedlbauer_isapnp(struct IsdnCard *card, int *bytecnt) |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 534 | { |
| 535 | struct IsdnCardState *cs = card->cs; |
| 536 | struct pnp_dev *pnp_d; |
| 537 | |
| 538 | if (!isapnp_present()) |
| 539 | return -1; |
| 540 | |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 541 | while (ipid->card_vendor) { |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 542 | if ((pnp_c = pnp_find_card(ipid->card_vendor, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 543 | ipid->card_device, pnp_c))) { |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 544 | pnp_d = NULL; |
| 545 | if ((pnp_d = pnp_find_dev(pnp_c, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 546 | ipid->vendor, ipid->function, pnp_d))) { |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 547 | int err; |
| 548 | |
| 549 | printk(KERN_INFO "HiSax: %s detected\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 550 | (char *)ipid->driver_data); |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 551 | pnp_disable_dev(pnp_d); |
| 552 | err = pnp_activate_dev(pnp_d); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 553 | if (err < 0) { |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 554 | printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 555 | __func__, err); |
| 556 | return (0); |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 557 | } |
| 558 | card->para[1] = pnp_port_start(pnp_d, 0); |
| 559 | card->para[0] = pnp_irq(pnp_d, 0); |
| 560 | |
| 561 | if (!card->para[0] || !card->para[1]) { |
| 562 | printk(KERN_ERR "Sedlbauer PnP:some resources are missing %ld/%lx\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 563 | card->para[0], card->para[1]); |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 564 | pnp_disable_dev(pnp_d); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 565 | return (0); |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 566 | } |
| 567 | cs->hw.sedl.cfg_reg = card->para[1]; |
| 568 | cs->irq = card->para[0]; |
| 569 | if (ipid->function == ISAPNP_FUNCTION(0x2)) { |
| 570 | cs->subtyp = SEDL_SPEED_FAX; |
| 571 | cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR; |
| 572 | *bytecnt = 16; |
| 573 | } else { |
| 574 | cs->subtyp = SEDL_SPEED_CARD_WIN; |
| 575 | cs->hw.sedl.chip = SEDL_CHIP_TEST; |
| 576 | } |
| 577 | |
| 578 | return (1); |
| 579 | } else { |
| 580 | printk(KERN_ERR "Sedlbauer PnP: PnP error card found, no device\n"); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 581 | return (0); |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 582 | } |
| 583 | } |
| 584 | ipid++; |
| 585 | pnp_c = NULL; |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 586 | } |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 587 | |
| 588 | printk(KERN_INFO "Sedlbauer PnP: no ISAPnP card found\n"); |
| 589 | return -1; |
| 590 | } |
| 591 | #else |
| 592 | |
Greg Kroah-Hartman | ed5a84c | 2012-12-21 13:13:05 -0800 | [diff] [blame] | 593 | static int setup_sedlbauer_isapnp(struct IsdnCard *card, int *bytecnt) |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 594 | { |
| 595 | return -1; |
| 596 | } |
| 597 | #endif /* __ISAPNP__ */ |
| 598 | |
Tilman Schmidt | 41a68a7 | 2010-01-18 17:24:10 +0100 | [diff] [blame] | 599 | #ifdef CONFIG_PCI |
Greg Kroah-Hartman | ed5a84c | 2012-12-21 13:13:05 -0800 | [diff] [blame] | 600 | static struct pci_dev *dev_sedl = NULL; |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 601 | |
Greg Kroah-Hartman | ed5a84c | 2012-12-21 13:13:05 -0800 | [diff] [blame] | 602 | static int setup_sedlbauer_pci(struct IsdnCard *card) |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 603 | { |
| 604 | struct IsdnCardState *cs = card->cs; |
| 605 | u16 sub_vendor_id, sub_id; |
| 606 | |
Tilman Schmidt | 41a68a7 | 2010-01-18 17:24:10 +0100 | [diff] [blame] | 607 | if ((dev_sedl = hisax_find_pci_device(PCI_VENDOR_ID_TIGERJET, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 608 | PCI_DEVICE_ID_TIGERJET_100, dev_sedl))) { |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 609 | if (pci_enable_device(dev_sedl)) |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 610 | return (0); |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 611 | cs->irq = dev_sedl->irq; |
| 612 | if (!cs->irq) { |
| 613 | printk(KERN_WARNING "Sedlbauer: No IRQ for PCI card found\n"); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 614 | return (0); |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 615 | } |
| 616 | cs->hw.sedl.cfg_reg = pci_resource_start(dev_sedl, 0); |
| 617 | } else { |
| 618 | printk(KERN_WARNING "Sedlbauer: No PCI card found\n"); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 619 | return (0); |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 620 | } |
| 621 | cs->irq_flags |= IRQF_SHARED; |
| 622 | cs->hw.sedl.bus = SEDL_BUS_PCI; |
| 623 | sub_vendor_id = dev_sedl->subsystem_vendor; |
| 624 | sub_id = dev_sedl->subsystem_device; |
| 625 | printk(KERN_INFO "Sedlbauer: PCI subvendor:%x subid %x\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 626 | sub_vendor_id, sub_id); |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 627 | printk(KERN_INFO "Sedlbauer: PCI base adr %#x\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 628 | cs->hw.sedl.cfg_reg); |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 629 | if (sub_id != PCI_SUB_ID_SEDLBAUER) { |
| 630 | printk(KERN_ERR "Sedlbauer: unknown sub id %#x\n", sub_id); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 631 | return (0); |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 632 | } |
| 633 | if (sub_vendor_id == PCI_SUBVENDOR_SPEEDFAX_PYRAMID) { |
| 634 | cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR; |
| 635 | cs->subtyp = SEDL_SPEEDFAX_PYRAMID; |
| 636 | } else if (sub_vendor_id == PCI_SUBVENDOR_SPEEDFAX_PCI) { |
| 637 | cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR; |
| 638 | cs->subtyp = SEDL_SPEEDFAX_PCI; |
| 639 | } else if (sub_vendor_id == PCI_SUBVENDOR_HST_SAPHIR3) { |
| 640 | cs->hw.sedl.chip = SEDL_CHIP_IPAC; |
| 641 | cs->subtyp = HST_SAPHIR3; |
| 642 | } else if (sub_vendor_id == PCI_SUBVENDOR_SEDLBAUER_PCI) { |
| 643 | cs->hw.sedl.chip = SEDL_CHIP_IPAC; |
| 644 | cs->subtyp = SEDL_SPEED_PCI; |
| 645 | } else { |
| 646 | printk(KERN_ERR "Sedlbauer: unknown sub vendor id %#x\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 647 | sub_vendor_id); |
| 648 | return (0); |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | cs->hw.sedl.reset_on = SEDL_ISAR_PCI_ISAR_RESET_ON; |
| 652 | cs->hw.sedl.reset_off = SEDL_ISAR_PCI_ISAR_RESET_OFF; |
| 653 | byteout(cs->hw.sedl.cfg_reg, 0xff); |
| 654 | byteout(cs->hw.sedl.cfg_reg, 0x00); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 655 | byteout(cs->hw.sedl.cfg_reg + 2, 0xdd); |
| 656 | byteout(cs->hw.sedl.cfg_reg + 5, 0); /* disable all IRQ */ |
| 657 | byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_on); |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 658 | mdelay(2); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 659 | byteout(cs->hw.sedl.cfg_reg + 3, cs->hw.sedl.reset_off); |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 660 | mdelay(10); |
| 661 | |
| 662 | return (1); |
| 663 | } |
| 664 | |
| 665 | #else |
| 666 | |
Greg Kroah-Hartman | ed5a84c | 2012-12-21 13:13:05 -0800 | [diff] [blame] | 667 | static int setup_sedlbauer_pci(struct IsdnCard *card) |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 668 | { |
| 669 | return (1); |
| 670 | } |
| 671 | |
Tilman Schmidt | 41a68a7 | 2010-01-18 17:24:10 +0100 | [diff] [blame] | 672 | #endif /* CONFIG_PCI */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | |
Greg Kroah-Hartman | ed5a84c | 2012-12-21 13:13:05 -0800 | [diff] [blame] | 674 | int setup_sedlbauer(struct IsdnCard *card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | { |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 676 | int bytecnt = 8, ver, val, rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | struct IsdnCardState *cs = card->cs; |
| 678 | char tmp[64]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | |
| 680 | strcpy(tmp, Sedlbauer_revision); |
| 681 | printk(KERN_INFO "HiSax: Sedlbauer driver Rev. %s\n", HiSax_getrev(tmp)); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 682 | |
| 683 | if (cs->typ == ISDN_CTYPE_SEDLBAUER) { |
| 684 | cs->subtyp = SEDL_SPEED_CARD_WIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | cs->hw.sedl.bus = SEDL_BUS_ISA; |
| 686 | cs->hw.sedl.chip = SEDL_CHIP_TEST; |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 687 | } else if (cs->typ == ISDN_CTYPE_SEDLBAUER_PCMCIA) { |
| 688 | cs->subtyp = SEDL_SPEED_STAR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | cs->hw.sedl.bus = SEDL_BUS_PCMCIA; |
| 690 | cs->hw.sedl.chip = SEDL_CHIP_TEST; |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 691 | } else if (cs->typ == ISDN_CTYPE_SEDLBAUER_FAX) { |
| 692 | cs->subtyp = SEDL_SPEED_FAX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | cs->hw.sedl.bus = SEDL_BUS_ISA; |
| 694 | cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR; |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 695 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | return (0); |
| 697 | |
| 698 | bytecnt = 8; |
| 699 | if (card->para[1]) { |
| 700 | cs->hw.sedl.cfg_reg = card->para[1]; |
| 701 | cs->irq = card->para[0]; |
| 702 | if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) { |
| 703 | bytecnt = 16; |
| 704 | } |
| 705 | } else { |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 706 | rc = setup_sedlbauer_isapnp(card, &bytecnt); |
| 707 | if (!rc) |
| 708 | return (0); |
| 709 | if (rc > 0) |
| 710 | goto ready; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | |
Jeff Garzik | 7da0d98 | 2007-10-03 15:37:40 -0400 | [diff] [blame] | 712 | /* Probe for Sedlbauer speed pci */ |
| 713 | rc = setup_sedlbauer_pci(card); |
| 714 | if (!rc) |
| 715 | return (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | bytecnt = 256; |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 718 | } |
Jeff Garzik | df61bec | 2006-12-08 02:39:37 -0800 | [diff] [blame] | 719 | |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 720 | ready: |
Jeff Garzik | df61bec | 2006-12-08 02:39:37 -0800 | [diff] [blame] | 721 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | /* In case of the sedlbauer pcmcia card, this region is in use, |
| 723 | * reserved for us by the card manager. So we do not check it |
| 724 | * here, it would fail. |
| 725 | */ |
| 726 | if (cs->hw.sedl.bus != SEDL_BUS_PCMCIA && |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 727 | !request_region(cs->hw.sedl.cfg_reg, bytecnt, "sedlbauer isdn")) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | printk(KERN_WARNING |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 729 | "HiSax: %s config port %x-%x already in use\n", |
| 730 | CardType[card->typ], |
| 731 | cs->hw.sedl.cfg_reg, |
| 732 | cs->hw.sedl.cfg_reg + bytecnt); |
| 733 | return (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | printk(KERN_INFO |
| 737 | "Sedlbauer: defined at 0x%x-0x%x IRQ %d\n", |
| 738 | cs->hw.sedl.cfg_reg, |
| 739 | cs->hw.sedl.cfg_reg + bytecnt, |
| 740 | cs->irq); |
| 741 | |
| 742 | cs->BC_Read_Reg = &ReadHSCX; |
| 743 | cs->BC_Write_Reg = &WriteHSCX; |
| 744 | cs->BC_Send_Data = &hscx_fill_fifo; |
| 745 | cs->cardmsg = &Sedl_card_msg; |
| 746 | |
| 747 | /* |
| 748 | * testing ISA and PCMCIA Cards for IPAC, default is ISAC |
| 749 | * do not test for PCI card, because ports are different |
| 750 | * and PCI card uses only IPAC (for the moment) |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 751 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | if (cs->hw.sedl.bus != SEDL_BUS_PCI) { |
| 753 | val = readreg(cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_ADR, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 754 | cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC, IPAC_ID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 755 | printk(KERN_DEBUG "Sedlbauer: testing IPAC version %x\n", val); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 756 | if ((val == 1) || (val == 2)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | /* IPAC */ |
| 758 | cs->subtyp = SEDL_SPEED_WIN2_PC104; |
| 759 | if (cs->hw.sedl.bus == SEDL_BUS_PCMCIA) { |
| 760 | cs->subtyp = SEDL_SPEED_STAR2; |
| 761 | } |
| 762 | cs->hw.sedl.chip = SEDL_CHIP_IPAC; |
| 763 | } else { |
| 764 | /* ISAC_HSCX oder ISAC_ISAR */ |
| 765 | if (cs->hw.sedl.chip == SEDL_CHIP_TEST) { |
| 766 | cs->hw.sedl.chip = SEDL_CHIP_ISAC_HSCX; |
| 767 | } |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | /* |
| 772 | * hw.sedl.chip is now properly set |
| 773 | */ |
| 774 | printk(KERN_INFO "Sedlbauer: %s detected\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 775 | Sedlbauer_Types[cs->subtyp]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | |
| 777 | setup_isac(cs); |
| 778 | if (cs->hw.sedl.chip == SEDL_CHIP_IPAC) { |
| 779 | if (cs->hw.sedl.bus == SEDL_BUS_PCI) { |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 780 | cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_ADR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_IPAC; |
| 782 | cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_IPAC; |
| 783 | } else { |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 784 | cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_ADR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 785 | cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC; |
| 786 | cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC; |
| 787 | } |
| 788 | test_and_set_bit(HW_IPAC, &cs->HW_Flags); |
| 789 | cs->readisac = &ReadISAC_IPAC; |
| 790 | cs->writeisac = &WriteISAC_IPAC; |
| 791 | cs->readisacfifo = &ReadISACfifo_IPAC; |
| 792 | cs->writeisacfifo = &WriteISACfifo_IPAC; |
| 793 | cs->irq_func = &sedlbauer_interrupt_ipac; |
| 794 | val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_ID); |
| 795 | printk(KERN_INFO "Sedlbauer: IPAC version %x\n", val); |
| 796 | } else { |
| 797 | /* ISAC_HSCX oder ISAC_ISAR */ |
| 798 | cs->readisac = &ReadISAC; |
| 799 | cs->writeisac = &WriteISAC; |
| 800 | cs->readisacfifo = &ReadISACfifo; |
| 801 | cs->writeisacfifo = &WriteISACfifo; |
| 802 | if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) { |
| 803 | if (cs->hw.sedl.bus == SEDL_BUS_PCI) { |
| 804 | cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 805 | SEDL_ISAR_PCI_ADR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 807 | SEDL_ISAR_PCI_ISAC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 809 | SEDL_ISAR_PCI_ISAR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | } else { |
| 811 | cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 812 | SEDL_ISAR_ISA_ADR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 814 | SEDL_ISAR_ISA_ISAC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 816 | SEDL_ISAR_ISA_ISAR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg + |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 818 | SEDL_ISAR_ISA_ISAR_RESET_ON; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg + |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 820 | SEDL_ISAR_ISA_ISAR_RESET_OFF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | } |
| 822 | cs->bcs[0].hw.isar.reg = &cs->hw.sedl.isar; |
| 823 | cs->bcs[1].hw.isar.reg = &cs->hw.sedl.isar; |
| 824 | test_and_set_bit(HW_ISAR, &cs->HW_Flags); |
| 825 | cs->irq_func = &sedlbauer_interrupt_isar; |
| 826 | cs->auxcmd = &isar_auxcmd; |
| 827 | ISACVersion(cs, "Sedlbauer:"); |
| 828 | cs->BC_Read_Reg = &ReadISAR; |
| 829 | cs->BC_Write_Reg = &WriteISAR; |
| 830 | cs->BC_Send_Data = &isar_fill_fifo; |
| 831 | bytecnt = 3; |
| 832 | while (bytecnt) { |
| 833 | ver = ISARVersion(cs, "Sedlbauer:"); |
| 834 | if (ver < 0) |
| 835 | printk(KERN_WARNING |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 836 | "Sedlbauer: wrong ISAR version (ret = %d)\n", ver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 837 | else |
| 838 | break; |
| 839 | reset_sedlbauer(cs); |
| 840 | bytecnt--; |
| 841 | } |
| 842 | if (!bytecnt) { |
| 843 | release_io_sedlbauer(cs); |
| 844 | return (0); |
| 845 | } |
| 846 | } else { |
| 847 | if (cs->hw.sedl.bus == SEDL_BUS_PCMCIA) { |
| 848 | cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_ADR; |
| 849 | cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_ISAC; |
| 850 | cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_HSCX; |
| 851 | cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_RESET; |
| 852 | cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_RESET; |
Thomas Gleixner | 9ba02be | 2006-07-01 19:29:36 -0700 | [diff] [blame] | 853 | cs->irq_flags |= IRQF_SHARED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 854 | } else { |
| 855 | cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_ADR; |
| 856 | cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_ISAC; |
| 857 | cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_HSCX; |
| 858 | cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_RESET_ON; |
| 859 | cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_RESET_OFF; |
| 860 | } |
| 861 | cs->irq_func = &sedlbauer_interrupt; |
| 862 | ISACVersion(cs, "Sedlbauer:"); |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 863 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | if (HscxVersion(cs, "Sedlbauer:")) { |
| 865 | printk(KERN_WARNING |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 866 | "Sedlbauer: wrong HSCX versions check IO address\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | release_io_sedlbauer(cs); |
| 868 | return (0); |
| 869 | } |
| 870 | } |
| 871 | } |
| 872 | return (1); |
| 873 | } |