Add support for the Alpha Processor, Inc. UP1000 EV6 system.

This commit is contained in:
thorpej 2000-06-01 20:30:28 +00:00
parent 7eb6966af4
commit 9851571246
13 changed files with 1414 additions and 5 deletions

View File

@ -0,0 +1,293 @@
/* $NetBSD: api_up1000.c,v 1.1 2000/06/01 20:30:28 thorpej Exp $ */
/*
* Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* 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.
*/
/*
* Additional Copyright (c) 1997 by Matthew Jacob for NASA/Ames Research Center
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: api_up1000.c,v 1.1 2000/06/01 20:30:28 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/termios.h>
#include <dev/cons.h>
#include <machine/alpha.h>
#include <machine/rpb.h>
#include <machine/autoconf.h>
#include <machine/conf.h>
#include <machine/bus.h>
#include <dev/ic/comreg.h>
#include <dev/ic/comvar.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
#include <dev/ic/pckbcvar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <alpha/pci/irongatereg.h>
#include <alpha/pci/irongatevar.h>
#include <dev/scsipi/scsi_all.h>
#include <dev/scsipi/scsipi_all.h>
#include <dev/scsipi/scsiconf.h>
#include <dev/ata/atavar.h>
#include "pckbd.h"
#ifndef CONSPEED
#define CONSPEED TTYDEF_SPEED
#endif
static int comcnrate = CONSPEED;
#define DPRINTF(x) if (bootdev_debug) printf x
void api_up1000_init __P((void));
static void api_up1000_cons_init __P((void));
static void api_up1000_device_register __P((struct device *, void *));
void
api_up1000_init()
{
platform.family = "Alpha Processor, Inc. UP1000";
if ((platform.model = alpha_dsr_sysname()) == NULL) {
/* XXX Don't know the system variations, yet. */
platform.model = alpha_unknown_sysname();
}
platform.iobus = "irongate";
platform.cons_init = api_up1000_cons_init;
platform.device_register = api_up1000_device_register;
}
static void
api_up1000_cons_init()
{
struct ctb *ctb;
struct irongate_config *icp;
extern struct irongate_config irongate_configuration;
icp = &irongate_configuration;
irongate_init(icp, 0);
ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off);
switch (ctb->ctb_term_type) {
case 2:
/* serial console ... */
/* XXX */
{
/*
* Delay to allow PROM putchars to complete.
* FIFO depth * character time,
* character time = (1000000 / (defaultrate / 10))
*/
DELAY(160000000 / comcnrate);
if(comcnattach(&icp->ic_iot, 0x3f8, comcnrate,
COM_FREQ,
(TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8))
panic("can't init serial console");
break;
}
case 3:
#if NPCKBD > 0
/* display console ... */
/* XXX */
(void) pckbc_cnattach(&icp->ic_iot, IO_KBD, PCKBC_KBD_SLOT);
if (CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot) ==
CTB_TURBOSLOT_TYPE_ISA)
isa_display_console(&icp->ic_iot, &icp->ic_memt);
else
pci_display_console(&icp->ic_iot, &icp->ic_memt,
&icp->ic_pc, CTB_TURBOSLOT_BUS(ctb->ctb_turboslot),
CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot), 0);
#else
panic("not configured to use display && keyboard console");
#endif
break;
default:
printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);
panic("consinit: unknown console type %ld\n",
ctb->ctb_term_type);
}
}
static void
api_up1000_device_register(dev, aux)
struct device *dev;
void *aux;
{
static int found, initted, scsiboot, ideboot, netboot;
static struct device *pcidev, *scsipidev;
struct bootdev_data *b = bootdev_data;
struct device *parent = dev->dv_parent;
struct cfdata *cf = dev->dv_cfdata;
struct cfdriver *cd = cf->cf_driver;
if (found)
return;
if (!initted) {
scsiboot = (strcmp(b->protocol, "SCSI") == 0);
netboot = (strcmp(b->protocol, "BOOTP") == 0) ||
(strcmp(b->protocol, "MOP") == 0);
/*
* Add an extra check to boot from ide drives:
* Newer SRM firmware use the protocol identifier IDE,
* older SRM firmware use the protocol identifier SCSI.
*/
ideboot = (strcmp(b->protocol, "IDE") == 0);
DPRINTF(("\nscsiboot = %d, ideboot = %d, netboot = %d\n",
scsiboot, ideboot, netboot));
initted = 1;
}
if (pcidev == NULL) {
if (strcmp(cd->cd_name, "pci"))
return;
else {
struct pcibus_attach_args *pba = aux;
if ((b->slot / 1000) != pba->pba_bus)
return;
pcidev = dev;
DPRINTF(("\npcidev = %s\n", pcidev->dv_xname));
return;
}
}
if ((ideboot || scsiboot) && (scsipidev == NULL)) {
if (parent != pcidev)
return;
else {
struct pci_attach_args *pa = aux;
if (b->slot % 1000 / 100 != pa->pa_function)
return;
if (b->slot % 100 != pa->pa_device)
return;
scsipidev = dev;
DPRINTF(("\nscsipidev = %s\n", scsipidev->dv_xname));
return;
}
}
if (scsiboot &&
(!strcmp(cd->cd_name, "sd") ||
!strcmp(cd->cd_name, "st") ||
!strcmp(cd->cd_name, "cd"))) {
struct scsipibus_attach_args *sa = aux;
if (parent->dv_parent != scsipidev)
return;
if (b->unit / 100 != sa->sa_sc_link->scsipi_scsi.target)
return;
/* XXX LUN! */
switch (b->boot_dev_type) {
case 0:
if (strcmp(cd->cd_name, "sd") &&
strcmp(cd->cd_name, "cd"))
return;
break;
case 1:
if (strcmp(cd->cd_name, "st"))
return;
break;
default:
return;
}
/* we've found it! */
booted_device = dev;
DPRINTF(("\nbooted_device = %s\n", booted_device->dv_xname));
found = 1;
}
/*
* Support to boot from IDE drives.
*/
if ((ideboot || scsiboot) && !strcmp(cd->cd_name, "wd")) {
struct ata_atapi_attach *aa_link = aux;
if ((strncmp("pciide", parent->dv_xname, 6) != 0)) {
return;
} else {
if (parent != scsipidev)
return;
}
DPRINTF(("\natapi info: drive %d, channel %d\n",
aa_link->aa_drv_data->drive, aa_link->aa_channel));
DPRINTF(("bootdev info: unit: %d, channel: %d\n",
b->unit, b->channel));
if (b->unit != aa_link->aa_drv_data->drive ||
b->channel != aa_link->aa_channel)
return;
/* we've found it! */
booted_device = dev;
DPRINTF(("booted_device = %s\n", booted_device->dv_xname));
found = 1;
}
if (netboot) {
if (parent != pcidev)
return;
else {
struct pci_attach_args *pa = aux;
if ((b->slot % 1000) != pa->pa_device)
return;
/* XXX function? */
booted_device = dev;
DPRINTF(("\nbooted_device = %s\n",
booted_device->dv_xname));
found = 1;
return;
}
}
}

