• Home
  • Raw
  • Download

Lines Matching refs:np

501 #define _m_calloc_dma(np, s, n)		__m_calloc_dma(np->dev, s, n)  argument
502 #define _m_free_dma(np, p, s, n) __m_free_dma(np->dev, p, s, n) argument
503 #define m_calloc_dma(s, n) _m_calloc_dma(np, s, n)
504 #define m_free_dma(p, s, n) _m_free_dma(np, p, s, n)
505 #define _vtobus(np, p) __vtobus(np->dev, p) argument
506 #define vtobus(p) _vtobus(np, p)
540 #define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd) argument
541 #define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd) argument
564 #define bootverbose (np->verbose)
1004 #define bootverbose (np->verbose)
1749 #define NCB_SCRIPT_PHYS(np,lbl) (np->p_script + offsetof (struct script, lbl)) argument
1750 #define NCB_SCRIPTH_PHYS(np,lbl) (np->p_scripth + offsetof (struct scripth,lbl)) argument
1907 static void ncr_alloc_ccb (struct ncb *np, u_char tn, u_char ln);
1908 static void ncr_complete (struct ncb *np, struct ccb *cp);
1909 static void ncr_exception (struct ncb *np);
1910 static void ncr_free_ccb (struct ncb *np, struct ccb *cp);
1911 static void ncr_init_ccb (struct ncb *np, struct ccb *cp);
1912 static void ncr_init_tcb (struct ncb *np, u_char tn);
1913 static struct lcb * ncr_alloc_lcb (struct ncb *np, u_char tn, u_char ln);
1914 static struct lcb * ncr_setup_lcb (struct ncb *np, struct scsi_device *sdev);
1915 static void ncr_getclock (struct ncb *np, int mult);
1916 static void ncr_selectclock (struct ncb *np, u_char scntl3);
1917 static struct ccb *ncr_get_ccb (struct ncb *np, struct scsi_cmnd *cmd);
1918 static void ncr_chip_reset (struct ncb *np, int delay);
1919 static void ncr_init (struct ncb *np, int reset, char * msg, u_long code);
1920 static int ncr_int_sbmc (struct ncb *np);
1921 static int ncr_int_par (struct ncb *np);
1922 static void ncr_int_ma (struct ncb *np);
1923 static void ncr_int_sir (struct ncb *np);
1924 static void ncr_int_sto (struct ncb *np);
1925 static void ncr_negotiate (struct ncb* np, struct tcb* tp);
1926 static int ncr_prepare_nego(struct ncb *np, struct ccb *cp, u_char *msgptr);
1929 (struct ncb *np, ncrcmd *src, ncrcmd *dst, int len);
1931 static int ncr_scatter (struct ncb *np, struct ccb *cp, struct scsi_cmnd *cmd);
1932 static void ncr_getsync (struct ncb *np, u_char sfac, u_char *fakp, u_char *scntl3p);
1933 static void ncr_setsync (struct ncb *np, struct ccb *cp, u_char scntl3, u_char sxfer);
1934 static void ncr_setup_tags (struct ncb *np, struct scsi_device *sdev);
1935 static void ncr_setwide (struct ncb *np, struct ccb *cp, u_char wide, u_char ack);
1936 static int ncr_snooptest (struct ncb *np);
1937 static void ncr_timeout (struct ncb *np);
1938 static void ncr_wakeup (struct ncb *np, u_long code);
1939 static void ncr_wakeup_done (struct ncb *np);
1940 static void ncr_start_next_ccb (struct ncb *np, struct lcb * lp, int maxn);
1941 static void ncr_put_start_queue(struct ncb *np, struct ccb *cp);
1943 static void insert_into_waiting_list(struct ncb *np, struct scsi_cmnd *cmd);
1944 static struct scsi_cmnd *retrieve_from_waiting_list(int to_remove, struct ncb *np, struct scsi_cmnd…
1945 static void process_waiting_list(struct ncb *np, int sts);
1947 #define remove_from_waiting_list(np, cmd) \ argument
1948 retrieve_from_waiting_list(1, (np), (cmd))
1949 #define requeue_waiting_list(np) process_waiting_list((np), DID_OK) argument
1950 #define reset_waiting_list(np) process_waiting_list((np), DID_RESET) argument
1952 static inline char *ncr_name (struct ncb *np) in ncr_name() argument
1954 return np->inst_name; in ncr_name()
3512 ncr_script_copy_and_bind (struct ncb *np, ncrcmd *src, ncrcmd *dst, int len) in ncr_script_copy_and_bind() argument
3536 ncr_name(np), (int) (src-start-1)); in ncr_script_copy_and_bind()
3566 ncr_name(np), (int) (src-start-1)); in ncr_script_copy_and_bind()
3573 if ((opcode & SCR_NO_FLUSH) && !(np->features & FE_PFEN)) { in ncr_script_copy_and_bind()
3615 new = (old & ~RELOC_MASK) + np->paddr; in ncr_script_copy_and_bind()
3618 new = (old & ~RELOC_MASK) + np->p_script; in ncr_script_copy_and_bind()
3621 new = (old & ~RELOC_MASK) + np->p_scripth; in ncr_script_copy_and_bind()
3624 new = (old & ~RELOC_MASK) + np->p_ncb; in ncr_script_copy_and_bind()
3716 static inline void ncr_init_burst(struct ncb *np, u_char bc) in ncr_init_burst() argument
3718 u_char *be = &np->rv_ctest0; in ncr_init_burst()
3720 np->rv_dmode &= ~(0x3 << 6); in ncr_init_burst()
3721 np->rv_ctest5 &= ~0x4; in ncr_init_burst()
3727 np->rv_dmode |= ((bc & 0x3) << 6); in ncr_init_burst()
3728 np->rv_ctest5 |= (bc & 0x4); in ncr_init_burst()
3732 static void __init ncr_prepare_setting(struct ncb *np) in ncr_prepare_setting() argument
3742 np->sv_scntl0 = INB(nc_scntl0) & 0x0a; in ncr_prepare_setting()
3743 np->sv_scntl3 = INB(nc_scntl3) & 0x07; in ncr_prepare_setting()
3744 np->sv_dmode = INB(nc_dmode) & 0xce; in ncr_prepare_setting()
3745 np->sv_dcntl = INB(nc_dcntl) & 0xa8; in ncr_prepare_setting()
3746 np->sv_ctest0 = INB(nc_ctest0) & 0x84; in ncr_prepare_setting()
3747 np->sv_ctest3 = INB(nc_ctest3) & 0x01; in ncr_prepare_setting()
3748 np->sv_ctest4 = INB(nc_ctest4) & 0x80; in ncr_prepare_setting()
3749 np->sv_ctest5 = INB(nc_ctest5) & 0x24; in ncr_prepare_setting()
3750 np->sv_gpcntl = INB(nc_gpcntl); in ncr_prepare_setting()
3751 np->sv_stest2 = INB(nc_stest2) & 0x20; in ncr_prepare_setting()
3752 np->sv_stest4 = INB(nc_stest4); in ncr_prepare_setting()
3758 np->maxwide = (np->features & FE_WIDE)? 1 : 0; in ncr_prepare_setting()
3763 if (np->features & FE_ULTRA) in ncr_prepare_setting()
3764 np->clock_khz = 80000; in ncr_prepare_setting()
3766 np->clock_khz = 40000; in ncr_prepare_setting()
3771 if (np->features & FE_QUAD) in ncr_prepare_setting()
3772 np->multiplier = 4; in ncr_prepare_setting()
3773 else if (np->features & FE_DBLR) in ncr_prepare_setting()
3774 np->multiplier = 2; in ncr_prepare_setting()
3776 np->multiplier = 1; in ncr_prepare_setting()
3782 if (np->features & FE_VARCLK) in ncr_prepare_setting()
3783 ncr_getclock(np, np->multiplier); in ncr_prepare_setting()
3788 i = np->clock_divn - 1; in ncr_prepare_setting()
3790 if (10ul * SCSI_NCR_MIN_ASYNC * np->clock_khz > div_10M[i]) { in ncr_prepare_setting()
3795 np->rv_scntl3 = i+1; in ncr_prepare_setting()
3802 period = (4 * div_10M[0] + np->clock_khz - 1) / np->clock_khz; in ncr_prepare_setting()
3803 if (period <= 250) np->minsync = 10; in ncr_prepare_setting()
3804 else if (period <= 303) np->minsync = 11; in ncr_prepare_setting()
3805 else if (period <= 500) np->minsync = 12; in ncr_prepare_setting()
3806 else np->minsync = (period + 40 - 1) / 40; in ncr_prepare_setting()
3812 if (np->minsync < 25 && !(np->features & FE_ULTRA)) in ncr_prepare_setting()
3813 np->minsync = 25; in ncr_prepare_setting()
3819 period = (11 * div_10M[np->clock_divn - 1]) / (4 * np->clock_khz); in ncr_prepare_setting()
3820 np->maxsync = period > 2540 ? 254 : period / 10; in ncr_prepare_setting()
3826 np->rv_scntl0 = np->sv_scntl0; in ncr_prepare_setting()
3827 np->rv_dmode = np->sv_dmode; in ncr_prepare_setting()
3828 np->rv_dcntl = np->sv_dcntl; in ncr_prepare_setting()
3829 np->rv_ctest0 = np->sv_ctest0; in ncr_prepare_setting()
3830 np->rv_ctest3 = np->sv_ctest3; in ncr_prepare_setting()
3831 np->rv_ctest4 = np->sv_ctest4; in ncr_prepare_setting()
3832 np->rv_ctest5 = np->sv_ctest5; in ncr_prepare_setting()
3833 burst_max = burst_code(np->sv_dmode, np->sv_ctest0); in ncr_prepare_setting()
3841 burst_max = burst_code(np->sv_dmode, np->sv_ctest0); in ncr_prepare_setting()
3844 if (burst_max > np->maxburst) in ncr_prepare_setting()
3845 burst_max = np->maxburst; in ncr_prepare_setting()
3850 if (np->features & FE_ERL) in ncr_prepare_setting()
3851 np->rv_dmode |= ERL; /* Enable Read Line */ in ncr_prepare_setting()
3852 if (np->features & FE_BOF) in ncr_prepare_setting()
3853 np->rv_dmode |= BOF; /* Burst Opcode Fetch */ in ncr_prepare_setting()
3854 if (np->features & FE_ERMP) in ncr_prepare_setting()
3855 np->rv_dmode |= ERMP; /* Enable Read Multiple */ in ncr_prepare_setting()
3856 if (np->features & FE_PFEN) in ncr_prepare_setting()
3857 np->rv_dcntl |= PFEN; /* Prefetch Enable */ in ncr_prepare_setting()
3858 if (np->features & FE_CLSE) in ncr_prepare_setting()
3859 np->rv_dcntl |= CLSE; /* Cache Line Size Enable */ in ncr_prepare_setting()
3860 if (np->features & FE_WRIE) in ncr_prepare_setting()
3861 np->rv_ctest3 |= WRIE; /* Write and Invalidate */ in ncr_prepare_setting()
3862 if (np->features & FE_DFS) in ncr_prepare_setting()
3863 np->rv_ctest5 |= DFS; /* Dma Fifo Size */ in ncr_prepare_setting()
3864 if (np->features & FE_MUX) in ncr_prepare_setting()
3865 np->rv_ctest4 |= MUX; /* Host bus multiplex mode */ in ncr_prepare_setting()
3866 if (np->features & FE_EA) in ncr_prepare_setting()
3867 np->rv_dcntl |= EA; /* Enable ACK */ in ncr_prepare_setting()
3868 if (np->features & FE_EHP) in ncr_prepare_setting()
3869 np->rv_ctest0 |= EHP; /* Even host parity */ in ncr_prepare_setting()
3875 np->rv_ctest4 |= MPEE; /* Master parity checking */ in ncr_prepare_setting()
3877 np->rv_scntl0 |= 0x0a; /* full arb., ena parity, par->ATN */ in ncr_prepare_setting()
3882 if (np->myaddr == 255) { in ncr_prepare_setting()
3883 np->myaddr = INB(nc_scid) & 0x07; in ncr_prepare_setting()
3884 if (!np->myaddr) in ncr_prepare_setting()
3885 np->myaddr = SCSI_NCR_MYADDR; in ncr_prepare_setting()
3893 ncr_init_burst(np, burst_max); in ncr_prepare_setting()
3904 np->scsi_mode = SMODE_SE; in ncr_prepare_setting()
3905 if (np->features & FE_DIFF) { in ncr_prepare_setting()
3908 if (np->sv_scntl3) { in ncr_prepare_setting()
3909 if (np->sv_stest2 & 0x20) in ncr_prepare_setting()
3910 np->scsi_mode = SMODE_HVD; in ncr_prepare_setting()
3919 np->scsi_mode = SMODE_HVD; in ncr_prepare_setting()
3922 if (np->sv_stest2 & 0x20) in ncr_prepare_setting()
3923 np->scsi_mode = SMODE_HVD; in ncr_prepare_setting()
3929 if (np->scsi_mode == SMODE_HVD) in ncr_prepare_setting()
3930 np->rv_stest2 |= 0x20; in ncr_prepare_setting()
3940 !(np->features & FE_LEDC) && !(np->sv_gpcntl & 0x01)) in ncr_prepare_setting()
3941 np->features |= FE_LED0; in ncr_prepare_setting()
3948 np->rv_dcntl |= IRQM; in ncr_prepare_setting()
3951 np->rv_dcntl |= (np->sv_dcntl & IRQM); in ncr_prepare_setting()
3963 struct tcb *tp = &np->target[i]; in ncr_prepare_setting()
3970 np->target[i].usrflag = UF_NODISC; in ncr_prepare_setting()
3977 printk(KERN_INFO "%s: ID %d, Fast-%d%s%s\n", ncr_name(np), in ncr_prepare_setting()
3978 np->myaddr, in ncr_prepare_setting()
3979 np->minsync < 12 ? 40 : (np->minsync < 25 ? 20 : 10), in ncr_prepare_setting()
3980 (np->rv_scntl0 & 0xa) ? ", Parity Checking" : ", NO Parity", in ncr_prepare_setting()
3981 (np->rv_stest2 & 0x20) ? ", Differential" : ""); in ncr_prepare_setting()
3986 ncr_name(np), np->sv_scntl3, np->sv_dmode, np->sv_dcntl, in ncr_prepare_setting()
3987 np->sv_ctest3, np->sv_ctest4, np->sv_ctest5); in ncr_prepare_setting()
3991 ncr_name(np), np->rv_scntl3, np->rv_dmode, np->rv_dcntl, in ncr_prepare_setting()
3992 np->rv_ctest3, np->rv_ctest4, np->rv_ctest5); in ncr_prepare_setting()
3995 if (bootverbose && np->paddr2) in ncr_prepare_setting()
3997 ncr_name(np), np->paddr2); in ncr_prepare_setting()
4019 static inline void ncr_queue_done_cmd(struct ncb *np, struct scsi_cmnd *cmd) in ncr_queue_done_cmd() argument
4021 unmap_scsi_data(np, cmd); in ncr_queue_done_cmd()
4022 cmd->host_scribble = (char *) np->done_list; in ncr_queue_done_cmd()
4023 np->done_list = cmd; in ncr_queue_done_cmd()
4051 static int ncr_prepare_nego(struct ncb *np, struct ccb *cp, u_char *msgptr) in ncr_prepare_nego() argument
4053 struct tcb *tp = &np->target[cp->target]; in ncr_prepare_nego()
4110 static int ncr_queue_command (struct ncb *np, struct scsi_cmnd *cmd) in ncr_queue_command() argument
4113 struct tcb *tp = &np->target[sdev->id]; in ncr_queue_command()
4129 if ((sdev->id == np->myaddr ) || in ncr_queue_command()
4164 if (np->settle_time && cmd->request->timeout >= HZ) { in ncr_queue_command()
4166 if (time_after(np->settle_time, tlimit)) in ncr_queue_command()
4167 np->settle_time = tlimit; in ncr_queue_command()
4170 if (np->settle_time || !(cp=ncr_get_ccb (np, cmd))) { in ncr_queue_command()
4171 insert_into_waiting_list(np, cmd); in ncr_queue_command()
4186 (cp != np->ccb && np->disc && !(tp->usrflag & UF_NODISC))) in ncr_queue_command()
4194 char order = np->order; in ncr_queue_command()
4244 segments = ncr_scatter(np, cp, cp->cmd); in ncr_queue_command()
4246 ncr_free_ccb(np, cp); in ncr_queue_command()
4267 msglen += ncr_prepare_nego (np, cp, msgptr + msglen); in ncr_queue_command()
4288 goalp = NCB_SCRIPT_PHYS (np, data_out2) + 8; in ncr_queue_command()
4292 lastp = NCB_SCRIPTH_PHYS (np, hdata_out2); in ncr_queue_command()
4301 goalp = NCB_SCRIPT_PHYS (np, data_in2) + 8; in ncr_queue_command()
4305 lastp = NCB_SCRIPTH_PHYS (np, hdata_in2); in ncr_queue_command()
4311 lastp = goalp = NCB_SCRIPT_PHYS (np, no_data); in ncr_queue_command()
4324 cpu_to_scr(NCB_SCRIPTH_PHYS (np, data_io)); in ncr_queue_command()
4348 cp->start.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); in ncr_queue_command()
4349 cp->restart.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_dsa)); in ncr_queue_command()
4399 ncr_start_next_ccb(np, lp, 2); in ncr_queue_command()
4401 ncr_put_start_queue(np, cp); in ncr_queue_command()
4419 static void ncr_start_next_ccb(struct ncb *np, struct lcb *lp, int maxn) in ncr_start_next_ccb() argument
4436 ncr_put_start_queue(np, cp); in ncr_start_next_ccb()
4440 static void ncr_put_start_queue(struct ncb *np, struct ccb *cp) in ncr_put_start_queue() argument
4447 if (!np->squeueput) np->squeueput = 1; in ncr_put_start_queue()
4448 qidx = np->squeueput + 2; in ncr_put_start_queue()
4451 np->scripth->tryloop [qidx] = cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); in ncr_put_start_queue()
4453 np->scripth->tryloop [np->squeueput] = cpu_to_scr(CCB_PHYS (cp, start)); in ncr_put_start_queue()
4455 np->squeueput = qidx; in ncr_put_start_queue()
4456 ++np->queuedccbs; in ncr_put_start_queue()
4460 printk ("%s: queuepos=%d.\n", ncr_name (np), np->squeueput); in ncr_put_start_queue()
4471 static int ncr_reset_scsi_bus(struct ncb *np, int enab_int, int settle_delay) in ncr_reset_scsi_bus() argument
4476 np->settle_time = jiffies + settle_delay * HZ; in ncr_reset_scsi_bus()
4481 ncr_name(np), settle_delay); in ncr_reset_scsi_bus()
4483 ncr_chip_reset(np, 100); in ncr_reset_scsi_bus()
4511 if (!(np->features & FE_WIDE)) in ncr_reset_scsi_bus()
4516 ncr_name(np)); in ncr_reset_scsi_bus()
4519 ncr_name(np), in ncr_reset_scsi_bus()
4520 (np->features & FE_WIDE) ? "dp1,d15-8," : "", in ncr_reset_scsi_bus()
4537 static void ncr_start_reset(struct ncb *np) in ncr_start_reset() argument
4539 if (!np->settle_time) { in ncr_start_reset()
4540 ncr_reset_scsi_bus(np, 1, driver_setup.settle_delay); in ncr_start_reset()
4553 static int ncr_reset_bus (struct ncb *np, struct scsi_cmnd *cmd, int sync_reset) in ncr_reset_bus() argument
4562 if (np->settle_time) { in ncr_reset_bus()
4571 ncr_start_reset(np); in ncr_reset_bus()
4575 for (found=0, cp=np->ccb; cp; cp=cp->link_ccb) { in ncr_reset_bus()
4588 if (!found && retrieve_from_waiting_list(0, np, cmd)) in ncr_reset_bus()
4593 reset_waiting_list(np); in ncr_reset_bus()
4597 ncr_wakeup(np, HS_RESET); in ncr_reset_bus()
4604 if (!found && sync_reset && !retrieve_from_waiting_list(0, np, cmd)) { in ncr_reset_bus()
4606 ncr_queue_done_cmd(np, cmd); in ncr_reset_bus()
4622 static int ncr_abort_command (struct ncb *np, struct scsi_cmnd *cmd)
4632 if (remove_from_waiting_list(np, cmd)) {
4634 ncr_queue_done_cmd(np, cmd);
4641 for (found=0, cp=np->ccb; cp; cp=cp->link_ccb) {
4656 if (np->settle_time) {
4668 printk ("%s: abort ccb=%p (cancel)\n", ncr_name (np), cp);
4670 cpu_to_scr(NCB_SCRIPTH_PHYS (np, cancel));
4675 cpu_to_scr(NCB_SCRIPTH_PHYS (np, abort));
4695 static void ncr_detach(struct ncb *np) in ncr_detach() argument
4705 strlcpy(inst_name, ncr_name(np), sizeof(inst_name)); in ncr_detach()
4707 printk("%s: releasing host resources\n", ncr_name(np)); in ncr_detach()
4715 printk("%s: stopping the timer\n", ncr_name(np)); in ncr_detach()
4717 np->release_stage = 1; in ncr_detach()
4718 for (i = 50 ; i && np->release_stage != 2 ; i--) in ncr_detach()
4720 if (np->release_stage != 2) in ncr_detach()
4721 printk("%s: the timer seems to be already stopped\n", ncr_name(np)); in ncr_detach()
4722 else np->release_stage = 2; in ncr_detach()
4729 printk("%s: disabling chip interrupts\n", ncr_name(np)); in ncr_detach()
4739 printk("%s: resetting chip\n", ncr_name(np)); in ncr_detach()
4740 ncr_chip_reset(np, 100); in ncr_detach()
4742 OUTB(nc_dmode, np->sv_dmode); in ncr_detach()
4743 OUTB(nc_dcntl, np->sv_dcntl); in ncr_detach()
4744 OUTB(nc_ctest0, np->sv_ctest0); in ncr_detach()
4745 OUTB(nc_ctest3, np->sv_ctest3); in ncr_detach()
4746 OUTB(nc_ctest4, np->sv_ctest4); in ncr_detach()
4747 OUTB(nc_ctest5, np->sv_ctest5); in ncr_detach()
4748 OUTB(nc_gpcntl, np->sv_gpcntl); in ncr_detach()
4749 OUTB(nc_stest2, np->sv_stest2); in ncr_detach()
4751 ncr_selectclock(np, np->sv_scntl3); in ncr_detach()
4757 while ((cp=np->ccb->link_ccb) != NULL) { in ncr_detach()
4758 np->ccb->link_ccb = cp->link_ccb; in ncr_detach()
4761 ncr_name(np), cp->host_status); in ncr_detach()
4764 printk("%s: freeing ccb (%lx)\n", ncr_name(np), (u_long) cp); in ncr_detach()
4772 tp=&np->target[target]; in ncr_detach()
4777 printk("%s: freeing lp (%lx)\n", ncr_name(np), (u_long) lp); in ncr_detach()
4786 if (np->scripth0) in ncr_detach()
4787 m_free_dma(np->scripth0, sizeof(struct scripth), "SCRIPTH"); in ncr_detach()
4788 if (np->script0) in ncr_detach()
4789 m_free_dma(np->script0, sizeof(struct script), "SCRIPT"); in ncr_detach()
4790 if (np->ccb) in ncr_detach()
4791 m_free_dma(np->ccb, sizeof(struct ccb), "CCB"); in ncr_detach()
4792 m_free_dma(np, sizeof(struct ncb), "NCB"); in ncr_detach()
4807 void ncr_complete (struct ncb *np, struct ccb *cp) in ncr_complete() argument
4834 tp = &np->target[cmd->device->id]; in ncr_complete()
4929 ncr_alloc_lcb (np, cmd->device->id, cmd->device->lun); in ncr_complete()
4943 ncr_setup_tags (np, cmd->device); in ncr_complete()
5049 ncr_free_ccb (np, cp); in ncr_complete()
5056 ncr_start_next_ccb(np, lp, 2); in ncr_complete()
5061 if (np->waiting_list) in ncr_complete()
5062 requeue_waiting_list(np); in ncr_complete()
5067 ncr_queue_done_cmd(np, cmd); in ncr_complete()
5083 static void ncr_ccb_skipped(struct ncb *np, struct ccb *cp) in ncr_ccb_skipped() argument
5085 struct tcb *tp = &np->target[cp->target]; in ncr_ccb_skipped()
5088 if (lp && cp != np->ccb) { in ncr_ccb_skipped()
5091 cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); in ncr_ccb_skipped()
5098 --np->queuedccbs; in ncr_ccb_skipped()
5107 void ncr_wakeup_done (struct ncb *np) in ncr_wakeup_done() argument
5113 i = np->ccb_done_ic; in ncr_wakeup_done()
5119 cp = np->ccb_done[j]; in ncr_wakeup_done()
5123 np->ccb_done[j] = (struct ccb *)CCB_DONE_EMPTY; in ncr_wakeup_done()
5124 np->scripth->done_queue[5*j + 4] = in ncr_wakeup_done()
5125 cpu_to_scr(NCB_SCRIPT_PHYS (np, done_plug)); in ncr_wakeup_done()
5127 np->scripth->done_queue[5*i + 4] = in ncr_wakeup_done()
5128 cpu_to_scr(NCB_SCRIPT_PHYS (np, done_end)); in ncr_wakeup_done()
5131 ncr_complete (np, cp); in ncr_wakeup_done()
5133 ncr_ccb_skipped (np, cp); in ncr_wakeup_done()
5137 np->ccb_done_ic = i; in ncr_wakeup_done()
5139 cp = np->ccb; in ncr_wakeup_done()
5142 ncr_complete (np, cp); in ncr_wakeup_done()
5144 ncr_ccb_skipped (np, cp); in ncr_wakeup_done()
5153 void ncr_wakeup (struct ncb *np, u_long code) in ncr_wakeup() argument
5155 struct ccb *cp = np->ccb; in ncr_wakeup()
5160 ncr_complete (np, cp); in ncr_wakeup()
5174 static void ncr_chip_reset(struct ncb *np, int delay) in ncr_chip_reset() argument
5180 if (np->features & FE_EHP) in ncr_chip_reset()
5182 if (np->features & FE_MUX) in ncr_chip_reset()
5196 void ncr_init (struct ncb *np, int reset, char * msg, u_long code) in ncr_init() argument
5217 if (msg) printk (KERN_INFO "%s: restart (%s).\n", ncr_name (np), msg); in ncr_init()
5222 np->queuedepth = MAX_START - 1; /* 1 entry needed as end marker */ in ncr_init()
5224 np->scripth0->tryloop[i] = in ncr_init()
5225 cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); in ncr_init()
5230 np->squeueput = 0; in ncr_init()
5231 np->script0->startpos[0] = cpu_to_scr(NCB_SCRIPTH_PHYS (np, tryloop)); in ncr_init()
5238 np->ccb_done[i] = (struct ccb *)CCB_DONE_EMPTY; in ncr_init()
5239 np->scripth0->done_queue[5*i + 4] = in ncr_init()
5240 cpu_to_scr(NCB_SCRIPT_PHYS (np, done_end)); in ncr_init()
5247 np->script0->done_pos[0] = cpu_to_scr(NCB_SCRIPTH_PHYS (np,done_queue)); in ncr_init()
5248 np->ccb_done_ic = MAX_DONE-1; in ncr_init()
5249 np->scripth0->done_queue[5*(MAX_DONE-1) + 4] = in ncr_init()
5250 cpu_to_scr(NCB_SCRIPT_PHYS (np, done_plug)); in ncr_init()
5255 ncr_wakeup (np, code); in ncr_init()
5265 ncr_chip_reset(np, 2000); in ncr_init()
5267 OUTB (nc_scntl0, np->rv_scntl0 | 0xc0); in ncr_init()
5271 ncr_selectclock(np, np->rv_scntl3); /* Select SCSI clock */ in ncr_init()
5273 OUTB (nc_scid , RRE|np->myaddr); /* Adapter SCSI address */ in ncr_init()
5274 OUTW (nc_respid, 1ul<<np->myaddr); /* Id to respond to */ in ncr_init()
5276 OUTB (nc_dmode , np->rv_dmode); /* Burst length, dma mode */ in ncr_init()
5277 OUTB (nc_ctest5, np->rv_ctest5); /* Large fifo + large burst */ in ncr_init()
5279 OUTB (nc_dcntl , NOCOM|np->rv_dcntl); /* Protect SFBR */ in ncr_init()
5280 OUTB (nc_ctest0, np->rv_ctest0); /* 720: CDIS and EHP */ in ncr_init()
5281 OUTB (nc_ctest3, np->rv_ctest3); /* Write and invalidate */ in ncr_init()
5282 OUTB (nc_ctest4, np->rv_ctest4); /* Master parity checking */ in ncr_init()
5284 OUTB (nc_stest2, EXT|np->rv_stest2); /* Extended Sreq/Sack filtering */ in ncr_init()
5292 np->disc = 0; in ncr_init()
5298 if (np->features & FE_LED0) { in ncr_init()
5317 struct tcb *tp = &np->target[i]; in ncr_init()
5320 tp->wval = np->rv_scntl3; in ncr_init()
5323 if (tp->usrsync <= np->maxsync) { in ncr_init()
5324 if (tp->usrsync < np->minsync) { in ncr_init()
5325 tp->usrsync = np->minsync; in ncr_init()
5332 if (tp->usrwide > np->maxwide) in ncr_init()
5333 tp->usrwide = np->maxwide; in ncr_init()
5340 if (np->paddr2) { in ncr_init()
5343 ncr_name(np)); in ncr_init()
5344 OUTL (nc_scratcha, vtobus(np->script0)); in ncr_init()
5345 OUTL_DSP (NCB_SCRIPTH_PHYS (np, start_ram)); in ncr_init()
5348 OUTL_DSP (NCB_SCRIPT_PHYS (np, start)); in ncr_init()
5359 static void ncr_negotiate (struct ncb* np, struct tcb* tp) in ncr_negotiate() argument
5371 if (np->scsi_mode && np->scsi_mode == SMODE_SE) { in ncr_negotiate()
5379 if (minsync < np->minsync) in ncr_negotiate()
5380 minsync = np->minsync; in ncr_negotiate()
5386 if (minsync > np->maxsync) in ncr_negotiate()
5389 if (tp->maxoffs > np->maxoffs) in ncr_negotiate()
5390 tp->maxoffs = np->maxoffs; in ncr_negotiate()
5417 static void ncr_getsync(struct ncb *np, u_char sfac, u_char *fakp, u_char *scntl3p) in ncr_getsync() argument
5419 u_long clk = np->clock_khz; /* SCSI clock frequency in kHz */ in ncr_getsync()
5420 int div = np->clock_divn; /* Number of divisors supported */ in ncr_getsync()
5486 static void ncr_set_sync_wide_status (struct ncb *np, u_char target) in ncr_set_sync_wide_status() argument
5489 struct tcb *tp = &np->target[target]; in ncr_set_sync_wide_status()
5495 np->sync_st = tp->sval; in ncr_set_sync_wide_status()
5497 np->wide_st = tp->wval; in ncr_set_sync_wide_status()
5502 for (cp = np->ccb; cp; cp = cp->link_ccb) { in ncr_set_sync_wide_status()
5521 static void ncr_setsync (struct ncb *np, struct ccb *cp, u_char scntl3, u_char sxfer) in ncr_setsync() argument
5530 tp = &np->target[target]; in ncr_setsync()
5533 scntl3 = np->rv_scntl3; in ncr_setsync()
5534 scntl3 = (scntl3 & 0xf0) | (tp->wval & EWS) | (np->rv_scntl3 & 0x07); in ncr_setsync()
5543 tp->period = (((sxfer>>5)+4)*div_10M[idiv-1])/np->clock_khz; in ncr_setsync()
5565 ncr_set_sync_wide_status(np, target); in ncr_setsync()
5578 static void ncr_setwide (struct ncb *np, struct ccb *cp, u_char wide, u_char ack) in ncr_setwide() argument
5588 tp = &np->target[target]; in ncr_setwide()
5613 ncr_set_sync_wide_status(np, target); in ncr_setwide()
5623 static void ncr_setup_tags (struct ncb *np, struct scsi_device *sdev) in ncr_setup_tags() argument
5626 struct tcb *tp = &np->target[tn]; in ncr_setup_tags()
5694 cpu_to_scr(NCB_SCRIPT_PHYS(np, resel_tag)) : in ncr_setup_tags()
5695 cpu_to_scr(NCB_SCRIPT_PHYS(np, resel_notag)); in ncr_setup_tags()
5726 static void ncr_timeout (struct ncb *np) in ncr_timeout() argument
5736 if (np->release_stage) { in ncr_timeout()
5737 if (np->release_stage == 1) np->release_stage = 2; in ncr_timeout()
5741 np->timer.expires = jiffies + SCSI_NCR_TIMER_INTERVAL; in ncr_timeout()
5742 add_timer(&np->timer); in ncr_timeout()
5748 if (np->settle_time) { in ncr_timeout()
5749 if (np->settle_time <= thistime) { in ncr_timeout()
5751 printk("%s: command processing resumed\n", ncr_name(np)); in ncr_timeout()
5752 np->settle_time = 0; in ncr_timeout()
5753 np->disc = 1; in ncr_timeout()
5754 requeue_waiting_list(np); in ncr_timeout()
5764 if (np->lasttime + 4*HZ < thistime) { in ncr_timeout()
5768 np->lasttime = thistime; in ncr_timeout()
5778 ncr_exception (np); in ncr_timeout()
5814 static void ncr_log_hard_error(struct ncb *np, u16 sist, u_char dstat) in ncr_log_hard_error() argument
5825 if (dsp > np->p_script && dsp <= np->p_script + sizeof(struct script)) { in ncr_log_hard_error()
5826 script_ofs = dsp - np->p_script; in ncr_log_hard_error()
5828 script_base = (u_char *) np->script0; in ncr_log_hard_error()
5831 else if (np->p_scripth < dsp && in ncr_log_hard_error()
5832 dsp <= np->p_scripth + sizeof(struct scripth)) { in ncr_log_hard_error()
5833 script_ofs = dsp - np->p_scripth; in ncr_log_hard_error()
5835 script_base = (u_char *) np->scripth0; in ncr_log_hard_error()
5845 ncr_name (np), (unsigned)INB (nc_sdid)&0x0f, dstat, sist, in ncr_log_hard_error()
5852 printk ("%s: script cmd = %08x\n", ncr_name(np), in ncr_log_hard_error()
5856 printk ("%s: regdump:", ncr_name(np)); in ncr_log_hard_error()
5894 void ncr_exception (struct ncb *np) in ncr_exception() argument
5912 ncr_wakeup_done (np); in ncr_exception()
5951 if ((sist & SBMC) && ncr_int_sbmc (np)) in ncr_exception()
5953 if ((sist & PAR) && ncr_int_par (np)) in ncr_exception()
5956 ncr_int_ma (np); in ncr_exception()
5960 ncr_int_sir (np); in ncr_exception()
5969 ncr_name(np), istat, dstat, sist); in ncr_exception()
5992 ncr_init (np, 1, bootverbose ? "scsi reset" : NULL, HS_RESET); in ncr_exception()
6003 ncr_int_sto (np); in ncr_exception()
6020 if (time_after(jiffies, np->regtime)) { in ncr_exception()
6021 np->regtime = jiffies + 10*HZ; in ncr_exception()
6022 for (i = 0; i<sizeof(np->regdump); i++) in ncr_exception()
6023 ((char*)&np->regdump)[i] = INB_OFF(i); in ncr_exception()
6024 np->regdump.nc_dstat = dstat; in ncr_exception()
6025 np->regdump.nc_sist = sist; in ncr_exception()
6028 ncr_log_hard_error(np, sist, dstat); in ncr_exception()
6030 printk ("%s: have to clear fifos.\n", ncr_name (np)); in ncr_exception()
6036 ncr_start_reset(np); in ncr_exception()
6041 printk ("%s: handshake timeout\n", ncr_name(np)); in ncr_exception()
6042 ncr_start_reset(np); in ncr_exception()
6047 printk ("%s: unexpected disconnect\n", ncr_name(np)); in ncr_exception()
6049 OUTL_DSP (NCB_SCRIPT_PHYS (np, cleanup)); in ncr_exception()
6058 printk ("%s: unknown interrupt\n", ncr_name(np)); in ncr_exception()
6077 void ncr_int_sto (struct ncb *np) in ncr_int_sto() argument
6088 cp = np->ccb; in ncr_int_sto()
6094 ncr_complete (np, cp); in ncr_int_sto()
6101 OUTL_DSP (NCB_SCRIPTH_PHYS (np, sto_restart)); in ncr_int_sto()
6122 static int ncr_int_sbmc (struct ncb *np) in ncr_int_sbmc() argument
6126 if (scsi_mode != np->scsi_mode) { in ncr_int_sbmc()
6128 ncr_name(np), np->scsi_mode, scsi_mode); in ncr_int_sbmc()
6130 np->scsi_mode = scsi_mode; in ncr_int_sbmc()
6137 np->settle_time = jiffies + HZ; in ncr_int_sbmc()
6138 ncr_init (np, 0, bootverbose ? "scsi mode change" : NULL, HS_RESET); in ncr_int_sbmc()
6154 static int ncr_int_par (struct ncb *np) in ncr_int_par() argument
6164 ncr_name(np), hsts, dbc, sstat1); in ncr_int_par()
6204 jmp = NCB_SCRIPTH_PHYS (np, par_err_data_in); in ncr_int_par()
6206 jmp = NCB_SCRIPTH_PHYS (np, par_err_other); in ncr_int_par()
6211 np->msgout[0] = msg; in ncr_int_par()
6216 ncr_start_reset(np); in ncr_int_par()
6234 static void ncr_int_ma (struct ncb *np) in ncr_int_ma() argument
6265 ctest5 = (np->rv_ctest5 & DFS) ? INB (nc_ctest5) : 0; in ncr_int_ma()
6310 cp = np->header.cp; in ncr_int_ma()
6314 cp = np->ccb; in ncr_int_ma()
6325 if (dsp > np->p_script && in ncr_int_ma()
6326 dsp <= np->p_script + sizeof(struct script)) { in ncr_int_ma()
6327 vdsp = (u32 *)((char*)np->script0 + (dsp-np->p_script-8)); in ncr_int_ma()
6330 else if (dsp > np->p_scripth && in ncr_int_ma()
6331 dsp <= np->p_scripth + sizeof(struct scripth)) { in ncr_int_ma()
6332 vdsp = (u32 *)((char*)np->scripth0 + (dsp-np->p_scripth-8)); in ncr_int_ma()
6352 cp, np->header.cp, in ncr_int_ma()
6366 ncr_name (np), (u_long) np->header.cp); in ncr_int_ma()
6410 if (cp != np->header.cp) { in ncr_int_ma()
6413 ncr_name (np), (u_long) cp, (u_long) np->header.cp); in ncr_int_ma()
6461 OUTL_DSP (NCB_SCRIPT_PHYS (np, dispatch)); in ncr_int_ma()
6497 nxtdsp = NCB_SCRIPT_PHYS (np, dispatch); in ncr_int_ma()
6501 nxtdsp = NCB_SCRIPT_PHYS (np, dispatch); in ncr_int_ma()
6505 np->scripth->nxtdsp_go_on[0] = cpu_to_scr(dsp + 8); in ncr_int_ma()
6506 if (dsp == NCB_SCRIPT_PHYS (np, send_ident)) { in ncr_int_ma()
6508 nxtdsp = NCB_SCRIPTH_PHYS (np, clratn_go_on); in ncr_int_ma()
6510 else if (dsp == NCB_SCRIPTH_PHYS (np, send_wdtr) || in ncr_int_ma()
6511 dsp == NCB_SCRIPTH_PHYS (np, send_sdtr)) { in ncr_int_ma()
6512 nxtdsp = NCB_SCRIPTH_PHYS (np, nego_bad_phase); in ncr_int_ma()
6517 nxtdsp = NCB_SCRIPT_PHYS (np, clrack); in ncr_int_ma()
6528 ncr_start_reset(np); in ncr_int_ma()
6532 static void ncr_sir_to_redo(struct ncb *np, int num, struct ccb *cp) in ncr_sir_to_redo() argument
6535 struct tcb *tp = &np->target[cmd->device->id]; in ncr_sir_to_redo()
6559 cpu_to_scr(NCB_SCRIPTH_PHYS (np, skip)); in ncr_sir_to_redo()
6581 ncr_setup_tags (np, cmd->device); in ncr_sir_to_redo()
6593 ncr_put_start_queue(np, cp); in ncr_sir_to_redo()
6596 OUTL_DSP (NCB_SCRIPT_PHYS (np, reselect)); in ncr_sir_to_redo()
6640 startp = cpu_to_scr(NCB_SCRIPTH_PHYS (np, sdata_in)); in ncr_sir_to_redo()
6653 cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); in ncr_sir_to_redo()
6660 cpu_to_scr(NCB_SCRIPTH_PHYS (np, select_no_atn)); in ncr_sir_to_redo()
6662 ncr_put_start_queue(np, cp); in ncr_sir_to_redo()
6664 OUTL_DSP (NCB_SCRIPT_PHYS (np, start)); in ncr_sir_to_redo()
6683 void ncr_int_sir (struct ncb *np) in ncr_int_sir() argument
6691 struct tcb *tp = &np->target[target]; in ncr_int_sir()
6702 ncr_wakeup_done(np); in ncr_int_sir()
6704 OUTL(nc_dsp, NCB_SCRIPT_PHYS (np, done_end) + 8); in ncr_int_sir()
6706 OUTL(nc_dsp, NCB_SCRIPT_PHYS (np, start)); in ncr_int_sir()
6727 ncr_name (np), target, num); in ncr_int_sir()
6732 ncr_name (np), target, num); in ncr_int_sir()
6735 cp = np->header.cp; in ncr_int_sir()
6738 ncr_sir_to_redo(np, num, cp); in ncr_int_sir()
6744 cp = np->ccb; in ncr_int_sir()
6749 BUG_ON(cp != np->header.cp); in ncr_int_sir()
6751 if (!cp || cp != np->header.cp) in ncr_int_sir()
6853 ncr_setsync (np, cp, 0, 0xe0); in ncr_int_sir()
6858 ncr_setwide (np, cp, 0, 0); in ncr_int_sir()
6862 np->msgin [0] = NOP; in ncr_int_sir()
6863 np->msgout[0] = NOP; in ncr_int_sir()
6869 ncr_print_msg(cp, "sync msgin", np->msgin); in ncr_int_sir()
6873 per = np->msgin[3]; in ncr_int_sir()
6874 ofs = np->msgin[4]; in ncr_int_sir()
6889 if (per < np->minsync) in ncr_int_sir()
6890 {chg = 1; per = np->minsync;} in ncr_int_sir()
6902 ncr_getsync(np, per, &fak, &scntl3); in ncr_int_sir()
6930 ncr_setsync(np, cp, 0, 0xe0); in ncr_int_sir()
6931 OUTL_DSP(NCB_SCRIPT_PHYS (np, msg_bad)); in ncr_int_sir()
6936 ncr_setsync(np, cp, scntl3, (fak<<5)|ofs); in ncr_int_sir()
6937 OUTL_DSP(NCB_SCRIPT_PHYS (np, clrack)); in ncr_int_sir()
6943 ncr_setwide(np, cp, 0, 0); in ncr_int_sir()
6955 ncr_setsync(np, cp, scntl3, (fak<<5)|ofs); in ncr_int_sir()
6957 spi_populate_sync_msg(np->msgout, per, ofs); in ncr_int_sir()
6961 ncr_print_msg(cp, "sync msgout", np->msgout); in ncr_int_sir()
6965 OUTL_DSP (NCB_SCRIPT_PHYS (np, msg_bad)); in ncr_int_sir()
6968 np->msgin [0] = NOP; in ncr_int_sir()
6977 ncr_print_msg(cp, "wide msgin", np->msgin); in ncr_int_sir()
6985 wide = np->msgin[3]; in ncr_int_sir()
7018 ncr_setwide(np, cp, 0, 1); in ncr_int_sir()
7019 OUTL_DSP (NCB_SCRIPT_PHYS (np, msg_bad)); in ncr_int_sir()
7023 ncr_setwide(np, cp, wide, 1); in ncr_int_sir()
7024 OUTL_DSP (NCB_SCRIPT_PHYS (np, clrack)); in ncr_int_sir()
7031 ncr_setsync(np, cp, 0, 0xe0); in ncr_int_sir()
7042 ncr_setwide(np, cp, wide, 1); in ncr_int_sir()
7043 spi_populate_width_msg(np->msgout, wide); in ncr_int_sir()
7045 np->msgin [0] = NOP; in ncr_int_sir()
7050 ncr_print_msg(cp, "wide msgout", np->msgin); in ncr_int_sir()
7070 (unsigned)scr_to_cpu(np->lastmsg), np->msgout[0]); in ncr_int_sir()
7081 ncr_print_msg(cp, "MESSAGE_REJECT sent for", np->msgin); in ncr_int_sir()
7116 (unsigned) scr_to_cpu(np->header.savep), in ncr_int_sir()
7117 (unsigned) scr_to_cpu(np->header.goalp)); in ncr_int_sir()
7135 static struct ccb *ncr_get_ccb(struct ncb *np, struct scsi_cmnd *cmd) in ncr_get_ccb() argument
7139 struct tcb *tp = &np->target[tn]; in ncr_get_ccb()
7159 ncr_alloc_ccb(np, tn, ln); in ncr_get_ccb()
7193 cp = np->ccb; in ncr_get_ccb()
7246 static void ncr_free_ccb (struct ncb *np, struct ccb *cp) in ncr_free_ccb() argument
7248 struct tcb *tp = &np->target[cp->target]; in ncr_free_ccb()
7268 cpu_to_scr(NCB_SCRIPTH_PHYS(np, bad_i_t_l_q)); in ncr_free_ccb()
7271 cpu_to_scr(NCB_SCRIPTH_PHYS(np, bad_i_t_l)); in ncr_free_ccb()
7280 if (cp != np->ccb) in ncr_free_ccb()
7290 --np->queuedccbs; in ncr_free_ccb()
7295 if (cp == np->ccb) in ncr_free_ccb()
7301 #define ncr_reg_bus_addr(r) (np->paddr + offsetof (struct ncr_reg, r))
7308 static void ncr_init_ccb(struct ncb *np, struct ccb *cp) in ncr_init_ccb() argument
7310 ncrcmd copy_4 = np->features & FE_PFEN ? SCR_COPY(4) : SCR_COPY_F(4); in ncr_init_ccb()
7337 cp->start.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); in ncr_init_ccb()
7338 cp->restart.schedule.l_paddr = cpu_to_scr(NCB_SCRIPTH_PHYS (np, abort)); in ncr_init_ccb()
7347 static void ncr_alloc_ccb(struct ncb *np, u_char tn, u_char ln) in ncr_alloc_ccb() argument
7349 struct tcb *tp = &np->target[tn]; in ncr_alloc_ccb()
7364 np->actccbs++; in ncr_alloc_ccb()
7366 ncr_init_ccb(np, cp); in ncr_alloc_ccb()
7372 cp->link_ccb = np->ccb->link_ccb; in ncr_alloc_ccb()
7373 np->ccb->link_ccb = cp; in ncr_alloc_ccb()
7396 static void ncr_init_tcb (struct ncb *np, u_char tn) in ncr_init_tcb() argument
7398 struct tcb *tp = &np->target[tn]; in ncr_init_tcb()
7399 ncrcmd copy_1 = np->features & FE_PFEN ? SCR_COPY(1) : SCR_COPY_F(1); in ncr_init_tcb()
7409 tp->jump_tcb.l_paddr = np->jump_tcb[th].l_paddr; in ncr_init_tcb()
7440 tp->call_lun.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_lun)); in ncr_init_tcb()
7451 cpu_to_scr(NCB_SCRIPTH_PHYS (np, bad_identify)); in ncr_init_tcb()
7457 np->jump_tcb[th].l_paddr = cpu_to_scr(vtobus (&tp->jump_tcb)); in ncr_init_tcb()
7483 static struct lcb *ncr_alloc_lcb (struct ncb *np, u_char tn, u_char ln) in ncr_alloc_lcb() argument
7485 struct tcb *tp = &np->target[tn]; in ncr_alloc_lcb()
7487 ncrcmd copy_4 = np->features & FE_PFEN ? SCR_COPY(4) : SCR_COPY_F(4); in ncr_alloc_lcb()
7509 ncr_init_tcb(np, tn); in ncr_alloc_lcb()
7547 lp->jump_tag.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_notag)); in ncr_alloc_lcb()
7573 static struct lcb *ncr_setup_lcb (struct ncb *np, struct scsi_device *sdev) in ncr_setup_lcb() argument
7576 struct tcb *tp = &np->target[tn]; in ncr_setup_lcb()
7580 if (!lp && !(lp = ncr_alloc_lcb(np, tn, ln))) in ncr_setup_lcb()
7597 cpu_to_scr(NCB_SCRIPTH_PHYS (np, bad_i_t_l_q)); in ncr_setup_lcb()
7602 ncr_setup_tags (np, sdev); in ncr_setup_lcb()
7639 static int ncr_scatter(struct ncb *np, struct ccb *cp, struct scsi_cmnd *cmd) in ncr_scatter() argument
7646 use_sg = map_scsi_sg_data(np, cmd); in ncr_scatter()
7652 unmap_scsi_data(np, cmd); in ncr_scatter()
7662 ncr_build_sge(np, &data[segment], baddr, len); in ncr_scatter()
7682 static int __init ncr_regtest (struct ncb* np) argument
7705 static int __init ncr_snooptest (struct ncb* np) argument
7709 if (np->reg) {
7710 err |= ncr_regtest (np);
7716 pc = NCB_SCRIPTH_PHYS (np, snooptest);
7722 np->ncr_cache = cpu_to_scr(host_wr);
7741 host_rd = scr_to_cpu(np->ncr_cache);
7747 ncr_chip_reset(np, 100);
7758 if (pc != NCB_SCRIPTH_PHYS (np, snoopend)+8) {
7761 (u_long) NCB_SCRIPTH_PHYS (np, snooptest), (u_long) pc,
7762 (u_long) NCB_SCRIPTH_PHYS (np, snoopend) +8);
7812 static void ncr_selectclock(struct ncb *np, u_char scntl3) argument
7814 if (np->multiplier < 2) {
7820 printk ("%s: enabling clock multiplier\n", ncr_name(np));
7823 if (np->multiplier > 2) { /* Poll bit 5 of stest4 for quadrupler */
7828 printk("%s: the chip cannot lock the frequency\n", ncr_name(np));
7841 static unsigned __init ncrgetfreq (struct ncb *np, int gen) argument
7882 printk ("%s: Delay (GEN=%d): %u msec\n", ncr_name(np), gen, ms);
7892 static void __init ncr_getclock (struct ncb *np, int mult) argument
7898 np->multiplier = 1;
7906 printk ("%s: clock multiplier found\n", ncr_name(np));
7907 np->multiplier = mult;
7915 if (np->multiplier != mult || (scntl3 & 7) < 3 || !(scntl3 & 1)) {
7918 ncr_chip_reset(np, 5);
7920 (void) ncrgetfreq (np, 11); /* throw away first result */
7921 f1 = ncrgetfreq (np, 11);
7922 f2 = ncrgetfreq (np, 11);
7925 printk ("%s: NCR clock is %uKHz, %uKHz\n", ncr_name(np), f1, f2);
7935 printk ("%s: clock multiplier assumed\n", ncr_name(np));
7936 np->multiplier = mult;
7943 f1 /= np->multiplier;
7949 f1 *= np->multiplier;
7950 np->clock_khz = f1;
7958 struct ncb *np = ((struct host_data *) host->hostdata)->ncb; local
7959 struct tcb *tp = &np->target[device->id];
7968 struct ncb *np = ((struct host_data *) host->hostdata)->ncb; local
7969 struct tcb *tp = &np->target[device->id];
7973 ncr_setup_lcb(np, device);
7981 numtags = device_queue_depth(np->unit, device->id, device->lun);
8007 ncr_setup_tags (np, device);
8011 np->unit, device->id, device->lun, depth_to_use);
8022 struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb; local
8035 spin_lock_irqsave(&np->smp_lock, flags);
8037 if ((sts = ncr_queue_command(np, cmd)) != DID_OK) {
8048 spin_unlock_irqrestore(&np->smp_lock, flags);
8051 unmap_scsi_data(np, cmd);
8066 struct ncb *np = host_data->ncb; local
8075 spin_lock_irqsave(&np->smp_lock, flags);
8076 ncr_exception(np);
8077 done_list = np->done_list;
8078 np->done_list = NULL;
8079 spin_unlock_irqrestore(&np->smp_lock, flags);
8090 struct ncb *np = from_timer(np, t, timer); local
8094 spin_lock_irqsave(&np->smp_lock, flags);
8095 ncr_timeout(np);
8096 done_list = np->done_list;
8097 np->done_list = NULL;
8098 spin_unlock_irqrestore(&np->smp_lock, flags);
8106 struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb; local
8118 spin_lock_irqsave(&np->smp_lock, flags);
8119 sts = ncr_reset_bus(np, cmd, 1);
8121 done_list = np->done_list;
8122 np->done_list = NULL;
8123 spin_unlock_irqrestore(&np->smp_lock, flags);
8133 struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
8140 NCR_LOCK_NCB(np, flags);
8142 sts = ncr_abort_command(np, cmd);
8144 done_list = np->done_list;
8145 np->done_list = NULL;
8146 NCR_UNLOCK_NCB(np, flags);
8170 static void insert_into_waiting_list(struct ncb *np, struct scsi_cmnd *cmd) argument
8175 printk("%s: cmd %lx inserted into waiting list\n", ncr_name(np), (u_long) cmd);
8178 if (!(wcmd = np->waiting_list)) np->waiting_list = cmd;
8186 static struct scsi_cmnd *retrieve_from_waiting_list(int to_remove, struct ncb *np, struct scsi_cmnd… argument
8188 struct scsi_cmnd **pcmd = &np->waiting_list;
8197 printk("%s: cmd %lx retrieved from waiting list\n", ncr_name(np), (u_long) cmd);
8206 static void process_waiting_list(struct ncb *np, int sts) argument
8210 waiting_list = np->waiting_list;
8211 np->waiting_list = NULL;
8214 …if (waiting_list) printk("%s: waiting_list=%lx processing sts=%d\n", ncr_name(np), (u_long) waitin…
8221 printk("%s: cmd %lx trying to requeue\n", ncr_name(np), (u_long) wcmd);
8223 sts = ncr_queue_command(np, wcmd);
8227 printk("%s: cmd %lx done forced sts=%d\n", ncr_name(np), (u_long) wcmd, sts);
8230 ncr_queue_done_cmd(np, wcmd);
8290 struct ncb *np = NULL; local
8320 np = __m_calloc_dma(device->dev, sizeof(struct ncb), "NCB");
8321 if (!np)
8323 spin_lock_init(&np->smp_lock);
8324 np->dev = device->dev;
8325 np->p_ncb = vtobus(np);
8326 host_data->ncb = np;
8328 np->ccb = m_calloc_dma(sizeof(struct ccb), "CCB");
8329 if (!np->ccb)
8333 np->unit = unit;
8334 np->verbose = driver_setup.verbose;
8335 sprintf(np->inst_name, "ncr53c720-%d", np->unit);
8336 np->revision_id = device->chip.revision_id;
8337 np->features = device->chip.features;
8338 np->clock_divn = device->chip.nr_divisor;
8339 np->maxoffs = device->chip.offset_max;
8340 np->maxburst = device->chip.burst_max;
8341 np->myaddr = device->host_id;
8344 np->script0 = m_calloc_dma(sizeof(struct script), "SCRIPT");
8345 if (!np->script0)
8347 np->scripth0 = m_calloc_dma(sizeof(struct scripth), "SCRIPTH");
8348 if (!np->scripth0)
8351 timer_setup(&np->timer, ncr53c8xx_timeout, 0);
8355 np->paddr = device->slot.base;
8356 np->paddr2 = (np->features & FE_RAM) ? device->slot.base_2 : 0;
8359 np->vaddr = device->slot.base_v;
8361 np->vaddr = ioremap(device->slot.base_c, 128);
8363 if (!np->vaddr) {
8365 "%s: can't map memory mapped IO region\n",ncr_name(np));
8370 "%s: using memory mapped IO at virtual address 0x%lx\n", ncr_name(np), (u_long) np->vaddr);
8377 np->reg = (struct ncr_reg __iomem *)np->vaddr;
8380 ncr_prepare_setting(np);
8382 if (np->paddr2 && sizeof(struct script) > 4096) {
8383 np->paddr2 = 0;
8385 ncr_name(np));
8389 instance->this_id = np->myaddr;
8390 instance->max_id = np->maxwide ? 16 : 8;
8392 instance->base = (unsigned long) np->reg;
8406 np->scripth = np->scripth0;
8407 np->p_scripth = vtobus(np->scripth);
8408 np->p_script = (np->paddr2) ? np->paddr2 : vtobus(np->script0);
8410 ncr_script_copy_and_bind(np, (ncrcmd *) &script0,
8411 (ncrcmd *) np->script0, sizeof(struct script));
8412 ncr_script_copy_and_bind(np, (ncrcmd *) &scripth0,
8413 (ncrcmd *) np->scripth0, sizeof(struct scripth));
8414 np->ccb->p_ccb = vtobus (np->ccb);
8418 if (np->features & FE_LED0) {
8419 np->script0->idle[0] =
8421 np->script0->reselected[0] =
8423 np->script0->start[0] =
8433 np->jump_tcb[i].l_cmd =
8435 np->jump_tcb[i].l_paddr =
8436 cpu_to_scr(NCB_SCRIPTH_PHYS (np, bad_target));
8439 ncr_chip_reset(np, 100);
8443 if (ncr_snooptest(np)) {
8449 np->irq = device->slot.irq;
8452 ncr_init_ccb(np, np->ccb);
8460 spin_lock_irqsave(&np->smp_lock, flags);
8461 if (ncr_reset_scsi_bus(np, 0, driver_setup.settle_delay) != 0) {
8462 …N_ERR "%s: FATAL ERROR: CHECK SCSI BUS - CABLES, TERMINATION, DEVICE POWER etc.!\n", ncr_name(np));
8464 spin_unlock_irqrestore(&np->smp_lock, flags);
8467 ncr_exception(np);
8469 np->disc = 1;
8477 ncr_name(np), driver_setup.settle_delay);
8482 np->lasttime=0;
8483 ncr_timeout (np);
8487 np->order = SIMPLE_QUEUE_TAG;
8490 spin_unlock_irqrestore(&np->smp_lock, flags);
8497 printk(KERN_INFO "%s: detaching...\n", ncr_name(np));
8498 if (!np)
8500 if (np->scripth0)
8501 m_free_dma(np->scripth0, sizeof(struct scripth), "SCRIPTH");
8502 if (np->script0)
8503 m_free_dma(np->script0, sizeof(struct script), "SCRIPT");
8504 if (np->ccb)
8505 m_free_dma(np->ccb, sizeof(struct ccb), "CCB");
8506 m_free_dma(np, sizeof(struct ncb), "NCB");
8530 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb; local
8531 struct tcb *tp = &np->target[starget->id];
8533 if (period > np->maxsync)
8534 period = np->maxsync;
8535 else if (period < np->minsync)
8536 period = np->minsync;
8540 ncr_negotiate(np, tp);
8546 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb; local
8547 struct tcb *tp = &np->target[starget->id];
8549 if (offset > np->maxoffs)
8550 offset = np->maxoffs;
8556 ncr_negotiate(np, tp);
8562 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb; local
8563 struct tcb *tp = &np->target[starget->id];
8565 if (width > np->maxwide)
8566 width = np->maxwide;
8572 ncr_negotiate(np, tp);
8577 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb; local
8580 switch (np->scsi_mode) {