xref: /openbsd-src/sys/dev/tc/if_le_tc.c (revision 50b7afb2c2c0993b0894d4e34bf857cb13ed9c80)
1 /*	$OpenBSD: if_le_tc.c,v 1.11 2013/09/24 20:11:05 miod Exp $	*/
2 /*	$NetBSD: if_le_tc.c,v 1.12 2001/11/13 06:26:10 lukem 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/lancereg.h>
51 #include <dev/ic/lancevar.h>
52 #include <dev/ic/am7990reg.h>
53 #include <dev/ic/am7990var.h>
54 
55 #include <dev/tc/if_levar.h>
56 #include <dev/tc/tcvar.h>
57 
58 int	le_tc_match(struct device *, void *, void *);
59 void	le_tc_attach(struct device *, struct device *, void *);
60 
61 struct cfattach le_tc_ca = {
62 	sizeof(struct le_softc), le_tc_match, le_tc_attach
63 };
64 
65 #define	LE_OFFSET_RAM		0x0
66 #define	LE_OFFSET_LANCE		0x100000
67 #define	LE_OFFSET_ROM		0x1c0000
68 
69 int
70 le_tc_match(struct device *parent, void *match, void *aux)
71 {
72 	struct tc_attach_args *d = aux;
73 
74 	if (strncmp("PMAD-AA ", d->ta_modname, TC_ROM_LLEN) != 0)
75 		return (0);
76 
77 	return (1);
78 }
79 
80 void
81 le_tc_attach(struct device *parent, struct device *self, void *aux)
82 {
83 	struct le_softc *lesc = (void *)self;
84 	struct lance_softc *sc = &lesc->sc_am7990.lsc;
85 	struct tc_attach_args *d = aux;
86 
87 	/*
88 	 * It's on the turbochannel proper, or a kn02
89 	 * baseboard implementation of a TC option card.
90 	 */
91 	lesc->sc_r1 = (struct lereg1 *)
92            TC_DENSE_TO_SPARSE(TC_PHYS_TO_UNCACHED(d->ta_addr + LE_OFFSET_LANCE));
93 	sc->sc_mem = (void *)(d->ta_addr + LE_OFFSET_RAM);
94 
95 	sc->sc_copytodesc = lance_copytobuf_contig;
96 	sc->sc_copyfromdesc = lance_copyfrombuf_contig;
97 	sc->sc_copytobuf = lance_copytobuf_contig;
98 	sc->sc_copyfrombuf = lance_copyfrombuf_contig;
99 	sc->sc_zerobuf = lance_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(&lesc->sc_am7990,
108 	    (u_char *)(d->ta_addr + LE_OFFSET_ROM + 2));
109 
110 	tc_intr_establish(parent, d->ta_cookie, IPL_NET, am7990_intr, sc,
111 	    self->dv_xname);
112 }
113