View File

@ -1,4 +1,4 @@
# $NetBSD: ALPHA,v 1.125 2000/05/28 23:06:39 thorpej Exp $
# $NetBSD: ALPHA,v 1.126 2000/06/01 20:30:29 thorpej Exp $
#
# Alpha kernel with all the options you'd want, and more.
@ -6,7 +6,7 @@ include "arch/alpha/conf/std.alpha"
maxusers 32
ident "ALPHA-$Revision: 1.125 $"
ident "ALPHA-$Revision: 1.126 $"
# CPU Support
#options DEC_2000_300 # "Jensen": 2000/300 (DECpc AXP 150)
@ -25,6 +25,7 @@ options DEC_1000A # Corelle etc: Digital AlphaServer 800/1000A
options DEC_ALPHABOOK1 # AlphaBook1: Tadpole/DEC AlphaBook
options DEC_EB66 # EB66: 21066 Evaluation Board
options DEC_6600 # EV6: 264DP OEM Board
options API_UP1000 # EV6: Alpha Processor, Inc. UP1000
# Standard system options
options KTRACE # System call tracing support
@ -197,6 +198,7 @@ fta* at tc? slot ? offset ? # DEC DEFTA FDDI cards
# PCI host bus adapter support
apecs* at mainbus?
cia* at mainbus?
irongate* at mainbus?
lca* at mainbus?
dwlpx* at kft?
mcpcia* at mcbus? mid ?
@ -205,6 +207,7 @@ tsp* at tsc?
# PCI bus support
pci* at apecs?
pci* at cia?
pci* at irongate?
pci* at lca?
pci* at ppb?
pci* at dwlpx?

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.155 2000/05/29 23:34:08 matt Exp $
# $NetBSD: GENERIC,v 1.156 2000/06/01 20:30:30 thorpej Exp $
#
# Generic Alpha kernel. Enough to get booted, etc., but not much more.
#
@ -6,7 +6,7 @@
include "arch/alpha/conf/std.alpha"
#ident "GENERIC-$Revision: 1.155 $"
#ident "GENERIC-$Revision: 1.156 $"
maxusers 32
@ -27,6 +27,7 @@ options DEC_1000A # Corelle etc: Digital AlphaServer 800/1000A
options DEC_ALPHABOOK1 # AlphaBook1: Tadpole/DEC AlphaBook
options DEC_EB66 # EB66: 21066 Evaluation Board
options DEC_6600 # EV6: 264DP OEM Board
options API_UP1000 # EV6: Alpha Processor, Inc. UP1000
# Standard system options
options KTRACE # System call tracing support
@ -169,6 +170,7 @@ fta* at tc? slot ? offset ? # DEC DEFTA FDDI cards
# PCI host bus adapter support
apecs* at mainbus?
cia* at mainbus?
irongate* at mainbus?
lca* at mainbus?
dwlpx* at kft?
mcpcia* at mcbus? mid ?
@ -177,6 +179,7 @@ tsp* at tsc?
# PCI bus support
pci* at apecs?
pci* at cia?
pci* at irongate?
pci* at lca?
pci* at ppb?
pci* at dwlpx?

