Lines Matching refs:np
506 #define _m_calloc_dma(np, s, n) __m_calloc_dma(np->dev, s, n) argument
507 #define _m_free_dma(np, p, s, n) __m_free_dma(np->dev, p, s, n) argument
508 #define m_calloc_dma(s, n) _m_calloc_dma(np, s, n)
509 #define m_free_dma(p, s, n) _m_free_dma(np, p, s, n)
510 #define _vtobus(np, p) __vtobus(np->dev, p) argument
511 #define vtobus(p) _vtobus(np, p)
544 #define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd) argument
545 #define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd) argument
568 #define bootverbose (np->verbose)
1006 #define bootverbose (np->verbose)
1746 #define NCB_SCRIPT_PHYS(np,lbl) (np->p_script + offsetof (struct script, lbl)) argument
1747 #define NCB_SCRIPTH_PHYS(np,lbl) (np->p_scripth + offsetof (struct scripth,lbl)) argument
1904 static void ncr_alloc_ccb (struct ncb *np, u_char tn, u_char ln);
1905 static void ncr_complete (struct ncb *np, struct ccb *cp);
1906 static void ncr_exception (struct ncb *np);
1907 static void ncr_free_ccb (struct ncb *np, struct ccb *cp);
1908 static void ncr_init_ccb (struct ncb *np, struct ccb *cp);
1909 static void ncr_init_tcb (struct ncb *np, u_char tn);
1910 static struct lcb * ncr_alloc_lcb (struct ncb *np, u_char tn, u_char ln);
1911 static struct lcb * ncr_setup_lcb (struct ncb *np, struct scsi_device *sdev);
1912 static void ncr_getclock (struct ncb *np, int mult);
1913 static void ncr_selectclock (struct ncb *np, u_char scntl3);
1914 static struct ccb *ncr_get_ccb (struct ncb *np, struct scsi_cmnd *cmd);
1915 static void ncr_chip_reset (struct ncb *np, int delay);
1916 static void ncr_init (struct ncb *np, int reset, char * msg, u_long code);
1917 static int ncr_int_sbmc (struct ncb *np);
1918 static int ncr_int_par (struct ncb *np);
1919 static void ncr_int_ma (struct ncb *np);
1920 static void ncr_int_sir (struct ncb *np);
1921 static void ncr_int_sto (struct ncb *np);
1922 static void ncr_negotiate (struct ncb* np, struct tcb* tp);
1923 static int ncr_prepare_nego(struct ncb *np, struct ccb *cp, u_char *msgptr);
1926 (struct ncb *np, ncrcmd *src, ncrcmd *dst, int len);
1928 static int ncr_scatter (struct ncb *np, struct ccb *cp, struct scsi_cmnd *cmd);
1929 static void ncr_getsync (struct ncb *np, u_char sfac, u_char *fakp, u_char *scntl3p);
1930 static void ncr_setsync (struct ncb *np, struct ccb *cp, u_char scntl3, u_char sxfer);
1931 static void ncr_setup_tags (struct ncb *np, struct scsi_device *sdev);
1932 static void ncr_setwide (struct ncb *np, struct ccb *cp, u_char wide, u_char ack);
1933 static int ncr_snooptest (struct ncb *np);
1934 static void ncr_timeout (struct ncb *np);
1935 static void ncr_wakeup (struct ncb *np, u_long code);
1936 static void ncr_wakeup_done (struct ncb *np);
1937 static void ncr_start_next_ccb (struct ncb *np, struct lcb * lp, int maxn);
1938 static void ncr_put_start_queue(struct ncb *np, struct ccb *cp);
1940 static void insert_into_waiting_list(struct ncb *np, struct scsi_cmnd *cmd);
1941 static void process_waiting_list(struct ncb *np, int sts);
1943 #define requeue_waiting_list(np) process_waiting_list((np), DID_OK) argument
1944 #define reset_waiting_list(np) process_waiting_list((np), DID_RESET) argument
1946 static inline char *ncr_name (struct ncb *np) in ncr_name() argument
1948 return np->inst_name; in ncr_name()
3484 ncr_script_copy_and_bind (struct ncb *np, ncrcmd *src, ncrcmd *dst, int len) in ncr_script_copy_and_bind() argument
3508 ncr_name(np), (int) (src-start-1)); in ncr_script_copy_and_bind()
3538 ncr_name(np), (int) (src-start-1)); in ncr_script_copy_and_bind()
3545 if ((opcode & SCR_NO_FLUSH) && !(np->features & FE_PFEN)) { in ncr_script_copy_and_bind()
3587 new = (old & ~RELOC_MASK) + np->paddr; in ncr_script_copy_and_bind()
3590 new = (old & ~RELOC_MASK) + np->p_script; in ncr_script_copy_and_bind()
3593 new = (old & ~RELOC_MASK) + np->p_scripth; in ncr_script_copy_and_bind()
3596 new = (old & ~RELOC_MASK) + np->p_ncb; in ncr_script_copy_and_bind()
3688 static inline void ncr_init_burst(struct ncb *np, u_char bc) in ncr_init_burst() argument
3690 u_char *be = &np->rv_ctest0; in ncr_init_burst()
3692 np->rv_dmode &= ~(0x3 << 6); in ncr_init_burst()
3693 np->rv_ctest5 &= ~0x4; in ncr_init_burst()
3699 np->rv_dmode |= ((bc & 0x3) << 6); in ncr_init_burst()
3700 np->rv_ctest5 |= (bc & 0x4); in ncr_init_burst()
3704 static void __init ncr_prepare_setting(struct ncb *np) in ncr_prepare_setting() argument
3714 np->sv_scntl0 = INB(nc_scntl0) & 0x0a; in ncr_prepare_setting()
3715 np->sv_scntl3 = INB(nc_scntl3) & 0x07; in ncr_prepare_setting()
3716 np->sv_dmode = INB(nc_dmode) & 0xce; in ncr_prepare_setting()
3717 np->sv_dcntl = INB(nc_dcntl) & 0xa8; in ncr_prepare_setting()
3718 np->sv_ctest0 = INB(nc_ctest0) & 0x84; in ncr_prepare_setting()
3719 np->sv_ctest3 = INB(nc_ctest3) & 0x01; in ncr_prepare_setting()
3720 np->sv_ctest4 = INB(nc_ctest4) & 0x80; in ncr_prepare_setting()
3721 np->sv_ctest5 = INB(nc_ctest5) & 0x24; in ncr_prepare_setting()
3722 np->sv_gpcntl = INB(nc_gpcntl); in ncr_prepare_setting()
3723 np->sv_stest2 = INB(nc_stest2) & 0x20; in ncr_prepare_setting()
3724 np->sv_stest4 = INB(nc_stest4); in ncr_prepare_setting()
3730 np->maxwide = (np->features & FE_WIDE)? 1 : 0; in ncr_prepare_setting()
3735 if (np->features & FE_ULTRA) in ncr_prepare_setting()
3736 np->clock_khz = 80000; in ncr_prepare_setting()
3738 np->clock_khz = 40000; in ncr_prepare_setting()
3743 if (np->features & FE_QUAD) in ncr_prepare_setting()
3744 np->multiplier = 4; in ncr_prepare_setting()
3745 else if (np->features & FE_DBLR) in ncr_prepare_setting()
3746 np->multiplier = 2; in ncr_prepare_setting()
3748 np->multiplier = 1; in ncr_prepare_setting()
3754 if (np->features & FE_VARCLK) in ncr_prepare_setting()
3755 ncr_getclock(np, np->multiplier); in ncr_prepare_setting()
3760 i = np->clock_divn - 1; in ncr_prepare_setting()
3762 if (10ul * SCSI_NCR_MIN_ASYNC * np->clock_khz > div_10M[i]) { in ncr_prepare_setting()
3767 np->rv_scntl3 = i+1; in ncr_prepare_setting()
3774 period = (4 * div_10M[0] + np->clock_khz - 1) / np->clock_khz; in ncr_prepare_setting()
3775 if (period <= 250) np->minsync = 10; in ncr_prepare_setting()
3776 else if (period <= 303) np->minsync = 11; in ncr_prepare_setting()
3777 else if (period <= 500) np->minsync = 12; in ncr_prepare_setting()
3778 else np->minsync = (period + 40 - 1) / 40; in ncr_prepare_setting()
3784 if (np->minsync < 25 && !(np->features & FE_ULTRA)) in ncr_prepare_setting()
3785 np->minsync = 25; in ncr_prepare_setting()
3791 period = (11 * div_10M[np->clock_divn - 1]) / (4 * np->clock_khz); in ncr_prepare_setting()
3792 np->maxsync = period > 2540 ? 254 : period / 10; in ncr_prepare_setting()
3798 np->rv_scntl0 = np->sv_scntl0; in ncr_prepare_setting()
3799 np->rv_dmode = np->sv_dmode; in ncr_prepare_setting()
3800 np->rv_dcntl = np->sv_dcntl; in ncr_prepare_setting()
3801 np->rv_ctest0 = np->sv_ctest0; in ncr_prepare_setting()
3802 np->rv_ctest3 = np->sv_ctest3; in ncr_prepare_setting()
3803 np->rv_ctest4 = np->sv_ctest4; in ncr_prepare_setting()
3804 np->rv_ctest5 = np->sv_ctest5; in ncr_prepare_setting()
3805 burst_max = burst_code(np->sv_dmode, np->sv_ctest0); in ncr_prepare_setting()
3813 burst_max = burst_code(np->sv_dmode, np->sv_ctest0); in ncr_prepare_setting()
3816 if (burst_max > np->maxburst) in ncr_prepare_setting()
3817 burst_max = np->maxburst; in ncr_prepare_setting()
3822 if (np->features & FE_ERL) in ncr_prepare_setting()
3823 np->rv_dmode |= ERL; /* Enable Read Line */ in ncr_prepare_setting()
3824 if (np->features & FE_BOF) in ncr_prepare_setting()
3825 np->rv_dmode |= BOF; /* Burst Opcode Fetch */ in ncr_prepare_setting()
3826 if (np->features & FE_ERMP) in ncr_prepare_setting()
3827 np->rv_dmode |= ERMP; /* Enable Read Multiple */ in ncr_prepare_setting()
3828 if (np->features & FE_PFEN) in ncr_prepare_setting()
3829 np->rv_dcntl |= PFEN; /* Prefetch Enable */ in ncr_prepare_setting()
3830 if (np->features & FE_CLSE) in ncr_prepare_setting()
3831 np->rv_dcntl |= CLSE; /* Cache Line Size Enable */ in ncr_prepare_setting()
3832 if (np->features & FE_WRIE) in ncr_prepare_setting()
3833 np->rv_ctest3 |= WRIE; /* Write and Invalidate */ in ncr_prepare_setting()
3834 if (np->features & FE_DFS) in ncr_prepare_setting()
3835 np->rv_ctest5 |= DFS; /* Dma Fifo Size */ in ncr_prepare_setting()
3836 if (np->features & FE_MUX) in ncr_prepare_setting()
3837 np->rv_ctest4 |= MUX; /* Host bus multiplex mode */ in ncr_prepare_setting()
3838 if (np->features & FE_EA) in ncr_prepare_setting()
3839 np->rv_dcntl |= EA; /* Enable ACK */ in ncr_prepare_setting()
3840 if (np->features & FE_EHP) in ncr_prepare_setting()
3841 np->rv_ctest0 |= EHP; /* Even host parity */ in ncr_prepare_setting()
3847 np->rv_ctest4 |= MPEE; /* Master parity checking */ in ncr_prepare_setting()
3849 np->rv_scntl0 |= 0x0a; /* full arb., ena parity, par->ATN */ in ncr_prepare_setting()
3854 if (np->myaddr == 255) { in ncr_prepare_setting()
3855 np->myaddr = INB(nc_scid) & 0x07; in ncr_prepare_setting()
3856 if (!np->myaddr) in ncr_prepare_setting()
3857 np->myaddr = SCSI_NCR_MYADDR; in ncr_prepare_setting()
3865 ncr_init_burst(np, burst_max); in ncr_prepare_setting()
3876 np->scsi_mode = SMODE_SE; in ncr_prepare_setting()
3877 if (np->features & FE_DIFF) { in ncr_prepare_setting()
3880 if (np->sv_scntl3) { in ncr_prepare_setting()
3881 if (np->sv_stest2 & 0x20) in ncr_prepare_setting()
3882 np->scsi_mode = SMODE_HVD; in ncr_prepare_setting()
3891 np->scsi_mode = SMODE_HVD; in ncr_prepare_setting()
3894 if (np->sv_stest2 & 0x20) in ncr_prepare_setting()
3895 np->scsi_mode = SMODE_HVD; in ncr_prepare_setting()
3901 if (np->scsi_mode == SMODE_HVD) in ncr_prepare_setting()
3902 np->rv_stest2 |= 0x20; in ncr_prepare_setting()
3912 !(np->features & FE_LEDC) && !(np->sv_gpcntl & 0x01)) in ncr_prepare_setting()
3913 np->features |= FE_LED0; in ncr_prepare_setting()
3920 np->rv_dcntl |= IRQM; in ncr_prepare_setting()
3923 np->rv_dcntl |= (np->sv_dcntl & IRQM); in ncr_prepare_setting()
3935 struct tcb *tp = &np->target[i]; in ncr_prepare_setting()
3942 np->target[i].usrflag = UF_NODISC; in ncr_prepare_setting()
3949 printk(KERN_INFO "%s: ID %d, Fast-%d%s%s\n", ncr_name(np), in ncr_prepare_setting()
3950 np->myaddr, in ncr_prepare_setting()
3951 np->minsync < 12 ? 40 : (np->minsync < 25 ? 20 : 10), in ncr_prepare_setting()
3952 (np->rv_scntl0 & 0xa) ? ", Parity Checking" : ", NO Parity", in ncr_prepare_setting()
3953 (np->rv_stest2 & 0x20) ? ", Differential" : ""); in ncr_prepare_setting()
3958 ncr_name(np), np->sv_scntl3, np->sv_dmode, np->sv_dcntl, in ncr_prepare_setting()
3959 np->sv_ctest3, np->sv_ctest4, np->sv_ctest5); in ncr_prepare_setting()
3963 ncr_name(np), np->rv_scntl3, np->rv_dmode, np->rv_dcntl, in ncr_prepare_setting()
3964 np->rv_ctest3, np->rv_ctest4, np->rv_ctest5); in ncr_prepare_setting()
3967 if (bootverbose && np->paddr2) in ncr_prepare_setting()
3969 ncr_name(np), np->paddr2); in ncr_prepare_setting()
3991 static inline void ncr_queue_done_cmd(struct ncb *np, struct scsi_cmnd *cmd) in ncr_queue_done_cmd() argument
3993 unmap_scsi_data(np, cmd); in ncr_queue_done_cmd()
3994 cmd->host_scribble = (char *) np->done_list; in ncr_queue_done_cmd()
3995 np->done_list = cmd; in ncr_queue_done_cmd()
4023 static int ncr_prepare_nego(struct ncb *np, struct ccb *cp, u_char *msgptr) in ncr_prepare_nego() argument
4025 struct tcb *tp = &np->target[cp->target]; in ncr_prepare_nego()
4082 static int ncr_queue_command (struct ncb *np, struct scsi_cmnd *cmd) in ncr_queue_command() argument
4085 struct tcb *tp = &np->target[sdev->id]; in ncr_queue_command()
4101 if ((sdev->id == np->myaddr ) || in ncr_queue_command()
4136 if (np->settle_time && scsi_cmd_to_rq(cmd)->timeout >= HZ) { in ncr_queue_command()
4138 if (time_after(np->settle_time, tlimit)) in ncr_queue_command()
4139 np->settle_time = tlimit; in ncr_queue_command()
4142 if (np->settle_time || !(cp=ncr_get_ccb (np, cmd))) { in ncr_queue_command()
4143 insert_into_waiting_list(np, cmd); in ncr_queue_command()
4158 (cp != np->ccb && np->disc && !(tp->usrflag & UF_NODISC))) in ncr_queue_command()
4166 char order = np->order; in ncr_queue_command()
4216 segments = ncr_scatter(np, cp, cp->cmd); in ncr_queue_command()
4218 ncr_free_ccb(np, cp); in ncr_queue_command()
4239 msglen += ncr_prepare_nego (np, cp, msgptr + msglen); in ncr_queue_command()
4260 goalp = NCB_SCRIPT_PHYS (np, data_out2) + 8; in ncr_queue_command()
4264 lastp = NCB_SCRIPTH_PHYS (np, hdata_out2); in ncr_queue_command()
4273 goalp = NCB_SCRIPT_PHYS (np, data_in2) + 8; in ncr_queue_command()
4277 lastp = NCB_SCRIPTH_PHYS (np, hdata_in2); in ncr_queue_command()
4283 lastp = goalp = NCB_SCRIPT_PHYS (np, no_data); in ncr_queue_command()
4296 cpu_to_scr(NCB_SCRIPTH_PHYS (np, data_io)); in ncr_queue_command()
4320 cp->start.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); in ncr_queue_command()
4321 cp->restart.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_dsa)); in ncr_queue_command()
4367 ncr_start_next_ccb(np, lp, 2); in ncr_queue_command()
4369 ncr_put_start_queue(np, cp); in ncr_queue_command()
4387 static void ncr_start_next_ccb(struct ncb *np, struct lcb *lp, int maxn) in ncr_start_next_ccb() argument
4404 ncr_put_start_queue(np, cp); in ncr_start_next_ccb()
4408 static void ncr_put_start_queue(struct ncb *np, struct ccb *cp) in ncr_put_start_queue() argument
4415 if (!np->squeueput) np->squeueput = 1; in ncr_put_start_queue()
4416 qidx = np->squeueput + 2; in ncr_put_start_queue()
4419 np->scripth->tryloop [qidx] = cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); in ncr_put_start_queue()
4421 np->scripth->tryloop [np->squeueput] = cpu_to_scr(CCB_PHYS (cp, start)); in ncr_put_start_queue()
4423 np->squeueput = qidx; in ncr_put_start_queue()
4424 ++np->queuedccbs; in ncr_put_start_queue()
4428 printk ("%s: queuepos=%d.\n", ncr_name (np), np->squeueput); in ncr_put_start_queue()
4439 static int ncr_reset_scsi_bus(struct ncb *np, int enab_int, int settle_delay) in ncr_reset_scsi_bus() argument
4444 np->settle_time = jiffies + settle_delay * HZ; in ncr_reset_scsi_bus()
4449 ncr_name(np), settle_delay); in ncr_reset_scsi_bus()
4451 ncr_chip_reset(np, 100); in ncr_reset_scsi_bus()
4479 if (!(np->features & FE_WIDE)) in ncr_reset_scsi_bus()
4484 ncr_name(np)); in ncr_reset_scsi_bus()
4487 ncr_name(np), in ncr_reset_scsi_bus()
4488 (np->features & FE_WIDE) ? "dp1,d15-8," : "", in ncr_reset_scsi_bus()
4505 static void ncr_start_reset(struct ncb *np) in ncr_start_reset() argument
4507 if (!np->settle_time) { in ncr_start_reset()
4508 ncr_reset_scsi_bus(np, 1, driver_setup.settle_delay); in ncr_start_reset()
4521 static int ncr_reset_bus (struct ncb *np) in ncr_reset_bus() argument
4526 if (np->settle_time) { in ncr_reset_bus()
4535 ncr_start_reset(np); in ncr_reset_bus()
4539 reset_waiting_list(np); in ncr_reset_bus()
4543 ncr_wakeup(np, HS_RESET); in ncr_reset_bus()
4548 static void ncr_detach(struct ncb *np) in ncr_detach() argument
4558 strscpy(inst_name, ncr_name(np), sizeof(inst_name)); in ncr_detach()
4560 printk("%s: releasing host resources\n", ncr_name(np)); in ncr_detach()
4568 printk("%s: stopping the timer\n", ncr_name(np)); in ncr_detach()
4570 np->release_stage = 1; in ncr_detach()
4571 for (i = 50 ; i && np->release_stage != 2 ; i--) in ncr_detach()
4573 if (np->release_stage != 2) in ncr_detach()
4574 printk("%s: the timer seems to be already stopped\n", ncr_name(np)); in ncr_detach()
4575 else np->release_stage = 2; in ncr_detach()
4582 printk("%s: disabling chip interrupts\n", ncr_name(np)); in ncr_detach()
4592 printk("%s: resetting chip\n", ncr_name(np)); in ncr_detach()
4593 ncr_chip_reset(np, 100); in ncr_detach()
4595 OUTB(nc_dmode, np->sv_dmode); in ncr_detach()
4596 OUTB(nc_dcntl, np->sv_dcntl); in ncr_detach()
4597 OUTB(nc_ctest0, np->sv_ctest0); in ncr_detach()
4598 OUTB(nc_ctest3, np->sv_ctest3); in ncr_detach()
4599 OUTB(nc_ctest4, np->sv_ctest4); in ncr_detach()
4600 OUTB(nc_ctest5, np->sv_ctest5); in ncr_detach()
4601 OUTB(nc_gpcntl, np->sv_gpcntl); in ncr_detach()
4602 OUTB(nc_stest2, np->sv_stest2); in ncr_detach()
4604 ncr_selectclock(np, np->sv_scntl3); in ncr_detach()
4610 while ((cp=np->ccb->link_ccb) != NULL) { in ncr_detach()
4611 np->ccb->link_ccb = cp->link_ccb; in ncr_detach()
4614 ncr_name(np), cp->host_status); in ncr_detach()
4617 printk("%s: freeing ccb (%lx)\n", ncr_name(np), (u_long) cp); in ncr_detach()
4625 tp=&np->target[target]; in ncr_detach()
4630 printk("%s: freeing lp (%lx)\n", ncr_name(np), (u_long) lp); in ncr_detach()
4639 if (np->scripth0) in ncr_detach()
4640 m_free_dma(np->scripth0, sizeof(struct scripth), "SCRIPTH"); in ncr_detach()
4641 if (np->script0) in ncr_detach()
4642 m_free_dma(np->script0, sizeof(struct script), "SCRIPT"); in ncr_detach()
4643 if (np->ccb) in ncr_detach()
4644 m_free_dma(np->ccb, sizeof(struct ccb), "CCB"); in ncr_detach()
4645 m_free_dma(np, sizeof(struct ncb), "NCB"); in ncr_detach()
4660 void ncr_complete (struct ncb *np, struct ccb *cp) in ncr_complete() argument
4687 tp = &np->target[cmd->device->id]; in ncr_complete()
4784 ncr_alloc_lcb (np, cmd->device->id, cmd->device->lun); in ncr_complete()
4798 ncr_setup_tags (np, cmd->device); in ncr_complete()
4908 ncr_free_ccb (np, cp); in ncr_complete()
4915 ncr_start_next_ccb(np, lp, 2); in ncr_complete()
4920 if (np->waiting_list) in ncr_complete()
4921 requeue_waiting_list(np); in ncr_complete()
4926 ncr_queue_done_cmd(np, cmd); in ncr_complete()
4942 static void ncr_ccb_skipped(struct ncb *np, struct ccb *cp) in ncr_ccb_skipped() argument
4944 struct tcb *tp = &np->target[cp->target]; in ncr_ccb_skipped()
4947 if (lp && cp != np->ccb) { in ncr_ccb_skipped()
4950 cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); in ncr_ccb_skipped()
4957 --np->queuedccbs; in ncr_ccb_skipped()
4966 void ncr_wakeup_done (struct ncb *np) in ncr_wakeup_done() argument
4972 i = np->ccb_done_ic; in ncr_wakeup_done()
4978 cp = np->ccb_done[j]; in ncr_wakeup_done()
4982 np->ccb_done[j] = (struct ccb *)CCB_DONE_EMPTY; in ncr_wakeup_done()
4983 np->scripth->done_queue[5*j + 4] = in ncr_wakeup_done()
4984 cpu_to_scr(NCB_SCRIPT_PHYS (np, done_plug)); in ncr_wakeup_done()
4986 np->scripth->done_queue[5*i + 4] = in ncr_wakeup_done()
4987 cpu_to_scr(NCB_SCRIPT_PHYS (np, done_end)); in ncr_wakeup_done()
4990 ncr_complete (np, cp); in ncr_wakeup_done()
4992 ncr_ccb_skipped (np, cp); in ncr_wakeup_done()
4996 np->ccb_done_ic = i; in ncr_wakeup_done()
4998 cp = np->ccb; in ncr_wakeup_done()
5001 ncr_complete (np, cp); in ncr_wakeup_done()
5003 ncr_ccb_skipped (np, cp); in ncr_wakeup_done()
5012 void ncr_wakeup (struct ncb *np, u_long code) in ncr_wakeup() argument
5014 struct ccb *cp = np->ccb; in ncr_wakeup()
5019 ncr_complete (np, cp); in ncr_wakeup()
5033 static void ncr_chip_reset(struct ncb *np, int delay) in ncr_chip_reset() argument
5039 if (np->features & FE_EHP) in ncr_chip_reset()
5041 if (np->features & FE_MUX) in ncr_chip_reset()
5055 void ncr_init (struct ncb *np, int reset, char * msg, u_long code) in ncr_init() argument
5076 if (msg) printk (KERN_INFO "%s: restart (%s).\n", ncr_name (np), msg); in ncr_init()
5081 np->queuedepth = MAX_START - 1; /* 1 entry needed as end marker */ in ncr_init()
5083 np->scripth0->tryloop[i] = in ncr_init()
5084 cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); in ncr_init()
5089 np->squeueput = 0; in ncr_init()
5090 np->script0->startpos[0] = cpu_to_scr(NCB_SCRIPTH_PHYS (np, tryloop)); in ncr_init()
5097 np->ccb_done[i] = (struct ccb *)CCB_DONE_EMPTY; in ncr_init()
5098 np->scripth0->done_queue[5*i + 4] = in ncr_init()
5099 cpu_to_scr(NCB_SCRIPT_PHYS (np, done_end)); in ncr_init()
5106 np->script0->done_pos[0] = cpu_to_scr(NCB_SCRIPTH_PHYS (np,done_queue)); in ncr_init()
5107 np->ccb_done_ic = MAX_DONE-1; in ncr_init()
5108 np->scripth0->done_queue[5*(MAX_DONE-1) + 4] = in ncr_init()
5109 cpu_to_scr(NCB_SCRIPT_PHYS (np, done_plug)); in ncr_init()
5114 ncr_wakeup (np, code); in ncr_init()
5124 ncr_chip_reset(np, 2000); in ncr_init()
5126 OUTB (nc_scntl0, np->rv_scntl0 | 0xc0); in ncr_init()
5130 ncr_selectclock(np, np->rv_scntl3); /* Select SCSI clock */ in ncr_init()
5132 OUTB (nc_scid , RRE|np->myaddr); /* Adapter SCSI address */ in ncr_init()
5133 OUTW (nc_respid, 1ul<<np->myaddr); /* Id to respond to */ in ncr_init()
5135 OUTB (nc_dmode , np->rv_dmode); /* Burst length, dma mode */ in ncr_init()
5136 OUTB (nc_ctest5, np->rv_ctest5); /* Large fifo + large burst */ in ncr_init()
5138 OUTB (nc_dcntl , NOCOM|np->rv_dcntl); /* Protect SFBR */ in ncr_init()
5139 OUTB (nc_ctest0, np->rv_ctest0); /* 720: CDIS and EHP */ in ncr_init()
5140 OUTB (nc_ctest3, np->rv_ctest3); /* Write and invalidate */ in ncr_init()
5141 OUTB (nc_ctest4, np->rv_ctest4); /* Master parity checking */ in ncr_init()
5143 OUTB (nc_stest2, EXT|np->rv_stest2); /* Extended Sreq/Sack filtering */ in ncr_init()
5151 np->disc = 0; in ncr_init()
5157 if (np->features & FE_LED0) { in ncr_init()
5176 struct tcb *tp = &np->target[i]; in ncr_init()
5179 tp->wval = np->rv_scntl3; in ncr_init()
5182 if (tp->usrsync <= np->maxsync) { in ncr_init()
5183 if (tp->usrsync < np->minsync) { in ncr_init()
5184 tp->usrsync = np->minsync; in ncr_init()
5191 if (tp->usrwide > np->maxwide) in ncr_init()
5192 tp->usrwide = np->maxwide; in ncr_init()
5199 if (np->paddr2) { in ncr_init()
5202 ncr_name(np)); in ncr_init()
5203 OUTL (nc_scratcha, vtobus(np->script0)); in ncr_init()
5204 OUTL_DSP (NCB_SCRIPTH_PHYS (np, start_ram)); in ncr_init()
5207 OUTL_DSP (NCB_SCRIPT_PHYS (np, start)); in ncr_init()
5218 static void ncr_negotiate (struct ncb* np, struct tcb* tp) in ncr_negotiate() argument
5230 if (np->scsi_mode && np->scsi_mode == SMODE_SE) { in ncr_negotiate()
5238 if (minsync < np->minsync) in ncr_negotiate()
5239 minsync = np->minsync; in ncr_negotiate()
5245 if (minsync > np->maxsync) in ncr_negotiate()
5248 if (tp->maxoffs > np->maxoffs) in ncr_negotiate()
5249 tp->maxoffs = np->maxoffs; in ncr_negotiate()
5276 static void ncr_getsync(struct ncb *np, u_char sfac, u_char *fakp, u_char *scntl3p) in ncr_getsync() argument
5278 u_long clk = np->clock_khz; /* SCSI clock frequency in kHz */ in ncr_getsync()
5279 int div = np->clock_divn; /* Number of divisors supported */ in ncr_getsync()
5324 static void ncr_set_sync_wide_status (struct ncb *np, u_char target) in ncr_set_sync_wide_status() argument
5327 struct tcb *tp = &np->target[target]; in ncr_set_sync_wide_status()
5333 np->sync_st = tp->sval; in ncr_set_sync_wide_status()
5335 np->wide_st = tp->wval; in ncr_set_sync_wide_status()
5340 for (cp = np->ccb; cp; cp = cp->link_ccb) { in ncr_set_sync_wide_status()
5355 static void ncr_setsync (struct ncb *np, struct ccb *cp, u_char scntl3, u_char sxfer) in ncr_setsync() argument
5364 tp = &np->target[target]; in ncr_setsync()
5367 scntl3 = np->rv_scntl3; in ncr_setsync()
5368 scntl3 = (scntl3 & 0xf0) | (tp->wval & EWS) | (np->rv_scntl3 & 0x07); in ncr_setsync()
5377 tp->period = (((sxfer>>5)+4)*div_10M[idiv-1])/np->clock_khz; in ncr_setsync()
5399 ncr_set_sync_wide_status(np, target); in ncr_setsync()
5412 static void ncr_setwide (struct ncb *np, struct ccb *cp, u_char wide, u_char ack) in ncr_setwide() argument
5422 tp = &np->target[target]; in ncr_setwide()
5447 ncr_set_sync_wide_status(np, target); in ncr_setwide()
5457 static void ncr_setup_tags (struct ncb *np, struct scsi_device *sdev) in ncr_setup_tags() argument
5460 struct tcb *tp = &np->target[tn]; in ncr_setup_tags()
5528 cpu_to_scr(NCB_SCRIPT_PHYS(np, resel_tag)) : in ncr_setup_tags()
5529 cpu_to_scr(NCB_SCRIPT_PHYS(np, resel_notag)); in ncr_setup_tags()
5560 static void ncr_timeout (struct ncb *np) in ncr_timeout() argument
5570 if (np->release_stage) { in ncr_timeout()
5571 if (np->release_stage == 1) np->release_stage = 2; in ncr_timeout()
5575 np->timer.expires = jiffies + SCSI_NCR_TIMER_INTERVAL; in ncr_timeout()
5576 add_timer(&np->timer); in ncr_timeout()
5582 if (np->settle_time) { in ncr_timeout()
5583 if (np->settle_time <= thistime) { in ncr_timeout()
5585 printk("%s: command processing resumed\n", ncr_name(np)); in ncr_timeout()
5586 np->settle_time = 0; in ncr_timeout()
5587 np->disc = 1; in ncr_timeout()
5588 requeue_waiting_list(np); in ncr_timeout()
5598 if (np->lasttime + 4*HZ < thistime) { in ncr_timeout()
5602 np->lasttime = thistime; in ncr_timeout()
5612 ncr_exception (np); in ncr_timeout()
5648 static void ncr_log_hard_error(struct ncb *np, u16 sist, u_char dstat) in ncr_log_hard_error() argument
5659 if (dsp > np->p_script && dsp <= np->p_script + sizeof(struct script)) { in ncr_log_hard_error()
5660 script_ofs = dsp - np->p_script; in ncr_log_hard_error()
5662 script_base = (u_char *) np->script0; in ncr_log_hard_error()
5665 else if (np->p_scripth < dsp && in ncr_log_hard_error()
5666 dsp <= np->p_scripth + sizeof(struct scripth)) { in ncr_log_hard_error()
5667 script_ofs = dsp - np->p_scripth; in ncr_log_hard_error()
5669 script_base = (u_char *) np->scripth0; in ncr_log_hard_error()
5679 ncr_name (np), (unsigned)INB (nc_sdid)&0x0f, dstat, sist, in ncr_log_hard_error()
5686 printk ("%s: script cmd = %08x\n", ncr_name(np), in ncr_log_hard_error()
5690 printk ("%s: regdump:", ncr_name(np)); in ncr_log_hard_error()
5728 void ncr_exception (struct ncb *np) in ncr_exception() argument
5746 ncr_wakeup_done (np); in ncr_exception()
5785 if ((sist & SBMC) && ncr_int_sbmc (np)) in ncr_exception()
5787 if ((sist & PAR) && ncr_int_par (np)) in ncr_exception()
5790 ncr_int_ma (np); in ncr_exception()
5794 ncr_int_sir (np); in ncr_exception()
5803 ncr_name(np), istat, dstat, sist); in ncr_exception()
5826 ncr_init (np, 1, bootverbose ? "scsi reset" : NULL, HS_RESET); in ncr_exception()
5837 ncr_int_sto (np); in ncr_exception()
5854 if (time_after(jiffies, np->regtime)) { in ncr_exception()
5855 np->regtime = jiffies + 10*HZ; in ncr_exception()
5856 for (i = 0; i<sizeof(np->regdump); i++) in ncr_exception()
5857 ((char*)&np->regdump)[i] = INB_OFF(i); in ncr_exception()
5858 np->regdump.nc_dstat = dstat; in ncr_exception()
5859 np->regdump.nc_sist = sist; in ncr_exception()
5862 ncr_log_hard_error(np, sist, dstat); in ncr_exception()
5864 printk ("%s: have to clear fifos.\n", ncr_name (np)); in ncr_exception()
5870 ncr_start_reset(np); in ncr_exception()
5875 printk ("%s: handshake timeout\n", ncr_name(np)); in ncr_exception()
5876 ncr_start_reset(np); in ncr_exception()
5881 printk ("%s: unexpected disconnect\n", ncr_name(np)); in ncr_exception()
5883 OUTL_DSP (NCB_SCRIPT_PHYS (np, cleanup)); in ncr_exception()
5892 printk ("%s: unknown interrupt\n", ncr_name(np)); in ncr_exception()
5911 void ncr_int_sto (struct ncb *np) in ncr_int_sto() argument
5922 cp = np->ccb; in ncr_int_sto()
5928 ncr_complete (np, cp); in ncr_int_sto()
5935 OUTL_DSP (NCB_SCRIPTH_PHYS (np, sto_restart)); in ncr_int_sto()
5956 static int ncr_int_sbmc (struct ncb *np) in ncr_int_sbmc() argument
5960 if (scsi_mode != np->scsi_mode) { in ncr_int_sbmc()
5962 ncr_name(np), np->scsi_mode, scsi_mode); in ncr_int_sbmc()
5964 np->scsi_mode = scsi_mode; in ncr_int_sbmc()
5971 np->settle_time = jiffies + HZ; in ncr_int_sbmc()
5972 ncr_init (np, 0, bootverbose ? "scsi mode change" : NULL, HS_RESET); in ncr_int_sbmc()
5988 static int ncr_int_par (struct ncb *np) in ncr_int_par() argument
5998 ncr_name(np), hsts, dbc, sstat1); in ncr_int_par()
6038 jmp = NCB_SCRIPTH_PHYS (np, par_err_data_in); in ncr_int_par()
6040 jmp = NCB_SCRIPTH_PHYS (np, par_err_other); in ncr_int_par()
6045 np->msgout[0] = msg; in ncr_int_par()
6050 ncr_start_reset(np); in ncr_int_par()
6068 static void ncr_int_ma (struct ncb *np) in ncr_int_ma() argument
6099 ctest5 = (np->rv_ctest5 & DFS) ? INB (nc_ctest5) : 0; in ncr_int_ma()
6144 cp = np->header.cp; in ncr_int_ma()
6148 cp = np->ccb; in ncr_int_ma()
6159 if (dsp > np->p_script && in ncr_int_ma()
6160 dsp <= np->p_script + sizeof(struct script)) { in ncr_int_ma()
6161 vdsp = (u32 *)((char*)np->script0 + (dsp-np->p_script-8)); in ncr_int_ma()
6164 else if (dsp > np->p_scripth && in ncr_int_ma()
6165 dsp <= np->p_scripth + sizeof(struct scripth)) { in ncr_int_ma()
6166 vdsp = (u32 *)((char*)np->scripth0 + (dsp-np->p_scripth-8)); in ncr_int_ma()
6186 cp, np->header.cp, in ncr_int_ma()
6200 ncr_name (np), (u_long) np->header.cp); in ncr_int_ma()
6244 if (cp != np->header.cp) { in ncr_int_ma()
6247 ncr_name (np), (u_long) cp, (u_long) np->header.cp); in ncr_int_ma()
6295 OUTL_DSP (NCB_SCRIPT_PHYS (np, dispatch)); in ncr_int_ma()
6331 nxtdsp = NCB_SCRIPT_PHYS (np, dispatch); in ncr_int_ma()
6335 nxtdsp = NCB_SCRIPT_PHYS (np, dispatch); in ncr_int_ma()
6339 np->scripth->nxtdsp_go_on[0] = cpu_to_scr(dsp + 8); in ncr_int_ma()
6340 if (dsp == NCB_SCRIPT_PHYS (np, send_ident)) { in ncr_int_ma()
6342 nxtdsp = NCB_SCRIPTH_PHYS (np, clratn_go_on); in ncr_int_ma()
6344 else if (dsp == NCB_SCRIPTH_PHYS (np, send_wdtr) || in ncr_int_ma()
6345 dsp == NCB_SCRIPTH_PHYS (np, send_sdtr)) { in ncr_int_ma()
6346 nxtdsp = NCB_SCRIPTH_PHYS (np, nego_bad_phase); in ncr_int_ma()
6351 nxtdsp = NCB_SCRIPT_PHYS (np, clrack); in ncr_int_ma()
6362 ncr_start_reset(np); in ncr_int_ma()
6366 static void ncr_sir_to_redo(struct ncb *np, int num, struct ccb *cp) in ncr_sir_to_redo() argument
6369 struct tcb *tp = &np->target[cmd->device->id]; in ncr_sir_to_redo()
6393 cpu_to_scr(NCB_SCRIPTH_PHYS (np, skip)); in ncr_sir_to_redo()
6415 ncr_setup_tags (np, cmd->device); in ncr_sir_to_redo()
6427 ncr_put_start_queue(np, cp); in ncr_sir_to_redo()
6430 OUTL_DSP (NCB_SCRIPT_PHYS (np, reselect)); in ncr_sir_to_redo()
6474 startp = cpu_to_scr(NCB_SCRIPTH_PHYS (np, sdata_in)); in ncr_sir_to_redo()
6487 cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); in ncr_sir_to_redo()
6494 cpu_to_scr(NCB_SCRIPTH_PHYS (np, select_no_atn)); in ncr_sir_to_redo()
6496 ncr_put_start_queue(np, cp); in ncr_sir_to_redo()
6498 OUTL_DSP (NCB_SCRIPT_PHYS (np, start)); in ncr_sir_to_redo()
6517 void ncr_int_sir (struct ncb *np) in ncr_int_sir() argument
6525 struct tcb *tp = &np->target[target]; in ncr_int_sir()
6536 ncr_wakeup_done(np); in ncr_int_sir()
6538 OUTL(nc_dsp, NCB_SCRIPT_PHYS (np, done_end) + 8); in ncr_int_sir()
6540 OUTL(nc_dsp, NCB_SCRIPT_PHYS (np, start)); in ncr_int_sir()
6561 ncr_name (np), target, num); in ncr_int_sir()
6566 ncr_name (np), target, num); in ncr_int_sir()
6569 cp = np->header.cp; in ncr_int_sir()
6572 ncr_sir_to_redo(np, num, cp); in ncr_int_sir()
6578 cp = np->ccb; in ncr_int_sir()
6583 BUG_ON(cp != np->header.cp); in ncr_int_sir()
6585 if (!cp || cp != np->header.cp) in ncr_int_sir()
6687 ncr_setsync (np, cp, 0, 0xe0); in ncr_int_sir()
6692 ncr_setwide (np, cp, 0, 0); in ncr_int_sir()
6696 np->msgin [0] = NOP; in ncr_int_sir()
6697 np->msgout[0] = NOP; in ncr_int_sir()
6703 ncr_print_msg(cp, "sync msgin", np->msgin); in ncr_int_sir()
6707 per = np->msgin[3]; in ncr_int_sir()
6708 ofs = np->msgin[4]; in ncr_int_sir()
6723 if (per < np->minsync) in ncr_int_sir()
6724 {chg = 1; per = np->minsync;} in ncr_int_sir()
6736 ncr_getsync(np, per, &fak, &scntl3); in ncr_int_sir()
6764 ncr_setsync(np, cp, 0, 0xe0); in ncr_int_sir()
6765 OUTL_DSP(NCB_SCRIPT_PHYS (np, msg_bad)); in ncr_int_sir()
6770 ncr_setsync(np, cp, scntl3, (fak<<5)|ofs); in ncr_int_sir()
6771 OUTL_DSP(NCB_SCRIPT_PHYS (np, clrack)); in ncr_int_sir()
6777 ncr_setwide(np, cp, 0, 0); in ncr_int_sir()
6789 ncr_setsync(np, cp, scntl3, (fak<<5)|ofs); in ncr_int_sir()
6791 spi_populate_sync_msg(np->msgout, per, ofs); in ncr_int_sir()
6795 ncr_print_msg(cp, "sync msgout", np->msgout); in ncr_int_sir()
6799 OUTL_DSP (NCB_SCRIPT_PHYS (np, msg_bad)); in ncr_int_sir()
6802 np->msgin [0] = NOP; in ncr_int_sir()
6811 ncr_print_msg(cp, "wide msgin", np->msgin); in ncr_int_sir()
6819 wide = np->msgin[3]; in ncr_int_sir()
6852 ncr_setwide(np, cp, 0, 1); in ncr_int_sir()
6853 OUTL_DSP (NCB_SCRIPT_PHYS (np, msg_bad)); in ncr_int_sir()
6857 ncr_setwide(np, cp, wide, 1); in ncr_int_sir()
6858 OUTL_DSP (NCB_SCRIPT_PHYS (np, clrack)); in ncr_int_sir()
6865 ncr_setsync(np, cp, 0, 0xe0); in ncr_int_sir()
6876 ncr_setwide(np, cp, wide, 1); in ncr_int_sir()
6877 spi_populate_width_msg(np->msgout, wide); in ncr_int_sir()
6879 np->msgin [0] = NOP; in ncr_int_sir()
6884 ncr_print_msg(cp, "wide msgout", np->msgin); in ncr_int_sir()
6904 (unsigned)scr_to_cpu(np->lastmsg), np->msgout[0]); in ncr_int_sir()
6915 ncr_print_msg(cp, "MESSAGE_REJECT sent for", np->msgin); in ncr_int_sir()
6950 (unsigned) scr_to_cpu(np->header.savep), in ncr_int_sir()
6951 (unsigned) scr_to_cpu(np->header.goalp)); in ncr_int_sir()
6969 static struct ccb *ncr_get_ccb(struct ncb *np, struct scsi_cmnd *cmd) in ncr_get_ccb() argument
6973 struct tcb *tp = &np->target[tn]; in ncr_get_ccb()
6993 ncr_alloc_ccb(np, tn, ln); in ncr_get_ccb()
7027 cp = np->ccb; in ncr_get_ccb()
7080 static void ncr_free_ccb (struct ncb *np, struct ccb *cp) in ncr_free_ccb() argument
7082 struct tcb *tp = &np->target[cp->target]; in ncr_free_ccb()
7102 cpu_to_scr(NCB_SCRIPTH_PHYS(np, bad_i_t_l_q)); in ncr_free_ccb()
7105 cpu_to_scr(NCB_SCRIPTH_PHYS(np, bad_i_t_l)); in ncr_free_ccb()
7114 if (cp != np->ccb) in ncr_free_ccb()
7124 --np->queuedccbs; in ncr_free_ccb()
7129 if (cp == np->ccb) in ncr_free_ccb()
7135 #define ncr_reg_bus_addr(r) (np->paddr + offsetof (struct ncr_reg, r))
7142 static void ncr_init_ccb(struct ncb *np, struct ccb *cp) in ncr_init_ccb() argument
7144 ncrcmd copy_4 = np->features & FE_PFEN ? SCR_COPY(4) : SCR_COPY_F(4); in ncr_init_ccb()
7171 cp->start.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); in ncr_init_ccb()
7172 cp->restart.schedule.l_paddr = cpu_to_scr(NCB_SCRIPTH_PHYS (np, abort)); in ncr_init_ccb()
7181 static void ncr_alloc_ccb(struct ncb *np, u_char tn, u_char ln) in ncr_alloc_ccb() argument
7183 struct tcb *tp = &np->target[tn]; in ncr_alloc_ccb()
7198 np->actccbs++; in ncr_alloc_ccb()
7200 ncr_init_ccb(np, cp); in ncr_alloc_ccb()
7206 cp->link_ccb = np->ccb->link_ccb; in ncr_alloc_ccb()
7207 np->ccb->link_ccb = cp; in ncr_alloc_ccb()
7230 static void ncr_init_tcb (struct ncb *np, u_char tn) in ncr_init_tcb() argument
7232 struct tcb *tp = &np->target[tn]; in ncr_init_tcb()
7233 ncrcmd copy_1 = np->features & FE_PFEN ? SCR_COPY(1) : SCR_COPY_F(1); in ncr_init_tcb()
7243 tp->jump_tcb.l_paddr = np->jump_tcb[th].l_paddr; in ncr_init_tcb()
7274 tp->call_lun.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_lun)); in ncr_init_tcb()
7285 cpu_to_scr(NCB_SCRIPTH_PHYS (np, bad_identify)); in ncr_init_tcb()
7291 np->jump_tcb[th].l_paddr = cpu_to_scr(vtobus (&tp->jump_tcb)); in ncr_init_tcb()
7317 static struct lcb *ncr_alloc_lcb (struct ncb *np, u_char tn, u_char ln) in ncr_alloc_lcb() argument
7319 struct tcb *tp = &np->target[tn]; in ncr_alloc_lcb()
7321 ncrcmd copy_4 = np->features & FE_PFEN ? SCR_COPY(4) : SCR_COPY_F(4); in ncr_alloc_lcb()
7343 ncr_init_tcb(np, tn); in ncr_alloc_lcb()
7381 lp->jump_tag.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_notag)); in ncr_alloc_lcb()
7407 static struct lcb *ncr_setup_lcb (struct ncb *np, struct scsi_device *sdev) in ncr_setup_lcb() argument
7410 struct tcb *tp = &np->target[tn]; in ncr_setup_lcb()
7414 if (!lp && !(lp = ncr_alloc_lcb(np, tn, ln))) in ncr_setup_lcb()
7431 cpu_to_scr(NCB_SCRIPTH_PHYS (np, bad_i_t_l_q)); in ncr_setup_lcb()
7436 ncr_setup_tags (np, sdev); in ncr_setup_lcb()
7473 static int ncr_scatter(struct ncb *np, struct ccb *cp, struct scsi_cmnd *cmd) in ncr_scatter() argument
7480 use_sg = map_scsi_sg_data(np, cmd); in ncr_scatter()
7486 unmap_scsi_data(np, cmd); in ncr_scatter()
7496 ncr_build_sge(np, &data[segment], baddr, len); in ncr_scatter()
7516 static int __init ncr_regtest (struct ncb* np) argument
7539 static int __init ncr_snooptest (struct ncb* np) argument
7543 if (np->reg) {
7544 err |= ncr_regtest (np);
7550 pc = NCB_SCRIPTH_PHYS (np, snooptest);
7556 np->ncr_cache = cpu_to_scr(host_wr);
7575 host_rd = scr_to_cpu(np->ncr_cache);
7581 ncr_chip_reset(np, 100);
7592 if (pc != NCB_SCRIPTH_PHYS (np, snoopend)+8) {
7595 (u_long) NCB_SCRIPTH_PHYS (np, snooptest), (u_long) pc,
7596 (u_long) NCB_SCRIPTH_PHYS (np, snoopend) +8);
7646 static void ncr_selectclock(struct ncb *np, u_char scntl3) argument
7648 if (np->multiplier < 2) {
7654 printk ("%s: enabling clock multiplier\n", ncr_name(np));
7657 if (np->multiplier > 2) { /* Poll bit 5 of stest4 for quadrupler */
7662 printk("%s: the chip cannot lock the frequency\n", ncr_name(np));
7675 static unsigned __init ncrgetfreq (struct ncb *np, int gen) argument
7716 printk ("%s: Delay (GEN=%d): %u msec\n", ncr_name(np), gen, ms);
7726 static void __init ncr_getclock (struct ncb *np, int mult) argument
7732 np->multiplier = 1;
7740 printk ("%s: clock multiplier found\n", ncr_name(np));
7741 np->multiplier = mult;
7749 if (np->multiplier != mult || (scntl3 & 7) < 3 || !(scntl3 & 1)) {
7752 ncr_chip_reset(np, 5);
7754 (void) ncrgetfreq (np, 11); /* throw away first result */
7755 f1 = ncrgetfreq (np, 11);
7756 f2 = ncrgetfreq (np, 11);
7759 printk ("%s: NCR clock is %uKHz, %uKHz\n", ncr_name(np), f1, f2);
7769 printk ("%s: clock multiplier assumed\n", ncr_name(np));
7770 np->multiplier = mult;
7777 f1 /= np->multiplier;
7783 f1 *= np->multiplier;
7784 np->clock_khz = f1;
7792 struct ncb *np = ((struct host_data *) host->hostdata)->ncb; local
7793 struct tcb *tp = &np->target[device->id];
7802 struct ncb *np = ((struct host_data *) host->hostdata)->ncb; local
7803 struct tcb *tp = &np->target[device->id];
7807 ncr_setup_lcb(np, device);
7815 numtags = device_queue_depth(np->unit, device->id, device->lun);
7841 ncr_setup_tags (np, device);
7845 np->unit, device->id, device->lun, depth_to_use);
7858 struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb; local
7870 spin_lock_irqsave(&np->smp_lock, flags);
7872 if ((sts = ncr_queue_command(np, cmd)) != DID_OK) {
7883 spin_unlock_irqrestore(&np->smp_lock, flags);
7886 unmap_scsi_data(np, cmd);
7901 struct ncb *np = host_data->ncb; local
7910 spin_lock_irqsave(&np->smp_lock, flags);
7911 ncr_exception(np);
7912 done_list = np->done_list;
7913 np->done_list = NULL;
7914 spin_unlock_irqrestore(&np->smp_lock, flags);
7925 struct ncb *np = from_timer(np, t, timer); local
7929 spin_lock_irqsave(&np->smp_lock, flags);
7930 ncr_timeout(np);
7931 done_list = np->done_list;
7932 np->done_list = NULL;
7933 spin_unlock_irqrestore(&np->smp_lock, flags);
7941 struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb; local
7953 spin_lock_irqsave(&np->smp_lock, flags);
7954 sts = ncr_reset_bus(np);
7956 done_list = np->done_list;
7957 np->done_list = NULL;
7958 spin_unlock_irqrestore(&np->smp_lock, flags);
7981 static void insert_into_waiting_list(struct ncb *np, struct scsi_cmnd *cmd) argument
7986 printk("%s: cmd %lx inserted into waiting list\n", ncr_name(np), (u_long) cmd);
7989 if (!(wcmd = np->waiting_list)) np->waiting_list = cmd;
7997 static void process_waiting_list(struct ncb *np, int sts) argument
8001 waiting_list = np->waiting_list;
8002 np->waiting_list = NULL;
8005 …if (waiting_list) printk("%s: waiting_list=%lx processing sts=%d\n", ncr_name(np), (u_long) waitin…
8012 printk("%s: cmd %lx trying to requeue\n", ncr_name(np), (u_long) wcmd);
8014 sts = ncr_queue_command(np, wcmd);
8018 printk("%s: cmd %lx done forced sts=%d\n", ncr_name(np), (u_long) wcmd, sts);
8021 ncr_queue_done_cmd(np, wcmd);
8083 struct ncb *np = NULL; local
8115 np = __m_calloc_dma(device->dev, sizeof(struct ncb), "NCB");
8116 if (!np)
8118 spin_lock_init(&np->smp_lock);
8119 np->dev = device->dev;
8120 np->p_ncb = vtobus(np);
8121 host_data->ncb = np;
8123 np->ccb = m_calloc_dma(sizeof(struct ccb), "CCB");
8124 if (!np->ccb)
8128 np->unit = unit;
8129 np->verbose = driver_setup.verbose;
8130 sprintf(np->inst_name, "ncr53c720-%d", np->unit);
8131 np->revision_id = device->chip.revision_id;
8132 np->features = device->chip.features;
8133 np->clock_divn = device->chip.nr_divisor;
8134 np->maxoffs = device->chip.offset_max;
8135 np->maxburst = device->chip.burst_max;
8136 np->myaddr = device->host_id;
8139 np->script0 = m_calloc_dma(sizeof(struct script), "SCRIPT");
8140 if (!np->script0)
8142 np->scripth0 = m_calloc_dma(sizeof(struct scripth), "SCRIPTH");
8143 if (!np->scripth0)
8146 timer_setup(&np->timer, ncr53c8xx_timeout, 0);
8150 np->paddr = device->slot.base;
8151 np->paddr2 = (np->features & FE_RAM) ? device->slot.base_2 : 0;
8154 np->vaddr = device->slot.base_v;
8156 np->vaddr = ioremap(device->slot.base_c, 128);
8158 if (!np->vaddr) {
8160 "%s: can't map memory mapped IO region\n",ncr_name(np));
8165 "%s: using memory mapped IO at virtual address 0x%lx\n", ncr_name(np), (u_long) np->vaddr);
8172 np->reg = (struct ncr_reg __iomem *)np->vaddr;
8175 ncr_prepare_setting(np);
8177 if (np->paddr2 && sizeof(struct script) > 4096) {
8178 np->paddr2 = 0;
8180 ncr_name(np));
8184 instance->this_id = np->myaddr;
8185 instance->max_id = np->maxwide ? 16 : 8;
8187 instance->base = (unsigned long) np->reg;
8201 np->scripth = np->scripth0;
8202 np->p_scripth = vtobus(np->scripth);
8203 np->p_script = (np->paddr2) ? np->paddr2 : vtobus(np->script0);
8205 ncr_script_copy_and_bind(np, (ncrcmd *) &script0,
8206 (ncrcmd *) np->script0, sizeof(struct script));
8207 ncr_script_copy_and_bind(np, (ncrcmd *) &scripth0,
8208 (ncrcmd *) np->scripth0, sizeof(struct scripth));
8209 np->ccb->p_ccb = vtobus (np->ccb);
8213 if (np->features & FE_LED0) {
8214 np->script0->idle[0] =
8216 np->script0->reselected[0] =
8218 np->script0->start[0] =
8228 np->jump_tcb[i].l_cmd =
8230 np->jump_tcb[i].l_paddr =
8231 cpu_to_scr(NCB_SCRIPTH_PHYS (np, bad_target));
8234 ncr_chip_reset(np, 100);
8238 if (ncr_snooptest(np)) {
8244 np->irq = device->slot.irq;
8247 ncr_init_ccb(np, np->ccb);
8255 spin_lock_irqsave(&np->smp_lock, flags);
8256 if (ncr_reset_scsi_bus(np, 0, driver_setup.settle_delay) != 0) {
8257 …N_ERR "%s: FATAL ERROR: CHECK SCSI BUS - CABLES, TERMINATION, DEVICE POWER etc.!\n", ncr_name(np));
8259 spin_unlock_irqrestore(&np->smp_lock, flags);
8262 ncr_exception(np);
8264 np->disc = 1;
8272 ncr_name(np), driver_setup.settle_delay);
8277 np->lasttime=0;
8278 ncr_timeout (np);
8282 np->order = SIMPLE_QUEUE_TAG;
8285 spin_unlock_irqrestore(&np->smp_lock, flags);
8292 printk(KERN_INFO "%s: detaching...\n", ncr_name(np));
8293 if (!np)
8295 if (np->scripth0)
8296 m_free_dma(np->scripth0, sizeof(struct scripth), "SCRIPTH");
8297 if (np->script0)
8298 m_free_dma(np->script0, sizeof(struct script), "SCRIPT");
8299 if (np->ccb)
8300 m_free_dma(np->ccb, sizeof(struct ccb), "CCB");
8301 m_free_dma(np, sizeof(struct ncb), "NCB");
8325 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb; local
8326 struct tcb *tp = &np->target[starget->id];
8328 if (period > np->maxsync)
8329 period = np->maxsync;
8330 else if (period < np->minsync)
8331 period = np->minsync;
8335 ncr_negotiate(np, tp);
8341 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb; local
8342 struct tcb *tp = &np->target[starget->id];
8344 if (offset > np->maxoffs)
8345 offset = np->maxoffs;
8351 ncr_negotiate(np, tp);
8357 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb; local
8358 struct tcb *tp = &np->target[starget->id];
8360 if (width > np->maxwide)
8361 width = np->maxwide;
8367 ncr_negotiate(np, tp);
8372 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb; local
8375 switch (np->scsi_mode) {