238 #include <linux/module.h>
243 #include <linux/errno.h>
244 #include <linux/string.h>
245 #include <linux/wait.h>
251 #include <linux/kernel.h>
255 #include <linux/list.h>
256 #include <linux/slab.h>
272 #if defined(PCMCIA) || defined(MODULE)
273 #if !defined(AUTOCONF)
278 #if !defined(AUTOCONF) && !defined(SETUP0)
279 #error define AUTOCONF or SETUP0
282 #if defined(AHA152X_DEBUG)
283 #define DEBUG_DEFAULT debug_eh
285 #define DPRINTK(when,msgs...) \
286 do { if(HOSTDATA(shpnt)->debug & (when)) printk(msgs); } while(0)
288 #define DO_LOCK(flags) \
290 if(spin_is_locked(&QLOCK)) { \
291 DPRINTK(debug_intr, DEBUG_LEAD "(%s:%d) already locked at %s:%d\n", CMDINFO(CURRENT_SC), __func__, __LINE__, QLOCKER, QLOCKERL); \
293 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locking\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \
294 spin_lock_irqsave(&QLOCK,flags); \
295 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locked\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \
300 #define DO_UNLOCK(flags) \
302 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocking (locked at %s:%d)\n", CMDINFO(CURRENT_SC), __func__, __LINE__, QLOCKER, QLOCKERL); \
303 spin_unlock_irqrestore(&QLOCK,flags); \
304 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocked\n", CMDINFO(CURRENT_SC), __func__, __LINE__); \
305 QLOCKER="(not locked)"; \
310 #define DPRINTK(when,msgs...)
311 #define DO_LOCK(flags) spin_lock_irqsave(&QLOCK,flags)
312 #define DO_UNLOCK(flags) spin_unlock_irqrestore(&QLOCK,flags)
315 #define LEAD "(scsi%d:%d:%d) "
316 #define WARN_LEAD KERN_WARNING LEAD
317 #define INFO_LEAD KERN_INFO LEAD
318 #define NOTE_LEAD KERN_NOTICE LEAD
319 #define ERR_LEAD KERN_ERR LEAD
320 #define DEBUG_LEAD KERN_DEBUG LEAD
321 #define CMDINFO(cmd) \
322 (cmd) ? ((cmd)->device->host->host_no) : -1, \
323 (cmd) ? ((cmd)->device->id & 0x0f) : -1, \
324 (cmd) ? ((cmd)->device->lun & 0x07) : -1
329 scsi_set_resid(cmd, scsi_get_resid(cmd) + inc);
332 #define DELAY_DEFAULT 1000
340 #define IRQ_MAX (nr_irqs-1)
367 static int io[] = {0, 0};
371 static int irq[] = {0, 0};
375 static int scsiid[] = {7, 7};
379 static int reconnect[] = {1, 1};
383 static int parity[] = {1, 1};
387 static int sync[] = {1, 1};
395 static int exttrans[] = {0, 0};
399 #if !defined(AHA152X_DEBUG)
400 static int aha152x[] = {0, 11, 7, 1, 1, 0,
DELAY_DEFAULT, 0};
404 static int aha152x1[] = {0, 11, 7, 1, 1, 0,
DELAY_DEFAULT, 0};
437 { ISAPNP_DEVICE_SINGLE_END, }
488 #if defined(AHA152X_DEBUG)
496 #if defined(AHA152X_STAT)
499 int busfree_without_any_action;
500 int busfree_without_old_command;
501 int busfree_without_new_command;
502 int busfree_without_done_command;
503 int busfree_with_check_condition;
576 #define HOSTDATA(shpnt) ((struct aha152x_hostdata *) &shpnt->hostdata)
578 #define HOSTNO ((shpnt)->host_no)
580 #define CURRENT_SC (HOSTDATA(shpnt)->current_SC)
581 #define DONE_SC (HOSTDATA(shpnt)->done_SC)
582 #define ISSUE_SC (HOSTDATA(shpnt)->issue_SC)
583 #define DISCONNECTED_SC (HOSTDATA(shpnt)->disconnected_SC)
584 #define QLOCK (HOSTDATA(shpnt)->lock)
585 #define QLOCKER (HOSTDATA(shpnt)->locker)
586 #define QLOCKERL (HOSTDATA(shpnt)->lockerl)
588 #define STATE (HOSTDATA(shpnt)->state)
589 #define PREVSTATE (HOSTDATA(shpnt)->prevstate)
590 #define LASTSTATE (HOSTDATA(shpnt)->laststate)
592 #define RECONN_TARGET (HOSTDATA(shpnt)->target)
594 #define CMD_I (HOSTDATA(shpnt)->cmd_i)
596 #define MSGO(i) (HOSTDATA(shpnt)->msgo[i])
597 #define MSGO_I (HOSTDATA(shpnt)->msgo_i)
598 #define MSGOLEN (HOSTDATA(shpnt)->msgo_len)
599 #define ADDMSGO(x) (MSGOLEN<256 ? (void)(MSGO(MSGOLEN++)=x) : aha152x_error(shpnt,"MSGO overflow"))
601 #define MSGI(i) (HOSTDATA(shpnt)->msgi[i])
602 #define MSGILEN (HOSTDATA(shpnt)->msgi_len)
603 #define ADDMSGI(x) (MSGILEN<256 ? (void)(MSGI(MSGILEN++)=x) : aha152x_error(shpnt,"MSGI overflow"))
605 #define DATA_LEN (HOSTDATA(shpnt)->data_len)
607 #define SYNCRATE (HOSTDATA(shpnt)->syncrate[CURRENT_SC->device->id])
608 #define SYNCNEG (HOSTDATA(shpnt)->syncneg[CURRENT_SC->device->id])
610 #define DELAY (HOSTDATA(shpnt)->delay)
611 #define EXT_TRANS (HOSTDATA(shpnt)->ext_trans)
612 #define TC1550 (HOSTDATA(shpnt)->tc1550)
613 #define RECONNECT (HOSTDATA(shpnt)->reconnect)
614 #define PARITY (HOSTDATA(shpnt)->parity)
615 #define SYNCHRONOUS (HOSTDATA(shpnt)->synchronous)
617 #define HOSTIOPORT0 (HOSTDATA(shpnt)->io_port0)
618 #define HOSTIOPORT1 (HOSTDATA(shpnt)->io_port1)
620 #define SCDATA(SCpnt) ((struct aha152x_scdata *) (SCpnt)->host_scribble)
621 #define SCNEXT(SCpnt) SCDATA(SCpnt)->next
622 #define SCSEM(SCpnt) SCDATA(SCpnt)->done
624 #define SG_ADDRESS(buffer) ((char *) sg_virt((buffer)))
627 static void seldi_run(
struct Scsi_Host *shpnt);
628 static void seldo_run(
struct Scsi_Host *shpnt);
629 static void selto_run(
struct Scsi_Host *shpnt);
630 static void busfree_run(
struct Scsi_Host *shpnt);
632 static void msgo_init(
struct Scsi_Host *shpnt);
633 static void msgo_run(
struct Scsi_Host *shpnt);
634 static void msgo_end(
struct Scsi_Host *shpnt);
636 static void cmd_init(
struct Scsi_Host *shpnt);
637 static void cmd_run(
struct Scsi_Host *shpnt);
638 static void cmd_end(
struct Scsi_Host *shpnt);
640 static void datai_init(
struct Scsi_Host *shpnt);
641 static void datai_run(
struct Scsi_Host *shpnt);
642 static void datai_end(
struct Scsi_Host *shpnt);
644 static void datao_init(
struct Scsi_Host *shpnt);
645 static void datao_run(
struct Scsi_Host *shpnt);
646 static void datao_end(
struct Scsi_Host *shpnt);
648 static void status_run(
struct Scsi_Host *shpnt);
650 static void msgi_run(
struct Scsi_Host *shpnt);
651 static void msgi_end(
struct Scsi_Host *shpnt);
653 static void parerr_run(
struct Scsi_Host *shpnt);
654 static void rsti_run(
struct Scsi_Host *shpnt);
656 static void is_complete(
struct Scsi_Host *shpnt);
671 {
"seldo",
NULL, seldo_run,
NULL, 0},
672 {
"seldi",
NULL, seldi_run,
NULL, 0},
673 {
"selto",
NULL, selto_run,
NULL, 0},
674 {
"busfree",
NULL, busfree_run,
NULL, 0},
675 {
"msgo", msgo_init, msgo_run, msgo_end, 1},
676 {
"cmd", cmd_init, cmd_run, cmd_end, 1},
677 {
"msgi",
NULL, msgi_run, msgi_end, 1},
678 {
"status",
NULL, status_run,
NULL, 1},
679 {
"datai", datai_init, datai_run, datai_end, 0},
680 {
"datao", datao_init, datao_run, datao_end, 0},
681 {
"parerr",
NULL, parerr_run,
NULL, 0},
687 static void reset_ports(
struct Scsi_Host *shpnt);
688 static void aha152x_error(
struct Scsi_Host *shpnt,
char *
msg);
692 static void disp_ports(
struct Scsi_Host *shpnt);
694 static void show_queues(
struct Scsi_Host *shpnt);
695 static void disp_enintr(
struct Scsi_Host *shpnt);
732 for (ptr = *SC, prev =
NULL;
753 for (ptr = *SC, prev =
NULL;
791 INIT_LIST_HEAD(&
HOSTDATA(shpnt)->host_list);
815 #if defined(AHA152X_DEBUG)
816 HOSTDATA(shpnt)->debug = setup->debug;
826 printk(
"aha152x: resetting bus...\n");
836 "vital data: rev=%x, "
837 "io=0x%03lx (0x%03lx/0x%03lx), "
844 "extended translation=%s\n",
851 PARITY ?
"enabled" :
"disabled",
884 "Please verify.\n", shpnt->
host_no, shpnt->
irq);
899 if( scsi_add_host(shpnt,
NULL) ) {
945 static int setup_expected_interrupts(
struct Scsi_Host *shpnt)
989 #if defined(AHA152X_DEBUG)
993 scsi_sg_count(SCpnt), scsi_bufflen(SCpnt));
1000 SCpnt->
SCp.Status = 0x1;
1001 SCpnt->
SCp.Message = 0;
1002 SCpnt->
SCp.have_data_in = 0;
1003 SCpnt->
SCp.sent_command = 0;
1028 if ((phase &
resetting) || !scsi_sglist(SCpnt)) {
1030 SCpnt->
SCp.this_residual = 0;
1031 scsi_set_resid(SCpnt, 0);
1033 SCpnt->
SCp.buffers_residual = 0;
1035 scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
1036 SCpnt->
SCp.buffer = scsi_sglist(SCpnt);
1038 SCpnt->
SCp.this_residual = SCpnt->
SCp.buffer->length;
1039 SCpnt->
SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
1044 #if defined(AHA152X_STAT)
1056 setup_expected_interrupts(shpnt);
1078 return aha152x_internal_queue(SCpnt,
NULL, 0,
done);
1088 static
void reset_done(
Scsi_Cmnd *SCpnt)
1105 static int aha152x_abort(
Scsi_Cmnd *SCpnt)
1109 unsigned long flags;
1111 #if defined(AHA152X_DEBUG)
1154 static int aha152x_device_reset(
Scsi_Cmnd * SCpnt)
1159 unsigned char old_cmd_len = SCpnt->
cmd_len;
1160 unsigned long flags;
1161 unsigned long timeleft;
1163 #if defined(AHA152X_DEBUG)
1182 aha152x_internal_queue(SCpnt, &
done, resetting, reset_done);
1208 }
else if(disconnected) {
1234 if (!ptr->
device->soft_reset) {
1236 remove_SC(SCs, ptr);
1250 static int aha152x_bus_reset_host(
struct Scsi_Host *shpnt)
1252 unsigned long flags;
1256 #if defined(AHA152X_DEBUG)
1263 free_hard_reset_SCs(shpnt, &
ISSUE_SC);
1275 setup_expected_interrupts(shpnt);
1288 static int aha152x_bus_reset(
Scsi_Cmnd *SCpnt)
1290 return aha152x_bus_reset_host(SCpnt->
device->host);
1297 static void reset_ports(
struct Scsi_Host *shpnt)
1299 unsigned long flags;
1326 setup_expected_interrupts(shpnt);
1338 aha152x_bus_reset_host(shpnt);
1350 static int aha152x_host_reset(
Scsi_Cmnd *SCpnt)
1367 info_array[2] = (
unsigned long)capacity / (64 * 32);
1370 if (info_array[2] >= 1024) {
1375 !((info[0] == 64 && info[1] == 32) || (info[0] == 255 && info[1] == 63))) {
1378 "aha152x: unable to verify geometry for disk with >1GB.\n"
1379 " using extended translation.\n");
1380 info_array[0] = 255;
1382 info_array[2] = (
unsigned long)capacity / (255 * 63);
1385 "aha152x: unable to verify geometry for disk with >1GB.\n"
1386 " Using default translation. Please verify yourself.\n"
1387 " Perhaps you need to enable extended translation in the driver.\n"
1388 " See Documentation/scsi/aha152x.txt for details.\n");
1391 info_array[0] = info[0];
1392 info_array[1] = info[1];
1393 info_array[2] = info[2];
1397 "aha152x: current partition table is using extended translation.\n"
1398 " using it also, although it's not explicitly enabled.\n");
1447 unsigned long flags;
1448 unsigned char rev, dmacntrl0;
1465 if ((rev == 0xFF) && (dmacntrl0 == 0xFF))
1493 static void busfree_run(
struct Scsi_Host *shpnt)
1495 unsigned long flags;
1496 #if defined(AHA152X_STAT)
1506 #if defined(AHA152X_STAT)
1523 }
else if(
CURRENT_SC->SCp.phase & disconnected) {
1529 #if defined(AHA152X_STAT)
1539 #if defined(AHA152X_STAT)
1541 HOSTDATA(shpnt)->busfree_without_old_command++;
1548 #if defined(AHA152X_STAT)
1571 #if defined(AHA152X_STAT)
1572 HOSTDATA(shpnt)->busfree_with_check_condition++;
1602 #if defined(AHA152X_DEBUG)
1603 int hostno=
DONE_SC->device->host->host_no;
1604 int id=
DONE_SC->device->id & 0xf;
1605 int lun=
DONE_SC->device->lun & 0x7;
1621 DPRINTK(debug_done,
DEBUG_LEAD "calling scsi_done(%p)\n", hostno,
id, lun, ptr);
1623 DPRINTK(debug_done,
DEBUG_LEAD "scsi_done(%p) returned\n", hostno,
id, lun, ptr);
1628 #if defined(AHA152X_STAT)
1630 HOSTDATA(shpnt)->busfree_without_done_command++;
1640 #if defined(AHA152X_STAT)
1654 #if defined(AHA152X_STAT)
1655 HOSTDATA(shpnt)->busfree_without_new_command++;
1660 #if defined(AHA152X_STAT)
1662 HOSTDATA(shpnt)->busfree_without_any_action++;
1671 static void seldo_run(
struct Scsi_Host *shpnt)
1693 }
else if (
CURRENT_SC->SCp.phase & resetting) {
1709 static void selto_run(
struct Scsi_Host *shpnt)
1743 static void seldi_run(
struct Scsi_Host *shpnt)
1747 unsigned long flags;
1777 printk(
"aha152x%d: target id unknown (%02x)\n",
HOSTNO, selid);
1781 for(target=7; !(selid & (1 <<
target)); target--)
1784 if(selid & ~(1 << target)) {
1785 printk(
"aha152x%d: multiple targets reconnected (%02x)\n",
1812 static void msgi_run(
struct Scsi_Host *shpnt)
1827 #if defined(AHA152X_DEBUG)
1921 ticks = (
MSGI(3) * 4 + 49) / 50;
1925 if (ticks > 9 ||
MSGI(4) < 1 ||
MSGI(4) > 8) {
1932 }
else if (ticks <= 9 &&
MSGI(4) >= 1) {
1963 for(i=0; i<8; i++) {
1985 static void msgi_end(
struct Scsi_Host *shpnt)
2000 static void msgo_init(
struct Scsi_Host *shpnt)
2011 #if defined(AHA152X_DEBUG)
2027 static void msgo_run(
struct Scsi_Host *shpnt)
2059 static void msgo_end(
struct Scsi_Host *shpnt)
2077 static void cmd_init(
struct Scsi_Host *shpnt)
2085 #if defined(AHA152X_DEBUG)
2099 static void cmd_run(
struct Scsi_Host *shpnt)
2106 while(CMD_I<CURRENT_SC->
cmd_len) {
2118 static void cmd_end(
struct Scsi_Host *shpnt)
2120 if(CMD_I<CURRENT_SC->cmd_len)
2130 static void status_run(
struct Scsi_Host *shpnt)
2139 #if defined(AHA152X_DEBUG)
2152 static void datai_init(
struct Scsi_Host *shpnt)
2165 DEBUG_LEAD "datai_init: request_bufflen=%d resid=%d\n",
2170 static void datai_run(
struct Scsi_Host *shpnt)
2172 unsigned long the_time;
2211 while(fifodata>0 &&
CURRENT_SC->SCp.this_residual>0) {
2212 data_count = fifodata>
CURRENT_SC->SCp.this_residual ?
2217 if(data_count & 1) {
2226 if(data_count > 1) {
2243 }
else if(fifodata>0) {
2271 "manual transfer count differs from automatic (count=%d;stcnt=%d;diff=%d;fifostat=%d)",
2278 static void datai_end(
struct Scsi_Host *shpnt)
2283 DEBUG_LEAD "datai_end: request_bufflen=%d resid=%d stcnt=%d\n",
2295 static void datao_init(
struct Scsi_Host *shpnt)
2309 DEBUG_LEAD "datao_init: request_bufflen=%d; resid=%d\n",
2314 static void datao_run(
struct Scsi_Host *shpnt)
2316 unsigned long the_time;
2322 if(data_count >
CURRENT_SC->SCp.this_residual)
2331 if(data_count & 1) {
2339 if(data_count > 1) {
2367 static void datao_end(
struct Scsi_Host *shpnt)
2373 DPRINTK(debug_datao,
DEBUG_LEAD "datao: %d bytes to resend (%d written, %d transferred)\n",
2383 while(data_count>0) {
2386 data_count -=
CURRENT_SC->SCp.buffer->length;
2394 DPRINTK(debug_datao,
DEBUG_LEAD "datao_end: request_bufflen=%d; resid=%d; stcnt=%d\n",
2410 static int update_state(
struct Scsi_Host *shpnt)
2427 }
else if(stat1 &
SELTO) {
2429 }
else if(stat1 & BUSFREE) {
2435 }
else if(stat1 & REQINIT) {
2465 static void parerr_run(
struct Scsi_Host *shpnt)
2475 static void rsti_run(
struct Scsi_Host *shpnt)
2485 if (!ptr->
device->soft_reset) {
2507 static void is_complete(
struct Scsi_Host *shpnt)
2510 unsigned long flags;
2528 aha152x_error(shpnt,
"bottom-half already running!?");
2540 dataphase=update_state(shpnt);
2590 states[
STATE].init(shpnt);
2597 states[
STATE].run(shpnt);
2608 pending=setup_expected_interrupts(shpnt);
2609 #if defined(AHA152X_STAT)
2632 static void aha152x_error(
struct Scsi_Host *shpnt,
char *
msg)
2636 panic(
"aha152x panic\n");
2642 static void disp_ports(
struct Scsi_Host *shpnt)
2644 #if defined(AHA152X_DEBUG)
2830 printk(
"SCSICNT (%d), OFFCNT(%d), ", (s & 0xf0) >> 4, s & 0x0f);
2874 static void disp_enintr(
struct Scsi_Host *shpnt)
2924 scsi_bufflen(ptr), scsi_get_resid(ptr));
2932 if (ptr->
SCp.phase & disconnected)
2947 printk(
"; next=(host scribble NULL)\n");
2954 static void show_queues(
struct Scsi_Host *shpnt)
2957 unsigned long flags;
2980 #define SPRINTF(args...) pos += sprintf(pos, ## args)
2987 SPRINTF(
"%p: target=%d; lun=%d; cmnd=( ",
2993 SPRINTF(
"); resid=%d; residual=%d; buffers=%d; phase |",
2994 scsi_get_resid(ptr), ptr->
SCp.this_residual,
2995 ptr->
SCp.buffers_residual);
3001 if (ptr->
SCp.phase & disconnected)
3015 return (pos - start);
3018 static int get_ports(
struct Scsi_Host *shpnt,
char *pos)
3047 switch (s & P_MASK) {
3203 SPRINTF(
"SCSICNT (%d), OFFCNT(%d), ", (s & 0xf0) >> 4, s & 0x0f);
3242 SPRINTF(
"enabled interrupts( ");
3277 return (pos - start);
3282 if(!shpnt || !buffer || length<8 ||
strncmp(
"aha152x ", buffer, 8)!=0)
3285 #if defined(AHA152X_DEBUG)
3286 if(length>14 &&
strncmp(
"debug ", buffer+8, 6)==0) {
3294 #if defined(AHA152X_STAT)
3295 if(length>13 &&
strncmp(
"reset", buffer+8, 5)==0) {
3300 HOSTDATA(shpnt)->busfree_without_any_action=0;
3301 HOSTDATA(shpnt)->busfree_without_old_command=0;
3302 HOSTDATA(shpnt)->busfree_without_new_command=0;
3303 HOSTDATA(shpnt)->busfree_without_done_command=0;
3304 HOSTDATA(shpnt)->busfree_with_check_condition=0;
3324 #define SPRINTF(args...) \
3325 do { if(pos < buffer + length) pos += sprintf(pos, ## args); } while(0)
3327 static int aha152x_proc_info(
struct Scsi_Host *shpnt,
char *buffer,
char **start,
3333 unsigned long flags;
3337 KERN_DEBUG "aha152x_proc_info: buffer=%p offset=%ld length=%d hostno=%d inout=%d\n",
3338 buffer, offset, length, shpnt->
host_no, inout);
3342 return aha152x_set_info(buffer, length, shpnt);
3346 SPRINTF(
"ioports 0x%04lx to 0x%04lx\n",
3349 SPRINTF(
"disconnection/reconnection %s\n",
3351 SPRINTF(
"parity checking %s\n",
3352 PARITY ?
"enabled" :
"disabled");
3353 SPRINTF(
"synchronous transfers %s\n",
3358 SPRINTF(
"synchronously operating targets (tick=50 ns):\n");
3359 for (i = 0; i < 8; i++)
3360 if (
HOSTDATA(shpnt)->syncrate[i] & 0x7f)
3361 SPRINTF(
"target %d: period %dT/%dns; req/ack offset %d\n",
3363 (((
HOSTDATA(shpnt)->syncrate[i] & 0x70) >> 4) + 2),
3364 (((
HOSTDATA(shpnt)->syncrate[i] & 0x70) >> 4) + 2) * 50,
3365 HOSTDATA(shpnt)->syncrate[i] & 0x0f);
3367 #if defined(AHA152X_DEBUG)
3368 #define PDEBUG(flags,txt) \
3369 if(HOSTDATA(shpnt)->debug & flags) SPRINTF("(%s) ", txt);
3371 SPRINTF(
"enabled debugging options: ");
3373 PDEBUG(debug_procinfo,
"procinfo");
3374 PDEBUG(debug_queue,
"queue");
3375 PDEBUG(debug_intr,
"interrupt");
3376 PDEBUG(debug_selection,
"selection");
3377 PDEBUG(debug_msgo,
"message out");
3378 PDEBUG(debug_msgi,
"message in");
3379 PDEBUG(debug_status,
"status");
3380 PDEBUG(debug_cmd,
"command");
3381 PDEBUG(debug_datai,
"data in");
3382 PDEBUG(debug_datao,
"data out");
3384 PDEBUG(debug_locking,
"locks");
3385 PDEBUG(debug_phases,
"phases");
3393 SPRINTF(
"not yet issued commands:\n");
3395 pos += get_command(pos, ptr);
3397 SPRINTF(
"no not yet issued commands\n");
3401 SPRINTF(
"current command:\n");
3404 SPRINTF(
"no current command\n");
3407 SPRINTF(
"disconnected commands:\n");
3409 pos += get_command(pos, ptr);
3411 SPRINTF(
"no disconnected commands\n");
3413 pos += get_ports(shpnt, pos);
3415 #if defined(AHA152X_STAT)
3417 "total commands: %d\n"
3418 "disconnections: %d\n"
3419 "busfree with check condition: %d\n"
3420 "busfree without old command: %d\n"
3421 "busfree without new command: %d\n"
3422 "busfree without done command: %d\n"
3423 "busfree without any action: %d\n"
3430 HOSTDATA(shpnt)->busfree_with_check_condition,
3431 HOSTDATA(shpnt)->busfree_without_old_command,
3432 HOSTDATA(shpnt)->busfree_without_new_command,
3433 HOSTDATA(shpnt)->busfree_without_done_command,
3434 HOSTDATA(shpnt)->busfree_without_any_action);
3436 SPRINTF(
"%-10s %-12d %-12d %-12ld\n",
3446 thislength = pos - (buffer +
offset);
3447 DPRINTK(debug_procinfo,
KERN_DEBUG "aha152x_proc_info: length=%d thislength=%d\n", length, thislength);
3455 thislength = thislength<length ? thislength :
length;
3457 DPRINTK(debug_procinfo,
KERN_DEBUG "aha152x_proc_info: return %d\n", thislength);
3459 *start = buffer +
offset;
3460 return thislength < length ? thislength :
length;
3472 .proc_name =
"aha152x",
3473 .proc_info = aha152x_proc_info,
3474 .queuecommand = aha152x_queue,
3475 .eh_abort_handler = aha152x_abort,
3476 .eh_device_reset_handler = aha152x_device_reset,
3477 .eh_bus_reset_handler = aha152x_bus_reset,
3478 .eh_host_reset_handler = aha152x_host_reset,
3479 .bios_param = aha152x_biosparam,
3485 .slave_alloc = aha152x_adjust_queue,
3488 #if !defined(PCMCIA)
3489 static int setup_count;
3493 static unsigned short ports[] = { 0x340, 0x140 };
3495 #if !defined(SKIP_BIOSTEST)
3497 static unsigned int addresses[] =
3523 {
"Adaptec AHA-1520 BIOS", 0x102e, 21 },
3525 {
"Adaptec AHA-1520B", 0x000b, 17 },
3527 {
"Adaptec AHA-1520B", 0x0026, 17 },
3529 {
"Adaptec ASW-B626 BIOS", 0x1029, 21 },
3531 {
"Adaptec BIOS: ASW-B626", 0x000f, 22 },
3533 {
"Adaptec ASW-B626 S2", 0x2e6c, 19 },
3535 {
"Adaptec BIOS:AIC-6360", 0x000c, 21 },
3537 {
"ScsiPro SP-360 BIOS", 0x2873, 19 },
3539 {
"GA-400 LOCAL BUS SCSI BIOS", 0x102e, 26 },
3541 {
"Adaptec BIOS:AVA-282X", 0x000c, 21 },
3543 {
"Adaptec IBM Dock II SCSI", 0x2edd, 24 },
3545 {
"Adaptec BIOS:AHA-1532P", 0x001c, 22 },
3547 {
"DTC3520A Host Adapter BIOS", 0x318a, 26 },
3556 static int aha152x_porttest(
int io_port)
3561 for (i = 0; i < 16; i++)
3571 static int tc1550_porttest(
int io_port)
3576 for (i = 0; i < 16; i++)
3601 if( aha152x_porttest(setup->
io_port) ) {
3603 }
else if( tc1550_porttest(setup->
io_port) ) {
3635 static int __init aha152x_init(
void)
3638 #if defined(AUTOCONF)
3645 if ( setup_count ) {
3648 for (i = 0; i<setup_count; i++) {
3649 if (!checksetup(&setup[i])) {
3661 if (setup_count == 0 || (
override.io_port != setup[0].io_port)) {
3662 if (!checksetup(&
override)) {
3663 printk(
KERN_ERR "\naha152x: invalid override SETUP0={0x%x,%d,%d,%d,%d,%d,%d,%d}\n",
3673 setup[setup_count++] =
override;
3682 if (setup_count == 0 || (
override.io_port != setup[0].io_port)) {
3683 if (!checksetup(&
override)) {
3684 printk(
KERN_ERR "\naha152x: invalid override SETUP1={0x%x,%d,%d,%d,%d,%d,%d,%d}\n",
3694 setup[setup_count++] =
override;
3700 if (setup_count<
ARRAY_SIZE(setup) && (aha152x[0]!=0 ||
io[0]!=0 ||
irq[0]!=0)) {
3702 setup[setup_count].
conf =
"";
3703 setup[setup_count].
io_port = aha152x[0];
3704 setup[setup_count].
irq = aha152x[1];
3705 setup[setup_count].
scsiid = aha152x[2];
3706 setup[setup_count].
reconnect = aha152x[3];
3707 setup[setup_count].
parity = aha152x[4];
3709 setup[setup_count].
delay = aha152x[6];
3710 setup[setup_count].
ext_trans = aha152x[7];
3711 #if defined(AHA152X_DEBUG)
3712 setup[setup_count].debug = aha152x[8];
3714 }
else if(
io[0]!=0 ||
irq[0]!=0) {
3716 if(
irq[0]!=0) setup[setup_count].
irq =
irq[0];
3723 setup[setup_count].
ext_trans = exttrans[0];
3724 #if defined(AHA152X_DEBUG)
3725 setup[setup_count].debug = debug[0];
3729 if (checksetup(&setup[setup_count]))
3732 printk(
KERN_ERR "aha152x: invalid module params io=0x%x, irq=%d,scsiid=%d,reconnect=%d,parity=%d,sync=%d,delay=%d,exttrans=%d\n",
3733 setup[setup_count].io_port,
3734 setup[setup_count].
irq,
3735 setup[setup_count].
scsiid,
3737 setup[setup_count].
parity,
3739 setup[setup_count].
delay,
3743 if (setup_count<
ARRAY_SIZE(setup) && (aha152x1[0]!=0 ||
io[1]!=0 ||
irq[1]!=0)) {
3744 if(aha152x1[0]!=0) {
3745 setup[setup_count].
conf =
"";
3746 setup[setup_count].
io_port = aha152x1[0];
3747 setup[setup_count].
irq = aha152x1[1];
3748 setup[setup_count].
scsiid = aha152x1[2];
3749 setup[setup_count].
reconnect = aha152x1[3];
3750 setup[setup_count].
parity = aha152x1[4];
3752 setup[setup_count].
delay = aha152x1[6];
3753 setup[setup_count].
ext_trans = aha152x1[7];
3754 #if defined(AHA152X_DEBUG)
3755 setup[setup_count].debug = aha152x1[8];
3757 }
else if(
io[1]!=0 ||
irq[1]!=0) {
3759 if(
irq[1]!=0) setup[setup_count].
irq =
irq[1];
3766 setup[setup_count].
ext_trans = exttrans[1];
3767 #if defined(AHA152X_DEBUG)
3768 setup[setup_count].debug = debug[1];
3771 if (checksetup(&setup[setup_count]))
3774 printk(
KERN_ERR "aha152x: invalid module params io=0x%x, irq=%d,scsiid=%d,reconnect=%d,parity=%d,sync=%d,delay=%d,exttrans=%d\n",
3775 setup[setup_count].io_port,
3776 setup[setup_count].
irq,
3777 setup[setup_count].
scsiid,
3779 setup[setup_count].
parity,
3781 setup[setup_count].
delay,
3787 for(i=0; setup_count<
ARRAY_SIZE(setup) && id_table[
i].vendor; i++) {
3798 if (!pnp_port_valid(dev, 0)) {
3803 if (setup_count==1 && pnp_port_start(dev, 0)==setup[0].io_port) {
3808 setup[setup_count].
io_port = pnp_port_start(dev, 0);
3810 setup[setup_count].
scsiid = 7;
3812 setup[setup_count].
parity = 1;
3816 #if defined(AHA152X_DEBUG)
3819 #if defined(__ISAPNP__)
3820 pnpdev[setup_count] =
dev;
3823 "aha152x: found ISAPnP adapter at io=0x%03x, irq=%d\n",
3824 setup[setup_count].io_port, setup[setup_count].
irq);
3830 #if defined(AUTOCONF)
3832 #if !defined(SKIP_BIOSTEST)
3834 for (i = 0; i <
ARRAY_SIZE(addresses) && !ok; i++) {
3838 for (j = 0; j<
ARRAY_SIZE(signatures) && !ok; j++)
3840 signatures[j].
signature, signatures[j].sig_length);
3843 if (!ok && setup_count == 0)
3852 for (i = 0; i <
ARRAY_SIZE(ports) && setup_count < 2; i++) {
3853 if ((setup_count == 1) && (setup[0].
io_port == ports[
i]))
3861 if (aha152x_porttest(ports[i])) {
3862 setup[setup_count].
tc1550 = 0;
3866 }
else if (tc1550_porttest(ports[i])) {
3867 setup[setup_count].
tc1550 = 1;
3879 setup[setup_count].
io_port = ports[
i];
3880 setup[setup_count].
irq =
IRQ_MIN + conf.cf_irq;
3881 setup[setup_count].
scsiid = conf.cf_id;
3882 setup[setup_count].
reconnect = conf.cf_tardisc;
3883 setup[setup_count].
parity = !conf.cf_parity;
3887 #if defined(AHA152X_DEBUG)
3895 printk(
"auto configuration: ok, ");
3899 printk(
"%d controller(s) configured\n", setup_count);
3901 for (i=0; i<setup_count; i++) {
3907 #if defined(__ISAPNP__)
3908 }
else if( pnpdev[i] ) {
3914 printk(
KERN_ERR "aha152x: io port 0x%x busy.\n", setup[i].io_port);
3917 #if defined(__ISAPNP__)
3926 static void __exit aha152x_exit(
void)
3940 #if !defined(MODULE)
3943 #if defined(AHA152X_DEBUG)
3951 printk(
KERN_ERR "aha152x: you can only configure up to two controllers\n");
3955 setup[setup_count].
conf =
str;
3956 setup[setup_count].
io_port = ints[0] >= 1 ? ints[1] : 0x340;
3957 setup[setup_count].
irq = ints[0] >= 2 ? ints[2] : 11;
3958 setup[setup_count].
scsiid = ints[0] >= 3 ? ints[3] : 7;
3959 setup[setup_count].
reconnect = ints[0] >= 4 ? ints[4] : 1;
3960 setup[setup_count].
parity = ints[0] >= 5 ? ints[5] : 1;
3961 setup[setup_count].
synchronous = ints[0] >= 6 ? ints[6] : 1;
3963 setup[setup_count].
ext_trans = ints[0] >= 8 ? ints[8] : 0;
3964 #if defined(AHA152X_DEBUG)
3965 setup[setup_count].debug = ints[0] >= 9 ? ints[9] :
DEBUG_DEFAULT;
3968 "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<EXT_TRANS>[,<DEBUG>]]]]]]]]\n");
3972 "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<EXT_TRANS>]]]]]]]\n");