add a driver for "PCI 'universal' communications" cards, that is, PCI cards

which contain 'standard' com- and lpt-type ports.  Some of these present
as PCI simple-communications/serial or simple-communications/parallel
devices, but many do not.  (Additionally, there is no document that I can
find that describes the "specific well-konwn register-level" description
of how the 'standard' devices' config space headers shold work.)  Eventually,
some of the devices driven by this code should become simple pci attachments
for the 'lpt' and 'com' drivers, but that requires solid documentation.
This commit is contained in:
cgd 1998-06-26 18:52:41 +00:00
parent d2ed6f63d6
commit d77d6869b1
6 changed files with 766 additions and 1 deletions

127
sys/dev/pci/com_puc.c Normal file
View File

@ -0,0 +1,127 @@
/* $NetBSD: com_puc.c,v 1.1 1998/06/26 18:52:41 cgd Exp $ */
/*
* Copyright (c) 1998 Christopher G. Demetriou. 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 Christopher G. Demetriou
* for the NetBSD Project.
* 4. 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.
*/
/*
* Machine-independent ns16x50 serial port ('com') driver attachment to
* "PCI Universal Communications" controller driver.
*
* Author: Christopher G. Demetriou, May 17, 1998.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/tty.h>
#include <machine/bus.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pucvar.h>
#include <dev/ic/comreg.h>
#include <dev/ic/comvar.h>
struct com_puc_softc {
struct com_softc sc_com; /* real "com" softc */
/* puc-specific goo. */
void *sc_ih; /* interrupt handler */
};
int com_puc_probe __P((struct device *, struct cfdata *, void *));
void com_puc_attach __P((struct device *, struct device *, void *));
struct cfattach com_puc_ca = {
sizeof(struct com_puc_softc), com_puc_probe, com_puc_attach
};
int
com_puc_probe(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
struct puc_attach_args *aa = aux;
/*
* Locators already matched, just check the type.
*/
if (aa->type != PUC_PORT_TYPE_COM)
return (0);
return (1);
}
void
com_puc_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct com_puc_softc *psc = (void *)self;
struct com_softc *sc = &psc->sc_com;
struct puc_attach_args *aa = aux;
const char *intrstr;
/*
* XXX This driver assumes that 'com' ports attached to 'puc'
* XXX can not be console. That isn't unreasonable, because PCI
* XXX devices are supposed to be dynamically mapped, and com
* XXX console ports want fixed addresses. When/if baseboard
* XXX 'com' ports are identified as PCI/communications/serial
* XXX devices and are known to be mapped at the standard
* XXX addresses, if they can be the system console then we have
* XXX to cope with doing the mapping right. Then this will get
* XXX really ugly. Of course, by then we might know the real
* XXX definition of PCI/communications/serial, and attach 'com'
* XXX directly on PCI.
*/
sc->sc_iobase = aa->a;
sc->sc_iot = aa->t;
sc->sc_ioh = aa->h;
sc->sc_frequency = COM_FREQ;
intrstr = pci_intr_string(aa->pc, aa->intrhandle);
psc->sc_ih = pci_intr_establish(aa->pc, aa->intrhandle, IPL_SERIAL,
comintr, sc);
if (psc->sc_ih == NULL) {
printf(": couldn't establish interrupt");
if (intrstr != NULL)
printf(" at %s", intrstr);
printf("\n");
return;
}
printf(": interrupting at %s\n", intrstr);
printf("%s", sc->sc_dev.dv_xname);
com_attach_subr(sc);
}

View File

@ -1,4 +1,4 @@
# $NetBSD: files.pci,v 1.39 1998/06/02 01:29:41 thorpej Exp $
# $NetBSD: files.pci,v 1.40 1998/06/26 18:52:41 cgd Exp $
#
# Config file and device description for machine-independent PCI code.
# Included by ports that need it. Requires that the SCSI files be
@ -118,3 +118,21 @@ file dev/pci/eap.c eap
# SMC EPIC/100 Fast Ethernet on PCI
attach epic at pci with epic_pci
file dev/pci/if_epic_pci.c epic_pci
# PCI "universal" communication device driver, for PCI com, lpt, etc. ports
# (see documentation in the driver for what, exactly, should be supported)
device puc { port = -1 }
attach puc at pci
file dev/pci/puc.c puc
file dev/pci/pucdata.c puc
attach com at puc with com_puc
file dev/pci/com_puc.c com_puc
# XXX THE FOLLOWING BLOCK SHOULD GO INTO dev/pci/files.pci, BUT CANNOT
# XXX BECAUSE NOT 'lpt' IS DEFINED IN files.isa, RATHER THAN files.
# XXX (when the conf/files and files.isa bogons are fixed, this can
# XXX be fixed as well.)
# attach lpt at puc with lpt_puc
# file dev/pci/lpt_puc.c lpt_puc

