diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-06-19 22:51:27 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-06-19 22:51:27 +0000 |
commit | 2509b20e596692dd601aea734d44ac68efd60fe3 (patch) | |
tree | e6e41171c3f34f08b03e7dfd75b9f249c97c53f6 /sys/arch/hppa | |
parent | e4f3b7560a486aaf7287319871dbfe014e0f1804 (diff) |
com at ssio
Diffstat (limited to 'sys/arch/hppa')
-rw-r--r-- | sys/arch/hppa/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/arch/hppa/conf/files.hppa | 7 | ||||
-rw-r--r-- | sys/arch/hppa/dev/com_ssio.c | 75 | ||||
-rw-r--r-- | sys/arch/hppa/dev/ssio.c | 37 | ||||
-rw-r--r-- | sys/arch/hppa/dev/ssiovar.h | 29 |
5 files changed, 144 insertions, 8 deletions
diff --git a/sys/arch/hppa/conf/GENERIC b/sys/arch/hppa/conf/GENERIC index 6d4391aba39..5a164045e8a 100644 --- a/sys/arch/hppa/conf/GENERIC +++ b/sys/arch/hppa/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.101 2007/06/19 19:16:59 kettenis Exp $ +# $OpenBSD: GENERIC,v 1.102 2007/06/19 22:51:26 kettenis Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -78,6 +78,8 @@ ppb* at pci? pci* at ppb? ssio* at pci? +com0 at ssio? irq 4 +com1 at ssio? irq 3 # CardBus bus support cbb* at pci? diff --git a/sys/arch/hppa/conf/files.hppa b/sys/arch/hppa/conf/files.hppa index 13fa326fbe7..26c6fa106c8 100644 --- a/sys/arch/hppa/conf/files.hppa +++ b/sys/arch/hppa/conf/files.hppa @@ -1,4 +1,4 @@ -# $OpenBSD: files.hppa,v 1.67 2007/06/19 19:16:59 kettenis Exp $ +# $OpenBSD: files.hppa,v 1.68 2007/06/19 22:51:26 kettenis Exp $ # # hppa-specific configuration info @@ -183,10 +183,13 @@ file arch/hppa/dev/sti_pci_machdep.c sti_pci attach siop at gedoens with siop_sgc file arch/hppa/dev/siop_sgc.c siop_sgc -device ssio +device ssio {[irq = -1]} attach ssio at pci file arch/hppa/dev/ssio.c ssio +attach com at ssio with com_ssio +file arch/hppa/dev/com_ssio.c com_ssio + ### major {ccd = 1} 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 *); |