xref: /openbsd-src/sys/dev/tc/if_le_tc.c (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 /*	$OpenBSD: if_le_tc.c,v 1.4 1998/09/16 22:41:22 jason Exp $	*/
2 /*	$NetBSD: if_le_tc.c,v 1.2 1996/05/07 02:24:57 thorpej Exp $	*/
3 
4 /*
5  * Copyright (c) 1996 Carnegie-Mellon University.
6  * All rights reserved.
7  *
8  * Author: Chris G. Demetriou
9  *
10  * Permission to use, copy, modify and distribute this software and
11  * its documentation is hereby granted, provided that both the copyright
12  * notice and this permission notice appear in all copies of the
13  * software, derivative works or modified versions, and any portions
14  * thereof, and that both notices appear in supporting documentation.
15  *
16  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19  *
20  * Carnegie Mellon requests users of this software to return to
21  *
22  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
23  *  School of Computer Science
24  *  Carnegie Mellon University
25  *  Pittsburgh PA 15213-3890
26  *
27  * any improvements or extensions that they make and grant Carnegie the
28  * rights to redistribute these changes.
29  */
30 
31 /*
32  * LANCE on TurboChannel.
33  */
34 
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/mbuf.h>
38 #include <sys/syslog.h>
39 #include <sys/socket.h>
40 #include <sys/device.h>
41 
42 #include <net/if.h>
43 #include <net/if_media.h>
44 
45 #ifdef INET
46 #include <netinet/in.h>
47 #include <netinet/if_ether.h>
48 #endif
49 
50 #include <dev/ic/am7990reg.h>
51 #include <dev/ic/am7990var.h>
52 
53 #include <dev/tc/if_levar.h>
54 #include <dev/tc/tcvar.h>
55 
56 int	le_tc_match __P((struct device *, void *, void *));
57 void	le_tc_attach __P((struct device *, struct device *, void *));
58 
59 struct cfattach le_tc_ca = {
60 	sizeof(struct le_softc), le_tc_match, le_tc_attach
61 };
62 
63 #define	LE_OFFSET_RAM		0x0
64 #define	LE_OFFSET_LANCE		0x100000
65 #define	LE_OFFSET_ROM		0x1c0000
66 
67 int
68 le_tc_match(parent, match, aux)
69 	struct device *parent;
70 	void *match, *aux;
71 {
72 	struct tc_attach_args *d = aux;
73 
74 	if (strncmp("PMAD-AA ", d->ta_modname, TC_ROM_LLEN) &&
75 	    strncmp("PMAD-BA ", d->ta_modname, TC_ROM_LLEN))
76 		return (0);
77 
78 	return (1);
79 }
80 
81 void
82 le_tc_attach(parent, self, aux)
83 	struct device *parent, *self;
84 	void *aux;
85 {
86 	register struct le_softc *lesc = (void *)self;
87 	register struct am7990_softc *sc = &lesc->sc_am7990;
88 	struct tc_attach_args *d = aux;
89 
90 	/*
91 	 * It's on the turbochannel proper, or a kn02
92 	 * baseboard implementation of a TC option card.
93 	 */
94 	lesc->sc_r1 = (struct lereg1 *)(d->ta_addr + LE_OFFSET_LANCE);
95 	sc->sc_mem = (void *)(d->ta_addr + LE_OFFSET_RAM);
96 
97 	sc->sc_copytodesc = am7990_copytobuf_contig;
98 	sc->sc_copyfromdesc = am7990_copyfrombuf_contig;
99 	sc->sc_copytobuf = am7990_copytobuf_contig;
100 	sc->sc_copyfrombuf = am7990_copyfrombuf_contig;
101 	sc->sc_zerobuf = am7990_zerobuf_contig;
102 
103 	/*
104 	 * TC lance boards have onboard SRAM buffers.  DMA
105 	 * between the onbard RAM and main memory is not possible,
106 	 * so  DMA setup is not required.
107 	 */
108 
109 	dec_le_common_attach(sc, (u_char *)(d->ta_addr + LE_OFFSET_ROM + 2));
110 
111 	tc_intr_establish(parent, d->ta_cookie, TC_IPL_NET, am7990_intr, sc);
112 }
113