100
sys/dev/pci/lpt_puc.c Normal file
View File

@ -0,0 +1,100 @@
/* $NetBSD: lpt_puc.c,v 1.1 1998/06/26 18:52:41 cgd Exp $ */
/*
* Copyright (c) 1998 Christopher G. Demetriou. 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 Christopher G. Demetriou
* for the NetBSD Project.
* 4. 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.
*/
/*
* Machine-independent parallel port ('lpt') driver attachment to "PCI
* Universal Communications" controller driver.
*
* Author: Christopher G. Demetriou, May 17, 1998.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/bus.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pucvar.h>
#include <dev/ic/lptvar.h>
int lpt_puc_probe __P((struct device *, struct cfdata *, void *));
void lpt_puc_attach __P((struct device *, struct device *, void *));
struct cfattach lpt_puc_ca = {
sizeof(struct lpt_softc), lpt_puc_probe, lpt_puc_attach
};
int
lpt_puc_probe(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
struct puc_attach_args *aa = aux;
/*
* Locators already matched, just check the type.
*/
if (aa->type != PUC_PORT_TYPE_LPT)
return (0);
return (1);
}
void
lpt_puc_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct lpt_softc *sc = (void *)self;
struct puc_attach_args *aa = aux;
const char *intrstr;
sc->sc_iot = aa->t;
sc->sc_ioh = aa->h;
intrstr = pci_intr_string(aa->pc, aa->intrhandle);
sc->sc_ih = pci_intr_establish(aa->pc, aa->intrhandle, IPL_TTY,
lptintr, sc);
if (sc->sc_ih == NULL) {
printf(": couldn't establish interrupt");
if (intrstr != NULL)
printf(" at %s", intrstr);
printf("\n");
return;
}
printf(": interrupting at %s\n", intrstr);
lpt_attach_subr(sc);
}

333
sys/dev/pci/puc.c Normal file
View File

