Blame view

drivers/isdn/hysdn/boardergo.c 15.8 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  /* $Id: boardergo.c,v 1.5.6.7 2001/11/06 21:58:19 kai Exp $
   *
   * Linux driver for HYSDN cards, specific routines for ergo type boards.
   *
   * Author    Werner Cornelius (werner@titro.de) for Hypercope GmbH
   * Copyright 1999 by Werner Cornelius (werner@titro.de)
   *
   * This software may be used and distributed according to the terms
   * of the GNU General Public License, incorporated herein by reference.
   *
   * As all Linux supported cards Champ2, Ergo and Metro2/4 use the same
   * DPRAM interface and layout with only minor differences all related
   * stuff is done here, not in separate modules.
   *
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  #include <linux/signal.h>
  #include <linux/kernel.h>
  #include <linux/ioport.h>
  #include <linux/interrupt.h>
  #include <linux/vmalloc.h>
  #include <linux/delay.h>
  #include <asm/io.h>
  
  #include "hysdn_defs.h"
  #include "boardergo.h"
  
  #define byteout(addr,val) outb(val,addr)
  #define bytein(addr) inb(addr)
  
  /***************************************************/
  /* The cards interrupt handler. Called from system */
  /***************************************************/
  static irqreturn_t
7d12e780e   David Howells   IRQ: Maintain reg...
34
  ergo_interrupt(int intno, void *dev_id)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
35
36
37
  {
  	hysdn_card *card = dev_id;	/* parameter from irq */
  	tErgDpram *dpr;
c721bccec   Andrew Morton   [PATCH] hysdn: re...
38
39
  	unsigned long flags;
  	unsigned char volatile b;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40
41
42
43
44
  
  	if (!card)
  		return IRQ_NONE;		/* error -> spurious interrupt */
  	if (!card->irq_enabled)
  		return IRQ_NONE;		/* other device interrupting or irq switched off */
0d9ba869e   Amol Lad   [PATCH] drivers/i...
45
  	spin_lock_irqsave(&card->hysdn_lock, flags); /* no further irqs allowed */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
46
47
  
  	if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) {
0d9ba869e   Amol Lad   [PATCH] drivers/i...
48
  		spin_unlock_irqrestore(&card->hysdn_lock, flags);	/* restore old state */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49
50
51
52
53
54
55
56
57
58
59
  		return IRQ_NONE;		/* no interrupt requested by E1 */
  	}
  	/* clear any pending ints on the board */
  	dpr = card->dpram;
  	b = dpr->ToPcInt;	/* clear for ergo */
  	b |= dpr->ToPcIntMetro;	/* same for metro */
  	b |= dpr->ToHyInt;	/* and for champ */
  
  	/* start kernel task immediately after leaving all interrupts */
  	if (!card->hw_lock)
  		schedule_work(&card->irq_queue);
0d9ba869e   Amol Lad   [PATCH] drivers/i...
60
  	spin_unlock_irqrestore(&card->hysdn_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
61
62
63
64
  	return IRQ_HANDLED;
  }				/* ergo_interrupt */
  
  /******************************************************************************/
a9dd7fe28   Mark Asselstine   hysdn: Remove cli...
65
66
67
68
69
  /* ergo_irq_bh will be called as part of the kernel clearing its shared work  */
  /* queue sometime after a call to schedule_work has been made passing our     */
  /* work_struct. This task is the only one handling data transfer from or to   */
  /* the card after booting. The task may be queued from everywhere             */
  /* (interrupts included).                                                     */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
70
71
  /******************************************************************************/
  static void
