202 #define AIC7XXX_STRICT_PCI_SETUP
222 #include <linux/module.h>
226 #include <asm/byteorder.h>
227 #include <linux/string.h>
228 #include <linux/errno.h>
229 #include <linux/kernel.h>
232 #include <linux/pci.h>
248 #include <linux/stat.h>
249 #include <linux/slab.h>
251 #define AIC7XXX_C_VERSION "5.2.6"
253 #define ALL_TARGETS -1
254 #define ALL_CHANNELS -1
256 #define MAX_TARGETS 16
265 #if defined(__powerpc__) || defined(__i386__) || defined(__x86_64__)
274 #define AIC7XXX_CMDS_PER_DEVICE 32
278 unsigned char tag_commands[16];
285 #define DEFAULT_TAG_COMMANDS {0, 0, 0, 0, 0, 0, 0, 0,\
286 0, 0, 0, 0, 0, 0, 0, 0}
350 static const char *board_names[] = {
352 "Adaptec AIC-7810 Hardware RAID Controller",
353 "Adaptec AIC-7770 SCSI host adapter",
354 "Adaptec AHA-274X SCSI host adapter",
355 "Adaptec AHA-284X SCSI host adapter",
356 "Adaptec AIC-7850 SCSI host adapter",
357 "Adaptec AIC-7855 SCSI host adapter",
358 "Adaptec AIC-7860 Ultra SCSI host adapter",
359 "Adaptec AHA-2940A Ultra SCSI host adapter",
360 "Adaptec AIC-7870 SCSI host adapter",
361 "Adaptec AHA-294X SCSI host adapter",
362 "Adaptec AHA-394X SCSI host adapter",
363 "Adaptec AHA-398X SCSI host adapter",
364 "Adaptec AHA-2944 SCSI host adapter",
365 "Adaptec AIC-7880 Ultra SCSI host adapter",
366 "Adaptec AHA-294X Ultra SCSI host adapter",
367 "Adaptec AHA-394X Ultra SCSI host adapter",
368 "Adaptec AHA-398X Ultra SCSI host adapter",
369 "Adaptec AHA-2944 Ultra SCSI host adapter",
370 "Adaptec AHA-2940UW Pro Ultra SCSI host adapter",
371 "Adaptec AIC-7895 Ultra SCSI host adapter",
372 "Adaptec AIC-7890/1 Ultra2 SCSI host adapter",
373 "Adaptec AHA-293X Ultra2 SCSI host adapter",
374 "Adaptec AHA-294X Ultra2 SCSI host adapter",
375 "Adaptec AIC-7896/7 Ultra2 SCSI host adapter",
376 "Adaptec AHA-394X Ultra2 SCSI host adapter",
377 "Adaptec AHA-395X Ultra2 SCSI host adapter",
378 "Adaptec PCMCIA SCSI controller",
379 "Adaptec AIC-7892 Ultra 160/m SCSI host adapter",
380 "Adaptec AIC-7899 Ultra 160/m SCSI host adapter",
387 #define DID_UNDERFLOW DID_ERROR
402 #define DID_RETRY_COMMAND DID_ERROR
405 #define SCSI_RESET 0x040
412 #define SLOTBASE(x) ((x) << 12)
413 #define BASE_TO_SLOT(x) ((x) >> 12)
418 #define AHC_HID0 0x80
419 #define AHC_HID1 0x81
420 #define AHC_HID2 0x82
421 #define AHC_HID3 0x83
434 #define CLASS_PROGIF_REVID 0x08
435 #define DEVREVID 0x000000FFul
436 #define PROGINFC 0x0000FF00ul
437 #define SUBCLASS 0x00FF0000ul
438 #define BASECLASS 0xFF000000ul
440 #define CSIZE_LATTIME 0x0C
441 #define CACHESIZE 0x0000003Ful
442 #define LATTIME 0x0000FF00ul
444 #define DEVCONFIG 0x40
445 #define SCBSIZE32 0x00010000ul
446 #define MPORTMODE 0x00000400ul
447 #define RAMPSM 0x00000200ul
448 #define RAMPSM_ULTRA2 0x00000004
449 #define VOLSENSE 0x00000100ul
450 #define SCBRAMSEL 0x00000080ul
451 #define SCBRAMSEL_ULTRA2 0x00000008
452 #define MRDCEN 0x00000040ul
453 #define EXTSCBTIME 0x00000020ul
454 #define EXTSCBPEN 0x00000010ul
455 #define BERREN 0x00000008ul
456 #define DACEN 0x00000004ul
457 #define STPWLEVEL 0x00000002ul
458 #define DIFACTNEGEN 0x00000001ul
461 #define CCSCBBADDR 0xf0
484 #define CFXFER 0x0007
485 #define CFSYNCH 0x0008
486 #define CFDISC 0x0010
487 #define CFWIDEB 0x0020
488 #define CFSYNCHISULTRA 0x0040
489 #define CFNEWULTRAFORMAT 0x0080
490 #define CFSTART 0x0100
491 #define CFINCBIOS 0x0200
492 #define CFRNFOUND 0x0400
493 #define CFMULTILUN 0x0800
494 #define CFWBCACHEYES 0x4000
495 #define CFWBCACHENC 0xc000
502 #define CFSUPREM 0x0001
503 #define CFSUPREMB 0x0002
504 #define CFBIOSEN 0x0004
506 #define CFSM2DRV 0x0010
507 #define CF284XEXTEND 0x0020
509 #define CFEXTEND 0x0080
516 #define CFAUTOTERM 0x0001
517 #define CFULTRAEN 0x0002
518 #define CF284XSELTO 0x0003
519 #define CF284XFIFO 0x000C
520 #define CFSTERM 0x0004
521 #define CFWSTERM 0x0008
522 #define CFSPARITY 0x0010
523 #define CF284XSTERM 0x0020
524 #define CFRESETB 0x0040
525 #define CFBPRIMARY 0x0100
526 #define CFSEAUTOTERM 0x0400
527 #define CFLVDSTERM 0x0800
534 #define CFSCSIID 0x000F
536 #define CFBRTIME 0xFF00
542 #define CFMAXTARG 0x00FF
550 #define SELBUS_MASK 0x0a
551 #define SELNARROW 0x00
553 #define SINGLE_BUS 0x00
555 #define SCB_TARGET(scb) \
556 (((scb)->hscb->target_channel_lun & TID) >> 4)
557 #define SCB_LUN(scb) \
558 ((scb)->hscb->target_channel_lun & LID)
559 #define SCB_IS_SCSIBUS_B(scb) \
560 (((scb)->hscb->target_channel_lun & SELBUSB) != 0)
568 #define aic7xxx_error(cmd) ((cmd)->SCp.Status)
573 #define aic7xxx_status(cmd) ((cmd)->SCp.sent_command)
578 #define aic7xxx_position(cmd) ((cmd)->SCp.have_data_in)
583 #define aic7xxx_mapping(cmd) ((cmd)->SCp.phase)
588 #define AIC_DEV(cmd) ((struct aic_dev_data *)(cmd)->device->hostdata)
608 #define AIC7XXX_MAX_SG 128
615 #define AIC7XXX_MAXSCB 255
634 #define SCB_PIO_TRANSFER_SIZE 26
708 #define AHC_IN_ISR_BIT 28
759 #define SCB_DMA_ADDR(scb, addr) ((unsigned long)(addr) + (scb)->scb_dma->dma_offset)
816 {
ILLHADDR,
"Illegal Host Access" },
817 {
ILLSADDR,
"Illegal Sequencer Address referenced" },
818 {
ILLOPCODE,
"Illegal Opcode in sequencer program" },
819 {
SQPARERR,
"Sequencer Ram Parity Error" },
820 {
DPARERR,
"Data-Path Ram Parity Error" },
821 {
MPARERR,
"Scratch Ram/SCB Array Ram Parity Error" },
836 unsigned char numscbs;
837 unsigned char maxhscbs;
838 unsigned char maxscbs;
840 unsigned int hscbs_dma_len;
841 void *hscb_kmalloc_ptr;
849 #define AHC_TRANS_CUR 0x0001
850 #define AHC_TRANS_ACTIVE 0x0002
851 #define AHC_TRANS_GOAL 0x0004
852 #define AHC_TRANS_USER 0x0008
853 #define AHC_TRANS_QUITE 0x0010
885 #define BUS_DEVICE_RESET_PENDING 0x01
886 #define DEVICE_RESET_DELAY 0x02
887 #define DEVICE_PRINT_DTR 0x04
888 #define DEVICE_WAS_BUSY 0x08
889 #define DEVICE_DTR_SCANNED 0x10
890 #define DEVICE_SCSI_3 0x20
956 #define MSG_TYPE_NONE 0x00
957 #define MSG_TYPE_INITIATOR_MSGOUT 0x01
958 #define MSG_TYPE_INITIATOR_MSGIN 0x02
1000 #define AHC_SYNCRATE_ULTRA3 0
1001 #define AHC_SYNCRATE_ULTRA2 1
1002 #define AHC_SYNCRATE_ULTRA 3
1003 #define AHC_SYNCRATE_FAST 6
1004 #define AHC_SYNCRATE_CRC 0x40
1005 #define AHC_SYNCRATE_SE 0x10
1006 static struct aic7xxx_syncrate {
1008 #define ULTRA_SXFR 0x100
1012 const char *
rate[2];
1013 } aic7xxx_syncrates[] = {
1014 { 0x42, 0x000, 9, {
"80.0",
"160.0"} },
1015 { 0x13, 0x000, 10, {
"40.0",
"80.0"} },
1016 { 0x14, 0x000, 11, {
"33.0",
"66.6"} },
1017 { 0x15, 0x100, 12, {
"20.0",
"40.0"} },
1018 { 0x16, 0x110, 15, {
"16.0",
"32.0"} },
1019 { 0x17, 0x120, 18, {
"13.4",
"26.8"} },
1020 { 0x18, 0x000, 25, {
"10.0",
"20.0"} },
1021 { 0x19, 0x010, 31, {
"8.0",
"16.0"} },
1022 { 0x1a, 0x020, 37, {
"6.67",
"13.3"} },
1023 { 0x1b, 0x030, 43, {
"5.7",
"11.4"} },
1024 { 0x10, 0x040, 50, {
"5.0",
"10.0"} },
1025 { 0x00, 0x050, 56, {
"4.4",
"8.8" } },
1026 { 0x00, 0x060, 62, {
"4.0",
"8.0" } },
1027 { 0x00, 0x070, 68, {
"3.6",
"7.2" } },
1031 #define CTL_OF_SCB(scb) (((scb->hscb)->target_channel_lun >> 3) & 0x1), \
1032 (((scb->hscb)->target_channel_lun >> 4) & 0xf), \
1033 ((scb->hscb)->target_channel_lun & 0x07)
1035 #define CTL_OF_CMD(cmd) ((cmd->device->channel) & 0x01), \
1036 ((cmd->device->id) & 0x0f), \
1037 ((cmd->device->lun) & 0x07)
1039 #define TARGET_INDEX(cmd) ((cmd)->device->id | ((cmd)->device->channel << 3))
1045 #define WARN_LEAD KERN_WARNING "(scsi%d:%d:%d:%d) "
1046 #define INFO_LEAD KERN_INFO "(scsi%d:%d:%d:%d) "
1064 static unsigned int aic7xxx_no_reset = 0;
1082 static int aic7xxx_reverse_scan = 0;
1088 static unsigned int aic7xxx_extended = 0;
1095 static int aic7xxx_irq_trigger = -1;
1129 static int aic7xxx_override_term = -1;
1156 static int aic7xxx_stpwlev = -1;
1161 static int aic7xxx_panic_on_abort = 0;
1177 static int aic7xxx_pci_parity = 0;
1187 static int aic7xxx_dump_card = 0;
1195 static int aic7xxx_dump_sequencer = 0;
1214 static int aic7xxx_scbram = 0;
1226 static int aic7xxx_seltime = 0x10;
1231 static char * aic7xxx =
NULL;
1235 #define VERBOSE_NORMAL 0x0000
1236 #define VERBOSE_NEGOTIATION 0x0001
1237 #define VERBOSE_SEQINT 0x0002
1238 #define VERBOSE_SCSIINT 0x0004
1239 #define VERBOSE_PROBE 0x0008
1240 #define VERBOSE_PROBE2 0x0010
1241 #define VERBOSE_NEGOTIATION2 0x0020
1242 #define VERBOSE_MINOR_ERROR 0x0040
1243 #define VERBOSE_TRACING 0x0080
1244 #define VERBOSE_ABORT 0x0f00
1245 #define VERBOSE_ABORT_MID 0x0100
1246 #define VERBOSE_ABORT_FIND 0x0200
1247 #define VERBOSE_ABORT_PROCESS 0x0400
1248 #define VERBOSE_ABORT_RETURN 0x0800
1249 #define VERBOSE_RESET 0xf000
1250 #define VERBOSE_RESET_MID 0x1000
1251 #define VERBOSE_RESET_FIND 0x2000
1252 #define VERBOSE_RESET_PROCESS 0x4000
1253 #define VERBOSE_RESET_RETURN 0x8000
1275 static void aic7xxx_print_scratch_ram(
struct aic7xxx_host *
p);
1276 static void aic7xxx_print_sequencer(
struct aic7xxx_host *
p,
int downloaded);
1277 #ifdef AIC7XXX_VERBOSE_DEBUGGING
1290 static unsigned char
1340 aic7xxx_setup(
char *
s)
1350 {
"extended", &aic7xxx_extended },
1351 {
"no_reset", &aic7xxx_no_reset },
1352 {
"irq_trigger", &aic7xxx_irq_trigger },
1354 {
"reverse_scan",&aic7xxx_reverse_scan },
1355 {
"override_term", &aic7xxx_override_term },
1356 {
"stpwlev", &aic7xxx_stpwlev },
1358 {
"panic_on_abort", &aic7xxx_panic_on_abort },
1359 {
"pci_parity", &aic7xxx_pci_parity },
1360 {
"dump_card", &aic7xxx_dump_card },
1361 {
"dump_sequencer", &aic7xxx_dump_sequencer },
1362 {
"default_queue_depth", &aic7xxx_default_queue_depth },
1363 {
"scbram", &aic7xxx_scbram },
1364 {
"seltime", &aic7xxx_seltime },
1365 {
"tag_info",
NULL }
1377 if (!
strncmp(p,
"tag_info", n))
1382 char *tok, *tok_end, *tok_end2;
1383 char tok_list[] = {
'.',
',',
'{',
'}',
'\0' };
1384 int i, instance = -1,
device = -1;
1389 tok_end =
strchr(tok,
'\0');
1406 else if (instance != -1)
1416 else if (instance >= 0)
1432 tok_end =
strchr(tok,
'\0');
1433 for(i=0; tok_list[
i]; i++)
1435 tok_end2 =
strchr(tok, tok_list[i]);
1436 if ( (tok_end2) && (tok_end2 < tok_end) )
1442 if ( (instance >= 0) && (
device >= 0) &&
1451 while((p != base) && (p !=
NULL))
1455 else if (p[n] ==
':')
1463 else if (!
strncmp(p,
"verbose", n))
1481 __setup(
"aic7xxx=", aic7xxx_setup);
1515 unpause_sequencer(
struct aic7xxx_host *p,
int unpause_always)
1517 if (unpause_always ||
1559 struct sequencer_patch **start_patch,
int start_instr,
int *skip_addr)
1567 cur_patch = *start_patch;
1569 while ((cur_patch < last_patch) && (start_instr == cur_patch->
begin))
1576 *skip_addr = start_instr + cur_patch->
skip_instr;
1589 *start_patch = cur_patch;
1590 if (start_instr < *skip_addr)
1607 aic7xxx_download_instr(
struct aic7xxx_host *p,
int instrptr,
1608 unsigned char *dconsts)
1619 fmt1_ins = &
instr.format1;
1623 opcode =
instr.format1.opcode;
1641 fmt3_ins = &
instr.format3;
1649 aic7xxx_check_patch(p, &cur_patch, i, &skip_addr);
1654 end_addr =
min_t(
int, address, skip_addr);
1655 address_offset += end_addr -
i;
1663 address -= address_offset;
1673 if (fmt1_ins->
parity != 0)
1685 for ( i=0, count=0; i < 31; i++)
1690 if ((
instr.integer & mask) != 0)
1693 if (!(count & 0x01))
1694 instr.format1.parity = 1;
1698 if (fmt3_ins !=
NULL)
1701 (fmt3_ins->
source << 8) |
1703 (fmt3_ins->
opcode << 25);
1708 (fmt1_ins->
source << 8) |
1710 (fmt1_ins->
ret << 24) |
1711 (fmt1_ins->
opcode << 25);
1715 aic_outb(p, ((
instr.integer >> 8) & 0xff),
SEQRAM);
1716 aic_outb(p, ((
instr.integer >> 16) & 0xff),
SEQRAM);
1717 aic_outb(p, ((
instr.integer >> 24) & 0xff),
SEQRAM);
1722 panic(
"aic7xxx: Unknown opcode encountered in sequencer program.");
1742 unsigned char download_consts[4] = {0, 0, 0, 0};
1760 for (i = 0; i <
sizeof(seqprog) / 4; i++)
1762 if (aic7xxx_check_patch(p, &cur_patch, i, &skip_addr) == 0)
1767 aic7xxx_download_instr(p, i, &download_consts[0]);
1774 unpause_sequencer(p,
TRUE);
1780 printk(
" %d instructions downloaded\n", downloaded);
1782 if (aic7xxx_dump_sequencer)
1783 aic7xxx_print_sequencer(p, downloaded);
1794 aic7xxx_print_sequencer(
struct aic7xxx_host *p,
int downloaded)
1803 for (i=0; i < downloaded; i++)
1807 temp = aic_inb(p,
SEQRAM);
1808 temp |= (aic_inb(p,
SEQRAM) << 8);
1809 temp |= (aic_inb(p,
SEQRAM) << 16);
1810 temp |= (aic_inb(p,
SEQRAM) << 24);
1823 unpause_sequencer(p,
TRUE);
1846 memset(bp, 0,
sizeof(buffer));
1847 strcpy(bp,
"Adaptec AHA274x/284x/294x (EISA/VLB/PCI-Fast SCSI) ");
1866 static struct aic7xxx_syncrate *
1868 unsigned int maxsync,
unsigned char *
options)
1870 struct aic7xxx_syncrate *syncrate;
1915 syncrate = &aic7xxx_syncrates[maxsync];
1916 while ( (syncrate->rate[0] !=
NULL) &&
1919 if (*period <= syncrate->period)
1937 *period = syncrate->period;
1942 if(syncrate == &aic7xxx_syncrates[maxsync])
1944 *period = syncrate->period;
1952 if(syncrate == &aic7xxx_syncrates[maxsync])
1954 *period = syncrate->period;
1966 if ( (*period == 0) || (syncrate->rate[0] ==
NULL) ||
1988 aic7xxx_find_period(
struct aic7xxx_host *p,
unsigned int scsirate,
1989 unsigned int maxsync)
1991 struct aic7xxx_syncrate *syncrate;
2002 syncrate = &aic7xxx_syncrates[maxsync];
2003 while (syncrate->rate[0] !=
NULL)
2007 if (syncrate->sxfr_ultra2 == 0)
2009 else if (scsirate == syncrate->sxfr_ultra2)
2010 return (syncrate->period);
2012 return (syncrate->period);
2014 else if (scsirate == (syncrate->sxfr & ~
ULTRA_SXFR))
2016 return (syncrate->period);
2033 struct aic7xxx_syncrate *syncrate,
unsigned int *
offset,
int wide)
2035 unsigned int maxoffset;
2038 if (syncrate ==
NULL)
2053 *offset =
min(*offset, maxoffset);
2064 aic7xxx_set_syncrate(
struct aic7xxx_host *p,
struct aic7xxx_syncrate *syncrate,
2065 int target,
int channel,
unsigned int period,
unsigned int offset,
2068 unsigned char tindex;
2069 unsigned short target_mask;
2070 unsigned char lun, old_options;
2071 unsigned int old_period, old_offset;
2073 tindex = target | (channel << 3);
2074 target_mask = 0x01 << tindex;
2075 lun = aic_inb(p,
SCB_TCL) & 0x07;
2077 if (syncrate ==
NULL)
2090 unsigned int scsirate;
2096 if (syncrate !=
NULL)
2107 scsirate |= syncrate->sxfr_ultra2;
2121 if (syncrate !=
NULL)
2127 scsirate |= (syncrate->sxfr &
SXFR);
2128 scsirate |= (offset &
SOFS);
2132 unsigned char sxfrctl0;
2143 if (type & AHC_TRANS_ACTIVE)
2157 int rate_mod = (scsirate &
WIDEXFER) ? 1 : 0;
2160 "offset %d.\n", p->
host_no, channel, target, lun,
2161 syncrate->rate[rate_mod], offset);
2166 p->
host_no, channel, target, lun);
2195 aic7xxx_set_width(
struct aic7xxx_host *p,
int target,
int channel,
int lun,
2198 unsigned char tindex;
2199 unsigned short target_mask;
2200 unsigned int old_width;
2202 tindex = target | (channel << 3);
2203 target_mask = 1 << tindex;
2207 if (type & AHC_TRANS_CUR)
2209 unsigned char scsirate;
2219 if (type & AHC_TRANS_ACTIVE)
2224 if ( !(type & AHC_TRANS_QUITE) &&
2229 lun, (scsirate &
WIDEXFER) ?
"Wide(16bit)" :
"Narrow(8bit)" );
2233 if (type & AHC_TRANS_GOAL)
2319 if (queue->
head == scb)
2322 scbq_remove_head(queue);
2332 while ((curscb !=
NULL) && (curscb->
q_next != scb))
2343 queue->
tail = curscb;
2380 int target,
int channel,
int lun,
unsigned char tag)
2382 int targ = (scb->
hscb->target_channel_lun >> 4) & 0x0F;
2383 int chan = (scb->
hscb->target_channel_lun >> 3) & 0x01;
2384 int slun = scb->
hscb->target_channel_lun & 0x07;
2391 match = ((lun == slun) || (lun ==
ALL_LUNS));
2406 aic7xxx_add_curscb_to_free_list(
struct aic7xxx_host *p)
2427 static unsigned char
2428 aic7xxx_rem_scb_from_disc_list(
struct aic7xxx_host *p,
unsigned char scbptr,
2433 aic_outb(p, scbptr,
SCBPTR);
2435 aic7xxx_add_curscb_to_free_list(p);
2439 aic_outb(p, prev,
SCBPTR);
2471 static inline unsigned char
2472 aic7xxx_index_busy_target(
struct aic7xxx_host *p,
unsigned char tcl,
2475 unsigned char busy_scbid;
2482 return (busy_scbid);
2495 static unsigned char
2498 unsigned char saved_scbptr;
2499 unsigned char curindex;
2501 saved_scbptr = aic_inb(p,
SCBPTR);
2505 aic_outb(p, curindex,
SCBPTR);
2511 aic_outb(p, saved_scbptr,
SCBPTR);
2534 unsigned long scb_count = 0;
2538 unsigned char *
bufs;
2558 for ( i=step;; i *= 2 )
2560 if ( (scb_size * (i-1)) >= ( (
PAGE_SIZE * (i/
step)) - 64 ) )
2581 #ifdef AIC7XXX_VERBOSE_DEBUGGING
2586 p->
host_no, -1, -1, -1, scb_count);
2589 p->
host_no, -1, -1, -1, scb_count);
2594 - (
unsigned long)hsgp;
2595 scb_dma->
dma_len = scb_size * scb_count;
2596 for (i=0; i < scb_count; i++)
2602 scbp->
cmnd = bufs + 6;
2642 static void aic7xxx_done_cmds_complete(
struct aic7xxx_host *p)
2670 scb->
hscb->control = 0;
2671 scb->
hscb->target_status = 0;
2697 pci_unmap_single(p->
pdev,
2713 unsigned short mask;
2714 int message_error =
FALSE;
2716 mask = 0x01 << tindex;
2723 ((scb->
cmd->sense_buffer[12] == 0x43) ||
2724 (scb->
cmd->sense_buffer[12] == 0x49)))
2726 message_error =
TRUE;
2794 if (queue_depth == 1)
2808 #ifdef AIC7XXX_VERBOSE_DEBUGGING
2823 aic7xxx_index_busy_target(p, scb->
hscb->target_channel_lun,
2825 if (cmd->
device->simple_tags)
2866 aic7xxx_free_scb(p, scb);
2867 aic7xxx_queue_cmd_complete(p, cmd);
2904 scb->
hscb->residual_SG_segment_count = 0;
2905 scb->
hscb->residual_data_count[0] = 0;
2906 scb->
hscb->residual_data_count[1] = 0;
2907 scb->
hscb->residual_data_count[2] = 0;
2910 aic7xxx_done(p, scb);
2916 "completion.\n", p->
host_no, -1, -1, -1, found);
2920 aic7xxx_done_cmds_complete(p);
2932 static unsigned char
2934 unsigned char scbpos,
unsigned char prev)
2936 unsigned char curscb,
next;
2941 curscb = aic_inb(p,
SCBPTR);
2942 aic_outb(p, scbpos,
SCBPTR);
2945 aic7xxx_add_curscb_to_free_list(p);
2962 aic_outb(p, prev,
SCBPTR);
2969 aic_outb(p, curscb,
SCBPTR);
2982 aic7xxx_search_qinfifo(
struct aic7xxx_host *p,
int target,
int channel,
2983 int lun,
unsigned char tag,
int flags,
int requeue,
2987 unsigned char qinpos, qintail;
2991 qinpos = aic_inb(p,
QINPOS);
2996 while (qinpos != qintail)
2999 if (aic7xxx_match_scb(p, scbp, target, channel, lun, tag))
3004 if (requeue && (queue !=
NULL))
3008 scbq_remove(queue, scbp);
3010 scbq_remove(&
AIC_DEV(scbp->
cmd)->delayed_scbs, scbp);
3014 scbq_insert_tail(queue, scbp);
3020 aic7xxx_index_busy_target(p, scbp->
hscb->target_channel_lun,
3036 if (aic7xxx_index_busy_target(p, scbp->
hscb->target_channel_lun,
3039 aic7xxx_index_busy_target(p, scbp->
hscb->target_channel_lun,
3058 while(qinpos != qintail)
3109 aic7xxx_reset_device(
struct aic7xxx_host *p,
int target,
int channel,
3110 int lun,
unsigned char tag)
3114 unsigned char active_scb, tcl, scb_tag;
3115 int i = 0, init_lists =
FALSE;
3121 active_scb = aic_inb(p,
SCBPTR);
3122 scb_tag = aic_inb(p,
SCB_TAG);
3127 p->
host_no, channel, target, lun, active_scb);
3130 p->
host_no, channel, target, lun, scb_tag,
3134 p->
host_no, channel, target, lun,
3150 sd = aic_dev->
SDptr;
3169 if ( (aic7xxx_index_busy_target(p, tcl,
FALSE) == tag) ||
3171 aic7xxx_index_busy_target(p, tcl,
TRUE);
3174 while (scbp !=
NULL)
3178 if (aic7xxx_match_scb(p, prev_scbp, target, channel, lun, tag))
3194 aic7xxx_search_qinfifo(p, target, channel, lun, tag,
3209 while (scbp !=
NULL)
3213 if (aic7xxx_match_scb(p, prev_scbp, target, channel, lun, tag))
3233 "list.\n", p->
host_no, channel, target, lun);
3235 unsigned char next,
prev, scb_index;
3241 aic_outb(p, next,
SCBPTR);
3242 scb_index = aic_inb(p,
SCB_TAG);
3250 "numscbs=%d\n", p->
host_no, channel, target, lun, scb_index,
3253 aic7xxx_add_curscb_to_free_list(p);
3258 if (aic7xxx_match_scb(p, scbp, target, channel, lun, tag))
3260 next = aic7xxx_abort_waiting_scb(p, scbp, next, prev);
3295 "list.\n", p->
host_no, channel, target, lun);
3298 unsigned char next,
prev, scb_index;
3304 aic_outb(p, next,
SCBPTR);
3305 scb_index = aic_inb(p,
SCB_TAG);
3309 "numscbs=%d\n", p->
host_no, channel, target, lun, scb_index,
3311 next = aic7xxx_rem_scb_from_disc_list(p, next, prev);
3316 if (aic7xxx_match_scb(p, scbp, target, channel, lun, tag))
3318 next = aic7xxx_rem_scb_from_disc_list(p, next, prev);
3326 scbp->
hscb->control = 0;
3348 aic_outb(p, next,
SCBPTR);
3377 unsigned char scbid;
3385 aic7xxx_add_curscb_to_free_list(p);
3393 if (aic7xxx_match_scb(p, scbp, target, channel, lun, tag))
3397 aic7xxx_add_curscb_to_free_list(p);
3417 aic7xxx_match_scb(p, scbp, target, channel, lun, tag) &&
3418 !aic7xxx_scb_on_qoutfifo(p, scbp))
3423 scbq_remove(&
AIC_DEV(scbp->
cmd)->delayed_scbs, scbp);
3432 aic_outb(p, active_scb,
SCBPTR);
3492 aic7xxx_clear_intstat(p);
3506 aic7xxx_reset_channel(
struct aic7xxx_host *p,
int channel,
int initiate_reset)
3508 unsigned long offset_min, offset_max;
3509 unsigned char sblkctl;
3514 p->
host_no, channel, -1, -1, (initiate_reset==
TRUE) ?
"will" :
"won't" );
3544 while (offset_min < offset_max)
3560 sblkctl = aic_inb(p,
SBLKCTL);
3562 cur_channel = (sblkctl &
SELBUSB) >> 3;
3580 aic7xxx_reset_current_bus(p);
3583 aic7xxx_clear_intstat(p);
3584 aic_outb(p, sblkctl,
SBLKCTL);
3601 aic7xxx_reset_current_bus(p);
3604 aic7xxx_clear_intstat(p);
3616 restart_sequencer(p);
3648 aic_dev = scb->
cmd->device->hostdata;
3664 aic7xxx_busy_target(p, scb);
3678 unpause_sequencer(p,
FALSE);
3714 "phase.\n", p->
host_no, -1, -1, -1);
3729 "PERR#\n", p->
host_no, -1, -1, -1);
3732 if (status1 & (DPR|RMA|RTA))
3735 if ( (aic7xxx_panic_on_abort) && (p->
spurious_int > 500) )
3736 aic7xxx_panic_abort(p,
NULL);
3772 aic7xxx_construct_sdtr(
struct aic7xxx_host *p,
unsigned char period,
3773 unsigned char offset)
3846 (rq_data_dir(cmd->
request) ==
WRITE) ?
"wrote" :
"read", actual,
3857 scsi_set_resid(cmd, scb->
sg_length - actual);
3880 aic7xxx_handle_device_reset(
struct aic7xxx_host *p,
int target,
int channel)
3882 unsigned char tindex =
target;
3884 tindex |= ((channel & 0x01) << 3);
3896 aic7xxx_run_done_queue(p,
TRUE);
3907 aic7xxx_handle_seqint(
struct aic7xxx_host *p,
unsigned char intstat)
3911 unsigned short target_mask;
3913 unsigned char queue_flag =
FALSE;
3917 target = ((aic_inb(p,
SAVED_TCL) >> 4) & 0x0f);
3922 tindex = target + (channel << 3);
3924 target_mask = (0x01 << tindex);
3938 "BUS DEVICE RESET.\n", p->
host_no, channel, target, lun);
3940 p->
host_no, channel, target, lun,
3943 if (aic7xxx_panic_on_abort)
3944 aic7xxx_panic_abort(p,
NULL);
3952 "target, SEQ_FLAGS=0x%x\n", p->
host_no, channel, target, lun,
3968 "LASTPHASE 0x%x, SAVED_TCL 0x%x\n", p->
host_no, channel, target,
3971 aic7xxx_reset_channel(p, channel,
TRUE);
3972 aic7xxx_run_done_queue(p,
TRUE);
3983 restart_sequencer(p);
3989 channel, target, lun);
3999 #ifdef AIC7XXX_VERBOSE_DEBUGGING
4002 channel, target, lun);
4026 unsigned char scb_index;
4027 unsigned char last_msg;
4029 scb_index = aic_inb(p,
SCB_TAG);
4047 scb->
cmd->device->queue_depth);
4069 p->
host->cmd_per_lun);
4093 if (aic7xxx_match_scb(p, scbp, target, channel, lun, i))
4095 aic7xxx_reset_device(p, target, channel, lun, i);
4099 aic7xxx_run_done_queue(p,
TRUE);
4106 aic7xxx_busy_target(p, scb);
4108 "untagged I/O.\n", p->
host_no, channel, target, lun);
4125 (AHC_TRANS_ACTIVE|AHC_TRANS_CUR|AHC_TRANS_QUITE), aic_dev);
4126 aic7xxx_set_syncrate(p,
NULL, target, channel, 0, 0, 0,
4127 AHC_TRANS_ACTIVE|AHC_TRANS_CUR|AHC_TRANS_QUITE,
4134 "back.\n", p->
host_no, channel, target, lun);
4165 (AHC_TRANS_ACTIVE|AHC_TRANS_GOAL|AHC_TRANS_CUR), aic_dev);
4166 aic7xxx_set_syncrate(p,
NULL, target, channel, 0, 0, 0,
4167 AHC_TRANS_ACTIVE|AHC_TRANS_CUR|AHC_TRANS_QUITE,
4172 "narrow transfers.\n", p->
host_no, channel, target, lun);
4183 aic7xxx_set_syncrate(p,
NULL, target, channel, 0, 0, 0,
4184 (AHC_TRANS_CUR|AHC_TRANS_ACTIVE|AHC_TRANS_GOAL), aic_dev);
4188 "async transfers.\n", p->
host_no, channel, target, lun);
4197 "Ignoring.\n", p->
host_no, channel, target, lun);
4204 unsigned char scb_index;
4219 scb_index = aic_inb(p,
SCB_TAG);
4223 p->
host_no, channel, target, lun, intstat, scb_index);
4231 printk(
WARN_LEAD "Invalid SCB during SEQINT 0x%x, scb %d, flags 0x%x,"
4232 " cmd 0x%lx.\n", p->
host_no, channel, target, lun, intstat,
4233 scb_index, scb->
flags, (
unsigned long) scb->
cmd);
4261 sizeof(generic_sense));
4300 #ifdef AIC7XXX_VERBOSE_DEBUGGING
4312 aic7xxx_busy_target(p, scb);
4328 unsigned char active_hscb, next_hscb, prev_hscb, scb_index;
4343 while ( next_scbp !=
NULL )
4345 prev_scbp = next_scbp;
4346 next_scbp = next_scbp->
q_next;
4347 if ( aic7xxx_match_scb(p, prev_scbp, target, channel, lun,
4356 aic7xxx_search_qinfifo(p, target, channel, lun,
4360 active_hscb = aic_inb(p,
SCBPTR);
4365 aic_outb(p, next_hscb,
SCBPTR);
4366 scb_index = aic_inb(p,
SCB_TAG);
4370 if (aic7xxx_match_scb(p, next_scbp, target, channel, lun,
4377 aic7xxx_add_curscb_to_free_list(p);
4391 aic_outb(p, prev_hscb,
SCBPTR);
4397 prev_hscb = next_hscb;
4402 aic_outb(p, active_hscb,
SCBPTR);
4403 aic7xxx_run_done_queue(p,
FALSE);
4405 #ifdef AIC7XXX_VERBOSE_DEBUGGING
4431 else if ( result > 0 )
4472 unsigned char scb_index,
msg_out;
4474 scb_index = aic_inb(p,
SCB_TAG);
4475 msg_out = aic_inb(p,
MSG_OUT);
4528 aic7xxx_construct_ppr(p, scb);
4537 aic7xxx_construct_wdtr(p, aic_dev->
goal.
width);
4541 unsigned int max_sync,
period;
4542 unsigned char options = 0;
4568 aic7xxx_find_syncrate(p, &period, max_sync, &options);
4575 aic7xxx_construct_sdtr(p, period, aic_dev->
goal.
offset);
4579 panic(
"aic7xxx: AWAITING_MSG for an SCB that does "
4580 "not have a waiting message.\n");
4605 unsigned char scb_index = aic_inb(p,
SCB_TAG);
4606 unsigned char lastphase = aic_inb(p,
LASTPHASE);
4624 (lastphase ==
P_DATAIN) ?
"Data-In" :
"Data-Out", scb->
hscb->tag);
4629 for (i = 0; i < scb->
hscb->SCSI_cmd_length; i++)
4636 for (i = 0; i < scb->
sg_count; i++)
4654 unsigned char resid_sgcnt,
index;
4655 unsigned char scb_index = aic_inb(p,
SCB_TAG);
4656 unsigned int cur_addr, resid_dcnt;
4657 unsigned int native_addr, native_length, sg_addr;
4674 scb->
flags, (
unsigned long)scb->
cmd);
4690 cur_addr = aic_inb(p,
SHADDR) | (aic_inb(p,
SHADDR + 1) << 8) |
4691 (aic_inb(p,
SHADDR + 2) << 16) | (aic_inb(p,
SHADDR + 3) << 24);
4698 index = scb->
sg_count - ((resid_sgcnt) ? resid_sgcnt : 1);
4705 if(resid_dcnt == native_length)
4719 cur_addr = native_addr + (native_length - 1);
4736 aic_outb(p, resid_sgcnt,
SG_COUNT);
4738 aic_outb(p, sg_addr & 0xff,
SG_COUNT + 1);
4739 aic_outb(p, (sg_addr >> 8) & 0xff,
SG_COUNT + 2);
4740 aic_outb(p, (sg_addr >> 16) & 0xff,
SG_COUNT + 3);
4741 aic_outb(p, (sg_addr >> 24) & 0xff,
SG_COUNT + 4);
4762 aic_outb(p, resid_dcnt & 0xff,
HCNT);
4763 aic_outb(p, (resid_dcnt >> 8) & 0xff,
HCNT + 1);
4764 aic_outb(p, (resid_dcnt >> 16) & 0xff,
HCNT + 2);
4765 aic_outb(p, cur_addr & 0xff,
HADDR);
4766 aic_outb(p, (cur_addr >> 8) & 0xff,
HADDR + 1);
4767 aic_outb(p, (cur_addr >> 16) & 0xff,
HADDR + 2);
4768 aic_outb(p, (cur_addr >> 24) & 0xff,
HADDR + 3);
4780 aic_outb(p, cur_addr & 0xff,
SHADDR);
4781 aic_outb(p, (cur_addr >> 8) & 0xff,
SHADDR + 1);
4782 aic_outb(p, (cur_addr >> 16) & 0xff,
SHADDR + 2);
4783 aic_outb(p, (cur_addr >> 24) & 0xff,
SHADDR + 3);
4790 unsigned char scb_index,
tmp;
4791 int sg_addr, sg_length;
4793 scb_index = aic_inb(p,
SCB_TAG);
4800 "0x%x\n", p->
host_no, -1, -1, -1,
4807 aic_inb(p,
STCNT + 1) << 8 | aic_inb(p,
STCNT));
4827 aic_inb(p,
STCNT + 1) << 8 | aic_inb(p,
STCNT));
4849 aic_outb(p, sg_addr & 0xff,
HADDR);
4850 aic_outb(p, (sg_addr >> 8) & 0xff,
HADDR + 1);
4851 aic_outb(p, (sg_addr >> 16) & 0xff,
HADDR + 2);
4852 aic_outb(p, (sg_addr >> 24) & 0xff,
HADDR + 3);
4853 aic_outb(p, sg_length & 0xff,
HCNT);
4854 aic_outb(p, (sg_length >> 8) & 0xff,
HCNT + 1);
4855 aic_outb(p, (sg_length >> 16) & 0xff,
HCNT + 2);
4863 #ifdef AIC7XXX_NOT_YET
4867 channel, target, lun);
4872 case MSG_BUFFER_BUSY:
4873 printk(
"aic7xxx: Message buffer busy.\n");
4876 printk(
"aic7xxx: Message-in phasemis.\n");
4882 p->
host_no, channel, target, lun, intstat,
4890 unpause_sequencer(p,
TRUE);
4904 int reject, reply,
done;
4905 unsigned char target_scsirate, tindex;
4906 unsigned short target_mask;
4909 unsigned char trans_options, new_trans_options;
4910 unsigned int period, new_period,
offset, new_offset, maxsync;
4911 struct aic7xxx_syncrate *syncrate;
4914 target = scb->
cmd->device->id;
4915 channel = scb->
cmd->device->channel;
4916 lun = scb->
cmd->device->lun;
4917 reply = reject = done =
FALSE;
4921 target_mask = (0x01 << tindex);
4943 if ( (aic_inb(p,
SBLKCTL) & ENAB40) &&
4970 if ( !reject && (p->
msg_len > 2) )
4988 period = new_period = p->
msg_buf[3];
4989 offset = new_offset = p->
msg_buf[4];
4990 trans_options = new_trans_options = 0;
4991 bus_width = new_bus_width = target_scsirate &
WIDEXFER;
5073 syncrate = aic7xxx_find_syncrate(p, &new_period, maxsync,
5075 aic7xxx_validate_offset(p, syncrate, &new_offset, bus_width);
5081 if ((new_offset == 0) && (new_offset != offset))
5098 aic7xxx_set_syncrate(p, syncrate, target, channel, new_period,
5099 new_offset, trans_options,
5100 AHC_TRANS_GOAL|AHC_TRANS_ACTIVE|AHC_TRANS_CUR,
5109 aic7xxx_set_syncrate(p, syncrate, target, channel, new_period,
5110 new_offset, trans_options,
5111 AHC_TRANS_ACTIVE|AHC_TRANS_CUR, aic_dev);
5131 bus_width = new_bus_width = p->
msg_buf[3];
5161 aic7xxx_set_width(p, target, channel, lun, new_bus_width,
5162 AHC_TRANS_ACTIVE|AHC_TRANS_CUR, aic_dev);
5266 aic7xxx_set_width(p, target, channel, lun, new_bus_width,
5267 AHC_TRANS_GOAL|AHC_TRANS_ACTIVE|AHC_TRANS_CUR,
5278 aic7xxx_set_syncrate(p,
NULL, target, channel, 0, 0, 0,
5279 AHC_TRANS_ACTIVE|AHC_TRANS_CUR|AHC_TRANS_QUITE,
5299 period = new_period = p->
msg_buf[3];
5300 offset = new_offset = p->
msg_buf[5];
5301 bus_width = new_bus_width = p->
msg_buf[6];
5302 trans_options = new_trans_options = p->
msg_buf[7] & 0xf;
5418 new_trans_options = 0;
5431 aic7xxx_set_width(p, target, channel, lun, new_bus_width,
5432 AHC_TRANS_GOAL|AHC_TRANS_ACTIVE|AHC_TRANS_CUR,
5434 syncrate = aic7xxx_find_syncrate(p, &new_period, maxsync,
5435 &new_trans_options);
5436 aic7xxx_validate_offset(p, syncrate, &new_offset, new_bus_width);
5437 aic7xxx_set_syncrate(p, syncrate, target, channel, new_period,
5438 new_offset, new_trans_options,
5439 AHC_TRANS_GOAL|AHC_TRANS_ACTIVE|AHC_TRANS_CUR,
5444 aic7xxx_set_width(p, target, channel, lun, new_bus_width,
5445 AHC_TRANS_ACTIVE|AHC_TRANS_CUR, aic_dev);
5446 syncrate = aic7xxx_find_syncrate(p, &new_period, maxsync,
5447 &new_trans_options);
5448 aic7xxx_validate_offset(p, syncrate, &new_offset, new_bus_width);
5449 aic7xxx_set_syncrate(p, syncrate, target, channel, new_period,
5450 new_offset, new_trans_options,
5451 AHC_TRANS_ACTIVE|AHC_TRANS_CUR, aic_dev);
5461 if(new_trans_options == 0)
5474 if((new_offset == 0) && (offset != 0))
5506 if (!reply && reject)
5527 unsigned char lastbyte;
5528 unsigned char phasemis;
5536 panic(
"aic7xxx: REQINIT with no active message!\n");
5541 if (lastbyte || phasemis)
5559 #ifdef AIC7XXX_VERBOSE_DEBUGGING
5568 #ifdef AIC7XXX_VERBOSE_DEBUGGING
5574 unpause_sequencer(p,
TRUE);
5597 done = aic7xxx_parse_msg(p, scb);
5604 if (phasemis || done)
5606 #ifdef AIC7XXX_VERBOSE_DEBUGGING
5623 unpause_sequencer(p,
TRUE);
5629 panic(
"aic7xxx: Unknown REQINIT message type.\n");
5643 aic7xxx_handle_scsiint(
struct aic7xxx_host *p,
unsigned char intstat)
5645 unsigned char scb_index;
5650 scb_index = aic_inb(p,
SCB_TAG);
5651 status = aic_inb(p,
SSTAT1);
5679 if (aic7xxx_panic_on_abort)
5680 aic7xxx_panic_abort(p,
NULL);
5685 aic7xxx_reset_channel(p, channel,
FALSE);
5686 aic7xxx_run_done_queue(p,
TRUE);
5689 else if ( ((status &
BUSFREE) != 0) && ((status &
SELTO) == 0) )
5696 unsigned char lastphase = aic_inb(p,
LASTPHASE);
5697 unsigned char saved_tcl = aic_inb(p,
SAVED_TCL);
5698 unsigned char target = (saved_tcl >> 4) & 0x0F;
5700 int printerror =
TRUE;
5713 message = aic_inb(p,
SINDEX);
5720 aic7xxx_reset_device(p, target, channel,
ALL_LUNS,
5722 aic7xxx_run_done_queue(p,
TRUE);
5728 aic7xxx_handle_device_reset(p, target, channel);
5743 aic7xxx_reset_device(p, target, channel,
ALL_LUNS, scb->
hscb->tag);
5744 aic7xxx_run_done_queue(p,
TRUE);
5747 if (printerror != 0)
5755 tag = scb->
hscb->tag;
5761 aic7xxx_reset_device(p, target, channel,
ALL_LUNS, tag);
5762 aic7xxx_run_done_queue(p,
TRUE);
5767 aic7xxx_run_done_queue(p,
TRUE);
5770 "SEQADDR = 0x%x\n", p->
host_no, channel, target, -1, lastphase,
5780 restart_sequencer(p);
5781 unpause_sequencer(p,
TRUE);
5783 else if ((status & SELTO) != 0)
5785 unsigned char scbptr;
5786 unsigned char nextscb;
5802 p->
host_no, -1, -1, -1, scbptr);
5808 aic_outb(p, scbptr,
SCBPTR);
5809 scb_index = aic_inb(p,
SCB_TAG);
5823 p->
host_no, -1, -1, -1, scb_index);
5825 "SSTAT1 = 0x%x\n", aic_inb(p,
SCSISEQ),
5828 if (aic7xxx_panic_on_abort)
5829 aic7xxx_panic_abort(p,
NULL);
5856 aic7xxx_add_curscb_to_free_list(p);
5857 #ifdef AIC7XXX_VERBOSE_DEBUGGING
5901 restart_sequencer(p);
5902 unpause_sequencer(p,
TRUE);
5904 else if (scb ==
NULL)
5907 "during scsiint 0x%x scb(%d)\n"
5908 " SIMODE0 0x%x, SIMODE1 0x%x, SSTAT0 0x%x, SEQADDR 0x%x\n",
5918 unpause_sequencer(p,
TRUE);
5929 unsigned char lastphase = aic_inb(p,
LASTPHASE);
5930 unsigned char sstat2 = aic_inb(p,
SSTAT2);
5946 phase =
"Message-Out";
5953 phase =
"Message-In";
6005 aic7xxx_set_width(p, scb->
cmd->device->id, scb->
cmd->device->channel, scb->
cmd->device->lun,
6007 (AHC_TRANS_ACTIVE|AHC_TRANS_CUR|AHC_TRANS_QUITE),
6009 aic7xxx_set_syncrate(p,
NULL, scb->
cmd->device->id, scb->
cmd->device->channel, 0, 0,
6010 0, AHC_TRANS_ACTIVE|AHC_TRANS_CUR|AHC_TRANS_QUITE,
6042 aic_outb(p, mesg_out,
MSG_OUT);
6048 unpause_sequencer(p,
TRUE);
6050 else if ( (status &
REQINIT) &&
6053 #ifdef AIC7XXX_VERBOSE_DEBUGGING
6058 aic7xxx_handle_reqinit(p, scb);
6069 p->
host_no, -1, -1, -1, status);
6072 unpause_sequencer(p,
TRUE);
6077 aic7xxx_done(p, scb);
6081 #ifdef AIC7XXX_VERBOSE_DEBUGGING
6083 aic7xxx_check_scbs(
struct aic7xxx_host *p,
char *buffer)
6085 unsigned char saved_scbptr, free_scbh, dis_scbh, wait_scbh,
temp;
6089 #define SCB_NO_LIST 0
6090 #define SCB_FREE_LIST 1
6091 #define SCB_WAITING_LIST 2
6092 #define SCB_DISCONNECTED_LIST 4
6093 #define SCB_CURRENTLY_ACTIVE 8
6105 memset(&scb_status[0], 0,
sizeof(scb_status));
6107 saved_scbptr = aic_inb(p,
SCBPTR);
6110 printk(
"Bogus SCBPTR %d\n", saved_scbptr);
6113 scb_status[saved_scbptr] = SCB_CURRENTLY_ACTIVE;
6118 printk(
"Bogus FREE_SCBH %d\n", free_scbh);
6126 if(scb_status[temp] & 0x07)
6128 printk(
"HSCB %d on multiple lists, status 0x%02x", temp,
6129 scb_status[temp] | SCB_FREE_LIST);
6132 scb_status[
temp] |= SCB_FREE_LIST;
6133 aic_outb(p, temp,
SCBPTR);
6142 printk(
"Bogus DISCONNECTED_SCBH %d\n", dis_scbh);
6150 if(scb_status[temp] & 0x07)
6152 printk(
"HSCB %d on multiple lists, status 0x%02x", temp,
6153 scb_status[temp] | SCB_DISCONNECTED_LIST);
6156 scb_status[
temp] |= SCB_DISCONNECTED_LIST;
6157 aic_outb(p, temp,
SCBPTR);
6166 printk(
"Bogus WAITING_SCBH %d\n", wait_scbh);
6174 if(scb_status[temp] & 0x07)
6176 printk(
"HSCB %d on multiple lists, status 0x%02x", temp,
6177 scb_status[temp] | SCB_WAITING_LIST);
6180 scb_status[
temp] |= SCB_WAITING_LIST;
6181 aic_outb(p, temp,
SCBPTR);
6194 printk(
"HSCB %d bad, SCB_NEXT invalid(%d).\n", i, temp);
6199 printk(
"HSCB %d bad, SCB_NEXT points to self.\n", i);
6202 if (scb_status[i] == 0)
6206 printk(
"Too many lost scbs.\n");
6210 aic_outb(p, saved_scbptr,
SCBPTR);
6211 unpause_sequencer(p,
FALSE);
6214 printk(
"Bogus parameters found in card SCB array structures.\n");
6216 aic7xxx_panic_abort(p,
NULL);
6231 aic7xxx_handle_command_completion_intr(
struct aic7xxx_host *p)
6236 unsigned char scb_index, tindex;
6238 #ifdef AIC7XXX_VERBOSE_DEBUGGING
6264 -1, -1, -1, scb_index);
6271 "0x%x, cmd 0x%lx\n", p->
host_no, -1, -1, -1, scb_index, scb->
flags,
6272 (
unsigned long) scb->
cmd);
6283 unpause_sequencer(p,
FALSE);
6286 aic7xxx_reset_device(p, scb->
cmd->device->id, scb->
cmd->device->channel,
6287 scb->
cmd->device->lun, scb->
hscb->tag);
6290 unpause_sequencer(p,
FALSE);
6302 char *buffer = &scb->
cmd->sense_buffer[0];
6304 if (buffer[12] == 0x47 || buffer[12] == 0x54)
6315 if (scb->
hscb->residual_SG_segment_count != 0)
6317 aic7xxx_calculate_residual(p, scb);
6320 aic7xxx_done(p, scb);
6332 aic7xxx_isr(
void *
dev_id)
6335 unsigned char intstat;
6352 aic7xxx_pci_intr(p);
6371 #ifdef AIC7XXX_VERBOSE_DEBUGGING
6374 aic7xxx_check_scbs(p,
"Bogus settings at start of interrupt.");
6383 aic7xxx_handle_command_completion_intr(p);
6394 if (errno & hard_error[i].errno)
6401 if (aic7xxx_panic_on_abort)
6402 aic7xxx_panic_abort(p,
NULL);
6405 aic7xxx_pci_intr(p);
6409 panic(
"aic7xxx: unrecoverable BRKADRINT.\n");
6413 printk(
KERN_ERR "(scsi%d) BUG! Driver accessed chip without first "
6414 "pausing controller!\n", p->
host_no);
6416 #ifdef AIC7XXX_VERBOSE_DEBUGGING
6420 printk(
"(scsi%d) while DMAing SCB from host to card.\n", p->
host_no);
6422 printk(
"(scsi%d) while DMAing SCB from card to host.\n", p->
host_no);
6426 unpause_sequencer(p,
FALSE);
6438 aic7xxx_handle_seqint(p, intstat);
6443 aic7xxx_handle_scsiint(p, intstat);
6446 #ifdef AIC7XXX_VERBOSE_DEBUGGING
6449 aic7xxx_check_scbs(p,
"Bogus settings at end of interrupt.");
6464 do_aic7xxx_isr(
int irq,
void *dev_id)
6466 unsigned long cpu_flags;
6476 aic7xxx_isr(dev_id);
6477 }
while ( (aic_inb(p,
INTSTAT) & INT_PEND) );
6478 aic7xxx_done_cmds_complete(p);
6479 aic7xxx_run_waiting_queues(p);
6481 spin_unlock_irqrestore(p->
host->host_lock, cpu_flags);
6498 unsigned char tindex;
6500 tindex = sdpnt->
id | (sdpnt->
channel << 3);
6514 aic7xxx_set_width(p, sdpnt->
id, sdpnt->
channel, sdpnt->
lun,
6517 AHC_TRANS_CUR), aic_dev );
6518 unpause_sequencer(p,
FALSE);
6596 aic_dev->
SDptr = SDptr;
6600 INIT_LIST_HEAD(&aic_dev->
list);
6629 int tag_enabled =
FALSE;
6631 unsigned char tindex;
6633 tindex = device->
id | (device->
channel << 3);
6646 "enable tagged queueing.\n",
6648 tag_enabled =
FALSE;
6654 static int print_warning =
TRUE;
6657 printk(
KERN_INFO "aic7xxx: WARNING, insufficient tag_info instances for"
6658 " installed controllers.\n");
6659 printk(
KERN_INFO "aic7xxx: Please update the aic7xxx_tag_info array in"
6660 " the aic7xxx.c source file.\n");
6661 print_warning =
FALSE;
6664 aic7xxx_default_queue_depth;
6671 tag_enabled =
FALSE;
6676 aic7xxx_default_queue_depth;
6702 device->
lun, device->
host->cmd_per_lun);
6737 aic7xxx_slave_configure(
struct scsi_device *SDptr)
6745 aic7xxx_init_transinfo(p, aic_dev);
6746 aic7xxx_device_queue_depth(p, SDptr);
6747 if(list_empty(&aic_dev->
list))
6761 if ( aic7xxx_allocate_scb(p) == 0 )
6796 #if defined(__i386__) || defined(__alpha__)
6801 unsigned char buf[4];
6809 { 4, { 0x04, 0x90, 0x77, 0x70 },
6811 { 4, { 0x04, 0x90, 0x77, 0x71 },
6813 { 4, { 0x04, 0x90, 0x77, 0x56 },
6815 { 4, { 0x04, 0x90, 0x77, 0x57 },
6823 for (i = 0; i <
sizeof(
buf); i++)
6825 outb(0x80 + i, base);
6826 buf[
i] =
inb(base + i);
6836 if (
inb(base + 4) & 1)
6838 if (AIC7xxx[i].bios_disabled)
6849 printk(
"aic7xxx: <Adaptec 7770 SCSI Host Adapter> "
6850 "disabled at slot %d, ignored.\n", slot);
6886 unsigned short *seeprom = (
unsigned short *) sc;
6889 unsigned char bits[3];
6893 #define CLOCK_PULSE(p) \
6894 while ((aic_inb(p, STATUS_2840) & EEPROM_TF) == 0) \
6898 (void) aic_inb(p, SEECTL_2840);
6906 for (k = 0; k < (
sizeof(*sc) / 2); k++)
6918 for (i = 0; i < seeprom_read.
len; i++)
6930 for (i = 5; i >= 0; i--)
6933 temp = (temp >>
i) & 1;
6948 for (i = 0; i <= 16; i++)
6964 if (k < (
sizeof(*sc) / 2) - 1)
6966 checksum = checksum + seeprom[
k];
6981 printk(
"Computed checksum 0x%x, checksum read 0x%x\n", checksum, sc->
checksum);
6982 printk(
"Serial EEPROM:");
6983 for (k = 0; k < (
sizeof(*sc) / 2); k++)
6985 if (((k % 8) == 0) && (k != 0))
6989 printk(
" 0x%x", seeprom[k]);
6996 printk(
"aic7xxx: SEEPROM checksum error, ignoring SEEPROM settings.\n");
7004 #define CLOCK_PULSE(p) \
7009 pause_sequencer(p); \
7016 } while (((aic_inb(p, SEECTL) & SEERDY) == 0) && (++limit < 1000)); \
7120 unsigned short checksum = 0;
7123 unsigned char bits[3];
7130 if (acquire_seeprom(p) == 0)
7142 for (k = 0; k <
len; k++)
7154 for (i = 0; i < seeprom_read.
len; i++)
7157 aic_outb(p, temp,
SEECTL);
7159 temp = temp ^
SEECK;
7160 aic_outb(p, temp,
SEECTL);
7166 for (i = ((
int) chip - 1); i >= 0; i--)
7169 temp = (temp >>
i) & 1;
7171 aic_outb(p, temp,
SEECTL);
7173 temp = temp ^
SEECK;
7174 aic_outb(p, temp,
SEECTL);
7184 for (i = 0; i <= 16; i++)
7187 aic_outb(p, temp,
SEECTL);
7189 temp = temp ^
SEECK;
7190 scarray[
k] = (scarray[
k] << 1) | (aic_inb(p,
SEECTL) &
SEEDI);
7191 aic_outb(p, temp,
SEECTL);
7203 checksum = checksum + scarray[
k];
7223 printk(
"Computed checksum 0x%x, checksum read 0x%x\n",
7224 checksum, scarray[len - 1]);
7225 printk(
"Serial EEPROM:");
7226 for (k = 0; k <
len; k++)
7228 if (((k % 8) == 0) && (k != 0))
7232 printk(
" 0x%x", scarray[k]);
7236 if ( (checksum != scarray[len - 1]) || (checksum == 0) )
7251 static unsigned char
7254 unsigned char brdctl,
value;
7263 aic_outb(p, brdctl,
BRDCTL);
7265 value = aic_inb(p,
BRDCTL);
7275 aic_outb(p, brdctl,
BRDCTL);
7277 value = aic_inb(p,
BRDCTL);
7292 write_brdctl(
struct aic7xxx_host *p,
unsigned char value)
7294 unsigned char brdctl;
7303 aic_outb(p, brdctl,
BRDCTL);
7306 aic_outb(p, brdctl,
BRDCTL);
7309 aic_outb(p, brdctl,
BRDCTL);
7323 aic_outb(p, brdctl,
BRDCTL);
7326 aic_outb(p, brdctl,
BRDCTL);
7329 aic_outb(p, brdctl,
BRDCTL);
7332 aic_outb(p, brdctl,
BRDCTL);
7345 aic785x_cable_detect(
struct aic7xxx_host *p,
int *int_50,
7346 int *ext_present,
int *
eeprom)
7348 unsigned char brdctl;
7354 brdctl = aic_inb(p,
BRDCTL);
7356 *int_50 = !(brdctl &
BRDDAT5);
7357 *ext_present = !(brdctl &
BRDDAT6);
7374 aic2940_uwpro_wide_cable_detect(
struct aic7xxx_host *p,
int *int_68,
7375 int *ext_68,
int *
eeprom)
7377 unsigned char brdctl;
7391 brdctl = read_brdctl(p);
7392 *int_68 = !(brdctl &
BRDDAT7);
7399 brdctl = read_brdctl(p);
7401 *ext_68 = !(brdctl &
BRDDAT6);
7402 *eeprom = !(brdctl &
BRDDAT7);
7420 aic787x_cable_detect(
struct aic7xxx_host *p,
int *int_50,
int *int_68,
7421 int *ext_present,
int *
eeprom)
7423 unsigned char brdctl;
7437 brdctl = read_brdctl(p);
7438 *int_50 = !(brdctl &
BRDDAT6);
7439 *int_68 = !(brdctl &
BRDDAT7);
7446 brdctl = read_brdctl(p);
7448 *ext_present = !(brdctl &
BRDDAT6);
7449 *eeprom = !(brdctl &
BRDDAT7);
7467 aic7xxx_ultra2_term_detect(
struct aic7xxx_host *p,
int *enableSE_low,
7468 int *enableSE_high,
int *enableLVD_low,
7469 int *enableLVD_high,
int *eprom_present)
7471 unsigned char brdctl;
7473 brdctl = read_brdctl(p);
7475 *eprom_present = (brdctl &
BRDDAT7);
7476 *enableSE_high = (brdctl &
BRDDAT6);
7477 *enableSE_low = (brdctl &
BRDDAT5);
7478 *enableLVD_high = (brdctl &
BRDDAT4);
7479 *enableLVD_low = (brdctl &
BRDDAT3);
7493 int internal50_present = 0;
7494 int internal68_present = 0;
7495 int external_present = 0;
7496 int eprom_present = 0;
7497 int enableSE_low = 0;
7498 int enableSE_high = 0;
7499 int enableLVD_low = 0;
7500 int enableLVD_high = 0;
7501 unsigned char brddat = 0;
7502 unsigned char max_target = 0;
7503 unsigned char sxfrctl1 = aic_inb(p,
SXFRCTL1);
7505 if (acquire_seeprom(p))
7526 if (aic7xxx_override_term == -1)
7528 aic7xxx_ultra2_term_detect(p, &enableSE_low, &enableSE_high,
7529 &enableLVD_low, &enableLVD_high,
7558 if (enableLVD_low != 0)
7567 if (enableLVD_high != 0)
7575 if (enableSE_low != 0)
7583 if (enableSE_high != 0)
7608 aic2940_uwpro_wide_cable_detect(p, &internal68_present,
7614 internal68_present ?
"YES" :
"NO",
7615 external_present ?
"YES" :
"NO");
7618 eprom_present ?
"is" :
"is not");
7619 if (internal68_present && external_present)
7666 "are correct.\n", p->
host_no);
7668 "device termination\n", p->
host_no);
7670 "CTRL-A when prompted\n", p->
host_no);
7677 aic787x_cable_detect(p, &internal50_present, &internal68_present,
7678 &external_present, &eprom_present);
7682 aic785x_cable_detect(p, &internal50_present, &external_present,
7686 if (max_target <= 8)
7687 internal68_present = 0;
7693 internal50_present ?
"YES" :
"NO",
7694 internal68_present ?
"YES" :
"NO",
7695 external_present ?
"YES" :
"NO");
7701 internal50_present ?
"YES" :
"NO",
7702 external_present ?
"YES" :
"NO");
7706 eprom_present ?
"is" :
"is not");
7714 if (internal50_present && internal68_present && external_present)
7719 "in use at a time!\n", p->
host_no);
7726 internal50_present = external_present = 0;
7727 enableSE_high = enableSE_low = 1;
7730 if ((max_target > 8) &&
7731 ((external_present == 0) || (internal68_present == 0)) )
7740 if ( ((internal50_present ? 1 : 0) +
7741 (internal68_present ? 1 : 0) +
7742 (external_present ? 1 : 0)) <= 1 )
7772 write_brdctl(p, brddat);
7823 aic_outb(p, i - 1,
SCBPTR);
7834 if ( i == AIC7XXX_MAXSCB )
7854 unsigned char term, scsi_conf;
7911 printk(
KERN_INFO "(scsi%d) Twin Channel, A SCSI ID %d, B SCSI ID %d, ",
7958 if (aic7xxx_stpwlev != -1)
7965 unsigned char devconfig;
7968 if ( (aic7xxx_stpwlev >> p->
instance) & 0x01 )
7972 printk(
"(scsi%d) Force setting STPWLEVEL bit\n", p->
host_no);
7978 printk(
"(scsi%d) Force clearing STPWLEVEL bit\n", p->
host_no);
7989 if (aic7xxx_override_term != -1)
7997 unsigned char term_override;
7999 term_override = ( (aic7xxx_override_term >> (p->
instance * 4)) & 0x0f);
8006 if (term_override & 0x02)
8010 if (term_override & 0x01)
8026 configure_termination(p);
8030 configure_termination(p);
8048 scsi_conf = aic_inb(p,
SCSICONF + 1);
8050 aic_outb(p, (scsi_conf &
ENSPCHK) | aic7xxx_seltime | term |
8074 aic_outb(p, (scsi_conf &
ENSPCHK) | aic7xxx_seltime | term |
8109 if (!(aic7xxx_no_reset))
8129 unsigned int hscb_physaddr;
8145 printk(
"(scsi%d) Unable to allocate hardware SCB array; "
8146 "failing detection.\n", p->
host_no);
8153 aic_outb(p, hscb_physaddr & 0xFF,
HSCB_ADDR);
8154 aic_outb(p, (hscb_physaddr >> 8) & 0xFF,
HSCB_ADDR + 1);
8155 aic_outb(p, (hscb_physaddr >> 16) & 0xFF,
HSCB_ADDR + 2);
8156 aic_outb(p, (hscb_physaddr >> 24) & 0xFF,
HSCB_ADDR + 3);
8162 printk(
"(scsi%d) Unable to allocate hardware FIFO arrays; "
8163 "failing detection.\n", p->
host_no);
8170 for (i = 0; i < 256; i++)
8178 aic_outb(p, hscb_physaddr & 0xFF,
SCBID_ADDR);
8179 aic_outb(p, (hscb_physaddr >> 8) & 0xFF,
SCBID_ADDR + 1);
8180 aic_outb(p, (hscb_physaddr >> 16) & 0xFF,
SCBID_ADDR + 2);
8181 aic_outb(p, (hscb_physaddr >> 24) & 0xFF,
SCBID_ADDR + 3);
8224 p->
next = first_aic7xxx;
8239 aic7xxx_allocate_scb(p);
8258 if ( !(aic7xxx_no_reset) )
8265 aic7xxx_reset_current_bus(p);
8281 aic7xxx_reset_current_bus(p);
8289 "the no_reset\n", p->
host_no);
8322 if(aic_inb(p,
INTSTAT) & INT_PEND)
8323 printk(
INFO_LEAD "spurious interrupt during configuration, cleared.\n",
8325 aic7xxx_clear_intstat(p);
8327 unpause_sequencer(p,
TRUE);
8343 unsigned char sblkctl;
8496 aic7xxx_load_seeprom(
struct aic7xxx_host *p,
unsigned char *sxfrctl1)
8498 int have_seeprom = 0;
8499 int i, max_targets,
mask;
8500 unsigned char scsirate, scsi_conf;
8501 unsigned short scarray[128];
8518 have_seeprom = read_284x_seeprom(p, (
struct seeprom_config *) scarray);
8555 printk(
"\naic7xxx: No SEEPROM available.\n");
8566 printk(
"aic7xxx: Using default values.\n");
8571 printk(
"aic7xxx: Using leftover BIOS values.\n");
8579 if (aic7xxx_extended)
8787 ((p->
ultraenb & mask) ? 0x18 : 0x10);
8790 p->
user[
i].
period = aic7xxx_find_period(p, scsirate,
8797 ((p->
ultraenb & mask) ? 0x18 : 0x10);
8799 p->
user[
i].
period = aic7xxx_find_period(p, scsirate,
8812 p->
user[
i].
period = aic7xxx_find_period(p, scsirate,
8818 p->
user[
i].
period = aic7xxx_find_period(p, scsirate,
8897 unsigned short tmp_word;
8979 #if defined(__i386__) || defined(__alpha__)
8983 unsigned char sxfrctl1;
8984 #if defined(__i386__) || defined(__alpha__)
8985 unsigned char hcntrl, hostconf;
8997 aic7xxx_setup(aic7xxx);
9000 template->proc_name =
"aic7xxx";
9017 unsigned short seeprom_size;
9018 unsigned short seeprom_type;
9019 }
const aic_pdevs[] = {
9172 unsigned int devconfig,
i, oldverbose;
9192 else if ( (temp_p = kzalloc(
sizeof(
struct aic7xxx_host),
9196 temp_p->
flags = aic_pdevs[
i].flags;
9197 temp_p->
features = aic_pdevs[
i].features;
9199 temp_p->
sc_size = aic_pdevs[
i].seeprom_size;
9200 temp_p->
sc_type = aic_pdevs[
i].seeprom_type;
9212 while(current_p && temp_p)
9224 current_p = current_p->
next;
9228 printk(
"aic7xxx: <%s> at PCI %d/%d/%d\n",
9233 printk(
"aic7xxx: I/O ports already in use, ignoring.\n");
9239 printk(
"aic7xxx: <%s> at PCI %d/%d\n",
9240 board_names[aic_pdevs[i].board_name_index],
9243 pci_read_config_word(pdev,
PCI_COMMAND, &command);
9246 printk(
"aic7xxx: Initial PCI_COMMAND value was 0x%x\n",
9249 #ifdef AIC7XXX_STRICT_PCI_SETUP
9256 if (aic7xxx_pci_parity == 0)
9258 pci_write_config_word(pdev,
PCI_COMMAND, command);
9259 #ifdef AIC7XXX_STRICT_PCI_SETUP
9260 pci_read_config_dword(pdev,
DEVCONFIG, &devconfig);
9263 printk(
"aic7xxx: Initial DEVCONFIG value was 0x%x\n", devconfig);
9265 devconfig |= 0x80000040;
9266 pci_write_config_dword(pdev,
DEVCONFIG, devconfig);
9271 if ( ((temp_p->
base == 0) &&
9272 (temp_p->
mbase == 0)) ||
9273 (temp_p->
irq == 0) )
9275 printk(
"aic7xxx: <%s> at PCI %d/%d/%d\n",
9276 board_names[aic_pdevs[i].board_name_index],
9280 printk(
"aic7xxx: Controller disabled by BIOS, ignoring.\n");
9281 goto skip_pci_controller;
9296 if(aic_inb(temp_p,
HCNTRL) == 0xff)
9302 board_names[aic_pdevs[i].board_name_index],
9307 "Programmed I/O.\n");
9310 if(temp_p->
base == 0)
9312 printk(
"aic7xxx: <%s> at PCI %d/%d/%d\n",
9313 board_names[aic_pdevs[i].board_name_index],
9317 printk(
"aic7xxx: Controller disabled by BIOS, ignoring.\n");
9318 goto skip_pci_controller;
9333 pause_sequencer(temp_p);
9342 aic7xxx_pci_intr(temp_p);
9357 sxfrctl1 = aic_inb(temp_p,
SXFRCTL1);
9359 if (aic7xxx_chip_reset(temp_p) == -1)
9361 goto skip_pci_controller;
9371 aic_outb(temp_p, sxfrctl1,
SXFRCTL1);
9418 pci_read_config_dword(pdev,
DEVCONFIG, &devconfig);
9420 pci_write_config_dword(pdev,
DEVCONFIG, devconfig);
9447 aic_outb(temp_p, 0x00, 0x0b);
9448 aic_outb(temp_p, 0x10, 0x0a);
9459 aic7xxx_load_seeprom(temp_p, &sxfrctl1);
9464 aic_outb(temp_p, (aic_inb(temp_p,
DSCOMMAND0) |
9467 aic7xxx_load_seeprom(temp_p, &sxfrctl1);
9475 aic_outb(temp_p, (aic_inb(temp_p,
DSCOMMAND0) |
9480 aic7xxx_load_seeprom(temp_p, &sxfrctl1);
9486 pci_read_config_dword(pdev,
DEVCONFIG, &devconfig);
9487 if ((devconfig & 0xff) >= 1)
9489 aic_outb(temp_p, (aic_inb(temp_p,
DSCOMMAND0) |
9493 aic7xxx_load_seeprom(temp_p, &sxfrctl1);
9513 while(current_p !=
NULL)
9536 current_p = current_p->
next;
9556 pci_read_config_dword(pdev,
DEVCONFIG, &devconfig);
9568 else if (aic_inb(temp_p,
DSCOMMAND0) & RAMPSM_ULTRA2)
9571 board_names[aic_pdevs[i].board_name_index],
9575 printk(
"aic7xxx: external SCB RAM detected, "
9576 "but not enabled\n");
9581 if ((devconfig &
RAMPSM) && (aic7xxx_scbram))
9587 else if (devconfig & RAMPSM)
9590 board_names[aic_pdevs[i].board_name_index],
9594 printk(
"aic7xxx: external SCB RAM detected, "
9595 "but not enabled\n");
9598 pci_write_config_dword(pdev,
DEVCONFIG, devconfig);
9632 aic7xxx_configure_bugs(temp_p);
9637 if ( list_p ==
NULL )
9639 list_p = current_p = temp_p;
9645 current_p = current_p->
next;
9646 current_p->
next = temp_p;
9651 skip_pci_controller:
9659 printk(
"aic7xxx: Found <%s>\n",
9660 board_names[aic_pdevs[i].board_name_index]);
9669 #if defined(__i386__) || defined(__alpha__)
9675 !(aic7xxx_no_probe) )
9689 type = aic7xxx_probe(slot, base +
AHC_HID0, &flags);
9709 if (aic7xxx_irq_trigger == 1)
9711 else if (aic7xxx_irq_trigger == 0)
9723 aic_outb(temp_p, hcntrl | PAUSE,
HCNTRL);
9724 while( (aic_inb(temp_p,
HCNTRL) & PAUSE) == 0 ) ;
9725 if (aic7xxx_chip_reset(temp_p) == -1)
9728 temp_p->
irq = aic_inb(temp_p,
INTDEF) & 0x0F;
9731 switch (temp_p->
irq)
9743 "level %d, ignoring.\n", temp_p->
irq);
9760 list_p = current_p = temp_p;
9766 current_p = current_p->
next;
9767 current_p->
next = temp_p;
9775 printk(
"aic7xxx: <%s> at EISA %d\n",
9776 board_names[2], slot);
9793 printk(
"aic7xxx: <%s> at EISA %d\n",
9794 board_names[3], slot);
9832 aic7xxx_load_seeprom(temp_p, &sxfrctl1);
9844 if (aic_inb(temp_p,
SCSICONF) & TERM_ENB)
9846 aic7xxx_load_seeprom(temp_p, &sxfrctl1);
9849 printk(
"aic7xxx: <%s> at VLB %d\n",
9850 board_names[2], slot);
9875 printk(
KERN_INFO "aic7xxx: BIOS %sabled, IO Port 0x%lx, IRQ %d (%s)\n",
9878 (temp_p->
pause &
IRQMS) ?
"level sensitive" :
"edge triggered");
9891 hostconf = aic_inb(temp_p,
HOSTCONF);
9893 aic_outb(temp_p, (hostconf << 2) &
BOFF,
BUSTIME);
9919 prev_p = vlb = pci =
NULL;
9922 while (temp_p !=
NULL)
9938 temp_p = temp_p->
next;
9945 while ( (current_p !=
NULL) &&
9949 current_p = current_p->
next;
9953 prev_p->
next = temp_p;
9954 temp_p = temp_p->
next;
9955 prev_p->
next->next = current_p;
9960 temp_p = temp_p->
next;
9961 vlb->
next = current_p;
9984 temp_p = temp_p->
next;
9991 if (!aic7xxx_reverse_scan)
9993 while ( (current_p !=
NULL) &&
10000 current_p = current_p->
next;
10005 while ( (current_p !=
NULL) &&
10011 prev_p = current_p;
10012 current_p = current_p->
next;
10029 prev_p = current_p;
10030 current_p = current_p->
next;
10037 prev_p = current_p;
10038 current_p = current_p->
next;
10042 if (prev_p !=
NULL)
10044 prev_p->
next = temp_p;
10045 temp_p = temp_p->
next;
10046 prev_p->
next->next = current_p;
10051 temp_p = temp_p->
next;
10052 pci->
next = current_p;
10057 sort_list[1] = pci;
10059 sort_list[3] = pci;
10075 temp_p = sort_list[
i];
10076 while(temp_p !=
NULL)
10079 p = aic7xxx_alloc(
template, temp_p);
10083 if (aic7xxx_register(
template, p, (--left)) == 0)
10086 aic7xxx_release(p->
host);
10089 else if (aic7xxx_dump_card)
10091 pause_sequencer(p);
10092 aic7xxx_print_card(p);
10093 aic7xxx_print_scratch_ram(p);
10094 unpause_sequencer(p,
TRUE);
10097 current_p = temp_p;
10117 unsigned short mask;
10124 mask = (0x01 << tindex);
10167 ((cmd->
device->channel & 0x01) << 3) | (cmd->
device->lun & 0x07);
10245 aic_dev = cmd->
device->hostdata;
10246 #ifdef AIC7XXX_VERBOSE_DEBUGGING
10250 "depth, active=%d\n",
10259 aic7xxx_allocate_scb(p);
10286 aic7xxx_buildscb(p, cmd, scb);
10291 aic7xxx_run_waiting_queues(p);
10314 unsigned char saved_scbptr, lastphase;
10315 unsigned char hscb_index;
10321 printk(
KERN_ERR "aic7xxx_bus_device_reset: called with NULL cmd!\n");
10334 aic7xxx_done_cmds_complete(p);
10340 pause_sequencer(p);
10349 printk(
"Data-Out phase\n");
10352 printk(
"Data-In phase\n");
10355 printk(
"Command phase\n");
10358 printk(
"Message-Out phase\n");
10361 printk(
"Status phase\n");
10364 printk(
"Message-In phase\n");
10370 printk(
"while idle, LASTPHASE = 0x%x\n", lastphase);
10382 aic_inb(p,
STCNT + 2) << 16 | aic_inb(p,
STCNT + 1) << 8 |
10383 aic_inb(p,
STCNT));
10386 channel = cmd->device->channel;
10400 saved_scbptr = aic_inb(p,
SCBPTR);
10401 disconnected =
FALSE;
10408 "SCB flags = 0x%x.\n", p->
host_no,
10410 unpause_sequencer(p,
FALSE);
10419 unpause_sequencer(p,
FALSE);
10432 unpause_sequencer(p,
FALSE);
10433 spin_unlock_irq(p->
host->host_lock);
10435 spin_lock_irq(p->
host->host_lock);
10453 if (aic7xxx_search_qinfifo(p, cmd->device->channel, cmd->device->id, cmd->device->lun, hscb->
tag,
10456 disconnected =
TRUE;
10457 if ((hscb_index = aic7xxx_find_scb(p, scb)) !=
SCB_LIST_NULL)
10459 unsigned char scb_control;
10461 aic_outb(p, hscb_index,
SCBPTR);
10490 aic_outb(p, saved_scbptr,
SCBPTR);
10491 unpause_sequencer(p,
FALSE);
10492 spin_unlock_irq(p->
host->host_lock);
10494 spin_lock_irq(p->
host->host_lock);
10501 static int aic7xxx_bus_device_reset(
struct scsi_cmnd *cmd)
10505 spin_lock_irq(cmd->
device->host->host_lock);
10506 rc = __aic7xxx_bus_device_reset(cmd);
10507 spin_unlock_irq(cmd->
device->host->host_lock);
10525 printk(
"p->flags=0x%lx, p->chip=0x%x, p->features=0x%x, "
10526 "sequencer %s paused\n",
10528 (aic_inb(p,
HCNTRL) & PAUSE) ?
"is" :
"isn't" );
10529 pause_sequencer(p);
10531 aic7xxx_print_card(p);
10532 aic7xxx_print_scratch_ram(p);
10533 spin_unlock_irq(p->
host->host_lock);
10544 static int __aic7xxx_abort(
struct scsi_cmnd *cmd)
10549 unsigned char saved_hscbptr, hscbptr, scb_control;
10565 aic7xxx_done_cmds_complete(p);
10571 pause_sequencer(p);
10581 if (aic7xxx_panic_on_abort)
10582 aic7xxx_panic_abort(p, cmd);
10586 printk(
INFO_LEAD "Aborting scb %d, flags 0x%x, SEQADDR 0x%x, LASTPHASE "
10617 if ( ((found = aic7xxx_search_qinfifo(p, cmd->
device->id, cmd->
device->channel,
10631 saved_hscbptr = aic_inb(p,
SCBPTR);
10634 aic_outb(p, hscbptr,
SCBPTR);
10660 aic_outb(p, next,
SCBPTR);
10661 if (next == hscbptr)
10666 aic_outb(p, prev,
SCBPTR);
10671 aic_outb(p, hscbptr,
SCBPTR);
10683 aic7xxx_add_curscb_to_free_list(p);
10687 else if (!disconnected)
10700 unpause_sequencer(p,
FALSE);
10711 aic_outb(p, saved_hscbptr,
SCBPTR);
10737 unpause_sequencer(p,
FALSE);
10738 spin_unlock_irq(p->
host->host_lock);
10740 spin_lock_irq(p->
host->host_lock);
10756 aic7xxx_run_done_queue(p,
TRUE);
10757 unpause_sequencer(p,
FALSE);
10761 static int aic7xxx_abort(
struct scsi_cmnd *cmd)
10765 spin_lock_irq(cmd->
device->host->host_lock);
10766 rc = __aic7xxx_abort(cmd);
10767 spin_unlock_irq(cmd->
device->host->host_lock);
10783 static int aic7xxx_reset(
struct scsi_cmnd *cmd)
10790 spin_lock_irq(p->
host->host_lock);
10796 if (scb->
cmd != cmd)
10812 if (aic7xxx_panic_on_abort)
10813 aic7xxx_panic_abort(p, cmd);
10815 pause_sequencer(p);
10820 pause_sequencer(p);
10822 aic7xxx_done_cmds_complete(p);
10824 if(scb && (scb->
cmd ==
NULL))
10830 unpause_sequencer(p,
FALSE);
10831 spin_unlock_irq(p->
host->host_lock);
10839 aic7xxx_reset_channel(p, cmd->
device->channel,
TRUE);
10842 aic7xxx_reset_channel(p, cmd->
device->channel ^ 0x01,
TRUE);
10843 restart_sequencer(p);
10846 aic7xxx_clear_intstat(p);
10851 aic7xxx_run_done_queue(p,
TRUE);
10852 unpause_sequencer(p,
FALSE);
10853 spin_unlock_irq(p->
host->host_lock);
10876 unsigned char *
buf;
10883 ret =
scsi_partsize(buf, capacity, &geom[2], &geom[0], &geom[1]);
10891 cylinders = capacity >> 11;
10897 cylinders = capacity >> 14;
10898 if(capacity > (65535 * heads * sectors))
10901 cylinders = ((
unsigned int)capacity) / (
unsigned int)(heads * sectors);
10904 geom[0] = (
int)heads;
10905 geom[1] = (
int)sectors;
10906 geom[2] = (
int)cylinders;
10920 aic7xxx_release(
struct Scsi_Host *host)
10942 next = first_aic7xxx;
10943 while(next !=
NULL)
10948 first_aic7xxx = next->
next;
10950 prev->next = next->
next;
10976 static struct register_ranges {
10981 {10, {0x00, 0x05, 0x08, 0x11, 0x18, 0x19, 0x1f, 0x1f, 0x60, 0x60,
10982 0x62, 0x66, 0x80, 0x8e, 0x90, 0x95, 0x97, 0x97, 0x9b, 0x9f} },
10983 { 9, {0x00, 0x05, 0x08, 0x11, 0x18, 0x1f, 0x60, 0x60, 0x62, 0x66,
10984 0x80, 0x8e, 0x90, 0x95, 0x97, 0x97, 0x9a, 0x9f} },
10985 { 9, {0x00, 0x05, 0x08, 0x11, 0x18, 0x1f, 0x60, 0x60, 0x62, 0x66,
10986 0x80, 0x8e, 0x90, 0x95, 0x97, 0x97, 0x9a, 0x9f} },
10987 {10, {0x00, 0x05, 0x08, 0x11, 0x18, 0x19, 0x1c, 0x1f, 0x60, 0x60,
10988 0x62, 0x66, 0x80, 0x8e, 0x90, 0x95, 0x97, 0x97, 0x9a, 0x9f} },
10989 {10, {0x00, 0x05, 0x08, 0x11, 0x18, 0x1a, 0x1c, 0x1f, 0x60, 0x60,
10990 0x62, 0x66, 0x80, 0x8e, 0x90, 0x95, 0x97, 0x97, 0x9a, 0x9f} },
10991 {16, {0x00, 0x05, 0x08, 0x11, 0x18, 0x1f, 0x60, 0x60, 0x62, 0x66,
10992 0x84, 0x8e, 0x90, 0x95, 0x97, 0x97, 0x9a, 0x9a, 0x9f, 0x9f,
10993 0xe0, 0xf1, 0xf4, 0xf4, 0xf6, 0xf6, 0xf8, 0xf8, 0xfa, 0xfc,
10995 {12, {0x00, 0x05, 0x08, 0x11, 0x18, 0x19, 0x1b, 0x1f, 0x60, 0x60,
10996 0x62, 0x66, 0x80, 0x8e, 0x90, 0x95, 0x97, 0x97, 0x9a, 0x9a,
10997 0x9f, 0x9f, 0xe0, 0xf1} },
10998 {16, {0x00, 0x05, 0x08, 0x11, 0x18, 0x1f, 0x60, 0x60, 0x62, 0x66,
10999 0x84, 0x8e, 0x90, 0x95, 0x97, 0x97, 0x9a, 0x9a, 0x9f, 0x9f,
11000 0xe0, 0xf1, 0xf4, 0xf4, 0xf6, 0xf6, 0xf8, 0xf8, 0xfa, 0xfc,
11002 {12, {0x00, 0x05, 0x08, 0x11, 0x18, 0x1f, 0x60, 0x60, 0x62, 0x66,
11003 0x84, 0x8e, 0x90, 0x95, 0x97, 0x97, 0x9a, 0x9a, 0x9c, 0x9f,
11004 0xe0, 0xf1, 0xf4, 0xfc} },
11005 {12, {0x00, 0x05, 0x08, 0x11, 0x18, 0x1f, 0x60, 0x60, 0x62, 0x66,
11006 0x84, 0x8e, 0x90, 0x95, 0x97, 0x97, 0x9a, 0x9a, 0x9c, 0x9f,
11007 0xe0, 0xf1, 0xf4, 0xfc} },
11032 for(i=0; i<cards_ds[
chip].num_ranges; i++)
11034 for(j = cards_ds[chip].range_val[ i * 2 ];
11035 j <= cards_ds[
chip].range_val[ i * 2 + 1 ] ;
11038 printk(
"%02x:%02x ", j, aic_inb(p, j));
11078 printk(
"Scratch RAM:\n");
11081 printk(
"%02x:%02x ", i, aic_inb(p, i));
11092 printk(
"%02x:%02x ", i, aic_inb(p, i));
11112 .detect = aic7xxx_detect,
11113 .release = aic7xxx_release,
11114 .info = aic7xxx_info,
11115 .queuecommand = aic7xxx_queue,
11116 .slave_alloc = aic7xxx_slave_alloc,
11117 .slave_configure = aic7xxx_slave_configure,
11118 .slave_destroy = aic7xxx_slave_destroy,
11119 .bios_param = aic7xxx_biosparam,
11120 .eh_abort_handler = aic7xxx_abort,
11121 .eh_device_reset_handler = aic7xxx_bus_device_reset,
11122 .eh_host_reset_handler = aic7xxx_reset,
11125 .max_sectors = 2048,