@ -0,0 +1,333 @@
/* $NetBSD: puc.c,v 1.1 1998/06/26 18:52:41 cgd Exp $ */
/*
* Copyright (c) 1996, 1998 Christopher G. Demetriou. 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 Christopher G. Demetriou
* for the NetBSD Project.
* 4. 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.
*/
/*
* PCI "universal" communication card device driver, glues com, lpt,
* and similar ports to PCI via bridge chip often much larger than
* the devices being glued.
*
* Author: Christopher G. Demetriou, May 14, 1998 (derived from NetBSD
* sys/dev/pci/pciide.c, revision 1.6).
*
* These devices could be (and some times are) described as
* communications/{serial,parallel}, etc. devices with known
* programming interfaces, but those programming interfaces (in
* particular the BAR assignments for devices, etc.) in fact are not
* particularly well defined.
*
* After I/we have seen more of these devices, it may be possible
* to generalize some of these bits. In particular, devices which
* describe themselves as communications/serial/16[45]50, and
* communications/parallel/??? might be attached via direct
* 'com' and 'lpt' attachments to pci.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pucvar.h>
struct puc_softc {
struct device sc_dev;
/* static configuration data */
const struct puc_device_description *sc_desc;
/* card-global dynamic data */
void *sc_ih;
struct {
int mapped;
bus_addr_t a;
bus_size_t s;
bus_space_tag_t t;
bus_space_handle_t h;
} sc_bar_mappings[6]; /* XXX constant */
/* per-port dynamic data */
struct {
struct device *dev;
/* filled in by port attachments */
int (*ihand) __P((void *));
void *ihandarg;
} sc_ports[PUC_MAX_PORTS];
};
int puc_match __P((struct device *, struct cfdata *, void *));
void puc_attach __P((struct device *, struct device *, void *));
int puc_print __P((void *, const char *));
int puc_submatch __P((struct device *, struct cfdata *, void *));
struct cfattach puc_ca = {
sizeof(struct puc_softc), puc_match, puc_attach
};
static const struct puc_device_description *
puc_find_description __P((pcireg_t, pcireg_t, pcireg_t, pcireg_t));
static const char *
puc_port_type_name __P((int));
int
puc_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
struct pci_attach_args *pa = aux;
const struct puc_device_description *desc;
pcireg_t bhlc, subsys;
bhlc = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG);
if (PCI_HDRTYPE_TYPE(bhlc) != 0)
return (0);
subsys = pci_conf_read(pa->pa_pc, pa->pa_tag, 0x2c); /* XXX const */
desc = puc_find_description(PCI_VENDOR(pa->pa_id),
PCI_PRODUCT(pa->pa_id), PCI_VENDOR(subsys), PCI_PRODUCT(subsys));
if (desc != NULL)
return (10);
/*
* Match class/subclass, so we can tell people to compile kernel
* with options that cause this driver to spew.
*/
if (PCI_CLASS(pa->pa_class) == PCI_CLASS_COMMUNICATIONS &&
PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_BRIDGE_PCI)
return (1);
return (0);
}
void
puc_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct puc_softc *sc = (struct puc_softc *)self;
struct pci_attach_args *pa = aux;
struct puc_attach_args paa;
pci_intr_handle_t intrhandle;
pcireg_t subsys;
int i, barindex;
subsys = pci_conf_read(pa->pa_pc, pa->pa_tag, 0x2c); /* XXX const */
sc->sc_desc = puc_find_description(PCI_VENDOR(pa->pa_id),
PCI_PRODUCT(pa->pa_id), PCI_VENDOR(subsys), PCI_PRODUCT(subsys));
if (sc->sc_desc == NULL) {
/*
* This was a class/subclass match, so tell people to compile
* kernel with options that cause this driver to spew.
*/
#ifdef PUC_PRINT_REGS
printf(":\n");
pci_conf_print(pa->pa_pc, pa->pa_tag, NULL);
#else
printf(": unknown PCI communications device\n");
printf("%s: compile kernel with PUC_PRINT_REGS and larger\n",
sc->sc_dev.dv_xname);
printf("%s: mesage buffer (via 'options MSGBUFSIZE=...'),\n",
sc->sc_dev.dv_xname);
printf("%s: and report the result with send-pr\n",
sc->sc_dev.dv_xname);
#endif
return;
}
printf(": %s (", sc->sc_desc->name);
for (i = 0; PUC_PORT_VALID(sc->sc_desc, i); i++)
printf("%s%s", i ? ", " : "",
puc_port_type_name(sc->sc_desc->ports[i].type));
printf(")\n");
/*
* XXX This driver assumes that 'com' ports attached to it
* XXX can not be console. That isn't unreasonable, because PCI
* XXX devices are supposed to be dynamically mapped, and com
* XXX console ports want fixed addresses. When/if baseboard
* XXX 'com' ports are identified as PCI/communications/serial
* XXX devices and are known to be mapped at the standard
* XXX addresses, if they can be the system console then we have
* XXX to cope with doing the mapping right. Then this will get
* XXX really ugly. Of course, by then we might know the real
* XXX definition of PCI/communications/serial, and attach 'com'
* XXX directly on PCI.
*/
for (i = 0; i < 6; i++) {
pcireg_t bar, type;
sc->sc_bar_mappings[i].mapped = 0;
bar = pci_conf_read(pa->pa_pc, pa->pa_tag,
PCI_MAPREG_START + 4 * i); /* XXX const */
if (bar == 0) /* BAR not implemented(?) */
continue;
type = (PCI_MAPREG_TYPE(bar) == PCI_MAPREG_TYPE_IO ?
PCI_MAPREG_TYPE_IO : PCI_MAPREG_MEM_TYPE(bar));
sc->sc_bar_mappings[i].mapped = (pci_mapreg_map(pa,
PCI_MAPREG_START + 4 * i, type, 0,
&sc->sc_bar_mappings[i].t, &sc->sc_bar_mappings[i].h,
&sc->sc_bar_mappings[i].a, &sc->sc_bar_mappings[i].s)
== 0);
if (sc->sc_bar_mappings[i].mapped)
continue;
printf("%s: couldn't map BAR at offset 0x%lx\n",
sc->sc_dev.dv_xname, (long)(PCI_MAPREG_START + 4 * i));
}
/* Map interrupt. */
if (pci_intr_map(pa->pa_pc, pa->pa_intrtag, pa->pa_intrpin,
pa->pa_intrline, &intrhandle)) {
printf("%s: couldn't map interrupt\n", sc->sc_dev.dv_xname);
return;
}
/*
* XXX the sub-devices establish the interrupts, for the
* XXX following reasons:
* XXX
* XXX * we can't really know what IPLs they'd want
* XXX
* XXX * the MD dispatching code can ("should") dispatch
* XXX chained interrupts better than we can.
* XXX
* XXX It would be nice if we could indicate to the MD interrupt
* XXX handling code that the interrupt line used by the device
* XXX was a PCI (level triggered) interrupt.
* XXX
* XXX It's not pretty, but hey, what is?
*/
/* Configure each port. */
for (i = 0; PUC_PORT_VALID(sc->sc_desc, i); i++) {
/* make sure the base address register is mapped */
barindex = PUC_PORT_BAR_INDEX(sc->sc_desc->ports[i].bar);
if (!sc->sc_bar_mappings[barindex].mapped) {
printf("%s: %s port uses unmapped BAR (0x%x)\n",
sc->sc_dev.dv_xname,
puc_port_type_name(sc->sc_desc->ports[i].type),
sc->sc_desc->ports[i].bar);
continue;
}
/* set up to configure the child device */
paa.port = i;
paa.type = sc->sc_desc->ports[i].type;
paa.pc = pa->pa_pc;
paa.intrhandle = intrhandle;
paa.a = sc->sc_bar_mappings[barindex].a;
paa.s = sc->sc_bar_mappings[barindex].s;
paa.t = sc->sc_bar_mappings[barindex].t;
paa.h = sc->sc_bar_mappings[barindex].h;
#if 0
printf("%s: port %d: %s @ (index %d) 0x%x/%d (0x%lx, 0x%lx)\n",
sc->sc_dev.dv_xname, paa.port,
puc_port_type_name(paa.type), barindex, (int)paa.a,
(int)paa.s, (long)paa.t, (long)paa.h);
#endif
/* and configure it */
sc->sc_ports[i].dev = config_found_sm(self, &paa, puc_print,
puc_submatch);
}
}
int
puc_print(aux, pnp)
void *aux;
const char *pnp;
{
struct puc_attach_args *paa = aux;
if (pnp)
printf("%s at %s", puc_port_type_name(paa->type), pnp);
printf(" port %d", paa->port);
return (UNCONF);
}
int
puc_submatch(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
struct puc_attach_args *aa = aux;
if (cf->cf_loc[PUCCF_PORT] != PUCCF_PORT_DEFAULT &&
cf->cf_loc[PUCCF_PORT] != aa->port)
return 0;
return ((*cf->cf_attach->ca_match)(parent, cf, aux));
}
static const struct puc_device_description *
puc_find_description(vend, prod, svend, sprod)
pcireg_t vend, prod, svend, sprod;
{
int i;
#define checkreg(val, index) \
(((val) & puc_devices[i].rmask[(index)]) == puc_devices[i].rval[(index)])
for (i = 0; puc_devices[i].name != NULL; i++) {
if (checkreg(vend, PUC_REG_VEND) &&
checkreg(prod, PUC_REG_PROD) &&
checkreg(svend, PUC_REG_SVEND) &&
checkreg(sprod, PUC_REG_SPROD))
return (&puc_devices[i]);
}
#undef checkreg
return (NULL);
}
static const char *
puc_port_type_name(type)
int type;
{
switch (type) {
case PUC_PORT_TYPE_COM:
return "com";
case PUC_PORT_TYPE_LPT:
return "lpt";
default:
panic("puc_port_type_name %d", type);
}
}

