diff options
Diffstat (limited to 'sys/arch/pmax/tc/asic.c')
-rw-r--r-- | sys/arch/pmax/tc/asic.c | 209 |
1 files changed, 122 insertions, 87 deletions
diff --git a/sys/arch/pmax/tc/asic.c b/sys/arch/pmax/tc/asic.c index 6e453741ec5..35322ff97ab 100644 --- a/sys/arch/pmax/tc/asic.c +++ b/sys/arch/pmax/tc/asic.c @@ -1,4 +1,4 @@ -/* $NetBSD: asic.c,v 1.6 1995/09/25 20:33:28 jonathan Exp $ */ +/* $NetBSD: asic.c,v 1.9.4.2 1996/09/09 20:19:11 thorpej Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -31,6 +31,8 @@ #include <sys/kernel.h> #include <sys/systm.h> #include <sys/device.h> +#include <dev/tc/tcvar.h> +#include <dev/tc/ioasicvar.h> #include <machine/autoconf.h> #include <machine/pte.h> @@ -61,22 +63,31 @@ extern int cputype; struct asic_softc { struct device sc_dv; - struct abus sc_bus; - caddr_t sc_base; + tc_addr_t sc_base; }; /* Definition of the driver for autoconfig. */ int asicmatch __P((struct device *, void *, void *)); void asicattach __P((struct device *, struct device *, void *)); int asicprint(void *, char *); -struct cfdriver ioasiccd = - { NULL, "asic", asicmatch, asicattach, DV_DULL, sizeof(struct asic_softc) }; + +/* Device locators. */ +#define ioasiccf_offset cf_loc[0] /* offset */ + +#define IOASIC_OFFSET_UNKNOWN -1 + +struct cfattach ioasic_ca = { + sizeof(struct asic_softc), asicmatch, asicattach +}; + +struct cfdriver ioasic_cd = { + NULL, "asic", DV_DULL +}; void asic_intr_establish __P((struct confargs *, intr_handler_t, intr_arg_t)); void asic_intr_disestablish __P((struct confargs *)); -caddr_t asic_cvtaddr __P((struct confargs *)); -int asic_matchname __P((struct confargs *, char *)); +caddr_t ioasic_cvtaddr __P((struct confargs *)); #ifndef pmax int asic_intr __P((void *)); @@ -92,30 +103,18 @@ struct asic_slot { }; #ifdef pmax -struct asic_slot *asic_slots; +/*#define IOASIC_DEBUG*/ +struct asic_slot *asic_slots; #include "ds-asic-conf.c" +#endif /*pmax*/ -#endif - -#ifdef alpha -struct asic_slot asic_slots[ASIC_MAX_NSLOTS] = -{ - { { "lance", /* XXX */ 0, 0x000c0000, }, - ASIC_INTR_LANCE, asic_intrnull, (void *)(long)ASIC_SLOT_LANCE, }, - { { "scc", /* XXX */ 1, 0x00100000, }, - ASIC_INTR_SCC_0, asic_intrnull, (void *)(long)ASIC_SLOT_SCC0, }, - { { "scc", /* XXX */ 2, 0x00180000, }, - ASIC_INTR_SCC_1, asic_intrnull, (void *)(long)ASIC_SLOT_SCC1, }, - { { "dallas_rtc", /* XXX */ 3, 0x00200000, }, - 0, asic_intrnull, (void *)(long)ASIC_SLOT_RTC, }, - { { "AMD79c30", /* XXX */ 4, 0x00240000, }, - 0 /* XXX */, asic_intrnull, (void *)(long)ASIC_SLOT_ISDN, }, -}; -#endif /*alpha*/ - -caddr_t asic_base; /* XXX XXX XXX */ +#ifdef IOASIC_DEBUG +#define IOASIC_DPRINTF(x) printf x +#else +#define IOASIC_DPRINTF(x) (void) x +#endif int asicmatch(parent, cfdata, aux) @@ -124,20 +123,25 @@ asicmatch(parent, cfdata, aux) void *aux; { struct cfdata *cf = cfdata; - struct confargs *ca = aux; + struct tc_attach_args *ta = aux; - /* It can only occur on the turbochannel, anyway. */ - if (ca->ca_bus->ab_type != BUS_TC) + IOASIC_DPRINTF(("asicmatch: %s slot %d offset 0x%x pri %d\n", + ta->ta_modname, ta->ta_slot, ta->ta_offset, (int)ta->ta_cookie)); + + /* An IOCTL asic can only occur on the turbochannel, anyway. */ +#ifdef notyet + if (parent != &tccd) return (0); +#endif /* The 3MAX (kn02) is special. */ - if (BUS_MATCHNAME(ca, KN02_ASIC_NAME)) { + if (TC_BUS_MATCHNAME(ta, KN02_ASIC_NAME)) { printf("(configuring KN02 system slot as asic)\n"); goto gotasic; } /* Make sure that we're looking for this type of device. */ - if (!BUS_MATCHNAME(ca, "IOCTL ")) + if (!TC_BUS_MATCHNAME(ta, "IOCTL ")) return (0); gotasic: @@ -177,31 +181,28 @@ asicattach(parent, self, aux) void *aux; { struct asic_softc *sc = (struct asic_softc *)self; - struct confargs *ca = aux; + struct tc_attach_args *ta = aux; struct confargs *nca; + struct ioasicdev_attach_args ioasicdev; int i; extern int cputype; if (asic_slots == NULL) panic("asicattach: no asic_slot map\n"); - sc->sc_base = BUS_CVTADDR(ca); - asic_base = sc->sc_base; /* XXX XXX XXX */ + IOASIC_DPRINTF(("asicattach: %s\n", sc->sc_dv.dv_xname)); + + sc->sc_base = ta->ta_addr; - sc->sc_bus.ab_dv = (struct device *)sc; - sc->sc_bus.ab_type = BUS_ASIC; - sc->sc_bus.ab_intr_establish = asic_intr_establish; - sc->sc_bus.ab_intr_disestablish = asic_intr_disestablish; - sc->sc_bus.ab_cvtaddr = asic_cvtaddr; - sc->sc_bus.ab_matchname = asic_matchname; + ioasic_base = sc->sc_base; /* XXX XXX XXX */ #ifdef pmax printf("\n"); #else /* Alpha AXP: select ASIC speed */ #ifdef DEC_3000_300 if (cputype == ST_DEC_3000_300) { - *(volatile u_int *)ASIC_REG_CSR(sc->sc_base) |= - ASIC_CSR_FASTMODE; + *(volatile u_int *)IOASIC_REG_CSR(sc->sc_base) |= + IOASIC_CSR_FASTMODE; MB(); printf(": slow mode\n"); } else @@ -209,7 +210,7 @@ asicattach(parent, self, aux) printf(": fast mode\n"); /* Decstations use hand-craft code to enable asic interrupts */ - BUS_INTR_ESTABLISH(ca, asic_intr, sc); + BUS_INTR_ESTABLISH(ta, asic_intr, sc); #endif /* Alpha AXP: select ASIC speed */ @@ -220,25 +221,28 @@ asicattach(parent, self, aux) /* Try to configure each CPU-internal device */ for (i = 0; i < ASIC_MAX_NSLOTS; i++) { -#ifdef DEBUG_ASIC - printf("asicattach: entry %d\n", i); /*XXX*/ -#endif + IOASIC_DPRINTF(("asicattach: entry %d, base addr %x\n", + i, sc->sc_base)); nca = &asic_slots[i].as_ca; if (nca == NULL) panic ("bad asic table\n"); - if (nca->ca_name == NULL && nca->ca_bus == NULL) + if (nca->ca_name == NULL || nca->ca_name[0] == 0) break; - nca->ca_bus = &sc->sc_bus; + nca->ca_addr = ((u_int)sc->sc_base) + nca->ca_offset; -#ifdef DEBUG_ASIC - printf(" adding %s subslot %d offset %x\n", /*XXX*/ - nca->ca_name, nca->ca_slot, nca->ca_offset); -#endif + IOASIC_DPRINTF((" adding %s subslot %d offset %x addr %x\n", + nca->ca_name, nca->ca_slot, nca->ca_offset, + nca->ca_addr)); + strncpy(ioasicdev.iada_modname, nca->ca_name, TC_ROM_LLEN); + ioasicdev.iada_modname[TC_ROM_LLEN] = '\0'; + ioasicdev.iada_offset = nca->ca_offset; + ioasicdev.iada_addr = nca->ca_addr; + ioasicdev.iada_cookie = (void *)nca->ca_slotpri; /* Tell the autoconfig machinery we've found the hardware. */ - config_found(self, nca, asicprint); + config_found(self, &ioasicdev, asicprint); } - + IOASIC_DPRINTF(("asicattach: done\n")); } int @@ -246,18 +250,28 @@ asicprint(aux, pnp) void *aux; char *pnp; { - struct confargs *ca = aux; + struct ioasicdev_attach_args *d = aux; if (pnp) - printf("%s at %s", ca->ca_name, pnp); - printf(" offset 0x%lx", ca->ca_offset); - printf(" priority %d", ca->ca_slotpri); + printf("%s at %s", d->iada_modname, pnp); + printf(" offset 0x%x", d->iada_offset); + printf(" priority %d", (int)d->iada_cookie); return (UNCONF); } +int +ioasic_submatch(match, d) + struct cfdata *match; + struct ioasicdev_attach_args *d; +{ + + return ((match->ioasiccf_offset == d->iada_offset) || + (match->ioasiccf_offset == IOASIC_OFFSET_UNKNOWN)); +} + /* * Save interrupt slotname and enable mask (??) - * On decstaitons this isn't useful, as the turbochannel + * On decstations this isn't useful, as the turbochannel * decstations all have incompatible ways of mapping interrupts * to IO ASIC or r3000 interrupt bits. * Instead of writing "as_bits" directly into an IOASIC interrupt-enable @@ -273,12 +287,10 @@ asic_intr_establish(ca, handler, val) intr_arg_t val; { -#ifdef DIAGNOSTIC -#ifdef alpha /*XXX*/ - if (ca->ca_slot == ASIC_SLOT_RTC) +#if defined(DIAGNOSTIC) && defined(alpha) + if (ca->ca_slot == IOASIC_SLOT_RTC) panic("setting clock interrupt incorrectly"); -#endif /*alpha*/ -#endif /*DIAGNOSTIC*/ +#endif /*defined(DIAGNOSTIC) && defined(alpha)*/ /* XXX SHOULD NOT BE THIS LITERAL */ if (asic_slots[ca->ca_slot].as_handler != asic_intrnull) @@ -288,14 +300,15 @@ asic_intr_establish(ca, handler, val) * XXX We need to invent a better interface to machine-dependent * interrupt-enable code, or redo the Decstation configuration * tables with unused entries, so that slot is always equal - * to "priority" (software pseudo-slot number). + * to "priority" (software pseudo-slot number). FIXME. */ +#if defined(IOASIC_DEBUG) && 0 + printf("asic: %s: intr for entry %d slot %d pri %d\n", + ca->ca_name, ca->ca_slot, ca->ca_slotpri, + (int)asic_slots[ca->ca_slot].as_val); +#endif /*IOASIC_DEBUG*/ + #ifdef pmax -#ifdef DEBUG_ASIC - printf("asic:%s%d: intr for entry %d(%d) slot %d\n", - ca->ca_name, val, ca->ca_slot, ca->ca_slotpri, - asic_slots[ca->ca_slot].as_val); -#endif /*DEBUG*/ tc_enable_interrupt(ca->ca_slotpri, handler, val, 1); #else /* Alpha AXP */ @@ -314,7 +327,7 @@ asic_intr_disestablish(ca) #ifdef pmax panic("asic_intr_disestablish: shouldn't ever be called\n"); #else - if (ca->ca_slot == ASIC_SLOT_RTC) + if (ca->ca_slot == IOASIC_SLOT_RTC) panic("asic_intr_disestablish: can't do clock interrupt"); /* XXX SHOULD NOT BE THIS LITERAL */ @@ -327,25 +340,20 @@ asic_intr_disestablish(ca) #endif } -caddr_t -asic_cvtaddr(ca) - struct confargs *ca; -{ - return - (((struct asic_softc *)ca->ca_bus->ab_dv)->sc_base + ca->ca_offset); -} - -int -asic_matchname(ca, name) - struct confargs *ca; - char *name; +void +ioasic_intr_establish(dev, cookie, level, handler, val) + struct device *dev; + void *cookie; + tc_intrlevel_t level; + intr_handler_t handler; + void *val; { - return (strcmp(name, ca->ca_name) == 0); + (*tc_enable_interrupt)((int)cookie, handler, val, 1); } -#ifndef pmax +#ifdef alpha /* * asic_intr -- * ASIC interrupt handler. @@ -360,7 +368,7 @@ asic_intr(val) u_int32_t sir, junk; volatile u_int32_t *sirp, *junkp; - sirp = (volatile u_int32_t *)ASIC_REG_INTR(sc->sc_base); + sirp = (volatile u_int32_t *)IOASIC_REG_INTR(sc->sc_base); gifound = 0; do { @@ -390,3 +398,30 @@ asic_intrnull(val) panic("uncaught IOCTL ASIC intr for slot %ld\n", (long)val); } + + +/* XXX */ +char * +ioasic_lance_ether_address() +{ + + return (u_char *)IOASIC_SYS_ETHER_ADDRESS(ioasic_base); +} + +void +ioasic_lance_dma_setup(v) + void *v; +{ + volatile u_int32_t *ldp; + tc_addr_t tca; + + tca = (tc_addr_t)v; + + ldp = (volatile u_int *)IOASIC_REG_LANCE_DMAPTR(ioasic_base); + *ldp = ((tca << 3) & ~(tc_addr_t)0x1f) | ((tca >> 29) & 0x1f); + tc_wmb(); + + *(volatile u_int32_t *)IOASIC_REG_CSR(ioasic_base) |= + IOASIC_CSR_DMAEN_LANCE; + tc_mb(); +} |