View File

@ -1,4 +1,4 @@
# $NetBSD: INSTALL,v 1.38 2000/05/23 02:04:30 thorpej Exp $
# $NetBSD: INSTALL,v 1.39 2000/06/01 20:30:30 thorpej Exp $
#
# Alpha INSTALL kernel.
@ -31,6 +31,7 @@ options DEC_1000A # Corelle etc: Digital AlphaServer 800/1000A
options DEC_ALPHABOOK1 # AlphaBook1: Tadpole/DEC AlphaBook
options DEC_EB66 # EB66: 21066 Evaluation Board
options DEC_6600 # EV6: 264DP OEM Board
options API_UP1000 # EV6: Alpha Processor, Inc. UP1000
# File systems
file-system FFS # Fast file system
@ -113,6 +114,7 @@ fta* at tc? slot ? offset ? # DEC DEFTA FDDI cards
# PCI host bus adapter support
apecs* at mainbus?
cia* at mainbus?
irongate* at mainbus?
lca* at mainbus?
dwlpx* at kft?
mcpcia* at mcbus? mid ?
@ -121,6 +123,7 @@ tsp* at tsc?
# PCI bus support
pci* at apecs?
pci* at cia?
pci* at irongate?
pci* at lca?
pci* at ppb?
pci* at dwlpx?

View File

