Lines Matching +full:no +full:- +full:cs +full:- +full:readback
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 ** Device driver for the PCI-SCSI NCR538XX controller family.
8 **-----------------------------------------------------------------------------
22 ** Stefan Esser <se@mi.Uni-Koeln.de>
27 **-----------------------------------------------------------------------------
38 ** Support for Fast-20 scsi.
42 ** Support for Fast-40 scsi.
43 ** Support for on-Board RAM.
46 ** Full support for scsi scripts instructions pre-fetching.
51 ** August 18 1997 by Cort <cort@cs.nmt.edu>:
57 ** Low PCI traffic for command handling when on-chip RAM is present.
61 ** PCI-ectomy. This driver now supports only the 720 chip (see the
68 ** Supported SCSI-II features:
77 ** 53C720 (Wide, Fast SCSI-2, intfly problems)
81 #define SCSI_NCR_DRIVER_NAME "ncr53c8xx-3.4.3g"
87 #include <linux/dma-mapping.h>
159 struct list_head *elem = head->next; in ncr_list_pop()
170 ** Simple power of two buddy-like allocator.
179 ** Enhanced in linux-2.3.44 to provide a memory pool
197 #define MEMO_CLUSTER_MASK (MEMO_CLUSTER_SIZE-1)
199 typedef u_long m_addr_t; /* Enough bits to bit-hack addresses */
213 #define VTOB_HASH_MASK (VTOB_HASH_SIZE-1)
224 struct m_link h[PAGE_SHIFT-MEMO_SHIFT+MEMO_PAGE_ORDER+1];
233 m_link_s *h = mp->h; in ___m_alloc()
246 h[j].next = (m_link_s *)mp->getp(mp); in ___m_alloc()
248 h[j].next->next = NULL; in ___m_alloc()
256 h[j].next = h[j].next->next; in ___m_alloc()
258 j -= 1; in ___m_alloc()
261 h[j].next->next = NULL; in ___m_alloc()
276 m_link_s *h = mp->h; in ___m_free()
295 mp->freep(mp, a); in ___m_free()
301 while (q->next && q->next != (m_link_s *) b) { in ___m_free()
302 q = q->next; in ___m_free()
304 if (!q->next) { in ___m_free()
305 ((m_link_s *) a)->next = h[i].next; in ___m_free()
309 q->next = q->next->next; in ___m_free()
325 printk ("new %-10s[%4d] @%p.\n", name, size, p); in __m_calloc2()
340 printk ("freeing %-10s[%4d] @%p.\n", name, size, ptr); in __m_free()
356 ++mp->nump; in ___mp0_getp()
363 --mp->nump; in ___mp0_freep()
384 vp = (m_addr_t) dma_alloc_coherent(mp->bush, in ___dma_getp()
389 vbp->vaddr = vp; in ___dma_getp()
390 vbp->baddr = daddr; in ___dma_getp()
391 vbp->next = mp->vtob[hc]; in ___dma_getp()
392 mp->vtob[hc] = vbp; in ___dma_getp()
393 ++mp->nump; in ___dma_getp()
407 vbpp = &mp->vtob[hc]; in ___dma_freep()
408 while (*vbpp && (*vbpp)->vaddr != m) in ___dma_freep()
409 vbpp = &(*vbpp)->next; in ___dma_freep()
412 *vbpp = (*vbpp)->next; in ___dma_freep()
413 dma_free_coherent(mp->bush, PAGE_SIZE<<MEMO_PAGE_ORDER, in ___dma_freep()
414 (void *)vbp->vaddr, (dma_addr_t)vbp->baddr); in ___dma_freep()
416 --mp->nump; in ___dma_freep()
423 for (mp = mp0.next; mp && mp->bush != bush; mp = mp->next); in ___get_dma_pool()
433 mp->bush = bush; in ___cre_dma_pool()
434 mp->getp = ___dma_getp; in ___cre_dma_pool()
435 mp->freep = ___dma_freep; in ___cre_dma_pool()
436 mp->next = mp0.next; in ___cre_dma_pool()
447 pp = &(*pp)->next; in ___del_dma_pool()
449 *pp = (*pp)->next; in ___del_dma_pool()
466 if (mp && !mp->nump) in __m_calloc_dma()
482 if (mp && !mp->nump) in __m_free_dma()
498 vp = mp->vtob[hc]; in __vtobus()
499 while (vp && (m_addr_t) vp->vaddr != a) in __vtobus()
500 vp = vp->next; in __vtobus()
503 return vp ? vp->baddr + (((m_addr_t) m) - a) : 0; in __vtobus()
506 #define _m_calloc_dma(np, s, n) __m_calloc_dma(np->dev, s, n)
507 #define _m_free_dma(np, p, s, n) __m_free_dma(np->dev, p, s, n)
510 #define _vtobus(np, p) __vtobus(np->dev, p)
521 switch(cmd_priv->data_mapped) { in __unmap_scsi_data()
526 cmd_priv->data_mapped = 0; in __unmap_scsi_data()
538 cmd_priv->data_mapped = 2; in __map_scsi_sg_data()
539 cmd_priv->data_mapping = use_sg; in __map_scsi_sg_data()
544 #define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd)
545 #define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd)
552 ** options. It can be overridden at boot-up by the boot
568 #define bootverbose (np->verbose)
649 if (!strncmp(p, cur, pc - cur)) in get_setup_token()
684 i < sizeof(driver_setup.tag_ctrl)-1) { in sym53c8xx__setup()
767 printk("sym53c8xx_setup: unexpected boot option '%.*s' ignored\n", (int)(pc-cur+1), cur); in sym53c8xx__setup()
786 #define ALL_TARGETS -2
787 #define NO_TARGET -1
788 #define ALL_LUNS -2
789 #define NO_LUN -1
797 h = -1; in device_queue_depth()
823 case '-': in device_queue_depth()
843 ** atomically, 64 bit little-endian architecture requires
863 /* All > 32 bit (64 bit) architectures regardless endian-ness */
921 ** n permits target numbers 0..n-1.
934 ** n enables logic unit numbers 0..n-1.
946 ** Asynchronous pre-scaler (ns). Shall be 40
979 ** The data scripts are broken into 2 sub-scripts.
980 ** 80 (MAX_SCATTERL) segments are moved from a sub-script
981 ** in on-chip RAM. This makes data transfers shorter than
989 #define MAX_SCATTERH (MAX_SCATTER - MAX_SCATTERL)
991 #define MAX_SCATTERL (MAX_SCATTER-1)
1006 #define bootverbose (np->verbose)
1153 /*----------------------------------------------------------------
1159 **----------------------------------------------------------------
1163 /*----------------------------------------------------------------
1169 **----------------------------------------------------------------
1173 /*----------------------------------------------------------------
1177 **----------------------------------------------------------------
1181 /*----------------------------------------------------------------
1189 **----------------------------------------------------------------
1194 /*----------------------------------------------------------------
1198 **----------------------------------------------------------------
1202 /*----------------------------------------------------------------
1204 **----------------------------------------------------------------
1209 /*----------------------------------------------------------------
1211 **----------------------------------------------------------------
1246 /*----------------------------------------------------------------
1258 **----------------------------------------------------------------
1265 /*----------------------------------------------------------------
1271 **----------------------------------------------------------------
1273 u32 jump_ccb_0; /* Default table if no tags */
1276 /*----------------------------------------------------------------
1278 **----------------------------------------------------------------
1291 /*----------------------------------------------------------------
1295 **----------------------------------------------------------------
1304 /*----------------------------------------------------------------
1306 **----------------------------------------------------------------
1308 /*----------------------------------------------------------------
1310 **----------------------------------------------------------------
1329 **------------------------------------------------------------------------
1332 /*----------------------------------------------------------------
1335 **----------------------------------------------------------------
1353 **------------------------------------------------------------------------
1357 /*----------------------------------------------------------------
1363 **----------------------------------------------------------------
1369 /*----------------------------------------------------------------
1373 **----------------------------------------------------------------
1378 /*----------------------------------------------------------------
1380 **----------------------------------------------------------------
1384 /*----------------------------------------------------------------
1386 **----------------------------------------------------------------
1465 ** the script-processor-changeable data and
1468 **----------------------------------------------------------
1498 /*----------------------------------------------------------------
1503 **----------------------------------------------------------------
1507 /*----------------------------------------------------------------
1508 ** Mini-script used at CCB execution start-up.
1511 **----------------------------------------------------------------
1515 /*----------------------------------------------------------------
1516 ** Mini-script used at CCB relection to restart the nexus.
1519 **----------------------------------------------------------------
1523 /*----------------------------------------------------------------
1528 **----------------------------------------------------------------
1532 /*----------------------------------------------------------------
1535 **----------------------------------------------------------------
1542 /*----------------------------------------------------------------
1550 **----------------------------------------------------------------
1555 /*----------------------------------------------------------------
1557 **----------------------------------------------------------------
1562 /* 255 means no tag */
1573 #define CCB_PHYS(cp,lbl) (cp->p_ccb + offsetof(struct ccb, lbl))
1583 /*----------------------------------------------------------------
1588 **----------------------------------------------------------------
1592 /*----------------------------------------------------------------
1594 **----------------------------------------------------------------
1602 /*----------------------------------------------------------------
1604 **----------------------------------------------------------------
1609 /*----------------------------------------------------------------
1613 **----------------------------------------------------------------
1618 /*----------------------------------------------------------------
1622 **----------------------------------------------------------------
1627 /*----------------------------------------------------------------
1636 **----------------------------------------------------------------
1641 /*----------------------------------------------------------------
1643 **----------------------------------------------------------------
1647 unsigned long paddr2; /* On-chip RAM bus address. */
1651 /*----------------------------------------------------------------
1653 ** 'script' is loaded in the on-chip RAM if present.
1655 **----------------------------------------------------------------
1663 /*----------------------------------------------------------------
1665 **----------------------------------------------------------------
1681 /*----------------------------------------------------------------
1685 **----------------------------------------------------------------
1692 /*----------------------------------------------------------------
1694 **----------------------------------------------------------------
1700 /*----------------------------------------------------------------
1702 **----------------------------------------------------------------
1707 /*----------------------------------------------------------------
1708 ** Miscellaneous buffers accessed by the scripts-processor.
1711 **----------------------------------------------------------------
1718 /*----------------------------------------------------------------
1720 **----------------------------------------------------------------
1729 /*----------------------------------------------------------------
1731 **----------------------------------------------------------------
1737 /*----------------------------------------------------------------
1739 **----------------------------------------------------------------
1746 #define NCB_SCRIPT_PHYS(np,lbl) (np->p_script + offsetof (struct script, lbl))
1747 #define NCB_SCRIPTH_PHYS(np,lbl) (np->p_scripth + offsetof (struct scripth,lbl))
1752 ** Script for NCR-Processor.
1767 **----------------------------------------------------------
1788 ** Script fragments which are loaded into the on-chip RAM
1948 return np->inst_name; in ncr_name()
1955 ** Scripts for NCR-Processor.
1968 **----------------------------------------------------------
1985 /*--------------------------< START >-----------------------*/ {
2003 }/*-------------------------< STARTPOS >--------------------*/,{
2006 }/*-------------------------< SELECT >----------------------*/,{
2030 }/*-------------------------< SELECT2 >----------------------*/,{
2047 ** complete or selection time-out to occur.
2075 ** COPY command with the DSA-register.
2091 }/*-------------------------< LOADPOS >---------------------*/,{
2096 ** to complete or time-out.
2101 }/*-------------------------< SEND_IDENT >----------------------*/,{
2116 }/*-------------------------< PREPARE >----------------------*/,{
2130 }/*-------------------------< PREPARE2 >---------------------*/,{
2146 }/*-------------------------< COMMAND >--------------------*/,{
2162 }/*-----------------------< DISPATCH >----------------------*/,{
2174 ** DEL 397 - 53C875 Rev 3 - Part Number 609-0392410 - ITEM 4.
2176 ** This work-around resets the addressing logic prior to the
2212 }/*-------------------------< CLRACK >----------------------*/,{
2221 }/*-------------------------< NO_DATA >--------------------*/,{
2251 }/*-------------------------< STATUS >--------------------*/,{
2267 }/*-------------------------< MSG_IN >--------------------*/,{
2277 }/*-------------------------< MSG_IN2 >--------------------*/,{
2304 }/*-------------------------< MSG_BAD >------------------*/,{
2306 ** unimplemented message - reject it.
2312 }/*-------------------------< SETMSG >----------------------*/,{
2320 }/*-------------------------< CLEANUP >-------------------*/,{
2323 ** or xxxxxxFF (no ccb)
2325 ** HS_REG: Host-Status (<>0!)
2338 }/*-------------------------< COMPLETE >-----------------*/,{
2367 }/*-------------------------< CLEANUP_OK >----------------*/,{
2386 }/*-------------------------< CLEANUP0 >--------------------*/,{
2388 }/*-------------------------< SIGNAL >----------------------*/,{
2427 }/*------------------------< DONE_POS >---------------------*/,{
2429 }/*------------------------< DONE_PLUG >--------------------*/,{
2432 }/*------------------------< DONE_END >---------------------*/,{
2443 }/*-------------------------< SAVE_DP >------------------*/,{
2455 }/*-------------------------< RESTORE_DP >---------------*/,{
2466 }/*-------------------------< DISCONNECT >---------------*/,{
2490 }/*-------------------------< MSG_OUT >-------------------*/,{
2500 ** If it was no ABORT message ...
2510 }/*-------------------------< MSG_OUT_DONE >--------------*/,{
2524 }/*-------------------------< IDLE >------------------------*/,{
2533 }/*-------------------------< RESELECT >--------------------*/,{
2551 }/*-------------------------< RESELECTED >------------------*/,{
2565 ** - struct ncb
2566 ** - struct tcb
2567 ** - struct lcb
2568 ** - struct ccb
2578 }/*-------------------------< RESEL_DSA >-------------------*/,{
2591 ** COPY command with the DSA-register.
2608 }/*-------------------------< LOADPOS1 >-------------------*/,{
2617 }/*-------------------------< RESEL_LUN >-------------------*/,{
2638 }/*-------------------------< RESEL_TAG >-------------------*/,{
2642 ** No need to test the SIMPLE TAG message, since the
2643 ** driver only supports conformant devices for tags. ;-)
2649 ** Still an aggressive optimization. ;-)
2658 }/*-------------------------< JUMP_TO_NEXUS >-------------------*/,{
2667 }/*-------------------------< NEXUS_INDIRECT >-------------------*/,{
2672 }/*-------------------------< RESEL_NOTAG >-------------------*/,{
2674 ** No tag expected.
2681 }/*-------------------------< DATA_IN >--------------------*/,{
2694 **---------------------------------------------------------
2697 }/*-------------------------< DATA_IN2 >-------------------*/,{
2702 }/*-------------------------< DATA_OUT >--------------------*/,{
2715 **---------------------------------------------------------
2718 }/*-------------------------< DATA_OUT2 >-------------------*/,{
2723 }/*--------------------------------------------------------*/
2727 /*-------------------------< TRYLOOP >---------------------*/{
2737 **-----------------------------------------------------------
2744 **-----------------------------------------------------------
2747 }/*------------------------< TRYLOOP2 >---------------------*/,{
2753 }/*------------------------< DONE_QUEUE >-------------------*/,{
2760 **-----------------------------------------------------------
2770 **-----------------------------------------------------------
2773 }/*------------------------< DONE_QUEUE2 >------------------*/,{
2778 }/*------------------------< SELECT_NO_ATN >-----------------*/,{
2793 }/*-------------------------< CANCEL >------------------------*/,{
2799 }/*-------------------------< SKIP >------------------------*/,{
2816 ** COPY command with the DSA-register.
2832 }/*-------------------------< SKIP2 >---------------------*/,{
2859 },/*-------------------------< PAR_ERR_DATA_IN >---------------*/{
2868 -24,
2869 },/*-------------------------< PAR_ERR_OTHER >------------------*/{
2880 }/*-------------------------< MSG_REJECT >---------------*/,{
2896 }/*-------------------------< MSG_IGN_RESIDUE >----------*/,{
2944 }/*-------------------------< MSG_EXTENDED >-------------*/,{
2963 }/*-------------------------< MSG_EXT_2 >----------------*/,{
2980 }/*-------------------------< MSG_WDTR >-----------------*/,{
3005 }/*-------------------------< SEND_WDTR >----------------*/,{
3017 }/*-------------------------< MSG_EXT_3 >----------------*/,{
3035 }/*-------------------------< MSG_SDTR >-----------------*/,{
3060 }/*-------------------------< SEND_SDTR >-------------*/,{
3072 }/*-------------------------< NEGO_BAD_PHASE >------------*/,{
3078 }/*-------------------------< MSG_OUT_ABORT >-------------*/,{
3098 }/*-------------------------< HDATA_IN >-------------------*/,{
3111 **---------------------------------------------------------
3114 }/*-------------------------< HDATA_IN2 >------------------*/,{
3118 }/*-------------------------< HDATA_OUT >-------------------*/,{
3131 **---------------------------------------------------------
3134 }/*-------------------------< HDATA_OUT2 >------------------*/,{
3138 }/*-------------------------< RESET >----------------------*/,{
3147 }/*-------------------------< ABORTTAG >-------------------*/,{
3155 }/*-------------------------< ABORT >----------------------*/,{
3157 ** Abort a reselection when no active CCB.
3161 }/*-------------------------< ABORT_RESEL >----------------*/,{
3186 }/*-------------------------< RESEND_IDENT >-------------------*/,{
3197 }/*-------------------------< CLRATN_GO_ON >-------------------*/,{
3201 }/*-------------------------< NXTDSP_GO_ON >-------------------*/,{
3203 }/*-------------------------< SDATA_IN >-------------------*/,{
3212 }/*-------------------------< DATA_IO >--------------------*/,{
3217 ** savep --> DATA_IO
3218 ** lastp --> start pointer when DATA_IN
3219 ** goalp --> goal pointer when DATA_IN
3220 ** wlastp --> start pointer when DATA_OUT
3221 ** wgoalp --> goal pointer when DATA_OUT
3253 -64,
3254 }/*-------------------------< BAD_IDENTIFY >---------------*/,{
3279 }/*-------------------------< BAD_I_T_L >------------------*/,{
3289 }/*-------------------------< BAD_I_T_L_Q >----------------*/,{
3299 }/*-------------------------< BAD_TARGET >-----------------*/,{
3314 }/*-------------------------< BAD_STATUS >-----------------*/,{
3328 }/*-------------------------< START_RAM >-------------------*/,{
3330 ** Load the script into on-chip RAM,
3341 }/*-------------------------< START_RAM0 >--------------------*/,{
3346 }/*-------------------------< STO_RESTART >-------------------*/,{
3357 }/*-------------------------< WAIT_DMA >-------------------*/,{
3368 }/*-------------------------< SNOOPTEST >-------------------*/,{
3387 }/*-------------------------< SNOOPEND >-------------------*/,{
3393 }/*--------------------------------------------------------*/
3410 p = scrh->tryloop; in ncr_script_fill()
3416 BUG_ON((u_long)p != (u_long)&scrh->tryloop + sizeof (scrh->tryloop)); in ncr_script_fill()
3420 p = scrh->done_queue; in ncr_script_fill()
3429 BUG_ON((u_long)p != (u_long)&scrh->done_queue+sizeof(scrh->done_queue)); in ncr_script_fill()
3433 p = scrh->hdata_in; in ncr_script_fill()
3441 BUG_ON((u_long)p != (u_long)&scrh->hdata_in + sizeof (scrh->hdata_in)); in ncr_script_fill()
3443 p = scr->data_in; in ncr_script_fill()
3451 BUG_ON((u_long)p != (u_long)&scr->data_in + sizeof (scr->data_in)); in ncr_script_fill()
3453 p = scrh->hdata_out; in ncr_script_fill()
3461 BUG_ON((u_long)p != (u_long)&scrh->hdata_out + sizeof (scrh->hdata_out)); in ncr_script_fill()
3463 p = scr->data_out; in ncr_script_fill()
3471 BUG_ON((u_long) p != (u_long)&scr->data_out + sizeof (scr->data_out)); in ncr_script_fill()
3508 ncr_name(np), (int) (src-start-1)); in ncr_script_copy_and_bind()
3514 (src-1), (unsigned)opcode); in ncr_script_copy_and_bind()
3538 ncr_name(np), (int) (src-start-1)); in ncr_script_copy_and_bind()
3543 ** the NO FLUSH bit if present. in ncr_script_copy_and_bind()
3545 if ((opcode & SCR_NO_FLUSH) && !(np->features & FE_PFEN)) { in ncr_script_copy_and_bind()
3546 dst[-1] = cpu_to_scr(opcode & ~SCR_NO_FLUSH); in ncr_script_copy_and_bind()
3561 ** don't relocate if relative :-) in ncr_script_copy_and_bind()
3582 while (relocs--) { 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()
3637 #define PRINT_ADDR(cmd, arg...) dev_info(&cmd->device->sdev_gendev , ## arg)
3641 PRINT_ADDR(cp->cmd, "%s: ", label); in ncr_print_msg()
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()
3698 --bc; 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()
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()
3758 * Divisor to be used for async (timer pre-scaler). in ncr_prepare_setting()
3760 i = np->clock_divn - 1; in ncr_prepare_setting()
3761 while (--i >= 0) { 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()
3781 * Check against chip SCSI standard support (SCSI-2,ULTRA,ULTRA2). 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()
3870 ** - ULTRA2 chips (895/895A/896) report the current in ncr_prepare_setting()
3872 ** - For previous generation chips (825/825A/875), 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()
3937 tp->usrsync = driver_setup.default_sync; in ncr_prepare_setting()
3938 tp->usrwide = driver_setup.max_wide; in ncr_prepare_setting()
3939 tp->usrtags = MAX_TAGS; in ncr_prepare_setting()
3940 tp->period = 0xffff; 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()
3968 printk (KERN_INFO "%s: on-chip RAM at 0x%lx\n", in ncr_prepare_setting()
3969 ncr_name(np), np->paddr2); in ncr_prepare_setting()
3994 cmd->host_scribble = (char *) np->done_list; in ncr_queue_done_cmd()
3995 np->done_list = cmd; in ncr_queue_done_cmd()
4004 lcmd = (struct scsi_cmnd *) cmd->host_scribble; in ncr_flush_done_cmds()
4025 struct tcb *tp = &np->target[cp->target]; in ncr_prepare_nego()
4028 struct scsi_target *starget = tp->starget; in ncr_prepare_nego()
4031 if (!tp->widedone) { in ncr_prepare_nego()
4035 tp->widedone=1; in ncr_prepare_nego()
4039 if (!nego && !tp->period) { in ncr_prepare_nego()
4043 tp->period =0xffff; in ncr_prepare_nego()
4044 dev_info(&starget->dev, "target did not report SYNC.\n"); in ncr_prepare_nego()
4051 tp->maxoffs ? tp->minsync : 0, tp->maxoffs); in ncr_prepare_nego()
4054 msglen += spi_populate_width_msg(msgptr + msglen, tp->usrwide); in ncr_prepare_nego()
4058 cp->nego_status = nego; in ncr_prepare_nego()
4061 tp->nego_cp = cp; in ncr_prepare_nego()
4084 struct scsi_device *sdev = cmd->device; in ncr_queue_command()
4085 struct tcb *tp = &np->target[sdev->id]; in ncr_queue_command()
4086 struct lcb *lp = tp->lp[sdev->lun]; in ncr_queue_command()
4095 /*--------------------------------------------- in ncr_queue_command()
4099 **--------------------------------------------- in ncr_queue_command()
4101 if ((sdev->id == np->myaddr ) || in ncr_queue_command()
4102 (sdev->id >= MAX_TARGET) || in ncr_queue_command()
4103 (sdev->lun >= MAX_LUN )) { in ncr_queue_command()
4107 /*--------------------------------------------- in ncr_queue_command()
4114 **--------------------------------------------- in ncr_queue_command()
4116 if ((cmd->cmnd[0] == 0 || cmd->cmnd[0] == 0x12) && in ncr_queue_command()
4117 (tp->usrflag & UF_NOSCAN)) { in ncr_queue_command()
4118 tp->usrflag &= ~UF_NOSCAN; in ncr_queue_command()
4123 PRINT_ADDR(cmd, "CMD=%x ", cmd->cmnd[0]); in ncr_queue_command()
4126 /*--------------------------------------------------- in ncr_queue_command()
4131 ** If resetting or no free ccb, in ncr_queue_command()
4134 **---------------------------------------------------- in ncr_queue_command()
4136 if (np->settle_time && scsi_cmd_to_rq(cmd)->timeout >= HZ) { in ncr_queue_command()
4137 u_long tlimit = jiffies + 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()
4146 cp->cmd = cmd; in ncr_queue_command()
4148 /*---------------------------------------------------- in ncr_queue_command()
4152 **---------------------------------------------------- in ncr_queue_command()
4155 idmsg = IDENTIFY(0, sdev->lun); in ncr_queue_command()
4157 if (cp ->tag != NO_TAG || in ncr_queue_command()
4158 (cp != np->ccb && np->disc && !(tp->usrflag & UF_NODISC))) in ncr_queue_command()
4161 msgptr = cp->scsi_smsg; in ncr_queue_command()
4165 if (cp->tag != NO_TAG) { in ncr_queue_command()
4166 char order = np->order; in ncr_queue_command()
4172 if (lp && time_after(jiffies, lp->tags_stime)) { in ncr_queue_command()
4173 if (lp->tags_smap) { in ncr_queue_command()
4180 lp->tags_stime = jiffies + 3*HZ; in ncr_queue_command()
4181 lp->tags_smap = lp->tags_umap; in ncr_queue_command()
4188 switch (cmd->cmnd[0]) { in ncr_queue_command()
4204 msgptr[msglen++] = (cp->tag << 1) + 1; in ncr_queue_command()
4207 /*---------------------------------------------------- in ncr_queue_command()
4211 **---------------------------------------------------- in ncr_queue_command()
4214 direction = cmd->sc_data_direction; in ncr_queue_command()
4216 segments = ncr_scatter(np, cp, cp->cmd); in ncr_queue_command()
4223 cp->data_len = 0; in ncr_queue_command()
4227 /*--------------------------------------------------- in ncr_queue_command()
4233 **--------------------------------------------------- in ncr_queue_command()
4236 cp->nego_status = 0; in ncr_queue_command()
4238 if ((!tp->widedone || !tp->period) && !tp->nego_cp && lp) { in ncr_queue_command()
4242 /*---------------------------------------------------- in ncr_queue_command()
4246 **---------------------------------------------------- in ncr_queue_command()
4248 if (!cp->data_len) in ncr_queue_command()
4262 lastp = goalp - 8 - (segments * 16); in ncr_queue_command()
4265 lastp -= (segments - MAX_SCATTERL) * 16; in ncr_queue_command()
4269 cp->phys.header.wgoalp = cpu_to_scr(goalp); in ncr_queue_command()
4270 cp->phys.header.wlastp = cpu_to_scr(lastp); in ncr_queue_command()
4275 lastp = goalp - 8 - (segments * 16); in ncr_queue_command()
4278 lastp -= (segments - MAX_SCATTERL) * 16; in ncr_queue_command()
4291 cp->phys.header.lastp = cpu_to_scr(lastp); in ncr_queue_command()
4292 cp->phys.header.goalp = cpu_to_scr(goalp); in ncr_queue_command()
4295 cp->phys.header.savep = in ncr_queue_command()
4298 cp->phys.header.savep= cpu_to_scr(lastp); in ncr_queue_command()
4304 cp->startp = cp->phys.header.savep; in ncr_queue_command()
4306 /*---------------------------------------------------- in ncr_queue_command()
4310 **---------------------------------------------------- in ncr_queue_command()
4313 ** physical -> virtual backlink 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()
4325 cp->phys.select.sel_id = sdev_id(sdev); in ncr_queue_command()
4326 cp->phys.select.sel_scntl3 = tp->wval; in ncr_queue_command()
4327 cp->phys.select.sel_sxfer = tp->sval; in ncr_queue_command()
4331 cp->phys.smsg.addr = cpu_to_scr(CCB_PHYS (cp, scsi_smsg)); in ncr_queue_command()
4332 cp->phys.smsg.size = cpu_to_scr(msglen); in ncr_queue_command()
4337 memcpy(cp->cdb_buf, cmd->cmnd, min_t(int, cmd->cmd_len, sizeof(cp->cdb_buf))); in ncr_queue_command()
4338 cp->phys.cmd.addr = cpu_to_scr(CCB_PHYS (cp, cdb_buf[0])); in ncr_queue_command()
4339 cp->phys.cmd.size = cpu_to_scr(cmd->cmd_len); in ncr_queue_command()
4344 cp->actualquirks = 0; in ncr_queue_command()
4345 cp->host_status = cp->nego_status ? HS_NEGOTIATE : HS_BUSY; in ncr_queue_command()
4346 cp->scsi_status = SAM_STAT_ILLEGAL; in ncr_queue_command()
4347 cp->parity_status = 0; in ncr_queue_command()
4349 cp->xerr_status = XE_OK; in ncr_queue_command()
4351 /*---------------------------------------------------- in ncr_queue_command()
4355 **---------------------------------------------------- in ncr_queue_command()
4359 cp->magic = CCB_MAGIC; in ncr_queue_command()
4365 cp->auto_sense = 0; in ncr_queue_command()
4392 if (lp->held_ccb) in ncr_start_next_ccb()
4395 while (maxn-- && lp->queuedccbs < lp->queuedepth) { in ncr_start_next_ccb()
4396 qp = ncr_list_pop(&lp->wait_ccbq); in ncr_start_next_ccb()
4399 ++lp->queuedccbs; in ncr_start_next_ccb()
4401 list_add_tail(qp, &lp->busy_ccbq); in ncr_start_next_ccb()
4402 lp->jump_ccb[cp->tag == NO_TAG ? 0 : cp->tag] = in ncr_start_next_ccb()
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()
4425 cp->queued = 1; in ncr_put_start_queue()
4428 printk ("%s: queuepos=%d.\n", ncr_name (np), np->squeueput); in ncr_put_start_queue()
4444 np->settle_time = jiffies + settle_delay * HZ; in ncr_reset_scsi_bus()
4466 ** Check for no terminators or SCSI bus shorts to ground. in ncr_reset_scsi_bus()
4475 ((INW(nc_sbdl) & 0xff) << 9) | /* d7-0 */ in ncr_reset_scsi_bus()
4476 ((INW(nc_sbdl) & 0xff00) << 10) | /* d15-8 */ in ncr_reset_scsi_bus()
4479 if (!(np->features & FE_WIDE)) in ncr_reset_scsi_bus()
4485 printk("%s: %sdp0,d7-0,rst,req,ack,bsy,sel,atn,msg,c/d,i/o = " in ncr_reset_scsi_bus()
4488 (np->features & FE_WIDE) ? "dp1,d15-8," : "", in ncr_reset_scsi_bus()
4507 if (!np->settle_time) { in ncr_start_reset()
4526 if (np->settle_time) { in ncr_reset_bus()
4537 * Wake-up all awaiting commands with DID_RESET. in ncr_reset_bus()
4541 * Wake-up all pending commands with HS_RESET -> DID_RESET. in ncr_reset_bus()
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()
4575 else np->release_stage = 2; 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()
4612 if (cp->host_status) { in ncr_detach()
4614 ncr_name(np), cp->host_status); in ncr_detach()
4625 tp=&np->target[target]; in ncr_detach()
4627 lp = tp->lp[lun]; in ncr_detach()
4632 if (lp->jump_ccb != &lp->jump_ccb_0) in ncr_detach()
4633 m_free_dma(lp->jump_ccb,256,"JUMP_CCB"); 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()
4670 if (!cp || cp->magic != CCB_MAGIC || !cp->cmd) in ncr_complete()
4679 cp->host_status,cp->scsi_status); in ncr_complete()
4685 cmd = cp->cmd; in ncr_complete()
4686 cp->cmd = NULL; in ncr_complete()
4687 tp = &np->target[cmd->device->id]; in ncr_complete()
4688 lp = tp->lp[cmd->device->lun]; in ncr_complete()
4696 if (cp == tp->nego_cp) in ncr_complete()
4697 tp->nego_cp = NULL; in ncr_complete()
4700 ** If auto-sense performed, change scsi status. in ncr_complete()
4702 if (cp->auto_sense) { in ncr_complete()
4703 cp->scsi_status = cp->auto_sense; in ncr_complete()
4708 ** auto-sense, requeue skipped CCBs to the wait queue. in ncr_complete()
4711 if (lp && lp->held_ccb) { in ncr_complete()
4712 if (cp == lp->held_ccb) { in ncr_complete()
4713 list_splice_init(&lp->skip_ccbq, &lp->wait_ccbq); in ncr_complete()
4714 lp->held_ccb = NULL; in ncr_complete()
4722 if (cp->parity_status > 1) { in ncr_complete()
4723 PRINT_ADDR(cmd, "%d parity error(s).\n",cp->parity_status); in ncr_complete()
4730 if (cp->xerr_status != XE_OK) { in ncr_complete()
4731 switch (cp->xerr_status) { in ncr_complete()
4740 cp->xerr_status); in ncr_complete()
4743 if (cp->host_status==HS_COMPLETE) in ncr_complete()
4744 cp->host_status = HS_FAIL; in ncr_complete()
4751 if (cp->host_status != HS_COMPLETE || in ncr_complete()
4752 cp->scsi_status != SAM_STAT_GOOD) { in ncr_complete()
4754 "scsi_status=%x\n", cmd->cmnd[0], in ncr_complete()
4755 cp->host_status, cp->scsi_status); in ncr_complete()
4762 cmd->result = 0; in ncr_complete()
4763 if ( (cp->host_status == HS_COMPLETE) in ncr_complete()
4764 && (cp->scsi_status == SAM_STAT_GOOD || in ncr_complete()
4765 cp->scsi_status == SAM_STAT_CONDITION_MET)) { in ncr_complete()
4769 * `Pre-Fetch' or `Search data' success. in ncr_complete()
4771 set_status_byte(cmd, cp->scsi_status); in ncr_complete()
4778 /* if (cp->phys.header.lastp != cp->phys.header.goalp) */ in ncr_complete()
4784 ncr_alloc_lcb (np, cmd->device->id, cmd->device->lun); in ncr_complete()
4786 tp->bytes += cp->data_len; in ncr_complete()
4787 tp->transfers ++; in ncr_complete()
4793 if (lp && lp->usetags && lp->numtags < lp->maxtags) { in ncr_complete()
4794 ++lp->num_good; in ncr_complete()
4795 if (lp->num_good >= 1000) { in ncr_complete()
4796 lp->num_good = 0; in ncr_complete()
4797 ++lp->numtags; in ncr_complete()
4798 ncr_setup_tags (np, cmd->device); in ncr_complete()
4801 } else if ((cp->host_status == HS_COMPLETE) in ncr_complete()
4802 && (cp->scsi_status == SAM_STAT_CHECK_CONDITION)) { in ncr_complete()
4811 memcpy(cmd->sense_buffer, cp->sense_buf, in ncr_complete()
4813 sizeof(cp->sense_buf))); in ncr_complete()
4816 u_char *p = cmd->sense_buffer; in ncr_complete()
4822 } else if ((cp->host_status == HS_COMPLETE) in ncr_complete()
4823 && (cp->scsi_status == SAM_STAT_RESERVATION_CONFLICT)) { in ncr_complete()
4829 } else if ((cp->host_status == HS_COMPLETE) in ncr_complete()
4830 && (cp->scsi_status == SAM_STAT_BUSY || in ncr_complete()
4831 cp->scsi_status == SAM_STAT_TASK_SET_FULL)) { in ncr_complete()
4836 set_status_byte(cmd, cp->scsi_status); in ncr_complete()
4838 } else if ((cp->host_status == HS_SEL_TIMEOUT) in ncr_complete()
4839 || (cp->host_status == HS_TIMEOUT)) { in ncr_complete()
4842 ** No response in ncr_complete()
4844 set_status_byte(cmd, cp->scsi_status); in ncr_complete()
4847 } else if (cp->host_status == HS_RESET) { in ncr_complete()
4852 set_status_byte(cmd, cp->scsi_status); in ncr_complete()
4855 } else if (cp->host_status == HS_ABORTED) { in ncr_complete()
4860 set_status_byte(cmd, cp->scsi_status); in ncr_complete()
4869 cp->host_status, cp->scsi_status, cp); in ncr_complete()
4871 set_status_byte(cmd, cp->scsi_status); in ncr_complete()
4879 if (tp->usrflag & UF_TRACE) { in ncr_complete()
4883 p = (u_char*) &cmd->cmnd[0]; in ncr_complete()
4884 for (i=0; i<cmd->cmd_len; i++) printk (" %x", *p++); in ncr_complete()
4886 if (cp->host_status==HS_COMPLETE) { in ncr_complete()
4887 switch (cp->scsi_status) { in ncr_complete()
4893 p = (u_char*) &cmd->sense_buffer; in ncr_complete()
4898 printk (" STAT: %x\n", cp->scsi_status); in ncr_complete()
4901 } else printk (" HOSTERROR: %x", cp->host_status); in ncr_complete()
4913 if (lp && lp->queuedccbs < lp->queuedepth && in ncr_complete()
4914 !list_empty(&lp->wait_ccbq)) in ncr_complete()
4920 if (np->waiting_list) in ncr_complete()
4944 struct tcb *tp = &np->target[cp->target]; in ncr_ccb_skipped()
4945 struct lcb *lp = tp->lp[cp->lun]; in ncr_ccb_skipped()
4947 if (lp && cp != np->ccb) { in ncr_ccb_skipped()
4948 cp->host_status &= ~HS_SKIPMASK; in ncr_ccb_skipped()
4949 cp->start.schedule.l_paddr = in ncr_ccb_skipped()
4951 list_move_tail(&cp->link_ccbq, &lp->skip_ccbq); in ncr_ccb_skipped()
4952 if (cp->queued) { in ncr_ccb_skipped()
4953 --lp->queuedccbs; in ncr_ccb_skipped()
4956 if (cp->queued) { in ncr_ccb_skipped()
4957 --np->queuedccbs; in ncr_ccb_skipped()
4958 cp->queued = 0; in ncr_ccb_skipped()
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()
4986 np->scripth->done_queue[5*i + 4] = in ncr_wakeup_done()
4989 if (cp->host_status & HS_DONEMASK) in ncr_wakeup_done()
4991 else if (cp->host_status & HS_SKIPMASK) in ncr_wakeup_done()
4996 np->ccb_done_ic = i; in ncr_wakeup_done()
4998 cp = np->ccb; in ncr_wakeup_done()
5000 if (cp->host_status & HS_DONEMASK) in ncr_wakeup_done()
5002 else if (cp->host_status & HS_SKIPMASK) in ncr_wakeup_done()
5004 cp = cp->link_ccb; in ncr_wakeup_done()
5014 struct ccb *cp = np->ccb; in ncr_wakeup()
5017 if (cp->host_status != HS_IDLE) { in ncr_wakeup()
5018 cp->host_status = code; in ncr_wakeup()
5021 cp = cp->link_ccb; in ncr_wakeup()
5039 if (np->features & FE_EHP) in ncr_chip_reset()
5041 if (np->features & FE_MUX) in ncr_chip_reset()
5081 np->queuedepth = MAX_START - 1; /* 1 entry needed as end marker */ in ncr_init()
5083 np->scripth0->tryloop[i] = 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()
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()
5126 OUTB (nc_scntl0, np->rv_scntl0 | 0xc0); in ncr_init()
5127 /* full arb., ena parity, par->ATN */ 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()
5178 tp->sval = 0; in ncr_init()
5179 tp->wval = np->rv_scntl3; in ncr_init()
5181 if (tp->usrsync != 255) { 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()
5188 tp->usrsync = 255; 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()
5203 OUTL (nc_scratcha, vtobus(np->script0)); in ncr_init()
5224 u_long minsync = tp->usrsync; in ncr_negotiate()
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()
5251 tp->minsync = minsync; in ncr_negotiate()
5252 tp->maxoffs = (minsync<255 ? tp->maxoffs : 0); in ncr_negotiate()
5258 tp->period=0; in ncr_negotiate()
5263 tp->widedone=0; in ncr_negotiate()
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()
5285 ** Compute the synchronous period in tenths of nano-seconds in ncr_getsync()
5297 while (--div > 0) in ncr_getsync()
5304 fak = (kpc - 1) / div_10M[div] + 1; in ncr_getsync()
5311 *fakp = fak - 4; in ncr_getsync()
5327 struct tcb *tp = &np->target[target]; in ncr_set_sync_wide_status()
5332 OUTB (nc_sxfer, tp->sval); in ncr_set_sync_wide_status()
5333 np->sync_st = tp->sval; in ncr_set_sync_wide_status()
5334 OUTB (nc_scntl3, tp->wval); 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()
5341 if (!cp->cmd) continue; in ncr_set_sync_wide_status()
5342 if (scmd_id(cp->cmd) != target) continue; in ncr_set_sync_wide_status()
5343 cp->phys.select.sel_scntl3 = tp->wval; in ncr_set_sync_wide_status()
5344 cp->phys.select.sel_sxfer = tp->sval; in ncr_set_sync_wide_status()
5357 struct scsi_cmnd *cmd = cp->cmd; in ncr_setsync()
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()
5372 ** period is in tenths of nano-seconds. in ncr_setsync()
5377 tp->period = (((sxfer>>5)+4)*div_10M[idiv-1])/np->clock_khz; in ncr_setsync()
5379 tp->period = 0xffff; in ncr_setsync()
5382 if (tp->sval == sxfer && tp->wval == scntl3) in ncr_setsync()
5384 tp->sval = sxfer; in ncr_setsync()
5385 tp->wval = scntl3; in ncr_setsync()
5389 if (tp->period <= 2000) in ncr_setsync()
5393 spi_display_xfer_agreement(tp->starget); in ncr_setsync()
5414 struct scsi_cmnd *cmd = cp->cmd; in ncr_setwide()
5422 tp = &np->target[target]; in ncr_setwide()
5423 tp->widedone = wide+1; in ncr_setwide()
5424 scntl3 = (tp->wval & (~EWS)) | (wide ? EWS : 0); in ncr_setwide()
5426 sxfer = ack ? 0 : tp->sval; in ncr_setwide()
5431 if (tp->sval == sxfer && tp->wval == scntl3) return; in ncr_setwide()
5432 tp->sval = sxfer; in ncr_setwide()
5433 tp->wval = scntl3; in ncr_setwide()
5436 ** Bells and whistles ;-) in ncr_setwide()
5439 dev_info(&cmd->device->sdev_target->dev, "WIDE SCSI %sabled.\n", in ncr_setwide()
5459 unsigned char tn = sdev->id, ln = sdev->lun; in ncr_setup_tags()
5460 struct tcb *tp = &np->target[tn]; in ncr_setup_tags()
5461 struct lcb *lp = tp->lp[ln]; in ncr_setup_tags()
5473 if (!lp->scdev_depth) in ncr_setup_tags()
5481 maxdepth = lp->scdev_depth; in ncr_setup_tags()
5482 if (maxdepth > lp->maxnxs) maxdepth = lp->maxnxs; in ncr_setup_tags()
5483 if (lp->maxtags > maxdepth) lp->maxtags = maxdepth; in ncr_setup_tags()
5484 if (lp->numtags > maxdepth) lp->numtags = maxdepth; in ncr_setup_tags()
5491 if (sdev->tagged_supported && lp->numtags > 1) { in ncr_setup_tags()
5492 reqtags = lp->numtags; in ncr_setup_tags()
5500 lp->numtags = reqtags; in ncr_setup_tags()
5501 if (lp->numtags > lp->maxtags) in ncr_setup_tags()
5502 lp->maxtags = lp->numtags; in ncr_setup_tags()
5506 ** for no CCB to be active. in ncr_setup_tags()
5508 if (reqtags > 1 && lp->usetags) { /* Stay in tagged mode */ in ncr_setup_tags()
5509 if (lp->queuedepth == reqtags) /* Already announced */ in ncr_setup_tags()
5511 lp->queuedepth = reqtags; in ncr_setup_tags()
5513 else if (reqtags <= 1 && !lp->usetags) { /* Stay in untagged mode */ in ncr_setup_tags()
5514 lp->queuedepth = reqtags; in ncr_setup_tags()
5518 if (lp->busyccbs) /* If not yet safe, return */ in ncr_setup_tags()
5520 lp->queuedepth = reqtags; in ncr_setup_tags()
5521 lp->usetags = reqtags > 1 ? 1 : 0; in ncr_setup_tags()
5525 ** Patch the lun mini-script, according to tag mode. in ncr_setup_tags()
5527 lp->jump_tag.l_paddr = lp->usetags? in ncr_setup_tags()
5535 if (lp->usetags) { in ncr_setup_tags()
5536 dev_info(&sdev->sdev_gendev, in ncr_setup_tags()
5540 dev_info(&sdev->sdev_gendev, in ncr_setup_tags()
5557 **----------------------------------------------------------
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()
5586 np->settle_time = 0; in ncr_timeout()
5587 np->disc = 1; in ncr_timeout()
5598 if (np->lasttime + 4*HZ < thistime) { in ncr_timeout()
5602 np->lasttime = thistime; in ncr_timeout()
5622 ** "ncr0 targ 0?: ERROR (ds:si) (so-si-sd) (sxfer/scntl3) @ name (dsp:dbc)."
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()
5678 printk ("%s:%d: ERROR (%x:%x) (%x-%x-%x) (%x/%x) @ (%s %x:%08x).\n", in ncr_log_hard_error()
5798 ** DEL 397 - 53C875 Rev 3 - Part Number 609-0392410 - ITEM 2. in ncr_exception()
5819 ** we ignore them. In any case we do enough fix-up in ncr_exception()
5833 ** DEL 397 - 53C875 Rev 3 - Part Number 609-0392410 - ITEM 1. 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()
5902 ** Although a STO-Interrupt is pending,
5908 **----------------------------------------------------------
5922 cp = np->ccb; in ncr_int_sto()
5924 cp = cp->link_ccb; in ncr_int_sto()
5927 cp-> host_status = HS_SEL_TIMEOUT; in ncr_int_sto()
5945 ** spi2-r12 11.2.3 says a transceiver mode change must
5953 **----------------------------------------------------------
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()
5985 **----------------------------------------------------------
5993 int phase = -1; in ncr_int_par()
5994 int msg = -1; in ncr_int_par()
6045 np->msgout[0] = msg; in ncr_int_par()
6065 **----------------------------------------------------------
6099 ctest5 = (np->rv_ctest5 & DFS) ? INB (nc_ctest5) : 0; in ncr_int_ma()
6101 delta=(((ctest5 << 8) | (INB (nc_dfifo) & 0xff)) - rest) & 0x3ff; in ncr_int_ma()
6103 delta=(INB (nc_dfifo) - rest) & 0x7f; in ncr_int_ma()
6107 ** the target -> add the amount to the rest in ncr_int_ma()
6144 cp = np->header.cp; in ncr_int_ma()
6148 cp = np->ccb; in ncr_int_ma()
6150 cp = cp->link_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()
6171 vdsp = &cp->patch[0]; in ncr_int_ma()
6175 vdsp = &cp->patch[4]; in ncr_int_ma()
6186 cp, np->header.cp, in ncr_int_ma()
6193 ** block. This should not happen since we donnot use multi-byte in ncr_int_ma()
6200 ncr_name (np), (u_long) np->header.cp); in ncr_int_ma()
6211 tblp = (u32 *) ((char*) &cp->phys + oadr); in ncr_int_ma()
6232 PRINT_ADDR(cp->cmd, "internal error: cmd=%02x != %02x=(vdsp[0] " in ncr_int_ma()
6239 ** cp != np->header.cp means that the header of the CCB 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()
6255 PRINT_ADDR(cp->cmd, "phase change %x-%x %d@%08x resid=%d.\n", in ncr_int_ma()
6266 newcmd = cp->patch; in ncr_int_ma()
6268 if (newtmp == scr_to_cpu(cp->phys.header.savep)) { in ncr_int_ma()
6269 newcmd = &cp->patch[4]; in ncr_int_ma()
6278 newcmd[1] = cpu_to_scr(oadr + olen - rest); in ncr_int_ma()
6283 PRINT_ADDR(cp->cmd, "newcmd[%d] %x %x %x %x.\n", in ncr_int_ma()
6284 (int) (newcmd - cp->patch), in ncr_int_ma()
6306 ** COMMAND --> MSG IN SCSI parity error detected by target. in ncr_int_ma()
6307 ** COMMAND --> STATUS Bad command or refused by target. in ncr_int_ma()
6308 ** MSG OUT --> MSG IN Message rejected by target. in ncr_int_ma()
6309 ** MSG OUT --> COMMAND Bogus target that discards extended in ncr_int_ma()
6326 dsp -= 8; in ncr_int_ma()
6339 np->scripth->nxtdsp_go_on[0] = cpu_to_scr(dsp + 8); in ncr_int_ma()
6341 cp->host_status = HS_BUSY; in ncr_int_ma()
6368 struct scsi_cmnd *cmd = cp->cmd; in ncr_sir_to_redo()
6369 struct tcb *tp = &np->target[cmd->device->id]; in ncr_sir_to_redo()
6370 struct lcb *lp = tp->lp[cmd->device->lun]; in ncr_sir_to_redo()
6385 qp = lp->busy_ccbq.prev; in ncr_sir_to_redo()
6386 while (qp != &lp->busy_ccbq) { in ncr_sir_to_redo()
6388 qp = qp->prev; in ncr_sir_to_redo()
6392 cp2->start.schedule.l_paddr = in ncr_sir_to_redo()
6395 lp->held_ccb = cp; /* Requeue when this one completes */ in ncr_sir_to_redo()
6396 disc_cnt = lp->queuedccbs - busy_cnt; in ncr_sir_to_redo()
6412 if (disc_cnt < lp->numtags) { in ncr_sir_to_redo()
6413 lp->numtags = disc_cnt > 2 ? disc_cnt : 2; in ncr_sir_to_redo()
6414 lp->num_good = 0; in ncr_sir_to_redo()
6415 ncr_setup_tags (np, cmd->device); in ncr_sir_to_redo()
6423 cp->phys.header.savep = cp->startp; in ncr_sir_to_redo()
6424 cp->host_status = HS_BUSY; in ncr_sir_to_redo()
6425 cp->scsi_status = SAM_STAT_ILLEGAL; in ncr_sir_to_redo()
6437 if (cp->auto_sense) in ncr_sir_to_redo()
6447 cp->scsi_smsg2[0] = IDENTIFY(0, cmd->device->lun); in ncr_sir_to_redo()
6448 cp->phys.smsg.addr = cpu_to_scr(CCB_PHYS (cp, scsi_smsg2)); in ncr_sir_to_redo()
6449 cp->phys.smsg.size = cpu_to_scr(1); in ncr_sir_to_redo()
6454 cp->phys.cmd.addr = cpu_to_scr(CCB_PHYS (cp, sensecmd)); in ncr_sir_to_redo()
6455 cp->phys.cmd.size = cpu_to_scr(6); in ncr_sir_to_redo()
6460 cp->sensecmd[0] = 0x03; in ncr_sir_to_redo()
6461 cp->sensecmd[1] = (cmd->device->lun & 0x7) << 5; in ncr_sir_to_redo()
6462 cp->sensecmd[4] = sizeof(cp->sense_buf); in ncr_sir_to_redo()
6467 memset(cp->sense_buf, 0, sizeof(cp->sense_buf)); in ncr_sir_to_redo()
6468 cp->phys.sense.addr = cpu_to_scr(CCB_PHYS(cp,sense_buf[0])); in ncr_sir_to_redo()
6469 cp->phys.sense.size = cpu_to_scr(sizeof(cp->sense_buf)); in ncr_sir_to_redo()
6476 cp->phys.header.savep = startp; in ncr_sir_to_redo()
6477 cp->phys.header.goalp = startp + 24; in ncr_sir_to_redo()
6478 cp->phys.header.lastp = startp; in ncr_sir_to_redo()
6479 cp->phys.header.wgoalp = startp + 24; in ncr_sir_to_redo()
6480 cp->phys.header.wlastp = startp; in ncr_sir_to_redo()
6482 cp->host_status = HS_BUSY; in ncr_sir_to_redo()
6483 cp->scsi_status = SAM_STAT_ILLEGAL; in ncr_sir_to_redo()
6484 cp->auto_sense = s_status; in ncr_sir_to_redo()
6486 cp->start.schedule.l_paddr = in ncr_sir_to_redo()
6492 if (cmd->device->select_no_atn) in ncr_sir_to_redo()
6493 cp->start.schedule.l_paddr = in ncr_sir_to_redo()
6525 struct tcb *tp = &np->target[target]; in ncr_int_sir()
6526 struct scsi_target *starget = tp->starget; in ncr_int_sir()
6548 ** We just assume lun=0, 1 CCB, no tag. in ncr_int_sir()
6550 if (tp->lp[0]) { in ncr_int_sir()
6551 OUTL_DSP (scr_to_cpu(tp->lp[0]->jump_ccb[0])); in ncr_int_sir()
6569 cp = np->header.cp; in ncr_int_sir()
6578 cp = np->ccb; in ncr_int_sir()
6580 cp = cp->link_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()
6590 /*----------------------------------------------------------------------------- in ncr_int_sir()
6622 ** If the target doesn't fetch the answer (no message out phase), in ncr_int_sir()
6632 ** -> target doesn't msgin NEG FAIL noop defa. - dispatch in ncr_int_sir()
6633 ** -> target rejected our msg NEG FAIL reject defa. - dispatch in ncr_int_sir()
6634 ** -> target answered (ok) NEG SYNC sdtr set - clrack in ncr_int_sir()
6635 ** -> target answered (!ok) NEG SYNC sdtr defa. REJ--->msg_bad in ncr_int_sir()
6636 ** -> target answered (ok) NEG WIDE wdtr set - clrack in ncr_int_sir()
6637 ** -> target answered (!ok) NEG WIDE wdtr defa. REJ--->msg_bad in ncr_int_sir()
6638 ** -> any other msgin NEG FAIL noop defa. - dispatch in ncr_int_sir()
6641 ** -> incoming message --- SYNC sdtr set SDTR - in ncr_int_sir()
6642 ** -> incoming message --- WIDE wdtr set WDTR - in ncr_int_sir()
6644 ** -> target doesn't msgout --- PROTO ? defa. - dispatch in ncr_int_sir()
6646 **----------------------------------------------------------------------------- in ncr_int_sir()
6650 /*------------------------------------------------------- in ncr_int_sir()
6658 **------------------------------------------------------- in ncr_int_sir()
6665 /*------------------------------------------------------- in ncr_int_sir()
6670 **------------------------------------------------------- in ncr_int_sir()
6674 PRINT_ADDR(cp->cmd, "negotiation failed sir=%x " in ncr_int_sir()
6675 "status=%x.\n", num, cp->nego_status); in ncr_int_sir()
6682 switch (cp->nego_status) { in ncr_int_sir()
6696 np->msgin [0] = NOP; in ncr_int_sir()
6697 np->msgout[0] = NOP; in ncr_int_sir()
6698 cp->nego_status = 0; 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()
6725 if (per < tp->minsync) in ncr_int_sir()
6726 {chg = 1; per = tp->minsync;} in ncr_int_sir()
6727 if (ofs > tp->maxoffs) in ncr_int_sir()
6728 {chg = 1; ofs = tp->maxoffs;} in ncr_int_sir()
6746 tp->minsync = 0; in ncr_int_sir()
6750 PRINT_ADDR(cp->cmd, "sync: per=%d scntl3=0x%x ofs=%d " in ncr_int_sir()
6756 switch (cp->nego_status) { in ncr_int_sir()
6791 spi_populate_sync_msg(np->msgout, per, ofs); in ncr_int_sir()
6792 cp->nego_status = NS_SYNC; in ncr_int_sir()
6795 ncr_print_msg(cp, "sync msgout", np->msgout); 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()
6833 if (wide > tp->usrwide) in ncr_int_sir()
6834 {chg = 1; wide = tp->usrwide;} in ncr_int_sir()
6837 PRINT_ADDR(cp->cmd, "wide: wide=%d chg=%d.\n", wide, in ncr_int_sir()
6843 switch (cp->nego_status) { 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()
6881 cp->nego_status = NS_WIDE; in ncr_int_sir()
6884 ncr_print_msg(cp, "wide msgout", np->msgin); in ncr_int_sir()
6888 /*-------------------------------------------------------------------- in ncr_int_sir()
6892 **-------------------------------------------------------------------- in ncr_int_sir()
6896 /*----------------------------------------------- in ncr_int_sir()
6900 **----------------------------------------------- in ncr_int_sir()
6903 PRINT_ADDR(cp->cmd, "MESSAGE_REJECT received (%x:%x).\n", in ncr_int_sir()
6904 (unsigned)scr_to_cpu(np->lastmsg), np->msgout[0]); in ncr_int_sir()
6908 /*----------------------------------------------- in ncr_int_sir()
6912 **----------------------------------------------- in ncr_int_sir()
6915 ncr_print_msg(cp, "MESSAGE_REJECT sent for", np->msgin); in ncr_int_sir()
6918 /*-------------------------------------------------------------------- in ncr_int_sir()
6922 **-------------------------------------------------------------------- in ncr_int_sir()
6926 /*----------------------------------------------- in ncr_int_sir()
6931 **----------------------------------------------- in ncr_int_sir()
6934 PRINT_ADDR(cp->cmd, "IGNORE_WIDE_RESIDUE received, but not yet " in ncr_int_sir()
6939 /*----------------------------------------------- in ncr_int_sir()
6944 **----------------------------------------------- in ncr_int_sir()
6947 PRINT_ADDR(cp->cmd, "DISCONNECT received, but datapointer " 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()
6971 u_char tn = cmd->device->id; in ncr_get_ccb()
6972 u_char ln = cmd->device->lun; in ncr_get_ccb()
6973 struct tcb *tp = &np->target[tn]; in ncr_get_ccb()
6974 struct lcb *lp = tp->lp[ln]; in ncr_get_ccb()
6986 if (lp->usetags && lp->busyccbs >= lp->maxnxs) in ncr_get_ccb()
6992 if (list_empty(&lp->free_ccbq)) in ncr_get_ccb()
6998 qp = ncr_list_pop(&lp->free_ccbq); in ncr_get_ccb()
7001 if (cp->magic) { in ncr_get_ccb()
7006 list_add_tail(qp, &lp->wait_ccbq); in ncr_get_ccb()
7007 ++lp->busyccbs; in ncr_get_ccb()
7016 if (lp->usetags) in ncr_get_ccb()
7017 tag = lp->cb_tags[lp->ia_tag]; in ncr_get_ccb()
7019 else if (lp->actccbs > 0) in ncr_get_ccb()
7027 cp = np->ccb; in ncr_get_ccb()
7033 while (cp->magic) { in ncr_get_ccb()
7040 if (cp->magic) in ncr_get_ccb()
7043 cp->magic = 1; in ncr_get_ccb()
7050 ++lp->ia_tag; in ncr_get_ccb()
7051 if (lp->ia_tag == MAX_TAGS) in ncr_get_ccb()
7052 lp->ia_tag = 0; in ncr_get_ccb()
7053 lp->tags_umap |= (((tagmap_t) 1) << tag); in ncr_get_ccb()
7060 cp->tag = tag; in ncr_get_ccb()
7061 cp->target = tn; in ncr_get_ccb()
7062 cp->lun = ln; in ncr_get_ccb()
7082 struct tcb *tp = &np->target[cp->target]; in ncr_free_ccb()
7083 struct lcb *lp = tp->lp[cp->lun]; in ncr_free_ccb()
7086 PRINT_ADDR(cp->cmd, "ccb @%p freeing tag %d.\n", cp, cp->tag); in ncr_free_ccb()
7095 if (cp->tag != NO_TAG) { in ncr_free_ccb()
7096 lp->cb_tags[lp->if_tag++] = cp->tag; in ncr_free_ccb()
7097 if (lp->if_tag == MAX_TAGS) in ncr_free_ccb()
7098 lp->if_tag = 0; in ncr_free_ccb()
7099 lp->tags_umap &= ~(((tagmap_t) 1) << cp->tag); in ncr_free_ccb()
7100 lp->tags_smap &= lp->tags_umap; in ncr_free_ccb()
7101 lp->jump_ccb[cp->tag] = in ncr_free_ccb()
7104 lp->jump_ccb[0] = in ncr_free_ccb()
7114 if (cp != np->ccb) in ncr_free_ccb()
7115 list_move(&cp->link_ccbq, &lp->free_ccbq); in ncr_free_ccb()
7116 --lp->busyccbs; in ncr_free_ccb()
7117 if (cp->queued) { in ncr_free_ccb()
7118 --lp->queuedccbs; in ncr_free_ccb()
7121 cp -> host_status = HS_IDLE; in ncr_free_ccb()
7122 cp -> magic = 0; in ncr_free_ccb()
7123 if (cp->queued) { in ncr_free_ccb()
7124 --np->queuedccbs; in ncr_free_ccb()
7125 cp->queued = 0; 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))
7137 /*------------------------------------------------------------------------
7139 **------------------------------------------------------------------------
7140 **------------------------------------------------------------------------
7144 ncrcmd copy_4 = np->features & FE_PFEN ? SCR_COPY(4) : SCR_COPY_F(4); in ncr_init_ccb()
7149 cp->p_ccb = vtobus(cp); in ncr_init_ccb()
7150 cp->phys.header.cp = cp; in ncr_init_ccb()
7155 INIT_LIST_HEAD(&cp->link_ccbq); in ncr_init_ccb()
7163 cp->start.setup_dsa[0] = cpu_to_scr(copy_4); in ncr_init_ccb()
7164 cp->start.setup_dsa[1] = cpu_to_scr(CCB_PHYS(cp, start.p_phys)); in ncr_init_ccb()
7165 cp->start.setup_dsa[2] = cpu_to_scr(ncr_reg_bus_addr(nc_dsa)); in ncr_init_ccb()
7166 cp->start.schedule.l_cmd = cpu_to_scr(SCR_JUMP); in ncr_init_ccb()
7167 cp->start.p_phys = cpu_to_scr(CCB_PHYS(cp, phys)); in ncr_init_ccb()
7169 memcpy(&cp->restart, &cp->start, sizeof(cp->restart)); 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()
7176 /*------------------------------------------------------------------------
7178 **------------------------------------------------------------------------
7179 **------------------------------------------------------------------------
7183 struct tcb *tp = &np->target[tn]; in ncr_alloc_ccb()
7184 struct lcb *lp = tp->lp[ln]; in ncr_alloc_ccb()
7197 lp->actccbs++; in ncr_alloc_ccb()
7198 np->actccbs++; 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()
7209 list_add(&cp->link_ccbq, &lp->free_ccbq); in ncr_alloc_ccb()
7222 /*------------------------------------------------------------------------
7224 **------------------------------------------------------------------------
7228 **------------------------------------------------------------------------
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()
7241 tp->jump_tcb.l_cmd = in ncr_init_tcb()
7243 tp->jump_tcb.l_paddr = np->jump_tcb[th].l_paddr; in ncr_init_tcb()
7247 ** COPY @(tp->sval), @(sxfer) in ncr_init_tcb()
7249 tp->getscr[0] = cpu_to_scr(copy_1); in ncr_init_tcb()
7250 tp->getscr[1] = cpu_to_scr(vtobus (&tp->sval)); in ncr_init_tcb()
7252 tp->getscr[2] = cpu_to_scr(ncr_reg_bus_addr(nc_sxfer) ^ 3); in ncr_init_tcb()
7254 tp->getscr[2] = cpu_to_scr(ncr_reg_bus_addr(nc_sxfer)); in ncr_init_tcb()
7259 ** COPY @(tp->wval), @(scntl3) in ncr_init_tcb()
7261 tp->getscr[3] = cpu_to_scr(copy_1); in ncr_init_tcb()
7262 tp->getscr[4] = cpu_to_scr(vtobus (&tp->wval)); in ncr_init_tcb()
7264 tp->getscr[5] = cpu_to_scr(ncr_reg_bus_addr(nc_scntl3) ^ 3); in ncr_init_tcb()
7266 tp->getscr[5] = cpu_to_scr(ncr_reg_bus_addr(nc_scntl3)); in ncr_init_tcb()
7273 tp->call_lun.l_cmd = cpu_to_scr(SCR_CALL); in ncr_init_tcb()
7274 tp->call_lun.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_lun)); in ncr_init_tcb()
7282 tp->jump_lcb[i].l_cmd = in ncr_init_tcb()
7284 tp->jump_lcb[i].l_paddr = in ncr_init_tcb()
7291 np->jump_tcb[th].l_paddr = cpu_to_scr(vtobus (&tp->jump_tcb)); in ncr_init_tcb()
7310 /*------------------------------------------------------------------------
7312 **------------------------------------------------------------------------
7315 **------------------------------------------------------------------------
7319 struct tcb *tp = &np->target[tn]; in ncr_alloc_lcb()
7320 struct lcb *lp = tp->lp[ln]; in ncr_alloc_lcb()
7321 ncrcmd copy_4 = np->features & FE_PFEN ? SCR_COPY(4) : SCR_COPY_F(4); in ncr_alloc_lcb()
7337 tp->lp[ln] = lp; in ncr_alloc_lcb()
7342 if (!tp->jump_tcb.l_cmd) in ncr_alloc_lcb()
7348 INIT_LIST_HEAD(&lp->free_ccbq); in ncr_alloc_lcb()
7349 INIT_LIST_HEAD(&lp->busy_ccbq); in ncr_alloc_lcb()
7350 INIT_LIST_HEAD(&lp->wait_ccbq); in ncr_alloc_lcb()
7351 INIT_LIST_HEAD(&lp->skip_ccbq); in ncr_alloc_lcb()
7357 lp->maxnxs = 1; in ncr_alloc_lcb()
7358 lp->jump_ccb = &lp->jump_ccb_0; in ncr_alloc_lcb()
7359 lp->p_jump_ccb = cpu_to_scr(vtobus(lp->jump_ccb)); in ncr_alloc_lcb()
7369 ** COPY @(lp->p_jump_ccb), @(temp) in ncr_alloc_lcb()
7372 lp->jump_lcb.l_cmd = in ncr_alloc_lcb()
7374 lp->jump_lcb.l_paddr = tp->jump_lcb[lh].l_paddr; in ncr_alloc_lcb()
7376 lp->load_jump_ccb[0] = cpu_to_scr(copy_4); in ncr_alloc_lcb()
7377 lp->load_jump_ccb[1] = cpu_to_scr(vtobus (&lp->p_jump_ccb)); in ncr_alloc_lcb()
7378 lp->load_jump_ccb[2] = cpu_to_scr(ncr_reg_bus_addr(nc_temp)); in ncr_alloc_lcb()
7380 lp->jump_tag.l_cmd = cpu_to_scr(SCR_JUMP); in ncr_alloc_lcb()
7381 lp->jump_tag.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_notag)); in ncr_alloc_lcb()
7386 tp->jump_lcb[lh].l_paddr = cpu_to_scr(vtobus (&lp->jump_lcb)); in ncr_alloc_lcb()
7391 lp->busyccbs = 1; in ncr_alloc_lcb()
7392 lp->queuedccbs = 1; in ncr_alloc_lcb()
7393 lp->queuedepth = 1; in ncr_alloc_lcb()
7399 /*------------------------------------------------------------------------
7401 **------------------------------------------------------------------------
7404 ** will play with CHANGE DEFINITION commands. :-)
7405 **------------------------------------------------------------------------
7409 unsigned char tn = sdev->id, ln = sdev->lun; in ncr_setup_lcb()
7410 struct tcb *tp = &np->target[tn]; in ncr_setup_lcb()
7411 struct lcb *lp = tp->lp[ln]; in ncr_setup_lcb()
7413 /* If no lcb, try to allocate it. */ in ncr_setup_lcb()
7421 if (sdev->tagged_supported && lp->jump_ccb == &lp->jump_ccb_0) { in ncr_setup_lcb()
7423 lp->jump_ccb = m_calloc_dma(256, "JUMP_CCB"); in ncr_setup_lcb()
7424 if (!lp->jump_ccb) { in ncr_setup_lcb()
7425 lp->jump_ccb = &lp->jump_ccb_0; in ncr_setup_lcb()
7428 lp->p_jump_ccb = cpu_to_scr(vtobus(lp->jump_ccb)); in ncr_setup_lcb()
7430 lp->jump_ccb[i] = in ncr_setup_lcb()
7433 lp->cb_tags[i] = i; in ncr_setup_lcb()
7434 lp->maxnxs = MAX_TAGS; in ncr_setup_lcb()
7435 lp->tags_stime = jiffies + 3*HZ; in ncr_setup_lcb()
7457 **----------------------------------------------------------
7478 cp->data_len = 0; in ncr_scatter()
7487 return -1; in ncr_scatter()
7490 data = &cp->phys.data[MAX_SCATTER - use_sg]; in ncr_scatter()
7497 cp->data_len += len; in ncr_scatter()
7500 segment = -2; in ncr_scatter()
7508 ** Test the bus snoop logic :-(
7532 printk ("CACHE TEST FAILED: reg dstat-sstat2 readback %x.\n",
7543 if (np->reg) {
7556 np->ncr_cache = cpu_to_scr(host_wr);
7575 host_rd = scr_to_cpu(np->ncr_cache);
7629 ** THERE IS NO SAFE DEFAULT VALUE.
7640 **----------------------------------------------------------
7648 if (np->multiplier < 2) {
7657 if (np->multiplier > 2) { /* Poll bit 5 of stest4 for quadrupler */
7659 while (!(INB(nc_stest4) & LCKFRQ) && --i > 0)
7663 } else /* Wait 20 micro-seconds for doubler */
7700 OUTB (nc_scntl3, 4); /* set pre-scaler to divide by 3 */
7732 np->multiplier = 1;
7741 np->multiplier = mult;
7749 if (np->multiplier != mult || (scntl3 & 7) < 3 || !(scntl3 & 1)) {
7770 np->multiplier = mult;
7777 f1 /= np->multiplier;
7783 f1 *= np->multiplier;
7784 np->clock_khz = f1;
7791 struct Scsi_Host *host = device->host;
7792 struct ncb *np = ((struct host_data *) host->hostdata)->ncb;
7793 struct tcb *tp = &np->target[device->id];
7794 tp->starget = device->sdev_target;
7801 struct Scsi_Host *host = device->host;
7802 struct ncb *np = ((struct host_data *) host->hostdata)->ncb;
7803 struct tcb *tp = &np->target[device->id];
7804 struct lcb *lp = tp->lp[device->lun];
7815 numtags = device_queue_depth(np->unit, device->id, device->lun);
7816 if (numtags > tp->usrtags)
7817 numtags = tp->usrtags;
7818 if (!device->tagged_supported)
7838 lp->numtags = lp->maxtags = numtags;
7839 lp->scdev_depth = depth_to_use;
7845 np->unit, device->id, device->lun, depth_to_use);
7848 if (spi_support_sync(device->sdev_target) &&
7849 !spi_initial_dv(device->sdev_target))
7858 struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
7866 cmd->host_scribble = NULL;
7867 cmd_priv->data_mapped = 0;
7868 cmd_priv->data_mapping = 0;
7870 spin_lock_irqsave(&np->smp_lock, flags);
7875 printk("ncr53c8xx : command not queued - result=%d\n", sts);
7883 spin_unlock_irqrestore(&np->smp_lock, flags);
7900 struct host_data *host_data = (struct host_data *)shost->hostdata;
7901 struct ncb *np = host_data->ncb;
7910 spin_lock_irqsave(&np->smp_lock, flags);
7912 done_list = np->done_list;
7913 np->done_list = NULL;
7914 spin_unlock_irqrestore(&np->smp_lock, flags);
7929 spin_lock_irqsave(&np->smp_lock, flags);
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;
7947 * If the mid-level driver told us reset is synchronous, it seems
7949 * even if this command was not queued to the low-level driver,
7953 spin_lock_irqsave(&np->smp_lock, flags);
7956 done_list = np->done_list;
7957 np->done_list = NULL;
7958 spin_unlock_irqrestore(&np->smp_lock, flags);
7988 cmd->next_wcmd = NULL;
7989 if (!(wcmd = np->waiting_list)) np->waiting_list = cmd;
7991 while (wcmd->next_wcmd)
7992 wcmd = (struct scsi_cmnd *) wcmd->next_wcmd;
7993 wcmd->next_wcmd = (char *) cmd;
8001 waiting_list = np->waiting_list;
8002 np->waiting_list = NULL;
8008 waiting_list = (struct scsi_cmnd *) wcmd->next_wcmd;
8009 wcmd->next_wcmd = NULL;
8032 struct host_data *host_data = (struct host_data *)host->hostdata;
8034 return snprintf(buf, 20, "0x%x\n", host_data->ncb->revision_id);
8088 WARN_ON_ONCE(tpnt->cmd_size < sizeof(struct ncr_cmd_priv));
8090 if (!tpnt->name)
8091 tpnt->name = SCSI_NCR_DRIVER_NAME;
8092 if (!tpnt->shost_groups)
8093 tpnt->shost_groups = ncr53c8xx_host_groups;
8095 tpnt->queuecommand = ncr53c8xx_queue_command;
8096 tpnt->slave_configure = ncr53c8xx_slave_configure;
8097 tpnt->slave_alloc = ncr53c8xx_slave_alloc;
8098 tpnt->eh_bus_reset_handler = ncr53c8xx_bus_reset;
8099 tpnt->can_queue = SCSI_NCR_CAN_QUEUE;
8100 tpnt->this_id = 7;
8101 tpnt->sg_tablesize = SCSI_NCR_SG_TABLESIZE;
8102 tpnt->cmd_per_lun = SCSI_NCR_CMD_PER_LUN;
8104 if (device->differential)
8105 driver_setup.diff_support = device->differential;
8107 printk(KERN_INFO "ncr53c720-%d: rev 0x%x irq %d\n",
8108 unit, device->chip.revision_id, device->slot.irq);
8113 host_data = (struct host_data *) instance->hostdata;
8115 np = __m_calloc_dma(device->dev, sizeof(struct ncb), "NCB");
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;
8153 if (device->slot.base_v)
8154 np->vaddr = device->slot.base_v;
8156 np->vaddr = ioremap(device->slot.base_c, 128);
8158 if (!np->vaddr) {
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;
8177 if (np->paddr2 && sizeof(struct script) > 4096) {
8178 np->paddr2 = 0;
8183 instance->max_channel = 0;
8184 instance->this_id = np->myaddr;
8185 instance->max_id = np->maxwide ? 16 : 8;
8186 instance->max_lun = SCSI_NCR_MAX_LUN;
8187 instance->base = (unsigned long) np->reg;
8188 instance->irq = device->slot.irq;
8189 instance->unique_id = device->slot.base;
8190 instance->dma_channel = 0;
8191 instance->cmd_per_lun = MAX_TAGS;
8192 instance->can_queue = (MAX_START-4);
8196 instance->transportt = ncr53c8xx_transport_template;
8201 np->scripth = np->scripth0;
8202 np->p_scripth = vtobus(np->scripth);
8203 np->p_script = (np->paddr2) ? np->paddr2 : vtobus(np->script0);
8206 (ncrcmd *) np->script0, sizeof(struct script));
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 =
8244 np->irq = device->slot.irq;
8247 ncr_init_ccb(np, np->ccb);
8255 spin_lock_irqsave(&np->smp_lock, flags);
8257 …printk(KERN_ERR "%s: FATAL ERROR: CHECK SCSI BUS - CABLES, TERMINATION, DEVICE POWER etc.!\n", ncr…
8259 spin_unlock_irqrestore(&np->smp_lock, flags);
8264 np->disc = 1;
8267 * The middle-level SCSI driver does not wait for devices to settle.
8277 np->lasttime=0;
8282 np->order = SIMPLE_QUEUE_TAG;
8285 spin_unlock_irqrestore(&np->smp_lock, flags);
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");
8302 host_data->ncb = NULL;
8317 if (host_data->ncb)
8318 ncr_detach(host_data->ncb);
8324 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
8325 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
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;
8333 tp->usrsync = period;
8340 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
8341 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
8342 struct tcb *tp = &np->target[starget->id];
8344 if (offset > np->maxoffs)
8345 offset = np->maxoffs;
8349 tp->maxoffs = offset;
8356 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
8357 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
8358 struct tcb *tp = &np->target[starget->id];
8360 if (width > np->maxwide)
8361 width = np->maxwide;
8365 tp->usrwide = width;
8372 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
8375 switch (np->scsi_mode) {
8403 return -ENODEV;