NCR5380.c (d5f7e65df0d41982b1e9cbba9df04003ebb2178d) NCR5380.c (54d8fe4425c9d3fdf8473c1833c6807b61c6e70e)
1/*
2 * NCR 5380 generic driver routines. These should make it *trivial*
3 * to implement 5380 SCSI drivers under Linux with a non-trantor
4 * architecture.
5 *
6 * Note that these routines also work with NR53c400 family chips.
7 *
8 * Copyright 1993, Drew Eckhardt

--- 216 unchanged lines hidden (view full) ---

225 * Defaults for these will be provided although the user may want to adjust
226 * these to allocate CPU resources to the SCSI driver or "real" code.
227 *
228 * USLEEP_SLEEP - amount of time, in jiffies, to sleep
229 *
230 * USLEEP_POLL - amount of time, in jiffies, to poll
231 *
232 * These macros MUST be defined :
1/*
2 * NCR 5380 generic driver routines. These should make it *trivial*
3 * to implement 5380 SCSI drivers under Linux with a non-trantor
4 * architecture.
5 *
6 * Note that these routines also work with NR53c400 family chips.
7 *
8 * Copyright 1993, Drew Eckhardt

--- 216 unchanged lines hidden (view full) ---

225 * Defaults for these will be provided although the user may want to adjust
226 * these to allocate CPU resources to the SCSI driver or "real" code.
227 *
228 * USLEEP_SLEEP - amount of time, in jiffies, to sleep
229 *
230 * USLEEP_POLL - amount of time, in jiffies, to poll
231 *
232 * These macros MUST be defined :
233 * NCR5380_local_declare() - declare any local variables needed for your
234 * transfer routines.
235 *
236 * NCR5380_setup(instance) - initialize any local variables needed from a given
237 * instance of the host adapter for NCR5380_{read,write,pread,pwrite}
238 *
239 * NCR5380_read(register) - read from the specified register
240 *
241 * NCR5380_write(register, value) - write to the specific register
242 *
243 * NCR5380_implementation_fields - additional fields needed for this
244 * specific implementation of the NCR5380
245 *

--- 16 unchanged lines hidden (view full) ---

262 * NCR5380_pread(instance, dst, count);
263 *
264 * The generic driver is initialized by calling NCR5380_init(instance),
265 * after setting the appropriate host specific fields and ID. If the
266 * driver wishes to autoprobe for an IRQ line, the NCR5380_probe_irq(instance,
267 * possible) function may be used.
268 */
269
233 *
234 * NCR5380_read(register) - read from the specified register
235 *
236 * NCR5380_write(register, value) - write to the specific register
237 *
238 * NCR5380_implementation_fields - additional fields needed for this
239 * specific implementation of the NCR5380
240 *

--- 16 unchanged lines hidden (view full) ---

257 * NCR5380_pread(instance, dst, count);
258 *
259 * The generic driver is initialized by calling NCR5380_init(instance),
260 * after setting the appropriate host specific fields and ID. If the
261 * driver wishes to autoprobe for an IRQ line, the NCR5380_probe_irq(instance,
262 * possible) function may be used.
263 */
264
270static int do_abort(struct Scsi_Host *host);
271static void do_reset(struct Scsi_Host *host);
265static int do_abort(struct Scsi_Host *);
266static void do_reset(struct Scsi_Host *);
272
273/*
274 * initialize_SCp - init the scsi pointer field
275 * @cmd: command block to set up
276 *
277 * Set up the internal fields in the SCSI command.
278 */
279

--- 28 unchanged lines hidden (view full) ---