109
sys/dev/pci/pucdata.c Normal file
View File

@ -0,0 +1,109 @@
/* $NetBSD: pucdata.c,v 1.1 1998/06/26 18:52:41 cgd Exp $ */
/*
* Copyright (c) 1998 Christopher G. Demetriou. 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 Christopher G. Demetriou
* for the NetBSD Project.
* 4. 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.
*/
/*
* PCI "universal" communications card driver configuration data (used to
* match/attach the cards).
*
* Author: Christopher G. Demetriou, May 14, 1998.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pucvar.h>
const struct puc_device_description puc_devices[] = {
/*
* XXX no entry because I have no data:
* XXX Dolphin 4006 (single parallel)
*/
/*
* Dolphin 4014 (dual parallel port) card. PLX 9050, with
* a seemingly-lame EEPROM setup that puts the Dolphin IDs
* into the subsystem fields, and claims that it's a
* network/misc (0x02/0x80) device.
*/
{ "Dolphin 4014",
{ 0x10b5, 0x9050, 0xd84d, 0x6810 },
{ 0xffff, 0xffff, 0xffff, 0xffff },
{
{ PUC_PORT_TYPE_LPT, 0x20 },
{ PUC_PORT_TYPE_LPT, 0x24 },
},
},
/*
* XXX no entry because I have no data:
* XXX Dolphin 4025 (single serial)
*/
/*
* Dolphin 4035 (dual serial port) card. PLX 9050, with
* a seemingly-lame EEPROM setup that puts the Dolphin IDs
* into the subsystem fields, and claims that it's a
* network/misc (0x02/0x80) device.
*/
{ "Dolphin 4035",
{ 0x10b5, 0x9050, 0xd84d, 0x6808 },
{ 0xffff, 0xffff, 0xffff, 0xffff },
{
{ PUC_PORT_TYPE_COM, 0x18 },
{ PUC_PORT_TYPE_COM, 0x1c },
},
},
/*
* XXX no entry because I have no data:
* XXX SIIG CyberParallel PCI (single parallel)
*/
/*
* SIIG CyberSerial PCI (single serial port) card. PLX 9052, with
* a more sensible EEPROM setup that reports "normal"-looking
* vendor and product IDs, and sensible class/subclass info,
* communications/serial (0x07/0x00), interface 0x02.
*/
{ "SIIG CyberSerial PCI",
{ 0x131f, 0x1000, 0, 0 },
{ 0xffff, 0xffff, 0, 0 },
{
{ PUC_PORT_TYPE_COM, 0x18 },
},
},
{ 0 }
};

