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