aic7xxx.seq (4568) | aic7xxx.seq (4866) |
---|---|
1# @(#)aic7xxx.seq 1.30 94/11/09 jda | 1# @(#)aic7xxx.seq 1.31 94/11/25 jda |
2# 3# Adaptec 274x device driver for Linux. 4# Copyright (c) 1994 The University of Calgary Department of Computer Science. 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 2 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, write to the Free Software 18# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 2# 3# Adaptec 274x device driver for Linux. 4# Copyright (c) 1994 The University of Calgary Department of Computer Science. 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 2 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, write to the Free Software 18# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 |
20VERSION AIC7XXX_SEQ_VERSION 1.30 | 20VERSION AIC7XXX_SEQ_VERSION 1.31 |
21 | 21 |
22MAXSCB-1 = 0xf | 22SCBMASK = 0x1f |
23 24SCSISEQ = 0x00 25SXFRCTL0 = 0x01 26SXFRCTL1 = 0x02 27SCSISIGI = 0x03 28SCSISIGO = 0x03 29SCSIRATE = 0x04 30SCSIID = 0x05 --- 123 unchanged lines hidden (view full) --- 154SG_NEXT+0 = 0x52 155SG_NEXT+1 = 0x53 156SG_NEXT+2 = 0x54 157SG_NEXT+3 = 0x55 158 159SCBCOUNT = 0x56 # the actual number of SCBs 160ACTIVE_A = 0x57 161 | 23 24SCSISEQ = 0x00 25SXFRCTL0 = 0x01 26SXFRCTL1 = 0x02 27SCSISIGI = 0x03 28SCSISIGO = 0x03 29SCSIRATE = 0x04 30SCSIID = 0x05 --- 123 unchanged lines hidden (view full) --- 154SG_NEXT+0 = 0x52 155SG_NEXT+1 = 0x53 156SG_NEXT+2 = 0x54 157SG_NEXT+3 = 0x55 158 159SCBCOUNT = 0x56 # the actual number of SCBs 160ACTIVE_A = 0x57 161 |
162# Poll QINCNT for work - the lower three bits contain | 162# Poll QINCNT for work - the lower bits contain |
163# the number of entries in the Queue In FIFO. 164# 165start: 166 test SCSISIGI,0x4 jnz reselect # BSYI | 163# the number of entries in the Queue In FIFO. 164# 165start: 166 test SCSISIGI,0x4 jnz reselect # BSYI |
167 test QINCNT,MAXSCB-1 jz start | 167 test QINCNT,SCBMASK jz start |
168 169# We have at least one queued SCB now. Set the SCB pointer 170# from the FIFO so we see the right bank of SCB registers, 171# then set SCSI options and set the initiator and target 172# SCSI IDs. 173# 174 mov SCBPTR,QINFIFO 175 --- 13 unchanged lines hidden (view full) --- 189 mov SCBARRAY+1 call initialize 190 clr SG_NOLOAD 191 clr RESELECT 192 193# As soon as we get a successful selection, the target should go 194# into the message out phase since we have ATN asserted. Prepare 195# the message to send, locking out the device driver. If the device 196# driver hasn't beaten us with an ABORT or RESET message, then tack | 168 169# We have at least one queued SCB now. Set the SCB pointer 170# from the FIFO so we see the right bank of SCB registers, 171# then set SCSI options and set the initiator and target 172# SCSI IDs. 173# 174 mov SCBPTR,QINFIFO 175 --- 13 unchanged lines hidden (view full) --- 189 mov SCBARRAY+1 call initialize 190 clr SG_NOLOAD 191 clr RESELECT 192 193# As soon as we get a successful selection, the target should go 194# into the message out phase since we have ATN asserted. Prepare 195# the message to send, locking out the device driver. If the device 196# driver hasn't beaten us with an ABORT or RESET message, then tack |
197# on a SDTR negotation if required. | 197# on an SDTR negotiation if required. |
198# 199# Messages are stored in scratch RAM starting with a flag byte (high bit 200# set means active message), one length byte, and then the message itself. 201# 202 mov SCBARRAY+1 call disconnect # disconnect ok? 203 204 and SINDEX,0x7,SCBARRAY+1 # lun 205 or SINDEX,A # return value from disconnect --- 452 unchanged lines hidden (view full) --- 658 dec A 659 cmp ALLZEROS,A jne bcopy 660 ret 661 662# Locking the driver out, build a one-byte message passed in SINDEX 663# if there is no active message already. SINDEX is returned intact. 664# 665mk_mesg: | 198# 199# Messages are stored in scratch RAM starting with a flag byte (high bit 200# set means active message), one length byte, and then the message itself. 201# 202 mov SCBARRAY+1 call disconnect # disconnect ok? 203 204 and SINDEX,0x7,SCBARRAY+1 # lun 205 or SINDEX,A # return value from disconnect --- 452 unchanged lines hidden (view full) --- 658 dec A 659 cmp ALLZEROS,A jne bcopy 660 ret 661 662# Locking the driver out, build a one-byte message passed in SINDEX 663# if there is no active message already. SINDEX is returned intact. 664# 665mk_mesg: |
666 mvi SEQCTL,0x40 # PAUSEDIS | 666 mvi SEQCTL,0x50 # PAUSEDIS|FASTMODE |
667 test MSG_FLAGS,0x80 jnz mk_mesg1 # active message? 668 669 mvi MSG_FLAGS,0x80 # if not, there is now 670 mvi MSG_LEN,1 # length = 1 671 mov MSG_START+0,SINDEX # 1-byte message 672 673mk_mesg1: | 667 test MSG_FLAGS,0x80 jnz mk_mesg1 # active message? 668 669 mvi MSG_FLAGS,0x80 # if not, there is now 670 mvi MSG_LEN,1 # length = 1 671 mov MSG_START+0,SINDEX # 1-byte message 672 673mk_mesg1: |
674 clr SEQCTL # !PAUSEDIS | 674 mvi SEQCTL,0x10 # !PAUSEDIS|FASTMODE |
675 ret 676 677# Input byte in Automatic PIO mode. The address to store the byte 678# in should be in SINDEX. DINDEX will be used by this routine. 679# 680inb: 681 test SSTAT0,0x2 jz inb # SPIORDY 682 mov DINDEX,SINDEX --- 77 unchanged lines hidden (view full) --- 760dma1: 761dma2: 762 test SSTAT0,0x1 jnz dma3 # DMADONE 763 test SSTAT1,0x10 jz dma1 # PHASEMIS, ie. underrun 764 765# We will be "done" DMAing when the transfer count goes to zero, or 766# the target changes the phase (in light of this, it makes sense that 767# the DMA circuitry doesn't ACK when PHASEMIS is active). If we are | 675 ret 676 677# Input byte in Automatic PIO mode. The address to store the byte 678# in should be in SINDEX. DINDEX will be used by this routine. 679# 680inb: 681 test SSTAT0,0x2 jz inb # SPIORDY 682 mov DINDEX,SINDEX --- 77 unchanged lines hidden (view full) --- 760dma1: 761dma2: 762 test SSTAT0,0x1 jnz dma3 # DMADONE 763 test SSTAT1,0x10 jz dma1 # PHASEMIS, ie. underrun 764 765# We will be "done" DMAing when the transfer count goes to zero, or 766# the target changes the phase (in light of this, it makes sense that 767# the DMA circuitry doesn't ACK when PHASEMIS is active). If we are |
768# doing a SCSI->Host transfer, flush the data FIFO. | 768# doing a SCSI->Host transfer, the data FIFO should be flushed auto- 769# magically on STCNT=0 or a phase change, so just wait for FIFO empty 770# status. |
769# 770dma3: 771 test SINDEX,0x4 jnz dma5 # DIRECTION | 771# 772dma3: 773 test SINDEX,0x4 jnz dma5 # DIRECTION |
772 and SINDEX,0xfe # mask out FIFORESET 773 or DFCNTRL,0x2,SINDEX # FIFOFLUSH | |
774dma4: | 774dma4: |
775 test DFCNTRL,0x2 jnz dma4 # FIFOFLUSHACK | 775 test DFSTATUS,0x1 jz dma4 # FIFOFLUSHACK |
776 777# Now shut the DMA enables off, and copy STCNT (ie. the underrun 778# amount, if any) to the SCB registers; SG_COUNT will get copied to 779# the SCB's residual S/G count field after sg_advance is called. Make 780# sure that the DMA enables are actually off first lest we get an ILLSADDR. 781# 782dma5: 783 clr DFCNTRL # disable DMA --- 22 unchanged lines hidden (view full) --- 806 clr SIGSTATE 807 808# Turn on Automatic PIO mode now, before we expect to see an REQ 809# from the target. It shouldn't hurt anything to leave it on. Set 810# CLRCHN here before the target has entered a data transfer mode - 811# with synchronous SCSI, if you do it later, you blow away some 812# data in the SCSI FIFO that the target has already sent to you. 813# | 776 777# Now shut the DMA enables off, and copy STCNT (ie. the underrun 778# amount, if any) to the SCB registers; SG_COUNT will get copied to 779# the SCB's residual S/G count field after sg_advance is called. Make 780# sure that the DMA enables are actually off first lest we get an ILLSADDR. 781# 782dma5: 783 clr DFCNTRL # disable DMA --- 22 unchanged lines hidden (view full) --- 806 clr SIGSTATE 807 808# Turn on Automatic PIO mode now, before we expect to see an REQ 809# from the target. It shouldn't hurt anything to leave it on. Set 810# CLRCHN here before the target has entered a data transfer mode - 811# with synchronous SCSI, if you do it later, you blow away some 812# data in the SCSI FIFO that the target has already sent to you. 813# |
814 mvi SXFRCTL0,0xa # SPIOEN|CLRCHN | 814# DFON is a 7870 bit enabling digital filtering of REQ and ACK signals. 815# 816 mvi SXFRCTL0,0x8a # DFON|SPIOEN|CLRCHN |
815 816# Set SCSI bus parity checking and the selection timeout value, 817# and enable the hardware selection timer. Set the SELTO interrupt 818# to signal the driver. 819# | 817 818# Set SCSI bus parity checking and the selection timeout value, 819# and enable the hardware selection timer. Set the SELTO interrupt 820# to signal the driver. 821# |
822# STPWEN is 7870-specific, enabling an external termination power source. 823# |
|
820 and A,0x38,SCSICONF # PARITY_ENB_A|SEL_TIM_A[10] | 824 and A,0x38,SCSICONF # PARITY_ENB_A|SEL_TIM_A[10] |
821 or SXFRCTL1,0x4,A # ENSTIMER | 825 or SXFRCTL1,0x5,A # ENSTIMER|STPWEN |
822 mvi SIMODE1,0x84 # ENSELTIMO|ENSCSIPERR 823 824# Initialize scatter-gather pointers by setting up the working copy 825# in scratch RAM. 826# 827 call sg_scb2ram 828 829# Initialize SCSIRATE with the appropriate value for this target. --- 11 unchanged lines hidden (view full) --- 841 842 mvi INTSTAT,SIGNAL_2 # no - cause a kernel panic 843 844assert1: 845 ret 846 847# Find out if disconnection is ok from the information the BIOS has left 848# us. The target ID should be in the upper four bits of SINDEX; A will | 826 mvi SIMODE1,0x84 # ENSELTIMO|ENSCSIPERR 827 828# Initialize scatter-gather pointers by setting up the working copy 829# in scratch RAM. 830# 831 call sg_scb2ram 832 833# Initialize SCSIRATE with the appropriate value for this target. --- 11 unchanged lines hidden (view full) --- 845 846 mvi INTSTAT,SIGNAL_2 # no - cause a kernel panic 847 848assert1: 849 ret 850 851# Find out if disconnection is ok from the information the BIOS has left 852# us. The target ID should be in the upper four bits of SINDEX; A will |
849# contain either 0x40 (disconnection ok) or 0x00 (diconnection not ok) | 853# contain either 0x40 (disconnection ok) or 0x00 (disconnection not ok) |
850# on exit. 851# 852# This is the only place the target ID is limited to three bits, so we 853# can use the FUNCTION1 register. 854# 855disconnect: 856 and FUNCTION1,0x70,SINDEX # strip off extra just in case 857 mov A,FUNCTION1 858 test DISC_DSB_A,A jz disconnect1 # bit nonzero if DISabled 859 860 clr A ret 861disconnect1: 862 mvi A,0x40 ret 863 864# Locate the SCB matching the target ID in SELID and the lun in the lower 865# three bits of SINDEX, and switch the SCB to it. Have the kernel print 866# a warning message if it can't be found, and generate an ABORT message | 854# on exit. 855# 856# This is the only place the target ID is limited to three bits, so we 857# can use the FUNCTION1 register. 858# 859disconnect: 860 and FUNCTION1,0x70,SINDEX # strip off extra just in case 861 mov A,FUNCTION1 862 test DISC_DSB_A,A jz disconnect1 # bit nonzero if DISabled 863 864 clr A ret 865disconnect1: 866 mvi A,0x40 ret 867 868# Locate the SCB matching the target ID in SELID and the lun in the lower 869# three bits of SINDEX, and switch the SCB to it. Have the kernel print 870# a warning message if it can't be found, and generate an ABORT message |
867# to the target. We keep the value of the t/c/l that we are trying to | 871# to the target. We keep the value of the t/c/l that we are trying to find |
868# in DINDEX so it is not overwritten during our check to see if we are 869# at the last SCB. 870# 871findSCB: 872 and A,0x7,SINDEX # lun in lower three bits 873 or DINDEX,A,SELID # can I do this? 874 and DINDEX,0xf7 # only channel A implemented 875 876 clr SINDEX 877 878findSCB1: | 872# in DINDEX so it is not overwritten during our check to see if we are 873# at the last SCB. 874# 875findSCB: 876 and A,0x7,SINDEX # lun in lower three bits 877 or DINDEX,A,SELID # can I do this? 878 and DINDEX,0xf7 # only channel A implemented 879 880 clr SINDEX 881 882findSCB1: |
879 mov SCBPTR,SINDEX # switch to new SCB | |
880 mov A,DINDEX | 883 mov A,DINDEX |
884 mov SCBPTR,SINDEX # switch to new SCB |
|
881 cmp SCBARRAY+1,A jne findSCB2 # target ID/channel/lun match? 882 test SCBARRAY+0,0x4 jz findSCB2 # should be disconnected 883 884 ret 885 886findSCB2: 887 inc SINDEX 888 mov A,SCBCOUNT --- 167 unchanged lines hidden (view full) --- 1056# it has to send an ABORT or RESET message, then it needs to know this 1057# so it can assert ATN without upsetting SCSISIGO. The new value is 1058# expected in SINDEX. Change the actual state last to avoid contention 1059# from the driver. 1060# 1061scsisig: 1062 mov SIGSTATE,SINDEX 1063 mov SCSISIGO,SINDEX ret | 885 cmp SCBARRAY+1,A jne findSCB2 # target ID/channel/lun match? 886 test SCBARRAY+0,0x4 jz findSCB2 # should be disconnected 887 888 ret 889 890findSCB2: 891 inc SINDEX 892 mov A,SCBCOUNT --- 167 unchanged lines hidden (view full) --- 1060# it has to send an ABORT or RESET message, then it needs to know this 1061# so it can assert ATN without upsetting SCSISIGO. The new value is 1062# expected in SINDEX. Change the actual state last to avoid contention 1063# from the driver. 1064# 1065scsisig: 1066 mov SIGSTATE,SINDEX 1067 mov SCSISIGO,SINDEX ret |
1064 | |