Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: niccy.c,v 1.21.2.4 2004/01/13 23:48:39 keil Exp $ |
| 2 | * |
| 3 | * low level stuff for Dr. Neuhaus NICCY PnP and NICCY PCI and |
| 4 | * compatible (SAGEM cybermodem) |
| 5 | * |
| 6 | * Author Karsten Keil |
| 7 | * Copyright by Karsten Keil <keil@isdn4linux.de> |
| 8 | * |
| 9 | * This software may be used and distributed according to the terms |
| 10 | * of the GNU General Public License, incorporated herein by reference. |
| 11 | * |
| 12 | * Thanks to Dr. Neuhaus and SAGEM for information |
| 13 | * |
| 14 | */ |
| 15 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/init.h> |
| 17 | #include "hisax.h" |
| 18 | #include "isac.h" |
| 19 | #include "hscx.h" |
| 20 | #include "isdnl1.h" |
| 21 | #include <linux/pci.h> |
| 22 | #include <linux/isapnp.h> |
| 23 | |
| 24 | extern const char *CardType[]; |
Adrian Bunk | 672c3fd | 2005-06-25 14:59:18 -0700 | [diff] [blame] | 25 | static const char *niccy_revision = "$Revision: 1.21.2.4 $"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | #define byteout(addr,val) outb(val,addr) |
| 28 | #define bytein(addr) inb(addr) |
| 29 | |
| 30 | #define ISAC_PCI_DATA 0 |
| 31 | #define HSCX_PCI_DATA 1 |
| 32 | #define ISAC_PCI_ADDR 2 |
| 33 | #define HSCX_PCI_ADDR 3 |
| 34 | #define ISAC_PNP 0 |
| 35 | #define HSCX_PNP 1 |
| 36 | |
| 37 | /* SUB Types */ |
| 38 | #define NICCY_PNP 1 |
| 39 | #define NICCY_PCI 2 |
| 40 | |
| 41 | /* PCI stuff */ |
| 42 | #define PCI_IRQ_CTRL_REG 0x38 |
| 43 | #define PCI_IRQ_ENABLE 0x1f00 |
| 44 | #define PCI_IRQ_DISABLE 0xff0000 |
| 45 | #define PCI_IRQ_ASSERT 0x800000 |
| 46 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 47 | static inline u_char readreg(unsigned int ale, unsigned int adr, u_char off) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | { |
| 49 | register u_char ret; |
| 50 | |
| 51 | byteout(ale, off); |
| 52 | ret = bytein(adr); |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 53 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 56 | static inline void readfifo(unsigned int ale, unsigned int adr, u_char off, |
| 57 | u_char *data, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | { |
| 59 | byteout(ale, off); |
| 60 | insb(adr, data, size); |
| 61 | } |
| 62 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 63 | static inline void writereg(unsigned int ale, unsigned int adr, u_char off, |
| 64 | u_char data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | { |
| 66 | byteout(ale, off); |
| 67 | byteout(adr, data); |
| 68 | } |
| 69 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 70 | static inline void writefifo(unsigned int ale, unsigned int adr, u_char off, |
| 71 | u_char *data, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | { |
| 73 | byteout(ale, off); |
| 74 | outsb(adr, data, size); |
| 75 | } |
| 76 | |
| 77 | /* Interface functions */ |
| 78 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 79 | static u_char ReadISAC(struct IsdnCardState *cs, u_char offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | { |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 81 | return readreg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | } |
| 83 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 84 | static void WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | { |
| 86 | writereg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, offset, value); |
| 87 | } |
| 88 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 89 | static void ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | { |
| 91 | readfifo(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, 0, data, size); |
| 92 | } |
| 93 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 94 | static void WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | { |
| 96 | writefifo(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, 0, data, size); |
| 97 | } |
| 98 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 99 | static u_char ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | { |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 101 | return readreg(cs->hw.niccy.hscx_ale, |
| 102 | cs->hw.niccy.hscx, offset + (hscx ? 0x40 : 0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | } |
| 104 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 105 | static void WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, |
| 106 | u_char value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | { |
| 108 | writereg(cs->hw.niccy.hscx_ale, |
| 109 | cs->hw.niccy.hscx, offset + (hscx ? 0x40 : 0), value); |
| 110 | } |
| 111 | |
| 112 | #define READHSCX(cs, nr, reg) readreg(cs->hw.niccy.hscx_ale, \ |
| 113 | cs->hw.niccy.hscx, reg + (nr ? 0x40 : 0)) |
| 114 | #define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.niccy.hscx_ale, \ |
| 115 | cs->hw.niccy.hscx, reg + (nr ? 0x40 : 0), data) |
| 116 | |
| 117 | #define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.niccy.hscx_ale, \ |
| 118 | cs->hw.niccy.hscx, (nr ? 0x40 : 0), ptr, cnt) |
| 119 | |
| 120 | #define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.niccy.hscx_ale, \ |
| 121 | cs->hw.niccy.hscx, (nr ? 0x40 : 0), ptr, cnt) |
| 122 | |
| 123 | #include "hscx_irq.c" |
| 124 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 125 | static irqreturn_t niccy_interrupt(int intno, void *dev_id, |
| 126 | struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | { |
| 128 | struct IsdnCardState *cs = dev_id; |
| 129 | u_char val; |
| 130 | u_long flags; |
| 131 | |
| 132 | spin_lock_irqsave(&cs->lock, flags); |
| 133 | if (cs->subtyp == NICCY_PCI) { |
| 134 | int ival; |
| 135 | ival = inl(cs->hw.niccy.cfg_reg + PCI_IRQ_CTRL_REG); |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 136 | if (!(ival & PCI_IRQ_ASSERT)) { /* IRQ not for us (shared) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | spin_unlock_irqrestore(&cs->lock, flags); |
| 138 | return IRQ_NONE; |
| 139 | } |
| 140 | outl(ival, cs->hw.niccy.cfg_reg + PCI_IRQ_CTRL_REG); |
| 141 | } |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 142 | val = readreg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, |
| 143 | HSCX_ISTA + 0x40); |
| 144 | Start_HSCX: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | if (val) |
| 146 | hscx_int_main(cs, val); |
| 147 | val = readreg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, ISAC_ISTA); |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 148 | Start_ISAC: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | if (val) |
| 150 | isac_interrupt(cs, val); |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 151 | val = readreg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, |
| 152 | HSCX_ISTA + 0x40); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | if (val) { |
| 154 | if (cs->debug & L1_DEB_HSCX) |
| 155 | debugl1(cs, "HSCX IntStat after IntRoutine"); |
| 156 | goto Start_HSCX; |
| 157 | } |
| 158 | val = readreg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, ISAC_ISTA); |
| 159 | if (val) { |
| 160 | if (cs->debug & L1_DEB_ISAC) |
| 161 | debugl1(cs, "ISAC IntStat after IntRoutine"); |
| 162 | goto Start_ISAC; |
| 163 | } |
| 164 | writereg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, HSCX_MASK, 0xFF); |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 165 | writereg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, HSCX_MASK + 0x40, |
| 166 | 0xFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | writereg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, ISAC_MASK, 0xFF); |
| 168 | writereg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, ISAC_MASK, 0); |
| 169 | writereg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, HSCX_MASK, 0); |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 170 | writereg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, HSCX_MASK + 0x40,0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | spin_unlock_irqrestore(&cs->lock, flags); |
| 172 | return IRQ_HANDLED; |
| 173 | } |
| 174 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 175 | static void release_io_niccy(struct IsdnCardState *cs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | { |
| 177 | if (cs->subtyp == NICCY_PCI) { |
| 178 | int val; |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 179 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | val = inl(cs->hw.niccy.cfg_reg + PCI_IRQ_CTRL_REG); |
| 181 | val &= PCI_IRQ_DISABLE; |
| 182 | outl(val, cs->hw.niccy.cfg_reg + PCI_IRQ_CTRL_REG); |
| 183 | release_region(cs->hw.niccy.cfg_reg, 0x40); |
| 184 | release_region(cs->hw.niccy.isac, 4); |
| 185 | } else { |
| 186 | release_region(cs->hw.niccy.isac, 2); |
| 187 | release_region(cs->hw.niccy.isac_ale, 2); |
| 188 | } |
| 189 | } |
| 190 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 191 | static void niccy_reset(struct IsdnCardState *cs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | { |
| 193 | if (cs->subtyp == NICCY_PCI) { |
| 194 | int val; |
| 195 | |
| 196 | val = inl(cs->hw.niccy.cfg_reg + PCI_IRQ_CTRL_REG); |
| 197 | val |= PCI_IRQ_ENABLE; |
| 198 | outl(val, cs->hw.niccy.cfg_reg + PCI_IRQ_CTRL_REG); |
| 199 | } |
| 200 | inithscxisac(cs, 3); |
| 201 | } |
| 202 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 203 | static int niccy_card_msg(struct IsdnCardState *cs, int mt, void *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | { |
| 205 | u_long flags; |
| 206 | |
| 207 | switch (mt) { |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 208 | case CARD_RESET: |
| 209 | spin_lock_irqsave(&cs->lock, flags); |
| 210 | niccy_reset(cs); |
| 211 | spin_unlock_irqrestore(&cs->lock, flags); |
| 212 | return 0; |
| 213 | case CARD_RELEASE: |
| 214 | release_io_niccy(cs); |
| 215 | return 0; |
| 216 | case CARD_INIT: |
| 217 | spin_lock_irqsave(&cs->lock, flags); |
| 218 | niccy_reset(cs); |
| 219 | spin_unlock_irqrestore(&cs->lock, flags); |
| 220 | return 0; |
| 221 | case CARD_TEST: |
| 222 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | } |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 224 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | } |
| 226 | |
Karsten Keil | 67eb5db | 2006-07-10 04:44:11 -0700 | [diff] [blame] | 227 | static struct pci_dev *niccy_dev __devinitdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | #ifdef __ISAPNP__ |
| 229 | static struct pnp_card *pnp_c __devinitdata = NULL; |
| 230 | #endif |
| 231 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 232 | int __devinit setup_niccy(struct IsdnCard *card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | { |
| 234 | struct IsdnCardState *cs = card->cs; |
| 235 | char tmp[64]; |
| 236 | |
| 237 | strcpy(tmp, niccy_revision); |
| 238 | printk(KERN_INFO "HiSax: Niccy driver Rev. %s\n", HiSax_getrev(tmp)); |
| 239 | if (cs->typ != ISDN_CTYPE_NICCY) |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 240 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | #ifdef __ISAPNP__ |
| 242 | if (!card->para[1] && isapnp_present()) { |
| 243 | struct pnp_dev *pnp_d = NULL; |
| 244 | int err; |
| 245 | |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 246 | pnp_c = pnp_find_card(ISAPNP_VENDOR('S', 'D', 'A'), |
| 247 | ISAPNP_FUNCTION(0x0150), pnp_c); |
| 248 | if (pnp_c) { |
| 249 | pnp_d = pnp_find_dev(pnp_c, |
| 250 | ISAPNP_VENDOR('S', 'D', 'A'), |
| 251 | ISAPNP_FUNCTION(0x0150), pnp_d); |
| 252 | if (!pnp_d) { |
| 253 | printk(KERN_ERR "NiccyPnP: PnP error card " |
| 254 | "found, no device\n"); |
| 255 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | } |
| 257 | pnp_disable_dev(pnp_d); |
| 258 | err = pnp_activate_dev(pnp_d); |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 259 | if (err < 0) { |
| 260 | printk(KERN_WARNING "%s: pnp_activate_dev " |
| 261 | "ret(%d)\n", __FUNCTION__, err); |
| 262 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | } |
| 264 | card->para[1] = pnp_port_start(pnp_d, 0); |
| 265 | card->para[2] = pnp_port_start(pnp_d, 1); |
| 266 | card->para[0] = pnp_irq(pnp_d, 0); |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 267 | if (!card->para[0] || !card->para[1] || |
| 268 | !card->para[2]) { |
| 269 | printk(KERN_ERR "NiccyPnP:some resources are " |
| 270 | "missing %ld/%lx/%lx\n", |
| 271 | card->para[0], card->para[1], |
| 272 | card->para[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | pnp_disable_dev(pnp_d); |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 274 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | } |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 276 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | printk(KERN_INFO "NiccyPnP: no ISAPnP card found\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | } |
| 279 | #endif |
| 280 | if (card->para[1]) { |
| 281 | cs->hw.niccy.isac = card->para[1] + ISAC_PNP; |
| 282 | cs->hw.niccy.hscx = card->para[1] + HSCX_PNP; |
| 283 | cs->hw.niccy.isac_ale = card->para[2] + ISAC_PNP; |
| 284 | cs->hw.niccy.hscx_ale = card->para[2] + HSCX_PNP; |
| 285 | cs->hw.niccy.cfg_reg = 0; |
| 286 | cs->subtyp = NICCY_PNP; |
| 287 | cs->irq = card->para[0]; |
| 288 | if (!request_region(cs->hw.niccy.isac, 2, "niccy data")) { |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 289 | printk(KERN_WARNING "HiSax: %s data port %x-%x " |
| 290 | "already in use\n", CardType[card->typ], |
| 291 | cs->hw.niccy.isac, cs->hw.niccy.isac + 1); |
| 292 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | } |
| 294 | if (!request_region(cs->hw.niccy.isac_ale, 2, "niccy addr")) { |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 295 | printk(KERN_WARNING "HiSax: %s address port %x-%x " |
| 296 | "already in use\n", CardType[card->typ], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | cs->hw.niccy.isac_ale, |
| 298 | cs->hw.niccy.isac_ale + 1); |
| 299 | release_region(cs->hw.niccy.isac, 2); |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 300 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | } |
| 302 | } else { |
| 303 | #ifdef CONFIG_PCI |
| 304 | u_int pci_ioaddr; |
| 305 | cs->subtyp = 0; |
| 306 | if ((niccy_dev = pci_find_device(PCI_VENDOR_ID_SATSAGEM, |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 307 | PCI_DEVICE_ID_SATSAGEM_NICCY, |
| 308 | niccy_dev))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | if (pci_enable_device(niccy_dev)) |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 310 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | /* get IRQ */ |
| 312 | if (!niccy_dev->irq) { |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 313 | printk(KERN_WARNING |
| 314 | "Niccy: No IRQ for PCI card found\n"); |
| 315 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | } |
| 317 | cs->irq = niccy_dev->irq; |
| 318 | cs->hw.niccy.cfg_reg = pci_resource_start(niccy_dev, 0); |
| 319 | if (!cs->hw.niccy.cfg_reg) { |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 320 | printk(KERN_WARNING |
| 321 | "Niccy: No IO-Adr for PCI cfg found\n"); |
| 322 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | } |
| 324 | pci_ioaddr = pci_resource_start(niccy_dev, 1); |
| 325 | if (!pci_ioaddr) { |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 326 | printk(KERN_WARNING |
| 327 | "Niccy: No IO-Adr for PCI card found\n"); |
| 328 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | } |
| 330 | cs->subtyp = NICCY_PCI; |
| 331 | } else { |
| 332 | printk(KERN_WARNING "Niccy: No PCI card found\n"); |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 333 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | } |
Thomas Gleixner | 9ba02be | 2006-07-01 19:29:36 -0700 | [diff] [blame] | 335 | cs->irq_flags |= IRQF_SHARED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | cs->hw.niccy.isac = pci_ioaddr + ISAC_PCI_DATA; |
| 337 | cs->hw.niccy.isac_ale = pci_ioaddr + ISAC_PCI_ADDR; |
| 338 | cs->hw.niccy.hscx = pci_ioaddr + HSCX_PCI_DATA; |
| 339 | cs->hw.niccy.hscx_ale = pci_ioaddr + HSCX_PCI_ADDR; |
| 340 | if (!request_region(cs->hw.niccy.isac, 4, "niccy")) { |
| 341 | printk(KERN_WARNING |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 342 | "HiSax: %s data port %x-%x already in use\n", |
| 343 | CardType[card->typ], |
| 344 | cs->hw.niccy.isac, cs->hw.niccy.isac + 4); |
| 345 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | } |
| 347 | if (!request_region(cs->hw.niccy.cfg_reg, 0x40, "niccy pci")) { |
| 348 | printk(KERN_WARNING |
| 349 | "HiSax: %s pci port %x-%x already in use\n", |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 350 | CardType[card->typ], |
| 351 | cs->hw.niccy.cfg_reg, |
| 352 | cs->hw.niccy.cfg_reg + 0x40); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | release_region(cs->hw.niccy.isac, 4); |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 354 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | } |
| 356 | #else |
| 357 | printk(KERN_WARNING "Niccy: io0 0 and NO_PCI_BIOS\n"); |
| 358 | printk(KERN_WARNING "Niccy: unable to config NICCY PCI\n"); |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 359 | return 0; |
| 360 | #endif /* CONFIG_PCI */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | } |
| 362 | printk(KERN_INFO "HiSax: %s %s config irq:%d data:0x%X ale:0x%X\n", |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 363 | CardType[cs->typ], (cs->subtyp == 1) ? "PnP" : "PCI", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | cs->irq, cs->hw.niccy.isac, cs->hw.niccy.isac_ale); |
| 365 | setup_isac(cs); |
| 366 | cs->readisac = &ReadISAC; |
| 367 | cs->writeisac = &WriteISAC; |
| 368 | cs->readisacfifo = &ReadISACfifo; |
| 369 | cs->writeisacfifo = &WriteISACfifo; |
| 370 | cs->BC_Read_Reg = &ReadHSCX; |
| 371 | cs->BC_Write_Reg = &WriteHSCX; |
| 372 | cs->BC_Send_Data = &hscx_fill_fifo; |
| 373 | cs->cardmsg = &niccy_card_msg; |
| 374 | cs->irq_func = &niccy_interrupt; |
| 375 | ISACVersion(cs, "Niccy:"); |
| 376 | if (HscxVersion(cs, "Niccy:")) { |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 377 | printk(KERN_WARNING "Niccy: wrong HSCX versions check IO " |
| 378 | "address\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | release_io_niccy(cs); |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 380 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | } |
Jiri Slaby | 1d02a03 | 2006-10-04 02:15:42 -0700 | [diff] [blame^] | 382 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | } |