1998-05-24 22:19:29 +04:00
|
|
|
/* $NetBSD: ptsc.c,v 1.19 1998/05/24 18:19:29 mark Exp $ */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1995 Scott Stevens
|
|
|
|
* Copyright (c) 1995 Daniel Widenfalk
|
|
|
|
* Copyright (c) 1994 Christian E. Hopps
|
|
|
|
* Copyright (c) 1982, 1990 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* @(#)ptsc.c
|
|
|
|
*/
|
1996-10-30 02:52:59 +03:00
|
|
|
|
1996-02-01 02:24:54 +03:00
|
|
|
/*
|
1996-10-15 03:42:17 +04:00
|
|
|
* Power-tec SCSI-2 driver uses SFAS216 generic driver
|
1996-10-30 02:52:59 +03:00
|
|
|
*
|
|
|
|
* Thanks to Alsystems for loaning a development card and providing
|
|
|
|
* programming information.
|
1996-02-01 02:24:54 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/device.h>
|
1997-08-27 15:22:52 +04:00
|
|
|
#include <dev/scsipi/scsi_all.h>
|
|
|
|
#include <dev/scsipi/scsipi_all.h>
|
|
|
|
#include <dev/scsipi/scsiconf.h>
|
1996-02-01 02:24:54 +03:00
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/vm_kern.h>
|
|
|
|
#include <vm/vm_page.h>
|
|
|
|
#include <machine/pmap.h>
|
|
|
|
#include <machine/io.h>
|
|
|
|
#include <machine/irqhandler.h>
|
1997-10-15 02:07:47 +04:00
|
|
|
#include <machine/bootconfig.h>
|
1996-02-01 02:24:54 +03:00
|
|
|
#include <arm32/podulebus/podulebus.h>
|
|
|
|
#include <arm32/podulebus/sfasreg.h>
|
|
|
|
#include <arm32/podulebus/sfasvar.h>
|
|
|
|
#include <arm32/podulebus/ptscreg.h>
|
|
|
|
#include <arm32/podulebus/ptscvar.h>
|
1996-10-15 03:42:17 +04:00
|
|
|
#include <arm32/podulebus/podules.h>
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
void ptscattach __P((struct device *, struct device *, void *));
|
1997-10-15 02:07:47 +04:00
|
|
|
int ptscmatch __P((struct device *, struct cfdata *, void *));
|
1997-08-27 15:22:52 +04:00
|
|
|
int ptsc_scsicmd __P((struct scsipi_xfer *));
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_adapter ptsc_scsiswitch = {
|
1996-02-01 02:24:54 +03:00
|
|
|
ptsc_scsicmd,
|
|
|
|
sfas_minphys,
|
|
|
|
0, /* no lun support */
|
|
|
|
0, /* no lun support */
|
|
|
|
};
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_device ptsc_scsidev = {
|
1996-02-01 02:24:54 +03:00
|
|
|
NULL, /* use default error handler */
|
|
|
|
NULL, /* do not have a start functio */
|
|
|
|
NULL, /* have no async handler */
|
|
|
|
NULL, /* Use default done routine */
|
|
|
|
};
|
|
|
|
|
1996-03-17 04:16:48 +03:00
|
|
|
struct cfattach ptsc_ca = {
|
|
|
|
sizeof(struct ptsc_softc), ptscmatch, ptscattach
|
|
|
|
};
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1997-01-28 07:20:58 +03:00
|
|
|
int ptsc_intr __P((void *arg));
|
1996-02-01 02:24:54 +03:00
|
|
|
int ptsc_setup_dma __P((struct sfas_softc *sc, void *ptr, int len,
|
|
|
|
int mode));
|
|
|
|
int ptsc_build_dma_chain __P((struct sfas_softc *sc,
|
|
|
|
struct sfas_dma_chain *chain, void *p, int l));
|
|
|
|
int ptsc_need_bump __P((struct sfas_softc *sc, void *ptr, int len));
|
|
|
|
void ptsc_led __P((struct sfas_softc *sc, int mode));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if we are a Power-tec SCSI-2 card
|
|
|
|
*/
|
|
|
|
int
|
1997-10-15 02:07:47 +04:00
|
|
|
ptscmatch(pdp, cf, auxp)
|
1996-02-01 02:24:54 +03:00
|
|
|
struct device *pdp;
|
1997-10-15 02:07:47 +04:00
|
|
|
struct cfdata *cf;
|
|
|
|
void *auxp;
|
1996-02-01 02:24:54 +03:00
|
|
|
{
|
|
|
|
struct podule_attach_args *pa = (struct podule_attach_args *)auxp;
|
|
|
|
|
1996-10-15 03:42:17 +04:00
|
|
|
/* Look for the card */
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-10-15 03:42:17 +04:00
|
|
|
if (matchpodule(pa, MANUFACTURER_ALSYSTEMS, PODULE_ALSYSTEMS_SCSI, -1) == 0)
|
1996-04-27 02:38:11 +04:00
|
|
|
return(0);
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ptscattach(pdp, dp, auxp)
|
|
|
|
struct device *pdp;
|
|
|
|
struct device *dp;
|
|
|
|
void *auxp;
|
|
|
|
{
|
|
|
|
struct ptsc_softc *sc = (struct ptsc_softc *)dp;
|
|
|
|
struct podule_attach_args *pa;
|
|
|
|
ptsc_regmap_p rp = &sc->sc_regmap;
|
|
|
|
vu_char *fas;
|
|
|
|
|
|
|
|
pa = (struct podule_attach_args *)auxp;
|
|
|
|
|
1996-04-27 02:38:11 +04:00
|
|
|
if (pa->pa_podule_number == -1)
|
|
|
|
panic("Podule has disappeared !");
|
|
|
|
|
|
|
|
sc->sc_specific.sc_podule_number = pa->pa_podule_number;
|
|
|
|
sc->sc_specific.sc_podule = pa->pa_podule;
|
1996-02-01 02:24:54 +03:00
|
|
|
sc->sc_specific.sc_iobase =
|
|
|
|
(vu_char *)sc->sc_specific.sc_podule->fast_base;
|
|
|
|
|
|
|
|
rp->chipreset = &sc->sc_specific.sc_iobase[PTSC_CONTROL_CHIPRESET];
|
|
|
|
rp->inten = &sc->sc_specific.sc_iobase[PTSC_CONTROL_INTEN];
|
|
|
|
rp->status = &sc->sc_specific.sc_iobase[PTSC_STATUS];
|
|
|
|
rp->term = &sc->sc_specific.sc_iobase[PTSC_CONTROL_TERM];
|
|
|
|
rp->led = &sc->sc_specific.sc_iobase[PTSC_CONTROL_LED];
|
|
|
|
fas = &sc->sc_specific.sc_iobase[PTSC_FASOFFSET_BASE];
|
|
|
|
|
|
|
|
rp->FAS216.sfas_tc_low = &fas[PTSC_FASOFFSET_TCL];
|
|
|
|
rp->FAS216.sfas_tc_mid = &fas[PTSC_FASOFFSET_TCM];
|
|
|
|
rp->FAS216.sfas_fifo = &fas[PTSC_FASOFFSET_FIFO];
|
|
|
|
rp->FAS216.sfas_command = &fas[PTSC_FASOFFSET_COMMAND];
|
|
|
|
rp->FAS216.sfas_dest_id = &fas[PTSC_FASOFFSET_DESTID];
|
|
|
|
rp->FAS216.sfas_timeout = &fas[PTSC_FASOFFSET_TIMEOUT];
|
|
|
|
rp->FAS216.sfas_syncper = &fas[PTSC_FASOFFSET_PERIOD];
|
|
|
|
rp->FAS216.sfas_syncoff = &fas[PTSC_FASOFFSET_OFFSET];
|
|
|
|
rp->FAS216.sfas_config1 = &fas[PTSC_FASOFFSET_CONFIG1];
|
|
|
|
rp->FAS216.sfas_clkconv = &fas[PTSC_FASOFFSET_CLOCKCONV];
|
|
|
|
rp->FAS216.sfas_test = &fas[PTSC_FASOFFSET_TEST];
|
|
|
|
rp->FAS216.sfas_config2 = &fas[PTSC_FASOFFSET_CONFIG2];
|
|
|
|
rp->FAS216.sfas_config3 = &fas[PTSC_FASOFFSET_CONFIG3];
|
|
|
|
rp->FAS216.sfas_tc_high = &fas[PTSC_FASOFFSET_TCH];
|
|
|
|
rp->FAS216.sfas_fifo_bot = &fas[PTSC_FASOFFSET_FIFOBOTTOM];
|
|
|
|
|
|
|
|
sc->sc_softc.sc_fas = (sfas_regmap_p)rp;
|
|
|
|
sc->sc_softc.sc_spec = &sc->sc_specific;
|
|
|
|
|
|
|
|
sc->sc_softc.sc_led = ptsc_led;
|
|
|
|
|
|
|
|
sc->sc_softc.sc_setup_dma = ptsc_setup_dma;
|
|
|
|
sc->sc_softc.sc_build_dma_chain = ptsc_build_dma_chain;
|
|
|
|
sc->sc_softc.sc_need_bump = ptsc_need_bump;
|
|
|
|
|
1997-01-17 04:12:26 +03:00
|
|
|
sc->sc_softc.sc_clock_freq = 40; /* Power-Tec runs at 8MHz */
|
1996-02-01 02:24:54 +03:00
|
|
|
sc->sc_softc.sc_timeout = 250; /* Set default timeout to 250ms */
|
|
|
|
sc->sc_softc.sc_config_flags = SFAS_NO_DMA /*| SFAS_NF_DEBUG*/;
|
|
|
|
sc->sc_softc.sc_host_id = 7; /* Should check the jumpers */
|
|
|
|
|
|
|
|
sc->sc_softc.sc_bump_sz = NBPG;
|
|
|
|
sc->sc_softc.sc_bump_pa = 0x0;
|
|
|
|
|
|
|
|
sfasinitialize((struct sfas_softc *)sc);
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
sc->sc_softc.sc_link.scsipi_scsi.channel = SCSI_CHANNEL_ONLY_ONE;
|
1996-02-01 02:24:54 +03:00
|
|
|
sc->sc_softc.sc_link.adapter_softc = sc;
|
1997-08-27 15:22:52 +04:00
|
|
|
sc->sc_softc.sc_link.scsipi_scsi.adapter_target = sc->sc_softc.sc_host_id;
|
1996-02-01 02:24:54 +03:00
|
|
|
sc->sc_softc.sc_link.adapter = &ptsc_scsiswitch;
|
|
|
|
sc->sc_softc.sc_link.device = &ptsc_scsidev;
|
|
|
|
sc->sc_softc.sc_link.openings = 1;
|
1997-08-27 15:22:52 +04:00
|
|
|
sc->sc_softc.sc_link.scsipi_scsi.max_target = 7;
|
|
|
|
sc->sc_softc.sc_link.type = BUS_SCSI;
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1997-10-15 02:07:47 +04:00
|
|
|
/* Provide an override for the host id */
|
|
|
|
(void)get_bootconf_option(boot_args, "ptsc.hostid",
|
|
|
|
BOOTOPT_TYPE_INT, &sc->sc_softc.sc_link.scsipi_scsi.adapter_target);
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
printf(" host=%d", sc->sc_softc.sc_link.scsipi_scsi.adapter_target);
|
1996-10-15 03:42:17 +04:00
|
|
|
|
1996-02-01 02:24:54 +03:00
|
|
|
sc->sc_softc.sc_ih.ih_func = ptsc_intr;
|
|
|
|
sc->sc_softc.sc_ih.ih_arg = &sc->sc_softc;
|
|
|
|
sc->sc_softc.sc_ih.ih_level = IPL_BIO;
|
1996-06-13 00:46:58 +04:00
|
|
|
sc->sc_softc.sc_ih.ih_name = "scsi: ptsc";
|
1996-06-13 22:29:45 +04:00
|
|
|
sc->sc_softc.sc_ih.ih_maskaddr = sc->sc_specific.sc_podule->irq_addr;
|
|
|
|
sc->sc_softc.sc_ih.ih_maskbits = sc->sc_specific.sc_podule->irq_mask;
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-10-15 03:42:17 +04:00
|
|
|
/* initialise the card */
|
|
|
|
/* *rp->term = 0;*/
|
1996-02-01 02:24:54 +03:00
|
|
|
*rp->inten = (PTSC_POLL?0:1);
|
|
|
|
*rp->led = 0;
|
|
|
|
|
|
|
|
#if PTSC_POLL == 0
|
|
|
|
if (irq_claim(IRQ_PODULE /*IRQ_EXPCARD0 + sc->sc_specific.sc_podule_number */,
|
|
|
|
&sc->sc_softc.sc_ih))
|
1996-10-15 03:42:17 +04:00
|
|
|
panic("%s: Cannot install IRQ handler\n", dp->dv_xname);
|
1997-01-17 04:12:26 +03:00
|
|
|
#else
|
|
|
|
printf(" polling");
|
1996-02-01 02:24:54 +03:00
|
|
|
#endif
|
|
|
|
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("\n");
|
1996-02-01 02:24:54 +03:00
|
|
|
|
1996-10-15 03:42:17 +04:00
|
|
|
/* attach all scsi units on us */
|
1996-08-28 22:59:15 +04:00
|
|
|
config_found(dp, &sc->sc_softc.sc_link, scsiprint);
|
1996-02-01 02:24:54 +03:00
|
|
|
}
|
|
|
|
|
1996-10-15 03:42:17 +04:00
|
|
|
|
1996-02-01 02:24:54 +03:00
|
|
|
int
|
1997-01-28 07:20:58 +03:00
|
|
|
ptsc_intr(arg)
|
|
|
|
void *arg;
|
1996-02-01 02:24:54 +03:00
|
|
|
{
|
1997-01-28 07:20:58 +03:00
|
|
|
struct sfas_softc *dev = arg;
|
1996-02-01 02:24:54 +03:00
|
|
|
ptsc_regmap_p rp;
|
|
|
|
int quickints;
|
|
|
|
|
|
|
|
rp = (ptsc_regmap_p)dev->sc_fas;
|
|
|
|
|
|
|
|
if (*rp->FAS216.sfas_status & SFAS_STAT_INTERRUPT_PENDING) {
|
|
|
|
quickints = 16;
|
|
|
|
do {
|
|
|
|
dev->sc_status = *rp->FAS216.sfas_status;
|
|
|
|
dev->sc_interrupt = *rp->FAS216.sfas_interrupt;
|
|
|
|
|
|
|
|
if (dev->sc_interrupt & SFAS_INT_RESELECTED) {
|
|
|
|
dev->sc_resel[0] = *rp->FAS216.sfas_fifo;
|
|
|
|
dev->sc_resel[1] = *rp->FAS216.sfas_fifo;
|
|
|
|
}
|
|
|
|
|
|
|
|
sfasintr(dev);
|
|
|
|
|
|
|
|
} while((*rp->FAS216.sfas_status & SFAS_STAT_INTERRUPT_PENDING)
|
|
|
|
&& --quickints);
|
|
|
|
}
|
|
|
|
|
1996-06-13 00:46:58 +04:00
|
|
|
return(0); /* Pass interrupt on down the chain */
|
1996-02-01 02:24:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Load transfer address into dma register */
|
|
|
|
void
|
|
|
|
ptsc_set_dma_adr(sc, ptr)
|
|
|
|
struct sfas_softc *sc;
|
|
|
|
void *ptr;
|
|
|
|
{
|
1996-05-06 04:11:16 +04:00
|
|
|
#if 0
|
1996-02-01 02:24:54 +03:00
|
|
|
ptsc_regmap_p rp;
|
|
|
|
unsigned int *p;
|
|
|
|
unsigned int d;
|
1996-05-06 04:11:16 +04:00
|
|
|
#endif
|
1996-02-01 02:24:54 +03:00
|
|
|
#if 0
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("ptsc_set_dma_adr(sc = 0x%08x, ptr = 0x%08x)\n", (u_int)sc, (u_int)ptr);
|
1996-02-01 02:24:54 +03:00
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
#if 0
|
|
|
|
rp = (ptsc_regmap_p)sc->sc_fas;
|
|
|
|
|
|
|
|
d = (unsigned int)ptr;
|
|
|
|
p = (unsigned int *)((d & 0xFFFFFF) + (int)rp->dmabase);
|
|
|
|
|
|
|
|
*rp->clear=0;
|
|
|
|
*p = d;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set DMA transfer counter */
|
|
|
|
void
|
|
|
|
ptsc_set_dma_tc(sc, len)
|
|
|
|
struct sfas_softc *sc;
|
|
|
|
unsigned int len;
|
|
|
|
{
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("ptsc_set_dma_tc(sc, len = 0x%08x)", len);
|
1996-02-01 02:24:54 +03:00
|
|
|
|
|
|
|
*sc->sc_fas->sfas_tc_low = len; len >>= 8;
|
|
|
|
*sc->sc_fas->sfas_tc_mid = len; len >>= 8;
|
|
|
|
*sc->sc_fas->sfas_tc_high = len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set DMA mode */
|
|
|
|
void
|
|
|
|
ptsc_set_dma_mode(sc, mode)
|
|
|
|
struct sfas_softc *sc;
|
|
|
|
int mode;
|
|
|
|
{
|
1996-05-06 04:11:16 +04:00
|
|
|
#if 0
|
1996-02-01 02:24:54 +03:00
|
|
|
struct csc_specific *spec;
|
|
|
|
|
|
|
|
spec = sc->sc_spec;
|
|
|
|
|
|
|
|
spec->portbits = (spec->portbits & ~FLSC_PB_DMA_BITS) | mode;
|
|
|
|
*((flsc_regmap_p)sc->sc_fas)->hardbits = spec->portbits;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize DMA for transfer */
|
|
|
|
int
|
|
|
|
ptsc_setup_dma(sc, ptr, len, mode)
|
|
|
|
struct sfas_softc *sc;
|
|
|
|
void *ptr;
|
|
|
|
int len;
|
|
|
|
int mode;
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
retval = 0;
|
|
|
|
|
|
|
|
#if 0
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("ptsc_setup_dma(sc, ptr = 0x%08x, len = 0x%08x, mode = 0x%08x)\n", (u_int)ptr, len, mode);
|
1996-02-01 02:24:54 +03:00
|
|
|
#endif
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
switch(mode) {
|
|
|
|
case SFAS_DMA_READ:
|
|
|
|
case SFAS_DMA_WRITE:
|
|
|
|
flsc_set_dma_adr(sc, ptr);
|
|
|
|
if (mode == SFAS_DMA_READ)
|
|
|
|
flsc_set_dma_mode(sc,FLSC_PB_ENABLE_DMA | FLSC_PB_DMA_READ);
|
|
|
|
else
|
|
|
|
flsc_set_dma_mode(sc,FLSC_PB_ENABLE_DMA | FLSC_PB_DMA_WRITE);
|
|
|
|
|
|
|
|
flsc_set_dma_tc(sc, len);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SFAS_DMA_CLEAR:
|
|
|
|
default:
|
|
|
|
flsc_set_dma_mode(sc, FLSC_PB_DISABLE_DMA);
|
|
|
|
flsc_set_dma_adr(sc, 0);
|
|
|
|
|
|
|
|
retval = (*sc->sc_fas->sfas_tc_high << 16) |
|
|
|
|
(*sc->sc_fas->sfas_tc_mid << 8) |
|
|
|
|
*sc->sc_fas->sfas_tc_low;
|
|
|
|
|
|
|
|
flsc_set_dma_tc(sc, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(retval);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if address and len is ok for DMA transfer */
|
|
|
|
int
|
|
|
|
ptsc_need_bump(sc, ptr, len)
|
|
|
|
struct sfas_softc *sc;
|
|
|
|
void *ptr;
|
|
|
|
int len;
|
|
|
|
{
|
|
|
|
int p;
|
|
|
|
|
|
|
|
p = (int)ptr & 0x03;
|
|
|
|
|
|
|
|
if (p) {
|
|
|
|
p = 4-p;
|
|
|
|
|
|
|
|
if (len < 256)
|
|
|
|
p = len;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Interrupt driven routines */
|
|
|
|
int
|
|
|
|
ptsc_build_dma_chain(sc, chain, p, l)
|
|
|
|
struct sfas_softc *sc;
|
|
|
|
struct sfas_dma_chain *chain;
|
|
|
|
void *p;
|
|
|
|
int l;
|
|
|
|
{
|
1996-05-06 04:11:16 +04:00
|
|
|
#if 0
|
1996-02-01 02:24:54 +03:00
|
|
|
vm_offset_t pa, lastpa;
|
|
|
|
char *ptr;
|
|
|
|
int len, prelen, postlen, max_t, n;
|
1996-05-06 04:11:16 +04:00
|
|
|
#endif
|
1996-02-01 02:24:54 +03:00
|
|
|
#if 0
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("ptsc_build_dma_chain()\n");
|
1996-02-01 02:24:54 +03:00
|
|
|
#endif
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (l == 0)
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
#define set_link(n, p, l, f)\
|
|
|
|
do { chain[n].ptr = (p); chain[n].len = (l); chain[n++].flg = (f); } while(0)
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
|
|
|
|
if (l < 512)
|
|
|
|
set_link(n, (vm_offset_t)p, l, SFAS_CHAIN_BUMP);
|
1998-05-24 22:19:29 +04:00
|
|
|
else if (p >= (void *)0xFF000000) {
|
1996-02-01 02:24:54 +03:00
|
|
|
while(l != 0) {
|
|
|
|
len = ((l > sc->sc_bump_sz) ? sc->sc_bump_sz : l);
|
|
|
|
|
|
|
|
set_link(n, (vm_offset_t)p, len, SFAS_CHAIN_BUMP);
|
|
|
|
|
|
|
|
p += len;
|
|
|
|
l -= len;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ptr = p;
|
|
|
|
len = l;
|
|
|
|
|
|
|
|
pa = kvtop(ptr);
|
|
|
|
prelen = ((int)ptr & 0x03);
|
|
|
|
|
|
|
|
if (prelen) {
|
|
|
|
prelen = 4-prelen;
|
|
|
|
set_link(n, (vm_offset_t)ptr, prelen, SFAS_CHAIN_BUMP);
|
|
|
|
ptr += prelen;
|
|
|
|
len -= prelen;
|
|
|
|
}
|
|
|
|
|
|
|
|
lastpa = 0;
|
|
|
|
while(len > 3) {
|
|
|
|
pa = kvtop(ptr);
|
|
|
|
max_t = NBPG - (pa & PGOFSET);
|
|
|
|
if (max_t > len)
|
|
|
|
max_t = len;
|
|
|
|
|
|
|
|
max_t &= ~3;
|
|
|
|
|
|
|
|
if (lastpa == pa)
|
|
|
|
sc->sc_chain[n-1].len += max_t;
|
|
|
|
else
|
|
|
|
set_link(n, pa, max_t, SFAS_CHAIN_DMA);
|
|
|
|
|
|
|
|
lastpa = pa+max_t;
|
|
|
|
|
|
|
|
ptr += max_t;
|
|
|
|
len -= max_t;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len)
|
|
|
|
set_link(n, (vm_offset_t)ptr, len, SFAS_CHAIN_BUMP);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(n);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Turn on/off led */
|
|
|
|
void
|
|
|
|
ptsc_led(sc, mode)
|
|
|
|
struct sfas_softc *sc;
|
|
|
|
int mode;
|
|
|
|
{
|
|
|
|
ptsc_regmap_p rp;
|
|
|
|
|
|
|
|
rp = (ptsc_regmap_p)sc->sc_fas;
|
|
|
|
|
|
|
|
if (mode) {
|
|
|
|
sc->sc_led_status++;
|
|
|
|
} else {
|
|
|
|
if (sc->sc_led_status)
|
|
|
|
sc->sc_led_status--;
|
|
|
|
}
|
|
|
|
*rp->led = (sc->sc_led_status?1:0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ptsc_scsicmd(xs)
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_xfer *xs;
|
1996-02-01 02:24:54 +03:00
|
|
|
{
|
|
|
|
/* ensure command is polling for the moment */
|
|
|
|
#if PTSC_POLL > 0
|
|
|
|
xs->flags |= SCSI_POLL;
|
|
|
|
#endif
|
|
|
|
#if 0
|
1996-10-13 07:05:43 +04:00
|
|
|
printf("Opcode %d\n", (int)(xs->cmd->opcode));
|
1996-02-01 02:24:54 +03:00
|
|
|
#endif
|
|
|
|
return(sfas_scsicmd(xs));
|
|
|
|
}
|