Lines Matching +full:- +full:dig +full:- +full:div
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.
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>
154 struct list_head *elem = head->next; in ncr_list_pop()
165 ** Simple power of two buddy-like allocator.
174 ** Enhanced in linux-2.3.44 to provide a memory pool
192 #define MEMO_CLUSTER_MASK (MEMO_CLUSTER_SIZE-1)
194 typedef u_long m_addr_t; /* Enough bits to bit-hack addresses */
208 #define VTOB_HASH_MASK (VTOB_HASH_SIZE-1)
219 struct m_link h[PAGE_SHIFT-MEMO_SHIFT+MEMO_PAGE_ORDER+1];
228 m_link_s *h = mp->h; in ___m_alloc()
241 h[j].next = (m_link_s *)mp->getp(mp); in ___m_alloc()
243 h[j].next->next = NULL; in ___m_alloc()
251 h[j].next = h[j].next->next; in ___m_alloc()
253 j -= 1; in ___m_alloc()
256 h[j].next->next = NULL; in ___m_alloc()
271 m_link_s *h = mp->h; in ___m_free()
290 mp->freep(mp, a); in ___m_free()
296 while (q->next && q->next != (m_link_s *) b) { in ___m_free()
297 q = q->next; in ___m_free()
299 if (!q->next) { in ___m_free()
300 ((m_link_s *) a)->next = h[i].next; in ___m_free()
304 q->next = q->next->next; in ___m_free()
320 printk ("new %-10s[%4d] @%p.\n", name, size, p); in __m_calloc2()
335 printk ("freeing %-10s[%4d] @%p.\n", name, size, ptr); in __m_free()
351 ++mp->nump; in ___mp0_getp()
358 --mp->nump; in ___mp0_freep()
379 vp = (m_addr_t) dma_alloc_coherent(mp->bush, in ___dma_getp()
384 vbp->vaddr = vp; in ___dma_getp()
385 vbp->baddr = daddr; in ___dma_getp()
386 vbp->next = mp->vtob[hc]; in ___dma_getp()
387 mp->vtob[hc] = vbp; in ___dma_getp()
388 ++mp->nump; in ___dma_getp()
402 vbpp = &mp->vtob[hc]; in ___dma_freep()
403 while (*vbpp && (*vbpp)->vaddr != m) in ___dma_freep()
404 vbpp = &(*vbpp)->next; in ___dma_freep()
407 *vbpp = (*vbpp)->next; in ___dma_freep()
408 dma_free_coherent(mp->bush, PAGE_SIZE<<MEMO_PAGE_ORDER, in ___dma_freep()
409 (void *)vbp->vaddr, (dma_addr_t)vbp->baddr); in ___dma_freep()
411 --mp->nump; in ___dma_freep()
418 for (mp = mp0.next; mp && mp->bush != bush; mp = mp->next); in ___get_dma_pool()
428 mp->bush = bush; in ___cre_dma_pool()
429 mp->getp = ___dma_getp; in ___cre_dma_pool()
430 mp->freep = ___dma_freep; in ___cre_dma_pool()
431 mp->next = mp0.next; in ___cre_dma_pool()
442 pp = &(*pp)->next; in ___del_dma_pool()
444 *pp = (*pp)->next; in ___del_dma_pool()
461 if (mp && !mp->nump) in __m_calloc_dma()
477 if (mp && !mp->nump) in __m_free_dma()
493 vp = mp->vtob[hc]; in __vtobus()
494 while (vp && (m_addr_t) vp->vaddr != a) in __vtobus()
495 vp = vp->next; in __vtobus()
498 return vp ? vp->baddr + (((m_addr_t) m) - a) : 0; in __vtobus()
501 #define _m_calloc_dma(np, s, n) __m_calloc_dma(np->dev, s, n)
502 #define _m_free_dma(np, p, s, n) __m_free_dma(np->dev, p, s, n)
505 #define _vtobus(np, p) __vtobus(np->dev, p)
518 switch(cmd->__data_mapped) { in __unmap_scsi_data()
523 cmd->__data_mapped = 0; in __unmap_scsi_data()
534 cmd->__data_mapped = 2; in __map_scsi_sg_data()
535 cmd->__data_mapping = use_sg; in __map_scsi_sg_data()
540 #define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd)
541 #define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd)
548 ** options. It can be overridden at boot-up by the boot
564 #define bootverbose (np->verbose)
645 if (!strncmp(p, cur, pc - cur)) in get_setup_token()
680 i < sizeof(driver_setup.tag_ctrl)-1) { in sym53c8xx__setup()
763 printk("sym53c8xx_setup: unexpected boot option '%.*s' ignored\n", (int)(pc-cur+1), cur); in sym53c8xx__setup()
782 #define ALL_TARGETS -2
783 #define NO_TARGET -1
784 #define ALL_LUNS -2
785 #define NO_LUN -1
793 h = -1; in device_queue_depth()
819 case '-': in device_queue_depth()
839 ** atomically, 64 bit little-endian architecture requires
859 /* All > 32 bit (64 bit) architectures regardless endian-ness */
917 ** n permits target numbers 0..n-1.
930 ** n enables logic unit numbers 0..n-1.
942 ** Asynchronous pre-scaler (ns). Shall be 40
975 ** The data scripts are broken into 2 sub-scripts.
976 ** 80 (MAX_SCATTERL) segments are moved from a sub-script
977 ** in on-chip RAM. This makes data transfers shorter than
985 #define MAX_SCATTERH (MAX_SCATTER - MAX_SCATTERL)
987 #define MAX_SCATTERL (MAX_SCATTER-1)
1004 #define bootverbose (np->verbose)
1151 /*----------------------------------------------------------------
1157 **----------------------------------------------------------------
1161 /*----------------------------------------------------------------
1167 **----------------------------------------------------------------
1171 /*----------------------------------------------------------------
1175 **----------------------------------------------------------------
1179 /*----------------------------------------------------------------
1187 **----------------------------------------------------------------
1192 /*----------------------------------------------------------------
1196 **----------------------------------------------------------------
1200 /*----------------------------------------------------------------
1202 **----------------------------------------------------------------
1207 /*----------------------------------------------------------------
1209 **----------------------------------------------------------------
1244 /*----------------------------------------------------------------
1256 **----------------------------------------------------------------
1263 /*----------------------------------------------------------------
1269 **----------------------------------------------------------------
1274 /*----------------------------------------------------------------
1276 **----------------------------------------------------------------
1289 /*----------------------------------------------------------------
1293 **----------------------------------------------------------------
1302 /*----------------------------------------------------------------
1304 **----------------------------------------------------------------
1306 /*----------------------------------------------------------------
1308 **----------------------------------------------------------------
1327 **------------------------------------------------------------------------
1330 /*----------------------------------------------------------------
1333 **----------------------------------------------------------------
1351 **------------------------------------------------------------------------
1355 /*----------------------------------------------------------------
1361 **----------------------------------------------------------------
1367 /*----------------------------------------------------------------
1371 **----------------------------------------------------------------
1376 /*----------------------------------------------------------------
1378 **----------------------------------------------------------------
1382 /*----------------------------------------------------------------
1384 **----------------------------------------------------------------
1468 ** the script-processor-changeable data and
1471 **----------------------------------------------------------
1501 /*----------------------------------------------------------------
1506 **----------------------------------------------------------------
1510 /*----------------------------------------------------------------
1511 ** Mini-script used at CCB execution start-up.
1514 **----------------------------------------------------------------
1518 /*----------------------------------------------------------------
1519 ** Mini-script used at CCB relection to restart the nexus.
1522 **----------------------------------------------------------------
1526 /*----------------------------------------------------------------
1531 **----------------------------------------------------------------
1535 /*----------------------------------------------------------------
1538 **----------------------------------------------------------------
1545 /*----------------------------------------------------------------
1553 **----------------------------------------------------------------
1558 /*----------------------------------------------------------------
1560 **----------------------------------------------------------------
1576 #define CCB_PHYS(cp,lbl) (cp->p_ccb + offsetof(struct ccb, lbl))
1586 /*----------------------------------------------------------------
1591 **----------------------------------------------------------------
1595 /*----------------------------------------------------------------
1597 **----------------------------------------------------------------
1605 /*----------------------------------------------------------------
1607 **----------------------------------------------------------------
1612 /*----------------------------------------------------------------
1616 **----------------------------------------------------------------
1621 /*----------------------------------------------------------------
1625 **----------------------------------------------------------------
1630 /*----------------------------------------------------------------
1639 **----------------------------------------------------------------
1644 /*----------------------------------------------------------------
1646 **----------------------------------------------------------------
1650 unsigned long paddr2; /* On-chip RAM bus address. */
1654 /*----------------------------------------------------------------
1656 ** 'script' is loaded in the on-chip RAM if present.
1658 **----------------------------------------------------------------
1666 /*----------------------------------------------------------------
1668 **----------------------------------------------------------------
1684 /*----------------------------------------------------------------
1688 **----------------------------------------------------------------
1695 /*----------------------------------------------------------------
1697 **----------------------------------------------------------------
1703 /*----------------------------------------------------------------
1705 **----------------------------------------------------------------
1710 /*----------------------------------------------------------------
1711 ** Miscellaneous buffers accessed by the scripts-processor.
1714 **----------------------------------------------------------------
1721 /*----------------------------------------------------------------
1723 **----------------------------------------------------------------
1732 /*----------------------------------------------------------------
1734 **----------------------------------------------------------------
1740 /*----------------------------------------------------------------
1742 **----------------------------------------------------------------
1749 #define NCB_SCRIPT_PHYS(np,lbl) (np->p_script + offsetof (struct script, lbl))
1750 #define NCB_SCRIPTH_PHYS(np,lbl) (np->p_scripth + offsetof (struct scripth,lbl))
1755 ** Script for NCR-Processor.
1770 **----------------------------------------------------------
1791 ** Script fragments which are loaded into the on-chip RAM
1954 return np->inst_name; in ncr_name()
1961 ** Scripts for NCR-Processor.
1974 **----------------------------------------------------------
2001 * THESE MUST ALL BE ALIGNED TO A 4-BYTE BOUNDARY.
2008 /*--------------------------< START >-----------------------*/ {
2026 }/*-------------------------< STARTPOS >--------------------*/,{
2029 }/*-------------------------< SELECT >----------------------*/,{
2053 }/*-------------------------< SELECT2 >----------------------*/,{
2070 ** complete or selection time-out to occur.
2098 ** COPY command with the DSA-register.
2114 }/*-------------------------< LOADPOS >---------------------*/,{
2119 ** to complete or time-out.
2124 }/*-------------------------< SEND_IDENT >----------------------*/,{
2139 }/*-------------------------< PREPARE >----------------------*/,{
2153 }/*-------------------------< PREPARE2 >---------------------*/,{
2174 }/*-------------------------< COMMAND >--------------------*/,{
2190 }/*-----------------------< DISPATCH >----------------------*/,{
2202 ** DEL 397 - 53C875 Rev 3 - Part Number 609-0392410 - ITEM 4.
2204 ** This work-around resets the addressing logic prior to the
2240 }/*-------------------------< CLRACK >----------------------*/,{
2249 }/*-------------------------< NO_DATA >--------------------*/,{
2279 }/*-------------------------< STATUS >--------------------*/,{
2295 }/*-------------------------< MSG_IN >--------------------*/,{
2305 }/*-------------------------< MSG_IN2 >--------------------*/,{
2332 }/*-------------------------< MSG_BAD >------------------*/,{
2334 ** unimplemented message - reject it.
2340 }/*-------------------------< SETMSG >----------------------*/,{
2348 }/*-------------------------< CLEANUP >-------------------*/,{
2353 ** HS_REG: Host-Status (<>0!)
2366 }/*-------------------------< COMPLETE >-----------------*/,{
2395 }/*-------------------------< CLEANUP_OK >----------------*/,{
2414 }/*-------------------------< CLEANUP0 >--------------------*/,{
2416 }/*-------------------------< SIGNAL >----------------------*/,{
2455 }/*------------------------< DONE_POS >---------------------*/,{
2457 }/*------------------------< DONE_PLUG >--------------------*/,{
2460 }/*------------------------< DONE_END >---------------------*/,{
2471 }/*-------------------------< SAVE_DP >------------------*/,{
2483 }/*-------------------------< RESTORE_DP >---------------*/,{
2494 }/*-------------------------< DISCONNECT >---------------*/,{
2518 }/*-------------------------< MSG_OUT >-------------------*/,{
2538 }/*-------------------------< MSG_OUT_DONE >--------------*/,{
2552 }/*-------------------------< IDLE >------------------------*/,{
2561 }/*-------------------------< RESELECT >--------------------*/,{
2579 }/*-------------------------< RESELECTED >------------------*/,{
2593 ** - struct ncb
2594 ** - struct tcb
2595 ** - struct lcb
2596 ** - struct ccb
2606 }/*-------------------------< RESEL_DSA >-------------------*/,{
2619 ** COPY command with the DSA-register.
2636 }/*-------------------------< LOADPOS1 >-------------------*/,{
2645 }/*-------------------------< RESEL_LUN >-------------------*/,{
2666 }/*-------------------------< RESEL_TAG >-------------------*/,{
2671 ** driver only supports conformant devices for tags. ;-)
2677 ** Still an aggressive optimization. ;-)
2686 }/*-------------------------< JUMP_TO_NEXUS >-------------------*/,{
2695 }/*-------------------------< NEXUS_INDIRECT >-------------------*/,{
2700 }/*-------------------------< RESEL_NOTAG >-------------------*/,{
2709 }/*-------------------------< DATA_IN >--------------------*/,{
2722 **---------------------------------------------------------
2725 }/*-------------------------< DATA_IN2 >-------------------*/,{
2730 }/*-------------------------< DATA_OUT >--------------------*/,{
2743 **---------------------------------------------------------
2746 }/*-------------------------< DATA_OUT2 >-------------------*/,{
2751 }/*--------------------------------------------------------*/
2755 /*-------------------------< TRYLOOP >---------------------*/{
2765 **-----------------------------------------------------------
2772 **-----------------------------------------------------------
2775 }/*------------------------< TRYLOOP2 >---------------------*/,{
2781 }/*------------------------< DONE_QUEUE >-------------------*/,{
2788 **-----------------------------------------------------------
2798 **-----------------------------------------------------------
2801 }/*------------------------< DONE_QUEUE2 >------------------*/,{
2806 }/*------------------------< SELECT_NO_ATN >-----------------*/,{
2821 }/*-------------------------< CANCEL >------------------------*/,{
2827 }/*-------------------------< SKIP >------------------------*/,{
2844 ** COPY command with the DSA-register.
2860 }/*-------------------------< SKIP2 >---------------------*/,{
2887 },/*-------------------------< PAR_ERR_DATA_IN >---------------*/{
2896 -24,
2897 },/*-------------------------< PAR_ERR_OTHER >------------------*/{
2908 }/*-------------------------< MSG_REJECT >---------------*/,{
2924 }/*-------------------------< MSG_IGN_RESIDUE >----------*/,{
2972 }/*-------------------------< MSG_EXTENDED >-------------*/,{
2991 }/*-------------------------< MSG_EXT_2 >----------------*/,{
3008 }/*-------------------------< MSG_WDTR >-----------------*/,{
3033 }/*-------------------------< SEND_WDTR >----------------*/,{
3045 }/*-------------------------< MSG_EXT_3 >----------------*/,{
3063 }/*-------------------------< MSG_SDTR >-----------------*/,{
3088 }/*-------------------------< SEND_SDTR >-------------*/,{
3100 }/*-------------------------< NEGO_BAD_PHASE >------------*/,{
3106 }/*-------------------------< MSG_OUT_ABORT >-------------*/,{
3126 }/*-------------------------< HDATA_IN >-------------------*/,{
3139 **---------------------------------------------------------
3142 }/*-------------------------< HDATA_IN2 >------------------*/,{
3146 }/*-------------------------< HDATA_OUT >-------------------*/,{
3159 **---------------------------------------------------------
3162 }/*-------------------------< HDATA_OUT2 >------------------*/,{
3166 }/*-------------------------< RESET >----------------------*/,{
3175 }/*-------------------------< ABORTTAG >-------------------*/,{
3183 }/*-------------------------< ABORT >----------------------*/,{
3189 }/*-------------------------< ABORT_RESEL >----------------*/,{
3214 }/*-------------------------< RESEND_IDENT >-------------------*/,{
3225 }/*-------------------------< CLRATN_GO_ON >-------------------*/,{
3229 }/*-------------------------< NXTDSP_GO_ON >-------------------*/,{
3231 }/*-------------------------< SDATA_IN >-------------------*/,{
3240 }/*-------------------------< DATA_IO >--------------------*/,{
3245 ** savep --> DATA_IO
3246 ** lastp --> start pointer when DATA_IN
3247 ** goalp --> goal pointer when DATA_IN
3248 ** wlastp --> start pointer when DATA_OUT
3249 ** wgoalp --> goal pointer when DATA_OUT
3281 -64,
3282 }/*-------------------------< BAD_IDENTIFY >---------------*/,{
3307 }/*-------------------------< BAD_I_T_L >------------------*/,{
3317 }/*-------------------------< BAD_I_T_L_Q >----------------*/,{
3327 }/*-------------------------< BAD_TARGET >-----------------*/,{
3342 }/*-------------------------< BAD_STATUS >-----------------*/,{
3356 }/*-------------------------< START_RAM >-------------------*/,{
3358 ** Load the script into on-chip RAM,
3369 }/*-------------------------< START_RAM0 >--------------------*/,{
3374 }/*-------------------------< STO_RESTART >-------------------*/,{
3385 }/*-------------------------< WAIT_DMA >-------------------*/,{
3396 }/*-------------------------< SNOOPTEST >-------------------*/,{
3415 }/*-------------------------< SNOOPEND >-------------------*/,{
3421 }/*--------------------------------------------------------*/
3438 p = scrh->tryloop; in ncr_script_fill()
3444 BUG_ON((u_long)p != (u_long)&scrh->tryloop + sizeof (scrh->tryloop)); in ncr_script_fill()
3448 p = scrh->done_queue; in ncr_script_fill()
3457 BUG_ON((u_long)p != (u_long)&scrh->done_queue+sizeof(scrh->done_queue)); in ncr_script_fill()
3461 p = scrh->hdata_in; in ncr_script_fill()
3469 BUG_ON((u_long)p != (u_long)&scrh->hdata_in + sizeof (scrh->hdata_in)); in ncr_script_fill()
3471 p = scr->data_in; in ncr_script_fill()
3479 BUG_ON((u_long)p != (u_long)&scr->data_in + sizeof (scr->data_in)); in ncr_script_fill()
3481 p = scrh->hdata_out; in ncr_script_fill()
3489 BUG_ON((u_long)p != (u_long)&scrh->hdata_out + sizeof (scrh->hdata_out)); in ncr_script_fill()
3491 p = scr->data_out; in ncr_script_fill()
3499 BUG_ON((u_long) p != (u_long)&scr->data_out + sizeof (scr->data_out)); in ncr_script_fill()
3536 ncr_name(np), (int) (src-start-1)); in ncr_script_copy_and_bind()
3542 (src-1), (unsigned)opcode); 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()
3574 dst[-1] = cpu_to_scr(opcode & ~SCR_NO_FLUSH); in ncr_script_copy_and_bind()
3589 ** don't relocate if relative :-) in ncr_script_copy_and_bind()
3610 while (relocs--) { 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()
3665 #define PRINT_ADDR(cmd, arg...) dev_info(&cmd->device->sdev_gendev , ## arg)
3669 PRINT_ADDR(cp->cmd, "%s: ", label); in ncr_print_msg()
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()
3726 --bc; 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()
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()
3786 * Divisor to be used for async (timer pre-scaler). in ncr_prepare_setting()
3788 i = np->clock_divn - 1; in ncr_prepare_setting()
3789 while (--i >= 0) { 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()
3809 * Check against chip SCSI standard support (SCSI-2,ULTRA,ULTRA2). 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()
3898 ** - ULTRA2 chips (895/895A/896) report the current in ncr_prepare_setting()
3900 ** - For previous generation chips (825/825A/875), 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()
3965 tp->usrsync = driver_setup.default_sync; in ncr_prepare_setting()
3966 tp->usrwide = driver_setup.max_wide; in ncr_prepare_setting()
3967 tp->usrtags = MAX_TAGS; in ncr_prepare_setting()
3968 tp->period = 0xffff; 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()
3996 printk (KERN_INFO "%s: on-chip RAM at 0x%lx\n", in ncr_prepare_setting()
3997 ncr_name(np), np->paddr2); in ncr_prepare_setting()
4022 cmd->host_scribble = (char *) np->done_list; in ncr_queue_done_cmd()
4023 np->done_list = cmd; in ncr_queue_done_cmd()
4032 lcmd = (struct scsi_cmnd *) cmd->host_scribble; in ncr_flush_done_cmds()
4033 cmd->scsi_done(cmd); in ncr_flush_done_cmds()
4053 struct tcb *tp = &np->target[cp->target]; in ncr_prepare_nego()
4056 struct scsi_target *starget = tp->starget; in ncr_prepare_nego()
4059 if (!tp->widedone) { in ncr_prepare_nego()
4063 tp->widedone=1; in ncr_prepare_nego()
4067 if (!nego && !tp->period) { in ncr_prepare_nego()
4071 tp->period =0xffff; in ncr_prepare_nego()
4072 dev_info(&starget->dev, "target did not report SYNC.\n"); in ncr_prepare_nego()
4079 tp->maxoffs ? tp->minsync : 0, tp->maxoffs); in ncr_prepare_nego()
4082 msglen += spi_populate_width_msg(msgptr + msglen, tp->usrwide); in ncr_prepare_nego()
4086 cp->nego_status = nego; in ncr_prepare_nego()
4089 tp->nego_cp = cp; in ncr_prepare_nego()
4112 struct scsi_device *sdev = cmd->device; in ncr_queue_command()
4113 struct tcb *tp = &np->target[sdev->id]; in ncr_queue_command()
4114 struct lcb *lp = tp->lp[sdev->lun]; in ncr_queue_command()
4123 /*--------------------------------------------- in ncr_queue_command()
4127 **--------------------------------------------- in ncr_queue_command()
4129 if ((sdev->id == np->myaddr ) || in ncr_queue_command()
4130 (sdev->id >= MAX_TARGET) || in ncr_queue_command()
4131 (sdev->lun >= MAX_LUN )) { in ncr_queue_command()
4135 /*--------------------------------------------- in ncr_queue_command()
4142 **--------------------------------------------- in ncr_queue_command()
4144 if ((cmd->cmnd[0] == 0 || cmd->cmnd[0] == 0x12) && in ncr_queue_command()
4145 (tp->usrflag & UF_NOSCAN)) { in ncr_queue_command()
4146 tp->usrflag &= ~UF_NOSCAN; in ncr_queue_command()
4151 PRINT_ADDR(cmd, "CMD=%x ", cmd->cmnd[0]); in ncr_queue_command()
4154 /*--------------------------------------------------- in ncr_queue_command()
4162 **---------------------------------------------------- in ncr_queue_command()
4164 if (np->settle_time && cmd->request->timeout >= HZ) { in ncr_queue_command()
4165 u_long tlimit = jiffies + 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()
4174 cp->cmd = cmd; in ncr_queue_command()
4176 /*---------------------------------------------------- in ncr_queue_command()
4180 **---------------------------------------------------- in ncr_queue_command()
4183 idmsg = IDENTIFY(0, sdev->lun); in ncr_queue_command()
4185 if (cp ->tag != NO_TAG || in ncr_queue_command()
4186 (cp != np->ccb && np->disc && !(tp->usrflag & UF_NODISC))) in ncr_queue_command()
4189 msgptr = cp->scsi_smsg; in ncr_queue_command()
4193 if (cp->tag != NO_TAG) { in ncr_queue_command()
4194 char order = np->order; in ncr_queue_command()
4200 if (lp && time_after(jiffies, lp->tags_stime)) { in ncr_queue_command()
4201 if (lp->tags_smap) { in ncr_queue_command()
4208 lp->tags_stime = jiffies + 3*HZ; in ncr_queue_command()
4209 lp->tags_smap = lp->tags_umap; in ncr_queue_command()
4216 switch (cmd->cmnd[0]) { in ncr_queue_command()
4232 msgptr[msglen++] = (cp->tag << 1) + 1; in ncr_queue_command()
4235 /*---------------------------------------------------- in ncr_queue_command()
4239 **---------------------------------------------------- in ncr_queue_command()
4242 direction = cmd->sc_data_direction; in ncr_queue_command()
4244 segments = ncr_scatter(np, cp, cp->cmd); in ncr_queue_command()
4251 cp->data_len = 0; in ncr_queue_command()
4255 /*--------------------------------------------------- in ncr_queue_command()
4261 **--------------------------------------------------- in ncr_queue_command()
4264 cp->nego_status = 0; in ncr_queue_command()
4266 if ((!tp->widedone || !tp->period) && !tp->nego_cp && lp) { in ncr_queue_command()
4270 /*---------------------------------------------------- in ncr_queue_command()
4274 **---------------------------------------------------- in ncr_queue_command()
4276 if (!cp->data_len) in ncr_queue_command()
4290 lastp = goalp - 8 - (segments * 16); in ncr_queue_command()
4293 lastp -= (segments - MAX_SCATTERL) * 16; in ncr_queue_command()
4297 cp->phys.header.wgoalp = cpu_to_scr(goalp); in ncr_queue_command()
4298 cp->phys.header.wlastp = cpu_to_scr(lastp); in ncr_queue_command()
4303 lastp = goalp - 8 - (segments * 16); in ncr_queue_command()
4306 lastp -= (segments - MAX_SCATTERL) * 16; in ncr_queue_command()
4319 cp->phys.header.lastp = cpu_to_scr(lastp); in ncr_queue_command()
4320 cp->phys.header.goalp = cpu_to_scr(goalp); in ncr_queue_command()
4323 cp->phys.header.savep = in ncr_queue_command()
4326 cp->phys.header.savep= cpu_to_scr(lastp); in ncr_queue_command()
4332 cp->startp = cp->phys.header.savep; in ncr_queue_command()
4334 /*---------------------------------------------------- in ncr_queue_command()
4338 **---------------------------------------------------- in ncr_queue_command()
4341 ** physical -> virtual backlink 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()
4353 cp->phys.select.sel_id = sdev_id(sdev); in ncr_queue_command()
4354 cp->phys.select.sel_scntl3 = tp->wval; in ncr_queue_command()
4355 cp->phys.select.sel_sxfer = tp->sval; in ncr_queue_command()
4359 cp->phys.smsg.addr = cpu_to_scr(CCB_PHYS (cp, scsi_smsg)); in ncr_queue_command()
4360 cp->phys.smsg.size = cpu_to_scr(msglen); in ncr_queue_command()
4365 memcpy(cp->cdb_buf, cmd->cmnd, min_t(int, cmd->cmd_len, sizeof(cp->cdb_buf))); in ncr_queue_command()
4366 cp->phys.cmd.addr = cpu_to_scr(CCB_PHYS (cp, cdb_buf[0])); in ncr_queue_command()
4367 cp->phys.cmd.size = cpu_to_scr(cmd->cmd_len); in ncr_queue_command()
4372 cp->actualquirks = 0; in ncr_queue_command()
4373 cp->host_status = cp->nego_status ? HS_NEGOTIATE : HS_BUSY; in ncr_queue_command()
4374 cp->scsi_status = S_ILLEGAL; in ncr_queue_command()
4375 cp->parity_status = 0; in ncr_queue_command()
4377 cp->xerr_status = XE_OK; in ncr_queue_command()
4379 cp->sync_status = tp->sval; in ncr_queue_command()
4380 cp->wide_status = tp->wval; in ncr_queue_command()
4383 /*---------------------------------------------------- in ncr_queue_command()
4387 **---------------------------------------------------- in ncr_queue_command()
4391 cp->magic = CCB_MAGIC; in ncr_queue_command()
4397 cp->auto_sense = 0; in ncr_queue_command()
4424 if (lp->held_ccb) in ncr_start_next_ccb()
4427 while (maxn-- && lp->queuedccbs < lp->queuedepth) { in ncr_start_next_ccb()
4428 qp = ncr_list_pop(&lp->wait_ccbq); in ncr_start_next_ccb()
4431 ++lp->queuedccbs; in ncr_start_next_ccb()
4433 list_add_tail(qp, &lp->busy_ccbq); in ncr_start_next_ccb()
4434 lp->jump_ccb[cp->tag == NO_TAG ? 0 : cp->tag] = in ncr_start_next_ccb()
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()
4457 cp->queued = 1; in ncr_put_start_queue()
4460 printk ("%s: queuepos=%d.\n", ncr_name (np), np->squeueput); in ncr_put_start_queue()
4476 np->settle_time = jiffies + settle_delay * HZ; in ncr_reset_scsi_bus()
4507 ((INW(nc_sbdl) & 0xff) << 9) | /* d7-0 */ in ncr_reset_scsi_bus()
4508 ((INW(nc_sbdl) & 0xff00) << 10) | /* d15-8 */ in ncr_reset_scsi_bus()
4511 if (!(np->features & FE_WIDE)) in ncr_reset_scsi_bus()
4517 printk("%s: %sdp0,d7-0,rst,req,ack,bsy,sel,atn,msg,c/d,i/o = " in ncr_reset_scsi_bus()
4520 (np->features & FE_WIDE) ? "dp1,d15-8," : "", in ncr_reset_scsi_bus()
4539 if (!np->settle_time) { in ncr_start_reset()
4555 /* struct scsi_device *device = cmd->device; */ in ncr_reset_bus()
4562 if (np->settle_time) { in ncr_reset_bus()
4575 for (found=0, cp=np->ccb; cp; cp=cp->link_ccb) { in ncr_reset_bus()
4579 if (cp->host_status == HS_IDLE) continue; in ncr_reset_bus()
4580 if (cp->cmd == cmd) { in ncr_reset_bus()
4591 * Wake-up all awaiting commands with DID_RESET. in ncr_reset_bus()
4595 * Wake-up all pending commands with HS_RESET -> DID_RESET. in ncr_reset_bus()
4605 cmd->result = DID_RESET << 16; in ncr_reset_bus()
4624 /* struct scsi_device *device = cmd->device; */
4633 cmd->result = ScsiResult(DID_ABORT, 0);
4641 for (found=0, cp=np->ccb; cp; cp=cp->link_ccb) {
4645 if (cp->host_status == HS_IDLE) continue;
4646 if (cp->cmd == cmd) {
4656 if (np->settle_time) {
4665 switch(cp->host_status) {
4669 cp->start.schedule.l_paddr =
4674 cp->restart.schedule.l_paddr =
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()
4722 else np->release_stage = 2; 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()
4759 if (cp->host_status) { in ncr_detach()
4761 ncr_name(np), cp->host_status); in ncr_detach()
4772 tp=&np->target[target]; in ncr_detach()
4774 lp = tp->lp[lun]; in ncr_detach()
4779 if (lp->jump_ccb != &lp->jump_ccb_0) in ncr_detach()
4780 m_free_dma(lp->jump_ccb,256,"JUMP_CCB"); 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()
4817 if (!cp || cp->magic != CCB_MAGIC || !cp->cmd) in ncr_complete()
4826 cp->host_status,cp->scsi_status); in ncr_complete()
4832 cmd = cp->cmd; in ncr_complete()
4833 cp->cmd = NULL; in ncr_complete()
4834 tp = &np->target[cmd->device->id]; in ncr_complete()
4835 lp = tp->lp[cmd->device->lun]; in ncr_complete()
4843 if (cp == tp->nego_cp) in ncr_complete()
4844 tp->nego_cp = NULL; in ncr_complete()
4847 ** If auto-sense performed, change scsi status. in ncr_complete()
4849 if (cp->auto_sense) { in ncr_complete()
4850 cp->scsi_status = cp->auto_sense; in ncr_complete()
4855 ** auto-sense, requeue skipped CCBs to the wait queue. in ncr_complete()
4858 if (lp && lp->held_ccb) { in ncr_complete()
4859 if (cp == lp->held_ccb) { in ncr_complete()
4860 list_splice_init(&lp->skip_ccbq, &lp->wait_ccbq); in ncr_complete()
4861 lp->held_ccb = NULL; in ncr_complete()
4869 if (cp->parity_status > 1) { in ncr_complete()
4870 PRINT_ADDR(cmd, "%d parity error(s).\n",cp->parity_status); in ncr_complete()
4877 if (cp->xerr_status != XE_OK) { in ncr_complete()
4878 switch (cp->xerr_status) { in ncr_complete()
4887 cp->xerr_status); in ncr_complete()
4890 if (cp->host_status==HS_COMPLETE) in ncr_complete()
4891 cp->host_status = HS_FAIL; in ncr_complete()
4898 if (cp->host_status!=HS_COMPLETE || cp->scsi_status!=S_GOOD) { in ncr_complete()
4900 "scsi_status=%x\n", cmd->cmnd[0], in ncr_complete()
4901 cp->host_status, cp->scsi_status); in ncr_complete()
4908 if ( (cp->host_status == HS_COMPLETE) in ncr_complete()
4909 && (cp->scsi_status == S_GOOD || in ncr_complete()
4910 cp->scsi_status == S_COND_MET)) { in ncr_complete()
4914 * `Pre-Fetch' or `Search data' success. in ncr_complete()
4916 cmd->result = ScsiResult(DID_OK, cp->scsi_status); in ncr_complete()
4920 ** Could dig out the correct value for resid, in ncr_complete()
4923 /* if (cp->phys.header.lastp != cp->phys.header.goalp) */ in ncr_complete()
4929 ncr_alloc_lcb (np, cmd->device->id, cmd->device->lun); in ncr_complete()
4931 tp->bytes += cp->data_len; in ncr_complete()
4932 tp->transfers ++; in ncr_complete()
4938 if (lp && lp->usetags && lp->numtags < lp->maxtags) { in ncr_complete()
4939 ++lp->num_good; in ncr_complete()
4940 if (lp->num_good >= 1000) { in ncr_complete()
4941 lp->num_good = 0; in ncr_complete()
4942 ++lp->numtags; in ncr_complete()
4943 ncr_setup_tags (np, cmd->device); in ncr_complete()
4946 } else if ((cp->host_status == HS_COMPLETE) in ncr_complete()
4947 && (cp->scsi_status == S_CHECK_COND)) { in ncr_complete()
4951 cmd->result = DID_OK << 16 | S_CHECK_COND; in ncr_complete()
4956 memcpy(cmd->sense_buffer, cp->sense_buf, in ncr_complete()
4958 sizeof(cp->sense_buf))); in ncr_complete()
4961 u_char *p = cmd->sense_buffer; in ncr_complete()
4967 } else if ((cp->host_status == HS_COMPLETE) in ncr_complete()
4968 && (cp->scsi_status == S_CONFLICT)) { in ncr_complete()
4972 cmd->result = DID_OK << 16 | S_CONFLICT; in ncr_complete()
4974 } else if ((cp->host_status == HS_COMPLETE) in ncr_complete()
4975 && (cp->scsi_status == S_BUSY || in ncr_complete()
4976 cp->scsi_status == S_QUEUE_FULL)) { in ncr_complete()
4981 cmd->result = ScsiResult(DID_OK, cp->scsi_status); in ncr_complete()
4983 } else if ((cp->host_status == HS_SEL_TIMEOUT) in ncr_complete()
4984 || (cp->host_status == HS_TIMEOUT)) { in ncr_complete()
4989 cmd->result = ScsiResult(DID_TIME_OUT, cp->scsi_status); in ncr_complete()
4991 } else if (cp->host_status == HS_RESET) { in ncr_complete()
4996 cmd->result = ScsiResult(DID_RESET, cp->scsi_status); in ncr_complete()
4998 } else if (cp->host_status == HS_ABORTED) { in ncr_complete()
5003 cmd->result = ScsiResult(DID_ABORT, cp->scsi_status); in ncr_complete()
5011 cp->host_status, cp->scsi_status, cp); in ncr_complete()
5013 cmd->result = ScsiResult(DID_ERROR, cp->scsi_status); in ncr_complete()
5020 if (tp->usrflag & UF_TRACE) { in ncr_complete()
5024 p = (u_char*) &cmd->cmnd[0]; in ncr_complete()
5025 for (i=0; i<cmd->cmd_len; i++) printk (" %x", *p++); in ncr_complete()
5027 if (cp->host_status==HS_COMPLETE) { in ncr_complete()
5028 switch (cp->scsi_status) { in ncr_complete()
5034 p = (u_char*) &cmd->sense_buffer; in ncr_complete()
5039 printk (" STAT: %x\n", cp->scsi_status); in ncr_complete()
5042 } else printk (" HOSTERROR: %x", cp->host_status); in ncr_complete()
5054 if (lp && lp->queuedccbs < lp->queuedepth && in ncr_complete()
5055 !list_empty(&lp->wait_ccbq)) in ncr_complete()
5061 if (np->waiting_list) in ncr_complete()
5085 struct tcb *tp = &np->target[cp->target]; in ncr_ccb_skipped()
5086 struct lcb *lp = tp->lp[cp->lun]; in ncr_ccb_skipped()
5088 if (lp && cp != np->ccb) { in ncr_ccb_skipped()
5089 cp->host_status &= ~HS_SKIPMASK; in ncr_ccb_skipped()
5090 cp->start.schedule.l_paddr = in ncr_ccb_skipped()
5092 list_move_tail(&cp->link_ccbq, &lp->skip_ccbq); in ncr_ccb_skipped()
5093 if (cp->queued) { in ncr_ccb_skipped()
5094 --lp->queuedccbs; in ncr_ccb_skipped()
5097 if (cp->queued) { in ncr_ccb_skipped()
5098 --np->queuedccbs; in ncr_ccb_skipped()
5099 cp->queued = 0; in ncr_ccb_skipped()
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()
5127 np->scripth->done_queue[5*i + 4] = in ncr_wakeup_done()
5130 if (cp->host_status & HS_DONEMASK) in ncr_wakeup_done()
5132 else if (cp->host_status & HS_SKIPMASK) in ncr_wakeup_done()
5137 np->ccb_done_ic = i; in ncr_wakeup_done()
5139 cp = np->ccb; in ncr_wakeup_done()
5141 if (cp->host_status & HS_DONEMASK) in ncr_wakeup_done()
5143 else if (cp->host_status & HS_SKIPMASK) in ncr_wakeup_done()
5145 cp = cp->link_ccb; in ncr_wakeup_done()
5155 struct ccb *cp = np->ccb; in ncr_wakeup()
5158 if (cp->host_status != HS_IDLE) { in ncr_wakeup()
5159 cp->host_status = code; in ncr_wakeup()
5162 cp = cp->link_ccb; in ncr_wakeup()
5180 if (np->features & FE_EHP) in ncr_chip_reset()
5182 if (np->features & FE_MUX) in ncr_chip_reset()
5222 np->queuedepth = MAX_START - 1; /* 1 entry needed as end marker */ in ncr_init()
5224 np->scripth0->tryloop[i] = 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()
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()
5267 OUTB (nc_scntl0, np->rv_scntl0 | 0xc0); in ncr_init()
5268 /* full arb., ena parity, par->ATN */ 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()
5319 tp->sval = 0; in ncr_init()
5320 tp->wval = np->rv_scntl3; in ncr_init()
5322 if (tp->usrsync != 255) { 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()
5329 tp->usrsync = 255; 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()
5344 OUTL (nc_scratcha, vtobus(np->script0)); in ncr_init()
5365 u_long minsync = tp->usrsync; in ncr_negotiate()
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()
5392 tp->minsync = minsync; in ncr_negotiate()
5393 tp->maxoffs = (minsync<255 ? tp->maxoffs : 0); in ncr_negotiate()
5399 tp->period=0; in ncr_negotiate()
5404 tp->widedone=0; in ncr_negotiate()
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() local
5426 ** Compute the synchronous period in tenths of nano-seconds in ncr_getsync()
5438 while (--div > 0) in ncr_getsync()
5439 if (kpc >= (div_10M[div] << 2)) break; in ncr_getsync()
5445 fak = (kpc - 1) / div_10M[div] + 1; in ncr_getsync()
5449 per = (fak * div_10M[div]) / clk; in ncr_getsync()
5456 if (div >= 1 && fak < 8) { in ncr_getsync()
5458 fak2 = (kpc - 1) / div_10M[div-1] + 1; in ncr_getsync()
5459 per2 = (fak2 * div_10M[div-1]) / clk; in ncr_getsync()
5463 --div; in ncr_getsync()
5473 *fakp = fak - 4; in ncr_getsync()
5474 *scntl3p = ((div+1) << 4) + (sfac < 25 ? 0x80 : 0); in ncr_getsync()
5489 struct tcb *tp = &np->target[target]; in ncr_set_sync_wide_status()
5494 OUTB (nc_sxfer, tp->sval); in ncr_set_sync_wide_status()
5495 np->sync_st = tp->sval; in ncr_set_sync_wide_status()
5496 OUTB (nc_scntl3, tp->wval); 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()
5503 if (!cp->cmd) continue; in ncr_set_sync_wide_status()
5504 if (scmd_id(cp->cmd) != target) continue; in ncr_set_sync_wide_status()
5506 cp->sync_status = tp->sval; in ncr_set_sync_wide_status()
5507 cp->wide_status = tp->wval; in ncr_set_sync_wide_status()
5509 cp->phys.select.sel_scntl3 = tp->wval; in ncr_set_sync_wide_status()
5510 cp->phys.select.sel_sxfer = tp->sval; in ncr_set_sync_wide_status()
5523 struct scsi_cmnd *cmd = cp->cmd; in ncr_setsync()
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()
5538 ** period is in tenths of nano-seconds. in ncr_setsync()
5543 tp->period = (((sxfer>>5)+4)*div_10M[idiv-1])/np->clock_khz; in ncr_setsync()
5545 tp->period = 0xffff; in ncr_setsync()
5548 if (tp->sval == sxfer && tp->wval == scntl3) in ncr_setsync()
5550 tp->sval = sxfer; in ncr_setsync()
5551 tp->wval = scntl3; in ncr_setsync()
5555 if (tp->period <= 2000) in ncr_setsync()
5559 spi_display_xfer_agreement(tp->starget); in ncr_setsync()
5580 struct scsi_cmnd *cmd = cp->cmd; in ncr_setwide()
5588 tp = &np->target[target]; in ncr_setwide()
5589 tp->widedone = wide+1; in ncr_setwide()
5590 scntl3 = (tp->wval & (~EWS)) | (wide ? EWS : 0); in ncr_setwide()
5592 sxfer = ack ? 0 : tp->sval; in ncr_setwide()
5597 if (tp->sval == sxfer && tp->wval == scntl3) return; in ncr_setwide()
5598 tp->sval = sxfer; in ncr_setwide()
5599 tp->wval = scntl3; in ncr_setwide()
5602 ** Bells and whistles ;-) in ncr_setwide()
5605 dev_info(&cmd->device->sdev_target->dev, "WIDE SCSI %sabled.\n", in ncr_setwide()
5625 unsigned char tn = sdev->id, ln = sdev->lun; in ncr_setup_tags()
5626 struct tcb *tp = &np->target[tn]; in ncr_setup_tags()
5627 struct lcb *lp = tp->lp[ln]; in ncr_setup_tags()
5639 if (!lp->scdev_depth) in ncr_setup_tags()
5647 maxdepth = lp->scdev_depth; in ncr_setup_tags()
5648 if (maxdepth > lp->maxnxs) maxdepth = lp->maxnxs; in ncr_setup_tags()
5649 if (lp->maxtags > maxdepth) lp->maxtags = maxdepth; in ncr_setup_tags()
5650 if (lp->numtags > maxdepth) lp->numtags = maxdepth; in ncr_setup_tags()
5657 if (sdev->tagged_supported && lp->numtags > 1) { in ncr_setup_tags()
5658 reqtags = lp->numtags; in ncr_setup_tags()
5666 lp->numtags = reqtags; in ncr_setup_tags()
5667 if (lp->numtags > lp->maxtags) in ncr_setup_tags()
5668 lp->maxtags = lp->numtags; in ncr_setup_tags()
5674 if (reqtags > 1 && lp->usetags) { /* Stay in tagged mode */ in ncr_setup_tags()
5675 if (lp->queuedepth == reqtags) /* Already announced */ in ncr_setup_tags()
5677 lp->queuedepth = reqtags; in ncr_setup_tags()
5679 else if (reqtags <= 1 && !lp->usetags) { /* Stay in untagged mode */ in ncr_setup_tags()
5680 lp->queuedepth = reqtags; in ncr_setup_tags()
5684 if (lp->busyccbs) /* If not yet safe, return */ in ncr_setup_tags()
5686 lp->queuedepth = reqtags; in ncr_setup_tags()
5687 lp->usetags = reqtags > 1 ? 1 : 0; in ncr_setup_tags()
5691 ** Patch the lun mini-script, according to tag mode. in ncr_setup_tags()
5693 lp->jump_tag.l_paddr = lp->usetags? in ncr_setup_tags()
5701 if (lp->usetags) { in ncr_setup_tags()
5702 dev_info(&sdev->sdev_gendev, in ncr_setup_tags()
5706 dev_info(&sdev->sdev_gendev, in ncr_setup_tags()
5723 **----------------------------------------------------------
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()
5752 np->settle_time = 0; in ncr_timeout()
5753 np->disc = 1; in ncr_timeout()
5764 if (np->lasttime + 4*HZ < thistime) { in ncr_timeout()
5768 np->lasttime = thistime; in ncr_timeout()
5788 ** "ncr0 targ 0?: ERROR (ds:si) (so-si-sd) (sxfer/scntl3) @ name (dsp:dbc)."
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()
5844 printk ("%s:%d: ERROR (%x:%x) (%x-%x-%x) (%x/%x) @ (%s %x:%08x).\n", in ncr_log_hard_error()
5964 ** DEL 397 - 53C875 Rev 3 - Part Number 609-0392410 - ITEM 2. in ncr_exception()
5985 ** we ignore them. In any case we do enough fix-up in ncr_exception()
5999 ** DEL 397 - 53C875 Rev 3 - Part Number 609-0392410 - ITEM 1. 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()
6068 ** Although a STO-Interrupt is pending,
6074 **----------------------------------------------------------
6088 cp = np->ccb; in ncr_int_sto()
6090 cp = cp->link_ccb; in ncr_int_sto()
6093 cp-> host_status = HS_SEL_TIMEOUT; in ncr_int_sto()
6111 ** spi2-r12 11.2.3 says a transceiver mode change must
6119 **----------------------------------------------------------
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()
6151 **----------------------------------------------------------
6159 int phase = -1; in ncr_int_par()
6160 int msg = -1; in ncr_int_par()
6211 np->msgout[0] = msg; in ncr_int_par()
6231 **----------------------------------------------------------
6265 ctest5 = (np->rv_ctest5 & DFS) ? INB (nc_ctest5) : 0; in ncr_int_ma()
6267 delta=(((ctest5 << 8) | (INB (nc_dfifo) & 0xff)) - rest) & 0x3ff; in ncr_int_ma()
6269 delta=(INB (nc_dfifo) - rest) & 0x7f; in ncr_int_ma()
6273 ** the target -> add the amount to the rest in ncr_int_ma()
6310 cp = np->header.cp; in ncr_int_ma()
6314 cp = np->ccb; in ncr_int_ma()
6316 cp = cp->link_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()
6337 vdsp = &cp->patch[0]; in ncr_int_ma()
6341 vdsp = &cp->patch[4]; in ncr_int_ma()
6352 cp, np->header.cp, in ncr_int_ma()
6359 ** block. This should not happen since we donnot use multi-byte in ncr_int_ma()
6366 ncr_name (np), (u_long) np->header.cp); in ncr_int_ma()
6377 tblp = (u32 *) ((char*) &cp->phys + oadr); in ncr_int_ma()
6398 PRINT_ADDR(cp->cmd, "internal error: cmd=%02x != %02x=(vdsp[0] " in ncr_int_ma()
6405 ** cp != np->header.cp means that the header of the CCB 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()
6421 PRINT_ADDR(cp->cmd, "phase change %x-%x %d@%08x resid=%d.\n", in ncr_int_ma()
6432 newcmd = cp->patch; in ncr_int_ma()
6434 if (newtmp == scr_to_cpu(cp->phys.header.savep)) { in ncr_int_ma()
6435 newcmd = &cp->patch[4]; in ncr_int_ma()
6444 newcmd[1] = cpu_to_scr(oadr + olen - rest); in ncr_int_ma()
6449 PRINT_ADDR(cp->cmd, "newcmd[%d] %x %x %x %x.\n", in ncr_int_ma()
6450 (int) (newcmd - cp->patch), in ncr_int_ma()
6472 ** COMMAND --> MSG IN SCSI parity error detected by target. in ncr_int_ma()
6473 ** COMMAND --> STATUS Bad command or refused by target. in ncr_int_ma()
6474 ** MSG OUT --> MSG IN Message rejected by target. in ncr_int_ma()
6475 ** MSG OUT --> COMMAND Bogus target that discards extended in ncr_int_ma()
6492 dsp -= 8; in ncr_int_ma()
6505 np->scripth->nxtdsp_go_on[0] = cpu_to_scr(dsp + 8); in ncr_int_ma()
6507 cp->host_status = HS_BUSY; in ncr_int_ma()
6534 struct scsi_cmnd *cmd = cp->cmd; in ncr_sir_to_redo()
6535 struct tcb *tp = &np->target[cmd->device->id]; in ncr_sir_to_redo()
6536 struct lcb *lp = tp->lp[cmd->device->lun]; in ncr_sir_to_redo()
6551 qp = lp->busy_ccbq.prev; in ncr_sir_to_redo()
6552 while (qp != &lp->busy_ccbq) { in ncr_sir_to_redo()
6554 qp = qp->prev; in ncr_sir_to_redo()
6558 cp2->start.schedule.l_paddr = in ncr_sir_to_redo()
6561 lp->held_ccb = cp; /* Requeue when this one completes */ in ncr_sir_to_redo()
6562 disc_cnt = lp->queuedccbs - busy_cnt; in ncr_sir_to_redo()
6578 if (disc_cnt < lp->numtags) { in ncr_sir_to_redo()
6579 lp->numtags = disc_cnt > 2 ? disc_cnt : 2; in ncr_sir_to_redo()
6580 lp->num_good = 0; in ncr_sir_to_redo()
6581 ncr_setup_tags (np, cmd->device); in ncr_sir_to_redo()
6589 cp->phys.header.savep = cp->startp; in ncr_sir_to_redo()
6590 cp->host_status = HS_BUSY; in ncr_sir_to_redo()
6591 cp->scsi_status = S_ILLEGAL; in ncr_sir_to_redo()
6603 if (cp->auto_sense) in ncr_sir_to_redo()
6613 cp->scsi_smsg2[0] = IDENTIFY(0, cmd->device->lun); in ncr_sir_to_redo()
6614 cp->phys.smsg.addr = cpu_to_scr(CCB_PHYS (cp, scsi_smsg2)); in ncr_sir_to_redo()
6615 cp->phys.smsg.size = cpu_to_scr(1); in ncr_sir_to_redo()
6620 cp->phys.cmd.addr = cpu_to_scr(CCB_PHYS (cp, sensecmd)); in ncr_sir_to_redo()
6621 cp->phys.cmd.size = cpu_to_scr(6); in ncr_sir_to_redo()
6626 cp->sensecmd[0] = 0x03; in ncr_sir_to_redo()
6627 cp->sensecmd[1] = (cmd->device->lun & 0x7) << 5; in ncr_sir_to_redo()
6628 cp->sensecmd[4] = sizeof(cp->sense_buf); in ncr_sir_to_redo()
6633 memset(cp->sense_buf, 0, sizeof(cp->sense_buf)); in ncr_sir_to_redo()
6634 cp->phys.sense.addr = cpu_to_scr(CCB_PHYS(cp,sense_buf[0])); in ncr_sir_to_redo()
6635 cp->phys.sense.size = cpu_to_scr(sizeof(cp->sense_buf)); in ncr_sir_to_redo()
6642 cp->phys.header.savep = startp; in ncr_sir_to_redo()
6643 cp->phys.header.goalp = startp + 24; in ncr_sir_to_redo()
6644 cp->phys.header.lastp = startp; in ncr_sir_to_redo()
6645 cp->phys.header.wgoalp = startp + 24; in ncr_sir_to_redo()
6646 cp->phys.header.wlastp = startp; in ncr_sir_to_redo()
6648 cp->host_status = HS_BUSY; in ncr_sir_to_redo()
6649 cp->scsi_status = S_ILLEGAL; in ncr_sir_to_redo()
6650 cp->auto_sense = s_status; in ncr_sir_to_redo()
6652 cp->start.schedule.l_paddr = in ncr_sir_to_redo()
6658 if (cmd->device->select_no_atn) in ncr_sir_to_redo()
6659 cp->start.schedule.l_paddr = in ncr_sir_to_redo()
6691 struct tcb *tp = &np->target[target]; in ncr_int_sir()
6692 struct scsi_target *starget = tp->starget; in ncr_int_sir()
6716 if (tp->lp[0]) { in ncr_int_sir()
6717 OUTL_DSP (scr_to_cpu(tp->lp[0]->jump_ccb[0])); in ncr_int_sir()
6735 cp = np->header.cp; in ncr_int_sir()
6744 cp = np->ccb; in ncr_int_sir()
6746 cp = cp->link_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()
6756 /*----------------------------------------------------------------------------- in ncr_int_sir()
6798 ** -> target doesn't msgin NEG FAIL noop defa. - dispatch in ncr_int_sir()
6799 ** -> target rejected our msg NEG FAIL reject defa. - dispatch in ncr_int_sir()
6800 ** -> target answered (ok) NEG SYNC sdtr set - clrack in ncr_int_sir()
6801 ** -> target answered (!ok) NEG SYNC sdtr defa. REJ--->msg_bad in ncr_int_sir()
6802 ** -> target answered (ok) NEG WIDE wdtr set - clrack in ncr_int_sir()
6803 ** -> target answered (!ok) NEG WIDE wdtr defa. REJ--->msg_bad in ncr_int_sir()
6804 ** -> any other msgin NEG FAIL noop defa. - dispatch in ncr_int_sir()
6807 ** -> incoming message --- SYNC sdtr set SDTR - in ncr_int_sir()
6808 ** -> incoming message --- WIDE wdtr set WDTR - in ncr_int_sir()
6810 ** -> target doesn't msgout --- PROTO ? defa. - dispatch in ncr_int_sir()
6812 **----------------------------------------------------------------------------- in ncr_int_sir()
6816 /*------------------------------------------------------- in ncr_int_sir()
6824 **------------------------------------------------------- in ncr_int_sir()
6831 /*------------------------------------------------------- in ncr_int_sir()
6836 **------------------------------------------------------- in ncr_int_sir()
6840 PRINT_ADDR(cp->cmd, "negotiation failed sir=%x " in ncr_int_sir()
6841 "status=%x.\n", num, cp->nego_status); in ncr_int_sir()
6848 switch (cp->nego_status) { in ncr_int_sir()
6862 np->msgin [0] = NOP; in ncr_int_sir()
6863 np->msgout[0] = NOP; in ncr_int_sir()
6864 cp->nego_status = 0; 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()
6891 if (per < tp->minsync) in ncr_int_sir()
6892 {chg = 1; per = tp->minsync;} in ncr_int_sir()
6893 if (ofs > tp->maxoffs) in ncr_int_sir()
6894 {chg = 1; ofs = tp->maxoffs;} in ncr_int_sir()
6912 tp->minsync = 0; in ncr_int_sir()
6916 PRINT_ADDR(cp->cmd, "sync: per=%d scntl3=0x%x ofs=%d " in ncr_int_sir()
6922 switch (cp->nego_status) { in ncr_int_sir()
6957 spi_populate_sync_msg(np->msgout, per, ofs); in ncr_int_sir()
6958 cp->nego_status = NS_SYNC; in ncr_int_sir()
6961 ncr_print_msg(cp, "sync msgout", np->msgout); 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()
6999 if (wide > tp->usrwide) in ncr_int_sir()
7000 {chg = 1; wide = tp->usrwide;} in ncr_int_sir()
7003 PRINT_ADDR(cp->cmd, "wide: wide=%d chg=%d.\n", wide, in ncr_int_sir()
7009 switch (cp->nego_status) { 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()
7047 cp->nego_status = NS_WIDE; in ncr_int_sir()
7050 ncr_print_msg(cp, "wide msgout", np->msgin); in ncr_int_sir()
7054 /*-------------------------------------------------------------------- in ncr_int_sir()
7058 **-------------------------------------------------------------------- in ncr_int_sir()
7062 /*----------------------------------------------- in ncr_int_sir()
7066 **----------------------------------------------- in ncr_int_sir()
7069 PRINT_ADDR(cp->cmd, "MESSAGE_REJECT received (%x:%x).\n", in ncr_int_sir()
7070 (unsigned)scr_to_cpu(np->lastmsg), np->msgout[0]); in ncr_int_sir()
7074 /*----------------------------------------------- in ncr_int_sir()
7078 **----------------------------------------------- in ncr_int_sir()
7081 ncr_print_msg(cp, "MESSAGE_REJECT sent for", np->msgin); in ncr_int_sir()
7084 /*-------------------------------------------------------------------- in ncr_int_sir()
7088 **-------------------------------------------------------------------- in ncr_int_sir()
7092 /*----------------------------------------------- in ncr_int_sir()
7097 **----------------------------------------------- in ncr_int_sir()
7100 PRINT_ADDR(cp->cmd, "IGNORE_WIDE_RESIDUE received, but not yet " in ncr_int_sir()
7105 /*----------------------------------------------- in ncr_int_sir()
7110 **----------------------------------------------- in ncr_int_sir()
7113 PRINT_ADDR(cp->cmd, "DISCONNECT received, but datapointer " 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()
7137 u_char tn = cmd->device->id; in ncr_get_ccb()
7138 u_char ln = cmd->device->lun; in ncr_get_ccb()
7139 struct tcb *tp = &np->target[tn]; in ncr_get_ccb()
7140 struct lcb *lp = tp->lp[ln]; in ncr_get_ccb()
7152 if (lp->usetags && lp->busyccbs >= lp->maxnxs) in ncr_get_ccb()
7158 if (list_empty(&lp->free_ccbq)) in ncr_get_ccb()
7164 qp = ncr_list_pop(&lp->free_ccbq); in ncr_get_ccb()
7167 if (cp->magic) { in ncr_get_ccb()
7172 list_add_tail(qp, &lp->wait_ccbq); in ncr_get_ccb()
7173 ++lp->busyccbs; in ncr_get_ccb()
7182 if (lp->usetags) in ncr_get_ccb()
7183 tag = lp->cb_tags[lp->ia_tag]; in ncr_get_ccb()
7185 else if (lp->actccbs > 0) in ncr_get_ccb()
7193 cp = np->ccb; in ncr_get_ccb()
7199 while (cp->magic) { in ncr_get_ccb()
7206 if (cp->magic) in ncr_get_ccb()
7209 cp->magic = 1; in ncr_get_ccb()
7216 ++lp->ia_tag; in ncr_get_ccb()
7217 if (lp->ia_tag == MAX_TAGS) in ncr_get_ccb()
7218 lp->ia_tag = 0; in ncr_get_ccb()
7219 lp->tags_umap |= (((tagmap_t) 1) << tag); in ncr_get_ccb()
7226 cp->tag = tag; in ncr_get_ccb()
7227 cp->target = tn; in ncr_get_ccb()
7228 cp->lun = ln; in ncr_get_ccb()
7248 struct tcb *tp = &np->target[cp->target]; in ncr_free_ccb()
7249 struct lcb *lp = tp->lp[cp->lun]; in ncr_free_ccb()
7252 PRINT_ADDR(cp->cmd, "ccb @%p freeing tag %d.\n", cp, cp->tag); in ncr_free_ccb()
7261 if (cp->tag != NO_TAG) { in ncr_free_ccb()
7262 lp->cb_tags[lp->if_tag++] = cp->tag; in ncr_free_ccb()
7263 if (lp->if_tag == MAX_TAGS) in ncr_free_ccb()
7264 lp->if_tag = 0; in ncr_free_ccb()
7265 lp->tags_umap &= ~(((tagmap_t) 1) << cp->tag); in ncr_free_ccb()
7266 lp->tags_smap &= lp->tags_umap; in ncr_free_ccb()
7267 lp->jump_ccb[cp->tag] = in ncr_free_ccb()
7270 lp->jump_ccb[0] = in ncr_free_ccb()
7280 if (cp != np->ccb) in ncr_free_ccb()
7281 list_move(&cp->link_ccbq, &lp->free_ccbq); in ncr_free_ccb()
7282 --lp->busyccbs; in ncr_free_ccb()
7283 if (cp->queued) { in ncr_free_ccb()
7284 --lp->queuedccbs; in ncr_free_ccb()
7287 cp -> host_status = HS_IDLE; in ncr_free_ccb()
7288 cp -> magic = 0; in ncr_free_ccb()
7289 if (cp->queued) { in ncr_free_ccb()
7290 --np->queuedccbs; in ncr_free_ccb()
7291 cp->queued = 0; 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))
7303 /*------------------------------------------------------------------------
7305 **------------------------------------------------------------------------
7306 **------------------------------------------------------------------------
7310 ncrcmd copy_4 = np->features & FE_PFEN ? SCR_COPY(4) : SCR_COPY_F(4); in ncr_init_ccb()
7315 cp->p_ccb = vtobus(cp); in ncr_init_ccb()
7316 cp->phys.header.cp = cp; in ncr_init_ccb()
7321 INIT_LIST_HEAD(&cp->link_ccbq); in ncr_init_ccb()
7329 cp->start.setup_dsa[0] = cpu_to_scr(copy_4); in ncr_init_ccb()
7330 cp->start.setup_dsa[1] = cpu_to_scr(CCB_PHYS(cp, start.p_phys)); in ncr_init_ccb()
7331 cp->start.setup_dsa[2] = cpu_to_scr(ncr_reg_bus_addr(nc_dsa)); in ncr_init_ccb()
7332 cp->start.schedule.l_cmd = cpu_to_scr(SCR_JUMP); in ncr_init_ccb()
7333 cp->start.p_phys = cpu_to_scr(CCB_PHYS(cp, phys)); in ncr_init_ccb()
7335 memcpy(&cp->restart, &cp->start, sizeof(cp->restart)); 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()
7342 /*------------------------------------------------------------------------
7344 **------------------------------------------------------------------------
7345 **------------------------------------------------------------------------
7349 struct tcb *tp = &np->target[tn]; in ncr_alloc_ccb()
7350 struct lcb *lp = tp->lp[ln]; in ncr_alloc_ccb()
7363 lp->actccbs++; in ncr_alloc_ccb()
7364 np->actccbs++; 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()
7375 list_add(&cp->link_ccbq, &lp->free_ccbq); in ncr_alloc_ccb()
7388 /*------------------------------------------------------------------------
7390 **------------------------------------------------------------------------
7394 **------------------------------------------------------------------------
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()
7407 tp->jump_tcb.l_cmd = in ncr_init_tcb()
7409 tp->jump_tcb.l_paddr = np->jump_tcb[th].l_paddr; in ncr_init_tcb()
7413 ** COPY @(tp->sval), @(sxfer) in ncr_init_tcb()
7415 tp->getscr[0] = cpu_to_scr(copy_1); in ncr_init_tcb()
7416 tp->getscr[1] = cpu_to_scr(vtobus (&tp->sval)); in ncr_init_tcb()
7418 tp->getscr[2] = cpu_to_scr(ncr_reg_bus_addr(nc_sxfer) ^ 3); in ncr_init_tcb()
7420 tp->getscr[2] = cpu_to_scr(ncr_reg_bus_addr(nc_sxfer)); in ncr_init_tcb()
7425 ** COPY @(tp->wval), @(scntl3) in ncr_init_tcb()
7427 tp->getscr[3] = cpu_to_scr(copy_1); in ncr_init_tcb()
7428 tp->getscr[4] = cpu_to_scr(vtobus (&tp->wval)); in ncr_init_tcb()
7430 tp->getscr[5] = cpu_to_scr(ncr_reg_bus_addr(nc_scntl3) ^ 3); in ncr_init_tcb()
7432 tp->getscr[5] = cpu_to_scr(ncr_reg_bus_addr(nc_scntl3)); in ncr_init_tcb()
7439 tp->call_lun.l_cmd = cpu_to_scr(SCR_CALL); in ncr_init_tcb()
7440 tp->call_lun.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_lun)); in ncr_init_tcb()
7448 tp->jump_lcb[i].l_cmd = in ncr_init_tcb()
7450 tp->jump_lcb[i].l_paddr = in ncr_init_tcb()
7457 np->jump_tcb[th].l_paddr = cpu_to_scr(vtobus (&tp->jump_tcb)); in ncr_init_tcb()
7476 /*------------------------------------------------------------------------
7478 **------------------------------------------------------------------------
7481 **------------------------------------------------------------------------
7485 struct tcb *tp = &np->target[tn]; in ncr_alloc_lcb()
7486 struct lcb *lp = tp->lp[ln]; in ncr_alloc_lcb()
7487 ncrcmd copy_4 = np->features & FE_PFEN ? SCR_COPY(4) : SCR_COPY_F(4); in ncr_alloc_lcb()
7503 tp->lp[ln] = lp; in ncr_alloc_lcb()
7508 if (!tp->jump_tcb.l_cmd) in ncr_alloc_lcb()
7514 INIT_LIST_HEAD(&lp->free_ccbq); in ncr_alloc_lcb()
7515 INIT_LIST_HEAD(&lp->busy_ccbq); in ncr_alloc_lcb()
7516 INIT_LIST_HEAD(&lp->wait_ccbq); in ncr_alloc_lcb()
7517 INIT_LIST_HEAD(&lp->skip_ccbq); in ncr_alloc_lcb()
7523 lp->maxnxs = 1; in ncr_alloc_lcb()
7524 lp->jump_ccb = &lp->jump_ccb_0; in ncr_alloc_lcb()
7525 lp->p_jump_ccb = cpu_to_scr(vtobus(lp->jump_ccb)); in ncr_alloc_lcb()
7535 ** COPY @(lp->p_jump_ccb), @(temp) in ncr_alloc_lcb()
7538 lp->jump_lcb.l_cmd = in ncr_alloc_lcb()
7540 lp->jump_lcb.l_paddr = tp->jump_lcb[lh].l_paddr; in ncr_alloc_lcb()
7542 lp->load_jump_ccb[0] = cpu_to_scr(copy_4); in ncr_alloc_lcb()
7543 lp->load_jump_ccb[1] = cpu_to_scr(vtobus (&lp->p_jump_ccb)); in ncr_alloc_lcb()
7544 lp->load_jump_ccb[2] = cpu_to_scr(ncr_reg_bus_addr(nc_temp)); in ncr_alloc_lcb()
7546 lp->jump_tag.l_cmd = cpu_to_scr(SCR_JUMP); in ncr_alloc_lcb()
7547 lp->jump_tag.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_notag)); in ncr_alloc_lcb()
7552 tp->jump_lcb[lh].l_paddr = cpu_to_scr(vtobus (&lp->jump_lcb)); in ncr_alloc_lcb()
7557 lp->busyccbs = 1; in ncr_alloc_lcb()
7558 lp->queuedccbs = 1; in ncr_alloc_lcb()
7559 lp->queuedepth = 1; in ncr_alloc_lcb()
7565 /*------------------------------------------------------------------------
7567 **------------------------------------------------------------------------
7570 ** will play with CHANGE DEFINITION commands. :-)
7571 **------------------------------------------------------------------------
7575 unsigned char tn = sdev->id, ln = sdev->lun; in ncr_setup_lcb()
7576 struct tcb *tp = &np->target[tn]; in ncr_setup_lcb()
7577 struct lcb *lp = tp->lp[ln]; in ncr_setup_lcb()
7587 if (sdev->tagged_supported && lp->jump_ccb == &lp->jump_ccb_0) { in ncr_setup_lcb()
7589 lp->jump_ccb = m_calloc_dma(256, "JUMP_CCB"); in ncr_setup_lcb()
7590 if (!lp->jump_ccb) { in ncr_setup_lcb()
7591 lp->jump_ccb = &lp->jump_ccb_0; in ncr_setup_lcb()
7594 lp->p_jump_ccb = cpu_to_scr(vtobus(lp->jump_ccb)); in ncr_setup_lcb()
7596 lp->jump_ccb[i] = in ncr_setup_lcb()
7599 lp->cb_tags[i] = i; in ncr_setup_lcb()
7600 lp->maxnxs = MAX_TAGS; in ncr_setup_lcb()
7601 lp->tags_stime = jiffies + 3*HZ; in ncr_setup_lcb()
7623 **----------------------------------------------------------
7644 cp->data_len = 0; in ncr_scatter()
7653 return -1; in ncr_scatter()
7656 data = &cp->phys.data[MAX_SCATTER - use_sg]; in ncr_scatter()
7663 cp->data_len += len; in ncr_scatter()
7666 segment = -2; in ncr_scatter()
7674 ** Test the bus snoop logic :-(
7698 printk ("CACHE TEST FAILED: reg dstat-sstat2 readback %x.\n",
7709 if (np->reg) {
7722 np->ncr_cache = cpu_to_scr(host_wr);
7741 host_rd = scr_to_cpu(np->ncr_cache);
7806 **----------------------------------------------------------
7814 if (np->multiplier < 2) {
7823 if (np->multiplier > 2) { /* Poll bit 5 of stest4 for quadrupler */
7825 while (!(INB(nc_stest4) & LCKFRQ) && --i > 0)
7829 } else /* Wait 20 micro-seconds for doubler */
7866 OUTB (nc_scntl3, 4); /* set pre-scaler to divide by 3 */
7898 np->multiplier = 1;
7907 np->multiplier = mult;
7915 if (np->multiplier != mult || (scntl3 & 7) < 3 || !(scntl3 & 1)) {
7936 np->multiplier = mult;
7943 f1 /= np->multiplier;
7949 f1 *= np->multiplier;
7950 np->clock_khz = f1;
7957 struct Scsi_Host *host = device->host;
7958 struct ncb *np = ((struct host_data *) host->hostdata)->ncb;
7959 struct tcb *tp = &np->target[device->id];
7960 tp->starget = device->sdev_target;
7967 struct Scsi_Host *host = device->host;
7968 struct ncb *np = ((struct host_data *) host->hostdata)->ncb;
7969 struct tcb *tp = &np->target[device->id];
7970 struct lcb *lp = tp->lp[device->lun];
7981 numtags = device_queue_depth(np->unit, device->id, device->lun);
7982 if (numtags > tp->usrtags)
7983 numtags = tp->usrtags;
7984 if (!device->tagged_supported)
8004 lp->numtags = lp->maxtags = numtags;
8005 lp->scdev_depth = depth_to_use;
8011 np->unit, device->id, device->lun, depth_to_use);
8014 if (spi_support_sync(device->sdev_target) &&
8015 !spi_initial_dv(device->sdev_target))
8022 struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
8030 cmd->scsi_done = done;
8031 cmd->host_scribble = NULL;
8032 cmd->__data_mapped = 0;
8033 cmd->__data_mapping = 0;
8035 spin_lock_irqsave(&np->smp_lock, flags);
8038 cmd->result = sts << 16;
8040 printk("ncr53c8xx : command not queued - result=%d\n", sts);
8048 spin_unlock_irqrestore(&np->smp_lock, flags);
8065 struct host_data *host_data = (struct host_data *)shost->hostdata;
8066 struct ncb *np = host_data->ncb;
8075 spin_lock_irqsave(&np->smp_lock, flags);
8077 done_list = np->done_list;
8078 np->done_list = NULL;
8079 spin_unlock_irqrestore(&np->smp_lock, flags);
8094 spin_lock_irqsave(&np->smp_lock, flags);
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;
8112 * If the mid-level driver told us reset is synchronous, it seems
8114 * even if this command was not queued to the low-level driver,
8118 spin_lock_irqsave(&np->smp_lock, flags);
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;
8144 done_list = np->done_list;
8145 np->done_list = NULL;
8177 cmd->next_wcmd = NULL;
8178 if (!(wcmd = np->waiting_list)) np->waiting_list = cmd;
8180 while (wcmd->next_wcmd)
8181 wcmd = (struct scsi_cmnd *) wcmd->next_wcmd;
8182 wcmd->next_wcmd = (char *) cmd;
8188 struct scsi_cmnd **pcmd = &np->waiting_list;
8193 *pcmd = (struct scsi_cmnd *) cmd->next_wcmd;
8194 cmd->next_wcmd = NULL;
8201 pcmd = (struct scsi_cmnd **) &(*pcmd)->next_wcmd;
8210 waiting_list = np->waiting_list;
8211 np->waiting_list = NULL;
8217 waiting_list = (struct scsi_cmnd *) wcmd->next_wcmd;
8218 wcmd->next_wcmd = NULL;
8229 wcmd->result = sts << 16;
8241 struct host_data *host_data = (struct host_data *)host->hostdata;
8243 return snprintf(buf, 20, "0x%x\n", host_data->ncb->revision_id);
8295 if (!tpnt->name)
8296 tpnt->name = SCSI_NCR_DRIVER_NAME;
8297 if (!tpnt->shost_attrs)
8298 tpnt->shost_attrs = ncr53c8xx_host_attrs;
8300 tpnt->queuecommand = ncr53c8xx_queue_command;
8301 tpnt->slave_configure = ncr53c8xx_slave_configure;
8302 tpnt->slave_alloc = ncr53c8xx_slave_alloc;
8303 tpnt->eh_bus_reset_handler = ncr53c8xx_bus_reset;
8304 tpnt->can_queue = SCSI_NCR_CAN_QUEUE;
8305 tpnt->this_id = 7;
8306 tpnt->sg_tablesize = SCSI_NCR_SG_TABLESIZE;
8307 tpnt->cmd_per_lun = SCSI_NCR_CMD_PER_LUN;
8309 if (device->differential)
8310 driver_setup.diff_support = device->differential;
8312 printk(KERN_INFO "ncr53c720-%d: rev 0x%x irq %d\n",
8313 unit, device->chip.revision_id, device->slot.irq);
8318 host_data = (struct host_data *) instance->hostdata;
8320 np = __m_calloc_dma(device->dev, sizeof(struct ncb), "NCB");
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;
8358 if (device->slot.base_v)
8359 np->vaddr = device->slot.base_v;
8361 np->vaddr = ioremap(device->slot.base_c, 128);
8363 if (!np->vaddr) {
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;
8382 if (np->paddr2 && sizeof(struct script) > 4096) {
8383 np->paddr2 = 0;
8388 instance->max_channel = 0;
8389 instance->this_id = np->myaddr;
8390 instance->max_id = np->maxwide ? 16 : 8;
8391 instance->max_lun = SCSI_NCR_MAX_LUN;
8392 instance->base = (unsigned long) np->reg;
8393 instance->irq = device->slot.irq;
8394 instance->unique_id = device->slot.base;
8395 instance->dma_channel = 0;
8396 instance->cmd_per_lun = MAX_TAGS;
8397 instance->can_queue = (MAX_START-4);
8401 instance->transportt = ncr53c8xx_transport_template;
8406 np->scripth = np->scripth0;
8407 np->p_scripth = vtobus(np->scripth);
8408 np->p_script = (np->paddr2) ? np->paddr2 : vtobus(np->script0);
8411 (ncrcmd *) np->script0, sizeof(struct script));
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 =
8449 np->irq = device->slot.irq;
8452 ncr_init_ccb(np, np->ccb);
8460 spin_lock_irqsave(&np->smp_lock, flags);
8462 …printk(KERN_ERR "%s: FATAL ERROR: CHECK SCSI BUS - CABLES, TERMINATION, DEVICE POWER etc.!\n", ncr…
8464 spin_unlock_irqrestore(&np->smp_lock, flags);
8469 np->disc = 1;
8472 * The middle-level SCSI driver does not wait for devices to settle.
8482 np->lasttime=0;
8487 np->order = SIMPLE_QUEUE_TAG;
8490 spin_unlock_irqrestore(&np->smp_lock, flags);
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");
8507 host_data->ncb = NULL;
8522 if (host_data->ncb)
8523 ncr_detach(host_data->ncb);
8529 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
8530 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
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;
8538 tp->usrsync = period;
8545 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
8546 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
8547 struct tcb *tp = &np->target[starget->id];
8549 if (offset > np->maxoffs)
8550 offset = np->maxoffs;
8554 tp->maxoffs = offset;
8561 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
8562 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
8563 struct tcb *tp = &np->target[starget->id];
8565 if (width > np->maxwide)
8566 width = np->maxwide;
8570 tp->usrwide = width;
8577 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
8580 switch (np->scsi_mode) {
8608 return -ENODEV;