Lines Matching +full:settle +full:- +full:time +full:- +full:us
1 /* ppa.c -- low level driver for the IOMEGA PPA3
55 return *(ppa_struct **)&host->hostdata; in ppa_dev()
62 dev->base = dev->dev->port->base; in got_it()
63 if (dev->cur_cmd) in got_it()
64 ppa_scsi_pointer(dev->cur_cmd)->phase = 1; in got_it()
66 wake_up(dev->waiting); in got_it()
75 if (dev->wanted) { in ppa_wakeup()
76 parport_claim(dev->dev); in ppa_wakeup()
78 dev->wanted = 0; in ppa_wakeup()
89 if (parport_claim(dev->dev) == 0) { in ppa_pb_claim()
93 dev->wanted = res; in ppa_pb_claim()
103 wanted = dev->wanted; in ppa_pb_dismiss()
104 dev->wanted = 0; in ppa_pb_dismiss()
107 parport_release(dev->dev); in ppa_pb_dismiss()
112 parport_release(dev->dev); in ppa_pb_release()
134 dev->mode = x; in ppa_write_info()
139 dev->recon_tmo = x; in ppa_write_info()
144 return -EINVAL; in ppa_write_info()
152 seq_printf(m, "Parport : %s\n", dev->dev->port->name); in ppa_show_info()
153 seq_printf(m, "Mode : %s\n", PPA_MODE_STRING[dev->mode]); in ppa_show_info()
155 seq_printf(m, "recon_tmo : %lu\n", dev->recon_tmo); in ppa_show_info()
171 if (dev->cur_cmd) { in ppa_fail_func()
172 dev->cur_cmd->result = error_code << 16; in ppa_fail_func()
173 dev->failed = 1; in ppa_fail_func()
187 unsigned short ppb = dev->base; in ppa_wait()
191 /* Wait for bit 6 and 7 - PJC */ in ppa_wait()
192 for (r = r_str(ppb); ((r & 0xc0) != 0xc0) && (k); k--) { in ppa_wait()
207 /* Counter expired - Time out occurred */ in ppa_wait()
230 int i, ppb_hi = dev->dev->port->base_hi; in ecp_sync()
249 for (i = len; i; i--) { in ppa_byte_out()
254 return 1; /* All went well - we hope! */ in ppa_byte_out()
261 for (i = len; i; i--) { in ppa_byte_in()
266 return 1; /* All went well - we hope! */ in ppa_byte_in()
271 for (; len; len--) { in ppa_nibble_in()
279 return 1; /* All went well - we hope! */ in ppa_nibble_in()
285 unsigned short ppb = dev->base; in ppa_out()
293 switch (dev->mode) { in ppa_out()
330 unsigned short ppb = dev->base; in ppa_in()
338 switch (dev->mode) { in ppa_in()
394 unsigned short ppb = dev->base; in ppa_disconnect()
413 unsigned short ppb = dev->base; in ppa_connect()
418 if ((flag == CONNECT_EPP_MAYBE) && IN_EPP_MODE(dev->mode)) in ppa_connect()
427 unsigned short ppb = dev->base; in ppa_select()
435 k--; in ppa_select()
449 k--; in ppa_select()
471 unsigned short ppb = dev->base; in ppa_init()
480 retv--; in ppa_init()
484 retv--; in ppa_init()
488 udelay(1000); /* Allow devices to settle down */ in ppa_init()
490 udelay(1000); /* Another delay to allow devices to settle */ in ppa_init()
493 return -EIO; in ppa_init()
500 ppa_struct *dev = ppa_dev(cmd->device->host); in ppa_send_command()
503 w_ctr(dev->base, 0x0c); in ppa_send_command()
505 for (k = 0; k < cmd->cmd_len; k++) in ppa_send_command()
506 if (!ppa_out(dev, &cmd->cmnd[k], 1)) in ppa_send_command()
522 * -1 Error in ppa_completion()
527 ppa_struct *dev = ppa_dev(cmd->device->host); in ppa_completion()
528 unsigned short ppb = dev->base; in ppa_completion()
534 v = cmd->cmnd[0]; in ppa_completion()
552 if (scsi_pointer->this_residual <= 0) { in ppa_completion()
554 return -1; /* ERROR_RETURN */ in ppa_completion()
571 unsigned long k = dev->recon_tmo; in ppa_completion()
573 k--) in ppa_completion()
581 fast = bulk && scsi_pointer->this_residual >= PPA_BURST_SIZE ? in ppa_completion()
585 status = ppa_out(dev, scsi_pointer->ptr, fast); in ppa_completion()
587 status = ppa_in(dev, scsi_pointer->ptr, fast); in ppa_completion()
589 scsi_pointer->ptr += fast; in ppa_completion()
590 scsi_pointer->this_residual -= fast; in ppa_completion()
594 return -1; /* ERROR_RETURN */ in ppa_completion()
596 if (scsi_pointer->buffer && !scsi_pointer->this_residual) { in ppa_completion()
598 if (scsi_pointer->buffers_residual--) { in ppa_completion()
599 scsi_pointer->buffer = in ppa_completion()
600 sg_next(scsi_pointer->buffer); in ppa_completion()
601 scsi_pointer->this_residual = in ppa_completion()
602 scsi_pointer->buffer->length; in ppa_completion()
603 scsi_pointer->ptr = in ppa_completion()
604 sg_virt(scsi_pointer->buffer); in ppa_completion()
618 * the scheduler's task queue to generate a stream of call-backs and
624 struct scsi_cmnd *cmd = dev->cur_cmd; in ppa_interrupt()
631 schedule_delayed_work(&dev->ppa_tq, 1); in ppa_interrupt()
636 switch ((cmd->result >> 16) & 0xff) { in ppa_interrupt()
640 printk(KERN_DEBUG "ppa: no device at SCSI ID %i\n", cmd->device->target); in ppa_interrupt()
643 printk(KERN_DEBUG "ppa: BUS BUSY - EPP timeout detected\n"); in ppa_interrupt()
665 (cmd->result >> 16) & 0xff); in ppa_interrupt()
669 if (ppa_scsi_pointer(cmd)->phase > 1) in ppa_interrupt()
674 dev->cur_cmd = NULL; in ppa_interrupt()
682 unsigned short ppb = dev->base; in ppa_engine()
689 if (dev->failed) in ppa_engine()
692 switch (scsi_pointer->phase) { in ppa_engine()
693 case 0: /* Phase 0 - Waiting for parport */ in ppa_engine()
694 if (time_after(jiffies, dev->jstart + HZ)) { in ppa_engine()
697 * for parport to call us in ppa_engine()
703 case 1: /* Phase 1 - Connected */ in ppa_engine()
711 retv--; in ppa_engine()
715 retv--; in ppa_engine()
718 if (time_after(jiffies, dev->jstart + (1 * HZ))) { in ppa_engine()
727 scsi_pointer->phase++; in ppa_engine()
731 case 2: /* Phase 2 - We are now talking to the scsi bus */ in ppa_engine()
736 scsi_pointer->phase++; in ppa_engine()
739 case 3: /* Phase 3 - Ready to accept a command */ in ppa_engine()
746 scsi_pointer->phase++; in ppa_engine()
749 case 4: /* Phase 4 - Setup scatter/gather buffers */ in ppa_engine()
751 scsi_pointer->buffer = scsi_sglist(cmd); in ppa_engine()
752 scsi_pointer->this_residual = in ppa_engine()
753 scsi_pointer->buffer->length; in ppa_engine()
754 scsi_pointer->ptr = sg_virt(scsi_pointer->buffer); in ppa_engine()
756 scsi_pointer->buffer = NULL; in ppa_engine()
757 scsi_pointer->this_residual = 0; in ppa_engine()
758 scsi_pointer->ptr = NULL; in ppa_engine()
760 scsi_pointer->buffers_residual = scsi_sg_count(cmd) - 1; in ppa_engine()
761 scsi_pointer->phase++; in ppa_engine()
764 case 5: /* Phase 5 - Data transfer stage */ in ppa_engine()
770 if (retv == -1) in ppa_engine()
774 scsi_pointer->phase++; in ppa_engine()
777 case 6: /* Phase 6 - Read status/message */ in ppa_engine()
778 cmd->result = DID_OK << 16; in ppa_engine()
788 cmd->result = in ppa_engine()
801 ppa_struct *dev = ppa_dev(cmd->device->host); in ppa_queuecommand_lck()
803 if (dev->cur_cmd) { in ppa_queuecommand_lck()
807 dev->failed = 0; in ppa_queuecommand_lck()
808 dev->jstart = jiffies; in ppa_queuecommand_lck()
809 dev->cur_cmd = cmd; in ppa_queuecommand_lck()
810 cmd->result = DID_ERROR << 16; /* default return code */ in ppa_queuecommand_lck()
811 ppa_scsi_pointer(cmd)->phase = 0; /* bus free */ in ppa_queuecommand_lck()
813 schedule_delayed_work(&dev->ppa_tq, 0); in ppa_queuecommand_lck()
823 * Apparently the disk->capacity attribute is off by 1 sector in DEF_SCSI_QCMD()
846 ppa_struct *dev = ppa_dev(cmd->device->host); in ppa_abort()
852 switch (ppa_scsi_pointer(cmd)->phase) { in ppa_abort()
855 dev->cur_cmd = NULL; /* Forget the problem */ in ppa_abort()
872 ppa_struct *dev = ppa_dev(cmd->device->host); in ppa_reset()
874 if (ppa_scsi_pointer(cmd)->phase) in ppa_reset()
876 dev->cur_cmd = NULL; /* Forget the problem */ in ppa_reset()
879 ppa_reset_pulse(dev->base); in ppa_reset()
880 mdelay(1); /* device settle delay */ in ppa_reset()
882 mdelay(1); /* device settle delay */ in ppa_reset()
892 int loop, old_mode, status, k, ppb = dev->base; in device_check()
895 old_mode = dev->mode; in device_check()
899 dev->mode = PPA_EPP_32; in device_check()
909 loop, PPA_MODE_STRING[dev->mode]); in device_check()
927 if (dev->mode == PPA_EPP_32) { in device_check()
928 dev->mode = old_mode; in device_check()
931 return -EIO; in device_check()
937 k--; in device_check()
950 if (dev->mode == PPA_EPP_32) { in device_check()
951 dev->mode = old_mode; in device_check()
954 return -EIO; in device_check()
958 loop, PPA_MODE_STRING[dev->mode]); in device_check()
966 return -ENODEV; in device_check()
971 blk_queue_bounce_limit(device->request_queue, BLK_BOUNCE_HIGH); in ppa_adjust_queue()
985 .this_id = -1,
1013 if (dev->dev_no != cnt) in find_parent()
1030 int err = -ENOMEM; in __ppa_attach()
1035 return -ENOMEM; in __ppa_attach()
1036 dev->base = -1; in __ppa_attach()
1037 dev->mode = PPA_AUTODETECT; in __ppa_attach()
1038 dev->recon_tmo = PPA_RECON_TMO; in __ppa_attach()
1042 dev->dev_no = temp->dev_no + 1; in __ppa_attach()
1048 dev->dev = parport_register_dev_model(pb, "ppa", &ppa_cb, dev->dev_no); in __ppa_attach()
1050 if (!dev->dev) in __ppa_attach()
1056 err = -EBUSY; in __ppa_attach()
1057 dev->waiting = &waiting; in __ppa_attach()
1061 if (dev->wanted) { in __ppa_attach()
1064 "time!\n", pb->number); in __ppa_attach()
1066 dev->waiting = NULL; in __ppa_attach()
1070 dev->waiting = NULL; in __ppa_attach()
1072 ppb = dev->base = dev->dev->port->base; in __ppa_attach()
1073 ppb_hi = dev->dev->port->base_hi; in __ppa_attach()
1075 modes = dev->dev->port->modes; in __ppa_attach()
1078 * This avoids a nasty if-then-else-if-... tree in __ppa_attach()
1080 dev->mode = PPA_NIBBLE; in __ppa_attach()
1083 dev->mode = PPA_PS2; in __ppa_attach()
1087 dev->mode = PPA_PS2; in __ppa_attach()
1101 if (dev->mode == PPA_NIBBLE || dev->mode == PPA_PS2) in __ppa_attach()
1106 INIT_DELAYED_WORK(&dev->ppa_tq, ppa_interrupt); in __ppa_attach()
1108 err = -ENOMEM; in __ppa_attach()
1112 host->io_port = pb->base; in __ppa_attach()
1113 host->n_io_port = ports; in __ppa_attach()
1114 host->dma_channel = -1; in __ppa_attach()
1115 host->unique_id = pb->number; in __ppa_attach()
1116 *(ppa_struct **)&host->hostdata = dev; in __ppa_attach()
1117 dev->host = host; in __ppa_attach()
1118 list_add_tail(&dev->list, &ppa_hosts); in __ppa_attach()
1125 list_del_init(&dev->list); in __ppa_attach()
1128 parport_unregister_device(dev->dev); in __ppa_attach()
1143 if (dev->dev->port == pb) { in ppa_detach()
1144 list_del_init(&dev->list); in ppa_detach()
1145 scsi_remove_host(dev->host); in ppa_detach()
1146 scsi_host_put(dev->host); in ppa_detach()
1147 parport_unregister_device(dev->dev); in ppa_detach()