Module Name:    src
Committed By:   jmcneill
Date:           Fri Nov 30 16:27:00 UTC 2018

Modified Files:
        src/sys/dev/pci: atppc_puc.c com_puc.c lpt_puc.c puc.c pucvar.h

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


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/atppc_puc.c
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/com_puc.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/pci/lpt_puc.c
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/pci/puc.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/pucvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/atppc_puc.c
diff -u src/sys/dev/pci/atppc_puc.c:1.14 src/sys/dev/pci/atppc_puc.c:1.15
--- src/sys/dev/pci/atppc_puc.c:1.14	Sat Mar 29 19:28:24 2014
+++ src/sys/dev/pci/atppc_puc.c	Fri Nov 30 16:26:59 2018
@@ -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 @@ atppc_puc_attach(device_t parent, device
 
 	sc->sc_dev_ok = ATPPC_NOATTACH;
 
+	if (aa->poll) {
+		aprint_error(": polling not supported\n");
+		return;
+	}
+
 	printf(": AT Parallel Port\n");
 
 	/* Attach */

Index: src/sys/dev/pci/com_puc.c
diff -u src/sys/dev/pci/com_puc.c:1.24 src/sys/dev/pci/com_puc.c:1.25
--- src/sys/dev/pci/com_puc.c:1.24	Thu Apr 27 10:01:54 2017
+++ src/sys/dev/pci/com_puc.c	Fri Nov 30 16:26:59 2018
@@ -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 @@ com_puc_attach(device_t parent, device_t
 	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_puc_attach(device_t parent, device_t
 	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 @@ com_puc_attach(device_t parent, device_t
 	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)) {

Index: src/sys/dev/pci/lpt_puc.c
diff -u src/sys/dev/pci/lpt_puc.c:1.18 src/sys/dev/pci/lpt_puc.c:1.19
--- src/sys/dev/pci/lpt_puc.c:1.18	Thu Apr 27 10:01:54 2017
+++ src/sys/dev/pci/lpt_puc.c	Fri Nov 30 16:26:59 2018
@@ -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 @@ lpt_puc_attach(device_t parent, device_t
 	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(": ");
 

Index: src/sys/dev/pci/puc.c
diff -u src/sys/dev/pci/puc.c:1.39 src/sys/dev/pci/puc.c:1.40
--- src/sys/dev/pci/puc.c:1.39	Thu Jul  7 06:55:41 2016
+++ src/sys/dev/pci/puc.c	Fri Nov 30 16:26:59 2018
@@ -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 @@ puc_attach(device_t parent, device_t sel
 	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 @@ puc_attach(device_t parent, device_t sel
 
 	/* 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 @@ puc_attach(device_t parent, device_t sel
 		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;

Index: src/sys/dev/pci/pucvar.h
diff -u src/sys/dev/pci/pucvar.h:1.11 src/sys/dev/pci/pucvar.h:1.12
--- src/sys/dev/pci/pucvar.h:1.11	Tue Mar 18 18:20:42 2014
+++ src/sys/dev/pci/pucvar.h	Fri Nov 30 16:26:59 2018
@@ -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 @@ struct puc_attach_args {
 
 	pci_chipset_tag_t	pc;
 	pci_intr_handle_t	intrhandle;
+	bool			poll;
 	pcitag_t		tag;
 
 	bus_addr_t		a;

Reply via email to