1 /* $Id: ix1_micro.c,v 1.1.1.1 2005/04/11 02:50:23 jack Exp $
3 * low level stuff for ITK ix1-micro Rev.2 isdn cards
4 * derived from the original file teles3.c from Karsten Keil
6 * Author Klaus-Peter Nischke
7 * Copyright by Klaus-Peter Nischke, ITK AG
8 * <klaus@nischke.do.eunet.de>
9 * by Karsten Keil <keil@isdn4linux.de>
11 * This software may be used and distributed according to the terms
12 * of the GNU General Public License, incorporated herein by reference.
20 #define __NO_VERSION__
21 #include <linux/init.h>
22 #include <linux/isapnp.h>
28 extern const char *CardType[];
29 const char *ix1_revision = "$Revision: 1.1.1.1 $";
31 #define byteout(addr,val) outb(val,addr)
32 #define bytein(addr) inb(addr)
34 #define SPECIAL_PORT_OFFSET 3
36 #define ISAC_COMMAND_OFFSET 2
37 #define ISAC_DATA_OFFSET 0
38 #define HSCX_COMMAND_OFFSET 2
39 #define HSCX_DATA_OFFSET 1
44 readreg(unsigned int ale, unsigned int adr, u_char off)
58 readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
60 /* fifo read without cli because it's allready done */
63 insb(adr, data, size);
68 writereg(unsigned int ale, unsigned int adr, u_char off, u_char data)
80 writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
82 /* fifo write without cli because it's allready done */
84 outsb(adr, data, size);
87 /* Interface functions */
90 ReadISAC(struct IsdnCardState *cs, u_char offset)
92 return (readreg(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, offset));
96 WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
98 writereg(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, offset, value);
102 ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
104 readfifo(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, 0, data, size);
108 WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
110 writefifo(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, 0, data, size);
114 ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
116 return (readreg(cs->hw.ix1.hscx_ale,
117 cs->hw.ix1.hscx, offset + (hscx ? 0x40 : 0)));
121 WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
123 writereg(cs->hw.ix1.hscx_ale,
124 cs->hw.ix1.hscx, offset + (hscx ? 0x40 : 0), value);
127 #define READHSCX(cs, nr, reg) readreg(cs->hw.ix1.hscx_ale, \
128 cs->hw.ix1.hscx, reg + (nr ? 0x40 : 0))
129 #define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.ix1.hscx_ale, \
130 cs->hw.ix1.hscx, reg + (nr ? 0x40 : 0), data)
132 #define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.ix1.hscx_ale, \
133 cs->hw.ix1.hscx, (nr ? 0x40 : 0), ptr, cnt)
135 #define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.ix1.hscx_ale, \
136 cs->hw.ix1.hscx, (nr ? 0x40 : 0), ptr, cnt)
138 #include "hscx_irq.c"
141 ix1micro_interrupt(int intno, void *dev_id, struct pt_regs *regs)
143 struct IsdnCardState *cs = dev_id;
147 printk(KERN_WARNING "IX1: Spurious interrupt!\n");
150 val = readreg(cs->hw.ix1.hscx_ale, cs->hw.ix1.hscx, HSCX_ISTA + 0x40);
153 hscx_int_main(cs, val);
154 val = readreg(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, ISAC_ISTA);
157 isac_interrupt(cs, val);
158 val = readreg(cs->hw.ix1.hscx_ale, cs->hw.ix1.hscx, HSCX_ISTA + 0x40);
160 if (cs->debug & L1_DEB_HSCX)
161 debugl1(cs, "HSCX IntStat after IntRoutine");
164 val = readreg(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, ISAC_ISTA);
166 if (cs->debug & L1_DEB_ISAC)
167 debugl1(cs, "ISAC IntStat after IntRoutine");
170 writereg(cs->hw.ix1.hscx_ale, cs->hw.ix1.hscx, HSCX_MASK, 0xFF);
171 writereg(cs->hw.ix1.hscx_ale, cs->hw.ix1.hscx, HSCX_MASK + 0x40, 0xFF);
172 writereg(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, ISAC_MASK, 0xFF);
173 writereg(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, ISAC_MASK, 0);
174 writereg(cs->hw.ix1.hscx_ale, cs->hw.ix1.hscx, HSCX_MASK, 0);
175 writereg(cs->hw.ix1.hscx_ale, cs->hw.ix1.hscx, HSCX_MASK + 0x40, 0);
179 release_io_ix1micro(struct IsdnCardState *cs)
181 if (cs->hw.ix1.cfg_reg)
182 release_region(cs->hw.ix1.cfg_reg, 4);
186 ix1_reset(struct IsdnCardState *cs)
193 cnt = 3 * (HZ / 10) + 1;
196 byteout(cs->hw.ix1.cfg_reg + SPECIAL_PORT_OFFSET, 1);
197 HZDELAY(1); /* wait >=10 ms */
199 byteout(cs->hw.ix1.cfg_reg + SPECIAL_PORT_OFFSET, 0);
200 restore_flags(flags);
204 ix1_card_msg(struct IsdnCardState *cs, int mt, void *arg)
211 release_io_ix1micro(cs);
223 static struct isapnp_device_id itk_ids[] __initdata = {
224 { ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x25),
225 ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x25),
226 (unsigned long) "ITK micro 2" },
227 { ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x29),
228 ISAPNP_VENDOR('I', 'T', 'K'), ISAPNP_FUNCTION(0x29),
229 (unsigned long) "ITK micro 2." },
233 static struct isapnp_device_id *idev = &itk_ids[0];
234 static struct pci_bus *pnp_c __devinitdata = NULL;
239 setup_ix1micro(struct IsdnCard *card)
241 struct IsdnCardState *cs = card->cs;
244 strcpy(tmp, ix1_revision);
245 printk(KERN_INFO "HiSax: ITK IX1 driver Rev. %s\n", HiSax_getrev(tmp));
246 if (cs->typ != ISDN_CTYPE_IX1MICROR2)
250 if (!card->para[1] && isapnp_present()) {
254 while(idev->card_vendor) {
255 if ((pb = isapnp_find_card(idev->card_vendor,
256 idev->card_device, pnp_c))) {
259 if ((pd = isapnp_find_dev(pnp_c,
260 idev->vendor, idev->function, pd))) {
261 printk(KERN_INFO "HiSax: %s detected\n",
262 (char *)idev->driver_data);
266 card->para[1] = pd->resource[0].start;
267 card->para[0] = pd->irq_resource[0].start;
268 if (!card->para[0] || !card->para[1]) {
269 printk(KERN_ERR "ITK PnP:some resources are missing %ld/%lx\n",
270 card->para[0], card->para[1]);
276 printk(KERN_ERR "ITK PnP: PnP error card found, no device\n");
282 if (!idev->card_vendor) {
283 printk(KERN_INFO "ITK PnP: no ISAPnP card found\n");
289 cs->hw.ix1.isac_ale = card->para[1] + ISAC_COMMAND_OFFSET;
290 cs->hw.ix1.hscx_ale = card->para[1] + HSCX_COMMAND_OFFSET;
291 cs->hw.ix1.isac = card->para[1] + ISAC_DATA_OFFSET;
292 cs->hw.ix1.hscx = card->para[1] + HSCX_DATA_OFFSET;
293 cs->hw.ix1.cfg_reg = card->para[1];
294 cs->irq = card->para[0];
295 if (cs->hw.ix1.cfg_reg) {
296 if (check_region((cs->hw.ix1.cfg_reg), 4)) {
298 "HiSax: %s config port %x-%x already in use\n",
301 cs->hw.ix1.cfg_reg + 4);
304 request_region(cs->hw.ix1.cfg_reg, 4, "ix1micro cfg");
307 "HiSax: %s config irq:%d io:0x%X\n",
308 CardType[cs->typ], cs->irq,
311 cs->readisac = &ReadISAC;
312 cs->writeisac = &WriteISAC;
313 cs->readisacfifo = &ReadISACfifo;
314 cs->writeisacfifo = &WriteISACfifo;
315 cs->BC_Read_Reg = &ReadHSCX;
316 cs->BC_Write_Reg = &WriteHSCX;
317 cs->BC_Send_Data = &hscx_fill_fifo;
318 cs->cardmsg = &ix1_card_msg;
319 cs->irq_func = &ix1micro_interrupt;
320 ISACVersion(cs, "ix1-Micro:");
321 if (HscxVersion(cs, "ix1-Micro:")) {
323 "ix1-Micro: wrong HSCX versions check IO address\n");
324 release_io_ix1micro(cs);