3e577a80e   Al Viro   [PATCH] drivers/{...
72
  ergo_irq_bh(struct work_struct *ugli_api)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
73
  {
3e577a80e   Al Viro   [PATCH] drivers/{...
74
  	hysdn_card * card = container_of(ugli_api, hysdn_card, irq_queue);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
75
76
  	tErgDpram *dpr;
  	int again;
c721bccec   Andrew Morton   [PATCH] hysdn: re...
77
  	unsigned long flags;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
78
79
80
81
82
  
  	if (card->state != CARD_STATE_RUN)
  		return;		/* invalid call */
  
  	dpr = card->dpram;	/* point to DPRAM */
0d9ba869e   Amol Lad   [PATCH] drivers/i...
83
  	spin_lock_irqsave(&card->hysdn_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
84
  	if (card->hw_lock) {
0d9ba869e   Amol Lad   [PATCH] drivers/i...
85
  		spin_unlock_irqrestore(&card->hysdn_lock, flags);	/* hardware currently unavailable */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
86
87
88
89
90
  		return;
  	}
  	card->hw_lock = 1;	/* we now lock the hardware */
  
  	do {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
  		again = 0;	/* assume loop not to be repeated */
  
  		if (!dpr->ToHyFlag) {
  			/* we are able to send a buffer */
  
  			if (hysdn_sched_tx(card, dpr->ToHyBuf, &dpr->ToHySize, &dpr->ToHyChannel,
  					   ERG_TO_HY_BUF_SIZE)) {
  				dpr->ToHyFlag = 1;	/* enable tx */
  				again = 1;	/* restart loop */
  			}
  		}		/* we are able to send a buffer */
  		if (dpr->ToPcFlag) {
  			/* a message has arrived for us, handle it */
  
  			if (hysdn_sched_rx(card, dpr->ToPcBuf, dpr->ToPcSize, dpr->ToPcChannel)) {
  				dpr->ToPcFlag = 0;	/* we worked the data */
  				again = 1;	/* restart loop */
  			}
  		}		/* a message has arrived for us */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110
111
112
113
114
115
  		if (again) {
  			dpr->ToHyInt = 1;
  			dpr->ToPcInt = 1;	/* interrupt to E1 for all cards */
  		} else
  			card->hw_lock = 0;	/* free hardware again */
  	} while (again);	/* until nothing more to do */
0d9ba869e   Amol Lad   [PATCH] drivers/i...
116
  	spin_unlock_irqrestore(&card->hysdn_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
117
118
119
120
121
122
123
124
125
  }				/* ergo_irq_bh */
  
  
  /*********************************************************/
  /* stop the card (hardware reset) and disable interrupts */
  /*********************************************************/
  static void
  ergo_stopcard(hysdn_card * card)
  {
c721bccec   Andrew Morton   [PATCH] hysdn: re...
126
127
  	unsigned long flags;
  	unsigned char val;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
128
129
130
131
132
  
  	hysdn_net_release(card);	/* first release the net device if existing */
  #ifdef CONFIG_HYSDN_CAPI
  	hycapi_capi_stop(card);
  #endif /* CONFIG_HYSDN_CAPI */
0d9ba869e   Amol Lad   [PATCH] drivers/i...
133
  	spin_lock_irqsave(&card->hysdn_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
134
135
136
137
138
139
140
  	val = bytein(card->iobase + PCI9050_INTR_REG);	/* get actual value */
  	val &= ~(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1);	/* mask irq */
  	byteout(card->iobase + PCI9050_INTR_REG, val);
  	card->irq_enabled = 0;
  	byteout(card->iobase + PCI9050_USER_IO, PCI9050_E1_RESET);	/* reset E1 processor */
  	card->state = CARD_STATE_UNUSED;
  	card->err_log_state = ERRLOG_STATE_OFF;		/* currently no log active */
0d9ba869e   Amol Lad   [PATCH] drivers/i...
141
  	spin_unlock_irqrestore(&card->hysdn_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
142
143
144
145
146
147
148
149
  }				/* ergo_stopcard */
  
  /**************************************************************************/
  /* enable or disable the cards error log. The event is queued if possible */
  /**************************************************************************/
  static void
  ergo_set_errlog_state(hysdn_card * card, int on)
  {
c721bccec   Andrew Morton   [PATCH] hysdn: re...
150
  	unsigned long flags;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
151
152
153
154
155
  
  	if (card->state != CARD_STATE_RUN) {
  		card->err_log_state = ERRLOG_STATE_OFF;		/* must be off */
  		return;
  	}
0d9ba869e   Amol Lad   [PATCH] drivers/i...
156
  	spin_lock_irqsave(&card->hysdn_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
157
158
159
  
  	if (((card->err_log_state == ERRLOG_STATE_OFF) && !on) ||
  	    ((card->err_log_state == ERRLOG_STATE_ON) && on)) {
0d9ba869e   Amol Lad   [PATCH] drivers/i...
160
  		spin_unlock_irqrestore(&card->hysdn_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
161
162
163
164
165
166
  		return;		/* nothing to do */
  	}
  	if (on)
  		card->err_log_state = ERRLOG_STATE_START;	/* request start */
  	else
  		card->err_log_state = ERRLOG_STATE_STOP;	/* request stop */
0d9ba869e   Amol Lad   [PATCH] drivers/i...
167
  	spin_unlock_irqrestore(&card->hysdn_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
  	schedule_work(&card->irq_queue);
  }				/* ergo_set_errlog_state */
  
  /******************************************/
  /* test the cards RAM and return 0 if ok. */
  /******************************************/
  static const char TestText[36] = "This Message is filler, why read it";
  
  static int
  ergo_testram(hysdn_card * card)
  {
  	tErgDpram *dpr = card->dpram;
  
  	memset(dpr->TrapTable, 0, sizeof(dpr->TrapTable));	/* clear all Traps */
  	dpr->ToHyInt = 1;	/* E1 INTR state forced */
  
  	memcpy(&dpr->ToHyBuf[ERG_TO_HY_BUF_SIZE - sizeof(TestText)], TestText,
  	       sizeof(TestText));
  	if (memcmp(&dpr->ToHyBuf[ERG_TO_HY_BUF_SIZE - sizeof(TestText)], TestText,
  		   sizeof(TestText)))
  		return (-1);
  
  	memcpy(&dpr->ToPcBuf[ERG_TO_PC_BUF_SIZE - sizeof(TestText)], TestText,
  	       sizeof(TestText));
  	if (memcmp(&dpr->ToPcBuf[ERG_TO_PC_BUF_SIZE - sizeof(TestText)], TestText,
  		   sizeof(TestText)))
  		return (-1);
  
  	return (0);
  }				/* ergo_testram */
  
  /*****************************************************************************/
  /* this function is intended to write stage 1 boot image to the cards buffer */
  /* this is done in two steps. First the 1024 hi-words are written (offs=0),  */
  /* then the 1024 lo-bytes are written. The remaining DPRAM is cleared, the   */
  /* PCI-write-buffers flushed and the card is taken out of reset.             */
  /* The function then waits for a reaction of the E1 processor or a timeout.  */
  /* Negative return values are interpreted as errors.                         */
  /*****************************************************************************/
  static int
c721bccec   Andrew Morton   [PATCH] hysdn: re...
208
209
  ergo_writebootimg(struct HYSDN_CARD *card, unsigned char *buf,
  			unsigned long offs)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
210
  {
c721bccec   Andrew Morton   [PATCH] hysdn: re...
211
  	unsigned char *dst;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
  	tErgDpram *dpram;
  	int cnt = (BOOT_IMG_SIZE >> 2);		/* number of words to move and swap (byte order!) */
  	
  	if (card->debug_flags & LOG_POF_CARD)
  		hysdn_addlog(card, "ERGO: write bootldr offs=0x%lx ", offs);
  
  	dst = card->dpram;	/* pointer to start of DPRAM */
  	dst += (offs + ERG_DPRAM_FILL_SIZE);	/* offset in the DPRAM */
  	while (cnt--) {
  		*dst++ = *(buf + 1);	/* high byte */
  		*dst++ = *buf;	/* low byte */
  		dst += 2;	/* point to next longword */
  		buf += 2;	/* buffer only filled with words */
  	}
  
  	/* if low words (offs = 2) have been written, clear the rest of the DPRAM, */
  	/* flush the PCI-write-buffer and take the E1 out of reset */
  	if (offs) {
  		memset(card->dpram, 0, ERG_DPRAM_FILL_SIZE);	/* fill the DPRAM still not cleared */
  		dpram = card->dpram;	/* get pointer to dpram structure */
  		dpram->ToHyNoDpramErrLog = 0xFF;	/* write a dpram register */
  		while (!dpram->ToHyNoDpramErrLog);	/* reread volatile register to flush PCI */
  
  		byteout(card->iobase + PCI9050_USER_IO, PCI9050_E1_RUN);	/* start E1 processor */
  		/* the interrupts are still masked */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
  		msleep_interruptible(20);		/* Timeout 20ms */
  
  		if (((tDpramBootSpooler *) card->dpram)->Len != DPRAM_SPOOLER_DATA_SIZE) {
  			if (card->debug_flags & LOG_POF_CARD)
  				hysdn_addlog(card, "ERGO: write bootldr no answer");
  			return (-ERR_BOOTIMG_FAIL);
  		}
  	}			/* start_boot_img */
  	return (0);		/* successful */
  }				/* ergo_writebootimg */
  
  /********************************************************************************/
  /* ergo_writebootseq writes the buffer containing len bytes to the E1 processor */
  /* using the boot spool mechanism. If everything works fine 0 is returned. In   */
  /* case of errors a negative error value is returned.                           */
  /********************************************************************************/
  static int
c721bccec   Andrew Morton   [PATCH] hysdn: re...
254
  ergo_writebootseq(struct HYSDN_CARD *card, unsigned char *buf, int len)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
255
256
  {
  	tDpramBootSpooler *sp = (tDpramBootSpooler *) card->dpram;
c721bccec   Andrew Morton   [PATCH] hysdn: re...
257
258
  	unsigned char *dst;
  	unsigned char buflen;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
259
  	int nr_write;
c721bccec   Andrew Morton   [PATCH] hysdn: re...
260
261
  	unsigned char tmp_rdptr;
  	unsigned char wr_mirror;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
262
263
264
265
266
267
268
269
  	int i;
  
  	if (card->debug_flags & LOG_POF_CARD)
  		hysdn_addlog(card, "ERGO: write boot seq len=%d ", len);
  
  	dst = sp->Data;		/* point to data in spool structure */
  	buflen = sp->Len;	/* maximum len of spooled data */
  	wr_mirror = sp->WrPtr;	/* only once read */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
  
  	/* try until all bytes written or error */
  	i = 0x1000;		/* timeout value */
  	while (len) {
  
  		/* first determine the number of bytes that may be buffered */
  		do {
  			tmp_rdptr = sp->RdPtr;	/* first read the pointer */
  			i--;	/* decrement timeout */
  		} while (i && (tmp_rdptr != sp->RdPtr));	/* wait for stable pointer */
  
  		if (!i) {
  			if (card->debug_flags & LOG_POF_CARD)
  				hysdn_addlog(card, "ERGO: write boot seq timeout");
  			return (-ERR_BOOTSEQ_FAIL);	/* value not stable -> timeout */
  		}
  		if ((nr_write = tmp_rdptr - wr_mirror - 1) < 0)
  			nr_write += buflen;	/* now we got number of free bytes - 1 in buffer */
  
  		if (!nr_write)
  			continue;	/* no free bytes in buffer */
  
  		if (nr_write > len)
  			nr_write = len;		/* limit if last few bytes */
  		i = 0x1000;	/* reset timeout value */
  
  		/* now we know how much bytes we may put in the puffer */
  		len -= nr_write;	/* we savely could adjust len before output */
  		while (nr_write--) {
  			*(dst + wr_mirror) = *buf++;	/* output one byte */
  			if (++wr_mirror >= buflen)
  				wr_mirror = 0;
  			sp->WrPtr = wr_mirror;	/* announce the next byte to E1 */
  		}		/* while (nr_write) */
  
  	}			/* while (len) */
  	return (0);
  }				/* ergo_writebootseq */
  
  /***********************************************************************************/
  /* ergo_waitpofready waits for a maximum of 10 seconds for the completition of the */
  /* boot process. If the process has been successful 0 is returned otherwise a     */
  /* negative error code is returned.                                                */
  /***********************************************************************************/
  static int
  ergo_waitpofready(struct HYSDN_CARD *card)
  {
  	tErgDpram *dpr = card->dpram;	/* pointer to DPRAM structure */
  	int timecnt = 10000 / 50;	/* timeout is 10 secs max. */
c721bccec   Andrew Morton   [PATCH] hysdn: re...
319
  	unsigned long flags;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
320
321
322
323
324
325
326
327
328
329
330
331
332
333
  	int msg_size;
  	int i;
  
  	if (card->debug_flags & LOG_POF_CARD)
  		hysdn_addlog(card, "ERGO: waiting for pof ready");
  	while (timecnt--) {
  		/* wait until timeout  */
  
  		if (dpr->ToPcFlag) {
  			/* data has arrived */
  
  			if ((dpr->ToPcChannel != CHAN_SYSTEM) ||
  			    (dpr->ToPcSize < MIN_RDY_MSG_SIZE) ||
  			    (dpr->ToPcSize > MAX_RDY_MSG_SIZE) ||
c721bccec   Andrew Morton   [PATCH] hysdn: re...
334
  			    ((*(unsigned long *) dpr->ToPcBuf) != RDY_MAGIC))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
335
336
337
338
339
340
341
342
343
344
  				break;	/* an error occurred */
  
  			/* Check for additional data delivered during SysReady */
  			msg_size = dpr->ToPcSize - RDY_MAGIC_SIZE;
  			if (msg_size > 0)
  				if (EvalSysrTokData(card, dpr->ToPcBuf + RDY_MAGIC_SIZE, msg_size))
  					break;
  
  			if (card->debug_flags & LOG_POF_RECORD)
  				hysdn_addlog(card, "ERGO: pof boot success");
0d9ba869e   Amol Lad   [PATCH] drivers/i...
345
  			spin_lock_irqsave(&card->hysdn_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
346
347
348
349
350
351
352
353
354
355
356
  
  			card->state = CARD_STATE_RUN;	/* now card is running */
  			/* enable the cards interrupt */
  			byteout(card->iobase + PCI9050_INTR_REG,
  				bytein(card->iobase + PCI9050_INTR_REG) |
  			(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1));
  			card->irq_enabled = 1;	/* we are ready to receive interrupts */
  
  			dpr->ToPcFlag = 0;	/* reset data indicator */
  			dpr->ToHyInt = 1;
  			dpr->ToPcInt = 1;	/* interrupt to E1 for all cards */
0d9ba869e   Amol Lad   [PATCH] drivers/i...
357
  			spin_unlock_irqrestore(&card->hysdn_lock, flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
  			if ((hynet_enable & (1 << card->myid)) 
  			    && (i = hysdn_net_create(card))) 
  			{
  				ergo_stopcard(card);
  				card->state = CARD_STATE_BOOTERR;
  				return (i);
  			}
  #ifdef CONFIG_HYSDN_CAPI
  			if((i = hycapi_capi_create(card))) {
  				printk(KERN_WARNING "HYSDN: failed to create capi-interface.
  ");
  			}
  #endif /* CONFIG_HYSDN_CAPI */
  			return (0);	/* success */
  		}		/* data has arrived */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
  		msleep_interruptible(50);		/* Timeout 50ms */
  	}			/* wait until timeout */
  
  	if (card->debug_flags & LOG_POF_CARD)
  		hysdn_addlog(card, "ERGO: pof boot ready timeout");
  	return (-ERR_POF_TIMEOUT);
  }				/* ergo_waitpofready */
  
  
  
  /************************************************************************************/
  /* release the cards hardware. Before releasing do a interrupt disable and hardware */
  /* reset. Also unmap dpram.                                                         */
  /* Use only during module release.                                                  */
  /************************************************************************************/
  static void
  ergo_releasehardware(hysdn_card * card)
  {
  	ergo_stopcard(card);	/* first stop the card if not already done */
  	free_irq(card->irq, card);	/* release interrupt */
  	release_region(card->iobase + PCI9050_INTR_REG, 1);	/* release all io ports */
  	release_region(card->iobase + PCI9050_USER_IO, 1);
fca4edb48   Amol Lad   [PATCH] drivers/i...
395
  	iounmap(card->dpram);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
  	card->dpram = NULL;	/* release shared mem */
  }				/* ergo_releasehardware */
  
  
  /*********************************************************************************/
  /* acquire the needed hardware ports and map dpram. If an error occurs a nonzero */
  /* value is returned.                                                            */
  /* Use only during module init.                                                  */
  /*********************************************************************************/
  int
  ergo_inithardware(hysdn_card * card)
  {
  	if (!request_region(card->iobase + PCI9050_INTR_REG, 1, "HYSDN")) 
  		return (-1);
  	if (!request_region(card->iobase + PCI9050_USER_IO, 1, "HYSDN")) {
  		release_region(card->iobase + PCI9050_INTR_REG, 1);
  		return (-1);	/* ports already in use */
  	}
  	card->memend = card->membase + ERG_DPRAM_PAGE_SIZE - 1;
  	if (!(card->dpram = ioremap(card->membase, ERG_DPRAM_PAGE_SIZE))) {
  		release_region(card->iobase + PCI9050_INTR_REG, 1);
  		release_region(card->iobase + PCI9050_USER_IO, 1);
  		return (-1);
  	}
  
  	ergo_stopcard(card);	/* disable interrupts */
9ba02bec3   Thomas Gleixner   [PATCH] irq-flags...
422
  	if (request_irq(card->irq, ergo_interrupt, IRQF_SHARED, "HYSDN", card)) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
423
424
425
426
427
428
429
430
431
432
433
  		ergo_releasehardware(card); /* return the acquired hardware */
  		return (-1);
  	}
  	/* success, now setup the function pointers */
  	card->stopcard = ergo_stopcard;
  	card->releasehardware = ergo_releasehardware;
  	card->testram = ergo_testram;
  	card->writebootimg = ergo_writebootimg;
  	card->writebootseq = ergo_writebootseq;
  	card->waitpofready = ergo_waitpofready;
  	card->set_errlog_state = ergo_set_errlog_state;
3e577a80e   Al Viro   [PATCH] drivers/{...
434
  	INIT_WORK(&card->irq_queue, ergo_irq_bh);
2bd7e20e0   Thomas Gleixner   ISDN: Spinlock in...
435
  	spin_lock_init(&card->hysdn_lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
436
437
438
  
  	return (0);
  }				/* ergo_inithardware */