1 /* $NetBSD: if_le_dec.c,v 1.18 2007/10/19 11:59:40 ad Exp $ */
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Ralph Campbell and Rick Macklem.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * @(#)if_le.c 8.2 (Berkeley) 11/16/93
38 * Copyright (c) 1997 Jonathan Stone. All rights reserved.
39 * Copyright (c) 1995 Charles M. Hannum. All rights reserved.
41 * This code is derived from software contributed to Berkeley by
42 * Ralph Campbell and Rick Macklem.
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * This product includes software developed by the University of
55 * California, Berkeley and its contributors.
56 * 4. Neither the name of the University nor the names of its contributors
57 * may be used to endorse or promote products derived from this software
58 * without specific prior written permission.
60 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * @(#)if_le.c 8.2 (Berkeley) 11/16/93
75 #include <sys/cdefs.h>
76 __KERNEL_RCSID(0, "$NetBSD: if_le_dec.c,v 1.18 2007/10/19 11:59:40 ad Exp $");
81 #include <sys/param.h>
82 #include <sys/systm.h>
84 #include <sys/syslog.h>
85 #include <sys/socket.h>
86 #include <sys/device.h>
89 #include <net/if_ether.h>
90 #include <net/if_media.h>
93 #include <netinet/in.h>
94 #include <netinet/if_inarp.h>
97 #include <dev/ic/lancereg.h>
98 #include <dev/ic/lancevar.h>
99 #include <dev/ic/am7990reg.h>
100 #include <dev/ic/am7990var.h>
102 #include <dev/tc/if_levar.h>
103 #include <dev/tc/tcvar.h>
107 /* access LANCE registers */
108 void le_dec_writereg(volatile uint16_t *regptr
, uint16_t val
);
109 #define LERDWR(cntl, src, dst) { (dst) = (src); tc_mb(); }
110 #define LEWREG(src, dst) le_dec_writereg(&(dst), (src))
112 #if defined(_KERNEL_OPT)
120 #define integrate static inline
124 hide
void le_dec_wrcsr(struct lance_softc
*, uint16_t, uint16_t);
125 hide
uint16_t le_dec_rdcsr(struct lance_softc
*, uint16_t);
128 dec_le_common_attach(struct am7990_softc
*sc
, uint8_t *eap
)
132 sc
->lsc
.sc_rdcsr
= le_dec_rdcsr
;
133 sc
->lsc
.sc_wrcsr
= le_dec_wrcsr
;
134 sc
->lsc
.sc_hwinit
= NULL
;
136 sc
->lsc
.sc_conf3
= 0;
138 sc
->lsc
.sc_memsize
= 65536;
141 * Get the ethernet address out of rom
143 for (i
= 0; i
< sizeof(sc
->lsc
.sc_enaddr
); i
++) {
144 sc
->lsc
.sc_enaddr
[i
] = *eap
;
152 le_dec_wrcsr(struct lance_softc
*sc
, uint16_t port
, uint16_t val
)
154 struct lereg1
*ler1
= ((struct le_softc
*)sc
)->sc_r1
;
156 LEWREG(port
, ler1
->ler1_rap
);
157 LERDWR(port
, val
, ler1
->ler1_rdp
);
161 le_dec_rdcsr(struct lance_softc
*sc
, uint16_t port
)
163 struct lereg1
*ler1
= ((struct le_softc
*)sc
)->sc_r1
;
166 LEWREG(port
, ler1
->ler1_rap
);
167 LERDWR(0, ler1
->ler1_rdp
, val
);
172 * Write a lance register port, reading it back to ensure success. This seems
173 * to be necessary during initialization, since the chip appears to be a bit
177 le_dec_writereg(volatile uint16_t *regptr
, uint16_t val
)
181 while (*regptr
!= val
) {
185 printf("le: Reg did not settle (to x%x): x%x\n", val
,
194 * Routines for accessing the transmit and receive buffers are provided
195 * by am7990.c, because of the LE_NEED_BUF_* macros defined above.
196 * Unfortunately, CPU addressing of these buffers is done in one of
198 * - contiguous (for the 3max and turbochannel option card)
199 * - gap2, which means shorts (2 bytes) interspersed with short (2 byte)
200 * spaces (for the pmax, vax 3400, and ioasic LANCE descriptors)
201 * - gap16, which means 16bytes interspersed with 16byte spaces
202 * for buffers which must begin on a 32byte boundary (for 3min, maxine,
204 * The buffer offset is the logical byte offset, assuming contiguous storage.