@ -0,0 +1,216 @@
/* $NetBSD: irongate.c,v 1.1 2000/06/01 20:30:30 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#include "opt_api_up1000.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irongate.c,v 1.1 2000/06/01 20:30:30 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <machine/autoconf.h>
#include <machine/rpb.h>
#include <machine/sysarch.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <alpha/pci/irongatereg.h>
#include <alpha/pci/irongatevar.h>
#ifdef API_UP1000
#include <alpha/pci/pci_up1000.h>
#endif
int irongate_match(struct device *, struct cfdata *, void *);
void irongate_attach(struct device *, struct device *, void *);
struct cfattach irongate_ca = {
sizeof(struct irongate_softc), irongate_match, irongate_attach,
};
int irongate_print(void *, const char *pnp);
extern struct cfdriver irongate_cd;
/* There can be only one. */
struct irongate_config irongate_configuration;
int irongate_found;
int irongate_bus_get_window(int, int,
struct alpha_bus_space_translation *);
/*
* Set up the chipset's function pointers.
*/
void
irongate_init(struct irongate_config *icp, int mallocsafe)
{
pcitag_t tag;
pcireg_t reg;
icp->ic_mallocsafe = mallocsafe;
/*
* Set up PCI configuration space; we can only read the
* revision info through configuration space.
*/
irongate_pci_init(&icp->ic_pc, icp);
alpha_pci_chipset = &icp->ic_pc;
tag = pci_make_tag(&icp->ic_pc, 0, IRONGATE_PCIHOST_DEV, 0);
/* Read the revision. */
reg = irongate_conf_read0(icp, tag, PCI_CLASS_REG);
icp->ic_rev = PCI_REVISION(reg);
if (icp->ic_initted == 0) {
/* Don't do these twice, since they set up extents. */
irongate_bus_io_init(&icp->ic_iot, icp);
irongate_bus_mem_init(&icp->ic_memt, icp);
/* Only one each PCI I/O and MEM window. */
alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_IO] = 1;
alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_MEM] = 1;
alpha_bus_get_window = irongate_bus_get_window;
}
icp->ic_initted = 1;
}
int
irongate_match(struct device *parent, struct cfdata *match, void *aux)
{
struct mainbus_attach_args *ma = aux;
/* Make sure we're looking for an Irongate. */
if (strcmp(ma->ma_name, irongate_cd.cd_name) != 0)
return (0);
if (irongate_found)
return (0);
return (1);
}
void
irongate_attach(struct device *parent, struct device *self, void *aux)
{
struct irongate_softc *sc = (void *) self;
struct irongate_config *icp;
struct pcibus_attach_args pba;
/* Note that we've attached the chipset; can't have 2 Irongates. */
irongate_found = 1;
/*
* Set up the chipset's info; done once at console init time
* (maybe), but we must do it here as well to take care of things
* that need to use memory allocation.
*/
icp = sc->sc_icp = &irongate_configuration;
irongate_init(icp, 1);
printf(": AMD 751 Core Logic + AGP Chipset, rev. %d\n", icp->ic_rev);
irongate_dma_init(icp);
switch (cputype) {
#ifdef API_UP1000
case ST_API_NAUTILUS:
pci_up1000_pickintr(icp);
break;
#endif
default:
panic("irongate_attach: shouldn't be here, really...");
}
pba.pba_busname = "pci";
pba.pba_iot = &icp->ic_iot;
pba.pba_memt = &icp->ic_memt;
pba.pba_dmat =
alphabus_dma_get_tag(&icp->ic_dmat_pci, ALPHA_BUS_PCI);
pba.pba_pc = &icp->ic_pc;
pba.pba_bus = 0;
pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED |
PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
(void) config_found(self, &pba, irongate_print);
}
int
irongate_print(void *aux, const char *pnp)
{
struct pcibus_attach_args *pba = aux;
/* Only PCIs can attach to Irongates; easy. */
if (pnp != NULL)
printf("%s at %s", pba->pba_busname, pnp);
printf(" bus %d", pba->pba_bus);
return (UNCONF);
}
int
irongate_bus_get_window(int type, int window,
struct alpha_bus_space_translation *abst)
{
struct irongate_config *icp = &irongate_configuration;
bus_space_tag_t st;
switch (type) {
case ALPHA_BUS_TYPE_PCI_IO:
st = &icp->ic_iot;
break;
case ALPHA_BUS_TYPE_PCI_MEM:
st = &icp->ic_memt;
break;
default:
panic("irongate_bus_get_window");
}
return (alpha_bus_space_get_window(st, window, abst));
}

View File

@ -0,0 +1,68 @@
/* $NetBSD: irongate_bus_io.c,v 1.1 2000/06/01 20:30:30 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(1, "$NetBSD: irongate_bus_io.c,v 1.1 2000/06/01 20:30:30 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/syslog.h>
#include <sys/device.h>
#include <vm/vm.h>
#include <machine/bus.h>
#include <alpha/pci/irongatereg.h>
#include <alpha/pci/irongatevar.h>
#define CHIP irongate
#define CHIP_EX_MALLOC_SAFE(v) (((struct irongate_config *)(v))->ic_mallocsafe)
#define CHIP_IO_EXTENT(v) (((struct irongate_config *)(v))->ic_io_ex)
#define CHIP_IO_SYS_START(v) IRONGATE_IO_BASE
/*
* AMD 751 core logic appears on EV6. We require at least EV56
* support for the assembler to emit BWX opcodes.
*/
__asm(".arch ev6");
#include <alpha/pci/pci_bwx_bus_io_chipdep.c>

View File

@ -0,0 +1,68 @@
/* $NetBSD: irongate_bus_mem.c,v 1.1 2000/06/01 20:30:30 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(1, "$NetBSD: irongate_bus_mem.c,v 1.1 2000/06/01 20:30:30 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/syslog.h>
#include <sys/device.h>
#include <vm/vm.h>
#include <machine/bus.h>
#include <alpha/pci/irongatereg.h>
#include <alpha/pci/irongatevar.h>
#define CHIP irongate
#define CHIP_EX_MALLOC_SAFE(v) (((struct irongate_config *)(v))->ic_mallocsafe)
#define CHIP_MEM_EXTENT(v) (((struct irongate_config *)(v))->ic_mem_ex)
#define CHIP_MEM_SYS_START(v) IRONGATE_MEM_BASE
/*
* AMD 751 core logic appears on EV6. We require at least EV56
* support for the assembler to emit BWX opcodes.
*/
__asm(".arch ev6");
#include <alpha/pci/pci_bwx_bus_mem_chipdep.c>