308 * an event to occur, after a short quick poll we begin giving the
309 * CPU back in non IRQ contexts
310 *
311 * Returns the value of the register or a negative error code.
312 */
313
314static int NCR5380_poll_politely(struct Scsi_Host *instance, int reg, int bit, int val, int t)
315{
267
268/*
269 * initialize_SCp - init the scsi pointer field
270 * @cmd: command block to set up
271 *
272 * Set up the internal fields in the SCSI command.
273 */
274

--- 28 unchanged lines hidden (view full) ---

303 * an event to occur, after a short quick poll we begin giving the
304 * CPU back in non IRQ contexts
305 *
306 * Returns the value of the register or a negative error code.
307 */
308
309static int NCR5380_poll_politely(struct Scsi_Host *instance, int reg, int bit, int val, int t)
310{
316 NCR5380_local_declare();
317 int n = 500; /* At about 8uS a cycle for the cpu access */
318 unsigned long end = jiffies + t;
319 int r;
311 int n = 500; /* At about 8uS a cycle for the cpu access */
312 unsigned long end = jiffies + t;
313 int r;
320
321 NCR5380_setup(instance);
322
323 while( n-- > 0)
324 {
325 r = NCR5380_read(reg);
326 if((r & bit) == val)
327 return 0;
328 cpu_relax();
329 }

--- 71 unchanged lines hidden (view full) ---

401 *
402 * Print the SCSI bus signals for debugging purposes
403 *
404 * Locks: caller holds hostdata lock (not essential)
405 */
406
407static void NCR5380_print(struct Scsi_Host *instance)
408{
314
315 while( n-- > 0)
316 {
317 r = NCR5380_read(reg);
318 if((r & bit) == val)
319 return 0;
320 cpu_relax();
321 }

--- 71 unchanged lines hidden (view full) ---

393 *
394 * Print the SCSI bus signals for debugging purposes
395 *
396 * Locks: caller holds hostdata lock (not essential)
397 */
398
399static void NCR5380_print(struct Scsi_Host *instance)
400{
409 NCR5380_local_declare();
410 unsigned char status, data, basr, mr, icr, i;
401 unsigned char status, data, basr, mr, icr, i;
411 NCR5380_setup(instance);
412
413 data = NCR5380_read(CURRENT_SCSI_DATA_REG);
414 status = NCR5380_read(STATUS_REG);
415 mr = NCR5380_read(MODE_REG);
416 icr = NCR5380_read(INITIATOR_COMMAND_REG);
417 basr = NCR5380_read(BUS_AND_STATUS_REG);
418
419 printk("STATUS_REG: %02x ", status);

--- 22 unchanged lines hidden (view full) ---

442 *
443 * Print the current SCSI phase for debugging purposes
444 *
445 * Locks: none
446 */
447
448static void NCR5380_print_phase(struct Scsi_Host *instance)
449{
402
403 data = NCR5380_read(CURRENT_SCSI_DATA_REG);
404 status = NCR5380_read(STATUS_REG);
405 mr = NCR5380_read(MODE_REG);
406 icr = NCR5380_read(INITIATOR_COMMAND_REG);
407 basr = NCR5380_read(BUS_AND_STATUS_REG);
408
409 printk("STATUS_REG: %02x ", status);

--- 22 unchanged lines hidden (view full) ---

432 *
433 * Print the current SCSI phase for debugging purposes
434 *
435 * Locks: none
436 */
437
438static void NCR5380_print_phase(struct Scsi_Host *instance)
439{
450 NCR5380_local_declare();
451 unsigned char status;
452 int i;
440 unsigned char status;
441 int i;
453 NCR5380_setup(instance);
454
455 status = NCR5380_read(STATUS_REG);
456 if (!(status & SR_REQ))
457 printk("scsi%d : REQ not asserted, phase unknown.\n", instance->host_no);
458 else {
459 for (i = 0; (phases[i].value != PHASE_UNKNOWN) && (phases[i].value != (status & PHASE_MASK)); ++i);
460 printk("scsi%d : phase %s\n", instance->host_no, phases[i].name);
461 }

--- 99 unchanged lines hidden (view full) ---

561 * and then looking to see what interrupt actually turned up.
562 *
563 * Locks: none, irqs must be enabled on entry
564 */
565
566static int __init __maybe_unused NCR5380_probe_irq(struct Scsi_Host *instance,
567 int possible)
568{
442
443 status = NCR5380_read(STATUS_REG);
444 if (!(status & SR_REQ))
445 printk("scsi%d : REQ not asserted, phase unknown.\n", instance->host_no);
446 else {
447 for (i = 0; (phases[i].value != PHASE_UNKNOWN) && (phases[i].value != (status & PHASE_MASK)); ++i);
448 printk("scsi%d : phase %s\n", instance->host_no, phases[i].name);
449 }

--- 99 unchanged lines hidden (view full) ---

549 * and then looking to see what interrupt actually turned up.
550 *
551 * Locks: none, irqs must be enabled on entry
552 */
553
554static int __init __maybe_unused NCR5380_probe_irq(struct Scsi_Host *instance,
555 int possible)
556{
569 NCR5380_local_declare();
570 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
571 unsigned long timeout;
572 int trying_irqs, i, mask;
557 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
558 unsigned long timeout;
559 int trying_irqs, i, mask;
573 NCR5380_setup(instance);
574
575 for (trying_irqs = 0, i = 1, mask = 2; i < 16; ++i, mask <<= 1)
576 if ((mask & possible) && (request_irq(i, &probe_intr, 0, "NCR-probe", NULL) == 0))
577 trying_irqs |= mask;
578
579 timeout = jiffies + msecs_to_jiffies(250);
580 probe_irq = NO_IRQ;
581

--- 204 unchanged lines hidden (view full) ---

786 *
787 * Returns 0 for success
788 *
789 * Locks: interrupts must be enabled when we are called
790 */
791
792static int NCR5380_init(struct Scsi_Host *instance, int flags)
793{
560
561 for (trying_irqs = 0, i = 1, mask = 2; i < 16; ++i, mask <<= 1)
562 if ((mask & possible) && (request_irq(i, &probe_intr, 0, "NCR-probe", NULL) == 0))
563 trying_irqs |= mask;
564
565 timeout = jiffies + msecs_to_jiffies(250);
566 probe_irq = NO_IRQ;
567

--- 204 unchanged lines hidden (view full) ---

772 *
773 * Returns 0 for success
774 *
775 * Locks: interrupts must be enabled when we are called
776 */
777
778static int NCR5380_init(struct Scsi_Host *instance, int flags)
779{
794 NCR5380_local_declare();
795 int i, pass;
796 unsigned long timeout;
797 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
798
799 if(in_interrupt())
800 printk(KERN_ERR "NCR5380_init called with interrupts off!\n");
801 /*
802 * On NCR53C400 boards, NCR5380 registers are mapped 8 past
803 * the base address.
804 */
805
806#ifdef NCR53C400
807 if (flags & FLAG_NCR53C400)
808 instance->NCR5380_instance_name += NCR53C400_address_adjust;
809#endif
810
780 int i, pass;
781 unsigned long timeout;
782 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
783
784 if(in_interrupt())
785 printk(KERN_ERR "NCR5380_init called with interrupts off!\n");
786 /*
787 * On NCR53C400 boards, NCR5380 registers are mapped 8 past
788 * the base address.
789 */
790
791#ifdef NCR53C400
792 if (flags & FLAG_NCR53C400)
793 instance->NCR5380_instance_name += NCR53C400_address_adjust;
794#endif
795
811 NCR5380_setup(instance);
812
813 hostdata->aborted = 0;
814 hostdata->id_mask = 1 << instance->this_id;
815 for (i = hostdata->id_mask; i <= 0x80; i <<= 1)
816 if (i > hostdata->id_mask)
817 hostdata->id_higher_mask |= i;
818 for (i = 0; i < 8; ++i)
819 hostdata->busy[i] = 0;
820#ifdef REAL_DMA

--- 274 unchanged lines hidden (view full) ---

1095 * from the disconnected queue, and restarting NCR5380_main()
1096 * as required.
1097 *
1098 * Locks: takes the needed instance locks
1099 */
1100
1101static irqreturn_t NCR5380_intr(int dummy, void *dev_id)
1102{
796 hostdata->aborted = 0;
797 hostdata->id_mask = 1 << instance->this_id;
798 for (i = hostdata->id_mask; i <= 0x80; i <<= 1)
799 if (i > hostdata->id_mask)
800 hostdata->id_higher_mask |= i;
801 for (i = 0; i < 8; ++i)
802 hostdata->busy[i] = 0;
803#ifdef REAL_DMA

--- 274 unchanged lines hidden (view full) ---

1078 * from the disconnected queue, and restarting NCR5380_main()
1079 * as required.
1080 *
1081 * Locks: takes the needed instance locks
1082 */
1083
1084static irqreturn_t NCR5380_intr(int dummy, void *dev_id)
1085{
1103 NCR5380_local_declare();
1104 struct Scsi_Host *instance = dev_id;
1105 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
1106 int done;
1107 unsigned char basr;
1108 unsigned long flags;
1109
1110 dprintk(NDEBUG_INTR, "scsi : NCR5380 irq %d triggered\n",
1111 instance->irq);
1112
1113 do {
1114 done = 1;
1115 spin_lock_irqsave(instance->host_lock, flags);
1116 /* Look for pending interrupts */
1086 struct Scsi_Host *instance = dev_id;
1087 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
1088 int done;
1089 unsigned char basr;
1090 unsigned long flags;
1091
1092 dprintk(NDEBUG_INTR, "scsi : NCR5380 irq %d triggered\n",
1093 instance->irq);
1094
1095 do {
1096 done = 1;
1097 spin_lock_irqsave(instance->host_lock, flags);
1098 /* Look for pending interrupts */
1117 NCR5380_setup(instance);
1118 basr = NCR5380_read(BUS_AND_STATUS_REG);
1119 /* XXX dispatch to appropriate routine if found and done=0 */
1120 if (basr & BASR_IRQ) {
1121 NCR5380_dprint(NDEBUG_INTR, instance);
1122 if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == (SR_SEL | SR_IO)) {
1123 done = 0;
1124 dprintk(NDEBUG_INTR, "scsi%d : SEL interrupt\n", instance->host_no);
1125 NCR5380_reselect(instance);

--- 74 unchanged lines hidden (view full) ---

1200 * If failed (no target) : cmd->scsi_done() will be called, and the
1201 * cmd->result host byte set to DID_BAD_TARGET.
1202 *
1203 * Locks: caller holds hostdata lock in IRQ mode
1204 */
1205
1206static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd)
1207{
1099 basr = NCR5380_read(BUS_AND_STATUS_REG);
1100 /* XXX dispatch to appropriate routine if found and done=0 */
1101 if (basr & BASR_IRQ) {
1102 NCR5380_dprint(NDEBUG_INTR, instance);
1103 if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) == (SR_SEL | SR_IO)) {
1104 done = 0;
1105 dprintk(NDEBUG_INTR, "scsi%d : SEL interrupt\n", instance->host_no);
1106 NCR5380_reselect(instance);

--- 74 unchanged lines hidden (view full) ---

1181 * If failed (no target) : cmd->scsi_done() will be called, and the
1182 * cmd->result host byte set to DID_BAD_TARGET.
1183 *
1184 * Locks: caller holds hostdata lock in IRQ mode
1185 */
1186
1187static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd)
1188{
1208 NCR5380_local_declare();
1209 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
1210 unsigned char tmp[3], phase;
1211 unsigned char *data;
1212 int len;
1213 unsigned long timeout;
1214 unsigned char value;
1215 int err;
1189 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
1190 unsigned char tmp[3], phase;
1191 unsigned char *data;
1192 int len;
1193 unsigned long timeout;
1194 unsigned char value;
1195 int err;
1216 NCR5380_setup(instance);
1217
1218 if (hostdata->selecting)
1219 goto part2;
1220
1221 hostdata->restart_select = 0;
1222
1223 NCR5380_dprint(NDEBUG_ARBITRATION, instance);
1224 dprintk(NDEBUG_ARBITRATION, "scsi%d : starting arbitration, id = %d\n", instance->host_no, instance->this_id);

--- 257 unchanged lines hidden (view full) ---

1482
1483/*
1484 * Note : this code is not as quick as it could be, however it
1485 * IS 100% reliable, and for the actual data transfer where speed
1486 * counts, we will always do a pseudo DMA or DMA transfer.
1487 */
1488
1489static int NCR5380_transfer_pio(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data) {
1196
1197 if (hostdata->selecting)
1198 goto part2;
1199
1200 hostdata->restart_select = 0;
1201
1202 NCR5380_dprint(NDEBUG_ARBITRATION, instance);
1203 dprintk(NDEBUG_ARBITRATION, "scsi%d : starting arbitration, id = %d\n", instance->host_no, instance->this_id);

--- 257 unchanged lines hidden (view full) ---

1461
1462/*
1463 * Note : this code is not as quick as it could be, however it
1464 * IS 100% reliable, and for the actual data transfer where speed
1465 * counts, we will always do a pseudo DMA or DMA transfer.
1466 */
1467
1468static int NCR5380_transfer_pio(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data) {
1490 NCR5380_local_declare();
1491 unsigned char p = *phase, tmp;
1492 int c = *count;
1493 unsigned char *d = *data;
1494 /*
1495 * RvC: some administrative data to process polling time
1496 */
1497 int break_allowed = 0;
1498 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
1469 unsigned char p = *phase, tmp;
1470 int c = *count;
1471 unsigned char *d = *data;
1472 /*
1473 * RvC: some administrative data to process polling time
1474 */
1475 int break_allowed = 0;
1476 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
1499 NCR5380_setup(instance);
1500
1501 if (!(p & SR_IO))
1502 dprintk(NDEBUG_PIO, "scsi%d : pio write %d bytes\n", instance->host_no, c);
1503 else
1504 dprintk(NDEBUG_PIO, "scsi%d : pio read %d bytes\n", instance->host_no, c);
1505
1506 /*
1507 * The NCR5380 chip will only drive the SCSI bus when the

--- 110 unchanged lines hidden (view full) ---

1618 * @host: adapter to reset
1619 *
1620 * Issue a reset sequence to the NCR5380 and try and get the bus
1621 * back into sane shape.
1622 *
1623 * Locks: caller holds queue lock
1624 */
1625
1477
1478 if (!(p & SR_IO))
1479 dprintk(NDEBUG_PIO, "scsi%d : pio write %d bytes\n", instance->host_no, c);
1480 else
1481 dprintk(NDEBUG_PIO, "scsi%d : pio read %d bytes\n", instance->host_no, c);
1482
1483 /*
1484 * The NCR5380 chip will only drive the SCSI bus when the

--- 110 unchanged lines hidden (view full) ---

1595 * @host: adapter to reset
1596 *
1597 * Issue a reset sequence to the NCR5380 and try and get the bus
1598 * back into sane shape.
1599 *
1600 * Locks: caller holds queue lock
1601 */
1602
1626static void do_reset(struct Scsi_Host *host) {
1627 NCR5380_local_declare();
1628 NCR5380_setup(host);
1629
1603static void do_reset(struct Scsi_Host *instance)
1604{
1630 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(NCR5380_read(STATUS_REG) & PHASE_MASK));
1631 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_RST);
1632 udelay(25);
1633 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
1634}
1635
1636/*
1637 * Function : do_abort (Scsi_Host *host)
1638 *
1639 * Purpose : abort the currently established nexus. Should only be
1640 * called from a routine which can drop into a
1641 *
1642 * Returns : 0 on success, -1 on failure.
1643 *
1644 * Locks: queue lock held by caller
1645 * FIXME: sort this out and get new_eh running
1646 */
1647
1605 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(NCR5380_read(STATUS_REG) & PHASE_MASK));
1606 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_RST);
1607 udelay(25);
1608 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
1609}
1610
1611/*
1612 * Function : do_abort (Scsi_Host *host)
1613 *
1614 * Purpose : abort the currently established nexus. Should only be
1615 * called from a routine which can drop into a
1616 *
1617 * Returns : 0 on success, -1 on failure.
1618 *
1619 * Locks: queue lock held by caller
1620 * FIXME: sort this out and get new_eh running
1621 */
1622
1648static int do_abort(struct Scsi_Host *host) {
1649 NCR5380_local_declare();
1623static int do_abort(struct Scsi_Host *instance)
1624{
1650 unsigned char *msgptr, phase, tmp;
1651 int len;
1652 int rc;
1625 unsigned char *msgptr, phase, tmp;
1626 int len;
1627 int rc;
1653 NCR5380_setup(host);
1654
1628
1655
1656 /* Request message out phase */
1657 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
1658
1659 /*
1660 * Wait for the target to indicate a valid phase by asserting
1661 * REQ. Once this happens, we'll have either a MSGOUT phase
1662 * and can immediately send the ABORT message, or we'll have some
1663 * other phase and will have to source/sink data.
1664 *
1665 * We really don't care what value was on the bus or what value
1666 * the target sees, so we just handshake.
1667 */
1668
1629 /* Request message out phase */
1630 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
1631
1632 /*
1633 * Wait for the target to indicate a valid phase by asserting
1634 * REQ. Once this happens, we'll have either a MSGOUT phase
1635 * and can immediately send the ABORT message, or we'll have some
1636 * other phase and will have to source/sink data.
1637 *
1638 * We really don't care what value was on the bus or what value
1639 * the target sees, so we just handshake.
1640 */
1641
1669 rc = NCR5380_poll_politely(host, STATUS_REG, SR_REQ, SR_REQ, 60 * HZ);
1642 rc = NCR5380_poll_politely(instance, STATUS_REG, SR_REQ, SR_REQ, 60 * HZ);
1670
1671 if(rc < 0)
1672 return -1;
1673
1674 tmp = (unsigned char)rc;
1675
1676 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
1677
1678 if ((tmp & PHASE_MASK) != PHASE_MSGOUT) {
1679 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN | ICR_ASSERT_ACK);
1643
1644 if(rc < 0)
1645 return -1;
1646
1647 tmp = (unsigned char)rc;
1648
1649 NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
1650
1651 if ((tmp & PHASE_MASK) != PHASE_MSGOUT) {
1652 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN | ICR_ASSERT_ACK);
1680 rc = NCR5380_poll_politely(host, STATUS_REG, SR_REQ, 0, 3*HZ);
1653 rc = NCR5380_poll_politely(instance, STATUS_REG, SR_REQ, 0, 3 * HZ);
1681 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
1682 if(rc == -1)
1683 return -1;
1684 }
1685 tmp = ABORT;
1686 msgptr = &tmp;
1687 len = 1;
1688 phase = PHASE_MSGOUT;
1654 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN);
1655 if(rc == -1)
1656 return -1;
1657 }
1658 tmp = ABORT;
1659 msgptr = &tmp;
1660 len = 1;
1661 phase = PHASE_MSGOUT;
1689 NCR5380_transfer_pio(host, &phase, &len, &msgptr);
1662 NCR5380_transfer_pio(instance, &phase, &len, &msgptr);
1690
1691 /*
1692 * If we got here, and the command completed successfully,
1693 * we're about to go into bus free state.
1694 */
1695
1696 return len ? -1 : 0;
1697}

--- 16 unchanged lines hidden (view full) ---

1714 *
1715 * Also, *phase, *count, *data are modified in place.
1716 *
1717 * Locks: io_request lock held by caller
1718 */
1719
1720
1721static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data) {
1663
1664 /*
1665 * If we got here, and the command completed successfully,
1666 * we're about to go into bus free state.
1667 */
1668
1669 return len ? -1 : 0;
1670}

--- 16 unchanged lines hidden (view full) ---

1687 *
1688 * Also, *phase, *count, *data are modified in place.
1689 *
1690 * Locks: io_request lock held by caller
1691 */
1692
1693
1694static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data) {
1722 NCR5380_local_declare();
1723 register int c = *count;
1724 register unsigned char p = *phase;
1725 register unsigned char *d = *data;
1726 unsigned char tmp;
1727 int foo;
1728#if defined(REAL_DMA_POLL)
1729 int cnt, toPIO;
1730 unsigned char saved_data = 0, overrun = 0, residue;
1731#endif
1732
1733 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
1734
1695 register int c = *count;
1696 register unsigned char p = *phase;
1697 register unsigned char *d = *data;
1698 unsigned char tmp;
1699 int foo;
1700#if defined(REAL_DMA_POLL)
1701 int cnt, toPIO;
1702 unsigned char saved_data = 0, overrun = 0, residue;
1703#endif
1704
1705 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
1706
1735 NCR5380_setup(instance);
1736
1737 if ((tmp = (NCR5380_read(STATUS_REG) & PHASE_MASK)) != p) {
1738 *phase = tmp;
1739 return -1;
1740 }
1741#if defined(REAL_DMA) || defined(REAL_DMA_POLL)
1742#ifdef READ_OVERRUNS
1743 if (p & SR_IO) {
1744 c -= 2;

--- 250 unchanged lines hidden (view full) ---

1995 *
1996 * XXX Note : we need to watch for bus free or a reset condition here
1997 * to recover from an unexpected bus free condition.
1998 *
1999 * Locks: io_request_lock held by caller in IRQ mode
2000 */
2001
2002static void NCR5380_information_transfer(struct Scsi_Host *instance) {
1707 if ((tmp = (NCR5380_read(STATUS_REG) & PHASE_MASK)) != p) {
1708 *phase = tmp;
1709 return -1;
1710 }
1711#if defined(REAL_DMA) || defined(REAL_DMA_POLL)
1712#ifdef READ_OVERRUNS
1713 if (p & SR_IO) {
1714 c -= 2;

--- 250 unchanged lines hidden (view full) ---

1965 *
1966 * XXX Note : we need to watch for bus free or a reset condition here
1967 * to recover from an unexpected bus free condition.
1968 *
1969 * Locks: io_request_lock held by caller in IRQ mode
1970 */
1971
1972static void NCR5380_information_transfer(struct Scsi_Host *instance) {
2003 NCR5380_local_declare();
2004 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)instance->hostdata;
2005 unsigned char msgout = NOP;
2006 int sink = 0;
2007 int len;
2008#if defined(PSEUDO_DMA) || defined(REAL_DMA_POLL)
2009 int transfersize;
2010#endif
2011 unsigned char *data;
2012 unsigned char phase, tmp, extended_msg[10], old_phase = 0xff;
2013 struct scsi_cmnd *cmd = (struct scsi_cmnd *) hostdata->connected;
2014 /* RvC: we need to set the end of the polling time */
2015 unsigned long poll_time = jiffies + USLEEP_POLL;
2016
1973 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)instance->hostdata;
1974 unsigned char msgout = NOP;
1975 int sink = 0;
1976 int len;
1977#if defined(PSEUDO_DMA) || defined(REAL_DMA_POLL)
1978 int transfersize;
1979#endif
1980 unsigned char *data;
1981 unsigned char phase, tmp, extended_msg[10], old_phase = 0xff;
1982 struct scsi_cmnd *cmd = (struct scsi_cmnd *) hostdata->connected;
1983 /* RvC: we need to set the end of the polling time */
1984 unsigned long poll_time = jiffies + USLEEP_POLL;
1985
2017 NCR5380_setup(instance);
2018
2019 while (1) {
2020 tmp = NCR5380_read(STATUS_REG);
2021 /* We only have a valid SCSI phase when REQ is asserted */
2022 if (tmp & SR_REQ) {
2023 phase = (tmp & PHASE_MASK);
2024 if (phase != old_phase) {
2025 old_phase = phase;
2026 NCR5380_dprint_phase(NDEBUG_INFORMATION, instance);

--- 374 unchanged lines hidden (view full) ---

2401 * nexus has been reestablished,
2402 *
2403 * Inputs : instance - this instance of the NCR5380.
2404 *
2405 * Locks: io_request_lock held by caller if IRQ driven
2406 */
2407
2408static void NCR5380_reselect(struct Scsi_Host *instance) {
1986 while (1) {
1987 tmp = NCR5380_read(STATUS_REG);
1988 /* We only have a valid SCSI phase when REQ is asserted */
1989 if (tmp & SR_REQ) {
1990 phase = (tmp & PHASE_MASK);
1991 if (phase != old_phase) {
1992 old_phase = phase;
1993 NCR5380_dprint_phase(NDEBUG_INFORMATION, instance);

--- 374 unchanged lines hidden (view full) ---

2368 * nexus has been reestablished,
2369 *
2370 * Inputs : instance - this instance of the NCR5380.
2371 *
2372 * Locks: io_request_lock held by caller if IRQ driven
2373 */
2374
2375static void NCR5380_reselect(struct Scsi_Host *instance) {
2409 NCR5380_local_declare();
2410 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
2411 instance->hostdata;
2412 unsigned char target_mask;
2413 unsigned char lun, phase;
2414 int len;
2415 unsigned char msg[3];
2416 unsigned char *data;
2417 struct scsi_cmnd *tmp = NULL, *prev;
2418 int abort = 0;
2376 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *)
2377 instance->hostdata;
2378 unsigned char target_mask;
2379 unsigned char lun, phase;
2380 int len;
2381 unsigned char msg[3];
2382 unsigned char *data;
2383 struct scsi_cmnd *tmp = NULL, *prev;
2384 int abort = 0;
2419 NCR5380_setup(instance);
2420
2421 /*
2422 * Disable arbitration, etc. since the host adapter obviously
2423 * lost, and tell an interrupted NCR5380_select() to restart.
2424 */
2425
2426 NCR5380_write(MODE_REG, MR_BASE);
2427 hostdata->restart_select = 1;

--- 92 unchanged lines hidden (view full) ---

2520 * Inputs : instance - this instance of the NCR5380.
2521 *
2522 * Returns : pointer to the scsi_cmnd structure for which the I_T_L
2523 * nexus has been reestablished, on failure NULL is returned.
2524 */
2525
2526#ifdef REAL_DMA
2527static void NCR5380_dma_complete(NCR5380_instance * instance) {
2385
2386 /*
2387 * Disable arbitration, etc. since the host adapter obviously
2388 * lost, and tell an interrupted NCR5380_select() to restart.
2389 */
2390
2391 NCR5380_write(MODE_REG, MR_BASE);
2392 hostdata->restart_select = 1;

--- 92 unchanged lines hidden (view full) ---

2485 * Inputs : instance - this instance of the NCR5380.
2486 *
2487 * Returns : pointer to the scsi_cmnd structure for which the I_T_L
2488 * nexus has been reestablished, on failure NULL is returned.
2489 */
2490
2491#ifdef REAL_DMA
2492static void NCR5380_dma_complete(NCR5380_instance * instance) {
2528 NCR5380_local_declare();
2529 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
2530 int transferred;
2493 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
2494 int transferred;
2531 NCR5380_setup(instance);
2532
2533 /*
2534 * XXX this might not be right.
2535 *
2536 * Wait for final byte to transfer, ie wait for ACK to go false.
2537 *
2538 * We should use the Last Byte Sent bit, unfortunately this is
2539 * not available on the 5380/5381 (only the various CMOS chips)

--- 36 unchanged lines hidden (view full) ---

2576 * a problem, we could implement longjmp() / setjmp(), setjmp()
2577 * called where the loop started in NCR5380_main().
2578 *
2579 * Locks: host lock taken by caller
2580 */
2581
2582static int NCR5380_abort(struct scsi_cmnd *cmd)
2583{
2495
2496 /*
2497 * XXX this might not be right.
2498 *
2499 * Wait for final byte to transfer, ie wait for ACK to go false.
2500 *
2501 * We should use the Last Byte Sent bit, unfortunately this is
2502 * not available on the 5380/5381 (only the various CMOS chips)

--- 36 unchanged lines hidden (view full) ---

2539 * a problem, we could implement longjmp() / setjmp(), setjmp()
2540 * called where the loop started in NCR5380_main().
2541 *
2542 * Locks: host lock taken by caller
2543 */
2544
2545static int NCR5380_abort(struct scsi_cmnd *cmd)
2546{
2584 NCR5380_local_declare();
2585 struct Scsi_Host *instance = cmd->device->host;
2586 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
2587 struct scsi_cmnd *tmp, **prev;
2588
2589 scmd_printk(KERN_WARNING, cmd, "aborting command\n");
2590
2591 NCR5380_print_status(instance);
2592
2547 struct Scsi_Host *instance = cmd->device->host;
2548 struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
2549 struct scsi_cmnd *tmp, **prev;
2550
2551 scmd_printk(KERN_WARNING, cmd, "aborting command\n");
2552
2553 NCR5380_print_status(instance);
2554
2593 NCR5380_setup(instance);
2594
2595 dprintk(NDEBUG_ABORT, "scsi%d : abort called\n", instance->host_no);
2596 dprintk(NDEBUG_ABORT, " basr 0x%X, sr 0x%X\n", NCR5380_read(BUS_AND_STATUS_REG), NCR5380_read(STATUS_REG));
2597
2598#if 0
2599/*
2600 * Case 1 : If the command is the currently executing command,
2601 * we'll set the aborted flag and return control so that
2602 * information transfer routine can exit cleanly.

--- 129 unchanged lines hidden (view full) ---

2732 *
2733 * Locks: host lock taken by caller
2734 */
2735
2736static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
2737{
2738 struct Scsi_Host *instance = cmd->device->host;
2739
2555 dprintk(NDEBUG_ABORT, "scsi%d : abort called\n", instance->host_no);
2556 dprintk(NDEBUG_ABORT, " basr 0x%X, sr 0x%X\n", NCR5380_read(BUS_AND_STATUS_REG), NCR5380_read(STATUS_REG));
2557
2558#if 0
2559/*
2560 * Case 1 : If the command is the currently executing command,
2561 * we'll set the aborted flag and return control so that
2562 * information transfer routine can exit cleanly.

--- 129 unchanged lines hidden (view full) ---

2692 *
2693 * Locks: host lock taken by caller
2694 */
2695
2696static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
2697{
2698 struct Scsi_Host *instance = cmd->device->host;
2699
2740 NCR5380_local_declare();
2741 NCR5380_setup(instance);
2742 NCR5380_print_status(instance);
2743
2744 spin_lock_irq(instance->host_lock);
2745 do_reset(instance);
2746 spin_unlock_irq(instance->host_lock);
2747
2748 return SUCCESS;
2749}
2700 NCR5380_print_status(instance);
2701
2702 spin_lock_irq(instance->host_lock);
2703 do_reset(instance);
2704 spin_unlock_irq(instance->host_lock);
2705
2706 return SUCCESS;
2707}