Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Add support for polling com devices when no inte...



details:   https://anonhg.NetBSD.org/src/rev/1124317f353d
branches:  trunk
changeset: 837360:1124317f353d
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri Nov 30 16:26:59 2018 +0000

description:
Add support for polling com devices when no interrupt is available.

diffstat:

 sys/dev/pci/atppc_puc.c |   9 +++++++--
 sys/dev/pci/com_puc.c   |  35 +++++++++++++++++++++--------------
 sys/dev/pci/lpt_puc.c   |   9 +++++++--
 sys/dev/pci/puc.c       |   9 +++++----
 sys/dev/pci/pucvar.h    |   3 ++-
 5 files changed, 42 insertions(+), 23 deletions(-)

diffs (191 lines):

diff -r 018a6a8decc6 -r 1124317f353d sys/dev/pci/atppc_puc.c
--- a/sys/dev/pci/atppc_puc.c   Fri Nov 30 16:26:19 2018 +0000
+++ b/sys/dev/pci/atppc_puc.c   Fri Nov 30 16:26:59 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atppc_puc.c,v 1.14 2014/03/29 19:28:24 christos Exp $ */
+/* $NetBSD: atppc_puc.c,v 1.15 2018/11/30 16:26:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "opt_atppc.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atppc_puc.c,v 1.14 2014/03/29 19:28:24 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atppc_puc.c,v 1.15 2018/11/30 16:26:59 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -101,6 +101,11 @@
 
        sc->sc_dev_ok = ATPPC_NOATTACH;
 
+       if (aa->poll) {
+               aprint_error(": polling not supported\n");
+               return;
+       }
+
        printf(": AT Parallel Port\n");
 
        /* Attach */