78
sys/dev/pci/pucvar.h Normal file
View File

@ -0,0 +1,78 @@
/* $NetBSD: pucvar.h,v 1.1 1998/06/26 18:52:41 cgd Exp $ */
/*
* Copyright (c) 1998 Christopher G. Demetriou. 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 Christopher G. Demetriou
* for the NetBSD Project.
* 4. 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.
*/
/*
* Exported (or conveniently located) PCI "universal" communications card
* software structures.
*
* Author: Christopher G. Demetriou, May 14, 1998.
*/
#define PUC_MAX_PORTS 2
struct puc_device_description {
const char *name;
pcireg_t rval[4];
pcireg_t rmask[4];
struct {
int type;
int bar;
} ports[PUC_MAX_PORTS];
};
#define PUC_REG_VEND 0
#define PUC_REG_PROD 1
#define PUC_REG_SVEND 2
#define PUC_REG_SPROD 3
#define PUC_PORT_TYPE_NONE 0
#define PUC_PORT_TYPE_COM 1
#define PUC_PORT_TYPE_LPT 2
#define PUC_PORT_VALID(desc, port) \
((port) < PUC_MAX_PORTS && (desc)->ports[(port)].type != PUC_PORT_TYPE_NONE)
#define PUC_PORT_BAR_INDEX(bar) (((bar) - PCI_MAPREG_START) / 4)
struct puc_attach_args {
int port;
int type;
pci_chipset_tag_t pc;
pci_intr_handle_t intrhandle;
bus_addr_t a;
bus_size_t s;
bus_space_tag_t t;
bus_space_handle_t h;
};
extern const struct puc_device_description puc_devices[];