View File

@ -0,0 +1,177 @@
/* $NetBSD: irongate_dma.c,v 1.1 2000/06/01 20:30:30 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*
* DMA support for the AMD 751 (``Irongate'') core logic chipset.
*
* The AMD 751 is really unlike all of the other Alpha PCI core logic
* chipsets. Instead, it looks like a normal PC chipset (not surprising,
* since it is used for Athlon processors).
*
* Because of this, it lacks all of the SGMAP hardware normally present
* on an Alpha system, and there are no DMA windows. Instead, a memory
* bus address is a PCI DMA address, and ISA DMA above 16M has to be
* bounced (this is not unlike the Jensen, actually).
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: irongate_dma.c,v 1.1 2000/06/01 20:30:30 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <vm/vm.h>
#define _ALPHA_BUS_DMA_PRIVATE
#include <machine/bus.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <alpha/pci/irongatereg.h>
#include <alpha/pci/irongatevar.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
bus_dma_tag_t irongate_dma_get_tag(bus_dma_tag_t, alpha_bus_t);
int irongate_bus_dmamap_create_pci_direct(bus_dma_tag_t, bus_size_t, int,
bus_size_t, bus_size_t, int, bus_dmamap_t *);
int irongate_bus_dmamap_create_isa_direct(bus_dma_tag_t, bus_size_t, int,
bus_size_t, bus_size_t, int, bus_dmamap_t *);
int irongate_bus_dmamap_create_isa_bounce(bus_dma_tag_t, bus_size_t, int,
bus_size_t, bus_size_t, int, bus_dmamap_t *);
void
irongate_dma_init(struct irongate_config *icp)
{
bus_dma_tag_t t;
/*
* Initialize the DMA tag used for PCI DMA.
*/
t = &icp->ic_dmat_pci;
t->_cookie = icp;
t->_wbase = 0;
t->_wsize = 0x100000000UL;
t->_next_window = NULL;
t->_boundary = 0;
t->_sgmap = NULL;
t->_get_tag = irongate_dma_get_tag;
t->_dmamap_create = _bus_dmamap_create;
t->_dmamap_destroy = _bus_dmamap_destroy;
t->_dmamap_load = _bus_dmamap_load_direct;
t->_dmamap_load_mbuf = _bus_dmamap_load_mbuf_direct;
t->_dmamap_load_uio = _bus_dmamap_load_uio_direct;
t->_dmamap_load_raw = _bus_dmamap_load_raw_direct;
t->_dmamap_unload = _bus_dmamap_unload;
t->_dmamap_sync = _bus_dmamap_sync;
t->_dmamem_alloc = _bus_dmamem_alloc;
t->_dmamem_free = _bus_dmamem_free;
t->_dmamem_map = _bus_dmamem_map;
t->_dmamem_unmap = _bus_dmamem_unmap;
t->_dmamem_mmap = _bus_dmamem_mmap;
/*
* Initialize the DMA tag used for ISA DMA.
*/
t = &icp->ic_dmat_isa;
t->_cookie = icp;
t->_wbase = 0;
t->_wsize = 0x1000000;
t->_next_window = NULL;
t->_boundary = 0;
t->_sgmap = NULL;
t->_get_tag = irongate_dma_get_tag;
t->_dmamap_create = isadma_bounce_dmamap_create;
t->_dmamap_destroy = isadma_bounce_dmamap_destroy;
t->_dmamap_load = isadma_bounce_dmamap_load;
t->_dmamap_load_mbuf = isadma_bounce_dmamap_load_mbuf;
t->_dmamap_load_uio = isadma_bounce_dmamap_load_uio;
t->_dmamap_load_raw = isadma_bounce_dmamap_load_raw;
t->_dmamap_unload = isadma_bounce_dmamap_unload;
t->_dmamap_sync = isadma_bounce_dmamap_sync;
t->_dmamem_alloc = isadma_bounce_dmamem_alloc;
t->_dmamem_free = _bus_dmamem_free;
t->_dmamem_map = _bus_dmamem_map;
t->_dmamem_unmap = _bus_dmamem_unmap;
t->_dmamem_mmap = _bus_dmamem_mmap;
/* XXX XXX BEGIN XXX XXX */
{ /* XXX */
extern paddr_t alpha_XXX_dmamap_or; /* XXX */
alpha_XXX_dmamap_or = 0; /* XXX */
} /* XXX */
/* XXX XXX END XXX XXX */
}
/*
* Return the bus dma tag to be used for the specified bus type.
* INTERNAL USE ONLY!
*/
bus_dma_tag_t
irongate_dma_get_tag(bus_dma_tag_t t, alpha_bus_t bustype)
{
struct irongate_config *icp = t->_cookie;
switch (bustype) {
case ALPHA_BUS_PCI:
case ALPHA_BUS_EISA:
/*
* Busses capable of 32-bit DMA get the PCI DMA tag.
*/
return (&icp->ic_dmat_pci);
case ALPHA_BUS_ISA:
/*
* Lame 24-bit busses have to bounce.
*/
return (&icp->ic_dmat_isa);
default:
panic("irongate_dma_get_tag: shouldn't be here, really...");
}
}

