Annotation of sys/arch/aviion/dev/if_le_syscon.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: if_le_syscon.c,v 1.2 2006/05/21 12:22:02 miod Exp $ */
2:
3: /*-
4: * Copyright (c) 1996 The NetBSD Foundation, Inc.
5: * All rights reserved.
6: *
7: * This code is derived from software contributed to The NetBSD Foundation
8: * by Adam Glass and Gordon W. Ross.
9: *
10: * Redistribution and use in source and binary forms, with or without
11: * modification, are permitted provided that the following conditions
12: * are met:
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. All advertising materials mentioning features or use of this software
19: * must display the following acknowledgement:
20: * This product includes software developed by the NetBSD
21: * Foundation, Inc. and its contributors.
22: * 4. Neither the name of The NetBSD Foundation nor the names of its
23: * contributors may be used to endorse or promote products derived
24: * from this software without specific prior written permission.
25: *
26: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
30: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36: * POSSIBILITY OF SUCH DAMAGE.
37: */
38:
39: #include <sys/param.h>
40: #include <sys/systm.h>
41: #include <sys/mbuf.h>
42: #include <sys/syslog.h>
43: #include <sys/socket.h>
44: #include <sys/device.h>
45:
46: #include <net/if.h>
47:
48: #ifdef INET
49: #include <netinet/in.h>
50: #include <netinet/if_ether.h>
51: #endif
52:
53: #include <net/if_media.h>
54:
55: #include <machine/autoconf.h>
56: #include <machine/cpu.h>
57:
58: #include <aviion/dev/sysconreg.h>
59:
60: #include <dev/ic/am7990reg.h>
61: #include <dev/ic/am7990var.h>
62:
63: /*
64: * LANCE registers. Although these are 16 bit registers, on the AV400
65: * design, they need to be accessed as 32 bit registers. Bus magic...
66: * The real stuff is in dev/ic/am7990reg.h
67: */
68: struct av_lereg {
69: volatile u_int32_t ler1_rdp; /* data port */
70: volatile u_int32_t ler1_rap; /* register select port */
71: };
72:
73: /*
74: * Ethernet software status per interface.
75: * The real stuff is in dev/ic/am7990var.h
76: */
77: struct le_softc {
78: struct am7990_softc sc_am7990; /* glue to MI code */
79:
80: struct av_lereg *sc_r1; /* LANCE registers */
81: struct intrhand sc_ih;
82: };
83:
84: int le_syscon_match(struct device *, void *, void *);
85: void le_syscon_attach(struct device *, struct device *, void *);
86:
87: struct cfattach le_syscon_ca = {
88: sizeof(struct le_softc), le_syscon_match, le_syscon_attach
89: };
90:
91: void le_syscon_wrcsr(struct am7990_softc *, u_int16_t, u_int16_t);
92: u_int16_t le_syscon_rdcsr(struct am7990_softc *, u_int16_t);
93:
94: void
95: le_syscon_wrcsr(sc, port, val)
96: struct am7990_softc *sc;
97: u_int16_t port, val;
98: {
99: struct av_lereg *ler1 = ((struct le_softc *)sc)->sc_r1;
100:
101: ler1->ler1_rap = port;
102: ler1->ler1_rdp = val;
103: }
104:
105: u_int16_t
106: le_syscon_rdcsr(sc, port)
107: struct am7990_softc *sc;
108: u_int16_t port;
109: {
110: struct av_lereg *ler1 = ((struct le_softc *)sc)->sc_r1;
111: u_int16_t val;
112:
113: ler1->ler1_rap = port;
114: val = ler1->ler1_rdp;
115: return (val);
116: }
117:
118: int
119: le_syscon_match(parent, cf, aux)
120: struct device *parent;
121: void *cf, *aux;
122: {
123: return (1);
124: }
125:
126: void
127: le_syscon_attach(parent, self, aux)
128: struct device *parent, *self;
129: void *aux;
130: {
131: struct le_softc *lesc = (struct le_softc *)self;
132: struct am7990_softc *sc = &lesc->sc_am7990;
133: struct confargs *ca = aux;
134: extern void *etherbuf;
135: extern size_t etherlen;
136:
137: if (etherbuf == NULL) {
138: printf(": no available memory, kernel is too large\n");
139: return;
140: }
141:
142: lesc->sc_r1 = (struct av_lereg *)ca->ca_paddr;
143:
144: sc->sc_mem = (void *)etherbuf;
145: etherbuf = NULL;
146: sc->sc_conf3 = LE_C3_BSWP;
147: sc->sc_addr = (u_long)sc->sc_mem & 0x00ffffff;
148: sc->sc_memsize = etherlen;
149:
150: myetheraddr(sc->sc_arpcom.ac_enaddr);
151:
152: sc->sc_copytodesc = am7990_copytobuf_contig;
153: sc->sc_copyfromdesc = am7990_copyfrombuf_contig;
154: sc->sc_copytobuf = am7990_copytobuf_contig;
155: sc->sc_copyfrombuf = am7990_copyfrombuf_contig;
156: sc->sc_zerobuf = am7990_zerobuf_contig;
157:
158: sc->sc_rdcsr = le_syscon_rdcsr;
159: sc->sc_wrcsr = le_syscon_wrcsr;
160: sc->sc_hwreset = NULL;
161: sc->sc_hwinit = NULL;
162:
163: am7990_config(sc);
164:
165: lesc->sc_ih.ih_fn = am7990_intr;
166: lesc->sc_ih.ih_arg = sc;
167: lesc->sc_ih.ih_wantframe = 0;
168: lesc->sc_ih.ih_ipl = ca->ca_ipl;
169:
170: sysconintr_establish(SYSCV_LE, &lesc->sc_ih, self->dv_xname);
171: }
CVSweb