diff -r 018a6a8decc6 -r 1124317f353d sys/dev/pci/com_puc.c
--- a/sys/dev/pci/com_puc.c     Fri Nov 30 16:26:19 2018 +0000
+++ b/sys/dev/pci/com_puc.c     Fri Nov 30 16:26:59 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: com_puc.c,v 1.24 2017/04/27 10:01:54 msaitoh Exp $     */
+/*     $NetBSD: com_puc.c,v 1.25 2018/11/30 16:26:59 jmcneill Exp $    */
 
 /*
  * Copyright (c) 1998 Christopher G. Demetriou.  All rights reserved.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: com_puc.c,v 1.24 2017/04/27 10:01:54 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com_puc.c,v 1.25 2018/11/30 16:26:59 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -91,7 +91,7 @@
        struct com_puc_softc *psc = device_private(self);
        struct com_softc *sc = &psc->sc_com;
        struct puc_attach_args *aa = aux;
-       const char *intrstr;
+       const char *intrstr = NULL;
        char intrbuf[PCI_INTRSTR_LEN];
        unsigned int iface;
 
@@ -106,16 +106,20 @@
        COM_INIT_REGS(sc->sc_regs, aa->t, aa->h, aa->a);
        sc->sc_frequency = aa->flags & PUC_COM_CLOCKMASK;
 
-       intrstr = pci_intr_string(aa->pc, aa->intrhandle, intrbuf,
-           sizeof(intrbuf));
-       psc->sc_ih = pci_intr_establish_xname(aa->pc, aa->intrhandle,
-           IPL_SERIAL, comintr, sc, device_xname(self));
-       if (psc->sc_ih == NULL) {
-               aprint_error("couldn't establish interrupt");
-               if (intrstr != NULL)
-                       aprint_error(" at %s", intrstr);
-               aprint_error("\n");
-               return;
+       if (!aa->poll) {
+               intrstr = pci_intr_string(aa->pc, aa->intrhandle, intrbuf,
+                   sizeof(intrbuf));
+               psc->sc_ih = pci_intr_establish_xname(aa->pc, aa->intrhandle,
+                   IPL_SERIAL, comintr, sc, device_xname(self));
+               if (psc->sc_ih == NULL) {
+                       aprint_error("couldn't establish interrupt");
+                       if (intrstr != NULL)
+                               aprint_error(" at %s", intrstr);
+                       aprint_error("\n");
+                       return;
+               }
+       } else {
+               sc->sc_hwflags |= COM_HW_POLL;
        }
 
 #if defined(amd64) || defined(i386)
@@ -129,7 +133,10 @@
        if (aa->h < 0x10000)
                aprint_normal("ioaddr 0x%04lx, ", aa->h);
 #endif
-       aprint_normal("interrupting at %s\n", intrstr);
+       if (!aa->poll)
+               aprint_normal("interrupting at %s\n", intrstr);
+       else
+               aprint_normal("polling\n");
 
        /* Enable Cyberserial 8X clock. */
        if (aa->flags & (PUC_COM_SIIG10x|PUC_COM_SIIG20x)) {
diff -r 018a6a8decc6 -r 1124317f353d sys/dev/pci/lpt_puc.c
--- a/sys/dev/pci/lpt_puc.c     Fri Nov 30 16:26:19 2018 +0000
+++ b/sys/dev/pci/lpt_puc.c     Fri Nov 30 16:26:59 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lpt_puc.c,v 1.18 2017/04/27 10:01:54 msaitoh Exp $     */
+/*     $NetBSD: lpt_puc.c,v 1.19 2018/11/30 16:26:59 jmcneill Exp $    */
 
 /*
  * Copyright (c) 1998 Christopher G. Demetriou.  All rights reserved.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lpt_puc.c,v 1.18 2017/04/27 10:01:54 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lpt_puc.c,v 1.19 2018/11/30 16:26:59 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -76,6 +76,11 @@
        sc->sc_iot = aa->t;
        sc->sc_ioh = aa->h;
 
+       if (aa->poll) {
+               aprint_error(": polling not supported\n");
+               return;
+       }
+
        aprint_naive(": Parallel port");
        aprint_normal(": ");
 
diff -r 018a6a8decc6 -r 1124317f353d sys/dev/pci/puc.c
--- a/sys/dev/pci/puc.c Fri Nov 30 16:26:19 2018 +0000
+++ b/sys/dev/pci/puc.c Fri Nov 30 16:26:59 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puc.c,v 1.39 2016/07/07 06:55:41 msaitoh Exp $ */
+/*     $NetBSD: puc.c,v 1.40 2018/11/30 16:26:59 jmcneill Exp $        */
 
 /*
  * Copyright (c) 1996, 1998, 1999
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puc.c,v 1.39 2016/07/07 06:55:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puc.c,v 1.40 2018/11/30 16:26:59 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -148,6 +148,7 @@
        pcireg_t subsys;
        int i, barindex;
        int locs[PUCCF_NLOCS];
+       bool poll = false;
 
        subsys = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG);
        sc->sc_desc = puc_find_description(PCI_VENDOR(pa->pa_id),
@@ -215,8 +216,7 @@
 
        /* Map interrupt. */
        if (pci_intr_map(pa, &intrhandle)) {
-               aprint_error_dev(self, "couldn't map interrupt\n");
-               return;
+               poll = true;
        }
        /*
         * XXX the sub-devices establish the interrupts, for the
@@ -288,6 +288,7 @@
                paa.pc = pa->pa_pc;
                paa.tag = pa->pa_tag;
                paa.intrhandle = intrhandle;
+               paa.poll = poll;
                paa.a = sc->sc_bar_mappings[barindex].a +
                    sc->sc_desc->ports[i].offset;
                paa.t = sc->sc_bar_mappings[barindex].t;
diff -r 018a6a8decc6 -r 1124317f353d sys/dev/pci/pucvar.h
--- a/sys/dev/pci/pucvar.h      Fri Nov 30 16:26:19 2018 +0000
+++ b/sys/dev/pci/pucvar.h      Fri Nov 30 16:26:59 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pucvar.h,v 1.11 2014/03/18 18:20:42 riastradh Exp $    */
+/*     $NetBSD: pucvar.h,v 1.12 2018/11/30 16:26:59 jmcneill Exp $     */
 
 /*
  * Copyright (c) 1998, 1999 Christopher G. Demetriou.  All rights reserved.
@@ -95,6 +95,7 @@
 
        pci_chipset_tag_t       pc;
        pci_intr_handle_t       intrhandle;
+       bool                    poll;
        pcitag_t                tag;
 
        bus_addr_t              a;



Home | Main Index | Thread Index | Old Index