This source file includes following definitions.
- eata_scsi_done
- eata_fake_int_handler
- eata_release
- eata_int_handler
- eata_send_command
- eata_send_immediate
- eata_queue
- eata_abort
- eata_reset
- get_board_data
- check_blink_state
- get_conf_PIO
- print_config
- register_HBA
- find_EISA
- find_ISA
- find_PCI
- eata_detect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 #include <linux/module.h>
57
58 #include <linux/kernel.h>
59 #include <linux/sched.h>
60 #include <linux/string.h>
61 #include <linux/ioport.h>
62 #include <linux/malloc.h>
63 #include <linux/in.h>
64 #include <linux/bios32.h>
65 #include <linux/pci.h>
66 #include <linux/proc_fs.h>
67 #include <asm/byteorder.h>
68 #include <asm/types.h>
69 #include <asm/io.h>
70 #include <asm/dma.h>
71 #include <linux/blk.h>
72 #include "scsi.h"
73 #include "sd.h"
74 #include "hosts.h"
75 #include <linux/scsicam.h>
76 #include "eata_dma.h"
77 #include "eata_dma_proc.h"
78
79 #include <linux/stat.h>
80 #include <linux/config.h>
81
82 struct proc_dir_entry proc_scsi_eata_dma = {
83 PROC_SCSI_EATA, 8, "eata_dma",
84 S_IFDIR | S_IRUGO | S_IXUGO, 2
85 };
86
87 static u32 ISAbases[] =
88 {0x1F0, 0x170, 0x330, 0x230};
89 static unchar EISAbases[] =
90 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
91 static uint registered_HBAs = 0;
92 static struct Scsi_Host *last_HBA = NULL;
93 static struct Scsi_Host *first_HBA = NULL;
94 static unchar reg_IRQ[] =
95 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
96 static unchar reg_IRQL[] =
97 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
98 static struct eata_sp *status = 0;
99 static void *dma_scratch = 0;
100
101 static u32 fake_int_base;
102 static int fake_int_result;
103 static int fake_int_happened;
104
105 static ulong int_counter = 0;
106 static ulong queue_counter = 0;
107
108 void eata_scsi_done (Scsi_Cmnd * scmd)
109 {
110 scmd->request.rq_status = RQ_SCSI_DONE;
111
112 if (scmd->request.sem != NULL)
113 up(scmd->request.sem);
114
115 return;
116 }
117
118 void eata_fake_int_handler(s32 irq, struct pt_regs * regs)
119 {
120 fake_int_result = inb(fake_int_base + HA_RSTATUS);
121 fake_int_happened = TRUE;
122 DBG(DBG_INTR3, printk("eata_fake_int_handler called irq%d base %#x"
123 " res %#x\n", irq, fake_int_base, fake_int_result));
124 return;
125 }
126
127 #include "eata_dma_proc.c"
128
129 #ifdef MODULE
130 int eata_release(struct Scsi_Host *sh)
131 {
132 uint i;
133 if (sh->irq && reg_IRQ[sh->irq] == 1) free_irq(sh->irq);
134 else reg_IRQ[sh->irq]--;
135
136 scsi_init_free((void *)status, 512);
137 scsi_init_free((void *)dma_scratch, 512);
138 for (i = 0; i < sh->can_queue; i++){
139 if(SD(sh)->ccb[i].sg_list != NULL)
140 scsi_init_free((void *) SD(sh)->ccb[i].sg_list,
141 sh->sg_tablesize * sizeof(struct eata_sg_list));
142 }
143
144 if (SD(sh)->channel == 0) {
145 if (sh->dma_channel != BUSMASTER) free_dma(sh->dma_channel);
146 if (sh->io_port && sh->n_io_port)
147 release_region(sh->io_port, sh->n_io_port);
148 }
149 return(TRUE);
150 }
151 #endif
152
153
154 void eata_int_handler(int irq, struct pt_regs * regs)
155 {
156 uint i, result = 0;
157 uint hba_stat, scsi_stat, eata_stat;
158 Scsi_Cmnd *cmd;
159 struct eata_ccb *cp;
160 struct eata_sp *sp;
161 uint base;
162 ulong flags;
163 uint x;
164 struct Scsi_Host *sh;
165
166 save_flags(flags);
167 cli();
168
169 for (x = 1, sh = first_HBA; x <= registered_HBAs; x++, sh = SD(sh)->prev) {
170 if (sh->irq != irq)
171 continue;
172 if (!(inb((uint)sh->base + HA_RAUXSTAT) & HA_AIRQ))
173 continue;
174
175 int_counter++;
176
177 sp=&SD(sh)->sp;
178
179 if((cp = sp->ccb) == NULL) {
180 eata_stat = inb(base + HA_RSTATUS);
181 printk("eata_dma: Board: %x Spurious IRQ %lx "
182 "received. CCB pointer not set.\n", base, (long)cp);
183 restore_flags(flags);
184 return;
185 }
186 cmd = cp->cmd;
187 base = (uint) cmd->host->base;
188
189 hba_stat = sp->hba_stat;
190
191 scsi_stat = (sp->scsi_stat >> 1) & 0x1f;
192
193 if (sp->EOC == FALSE) {
194 eata_stat = inb(base + HA_RSTATUS);
195 printk("eata_dma: int_handler, board: %x cmd %lx returned "
196 "unfinished.\nEATA: %x HBA: %x SCSI: %x spadr %lx spadrirq "
197 "%lx, irq%d\n", base, (long)cp, eata_stat, hba_stat,
198 scsi_stat,(long)&status, (long)&status[irq], irq);
199 DBG(DBG_DELAY, DEL2(800));
200 restore_flags(flags);
201 return;
202 }
203
204 if (cp->status == LOCKED) {
205 cp->status = FREE;
206 eata_stat = inb(base + HA_RSTATUS);
207 printk("eata_dma: int_handler, freeing locked queueslot\n");
208 DBG(DBG_INTR && DBG_DELAY, DEL2(800));
209 restore_flags(flags);
210 return;
211 }
212
213 eata_stat = inb(base + HA_RSTATUS);
214 DBG(DBG_INTR, printk("IRQ %d received, base %#.4x, pid %ld, target: "
215 "%x, lun: %x, ea_s: %#.2x, hba_s: %#.2x \n",
216 irq, base, cmd->pid, cmd->target, cmd->lun,
217 eata_stat, hba_stat));
218
219 switch (hba_stat) {
220 case HA_NO_ERROR:
221 if (scsi_stat == CONDITION_GOOD
222 && cmd->device->type == TYPE_DISK
223 && (HD(cmd)->t_state[cp->cp_channel][cp->cp_id] == RESET))
224 result = DID_BUS_BUSY << 16;
225 else if (scsi_stat == GOOD) {
226 HD(cmd)->t_state[cp->cp_channel][cp->cp_id] = OK;
227 if(HD(cmd)->do_latency == TRUE && cp->timestamp) {
228 uint time;
229 time = jiffies - cp->timestamp;
230 if((cp->rw_latency) == TRUE) {
231 if(HD(cmd)->writes_lat[cp->sizeindex][1] > time)
232 HD(cmd)->writes_lat[cp->sizeindex][1] = time;
233 if(HD(cmd)->writes_lat[cp->sizeindex][2] < time)
234 HD(cmd)->writes_lat[cp->sizeindex][2] = time;
235 HD(cmd)->writes_lat[cp->sizeindex][3] += time;
236 HD(cmd)->writes_lat[cp->sizeindex][0]++;
237 } else {
238 if(HD(cmd)->reads_lat[cp->sizeindex][1] > time)
239 HD(cmd)->reads_lat[cp->sizeindex][1] = time;
240 if(HD(cmd)->reads_lat[cp->sizeindex][2] < time)
241 HD(cmd)->reads_lat[cp->sizeindex][2] = time;
242 HD(cmd)->reads_lat[cp->sizeindex][3] += time;
243 HD(cmd)->reads_lat[cp->sizeindex][0]++;
244 }
245 }
246 }
247 else if (scsi_stat == CHECK_CONDITION
248 && cmd->device->type == TYPE_DISK
249 && (cmd->sense_buffer[2] & 0xf) == RECOVERED_ERROR)
250 result = DID_BUS_BUSY << 16;
251 else
252 result = DID_OK << 16;
253 HD(cmd)->t_timeout[cp->cp_channel][cp->cp_id] = OK;
254 break;
255 case HA_ERR_SEL_TO:
256 result = DID_BAD_TARGET << 16;
257 break;
258 case HA_ERR_CMD_TO:
259 if (HD(cmd)->t_timeout[cp->cp_channel][cp->cp_id] > 1)
260 result = DID_ERROR << 16;
261 else {
262 result = DID_TIME_OUT << 16;
263 HD(cmd)->t_timeout[cp->cp_channel][cp->cp_id]++;
264 }
265 break;
266 case HA_ERR_RESET:
267 case HA_INIT_POWERUP:
268 if (cmd->device->type != TYPE_TAPE)
269 result = DID_BUS_BUSY << 16;
270 else
271 result = DID_ERROR << 16;
272
273 for (i = 0; i < MAXTARGET; i++)
274 HD(cmd)->t_state[cp->cp_channel][i] = RESET;
275 break;
276 case HA_UNX_BUSPHASE:
277 case HA_UNX_BUS_FREE:
278 case HA_BUS_PARITY:
279 case HA_SCSI_HUNG:
280 case HA_UNX_MSGRJCT:
281 case HA_RESET_STUCK:
282 case HA_RSENSE_FAIL:
283 case HA_PARITY_ERR:
284 default:
285 result = DID_ERROR << 16;
286 break;
287 }
288 cmd->result = result | (scsi_stat << 1);
289
290 #if DBG_INTR2
291 if (scsi_stat || result || hba_stat || eata_stat != 0x50
292 || cmd->scsi_done == NULL || cmd->device->id == 7)
293 printk("HBA: %d, channel %d, id: %d, lun %d, pid %ld:\n"
294 "eata_stat %#x, hba_stat %#.2x, scsi_stat %#.2x, "
295 "sense_key: %#x, result: %#.8x\n",
296 x, cmd->device->channel, cmd->device->id, cmd->device->lun,
297 cmd->pid, eata_stat, hba_stat, scsi_stat,
298 cmd->sense_buffer[2] & 0xf, cmd->result);
299 DBG(DBG_INTR&&DBG_DELAY,DEL2(800));
300 #endif
301
302 cp->status = FREE;
303 cmd->scsi_done(cmd);
304 }
305 restore_flags(flags);
306
307 return;
308 }
309
310 inline int eata_send_command(u32 addr, u32 base, u8 command)
311 {
312 long loop = R_LIMIT;
313
314 while (inb(base + HA_RAUXSTAT) & HA_ABUSY)
315 if (--loop == 0)
316 return(FALSE);
317
318
319 outb( addr & 0x000000ff, base + HA_WDMAADDR);
320 outb((addr & 0x0000ff00) >> 8, base + HA_WDMAADDR + 1);
321 outb((addr & 0x00ff0000) >> 16, base + HA_WDMAADDR + 2);
322 outb((addr & 0xff000000) >> 24, base + HA_WDMAADDR + 3);
323 outb(command, base + HA_WCOMMAND);
324 return(TRUE);
325 }
326
327 #if 0
328 inline int eata_send_immediate(u32 addr, u32 base, u8 cmnd, u8 cmnd2, u8 id,
329 u8 lun)
330 {
331 if(addr){
332 outb( addr & 0x000000ff, base + HA_WDMAADDR);
333 outb((addr & 0x0000ff00) >> 8, base + HA_WDMAADDR + 1);
334 outb((addr & 0x00ff0000) >> 16, base + HA_WDMAADDR + 2);
335 outb((addr & 0xff000000) >> 24, base + HA_WDMAADDR + 3);
336 } else {
337 outb(id, base + HA_WSUBCODE);
338 outb(lun, base + HA_WSUBLUN);
339 }
340
341 outb(cmnd2, base + HA_WCOMMAND2);
342 outb(cmnd, base + HA_WCOMMAND);
343 return(TRUE);
344 }
345 #endif
346
347 int eata_queue(Scsi_Cmnd * cmd, void (* done) (Scsi_Cmnd *))
348 {
349 unsigned int i, x, y;
350 u32 flags;
351 hostdata *hd;
352 struct Scsi_Host *sh;
353 struct eata_ccb *cp;
354 struct scatterlist *sl;
355
356 save_flags(flags);
357 cli();
358
359 queue_counter++;
360
361 hd = HD(cmd);
362 sh = cmd->host;
363
364
365 for (y = hd->last_ccb + 1, x = 0; x < sh->can_queue; x++, y++) {
366 if (y >= sh->can_queue)
367 y = 0;
368 if (hd->ccb[y].status == FREE)
369 break;
370 }
371
372 hd->last_ccb = y;
373
374 if (x >= sh->can_queue) {
375 uint z;
376
377 printk(KERN_EMERG "eata_dma: run out of queue slots cmdno:%ld"
378 " intrno: %ld, can_queue: %d, x: %d, y: %d\n",
379 queue_counter, int_counter, sh->can_queue, x, y);
380 printk(KERN_EMERG "Status of queueslots:");
381 for(z = 0; z < sh->can_queue; z +=2) {
382 switch(hd->ccb[z].status) {
383 case FREE:
384 printk(KERN_EMERG "Slot %2d is FREE \t", z);
385 break;
386 case USED:
387 printk(KERN_EMERG "Slot %2d is USED \t", z);
388 break;
389 case LOCKED:
390 printk(KERN_EMERG "Slot %2d is LOCKED\t", z);
391 break;
392 default:
393 printk(KERN_EMERG "Slot %2d is UNKNOWN\t", z);
394 }
395 panic("\nSystem halted.\n");
396 }
397 }
398 cp = &hd->ccb[y];
399
400 memset(cp, 0, sizeof(struct eata_ccb) - sizeof(struct eata_sg_list *));
401
402 cp->status = USED;
403
404 DBG(DBG_QUEUE, printk("eata_queue pid %ld, target: %x, lun: %x, y %d\n",
405 cmd->pid, cmd->target, cmd->lun, y));
406 DBG(DBG_QUEUE && DBG_DELAY, DEL2(250));
407
408 if(hd->do_latency == TRUE) {
409 int x, z;
410 short *sho;
411 long *lon;
412 x = 0;
413 if (cmd->cmnd[0] == WRITE_6 || cmd->cmnd[0] == WRITE_10 ||
414 cmd->cmnd[0] == WRITE_12 || cmd->cmnd[0] == READ_6 ||
415 cmd->cmnd[0] == READ_10 || cmd->cmnd[0] == READ_12) {
416
417 cp->timestamp = jiffies;
418 switch(cmd->cmnd[0]) {
419 case WRITE_6:
420 case READ_6:
421 x = cmd->cmnd[4]/2;
422 break;
423 case WRITE_10:
424 case READ_10:
425 sho = (short *) &cmd->cmnd[7];
426 x = ntohs(*sho)/2;
427 break;
428 case WRITE_12:
429 case READ_12:
430 lon = (long *) &cmd->cmnd[6];
431 x = ntohl(*lon)/2;
432 break;
433 }
434
435 for(z = 0; (x > (1 << z)) && (z <= 11); z++)
436 ;
437 cp->sizeindex = z;
438 if (cmd->cmnd[0] == WRITE_6 || cmd->cmnd[0] == WRITE_10 ||
439 cmd->cmnd[0] == WRITE_12){
440 cp->rw_latency = TRUE;
441 }
442 }
443 }
444 cmd->scsi_done = (void *)done;
445
446 switch (cmd->cmnd[0]) {
447 case CHANGE_DEFINITION: case COMPARE: case COPY:
448 case COPY_VERIFY: case LOG_SELECT: case MODE_SELECT:
449 case MODE_SELECT_10: case SEND_DIAGNOSTIC: case WRITE_BUFFER:
450 case FORMAT_UNIT: case REASSIGN_BLOCKS: case RESERVE:
451 case SEARCH_EQUAL: case SEARCH_HIGH: case SEARCH_LOW:
452 case WRITE_6: case WRITE_10: case WRITE_VERIFY:
453 case UPDATE_BLOCK: case WRITE_LONG: case WRITE_SAME:
454 case SEARCH_HIGH_12: case SEARCH_EQUAL_12: case SEARCH_LOW_12:
455 case WRITE_12: case WRITE_VERIFY_12: case SET_WINDOW:
456 case MEDIUM_SCAN: case SEND_VOLUME_TAG:
457 case 0xea:
458 cp->DataOut = TRUE;
459 break;
460 case TEST_UNIT_READY:
461 default:
462 cp->DataIn = TRUE;
463 }
464
465
466
467
468 if (cmd->target == sh->this_id)
469 cp->Interpret = TRUE;
470
471 if (cmd->use_sg) {
472 cp->scatter = TRUE;
473 if (cp->sg_list == NULL) {
474 cp->sg_list = kmalloc(SG_SIZE_BIG*sizeof(struct eata_sg_list),
475 GFP_ATOMIC | GFP_DMA);
476 }
477 if (cp->sg_list == NULL)
478 panic("eata_dma: Run out of DMA memory for SG lists !\n");
479 cp->cp_dataDMA = htonl(virt_to_bus(cp->sg_list));
480
481 cp->cp_datalen = htonl(cmd->use_sg * sizeof(struct eata_sg_list));
482 sl=(struct scatterlist *)cmd->request_buffer;
483 for(i = 0; i < cmd->use_sg; i++, sl++){
484 cp->sg_list[i].data = htonl(virt_to_bus(sl->address));
485 cp->sg_list[i].len = htonl((u32) sl->length);
486 }
487 } else {
488 cp->scatter = FALSE;
489 cp->cp_datalen = htonl(cmd->request_bufflen);
490 cp->cp_dataDMA = htonl(virt_to_bus(cmd->request_buffer));
491 }
492
493 cp->Auto_Req_Sen = TRUE;
494 cp->cp_reqDMA = htonl(virt_to_bus(cmd->sense_buffer));
495 cp->reqlen = sizeof(cmd->sense_buffer);
496
497 cp->cp_id = cmd->target;
498 cp->cp_channel = cmd->channel;
499 cp->cp_lun = cmd->lun;
500 cp->cp_dispri = TRUE;
501 cp->cp_identify = TRUE;
502 memcpy(cp->cp_cdb, cmd->cmnd, cmd->cmd_len);
503
504 cp->cp_statDMA = htonl(virt_to_bus(&(hd->sp)));
505
506 cp->cp_viraddr = cp;
507
508 cp->cmd = cmd;
509 cmd->host_scribble = (char *)&hd->ccb[y];
510
511 if(eata_send_command((u32) cp, (u32) sh->base, EATA_CMD_DMA_SEND_CP) == FALSE) {
512 cmd->result = DID_BUS_BUSY << 16;
513 DBG(DBG_QUEUE && DBG_ABNORM,
514 printk("eata_queue target %d, pid %ld, HBA busy, "
515 "returning DID_BUS_BUSY\n",cmd->target, cmd->pid));
516 done(cmd);
517 cp->status = FREE;
518 restore_flags(flags);
519 return(0);
520 }
521 DBG(DBG_QUEUE, printk("Queued base %#.4x pid: %ld target: %x lun: %x "
522 "slot %d irq %d\n", (s32)sh->base, cmd->pid,
523 cmd->target, cmd->lun, y, sh->irq));
524 DBG(DBG_QUEUE && DBG_DELAY, DEL2(200));
525 restore_flags(flags);
526 return(0);
527 }
528
529
530 int eata_abort(Scsi_Cmnd * cmd)
531 {
532 ulong flags;
533 ulong loop = R_LIMIT;
534
535 save_flags(flags);
536 cli();
537
538 DBG(DBG_ABNORM, printk("eata_abort called pid: %ld target: %x lun: %x"
539 " reason %x\n", cmd->pid, cmd->target, cmd->lun,
540 cmd->abort_reason));
541 DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
542
543
544 while (inb((u32)(cmd->host->base) + HA_RAUXSTAT) & HA_ABUSY)
545 if (--loop == 0) {
546 printk("eata_dma: abort, timeout error.\n");
547 restore_flags(flags);
548 DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
549 return (SCSI_ABORT_ERROR);
550 }
551 if (CD(cmd)->status == USED) {
552 DBG(DBG_ABNORM, printk("Returning: SCSI_ABORT_BUSY\n"));
553 restore_flags(flags);
554 return (SCSI_ABORT_BUSY);
555 }
556 if (CD(cmd)->status == FREE) {
557 DBG(DBG_ABNORM, printk("Returning: SCSI_ABORT_NOT_RUNNING\n"));
558 restore_flags(flags);
559 return (SCSI_ABORT_NOT_RUNNING);
560 }
561 if (CD(cmd)->status == RESET) {
562 restore_flags(flags);
563 printk("eata_dma: abort, command reset error.\n");
564 DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
565 return (SCSI_ABORT_ERROR);
566 }
567 if (CD(cmd)->status == LOCKED) {
568 restore_flags(flags);
569 DBG(DBG_ABNORM, printk("eata_dma: abort, queue slot locked.\n"));
570 DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
571 return (SCSI_ABORT_NOT_RUNNING);
572 }
573 restore_flags(flags);
574 panic("eata_dma: abort: invalid slot status\n");
575 }
576
577 int eata_reset(Scsi_Cmnd * cmd)
578 {
579 ushort x, z;
580 ulong time, limit = 0;
581 ulong loop = R_LIMIT;
582 ulong flags;
583 unchar success = FALSE;
584 Scsi_Cmnd *sp;
585
586 save_flags(flags);
587 cli();
588
589 DBG(DBG_ABNORM, printk("eata_reset called pid:%ld target: %x lun: %x"
590 " reason %x\n", cmd->pid, cmd->target, cmd->lun,
591 cmd->abort_reason));
592
593 if (HD(cmd)->state == RESET) {
594 printk("eata_reset: exit, already in reset.\n");
595 restore_flags(flags);
596 DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
597 return (SCSI_RESET_ERROR);
598 }
599
600 while (inb((u32)(cmd->host->base) + HA_RAUXSTAT) & HA_ABUSY)
601 if (--loop == 0) {
602 printk("eata_reset: exit, timeout error.\n");
603 restore_flags(flags);
604 DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
605 return (SCSI_RESET_ERROR);
606 }
607
608 for (x = 0; x < MAXCHANNEL; x++) {
609 for (z = 0; z < MAXTARGET; z++) {
610 HD(cmd)->t_state[x][z] = RESET;
611 HD(cmd)->t_timeout[x][z] = NO_TIMEOUT;
612 }
613 }
614
615 for (x = 0; x < cmd->host->can_queue; x++) {
616 if (HD(cmd)->ccb[x].status == FREE)
617 continue;
618
619 if (HD(cmd)->ccb[x].status == LOCKED) {
620 HD(cmd)->ccb[x].status = FREE;
621 printk("eata_reset: locked slot %d forced free.\n", x);
622 DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
623 continue;
624 }
625 sp = HD(cmd)->ccb[x].cmd;
626 HD(cmd)->ccb[x].status = RESET;
627 printk("eata_reset: slot %d in reset, pid %ld.\n", x, sp->pid);
628 DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
629
630 if (sp == NULL)
631 panic("eata_reset: slot %d, sp==NULL.\n", x);
632 DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
633
634 if (sp == cmd)
635 success = TRUE;
636 }
637
638
639 inb((u32) (cmd->host->base) + HA_RSTATUS);
640 eata_send_command(0, (u32) cmd->host->base, EATA_CMD_RESET);
641
642 DBG(DBG_ABNORM, printk("eata_reset: board reset done, enabling interrupts.\n"));
643 HD(cmd)->state = RESET;
644
645 restore_flags(flags);
646
647 time = jiffies;
648 while (jiffies < (time + (3 * HZ)) || limit++ < 10000000)
649 ;
650
651 save_flags(flags);
652 cli();
653
654 DBG(DBG_ABNORM, printk("eata_reset: interrupts disabled, loops %ld.\n",
655 limit));
656 DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
657
658 for (x = 0; x < cmd->host->can_queue; x++) {
659
660
661 if (HD(cmd)->ccb[x].status != RESET)
662 continue;
663
664 sp = HD(cmd)->ccb[x].cmd;
665 sp->result = DID_RESET << 16;
666
667
668 HD(cmd)->ccb[x].status = LOCKED;
669
670 printk("eata_reset: slot %d locked, DID_RESET, pid %ld done.\n",
671 x, sp->pid);
672 DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
673 restore_flags(flags);
674 sp->scsi_done(sp);
675 cli();
676 }
677
678 HD(cmd)->state = FALSE;
679 restore_flags(flags);
680
681 if (success) {
682 DBG(DBG_ABNORM, printk("eata_reset: exit, success.\n"));
683 DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
684 return (SCSI_RESET_SUCCESS);
685 } else {
686 DBG(DBG_ABNORM, printk("eata_reset: exit, wakeup.\n"));
687 DBG(DBG_ABNORM && DBG_DELAY, DEL2(500));
688 return (SCSI_RESET_PUNT);
689 }
690 }
691
692 char * get_board_data(u32 base, u32 irq, u32 id)
693 {
694 struct eata_ccb *cp;
695 struct eata_sp *sp;
696 static char *buff;
697 ulong i;
698 ulong limit = 0;
699
700 cp = (struct eata_ccb *) scsi_init_malloc(sizeof(struct eata_ccb),
701 GFP_ATOMIC | GFP_DMA);
702 sp = (struct eata_sp *) scsi_init_malloc(sizeof(struct eata_sp),
703 GFP_ATOMIC | GFP_DMA);
704
705 buff = dma_scratch;
706
707 memset(cp, 0, sizeof(struct eata_ccb));
708 memset(sp, 0, sizeof(struct eata_sp));
709 memset(buff, 0, 256);
710
711 cp->DataIn = TRUE;
712 cp->Interpret = TRUE;
713 cp->cp_dispri = TRUE;
714 cp->cp_identify = TRUE;
715
716 cp->cp_datalen = htonl(56);
717 cp->cp_dataDMA = htonl(virt_to_bus(buff));
718 cp->cp_statDMA = htonl(virt_to_bus(sp));
719 cp->cp_viraddr = cp;
720
721 cp->cp_id = id;
722 cp->cp_lun = 0;
723
724 cp->cp_cdb[0] = INQUIRY;
725 cp->cp_cdb[1] = 0;
726 cp->cp_cdb[2] = 0;
727 cp->cp_cdb[3] = 0;
728 cp->cp_cdb[4] = 56;
729 cp->cp_cdb[5] = 0;
730
731 fake_int_base = base;
732 fake_int_result = FALSE;
733 fake_int_happened = FALSE;
734
735 eata_send_command((u32) cp, (u32) base, EATA_CMD_DMA_SEND_CP);
736
737 i = jiffies + (3 * HZ);
738 while (fake_int_happened == FALSE && jiffies <= i)
739 barrier();
740
741 DBG(DBG_INTR3, printk("fake_int_result: %#x hbastat %#x scsistat %#x,"
742 " buff %p sp %p\n",
743 fake_int_result, (u32) (sp->hba_stat ),
744 (u32) sp->scsi_stat, buff, sp));
745
746 scsi_init_free((void *)cp, sizeof(struct eata_ccb));
747 scsi_init_free((void *)sp, sizeof(struct eata_sp));
748
749 if ((fake_int_result & HA_SERROR) || jiffies > i){
750
751 inb((u32) (base) + HA_RSTATUS);
752 eata_send_command(0, base, EATA_CMD_RESET);
753 i = jiffies;
754 while (jiffies < (i + (3 * HZ)) && limit++ < 10000000)
755 barrier();
756 return (NULL);
757 } else
758 return (buff);
759 }
760
761 int check_blink_state(long base)
762 {
763 ushort loops = 10;
764 u32 blinkindicator;
765 u32 state = 0x12345678;
766 u32 oldstate = 0;
767
768 blinkindicator = htonl(0x54504442);
769 while ((loops--) && (state != oldstate)) {
770 oldstate = state;
771 state = inl((uint) base + 1);
772 }
773
774 DBG(DBG_BLINK, printk("Did Blink check. Status: %d\n",
775 (state == oldstate) && (state == blinkindicator)));
776
777 if ((state == oldstate) && (state == blinkindicator))
778 return(TRUE);
779 else
780 return (FALSE);
781 }
782
783 int get_conf_PIO(u32 base, struct get_conf *buf)
784 {
785 ulong loop = R_LIMIT;
786 u16 *p;
787
788 if(check_region(base, 9))
789 return (FALSE);
790
791 memset(buf, 0, sizeof(struct get_conf));
792
793 while (inb(base + HA_RSTATUS) & HA_SBUSY)
794 if (--loop == 0)
795 return (FALSE);
796
797 DBG(DBG_PIO && DBG_PROBE,
798 printk("Issuing PIO READ CONFIG to HBA at %#x\n", base));
799 eata_send_command(0, base, EATA_CMD_PIO_READ_CONFIG);
800
801 loop = R_LIMIT;
802 for (p = (u16 *) buf;
803 (long)p <= ((long)buf + (sizeof(struct get_conf) / 2)); p++) {
804 while (!(inb(base + HA_RSTATUS) & HA_SDRQ))
805 if (--loop == 0)
806 return (FALSE);
807
808 loop = R_LIMIT;
809 *p = inw(base + HA_RDATA);
810 }
811
812 if (!(inb(base + HA_RSTATUS) & HA_SERROR)) {
813 if (htonl(EATA_SIGNATURE) == buf->signature) {
814 DBG(DBG_PIO&&DBG_PROBE, printk("EATA Controller found at %x "
815 "EATA Level: %x\n", (uint) base,
816 (uint) (buf->version)));
817
818 while (inb(base + HA_RSTATUS) & HA_SDRQ)
819 inw(base + HA_RDATA);
820 return (TRUE);
821 }
822 } else {
823 DBG(DBG_PROBE, printk("eata_dma: get_conf_PIO, error during transfer "
824 "for HBA at %lx\n", (long)base));
825 }
826 return (FALSE);
827 }
828
829 void print_config(struct get_conf *gc)
830 {
831 printk("Please check values: (read config data)\n");
832 printk("LEN: %d ver:%d OCS:%d TAR:%d TRNXFR:%d MORES:%d DMAS:%d\n",
833 (u32) ntohl(gc->len), gc->version,
834 gc->OCS_enabled, gc->TAR_support, gc->TRNXFR, gc->MORE_support,
835 gc->DMA_support);
836 printk("DMAV:%d HAAV:%d SCSIID0:%d ID1:%d ID2:%d QUEUE:%d SG:%d SEC:%d\n",
837 gc->DMA_valid, gc->HAA_valid, gc->scsi_id[3], gc->scsi_id[2],
838 gc->scsi_id[1], ntohs(gc->queuesiz), ntohs(gc->SGsiz), gc->SECOND);
839 printk("IRQ:%d IRQT:%d DMAC:%d FORCADR:%d SG_64K:%d SG_UAE:%d MID:%d "
840 "MCH:%d MLUN:%d\n",
841 gc->IRQ, gc->IRQ_TR, (8 - gc->DMA_channel) & 7, gc->FORCADR,
842 gc->SG_64K, gc->SG_UAE, gc->MAX_ID, gc->MAX_CHAN, gc->MAX_LUN);
843 printk("RIDQ:%d PCI:%d EISA:%d\n",
844 gc->ID_qest, gc->is_PCI, gc->is_EISA);
845 DBG(DPT_DEBUG, DELAY(14));
846 }
847
848 short register_HBA(u32 base, struct get_conf *gc, Scsi_Host_Template * tpnt,
849 u8 bustype)
850 {
851 ulong size = 0;
852 unchar dma_channel = 0;
853 char *buff = 0;
854 unchar bugs = 0;
855 struct Scsi_Host *sh;
856 hostdata *hd;
857 int x;
858
859
860 DBG(DBG_REGISTER, print_config(gc));
861
862 if (gc->DMA_support == FALSE) {
863 printk("The EATA HBA at %#.4x does not support DMA.\n"
864 "Please use the EATA-PIO driver.\n", base);
865 return (FALSE);
866 }
867 if(gc->HAA_valid == FALSE || ntohl(gc->len) < 0x22)
868 gc->MAX_CHAN = 0;
869
870 if (reg_IRQ[gc->IRQ] == FALSE) {
871 if (!request_irq(gc->IRQ, (void *) eata_fake_int_handler, SA_INTERRUPT,
872 "eata_dma")){
873 reg_IRQ[gc->IRQ]++;
874 if (!gc->IRQ_TR)
875 reg_IRQL[gc->IRQ] = TRUE;
876 } else {
877 printk("Couldn't allocate IRQ %d, Sorry.", gc->IRQ);
878 return (FALSE);
879 }
880 } else {
881 if (reg_IRQL[gc->IRQ] == TRUE) {
882 printk("Can't support more than one HBA on this IRQ,\n"
883 " if the IRQ is edge triggered. Sorry.\n");
884 return (FALSE);
885 } else
886 reg_IRQ[gc->IRQ]++;
887 }
888
889
890 dma_channel = BUSMASTER;
891 if (gc->DMA_valid) {
892 if (request_dma(dma_channel = (8 - gc->DMA_channel) & 7, "eata_dma")) {
893 printk("Unable to allocate DMA channel %d for ISA HBA at %#.4x.\n",
894 dma_channel, base);
895 reg_IRQ[gc->IRQ]--;
896 if (reg_IRQ[gc->IRQ] == 0)
897 free_irq(gc->IRQ);
898 if (gc->IRQ_TR == FALSE)
899 reg_IRQL[gc->IRQ] = FALSE;
900 return (FALSE);
901 }
902 }
903
904 #if !(NEWSTUFF)
905 if (bustype != IS_EISA && bustype != IS_ISA)
906 #endif
907 buff = get_board_data(base, gc->IRQ, gc->scsi_id[3]);
908
909 if (buff == NULL) {
910 #if !(NEWSTUFF)
911 if (bustype == IS_EISA || bustype == IS_ISA) {
912 bugs = bugs || BROKEN_INQUIRY;
913 } else {
914 #endif
915 if (gc->DMA_support == FALSE)
916 printk("HBA at %#.4x doesn't support DMA. Sorry\n", base);
917 else
918 printk("HBA at %#.4x does not react on INQUIRY. Sorry.\n",
919 base);
920 if (gc->DMA_valid)
921 free_dma(dma_channel);
922 reg_IRQ[gc->IRQ]--;
923 if (reg_IRQ[gc->IRQ] == 0)
924 free_irq(gc->IRQ);
925 if (gc->IRQ_TR == FALSE)
926 reg_IRQL[gc->IRQ] = FALSE;
927 return (FALSE);
928 #if !(NEWSTUFF)
929 }
930 #endif
931 }
932
933 if (gc->DMA_support == FALSE && buff != NULL)
934 printk("HBA %.12sat %#.4x doesn't set the DMA_support flag correctly.\n",
935 &buff[16], base);
936
937 request_region(base, 9, "eata_dma");
938
939
940
941
942 if(ntohs(gc->queuesiz) == 0) {
943 gc->queuesiz = ntohs(64);
944 printk("Warning: Queue size has to be corrected. Assuming 64 queueslots\n"
945 " This might be a PM2012B with a defective Firmware\n");
946 }
947
948 size = sizeof(hostdata) + ((sizeof(struct eata_ccb) + sizeof(long))
949 * ntohs(gc->queuesiz));
950
951 DBG(DBG_REGISTER, printk("scsi_register size: %ld\n", size));
952
953 sh = scsi_register(tpnt, size);
954
955 if(sh == NULL) {
956 if (gc->DMA_valid)
957 free_dma(dma_channel);
958
959 reg_IRQ[gc->IRQ]--;
960 if (reg_IRQ[gc->IRQ] == 0)
961 free_irq(gc->IRQ);
962 if (gc->IRQ_TR == FALSE)
963 reg_IRQL[gc->IRQ] = FALSE;
964 return (FALSE);
965 }
966
967 hd = SD(sh);
968
969 memset(hd->ccb, 0, sizeof(struct eata_ccb) * ntohs(gc->queuesiz));
970 memset(hd->reads, 0, sizeof(u32) * 26);
971
972 hd->broken_INQUIRY = (bugs & BROKEN_INQUIRY);
973
974 if(hd->broken_INQUIRY == TRUE) {
975 strcpy(SD(sh)->vendor, "DPT");
976 strcpy(SD(sh)->name, "??????????");
977 strcpy(SD(sh)->revision, "???.?");
978 } else {
979 strncpy(SD(sh)->vendor, &buff[8], 8);
980 SD(sh)->vendor[8] = 0;
981 strncpy(SD(sh)->name, &buff[16], 17);
982 SD(sh)->name[17] = 0;
983 SD(sh)->revision[0] = buff[32];
984 SD(sh)->revision[1] = buff[33];
985 SD(sh)->revision[2] = buff[34];
986 SD(sh)->revision[3] = '.';
987 SD(sh)->revision[4] = buff[35];
988 SD(sh)->revision[5] = 0;
989 }
990
991 switch (ntohl(gc->len)) {
992 case 0x1c:
993 SD(sh)->EATA_revision = 'a';
994 break;
995 case 0x1e:
996 SD(sh)->EATA_revision = 'b';
997 break;
998 case 0x22:
999 SD(sh)->EATA_revision = 'c';
1000 break;
1001 case 0x24:
1002 SD(sh)->EATA_revision = 'z';
1003 default:
1004 SD(sh)->EATA_revision = '?';
1005 }
1006
1007 if(ntohl(gc->len) >= 0x22) {
1008 if (gc->is_PCI == TRUE)
1009 hd->bustype = IS_PCI;
1010 else if (gc->is_EISA == TRUE)
1011 hd->bustype = IS_EISA;
1012 else
1013 hd->bustype = IS_ISA;
1014 } else if(hd->broken_INQUIRY == FALSE) {
1015 if (buff[21] == '4')
1016 hd->bustype = IS_PCI;
1017 else if (buff[21] == '2')
1018 hd->bustype = IS_EISA;
1019 else
1020 hd->bustype = IS_ISA;
1021 } else
1022 hd->bustype = bustype;
1023
1024 if(ntohl(gc->len) >= 0x22) {
1025 sh->max_id = gc->MAX_ID + 1;
1026 sh->max_lun = gc->MAX_LUN + 1;
1027 } else {
1028 sh->max_id = 8;
1029 sh->max_lun = 8;
1030 }
1031
1032 hd->channel = gc->MAX_CHAN;
1033 sh->max_channel = gc->MAX_CHAN;
1034 sh->unique_id = base;
1035 sh->base = (char *) base;
1036 sh->io_port = base;
1037 sh->n_io_port = 9;
1038 sh->irq = gc->IRQ;
1039 sh->dma_channel = dma_channel;
1040
1041
1042
1043
1044 sh->this_id = gc->scsi_id[3];
1045 sh->can_queue = ntohs(gc->queuesiz);
1046
1047 if (gc->OCS_enabled == TRUE) {
1048 if(hd->bustype != IS_ISA)
1049 sh->cmd_per_lun = sh->can_queue/C_P_L_DIV;
1050 else
1051 sh->cmd_per_lun = 8;
1052
1053
1054 } else
1055 sh->cmd_per_lun = 1;
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065 if (gc->SG_64K == TRUE && ntohs(gc->SGsiz) == 64 && hd->bustype != IS_ISA){
1066 sh->sg_tablesize = SG_SIZE_BIG;
1067 sh->use_clustering = FALSE;
1068 } else {
1069 sh->sg_tablesize = ntohs(gc->SGsiz);
1070 sh->use_clustering = TRUE;
1071 if (sh->sg_tablesize > SG_SIZE || sh->sg_tablesize == 0) {
1072 sh->sg_tablesize = SG_SIZE;
1073 if (ntohs(gc->SGsiz) == 0)
1074 printk("Warning: SG size had to be corrected.\n"
1075 "This might be a PM2012 with a defective Firmware\n");
1076 }
1077 }
1078
1079 if (gc->SECOND)
1080 hd->primary = FALSE;
1081 else
1082 hd->primary = TRUE;
1083
1084 sh->wish_block = FALSE;
1085
1086 if (hd->bustype != IS_ISA) {
1087 sh->unchecked_isa_dma = FALSE;
1088 } else {
1089 sh->unchecked_isa_dma = TRUE;
1090 }
1091
1092 for(x = 0; x <= 11; x++){
1093 hd->writes_lat[x][1] = 0xffffffff;
1094 hd->reads_lat[x][1] = 0xffffffff;
1095 }
1096
1097 hd->next = NULL;
1098 hd->prev = last_HBA;
1099 if(hd->prev != NULL)
1100 SD(hd->prev)->next = sh;
1101 last_HBA = sh;
1102 if (first_HBA == NULL)
1103 first_HBA = sh;
1104 registered_HBAs++;
1105
1106 return (TRUE);
1107 }
1108
1109
1110 void find_EISA(struct get_conf *buf, Scsi_Host_Template * tpnt)
1111 {
1112 u32 base;
1113 int i;
1114
1115 #if CHECKPAL
1116 u8 pal1, pal2, pal3;
1117 #endif
1118
1119 for (i = 0; i < MAXEISA; i++) {
1120 if (EISAbases[i] == TRUE) {
1121
1122 base = 0x1c88 + (i * 0x1000);
1123 #if CHECKPAL
1124 pal1 = inb((u16)base - 8);
1125 pal2 = inb((u16)base - 7);
1126 pal3 = inb((u16)base - 6);
1127
1128 if (((pal1 == DPT_ID1) && (pal2 == DPT_ID2)) ||
1129 ((pal1 == NEC_ID1) && (pal2 == NEC_ID2) && (pal3 == NEC_ID3))||
1130 ((pal1 == ATT_ID1) && (pal2 == ATT_ID2) && (pal3 == ATT_ID3))){
1131 DBG(DBG_PROBE, printk("EISA EATA id tags found: %x %x %x \n",
1132 (int)pal1, (int)pal2, (int)pal3));
1133 #endif
1134 if (get_conf_PIO(base, buf) == TRUE) {
1135 if (buf->IRQ) {
1136 DBG(DBG_EISA, printk("Registering EISA HBA\n"));
1137 register_HBA(base, buf, tpnt, IS_EISA);
1138 } else
1139 printk("eata_dma: No valid IRQ. HBA removed from list\n");
1140 } else {
1141 if (check_blink_state(base))
1142 printk("HBA is in BLINK state. Consult your HBAs "
1143 "Manual to correct this.\n");
1144 }
1145
1146 EISAbases[i] = 0;
1147 #if CHECKPAL
1148 }
1149 #endif
1150 }
1151 }
1152 return;
1153 }
1154
1155 void find_ISA(struct get_conf *buf, Scsi_Host_Template * tpnt)
1156 {
1157 int i;
1158
1159 for (i = 0; i < MAXISA; i++) {
1160 if (ISAbases[i]) {
1161 if (get_conf_PIO(ISAbases[i],buf) == TRUE){
1162 DBG(DBG_ISA, printk("Registering ISA HBA\n"));
1163 register_HBA(ISAbases[i], buf, tpnt, IS_ISA);
1164 } else {
1165 if (check_blink_state(ISAbases[i]))
1166 printk("HBA is in BLINK state. Consult your HBAs "
1167 "Manual to correct this.\n");
1168 }
1169 ISAbases[i] = 0;
1170 }
1171 }
1172 return;
1173 }
1174
1175 void find_PCI(struct get_conf *buf, Scsi_Host_Template * tpnt)
1176 {
1177
1178 #ifndef CONFIG_PCI
1179 printk("eata_dma: kernel PCI support not enabled. Skipping scan for PCI HBAs.\n");
1180 #else
1181
1182 u8 pci_bus, pci_device_fn;
1183 static s16 pci_index = 0;
1184 u32 base = 0;
1185 u16 com_adr;
1186 u16 rev_device;
1187 u32 error, i, x;
1188 u8 pal1, pal2, pal3;
1189
1190 if (pcibios_present()) {
1191 for (i = 0; i <= MAXPCI; ++i, ++pci_index) {
1192 if (pcibios_find_device(PCI_VENDOR_ID_DPT, PCI_DEVICE_ID_DPT,
1193 pci_index, &pci_bus, &pci_device_fn))
1194 break;
1195 DBG(DBG_PROBE && DBG_PCI,
1196 printk("eata_dma: HBA at bus %d, device %d,"
1197 " function %d, index %d\n", (s32)pci_bus,
1198 (s32)((pci_device_fn & 0xf8) >> 3),
1199 (s32)(pci_device_fn & 7), pci_index));
1200
1201 if (!(error = pcibios_read_config_word(pci_bus, pci_device_fn,
1202 PCI_CLASS_DEVICE, &rev_device))) {
1203 if (rev_device == PCI_CLASS_STORAGE_SCSI) {
1204 if (!(error = pcibios_read_config_word(pci_bus,
1205 pci_device_fn, PCI_COMMAND,
1206 (u16 *) & com_adr))) {
1207 if (!((com_adr & PCI_COMMAND_IO) &&
1208 (com_adr & PCI_COMMAND_MASTER))) {
1209 printk("eata_dma: HBA has IO or BUSMASTER mode disabled\n");
1210 continue;
1211 }
1212 } else
1213 printk("eata_dma: error %x while reading "
1214 "PCI_COMMAND\n", error);
1215 } else
1216 printk("eata_dma: DEVICECLASSID %x didn't match\n",
1217 rev_device);
1218 } else {
1219 printk("eata_dma: error %x while reading PCI_CLASS_BASE\n",
1220 error);
1221 continue;
1222 }
1223
1224 if (!(error = pcibios_read_config_dword(pci_bus, pci_device_fn,
1225 PCI_BASE_ADDRESS_0, (int *) &base))){
1226
1227
1228 if (base & 0x01) {
1229 base &= 0xfffffffe;
1230
1231 pal1 = inb(base);
1232 pal2 = inb(base + 1);
1233 pal3 = inb(base + 2);
1234 if (((pal1 == DPT_ID1) && (pal2 == DPT_ID2)) ||
1235 ((pal1 == NEC_ID1) && (pal2 == NEC_ID2) &&
1236 (pal3 == NEC_ID3)) ||
1237 ((pal1 == ATT_ID1) && (pal2 == ATT_ID2) &&
1238 (pal3 == ATT_ID3)))
1239 base += 0x08;
1240 else
1241 base += 0x10;
1242
1243 if (base != 0x1f8) {
1244
1245 if (get_conf_PIO(base, buf) == TRUE) {
1246
1247
1248
1249
1250
1251 DBG(DBG_PCI, printk("Registering PCI HBA\n"));
1252 register_HBA(base, buf, tpnt, IS_PCI);
1253
1254 if (base < 0x1000) {
1255 for (x = 0; x < MAXISA; ++x) {
1256 if (ISAbases[x] == base) {
1257 ISAbases[x] = 0;
1258 break;
1259 }
1260 }
1261 } else if ((base & 0x0fff) == 0x0c88)
1262 EISAbases[(base >> 12) & 0x0f] = 0;
1263 continue;
1264 } else if (check_blink_state(base) == TRUE) {
1265 printk("eata_dma: HBA is in BLINK state.\n"
1266 "Consult your HBAs Manual to correct this.\n");
1267 }
1268 }
1269 }
1270 } else {
1271 printk("eata_dma: error %x while reading "
1272 "PCI_BASE_ADDRESS_0\n", error);
1273 }
1274 }
1275 } else {
1276 printk("eata_dma: No BIOS32 extensions present. This driver release "
1277 "still depends on it.\n"
1278 " Skipping scan for PCI HBAs. \n");
1279 }
1280 #endif
1281 return;
1282 }
1283
1284 int eata_detect(Scsi_Host_Template * tpnt)
1285 {
1286 struct Scsi_Host *HBA_ptr;
1287 struct get_conf gc;
1288 int i;
1289
1290 DBG((DBG_PROBE && DBG_DELAY) || DPT_DEBUG,
1291 printk("Using lots of delays to let you read the debugging output\n"));
1292
1293 tpnt->proc_dir = &proc_scsi_eata_dma;
1294
1295 status = scsi_init_malloc(512, GFP_ATOMIC | GFP_DMA);
1296 dma_scratch = scsi_init_malloc(512, GFP_ATOMIC | GFP_DMA);
1297
1298 if(status == NULL || dma_scratch == NULL) {
1299 printk("eata_dma: can't allocate enough memory to probe for hosts !\n");
1300 return(0);
1301 }
1302
1303 find_PCI(&gc, tpnt);
1304
1305 find_EISA(&gc, tpnt);
1306
1307 find_ISA(&gc, tpnt);
1308
1309 for (i = 0; i <= MAXIRQ; i++) {
1310 if (reg_IRQ[i]){
1311 free_irq(i);
1312 request_irq(i, (void *)(eata_int_handler), SA_INTERRUPT, "eata_dma");
1313 }
1314 }
1315 HBA_ptr = first_HBA;
1316
1317 if (registered_HBAs != 0) {
1318 printk("EATA (Extended Attachment) driver version: %d.%d%s\n"
1319 "developed in co-operation with DPT\n"
1320 "(c) 1993-95 Michael Neuffer, neuffer@goofy.zdv.uni-mainz.de\n",
1321 VER_MAJOR, VER_MINOR, VER_SUB);
1322 printk("Registered HBAs:");
1323 printk("\nHBA no. Boardtype: Revis: EATA: Bus: BaseIO: IRQ: DMA: Ch: "
1324 "ID: Pr: QS: SG: CPL:\n");
1325 for (i = 1; i <= registered_HBAs; i++) {
1326 printk("scsi%-2d: %.10s v%s 2.0%c %s %#.4x %2d",
1327 HBA_ptr->host_no, SD(HBA_ptr)->name, SD(HBA_ptr)->revision,
1328 SD(HBA_ptr)->EATA_revision, (SD(HBA_ptr)->bustype == 'P')?
1329 "PCI ":(SD(HBA_ptr)->bustype == 'E')?"EISA":"ISA ",
1330 (u32) HBA_ptr->base, HBA_ptr->irq);
1331 if(HBA_ptr->dma_channel != BUSMASTER)
1332 printk(" %2x ", HBA_ptr->dma_channel);
1333 else
1334 printk(" %s", "BMST");
1335 printk(" %d %d %c %2d %2d %2d\n", SD(HBA_ptr)->channel,
1336 HBA_ptr->this_id, (SD(HBA_ptr)->primary == TRUE)?'Y':'N',
1337 HBA_ptr->can_queue, HBA_ptr->sg_tablesize, HBA_ptr->cmd_per_lun);
1338 HBA_ptr = SD(HBA_ptr)->next;
1339 }
1340 } else {
1341 scsi_init_free((void *)status, 512);
1342 }
1343
1344 scsi_init_free((void *)dma_scratch, 512);
1345
1346 DBG(DPT_DEBUG, DELAY(12));
1347
1348 return(registered_HBAs);
1349 }
1350
1351 #ifdef MODULE
1352
1353 Scsi_Host_Template driver_template = EATA_DMA;
1354 #include "scsi_module.c"
1355 #endif
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373