diff options
-rw-r--r-- | sys/dev/ic/com.c | 30 | ||||
-rw-r--r-- | sys/dev/ic/comreg.h | 7 | ||||
-rw-r--r-- | sys/dev/ic/comvar.h | 3 | ||||
-rw-r--r-- | sys/dev/pci/puc.c | 45 | ||||
-rw-r--r-- | sys/dev/pci/pucdata.c | 10 | ||||
-rw-r--r-- | sys/dev/pci/pucvar.h | 7 |
6 files changed, 85 insertions, 17 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 4e692f6fb4c..d94cd170685 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com.c,v 1.166 2018/04/02 07:45:20 kettenis Exp $ */ +/* $OpenBSD: com.c,v 1.167 2018/04/15 15:07:25 jcs Exp $ */ /* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */ /* @@ -306,6 +306,9 @@ comopen(dev_t dev, int flag, int mode, struct proc *p) case COM_UART_TI16750: com_write_reg(sc, com_ier, 0); break; + case COM_UART_XR17V35X: + com_write_reg(sc, UART_EXAR_SLEEP, 0); + break; } } @@ -498,6 +501,9 @@ compwroff(struct com_softc *sc) case COM_UART_TI16750: com_write_reg(sc, com_ier, IER_SLEEP); break; + case COM_UART_XR17V35X: + com_write_reg(sc, UART_EXAR_SLEEP, 0xff); + break; } } } @@ -533,6 +539,9 @@ com_resume(struct com_softc *sc) case COM_UART_TI16750: com_write_reg(sc, com_ier, 0); break; + case COM_UART_XR17V35X: + com_write_reg(sc, UART_EXAR_SLEEP, 0); + break; } } @@ -919,7 +928,7 @@ comstart(struct tty *tp) } if (ISSET(sc->sc_hwflags, COM_HW_FIFO)) { - u_char buffer[128]; /* largest fifo */ + u_char buffer[256]; /* largest fifo */ int i, n; n = q_to_b(&tp->t_outq, buffer, @@ -1308,7 +1317,7 @@ void com_attach_subr(struct com_softc *sc) { int probe = 0; - u_int8_t lcr; + u_int8_t lcr, dvid; sc->sc_ier = 0; /* disable interrupts */ @@ -1355,6 +1364,13 @@ com_attach_subr(struct com_softc *sc) probe = 1; } + /* Probe for XR17V35X */ + if (probe && sc->sc_uarttype == COM_UART_16550A) { + dvid = com_read_reg(sc, UART_EXAR_DVID); + if (dvid == 0x82 || dvid == 0x84 || dvid == 0x88) + sc->sc_uarttype = COM_UART_XR17V35X; + } + /* Probe for ST16650s */ if (probe && sc->sc_uarttype == COM_UART_16550A) { com_write_reg(sc, com_lcr, lcr | LCR_DLAB); @@ -1483,6 +1499,11 @@ com_attach_subr(struct com_softc *sc) break; #endif #endif + case COM_UART_XR17V35X: + printf(": xr17v35x, 256 byte fifo\n"); + SET(sc->sc_hwflags, COM_HW_FIFO); + sc->sc_fifolen = 256; + break; default: panic("comattach: bad fifo type"); } @@ -1490,7 +1511,8 @@ com_attach_subr(struct com_softc *sc) #ifdef COM_CONSOLE if (!ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) #endif - com_fifo_probe(sc); + if (sc->sc_fifolen < 256) + com_fifo_probe(sc); if (sc->sc_fifolen == 0) { CLR(sc->sc_hwflags, COM_HW_FIFO); diff --git a/sys/dev/ic/comreg.h b/sys/dev/ic/comreg.h index 8771c454f44..96ee9fcc764 100644 --- a/sys/dev/ic/comreg.h +++ b/sys/dev/ic/comreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: comreg.h,v 1.17 2016/09/03 14:43:37 jsg Exp $ */ +/* $OpenBSD: comreg.h,v 1.18 2018/04/15 15:07:25 jcs Exp $ */ /* $NetBSD: comreg.h,v 1.8 1996/02/05 23:01:50 scottr Exp $ */ /* @@ -182,6 +182,11 @@ #define COM_NPORTS 8 +/* Exar XR17V35X */ +#define UART_EXAR_INT0 0x80 +#define UART_EXAR_SLEEP 0x8b /* Sleep mode */ +#define UART_EXAR_DVID 0x8d /* Device identification */ + /* * WARNING: Serial console is assumed to be at COM1 address */ diff --git a/sys/dev/ic/comvar.h b/sys/dev/ic/comvar.h index 5349513438d..0b75bb30172 100644 --- a/sys/dev/ic/comvar.h +++ b/sys/dev/ic/comvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: comvar.h,v 1.54 2018/04/02 07:45:20 kettenis Exp $ */ +/* $OpenBSD: comvar.h,v 1.55 2018/04/15 15:07:25 jcs Exp $ */ /* $NetBSD: comvar.h,v 1.5 1996/05/05 19:50:47 christos Exp $ */ /* @@ -103,6 +103,7 @@ struct com_softc { #define COM_UART_ST16C654 0x08 /* 64 bytes fifo */ #define COM_UART_XR16850 0x10 /* 128 byte fifo */ #define COM_UART_OX16C950 0x11 /* 128 byte fifo */ +#define COM_UART_XR17V35X 0x12 /* 256 byte fifo */ u_char sc_hwflags; #define COM_HW_NOIEN 0x01 diff --git a/sys/dev/pci/puc.c b/sys/dev/pci/puc.c index ff65cafd26a..bbd05098395 100644 --- a/sys/dev/pci/puc.c +++ b/sys/dev/pci/puc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: puc.c,v 1.24 2015/03/14 03:38:49 jsg Exp $ */ +/* $OpenBSD: puc.c,v 1.25 2018/04/15 15:07:25 jcs Exp $ */ /* $NetBSD: puc.c,v 1.3 1999/02/06 06:29:54 cgd Exp $ */ /* @@ -61,6 +61,7 @@ #include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> #include <dev/pci/pucvar.h> +#include <dev/pci/pcidevs.h> #include <dev/ic/comreg.h> #include <dev/ic/comvar.h> @@ -78,6 +79,7 @@ int puc_pci_detach(struct device *, int); const char *puc_pci_intr_string(struct puc_attach_args *); void *puc_pci_intr_establish(struct puc_attach_args *, int, int (*)(void *), void *, char *); +int puc_pci_xr17v35x_intr(void *arg); struct cfattach puc_pci_ca = { sizeof(struct puc_pci_softc), puc_pci_match, @@ -125,9 +127,20 @@ puc_pci_intr_establish(struct puc_attach_args *paa, int type, { struct puc_pci_softc *sc = paa->puc; struct puc_softc *psc = &sc->sc_psc; - - psc->sc_ports[paa->port].intrhand = - pci_intr_establish(sc->pc, sc->ih, type, func, arg, name); + + if (psc->sc_xr17v35x) { + psc->sc_ports[paa->port].real_intrhand = func; + psc->sc_ports[paa->port].real_intrhand_arg = arg; + if (paa->port == 0) + psc->sc_ports[paa->port].intrhand = + pci_intr_establish(sc->pc, sc->ih, type, + puc_pci_xr17v35x_intr, sc, name); + return (psc->sc_ports[paa->port].real_intrhand); + } else { + psc->sc_ports[paa->port].intrhand = + pci_intr_establish(sc->pc, sc->ih, type, func, arg, name); + return (psc->sc_ports[paa->port].intrhand); + } return (psc->sc_ports[paa->port].intrhand); } @@ -146,6 +159,10 @@ puc_pci_attach(struct device *parent, struct device *self, void *aux) sc->sc_desc = puc_find_description(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id), PCI_VENDOR(subsys), PCI_PRODUCT(subsys)); + if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_EXAR && + PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_EXAR_XR17V354) + sc->sc_xr17v35x = 1; + puc_print_ports(sc->sc_desc); for (i = 0; i < PUC_NBARS; i++) { @@ -319,7 +336,6 @@ puc_find_description(u_int16_t vend, u_int16_t prod, const char * puc_port_type_name(int type) { - if (PUC_IS_COM(type)) return "com"; if (PUC_IS_LPT(type)) @@ -348,3 +364,22 @@ puc_print_ports(const struct puc_device_description *desc) } printf("\n"); } + +int +puc_pci_xr17v35x_intr(void *arg) +{ + struct puc_pci_softc *sc = arg; + struct puc_softc *psc = &sc->sc_psc; + int ports, i; + + ports = bus_space_read_1(psc->sc_bar_mappings[0].t, + psc->sc_bar_mappings[0].h, UART_EXAR_INT0); + + for (i = 0; i < 8; i++) { + if ((ports & (1 << i)) && psc->sc_ports[i].real_intrhand) + (*(psc->sc_ports[i].real_intrhand))( + psc->sc_ports[i].real_intrhand_arg); + } + + return (1); +} diff --git a/sys/dev/pci/pucdata.c b/sys/dev/pci/pucdata.c index 172ae5c7ae1..840b8e156b9 100644 --- a/sys/dev/pci/pucdata.c +++ b/sys/dev/pci/pucdata.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pucdata.c,v 1.107 2018/04/15 00:10:59 jcs Exp $ */ +/* $OpenBSD: pucdata.c,v 1.108 2018/04/15 15:07:25 jcs Exp $ */ /* $NetBSD: pucdata.c,v 1.6 1999/07/03 05:55:23 cgd Exp $ */ /* @@ -2062,10 +2062,10 @@ const struct puc_device_description puc_devs[] = { { PCI_VENDOR_EXAR, PCI_PRODUCT_EXAR_XR17V354, 0, 0 }, { 0xffff, 0xffff, 0, 0 }, { - { PUC_PORT_COM_MUL8, 0x10, 0x0000 }, - { PUC_PORT_COM_MUL8, 0x10, 0x0400 }, - { PUC_PORT_COM_MUL8, 0x10, 0x0800 }, - { PUC_PORT_COM_MUL8, 0x10, 0x0C00 }, + { PUC_PORT_COM_125MHZ, 0x10, 0x0000 }, + { PUC_PORT_COM_125MHZ, 0x10, 0x0400 }, + { PUC_PORT_COM_125MHZ, 0x10, 0x0800 }, + { PUC_PORT_COM_125MHZ, 0x10, 0x0C00 }, }, }, diff --git a/sys/dev/pci/pucvar.h b/sys/dev/pci/pucvar.h index 78824f3fd65..c4c655e6fea 100644 --- a/sys/dev/pci/pucvar.h +++ b/sys/dev/pci/pucvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pucvar.h,v 1.14 2018/04/15 00:10:59 jcs Exp $ */ +/* $OpenBSD: pucvar.h,v 1.15 2018/04/15 15:07:25 jcs Exp $ */ /* $NetBSD: pucvar.h,v 1.2 1999/02/06 06:29:54 cgd Exp $ */ /* @@ -72,6 +72,7 @@ static const struct puc_port_type puc_port_types[] = { { PUC_PORT_COM_MUL8, COM_FREQ * 8 }, { PUC_PORT_COM_MUL10, COM_FREQ * 10 }, { PUC_PORT_COM_MUL128, COM_FREQ * 128 }, + { PUC_PORT_COM_125MHZ, 125000000 }, }; #define PUC_IS_LPT(type) ((type) == PUC_PORT_LPT) @@ -117,7 +118,11 @@ struct puc_softc { struct device *dev; /* filled in by port attachments */ void *intrhand; + int (*real_intrhand)(void *); + void *real_intrhand_arg; } sc_ports[PUC_MAX_PORTS]; + + int sc_xr17v35x; }; const struct puc_device_description * |