summaryrefslogtreecommitdiff
path: root/sys/arch/hppa/dev
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2007-06-19 22:51:27 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2007-06-19 22:51:27 +0000
commit2509b20e596692dd601aea734d44ac68efd60fe3 (patch)
treee6e41171c3f34f08b03e7dfd75b9f249c97c53f6 /sys/arch/hppa/dev
parente4f3b7560a486aaf7287319871dbfe014e0f1804 (diff)
com at ssio
Diffstat (limited to 'sys/arch/hppa/dev')
-rw-r--r--sys/arch/hppa/dev/com_ssio.c75
-rw-r--r--sys/arch/hppa/dev/ssio.c37
-rw-r--r--sys/arch/hppa/dev/ssiovar.h29
3 files changed, 136 insertions, 5 deletions
diff --git a/sys/arch/hppa/dev/com_ssio.c b/sys/arch/hppa/dev/com_ssio.c
new file mode 100644
index 00000000000..249bf4a6b3a
--- /dev/null
+++ b/sys/arch/hppa/dev/com_ssio.c
@@ -0,0 +1,75 @@
+/* $OpenBSD: com_ssio.c,v 1.1 2007/06/19 22:51:26 kettenis Exp $ */
+
+/*
+ * Copyright (c) 2007 Mark Kettenis
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/tty.h>
+
+#include <machine/bus.h>
+
+#include <dev/ic/comreg.h>
+#include <dev/ic/comvar.h>
+
+#include <hppa/dev/ssiovar.h>
+
+#define COM_SSIO_FREQ 1843200
+
+int com_ssio_match(struct device *, void *, void *);
+void com_ssio_attach(struct device *, struct device *, void *);
+
+struct cfattach com_ssio_ca = {
+ sizeof(struct com_softc), com_ssio_match, com_ssio_attach
+};
+
+int
+com_ssio_match(struct device *parent, void *match, void *aux)
+{
+ struct cfdata *cf = match;
+ struct ssio_attach_args *saa = aux;
+
+ if (strcmp(saa->saa_name, "com") != 0)
+ return (0);
+
+ /* Check locators. */
+ if (cf->ssiocf_irq != SSIO_UNK_IRQ && cf->ssiocf_irq != saa->saa_irq)
+ return (0);
+
+ return (1);
+}
+
+void
+com_ssio_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct com_softc *sc = (void *)self;
+ struct ssio_attach_args *saa = aux;
+
+ sc->sc_iot = saa->saa_iot;
+ sc->sc_iobase = saa->saa_iobase;
+ if (bus_space_map(sc->sc_iot, sc->sc_iobase, COM_NPORTS,
+ 0, &sc->sc_ioh)) {
+ printf(": cannot map io space\n");
+ return;
+ }
+
+ sc->sc_frequency = COM_SSIO_FREQ;
+ com_attach_subr(sc);
+
+ sc->sc_ih = ssio_intr_establish(IPL_TTY, saa->saa_irq,
+ comintr, sc, sc->sc_dev.dv_xname);
+}
diff --git a/sys/arch/hppa/dev/ssio.c b/sys/arch/hppa/dev/ssio.c
index 5274de7855c..0133a1e0ce7 100644
--- a/sys/arch/hppa/dev/ssio.c
+++ b/sys/arch/hppa/dev/ssio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssio.c,v 1.1 2007/06/19 19:16:59 kettenis Exp $ */
+/* $OpenBSD: ssio.c,v 1.2 2007/06/19 22:51:26 kettenis Exp $ */
/*
* Copyright (c) 2007 Mark Kettenis
@@ -30,6 +30,8 @@
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>
+#include <hppa/dev/ssiovar.h>
+
/* PCI config space. */
#define SSIO_PCI_DMA_RC2 0x64
#define SSIO_PCI_INT_TC1 0x67
@@ -117,6 +119,7 @@ const struct pci_matchid ssio_devices[] = {
};
int ssio_intr(void *);
+int ssio_print(void *, const char *);
int
ssio_match(struct device *parent, void *match, void *aux)
@@ -130,6 +133,7 @@ ssio_attach(struct device *parent, struct device *self, void *aux)
{
struct ssio_softc *sc = (void *)self;
struct pci_attach_args *pa = aux;
+ struct ssio_attach_args saa;
pci_intr_handle_t ih;
const char *intrstr;
pcireg_t reg;
@@ -203,7 +207,23 @@ ssio_attach(struct device *parent, struct device *self, void *aux)
/* Unmask all interrupts. */
bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 1, 0x00);
bus_space_write_1(sc->sc_iot, sc->sc_ic2h, 1, 0x00);
-
+
+ /* Serial Port 1. */
+ saa.saa_name = "com";
+ saa.saa_iot = sc->sc_iot;
+ saa.saa_iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, SSIO_PCI_SP1BAR);
+ saa.saa_iobase &= 0xfffffffe;
+ saa.saa_irq = 4;
+ config_found(self, &saa, ssio_print);
+
+ /* Serial Port 2. */
+ saa.saa_name = "com";
+ saa.saa_iot = sc->sc_iot;
+ saa.saa_iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, SSIO_PCI_SP2BAR);
+ saa.saa_iobase &= 0xfffffffe;
+ saa.saa_irq = 3;
+ config_found(self, &saa, ssio_print);
+
return;
unmap_ic2:
@@ -240,9 +260,6 @@ ssio_intr(void *v)
/* Signal EOI. */
bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 0, 0x60 | (irq & 0x0f));
- if (claimed)
- printf("claimed irq %d\n", irq);
-
return (claimed);
}
@@ -261,3 +278,13 @@ ssio_intr_establish(int pri, int irq, int (*handler)(void *), void *arg,
return (iv);
}
+
+int
+ssio_print(void *aux, const char *pnp)
+{
+ struct ssio_attach_args *saa = aux;
+
+ if (pnp)
+ printf("%s at %s\n", saa->saa_name, pnp);
+ return (UNCONF);
+}
diff --git a/sys/arch/hppa/dev/ssiovar.h b/sys/arch/hppa/dev/ssiovar.h
new file mode 100644
index 00000000000..dfbf5c1378b
--- /dev/null
+++ b/sys/arch/hppa/dev/ssiovar.h
@@ -0,0 +1,29 @@
+/* $OpenBSD: ssiovar.h,v 1.1 2007/06/19 22:51:26 kettenis Exp $ */
+
+/*
+ * Copyright (c) 2007 Mark Kettenis
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+struct ssio_attach_args {
+ const char *saa_name;
+ bus_space_tag_t saa_iot;
+ bus_addr_t saa_iobase;
+ int saa_irq;
+};
+
+#define ssiocf_irq cf_loc[0]
+#define SSIO_UNK_IRQ -1
+
+void *ssio_intr_establish(int, int, int (*)(void *), void *, const char *);