1999-03-18 09:37:35 +03:00
|
|
|
|
/* $NetBSD: asic.c,v 1.34 1999/03/18 06:37:35 simonb Exp $ */
|
1995-08-07 11:07:43 +04:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Author: Keith Bostic, Chris G. Demetriou, Jonathan Stone
|
|
|
|
|
*
|
|
|
|
|
* Permission to use, copy, modify and distribute this software and
|
|
|
|
|
* its documentation is hereby granted, provided that both the copyright
|
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
|
|
|
|
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
|
*
|
|
|
|
|
* Carnegie Mellon requests users of this software to return to
|
|
|
|
|
*
|
|
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
|
* School of Computer Science
|
|
|
|
|
* Carnegie Mellon University
|
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
|
*
|
|
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
|
* rights to redistribute these changes.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
#include <sys/device.h>
|
1996-01-30 01:52:15 +03:00
|
|
|
|
#include <dev/tc/tcvar.h>
|
1996-05-29 10:29:02 +04:00
|
|
|
|
#include <dev/tc/ioasicvar.h>
|
1995-08-07 11:07:43 +04:00
|
|
|
|
|
1997-06-16 08:18:57 +04:00
|
|
|
|
#include <machine/bus.h> /* wbflush() */
|
1995-08-07 11:07:43 +04:00
|
|
|
|
#include <machine/autoconf.h>
|
|
|
|
|
|
1998-03-25 09:22:19 +03:00
|
|
|
|
#ifdef alpha
|
1995-08-07 11:07:43 +04:00
|
|
|
|
#include <machine/rpb.h>
|
|
|
|
|
#include <alpha/tc/tc.h>
|
|
|
|
|
#include <alpha/tc/asic.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef pmax
|
|
|
|
|
#include <pmax/pmax/pmaxtype.h>
|
1998-03-25 09:22:19 +03:00
|
|
|
|
#include <pmax/pmax/machdep.h> /* XXX ioasic_init( */
|
1995-08-07 11:07:43 +04:00
|
|
|
|
#include <pmax/pmax/asic.h>
|
|
|
|
|
#include <pmax/pmax/kmin.h>
|
|
|
|
|
#include <pmax/pmax/maxine.h>
|
|
|
|
|
#include <pmax/pmax/kn03.h>
|
|
|
|
|
#include <pmax/pmax/turbochannel.h> /* interrupt enable declaration */
|
|
|
|
|
|
|
|
|
|
#include <pmax/pmax/kmin.h>
|
|
|
|
|
#include <pmax/pmax/nameglue.h>
|
|
|
|
|
|
1998-04-19 14:18:20 +04:00
|
|
|
|
/*
|
|
|
|
|
* Which system models were configured?
|
|
|
|
|
*/
|
|
|
|
|
#include "opt_dec_3max.h"
|
|
|
|
|
#include "opt_dec_3min.h"
|
|
|
|
|
#include "opt_dec_3maxplus.h"
|
|
|
|
|
#include "opt_dec_maxine.h"
|
|
|
|
|
|
1999-03-15 02:59:53 +03:00
|
|
|
|
/* We support only one ioctl asic chip, and this is its address. */
|
|
|
|
|
tc_addr_t ioasic_base = 0;
|
1998-04-19 14:18:20 +04:00
|
|
|
|
|
1999-03-15 02:59:53 +03:00
|
|
|
|
/* tables of child devices on an ioasic bus. */
|
1998-04-19 14:18:20 +04:00
|
|
|
|
#define C(x) ((void*)(x))
|
|
|
|
|
#define ASIC_NDEVS(x) (sizeof(x)/sizeof(x[0]))
|
|
|
|
|
#define ARRAY_SIZEOF(x) (sizeof((x)) / sizeof ((x)[0]))
|
|
|
|
|
|
|
|
|
|
#if defined(DEC_3MAXPLUS) || defined(DEC_3MIN)
|
1999-03-15 02:59:53 +03:00
|
|
|
|
struct ioasic_dev kn03_ioasic_devs[] = {
|
|
|
|
|
{ "lance", 0x0C0000, C(KN03_LANCE_SLOT), IOASIC_INTR_LANCE },
|
|
|
|
|
{ "scc", 0x100000, C(KN03_SCC0_SLOT), IOASIC_INTR_SCC_0 },
|
|
|
|
|
{ "scc", 0x180000, C(KN03_SCC1_SLOT), IOASIC_INTR_SCC_1 },
|
|
|
|
|
{ "mc146818", 0x200000, C(0), 0 },
|
|
|
|
|
{ "asc", 0x300000, C(KN03_SCSI_SLOT), IOASIC_INTR_SCSI },
|
1998-04-19 14:18:20 +04:00
|
|
|
|
};
|
1999-03-15 02:59:53 +03:00
|
|
|
|
const int kn03_ioasic_ndevs = ARRAY_SIZEOF(kn03_ioasic_devs);
|
1998-04-19 14:18:20 +04:00
|
|
|
|
#endif /* DEC_3MAXPLUS || DEC_3MIN */
|
|
|
|
|
|
|
|
|
|
#if defined(DEC_MAXINE)
|
1999-03-15 02:59:53 +03:00
|
|
|
|
struct ioasic_dev xine_ioasic_devs[] = {
|
|
|
|
|
{ "lance", 0x0C0000, C(XINE_LANCE_SLOT), IOASIC_INTR_LANCE },
|
|
|
|
|
{ "scc", 0x100000, C(XINE_SCC0_SLOT), IOASIC_INTR_SCC_0 },
|
|
|
|
|
{ "mc146818", 0x200000, C(0), 0 },
|
|
|
|
|
{ "isdn", 0x240000, C(XINE_ISDN_SLOT), XINE_INTR_ISDN },
|
|
|
|
|
{ "dtop", 0x280000, C(XINE_DTOP_SLOT), XINE_INTR_DTOP },
|
|
|
|
|
{ "fdc", 0x2C0000, C(XINE_FLOPPY_SLOT), 0 },
|
|
|
|
|
{ "asc", 0x300000, C(XINE_SCSI_SLOT), IOASIC_INTR_SCSI },
|
1998-04-19 14:18:20 +04:00
|
|
|
|
};
|
1999-03-15 02:59:53 +03:00
|
|
|
|
const int xine_ioasic_ndevs = ARRAY_SIZEOF(xine_ioasic_devs);
|
1998-04-19 14:18:20 +04:00
|
|
|
|
#endif /* DEC_MAXINE */
|
|
|
|
|
|
|
|
|
|
#if defined(DEC_3MAX)
|
1999-03-15 02:59:53 +03:00
|
|
|
|
struct ioasic_dev kn02_ioasic_devs[] = {
|
|
|
|
|
{ "dc", 0x200000, C(7), 0 },
|
|
|
|
|
{ "mc146818", 0x280000, C(0), 0 },
|
1998-04-19 14:18:20 +04:00
|
|
|
|
};
|
1999-03-15 02:59:53 +03:00
|
|
|
|
const int kn02_ioasic_ndevs = ARRAY_SIZEOF(kn02_ioasic_devs);
|
1998-04-19 14:18:20 +04:00
|
|
|
|
#endif /* DEC_3MAX */
|
|
|
|
|
#endif /* pmax */
|
1995-08-07 11:07:43 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Definition of the driver for autoconfig. */
|
1998-04-19 14:18:20 +04:00
|
|
|
|
int ioasicmatch __P((struct device *, struct cfdata *, void *));
|
|
|
|
|
void ioasicattach __P((struct device *, struct device *, void *));
|
1996-01-31 11:46:42 +03:00
|
|
|
|
|
|
|
|
|
/* Device locators. */
|
1997-07-17 05:17:45 +04:00
|
|
|
|
#include "locators.h"
|
|
|
|
|
#define ioasiccf_offset cf_loc[IOASICCF_OFFSET] /* offset */
|
1996-01-31 11:46:42 +03:00
|
|
|
|
|
1996-03-17 04:38:52 +03:00
|
|
|
|
struct cfattach ioasic_ca = {
|
1999-03-15 04:25:26 +03:00
|
|
|
|
sizeof(struct ioasic_softc), ioasicmatch, ioasicattach
|
1996-03-17 04:38:52 +03:00
|
|
|
|
};
|
|
|
|
|
|
1995-08-07 11:07:43 +04:00
|
|
|
|
#ifdef pmax
|
1999-03-15 02:59:53 +03:00
|
|
|
|
struct ioasic_dev *ioasic_devs;
|
1996-01-30 01:52:15 +03:00
|
|
|
|
#endif /*pmax*/
|
1995-08-29 13:43:37 +04:00
|
|
|
|
|
1995-08-07 11:07:43 +04:00
|
|
|
|
|
|
|
|
|
int
|
1998-04-19 14:18:20 +04:00
|
|
|
|
ioasicmatch(parent, cf, aux)
|
1995-08-07 11:07:43 +04:00
|
|
|
|
struct device *parent;
|
1997-07-21 09:39:02 +04:00
|
|
|
|
struct cfdata *cf;
|
1995-08-07 11:07:43 +04:00
|
|
|
|
void *aux;
|
|
|
|
|
{
|
1996-05-29 10:29:02 +04:00
|
|
|
|
struct tc_attach_args *ta = aux;
|
1995-08-07 11:07:43 +04:00
|
|
|
|
|
1996-01-30 01:52:15 +03:00
|
|
|
|
/* An IOCTL asic can only occur on the turbochannel, anyway. */
|
|
|
|
|
#ifdef notyet
|
|
|
|
|
if (parent != &tccd)
|
1995-08-07 11:07:43 +04:00
|
|
|
|
return (0);
|
1996-01-30 01:52:15 +03:00
|
|
|
|
#endif
|
1995-08-07 11:07:43 +04:00
|
|
|
|
|
1998-03-26 09:35:27 +03:00
|
|
|
|
/*
|
|
|
|
|
* XXX This is wrong.
|
1999-03-12 11:15:27 +03:00
|
|
|
|
* XXX this file will be re-implemented, anyway.
|
1998-03-26 09:35:27 +03:00
|
|
|
|
*/
|
1995-08-07 11:07:43 +04:00
|
|
|
|
/* The 3MAX (kn02) is special. */
|
1999-03-12 11:15:27 +03:00
|
|
|
|
if (TC_BUS_MATCHNAME(ta, "KN02 ")) {
|
1998-03-26 09:35:27 +03:00
|
|
|
|
#if 0
|
1996-10-13 07:39:27 +04:00
|
|
|
|
printf("(configuring KN02 system slot as asic)\n");
|
1998-03-26 09:35:27 +03:00
|
|
|
|
#endif
|
1995-08-07 11:07:43 +04:00
|
|
|
|
goto gotasic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make sure that we're looking for this type of device. */
|
1996-05-29 10:29:02 +04:00
|
|
|
|
if (!TC_BUS_MATCHNAME(ta, "IOCTL "))
|
1995-08-07 11:07:43 +04:00
|
|
|
|
return (0);
|
|
|
|
|
gotasic:
|
|
|
|
|
|
1998-04-19 14:18:20 +04:00
|
|
|
|
if (cf->cf_unit > 0)
|
1995-08-07 11:07:43 +04:00
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
1998-04-19 14:18:20 +04:00
|
|
|
|
ioasicattach(parent, self, aux)
|
1995-08-07 11:07:43 +04:00
|
|
|
|
struct device *parent, *self;
|
|
|
|
|
void *aux;
|
|
|
|
|
{
|
1999-03-15 04:25:26 +03:00
|
|
|
|
struct ioasic_softc *sc = (struct ioasic_softc *)self;
|
1996-05-29 10:29:02 +04:00
|
|
|
|
struct tc_attach_args *ta = aux;
|
1999-03-15 04:25:26 +03:00
|
|
|
|
int ndevs;
|
1998-04-19 14:18:20 +04:00
|
|
|
|
|
|
|
|
|
/* See if the unit number is valid. */
|
|
|
|
|
switch (systype) {
|
1998-05-21 21:41:29 +04:00
|
|
|
|
#if defined(DEC_3MAXPLUS) || defined(DEC_3MIN)
|
1998-04-19 14:18:20 +04:00
|
|
|
|
case DS_3MIN:
|
|
|
|
|
case DS_3MAXPLUS:
|
|
|
|
|
/* 3min ioasic addressees are the same as 3maxplus. */
|
1999-03-15 02:59:53 +03:00
|
|
|
|
ioasic_devs = kn03_ioasic_devs;
|
1999-03-15 04:25:26 +03:00
|
|
|
|
ndevs = kn03_ioasic_ndevs;
|
1998-04-19 14:18:20 +04:00
|
|
|
|
break;
|
1998-05-21 21:41:29 +04:00
|
|
|
|
#endif
|
1998-04-19 14:18:20 +04:00
|
|
|
|
|
|
|
|
|
#ifdef DEC_MAXINE
|
|
|
|
|
case DS_MAXINE:
|
1999-03-15 02:59:53 +03:00
|
|
|
|
ioasic_devs = xine_ioasic_devs;
|
1999-03-15 04:25:26 +03:00
|
|
|
|
ndevs = xine_ioasic_ndevs;
|
1998-04-19 14:18:20 +04:00
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef DEC_3MAX
|
|
|
|
|
case DS_3MAX:
|
1999-03-15 02:59:53 +03:00
|
|
|
|
ioasic_devs = kn02_ioasic_devs;
|
1999-03-15 04:25:26 +03:00
|
|
|
|
ndevs = kn02_ioasic_ndevs;
|
1998-04-19 14:18:20 +04:00
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
default:
|
1998-05-21 21:41:29 +04:00
|
|
|
|
panic("ioasicattach: shouldn't be here, really...");
|
1998-04-19 14:18:20 +04:00
|
|
|
|
}
|
1995-08-07 11:07:43 +04:00
|
|
|
|
|
1996-05-29 10:29:02 +04:00
|
|
|
|
sc->sc_base = ta->ta_addr;
|
1996-01-30 01:52:15 +03:00
|
|
|
|
|
1996-01-31 11:46:42 +03:00
|
|
|
|
ioasic_base = sc->sc_base; /* XXX XXX XXX */
|
1995-08-07 11:07:43 +04:00
|
|
|
|
|
1995-08-10 08:30:41 +04:00
|
|
|
|
#ifdef pmax
|
1996-10-13 07:39:27 +04:00
|
|
|
|
printf("\n");
|
1995-08-10 08:30:41 +04:00
|
|
|
|
#else /* Alpha AXP: select ASIC speed */
|
1995-08-07 11:07:43 +04:00
|
|
|
|
#ifdef DEC_3000_300
|
1998-03-25 06:57:53 +03:00
|
|
|
|
if (systype == ST_DEC_3000_300) {
|
1996-01-31 11:46:42 +03:00
|
|
|
|
*(volatile u_int *)IOASIC_REG_CSR(sc->sc_base) |=
|
|
|
|
|
IOASIC_CSR_FASTMODE;
|
1995-08-07 11:07:43 +04:00
|
|
|
|
MB();
|
1996-10-13 07:39:27 +04:00
|
|
|
|
printf(": slow mode\n");
|
1995-08-07 11:07:43 +04:00
|
|
|
|
} else
|
1995-08-10 08:30:41 +04:00
|
|
|
|
#endif /*DEC_3000_300*/
|
1996-10-13 07:39:27 +04:00
|
|
|
|
printf(": fast mode\n");
|
1995-08-07 11:07:43 +04:00
|
|
|
|
|
|
|
|
|
/* Decstations use hand-craft code to enable asic interrupts */
|
1996-05-29 10:29:02 +04:00
|
|
|
|
BUS_INTR_ESTABLISH(ta, asic_intr, sc);
|
1995-08-07 11:07:43 +04:00
|
|
|
|
|
1995-08-10 08:30:41 +04:00
|
|
|
|
#endif /* Alpha AXP: select ASIC speed */
|
1995-08-07 11:07:43 +04:00
|
|
|
|
|
|
|
|
|
|
1999-03-15 04:25:26 +03:00
|
|
|
|
/*
|
1999-03-15 02:59:53 +03:00
|
|
|
|
* Try to configure each ioctl asic baseboard device.
|
|
|
|
|
*/
|
1999-03-15 04:25:26 +03:00
|
|
|
|
ioasic_attach_devs(sc, ioasic_devs, ndevs);
|
1996-01-31 11:46:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ioasic_intr_establish(dev, cookie, level, handler, val)
|
|
|
|
|
struct device *dev;
|
|
|
|
|
void *cookie;
|
|
|
|
|
tc_intrlevel_t level;
|
|
|
|
|
intr_handler_t handler;
|
|
|
|
|
void *val;
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
(*tc_enable_interrupt)((int)cookie, handler, val, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 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();
|
|
|
|
|
}
|
1998-03-25 09:22:19 +03:00
|
|
|
|
|
|
|
|
|
void ioasic_init(int flag);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Initialize the I/O asic
|
|
|
|
|
*/
|
|
|
|
|
void
|
1998-09-05 09:54:15 +04:00
|
|
|
|
ioasic_init(bogus)
|
|
|
|
|
int bogus; /* XXX */
|
1998-03-25 09:22:19 +03:00
|
|
|
|
{
|
1998-09-05 09:54:15 +04:00
|
|
|
|
/* common across 3min, 3maxplus and maxine */
|
|
|
|
|
*(volatile u_int *)(ioasic_base + IOASIC_LANCE_DECODE) = 0x3;
|
|
|
|
|
*(volatile u_int *)(ioasic_base + IOASIC_SCSI_DECODE) = 0xe;
|
1998-03-25 09:22:19 +03:00
|
|
|
|
|
1998-09-05 09:54:15 +04:00
|
|
|
|
#if 0
|
|
|
|
|
switch (systype) {
|
|
|
|
|
case DS_3MIN:
|
|
|
|
|
case DS_3MAXPLUS:
|
|
|
|
|
*(volatile u_int *)(ioasic_base + IOASIC_SCC0_DECODE) = (0x10|4);
|
|
|
|
|
*(volatile u_int *)(ioasic_base + IOASIC_SCC1_DECODE) = (0x10|6);
|
|
|
|
|
*(volatile u_int *)(ioasic_base + IOASIC_CSR) = 0x00000f00;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DS_MAXINE:
|
|
|
|
|
*(volatile u_int *)(ioasic_base + IOASIC_SCC0_DECODE) = (0x10|4);
|
|
|
|
|
*(volatile u_int *)(ioasic_base + IOASIC_DTOP_DECODE) = 10;
|
|
|
|
|
*(volatile u_int *)(ioasic_base + IOASIC_FLOPPY_DECODE) = 13;
|
|
|
|
|
*(volatile u_int *)(ioasic_base + IOASIC_CSR) = 0x00001fc1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
1998-03-25 09:22:19 +03:00
|
|
|
|
}
|