/*
* Copyright (c) 1999, 2000 Matthew R. Green
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* Copyright (c) 2001, 2002 Eduardo E. Horvath
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/* Interrupt handlers */
static int psycho_ue(void *);
static int psycho_ce(void *);
static int psycho_bus_a(void *);
static int psycho_bus_b(void *);
static int psycho_powerfail(void *);
static int psycho_wakeup(void *);
/* IOMMU support */
static void psycho_iommu_init(struct psycho_softc *, int);
/*
* bus space and bus DMA support for UltraSPARC `psycho'. note that most
* of the bus DMA support is provided by the iommu dvma controller.
*/
static struct psycho_ranges *get_psychorange(struct psycho_pbm *, int);
/*
* "sabre" is the UltraSPARC IIi onboard UPA to PCI bridge. It manages a
* single PCI bus and does not have a streaming buffer. It often has an APB
* (advanced PCI bridge) connected to it, which was designed specifically for
* the IIi. The APB lets the IIi handle two independent PCI buses, and
* appears as two "simba"'s underneath the sabre.
*
* "psycho" and "psycho+" is a dual UPA to PCI bridge. It sits on the UPA bus
* and manages two PCI buses. "psycho" has two 64-bit 33 MHz buses, while
* "psycho+" controls both a 64-bit 33 MHz and a 64-bit 66 MHz PCI bus. You
* will usually find a "psycho+" since I don't think the original "psycho"
* ever shipped, and if it did it would be in the U30.
*
* Each "psycho" PCI bus appears as a separate OFW node, but since they are
* both part of the same IC, they only have a single register space. As such,
* they need to be configured together, even though the autoconfiguration will
* attach them separately.
*
* On UltraIIi machines, "sabre" itself usually takes pci0, with "simba" often
* as pci1 and pci2, although they have been implemented with other PCI bus
* numbers on some machines.
*
* On UltraII machines, there can be any number of "psycho+" ICs, each
* providing two PCI buses.
*
*
* XXXX The psycho/sabre node has an `interrupts' attribute. They contain
* the values of the following interrupts in this order:
*
* PCI Bus Error (30)
* DMA UE (2e)
* DMA CE (2f)
* Power Fail (25)
*
* We really should attach handlers for each.
*
*/
static int
psycho_match(device_t parent, cfdata_t match, void *aux)
{
struct mainbus_attach_args *ma = aux;
char *model;
int i;
if (ma->ma_node == 0)
return 0; /* no OF node, can't be us */
model = prom_getpropstring(ma->ma_node, "model");
/* match on a name of "pci" and a sabre or a psycho */
if (strcmp(ma->ma_name, ROM_PCI_NAME) == 0) {
for (i=0; psycho_names[i].p_name; i++)
if (strcmp(model, psycho_names[i].p_name) == 0)
return (1);
model = prom_getpropstring(ma->ma_node, "compatible");
for (i=0; psycho_names[i].p_name; i++)
if (strcmp(model, psycho_names[i].p_name) == 0)
return (1);
}
return (0);
}
/* We need to map this in ourselves. */
if (bus_space_map(sc->sc_bustag,
ma->ma_reg[2].ur_paddr,
ma->ma_reg[2].ur_len, BUS_SPACE_MAP_LINEAR,
&sc->sc_bh))
panic("psycho_attach: cannot map regs");
sc->sc_regs = (struct psychoreg *)
bus_space_vaddr(sc->sc_bustag, sc->sc_bh);
if (bus_space_map(sc->sc_bustag,
ma->ma_reg[0].ur_paddr,
ma->ma_reg[0].ur_len, BUS_SPACE_MAP_LINEAR,
&pci_ctl))
panic("psycho_attach: cannot map ctl");
} else
panic("psycho_attach: %d not enough registers",
ma->ma_nreg);
/* We need to map this in ourselves. */
if (bus_space_map(sc->sc_bustag,
ma->ma_reg[0].ur_paddr,
ma->ma_reg[0].ur_len, BUS_SPACE_MAP_LINEAR,
&sc->sc_bh))
panic("psycho_attach: cannot map regs");
sc->sc_regs = (struct psychoreg *)
bus_space_vaddr(sc->sc_bustag, sc->sc_bh);
aprint_normal_dev(self, "%s: impl %d, version %d: ign %x ",
model, PSYCHO_GCSR_IMPL(csr), PSYCHO_GCSR_VERS(csr),
sc->sc_ign);
/*
* Match other psycho's that are already configured against
* the base physical address. This will be the same for a
* pair of devices that share register space.
*/
for (n = 0; n < psycho_cd.cd_ndevs; n++) {
/* Fix up invalid 0x00-0xff bus-range, as found on SPARCle */
if (psycho_br[0] == 0 && psycho_br[1] == 0xff)
psycho_fixup_bus_range(sc->sc_node, psycho_br);
aprint_normal("bus range %u to %u", psycho_br[0], psycho_br[1]);
aprint_normal("; PCI bus %d", psycho_br[0]);
/* allocate a chipset for this */
pp->pp_pc = psycho_alloc_chipset(pp, sc->sc_node, &_sparc_pci_chipset);
pp->pp_pc->spc_busmax = psycho_br[1];
switch((ma->ma_reg[0].ur_paddr) & 0xf000) {
case 0x2000:
pp->pp_id = PSYCHO_PBM_A;
break;
case 0x4000:
pp->pp_id = PSYCHO_PBM_B;
break;
}
aprint_normal("\n");
/* allocate extents for free bus space */
pp->pp_exmem = psycho_alloc_extent(pp, sc->sc_node, 0x02, "psycho mem");
pp->pp_exio = psycho_alloc_extent(pp, sc->sc_node, 0x01, "psycho io");
#ifdef DEBUG
if (psycho_debug & PDB_INTR)
psycho_dump_intmap(sc);
#endif
/*
* And finally, if we're a sabre or the first of a pair of psycho's to
* arrive here, start up the IOMMU and get a config space tag.
*/
if (osc == NULL) {
uint64_t timeo;
/*
* Establish handlers for interesting interrupts....
*
* XXX We need to remember these and remove this to support
* hotplug on the UPA/FHC bus.
*
* XXX Not all controllers have these, but installing them
* is better than trying to sort through this mess.
*/
psycho_set_intr(sc, 15, psycho_ue,
&sc->sc_regs->ue_int_map,
&sc->sc_regs->ue_clr_int);
psycho_set_intr(sc, 1, psycho_ce,
&sc->sc_regs->ce_int_map,
&sc->sc_regs->ce_clr_int);
psycho_set_intr(sc, 15, psycho_bus_a,
&sc->sc_regs->pciaerr_int_map,
&sc->sc_regs->pciaerr_clr_int);
/*
* Netra X1 may hang when the powerfail interrupt is enabled.
*/
if (strcmp(machine_model, "SUNW,UltraAX-i2") != 0) {
psycho_set_intr(sc, 15, psycho_powerfail,
&sc->sc_regs->power_int_map,
&sc->sc_regs->power_clr_int);
psycho_register_power_button(sc);
}
if (sc->sc_mode != PSYCHO_MODE_SABRE) {
/* sabre doesn't have these interrupts */
psycho_set_intr(sc, 15, psycho_bus_b,
&sc->sc_regs->pciberr_int_map,
&sc->sc_regs->pciberr_clr_int);
psycho_set_intr(sc, 1, psycho_wakeup,
&sc->sc_regs->pwrmgt_int_map,
&sc->sc_regs->pwrmgt_clr_int);
}
/*
* Apparently a number of machines with psycho and psycho+
* controllers have interrupt latency issues. We'll try
* setting the interrupt retry timeout to 0xff which gives us
* a retry of 3-6 usec (which is what sysio is set to) for the
* moment, which seems to help alleviate this problem.
*/
timeo = sc->sc_regs->intr_retry_timer;
if (timeo > 0xfff) {
#ifdef DEBUG
printf("decreasing interrupt retry timeout "
"from %lx to 0xff\n", (long)timeo);
#endif
sc->sc_regs->intr_retry_timer = 0xff;
}
/*
* Allocate bus node, this contains a prom node per bus.
*/
pp->pp_pc->spc_busnode =
kmem_zalloc(sizeof(*pp->pp_pc->spc_busnode), KM_SLEEP);
/*
* Setup IOMMU and PCI configuration if we're the first
* of a pair of psycho's to arrive here.
*
* We should calculate a TSB size based on amount of RAM
* and number of bus controllers and number and type of
* child devices.
*
* For the moment, 32KB should be more than enough.
*/
sc->sc_is = kmem_alloc(sizeof(struct iommu_state), KM_SLEEP);
/* Point the strbuf_ctl at the iommu_state */
pp->pp_sb.sb_is = sc->sc_is;
sc->sc_is->is_sb[0] = sc->sc_is->is_sb[1] = NULL;
if (prom_getproplen(sc->sc_node, "no-streaming-cache") < 0) {
struct strbuf_ctl *sb = &pp->pp_sb;
vaddr_t va = (vaddr_t)&pp->pp_flush[0x40];
/*
* Initialize the strbuf_ctl.
*
* The flush sync buffer must be 64-byte aligned.
*/
sb->sb_flush = (void *)(va & ~0x3f);
/*
* XXX This is a really ugly hack because PCI config space
* is explicitly handled with unmapped accesses.
*/
i = sc->sc_bustag->type;
sc->sc_bustag->type = PCI_CONFIG_BUS_SPACE;
if (bus_space_map(sc->sc_bustag, sc->sc_basepaddr + 0x01000000,
0x01000000, 0, &bh))
panic("could not map psycho PCI configuration space");
sc->sc_bustag->type = i;
sc->sc_configaddr = bh;
} else {
/* Share bus numbers with the pair of mine */
pp->pp_pc->spc_busnode =
osc->sc_psycho_this->pp_pc->spc_busnode;
/* Just copy IOMMU state, config tag and address */
sc->sc_is = osc->sc_is;
sc->sc_configtag = osc->sc_configtag;
sc->sc_configaddr = osc->sc_configaddr;
/* Point the strbuf_ctl at the iommu_state */
pp->pp_sb.sb_is = sc->sc_is;
if (prom_getproplen(sc->sc_node, "no-streaming-cache") < 0) {
struct strbuf_ctl *sb = &pp->pp_sb;
vaddr_t va = (vaddr_t)&pp->pp_flush[0x40];
/*
* Initialize the strbuf_ctl.
*
* The flush sync buffer must be 64-byte aligned.
*/
sb->sb_flush = (void *)(va & ~0x3f);
/*
* allocate a PCI chipset tag and set its cookie.
*/
static pci_chipset_tag_t
psycho_alloc_chipset(struct psycho_pbm *pp, int node, pci_chipset_tag_t pc)
{
pci_chipset_tag_t npc;
/*
* create extent for free bus space, then allocate assigned regions.
*/
static struct extent *
psycho_alloc_extent(struct psycho_pbm *pp, int node, int ss, const char *name)
{
struct psycho_registers *pa = NULL;
struct psycho_ranges *pr;
struct extent *ex;
bus_addr_t baddr, addr;
bus_size_t bsize, size;
int i, num;
/* get bus space size */
pr = get_psychorange(pp, ss);
if (pr == NULL) {
printf("psycho_alloc_extent: get_psychorange failed\n");
return NULL;
}
baddr = 0x00000000;
bsize = BUS_ADDR(pr->size_hi, pr->size_lo);
/* get available lists */
num = 0;
if (prom_getprop(node, "available", sizeof(*pa), &num, &pa)) {
printf("psycho_alloc_extent: no \"available\" property\n");
return NULL;
}
/* create extent */
ex = extent_create(name, baddr, bsize - baddr - 1, 0, 0, EX_NOWAIT);
if (ex == NULL) {
printf("psycho_alloc_extent: extent_create failed\n");
goto ret;
}
/* allocate assigned regions */
for (i = 0; i < num; i++)
if (((pa[i].phys_hi >> 24) & 0x03) == ss) {
/* allocate bus space */
addr = BUS_ADDR(pa[i].phys_mid, pa[i].phys_lo);
size = BUS_ADDR(pa[i].size_hi, pa[i].size_lo);
if (extent_alloc_region(ex, baddr, addr - baddr,
EX_NOWAIT)) {
printf("psycho_alloc_extent: "
"extent_alloc_region %" PRIx64 "-%"
PRIx64 " failed\n", baddr, addr);
extent_destroy(ex);
ex = NULL;
goto ret;
}
baddr = addr + size;
}
/* allocate left region if available */
if (baddr < bsize)
if (extent_alloc_region(ex, baddr, bsize - baddr, EX_NOWAIT)) {
printf("psycho_alloc_extent: extent_alloc_region %"
PRIx64 "-%" PRIx64 " failed\n", baddr, bsize);
extent_destroy(ex);
ex = NULL;
goto ret;
}
/*
* grovel the OBP for various psycho properties
*/
static void
psycho_get_bus_range(int node, int *brp)
{
int n, error;
n = 2;
error = prom_getprop(node, "bus-range", sizeof(*brp), &n, &brp);
if (error)
panic("could not get psycho bus-range, error %d", error);
if (n != 2)
panic("broken psycho bus-range");
DPRINTF(PDB_PROM, ("%s: got `bus-range' for node %08x: %u - %u\n",
__func__, node, brp[0], brp[1]));
}
static void
psycho_fixup_bus_range(int node0, int *brp0)
{
int node;
int len, busrange[2], *brp;
DPRINTF(PDB_PROM,
("%s: fixing up `bus-range' for node %08x: %u - %u\n",
__func__, node0, brp0[0], brp0[1]));
/*
* Check all nodes under this one and increase the bus range to
* match. Recurse through PCI-PCI bridges. Cardbus bridges are
* fixed up in pccbb_attach_hook(). Assumes that "bus-range" for
* PCI-PCI bridges apart from this one is correct.
*/
brp0[1] = brp0[0];
node = prom_firstchild(node0);
for (node = ((node)); node; node = prom_nextsibling(node)) {
len = 2;
brp = busrange;
if (prom_getprop(node, "bus-range", sizeof(*brp),
&len, &brp) != 0)
break;
if (len != 2)
break;
psycho_fixup_bus_range(node, busrange);
if (brp0[0] > busrange[0] && busrange[0] >= 0)
brp0[0] = busrange[0];
if (brp0[1] < busrange[1] && busrange[1] < 256)
brp0[1] = busrange[1];
}
DPRINTF(PDB_PROM,
("%s: fixed up `bus-range' for node %08x: %u - %u\n",
__func__, node0, brp[0], brp[1]));
}
static void
psycho_get_ranges(int node, struct psycho_ranges **rp, int *np)
{
if (prom_getprop(node, "ranges", sizeof(**rp), np, rp))
panic("could not get psycho ranges");
DPRINTF(PDB_PROM, ("%s: got `ranges' for node %08x: %d entries\n",
__func__, node, *np));
}
/*
* We lost power. Queue a callback with thread context to
* handle all the real work.
*/
if (sc->sc_powerpressed == 0 && sc->sc_smcontext != NULL) {
sc->sc_powerpressed = 1;
sysmon_task_queue_sched(0, psycho_power_button_pressed, sc);
}
return (1);
}
/*
* Separate the men from the boys. Get the `virtual-dma'
* property for sabre and use that to make sure the damn
* iommu works.
*
* We could query the `#virtual-dma-size-cells' and
* `#virtual-dma-addr-cells' and DTRT, but I'm lazy.
*/
nitem = 0;
if (!prom_getprop(sc->sc_node, "virtual-dma", sizeof(vdma), &nitem,
&vdma)) {
/* Damn. Gotta use these values. */
iobase = vdma[0];
#define TSBCASE(x) case 1<<((x)+23): tsbsize = (x); break
switch (vdma[1]) {
TSBCASE(1);
TSBCASE(2);
TSBCASE(3);
TSBCASE(4);
TSBCASE(5);
TSBCASE(6);
TSBCASE(7);
default:
printf("bogus tsb size %x, using 7\n", vdma[1]);
tsbsize = 7;
}
#undef TSBCASE
}
/* give us a nice name.. */
name = kmem_asprintf("%s dvma", device_xname(sc->sc_dev));
iommu_init(name, is, tsbsize, iobase);
}
/*
* below here is bus space and bus DMA support
*/
bus_space_tag_t
psycho_alloc_bus_tag(struct psycho_pbm *pp, int type)
{
struct psycho_softc *sc = pp->pp_sc;
bus_space_tag_t bt;
/*
* install an interrupt handler for a PCI device
*/
void *
psycho_intr_establish(bus_space_tag_t t, int ihandle, int level,
int (*handler)(void *), void *arg, void (*fastvec)(void) /* ignored */)
{
struct psycho_pbm *pp = t->cookie;
struct psycho_softc *sc = pp->pp_sc;
struct intrhand *ih;
volatile uint64_t *intrmapptr = NULL, *intrclrptr = NULL;
int64_t imap = 0;
int ino;
long vec = INTVEC(ihandle);
ih = intrhand_alloc();
ih->ih_ivec = ihandle;
/*
* Hunt through all the interrupt mapping regs to look for our
* interrupt vector.
*
* XXX We only compare INOs rather than IGNs since the firmware may
* not provide the IGN and the IGN is constant for all device on that
* PCI controller. This could cause problems for the FFB/external
* interrupt which has a full vector that can be set arbitrarily.
*/
/* If the device didn't ask for an IPL, use the one encoded. */
if (level == IPL_NONE) level = INTLEV(vec);
/* If it still has no level, print a warning and assign IPL 2 */
if (level == IPL_NONE) {
printf("ERROR: no IPL, setting IPL 2.\n");
level = 2;
}
DPRINTF(PDB_INTR, ("%s: intr %lx: %p\nHunting for IRQ...\n",
__func__, (long)ino, intrlev[ino]));
/*
* First look for PCI interrupts, otherwise the PCI A slot 0
* INTA# interrupt might match an unused non-PCI (obio)
* interrupt.
*/
for (intrmapptr = &sc->sc_regs->pcia_slot0_int,
intrclrptr = &sc->sc_regs->pcia0_clr_int[0];
intrmapptr <= &sc->sc_regs->pcib_slot3_int;
intrmapptr++, intrclrptr += 4) {
if (sc->sc_mode == PSYCHO_MODE_PSYCHO &&
(intrmapptr == &sc->sc_regs->pcia_slot2_int ||
intrmapptr == &sc->sc_regs->pcia_slot3_int))
continue;
if (((*intrmapptr ^ vec) & 0x3c) == 0) {
intrclrptr += vec & 0x3;
goto found;
}
}
/* Now hunt thru obio. */
for (intrmapptr = &sc->sc_regs->scsi_int_map,
intrclrptr = &sc->sc_regs->scsi_clr_int;
intrmapptr < &sc->sc_regs->ue_int_map;
intrmapptr++, intrclrptr++) {
if (INTINO(*intrmapptr) == ino)
goto found;
}
/* Finally check the two FFB slots */
intrclrptr = NULL; /* XXX? */
for (intrmapptr = &sc->sc_regs->ffb0_int_map;
intrmapptr <= &sc->sc_regs->ffb1_int_map;
intrmapptr++) {
if (INTVEC(*intrmapptr) == ino)
goto found;
}
/*
* Enable the interrupt now we have the handler installed.
* Read the current value as we can't change it besides the
* valid bit so so make sure only this bit is changed.
*
* XXXX --- we really should use bus_space for this.
*/
if (intrmapptr) {
imap = *intrmapptr;
DPRINTF(PDB_INTR, ("%s: read intrmap = %016qx",
__func__, (unsigned long long)imap));
/* Enable the interrupt */
imap |= INTMAP_V|(CPU_UPAID << INTMAP_TID_SHIFT);
DPRINTF(PDB_INTR, ("; addr of intrmapptr = %p", intrmapptr));
DPRINTF(PDB_INTR, ("; writing intrmap = %016qx\n",
(unsigned long long)imap));
*intrmapptr = imap;
DPRINTF(PDB_INTR, ("; reread intrmap = %016qx\n",
(unsigned long long)(imap = *intrmapptr)));
}
if (intrclrptr) {
/* set state to IDLE */
*intrclrptr = 0;
}
return (ih);
}
/*
* per-controller driver calls
*/
/* assume we are mapped little-endian/side-effect */
static pcireg_t
psycho_pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg)
{
struct psycho_pbm *pp = pc->cookie;
struct psycho_softc *sc = pp->pp_sc;
pcireg_t val = (pcireg_t)~0;
int s;
DPRINTF(PDB_CONF, ("%s: tag %lx reg %x ", __func__,
(long)tag, reg));
if (PCITAG_NODE(tag) != -1 && (unsigned int)reg < PCI_CONF_SIZE) {
bus = (pp->pp_id == PSYCHO_PBM_B);
/*
* If we are on a ppb, use the devno on the underlying bus when forming
* the ivec.
*/
if (pa->pa_intrswiz != 0 && PCITAG_NODE(pa->pa_intrtag) != 0)
dev = PCITAG_DEV(pa->pa_intrtag);
else
dev = pa->pa_device;
dev--;
if (sc->sc_mode == PSYCHO_MODE_PSYCHO &&
pp->pp_id == PSYCHO_PBM_B)
dev--;
/*
* UltraSPARC IIi and IIe have no streaming buffers, but have PCI DMA
* Write Synchronization Register (see UltraSPARC-IIi User's Manual
* section 19.3.0.5). So use it to synchronize with the DMA writes.
*/
static void
psycho_sabre_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset,
bus_size_t len, int ops)
{
struct psycho_pbm *pp;
struct psycho_softc *sc;
/* If len is 0, then there is nothing to do. */
if (len == 0)
return;
/*
* there is no way we'll ever overflow
* the counter is 63 bits wide, at 12MHz that's >24000 years
*/
now = psycho_getstick() + 1000;
cmp = psycho0->sc_last_stick;