32 #include <linux/types.h>
33 #include <linux/stddef.h>
34 #include <linux/ctype.h>
37 #include <linux/module.h>
38 #include <linux/signal.h>
62 #define NDEBUG (NDEBUG_INTR | NDEBUG_PSEUDO_DMA | NDEBUG_ARBITRATION | NDEBUG_SELECTION | NDEBUG_RESELECTION)
64 #define NDEBUG (NDEBUG_ABORT)
73 static void mac_scsi_reset_boot(
struct Scsi_Host *instance);
76 static int setup_called = 0;
77 static int setup_can_queue = -1;
78 static int setup_cmd_per_lun = -1;
79 static int setup_sg_tablesize = -1;
80 static int setup_use_pdma = -1;
82 static int setup_use_tagged_queuing = -1;
84 static int setup_hostid = -1;
92 #define AFTER_RESET_DELAY (5*HZ/2)
94 #define AFTER_RESET_DELAY (HZ/2)
97 static volatile unsigned char *mac_scsi_regp =
NULL;
98 static volatile unsigned char *mac_scsi_drq =
NULL;
99 static volatile unsigned char *mac_scsi_nodrq =
NULL;
108 #define CTRL(p,v) (*ctrl = (v))
110 static char macscsi_read(
struct Scsi_Host *instance,
int reg)
117 i =
in_8(iobase + (reg<<4));
129 out_8(iobase + (reg<<4), value);
156 static int __init mac_scsi_setup(
char *
str) {
162 if (setup_called++ || ints[0] < 1 || ints[0] > 6) {
164 " Usage: mac5380=<can_queue>[,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags>,<use_pdma>]\n");
172 setup_can_queue = ints[1];
176 setup_cmd_per_lun = ints[2];
180 setup_sg_tablesize = ints[3];
182 if (setup_sg_tablesize >
SG_ALL)
183 setup_sg_tablesize =
SG_ALL;
188 if (ints[4] >= 0 && ints[4] <= 7)
189 setup_hostid = ints[4];
190 else if (ints[4] > 7)
196 setup_use_tagged_queuing = !!ints[5];
201 setup_use_pdma = ints[6];
206 setup_use_pdma = ints[5];
214 __setup(
"mac5380=", mac_scsi_setup);
230 static int called = 0;
242 (setup_can_queue > 0) ? setup_can_queue :
CAN_QUEUE;
244 (setup_cmd_per_lun > 0) ? setup_cmd_per_lun :
CMD_PER_LUN;
246 (setup_sg_tablesize >= 0) ? setup_sg_tablesize :
SG_TABLESIZE;
248 if (setup_hostid >= 0)
256 if (setup_use_tagged_queuing < 0)
265 mac_scsi_regp =
via1+0x8000;
266 mac_scsi_drq =
via1+0xE000;
267 mac_scsi_nodrq =
via1+0xC000;
271 mac_scsi_regp =
via1+0x10000;
272 mac_scsi_drq =
via1+0x6000;
273 mac_scsi_nodrq =
via1+0x12000;
276 if (! setup_use_pdma)
283 mac_scsi_reset_boot(instance);
286 NCR5380_init(instance, flags);
307 NCR5380_print_options(instance);
327 static void mac_scsi_reset_boot(
struct Scsi_Host *instance)
375 #define CP_IO_TO_MEM(s,d,len) \
376 __asm__ __volatile__ \
379 " move.w %1,%%d0\n" \
384 " 1: move.b (%0),(%1)+\n" \
385 " 2: dbf %%d0,1b\n" \
386 " move.w %2,%%d0\n" \
389 " 3: move.l (%0),(%1)+\n" \
390 "31: move.l (%0),(%1)+\n" \
391 "32: move.l (%0),(%1)+\n" \
392 "33: move.l (%0),(%1)+\n" \
393 "34: move.l (%0),(%1)+\n" \
394 "35: move.l (%0),(%1)+\n" \
395 "36: move.l (%0),(%1)+\n" \
396 "37: move.l (%0),(%1)+\n" \
397 " 4: dbf %%d0,3b\n" \
398 " move.w %2,%%d0\n" \
402 " 5: move.l (%0),(%1)+\n" \
403 " 6: dbf %%d0,5b\n" \
406 " 7: move.b (%0),(%1)+\n" \
408 " moveq.l #0, %2\n" \
410 ".section .fixup,\"ax\"\n" \
412 "90: moveq.l #1, %2\n" \
415 ".section __ex_table,\"a\"\n" \
429 : "=a"(s), "=a"(d), "=d"(len) \
430 : "0"(s), "1"(d), "2"(len) \
434 static int macscsi_pread (
struct Scsi_Host *instance,
435 unsigned char *
dst,
int len)
438 volatile unsigned char *
s;
443 s = mac_scsi_drq+0x60;
468 #define CP_MEM_TO_IO(s,d,len) \
469 __asm__ __volatile__ \
472 " move.w %0,%%d0\n" \
477 " 1: move.b (%0)+,(%1)\n" \
478 " 2: dbf %%d0,1b\n" \
479 " move.w %2,%%d0\n" \
482 " 3: move.l (%0)+,(%1)\n" \
483 "31: move.l (%0)+,(%1)\n" \
484 "32: move.l (%0)+,(%1)\n" \
485 "33: move.l (%0)+,(%1)\n" \
486 "34: move.l (%0)+,(%1)\n" \
487 "35: move.l (%0)+,(%1)\n" \
488 "36: move.l (%0)+,(%1)\n" \
489 "37: move.l (%0)+,(%1)\n" \
490 " 4: dbf %%d0,3b\n" \
491 " move.w %2,%%d0\n" \
495 " 5: move.l (%0)+,(%1)\n" \
496 " 6: dbf %%d0,5b\n" \
499 " 7: move.b (%0)+,(%1)\n" \
501 " moveq.l #0, %2\n" \
503 ".section .fixup,\"ax\"\n" \
505 "90: moveq.l #1, %2\n" \
508 ".section __ex_table,\"a\"\n" \
522 : "=a"(s), "=a"(d), "=d"(len) \
523 : "0"(s), "1"(d), "2"(len) \
526 static int macscsi_pwrite (
struct Scsi_Host *instance,
527 unsigned char *
src,
int len)
530 volatile unsigned char *
d;
563 .proc_name =
"Mac5380",
564 .proc_info = macscsi_proc_info,
565 .name =
"Macintosh NCR5380 SCSI",
569 .queuecommand = macscsi_queue_command,
570 .eh_abort_handler = macscsi_abort,
571 .eh_bus_reset_handler = macscsi_bus_reset,