View File

@ -0,0 +1,171 @@
/* $NetBSD: irongate_pci.c,v 1.1 2000/06/01 20:30:30 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*
* PCI Configuration Space support for the AMD 751 (``Irongate'') core logic
* chipset.
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: irongate_pci.c,v 1.1 2000/06/01 20:30:30 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <vm/vm.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <alpha/pci/irongatereg.h>
#include <alpha/pci/irongatevar.h>
void irongate_attach_hook __P((struct device *, struct device *,
struct pcibus_attach_args *));
int irongate_bus_maxdevs __P((void *, int));
pcitag_t irongate_make_tag __P((void *, int, int, int));
void irongate_decompose_tag __P((void *, pcitag_t, int *, int *,
int *));
pcireg_t irongate_conf_read __P((void *, pcitag_t, int));
void irongate_conf_write __P((void *, pcitag_t, int, pcireg_t));
/* AMD 751 systems are always single-processor, so this is easy. */
#define PCI_CONF_LOCK(s) (s) = splhigh()
#define PCI_CONF_UNLOCK(s) splx((s))
#define PCI_CONF_ADDR (IRONGATE_IO_BASE|IRONGATE_CONFADDR)
#define PCI_CONF_DATA (IRONGATE_IO_BASE|IRONGATE_CONFDATA)
#define REGVAL(r) (*(__volatile u_int32_t *)ALPHA_PHYS_TO_K0SEG(r))
void
irongate_pci_init(pci_chipset_tag_t pc, void *v)
{
pc->pc_conf_v = v;
pc->pc_attach_hook = irongate_attach_hook;
pc->pc_bus_maxdevs = irongate_bus_maxdevs;
pc->pc_make_tag = irongate_make_tag;
pc->pc_decompose_tag = irongate_decompose_tag;
pc->pc_conf_read = irongate_conf_read;
pc->pc_conf_write = irongate_conf_write;
}
void
irongate_attach_hook(struct device *parent, struct device *self,
struct pcibus_attach_args *pba)
{
}
int
irongate_bus_maxdevs(void *ipv, int busno)
{
return 32;
}
pcitag_t
irongate_make_tag(void *ipv, int b, int d, int f)
{
return (b << 16) | (d << 11) | (f << 8);
}
void
irongate_decompose_tag(void *ipv, pcitag_t tag, int *bp, int *dp, int *fp)
{
if (bp != NULL)
*bp = (tag >> 16) & 0xff;
if (dp != NULL)
*dp = (tag >> 11) & 0x1f;
if (fp != NULL)
*fp = (tag >> 8) & 0x7;
}
pcireg_t
irongate_conf_read(void *ipv, pcitag_t tag, int offset)
{
int d;
/*
* The AMD 751 appears in PCI configuration space, but
* that is ... counter-intuitive to the way we normally
* attach PCI-Host bridges on the Alpha. So, filter out
* the AMD 751 device here. We provide a private entry
* point for getting at it from machdep code.
*/
irongate_decompose_tag(ipv, tag, NULL, &d, NULL);
if (d == IRONGATE_PCIHOST_DEV)
return ((pcireg_t) -1);
return (irongate_conf_read0(ipv, tag, offset));
}
pcireg_t
irongate_conf_read0(void *ipv, pcitag_t tag, int offset)
{
pcireg_t data;
int s;
PCI_CONF_LOCK(s);
REGVAL(PCI_CONF_ADDR) = (CONFADDR_ENABLE | tag | (offset & 0xff));
alpha_mb();
data = REGVAL(PCI_CONF_DATA);
REGVAL(PCI_CONF_ADDR) = 0;
alpha_mb();
PCI_CONF_UNLOCK(s);
return (data);
}
void
irongate_conf_write(void *ipv, pcitag_t tag, int offset, pcireg_t data)
{
int s;
PCI_CONF_LOCK(s);
REGVAL(PCI_CONF_ADDR) = (CONFADDR_ENABLE | tag | (offset & 0xff));
alpha_mb();
REGVAL(PCI_CONF_DATA) = data;
alpha_mb();
REGVAL(PCI_CONF_ADDR) = 0;
alpha_mb();
PCI_CONF_UNLOCK(s);
}

