Lines Matching refs:np
513 #define _m_calloc_dma(np, s, n) __m_calloc_dma(np->dev, s, n) argument
514 #define _m_free_dma(np, p, s, n) __m_free_dma(np->dev, p, s, n) argument
515 #define m_calloc_dma(s, n) _m_calloc_dma(np, s, n)
516 #define m_free_dma(p, s, n) _m_free_dma(np, p, s, n)
517 #define _vtobus(np, p) __vtobus(np->dev, p) argument
518 #define vtobus(p) _vtobus(np, p)
552 #define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd) argument
553 #define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd) argument
576 #define bootverbose (np->verbose)
1016 #define bootverbose (np->verbose)
1761 #define NCB_SCRIPT_PHYS(np,lbl) (np->p_script + offsetof (struct script, lbl)) argument
1762 #define NCB_SCRIPTH_PHYS(np,lbl) (np->p_scripth + offsetof (struct scripth,lbl)) argument
1919 static void ncr_alloc_ccb (struct ncb *np, u_char tn, u_char ln);
1920 static void ncr_complete (struct ncb *np, struct ccb *cp);
1921 static void ncr_exception (struct ncb *np);
1922 static void ncr_free_ccb (struct ncb *np, struct ccb *cp);
1923 static void ncr_init_ccb (struct ncb *np, struct ccb *cp);
1924 static void ncr_init_tcb (struct ncb *np, u_char tn);
1925 static struct lcb * ncr_alloc_lcb (struct ncb *np, u_char tn, u_char ln);
1926 static struct lcb * ncr_setup_lcb (struct ncb *np, struct scsi_device *sdev);
1927 static void ncr_getclock (struct ncb *np, int mult);
1928 static void ncr_selectclock (struct ncb *np, u_char scntl3);
1929 static struct ccb *ncr_get_ccb (struct ncb *np, struct scsi_cmnd *cmd);
1930 static void ncr_chip_reset (struct ncb *np, int delay);
1931 static void ncr_init (struct ncb *np, int reset, char * msg, u_long code);
1932 static int ncr_int_sbmc (struct ncb *np);
1933 static int ncr_int_par (struct ncb *np);
1934 static void ncr_int_ma (struct ncb *np);
1935 static void ncr_int_sir (struct ncb *np);
1936 static void ncr_int_sto (struct ncb *np);
1937 static void ncr_negotiate (struct ncb* np, struct tcb* tp);
1938 static int ncr_prepare_nego(struct ncb *np, struct ccb *cp, u_char *msgptr);
1941 (struct ncb *np, ncrcmd *src, ncrcmd *dst, int len);
1943 static int ncr_scatter (struct ncb *np, struct ccb *cp, struct scsi_cmnd *cmd);
1944 static void ncr_getsync (struct ncb *np, u_char sfac, u_char *fakp, u_char *scntl3p);
1945 static void ncr_setsync (struct ncb *np, struct ccb *cp, u_char scntl3, u_char sxfer);
1946 static void ncr_setup_tags (struct ncb *np, struct scsi_device *sdev);
1947 static void ncr_setwide (struct ncb *np, struct ccb *cp, u_char wide, u_char ack);
1948 static int ncr_snooptest (struct ncb *np);
1949 static void ncr_timeout (struct ncb *np);
1950 static void ncr_wakeup (struct ncb *np, u_long code);
1951 static void ncr_wakeup_done (struct ncb *np);
1952 static void ncr_start_next_ccb (struct ncb *np, struct lcb * lp, int maxn);
1953 static void ncr_put_start_queue(struct ncb *np, struct ccb *cp);
1955 static void insert_into_waiting_list(struct ncb *np, struct scsi_cmnd *cmd);
1956 static struct scsi_cmnd *retrieve_from_waiting_list(int to_remove, struct ncb *np, struct scsi_cmnd…
1957 static void process_waiting_list(struct ncb *np, int sts);
1959 #define remove_from_waiting_list(np, cmd) \ argument
1960 retrieve_from_waiting_list(1, (np), (cmd))
1961 #define requeue_waiting_list(np) process_waiting_list((np), DID_OK) argument
1962 #define reset_waiting_list(np) process_waiting_list((np), DID_RESET) argument
1964 static inline char *ncr_name (struct ncb *np) in ncr_name() argument
1966 return np->inst_name; in ncr_name()
3524 ncr_script_copy_and_bind (struct ncb *np, ncrcmd *src, ncrcmd *dst, int len) in ncr_script_copy_and_bind() argument
3548 ncr_name(np), (int) (src-start-1)); in ncr_script_copy_and_bind()
3578 ncr_name(np), (int) (src-start-1)); in ncr_script_copy_and_bind()
3585 if ((opcode & SCR_NO_FLUSH) && !(np->features & FE_PFEN)) { in ncr_script_copy_and_bind()
3627 new = (old & ~RELOC_MASK) + np->paddr; in ncr_script_copy_and_bind()
3630 new = (old & ~RELOC_MASK) + np->p_script; in ncr_script_copy_and_bind()
3633 new = (old & ~RELOC_MASK) + np->p_scripth; in ncr_script_copy_and_bind()
3636 new = (old & ~RELOC_MASK) + np->p_ncb; in ncr_script_copy_and_bind()
3728 static inline void ncr_init_burst(struct ncb *np, u_char bc) in ncr_init_burst() argument
3730 u_char *be = &np->rv_ctest0; in ncr_init_burst()
3732 np->rv_dmode &= ~(0x3 << 6); in ncr_init_burst()
3733 np->rv_ctest5 &= ~0x4; in ncr_init_burst()
3739 np->rv_dmode |= ((bc & 0x3) << 6); in ncr_init_burst()
3740 np->rv_ctest5 |= (bc & 0x4); in ncr_init_burst()
3744 static void __init ncr_prepare_setting(struct ncb *np) in ncr_prepare_setting() argument
3754 np->sv_scntl0 = INB(nc_scntl0) & 0x0a; in ncr_prepare_setting()
3755 np->sv_scntl3 = INB(nc_scntl3) & 0x07; in ncr_prepare_setting()
3756 np->sv_dmode = INB(nc_dmode) & 0xce; in ncr_prepare_setting()
3757 np->sv_dcntl = INB(nc_dcntl) & 0xa8; in ncr_prepare_setting()
3758 np->sv_ctest0 = INB(nc_ctest0) & 0x84; in ncr_prepare_setting()
3759 np->sv_ctest3 = INB(nc_ctest3) & 0x01; in ncr_prepare_setting()
3760 np->sv_ctest4 = INB(nc_ctest4) & 0x80; in ncr_prepare_setting()
3761 np->sv_ctest5 = INB(nc_ctest5) & 0x24; in ncr_prepare_setting()
3762 np->sv_gpcntl = INB(nc_gpcntl); in ncr_prepare_setting()
3763 np->sv_stest2 = INB(nc_stest2) & 0x20; in ncr_prepare_setting()
3764 np->sv_stest4 = INB(nc_stest4); in ncr_prepare_setting()
3770 np->maxwide = (np->features & FE_WIDE)? 1 : 0; in ncr_prepare_setting()
3775 if (np->features & FE_ULTRA) in ncr_prepare_setting()
3776 np->clock_khz = 80000; in ncr_prepare_setting()
3778 np->clock_khz = 40000; in ncr_prepare_setting()
3783 if (np->features & FE_QUAD) in ncr_prepare_setting()
3784 np->multiplier = 4; in ncr_prepare_setting()
3785 else if (np->features & FE_DBLR) in ncr_prepare_setting()
3786 np->multiplier = 2; in ncr_prepare_setting()
3788 np->multiplier = 1; in ncr_prepare_setting()
3794 if (np->features & FE_VARCLK) in ncr_prepare_setting()
3795 ncr_getclock(np, np->multiplier); in ncr_prepare_setting()
3800 i = np->clock_divn - 1; in ncr_prepare_setting()
3802 if (10ul * SCSI_NCR_MIN_ASYNC * np->clock_khz > div_10M[i]) { in ncr_prepare_setting()
3807 np->rv_scntl3 = i+1; in ncr_prepare_setting()
3814 period = (4 * div_10M[0] + np->clock_khz - 1) / np->clock_khz; in ncr_prepare_setting()
3815 if (period <= 250) np->minsync = 10; in ncr_prepare_setting()
3816 else if (period <= 303) np->minsync = 11; in ncr_prepare_setting()
3817 else if (period <= 500) np->minsync = 12; in ncr_prepare_setting()
3818 else np->minsync = (period + 40 - 1) / 40; in ncr_prepare_setting()
3824 if (np->minsync < 25 && !(np->features & FE_ULTRA)) in ncr_prepare_setting()
3825 np->minsync = 25; in ncr_prepare_setting()
3831 period = (11 * div_10M[np->clock_divn - 1]) / (4 * np->clock_khz); in ncr_prepare_setting()
3832 np->maxsync = period > 2540 ? 254 : period / 10; in ncr_prepare_setting()
3838 np->rv_scntl0 = np->sv_scntl0; in ncr_prepare_setting()
3839 np->rv_dmode = np->sv_dmode; in ncr_prepare_setting()
3840 np->rv_dcntl = np->sv_dcntl; in ncr_prepare_setting()
3841 np->rv_ctest0 = np->sv_ctest0; in ncr_prepare_setting()
3842 np->rv_ctest3 = np->sv_ctest3; in ncr_prepare_setting()
3843 np->rv_ctest4 = np->sv_ctest4; in ncr_prepare_setting()
3844 np->rv_ctest5 = np->sv_ctest5; in ncr_prepare_setting()
3845 burst_max = burst_code(np->sv_dmode, np->sv_ctest0); in ncr_prepare_setting()
3853 burst_max = burst_code(np->sv_dmode, np->sv_ctest0); in ncr_prepare_setting()
3856 if (burst_max > np->maxburst) in ncr_prepare_setting()
3857 burst_max = np->maxburst; in ncr_prepare_setting()
3862 if (np->features & FE_ERL) in ncr_prepare_setting()
3863 np->rv_dmode |= ERL; /* Enable Read Line */ in ncr_prepare_setting()
3864 if (np->features & FE_BOF) in ncr_prepare_setting()
3865 np->rv_dmode |= BOF; /* Burst Opcode Fetch */ in ncr_prepare_setting()
3866 if (np->features & FE_ERMP) in ncr_prepare_setting()
3867 np->rv_dmode |= ERMP; /* Enable Read Multiple */ in ncr_prepare_setting()
3868 if (np->features & FE_PFEN) in ncr_prepare_setting()
3869 np->rv_dcntl |= PFEN; /* Prefetch Enable */ in ncr_prepare_setting()
3870 if (np->features & FE_CLSE) in ncr_prepare_setting()
3871 np->rv_dcntl |= CLSE; /* Cache Line Size Enable */ in ncr_prepare_setting()
3872 if (np->features & FE_WRIE) in ncr_prepare_setting()
3873 np->rv_ctest3 |= WRIE; /* Write and Invalidate */ in ncr_prepare_setting()
3874 if (np->features & FE_DFS) in ncr_prepare_setting()
3875 np->rv_ctest5 |= DFS; /* Dma Fifo Size */ in ncr_prepare_setting()
3876 if (np->features & FE_MUX) in ncr_prepare_setting()
3877 np->rv_ctest4 |= MUX; /* Host bus multiplex mode */ in ncr_prepare_setting()
3878 if (np->features & FE_EA) in ncr_prepare_setting()
3879 np->rv_dcntl |= EA; /* Enable ACK */ in ncr_prepare_setting()
3880 if (np->features & FE_EHP) in ncr_prepare_setting()
3881 np->rv_ctest0 |= EHP; /* Even host parity */ in ncr_prepare_setting()
3887 np->rv_ctest4 |= MPEE; /* Master parity checking */ in ncr_prepare_setting()
3889 np->rv_scntl0 |= 0x0a; /* full arb., ena parity, par->ATN */ in ncr_prepare_setting()
3894 if (np->myaddr == 255) { in ncr_prepare_setting()
3895 np->myaddr = INB(nc_scid) & 0x07; in ncr_prepare_setting()
3896 if (!np->myaddr) in ncr_prepare_setting()
3897 np->myaddr = SCSI_NCR_MYADDR; in ncr_prepare_setting()
3905 ncr_init_burst(np, burst_max); in ncr_prepare_setting()
3916 np->scsi_mode = SMODE_SE; in ncr_prepare_setting()
3917 if (np->features & FE_DIFF) { in ncr_prepare_setting()
3920 if (np->sv_scntl3) { in ncr_prepare_setting()
3921 if (np->sv_stest2 & 0x20) in ncr_prepare_setting()
3922 np->scsi_mode = SMODE_HVD; in ncr_prepare_setting()
3929 np->scsi_mode = SMODE_HVD; in ncr_prepare_setting()
3931 if (np->sv_stest2 & 0x20) in ncr_prepare_setting()
3932 np->scsi_mode = SMODE_HVD; in ncr_prepare_setting()
3938 if (np->scsi_mode == SMODE_HVD) in ncr_prepare_setting()
3939 np->rv_stest2 |= 0x20; in ncr_prepare_setting()
3949 !(np->features & FE_LEDC) && !(np->sv_gpcntl & 0x01)) in ncr_prepare_setting()
3950 np->features |= FE_LED0; in ncr_prepare_setting()
3957 np->rv_dcntl |= IRQM; in ncr_prepare_setting()
3960 np->rv_dcntl |= (np->sv_dcntl & IRQM); in ncr_prepare_setting()
3972 struct tcb *tp = &np->target[i]; in ncr_prepare_setting()
3979 np->target[i].usrflag = UF_NODISC; in ncr_prepare_setting()
3986 printk(KERN_INFO "%s: ID %d, Fast-%d%s%s\n", ncr_name(np), in ncr_prepare_setting()
3987 np->myaddr, in ncr_prepare_setting()
3988 np->minsync < 12 ? 40 : (np->minsync < 25 ? 20 : 10), in ncr_prepare_setting()
3989 (np->rv_scntl0 & 0xa) ? ", Parity Checking" : ", NO Parity", in ncr_prepare_setting()
3990 (np->rv_stest2 & 0x20) ? ", Differential" : ""); in ncr_prepare_setting()
3995 ncr_name(np), np->sv_scntl3, np->sv_dmode, np->sv_dcntl, in ncr_prepare_setting()
3996 np->sv_ctest3, np->sv_ctest4, np->sv_ctest5); in ncr_prepare_setting()
4000 ncr_name(np), np->rv_scntl3, np->rv_dmode, np->rv_dcntl, in ncr_prepare_setting()
4001 np->rv_ctest3, np->rv_ctest4, np->rv_ctest5); in ncr_prepare_setting()
4004 if (bootverbose && np->paddr2) in ncr_prepare_setting()
4006 ncr_name(np), np->paddr2); in ncr_prepare_setting()
4028 static inline void ncr_queue_done_cmd(struct ncb *np, struct scsi_cmnd *cmd) in ncr_queue_done_cmd() argument
4030 unmap_scsi_data(np, cmd); in ncr_queue_done_cmd()
4031 cmd->host_scribble = (char *) np->done_list; in ncr_queue_done_cmd()
4032 np->done_list = cmd; in ncr_queue_done_cmd()
4060 static int ncr_prepare_nego(struct ncb *np, struct ccb *cp, u_char *msgptr) in ncr_prepare_nego() argument
4062 struct tcb *tp = &np->target[cp->target]; in ncr_prepare_nego()
4119 static int ncr_queue_command (struct ncb *np, struct scsi_cmnd *cmd) in ncr_queue_command() argument
4122 struct tcb *tp = &np->target[sdev->id]; in ncr_queue_command()
4138 if ((sdev->id == np->myaddr ) || in ncr_queue_command()
4173 if (np->settle_time && cmd->request->timeout >= HZ) { in ncr_queue_command()
4175 if (time_after(np->settle_time, tlimit)) in ncr_queue_command()
4176 np->settle_time = tlimit; in ncr_queue_command()
4179 if (np->settle_time || !(cp=ncr_get_ccb (np, cmd))) { in ncr_queue_command()
4180 insert_into_waiting_list(np, cmd); in ncr_queue_command()
4195 (cp != np->ccb && np->disc && !(tp->usrflag & UF_NODISC))) in ncr_queue_command()
4203 char order = np->order; in ncr_queue_command()
4253 segments = ncr_scatter(np, cp, cp->cmd); in ncr_queue_command()
4255 ncr_free_ccb(np, cp); in ncr_queue_command()
4276 msglen += ncr_prepare_nego (np, cp, msgptr + msglen); in ncr_queue_command()
4297 goalp = NCB_SCRIPT_PHYS (np, data_out2) + 8; in ncr_queue_command()
4301 lastp = NCB_SCRIPTH_PHYS (np, hdata_out2); in ncr_queue_command()
4310 goalp = NCB_SCRIPT_PHYS (np, data_in2) + 8; in ncr_queue_command()
4314 lastp = NCB_SCRIPTH_PHYS (np, hdata_in2); in ncr_queue_command()
4320 lastp = goalp = NCB_SCRIPT_PHYS (np, no_data); in ncr_queue_command()
4333 cpu_to_scr(NCB_SCRIPTH_PHYS (np, data_io)); in ncr_queue_command()
4357 cp->start.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); in ncr_queue_command()
4358 cp->restart.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_dsa)); in ncr_queue_command()
4408 ncr_start_next_ccb(np, lp, 2); in ncr_queue_command()
4410 ncr_put_start_queue(np, cp); in ncr_queue_command()
4428 static void ncr_start_next_ccb(struct ncb *np, struct lcb *lp, int maxn) in ncr_start_next_ccb() argument
4445 ncr_put_start_queue(np, cp); in ncr_start_next_ccb()
4449 static void ncr_put_start_queue(struct ncb *np, struct ccb *cp) in ncr_put_start_queue() argument
4456 if (!np->squeueput) np->squeueput = 1; in ncr_put_start_queue()
4457 qidx = np->squeueput + 2; in ncr_put_start_queue()
4460 np->scripth->tryloop [qidx] = cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); in ncr_put_start_queue()
4462 np->scripth->tryloop [np->squeueput] = cpu_to_scr(CCB_PHYS (cp, start)); in ncr_put_start_queue()
4464 np->squeueput = qidx; in ncr_put_start_queue()
4465 ++np->queuedccbs; in ncr_put_start_queue()
4469 printk ("%s: queuepos=%d.\n", ncr_name (np), np->squeueput); in ncr_put_start_queue()
4480 static int ncr_reset_scsi_bus(struct ncb *np, int enab_int, int settle_delay) in ncr_reset_scsi_bus() argument
4485 np->settle_time = jiffies + settle_delay * HZ; in ncr_reset_scsi_bus()
4490 ncr_name(np), settle_delay); in ncr_reset_scsi_bus()
4492 ncr_chip_reset(np, 100); in ncr_reset_scsi_bus()
4520 if (!(np->features & FE_WIDE)) in ncr_reset_scsi_bus()
4525 ncr_name(np)); in ncr_reset_scsi_bus()
4528 ncr_name(np), in ncr_reset_scsi_bus()
4529 (np->features & FE_WIDE) ? "dp1,d15-8," : "", in ncr_reset_scsi_bus()
4546 static void ncr_start_reset(struct ncb *np) in ncr_start_reset() argument
4548 if (!np->settle_time) { in ncr_start_reset()
4549 ncr_reset_scsi_bus(np, 1, driver_setup.settle_delay); in ncr_start_reset()
4562 static int ncr_reset_bus (struct ncb *np, struct scsi_cmnd *cmd, int sync_reset) in ncr_reset_bus() argument
4571 if (np->settle_time) { in ncr_reset_bus()
4580 ncr_start_reset(np); in ncr_reset_bus()
4584 for (found=0, cp=np->ccb; cp; cp=cp->link_ccb) { in ncr_reset_bus()
4597 if (!found && retrieve_from_waiting_list(0, np, cmd)) in ncr_reset_bus()
4602 reset_waiting_list(np); in ncr_reset_bus()
4606 ncr_wakeup(np, HS_RESET); in ncr_reset_bus()
4613 if (!found && sync_reset && !retrieve_from_waiting_list(0, np, cmd)) { in ncr_reset_bus()
4615 ncr_queue_done_cmd(np, cmd); in ncr_reset_bus()
4631 static int ncr_abort_command (struct ncb *np, struct scsi_cmnd *cmd)
4641 if (remove_from_waiting_list(np, cmd)) {
4643 ncr_queue_done_cmd(np, cmd);
4650 for (found=0, cp=np->ccb; cp; cp=cp->link_ccb) {
4665 if (np->settle_time) {
4677 printk ("%s: abort ccb=%p (cancel)\n", ncr_name (np), cp);
4679 cpu_to_scr(NCB_SCRIPTH_PHYS (np, cancel));
4684 cpu_to_scr(NCB_SCRIPTH_PHYS (np, abort));
4704 static void ncr_detach(struct ncb *np) in ncr_detach() argument
4714 strlcpy(inst_name, ncr_name(np), sizeof(inst_name)); in ncr_detach()
4716 printk("%s: releasing host resources\n", ncr_name(np)); in ncr_detach()
4724 printk("%s: stopping the timer\n", ncr_name(np)); in ncr_detach()
4726 np->release_stage = 1; in ncr_detach()
4727 for (i = 50 ; i && np->release_stage != 2 ; i--) in ncr_detach()
4729 if (np->release_stage != 2) in ncr_detach()
4730 printk("%s: the timer seems to be already stopped\n", ncr_name(np)); in ncr_detach()
4731 else np->release_stage = 2; in ncr_detach()
4738 printk("%s: disabling chip interrupts\n", ncr_name(np)); in ncr_detach()
4748 printk("%s: resetting chip\n", ncr_name(np)); in ncr_detach()
4749 ncr_chip_reset(np, 100); in ncr_detach()
4751 OUTB(nc_dmode, np->sv_dmode); in ncr_detach()
4752 OUTB(nc_dcntl, np->sv_dcntl); in ncr_detach()
4753 OUTB(nc_ctest0, np->sv_ctest0); in ncr_detach()
4754 OUTB(nc_ctest3, np->sv_ctest3); in ncr_detach()
4755 OUTB(nc_ctest4, np->sv_ctest4); in ncr_detach()
4756 OUTB(nc_ctest5, np->sv_ctest5); in ncr_detach()
4757 OUTB(nc_gpcntl, np->sv_gpcntl); in ncr_detach()
4758 OUTB(nc_stest2, np->sv_stest2); in ncr_detach()
4760 ncr_selectclock(np, np->sv_scntl3); in ncr_detach()
4766 while ((cp=np->ccb->link_ccb) != NULL) { in ncr_detach()
4767 np->ccb->link_ccb = cp->link_ccb; in ncr_detach()
4770 ncr_name(np), cp->host_status); in ncr_detach()
4773 printk("%s: freeing ccb (%lx)\n", ncr_name(np), (u_long) cp); in ncr_detach()
4781 tp=&np->target[target]; in ncr_detach()
4786 printk("%s: freeing lp (%lx)\n", ncr_name(np), (u_long) lp); in ncr_detach()
4795 if (np->scripth0) in ncr_detach()
4796 m_free_dma(np->scripth0, sizeof(struct scripth), "SCRIPTH"); in ncr_detach()
4797 if (np->script0) in ncr_detach()
4798 m_free_dma(np->script0, sizeof(struct script), "SCRIPT"); in ncr_detach()
4799 if (np->ccb) in ncr_detach()
4800 m_free_dma(np->ccb, sizeof(struct ccb), "CCB"); in ncr_detach()
4801 m_free_dma(np, sizeof(struct ncb), "NCB"); in ncr_detach()
4816 void ncr_complete (struct ncb *np, struct ccb *cp) in ncr_complete() argument
4843 tp = &np->target[cmd->device->id]; in ncr_complete()
4938 ncr_alloc_lcb (np, cmd->device->id, cmd->device->lun); in ncr_complete()
4952 ncr_setup_tags (np, cmd->device); in ncr_complete()
5058 ncr_free_ccb (np, cp); in ncr_complete()
5065 ncr_start_next_ccb(np, lp, 2); in ncr_complete()
5070 if (np->waiting_list) in ncr_complete()
5071 requeue_waiting_list(np); in ncr_complete()
5076 ncr_queue_done_cmd(np, cmd); in ncr_complete()
5092 static void ncr_ccb_skipped(struct ncb *np, struct ccb *cp) in ncr_ccb_skipped() argument
5094 struct tcb *tp = &np->target[cp->target]; in ncr_ccb_skipped()
5097 if (lp && cp != np->ccb) { in ncr_ccb_skipped()
5100 cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); in ncr_ccb_skipped()
5107 --np->queuedccbs; in ncr_ccb_skipped()
5116 void ncr_wakeup_done (struct ncb *np) in ncr_wakeup_done() argument
5122 i = np->ccb_done_ic; in ncr_wakeup_done()
5128 cp = np->ccb_done[j]; in ncr_wakeup_done()
5132 np->ccb_done[j] = (struct ccb *)CCB_DONE_EMPTY; in ncr_wakeup_done()
5133 np->scripth->done_queue[5*j + 4] = in ncr_wakeup_done()
5134 cpu_to_scr(NCB_SCRIPT_PHYS (np, done_plug)); in ncr_wakeup_done()
5136 np->scripth->done_queue[5*i + 4] = in ncr_wakeup_done()
5137 cpu_to_scr(NCB_SCRIPT_PHYS (np, done_end)); in ncr_wakeup_done()
5140 ncr_complete (np, cp); in ncr_wakeup_done()
5142 ncr_ccb_skipped (np, cp); in ncr_wakeup_done()
5146 np->ccb_done_ic = i; in ncr_wakeup_done()
5148 cp = np->ccb; in ncr_wakeup_done()
5151 ncr_complete (np, cp); in ncr_wakeup_done()
5153 ncr_ccb_skipped (np, cp); in ncr_wakeup_done()
5162 void ncr_wakeup (struct ncb *np, u_long code) in ncr_wakeup() argument
5164 struct ccb *cp = np->ccb; in ncr_wakeup()
5169 ncr_complete (np, cp); in ncr_wakeup()
5183 static void ncr_chip_reset(struct ncb *np, int delay) in ncr_chip_reset() argument
5189 if (np->features & FE_EHP) in ncr_chip_reset()
5191 if (np->features & FE_MUX) in ncr_chip_reset()
5205 void ncr_init (struct ncb *np, int reset, char * msg, u_long code) in ncr_init() argument
5226 if (msg) printk (KERN_INFO "%s: restart (%s).\n", ncr_name (np), msg); in ncr_init()
5231 np->queuedepth = MAX_START - 1; /* 1 entry needed as end marker */ in ncr_init()
5233 np->scripth0->tryloop[i] = in ncr_init()
5234 cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); in ncr_init()
5239 np->squeueput = 0; in ncr_init()
5240 np->script0->startpos[0] = cpu_to_scr(NCB_SCRIPTH_PHYS (np, tryloop)); in ncr_init()
5247 np->ccb_done[i] = (struct ccb *)CCB_DONE_EMPTY; in ncr_init()
5248 np->scripth0->done_queue[5*i + 4] = in ncr_init()
5249 cpu_to_scr(NCB_SCRIPT_PHYS (np, done_end)); in ncr_init()
5256 np->script0->done_pos[0] = cpu_to_scr(NCB_SCRIPTH_PHYS (np,done_queue)); in ncr_init()
5257 np->ccb_done_ic = MAX_DONE-1; in ncr_init()
5258 np->scripth0->done_queue[5*(MAX_DONE-1) + 4] = in ncr_init()
5259 cpu_to_scr(NCB_SCRIPT_PHYS (np, done_plug)); in ncr_init()
5264 ncr_wakeup (np, code); in ncr_init()
5274 ncr_chip_reset(np, 2000); in ncr_init()
5276 OUTB (nc_scntl0, np->rv_scntl0 | 0xc0); in ncr_init()
5280 ncr_selectclock(np, np->rv_scntl3); /* Select SCSI clock */ in ncr_init()
5282 OUTB (nc_scid , RRE|np->myaddr); /* Adapter SCSI address */ in ncr_init()
5283 OUTW (nc_respid, 1ul<<np->myaddr); /* Id to respond to */ in ncr_init()
5285 OUTB (nc_dmode , np->rv_dmode); /* Burst length, dma mode */ in ncr_init()
5286 OUTB (nc_ctest5, np->rv_ctest5); /* Large fifo + large burst */ in ncr_init()
5288 OUTB (nc_dcntl , NOCOM|np->rv_dcntl); /* Protect SFBR */ in ncr_init()
5289 OUTB (nc_ctest0, np->rv_ctest0); /* 720: CDIS and EHP */ in ncr_init()
5290 OUTB (nc_ctest3, np->rv_ctest3); /* Write and invalidate */ in ncr_init()
5291 OUTB (nc_ctest4, np->rv_ctest4); /* Master parity checking */ in ncr_init()
5293 OUTB (nc_stest2, EXT|np->rv_stest2); /* Extended Sreq/Sack filtering */ in ncr_init()
5301 np->disc = 0; in ncr_init()
5307 if (np->features & FE_LED0) { in ncr_init()
5326 struct tcb *tp = &np->target[i]; in ncr_init()
5329 tp->wval = np->rv_scntl3; in ncr_init()
5332 if (tp->usrsync <= np->maxsync) { in ncr_init()
5333 if (tp->usrsync < np->minsync) { in ncr_init()
5334 tp->usrsync = np->minsync; in ncr_init()
5341 if (tp->usrwide > np->maxwide) in ncr_init()
5342 tp->usrwide = np->maxwide; in ncr_init()
5349 if (np->paddr2) { in ncr_init()
5352 ncr_name(np)); in ncr_init()
5353 OUTL (nc_scratcha, vtobus(np->script0)); in ncr_init()
5354 OUTL_DSP (NCB_SCRIPTH_PHYS (np, start_ram)); in ncr_init()
5357 OUTL_DSP (NCB_SCRIPT_PHYS (np, start)); in ncr_init()
5368 static void ncr_negotiate (struct ncb* np, struct tcb* tp) in ncr_negotiate() argument
5380 if (np->scsi_mode && np->scsi_mode == SMODE_SE) { in ncr_negotiate()
5388 if (minsync < np->minsync) in ncr_negotiate()
5389 minsync = np->minsync; in ncr_negotiate()
5395 if (minsync > np->maxsync) in ncr_negotiate()
5398 if (tp->maxoffs > np->maxoffs) in ncr_negotiate()
5399 tp->maxoffs = np->maxoffs; in ncr_negotiate()
5426 static void ncr_getsync(struct ncb *np, u_char sfac, u_char *fakp, u_char *scntl3p) in ncr_getsync() argument
5428 u_long clk = np->clock_khz; /* SCSI clock frequency in kHz */ in ncr_getsync()
5429 int div = np->clock_divn; /* Number of divisors supported */ in ncr_getsync()
5495 static void ncr_set_sync_wide_status (struct ncb *np, u_char target) in ncr_set_sync_wide_status() argument
5498 struct tcb *tp = &np->target[target]; in ncr_set_sync_wide_status()
5504 np->sync_st = tp->sval; in ncr_set_sync_wide_status()
5506 np->wide_st = tp->wval; in ncr_set_sync_wide_status()
5511 for (cp = np->ccb; cp; cp = cp->link_ccb) { in ncr_set_sync_wide_status()
5530 static void ncr_setsync (struct ncb *np, struct ccb *cp, u_char scntl3, u_char sxfer) in ncr_setsync() argument
5539 tp = &np->target[target]; in ncr_setsync()
5542 scntl3 = np->rv_scntl3; in ncr_setsync()
5543 scntl3 = (scntl3 & 0xf0) | (tp->wval & EWS) | (np->rv_scntl3 & 0x07); in ncr_setsync()
5552 tp->period = (((sxfer>>5)+4)*div_10M[idiv-1])/np->clock_khz; in ncr_setsync()
5574 ncr_set_sync_wide_status(np, target); in ncr_setsync()
5587 static void ncr_setwide (struct ncb *np, struct ccb *cp, u_char wide, u_char ack) in ncr_setwide() argument
5597 tp = &np->target[target]; in ncr_setwide()
5622 ncr_set_sync_wide_status(np, target); in ncr_setwide()
5632 static void ncr_setup_tags (struct ncb *np, struct scsi_device *sdev) in ncr_setup_tags() argument
5635 struct tcb *tp = &np->target[tn]; in ncr_setup_tags()
5703 cpu_to_scr(NCB_SCRIPT_PHYS(np, resel_tag)) : in ncr_setup_tags()
5704 cpu_to_scr(NCB_SCRIPT_PHYS(np, resel_notag)); in ncr_setup_tags()
5735 static void ncr_timeout (struct ncb *np) in ncr_timeout() argument
5745 if (np->release_stage) { in ncr_timeout()
5746 if (np->release_stage == 1) np->release_stage = 2; in ncr_timeout()
5750 np->timer.expires = jiffies + SCSI_NCR_TIMER_INTERVAL; in ncr_timeout()
5751 add_timer(&np->timer); in ncr_timeout()
5757 if (np->settle_time) { in ncr_timeout()
5758 if (np->settle_time <= thistime) { in ncr_timeout()
5760 printk("%s: command processing resumed\n", ncr_name(np)); in ncr_timeout()
5761 np->settle_time = 0; in ncr_timeout()
5762 np->disc = 1; in ncr_timeout()
5763 requeue_waiting_list(np); in ncr_timeout()
5773 if (np->lasttime + 4*HZ < thistime) { in ncr_timeout()
5777 np->lasttime = thistime; in ncr_timeout()
5787 ncr_exception (np); in ncr_timeout()
5823 static void ncr_log_hard_error(struct ncb *np, u16 sist, u_char dstat) in ncr_log_hard_error() argument
5834 if (dsp > np->p_script && dsp <= np->p_script + sizeof(struct script)) { in ncr_log_hard_error()
5835 script_ofs = dsp - np->p_script; in ncr_log_hard_error()
5837 script_base = (u_char *) np->script0; in ncr_log_hard_error()
5840 else if (np->p_scripth < dsp && in ncr_log_hard_error()
5841 dsp <= np->p_scripth + sizeof(struct scripth)) { in ncr_log_hard_error()
5842 script_ofs = dsp - np->p_scripth; in ncr_log_hard_error()
5844 script_base = (u_char *) np->scripth0; in ncr_log_hard_error()
5854 ncr_name (np), (unsigned)INB (nc_sdid)&0x0f, dstat, sist, in ncr_log_hard_error()
5861 printk ("%s: script cmd = %08x\n", ncr_name(np), in ncr_log_hard_error()
5865 printk ("%s: regdump:", ncr_name(np)); in ncr_log_hard_error()
5903 void ncr_exception (struct ncb *np) in ncr_exception() argument
5921 ncr_wakeup_done (np); in ncr_exception()
5960 if ((sist & SBMC) && ncr_int_sbmc (np)) in ncr_exception()
5962 if ((sist & PAR) && ncr_int_par (np)) in ncr_exception()
5965 ncr_int_ma (np); in ncr_exception()
5969 ncr_int_sir (np); in ncr_exception()
5978 ncr_name(np), istat, dstat, sist); in ncr_exception()
6001 ncr_init (np, 1, bootverbose ? "scsi reset" : NULL, HS_RESET); in ncr_exception()
6012 ncr_int_sto (np); in ncr_exception()
6029 if (time_after(jiffies, np->regtime)) { in ncr_exception()
6030 np->regtime = jiffies + 10*HZ; in ncr_exception()
6031 for (i = 0; i<sizeof(np->regdump); i++) in ncr_exception()
6032 ((char*)&np->regdump)[i] = INB_OFF(i); in ncr_exception()
6033 np->regdump.nc_dstat = dstat; in ncr_exception()
6034 np->regdump.nc_sist = sist; in ncr_exception()
6037 ncr_log_hard_error(np, sist, dstat); in ncr_exception()
6039 printk ("%s: have to clear fifos.\n", ncr_name (np)); in ncr_exception()
6045 ncr_start_reset(np); in ncr_exception()
6050 printk ("%s: handshake timeout\n", ncr_name(np)); in ncr_exception()
6051 ncr_start_reset(np); in ncr_exception()
6056 printk ("%s: unexpected disconnect\n", ncr_name(np)); in ncr_exception()
6058 OUTL_DSP (NCB_SCRIPT_PHYS (np, cleanup)); in ncr_exception()
6067 printk ("%s: unknown interrupt\n", ncr_name(np)); in ncr_exception()
6086 void ncr_int_sto (struct ncb *np) in ncr_int_sto() argument
6097 cp = np->ccb; in ncr_int_sto()
6103 ncr_complete (np, cp); in ncr_int_sto()
6110 OUTL_DSP (NCB_SCRIPTH_PHYS (np, sto_restart)); in ncr_int_sto()
6131 static int ncr_int_sbmc (struct ncb *np) in ncr_int_sbmc() argument
6135 if (scsi_mode != np->scsi_mode) { in ncr_int_sbmc()
6137 ncr_name(np), np->scsi_mode, scsi_mode); in ncr_int_sbmc()
6139 np->scsi_mode = scsi_mode; in ncr_int_sbmc()
6146 np->settle_time = jiffies + HZ; in ncr_int_sbmc()
6147 ncr_init (np, 0, bootverbose ? "scsi mode change" : NULL, HS_RESET); in ncr_int_sbmc()
6163 static int ncr_int_par (struct ncb *np) in ncr_int_par() argument
6173 ncr_name(np), hsts, dbc, sstat1); in ncr_int_par()
6213 jmp = NCB_SCRIPTH_PHYS (np, par_err_data_in); in ncr_int_par()
6215 jmp = NCB_SCRIPTH_PHYS (np, par_err_other); in ncr_int_par()
6220 np->msgout[0] = msg; in ncr_int_par()
6225 ncr_start_reset(np); in ncr_int_par()
6243 static void ncr_int_ma (struct ncb *np) in ncr_int_ma() argument
6274 ctest5 = (np->rv_ctest5 & DFS) ? INB (nc_ctest5) : 0; in ncr_int_ma()
6319 cp = np->header.cp; in ncr_int_ma()
6323 cp = np->ccb; in ncr_int_ma()
6334 if (dsp > np->p_script && in ncr_int_ma()
6335 dsp <= np->p_script + sizeof(struct script)) { in ncr_int_ma()
6336 vdsp = (u32 *)((char*)np->script0 + (dsp-np->p_script-8)); in ncr_int_ma()
6339 else if (dsp > np->p_scripth && in ncr_int_ma()
6340 dsp <= np->p_scripth + sizeof(struct scripth)) { in ncr_int_ma()
6341 vdsp = (u32 *)((char*)np->scripth0 + (dsp-np->p_scripth-8)); in ncr_int_ma()
6361 cp, np->header.cp, in ncr_int_ma()
6375 ncr_name (np), (u_long) np->header.cp); in ncr_int_ma()
6419 if (cp != np->header.cp) { in ncr_int_ma()
6422 ncr_name (np), (u_long) cp, (u_long) np->header.cp); in ncr_int_ma()
6470 OUTL_DSP (NCB_SCRIPT_PHYS (np, dispatch)); in ncr_int_ma()
6506 nxtdsp = NCB_SCRIPT_PHYS (np, dispatch); in ncr_int_ma()
6510 nxtdsp = NCB_SCRIPT_PHYS (np, dispatch); in ncr_int_ma()
6514 np->scripth->nxtdsp_go_on[0] = cpu_to_scr(dsp + 8); in ncr_int_ma()
6515 if (dsp == NCB_SCRIPT_PHYS (np, send_ident)) { in ncr_int_ma()
6517 nxtdsp = NCB_SCRIPTH_PHYS (np, clratn_go_on); in ncr_int_ma()
6519 else if (dsp == NCB_SCRIPTH_PHYS (np, send_wdtr) || in ncr_int_ma()
6520 dsp == NCB_SCRIPTH_PHYS (np, send_sdtr)) { in ncr_int_ma()
6521 nxtdsp = NCB_SCRIPTH_PHYS (np, nego_bad_phase); in ncr_int_ma()
6526 nxtdsp = NCB_SCRIPT_PHYS (np, clrack); in ncr_int_ma()
6537 ncr_start_reset(np); in ncr_int_ma()
6541 static void ncr_sir_to_redo(struct ncb *np, int num, struct ccb *cp) in ncr_sir_to_redo() argument
6544 struct tcb *tp = &np->target[cmd->device->id]; in ncr_sir_to_redo()
6568 cpu_to_scr(NCB_SCRIPTH_PHYS (np, skip)); in ncr_sir_to_redo()
6590 ncr_setup_tags (np, cmd->device); in ncr_sir_to_redo()
6602 ncr_put_start_queue(np, cp); in ncr_sir_to_redo()
6605 OUTL_DSP (NCB_SCRIPT_PHYS (np, reselect)); in ncr_sir_to_redo()
6649 startp = cpu_to_scr(NCB_SCRIPTH_PHYS (np, sdata_in)); in ncr_sir_to_redo()
6662 cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); in ncr_sir_to_redo()
6669 cpu_to_scr(NCB_SCRIPTH_PHYS (np, select_no_atn)); in ncr_sir_to_redo()
6671 ncr_put_start_queue(np, cp); in ncr_sir_to_redo()
6673 OUTL_DSP (NCB_SCRIPT_PHYS (np, start)); in ncr_sir_to_redo()
6692 void ncr_int_sir (struct ncb *np) in ncr_int_sir() argument
6700 struct tcb *tp = &np->target[target]; in ncr_int_sir()
6711 ncr_wakeup_done(np); in ncr_int_sir()
6713 OUTL(nc_dsp, NCB_SCRIPT_PHYS (np, done_end) + 8); in ncr_int_sir()
6715 OUTL(nc_dsp, NCB_SCRIPT_PHYS (np, start)); in ncr_int_sir()
6735 ncr_name (np), target, num); in ncr_int_sir()
6740 ncr_name (np), target, num); in ncr_int_sir()
6743 cp = np->header.cp; in ncr_int_sir()
6746 ncr_sir_to_redo(np, num, cp); in ncr_int_sir()
6752 cp = np->ccb; in ncr_int_sir()
6757 BUG_ON(cp != np->header.cp); in ncr_int_sir()
6759 if (!cp || cp != np->header.cp) in ncr_int_sir()
6861 ncr_setsync (np, cp, 0, 0xe0); in ncr_int_sir()
6866 ncr_setwide (np, cp, 0, 0); in ncr_int_sir()
6870 np->msgin [0] = NOP; in ncr_int_sir()
6871 np->msgout[0] = NOP; in ncr_int_sir()
6877 ncr_print_msg(cp, "sync msgin", np->msgin); in ncr_int_sir()
6881 per = np->msgin[3]; in ncr_int_sir()
6882 ofs = np->msgin[4]; in ncr_int_sir()
6897 if (per < np->minsync) in ncr_int_sir()
6898 {chg = 1; per = np->minsync;} in ncr_int_sir()
6910 ncr_getsync(np, per, &fak, &scntl3); in ncr_int_sir()
6938 ncr_setsync(np, cp, 0, 0xe0); in ncr_int_sir()
6939 OUTL_DSP(NCB_SCRIPT_PHYS (np, msg_bad)); in ncr_int_sir()
6944 ncr_setsync(np, cp, scntl3, (fak<<5)|ofs); in ncr_int_sir()
6945 OUTL_DSP(NCB_SCRIPT_PHYS (np, clrack)); in ncr_int_sir()
6951 ncr_setwide(np, cp, 0, 0); in ncr_int_sir()
6963 ncr_setsync(np, cp, scntl3, (fak<<5)|ofs); in ncr_int_sir()
6965 spi_populate_sync_msg(np->msgout, per, ofs); in ncr_int_sir()
6969 ncr_print_msg(cp, "sync msgout", np->msgout); in ncr_int_sir()
6973 OUTL_DSP (NCB_SCRIPT_PHYS (np, msg_bad)); in ncr_int_sir()
6976 np->msgin [0] = NOP; in ncr_int_sir()
6985 ncr_print_msg(cp, "wide msgin", np->msgin); in ncr_int_sir()
6993 wide = np->msgin[3]; in ncr_int_sir()
7026 ncr_setwide(np, cp, 0, 1); in ncr_int_sir()
7027 OUTL_DSP (NCB_SCRIPT_PHYS (np, msg_bad)); in ncr_int_sir()
7031 ncr_setwide(np, cp, wide, 1); in ncr_int_sir()
7032 OUTL_DSP (NCB_SCRIPT_PHYS (np, clrack)); in ncr_int_sir()
7039 ncr_setsync(np, cp, 0, 0xe0); in ncr_int_sir()
7050 ncr_setwide(np, cp, wide, 1); in ncr_int_sir()
7051 spi_populate_width_msg(np->msgout, wide); in ncr_int_sir()
7053 np->msgin [0] = NOP; in ncr_int_sir()
7058 ncr_print_msg(cp, "wide msgout", np->msgin); in ncr_int_sir()
7078 (unsigned)scr_to_cpu(np->lastmsg), np->msgout[0]); in ncr_int_sir()
7089 ncr_print_msg(cp, "MESSAGE_REJECT sent for", np->msgin); in ncr_int_sir()
7124 (unsigned) scr_to_cpu(np->header.savep), in ncr_int_sir()
7125 (unsigned) scr_to_cpu(np->header.goalp)); in ncr_int_sir()
7143 static struct ccb *ncr_get_ccb(struct ncb *np, struct scsi_cmnd *cmd) in ncr_get_ccb() argument
7147 struct tcb *tp = &np->target[tn]; in ncr_get_ccb()
7167 ncr_alloc_ccb(np, tn, ln); in ncr_get_ccb()
7201 cp = np->ccb; in ncr_get_ccb()
7254 static void ncr_free_ccb (struct ncb *np, struct ccb *cp) in ncr_free_ccb() argument
7256 struct tcb *tp = &np->target[cp->target]; in ncr_free_ccb()
7276 cpu_to_scr(NCB_SCRIPTH_PHYS(np, bad_i_t_l_q)); in ncr_free_ccb()
7279 cpu_to_scr(NCB_SCRIPTH_PHYS(np, bad_i_t_l)); in ncr_free_ccb()
7288 if (cp != np->ccb) in ncr_free_ccb()
7298 --np->queuedccbs; in ncr_free_ccb()
7303 if (cp == np->ccb) in ncr_free_ccb()
7309 #define ncr_reg_bus_addr(r) (np->paddr + offsetof (struct ncr_reg, r))
7316 static void ncr_init_ccb(struct ncb *np, struct ccb *cp) in ncr_init_ccb() argument
7318 ncrcmd copy_4 = np->features & FE_PFEN ? SCR_COPY(4) : SCR_COPY_F(4); in ncr_init_ccb()
7345 cp->start.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); in ncr_init_ccb()
7346 cp->restart.schedule.l_paddr = cpu_to_scr(NCB_SCRIPTH_PHYS (np, abort)); in ncr_init_ccb()
7355 static void ncr_alloc_ccb(struct ncb *np, u_char tn, u_char ln) in ncr_alloc_ccb() argument
7357 struct tcb *tp = &np->target[tn]; in ncr_alloc_ccb()
7372 np->actccbs++; in ncr_alloc_ccb()
7374 ncr_init_ccb(np, cp); in ncr_alloc_ccb()
7380 cp->link_ccb = np->ccb->link_ccb; in ncr_alloc_ccb()
7381 np->ccb->link_ccb = cp; in ncr_alloc_ccb()
7404 static void ncr_init_tcb (struct ncb *np, u_char tn) in ncr_init_tcb() argument
7406 struct tcb *tp = &np->target[tn]; in ncr_init_tcb()
7407 ncrcmd copy_1 = np->features & FE_PFEN ? SCR_COPY(1) : SCR_COPY_F(1); in ncr_init_tcb()
7417 tp->jump_tcb.l_paddr = np->jump_tcb[th].l_paddr; in ncr_init_tcb()
7448 tp->call_lun.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_lun)); in ncr_init_tcb()
7459 cpu_to_scr(NCB_SCRIPTH_PHYS (np, bad_identify)); in ncr_init_tcb()
7465 np->jump_tcb[th].l_paddr = cpu_to_scr(vtobus (&tp->jump_tcb)); in ncr_init_tcb()
7491 static struct lcb *ncr_alloc_lcb (struct ncb *np, u_char tn, u_char ln) in ncr_alloc_lcb() argument
7493 struct tcb *tp = &np->target[tn]; in ncr_alloc_lcb()
7495 ncrcmd copy_4 = np->features & FE_PFEN ? SCR_COPY(4) : SCR_COPY_F(4); in ncr_alloc_lcb()
7517 ncr_init_tcb(np, tn); in ncr_alloc_lcb()
7555 lp->jump_tag.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_notag)); in ncr_alloc_lcb()
7581 static struct lcb *ncr_setup_lcb (struct ncb *np, struct scsi_device *sdev) in ncr_setup_lcb() argument
7584 struct tcb *tp = &np->target[tn]; in ncr_setup_lcb()
7588 if (!lp && !(lp = ncr_alloc_lcb(np, tn, ln))) in ncr_setup_lcb()
7605 cpu_to_scr(NCB_SCRIPTH_PHYS (np, bad_i_t_l_q)); in ncr_setup_lcb()
7610 ncr_setup_tags (np, sdev); in ncr_setup_lcb()
7647 static int ncr_scatter(struct ncb *np, struct ccb *cp, struct scsi_cmnd *cmd) in ncr_scatter() argument
7654 use_sg = map_scsi_sg_data(np, cmd); in ncr_scatter()
7660 unmap_scsi_data(np, cmd); in ncr_scatter()
7670 ncr_build_sge(np, &data[segment], baddr, len); in ncr_scatter()
7690 static int __init ncr_regtest (struct ncb* np) argument
7713 static int __init ncr_snooptest (struct ncb* np) argument
7717 if (np->reg) {
7718 err |= ncr_regtest (np);
7724 pc = NCB_SCRIPTH_PHYS (np, snooptest);
7730 np->ncr_cache = cpu_to_scr(host_wr);
7749 host_rd = scr_to_cpu(np->ncr_cache);
7755 ncr_chip_reset(np, 100);
7766 if (pc != NCB_SCRIPTH_PHYS (np, snoopend)+8) {
7769 (u_long) NCB_SCRIPTH_PHYS (np, snooptest), (u_long) pc,
7770 (u_long) NCB_SCRIPTH_PHYS (np, snoopend) +8);
7820 static void ncr_selectclock(struct ncb *np, u_char scntl3) argument
7822 if (np->multiplier < 2) {
7828 printk ("%s: enabling clock multiplier\n", ncr_name(np));
7831 if (np->multiplier > 2) { /* Poll bit 5 of stest4 for quadrupler */
7836 printk("%s: the chip cannot lock the frequency\n", ncr_name(np));
7849 static unsigned __init ncrgetfreq (struct ncb *np, int gen) argument
7890 printk ("%s: Delay (GEN=%d): %u msec\n", ncr_name(np), gen, ms);
7900 static void __init ncr_getclock (struct ncb *np, int mult) argument
7906 np->multiplier = 1;
7914 printk ("%s: clock multiplier found\n", ncr_name(np));
7915 np->multiplier = mult;
7923 if (np->multiplier != mult || (scntl3 & 7) < 3 || !(scntl3 & 1)) {
7926 ncr_chip_reset(np, 5);
7928 (void) ncrgetfreq (np, 11); /* throw away first result */
7929 f1 = ncrgetfreq (np, 11);
7930 f2 = ncrgetfreq (np, 11);
7933 printk ("%s: NCR clock is %uKHz, %uKHz\n", ncr_name(np), f1, f2);
7943 printk ("%s: clock multiplier assumed\n", ncr_name(np));
7944 np->multiplier = mult;
7951 f1 /= np->multiplier;
7957 f1 *= np->multiplier;
7958 np->clock_khz = f1;
7966 struct ncb *np = ((struct host_data *) host->hostdata)->ncb; local
7967 struct tcb *tp = &np->target[device->id];
7976 struct ncb *np = ((struct host_data *) host->hostdata)->ncb; local
7977 struct tcb *tp = &np->target[device->id];
7981 ncr_setup_lcb(np, device);
7989 numtags = device_queue_depth(np->unit, device->id, device->lun);
8015 ncr_setup_tags (np, device);
8019 np->unit, device->id, device->lun, depth_to_use);
8030 struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb; local
8043 spin_lock_irqsave(&np->smp_lock, flags);
8045 if ((sts = ncr_queue_command(np, cmd)) != DID_OK) {
8056 spin_unlock_irqrestore(&np->smp_lock, flags);
8059 unmap_scsi_data(np, cmd);
8074 struct ncb *np = host_data->ncb; local
8083 spin_lock_irqsave(&np->smp_lock, flags);
8084 ncr_exception(np);
8085 done_list = np->done_list;
8086 np->done_list = NULL;
8087 spin_unlock_irqrestore(&np->smp_lock, flags);
8098 struct ncb *np = (struct ncb *) npref; local
8102 spin_lock_irqsave(&np->smp_lock, flags);
8103 ncr_timeout(np);
8104 done_list = np->done_list;
8105 np->done_list = NULL;
8106 spin_unlock_irqrestore(&np->smp_lock, flags);
8114 struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb; local
8126 spin_lock_irqsave(&np->smp_lock, flags);
8127 sts = ncr_reset_bus(np, cmd, 1);
8129 done_list = np->done_list;
8130 np->done_list = NULL;
8131 spin_unlock_irqrestore(&np->smp_lock, flags);
8141 struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
8148 NCR_LOCK_NCB(np, flags);
8150 sts = ncr_abort_command(np, cmd);
8152 done_list = np->done_list;
8153 np->done_list = NULL;
8154 NCR_UNLOCK_NCB(np, flags);
8178 static void insert_into_waiting_list(struct ncb *np, struct scsi_cmnd *cmd) argument
8183 printk("%s: cmd %lx inserted into waiting list\n", ncr_name(np), (u_long) cmd);
8186 if (!(wcmd = np->waiting_list)) np->waiting_list = cmd;
8194 static struct scsi_cmnd *retrieve_from_waiting_list(int to_remove, struct ncb *np, struct scsi_cmnd… argument
8196 struct scsi_cmnd **pcmd = &np->waiting_list;
8205 printk("%s: cmd %lx retrieved from waiting list\n", ncr_name(np), (u_long) cmd);
8214 static void process_waiting_list(struct ncb *np, int sts) argument
8218 waiting_list = np->waiting_list;
8219 np->waiting_list = NULL;
8222 …if (waiting_list) printk("%s: waiting_list=%lx processing sts=%d\n", ncr_name(np), (u_long) waitin…
8229 printk("%s: cmd %lx trying to requeue\n", ncr_name(np), (u_long) wcmd);
8231 sts = ncr_queue_command(np, wcmd);
8235 printk("%s: cmd %lx done forced sts=%d\n", ncr_name(np), (u_long) wcmd, sts);
8238 ncr_queue_done_cmd(np, wcmd);
8298 struct ncb *np = NULL; local
8329 np = __m_calloc_dma(device->dev, sizeof(struct ncb), "NCB");
8330 if (!np)
8332 spin_lock_init(&np->smp_lock);
8333 np->dev = device->dev;
8334 np->p_ncb = vtobus(np);
8335 host_data->ncb = np;
8337 np->ccb = m_calloc_dma(sizeof(struct ccb), "CCB");
8338 if (!np->ccb)
8342 np->unit = unit;
8343 np->verbose = driver_setup.verbose;
8344 sprintf(np->inst_name, "ncr53c720-%d", np->unit);
8345 np->revision_id = device->chip.revision_id;
8346 np->features = device->chip.features;
8347 np->clock_divn = device->chip.nr_divisor;
8348 np->maxoffs = device->chip.offset_max;
8349 np->maxburst = device->chip.burst_max;
8350 np->myaddr = device->host_id;
8353 np->script0 = m_calloc_dma(sizeof(struct script), "SCRIPT");
8354 if (!np->script0)
8356 np->scripth0 = m_calloc_dma(sizeof(struct scripth), "SCRIPTH");
8357 if (!np->scripth0)
8360 init_timer(&np->timer);
8361 np->timer.data = (unsigned long) np;
8362 np->timer.function = ncr53c8xx_timeout;
8366 np->paddr = device->slot.base;
8367 np->paddr2 = (np->features & FE_RAM) ? device->slot.base_2 : 0;
8370 np->vaddr = device->slot.base_v;
8372 np->vaddr = ioremap(device->slot.base_c, 128);
8374 if (!np->vaddr) {
8376 "%s: can't map memory mapped IO region\n",ncr_name(np));
8381 "%s: using memory mapped IO at virtual address 0x%lx\n", ncr_name(np), (u_long) np->vaddr);
8388 np->reg = (struct ncr_reg __iomem *)np->vaddr;
8391 ncr_prepare_setting(np);
8393 if (np->paddr2 && sizeof(struct script) > 4096) {
8394 np->paddr2 = 0;
8396 ncr_name(np));
8400 instance->this_id = np->myaddr;
8401 instance->max_id = np->maxwide ? 16 : 8;
8403 instance->base = (unsigned long) np->reg;
8417 np->scripth = np->scripth0;
8418 np->p_scripth = vtobus(np->scripth);
8419 np->p_script = (np->paddr2) ? np->paddr2 : vtobus(np->script0);
8421 ncr_script_copy_and_bind(np, (ncrcmd *) &script0,
8422 (ncrcmd *) np->script0, sizeof(struct script));
8423 ncr_script_copy_and_bind(np, (ncrcmd *) &scripth0,
8424 (ncrcmd *) np->scripth0, sizeof(struct scripth));
8425 np->ccb->p_ccb = vtobus (np->ccb);
8429 if (np->features & FE_LED0) {
8430 np->script0->idle[0] =
8432 np->script0->reselected[0] =
8434 np->script0->start[0] =
8444 np->jump_tcb[i].l_cmd =
8446 np->jump_tcb[i].l_paddr =
8447 cpu_to_scr(NCB_SCRIPTH_PHYS (np, bad_target));
8450 ncr_chip_reset(np, 100);
8454 if (ncr_snooptest(np)) {
8460 np->irq = device->slot.irq;
8463 ncr_init_ccb(np, np->ccb);
8471 spin_lock_irqsave(&np->smp_lock, flags);
8472 if (ncr_reset_scsi_bus(np, 0, driver_setup.settle_delay) != 0) {
8473 …N_ERR "%s: FATAL ERROR: CHECK SCSI BUS - CABLES, TERMINATION, DEVICE POWER etc.!\n", ncr_name(np));
8475 spin_unlock_irqrestore(&np->smp_lock, flags);
8478 ncr_exception(np);
8480 np->disc = 1;
8488 ncr_name(np), driver_setup.settle_delay);
8493 np->lasttime=0;
8494 ncr_timeout (np);
8498 np->order = SIMPLE_QUEUE_TAG;
8501 spin_unlock_irqrestore(&np->smp_lock, flags);
8508 printk(KERN_INFO "%s: detaching...\n", ncr_name(np));
8509 if (!np)
8511 if (np->scripth0)
8512 m_free_dma(np->scripth0, sizeof(struct scripth), "SCRIPTH");
8513 if (np->script0)
8514 m_free_dma(np->script0, sizeof(struct script), "SCRIPT");
8515 if (np->ccb)
8516 m_free_dma(np->ccb, sizeof(struct ccb), "CCB");
8517 m_free_dma(np, sizeof(struct ncb), "NCB");
8541 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb; local
8542 struct tcb *tp = &np->target[starget->id];
8544 if (period > np->maxsync)
8545 period = np->maxsync;
8546 else if (period < np->minsync)
8547 period = np->minsync;
8551 ncr_negotiate(np, tp);
8557 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb; local
8558 struct tcb *tp = &np->target[starget->id];
8560 if (offset > np->maxoffs)
8561 offset = np->maxoffs;
8567 ncr_negotiate(np, tp);
8573 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb; local
8574 struct tcb *tp = &np->target[starget->id];
8576 if (width > np->maxwide)
8577 width = np->maxwide;
8583 ncr_negotiate(np, tp);
8588 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb; local
8591 switch (np->scsi_mode) {