Lines Matching +full:4 +full:- +full:pole

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * of PCI-SCSI IO processors.
6 * Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr>
7 * Copyright (c) 2003-2005 Matthew Wilcox <matthew@wil.cx>
10 * Copyright (C) 1998-2000 Gerard Roudier
13 * a port of the FreeBSD ncr driver to Linux-1.2.13.
17 * Stefan Esser <se@mi.Uni-Koeln.de>
25 *-----------------------------------------------------------------------------
66 MODULE_PARM_DESC(irqm, "0 for open drain, 1 to leave alone, 2 for totem pole");
122 #define SYM_SOFTC_PTR(cmd) sym_get_hcb(cmd->device->host)
131 if (ucmd->eh_done) in sym_xpt_done()
132 complete(ucmd->eh_done); in sym_xpt_done()
144 np->s.settle_time = jiffies + sym_driver_setup.settle_delay * HZ; in sym_xpt_async_bus_reset()
145 np->s.settle_time_valid = 1; in sym_xpt_async_bus_reset()
167 * Build CAM result for a failed or auto-sensed IO.
171 struct scsi_cmnd *cmd = cp->cmd; in sym_set_cam_result_error()
175 scsi_status = cp->ssss_status; in sym_set_cam_result_error()
177 if (cp->host_flags & HF_SENSE) { in sym_set_cam_result_error()
178 scsi_status = cp->sv_scsi_status; in sym_set_cam_result_error()
179 resid = cp->sv_resid; in sym_set_cam_result_error()
180 if (sym_verbose && cp->sv_xerr_status) in sym_set_cam_result_error()
181 sym_print_xerr(cmd, cp->sv_xerr_status); in sym_set_cam_result_error()
182 if (cp->host_status == HS_COMPLETE && in sym_set_cam_result_error()
183 cp->ssss_status == S_GOOD && in sym_set_cam_result_error()
184 cp->xerr_status == 0) { in sym_set_cam_result_error()
186 cp->sv_xerr_status); in sym_set_cam_result_error()
190 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in sym_set_cam_result_error()
191 memcpy(cmd->sense_buffer, cp->sns_bbuf, in sym_set_cam_result_error()
201 p = (u_char *) cmd->sense_data; in sym_set_cam_result_error()
204 cp->target,cp->lun, -1); in sym_set_cam_result_error()
214 sym_reset_scsi_target(np, cmd->device->id); in sym_set_cam_result_error()
217 } else if (cp->host_status == HS_COMPLETE) /* Bad SCSI status */ in sym_set_cam_result_error()
219 else if (cp->host_status == HS_SEL_TIMEOUT) /* Selection timeout */ in sym_set_cam_result_error()
221 else if (cp->host_status == HS_UNEXPECTED) /* Unexpected BUS FREE*/ in sym_set_cam_result_error()
226 cp->host_status, cp->ssss_status, in sym_set_cam_result_error()
227 cp->xerr_status); in sym_set_cam_result_error()
232 cam_status = sym_xerr_cam_status(DID_ERROR, cp->xerr_status); in sym_set_cam_result_error()
235 cmd->result = (cam_status << 16) | scsi_status; in sym_set_cam_result_error()
243 cp->data_len = 0; in sym_scatter()
248 struct sym_tcb *tp = &np->target[cp->target]; in sym_scatter()
253 return -1; in sym_scatter()
256 data = &cp->phys.data[SYM_CONF_MAX_SG - use_sg]; in sym_scatter()
262 if ((len & 1) && (tp->head.wval & EWS)) { in sym_scatter()
264 cp->odd_byte_adjustment++; in sym_scatter()
268 cp->data_len += len; in sym_scatter()
271 segment = -2; in sym_scatter()
282 struct scsi_device *sdev = cmd->device; in sym_queue_command()
291 tp = &np->target[sdev->id]; in sym_queue_command()
296 lp = sym_lp(tp, sdev->lun); in sym_queue_command()
297 order = (lp && lp->s.reqtags) ? M_SIMPLE_TAG : 0; in sym_queue_command()
314 memcpy(cp->cdb_buf, cmd->cmnd, cmd->cmd_len); in sym_setup_cdb()
316 cp->phys.cmd.addr = CCB_BA(cp, cdb_buf[0]); in sym_setup_cdb()
317 cp->phys.cmd.size = cpu_to_scr(cmd->cmd_len); in sym_setup_cdb()
339 dir = cmd->sc_data_direction; in sym_setup_data_and_start()
341 cp->segments = sym_scatter(np, cp, cmd); in sym_setup_data_and_start()
342 if (cp->segments < 0) { in sym_setup_data_and_start()
350 if (!cp->segments) in sym_setup_data_and_start()
353 cp->data_len = 0; in sym_setup_data_and_start()
354 cp->segments = 0; in sym_setup_data_and_start()
367 lastp = goalp - 8 - (cp->segments * (2*4)); in sym_setup_data_and_start()
370 cp->host_flags |= HF_DATA_IN; in sym_setup_data_and_start()
372 lastp = goalp - 8 - (cp->segments * (2*4)); in sym_setup_data_and_start()
383 cp->phys.head.lastp = cpu_to_scr(lastp); in sym_setup_data_and_start()
384 cp->phys.head.savep = cpu_to_scr(lastp); in sym_setup_data_and_start()
385 cp->startp = cp->phys.head.savep; in sym_setup_data_and_start()
386 cp->goalp = cpu_to_scr(goalp); in sym_setup_data_and_start()
395 switch (cp->cdb_buf[0]) { in sym_setup_data_and_start()
430 np->s.timer.expires = thistime + SYM_CONF_TIMER_INTERVAL; in sym_timer()
431 add_timer(&np->s.timer); in sym_timer()
437 if (np->s.settle_time_valid) { in sym_timer()
438 if (time_before_eq(np->s.settle_time, thistime)) { in sym_timer()
442 np->s.settle_time_valid = 0; in sym_timer()
450 if (np->s.lasttime + 4*HZ < thistime) { in sym_timer()
451 np->s.lasttime = thistime; in sym_timer()
456 * Some way-broken PCI bridges may lead to in sym_timer()
474 struct pci_dev *pdev = sym_data->pdev; in sym_log_bus_error()
500 if (np->s.settle_time_valid && scsi_cmd_to_rq(cmd)->timeout) { in sym53c8xx_queue_command_lck()
501 unsigned long tlimit = jiffies + scsi_cmd_to_rq(cmd)->timeout; in sym53c8xx_queue_command_lck()
502 tlimit -= SYM_CONF_TIMER_INTERVAL*2; in sym53c8xx_queue_command_lck()
503 if (time_after(np->s.settle_time, tlimit)) { in sym53c8xx_queue_command_lck()
504 np->s.settle_time = tlimit; in sym53c8xx_queue_command_lck()
508 if (np->s.settle_time_valid) in sym53c8xx_queue_command_lck()
529 if (pci_channel_offline(sym_data->pdev)) in DEF_SCSI_QCMD()
534 spin_lock(shost->host_lock); in DEF_SCSI_QCMD()
536 spin_unlock(shost->host_lock); in DEF_SCSI_QCMD()
551 spin_lock_irqsave(np->s.host->host_lock, flags); in sym53c8xx_timer()
553 spin_unlock_irqrestore(np->s.host->host_lock, flags); in sym53c8xx_timer()
573 struct Scsi_Host *shost = cmd->device->host; in sym53c8xx_eh_abort_handler()
575 struct pci_dev *pdev = sym_data->pdev; in sym53c8xx_eh_abort_handler()
576 struct sym_hcb *np = sym_data->ncb; in sym53c8xx_eh_abort_handler()
579 int sts = -1; in sym53c8xx_eh_abort_handler()
590 spin_lock_irq(shost->host_lock); in sym53c8xx_eh_abort_handler()
591 /* This one is queued in some place -> to wait for completion */ in sym53c8xx_eh_abort_handler()
592 FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) { in sym53c8xx_eh_abort_handler()
594 if (cp->cmd == cmd) { in sym53c8xx_eh_abort_handler()
607 ucmd->eh_done = &eh_done; in sym53c8xx_eh_abort_handler()
608 spin_unlock_irq(shost->host_lock); in sym53c8xx_eh_abort_handler()
610 ucmd->eh_done = NULL; in sym53c8xx_eh_abort_handler()
611 sts = -2; in sym53c8xx_eh_abort_handler()
614 spin_unlock_irq(shost->host_lock); in sym53c8xx_eh_abort_handler()
617 dev_warn(&cmd->device->sdev_gendev, "ABORT operation %s.\n", in sym53c8xx_eh_abort_handler()
618 sts==0 ? "complete" :sts==-2 ? "timed-out" : "failed"); in sym53c8xx_eh_abort_handler()
624 struct scsi_target *starget = scsi_target(cmd->device); in sym53c8xx_eh_target_reset_handler()
625 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in sym53c8xx_eh_target_reset_handler()
627 struct pci_dev *pdev = sym_data->pdev; in sym53c8xx_eh_target_reset_handler()
628 struct sym_hcb *np = sym_data->ncb; in sym53c8xx_eh_target_reset_handler()
642 spin_lock_irq(shost->host_lock); in sym53c8xx_eh_target_reset_handler()
643 sts = sym_reset_scsi_target(np, starget->id); in sym53c8xx_eh_target_reset_handler()
645 FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) { in sym53c8xx_eh_target_reset_handler()
648 struct scsi_cmnd *cmd = cp->cmd; in sym53c8xx_eh_target_reset_handler()
651 if (!cmd || cmd->device->channel != starget->channel || in sym53c8xx_eh_target_reset_handler()
652 cmd->device->id != starget->id) in sym53c8xx_eh_target_reset_handler()
657 ucmd->eh_done = &eh_done; in sym53c8xx_eh_target_reset_handler()
658 spin_unlock_irq(shost->host_lock); in sym53c8xx_eh_target_reset_handler()
660 ucmd->eh_done = NULL; in sym53c8xx_eh_target_reset_handler()
661 sts = -2; in sym53c8xx_eh_target_reset_handler()
663 spin_lock_irq(shost->host_lock); in sym53c8xx_eh_target_reset_handler()
666 spin_unlock_irq(shost->host_lock); in sym53c8xx_eh_target_reset_handler()
669 sts==0 ? "complete" :sts==-2 ? "timed-out" : "failed"); in sym53c8xx_eh_target_reset_handler()
675 struct Scsi_Host *shost = cmd->device->host; in sym53c8xx_eh_bus_reset_handler()
677 struct pci_dev *pdev = sym_data->pdev; in sym53c8xx_eh_bus_reset_handler()
678 struct sym_hcb *np = sym_data->ncb; in sym53c8xx_eh_bus_reset_handler()
688 spin_lock_irq(shost->host_lock); in sym53c8xx_eh_bus_reset_handler()
690 spin_unlock_irq(shost->host_lock); in sym53c8xx_eh_bus_reset_handler()
692 dev_warn(&cmd->device->sdev_gendev, "BUS RESET operation complete.\n"); in sym53c8xx_eh_bus_reset_handler()
698 struct Scsi_Host *shost = cmd->device->host; in sym53c8xx_eh_host_reset_handler()
700 struct pci_dev *pdev = sym_data->pdev; in sym53c8xx_eh_host_reset_handler()
701 struct sym_hcb *np = sym_data->ncb; in sym53c8xx_eh_host_reset_handler()
716 spin_lock_irq(shost->host_lock); in sym53c8xx_eh_host_reset_handler()
719 BUG_ON(sym_data->io_reset); in sym53c8xx_eh_host_reset_handler()
720 sym_data->io_reset = &eh_done; in sym53c8xx_eh_host_reset_handler()
723 spin_unlock_irq(shost->host_lock); in sym53c8xx_eh_host_reset_handler()
726 (sym_data->io_reset, in sym53c8xx_eh_host_reset_handler()
728 spin_lock_irq(shost->host_lock); in sym53c8xx_eh_host_reset_handler()
729 sym_data->io_reset = NULL; in sym53c8xx_eh_host_reset_handler()
730 spin_unlock_irq(shost->host_lock); in sym53c8xx_eh_host_reset_handler()
754 oldtags = lp->s.reqtags; in sym_tune_dev_queuing()
756 if (reqtags > lp->s.scdev_depth) in sym_tune_dev_queuing()
757 reqtags = lp->s.scdev_depth; in sym_tune_dev_queuing()
759 lp->s.reqtags = reqtags; in sym_tune_dev_queuing()
762 dev_info(&tp->starget->dev, in sym_tune_dev_queuing()
764 lp->s.reqtags ? "enabled" : "disabled", reqtags); in sym_tune_dev_queuing()
770 struct sym_hcb *np = sym_get_hcb(sdev->host); in sym53c8xx_slave_alloc()
771 struct sym_tcb *tp = &np->target[sdev->id]; in sym53c8xx_slave_alloc()
776 if (sdev->id >= SYM_CONF_MAX_TARGET || sdev->lun >= SYM_CONF_MAX_LUN) in sym53c8xx_slave_alloc()
777 return -ENXIO; in sym53c8xx_slave_alloc()
779 spin_lock_irqsave(np->s.host->host_lock, flags); in sym53c8xx_slave_alloc()
790 if (tp->usrflags & SYM_SCAN_BOOT_DISABLED) { in sym53c8xx_slave_alloc()
791 tp->usrflags &= ~SYM_SCAN_BOOT_DISABLED; in sym53c8xx_slave_alloc()
792 starget_printk(KERN_INFO, sdev->sdev_target, in sym53c8xx_slave_alloc()
794 error = -ENXIO; in sym53c8xx_slave_alloc()
798 if (tp->usrflags & SYM_SCAN_LUNS_DISABLED) { in sym53c8xx_slave_alloc()
799 if (sdev->lun != 0) { in sym53c8xx_slave_alloc()
800 error = -ENXIO; in sym53c8xx_slave_alloc()
803 starget_printk(KERN_INFO, sdev->sdev_target, in sym53c8xx_slave_alloc()
807 lp = sym_alloc_lcb(np, sdev->id, sdev->lun); in sym53c8xx_slave_alloc()
809 error = -ENOMEM; in sym53c8xx_slave_alloc()
812 if (tp->nlcb == 1) in sym53c8xx_slave_alloc()
813 tp->starget = sdev->sdev_target; in sym53c8xx_slave_alloc()
815 spi_min_period(tp->starget) = tp->usr_period; in sym53c8xx_slave_alloc()
816 spi_max_width(tp->starget) = tp->usr_width; in sym53c8xx_slave_alloc()
820 spin_unlock_irqrestore(np->s.host->host_lock, flags); in sym53c8xx_slave_alloc()
830 struct sym_hcb *np = sym_get_hcb(sdev->host); in sym53c8xx_slave_configure()
831 struct sym_tcb *tp = &np->target[sdev->id]; in sym53c8xx_slave_configure()
832 struct sym_lcb *lp = sym_lp(tp, sdev->lun); in sym53c8xx_slave_configure()
838 lp->curr_flags = lp->user_flags; in sym53c8xx_slave_configure()
847 if (reqtags > tp->usrtags) in sym53c8xx_slave_configure()
848 reqtags = tp->usrtags; in sym53c8xx_slave_configure()
849 if (!sdev->tagged_supported) in sym53c8xx_slave_configure()
855 lp->s.scdev_depth = depth_to_use; in sym53c8xx_slave_configure()
856 sym_tune_dev_queuing(tp, sdev->lun, reqtags); in sym53c8xx_slave_configure()
858 if (!spi_initial_dv(sdev->sdev_target)) in sym53c8xx_slave_configure()
866 struct sym_hcb *np = sym_get_hcb(sdev->host); in sym53c8xx_slave_destroy()
867 struct sym_tcb *tp = &np->target[sdev->id]; in sym53c8xx_slave_destroy()
868 struct sym_lcb *lp = sym_lp(tp, sdev->lun); in sym53c8xx_slave_destroy()
875 spin_lock_irqsave(np->s.host->host_lock, flags); in sym53c8xx_slave_destroy()
877 if (lp->busy_itlq || lp->busy_itl) { in sym53c8xx_slave_destroy()
880 * so let's try to stop all on-going I/O. in sym53c8xx_slave_destroy()
882 starget_printk(KERN_WARNING, tp->starget, in sym53c8xx_slave_destroy()
883 "Removing busy LCB (%d)\n", (u8)sdev->lun); in sym53c8xx_slave_destroy()
887 if (sym_free_lcb(np, sdev->id, sdev->lun) == 0) { in sym53c8xx_slave_destroy()
891 tp->head.sval = 0; in sym53c8xx_slave_destroy()
892 tp->head.wval = np->rv_scntl3; in sym53c8xx_slave_destroy()
893 tp->head.uval = 0; in sym53c8xx_slave_destroy()
894 tp->tgoal.check_nego = 1; in sym53c8xx_slave_destroy()
895 tp->starget = NULL; in sym53c8xx_slave_destroy()
898 spin_unlock_irqrestore(np->s.host->host_lock, flags); in sym53c8xx_slave_destroy()
943 switch (uc->cmd) { in sym_exec_user_command()
948 sym_debug_flags = uc->data; in sym_exec_user_command()
952 np->verbose = uc->data; in sym_exec_user_command()
958 * 4 lines to be repeated 6 times. in sym_exec_user_command()
961 if (!((uc->target >> t) & 1)) in sym_exec_user_command()
963 tp = &np->target[t]; in sym_exec_user_command()
964 if (!tp->nlcb) in sym_exec_user_command()
967 switch (uc->cmd) { in sym_exec_user_command()
970 if (!uc->data || uc->data >= 255) { in sym_exec_user_command()
971 tp->tgoal.iu = tp->tgoal.dt = in sym_exec_user_command()
972 tp->tgoal.qas = 0; in sym_exec_user_command()
973 tp->tgoal.offset = 0; in sym_exec_user_command()
974 } else if (uc->data <= 9 && np->minsync_dt) { in sym_exec_user_command()
975 if (uc->data < np->minsync_dt) in sym_exec_user_command()
976 uc->data = np->minsync_dt; in sym_exec_user_command()
977 tp->tgoal.iu = tp->tgoal.dt = in sym_exec_user_command()
978 tp->tgoal.qas = 1; in sym_exec_user_command()
979 tp->tgoal.width = 1; in sym_exec_user_command()
980 tp->tgoal.period = uc->data; in sym_exec_user_command()
981 tp->tgoal.offset = np->maxoffs_dt; in sym_exec_user_command()
983 if (uc->data < np->minsync) in sym_exec_user_command()
984 uc->data = np->minsync; in sym_exec_user_command()
985 tp->tgoal.iu = tp->tgoal.dt = in sym_exec_user_command()
986 tp->tgoal.qas = 0; in sym_exec_user_command()
987 tp->tgoal.period = uc->data; in sym_exec_user_command()
988 tp->tgoal.offset = np->maxoffs; in sym_exec_user_command()
990 tp->tgoal.check_nego = 1; in sym_exec_user_command()
993 tp->tgoal.width = uc->data ? 1 : 0; in sym_exec_user_command()
994 tp->tgoal.check_nego = 1; in sym_exec_user_command()
998 sym_tune_dev_queuing(tp, l, uc->data); in sym_exec_user_command()
1001 tp->to_reset = 1; in sym_exec_user_command()
1002 np->istat_sem = SEM; in sym_exec_user_command()
1008 if (lp) lp->to_clear = 1; in sym_exec_user_command()
1010 np->istat_sem = SEM; in sym_exec_user_command()
1014 tp->usrflags = uc->data; in sym_exec_user_command()
1026 for (cnt = len; cnt > 0 && (c = *ptr++) && isspace(c); cnt--); in sym_skip_spaces()
1028 return (len - cnt); in sym_skip_spaces()
1036 return (end - ptr); in get_int_arg()
1051 return -EINVAL; \
1052 ptr += arg_len; len -= arg_len;
1056 return -EINVAL; \
1057 ptr += arg_len; len -= arg_len;
1075 if (len > 0 && ptr[len-1] == '\n') in sym_user_command()
1076 --len; in sym_user_command()
1079 uc->cmd = UC_SETSYNC; in sym_user_command()
1081 uc->cmd = UC_SETTAGS; in sym_user_command()
1083 uc->cmd = UC_SETVERBOSE; in sym_user_command()
1085 uc->cmd = UC_SETWIDE; in sym_user_command()
1088 uc->cmd = UC_SETDEBUG; in sym_user_command()
1091 uc->cmd = UC_SETFLAG; in sym_user_command()
1093 uc->cmd = UC_RESETDEV; in sym_user_command()
1095 uc->cmd = UC_CLEARDEV; in sym_user_command()
1100 printk("sym_user_command: arg_len=%d, cmd=%ld\n", arg_len, uc->cmd); in sym_user_command()
1104 return -EINVAL; in sym_user_command()
1105 ptr += arg_len; len -= arg_len; in sym_user_command()
1107 switch(uc->cmd) { in sym_user_command()
1116 ptr += arg_len; len -= arg_len; in sym_user_command()
1117 uc->target = ~0; in sym_user_command()
1120 uc->target = (1<<target); in sym_user_command()
1128 switch(uc->cmd) { in sym_user_command()
1134 GET_INT_ARG(ptr, len, uc->data); in sym_user_command()
1136 printk("sym_user_command: data=%ld\n", uc->data); in sym_user_command()
1144 uc->data |= DEBUG_ALLOC; in sym_user_command()
1146 uc->data |= DEBUG_PHASE; in sym_user_command()
1148 uc->data |= DEBUG_QUEUE; in sym_user_command()
1150 uc->data |= DEBUG_RESULT; in sym_user_command()
1152 uc->data |= DEBUG_SCATTER; in sym_user_command()
1154 uc->data |= DEBUG_SCRIPT; in sym_user_command()
1156 uc->data |= DEBUG_TINY; in sym_user_command()
1158 uc->data |= DEBUG_TIMING; in sym_user_command()
1160 uc->data |= DEBUG_NEGO; in sym_user_command()
1162 uc->data |= DEBUG_TAGS; in sym_user_command()
1164 uc->data |= DEBUG_POINTER; in sym_user_command()
1166 return -EINVAL; in sym_user_command()
1167 ptr += arg_len; len -= arg_len; in sym_user_command()
1170 printk("sym_user_command: data=%ld\n", uc->data); in sym_user_command()
1178 uc->data &= ~SYM_DISC_ENABLED; in sym_user_command()
1180 return -EINVAL; in sym_user_command()
1181 ptr += arg_len; len -= arg_len; in sym_user_command()
1189 return -EINVAL; in sym_user_command()
1193 spin_lock_irqsave(shost->host_lock, flags); in sym_user_command()
1195 spin_unlock_irqrestore(shost->host_lock, flags); in sym_user_command()
1210 struct pci_dev *pdev = sym_data->pdev; in sym_show_info()
1211 struct sym_hcb *np = sym_data->ncb; in sym_show_info()
1214 "revision id 0x%x\n", np->s.chip_name, in sym_show_info()
1215 pdev->device, pdev->revision); in sym_show_info()
1217 pci_name(pdev), pdev->irq); in sym_show_info()
1219 (int) (np->minsync_dt ? np->minsync_dt : np->minsync), in sym_show_info()
1220 np->maxwide ? "Wide" : "Narrow", in sym_show_info()
1221 np->minsync_dt ? ", DT capable" : ""); in sym_show_info()
1229 return -EINVAL; in sym_show_info()
1242 if (device->s.ioaddr) in sym_iounmap_device()
1243 pci_iounmap(device->pdev, device->s.ioaddr); in sym_iounmap_device()
1244 if (device->s.ramaddr) in sym_iounmap_device()
1245 pci_iounmap(device->pdev, device->s.ramaddr); in sym_iounmap_device()
1258 free_irq(pdev->irq, np->s.host); in sym_free_resources()
1259 if (np->s.ioaddr) in sym_free_resources()
1260 pci_iounmap(pdev, np->s.ioaddr); in sym_free_resources()
1261 if (np->s.ramaddr) in sym_free_resources()
1262 pci_iounmap(pdev, np->s.ramaddr); in sym_free_resources()
1286 struct pci_dev *pdev = dev->pdev; in sym_attach()
1292 unit, dev->chip.name, pdev->revision, pci_name(pdev), in sym_attach()
1293 pdev->irq); in sym_attach()
1298 fw = sym_find_firmware(&dev->chip); in sym_attach()
1313 np = __sym_calloc_dma(&pdev->dev, sizeof(*np), "HCB"); in sym_attach()
1316 np->bus_dmat = &pdev->dev; /* Result in 1 DMA pool per HBA */ in sym_attach()
1317 sym_data->ncb = np; in sym_attach()
1318 sym_data->pdev = pdev; in sym_attach()
1319 np->s.host = shost; in sym_attach()
1326 np->hcb_ba = vtobus(np); in sym_attach()
1327 np->verbose = sym_driver_setup.verbose; in sym_attach()
1328 np->s.unit = unit; in sym_attach()
1329 np->features = dev->chip.features; in sym_attach()
1330 np->clock_divn = dev->chip.nr_divisor; in sym_attach()
1331 np->maxoffs = dev->chip.offset_max; in sym_attach()
1332 np->maxburst = dev->chip.burst_max; in sym_attach()
1333 np->myaddr = dev->host_id; in sym_attach()
1334 np->mmio_ba = (u32)dev->mmio_base; in sym_attach()
1335 np->ram_ba = (u32)dev->ram_base; in sym_attach()
1336 np->s.ioaddr = dev->s.ioaddr; in sym_attach()
1337 np->s.ramaddr = dev->s.ramaddr; in sym_attach()
1342 strscpy(np->s.chip_name, dev->chip.name, sizeof(np->s.chip_name)); in sym_attach()
1343 sprintf(np->s.inst_name, "sym%d", np->s.unit); in sym_attach()
1345 if ((SYM_CONF_DMA_ADDRESSING_MODE > 0) && (np->features & FE_DAC) && in sym_attach()
1346 !dma_set_mask(&pdev->dev, DMA_DAC_MASK)) { in sym_attach()
1348 } else if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { in sym_attach()
1353 if (sym_hcb_attach(shost, fw, dev->nvram)) in sym_attach()
1361 if (request_irq(pdev->irq, sym53c8xx_intr, IRQF_SHARED, NAME53C8XX, in sym_attach()
1364 sym_name(np), pdev->irq); in sym_attach()
1373 spin_lock_irqsave(shost->host_lock, flags); in sym_attach()
1385 timer_setup(&np->s.timer, sym53c8xx_timer, 0); in sym_attach()
1386 np->s.lasttime=0; in sym_attach()
1393 shost->max_channel = 0; in sym_attach()
1394 shost->this_id = np->myaddr; in sym_attach()
1395 shost->max_id = np->maxwide ? 16 : 8; in sym_attach()
1396 shost->max_lun = SYM_CONF_MAX_LUN; in sym_attach()
1397 shost->unique_id = pci_resource_start(pdev, 0); in sym_attach()
1398 shost->cmd_per_lun = SYM_CONF_MAX_TAG; in sym_attach()
1399 shost->can_queue = (SYM_CONF_MAX_START-2); in sym_attach()
1400 shost->sg_tablesize = SYM_CONF_MAX_SG; in sym_attach()
1401 shost->max_cmd_len = 16; in sym_attach()
1403 shost->transportt = sym2_transport_template; in sym_attach()
1406 if (pdev->device == PCI_DEVICE_ID_NCR_53C896 && pdev->revision < 2) in sym_attach()
1407 shost->dma_boundary = 0xFFFFFF; in sym_attach()
1409 spin_unlock_irqrestore(shost->host_lock, flags); in sym_attach()
1414 printf_err("%s: FATAL ERROR: CHECK SCSI BUS - CABLES, " in sym_attach()
1416 spin_unlock_irqrestore(shost->host_lock, flags); in sym_attach()
1436 devp->nvram = nvp; in sym_get_nvram()
1437 nvp->type = 0; in sym_get_nvram()
1450 struct pci_dev *pdev = device->pdev; in sym_check_supported()
1461 return -ENODEV; in sym_check_supported()
1470 chip = sym_lookup_chip_table(pdev->device, pdev->revision); in sym_check_supported()
1472 dev_info(&pdev->dev, "device not supported\n"); in sym_check_supported()
1473 return -ENODEV; in sym_check_supported()
1475 memcpy(&device->chip, chip, sizeof(device->chip)); in sym_check_supported()
1482 * These controllers set value 0x52414944 at RAM end - 16.
1488 if (!device->s.ramaddr) in sym_check_raid()
1491 if (device->chip.features & FE_RAM8K) in sym_check_raid()
1496 ram_val = readl(device->s.ramaddr + ram_size - 16); in sym_check_raid()
1500 dev_info(&device->pdev->dev, in sym_check_raid()
1502 return -ENODEV; in sym_check_raid()
1507 struct sym_chip *chip = &device->chip; in sym_set_workarounds()
1508 struct pci_dev *pdev = device->pdev; in sym_set_workarounds()
1516 if (pdev->device == PCI_DEVICE_ID_NCR_53C896 && pdev->revision < 0x4) { in sym_set_workarounds()
1517 chip->features |= (FE_WRIE | FE_CLSE); in sym_set_workarounds()
1521 if (chip->features & FE_WRIE) { in sym_set_workarounds()
1523 return -ENODEV; in sym_set_workarounds()
1533 * Recall: writes are not normal to status register - in sym_set_workarounds()
1538 if (chip->features & FE_66MHZ) { in sym_set_workarounds()
1540 chip->features &= ~FE_66MHZ; in sym_set_workarounds()
1553 * Map HBA registers and on-chip SRAM (if present).
1557 struct pci_dev *pdev = device->pdev; in sym_iomap_device()
1561 pcibios_resource_to_bus(pdev->bus, &bus_addr, &pdev->resource[1]); in sym_iomap_device()
1562 device->mmio_base = bus_addr.start; in sym_iomap_device()
1564 if (device->chip.features & FE_RAM) { in sym_iomap_device()
1566 * If the BAR is 64-bit, resource 2 will be occupied by the in sym_iomap_device()
1569 if (!pdev->resource[i].flags) in sym_iomap_device()
1571 pcibios_resource_to_bus(pdev->bus, &bus_addr, in sym_iomap_device()
1572 &pdev->resource[i]); in sym_iomap_device()
1573 device->ram_base = bus_addr.start; in sym_iomap_device()
1577 if (device->mmio_base) in sym_iomap_device()
1578 device->s.ioaddr = pci_iomap(pdev, 1, in sym_iomap_device()
1581 if (!device->s.ioaddr) in sym_iomap_device()
1582 device->s.ioaddr = pci_iomap(pdev, 0, in sym_iomap_device()
1584 if (!device->s.ioaddr) { in sym_iomap_device()
1585 dev_err(&pdev->dev, "could not map registers; giving up.\n"); in sym_iomap_device()
1586 return -EIO; in sym_iomap_device()
1588 if (device->ram_base) { in sym_iomap_device()
1589 device->s.ramaddr = pci_iomap(pdev, i, in sym_iomap_device()
1591 if (!device->s.ramaddr) { in sym_iomap_device()
1592 dev_warn(&pdev->dev, in sym_iomap_device()
1594 device->ram_base = 0; in sym_iomap_device()
1620 struct pci_dev *memc = pci_get_slot(pdev->bus, slot); in sym_config_pqs()
1622 if (!memc || memc->vendor != 0x101a || memc->device == 0x0009) { in sym_config_pqs()
1646 sym_dev->host_id = tmp; in sym_config_pqs()
1659 del_timer_sync(&np->s.timer); in sym_detach()
1752 if (scsi_add_host(shost, &pdev->dev)) in sym2_probe()
1770 return -ENODEV; in sym2_probe()
1782 attach_count--; in sym2_remove()
1786 * sym2_io_error_detected() - called when PCI error is detected
1799 disable_irq(pdev->irq); in sym2_io_error_detected()
1807 * sym2_io_slot_dump - Enable MMIO and dump debug registers
1821 * sym2_reset_workarounds - hardware-specific work-arounds
1827 * of the steps taken there are un-needed here.
1834 chip = sym_lookup_chip_table(pdev->device, pdev->revision); in sym2_reset_workarounds()
1840 if (!(chip->features & FE_66MHZ) && (status_reg & PCI_STATUS_66MHZ)) { in sym2_reset_workarounds()
1848 * sym2_io_slot_reset() - called when the pci bus has been reset.
1868 enable_irq(pdev->irq); in sym2_io_slot_reset()
1871 if (np->features & FE_WRIE) { in sym2_io_slot_reset()
1876 /* Perform work-arounds, analogous to sym_set_workarounds() */ in sym2_io_slot_reset()
1880 if (PCI_FUNC(pdev->devfn) == 0) { in sym2_io_slot_reset()
1893 * sym2_io_resume() - resume normal ops after PCI reset
1905 spin_lock_irq(shost->host_lock); in sym2_io_resume()
1906 if (sym_data->io_reset) in sym2_io_resume()
1907 complete(sym_data->io_reset); in sym2_io_resume()
1908 spin_unlock_irq(shost->host_lock); in sym2_io_resume()
1916 switch (np->scsi_mode) { in sym2_get_signalling()
1935 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in sym2_set_offset()
1937 struct sym_tcb *tp = &np->target[starget->id]; in sym2_set_offset()
1939 tp->tgoal.offset = offset; in sym2_set_offset()
1940 tp->tgoal.check_nego = 1; in sym2_set_offset()
1945 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in sym2_set_period()
1947 struct sym_tcb *tp = &np->target[starget->id]; in sym2_set_period()
1951 if (period <= np->minsync && spi_width(starget)) in sym2_set_period()
1952 tp->tgoal.dt = 1; in sym2_set_period()
1954 tp->tgoal.period = period; in sym2_set_period()
1955 tp->tgoal.check_nego = 1; in sym2_set_period()
1960 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in sym2_set_width()
1962 struct sym_tcb *tp = &np->target[starget->id]; in sym2_set_width()
1967 tp->tgoal.iu = tp->tgoal.dt = tp->tgoal.qas = 0; in sym2_set_width()
1969 tp->tgoal.width = width; in sym2_set_width()
1970 tp->tgoal.check_nego = 1; in sym2_set_width()
1975 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in sym2_set_dt()
1977 struct sym_tcb *tp = &np->target[starget->id]; in sym2_set_dt()
1981 tp->tgoal.dt = 1; in sym2_set_dt()
1983 tp->tgoal.iu = tp->tgoal.dt = tp->tgoal.qas = 0; in sym2_set_dt()
1984 tp->tgoal.check_nego = 1; in sym2_set_dt()
1990 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
1992 struct sym_tcb *tp = &np->target[starget->id];
1995 tp->tgoal.iu = tp->tgoal.dt = 1;
1997 tp->tgoal.iu = 0;
1998 tp->tgoal.check_nego = 1;
2003 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
2005 struct sym_tcb *tp = &np->target[starget->id];
2008 tp->tgoal.dt = tp->tgoal.qas = 1;
2010 tp->tgoal.qas = 0;
2011 tp->tgoal.check_nego = 1;
2095 return -ENODEV; in sym2_init()