1*34406Skarels /* 2*34406Skarels * @(#)dr.c 7.1 (Berkeley) 05/21/88 3*34406Skarels */ 429651Ssam 529651Ssam #include "dr.h" 629651Ssam #if NDR > 0 730294Ssam /* 830294Ssam * DRV11-W DMA interface driver. 930294Ssam * 1030227Ssam * UNTESTED WITH 4.3 1129651Ssam */ 1229651Ssam #include "../machine/mtpr.h" 1329651Ssam #include "../machine/pte.h" 1429651Ssam 1529651Ssam #include "param.h" 1629651Ssam #include "conf.h" 1729651Ssam #include "dir.h" 1829651Ssam #include "user.h" 1929651Ssam #include "proc.h" 2029651Ssam #include "map.h" 2129651Ssam #include "ioctl.h" 2229651Ssam #include "buf.h" 2329651Ssam #include "vm.h" 2429651Ssam #include "uio.h" 2530294Ssam #include "kernel.h" 2629651Ssam 2729651Ssam #include "../tahoevba/vbavar.h" 2829651Ssam #include "../tahoevba/drreg.h" 2929651Ssam 3029651Ssam #define YES 1 3129651Ssam #define NO 0 3229651Ssam 3329651Ssam struct vba_device *drinfo[NDR]; 3429651Ssam struct dr_aux dr_aux[NDR]; 3529651Ssam 3629651Ssam unsigned drminphys(); 3730294Ssam int drprobe(), drintr(), drattach(), drtimo(), drrwtimo(); 3830294Ssam int drstrategy(); 3930294Ssam extern struct vba_device *drinfo[]; 4030294Ssam static long drstd[] = { 0 }; 4129651Ssam struct vba_driver drdriver = 4230294Ssam { drprobe, 0, drattach, 0, drstd, "rs", drinfo }; 4329651Ssam 4429651Ssam #define RSUNIT(dev) (minor(dev) & 7) 4529651Ssam #define SPL_UP spl5 4629651Ssam 4729651Ssam /* -------- Per-unit data -------- */ 4829651Ssam 4929651Ssam extern struct dr_aux dr_aux[]; 5029651Ssam 5129651Ssam #ifdef DR_DEBUG 5230294Ssam long DR11 = 0; 5329651Ssam #endif 5429651Ssam 5529651Ssam drprobe(reg, vi) 5630294Ssam caddr_t reg; 5730294Ssam struct vba_device *vi; 5829651Ssam { 5930294Ssam register int br, cvec; /* must be r12, r11 */ 6030294Ssam struct rsdevice *dr; 6129651Ssam 6230294Ssam #ifdef lint 6330294Ssam br = 0; cvec = br; br = cvec; 6430294Ssam drintr(0); 6529651Ssam #endif 6630294Ssam if (badaddr(reg, 2)) 6730294Ssam return (0); 6830294Ssam dr = (struct rsdevice *)reg; 6930294Ssam dr->dr_intvect = --vi->ui_hd->vh_lastiv; 7029651Ssam #ifdef DR_DEBUG 7130294Ssam printf("dprobe: Set interrupt vector %lx and init\n",dr->dr_intvec); 7229651Ssam #endif 7330294Ssam /* generate interrupt here for autoconfig */ 7430294Ssam dr->dr_cstat = MCLR; /* init board and device */ 7529651Ssam #ifdef DR_DEBUG 7630294Ssam printf("drprobe: Initial status %lx\n", dr->dr_cstat); 7729651Ssam #endif 7830294Ssam br = 0x18, cvec = dr->dr_intvect; /* XXX */ 7930294Ssam return (sizeof (struct rsdevice)); /* DR11 exist */ 8029651Ssam } 8129651Ssam 8229651Ssam /* ARGSUSED */ 8329651Ssam drattach(ui) 8430294Ssam struct vba_device *ui; 8529651Ssam { 8630294Ssam register struct dr_aux *rsd; 8729651Ssam 8830294Ssam rsd = &dr_aux[ui->ui_unit]; 8930294Ssam rsd->dr_flags = DR_PRES; /* This dr11 is present */ 9030294Ssam rsd->dr_addr = (struct rsdevice *)ui->ui_addr; /* Save addr of this dr11 */ 9130294Ssam rsd->dr_istat = 0; 9230294Ssam rsd->dr_bycnt = 0; 9330294Ssam rsd->dr_cmd = 0; 9430294Ssam rsd->currenttimo = 0; 9529651Ssam } 9629651Ssam 9730294Ssam /*ARGSUSED*/ 9830294Ssam dropen(dev, flag) 9930294Ssam dev_t dev; 10030294Ssam int flag; 10129651Ssam { 10230294Ssam register int unit = RSUNIT(dev); 10330294Ssam register struct rsdevice *dr; 10430294Ssam register struct dr_aux *rsd; 10529651Ssam 10630294Ssam if (drinfo[unit] == 0 || !drinfo[unit]->ui_alive) 10730294Ssam return (ENXIO); 10830294Ssam dr = RSADDR(unit); 10930294Ssam rsd = &dr_aux[unit]; 11030294Ssam if (rsd->dr_flags & DR_OPEN) { 11129651Ssam #ifdef DR_DEBUG 11230294Ssam printf("\ndropen: dr11 unit %ld already open",unit); 11329651Ssam #endif 11430294Ssam return (ENXIO); /* DR11 already open */ 11530294Ssam } 11630294Ssam rsd->dr_flags |= DR_OPEN; /* Mark it OPEN */ 11730294Ssam rsd->dr_istat = 0; /* Clear status of previous interrupt */ 11830294Ssam rsd->rtimoticks = hz; /* Set read no stall timout to 1 sec */ 11930294Ssam rsd->wtimoticks = hz*60; /* Set write no stall timout to 1 min */ 12030294Ssam dr->dr_cstat = DR_ZERO; /* Clear function & latches */ 12130294Ssam dr->dr_pulse = (RDMA | RATN); /* clear leftover attn & e-o-r flags */ 12230294Ssam drtimo(dev); /* start the self kicker */ 12330294Ssam return (0); 12429651Ssam } 12529651Ssam 12629651Ssam drclose (dev) 12730294Ssam dev_t dev; 12829651Ssam { 12930294Ssam register int unit = RSUNIT(dev); 13030294Ssam register struct dr_aux *dra; 13130294Ssam register struct rsdevice *rs; 13230294Ssam register short s; 13329651Ssam 13430294Ssam dra = &dr_aux[unit]; 13530294Ssam if ((dra->dr_flags & DR_OPEN) == 0) { 13629651Ssam #ifdef DR_DEBUG 13730294Ssam printf("\ndrclose: DR11 device %ld not open",unit); 13829651Ssam #endif 13930294Ssam return; 14030294Ssam } 14130294Ssam dra->dr_flags &= ~(DR_OPEN|DR_ACTV); 14230294Ssam rs = dra->dr_addr; 14330294Ssam s = SPL_UP(); 14430294Ssam rs->dr_cstat = DR_ZERO; 14530294Ssam if (dra->dr_buf.b_flags & B_BUSY) { 14630294Ssam dra->dr_buf.b_flags &= ~B_BUSY; 14730294Ssam wakeup((caddr_t)&dra->dr_buf.b_flags); 14830294Ssam } 14930294Ssam splx(s); 15029651Ssam } 15129651Ssam 15229651Ssam 15329651Ssam /* drread() works exactly like drwrite() except that the 15429651Ssam B_READ flag is used when physio() is called 15529651Ssam */ 15629651Ssam drread (dev, uio) 15730294Ssam dev_t dev; 15830294Ssam struct uio *uio; 15929651Ssam { register struct dr_aux *dra; 16029651Ssam register struct buf *bp; 16130294Ssam register int spl, err; 16230294Ssam register int unit = RSUNIT(dev); 16329651Ssam 16430294Ssam if (uio->uio_iov->iov_len <= 0 || /* Negative count */ 16530294Ssam uio->uio_iov->iov_len & 1 || /* odd count */ 16630294Ssam (int)uio->uio_iov->iov_base & 1) /* odd destination address */ 16730294Ssam return (EINVAL); 16829651Ssam #ifdef DR_DEBUG 16930294Ssam if (DR11 & 8) 17030294Ssam printf("\ndrread: (len:%ld)(base:%lx)", 17130294Ssam uio->uio_iov->iov_len,(int)uio->uio_iov->iov_base); 17229651Ssam #endif 17330294Ssam dra = &dr_aux[RSUNIT(dev)]; 17430294Ssam dra->dr_op = DR_READ; 17530294Ssam bp = &dra->dr_buf; 17630294Ssam bp->b_resid = 0; 17730294Ssam if (dra->dr_flags & DR_NORSTALL) { 17830294Ssam /* 17930294Ssam * We are in no stall mode, start the timer, 18030294Ssam * raise IPL so nothing can stop us once the 18130294Ssam * timer's running 18230294Ssam */ 18330294Ssam spl = SPL_UP(); 18430294Ssam timeout(drrwtimo, (caddr_t)((dra->currenttimo<<8) | unit), 18530294Ssam (int)dra->rtimoticks); 18630294Ssam err = physio(drstrategy, bp, dev,B_READ, drminphys, uio); 18730294Ssam splx(spl); 18830294Ssam if (err) 18930294Ssam return (err); 19030294Ssam dra->currenttimo++; /* Update current timeout number */ 19130294Ssam /* Did we timeout */ 19230294Ssam if (dra->dr_flags & DR_TMDM) { 19330294Ssam dra->dr_flags &= ~DR_TMDM; /* Clear timeout flag */ 19430294Ssam u.u_error = 0; /* Made the error ourself, ignore it */ 19530294Ssam } 19630294Ssam return (err); 19729651Ssam } 19830294Ssam return (physio(drstrategy, bp, dev,B_READ, drminphys, uio)); 19929651Ssam } 20029651Ssam 20130294Ssam drwrite(dev, uio) 20230294Ssam dev_t dev; 20330294Ssam struct uio *uio; 20429651Ssam { register struct dr_aux *dra; 20529651Ssam register struct buf *bp; 20630294Ssam register int unit = RSUNIT(dev); 20730294Ssam int spl, err; 20829651Ssam 20930294Ssam if (uio->uio_iov->iov_len <= 0 || uio->uio_iov->iov_len & 1 || 21030294Ssam (int)uio->uio_iov->iov_base & 1) 21130294Ssam return (EINVAL); 21229651Ssam #ifdef DR_DEBUG 21330294Ssam if (DR11 & 4) 21430294Ssam printf("\ndrwrite: (len:%ld)(base:%lx)", 21530294Ssam uio->uio_iov->iov_len,(int)uio->uio_iov->iov_base); 21629651Ssam #endif 21730294Ssam dra = &dr_aux[RSUNIT(dev)]; 21830294Ssam dra->dr_op = DR_WRITE; 21930294Ssam bp = &dra->dr_buf; 22030294Ssam bp->b_resid = 0; 22130294Ssam if (dra->dr_flags & DR_NOWSTALL) { 22230294Ssam /* 22330294Ssam * We are in no stall mode, start the timer, 22430294Ssam * raise IPL so nothing can stop us once the 22530294Ssam * timer's running 22630294Ssam */ 22730294Ssam spl = SPL_UP(); 22830294Ssam timeout(drrwtimo,(caddr_t)((dra->currenttimo<<8) | unit), 22930294Ssam (int)dra->wtimoticks); 23030294Ssam err = physio (drstrategy, bp, dev,B_WRITE, drminphys, uio); 23130294Ssam splx(spl); 23230294Ssam if (err) 23330294Ssam return (err); 23430294Ssam dra->currenttimo++; /* Update current timeout number */ 23530294Ssam /* Did we timeout */ 23630294Ssam if (dra->dr_flags & DR_TMDM) { 23730294Ssam dra->dr_flags &= ~DR_TMDM; /* Clear timeout flag */ 23830294Ssam u.u_error = 0; /* Made the error ourself, ignore it */ 23930294Ssam } 24030294Ssam return (err); 24129651Ssam } 24230294Ssam return (physio(drstrategy, bp, dev,B_WRITE, drminphys, uio)); 24329651Ssam } 24429651Ssam 24530294Ssam /* 24630294Ssam * Routine used by calling program to issue commands to dr11 driver and 24730294Ssam * through it to the device. 24830294Ssam * It is also used to read status from the device and driver and to wait 24930294Ssam * for attention interrupts. 25030294Ssam * Status is returned in an 8 elements unsigned short integer array, the 25130294Ssam * first two elements of the array are also used to pass arguments to 25230294Ssam * drioctl() if required. 25330294Ssam * The function bits to be written to the dr11 are included in the cmd 25430294Ssam * argument. Even if they are not being written to the dr11 in a particular 25530294Ssam * drioctl() call, they will update the copy of cmd that is stored in the 25630294Ssam * driver. When drstrategy() is called, this updated copy is used if a 25730294Ssam * deferred function bit write has been specified. The "side effect" of 25830294Ssam * calls to the drioctl() requires that the last call prior to a read or 25930294Ssam * write has an appropriate copy of the function bits in cmd if they are 26030294Ssam * to be used in drstrategy(). 26130294Ssam * When used as command value, the contents of data[0] is the command 26230294Ssam * parameter. 26330294Ssam */ 26430294Ssam drioctl(dev, cmd, data) 26530294Ssam dev_t dev; 26630294Ssam int cmd; 26730294Ssam long *data; 26829651Ssam { 26930294Ssam register int unit = RSUNIT(dev); 27030294Ssam register struct dr_aux *dra; 27130294Ssam register struct rsdevice *rsaddr = RSADDR(unit); 27230294Ssam int s; 27330294Ssam u_short status; 27430294Ssam long temp; 27529651Ssam 27629651Ssam #ifdef DR_DEBUG 27730294Ssam if (DR11 & 0x10) 27830294Ssam printf("\ndrioctl: (dev:%lx)(cmd:%lx)(data:%lx)(data[0]:%lx)", 27930294Ssam dev,cmd,data,data[0]); 28029651Ssam #endif 28130294Ssam dra = &dr_aux[unit]; 28230294Ssam dra->dr_cmd = 0; /* Fresh copy; clear all previous flags */ 28330294Ssam switch (cmd) { 28429651Ssam 28530294Ssam case DRWAIT: /* Wait for attention interrupt */ 28629651Ssam #ifdef DR_DEBUG 28730294Ssam printf("\ndrioctl: wait for attention interrupt"); 28829651Ssam #endif 28930294Ssam s = SPL_UP(); 29030294Ssam /* 29130294Ssam * If the attention flag in dr_flags is set, it probably 29230294Ssam * means that an attention has arrived by the time a 29330294Ssam * previous DMA end-of-range interrupt was serviced. If 29430294Ssam * ATRX is set, we will return with out sleeping, since 29530294Ssam * we have received an attention since the last call to 29630294Ssam * wait on attention. This may not be appropriate for 29730294Ssam * some applications. 29830294Ssam */ 29930294Ssam if ((dra->dr_flags & DR_ATRX) == 0) { 30030294Ssam dra->dr_flags |= DR_ATWT; /* Set waiting flag */ 30130294Ssam /* 30230294Ssam * Enable interrupt; use pulse reg. 30330294Ssam * so function bits are not changed 30430294Ssam */ 30530294Ssam rsaddr->dr_pulse = IENB; 30630294Ssam sleep((caddr_t)&dra->dr_cmd, DRPRI); 30730294Ssam } 30830294Ssam splx(s); 30930294Ssam break; 31029651Ssam 31130294Ssam case DRPIOW: /* Write to p-i/o register */ 31230294Ssam rsaddr->dr_data = data[0]; 31330294Ssam break; 31429651Ssam 31530294Ssam case DRPACL: /* Send pulse to device */ 31630294Ssam rsaddr->dr_pulse = FCN2; 31730294Ssam break; 31829651Ssam 31930294Ssam case DRDACL: /* Defer alco pulse until go */ 32030294Ssam dra->dr_cmd |= DR_DACL; 32130294Ssam break; 32229651Ssam 32330294Ssam case DRPCYL: /* Set cycle with next go */ 32430294Ssam dra->dr_cmd |= DR_PCYL; 32530294Ssam break; 32629651Ssam 32730294Ssam case DRDFCN: /* Update function with next go */ 32830294Ssam dra->dr_cmd |= DR_DFCN; 32930294Ssam break; 33029651Ssam 33130294Ssam case DRRATN: /* Reset attention flag */ 33230294Ssam rsaddr->dr_pulse = RATN; 33330294Ssam break; 33429651Ssam 33530294Ssam case DRRDMA: /* Reset DMA e-o-r flag */ 33630294Ssam rsaddr->dr_pulse = RDMA; 33730294Ssam break; 33829651Ssam 33930294Ssam case DRSFCN: /* Set function bits */ 34030294Ssam temp = data[0] & DR_FMSK; 34130294Ssam /* 34230294Ssam * This has a very important side effect -- It clears 34330294Ssam * the interrupt enable flag. That is fine for this driver, 34430294Ssam * but if it is desired to leave interrupt enable at all 34530294Ssam * times, it will be necessary to read the status register 34630294Ssam * first to get IENB, or carry a software flag that indicates 34730294Ssam * whether interrupts are set, and or this into the control 34830294Ssam * register value being written. 34930294Ssam */ 35030294Ssam rsaddr->dr_cstat = temp; 35130294Ssam break; 35229651Ssam 35330294Ssam case DRRPER: /* Clear parity flag */ 35430294Ssam rsaddr->dr_pulse = RPER; 35530294Ssam break; 35629651Ssam 35730294Ssam case DRSETRSTALL: /* Set read stall mode. */ 35830294Ssam dra->dr_flags &= (~DR_NORSTALL); 35930294Ssam break; 36029651Ssam 36130294Ssam case DRSETNORSTALL: /* Set no stall read mode. */ 36230294Ssam dra->dr_flags |= DR_NORSTALL; 36330294Ssam break; 36429651Ssam 36530294Ssam case DRGETRSTALL: /* Returns true if in read stall mode */ 36630294Ssam data[0] = (dra->dr_flags & DR_NORSTALL)? 0 : 1; 36730294Ssam break; 36829651Ssam 36930294Ssam case DRSETRTIMEOUT: /* Set read stall timeout (1/10 secs) */ 37030294Ssam if (data[0] < 1) { 37130294Ssam u.u_error = EINVAL; 37230294Ssam temp = 1; 37330294Ssam } 37430294Ssam dra->rtimoticks = (data[0] * hz )/10; 37530294Ssam break; 37629651Ssam 37730294Ssam case DRGETRTIMEOUT: /* Return read stall timeout */ 37830294Ssam data[0] = ((dra->rtimoticks)*10)/hz; 37930294Ssam break; 38029651Ssam 38130294Ssam case DRSETWSTALL: /* Set write stall mode. */ 38230294Ssam dra->dr_flags &= (~DR_NOWSTALL); 38330294Ssam break; 38429651Ssam 38530294Ssam case DRSETNOWSTALL: /* Set write stall mode. */ 38630294Ssam dra->dr_flags |= DR_NOWSTALL; 38730294Ssam break; 38829651Ssam 38930294Ssam case DRGETWSTALL: /* Return true if in write stall mode */ 39030294Ssam data[0] = (dra->dr_flags & DR_NOWSTALL)? 0 : 1; 39130294Ssam break; 39229651Ssam 39330294Ssam case DRSETWTIMEOUT: /* Set write stall timeout (1/10's) */ 39430294Ssam if (data[0] < 1) { 39530294Ssam u.u_error = EINVAL; 39630294Ssam temp = 1; 39730294Ssam } 39830294Ssam dra->wtimoticks = (data[0] * hz )/10; 39930294Ssam break; 40029651Ssam 40130294Ssam case DRGETWTIMEOUT: /* Return write stall timeout */ 40230294Ssam data[0] = ((dra->wtimoticks)*10)/hz; 40330294Ssam break; 40429651Ssam 40530294Ssam case DRWRITEREADY: /* Return true if can write data */ 40630294Ssam data[0] = (rsaddr->dr_cstat & STTA)? 1 : 0; 40730294Ssam break; 40829651Ssam 40930294Ssam case DRREADREADY: /* Return true if data to be read */ 41030294Ssam data[0] = (rsaddr->dr_cstat & STTB)? 1 : 0; 41130294Ssam break; 41229651Ssam 41330294Ssam case DRBUSY: /* Return true if device busy */ 41430294Ssam /* 41530294Ssam * Internally this is the DR11-W 41630294Ssam * STAT C bit, but there is a bug in the Omega 500/FIFO 41730294Ssam * interface board that it cannot drive this signal low 41830294Ssam * for certain DR11-W ctlr such as the Ikon. We use the 41930294Ssam * REDY signal of the CSR on the Ikon DR11-W instead. 42030294Ssam */ 42130294Ssam #ifdef notdef 42230294Ssam data[0] = (rsaddr->dr_cstat & STTC)? 1 : 0; 42330294Ssam #else 42430294Ssam data[0] = ((rsaddr->dr_cstat & REDY)? 0 : 1); 42530294Ssam #endif 42630294Ssam break; 42729651Ssam 42830294Ssam case DRRESET: /* Reset device */ 42930294Ssam /* Reset DMA ATN RPER flag */ 43030294Ssam rsaddr->dr_pulse = (MCLR|RDMA|RATN|RPER); 43130294Ssam DELAY(0x1f000); 43230294Ssam while ((rsaddr->dr_cstat & REDY) == 0) 43330294Ssam sleep((caddr_t)dra, DRPRI); /* Wakeup by drtimo() */ 43430294Ssam dra->dr_istat = 0; 43530294Ssam dra->dr_cmd = 0; 43630294Ssam dra->currenttimo = 0; 43730294Ssam break; 43829651Ssam 43930294Ssam case DR11STAT: { /* Copy back dr11 status to user */ 44030294Ssam register struct dr11io *dr = (struct dr11io *)data; 44130294Ssam dr->arg[0] = dra->dr_flags; 44230294Ssam dr->arg[1] = rsaddr->dr_cstat; 44330294Ssam dr->arg[2] = dra->dr_istat; /* Status at last interrupt */ 44430294Ssam dr->arg[3] = rsaddr->dr_data; /* P-i/o input data */ 44530294Ssam status = (u_short)((rsaddr->dr_addmod << 8) & 0xff00); 44630294Ssam dr->arg[4] = status | (u_short)(rsaddr->dr_intvect & 0xff); 44730294Ssam dr->arg[5] = rsaddr->dr_range; 44830294Ssam dr->arg[6] = rsaddr->dr_rahi; 44930294Ssam dr->arg[7] = rsaddr->dr_ralo; 45030294Ssam break; 45130294Ssam } 45230294Ssam case DR11LOOP: /* Perform loopback test */ 45330294Ssam /* 45430294Ssam * NB: MUST HAVE LOOPBACK CABLE ATTACHED -- 45530294Ssam * Test results are printed on system console 45630294Ssam */ 45730294Ssam if (suser()) 45830294Ssam dr11loop(rsaddr, dra, unit); 45930294Ssam break; 46029651Ssam 46130294Ssam default: 46230294Ssam return (EINVAL); 46329651Ssam } 46429651Ssam #ifdef DR_DEBUG 46530294Ssam if (DR11 & 0x10) 46630294Ssam printf("**** (data[0]:%lx)",data[0]); 46729651Ssam #endif 46830294Ssam return (0); 46929651Ssam } 47029651Ssam 47130294Ssam #define NPAT 2 47230294Ssam #define DMATBL 20 47330294Ssam u_short tstpat[DMATBL] = { 0xAAAA, 0x5555}; 47430294Ssam long DMAin = 0; 47530138Ssam 47630294Ssam /* 47730294Ssam * Perform loopback test -- MUST HAVE LOOPBACK CABLE ATTACHED 47830294Ssam * Test results are printed on system console 47930294Ssam */ 48030294Ssam dr11loop(dr, dra, unit) 48130294Ssam struct rsdevice *dr; 48230294Ssam struct dr_aux *dra; 48330294Ssam int unit; 48430294Ssam { 48530294Ssam register long result, ix; 48630294Ssam long addr, wait; 48730138Ssam 48830138Ssam dr->dr_cstat = MCLR; /* Clear board & device, disable intr */ 48930294Ssam printf("\n\t ----- DR11 unit %ld loopback test -----", unit); 49030138Ssam printf("\n\t Program I/O ..."); 49130138Ssam for (ix=0;ix<NPAT;ix++) { 49230138Ssam dr->dr_data = tstpat[ix]; /* Write to Data out register */ 49330294Ssam result = dr->dr_data & 0xFFFF; /* Read it back */ 49430138Ssam if (result != tstpat[ix]) { 49530138Ssam printf("Failed, expected : %lx --- actual : %lx", 49630294Ssam tstpat[ix], result); 49730138Ssam return; 49830138Ssam } 49930138Ssam } 50030138Ssam printf("OK\n\t Functions & Status Bits ..."); 50130138Ssam dr->dr_cstat = (FCN1 | FCN3); 50230138Ssam result = dr->dr_cstat & 0xffff; /* Read them back */ 50330138Ssam if ((result & (STTC | STTA)) != (STTC |STTA)) { 50430138Ssam printf("Failed, expected : %lx --- actual : %lx, ISR:%lx", 50530294Ssam (STTA|STTC), (result & (STTA|STTC)), result); 50630138Ssam return; 50730138Ssam } 50830138Ssam dr->dr_cstat = FCN2; 50930138Ssam result = dr->dr_cstat & 0xffff; /* Read them back */ 51030138Ssam if ((result & STTB) != STTB) { 51130138Ssam printf("Failed, expected : %lx --- actual : %lx, ISR:%lx", 51230294Ssam STTB, (result & STTB), result); 51330138Ssam return; 51430138Ssam } 51530138Ssam printf("OK\n\t DMA output ..."); 51630294Ssam if (DMAin) 51730294Ssam goto dmain; 51830138Ssam /* Initialize DMA data buffer */ 51930294Ssam for (ix=0; ix<DMATBL; ix++) 52030294Ssam tstpat[ix] = 0xCCCC + ix; 52130138Ssam tstpat[DMATBL-1] = 0xCCCC; /* Last word output */ 52230138Ssam /* Setup normal DMA */ 52330294Ssam addr = (long)vtoph((struct proc *)0, (unsigned)tstpat); 52430294Ssam dr->dr_walo = (addr >> 1) & 0xffff; 52530294Ssam dr->dr_wahi = (addr >> 17) & 0x7fff; 52630294Ssam /* Set DMA range count: (number of words - 1) */ 52730294Ssam dr->dr_range = DMATBL - 1; 52830294Ssam /* Set address modifier code to be used for DMA access to memory */ 52930294Ssam dr->dr_addmod = DRADDMOD; 53030138Ssam 53130294Ssam /* 53230294Ssam * Clear dmaf and attf to assure a clean dma start, also disable 53330294Ssam * attention interrupt 53430294Ssam */ 53530294Ssam dr->dr_pulse = RDMA|RATN|RMSK; /* Use pulse register */ 53630294Ssam dr->dr_cstat = GO|CYCL; /* GO...... */ 53730138Ssam 53830138Ssam /* Wait for DMA complete; REDY and DMAF are true in ISR */ 53930138Ssam wait = 0; 54030294Ssam while ((result=(dr->dr_cstat & (REDY|DMAF))) != (REDY|DMAF)) { 54130294Ssam printf("\n\tWait for DMA complete...ISR : %lx", result); 54230138Ssam if (++wait > 5) { 54330138Ssam printf("\n\t DMA output fails...timeout!!, ISR:%lx", 54430138Ssam result); 54530138Ssam return; 54630138Ssam } 54730138Ssam } 54830138Ssam result = dr->dr_data & 0xffff; /* Read last word output */ 54930138Ssam if (result != 0xCCCC) { 55030138Ssam printf("\n\t Fails, expected : %lx --- actual : %lx", 55130294Ssam 0xCCCC, result); 55230138Ssam return; 55330138Ssam } 55430138Ssam printf("OK\n\t DMA input ..."); 55530138Ssam dmain: 55630138Ssam dr->dr_data = 0x1111; /* DMA input data */ 55730138Ssam /* Setup normal DMA */ 55830294Ssam addr = (long)vtoph((struct proc *)0, (unsigned)tstpat); 55930294Ssam dr->dr_walo = (addr >> 1) & 0xffff; 56030294Ssam dr->dr_wahi = (addr >> 17) & 0x7fff; 56130294Ssam dr->dr_range = DMATBL - 1; 56230294Ssam dr->dr_addmod = (char)DRADDMOD; 56330294Ssam dr->dr_cstat = FCN1; /* Set FCN1 in ICR to DMA in*/ 56430294Ssam if ((dra->dr_flags & DR_LOOPTST) == 0) { 56530138Ssam /* Use pulse reg */ 56630294Ssam dr->dr_pulse = RDMA|RATN|RMSK|CYCL|GO; 56730138Ssam /* Wait for DMA complete; REDY and DMAF are true in ISR */ 56830138Ssam wait = 0; 56930294Ssam while ((result=(dr->dr_cstat & (REDY|DMAF))) != (REDY|DMAF)) { 57030138Ssam printf("\n\tWait for DMA to complete...ISR:%lx",result); 57130138Ssam if (++wait > 5) { 57230138Ssam printf("\n\t DMA input timeout!!, ISR:%lx", 57330138Ssam result); 57430138Ssam return; 57530138Ssam } 57630138Ssam } 57730294Ssam } else { 57830138Ssam /* Enable DMA e-o-r interrupt */ 57930294Ssam dr->dr_pulse = IENB|RDMA|RATN|CYCL|GO; 58030138Ssam /* Wait for DMA complete; DR_LOOPTST is false in dra->dr_flags*/ 58130138Ssam wait = 0; 58230138Ssam while (dra->dr_flags & DR_LOOPTST) { 58330138Ssam result = dr->dr_cstat & 0xffff; 58430294Ssam printf("\n\tWait for DMA e-o-r intr...ISR:%lx", result); 58530138Ssam if (++wait > 7) { 58630138Ssam printf("\n\t DMA e-o-r timeout!!, ISR:%lx", 58730138Ssam result); 58830138Ssam dra->dr_flags &= ~DR_LOOPTST; 58930138Ssam return; 59030138Ssam } 59130138Ssam } 59230138Ssam dra->dr_flags |= DR_LOOPTST; 59330138Ssam } 59430294Ssam mtpr(P1DC, tstpat); /* Purge cache */ 59530294Ssam mtpr(P1DC, 0x3ff+tstpat); 59630294Ssam for (ix=0; ix<DMATBL; ix++) { 59730138Ssam if (tstpat[ix] != 0x1111) { 59830294Ssam printf("\n\t Fails, ix:%d, expected:%x --- actual:%x", 59930294Ssam ix, 0x1111, tstpat[ix]); 60030138Ssam return; 60130138Ssam } 60230138Ssam } 60330294Ssam if ((dra->dr_flags & DR_LOOPTST) == 0) { 60430138Ssam dra->dr_flags |= DR_LOOPTST; 60530138Ssam printf(" OK..\n\tDMA end of range interrupt..."); 60630138Ssam goto dmain; 60730138Ssam } 60830138Ssam printf(" OK..\n\tAttention interrupt...."); 60930294Ssam dr->dr_pulse = IENB|RDMA; 61030294Ssam dr->dr_pulse = FCN2; 61130138Ssam /* Wait for ATTN interrupt; DR_LOOPTST is false in dra->dr_flags*/ 61230138Ssam wait = 0; 61330138Ssam while (dra->dr_flags & DR_LOOPTST) { 61430138Ssam result = dr->dr_cstat & 0xffff; 61530138Ssam printf("\n\tWait for Attention intr...ISR:%lx",result); 61630138Ssam if (++wait > 7) { 61730138Ssam printf("\n\t Attention interrupt timeout!!, ISR:%lx", 61830138Ssam result); 61930138Ssam dra->dr_flags &= ~DR_LOOPTST; 62030138Ssam return; 62130138Ssam } 62230138Ssam } 62330138Ssam dra->dr_flags &= ~DR_LOOPTST; 62430138Ssam printf(" OK..\n\tDone..."); 62530138Ssam } 62630138Ssam 62729651Ssam /* Reset state on Unibus reset */ 62830294Ssam /*ARGSUSED*/ 62929651Ssam drreset(uban) 63030294Ssam int uban; 63129651Ssam { 63229651Ssam 63329651Ssam } 63429651Ssam 63529651Ssam /* 63629651Ssam * An interrupt is caused either by an error, 63729651Ssam * base address overflow, or transfer complete 63829651Ssam */ 63930294Ssam drintr(dr11) 64030294Ssam int dr11; 64129651Ssam { 64230294Ssam register struct dr_aux *dra = &dr_aux[dr11]; 64330294Ssam register struct rsdevice *rsaddr = RSADDR(dr11); 64430294Ssam register struct buf *bp; 64530294Ssam register short status; 64629651Ssam 64730294Ssam status = rsaddr->dr_cstat & 0xffff; /* get board status register */ 64830294Ssam dra->dr_istat = status; 64929651Ssam #ifdef DR_DEBUG 65030294Ssam if (DR11 & 2) 65130294Ssam printf("\ndrintr: dr11 status : %lx",status & 0xffff); 65229651Ssam #endif 65330294Ssam if (dra->dr_flags & DR_LOOPTST) { /* doing loopback test */ 65430294Ssam dra->dr_flags &= ~DR_LOOPTST; 65530294Ssam return; 65630294Ssam } 65730294Ssam /* 65830294Ssam * Make sure this is not a stray interrupt; at least one of dmaf or attf 65930294Ssam * must be set. Note that if the dr11 interrupt enable latch is reset 66030294Ssam * during a hardware interrupt ack sequence, and by the we get to this 66130294Ssam * point in the interrupt code it will be 0. This is done to give the 66230294Ssam * programmer some control over how the two more-or-less independent 66330294Ssam * interrupt sources on the board are handled. 66430294Ssam * If the attention flag is set when drstrategy() is called to start a 66530294Ssam * dma read or write an interrupt will be generated as soon as the 66630294Ssam * strategy routine enables interrupts for dma end-of-range. This will 66730294Ssam * cause execution of the interrupt routine (not necessarily bad) and 66830294Ssam * will cause the interrupt enable mask to be reset (very bad since the 66930294Ssam * dma end-of-range condition will not be able to generate an interrupt 67030294Ssam * when it occurs) causing the dma operation to time-out (even though 67130294Ssam * the dma transfer will be done successfully) or hang the process if a 67230294Ssam * software time-out capability is not implemented. One way to avoid 67330294Ssam * this situation is to check for a pending attention interrupt (attf 67430294Ssam * set) by calling drioctl() before doing a read or a write. For the 67530294Ssam * time being this driver will solve the problem by clearing the attf 67630294Ssam * flag in the status register before enabling interrupts in 67730294Ssam * drstrategy(). 67830294Ssam * 67930294Ssam * **** The IKON 10084 for which this driver is written will set both 68030294Ssam * attf and dmaf if dma is terminated by an attention pulse. This will 68130294Ssam * cause a wakeup(&dr_aux), which will be ignored since it is not being 68230294Ssam * waited on, and an iodone(bp) which is the desired action. Some other 68330294Ssam * dr11 emulators, in particular the IKON 10077 for the Multibus, donot 68430294Ssam * dmaf in this case. This may require some addtional code in the inter- 68530294Ssam * rupt routine to ensure that en iodone(bp) is issued when dma is term- 68630294Ssam * inated by attention. 68730294Ssam */ 68830294Ssam bp = dra->dr_actf; 68930294Ssam if ((status & (ATTF | DMAF)) == 0) { 69030294Ssam printf("dr%d: stray interrupt, status=%x", dr11, status); 69130294Ssam return; 69230294Ssam } 69330294Ssam if (status & DMAF) { /* End-of-range interrupt */ 69430294Ssam dra->dr_flags |= DR_DMAX; 69529651Ssam 69629651Ssam #ifdef DR_DEBUG 69730294Ssam if (DR11 & 2) 69830294Ssam printf("\ndrintr: e-o-r interrupt,cstat:%lx,dr_flags:%lx", 69930294Ssam status&0xffff, dra->dr_flags & DR_ACTV); 70029651Ssam #endif 70130294Ssam if ((dra->dr_flags & DR_ACTV) == 0) { 70230294Ssam /* We are not doing DMA !! */ 70330294Ssam bp->b_flags |= B_ERROR; 70430294Ssam } else { 70530294Ssam if (dra->dr_op == DR_READ) 70630294Ssam mtpr(P1DC, bp->b_un.b_addr); 70730294Ssam dra->dr_bycnt -= bp->b_bcount; 70830294Ssam if (dra->dr_bycnt >0) { 70930294Ssam bp->b_un.b_addr += bp->b_bcount; 71030294Ssam bp->b_bcount = (dra->dr_bycnt > NBPG) ? NBPG: 71129651Ssam dra->dr_bycnt; 71230294Ssam drstart(rsaddr, dra, bp); 71330294Ssam return; 71430294Ssam } 71529651Ssam } 71630294Ssam dra->dr_flags &= ~DR_ACTV; 71730294Ssam wakeup((caddr_t)dra); /* Wakeup waiting in drwait() */ 71830294Ssam rsaddr->dr_pulse = (RPER|RDMA|RATN); /* reset dma e-o-r flag */ 71929651Ssam } 72030294Ssam /* 72130294Ssam * Now test for attention interrupt -- It may be set in addition to 72230294Ssam * the dma e-o-r interrupt. If we get one we will issue a wakeup to 72330294Ssam * the drioctl() routine which is presumable waiting for one. 72430294Ssam * The program may have to monitor the attention interrupt received 72530294Ssam * flag in addition to doing waits for the interrupt. Futhermore, 72630294Ssam * interrupts are not enabled unless dma is in progress or drioctl() 72730294Ssam * has been called to wait for attention -- this may produce some 72830294Ssam * strange results if attf is set on the dr11 when a read or a write 72930294Ssam * is initiated, since that will enables interrupts. 73030294Ssam * **** The appropriate code for this interrupt routine will probably 73130294Ssam * be rather application dependent. 73230294Ssam */ 73330294Ssam if (status & ATTF) { 73430294Ssam dra->dr_flags |= DR_ATRX; 73530294Ssam dra->dr_flags &= ~DR_ATWT; 73630294Ssam rsaddr->dr_cstat = RATN; /* reset attention flag */ 73730294Ssam /* 73830294Ssam * Some applications which use attention to terminate 73930294Ssam * dma may also want to issue an iodone() here to 74030294Ssam * wakeup physio(). 74130294Ssam */ 74230294Ssam wakeup((caddr_t)&dra->dr_cmd); 74330294Ssam } 74429651Ssam } 74529651Ssam 74629651Ssam unsigned 74729651Ssam drminphys(bp) 74830294Ssam struct buf *bp; 74929651Ssam { 75030294Ssam 75130294Ssam if (bp->b_bcount > 65536) 75230294Ssam bp->b_bcount = 65536; 75329651Ssam } 75429651Ssam 75529651Ssam /* 75630294Ssam * This routine performs the device unique operations on the DR11W 75730294Ssam * it is passed as an argument to and invoked by physio 75829651Ssam */ 75929651Ssam drstrategy (bp) 76030294Ssam register struct buf *bp; 76129651Ssam { 76230294Ssam register int s; 76330294Ssam int unit = RSUNIT(bp->b_dev); 76430294Ssam register struct rsdevice *rsaddr = RSADDR(unit); 76530294Ssam register struct dr_aux *dra = &dr_aux[unit]; 76630294Ssam register int ok; 76729651Ssam #ifdef DR_DEBUG 76830294Ssam register char *caddr; 76930294Ssam long drva(); 77029651Ssam #endif 77129651Ssam 77230294Ssam if ((dra->dr_flags & DR_OPEN) == 0) { /* Device not open */ 77330294Ssam bp->b_error = ENXIO; 77430294Ssam bp->b_flags |= B_ERROR; 77530294Ssam iodone (bp); 77630294Ssam return; 77730294Ssam } 77830294Ssam while (dra->dr_flags & DR_ACTV) 77930294Ssam /* Device is active; should never be in here... */ 78030294Ssam sleep((caddr_t)&dra->dr_flags,DRPRI); 78130294Ssam dra->dr_actf = bp; 78229651Ssam #ifdef DR_DEBUG 78330294Ssam drva(dra, bp->b_proc, bp->b_un.b_addr, bp->b_bcount); 78429651Ssam #endif 78530294Ssam dra->dr_oba = bp->b_un.b_addr; /* Save original addr, count */ 78630294Ssam dra->dr_obc = bp->b_bcount; 78730294Ssam dra->dr_bycnt = bp->b_bcount; /* Save xfer count used by drintr() */ 78830294Ssam if ((((long)bp->b_un.b_addr & 0x3fffffff) >> PGSHIFT) != 78930294Ssam ((((long)bp->b_un.b_addr & 0x3fffffff) + bp->b_bcount) >> PGSHIFT)) 79030294Ssam bp->b_bcount = NBPG - (((long)bp->b_un.b_addr) & PGOFSET); 79130294Ssam dra->dr_flags |= DR_ACTV; /* Mark active (use in intr handler) */ 79230294Ssam s = SPL_UP(); 79330294Ssam drstart(rsaddr,dra,bp); 79430294Ssam splx(s); 79530294Ssam ok = drwait(rsaddr,dra); 79629651Ssam #ifdef DR_DEBUG 79730294Ssam if (DR11 & 0x40) { 79830294Ssam caddr = (char *)dra->dr_oba; 79930294Ssam if (dra->dr_op == DR_READ) 80030294Ssam printf("\nAfter read: (%lx)(%lx)", 80130294Ssam caddr[0]&0xff, caddr[1]&0xff); 80230294Ssam } 80329651Ssam #endif 80430294Ssam dra->dr_flags &= ~DR_ACTV; /* Clear active flag */ 80530294Ssam bp->b_un.b_addr = dra->dr_oba; /* Restore original addr, count */ 80630294Ssam bp->b_bcount = dra->dr_obc; 80730294Ssam if (!ok) 80830294Ssam bp->b_flags |= B_ERROR; 80930294Ssam /* Mark buffer B_DONE,so physstrat() in ml/machdep.c won't sleep */ 81030294Ssam iodone(bp); 81130294Ssam wakeup((caddr_t)&dra->dr_flags); 81230294Ssam /* 81330294Ssam * Return to the calling program (physio()). Physio() will sleep 81430294Ssam * until awaken by a call to iodone() in the interupt handler -- 81530294Ssam * which will be called by the dispatcher when it receives dma 81630294Ssam * end-of-range interrupt. 81730294Ssam */ 81829651Ssam } 81929651Ssam 82030294Ssam drwait(rs, dr) 82130294Ssam register struct rsdevice *rs; 82230294Ssam register struct dr_aux *dr; 82329651Ssam { 82430294Ssam int s; 82529651Ssam 82629651Ssam s = SPL_UP(); 82730294Ssam while (dr->dr_flags & DR_ACTV) 82830294Ssam sleep((caddr_t)dr, DRPRI); 82929651Ssam splx(s); 83030294Ssam if (dr->dr_flags & DR_TMDM) { /* DMA timed out */ 83129651Ssam dr->dr_flags &= ~DR_TMDM; 83230294Ssam return (0); 83329651Ssam } 83430294Ssam if (rs->dr_cstat & (PERR|BERR|TERR)) { 83530294Ssam dr->dr_actf->b_flags |= B_ERROR; 83630294Ssam return (0); 83729651Ssam } 83829651Ssam dr->dr_flags &= ~DR_DMAX; 83930294Ssam return (1); 84029651Ssam } 84129651Ssam 84230294Ssam /* 84330294Ssam * 84430294Ssam * The lower 8-bit of tinfo is the minor device number, the 84530294Ssam * remaining higher 8-bit is the current timout number 84630294Ssam */ 84729651Ssam drrwtimo(tinfo) 84830294Ssam register u_long tinfo; 84930294Ssam { 85030294Ssam register long unit = tinfo & 0xff; 85129651Ssam register struct dr_aux *dr = &dr_aux[unit]; 85229651Ssam register struct rsdevice *rs = dr->dr_addr; 85329651Ssam 85430294Ssam /* 85530294Ssam * If this is not the timeout that drwrite/drread is waiting 85630294Ssam * for then we should just go away 85730294Ssam */ 85830294Ssam if ((tinfo &~ 0xff) != (dr->currenttimo << 8)) 85930294Ssam return; 86029651Ssam /* Mark the device timed out */ 86129651Ssam dr->dr_flags |= DR_TMDM; 86229651Ssam dr->dr_flags &= ~DR_ACTV; 86329651Ssam rs->dr_pulse = RMSK; /* Inihibit interrupt */ 86429651Ssam rs->dr_pulse = (RPER|RDMA|RATN|IENB); /* Clear DMA logic */ 86530294Ssam /* 86630294Ssam * Some applications will not issue a master after dma timeout, 86730294Ssam * since doing so sends an INIT H pulse to the external device, 86830294Ssam * which may produce undesirable side-effects. 86930294Ssam */ 87029651Ssam /* Wake up process waiting in drwait() and flag the error */ 87130294Ssam dr->dr_actf->b_flags |= B_ERROR; 87229651Ssam wakeup((caddr_t)dr->dr_cmd); 87329651Ssam } 87429651Ssam 87529651Ssam /* 87630294Ssam * Kick the driver every second 87730294Ssam */ 87829651Ssam drtimo(dev) 87930294Ssam dev_t dev; 88029651Ssam { 88130294Ssam register int unit = RSUNIT(dev); 88229651Ssam register struct dr_aux *dr; 88329651Ssam 88430294Ssam dr = &dr_aux[unit]; 88529651Ssam if (dr->dr_flags & DR_OPEN) 88630294Ssam timeout(drtimo, (caddr_t)dev, hz); 88729651Ssam wakeup((caddr_t)dr); /* Wakeup any process waiting for interrupt */ 88829651Ssam } 88929651Ssam 89029651Ssam #ifdef DR_DEBUG 89130294Ssam drva(dra, p, va, bcnt) 89230294Ssam struct dr_aux *dra; 89330294Ssam struct proc *p; 89430294Ssam char *va; 89530294Ssam long bcnt; 89630294Ssam { 89730294Ssam register long first, last , np; 89829651Ssam 89929651Ssam if (DR11 & 0x20) { 90030294Ssam first = ((long)(vtoph(p, (unsigned)va))) >> 10; 90130294Ssam last = ((long)(vtoph(p, (unsigned)va+bcnt))) >> 10; 90229651Ssam np = bcnt / 0x3ff; 90329651Ssam printf("\ndrva: (op:%ld)(first:%ld)(last:%ld)(np:%ld)(cnt:%ld)", 90429651Ssam dra->dr_op,first,last,np,bcnt); 90529651Ssam } 90629651Ssam } 90729651Ssam #endif 90829651Ssam 90930294Ssam drstart(rsaddr, dra, bp) 91030294Ssam register struct rsdevice *rsaddr; 91130294Ssam register struct dr_aux *dra; 91230294Ssam register struct buf *bp; 91330294Ssam { 91430294Ssam register long addr; 91530294Ssam u_short go; 91629651Ssam 91729651Ssam #ifdef DR_DEBUG 91830294Ssam if (dra->dr_op == DR_READ && (DR11 & 8)) { 91930294Ssam char *caddr = (char *)bp->b_un.b_addr; 92029651Ssam printf("\ndrstart: READ, bcnt:%ld",bp->b_bcount); 92129651Ssam printf(",(%lx)(%lx)",caddr[0]&0xff,caddr[1]&0xff); 92229651Ssam } 92329651Ssam #endif 92430294Ssam /* we are doing raw IO, bp->b_un.b_addr is user's address */ 92530294Ssam addr = (long)vtoph(bp->b_proc, (unsigned)bp->b_un.b_addr); 92630294Ssam /* 92730294Ssam * Set DMA address into DR11 interace registers: DR11 requires that 92830294Ssam * the address be right shifted 1 bit position before it is written 92930294Ssam * to the board (The board will left shift it one bit position before 93030294Ssam * it places the address on the bus 93130294Ssam */ 93230294Ssam rsaddr->dr_walo = (addr >> 1) & 0xffff; 93330294Ssam rsaddr->dr_wahi = (addr >> 17) & 0x7fff; 93430294Ssam /* Set DMA range count: (number of words - 1) */ 93530294Ssam rsaddr->dr_range = (bp->b_bcount >> 1) - 1; 93630294Ssam /* Set address modifier code to be used for DMA access to memory */ 93730294Ssam rsaddr->dr_addmod = DRADDMOD; 93830294Ssam /* 93930294Ssam * Now determine whether this is a read or a write. ***** This is 94030294Ssam * probably only usefull for link mode operation, since dr11 doesnot 94130294Ssam * controll the direction of data transfer. The C1 control input 94230294Ssam * controls whether the hardware is doing a read or a write. In link 94330294Ssam * mode this is controlled by function 1 latch (looped back by the 94430294Ssam * cable) and could be set the program. In the general case, the dr11 94530294Ssam * doesnot know in advance what the direction of transfer is - although 94630294Ssam * the program and protocol logic probably is 94730294Ssam */ 94829651Ssam #ifdef DR_DEBUG 94930294Ssam if (DR11 & 1) 95030294Ssam printf( 95130294Ssam "\ndrstrat: about to GO..,dr_cmd:%lx,drstat:%lx,drcnt:%ld,cdata:%lx,OP:%ld", 95230294Ssam dra->dr_cmd, rsaddr->dr_cstat, rsaddr->dr_range, 95330294Ssam rsaddr->dr_data, dra->dr_op); 95429651Ssam #endif 95530294Ssam /* 95630294Ssam * Update function latches may have been done already by drioctl() if 95730294Ssam * request from drioctl() 95830294Ssam */ 95930294Ssam if (dra->dr_cmd & DR_DFCN) { /* deferred function write */ 96030294Ssam dra->dr_cmd &= ~DR_DFCN; /* Clear request */ 96130294Ssam go = dra->dr_cmd & DR_FMSK; /* mask out fcn bits */ 96230294Ssam rsaddr->dr_cstat = go; /* Write it to the board */ 96330294Ssam } 96430294Ssam /* Clear dmaf and attf to assure a clean dma start */ 96530294Ssam rsaddr->dr_pulse = RATN|RDMA|RPER; 96630294Ssam rsaddr->dr_cstat = IENB|GO|CYCL|dra->dr_op; /* GO...... */ 96730294Ssam /* 96830294Ssam * Now check for software cycle request -- usually 96930294Ssam * by transmitter in link mode. 97030294Ssam */ 97130294Ssam if (dra->dr_cmd & DR_PCYL) { 97230294Ssam dra->dr_cmd &= ~DR_PCYL; /* Clear request */ 97330294Ssam rsaddr->dr_pulse = CYCL; /* Use pulse register again */ 97430294Ssam } 97530294Ssam /* 97630294Ssam * Now check for deferred ACLO FCNT2 pulse request -- usually to tell 97730294Ssam * the transmitter (via its attention) that we have enabled dma. 97830294Ssam */ 97930294Ssam if (dra->dr_cmd & DR_DACL) { 98030294Ssam dra->dr_cmd &= ~DR_DACL; /* Clear request */ 98130294Ssam rsaddr->dr_pulse = FCN2; /* Use pulse register again */ 98230294Ssam } 98329651Ssam } 98429651Ssam #endif NDR 985