View File

@ -0,0 +1,89 @@
/* $NetBSD: irongatereg.h,v 1.1 2000/06/01 20:30:31 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*
* Register definitions for the AMD 751 (``Irongate'') core logic
* chipset.
*/
/*
* Address map.
*
* This from the Tsunami address map:
* EV6 has a new superpage which can pass through 44 address bits. (Umm, a
* superduperpage?) But, the firmware doesn't turn it on, so we use the old
* one and let the HW sign extend va/pa<40> to get us the pa<43> that makes
* the needed I/O space access. This is just as well; it means we don't have
* to worry about which GENERIC code might get called on other CPU models.
*
* E.g., we want this: 0x0801##fc00##0000
* We use this: 0x0101##fc00##0000
* ...mix in the old SP: 0xffff##fc00##0000##0000
* ...after PA sign ext: 0xffff##ff01##fc00##0000
* (PA<42:41> ignored)
*
* PCI memory and RAM: 0000.0000.0000
* IACK 0001.f800.0000
* PCI I/O: 0001.fc00.0000
* AMD 751 (also in PCI config space): 0001.fe00.0000
*/
#define IRONGATE_KSEG_BIAS 0x0100##0000##0000UL
#define IRONGATE_MEM_BASE (IRONGATE_KSEG_BIAS | 0x0000##0000##0000UL)
#define IRONGATE_IACK_BASE (IRONGATE_KSEG_BIAS | 0x0001##f800##0000UL)
#define IRONGATE_IO_BASE (IRONGATE_KSEG_BIAS | 0x0001##fc00##0000UL)
#define IRONGATE_SELF_BASE (IRONGATE_KSEG_BIAS | 0x0001##fe00##0000UL)
/*
* PCI configuration register access using done by using
* ``configuration mode 1'' (in PC lingo), using the I/O
* space addresses described in the PCI Local Bus Specification
* Revision 2.2.
*/
#define IRONGATE_CONFADDR 0x0cf8
#define IRONGATE_CONFDATA 0x0cfc
#define CONFADDR_ENABLE 0x80000000U
/*
* The AMD 751 PCI-Host bridge is located at device 0, and the
* AGP controller (seen as a PCI-PCI bridge) is at device 1.
*/
#define IRONGATE_PCIHOST_DEV 0
#define IRONGATE_PCIAGP_DEV 1

View File

@ -0,0 +1,77 @@
/* $NetBSD: irongatevar.h,v 1.1 2000/06/01 20:30:31 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#include <dev/isa/isavar.h>
#include <dev/pci/pcivar.h>
#include <alpha/pci/pci_sgmap_pte64.h>
/*
* AMD 751 chipset's configuration.
*
* All of the information that the chipset-specific functions need to
* do their dirty work (and more!).
*/
struct irongate_config {
int ic_initted;
struct alpha_bus_space ic_iot, ic_memt;
struct alpha_pci_chipset ic_pc;
struct alpha_bus_dma_tag ic_dmat_pci;
struct alpha_bus_dma_tag ic_dmat_isa;
u_int32_t ic_rev;
struct extent *ic_io_ex, *ic_mem_ex;
int ic_mallocsafe;
};
struct irongate_softc {
struct device sc_dev;
struct irongate_config *sc_icp;
};
void irongate_init(struct irongate_config *, int);
void irongate_pci_init(pci_chipset_tag_t, void *);
void irongate_dma_init(struct irongate_config *);
void irongate_bus_io_init(bus_space_tag_t, void *);
void irongate_bus_mem_init(bus_space_tag_t, void *);
pcireg_t irongate_conf_read0(void *, pcitag_t, int);

View File

