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