xref: /netbsd-src/sys/dev/tc/if_le_tc.c (revision 3b01aba77a7a698587faaae455bbfe740923c1f5)
1 /*	$NetBSD: if_le_tc.c,v 1.11 2000/03/30 12:45:43 augustss 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 #include "opt_inet.h"
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_ether.h>
44 #include <net/if_media.h>
45 
46 #ifdef INET
47 #include <netinet/in.h>
48 #include <netinet/if_inarp.h>
49 #endif
50 
51 #include <dev/ic/lancereg.h>
52 #include <dev/ic/lancevar.h>
53 #include <dev/ic/am7990reg.h>
54 #include <dev/ic/am7990var.h>
55 
56 #include <dev/tc/if_levar.h>
57 #include <dev/tc/tcvar.h>
58 
59 int	le_tc_match __P((struct device *, struct cfdata *, void *));
60 void	le_tc_attach __P((struct device *, struct device *, void *));
61 
62 struct cfattach le_tc_ca = {
63 	sizeof(struct le_softc), le_tc_match, le_tc_attach
64 };
65 
66 #define	LE_OFFSET_RAM		0x0
67 #define	LE_OFFSET_LANCE		0x100000
68 #define	LE_OFFSET_ROM		0x1c0000
69 
70 int
71 le_tc_match(parent, match, aux)
72 	struct device *parent;
73 	struct cfdata *match;
74 	void *aux;
75 {
76 	struct tc_attach_args *d = aux;
77 
78 	if (strncmp("PMAD-AA ", d->ta_modname, TC_ROM_LLEN) != 0)
79 		return (0);
80 
81 	return (1);
82 }
83 
84 void
85 le_tc_attach(parent, self, aux)
86 	struct device *parent, *self;
87 	void *aux;
88 {
89 	struct le_softc *lesc = (void *)self;
90 	struct lance_softc *sc = &lesc->sc_am7990.lsc;
91 	struct tc_attach_args *d = aux;
92 
93 	/*
94 	 * It's on the turbochannel proper, or a kn02
95 	 * baseboard implementation of a TC option card.
96 	 */
97 	lesc->sc_r1 = (struct lereg1 *)(d->ta_addr + LE_OFFSET_LANCE);
98 	sc->sc_mem = (void *)(d->ta_addr + LE_OFFSET_RAM);
99 
100 	sc->sc_copytodesc = lance_copytobuf_contig;
101 	sc->sc_copyfromdesc = lance_copyfrombuf_contig;
102 	sc->sc_copytobuf = lance_copytobuf_contig;
103 	sc->sc_copyfrombuf = lance_copyfrombuf_contig;
104 	sc->sc_zerobuf = lance_zerobuf_contig;
105 
106 	/*
107 	 * TC lance boards have onboard SRAM buffers.  DMA
108 	 * between the onbard RAM and main memory is not possible,
109 	 * so  DMA setup is not required.
110 	 */
111 
112 	dec_le_common_attach(&lesc->sc_am7990,
113 			     (u_char *)(d->ta_addr + LE_OFFSET_ROM + 2));
114 
115 	tc_intr_establish(parent, d->ta_cookie, TC_IPL_NET, am7990_intr, sc);
116 }
117