@ -0,0 +1,202 @@
/* $NetBSD: pci_up1000.c,v 1.1 2000/06/01 20:30:31 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: pci_up1000.c,v 1.1 2000/06/01 20:30:31 thorpej Exp $");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/device.h>
#include <vm/vm.h>
#include <machine/autoconf.h>
#include <machine/bus.h>
#include <machine/intr.h>
#include <machine/intrcnt.h>
#include <dev/isa/isavar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pciidereg.h>
#include <dev/pci/pciidevar.h>
#include <alpha/pci/irongatevar.h>
#include <alpha/pci/pci_up1000.h>
#include <alpha/pci/siovar.h>
#include <alpha/pci/sioreg.h>
#include "sio.h"
int api_up1000_intr_map(void *, pcitag_t, int, int, pci_intr_handle_t *);
const char *api_up1000_intr_string(void *, pci_intr_handle_t);
void *api_up1000_intr_establish(void *, pci_intr_handle_t,
int, int (*func)(void *), void *);
void api_up1000_intr_disestablish(void *, void *);
void *api_up1000_pciide_compat_intr_establish(void *, struct device *,
struct pci_attach_args *, int, int (*)(void *), void *);
void
pci_up1000_pickintr(struct irongate_config *icp)
{
bus_space_tag_t iot = &icp->ic_iot;
pci_chipset_tag_t pc = &icp->ic_pc;
pc->pc_intr_v = icp;
pc->pc_intr_map = api_up1000_intr_map;
pc->pc_intr_string = api_up1000_intr_string;
pc->pc_intr_establish = api_up1000_intr_establish;
pc->pc_intr_disestablish = api_up1000_intr_disestablish;
pc->pc_pciide_compat_intr_establish =
api_up1000_pciide_compat_intr_establish;
#if NSIO
sio_intr_setup(pc, iot);
set_iointr(&sio_iointr);
#else
panic("pci_up1000_pickintr: no I/O interrupt handler (no sio)");
#endif
}
int
api_up1000_intr_map(void *icv, pcitag_t bustag, int buspin, int line,
pci_intr_handle_t *ihp)
{
struct irongate_config *icp = icv;
pci_chipset_tag_t pc = &icp->ic_pc;
int bus, device, function;
if (buspin == 0) {
/* No IRQ used. */
return 1;
}
if (buspin > 4) {
printf("api_up1000_intr_map: bad interrupt pin %d\n",
buspin);
return 1;
}
alpha_pci_decompose_tag(pc, bustag, &bus, &device, &function);
/*
* The console places the interrupt mapping in the "line" value.
* A value of (char)-1 indicates there is no mapping.
*/
if (line == 0xff) {
printf("api_up1000_intr_map: no mapping for %d/%d/%d\n",
bus, device, function);
return (1);
}
/* XXX Check for 0? */
if (line > 15) {
printf("api_up1000_intr_map: ISA IRQ too large (%d)\n",
line);
return (1);
}
if (line == 2) {
printf("api_up1000_intr_map: changed IRQ 2 to IRQ 9\n");
line = 9;
}
*ihp = line;
return (0);
}
const char *
api_up1000_intr_string(void *icv, pci_intr_handle_t ih)
{
#if 0
struct irongate_config *icp = icv;
#endif
return sio_intr_string(NULL /*XXX*/, ih);
}
void *
api_up1000_intr_establish(void *icv, pci_intr_handle_t ih, int level,
int (*func)(void *), void *arg)
{
#if 0
struct irongate_config *icp = icv;
#endif
return sio_intr_establish(NULL /*XXX*/, ih, IST_LEVEL, level, func,
arg);
}
void
api_up1000_intr_disestablish(void *icv, void *cookie)
{
#if 0
struct irongate_config *icp = icv;
#endif
sio_intr_disestablish(NULL /*XXX*/, cookie);
}
void *
api_up1000_pciide_compat_intr_establish(void *icv, struct device *dev,
struct pci_attach_args *pa, int chan, int (*func)(void *), void *arg)
{
pci_chipset_tag_t pc = pa->pa_pc;
void *cookie = NULL;
int bus, irq;
alpha_pci_decompose_tag(pc, pa->pa_tag, &bus, NULL, NULL);
/*
* If this isn't PCI bus #0, all bets are off.
*/
if (bus != 0)
return (NULL);
irq = PCIIDE_COMPAT_IRQ(chan);
#if NSIO
cookie = sio_intr_establish(NULL /*XXX*/, irq, IST_EDGE, IPL_BIO,
func, arg);
#endif
return (cookie);
}

View File

@ -0,0 +1,39 @@
/* $NetBSD: pci_up1000.h,v 1.1 2000/06/01 20:30:31 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
void pci_up1000_pickintr __P((struct irongate_config *));