Subject: there is no cardbus attachment for the com driver
To: None <gnats-bugs@gnats.netbsd.org>
From: Johan Danielsson <joda@pdc.kth.se>
List: netbsd-bugs
Date: 10/15/1999 18:03:45
>Number: 8632
>Category: kern
>Synopsis: there is no cardbus attachment for the com driver
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: kern-bug-people (Kernel Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Oct 16 00:03:00 1999
>Last-Modified:
>Originator: Johan Danielsson
>Organization:
>Release: 1999-10-15
>Environment:
<machine, os, target, libraries (multiple lines)>
System: NetBSD 1.4L (BLUBB) #9: Fri Oct 15 17:22:11 CEST 1999
>Description:
>How-To-Repeat:
>Fix:
Index: com_cardbus.c
===================================================================
RCS file: com_cardbus.c
diff -N com_cardbus.c
--- /dev/null Sat Jun 19 04:06:14 1999
+++ com_cardbus.c Fri Oct 15 12:02:35 1999
@@ -0,0 +1,134 @@
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/tty.h>
+#include <sys/device.h>
+
+#include <dev/cardbus/cardbusvar.h>
+#include <dev/cardbus/cardbusdevs.h>
+
+#include <dev/ic/comreg.h>
+#include <dev/ic/comvar.h>
+
+struct com_cardbus_softc {
+ struct com_softc sc;
+ void *sc_ih; /* interrupt handler */
+ cardbus_devfunc_t ct;
+ pcireg_t base0_reg;
+};
+
+static int com_cardbus_match(struct device*, struct cfdata*, void*);
+static void com_cardbus_attach(struct device*, struct device*, void*);
+
+static void com_cardbus_setup(struct com_softc*);
+
+static int com_cardbus_enable(struct com_softc*);
+static void com_cardbus_disable(struct com_softc*);
+
+struct cfattach com_cardbus_ca = {
+ sizeof(struct com_cardbus_softc), com_cardbus_match, com_cardbus_attach
+};
+
+static int
+com_cardbus_match(struct device *parent, struct cfdata *match, void *aux)
+{
+ struct cardbus_attach_args *ca = aux;
+ if(PCI_CLASS(ca->ca_class) == PCI_CLASS_COMMUNICATIONS &&
+ PCI_SUBCLASS(ca->ca_class) == PCI_SUBCLASS_COMMUNICATIONS_SERIAL)
+ return 1;
+ return 0;
+}
+
+static void
+com_cardbus_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct com_softc *sc = (struct com_softc*)self;
+ struct com_cardbus_softc *csc = (struct com_cardbus_softc*)self;
+ struct cardbus_attach_args *ca = aux;
+ bus_space_tag_t iot;
+ bus_space_handle_t ioh;
+
+ bus_addr_t adr;
+
+ csc->ct = ca->ca_ct;
+ if(cardbus_mapreg_map(csc->ct, CARDBUS_BASE0_REG,
+ PCI_MAPREG_TYPE_IO,
+ 0, &iot, &ioh, &adr, NULL) != 0)
+ panic("io alloc");
+
+ csc->base0_reg = adr | 1;
+ sc->sc_iot = iot;
+ sc->sc_ioh = ioh;
+
+ sc->sc_iobase = adr;
+ sc->sc_frequency = COM_FREQ;
+
+ sc->enable = com_cardbus_enable;
+ sc->disable = com_cardbus_disable;
+
+ sc->enabled = 1;
+
+ com_cardbus_setup(sc);
+
+ com_attach_subr(sc);
+}
+
+static void
+com_cardbus_setup(struct com_softc *sc)
+{
+ struct com_cardbus_softc *csc = (struct com_cardbus_softc*)sc;
+ struct cardbus_softc *psc = (struct cardbus_softc *)sc->sc_dev.dv_parent;
+ cardbus_chipset_tag_t cc = psc->sc_cc;
+ cardbus_function_tag_t cf = psc->sc_cf;
+ pcireg_t command;
+
+ cardbustag_t tag = cardbus_make_tag(cc, cf, csc->ct->ct_bus,
+ csc->ct->ct_dev, csc->ct->ct_func);
+
+ Cardbus_conf_write(csc->ct, tag, CARDBUS_BASE0_REG, csc->base0_reg);
+
+ (cf->cardbus_ctrl)(cc, CARDBUS_IO_ENABLE);
+
+ /* enable the card */
+ command = Cardbus_conf_read(csc->ct, tag, CARDBUS_COMMAND_STATUS_REG);
+ command |= CARDBUS_COMMAND_IO_ENABLE | CARDBUS_COMMAND_MASTER_ENABLE;
+ Cardbus_conf_write(csc->ct, tag, CARDBUS_COMMAND_STATUS_REG, command);
+}
+
+static int
+com_cardbus_enable(struct com_softc *sc)
+{
+ struct com_cardbus_softc *csc = (struct com_cardbus_softc*)sc;
+ struct cardbus_softc *psc = (struct cardbus_softc *)sc->sc_dev.dv_parent;
+ cardbus_chipset_tag_t cc = psc->sc_cc;
+ cardbus_function_tag_t cf = psc->sc_cf;
+
+ cardbus_function_enable(csc->ct);
+
+ com_cardbus_setup(sc);
+
+ /* establish the interrupt. */
+ csc->sc_ih = cardbus_intr_establish(cc, cf, psc->sc_intrline, IPL_SERIAL,
+ comintr, sc);
+ if (csc->sc_ih == NULL) {
+ printf("%s: couldn't establish interrupt\n", sc->sc_dev.dv_xname);
+ return 1;
+ }
+
+ printf("%s: interrupting at irq %d\n",
+ sc->sc_dev.dv_xname, psc->sc_intrline);
+
+ return 0;
+}
+
+static void
+com_cardbus_disable(struct com_softc *sc)
+{
+ struct com_cardbus_softc *csc = (struct com_cardbus_softc*)sc;
+ struct cardbus_softc *psc = (struct cardbus_softc *)sc->sc_dev.dv_parent;
+ cardbus_chipset_tag_t cc = psc->sc_cc;
+ cardbus_function_tag_t cf = psc->sc_cf;
+
+ cardbus_intr_disestablish(cc, cf, csc->sc_ih); /* remove intr handler */
+
+ cardbus_function_disable(csc->ct);
+}
Index: cardbus/files.cardbus
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/cardbus/files.cardbus,v
retrieving revision 1.2
diff -w -u -r1.2 files.cardbus
--- files.cardbus 1999/10/15 06:42:22 1.2
+++ files.cardbus 1999/10/15 16:01:26
@@ -25,9 +25,9 @@
#
#
#
#attach fxp at cardbus with fxp_cardbus
#file dev/cardbus/if_fxp_cardbus.c fxp_cardbus
-#attach com at cardbus with com_cardbus
-#file dev/cardbus/com_cardbus.c com_cardbus
+attach com at cardbus with com_cardbus
+file dev/cardbus/com_cardbus.c com_cardbus
>Audit-Trail:
>Unformatted: