1 /**	$MirOS: src/sys/dev/puc/lpt_puc.c,v 1.2 2005/03/06 21:27:55 tg Exp $	*/
2 /*	$OpenBSD: lpt_puc.c,v 1.3 2002/03/14 01:27:01 millert Exp $	*/
3 /*	$NetBSD: lpt_puc.c,v 1.1 1998/06/26 18:52:41 cgd Exp $	*/
4 
5 /*
6  * Copyright (c) 1998 Christopher G. Demetriou.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by Christopher G. Demetriou
19  *	for the NetBSD Project.
20  * 4. The name of the author may not be used to endorse or promote products
21  *    derived from this software without specific prior written permission
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 /*
36  * Machine-independent parallel port ('lpt') driver attachment to "PCI
37  * Universal Communications" controller driver.
38  *
39  * Author: Christopher G. Demetriou, May 17, 1998.
40  */
41 
42 #include <sys/types.h>
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <sys/device.h>
46 
47 #include <machine/bus.h>
48 
49 #if defined(INET) && defined(PLIP)
50 #include <sys/socket.h>
51 #include <net/if.h>
52 #ifdef	__NetBSD__
53 #include <net/if_ether.h>
54 #else
55 #include <netinet/in.h>
56 #include <netinet/if_ether.h>
57 #endif
58 #endif
59 
60 #include <dev/pci/pcivar.h>
61 #include <dev/pci/pucvar.h>
62 #include <dev/ic/lptreg.h>
63 #include <dev/ic/lptvar.h>
64 
65 int	lpt_puc_probe(struct device *, void *, void *);
66 void	lpt_puc_attach(struct device *, struct device *, void *);
67 
68 struct cfattach lpt_puc_ca = {
69 	sizeof(struct lpt_softc), lpt_puc_probe, lpt_puc_attach
70 };
71 
72 int
lpt_puc_probe(parent,match,aux)73 lpt_puc_probe(parent, match, aux)
74 	struct device *parent;
75 	void *match, *aux;
76 {
77 	struct puc_attach_args *aa = aux;
78 
79 	/*
80 	 * Locators already matched, just check the type.
81 	 */
82 	if (aa->type != PUC_PORT_TYPE_LPT)
83 		return (0);
84 
85 	return (1);
86 }
87 
88 void
lpt_puc_attach(parent,self,aux)89 lpt_puc_attach(parent, self, aux)
90 	struct device *parent, *self;
91 	void *aux;
92 {
93 	struct lpt_softc *sc = (void *)self;
94 	struct puc_attach_args *aa = aux;
95 	const char *intrstr;
96 
97 	sc->sc_iot = aa->t;
98 	sc->sc_ioh = aa->h;
99 
100 	intrstr = pci_intr_string(aa->pc, aa->intrhandle);
101 	sc->sc_ih = pci_intr_establish(aa->pc, aa->intrhandle, IPL_TTY,
102 	    lptintr, sc, sc->sc_dev.dv_xname);
103 	if (sc->sc_ih == NULL) {
104 		printf(": couldn't establish interrupt");
105 		if (intrstr != NULL)
106 			printf(" at %s", intrstr);
107 		printf("\n");
108 		return;
109 	}
110 	printf(": interrupting at %s", intrstr);
111 
112 	sc->sc_state = 0;
113 
114 	lpt_attach_common(sc);
115 }
116